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>
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 =
*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;
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;
}
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) {
}
}
-const gchar *
+/*
+ * gst_mpdparser_get_initializationURL:
+ *
+ * Returns: (transfer full): stream initializationURL if available,
+ * baseURL otherwise.
+ */
+gchar *
gst_mpdparser_get_initializationURL (GstActiveStream * stream,
GstMPDURLTypeNode * InitializationURL)
{
&& 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)
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 */
/* 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
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 =
*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;
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;
}
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) {
}
}
-const gchar *
+/*
+ * gst_mpdparser_get_initializationURL:
+ *
+ * Returns: (transfer full): stream initializationURL if available,
+ * baseURL otherwise.
+ */
+gchar *
gst_mpdparser_get_initializationURL (GstActiveStream * stream,
GstMPDURLTypeNode * InitializationURL)
{
&& 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)
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 */
/* 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