From 216f9d66a0e93bb3a9050706ef55c2730d9ca11a Mon Sep 17 00:00:00 2001 From: Fabian Orccon Date: Wed, 19 Jul 2023 09:51:12 +0200 Subject: [PATCH] h265parser: Write Unregistered User Data Part-of: --- .../gst-libs/gst/codecparsers/gsth265parser.c | 28 +++++++++++++++++++ .../tests/check/libs/h265parser.c | 22 +++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c index 4a73c6a49d..fc11b19ab2 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c @@ -4144,6 +4144,19 @@ error: return FALSE; } +static gboolean +gst_h265_write_sei_user_data_unregistered (NalWriter * nw, + GstH265UserDataUnregistered * udu) +{ + WRITE_BYTES (nw, udu->uuid, 16); + WRITE_BYTES (nw, udu->data, udu->size); + + return TRUE; + +error: + return FALSE; +} + static gboolean gst_h265_write_sei_time_code (NalWriter * nw, GstH265TimeCode * tc) { @@ -4274,6 +4287,12 @@ gst_h265_create_sei_memory_internal (guint8 layer_id, guint8 temporal_id_plus1, payload_size_data += rud->size; break; } + case GST_H265_SEI_USER_DATA_UNREGISTERED:{ + GstH265UserDataUnregistered *udu = &msg->payload.user_data_unregistered; + + payload_size_data = 16 + udu->size; + break; + } case GST_H265_SEI_TIME_CODE:{ gint j; GstH265TimeCode *tc = &msg->payload.time_code; @@ -4387,6 +4406,15 @@ gst_h265_create_sei_memory_internal (guint8 layer_id, guint8 temporal_id_plus1, } have_written_data = TRUE; break; + case GST_H265_SEI_USER_DATA_UNREGISTERED: + GST_DEBUG ("Writing \"Unregistered user data\" done"); + if (!gst_h265_write_sei_user_data_unregistered (&nw, + &msg->payload.user_data_unregistered)) { + GST_WARNING ("Failed to write \"Unregistered user data\""); + goto error; + } + have_written_data = TRUE; + break; case GST_H265_SEI_TIME_CODE: GST_DEBUG ("Wrtiting \"Time code\""); if (!gst_h265_write_sei_time_code (&nw, &msg->payload.time_code)) { diff --git a/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c b/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c index a565ba738d..6db417f57f 100644 --- a/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c +++ b/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c @@ -123,6 +123,16 @@ static guint8 h265_sei_user_data_registered[] = { 0xa6, 0xae, 0x5c, 0x83, 0x50, 0xdd, 0xf9, 0x8e, 0xc7, 0xbd, 0x00, 0x80 }; +static guint8 h265_sei_user_data_unregistered[] = { + 0x00, 0x00, 0x00, 0x01, 0x4e, 0x01, + 0x05, // Payload type. + 0x18, // Payload size. + 0x4D, 0x49, 0x53, 0x50, 0x6D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x65, 0x63, + 0x74, 0x69, 0x6D, 0x65, // UUID. + 0x70, 0x69, 0x67, 0x73, 0x20, 0x66, 0x6c, 0x79, // Payload data + 0x80 +}; + static guint8 h265_sei_time_code[] = { 0x00, 0x00, 0x00, 0x01, 0x4e, 0x01, 0x88, 0x06, 0x60, 0x40, 0x00, 0x00, 0x03, 0x00, 0x10, 0x80 @@ -972,6 +982,15 @@ check_sei_user_data_registered (const GstH265RegisteredUserData * a, return !memcmp (a->data, b->data, a->size); } +static gboolean +check_sei_user_data_unregistered (const GstH265UserDataUnregistered * a, + const GstH265UserDataUnregistered * b) +{ + return a->size == b->size && + !memcmp (a->uuid, b->uuid, sizeof (a->uuid)) && + !memcmp (a->data, b->data, a->size); +} + static gboolean check_sei_time_code (const GstH265TimeCode * a, const GstH265TimeCode * b) { @@ -1076,6 +1095,9 @@ GST_START_TEST (test_h265_create_sei) {h265_sei_user_data_registered, G_N_ELEMENTS (h265_sei_user_data_registered), GST_H265_SEI_REGISTERED_USER_DATA, {0,}, (SEICheckFunc) check_sei_user_data_registered}, + {h265_sei_user_data_unregistered, G_N_ELEMENTS (h265_sei_user_data_unregistered), + GST_H265_SEI_USER_DATA_UNREGISTERED, {0,}, + (SEICheckFunc) check_sei_user_data_unregistered}, {h265_sei_time_code, G_N_ELEMENTS (h265_sei_time_code), GST_H265_SEI_TIME_CODE, {0,}, ( SEICheckFunc) check_sei_time_code},