hlsdemux: use a typefinder to set the caps in the source pad
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Tue, 15 Feb 2011 20:49:20 +0000 (21:49 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 30 Mar 2011 07:19:21 +0000 (09:19 +0200)
gst/hls/gsthlsdemux.c
gst/hls/gsthlsdemux.h

index 3d1037e7191fc2dba1ed2621552b877f5f7bb8ce..48666b1d8be87c78b17b7eadd1aa0d37f5448ef4 100644 (file)
 
 
 #include <string.h>
+#include <gst/base/gsttypefindhelper.h>
 #include "gsthlsdemux.h"
 
 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("video/mpegts, systemstream=(boolean)true; "
-        "video/webm"));
+    GST_STATIC_CAPS_ANY);
 
 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
@@ -128,7 +128,7 @@ gst_hls_demux_base_init (gpointer g_class)
 
   gst_element_class_set_details_simple (element_class,
       "HLS Source",
-      "Decoder",
+      "Demuxer/URIList",
       "HTTP Live Streaming source",
       "Marc-Andre Lureau <marcandre.lureau@gmail.com>\n"
       "Andoni Morales Alastruey <ylatuya@gmail.com>");
@@ -584,6 +584,11 @@ gst_hls_demux_reset (GstHLSDemux * demux)
   demux->accumulated_delay = 0;
   demux->end_of_playlist = FALSE;
 
+  if (demux->input_caps) {
+    gst_caps_unref (demux->input_caps);
+    demux->input_caps = NULL;
+  }
+
   if (demux->playlist) {
     gst_buffer_unref (demux->playlist);
     demux->playlist = NULL;
@@ -894,6 +899,7 @@ gst_hls_demux_switch_playlist (GstHLSDemux * demux)
 static gboolean
 gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean retry)
 {
+  GstBuffer *buf;
   const gchar *next_fragment_uri;
   gboolean discont;
 
@@ -911,12 +917,23 @@ gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean retry)
   if (!gst_hls_demux_fetch_location (demux, next_fragment_uri))
     return FALSE;
 
+  buf = demux->downloaded_uri;
+
+  if (G_UNLIKELY (demux->input_caps == NULL)) {
+    demux->input_caps = gst_type_find_helper_for_buffer (NULL, buf, NULL);
+    if (demux->input_caps) {
+      gst_pad_set_caps (demux->srcpad, demux->input_caps);
+      GST_INFO_OBJECT (demux, "Input source caps: %" GST_PTR_FORMAT,
+          demux->input_caps);
+    }
+  }
+
   if (discont) {
     GST_DEBUG_OBJECT (demux, "Marking fragment as discontinuous");
-    GST_BUFFER_FLAG_SET (demux->downloaded_uri, GST_BUFFER_FLAG_DISCONT);
+    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
   }
 
-  g_queue_push_tail (demux->queue, demux->downloaded_uri);
+  g_queue_push_tail (demux->queue, buf);
   GST_TASK_SIGNAL (demux->task);
   demux->downloaded_uri = NULL;
   return TRUE;
index d9b30075fa0d24f72cb54981dd78f37e6e9692ed..a486b910d1c3816940a3ab523d2e2aebe5cd1b04 100644 (file)
@@ -55,6 +55,7 @@ struct _GstHLSDemux
   GstPad *srcpad;
   GstPad *sinkpad;
   GstBuffer *playlist;
+  GstCaps *input_caps;
   GstM3U8Client *client;        /* M3U8 client */
   GQueue *queue;                /* Queue storing the fetched fragments */
   gboolean need_cache;          /* Wheter we need to cache some fragments before starting to push data */