*/
#include <glib.h>
+#include <gst/base/gsttypefindhelper.h>
#include "gstfragmented.h"
#include "gstfragment.h"
PROP_NAME,
PROP_DURATION,
PROP_DISCONTINOUS,
- PROP_BUFFER_LIST,
+ PROP_BUFFER,
+ PROP_CAPS,
PROP_LAST
};
struct _GstFragmentPrivate
{
- GstBufferList *buffer_list;
- GstBufferListIterator *buffer_iterator;
- gboolean headers_set;
+ GstBuffer *buffer;
+ GstCaps *caps;
+ GMutex lock;
};
G_DEFINE_TYPE (GstFragment, gst_fragment, G_TYPE_OBJECT);
static void gst_fragment_finalize (GObject * object);
static void
+gst_fragment_set_property (GObject * object,
+ guint property_id, const GValue * value, GParamSpec * pspec)
+{
+ GstFragment *fragment = GST_FRAGMENT (object);
+
+ switch (property_id) {
+ case PROP_CAPS:
+ gst_fragment_set_caps (fragment, g_value_get_boxed (value));
+ break;
+
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
gst_fragment_get_property (GObject * object,
guint property_id, GValue * value, GParamSpec * pspec)
{
g_value_set_boolean (value, fragment->discontinuous);
break;
- case PROP_BUFFER_LIST:
- g_value_set_object (value, gst_fragment_get_buffer_list (fragment));
+ case PROP_BUFFER:
+ g_value_set_boxed (value, gst_fragment_get_buffer (fragment));
+ break;
+
+ case PROP_CAPS:
+ g_value_set_boxed (value, gst_fragment_get_caps (fragment));
break;
default:
}
}
+
+
static void
gst_fragment_class_init (GstFragmentClass * klass)
{
g_type_class_add_private (klass, sizeof (GstFragmentPrivate));
+ gobject_class->set_property = gst_fragment_set_property;
gobject_class->get_property = gst_fragment_get_property;
gobject_class->dispose = gst_fragment_dispose;
gobject_class->finalize = gst_fragment_finalize;
g_param_spec_uint64 ("duration", "Fragment duration",
"Duration of the fragment", 0, G_MAXUINT64, 0, G_PARAM_READABLE));
- g_object_class_install_property (gobject_class, PROP_BUFFER_LIST,
- g_param_spec_object ("buffer-list", "Buffer List",
- "A list with the fragment's buffers", GST_TYPE_FRAGMENT,
- G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, PROP_BUFFER,
+ g_param_spec_boxed ("buffer", "Buffer",
+ "The fragment's buffer", GST_TYPE_BUFFER,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_CAPS,
+ g_param_spec_boxed ("caps", "Fragment caps",
+ "The caps of the fragment's buffer. (NULL = detect)", GST_TYPE_CAPS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
fragment->priv = priv = GST_FRAGMENT_GET_PRIVATE (fragment);
- priv->buffer_list = gst_buffer_list_new ();
- priv->buffer_iterator = gst_buffer_list_iterate (priv->buffer_list);
- gst_buffer_list_iterator_add_group (priv->buffer_iterator);
- priv->headers_set = FALSE;
+ g_mutex_init (&fragment->priv->lock);
+ priv->buffer = NULL;
fragment->download_start_time = g_get_real_time ();
fragment->start_time = 0;
fragment->stop_time = 0;
GstFragment *fragment = GST_FRAGMENT (gobject);
g_free (fragment->name);
+ g_mutex_clear (&fragment->priv->lock);
G_OBJECT_CLASS (gst_fragment_parent_class)->finalize (gobject);
}
{
GstFragmentPrivate *priv = GST_FRAGMENT (object)->priv;
- if (priv->buffer_list != NULL) {
- gst_buffer_list_iterator_free (priv->buffer_iterator);
- gst_buffer_list_unref (priv->buffer_list);
- priv->buffer_list = NULL;
+ if (priv->buffer != NULL) {
+ gst_buffer_unref (priv->buffer);
+ priv->buffer = NULL;
+ }
+
+ if (priv->caps != NULL) {
+ gst_caps_unref (priv->caps);
+ priv->caps = NULL;
}
G_OBJECT_CLASS (gst_fragment_parent_class)->dispose (object);
}
-GstBufferList *
-gst_fragment_get_buffer_list (GstFragment * fragment)
+GstBuffer *
+gst_fragment_get_buffer (GstFragment * fragment)
{
g_return_val_if_fail (fragment != NULL, NULL);
if (!fragment->completed)
return NULL;
- gst_buffer_list_ref (fragment->priv->buffer_list);
- return fragment->priv->buffer_list;
+ gst_buffer_ref (fragment->priv->buffer);
+ return fragment->priv->buffer;
}
-gboolean
-gst_fragment_set_headers (GstFragment * fragment, GstBuffer ** buffer,
- guint count)
+void
+gst_fragment_set_caps (GstFragment * fragment, GstCaps * caps)
{
- guint i;
+ g_return_if_fail (fragment != NULL);
- g_return_val_if_fail (fragment != NULL, FALSE);
- g_return_val_if_fail (buffer != NULL, FALSE);
+ g_mutex_lock (&fragment->priv->lock);
+ gst_caps_replace (&fragment->priv->caps, caps);
+ g_mutex_unlock (&fragment->priv->lock);
+}
- if (fragment->priv->headers_set)
- return FALSE;
+GstCaps *
+gst_fragment_get_caps (GstFragment * fragment)
+{
+ g_return_val_if_fail (fragment != NULL, NULL);
- for (i = 0; i < count; i++) {
- /* We steal the buffers you pass in */
- gst_buffer_list_iterator_add (fragment->priv->buffer_iterator, buffer[i]);
- gst_buffer_list_iterator_add_group (fragment->priv->buffer_iterator);
- }
- return TRUE;
+ if (!fragment->completed)
+ return NULL;
+
+ g_mutex_lock (&fragment->priv->lock);
+ if (fragment->priv->caps == NULL)
+ fragment->priv->caps =
+ gst_type_find_helper_for_buffer (NULL, fragment->priv->buffer, NULL);
+ gst_caps_ref (fragment->priv->caps);
+ g_mutex_unlock (&fragment->priv->lock);
+
+ return fragment->priv->caps;
}
gboolean
return FALSE;
}
- /* if this is the first buffer forbid setting the headers anymore */
- if (G_UNLIKELY (fragment->priv->headers_set == FALSE))
- fragment->priv->headers_set = TRUE;
-
GST_DEBUG ("Adding new buffer to the fragment");
/* We steal the buffers you pass in */
- gst_buffer_list_iterator_add (fragment->priv->buffer_iterator, buffer);
+ if (fragment->priv->buffer == NULL)
+ fragment->priv->buffer = buffer;
+ else
+ fragment->priv->buffer = gst_buffer_append (fragment->priv->buffer, buffer);
return TRUE;
}
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <string.h>
-#include <gst/base/gsttypefindhelper.h>
#include <gst/glib-compat-private.h>
#include "gsthlsdemux.h"
gst_hls_demux_change_state (GstElement * element, GstStateChange transition);
/* GstHLSDemux */
-static GstFlowReturn gst_hls_demux_chain (GstPad * pad, GstBuffer * buf);
-static gboolean gst_hls_demux_sink_event (GstPad * pad, GstEvent * event);
-static gboolean gst_hls_demux_src_event (GstPad * pad, GstEvent * event);
-static gboolean gst_hls_demux_src_query (GstPad * pad, GstQuery * query);
+static GstFlowReturn gst_hls_demux_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
+static gboolean gst_hls_demux_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static gboolean gst_hls_demux_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static gboolean gst_hls_demux_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
static void gst_hls_demux_stream_loop (GstHLSDemux * demux);
static void gst_hls_demux_updates_loop (GstHLSDemux * demux);
static void gst_hls_demux_stop (GstHLSDemux * demux);
const gchar * uri);
static gchar *gst_hls_src_buf_to_utf8_playlist (GstBuffer * buf);
-static void
-_do_init (GType type)
-{
- GST_DEBUG_CATEGORY_INIT (gst_hls_demux_debug, "hlsdemux", 0,
- "hlsdemux element");
-}
-
-GST_BOILERPLATE_FULL (GstHLSDemux, gst_hls_demux, GstElement,
- GST_TYPE_ELEMENT, _do_init);
-
-static void
-gst_hls_demux_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&srctemplate));
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sinktemplate));
-
- gst_element_class_set_details_simple (element_class,
- "HLS Demuxer",
- "Demuxer/URIList",
- "HTTP Live Streaming demuxer",
- "Marc-Andre Lureau <marcandre.lureau@gmail.com>\n"
- "Andoni Morales Alastruey <ylatuya@gmail.com>");
-}
+#define gst_hls_demux_parent_class parent_class
+G_DEFINE_TYPE (GstHLSDemux, gst_hls_demux, GST_TYPE_ELEMENT);
static void
gst_hls_demux_dispose (GObject * obj)
gst_task_join (demux->stream_task);
}
gst_object_unref (demux->stream_task);
- g_static_rec_mutex_free (&demux->stream_lock);
+ g_rec_mutex_clear (&demux->stream_lock);
demux->stream_task = NULL;
}
gst_task_join (demux->updates_task);
}
gst_object_unref (demux->updates_task);
- g_mutex_free (demux->updates_timed_lock);
- g_static_rec_mutex_free (&demux->updates_lock);
+ g_mutex_clear (&demux->updates_timed_lock);
+ g_rec_mutex_clear (&demux->updates_lock);
demux->updates_task = NULL;
}
gst_hls_demux_class_init (GstHLSDemuxClass * klass)
{
GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
+ GstElementClass *element_class;
gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
+ element_class = (GstElementClass *) klass;
gobject_class->set_property = gst_hls_demux_set_property;
gobject_class->get_property = gst_hls_demux_get_property;
0, 1, DEFAULT_BITRATE_SWITCH_TOLERANCE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gstelement_class->change_state =
- GST_DEBUG_FUNCPTR (gst_hls_demux_change_state);
+ element_class->change_state = GST_DEBUG_FUNCPTR (gst_hls_demux_change_state);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&srctemplate));
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sinktemplate));
+
+ gst_element_class_set_details_simple (element_class,
+ "HLS Demuxer",
+ "Demuxer/URIList",
+ "HTTP Live Streaming demuxer",
+ "Marc-Andre Lureau <marcandre.lureau@gmail.com>\n"
+ "Andoni Morales Alastruey <ylatuya@gmail.com>");
+
+ GST_DEBUG_CATEGORY_INIT (gst_hls_demux_debug, "hlsdemux", 0,
+ "hlsdemux element");
}
static void
-gst_hls_demux_init (GstHLSDemux * demux, GstHLSDemuxClass * klass)
+gst_hls_demux_init (GstHLSDemux * demux)
{
/* sink pad */
demux->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
demux->queue = g_queue_new ();
/* Updates task */
- g_static_rec_mutex_init (&demux->updates_lock);
+ g_rec_mutex_init (&demux->updates_lock);
demux->updates_task =
- gst_task_create ((GstTaskFunction) gst_hls_demux_updates_loop, demux);
+ gst_task_new ((GstTaskFunction) gst_hls_demux_updates_loop, demux);
gst_task_set_lock (demux->updates_task, &demux->updates_lock);
- demux->updates_timed_lock = g_mutex_new ();
+ g_mutex_init (&demux->updates_timed_lock);
/* Streaming task */
- g_static_rec_mutex_init (&demux->stream_lock);
+ g_rec_mutex_init (&demux->stream_lock);
demux->stream_task =
- gst_task_create ((GstTaskFunction) gst_hls_demux_stream_loop, demux);
+ gst_task_new ((GstTaskFunction) gst_hls_demux_stream_loop, demux);
gst_task_set_lock (demux->stream_task, &demux->stream_lock);
}
}
static gboolean
-gst_hls_demux_src_event (GstPad * pad, GstEvent * event)
+gst_hls_demux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstHLSDemux *demux;
- demux = GST_HLS_DEMUX (gst_pad_get_element_private (pad));
+ demux = GST_HLS_DEMUX (parent);
switch (event->type) {
case GST_EVENT_SEEK:
gst_task_pause (demux->stream_task);
/* wait for streaming to finish */
- g_static_rec_mutex_lock (&demux->stream_lock);
+ g_rec_mutex_lock (&demux->stream_lock);
demux->need_cache = TRUE;
while (!g_queue_is_empty (demux->queue)) {
- GstBufferList *buf_list = g_queue_pop_head (demux->queue);
- gst_buffer_list_unref (buf_list);
+ GstFragment *fragment = g_queue_pop_head (demux->queue);
+ g_object_unref (fragment);
}
g_queue_clear (demux->queue);
if (flags & GST_SEEK_FLAG_FLUSH) {
GST_DEBUG_OBJECT (demux, "sending flush stop");
- gst_pad_push_event (demux->srcpad, gst_event_new_flush_stop ());
+ gst_pad_push_event (demux->srcpad, gst_event_new_flush_stop (TRUE));
}
demux->cancelled = FALSE;
gst_task_start (demux->stream_task);
- g_static_rec_mutex_unlock (&demux->stream_lock);
+ g_rec_mutex_unlock (&demux->stream_lock);
return TRUE;
}
break;
}
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static gboolean
-gst_hls_demux_sink_event (GstPad * pad, GstEvent * event)
+gst_hls_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstHLSDemux *demux = GST_HLS_DEMUX (gst_pad_get_parent (pad));
+ GstHLSDemux *demux;
GstQuery *query;
gboolean ret;
gchar *uri;
+ demux = GST_HLS_DEMUX (parent);
switch (event->type) {
case GST_EVENT_EOS:{
- gchar *playlist;
+ gchar *playlist = NULL;
if (demux->playlist == NULL) {
GST_WARNING_OBJECT (demux, "Received EOS without a playlist.");
gst_event_unref (event);
return TRUE;
}
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
/* Swallow newsegments, we'll push our own */
gst_event_unref (event);
return TRUE;
break;
}
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static gboolean
-gst_hls_demux_src_query (GstPad * pad, GstQuery * query)
+gst_hls_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
GstHLSDemux *hlsdemux;
gboolean ret = FALSE;
if (query == NULL)
return FALSE;
- hlsdemux = GST_HLS_DEMUX (gst_pad_get_element_private (pad));
+ hlsdemux = GST_HLS_DEMUX (parent);
switch (query->type) {
case GST_QUERY_DURATION:{
}
static GstFlowReturn
-gst_hls_demux_chain (GstPad * pad, GstBuffer * buf)
+gst_hls_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
- GstHLSDemux *demux = GST_HLS_DEMUX (gst_pad_get_parent (pad));
+ GstHLSDemux *demux = GST_HLS_DEMUX (parent);
if (demux->playlist == NULL)
demux->playlist = buf;
else
demux->playlist = gst_buffer_append (demux->playlist, buf);
- gst_object_unref (demux);
-
return GST_FLOW_OK;
}
GST_DEBUG ("Switching pads (oldpad:%p) with caps: %" GST_PTR_FORMAT, oldpad,
newcaps);
- /* FIXME: This is a workaround for a bug in playsink.
- * If we're switching from an audio-only or video-only fragment
- * to an audio-video segment, the new sink doesn't know about
- * the current running time and audio/video will go out of sync.
- *
- * This should be fixed in playsink by distributing the
- * current running time to newly created sinks and is
- * fixed in 0.11 with the new segments.
- */
- if (demux->srcpad)
- gst_pad_push_event (demux->srcpad, gst_event_new_flush_stop ());
-
/* First create and activate new pad */
demux->srcpad = gst_pad_new_from_static_template (&srctemplate, NULL);
gst_pad_set_event_function (demux->srcpad,
GST_DEBUG_FUNCPTR (gst_hls_demux_src_query));
gst_pad_set_element_private (demux->srcpad, demux);
gst_pad_set_active (demux->srcpad, TRUE);
+ gst_pad_push_event (demux->srcpad, gst_event_new_stream_start ());
gst_pad_set_caps (demux->srcpad, newcaps);
+ gst_pad_push_event (demux->srcpad, gst_event_new_caps (newcaps));
gst_element_add_pad (GST_ELEMENT (demux), demux->srcpad);
gst_element_no_more_pads (GST_ELEMENT (demux));
static void
gst_hls_demux_stream_loop (GstHLSDemux * demux)
{
- GstBufferList *buffer_list;
+ GstFragment *fragment;
GstBuffer *buf;
GstFlowReturn ret;
+ GstCaps *bufcaps, *srccaps = NULL;
/* Loop for the source pad task. The task is started when we have
* received the main playlist from the source element. It tries first to
goto pause_task;
}
- buffer_list = g_queue_pop_head (demux->queue);
- /* Work with the first buffer of the list */
- buf = gst_buffer_list_get (buffer_list, 0, 0);
+ fragment = g_queue_pop_head (demux->queue);
+ buf = gst_fragment_get_buffer (fragment);
+
/* Figure out if we need to create/switch pads */
- if (G_UNLIKELY (!demux->srcpad
- || GST_BUFFER_CAPS (buf) != GST_PAD_CAPS (demux->srcpad)
+ if (G_LIKELY (demux->srcpad))
+ srccaps = gst_pad_get_current_caps (demux->srcpad);
+ bufcaps = gst_fragment_get_caps (fragment);
+ if (G_UNLIKELY (!srccaps || !gst_caps_is_equal_fixed (bufcaps, srccaps)
|| demux->need_segment)) {
- switch_pads (demux, GST_BUFFER_CAPS (buf));
+ switch_pads (demux, bufcaps);
demux->need_segment = TRUE;
}
+ gst_caps_unref (bufcaps);
+ if (G_LIKELY (srccaps))
+ gst_caps_unref (srccaps);
+ g_object_unref (fragment);
+
if (demux->need_segment) {
GstClockTime start = demux->position + demux->position_shift;
+ GstSegment segment;
/* And send a newsegment */
GST_DEBUG_OBJECT (demux, "Sending new-segment. segment start:%"
GST_TIME_FORMAT, GST_TIME_ARGS (start));
- gst_pad_push_event (demux->srcpad,
- gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
- start, GST_CLOCK_TIME_NONE, start));
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = start;
+ segment.time = start;
+ gst_pad_push_event (demux->srcpad, gst_event_new_segment (&segment));
demux->need_segment = FALSE;
demux->position_shift = 0;
}
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buf)))
demux->position += GST_BUFFER_DURATION (buf);
- ret = gst_pad_push_list (demux->srcpad, buffer_list);
+ ret = gst_pad_push (demux->srcpad, buf);
if (ret != GST_FLOW_OK)
goto error_pushing;
}
while (!g_queue_is_empty (demux->queue)) {
- GstBufferList *buffer_list = g_queue_pop_head (demux->queue);
- gst_buffer_list_unref (buffer_list);
+ GstFragment *fragment = g_queue_pop_head (demux->queue);
+ g_object_unref (fragment);
}
g_queue_clear (demux->queue);
* switch to a different bitrate */
/* block until the next scheduled update or the signal to quit this thread */
- g_mutex_lock (demux->updates_timed_lock);
+ g_mutex_lock (&demux->updates_timed_lock);
GST_DEBUG_OBJECT (demux, "Started updates task");
while (TRUE) {
if (g_cond_timed_wait (GST_TASK_GET_COND (demux->updates_task),
- demux->updates_timed_lock, &demux->next_update)) {
+ &demux->updates_timed_lock, &demux->next_update)) {
goto quit;
}
/* update the playlist for live sources */
{
GST_DEBUG_OBJECT (demux, "Stopped updates task");
gst_hls_demux_stop (demux);
- g_mutex_unlock (demux->updates_timed_lock);
+ g_mutex_unlock (&demux->updates_timed_lock);
}
}
static gchar *
gst_hls_src_buf_to_utf8_playlist (GstBuffer * buf)
{
- gint size;
- gchar *data;
+ GstMapInfo info;
gchar *playlist;
- data = (gchar *) GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
-
- if (!g_utf8_validate (data, size, NULL))
+ if (!gst_buffer_map (buf, &info, GST_MAP_READ))
return NULL;
+ if (!g_utf8_validate ((gchar *) info.data, info.size, NULL))
+ goto validate_error;
+
/* alloc size + 1 to end with a null character */
- playlist = g_malloc0 (size + 1);
- memcpy (playlist, data, size + 1);
+ playlist = g_malloc0 (info.size + 1);
+ memcpy (playlist, info.data, info.size + 1);
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
return playlist;
+
+validate_error:
+ gst_buffer_unmap (buf, &info);
+ gst_buffer_unref (buf);
+ return NULL;
}
static gboolean
gst_hls_demux_update_playlist (GstHLSDemux * demux)
{
GstFragment *download;
- GstBufferListIterator *it;
GstBuffer *buf;
gchar *playlist;
if (download == NULL)
return FALSE;
- /* Merge all the buffers in the list to build a unique buffer with the
- * playlist */
- it = gst_buffer_list_iterate (gst_fragment_get_buffer_list (download));
-
- /* skip the first group, which contains the headers, which are not set in the
- * demuxer*/
- gst_buffer_list_iterator_next_group (it);
- buf = gst_buffer_list_iterator_merge_group (it);
-
+ buf = gst_fragment_get_buffer (download);
playlist = gst_hls_src_buf_to_utf8_playlist (buf);
- gst_buffer_list_iterator_free (it);
g_object_unref (download);
if (playlist == NULL) {
const gchar *next_fragment_uri;
GstClockTime duration;
GstClockTime timestamp;
- GstBufferList *buffer_list;
GstBuffer *buf;
gboolean discont;
if (download == NULL)
goto error;
- buffer_list = gst_fragment_get_buffer_list (download);
- buf = gst_buffer_list_get (buffer_list, 0, 0);
+ buf = gst_fragment_get_buffer (download);
GST_BUFFER_DURATION (buf) = duration;
- GST_BUFFER_TIMESTAMP (buf) = timestamp;
+ GST_BUFFER_PTS (buf) = timestamp;
/* We actually need to do this every time we switch bitrate */
if (G_UNLIKELY (demux->do_typefind)) {
- GstCaps *caps = gst_type_find_helper_for_buffer (NULL, buf, NULL);
+ GstCaps *caps = gst_fragment_get_caps (download);
if (!demux->input_caps || !gst_caps_is_equal (caps, demux->input_caps)) {
gst_caps_replace (&demux->input_caps, caps);
GST_INFO_OBJECT (demux, "Input source caps: %" GST_PTR_FORMAT,
demux->input_caps);
demux->do_typefind = FALSE;
- } else
- gst_caps_unref (caps);
+ }
+ gst_caps_unref (caps);
+ } else {
+ gst_fragment_set_caps (download, demux->input_caps);
}
- gst_buffer_set_caps (buf, demux->input_caps);
if (discont) {
GST_DEBUG_OBJECT (demux, "Marking fragment as discontinuous");
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
}
- g_queue_push_tail (demux->queue, buffer_list);
- g_object_unref (download);
+ g_queue_push_tail (demux->queue, download);
if (!caching) {
GST_TASK_SIGNAL (demux->updates_task);
}
-
return TRUE;
error:
GstPad *pad;
GTimeVal *timeout;
GstFragment *download;
- GMutex *lock;
- GCond *cond;
+ GMutex lock;
+ GCond cond;
};
static void gst_uri_downloader_finalize (GObject * object);
static void gst_uri_downloader_dispose (GObject * object);
-static GstFlowReturn gst_uri_downloader_chain (GstPad * pad, GstBuffer * buf);
-static gboolean gst_uri_downloader_sink_event (GstPad * pad, GstEvent * event);
+static GstFlowReturn gst_uri_downloader_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
+static gboolean gst_uri_downloader_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstBusSyncReply gst_uri_downloader_bus_handler (GstBus * bus,
GstMessage * message, gpointer data);
gst_pad_set_event_function (downloader->priv->pad,
GST_DEBUG_FUNCPTR (gst_uri_downloader_sink_event));
gst_pad_set_element_private (downloader->priv->pad, downloader);
- gst_pad_activate_push (downloader->priv->pad, TRUE);
+ gst_pad_set_active (downloader->priv->pad, TRUE);
/* Create a bus to handle error and warning message from the source element */
downloader->priv->bus = gst_bus_new ();
- downloader->priv->lock = g_mutex_new ();
- downloader->priv->cond = g_cond_new ();
+ g_mutex_init (&downloader->priv->lock);
+ g_cond_init (&downloader->priv->cond);
}
static void
{
GstUriDownloader *downloader = GST_URI_DOWNLOADER (object);
- g_mutex_free (downloader->priv->lock);
- g_cond_free (downloader->priv->cond);
+ g_mutex_clear (&downloader->priv->lock);
+ g_cond_clear (&downloader->priv->cond);
G_OBJECT_CLASS (gst_uri_downloader_parent_class)->finalize (object);
}
}
static gboolean
-gst_uri_downloader_sink_event (GstPad * pad, GstEvent * event)
+gst_uri_downloader_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstUriDownloader *downloader =
- (GstUriDownloader *) (gst_pad_get_element_private (pad));
+ gboolean ret = FALSE;
+ GstUriDownloader *downloader;
+
+ downloader = GST_URI_DOWNLOADER (gst_pad_get_element_private (pad));
switch (event->type) {
case GST_EVENT_EOS:{
downloader->priv->download->download_stop_time = g_get_real_time ();
GST_OBJECT_UNLOCK (downloader);
GST_DEBUG_OBJECT (downloader, "Signaling chain funtion");
- g_cond_signal (downloader->priv->cond);
-
+ g_cond_signal (&downloader->priv->cond);
} else {
GST_OBJECT_UNLOCK (downloader);
}
+ gst_event_unref (event);
break;
}
default:
+ ret = gst_pad_event_default (pad, parent, event);
break;
}
- gst_event_unref (event);
- return FALSE;
+ return ret;
}
static GstBusSyncReply
}
static GstFlowReturn
-gst_uri_downloader_chain (GstPad * pad, GstBuffer * buf)
+gst_uri_downloader_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
- GstUriDownloader *downloader =
- (GstUriDownloader *) gst_pad_get_element_private (pad);
+ GstUriDownloader *downloader;
+
+ downloader = GST_URI_DOWNLOADER (gst_pad_get_element_private (pad));
/* HTML errors (404, 500, etc...) are also pushed through this pad as
* response but the source element will also post a warning or error message
}
GST_LOG_OBJECT (downloader, "The uri fetcher received a new buffer "
- "of size %u", GST_BUFFER_SIZE (buf));
+ "of size %u", gst_buffer_get_size (buf));
if (!gst_fragment_add_buffer (downloader->priv->download, buf))
GST_WARNING_OBJECT (downloader, "Could not add buffer to fragment");
GST_OBJECT_UNLOCK (downloader);
downloader->priv->download = NULL;
GST_OBJECT_UNLOCK (downloader);
GST_DEBUG_OBJECT (downloader, "Signaling chain funtion");
- g_cond_signal (downloader->priv->cond);
+ g_cond_signal (&downloader->priv->cond);
} else {
GST_OBJECT_UNLOCK (downloader);
GST_DEBUG_OBJECT (downloader,
GstStateChangeReturn ret;
GstFragment *download = NULL;
- g_mutex_lock (downloader->priv->lock);
+ g_mutex_lock (&downloader->priv->lock);
if (!gst_uri_downloader_set_uri (downloader, uri)) {
goto quit;
* - the download was canceled
*/
GST_DEBUG_OBJECT (downloader, "Waiting to fetch the URI");
- g_cond_wait (downloader->priv->cond, downloader->priv->lock);
+ g_cond_wait (&downloader->priv->cond, &downloader->priv->lock);
GST_OBJECT_LOCK (downloader);
download = downloader->priv->download;
quit:
{
gst_uri_downloader_stop (downloader);
- g_mutex_unlock (downloader->priv->lock);
+ g_mutex_unlock (&downloader->priv->lock);
return download;
}
}