mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 21:48:55 +00:00
Support Multi languages (need a decodebin2 patch)
This commit is contained in:
parent
a4ac4a3117
commit
713d02b81a
4 changed files with 101 additions and 22 deletions
|
@ -534,23 +534,35 @@ gst_dash_demux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
gst_buffer_unref (demux->playlist);
|
gst_buffer_unref (demux->playlist);
|
||||||
demux->playlist = NULL;
|
demux->playlist = NULL;
|
||||||
|
|
||||||
if (!gst_mpd_client_setup_streaming (demux->client, GST_STREAM_VIDEO)) {
|
if (!gst_mpd_client_setup_streaming (demux->client, GST_STREAM_VIDEO, "")) {
|
||||||
GST_ELEMENT_ERROR (demux, STREAM, DECODE,
|
GST_ELEMENT_ERROR (demux, STREAM, DECODE,
|
||||||
("Incompatible manifest file."), (NULL));
|
("Incompatible manifest file."), (NULL));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gst_mpdparser_get_nb_adaptationSet (demux->client) > 1)
|
guint nb_audio =
|
||||||
if (!gst_mpd_client_setup_streaming (demux->client, GST_STREAM_AUDIO))
|
gst_mpdparser_get_nb_audio_adapt_set (demux->client->
|
||||||
GST_INFO_OBJECT (demux, "No audio adaptation set found");
|
cur_period->AdaptationSets);
|
||||||
|
GST_INFO_OBJECT (demux, "Number of language is=%d", nb_audio);
|
||||||
|
if (nb_audio == 0)
|
||||||
|
nb_audio = 1;
|
||||||
|
GList *listLang = NULL;
|
||||||
|
gst_mpdparser_get_list_of_audio_language (&listLang,
|
||||||
|
demux->client->cur_period->AdaptationSets);
|
||||||
|
guint i = 0;
|
||||||
|
for (i = 0; i < nb_audio; i++) {
|
||||||
|
gchar *lang = (gchar *) g_list_nth_data (listLang, i);
|
||||||
|
if (gst_mpdparser_get_nb_adaptationSet (demux->client) > 1)
|
||||||
|
if (!gst_mpd_client_setup_streaming (demux->client, GST_STREAM_AUDIO,
|
||||||
|
lang))
|
||||||
|
GST_INFO_OBJECT (demux, "No audio adaptation set found");
|
||||||
|
|
||||||
if (gst_mpdparser_get_nb_adaptationSet (demux->client) > 2)
|
if (gst_mpdparser_get_nb_adaptationSet (demux->client) > nb_audio)
|
||||||
if (!gst_mpd_client_setup_streaming (demux->client,
|
if (!gst_mpd_client_setup_streaming (demux->client,
|
||||||
GST_STREAM_APPLICATION)) {
|
GST_STREAM_APPLICATION, lang)) {
|
||||||
GST_INFO_OBJECT (demux, "No application adaptation set found");
|
GST_INFO_OBJECT (demux, "No application adaptation set found");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
demux->client->stream_idx = 0;
|
|
||||||
|
|
||||||
/* Send duration message */
|
/* Send duration message */
|
||||||
if (!gst_mpd_client_is_live (demux->client)) {
|
if (!gst_mpd_client_is_live (demux->client)) {
|
||||||
|
@ -697,7 +709,7 @@ gst_dash_demux_stop (GstDashDemux * demux)
|
||||||
static void
|
static void
|
||||||
switch_pads (GstDashDemux * demux, guint nb_adaptation_set)
|
switch_pads (GstDashDemux * demux, guint nb_adaptation_set)
|
||||||
{
|
{
|
||||||
GstPad *oldpad[3];
|
GstPad *oldpad[MAX_LANGUAGES];
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
while (i < nb_adaptation_set) {
|
while (i < nb_adaptation_set) {
|
||||||
oldpad[i] = demux->srcpad[i];
|
oldpad[i] = demux->srcpad[i];
|
||||||
|
@ -782,6 +794,7 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstBufferList *buffer_list;
|
GstBufferList *buffer_list;
|
||||||
guint nb_adaptation_set = 0;
|
guint nb_adaptation_set = 0;
|
||||||
|
GstActiveStream *stream;
|
||||||
/* Loop for the source pad task.
|
/* Loop for the source pad task.
|
||||||
*
|
*
|
||||||
* Startup:
|
* Startup:
|
||||||
|
@ -833,6 +846,7 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
for (i = 0; i < nb_adaptation_set; i++) {
|
for (i = 0; i < nb_adaptation_set; i++) {
|
||||||
GstFragment *fragment = g_list_nth_data (listfragment, i);
|
GstFragment *fragment = g_list_nth_data (listfragment, i);
|
||||||
|
stream = gst_mpdparser_get_active_stream_by_index (demux->client, i);
|
||||||
if (demux->need_segment) {
|
if (demux->need_segment) {
|
||||||
GstClockTime start = fragment->start_time + demux->position_shift;
|
GstClockTime start = fragment->start_time + demux->position_shift;
|
||||||
/* And send a newsegment */
|
/* And send a newsegment */
|
||||||
|
@ -849,7 +863,7 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
|
||||||
buffer_list = gst_fragment_get_buffer_list (fragment);
|
buffer_list = gst_fragment_get_buffer_list (fragment);
|
||||||
g_object_unref (fragment);
|
g_object_unref (fragment);
|
||||||
ret = gst_pad_push_list (demux->srcpad[i], buffer_list);
|
ret = gst_pad_push_list (demux->srcpad[i], buffer_list);
|
||||||
if (ret != GST_FLOW_OK)
|
if ((ret != GST_FLOW_OK)&& (stream->mimeType == GST_STREAM_VIDEO))
|
||||||
goto error_pushing;
|
goto error_pushing;
|
||||||
}
|
}
|
||||||
if (GST_STATE (demux) == GST_STATE_PLAYING) {
|
if (GST_STATE (demux) == GST_STATE_PLAYING) {
|
||||||
|
@ -896,7 +910,7 @@ gst_dash_demux_reset (GstDashDemux * demux, gboolean dispose)
|
||||||
demux->cancelled = FALSE;
|
demux->cancelled = FALSE;
|
||||||
|
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < MAX_LANGUAGES; i++)
|
||||||
if (demux->input_caps[i]) {
|
if (demux->input_caps[i]) {
|
||||||
gst_caps_unref (demux->input_caps[i]);
|
gst_caps_unref (demux->input_caps[i]);
|
||||||
demux->input_caps[i] = NULL;
|
demux->input_caps[i] = NULL;
|
||||||
|
|
|
@ -50,6 +50,7 @@ G_BEGIN_DECLS
|
||||||
//
|
//
|
||||||
typedef struct _GstDashDemux GstDashDemux;
|
typedef struct _GstDashDemux GstDashDemux;
|
||||||
typedef struct _GstDashDemuxClass GstDashDemuxClass;
|
typedef struct _GstDashDemuxClass GstDashDemuxClass;
|
||||||
|
#define MAX_LANGUAGES 20
|
||||||
/**
|
/**
|
||||||
* GstDashDemux:
|
* GstDashDemux:
|
||||||
*
|
*
|
||||||
|
@ -59,9 +60,9 @@ struct _GstDashDemux
|
||||||
{
|
{
|
||||||
GstElement parent;
|
GstElement parent;
|
||||||
GstPad *sinkpad;
|
GstPad *sinkpad;
|
||||||
GstPad *srcpad[3]; /*Video/Audio/Application src pad*/
|
GstPad *srcpad[MAX_LANGUAGES]; /*Video/Audio/Application src pad*/
|
||||||
GstCaps *output_caps[3]; /*Video/Audio/Application output buf caps*/
|
GstCaps *output_caps[MAX_LANGUAGES]; /*Video/Audio/Application output buf caps*/
|
||||||
GstCaps *input_caps[3]; /*Video/Audio/Application input caps*/
|
GstCaps *input_caps[MAX_LANGUAGES]; /*Video/Audio/Application input caps*/
|
||||||
|
|
||||||
GstBuffer *playlist;
|
GstBuffer *playlist;
|
||||||
GstUriDownloader *downloader;
|
GstUriDownloader *downloader;
|
||||||
|
|
|
@ -2562,7 +2562,7 @@ gst_mpd_client_setup_representation (GstMpdClient * client, GstActiveStream *str
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_mpd_client_setup_streaming (GstMpdClient * client,
|
gst_mpd_client_setup_streaming (GstMpdClient * client,
|
||||||
GstStreamMimeType mimeType)
|
GstStreamMimeType mimeType, gchar* lang)
|
||||||
{
|
{
|
||||||
GstActiveStream *stream;
|
GstActiveStream *stream;
|
||||||
GstAdaptationSetNode *adapt_set;
|
GstAdaptationSetNode *adapt_set;
|
||||||
|
@ -2607,7 +2607,7 @@ gst_mpd_client_setup_streaming (GstMpdClient * client,
|
||||||
#endif
|
#endif
|
||||||
adapt_set =
|
adapt_set =
|
||||||
gst_mpdparser_get_first_adapt_set_with_mimeType_and_lang (client->
|
gst_mpdparser_get_first_adapt_set_with_mimeType_and_lang (client->
|
||||||
cur_period->AdaptationSets, "audio", "en");
|
cur_period->AdaptationSets, "audio", lang);
|
||||||
/* if we did not found the requested audio language, get the first one */
|
/* if we did not found the requested audio language, get the first one */
|
||||||
if (!adapt_set)
|
if (!adapt_set)
|
||||||
adapt_set =
|
adapt_set =
|
||||||
|
@ -2632,7 +2632,7 @@ gst_mpd_client_setup_streaming (GstMpdClient * client,
|
||||||
#endif
|
#endif
|
||||||
adapt_set =
|
adapt_set =
|
||||||
gst_mpdparser_get_first_adapt_set_with_mimeType_and_lang (client->
|
gst_mpdparser_get_first_adapt_set_with_mimeType_and_lang (client->
|
||||||
cur_period->AdaptationSets, "application", "en");
|
cur_period->AdaptationSets, "application", lang);
|
||||||
/* if we did not found the requested subtitles language, get the first one */
|
/* if we did not found the requested subtitles language, get the first one */
|
||||||
if (!adapt_set)
|
if (!adapt_set)
|
||||||
adapt_set =
|
adapt_set =
|
||||||
|
@ -2877,6 +2877,7 @@ guint gst_mpd_client_get_width_of_video_current_stream (GstMpdClient *client, Gs
|
||||||
g_return_val_if_fail (stream != NULL, FALSE);
|
g_return_val_if_fail (stream != NULL, FALSE);
|
||||||
return stream->cur_representation->RepresentationBase->width;
|
return stream->cur_representation->RepresentationBase->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream){
|
guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream){
|
||||||
|
|
||||||
g_return_val_if_fail (stream != NULL, FALSE);
|
g_return_val_if_fail (stream != NULL, FALSE);
|
||||||
|
@ -2886,8 +2887,9 @@ guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client, G
|
||||||
guint gst_mpd_client_get_rate_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream){
|
guint gst_mpd_client_get_rate_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream){
|
||||||
|
|
||||||
g_return_val_if_fail (stream != NULL, FALSE);
|
g_return_val_if_fail (stream != NULL, FALSE);
|
||||||
return stream->cur_representation->RepresentationBase->audioSamplingRate;
|
return (guint) stream->cur_representation->RepresentationBase->audioSamplingRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream){
|
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream){
|
||||||
|
|
||||||
g_return_val_if_fail (stream != NULL, FALSE);
|
g_return_val_if_fail (stream != NULL, FALSE);
|
||||||
|
@ -2895,3 +2897,62 @@ guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstMpdClient *cli
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
gst_mpdparser_get_nb_audio_adapt_set(GList * AdaptationSets)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
GstAdaptationSetNode *adapt_set;
|
||||||
|
guint nb_adapatation_set = 0;
|
||||||
|
gchar *this_mimeType = "audio";
|
||||||
|
gchar *mimeType = NULL;
|
||||||
|
if (AdaptationSets == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (list = g_list_first (AdaptationSets); list; list = g_list_next (list)) {
|
||||||
|
adapt_set = (GstAdaptationSetNode *) list->data;
|
||||||
|
if (adapt_set) {
|
||||||
|
GstRepresentationNode *rep;
|
||||||
|
rep =
|
||||||
|
gst_mpdparser_get_lowest_representation (adapt_set->Representations);
|
||||||
|
if (rep->RepresentationBase)
|
||||||
|
mimeType = rep->RepresentationBase->mimeType;
|
||||||
|
if (!mimeType && adapt_set->RepresentationBase) {
|
||||||
|
mimeType = adapt_set->RepresentationBase->mimeType;
|
||||||
|
}
|
||||||
|
if (strncmp_ext (mimeType, this_mimeType) == 0)
|
||||||
|
nb_adapatation_set++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nb_adapatation_set;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gst_mpdparser_get_list_of_audio_language(GList** lang, GList * AdaptationSets)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
GstAdaptationSetNode *adapt_set;
|
||||||
|
gchar *this_mimeType = "audio";
|
||||||
|
gchar *mimeType = NULL;
|
||||||
|
if (AdaptationSets == NULL)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
for (list = g_list_first (AdaptationSets); list; list = g_list_next (list)) {
|
||||||
|
adapt_set = (GstAdaptationSetNode *) list->data;
|
||||||
|
if (adapt_set) {
|
||||||
|
gchar *this_lang = adapt_set->lang;
|
||||||
|
GstRepresentationNode *rep;
|
||||||
|
rep =
|
||||||
|
gst_mpdparser_get_lowest_representation (adapt_set->Representations);
|
||||||
|
if (rep->RepresentationBase)
|
||||||
|
mimeType = rep->RepresentationBase->mimeType;
|
||||||
|
if (!mimeType && adapt_set->RepresentationBase) {
|
||||||
|
mimeType = adapt_set->RepresentationBase->mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp_ext (mimeType, this_mimeType) == 0){
|
||||||
|
if(this_lang){
|
||||||
|
*lang = g_list_append (*lang, this_lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -452,7 +452,7 @@ void gst_mpd_client_free (GstMpdClient * client);
|
||||||
|
|
||||||
/* Basic parsing */
|
/* Basic parsing */
|
||||||
gboolean gst_mpd_parse (GstMpdClient *client, const gchar *data, gint size);
|
gboolean gst_mpd_parse (GstMpdClient *client, const gchar *data, gint size);
|
||||||
gboolean gst_mpd_client_setup_streaming (GstMpdClient *client, GstStreamMimeType mimeType);
|
gboolean gst_mpd_client_setup_streaming (GstMpdClient *client, GstStreamMimeType mimeType, gchar* lang);
|
||||||
gboolean gst_mpd_client_setup_representation (GstMpdClient *client, GstActiveStream *stream, GstRepresentationNode *representation);
|
gboolean gst_mpd_client_setup_representation (GstMpdClient *client, GstActiveStream *stream, GstRepresentationNode *representation);
|
||||||
void gst_mpd_client_get_current_position (GstMpdClient *client, GstClockTime * timestamp);
|
void gst_mpd_client_get_current_position (GstMpdClient *client, GstClockTime * timestamp);
|
||||||
GstClockTime gst_mpd_client_get_duration (GstMpdClient *client);
|
GstClockTime gst_mpd_client_get_duration (GstMpdClient *client);
|
||||||
|
@ -483,6 +483,9 @@ guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client,
|
||||||
guint gst_mpd_client_get_rate_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
guint gst_mpd_client_get_rate_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
||||||
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
||||||
|
|
||||||
|
/* To support multi language */
|
||||||
|
guint gst_mpdparser_get_nb_audio_adapt_set(GList *AdaptationSets);
|
||||||
|
void gst_mpdparser_get_list_of_audio_language(GList** lang, GList * AdaptationSets);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_MPDPARSER_H__ */
|
#endif /* __GST_MPDPARSER_H__ */
|
||||||
|
|
Loading…
Reference in a new issue