mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 10:10:32 +00:00
mpdparser: Be consistent about returning duplicated URL
Instead of returning a "const gchar" or a "gchar" that should not be freed, always return a duplicated string as those functions were used together with g_strdup anyway. This is needed to prepare support for returning modified strings in next commit. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1147>
This commit is contained in:
parent
0d79dbedf3
commit
548bbc3147
6 changed files with 46 additions and 32 deletions
|
@ -2041,9 +2041,7 @@ gst_mpd_client_get_next_fragment (GstMPDClient * client,
|
|||
|
||||
GST_DEBUG ("currentChunk->SegmentURL = %p", currentChunk->SegmentURL);
|
||||
if (currentChunk->SegmentURL != NULL) {
|
||||
mediaURL =
|
||||
g_strdup (gst_mpdparser_get_mediaURL (stream,
|
||||
currentChunk->SegmentURL));
|
||||
mediaURL = gst_mpdparser_get_mediaURL (stream, currentChunk->SegmentURL);
|
||||
indexURL = g_strdup (currentChunk->SegmentURL->index);
|
||||
} else if (stream->cur_seg_template != NULL) {
|
||||
mediaURL =
|
||||
|
@ -2315,9 +2313,8 @@ gst_mpd_client_get_next_header (GstMPDClient * client, gchar ** uri,
|
|||
*uri = NULL;
|
||||
if (stream->cur_segment_base) {
|
||||
if (stream->cur_segment_base->Initialization) {
|
||||
*uri =
|
||||
g_strdup (gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization));
|
||||
*uri = gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization);
|
||||
if (stream->cur_segment_base->Initialization->range) {
|
||||
*range_start =
|
||||
stream->cur_segment_base->Initialization->range->first_byte_pos;
|
||||
|
@ -2325,9 +2322,8 @@ gst_mpd_client_get_next_header (GstMPDClient * client, gchar ** uri,
|
|||
stream->cur_segment_base->Initialization->range->last_byte_pos;
|
||||
}
|
||||
} else if (stream->cur_segment_base->indexRange) {
|
||||
*uri =
|
||||
g_strdup (gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization));
|
||||
*uri = gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization);
|
||||
*range_start = 0;
|
||||
*range_end = stream->cur_segment_base->indexRange->first_byte_pos - 1;
|
||||
}
|
||||
|
@ -2362,9 +2358,8 @@ gst_mpd_client_get_next_header_index (GstMPDClient * client, gchar ** uri,
|
|||
GST_DEBUG ("Looking for current representation index");
|
||||
*uri = NULL;
|
||||
if (stream->cur_segment_base && stream->cur_segment_base->indexRange) {
|
||||
*uri =
|
||||
g_strdup (gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->RepresentationIndex));
|
||||
*uri = gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->RepresentationIndex);
|
||||
*range_start = stream->cur_segment_base->indexRange->first_byte_pos;
|
||||
*range_end = stream->cur_segment_base->indexRange->last_byte_pos;
|
||||
} else if (stream->cur_seg_template && stream->cur_seg_template->index) {
|
||||
|
|
|
@ -1366,7 +1366,13 @@ gst_mpdparser_free_active_stream (GstActiveStream * active_stream)
|
|||
}
|
||||
}
|
||||
|
||||
const gchar *
|
||||
/*
|
||||
* gst_mpdparser_get_initializationURL:
|
||||
*
|
||||
* Returns: (transfer full): stream initializationURL if available,
|
||||
* baseURL otherwise.
|
||||
*/
|
||||
gchar *
|
||||
gst_mpdparser_get_initializationURL (GstActiveStream * stream,
|
||||
GstMPDURLTypeNode * InitializationURL)
|
||||
{
|
||||
|
@ -1378,9 +1384,15 @@ gst_mpdparser_get_initializationURL (GstActiveStream * stream,
|
|||
&& InitializationURL->sourceURL) ? InitializationURL->sourceURL : stream->
|
||||
baseURL;
|
||||
|
||||
return url_prefix;
|
||||
return g_strdup (url_prefix);
|
||||
}
|
||||
|
||||
/*
|
||||
* gst_mpdparser_get_mediaURL:
|
||||
*
|
||||
* Returns: (transfer full): stream mediaURL if available,
|
||||
* baseURL otherwise.
|
||||
*/
|
||||
gchar *
|
||||
gst_mpdparser_get_mediaURL (GstActiveStream * stream,
|
||||
GstMPDSegmentURLNode * segmentURL)
|
||||
|
@ -1393,7 +1405,7 @@ gst_mpdparser_get_mediaURL (GstActiveStream * stream,
|
|||
url_prefix = segmentURL->media ? segmentURL->media : stream->baseURL;
|
||||
g_return_val_if_fail (url_prefix != NULL, NULL);
|
||||
|
||||
return url_prefix;
|
||||
return g_strdup (url_prefix);
|
||||
}
|
||||
|
||||
/* navigation functions */
|
||||
|
|
|
@ -162,7 +162,7 @@ void gst_mpdparser_media_fragment_info_clear (GstMediaFragmentInfo * fragment);
|
|||
/* Active stream methods*/
|
||||
void gst_mpdparser_init_active_stream_segments (GstActiveStream * stream);
|
||||
gchar *gst_mpdparser_get_mediaURL (GstActiveStream * stream, GstMPDSegmentURLNode * segmentURL);
|
||||
const gchar *gst_mpdparser_get_initializationURL (GstActiveStream * stream, GstMPDURLTypeNode * InitializationURL);
|
||||
gchar *gst_mpdparser_get_initializationURL (GstActiveStream * stream, GstMPDURLTypeNode * InitializationURL);
|
||||
gchar *gst_mpdparser_build_URL_from_template (const gchar * url_template, const gchar * id, guint number, guint bandwidth, guint64 time);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -2045,9 +2045,7 @@ gst_mpd_client2_get_next_fragment (GstMPDClient2 * client,
|
|||
|
||||
GST_DEBUG ("currentChunk->SegmentURL = %p", currentChunk->SegmentURL);
|
||||
if (currentChunk->SegmentURL != NULL) {
|
||||
mediaURL =
|
||||
g_strdup (gst_mpdparser_get_mediaURL (stream,
|
||||
currentChunk->SegmentURL));
|
||||
mediaURL = gst_mpdparser_get_mediaURL (stream, currentChunk->SegmentURL);
|
||||
indexURL = g_strdup (currentChunk->SegmentURL->index);
|
||||
} else if (stream->cur_seg_template != NULL) {
|
||||
mediaURL =
|
||||
|
@ -2320,9 +2318,8 @@ gst_mpd_client2_get_next_header (GstMPDClient2 * client, gchar ** uri,
|
|||
*uri = NULL;
|
||||
if (stream->cur_segment_base) {
|
||||
if (stream->cur_segment_base->Initialization) {
|
||||
*uri =
|
||||
g_strdup (gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization));
|
||||
*uri = gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization);
|
||||
if (stream->cur_segment_base->Initialization->range) {
|
||||
*range_start =
|
||||
stream->cur_segment_base->Initialization->range->first_byte_pos;
|
||||
|
@ -2330,9 +2327,8 @@ gst_mpd_client2_get_next_header (GstMPDClient2 * client, gchar ** uri,
|
|||
stream->cur_segment_base->Initialization->range->last_byte_pos;
|
||||
}
|
||||
} else if (stream->cur_segment_base->indexRange) {
|
||||
*uri =
|
||||
g_strdup (gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization));
|
||||
*uri = gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->Initialization);
|
||||
*range_start = 0;
|
||||
*range_end = stream->cur_segment_base->indexRange->first_byte_pos - 1;
|
||||
}
|
||||
|
@ -2367,9 +2363,8 @@ gst_mpd_client2_get_next_header_index (GstMPDClient2 * client, gchar ** uri,
|
|||
GST_DEBUG ("Looking for current representation index");
|
||||
*uri = NULL;
|
||||
if (stream->cur_segment_base && stream->cur_segment_base->indexRange) {
|
||||
*uri =
|
||||
g_strdup (gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->RepresentationIndex));
|
||||
*uri = gst_mpdparser_get_initializationURL (stream,
|
||||
stream->cur_segment_base->RepresentationIndex);
|
||||
*range_start = stream->cur_segment_base->indexRange->first_byte_pos;
|
||||
*range_end = stream->cur_segment_base->indexRange->last_byte_pos;
|
||||
} else if (stream->cur_seg_template && stream->cur_seg_template->index) {
|
||||
|
|
|
@ -1397,7 +1397,13 @@ gst_mpdparser_free_active_stream (GstActiveStream * active_stream)
|
|||
}
|
||||
}
|
||||
|
||||
const gchar *
|
||||
/*
|
||||
* gst_mpdparser_get_initializationURL:
|
||||
*
|
||||
* Returns: (transfer full): stream initializationURL if available,
|
||||
* baseURL otherwise.
|
||||
*/
|
||||
gchar *
|
||||
gst_mpdparser_get_initializationURL (GstActiveStream * stream,
|
||||
GstMPDURLTypeNode * InitializationURL)
|
||||
{
|
||||
|
@ -1409,9 +1415,15 @@ gst_mpdparser_get_initializationURL (GstActiveStream * stream,
|
|||
&& InitializationURL->sourceURL) ? InitializationURL->sourceURL : stream->
|
||||
baseURL;
|
||||
|
||||
return url_prefix;
|
||||
return g_strdup (url_prefix);
|
||||
}
|
||||
|
||||
/*
|
||||
* gst_mpdparser_get_mediaURL:
|
||||
*
|
||||
* Returns: (transfer full): stream mediaURL if available,
|
||||
* baseURL otherwise.
|
||||
*/
|
||||
gchar *
|
||||
gst_mpdparser_get_mediaURL (GstActiveStream * stream,
|
||||
GstMPDSegmentURLNode * segmentURL)
|
||||
|
@ -1424,7 +1436,7 @@ gst_mpdparser_get_mediaURL (GstActiveStream * stream,
|
|||
url_prefix = segmentURL->media ? segmentURL->media : stream->baseURL;
|
||||
g_return_val_if_fail (url_prefix != NULL, NULL);
|
||||
|
||||
return url_prefix;
|
||||
return g_strdup (url_prefix);
|
||||
}
|
||||
|
||||
/* navigation functions */
|
||||
|
|
|
@ -165,7 +165,7 @@ void gst_mpdparser_media_fragment_info_clear (GstMediaFragmentInfo * fragment);
|
|||
/* Active stream methods*/
|
||||
void gst_mpdparser_init_active_stream_segments (GstActiveStream * stream);
|
||||
gchar *gst_mpdparser_get_mediaURL (GstActiveStream * stream, GstMPDSegmentURLNode * segmentURL);
|
||||
const gchar *gst_mpdparser_get_initializationURL (GstActiveStream * stream, GstMPDURLTypeNode * InitializationURL);
|
||||
gchar *gst_mpdparser_get_initializationURL (GstActiveStream * stream, GstMPDURLTypeNode * InitializationURL);
|
||||
gchar *gst_mpdparser_build_URL_from_template (const gchar * url_template, const gchar * id, guint number, guint bandwidth, guint64 time);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Reference in a new issue