gst_buffer_unref (demux->playlist);
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,
("Incompatible manifest file."), (NULL));
return FALSE;
}
- if (gst_mpdparser_get_nb_adaptationSet (demux->client) > 1)
- if (!gst_mpd_client_setup_streaming (demux->client, GST_STREAM_AUDIO))
- GST_INFO_OBJECT (demux, "No audio adaptation set found");
-
- if (gst_mpdparser_get_nb_adaptationSet (demux->client) > 2)
- if (!gst_mpd_client_setup_streaming (demux->client,
- GST_STREAM_APPLICATION)) {
- GST_INFO_OBJECT (demux, "No application adaptation set found");
- }
-
- demux->client->stream_idx = 0;
+ guint nb_audio =
+ gst_mpdparser_get_nb_audio_adapt_set (demux->client->
+ 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) > nb_audio)
+ if (!gst_mpd_client_setup_streaming (demux->client,
+ GST_STREAM_APPLICATION, lang)) {
+ GST_INFO_OBJECT (demux, "No application adaptation set found");
+ }
+ }
/* Send duration message */
if (!gst_mpd_client_is_live (demux->client)) {
static void
switch_pads (GstDashDemux * demux, guint nb_adaptation_set)
{
- GstPad *oldpad[3];
+ GstPad *oldpad[MAX_LANGUAGES];
guint i = 0;
while (i < nb_adaptation_set) {
oldpad[i] = demux->srcpad[i];
GstFlowReturn ret;
GstBufferList *buffer_list;
guint nb_adaptation_set = 0;
+ GstActiveStream *stream;
/* Loop for the source pad task.
*
* Startup:
guint i = 0;
for (i = 0; i < nb_adaptation_set; i++) {
GstFragment *fragment = g_list_nth_data (listfragment, i);
+ stream = gst_mpdparser_get_active_stream_by_index (demux->client, i);
if (demux->need_segment) {
GstClockTime start = fragment->start_time + demux->position_shift;
/* And send a newsegment */
buffer_list = gst_fragment_get_buffer_list (fragment);
g_object_unref (fragment);
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;
}
if (GST_STATE (demux) == GST_STATE_PLAYING) {
demux->cancelled = FALSE;
guint i = 0;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < MAX_LANGUAGES; i++)
if (demux->input_caps[i]) {
gst_caps_unref (demux->input_caps[i]);
demux->input_caps[i] = NULL;
//
typedef struct _GstDashDemux GstDashDemux;
typedef struct _GstDashDemuxClass GstDashDemuxClass;
+#define MAX_LANGUAGES 20
/**
* GstDashDemux:
*
{
GstElement parent;
GstPad *sinkpad;
- GstPad *srcpad[3]; /*Video/Audio/Application src pad*/
- GstCaps *output_caps[3]; /*Video/Audio/Application output buf caps*/
- GstCaps *input_caps[3]; /*Video/Audio/Application input caps*/
+ GstPad *srcpad[MAX_LANGUAGES]; /*Video/Audio/Application src pad*/
+ GstCaps *output_caps[MAX_LANGUAGES]; /*Video/Audio/Application output buf caps*/
+ GstCaps *input_caps[MAX_LANGUAGES]; /*Video/Audio/Application input caps*/
GstBuffer *playlist;
GstUriDownloader *downloader;
gboolean
gst_mpd_client_setup_streaming (GstMpdClient * client,
- GstStreamMimeType mimeType)
+ GstStreamMimeType mimeType, gchar* lang)
{
GstActiveStream *stream;
GstAdaptationSetNode *adapt_set;
#endif
adapt_set =
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 (!adapt_set)
adapt_set =
#endif
adapt_set =
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 (!adapt_set)
adapt_set =
g_return_val_if_fail (stream != NULL, FALSE);
return stream->cur_representation->RepresentationBase->width;
}
+
guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream){
g_return_val_if_fail (stream != NULL, FALSE);
guint gst_mpd_client_get_rate_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream){
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){
g_return_val_if_fail (stream != NULL, FALSE);
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);
+ }
+ }
+ }
+ }
+}
/* Basic parsing */
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);
void gst_mpd_client_get_current_position (GstMpdClient *client, GstClockTime * timestamp);
GstClockTime gst_mpd_client_get_duration (GstMpdClient *client);
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);
+/* 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
#endif /* __GST_MPDPARSER_H__ */