mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
dashdemux: reworked caps detection
also reworked the API to extract audio/video parameters from the manifest file (mimeType, width, height, rate, num channels)
This commit is contained in:
parent
fe05060044
commit
53f383eff0
3 changed files with 109 additions and 75 deletions
|
@ -1328,47 +1328,29 @@ gst_dash_demux_prepend_header (GstDashDemux * demux,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
|
||||||
return "video/quicktime";
|
|
||||||
} else if (strcmp (mimeType, "audio/mp4") == 0) {
|
|
||||||
return "audio/x-m4a";
|
|
||||||
} else
|
|
||||||
return mimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_dash_demux_get_video_input_caps (GstDashDemux * demux,
|
gst_dash_demux_get_video_input_caps (GstDashDemux * demux,
|
||||||
GstActiveStream * stream)
|
GstActiveStream * stream)
|
||||||
{
|
{
|
||||||
guint width, height;
|
guint width, height;
|
||||||
const gchar *mimeType;
|
const gchar *mimeType = NULL;
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstRepresentationBaseType *RepresentationBase;
|
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (stream->cur_representation->RepresentationBase) {
|
width = gst_mpd_client_get_video_stream_width (stream);
|
||||||
RepresentationBase = stream->cur_representation->RepresentationBase;
|
height = gst_mpd_client_get_video_stream_height (stream);
|
||||||
} else {
|
mimeType = gst_mpd_client_get_stream_mimeType (stream);
|
||||||
RepresentationBase = stream->cur_adapt_set->RepresentationBase;
|
if (mimeType == NULL)
|
||||||
}
|
|
||||||
if (RepresentationBase == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
width = gst_mpd_client_get_width_of_video_current_stream (RepresentationBase);
|
caps = gst_caps_new_simple (mimeType, NULL);
|
||||||
height =
|
if (width > 0 && height > 0) {
|
||||||
gst_mpd_client_get_height_of_video_current_stream (RepresentationBase);
|
gst_caps_set_simple (caps, "width", G_TYPE_INT, width, "height",
|
||||||
mimeType = gst_mpd_mimetype_to_caps (RepresentationBase->mimeType);
|
G_TYPE_INT, height, NULL);
|
||||||
caps =
|
}
|
||||||
gst_caps_new_simple (mimeType, "width", G_TYPE_INT, width, "height",
|
|
||||||
G_TYPE_INT, height, NULL);
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1379,26 +1361,24 @@ gst_dash_demux_get_audio_input_caps (GstDashDemux * demux,
|
||||||
guint rate, channels;
|
guint rate, channels;
|
||||||
const gchar *mimeType;
|
const gchar *mimeType;
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstRepresentationBaseType *RepresentationBase;
|
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (stream->cur_representation->RepresentationBase) {
|
channels = gst_mpd_client_get_audio_stream_num_channels (stream);
|
||||||
RepresentationBase = stream->cur_representation->RepresentationBase;
|
rate = gst_mpd_client_get_audio_stream_rate (stream);
|
||||||
} else {
|
mimeType = gst_mpd_client_get_stream_mimeType (stream);
|
||||||
RepresentationBase = stream->cur_adapt_set->RepresentationBase;
|
if (mimeType == NULL)
|
||||||
}
|
|
||||||
if (RepresentationBase == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
channels =
|
caps = gst_caps_new_simple (mimeType, NULL);
|
||||||
gst_mpd_client_get_num_channels_of_audio_current_stream
|
if (rate > 0) {
|
||||||
(RepresentationBase);
|
gst_caps_set_simple (caps, "rate", G_TYPE_INT, rate, NULL);
|
||||||
rate = gst_mpd_client_get_rate_of_audio_current_stream (RepresentationBase);
|
}
|
||||||
mimeType = gst_mpd_mimetype_to_caps (RepresentationBase->mimeType);
|
if (channels > 0) {
|
||||||
caps =
|
gst_caps_set_simple (caps, "channels", G_TYPE_INT, channels, NULL);
|
||||||
gst_caps_new_simple (mimeType, "channels", G_TYPE_INT, channels, "rate",
|
}
|
||||||
G_TYPE_INT, rate, NULL);
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1408,20 +1388,16 @@ gst_dash_demux_get_application_input_caps (GstDashDemux * demux,
|
||||||
{
|
{
|
||||||
const gchar *mimeType;
|
const gchar *mimeType;
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstRepresentationBaseType *RepresentationBase;
|
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (stream->cur_representation->RepresentationBase) {
|
mimeType = gst_mpd_client_get_stream_mimeType (stream);
|
||||||
RepresentationBase = stream->cur_representation->RepresentationBase;
|
if (mimeType == NULL)
|
||||||
} else {
|
|
||||||
RepresentationBase = stream->cur_adapt_set->RepresentationBase;
|
|
||||||
}
|
|
||||||
if (RepresentationBase == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
mimeType = gst_mpd_mimetype_to_caps (RepresentationBase->mimeType);
|
|
||||||
caps = gst_caps_new_simple (mimeType, NULL);
|
caps = gst_caps_new_simple (mimeType, NULL);
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ static gchar *gst_mpdparser_get_mediaURL (GstSegmentURLNode *segmentURL);
|
||||||
static gchar *gst_mpdparser_get_initializationURL (GstURLType *InitializationURL);
|
static gchar *gst_mpdparser_get_initializationURL (GstURLType *InitializationURL);
|
||||||
static gchar *gst_mpdparser_build_URL_from_template (const gchar *url_template, const gchar *id, guint number, guint bandwidth, guint time);
|
static gchar *gst_mpdparser_build_URL_from_template (const gchar *url_template, const gchar *id, guint number, guint bandwidth, guint time);
|
||||||
static gboolean gst_mpd_client_add_media_segment (GstActiveStream *stream, GstSegmentURLNode *url_node, guint number, guint start, GstClockTime start_time, GstClockTime duration);
|
static gboolean gst_mpd_client_add_media_segment (GstActiveStream *stream, GstSegmentURLNode *url_node, guint number, guint start, GstClockTime start_time, GstClockTime duration);
|
||||||
|
static const gchar *gst_mpdparser_mimetype_to_caps (const gchar * mimeType);
|
||||||
|
|
||||||
/* Period */
|
/* Period */
|
||||||
static GstPeriodNode *gst_mpdparser_get_next_period (GList *Periods, GstPeriodNode *prev_period);
|
static GstPeriodNode *gst_mpdparser_get_next_period (GList *Periods, GstPeriodNode *prev_period);
|
||||||
|
@ -2736,7 +2737,7 @@ gst_mpd_client_setup_streaming (GstMpdClient * client,
|
||||||
gst_mpdparser_get_first_adapt_set_with_mimeType (client->
|
gst_mpdparser_get_first_adapt_set_with_mimeType (client->
|
||||||
cur_period->AdaptationSets, "audio");
|
cur_period->AdaptationSets, "audio");
|
||||||
if (!adapt_set) {
|
if (!adapt_set) {
|
||||||
GST_INFO ("No audio adaptation set found, aborting...");
|
GST_INFO ("No audio adaptation set found");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
rep_list = adapt_set->Representations;
|
rep_list = adapt_set->Representations;
|
||||||
|
@ -2761,7 +2762,7 @@ gst_mpd_client_setup_streaming (GstMpdClient * client,
|
||||||
gst_mpdparser_get_first_adapt_set_with_mimeType (client->
|
gst_mpdparser_get_first_adapt_set_with_mimeType (client->
|
||||||
cur_period->AdaptationSets, "application");
|
cur_period->AdaptationSets, "application");
|
||||||
if (!adapt_set) {
|
if (!adapt_set) {
|
||||||
GST_INFO ("No application adaptation set found, aborting...");
|
GST_INFO ("No application adaptation set found");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
rep_list = adapt_set->Representations;
|
rep_list = adapt_set->Representations;
|
||||||
|
@ -3011,29 +3012,87 @@ GstActiveStream *gst_mpdparser_get_active_stream_by_index (GstMpdClient *client,
|
||||||
stream_idx);
|
stream_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint gst_mpd_client_get_width_of_video_current_stream (GstRepresentationBaseType *RepresentationBase)
|
static const gchar *
|
||||||
|
gst_mpdparser_mimetype_to_caps (const gchar * mimeType)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (RepresentationBase != NULL, 0);
|
if (mimeType == NULL)
|
||||||
return RepresentationBase->width;
|
return NULL;
|
||||||
|
if (strcmp (mimeType, "video/mp2t") == 0) {
|
||||||
|
return "video/mpegts";
|
||||||
|
} else if (strcmp (mimeType, "video/mp4") == 0) {
|
||||||
|
return "video/quicktime";
|
||||||
|
} else if (strcmp (mimeType, "audio/mp4") == 0) {
|
||||||
|
return "audio/x-m4a";
|
||||||
|
} else
|
||||||
|
return mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint gst_mpd_client_get_height_of_video_current_stream (GstRepresentationBaseType *RepresentationBase)
|
const gchar *gst_mpd_client_get_stream_mimeType (GstActiveStream * stream)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (RepresentationBase != NULL, 0);
|
const gchar *mimeType;
|
||||||
return RepresentationBase->height;
|
|
||||||
|
if (stream == NULL || stream->cur_adapt_set == NULL || stream->cur_representation == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
mimeType = stream->cur_representation->RepresentationBase->mimeType;
|
||||||
|
if (mimeType == NULL) {
|
||||||
|
mimeType = stream->cur_adapt_set->RepresentationBase->mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gst_mpdparser_mimetype_to_caps (mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint gst_mpd_client_get_rate_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase)
|
guint gst_mpd_client_get_video_stream_width (GstActiveStream * stream)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (RepresentationBase != NULL, 0);
|
guint width;
|
||||||
return (guint) RepresentationBase->audioSamplingRate;
|
|
||||||
|
if (stream == NULL || stream->cur_adapt_set == NULL || stream->cur_representation == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
width = stream->cur_representation->RepresentationBase->width;
|
||||||
|
if (width == 0) {
|
||||||
|
width = stream->cur_adapt_set->RepresentationBase->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase)
|
guint gst_mpd_client_get_video_stream_height (GstActiveStream * stream)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (RepresentationBase != NULL, 0);
|
guint height;
|
||||||
/* TODO*/
|
|
||||||
return 1;
|
if (stream == NULL || stream->cur_adapt_set == NULL || stream->cur_representation == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
height = stream->cur_representation->RepresentationBase->height;
|
||||||
|
if (height == 0) {
|
||||||
|
height = stream->cur_adapt_set->RepresentationBase->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint gst_mpd_client_get_audio_stream_rate (GstActiveStream * stream)
|
||||||
|
{
|
||||||
|
const gchar *rate;
|
||||||
|
|
||||||
|
if (stream == NULL || stream->cur_adapt_set == NULL || stream->cur_representation == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
rate = stream->cur_representation->RepresentationBase->audioSamplingRate;
|
||||||
|
if (rate == NULL) {
|
||||||
|
rate = stream->cur_adapt_set->RepresentationBase->audioSamplingRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rate ? atoi (rate) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint gst_mpd_client_get_audio_stream_num_channels (GstActiveStream * stream)
|
||||||
|
{
|
||||||
|
if (stream == NULL || stream->cur_adapt_set == NULL || stream->cur_representation == NULL)
|
||||||
|
return 0;
|
||||||
|
/* TODO: here we have to parse the AudioChannelConfiguration descriptors */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
|
|
|
@ -468,13 +468,12 @@ GstActiveStream *gst_mpdparser_get_active_stream_by_index (GstMpdClient *client,
|
||||||
/* AdaptationSet */
|
/* AdaptationSet */
|
||||||
guint gst_mpdparser_get_nb_adaptationSet(GstMpdClient *client);
|
guint gst_mpdparser_get_nb_adaptationSet(GstMpdClient *client);
|
||||||
|
|
||||||
/* Get With and high of video parameter by stream */
|
/* Get audio/video stream parameters (mimeType, width, height, rate, number of channels) */
|
||||||
guint gst_mpd_client_get_width_of_video_current_stream (GstRepresentationBaseType *RepresentationBase);
|
const gchar *gst_mpd_client_get_stream_mimeType (GstActiveStream * stream);
|
||||||
guint gst_mpd_client_get_height_of_video_current_stream (GstRepresentationBaseType *RepresentationBase);
|
guint gst_mpd_client_get_video_stream_width (GstActiveStream * stream);
|
||||||
|
guint gst_mpd_client_get_video_stream_height (GstActiveStream * stream);
|
||||||
/* Get channel and rate of audio parameter by stream */
|
guint gst_mpd_client_get_audio_stream_rate (GstActiveStream * stream);
|
||||||
guint gst_mpd_client_get_rate_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase);
|
guint gst_mpd_client_get_audio_stream_num_channels (GstActiveStream * stream);
|
||||||
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstRepresentationBaseType *RepresentationBase);
|
|
||||||
|
|
||||||
/* Support multi language */
|
/* Support multi language */
|
||||||
guint gst_mpdparser_get_list_and_nb_of_audio_language(GList **lang, GList *AdaptationSets);
|
guint gst_mpdparser_get_list_and_nb_of_audio_language(GList **lang, GList *AdaptationSets);
|
||||||
|
|
Loading…
Reference in a new issue