Skip to content

Commit d3de8a0

Browse files
authored
Fixes forward scrubbing (#468)
The root cause was among the validation flags, where is_first_sei was not updated correctly.
1 parent b9c8ffe commit d3de8a0

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

lib/src/sv_auth.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ validate_authenticity(signed_video_t *self, bu_list_item_t *sei)
807807

808808
// Determine if this GOP is valid, but has missing information. This happens if we have detected
809809
// missed BUs or if the GOP is incomplete.
810-
if (valid == SV_AUTH_RESULT_OK && (num_missed > 0)) { // && verify_success)) {
810+
if (valid == SV_AUTH_RESULT_OK && (num_missed > 0)) {
811811
valid = SV_AUTH_RESULT_OK_WITH_MISSING_INFO;
812812
DEBUG_LOG("Successful validation, but detected missing Bitstream Units");
813813
}
@@ -1188,7 +1188,7 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
11881188
// If this is the first arrived SEI, but could still not validate the authenticity, signal to
11891189
// the user that the Signed Video feature has been detected.
11901190
svrc_t status = SV_OK;
1191-
if (validation_flags->is_first_sei) {
1191+
if (validation_flags->is_first_sei && bu->is_sv_sei) {
11921192
latest->authenticity = SV_AUTH_RESULT_SIGNATURE_PRESENT;
11931193
latest->public_key_has_changed = false;
11941194
// Check if the data is golden. If it is, update the validation status accordingly.
@@ -1201,7 +1201,7 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
12011201
latest->number_of_pending_picture_nalus = bu_list_num_pending_items(bu_list);
12021202
status = bu_list_update_status(bu_list, true);
12031203
validation_flags->has_auth_result = true;
1204-
validation_flags->lost_start_of_gop = false;
1204+
validation_flags->is_first_sei = false;
12051205
}
12061206
return status;
12071207
}
@@ -1225,6 +1225,8 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
12251225
latest->number_of_received_picture_nalus = 0;
12261226
latest->number_of_pending_picture_nalus = -1;
12271227
latest->public_key_has_changed = public_key_has_changed;
1228+
validation_flags->num_invalid = 0;
1229+
validation_flags->lost_start_of_gop = false;
12281230
// Reset |in_validation|.
12291231
update_sei_in_validation(self, true, NULL, NULL);
12301232
}
@@ -1248,6 +1250,7 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
12481250
// The flag |is_first_validation| is used to ignore the first validation if we start the
12491251
// validation in the middle of a stream. Now it is time to reset it.
12501252
validation_flags->is_first_validation = !validation_flags->signing_present;
1253+
validation_flags->is_first_sei &= !bu->is_sv_sei;
12511254

12521255
if (validation_flags->reset_first_validation) {
12531256
validation_flags->is_first_validation = true;
@@ -1491,7 +1494,7 @@ add_bitstream_unit(signed_video_t *self, const uint8_t *bu_data, size_t bu_data_
14911494
SV_THROW_IF(!self->legacy_sv, SV_MEMORY);
14921495
sv_accumulated_validation_init(self->accumulated_validation);
14931496
}
1494-
if (nalus_pending_registration && self->validation_flags.hash_algo_known) {
1497+
if (nalus_pending_registration && validation_flags->hash_algo_known) {
14951498
SV_THROW(reregister_bu(self));
14961499
}
14971500
SV_THROW(maybe_validate_gop(self, &bu));

lib/src/sv_common.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ update_validation_flags(validation_flags_t *validation_flags, bu_info_t *bu)
664664
{
665665
if (!validation_flags || !bu) return;
666666

667-
validation_flags->is_first_sei = !validation_flags->signing_present && bu->is_sv_sei;
668667
// As soon as we receive a SEI, Signed Video is present.
669668
validation_flags->signing_present |= bu->is_sv_sei;
670669
}

lib/src/sv_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ typedef struct {
212212
bool sei_in_sync; // The SEIs are correctly associated with a (partial) GOP
213213
int num_lost_seis; // Indicates how many SEIs has been lost since last the session got
214214
// the latest SEI. Note that this value can become negative if SEIs have changed order.
215+
int num_invalid; // Tracks invalid GOPs across multiple GOP validation.
215216
bool lost_start_of_gop; // Tracks if an I-frame has been lost, which needs to be
216217
// handled as a special case if it happens for the first validation.
217218
} validation_flags_t;

tests/check/check_signed_video_auth.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,10 +1220,6 @@ mimic_au_fast_forward_and_get_list(signed_video_t *sv, struct sv_setting setting
12201220

12211221
START_TEST(fast_forward_stream_with_reset)
12221222
{
1223-
// TODO: Remove when scrubbing forward works. Currently, the first SEI after a "fast
1224-
// forward" operation is validated as 'invalid' when it should not be validated at all.
1225-
// Disabling the test until it has been solved.
1226-
return;
12271223
// Create a session.
12281224
signed_video_t *sv = get_initialized_signed_video(settings[_i], false);
12291225
ck_assert(sv);
@@ -1319,10 +1315,6 @@ mimic_au_fast_forward_on_late_seis_and_get_list(signed_video_t *sv, struct sv_se
13191315

13201316
START_TEST(fast_forward_stream_with_delayed_seis)
13211317
{
1322-
// TODO: Remove when scrubbing forward works. Currently, the first SEI after a "fast
1323-
// forward" operation is validated as 'invalid' when it should not be validated at all.
1324-
// Disabling the test until it has been solved.
1325-
return;
13261318
// Create a new session.
13271319
signed_video_t *sv = get_initialized_signed_video(settings[_i], false);
13281320
ck_assert(sv);
@@ -2388,10 +2380,6 @@ END_TEST
23882380

23892381
START_TEST(file_export_and_scrubbing_partial_gops)
23902382
{
2391-
// TODO: Remove when scrubbing forward works. Currently, the first SEI after a "fast
2392-
// forward" operation is validated as 'invalid' when it should not be validated at all.
2393-
// Disabling the test until it has been solved.
2394-
return;
23952383
// Device side
23962384
struct sv_setting setting = settings[_i];
23972385
const unsigned max_signing_frames = 4;

0 commit comments

Comments
 (0)