diff --git a/gst/mpegtsdemux/Makefile.am b/gst/mpegtsdemux/Makefile.am index 028373165d..f0475c68df 100644 --- a/gst/mpegtsdemux/Makefile.am +++ b/gst/mpegtsdemux/Makefile.am @@ -15,7 +15,7 @@ libgstmpegtsdemux_la_LIBADD = \ $(top_builddir)/gst-libs/gst/mpegts/libgstmpegts-$(GST_API_VERSION).la \ $(top_builddir)/gst-libs/gst/codecparsers/libgstcodecparsers-$(GST_API_VERSION).la \ $(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_API_VERSION) \ - -lgstpbutils-@GST_API_VERSION@ \ + -lgstpbutils-@GST_API_VERSION@ -lgstaudio-$(GST_API_VERSION) \ $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) libgstmpegtsdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstmpegtsdemux_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 3c61a33d27..bcc3018c77 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "mpegtsbase.h" #include "tsdemux.h" @@ -2363,13 +2364,11 @@ parse_opus_access_unit (TSDemuxStream * stream) if (start_trim_flag) { if (!gst_byte_reader_get_uint16_be (&reader, &start_trim)) goto error; - start_trim >>= 3; } if (end_trim_flag) { if (!gst_byte_reader_get_uint16_be (&reader, &end_trim)) goto error; - end_trim >>= 3; } if (control_extension_flag) { @@ -2393,13 +2392,13 @@ parse_opus_access_unit (TSDemuxStream * stream) goto error; buffer = gst_buffer_new_wrapped (packet_data, packet_size); - gst_buffer_list_add (buffer_list, buffer); - /* FIXME: Do something with start_trim and end_trim */ - if (start_trim != 0 || end_trim != 0) - GST_FIXME - ("Handling of Opus start_trim (%u) and end_trim (%u) not implemented", + if (start_trim != 0 || end_trim != 0) { + gst_buffer_add_audio_clipping_meta (buffer, GST_FORMAT_DEFAULT, start_trim, end_trim); + } + + gst_buffer_list_add (buffer_list, buffer); } while (gst_byte_reader_get_remaining (&reader) > 0); g_free (stream->data); diff --git a/gst/mpegtsmux/Makefile.am b/gst/mpegtsmux/Makefile.am index c9944f81b2..37fc935de0 100644 --- a/gst/mpegtsmux/Makefile.am +++ b/gst/mpegtsmux/Makefile.am @@ -11,8 +11,9 @@ libgstmpegtsmux_la_SOURCES = \ libgstmpegtsmux_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) $(GST_CFLAGS) libgstmpegtsmux_la_LIBADD = $(top_builddir)/gst/mpegtsmux/tsmux/libtsmux.la \ - -lgsttag-@GST_API_VERSION@ \ - $(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_API_VERSION@ $(GST_BASE_LIBS) $(GST_LIBS) + $(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_API_VERSION@ \ + -lgstaudio-@GST_API_VERSION@ -lgsttag-@GST_API_VERSION@ \ + $(GST_BASE_LIBS) $(GST_LIBS) libgstmpegtsmux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstmpegtsmux_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) diff --git a/gst/mpegtsmux/mpegtsmux_opus.c b/gst/mpegtsmux/mpegtsmux_opus.c index b64f8f52a3..26176b26dd 100644 --- a/gst/mpegtsmux/mpegtsmux_opus.c +++ b/gst/mpegtsmux/mpegtsmux_opus.c @@ -86,6 +86,7 @@ #include "mpegtsmux_opus.h" #include +#include #define GST_CAT_DEFAULT mpegtsmux_debug @@ -98,9 +99,15 @@ mpegtsmux_prepare_opus (GstBuffer * buf, MpegTsPadData * pad_data, GstBuffer *outbuf; GstMapInfo map; guint n; + GstAudioClippingMeta *cmeta = gst_buffer_get_audio_clipping_meta (buf); + + g_assert (!cmeta || cmeta->format == GST_FORMAT_DEFAULT); - /* TODO: Write start/end trim */ outsize = 2 + insize / 255 + 1; + if (cmeta && cmeta->start) + outsize += 2; + if (cmeta && cmeta->end) + outsize += 2; outbuf = gst_buffer_new_and_alloc (outsize); gst_buffer_copy_into (outbuf, buf, @@ -108,6 +115,12 @@ mpegtsmux_prepare_opus (GstBuffer * buf, MpegTsPadData * pad_data, gst_buffer_map (outbuf, &map, GST_MAP_WRITE); map.data[0] = 0x7f; map.data[1] = 0xe0; + + if (cmeta && cmeta->start) + map.data[1] |= 0x10; + if (cmeta && cmeta->end) + map.data[1] |= 0x08; + n = 2; do { g_assert (n < outsize); @@ -120,6 +133,14 @@ mpegtsmux_prepare_opus (GstBuffer * buf, MpegTsPadData * pad_data, n++; } while (insize >= 0); + if (cmeta && cmeta->start) { + GST_WRITE_UINT16_BE (&map.data[n], cmeta->start); + n += 2; + } + + if (cmeta && cmeta->end) + GST_WRITE_UINT16_BE (&map.data[n], cmeta->end); + gst_buffer_unmap (outbuf, &map); outbuf = gst_buffer_append (outbuf, gst_buffer_ref (buf));