1919 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020 */
2121#include <check.h>
22+ #include <stdbool.h>
2223#include <stdint.h> // uint8_t
2324#ifdef PRINT_DECODED_SEI
2425#include <stdio.h>
@@ -58,18 +59,26 @@ verify_seis(test_stream_t *list, struct sv_setting setting)
5859 return ;
5960 }
6061
62+ bool is_first_signed_sei = true;
63+ bool is_first_unsigned_sei = true;
6164 int num_seis = 0 ;
62- size_t sei_size = 0 ;
65+ size_t sei_size_signed = 0 ;
66+ size_t sei_size_unsigned = 0 ;
6367 test_stream_item_t * item = list -> first_item ;
6468 while (item ) {
6569 bu_info_t bu = parse_bu_info (item -> data , item -> data_size , list -> codec , false, true);
6670 if (bu .is_sv_sei ) {
67- if (num_seis == 0 ) {
71+ if (bu .is_signed && is_first_signed_sei ) {
72+ // Set the SEI size for the first detected SEI.
73+ sei_size_signed = item -> data_size ;
74+ is_first_signed_sei = false;
75+ }
76+ if (!bu .is_signed && is_first_unsigned_sei ) {
6877 // Set the SEI size for the first detected SEI.
69- sei_size = item -> data_size ;
78+ sei_size_unsigned = item -> data_size ;
79+ is_first_unsigned_sei = false;
7080 }
7181 num_seis ++ ;
72- const bool has_signature = tag_is_present (item , list -> codec , SIGNATURE_TAG );
7382 const bool has_hash_list = tag_is_present (item , list -> codec , HASH_LIST_TAG );
7483 const bool has_axis_tag = tag_is_present (item , list -> codec , VENDOR_AXIS_COMMUNICATIONS_TAG );
7584 const bool has_public_key_tag = tag_is_present (item , list -> codec , PUBLIC_KEY_TAG );
@@ -80,12 +89,12 @@ verify_seis(test_stream_t *list, struct sv_setting setting)
8089 // Verify SEI sizes if emulation prevention is turned off.
8190 if (setting .auth_level == SV_AUTHENTICITY_LEVEL_GOP && !setting .ep_before_signing ) {
8291 // For GOP level authenticity, all SEIs should have the same size
83- ck_assert (item -> data_size == sei_size );
92+ ck_assert (item -> data_size == ( bu . is_signed ? sei_size_signed : sei_size_unsigned ) );
8493 }
8594 // Verify that SEI sizes increase over time.
8695 if (setting .increased_sei_size ) {
87- ck_assert_int_ge (item -> data_size , sei_size );
88- sei_size = item -> data_size ;
96+ ck_assert_int_ge (item -> data_size , sei_size_signed );
97+ sei_size_signed = item -> data_size ;
8998 }
9099 if (setting .max_sei_payload_size > 0 ) {
91100 // Verify the SEI size. This overrides the authenticity level.
@@ -111,14 +120,14 @@ verify_seis(test_stream_t *list, struct sv_setting setting)
111120 ck_assert (has_optional_tags );
112121 // Verify that signatures follow the signing_frequency.
113122 if (num_seis % setting .signing_frequency == 0 ) {
114- ck_assert (has_signature );
123+ ck_assert (bu . is_signed );
115124 } else {
116- ck_assert (!has_signature );
125+ ck_assert (!bu . is_signed );
117126 }
118127 }
119128 // Verify that a golden SEI has a signature.
120129 if (bu .is_golden_sei ) {
121- ck_assert (has_signature );
130+ ck_assert (bu . is_signed );
122131 }
123132 // Verify that Axis vendor tag is present.
124133 ck_assert (!((setting .vendor_axis_mode > 0 ) ^ has_axis_tag ));
@@ -198,6 +207,13 @@ START_TEST(api_inputs)
198207 sv_rc = signed_video_set_private_key (sv , private_key , private_key_size );
199208 ck_assert_int_eq (sv_rc , SV_OK );
200209
210+ // Check setting signing_frequency
211+ sv_rc = signed_video_set_signing_frequency (NULL , 1 );
212+ ck_assert_int_eq (sv_rc , SV_INVALID_PARAMETER );
213+ sv_rc = signed_video_set_signing_frequency (sv , 0 );
214+ ck_assert_int_eq (sv_rc , SV_INVALID_PARAMETER );
215+ sv_rc = signed_video_set_signing_frequency (sv , 2 );
216+ ck_assert_int_eq (sv_rc , SV_OK );
201217 // Check setting recurrence
202218 sv_rc = signed_video_set_recurrence_interval_frames (NULL , 1 );
203219 ck_assert_int_eq (sv_rc , SV_INVALID_PARAMETER );
@@ -884,6 +900,22 @@ START_TEST(limited_sei_payload_size)
884900}
885901END_TEST
886902
903+ /* Test description
904+ * Verifies the signing frequency setter, that is, signing multiple GOPs. */
905+ START_TEST (signing_multiple_gops )
906+ {
907+ struct sv_setting setting = settings [_i ];
908+ // Select a signing frequency longer than every GOP.
909+ const unsigned signing_frequency = 2 ;
910+ setting .signing_frequency = signing_frequency ;
911+ test_stream_t * list = create_signed_stream ("IPPIPPIPPIPPIP" , setting );
912+ test_stream_check_types (list , "IPPIsPPISPPIsPPISP" );
913+ verify_seis (list , setting );
914+
915+ test_stream_free (list );
916+ }
917+ END_TEST
918+
887919/* Test description
888920 * Verifies the setter for maximum Bitstream Units before signing, that is, triggers
889921 * signing partial GOPs. */
@@ -951,6 +983,7 @@ signed_video_suite(void)
951983 tcase_add_loop_test (tc , golden_sei_created , s , e );
952984 tcase_add_loop_test (tc , w_wo_emulation_prevention_bytes , s , e );
953985 tcase_add_loop_test (tc , limited_sei_payload_size , s , e );
986+ tcase_add_loop_test (tc , signing_multiple_gops , s , e );
954987 tcase_add_loop_test (tc , signing_partial_gops , s , e );
955988 tcase_add_loop_test (tc , signing_mulitslice_stream_partial_gops , s , e );
956989
0 commit comments