mpdparser/dashdemux: fixed get_width, get_height, get_audio_rate, get_num_audio_channels API functions

the actual values now can be extracted also from the AdaptationSet element;
checking NULL structs for better robustness;
This commit is contained in:
Gianluca Gennari 2012-10-08 17:43:14 +02:00 committed by Thiago Santos
parent 98a41f2c9e
commit 375634f669
3 changed files with 67 additions and 37 deletions

View file

@ -1175,6 +1175,8 @@ gst_dash_demux_prepend_header (GstDashDemux * demux,
const gchar *
gst_mpd_mimetype_to_caps (const gchar * mimeType)
{
if (mimeType == NULL)
return NULL;
if (strcmp (mimeType, "video/mp2t") == 0) {
return "video/mpegts";
} else if (strcmp (mimeType, "video/mp4") == 0) {
@ -1192,17 +1194,24 @@ gst_dash_demux_get_video_input_caps (GstDashDemux * demux,
guint width, height;
const gchar *mimeType;
GstCaps *caps = NULL;
GstRepresentationBaseType *RepresentationBase;
if (stream == NULL)
return NULL;
width =
gst_mpd_client_get_width_of_video_current_stream (demux->client, stream);
height =
gst_mpd_client_get_height_of_video_current_stream (demux->client, stream);
if (!stream->cur_representation->RepresentationBase->mimeType)
if (stream->cur_representation->RepresentationBase) {
RepresentationBase = stream->cur_representation->RepresentationBase;
} else {
RepresentationBase = stream->cur_adapt_set->RepresentationBase;
}
if (RepresentationBase == NULL)
return NULL;
width =
gst_mpd_client_get_width_of_video_current_stream (RepresentationBase);
height =
gst_mpd_client_get_height_of_video_current_stream (RepresentationBase);
mimeType =
gst_mpd_mimetype_to_caps (stream->cur_representation->
RepresentationBase->mimeType);
gst_mpd_mimetype_to_caps (RepresentationBase->mimeType);
caps =
gst_caps_new_simple (mimeType, "width", G_TYPE_INT, width, "height",
G_TYPE_INT, height, NULL);
@ -1216,14 +1225,24 @@ gst_dash_demux_get_audio_input_caps (GstDashDemux * demux,
guint rate, channels;
const gchar *mimeType;
GstCaps *caps = NULL;
GstRepresentationBaseType *RepresentationBase;
if (stream == NULL)
return NULL;
if (stream->cur_representation->RepresentationBase) {
RepresentationBase = stream->cur_representation->RepresentationBase;
} else {
RepresentationBase = stream->cur_adapt_set->RepresentationBase;
}
if (RepresentationBase == NULL)
return NULL;
channels =
gst_mpd_client_get_num_channels_of_audio_current_stream (demux->client,
stream);
gst_mpd_client_get_num_channels_of_audio_current_stream (RepresentationBase);
rate =
gst_mpd_client_get_rate_of_audio_current_stream (demux->client, stream);
gst_mpd_client_get_rate_of_audio_current_stream (RepresentationBase);
mimeType =
gst_mpd_mimetype_to_caps (stream->cur_representation->
RepresentationBase->mimeType);
gst_mpd_mimetype_to_caps (RepresentationBase->mimeType);
caps =
gst_caps_new_simple (mimeType, "channels", G_TYPE_INT, channels, "rate",
G_TYPE_INT, rate, NULL);
@ -1236,9 +1255,20 @@ gst_dash_demux_get_application_input_caps (GstDashDemux * demux,
{
const gchar *mimeType;
GstCaps *caps = NULL;
GstRepresentationBaseType *RepresentationBase;
if (stream == NULL)
return NULL;
if (stream->cur_representation->RepresentationBase) {
RepresentationBase = stream->cur_representation->RepresentationBase;
} else {
RepresentationBase = stream->cur_adapt_set->RepresentationBase;
}
if (RepresentationBase == NULL)
return NULL;
mimeType =
gst_mpd_mimetype_to_caps (stream->cur_representation->
RepresentationBase->mimeType);
gst_mpd_mimetype_to_caps (RepresentationBase->mimeType);
caps = gst_caps_new_simple (mimeType, NULL);
return caps;
}

View file

@ -2884,43 +2884,43 @@ guint gst_mpdparser_get_nb_active_stream (GstMpdClient *client){
return g_list_length (client->active_streams);
}
guint gst_mpdparser_get_nb_adaptationSet(GstMpdClient *client){
guint gst_mpdparser_get_nb_adaptationSet(GstMpdClient *client)
{
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (client->cur_period != NULL, FALSE);
g_return_val_if_fail (client->cur_period->AdaptationSets != NULL, FALSE);
return g_list_length (client->cur_period->AdaptationSets);
}
GstActiveStream *gst_mpdparser_get_active_stream_by_index (GstMpdClient *client, gint stream_idx){
GstActiveStream *gst_mpdparser_get_active_stream_by_index (GstMpdClient *client, gint stream_idx)
{
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (client->active_streams != NULL, FALSE);
return g_list_nth_data (client->active_streams,
stream_idx);
}
guint gst_mpd_client_get_width_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream){
g_return_val_if_fail (stream != NULL, FALSE);
return stream->cur_representation->RepresentationBase->width;
guint gst_mpd_client_get_width_of_video_current_stream (GstRepresentationBaseType *RepresentationBase)
{
g_return_val_if_fail (RepresentationBase != NULL, 0);
return RepresentationBase->width;
}
guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream){
g_return_val_if_fail (stream != NULL, FALSE);
return stream->cur_representation->RepresentationBase->height;
guint gst_mpd_client_get_height_of_video_current_stream (GstRepresentationBaseType *RepresentationBase)
{
g_return_val_if_fail (RepresentationBase != NULL, 0);
return RepresentationBase->height;
}
guint gst_mpd_client_get_rate_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream){
g_return_val_if_fail (stream != NULL, FALSE);
return (guint) stream->cur_representation->RepresentationBase->audioSamplingRate;
guint gst_mpd_client_get_rate_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase)
{
g_return_val_if_fail (RepresentationBase != NULL, 0);
return (guint) 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);
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase)
{
g_return_val_if_fail (RepresentationBase != NULL, 0);
/* TODO*/
return 1;
}

View file

@ -468,12 +468,12 @@ GstActiveStream *gst_mpdparser_get_active_stream_by_index (GstMpdClient *client,
guint gst_mpdparser_get_nb_adaptationSet(GstMpdClient *client);
/* Get With and high of video parameter by stream */
guint gst_mpd_client_get_width_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream);
guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream);
guint gst_mpd_client_get_width_of_video_current_stream (GstRepresentationBaseType *RepresentationBase);
guint gst_mpd_client_get_height_of_video_current_stream (GstRepresentationBaseType *RepresentationBase);
/* Get channel and rate of audio parameter by 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_rate_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase);
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase);
/* Support multi language */
guint gst_mpdparser_get_list_and_nb_of_audio_language(GList **lang, GList *AdaptationSets);