Optimize the two functions that return the number and the list of languages in a single function

This commit is contained in:
hzakari 2012-10-02 02:28:58 +02:00 committed by Thiago Santos
parent fab388c9fd
commit ec44485510
3 changed files with 37 additions and 63 deletions

View file

@ -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);

View file

@ -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);
}
}
}
}
}

View file

@ -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__ */