mpegtsmux: write language descriptor when language is available

Adds a new function to mpegts lib to create a iso639 language
descriptor from a language and use it in mpegtsmux to add
a language descriptor to audio streams that have a language set.

https://bugzilla.gnome.org/show_bug.cgi?id=763647
This commit is contained in:
Thiago Santos 2016-04-19 10:27:43 -03:00
parent c9cd32bcea
commit 9cc00bf2c9
4 changed files with 38 additions and 1 deletions

View file

@ -1039,6 +1039,30 @@ gst_mpegts_descriptor_parse_iso_639_language_nb (const GstMpegtsDescriptor *
return descriptor->length / 4;
}
/**
* gst_mpegts_descriptor_from_iso_639_language:
* @language: (transfer none): ISO-639-2 language 3-char code
*
* Creates a %GST_MTS_DESC_ISO_639_LANGUAGE #GstMpegtsDescriptor with
* a single language
*
* Return: #GstMpegtsDescriptor, %NULL on failure
*/
GstMpegtsDescriptor *
gst_mpegts_descriptor_from_iso_639_language (const gchar * language)
{
GstMpegtsDescriptor *descriptor;
g_return_val_if_fail (language != NULL, NULL);
descriptor = _new_descriptor (GST_MTS_DESC_ISO_639_LANGUAGE, 4 + 4); /* a language takes 4 bytes */
memcpy (descriptor->data + 2, language, 3);
descriptor->data[2 + 3] = 0; /* set audio type to undefined */
return descriptor;
}
/**
* gst_mpegts_descriptor_parse_logical_channel:
* @descriptor: a %GST_MTS_DESC_DTG_LOGICAL_CHANNEL #GstMpegtsDescriptor

View file

@ -313,6 +313,7 @@ gboolean gst_mpegts_descriptor_parse_iso_639_language_idx (const GstMpegtsDescri
guint idx, gchar **lang,
GstMpegtsIso639AudioType *audio_type);
guint gst_mpegts_descriptor_parse_iso_639_language_nb (const GstMpegtsDescriptor *descriptor);
GstMpegtsDescriptor * gst_mpegts_descriptor_from_iso_639_language (const gchar * language);

View file

@ -148,6 +148,7 @@ tsmux_stream_new (guint16 pid, TsMuxStreamType stream_type)
case TSMUX_ST_AUDIO_MPEG1:
case TSMUX_ST_AUDIO_MPEG2:
/* FIXME: Assign sequential IDs? */
stream->is_audio = TRUE;
stream->id = 0xC0;
stream->pi.flags |= TSMUX_PACKET_FLAG_PES_FULL_HEADER;
break;
@ -163,12 +164,15 @@ tsmux_stream_new (guint16 pid, TsMuxStreamType stream_type)
stream->is_video_stream = TRUE;
break;
case TSMUX_ST_PS_AUDIO_LPCM:
stream->is_audio = TRUE;
stream->id_extended = 0x80;
break;
case TSMUX_ST_PS_AUDIO_AC3:
stream->is_audio = TRUE;
stream->id_extended = 0x71;
break;
case TSMUX_ST_PS_AUDIO_DTS:
stream->is_audio = TRUE;
stream->id_extended = 0x82;
break;
default:
@ -204,6 +208,7 @@ tsmux_stream_new (guint16 pid, TsMuxStreamType stream_type)
case TSMUX_ST_PS_OPUS:
/* FIXME: assign sequential extended IDs? */
stream->id = 0xBD;
stream->is_audio = TRUE;
stream->stream_type = TSMUX_ST_PRIVATE_DATA;
stream->is_opus = TRUE;
stream->pi.flags |= TSMUX_PACKET_FLAG_PES_FULL_HEADER;
@ -732,7 +737,13 @@ tsmux_stream_get_es_descrs (TsMuxStream * stream,
g_return_if_fail (stream != NULL);
g_return_if_fail (pmt_stream != NULL);
/* Based on the stream type, write out any descriptors to go in the
if (stream->is_audio && stream->language) {
descriptor = gst_mpegts_descriptor_from_iso_639_language (stream->language);
g_ptr_array_add (pmt_stream->descriptors, descriptor);
descriptor = NULL;
}
/* Based on the stream type, write out any descriptors to go in the
* PMT ES_info field */
/* tag (registration_descriptor), length, format_identifier */
switch (stream->stream_type) {

View file

@ -211,6 +211,7 @@ struct TsMuxStream {
gchar language[4];
gboolean is_meta;
gboolean is_audio;
/* Opus */
gboolean is_opus;