GMutex *chain_lock; /* we need the lock to protect the chains */
GArray *chains; /* list of chains we know */
GstClockTime total_time;
+ GstFlowReturn chain_error; /* error we received while finding chains */
GstOggChain *current_chain;
GstOggChain *building_chain;
GstOggDemux *ogg;
GstOggPad *cur;
- ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
+ ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
cur = GST_OGG_PAD (pad);
switch (GST_QUERY_TYPE (query)) {
gst_query_parse_duration (query, &format, NULL);
/* can only get position in time */
- if (format != GST_FORMAT_TIME) {
- GST_DEBUG_OBJECT (ogg, "only query duration on TIME is supported");
- res = FALSE;
- goto done;
- }
+ if (format != GST_FORMAT_TIME)
+ goto wrong_format;
+
/* can only return the total time position */
+ /* FIXME, return time for this specific stream */
gst_query_set_duration (query, GST_FORMAT_TIME, ogg->total_time);
break;
}
break;
}
done:
+ gst_object_unref (ogg);
+
return res;
+
+ /* ERRORS */
+wrong_format:
+ {
+ GST_DEBUG_OBJECT (ogg, "only query duration on TIME is supported");
+ res = FALSE;
+ goto done;
+ }
}
static gboolean
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
- {
/* can't seek if we are not seekable, FIXME could pass the
* seek query upstream after converting it to bytes using
* the average bitrate of the stream. */
/* now do the seek */
res = gst_ogg_demux_perform_seek (ogg, event);
+ gst_event_unref (event);
break;
-
- }
default:
GST_DEBUG_OBJECT (ogg, "We only handle seek events here");
goto error;
- break;
}
return res;
GstOggDemux *ogg;
GstOggPad *cur;
- ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
+ ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
cur = GST_OGG_PAD (pad);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
- {
/* can't seek if we are not seekable, FIXME could pass the
* seek query upstream after converting it to bytes using
* the average bitrate of the stream. */
/* now do the seek */
res = gst_ogg_demux_perform_seek (ogg, event);
+ gst_event_unref (event);
break;
- }
default:
res = gst_pad_event_default (pad, event);
break;
}
+done:
+ gst_object_unref (ogg);
+
return res;
/* ERRORS */
{
GST_DEBUG_OBJECT (ogg, "error handling event");
gst_event_unref (event);
- return FALSE;
+ res = FALSE;
+ goto done;
}
}
static gint gst_ogg_demux_read_end_chain (GstOggDemux * ogg,
GstOggChain * chain);
-static gboolean gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_ogg_demux_sink_event (GstPad * pad, GstEvent * event);
static void gst_ogg_demux_loop (GstOggPad * pad);
static GstFlowReturn gst_ogg_demux_chain (GstPad * pad, GstBuffer * buffer);
static gboolean gst_ogg_demux_sink_activate (GstPad * sinkpad);
gst_pad_new_from_static_template (&ogg_demux_sink_template_factory,
"sink");
- gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_handle_event);
+ gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_sink_event);
gst_pad_set_chain_function (ogg->sinkpad, gst_ogg_demux_chain);
gst_pad_set_activate_function (ogg->sinkpad, gst_ogg_demux_sink_activate);
gst_pad_set_activatepull_function (ogg->sinkpad,
g_mutex_free (ogg->chain_lock);
ogg_sync_clear (&ogg->sync);
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
-gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event)
+gst_ogg_demux_sink_event (GstPad * pad, GstEvent * event)
{
- GstOggDemux *ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
+ gboolean res;
+ GstOggDemux *ogg;
+
+ ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
+ /* FIXME */
GST_DEBUG_OBJECT (ogg, "got a new segment event");
ogg_sync_reset (&ogg->sync);
gst_event_unref (event);
+ res = TRUE;
break;
+ case GST_EVENT_EOS:
default:
- return gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, event);
+ break;
}
- return TRUE;
+ gst_object_unref (ogg);
+
+ return res;
}
/* submit the given buffer to the ogg sync.
{
GST_WARNING_OBJECT (ogg, "got %d (%s) from pull range", ret,
gst_flow_get_name (ret));
+ ogg->chain_error = ret;
return -1;
}
}
}
}
+/* does not take ownership of the event */
static gboolean
gst_ogg_demux_perform_seek (GstOggDemux * ogg, GstEvent * event)
{
/* this is the only place where we write chains */
GST_CHAIN_LOCK (ogg);
+ ogg->chain_error = GST_FLOW_OK;
got_chains = gst_ogg_demux_find_chains (ogg);
GST_CHAIN_UNLOCK (ogg);
if (!got_chains)
/* and seek to configured positions without FLUSH */
gst_ogg_demux_perform_seek (ogg, event);
+ if (event)
+ gst_event_unref (event);
}
GST_LOG_OBJECT (ogg, "pull data %lld", ogg->offset);
chain_read_failed:
{
GST_ELEMENT_ERROR (ogg, STREAM, DEMUX, (NULL), ("could not read chains"));
- ret = GST_FLOW_ERROR;
+ ret = ogg->chain_error;
goto pause;
}
pause: