From ec44485510a1a36339623cb5dd376055a2375128 Mon Sep 17 00:00:00 2001 From: hzakari Date: Tue, 2 Oct 2012 02:28:58 +0200 Subject: [PATCH] Optimize the two functions that return the number and the list of languages in a single function --- ext/dash/gstdashdemux.c | 10 ++--- ext/dash/gstmpdparser.c | 85 +++++++++++++++-------------------------- ext/dash/gstmpdparser.h | 5 +-- 3 files changed, 37 insertions(+), 63 deletions(-) diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index 5400d35159..12bacc563e 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -540,15 +540,13 @@ gst_dash_demux_sink_event (GstPad * pad, GstEvent * event) return FALSE; } + GList *listLang = NULL; 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); + gst_mpdparser_get_list_and_nb_of_audio_language (&listLang, + demux->client->cur_period->AdaptationSets); if (nb_audio == 0) nb_audio = 1; - GList *listLang = NULL; - gst_mpdparser_get_list_of_audio_language (&listLang, - demux->client->cur_period->AdaptationSets); + GST_INFO_OBJECT (demux, "Number of language is=%d", nb_audio); guint i = 0; for (i = 0; i < nb_audio; i++) { gchar *lang = (gchar *) g_list_nth_data (listLang, i); diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index aec00b0c6b..2fbed40759 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -2898,61 +2898,38 @@ guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstMpdClient *cli } guint -gst_mpdparser_get_nb_audio_adapt_set(GList * AdaptationSets) +gst_mpdparser_get_list_and_nb_of_audio_language (GList **lang, + GList *AdaptationSets) { - GList *list; - GstAdaptationSetNode *adapt_set; - guint nb_adapatation_set = 0; - gchar *this_mimeType = "audio"; - gchar *mimeType = NULL; - if (AdaptationSets == NULL) - return 0; + GList *list; + GstAdaptationSetNode *adapt_set; + gchar *this_mimeType = "audio"; + gchar *mimeType = NULL; + guint nb_adapatation_set = 0; + if (AdaptationSets == NULL) + return; - 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; + 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) { + nb_adapatation_set++; + *lang = g_list_append (*lang, this_lang); + } + } + } + } + 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); - } - } - } - } -} diff --git a/ext/dash/gstmpdparser.h b/ext/dash/gstmpdparser.h index 0dc1dd878f..e1bd5c4a62 100644 --- a/ext/dash/gstmpdparser.h +++ b/ext/dash/gstmpdparser.h @@ -483,9 +483,8 @@ 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_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); +/* Support multi language */ +guint gst_mpdparser_get_list_and_nb_of_audio_language(GList **lang, GList *AdaptationSets); G_END_DECLS #endif /* __GST_MPDPARSER_H__ */