mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-01 03:52:25 +00:00
uridownloader: when possible, reuse existing element to download a new URI
previously a new element was allocated for each media segment, and it was never freed
This commit is contained in:
parent
5b830c3c91
commit
122f10669f
1 changed files with 10 additions and 4 deletions
|
@ -273,10 +273,16 @@ gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri)
|
||||||
if (!gst_uri_is_valid (uri))
|
if (!gst_uri_is_valid (uri))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (downloader->priv->urisrc == NULL) {
|
||||||
GST_DEBUG_OBJECT (downloader, "Creating source element for the URI:%s", uri);
|
GST_DEBUG_OBJECT (downloader, "Creating source element for the URI:%s", uri);
|
||||||
downloader->priv->urisrc = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
|
downloader->priv->urisrc = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
|
||||||
if (!downloader->priv->urisrc)
|
if (!downloader->priv->urisrc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
GST_DEBUG_OBJECT (downloader, "Reusing existing source element for the URI:%s", uri);
|
||||||
|
if (!gst_uri_handler_set_uri (GST_URI_HANDLER (downloader->priv->urisrc), uri))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* add a sync handler for the bus messages to detect errors in the download */
|
/* add a sync handler for the bus messages to detect errors in the download */
|
||||||
gst_element_set_bus (GST_ELEMENT (downloader->priv->urisrc),
|
gst_element_set_bus (GST_ELEMENT (downloader->priv->urisrc),
|
||||||
|
|
Loading…
Reference in a new issue