From 790b12cf136d7d71353cea0f7fbf0ce10a259958 Mon Sep 17 00:00:00 2001 From: Mart Raudsepp Date: Sat, 16 Mar 2024 00:38:58 +0200 Subject: [PATCH] mpegtsmux: Add support for SMPTE 302M (audio/x-smpte-302m) Part-of: --- .../docs/plugins/gst_plugins_cache.json | 2 +- .../gst-plugins-bad/gst/mpegtsmux/gstbasetsmux.c | 2 ++ .../gst-plugins-bad/gst/mpegtsmux/gstmpegtsmux.c | 1 + .../gst/mpegtsmux/tsmux/tsmuxstream.c | 12 ++++++++++++ .../gst/mpegtsmux/tsmux/tsmuxstream.h | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json index 7656937051..2170341484 100644 --- a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json +++ b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json @@ -223194,7 +223194,7 @@ "long-name": "MPEG Transport Stream Muxer", "pad-templates": { "sink_%%d": { - "caps": "video/mpeg:\n parsed: true\n mpegversion: { (int)1, (int)2, (int)4 }\n systemstream: false\nvideo/x-dirac:\nimage/x-jpc:\n alignment: frame\nvideo/x-h264:\n stream-format: byte-stream\n alignment: { (string)au, (string)nal }\nvideo/x-h265:\n stream-format: byte-stream\n alignment: { (string)au, (string)nal }\naudio/mpeg:\n parsed: true\n mpegversion: 1\naudio/mpeg:\n framed: true\n mpegversion: { (int)2, (int)4 }\n stream-format: { (string)adts, (string)raw }\naudio/x-lpcm:\n width: { (int)16, (int)20, (int)24 }\n rate: { (int)48000, (int)96000 }\n channels: [ 1, 8 ]\n dynamic_range: [ 0, 255 ]\n emphasis: { (boolean)false, (boolean)true }\n mute: { (boolean)false, (boolean)true }\naudio/x-ac3:\n framed: true\naudio/x-dts:\n framed: true\naudio/x-opus:\n channels: [ 1, 255 ]\nsubpicture/x-dvb:\napplication/x-teletext:\nmeta/x-klv:\n parsed: true\nmeta/x-id3:\n parsed: true\nmeta/x-st-2038:\n alignment: line\nimage/x-jpc:\n alignment: frame\n profile: [ 0, 49151 ]\nimage/x-jxsc:\n alignment: frame\n sampling: { (string)YCbCr-4:2:2, (string)YCbCr-4:4:4 }\n", + "caps": "video/mpeg:\n parsed: true\n mpegversion: { (int)1, (int)2, (int)4 }\n systemstream: false\nvideo/x-dirac:\nimage/x-jpc:\n alignment: frame\nvideo/x-h264:\n stream-format: byte-stream\n alignment: { (string)au, (string)nal }\nvideo/x-h265:\n stream-format: byte-stream\n alignment: { (string)au, (string)nal }\naudio/mpeg:\n parsed: true\n mpegversion: 1\naudio/mpeg:\n framed: true\n mpegversion: { (int)2, (int)4 }\n stream-format: { (string)adts, (string)raw }\naudio/x-lpcm:\n width: { (int)16, (int)20, (int)24 }\n rate: { (int)48000, (int)96000 }\n channels: [ 1, 8 ]\n dynamic_range: [ 0, 255 ]\n emphasis: { (boolean)false, (boolean)true }\n mute: { (boolean)false, (boolean)true }\naudio/x-ac3:\n framed: true\naudio/x-dts:\n framed: true\naudio/x-opus:\n channels: [ 1, 255 ]\naudio/x-smpte-302m:\nsubpicture/x-dvb:\napplication/x-teletext:\nmeta/x-klv:\n parsed: true\nmeta/x-id3:\n parsed: true\nmeta/x-st-2038:\n alignment: line\nimage/x-jpc:\n alignment: frame\n profile: [ 0, 49151 ]\nimage/x-jxsc:\n alignment: frame\n sampling: { (string)YCbCr-4:2:2, (string)YCbCr-4:4:4 }\n", "direction": "sink", "presence": "request", "type": "GstBaseTsMuxPad" diff --git a/subprojects/gst-plugins-bad/gst/mpegtsmux/gstbasetsmux.c b/subprojects/gst-plugins-bad/gst/mpegtsmux/gstbasetsmux.c index 87ce645158..061874c79f 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsmux/gstbasetsmux.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsmux/gstbasetsmux.c @@ -830,6 +830,8 @@ gst_base_ts_mux_create_or_update_stream (GstBaseTsMux * mux, ts_pad->prepare_func = gst_base_ts_mux_prepare_jpegxs; ts_pad->prepare_data = jpegxs_descriptor; ts_pad->free_func = gst_base_ts_mux_free_jpegxs; + } else if (strcmp (mt, "audio/x-smpte-302m") == 0) { + st = TSMUX_ST_PS_S302M; } else if (strcmp (mt, "image/x-jpc") == 0) { /* * See this document for more details on standard: diff --git a/subprojects/gst-plugins-bad/gst/mpegtsmux/gstmpegtsmux.c b/subprojects/gst-plugins-bad/gst/mpegtsmux/gstmpegtsmux.c index 792a3e340c..3b41643fa0 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsmux/gstmpegtsmux.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsmux/gstmpegtsmux.c @@ -124,6 +124,7 @@ static GstStaticPadTemplate gst_mpeg_ts_mux_sink_factory = "audio/x-dts, framed = (boolean) TRUE;" "audio/x-opus, " "channels = (int) [1, 255];" + "audio/x-smpte-302m;" "subpicture/x-dvb; application/x-teletext; meta/x-klv, parsed=true;" "meta/x-id3, parsed=true;" "meta/x-st-2038, alignment = (string) line;" diff --git a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c index 0a7c66e82d..b63d050560 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c @@ -245,6 +245,13 @@ tsmux_stream_new (guint16 pid, guint stream_type, guint stream_number) stream->stream_type = TSMUX_ST_PRIVATE_DATA; stream->pi.flags |= TSMUX_PACKET_FLAG_PES_FULL_HEADER; break; + case TSMUX_ST_PS_S302M: + /* FIXME: assign sequential extended IDs? */ + stream->id = 0xBD; + stream->gst_stream_type = GST_STREAM_TYPE_AUDIO; + stream->stream_type = TSMUX_ST_PRIVATE_DATA; + stream->pi.flags |= TSMUX_PACKET_FLAG_PES_FULL_HEADER; + break; default: /* Might be a custom stream type implemented by a subclass */ break; @@ -1022,6 +1029,11 @@ tsmux_stream_default_get_es_descrs (TsMuxStream * stream, descriptor = gst_mpegts_descriptor_from_custom (0xc4, NULL, 0); g_ptr_array_add (pmt_stream->descriptors, descriptor); } + if (stream->internal_stream_type == TSMUX_ST_PS_S302M) { + descriptor = gst_mpegts_descriptor_from_registration ("BSSD", NULL, 0); + GST_DEBUG ("adding SMPTE 302M registration descriptor"); + g_ptr_array_add (pmt_stream->descriptors, descriptor); + } default: break; } diff --git a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h index 322cc5d886..1609f005b2 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h +++ b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h @@ -134,6 +134,7 @@ enum TsMuxStreamType { TSMUX_ST_PS_OPUS = 0x8f, /* only used internally */ TSMUX_ST_PS_ID3 = 0x90, /* only used internally */ TSMUX_ST_PS_ST_2038 = 0x91, /* only used internally */ + TSMUX_ST_PS_S302M = 0x92, /* only used internally */ TSMUX_ST_PS_DVD_SUBPICTURE = 0xff, /* Non-standard definitions */