scte-section: add support for packetizing schedule events

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/913>
This commit is contained in:
Mathieu Duponchelle 2021-04-13 23:56:06 +02:00 committed by GStreamer Marge Bot
parent 5ecd395d91
commit 612e064154

View file

@ -385,7 +385,7 @@ _parse_sit (GstMpegtsSection * section)
default: default:
GST_WARNING ("Unknown SCTE splice command type (0x%02x) !", GST_WARNING ("Unknown SCTE splice command type (0x%02x) !",
sit->splice_command_type); sit->splice_command_type);
goto done; break;;
} }
/* descriptors */ /* descriptors */
@ -653,7 +653,6 @@ _packetize_sit (GstMpegtsSection * section)
} }
switch (sit->splice_command_type) { switch (sit->splice_command_type) {
case GST_MTS_SCTE_SPLICE_COMMAND_SCHEDULE:
case GST_MTS_SCTE_SPLICE_COMMAND_PRIVATE: case GST_MTS_SCTE_SPLICE_COMMAND_PRIVATE:
GST_WARNING ("SCTE command not supported"); GST_WARNING ("SCTE command not supported");
return FALSE; return FALSE;
@ -681,12 +680,18 @@ _packetize_sit (GstMpegtsSection * section)
} }
/* Add at least 5 bytes for common fields */ /* Add at least 5 bytes for common fields */
command_length += 5; command_length += 5;
if (!event->splice_immediate_flag) { if (event->insert_event) {
if (event->program_splice_time_specified) if (!event->splice_immediate_flag) {
command_length += 5; if (event->program_splice_time_specified)
else command_length += 5;
command_length += 1; else
command_length += 1;
}
} else {
/* Schedule events, 4 bytes for utc_splice_time */
command_length += 4;
} }
if (event->duration_flag) if (event->duration_flag)
command_length += 5; command_length += 5;
} }
@ -764,19 +769,26 @@ _packetize_sit (GstMpegtsSection * section)
*data++ = (event->out_of_network_indicator << 7) | *data++ = (event->out_of_network_indicator << 7) |
(event->program_splice_flag << 6) | (event->program_splice_flag << 6) |
(event->duration_flag << 5) | (event->duration_flag << 5) |
(event->splice_immediate_flag << 4) | 0x0f; (event->insert_event ? (event->splice_immediate_flag << 4) : 0) |
if (!event->splice_immediate_flag) { 0x0f;
/* program_splice_time_specified : 1bit if (event->insert_event) {
* reserved : 6/7 bit */ if (!event->splice_immediate_flag) {
if (!event->program_splice_time_specified) /* program_splice_time_specified : 1bit
*data++ = 0x7f; * reserved : 6/7 bit */
else { if (!event->program_splice_time_specified)
/* time : 33bit */ *data++ = 0x7f;
*data++ = 0xf2 | ((event->program_splice_time >> 32) & 0x1); else {
GST_WRITE_UINT32_BE (data, event->program_splice_time & 0xffffffff); /* time : 33bit */
data += 4; *data++ = 0xf2 | ((event->program_splice_time >> 32) & 0x1);
GST_WRITE_UINT32_BE (data, event->program_splice_time & 0xffffffff);
data += 4;
}
} }
} else {
GST_WRITE_UINT32_BE (data, event->utc_splice_time);
data += 4;
} }
if (event->duration_flag) { if (event->duration_flag) {
*data = event->break_duration_auto_return ? 0xfe : 0x7e; *data = event->break_duration_auto_return ? 0xfe : 0x7e;
*data++ |= (event->break_duration >> 32) & 0x1; *data++ |= (event->break_duration >> 32) & 0x1;