mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
uridownloader: Add parameter to disallow caching as required by HLS
This commit is contained in:
parent
816000f726
commit
706a88ccb3
2 changed files with 16 additions and 9 deletions
|
@ -323,7 +323,8 @@ gst_uri_downloader_set_range (GstUriDownloader * downloader,
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri,
|
gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri,
|
||||||
const gchar * referer, gboolean compress, gboolean refresh)
|
const gchar * referer, gboolean compress, gboolean refresh,
|
||||||
|
gboolean allow_cache)
|
||||||
{
|
{
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
@ -379,13 +380,17 @@ gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri,
|
||||||
if (g_object_class_find_property (gobject_class, "keep-alive"))
|
if (g_object_class_find_property (gobject_class, "keep-alive"))
|
||||||
g_object_set (downloader->priv->urisrc, "keep-alive", TRUE, NULL);
|
g_object_set (downloader->priv->urisrc, "keep-alive", TRUE, NULL);
|
||||||
if (g_object_class_find_property (gobject_class, "extra-headers")) {
|
if (g_object_class_find_property (gobject_class, "extra-headers")) {
|
||||||
if (referer || refresh) {
|
if (referer || refresh || !allow_cache) {
|
||||||
GstStructure *extra_headers = gst_structure_new_empty ("headers");
|
GstStructure *extra_headers = gst_structure_new_empty ("headers");
|
||||||
|
|
||||||
if (referer)
|
if (referer)
|
||||||
gst_structure_set (extra_headers, "Referer", G_TYPE_STRING, referer,
|
gst_structure_set (extra_headers, "Referer", G_TYPE_STRING, referer,
|
||||||
NULL);
|
NULL);
|
||||||
if (refresh)
|
|
||||||
|
if (!allow_cache)
|
||||||
|
gst_structure_set (extra_headers, "Cache-Control", G_TYPE_STRING,
|
||||||
|
"no-cache", NULL);
|
||||||
|
else if (refresh)
|
||||||
gst_structure_set (extra_headers, "Cache-Control", G_TYPE_STRING,
|
gst_structure_set (extra_headers, "Cache-Control", G_TYPE_STRING,
|
||||||
"max-age=0", NULL);
|
"max-age=0", NULL);
|
||||||
|
|
||||||
|
@ -415,10 +420,10 @@ gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri,
|
||||||
GstFragment *
|
GstFragment *
|
||||||
gst_uri_downloader_fetch_uri (GstUriDownloader * downloader,
|
gst_uri_downloader_fetch_uri (GstUriDownloader * downloader,
|
||||||
const gchar * uri, const gchar * referer, gboolean compress,
|
const gchar * uri, const gchar * referer, gboolean compress,
|
||||||
gboolean refresh, GError ** err)
|
gboolean refresh, gboolean allow_cache, GError ** err)
|
||||||
{
|
{
|
||||||
return gst_uri_downloader_fetch_uri_with_range (downloader, uri,
|
return gst_uri_downloader_fetch_uri_with_range (downloader, uri,
|
||||||
referer, compress, refresh, 0, -1, err);
|
referer, compress, refresh, allow_cache, 0, -1, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,7 +438,8 @@ gst_uri_downloader_fetch_uri (GstUriDownloader * downloader,
|
||||||
GstFragment *
|
GstFragment *
|
||||||
gst_uri_downloader_fetch_uri_with_range (GstUriDownloader *
|
gst_uri_downloader_fetch_uri_with_range (GstUriDownloader *
|
||||||
downloader, const gchar * uri, const gchar * referer, gboolean compress,
|
downloader, const gchar * uri, const gchar * referer, gboolean compress,
|
||||||
gboolean refresh, gint64 range_start, gint64 range_end, GError ** err)
|
gboolean refresh, gboolean allow_cache,
|
||||||
|
gint64 range_start, gint64 range_end, GError ** err)
|
||||||
{
|
{
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstFragment *download = NULL;
|
GstFragment *download = NULL;
|
||||||
|
@ -450,7 +456,8 @@ gst_uri_downloader_fetch_uri_with_range (GstUriDownloader *
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_uri_downloader_set_uri (downloader, uri, referer, compress, refresh)) {
|
if (!gst_uri_downloader_set_uri (downloader, uri, referer, compress, refresh,
|
||||||
|
allow_cache)) {
|
||||||
GST_WARNING_OBJECT (downloader, "Failed to set URI");
|
GST_WARNING_OBJECT (downloader, "Failed to set URI");
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ struct _GstUriDownloaderClass
|
||||||
GType gst_uri_downloader_get_type (void);
|
GType gst_uri_downloader_get_type (void);
|
||||||
|
|
||||||
GstUriDownloader * gst_uri_downloader_new (void);
|
GstUriDownloader * gst_uri_downloader_new (void);
|
||||||
GstFragment * gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri, const gchar * referer, gboolean compress, gboolean refresh, GError ** err);
|
GstFragment * gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri, const gchar * referer, gboolean compress, gboolean refresh, gboolean allow_cache, GError ** err);
|
||||||
GstFragment * gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader, const gchar * uri, const gchar * referer, gboolean compress, gboolean refresh, gint64 range_start, gint64 range_end, GError ** err);
|
GstFragment * gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader, const gchar * uri, const gchar * referer, gboolean compress, gboolean refresh, gboolean allow_cache, gint64 range_start, gint64 range_end, GError ** err);
|
||||||
void gst_uri_downloader_reset (GstUriDownloader *downloader);
|
void gst_uri_downloader_reset (GstUriDownloader *downloader);
|
||||||
void gst_uri_downloader_cancel (GstUriDownloader *downloader);
|
void gst_uri_downloader_cancel (GstUriDownloader *downloader);
|
||||||
void gst_uri_downloader_free (GstUriDownloader *downloader);
|
void gst_uri_downloader_free (GstUriDownloader *downloader);
|
||||||
|
|
Loading…
Reference in a new issue