uridownloader: Add support for compressed downloads

Very useful for playlists, less useful for media files.
This commit is contained in:
Sebastian Dröge 2014-02-12 13:08:29 +01:00
parent 245a7d94f5
commit 2a38c1409b
2 changed files with 15 additions and 7 deletions

View file

@ -309,9 +309,11 @@ gst_uri_downloader_set_range (GstUriDownloader * downloader,
}
static gboolean
gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri)
gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri,
gboolean compress)
{
GstPad *pad;
GObjectClass *gobject_class;
if (!gst_uri_is_valid (uri))
return FALSE;
@ -324,6 +326,10 @@ gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri)
if (!downloader->priv->urisrc)
return FALSE;
gobject_class = G_OBJECT_GET_CLASS (downloader->priv->urisrc);
if (g_object_class_find_property (gobject_class, "compress"))
g_object_set (downloader->priv->urisrc, "compress", compress, NULL);
/* add a sync handler for the bus messages to detect errors in the download */
gst_element_set_bus (GST_ELEMENT (downloader->priv->urisrc),
downloader->priv->bus);
@ -340,9 +346,10 @@ gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri)
GstFragment *
gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri,
GError ** err)
gboolean compress, GError ** err)
{
return gst_uri_downloader_fetch_uri_with_range (downloader, uri, 0, -1, err);
return gst_uri_downloader_fetch_uri_with_range (downloader, uri, compress, 0,
-1, err);
}
/**
@ -356,7 +363,8 @@ gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri,
*/
GstFragment *
gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader,
const gchar * uri, gint64 range_start, gint64 range_end, GError ** err)
const gchar * uri, gboolean compress, gint64 range_start,
gint64 range_end, GError ** err)
{
GstStateChangeReturn ret;
GstFragment *download = NULL;
@ -372,7 +380,7 @@ gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader,
goto quit;
}
if (!gst_uri_downloader_set_uri (downloader, uri)) {
if (!gst_uri_downloader_set_uri (downloader, uri, compress)) {
GST_WARNING_OBJECT (downloader, "Failed to set URI");
goto quit;
}

View file

@ -56,8 +56,8 @@ struct _GstUriDownloaderClass
GType gst_uri_downloader_get_type (void);
GstUriDownloader * gst_uri_downloader_new (void);
GstFragment * gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri, GError ** err);
GstFragment * gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader, const gchar * uri, gint64 range_start, gint64 range_end, GError ** err);
GstFragment * gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri, gboolean compress, GError ** err);
GstFragment * gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader, const gchar * uri, gboolean compress, gint64 range_start, gint64 range_end, GError ** err);
void gst_uri_downloader_reset (GstUriDownloader *downloader);
void gst_uri_downloader_cancel (GstUriDownloader *downloader);
void gst_uri_downloader_free (GstUriDownloader *downloader);