gst/videotestsrc/gstvideotestsrc.c

Original commit message from CVS:
2005-06-27  Andy Wingo  <wingo@pobox.com>

* gst/videotestsrc/gstvideotestsrc.c
(gst_videotestsrc_activate_push): Activation API changes.

* gst/playback/gstdecodebin.c (gst_decode_bin_change_state)
(gst_decode_bin_dispose): Free dynamics in READY->NULL, because
they have refs on the decodebin.

* ext/ogg/gstoggdemux.c (gst_ogg_pad_class_init): Ref the right
parent class.
(gst_ogg_pad_typefind): Don't leak a pad ref.
(gst_ogg_chain_new_stream): gst_object_unref, not g_object_unref.
(gst_ogg_demux_sink_activate, gst_ogg_demux_sink_activate_push)
(gst_ogg_demux_sink_activate_pull): Changes for activation API.
This commit is contained in:
Andy Wingo 2005-06-27 18:41:22 +00:00
parent 6ec852f662
commit 97697df71d
4 changed files with 82 additions and 62 deletions

View File

@ -1,3 +1,19 @@
2005-06-27 Andy Wingo <wingo@pobox.com>
* gst/videotestsrc/gstvideotestsrc.c
(gst_videotestsrc_activate_push): Activation API changes.
* gst/playback/gstdecodebin.c (gst_decode_bin_change_state)
(gst_decode_bin_dispose): Free dynamics in READY->NULL, because
they have refs on the decodebin.
* ext/ogg/gstoggdemux.c (gst_ogg_pad_class_init): Ref the right
parent class.
(gst_ogg_pad_typefind): Don't leak a pad ref.
(gst_ogg_chain_new_stream): gst_object_unref, not g_object_unref.
(gst_ogg_demux_sink_activate, gst_ogg_demux_sink_activate_push)
(gst_ogg_demux_sink_activate_pull): Changes for activation API.
2005-06-27 Edward Hervey <edward@fluendo.com> 2005-06-27 Edward Hervey <edward@fluendo.com>
* ext/theora/theoradec.c: (theora_dec_change_state): * ext/theora/theoradec.c: (theora_dec_change_state):

View File

@ -232,7 +232,7 @@ gst_ogg_pad_class_init (GstOggPadClass * klass)
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
ogg_pad_parent_class = g_type_class_ref (G_TYPE_OBJECT); ogg_pad_parent_class = g_type_class_ref (GST_TYPE_PAD);
gobject_class->dispose = gst_ogg_pad_dispose; gobject_class->dispose = gst_ogg_pad_dispose;
gobject_class->finalize = gst_ogg_pad_finalize; gobject_class->finalize = gst_ogg_pad_finalize;
@ -578,7 +578,13 @@ gst_ogg_pad_typefind (GstOggPad * pad, ogg_packet * packet)
gst_pad_set_active (pad->elem_out, TRUE); gst_pad_set_active (pad->elem_out, TRUE);
/* and this pad may not be named src.. */ /* and this pad may not be named src.. */
gst_pad_link (gst_element_get_pad (element, "src"), pad->elem_out); {
GstPad *p;
p = gst_element_get_pad (element, "src");
gst_pad_link (p, pad->elem_out);
gst_object_unref (GST_OBJECT (p));
}
} }
} }
g_list_free (factories); g_list_free (factories);
@ -797,7 +803,7 @@ gst_ogg_chain_new_stream (GstOggChain * chain, glong serialno)
if (ogg_stream_init (&ret->stream, serialno) != 0) { if (ogg_stream_init (&ret->stream, serialno) != 0) {
GST_ERROR ("Could not initialize ogg_stream struct for serial %08lx.", GST_ERROR ("Could not initialize ogg_stream struct for serial %08lx.",
serialno); serialno);
g_object_unref (G_OBJECT (ret)); gst_object_unref (GST_OBJECT (ret));
return NULL; return NULL;
} }
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_SERIAL, serialno, gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_SERIAL, serialno,
@ -872,8 +878,11 @@ static gint gst_ogg_demux_read_end_chain (GstOggDemux * ogg,
static gboolean gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event); static gboolean gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event);
static void gst_ogg_demux_loop (GstOggPad * pad); static void gst_ogg_demux_loop (GstOggPad * pad);
static GstFlowReturn gst_ogg_demux_chain (GstPad * pad, GstBuffer * buffer); static GstFlowReturn gst_ogg_demux_chain (GstPad * pad, GstBuffer * buffer);
static gboolean gst_ogg_demux_sink_activate (GstPad * sinkpad, static gboolean gst_ogg_demux_sink_activate (GstPad * sinkpad);
GstActivateMode mode); static gboolean gst_ogg_demux_sink_activate_pull (GstPad * sinkpad,
gboolean active);
static gboolean gst_ogg_demux_sink_activate_push (GstPad * sinkpad,
gboolean active);
static GstElementStateReturn gst_ogg_demux_change_state (GstElement * element); static GstElementStateReturn gst_ogg_demux_change_state (GstElement * element);
static void gst_ogg_print (GstOggDemux * demux); static void gst_ogg_print (GstOggDemux * demux);
@ -920,6 +929,10 @@ gst_ogg_demux_init (GstOggDemux * ogg)
gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_handle_event); gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_handle_event);
gst_pad_set_chain_function (ogg->sinkpad, gst_ogg_demux_chain); 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_activate_function (ogg->sinkpad, gst_ogg_demux_sink_activate);
gst_pad_set_activatepull_function (ogg->sinkpad,
gst_ogg_demux_sink_activate_pull);
gst_pad_set_activatepush_function (ogg->sinkpad,
gst_ogg_demux_sink_activate_push);
gst_element_add_pad (GST_ELEMENT (ogg), ogg->sinkpad); gst_element_add_pad (GST_ELEMENT (ogg), ogg->sinkpad);
ogg->chain_lock = g_mutex_new (); ogg->chain_lock = g_mutex_new ();
@ -1972,35 +1985,43 @@ gst_ogg_demux_clear_chains (GstOggDemux * ogg)
} }
static gboolean static gboolean
gst_ogg_demux_sink_activate (GstPad * sinkpad, GstActivateMode mode) gst_ogg_demux_sink_activate (GstPad * sinkpad)
{
if (gst_pad_check_pull_range (sinkpad)) {
return gst_pad_activate_pull (sinkpad, TRUE);
} else {
return gst_pad_activate_push (sinkpad, TRUE);
}
}
static gboolean
gst_ogg_demux_sink_activate_push (GstPad * sinkpad, gboolean active)
{ {
gboolean result = FALSE;
GstOggDemux *ogg; GstOggDemux *ogg;
ogg = GST_OGG_DEMUX (GST_OBJECT_PARENT (sinkpad)); ogg = GST_OGG_DEMUX (GST_OBJECT_PARENT (sinkpad));
switch (mode) { ogg->seekable = FALSE;
case GST_ACTIVATE_PUSH:
ogg->seekable = FALSE;
result = TRUE;
break;
case GST_ACTIVATE_PULL:
/* if we have a scheduler we can start the task */
gst_pad_peer_set_active (sinkpad, mode);
ogg->need_chains = TRUE;
ogg->seekable = TRUE;
result =
gst_pad_start_task (sinkpad, (GstTaskFunction) gst_ogg_demux_loop,
sinkpad);
break;
case GST_ACTIVATE_NONE:
/* step 1, unblock clock sync (if any) */
/* step 2, make sure streaming finishes */ return TRUE;
result = gst_pad_stop_task (sinkpad); }
break;
static gboolean
gst_ogg_demux_sink_activate_pull (GstPad * sinkpad, gboolean active)
{
GstOggDemux *ogg;
ogg = GST_OGG_DEMUX (GST_OBJECT_PARENT (sinkpad));
if (active) {
ogg->need_chains = TRUE;
ogg->seekable = TRUE;
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_ogg_demux_loop,
sinkpad);
} else {
return gst_pad_stop_task (sinkpad);
} }
return result;
} }
static GstElementStateReturn static GstElementStateReturn

View File

@ -344,20 +344,11 @@ static void
gst_decode_bin_dispose (GObject * object) gst_decode_bin_dispose (GObject * object)
{ {
GstDecodeBin *decode_bin; GstDecodeBin *decode_bin;
GList *dyns;
decode_bin = GST_DECODE_BIN (object); decode_bin = GST_DECODE_BIN (object);
g_list_free (decode_bin->factories); g_list_free (decode_bin->factories);
for (dyns = decode_bin->dynamics; dyns; dyns = g_list_next (dyns)) {
GstDynamic *dynamic = (GstDynamic *) dyns->data;
dynamic_free (dynamic);
}
g_list_free (decode_bin->dynamics);
decode_bin->dynamics = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -1055,6 +1046,7 @@ gst_decode_bin_change_state (GstElement * element)
{ {
GstElementStateReturn ret; GstElementStateReturn ret;
GstDecodeBin *decode_bin; GstDecodeBin *decode_bin;
GList *dyns;
gint transition; gint transition;
decode_bin = GST_DECODE_BIN (element); decode_bin = GST_DECODE_BIN (element);
@ -1077,7 +1069,16 @@ gst_decode_bin_change_state (GstElement * element)
switch (transition) { switch (transition) {
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
for (dyns = decode_bin->dynamics; dyns; dyns = g_list_next (dyns)) {
GstDynamic *dynamic = (GstDynamic *) dyns->data;
dynamic_free (dynamic);
}
g_list_free (decode_bin->dynamics);
decode_bin->dynamics = NULL;
break;
default: default:
break; break;
} }

View File

@ -312,34 +312,16 @@ gst_videotestsrc_src_unlink (GstPad * pad)
} }
static gboolean static gboolean
gst_videotestsrc_activate (GstPad * pad, GstActivateMode mode) gst_videotestsrc_activate_push (GstPad * pad, gboolean active)
{ {
gboolean result = FALSE; if (active) {
GstVideotestsrc *videotestsrc; return gst_pad_start_task (pad,
(GstTaskFunction) gst_videotestsrc_loop, pad);
videotestsrc = GST_VIDEOTESTSRC (GST_OBJECT_PARENT (pad)); } else {
return gst_pad_stop_task (pad);
switch (mode) {
case GST_ACTIVATE_PULL:
break;
case GST_ACTIVATE_PUSH:
result = gst_pad_start_task (pad,
(GstTaskFunction) gst_videotestsrc_loop, pad);
break;
case GST_ACTIVATE_NONE:
/* step 1, unblock clock sync (if any) */
/* step 2, make sure streaming finishes */
result = gst_pad_stop_task (pad);
break;
default:
result = FALSE;
break;
} }
return result;
} }
static GstElementStateReturn static GstElementStateReturn
gst_videotestsrc_change_state (GstElement * element) gst_videotestsrc_change_state (GstElement * element)
{ {
@ -443,8 +425,8 @@ gst_videotestsrc_init (GstVideotestsrc * videotestsrc)
gst_pad_set_getcaps_function (videotestsrc->srcpad, gst_videotestsrc_getcaps); gst_pad_set_getcaps_function (videotestsrc->srcpad, gst_videotestsrc_getcaps);
gst_pad_set_setcaps_function (videotestsrc->srcpad, gst_videotestsrc_setcaps); gst_pad_set_setcaps_function (videotestsrc->srcpad, gst_videotestsrc_setcaps);
gst_element_add_pad (GST_ELEMENT (videotestsrc), videotestsrc->srcpad); gst_element_add_pad (GST_ELEMENT (videotestsrc), videotestsrc->srcpad);
gst_pad_set_activate_function (videotestsrc->srcpad, gst_pad_set_activatepush_function (videotestsrc->srcpad,
gst_videotestsrc_activate); gst_videotestsrc_activate_push);
gst_pad_set_loop_function (videotestsrc->srcpad, gst_videotestsrc_loop); gst_pad_set_loop_function (videotestsrc->srcpad, gst_videotestsrc_loop);
gst_pad_set_link_function (videotestsrc->srcpad, gst_videotestsrc_src_link); gst_pad_set_link_function (videotestsrc->srcpad, gst_videotestsrc_src_link);
gst_pad_set_unlink_function (videotestsrc->srcpad, gst_pad_set_unlink_function (videotestsrc->srcpad,