diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/gstmpegdesc.h b/subprojects/gst-plugins-bad/gst/mpegtsdemux/gstmpegdesc.h index 65fb44fd3a..be491d5c27 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/gstmpegdesc.h +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/gstmpegdesc.h @@ -211,6 +211,10 @@ /* AC3_audio_stream_descriptor */ #define DESC_AC_AUDIO_STREAM_bsid(desc) ((desc)[2] & 0x1f) +#define DESC_AC_AUDIO_STREAM_channels(desc) ((desc[4] >> 1) & 0x0f) +#define DESC_AC_AUDIO_STREAM_textlen(desc) ((desc[7 + (DESC_AC_AUDIO_STREAM_channels(desc)==0)] >> 1) & 0x7f) +#define DESC_AC_AUDIO_STREAM_has_lang1(desc) ((desc[8 + DESC_AC_AUDIO_STREAM_textlen(desc)] >> 7) & 0x01) +#define DESC_AC_AUDIO_STREAM_lang1_code(desc) (desc + 9 + DESC_AC_AUDIO_STREAM_textlen(desc)) /* FIXME : Move list of well know registration ids to an enum * in the mpegts library. diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c b/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c index fadf707dd5..77a74a4786 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c @@ -1269,6 +1269,21 @@ gst_ts_demux_create_tags (TSDemuxStream * stream) const GstMpegtsDescriptor *desc = NULL; int i, nb; + if (bstream->stream_type == ST_PS_AUDIO_AC3 && + !mpegts_get_descriptor_from_stream (bstream, + GST_MTS_DESC_DVB_ENHANCED_AC3)) { + const GstMpegtsDescriptor *ac3_desc = + mpegts_get_descriptor_from_stream (bstream, + GST_MTS_DESC_AC3_AUDIO_STREAM); + if (ac3_desc && DESC_AC_AUDIO_STREAM_has_lang1 (ac3_desc->data)) { + gchar lang_code[4]; + + memcpy (lang_code, DESC_AC_AUDIO_STREAM_lang1_code (ac3_desc->data), 3); + lang_code[3] = '\0'; + add_iso639_language_to_tags (stream, lang_code); + } + } + desc = mpegts_get_descriptor_from_stream (bstream, GST_MTS_DESC_ISO_639_LANGUAGE);