mpdparser: added support for single-segment streams with the URL encoded in the baseURL syntax element

This commit is contained in:
Gianluca Gennari 2012-10-08 16:59:21 +02:00 committed by Thiago Santos
parent 779bf29879
commit 98a41f2c9e
2 changed files with 42 additions and 29 deletions

View file

@ -1119,7 +1119,7 @@ gst_dash_demux_get_next_header (GstDashDemux * demux, guint stream_idx)
if (!gst_mpd_client_get_next_header (demux->client, &initializationURL, if (!gst_mpd_client_get_next_header (demux->client, &initializationURL,
stream_idx)) stream_idx))
return FALSE; return NULL;
if (strncmp (initializationURL, "http://", 7) != 0) { if (strncmp (initializationURL, "http://", 7) != 0) {
next_header_uri = next_header_uri =
@ -1336,15 +1336,14 @@ gst_dash_demux_get_next_fragment (GstDashDemux * demux, gboolean caching)
/* We need to fetch a new header */ /* We need to fetch a new header */
if ((header = gst_dash_demux_get_next_header (demux, stream_idx)) == NULL) { if ((header = gst_dash_demux_get_next_header (demux, stream_idx)) == NULL) {
GST_INFO_OBJECT (demux, "Unable to fetch header"); GST_INFO_OBJECT (demux, "Unable to fetch header");
return FALSE; } else {
/* Replace fragment with a new one including the header */
GstFragment *new_fragment =
gst_dash_demux_prepend_header (demux, download, header);
g_object_unref (header);
g_object_unref (download);
download = new_fragment;
} }
/* Replace fragment with a new one including the header */
GstFragment *new_fragment =
gst_dash_demux_prepend_header (demux, download, header);
g_object_unref (header);
g_object_unref (download);
download = new_fragment;
} else } else
gst_caps_unref (caps); gst_caps_unref (caps);

View file

@ -2534,29 +2534,37 @@ gst_mpd_client_setup_representation (GstMpdClient * client, GstActiveStream *str
} }
if (stream->cur_seg_template == NULL || stream->cur_seg_template->MultSegBaseType == NULL) { if (stream->cur_seg_template == NULL || stream->cur_seg_template->MultSegBaseType == NULL) {
GST_WARNING ("Can not parse segment informations from MPD file due to incompatible syntax, aborting..."); /* here we should have a single segment for each representation, whose URL is encoded in the baseURL element */
return FALSE;
}
/* build segment list */
i = stream->cur_seg_template->MultSegBaseType->startNumber;
start_time = 0;
duration = gst_mpd_client_get_target_duration (client);
GST_LOG ("using template %s", stream->cur_seg_template->media);
while (PeriodStart + start_time < PeriodEnd) {
media_segment = g_slice_new0 (GstMediaSegment); media_segment = g_slice_new0 (GstMediaSegment);
if (media_segment == NULL) { if (media_segment == NULL) {
GST_WARNING ("Allocation of GstMediaSegment struct failed!"); GST_WARNING ("Allocation of GstMediaSegment struct failed!");
return FALSE; return FALSE;
} }
stream->segments = g_list_append (stream->segments, media_segment); stream->segments = g_list_append (stream->segments, media_segment);
/* TODO: support SegmentTimeline */ media_segment->number = 1;
media_segment->number = i; media_segment->start_time = 0;
media_segment->start_time = start_time; media_segment->duration = PeriodEnd;
media_segment->duration = duration; } else {
i++; /* build segment list */
start_time += duration; i = stream->cur_seg_template->MultSegBaseType->startNumber;
start_time = 0;
duration = gst_mpd_client_get_target_duration (client);
GST_LOG ("using template %s", stream->cur_seg_template->media);
while (PeriodStart + start_time < PeriodEnd) {
media_segment = g_slice_new0 (GstMediaSegment);
if (media_segment == NULL) {
GST_WARNING ("Allocation of GstMediaSegment struct failed!");
return FALSE;
}
stream->segments = g_list_append (stream->segments, media_segment);
/* TODO: support SegmentTimeline */
media_segment->number = i;
media_segment->start_time = start_time;
media_segment->duration = duration;
i++;
start_time += duration;
}
} }
} }
@ -2748,10 +2756,14 @@ gst_mpd_client_get_next_fragment (GstMpdClient * client,
mediaURL = gst_mpdparser_build_URL_from_template (stream->cur_seg_template->media, mediaURL = gst_mpdparser_build_URL_from_template (stream->cur_seg_template->media,
stream->cur_representation->id, currentChunk->number, stream->cur_representation->bandwidth, 0); stream->cur_representation->id, currentChunk->number, stream->cur_representation->bandwidth, 0);
} }
gst_mpd_client_get_current_position (client, timestamp); gst_mpd_client_get_current_position (client, timestamp);
*discontinuity = stream->segment_idx != currentChunk->number; *discontinuity = stream->segment_idx != currentChunk->number;
stream->segment_idx += 1; stream->segment_idx += 1;
if (strncmp (mediaURL, "http://", 7) != 0) { if (mediaURL == NULL) {
/* single segment with URL encoded in the baseURL syntax element */
*uri = g_strdup (gst_mpdparser_get_baseURL (client));
} else if (strncmp (mediaURL, "http://", 7) != 0) {
*uri = g_strconcat (gst_mpdparser_get_baseURL (client), mediaURL, NULL); *uri = g_strconcat (gst_mpdparser_get_baseURL (client), mediaURL, NULL);
g_free (mediaURL); g_free (mediaURL);
} else { } else {
@ -2847,8 +2859,10 @@ gst_mpd_client_get_target_duration (GstMpdClient * client)
base = stream->cur_seg_template->MultSegBaseType; base = stream->cur_seg_template->MultSegBaseType;
} }
g_return_val_if_fail (base != NULL, GST_CLOCK_TIME_NONE); if (base == NULL || base->SegBaseType == NULL) {
g_return_val_if_fail (base->SegBaseType != NULL, GST_CLOCK_TIME_NONE); return GST_CLOCK_TIME_NONE;
}
duration = base->duration * GST_SECOND; duration = base->duration * GST_SECOND;
timescale = base->SegBaseType->timescale; timescale = base->SegBaseType->timescale;