Skip to content

Commit 7e9c0a1

Browse files
authored
Updates applications w.r.t. liv v2.0.4 (#31)
Co-authored-by: bjornvolcker <[email protected]>
1 parent 6fb5f18 commit 7e9c0a1

File tree

2 files changed

+17
-62
lines changed

2 files changed

+17
-62
lines changed

apps/signer/gst-plugin/gstsigning.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,15 @@ setup_signing(GstSigning *signing, GstCaps *caps)
371371
GST_DEBUG_OBJECT(signing, "failed to generate pem file");
372372
goto generate_private_key_failed;
373373
}
374-
if (signed_video_set_private_key_new(priv->signed_video, private_key, private_key_size) != SV_OK) {
374+
if (signed_video_set_private_key(priv->signed_video, private_key, private_key_size) != SV_OK) {
375375
GST_DEBUG_OBJECT(signing, "failed to set private key content");
376376
goto set_private_key_failed;
377377
}
378378

379379
// Send properties information to video library.
380380
if (signed_video_set_product_info(priv->signed_video, "N/A", signed_video_get_version(), "N/A",
381381
"Signed Video Framework",
382-
"github.com/axteams-software/signed-video-framework") != SV_OK) {
382+
"github.com/AxisCommunications/signed-video-framework") != SV_OK) {
383383
GST_ERROR_OBJECT(signing, "failed to set properties");
384384
goto product_info_failed;
385385
}

apps/validator/main.c

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#define RESULTS_FILE "validation_results.txt"
4444
// Increment VALIDATOR_VERSION when a change is affecting the code.
45-
#define VALIDATOR_VERSION "v2.0.0" // Requires at least signed-video-framework v2.0.1
45+
#define VALIDATOR_VERSION "v2.0.1" // Requires at least signed-video-framework v2.0.4
4646

4747
typedef struct {
4848
GMainLoop *loop;
@@ -51,7 +51,7 @@ typedef struct {
5151

5252
signed_video_t *sv;
5353
signed_video_authenticity_t *auth_report;
54-
signed_video_product_info_t *product_info;
54+
signed_video_product_info_t product_info;
5555
char *version_on_signing_side;
5656
char *this_version;
5757
bool no_container;
@@ -91,53 +91,19 @@ static gsize ongoing_obu_size = 0;
9191
const bool parse_av1_manually = true;
9292
#define METADATA_TYPE_USER_PRIVATE 25
9393

94-
/* Helper function that copies a string and (re)allocates memory if necessary. */
95-
static gint
96-
reallocate_memory_and_copy_string(gchar **dst_str, const gchar *src_str)
97-
{
98-
if (!dst_str) return 0;
99-
// If the |src_str| is a NULL pointer make sure to copy an empty string.
100-
if (!src_str) src_str = "";
101-
102-
gsize dst_size = *dst_str ? strlen(*dst_str) + 1 : 0;
103-
const gsize src_size = strlen(src_str) + 1;
104-
gint success = 0;
105-
if (src_size != dst_size) {
106-
gchar *new_dst_str = realloc(*dst_str, src_size);
107-
if (!new_dst_str) goto done;
108-
109-
*dst_str = new_dst_str;
110-
}
111-
strcpy(*dst_str, src_str);
112-
success = 1;
113-
114-
done:
115-
if (!success) {
116-
free(*dst_str);
117-
*dst_str = NULL;
118-
}
119-
120-
return success;
121-
}
122-
12394
/* Helper function to copy signed_video_product_info_t. */
12495
static gint
12596
copy_product_info(signed_video_product_info_t *dst, const signed_video_product_info_t *src)
12697
{
127-
if (!src) return 0;
128-
129-
gint success = 0;
130-
if (!reallocate_memory_and_copy_string(&dst->hardware_id, src->hardware_id)) goto done;
131-
if (!reallocate_memory_and_copy_string(&dst->firmware_version, src->firmware_version)) goto done;
132-
if (!reallocate_memory_and_copy_string(&dst->serial_number, src->serial_number)) goto done;
133-
if (!reallocate_memory_and_copy_string(&dst->manufacturer, src->manufacturer)) goto done;
134-
if (!reallocate_memory_and_copy_string(&dst->address, src->address)) goto done;
135-
136-
success = 1;
98+
if (!src || !dst) return 0;
13799

138-
done:
100+
strcpy(dst->hardware_id, src->hardware_id);
101+
strcpy(dst->firmware_version, src->firmware_version);
102+
strcpy(dst->serial_number, src->serial_number);
103+
strcpy(dst->manufacturer, src->manufacturer);
104+
strcpy(dst->address, src->address);
139105

140-
return success;
106+
return 1;
141107
}
142108

143109
static void
@@ -415,13 +381,7 @@ on_new_sample_from_sink(GstElement *elt, ValidationData *data)
415381
}
416382
strcat(result, data->auth_report->latest_validation.validation_str);
417383
post_validation_result_message(sink, bus, result);
418-
// Allocate memory for |product_info| the first time it will be copied from the authenticity
419-
// report.
420-
if (!data->product_info) {
421-
data->product_info =
422-
(signed_video_product_info_t *)g_malloc0(sizeof(signed_video_product_info_t));
423-
}
424-
if (!copy_product_info(data->product_info, &(data->auth_report->product_info))) {
384+
if (!copy_product_info(&(data->product_info), &(data->auth_report->product_info))) {
425385
g_warning("product info could not be transfered from authenticity report");
426386
}
427387
// Allocate memory and copy version strings.
@@ -538,15 +498,11 @@ on_source_message(GstBus __attribute__((unused)) *bus, GstMessage *message, Vali
538498
fprintf(f, "-----------------------------\n");
539499
fprintf(f, "\nProduct Info\n");
540500
fprintf(f, "-----------------------------\n");
541-
if (data->product_info) {
542-
fprintf(f, "Hardware ID: %s\n", data->product_info->hardware_id);
543-
fprintf(f, "Serial Number: %s\n", data->product_info->serial_number);
544-
fprintf(f, "Firmware version: %s\n", data->product_info->firmware_version);
545-
fprintf(f, "Manufacturer: %s\n", data->product_info->manufacturer);
546-
fprintf(f, "Address: %s\n", data->product_info->address);
547-
} else {
548-
fprintf(f, "NOT PRESENT!\n");
549-
}
501+
fprintf(f, "Hardware ID: %s\n", data->product_info.hardware_id);
502+
fprintf(f, "Serial Number: %s\n", data->product_info.serial_number);
503+
fprintf(f, "Firmware version: %s\n", data->product_info.firmware_version);
504+
fprintf(f, "Manufacturer: %s\n", data->product_info.manufacturer);
505+
fprintf(f, "Address: %s\n", data->product_info.address);
550506
fprintf(f, "-----------------------------\n");
551507
fprintf(f, "\nSigned Video timestamps\n");
552508
fprintf(f, "-----------------------------\n");
@@ -758,7 +714,6 @@ main(int argc, char **argv)
758714
if (data->source) gst_object_unref(data->source);
759715
g_main_loop_unref(data->loop);
760716
signed_video_free(data->sv);
761-
g_free(data->product_info);
762717
g_free(data->this_version);
763718
g_free(data->version_on_signing_side);
764719
g_free(data);

0 commit comments

Comments
 (0)