summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2020-01-23 09:45:59 +0200
committerSebastian Dröge <sebastian@centricular.com>2020-01-23 11:58:29 +0200
commit6c3fc7a16d7c2f1df0563748d400e3b66e0557af (patch)
treeac1064e20aca6f5eafa2ccad04683f80ef0fa90b /ext
parentb7d450b11834d0a510fdcb661ce105860338e2d6 (diff)
downloadgst-libav-6c3fc7a16d7c2f1df0563748d400e3b66e0557af.tar.gz
avdemux: Pass the URI from the URI query to avformat_open_input()
Some demuxers make use of it in various ways, for example the HLS demuxer.
Diffstat (limited to 'ext')
-rw-r--r--ext/libav/gstavdemux.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/ext/libav/gstavdemux.c b/ext/libav/gstavdemux.c
index fa5fd4e..66f6bb1 100644
--- a/ext/libav/gstavdemux.c
+++ b/ext/libav/gstavdemux.c
@@ -1218,6 +1218,8 @@ gst_ffmpegdemux_open (GstFFMpegDemux * demux)
GstTagList *tags;
GstEvent *event;
GList *cached_events;
+ GstQuery *query;
+ gchar *uri = NULL;
/* to be sure... */
gst_ffmpegdemux_close (demux);
@@ -1231,9 +1233,32 @@ gst_ffmpegdemux_open (GstFFMpegDemux * demux)
if (res < 0)
goto beach;
+ query = gst_query_new_uri ();
+ if (gst_pad_peer_query (demux->sinkpad, query)) {
+ gchar *query_uri, *redirect_uri;
+ gboolean permanent;
+
+ gst_query_parse_uri (query, &query_uri);
+ gst_query_parse_uri_redirection (query, &redirect_uri);
+ gst_query_parse_uri_redirection_permanent (query, &permanent);
+
+ if (permanent && redirect_uri) {
+ uri = redirect_uri;
+ g_free (query_uri);
+ } else {
+ uri = query_uri;
+ g_free (redirect_uri);
+ }
+ }
+ gst_query_unref (query);
+
+ GST_DEBUG_OBJECT (demux, "Opening context with URI %s", GST_STR_NULL (uri));
+
demux->context = avformat_alloc_context ();
demux->context->pb = iocontext;
- res = avformat_open_input (&demux->context, NULL, oclass->in_plugin, NULL);
+ res = avformat_open_input (&demux->context, uri, oclass->in_plugin, NULL);
+
+ g_free (uri);
GST_DEBUG_OBJECT (demux, "av_open_input returned %d", res);
if (res < 0)