scte-section: add support for packetizing time_signal splices
authorMathieu Duponchelle <mathieu@centricular.com>
Tue, 6 Apr 2021 15:37:28 +0000 (17:37 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 25 Sep 2021 01:29:37 +0000 (01:29 +0000)
time_signal splices are trivial, they only contain a splice_time()
and all the relevant information is carried in descriptors.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/913>

subprojects/gst-plugins-bad/gst-libs/gst/mpegts/gst-scte-section.c

index e91191d..de20fe0 100644 (file)
@@ -500,7 +500,6 @@ _packetize_sit (GstMpegtsSection * section)
 
   switch (sit->splice_command_type) {
     case GST_MTS_SCTE_SPLICE_COMMAND_SCHEDULE:
-    case GST_MTS_SCTE_SPLICE_COMMAND_TIME:
     case GST_MTS_SCTE_SPLICE_COMMAND_PRIVATE:
       GST_WARNING ("SCTE command not supported");
       return FALSE;
@@ -538,6 +537,14 @@ _packetize_sit (GstMpegtsSection * section)
         command_length += 5;
     }
   }
+
+  if (sit->splice_command_type == GST_MTS_SCTE_SPLICE_COMMAND_TIME) {
+    if (sit->splice_time_specified)
+      command_length += 5;
+    else
+      command_length += 1;
+  }
+
   length += command_length;
 
   /* Calculate size of descriptors */
@@ -573,6 +580,16 @@ _packetize_sit (GstMpegtsSection * section)
   GST_WRITE_UINT32_BE (data, tmp32);
   data += 4;
 
+  if (sit->splice_command_type == GST_MTS_SCTE_SPLICE_COMMAND_TIME) {
+    if (!sit->splice_time_specified) {
+      *data++ = 0x7f;
+    } else {
+      *data++ = 0xf2 | ((sit->splice_time >> 32) & 0x1);
+      GST_WRITE_UINT32_BE (data, sit->splice_time & 0xffffffff);
+      data += 4;
+    }
+  }
+
   /* Write the events */
   for (i = 0; i < sit->splices->len; i++) {
     GstMpegtsSCTESpliceEvent *event = g_ptr_array_index (sit->splices, i);