+2005-09-02 Andy Wingo <wingo@pobox.com>
+
+ * gst/gstelement.h (GstState): Renamed from GstElementState,
+ changed to be a normal enum instead of flags.
+ (GstStateChangeReturn): Renamed from GstElementStateReturn, names
+ munged to be GST_STATE_CHANGE_*.
+ (GST_STATE_CHANGE): Renamed from GST_STATE_TRANSITION, updated to
+ work with the new state representation.
+ (GstStateChange): New enumeration of possible state transitions.
+ Replaces GST_STATE_FOO_TO_BAR with GST_STATE_CHANGE_FOO_TO_BAR.
+ (GstElementClass::change_state): Pass the GstStateChange along as
+ an argument. Helps language bindings, so they don't have to use
+ tricky lock-needing macros like GST_STATE_CHANGE ().
+
+ * scripts/update-states (file): New script. Run it on a file to
+ update it for state naming and API changes. Updates files in
+ place.
+
+ * All files updated for the new API.
+
2005-09-02 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gsttrace.c: (gst_trace_flush), (gst_trace_text_flush):
src = setup_fakesrc ();
g_object_set (G_OBJECT (src), "num-buffers", 3, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
identity = setup_identity ();
fail_unless (gst_element_set_state (identity,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
buffer = gst_buffer_new_and_alloc (4);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
* - second for bin, causing an incref on the bin */
GST_DEBUG ("setting bin to READY");
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
ASSERT_OBJECT_REFCOUNT (src, "src", 2);
ASSERT_OBJECT_REFCOUNT (bin, "bin", 2);
/* change state to READY, spawning three messages */
GST_DEBUG ("setting pipeline to READY");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by a message */
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
/* change state to PAUSED, spawning three messages */
GST_DEBUG ("setting pipeline to PAUSED");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by a message;
* base_sink_chain has taken a refcount on the sink, and is blocked on
/* change state to PLAYING, spawning three messages */
GST_DEBUG ("setting pipeline to PLAYING");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by one message
* sink might have an extra reference if it's still blocked on preroll */
/* go back to READY, spawning six messages */
GST_DEBUG ("setting pipeline to READY");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by two messages */
ASSERT_OBJECT_REFCOUNT (src, "src", 3);
/* setting pipeline to NULL flushes the bus automatically */
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
/* change state, spawning two times three messages, minus one async */
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED)
- == GST_STATE_ASYNC);
+ == GST_STATE_CHANGE_ASYNC);
pop_messages (bus, 5);
"Unexpected messages on bus");
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
pop_messages (bus, 3);
/* setting bin to NULL flushes the bus automatically */
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* clean up */
gst_object_unref (bin);
assert_gstrefcount (isrc, 3); /* parent and gsrc */
fail_unless (gst_element_set_state (b1,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS);
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
- fail_unless (gst_element_set_state (b1, GST_STATE_NULL) == GST_STATE_SUCCESS);
+ fail_unless (gst_element_set_state (b1,
+ GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
gst_object_unref (b1);
/* unreffing the bin will unref all elements, which will unlink and unparent
}
/* GST_MESSAGE_STATE_CHANGED */
{
- GstElementState oldstate, newstate;
+ GstState oldstate, newstate;
oldstate = GST_STATE_PAUSED;
newstate = GST_STATE_PLAYING;
/*
void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
- void gst_message_parse_state_changed (GstMessage *message, GstElementState *old_state,
- GstElementState *new_state);
+ void gst_message_parse_state_changed (GstMessage *message, GstState *old_state,
+ GstState *new_state);
void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug);
void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug);
*/
bus = gst_element_get_bus (pipe);
g_assert (bus);
- if (gst_element_set_state (pipe, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
+ if (gst_element_set_state (pipe,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS) {
g_critical ("Couldn't set pipeline to PLAYING");
goto done;
}
GST_START_TEST (test_sink)
{
GstElement *sink;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GTimeVal tv;
sink = gst_element_factory_make ("fakesink", "sink");
ret = gst_element_set_state (sink, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_ASYNC, "no async state return");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_ASYNC, "no forced async state change");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no forced async state change");
GST_TIME_TO_TIMEVAL ((GstClockTime) 0, tv);
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
- fail_unless (ret == GST_STATE_ASYNC, "not changing state async");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
fail_unless (current == GST_STATE_PAUSED, "bad current state");
fail_unless (pending == GST_STATE_PLAYING, "bad pending state");
ret = gst_element_set_state (sink, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_ASYNC, "no async going back to paused");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async going back to paused");
ret = gst_element_set_state (sink, GST_STATE_READY);
- fail_unless (ret == GST_STATE_SUCCESS, "failed to go to ready");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to ready");
gst_object_unref (sink);
}
GST_START_TEST (test_src_sink)
{
GstElement *sink, *src, *pipeline;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GstPad *srcpad, *sinkpad;
pipeline = gst_pipeline_new ("pipeline");
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
ret = gst_element_get_state (pipeline, NULL, NULL, NULL);
- fail_unless (ret == GST_STATE_SUCCESS, "no success state return");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_SUCCESS, "cannot start play");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot start play");
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_SUCCESS, "not playing");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
fail_unless (current == GST_STATE_PLAYING, "not playing");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
}
GST_START_TEST (test_livesrc_remove)
{
GstElement *sink, *src, *pipeline;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GstPad *srcpad, *sinkpad;
GTimeVal tv;
gst_object_unref (sinkpad);
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_NO_PREROLL, "no no_preroll state return");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
+ "no no_preroll state return");
ret = gst_element_get_state (src, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
GST_TIME_TO_TIMEVAL (0, tv);
ret = gst_element_get_state (pipeline, ¤t, &pending, &tv);
- fail_unless (ret == GST_STATE_ASYNC, "not async");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
GST_START_TEST (test_livesrc_sink)
{
GstElement *sink, *src, *pipeline;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GstPad *srcpad, *sinkpad;
pipeline = gst_pipeline_new ("pipeline");
gst_object_unref (sinkpad);
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_NO_PREROLL, "no no_preroll state return");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
+ "no no_preroll state return");
ret = gst_element_get_state (src, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_SUCCESS, "cannot force play");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot force play");
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_SUCCESS, "not playing");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
fail_unless (current == GST_STATE_PLAYING, "not playing");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
}
@GST_ELEMENT_UNPARENTING:
@GST_ELEMENT_FLAG_LAST:
-<!-- ##### MACRO GST_NUM_STATES ##### -->
-<para>
-The maximun number of states.
-</para>
-
-
-
<!-- ##### MACRO GST_STATE ##### -->
<para>
This macro returns the current state of the element.
@obj: Element to return the pending state for.
-<!-- ##### MACRO GST_STATE_TRANSITION ##### -->
-<para>
-Returns the state transition this object is going through.
-</para>
-
-@obj: the Element to return the state transition for
-
-
-<!-- ##### MACRO GST_STATE_NULL_TO_READY ##### -->
-<para>
-The Element is going from the NULL state to the READY state.
-</para>
-
-
-
-<!-- ##### MACRO GST_STATE_READY_TO_PAUSED ##### -->
-<para>
-The Element is going from the READY state to the PAUSED state.
-</para>
-
-
-
-<!-- ##### MACRO GST_STATE_PAUSED_TO_PLAYING ##### -->
-<para>
-The Element is going from the PAUSED state to the PLAYING state.
-</para>
-
-
-
-<!-- ##### MACRO GST_STATE_PLAYING_TO_PAUSED ##### -->
-<para>
-The Element is going from the PLAYING state to the PAUSED state.
-</para>
-
-
-
-<!-- ##### MACRO GST_STATE_PAUSED_TO_READY ##### -->
-<para>
-The Element is going from the PAUSED state to the READY state.
-</para>
-
-
-
-<!-- ##### MACRO GST_STATE_READY_TO_NULL ##### -->
-<para>
-The Element is going from the READY state to the NULL state.
-</para>
-
-
-
<!-- ##### MACRO GST_STATE_BROADCAST ##### -->
<para>
<!-- ##### SECTION Stability_Level ##### -->
-<!-- ##### ENUM GstElementState ##### -->
-<para>
-These contants describe the state a #GstElement is in and transition scheduled for the #GstElement (the pending state).
-</para>
-
-@GST_STATE_VOID_PENDING: no transition is schedules for this element
-@GST_STATE_NULL: this is the default state all elements are in, after they have been created and are doing nothing
-@GST_STATE_READY: the element is ready to start doing something
-@GST_STATE_PAUSED: the element is paused for a period of time
-@GST_STATE_PLAYING: the element is doing something
-
-<!-- ##### ENUM GstElementStateReturn ##### -->
-<para>
-One of these values is returned from a gst_element_set_state() call.
-As GST_STATE_FAILURE is equal to 0, one can use a boolean comparission
-against the GstElementStateReturn value.
-</para>
-
-@GST_STATE_FAILURE: the state of the element could not be changed
-@GST_STATE_SUCCESS: the state of the element has already be changed
-@GST_STATE_ASYNC: the state of the element will change in the near future
-@GST_STATE_NO_PREROLL:
-
<!-- ##### ENUM GstRank ##### -->
<para>
Element priority ranks. Defines the order in which the autoplugger (or similar
make_pipeline ();
while (i < argc) {
- GstElementStateReturn sret;
- GstElementState state;
+ GstStateChangeReturn sret;
+ GstState state;
filename = argv[i];
g_object_set (source, "location", filename, NULL);
* otherwise the state change fails */
sret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
- if (GST_STATE_ASYNC == sret) {
- if (GST_STATE_FAILURE ==
+ if (GST_STATE_CHANGE_ASYNC == sret) {
+ if (GST_STATE_CHANGE_FAILURE ==
gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL)) {
g_print ("State change failed. Aborting");
break;
}
- } else if (sret != GST_STATE_SUCCESS) {
+ } else if (sret != GST_STATE_CHANGE_SUCCESS) {
g_print ("%s - Could not read file\n", argv[i]);
} else {
GstTagList *tags = NULL;
g_print ("No metadata found for %s\n", argv[i]);
sret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
- if (GST_STATE_ASYNC == sret) {
- if (GST_STATE_FAILURE ==
+ if (GST_STATE_CHANGE_ASYNC == sret) {
+ if (GST_STATE_CHANGE_FAILURE ==
gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL))
{
g_print ("State change failed. Aborting");
const GValue * value, GParamSpec * pspec);
static void gst_example_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_example_change_state (GstElement * element);
+static GstStateChangeReturn gst_example_change_state (GstElement * element,
+ GstStateChange transition);
/* The parent class pointer needs to be kept around for some object
* operations.
* The plugin can prepare itself and its internal data structures
* in the various state transitions.
*/
-static GstElementStateReturn
-gst_example_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_example_change_state (GstElement * element, GstStateChange transition)
{
GstExample *example;
/* we perform our actions based on the state transition
* of the element */
- switch (GST_STATE_TRANSITION (element)) {
+ switch (transition) {
/* The NULL to READY transition is used to
* create threads (if any), and/or open devices */
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
/* In the PAUSED to PLAYING state, the element should
* prepare itself for operation or continue after a PAUSE */
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
/* In the PLAYING to PAUSED state, the element should
* PAUSE itself and make sure it can resume operation */
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
/* In the PAUSED to READY state, the element should reset
* its internal state and close any devices. */
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
/* The element should free all resources, terminate threads
* and put itself into its initial state again */
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
}
/* Then we call the parent state change handler */
- return parent_class->change_state (element);
+ return parent_class->change_state (element, transition);
}
static void gst_base_sink_get_times (GstBaseSink * basesink, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end);
-static GstElementStateReturn gst_base_sink_change_state (GstElement * element);
+static GstStateChangeReturn gst_base_sink_change_state (GstElement * element,
+ GstStateChange transition);
static GstFlowReturn gst_base_sink_chain (GstPad * pad, GstBuffer * buffer);
static void gst_base_sink_loop (GstPad * pad);
return result;
}
-static GstElementStateReturn
-gst_base_sink_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_base_sink_change_state (GstElement * element, GstStateChange transition)
{
- GstElementStateReturn ret = GST_STATE_SUCCESS;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstBaseSink *basesink = GST_BASE_SINK (element);
- GstElementState transition = GST_STATE_TRANSITION (element);
GstBaseSinkClass *bclass;
bclass = GST_BASE_SINK_GET_CLASS (basesink);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
if (bclass->start)
if (!bclass->start (basesink))
goto start_failed;
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
/* need to complete preroll before this state change completes, there
* is no data flow in READY so we can safely assume we need to preroll. */
basesink->offset = 0;
basesink->segment_rate = 1.0;
basesink->segment_start = 0;
basesink->segment_stop = 0;
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
{
GST_PREROLL_LOCK (basesink->sinkpad);
/* if we have EOS, we should empty the queue now as there will
/* don't need preroll, but do queue a commit_state */
basesink->need_preroll = FALSE;
basesink->playing_async = TRUE;
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
/* we know it's not waiting, no need to signal */
} else {
/* don't need the preroll anymore */
}
{
- GstElementStateReturn bret;
+ GstStateChangeReturn bret;
- bret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ bret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (bret != GST_STATE_SUCCESS)
+ if (bret != GST_STATE_CHANGE_SUCCESS)
goto activate_failed;
}
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
{
GstBaseSinkClass *bclass;
basesink->eos);
if (!basesink->have_preroll && !basesink->eos) {
basesink->need_preroll = TRUE;
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
}
GST_PREROLL_UNLOCK (basesink->sinkpad);
break;
}
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
if (bclass->stop)
if (!bclass->stop (basesink)) {
GST_WARNING ("failed to stop");
start_failed:
{
GST_DEBUG ("failed to start");
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
activate_failed:
{
GST_DEBUG ("element failed to change states -- activation problem?");
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
}
static gboolean gst_base_src_start (GstBaseSrc * basesrc);
static gboolean gst_base_src_stop (GstBaseSrc * basesrc);
-static GstElementStateReturn gst_base_src_change_state (GstElement * element);
+static GstStateChangeReturn gst_base_src_change_state (GstElement * element,
+ GstStateChange transition);
static void gst_base_src_loop (GstPad * pad);
static gboolean gst_base_src_check_get_range (GstPad * pad);
}
}
-static GstElementStateReturn
-gst_base_src_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_base_src_change_state (GstElement * element, GstStateChange transition)
{
GstBaseSrc *basesrc;
- GstElementStateReturn result = GST_STATE_SUCCESS;
- GstElementStateReturn presult;
- GstElementState transition;
+ GstStateChangeReturn result = GST_STATE_CHANGE_SUCCESS;
+ GstStateChangeReturn presult;
basesrc = GST_BASE_SRC (element);
- transition = GST_STATE_TRANSITION (element);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_LIVE_LOCK (element);
if (basesrc->is_live) {
- result = GST_STATE_NO_PREROLL;
+ result = GST_STATE_CHANGE_NO_PREROLL;
basesrc->live_running = FALSE;
}
GST_LIVE_UNLOCK (element);
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
GST_LIVE_LOCK (element);
if (basesrc->is_live) {
basesrc->live_running = TRUE;
break;
}
- if ((presult = GST_ELEMENT_CLASS (parent_class)->change_state (element)) !=
- GST_STATE_SUCCESS) {
+ if ((presult =
+ GST_ELEMENT_CLASS (parent_class)->change_state (element,
+ transition)) != GST_STATE_CHANGE_SUCCESS) {
gst_base_src_stop (basesrc);
return presult;
}
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
GST_LIVE_LOCK (element);
if (basesrc->is_live) {
- result = GST_STATE_NO_PREROLL;
+ result = GST_STATE_CHANGE_NO_PREROLL;
basesrc->live_running = FALSE;
}
GST_LIVE_UNLOCK (element);
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
if (!gst_base_src_stop (basesrc))
- result = GST_STATE_FAILURE;
+ result = GST_STATE_CHANGE_FAILURE;
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
static gboolean gst_base_transform_get_unit_size (GstBaseTransform * trans,
GstCaps * caps, guint * size);
-static GstElementStateReturn gst_base_transform_change_state (GstElement *
- element);
+static GstStateChangeReturn gst_base_transform_change_state (GstElement *
+ element, GstStateChange transition);
static gboolean gst_base_transform_event (GstPad * pad, GstEvent * event);
static GstFlowReturn gst_base_transform_getrange (GstPad * pad, guint64 offset,
return result;
}
-static GstElementStateReturn
-gst_base_transform_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_base_transform_change_state (GstElement * element,
+ GstStateChange transition)
{
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
- GstElementState transition;
- GstElementStateReturn result;
+ GstStateChangeReturn result;
trans = GST_BASE_TRANSFORM (element);
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
- transition = GST_STATE_TRANSITION (element);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_LOCK (trans);
if (GST_PAD_CAPS (trans->sinkpad) && GST_PAD_CAPS (trans->srcpad))
trans->in_place = gst_caps_is_equal (GST_PAD_CAPS (trans->sinkpad),
trans->negotiated = FALSE;
GST_UNLOCK (trans);
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
- result = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
if (bclass->stop)
result = bclass->stop (trans);
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
GST_DEBUG ("teardown_element");
fail_unless (gst_element_set_state (element, GST_STATE_NULL) ==
- GST_STATE_SUCCESS, "could not set to null");
+ GST_STATE_CHANGE_SUCCESS, "could not set to null");
ASSERT_OBJECT_REFCOUNT (element, "element", 1);
gst_object_unref (element);
}
static void gst_fake_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_fake_sink_change_state (GstElement * element);
+static GstStateChangeReturn gst_fake_sink_change_state (GstElement * element,
+ GstStateChange transition);
static GstFlowReturn gst_fake_sink_preroll (GstBaseSink * bsink,
GstBuffer * buffer);
return GST_FLOW_OK;
}
-static GstElementStateReturn
-gst_fake_sink_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_fake_sink_change_state (GstElement * element, GstStateChange transition)
{
- GstElementStateReturn ret = GST_STATE_SUCCESS;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstFakeSink *fakesink = GST_FAKE_SINK (element);
- GstElementState transition = GST_STATE_TRANSITION (element);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_NULL_READY)
goto error;
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_PAUSED)
goto error;
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PAUSED_PLAYING)
goto error;
break;
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PLAYING_PAUSED)
goto error;
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PAUSED_READY)
goto error;
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_NULL)
goto error;
g_free (fakesink->last_message);
break;
}
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
return ret;
error:
GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
static void gst_fdsrc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_fdsrc_change_state (GstElement * element);
+static GstStateChangeReturn gst_fdsrc_change_state (GstElement * element,
+ GstStateChange transition);
static GstFlowReturn gst_fdsrc_create (GstPushSrc * psrc, GstBuffer ** outbuf);
fdsrc->seq = 0;
}
-static GstElementStateReturn
-gst_fdsrc_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_fdsrc_change_state (GstElement * element, GstStateChange transition)
{
GstFdSrc *src = GST_FDSRC (element);
- switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
src->curoffset = 0;
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
default:
break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- return GST_STATE_SUCCESS;
+ return GST_STATE_CHANGE_SUCCESS;
}
static void gst_file_sink_uri_handler_init (gpointer g_iface,
gpointer iface_data);
-static GstElementStateReturn gst_file_sink_change_state (GstElement * element);
+static GstStateChangeReturn gst_file_sink_change_state (GstElement * element,
+ GstStateChange transition);
//static guint gst_file_sink_signals[LAST_SIGNAL] = { 0 };
return GST_FLOW_ERROR;
}
-static GstElementStateReturn
-gst_file_sink_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_file_sink_change_state (GstElement * element, GstStateChange transition)
{
- GstElementStateReturn ret;
- gint transition;
-
- transition = GST_STATE_TRANSITION (element);
+ GstStateChangeReturn ret;
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
if (!gst_file_sink_open_file (GST_FILE_SINK (element)))
goto open_error;
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_file_sink_close_file (GST_FILE_SINK (element));
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
open_error:
{
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
}
/* the element must be stopped in order to do this */
GST_STATE_LOCK (src);
{
- GstElementState state;
+ GstState state;
state = GST_STATE (src);
if (state != GST_STATE_READY && state != GST_STATE_NULL)
guint64 offset, guint length, GstBuffer ** buffer);
static gboolean gst_type_find_element_checkgetrange (GstPad * srcpad);
-static GstElementStateReturn
-gst_type_find_element_change_state (GstElement * element);
+static GstStateChangeReturn
+gst_type_find_element_change_state (GstElement * element,
+ GstStateChange transition);
static gboolean gst_type_find_element_activate (GstPad * pad);
static gboolean
gst_type_find_element_activate_src_pull (GstPad * pad, gboolean active);
static void
stop_typefinding (GstTypeFindElement * typefind)
{
- GstElementState state;
+ GstState state;
gboolean push_cached_buffers;
gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, NULL);
}
}
-static GstElementStateReturn
-gst_type_find_element_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_type_find_element_change_state (GstElement * element,
+ GstStateChange transition)
{
- GstElementState transition;
- GstElementStateReturn ret;
+ GstStateChangeReturn ret;
GstTypeFindElement *typefind;
typefind = GST_TYPE_FIND_ELEMENT (element);
- transition = GST_STATE_TRANSITION (element);
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_caps_replace (&typefind->caps, NULL);
break;
default:
static void gst_bin_dispose (GObject * object);
-static GstElementStateReturn gst_bin_change_state (GstElement * element);
-static GstElementStateReturn gst_bin_get_state (GstElement * element,
- GstElementState * state, GstElementState * pending, GTimeVal * timeout);
+static GstStateChangeReturn gst_bin_change_state (GstElement * element,
+ GstStateChange transition);
+static GstStateChangeReturn gst_bin_get_state (GstElement * element,
+ GstState * state, GstState * pending, GTimeVal * timeout);
static gboolean gst_bin_add_func (GstBin * bin, GstElement * element);
static gboolean gst_bin_remove_func (GstBin * bin, GstElement * element);
*
* MT safe
*/
-static GstElementStateReturn
-gst_bin_get_state (GstElement * element, GstElementState * state,
- GstElementState * pending, GTimeVal * timeout)
+static GstStateChangeReturn
+gst_bin_get_state (GstElement * element, GstState * state,
+ GstState * pending, GTimeVal * timeout)
{
GstBin *bin = GST_BIN (element);
- GstElementStateReturn ret = GST_STATE_SUCCESS;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GList *children;
guint32 children_cookie;
gboolean have_no_preroll;
switch (ret) {
/* report FAILURE immediatly */
- case GST_STATE_FAILURE:
+ case GST_STATE_CHANGE_FAILURE:
goto done;
- case GST_STATE_NO_PREROLL:
+ case GST_STATE_CHANGE_NO_PREROLL:
/* we have to continue scanning as there might be
* ERRORS too */
have_no_preroll = TRUE;
break;
- case GST_STATE_ASYNC:
+ case GST_STATE_CHANGE_ASYNC:
have_async = TRUE;
break;
default:
/* if we get here, we have no FAILURES, check for any NO_PREROLL
* elements then. */
if (have_no_preroll) {
- ret = GST_STATE_NO_PREROLL;
+ ret = GST_STATE_CHANGE_NO_PREROLL;
goto done;
}
/* if no ASYNC elements exist we don't even have to poll with a
* timeout again */
if (!have_async) {
- ret = GST_STATE_SUCCESS;
+ ret = GST_STATE_CHANGE_SUCCESS;
goto done;
}
}
}
switch (ret) {
- case GST_STATE_SUCCESS:
+ case GST_STATE_CHANGE_SUCCESS:
break;
- case GST_STATE_FAILURE:
- case GST_STATE_NO_PREROLL:
+ case GST_STATE_CHANGE_FAILURE:
+ case GST_STATE_CHANGE_NO_PREROLL:
/* report FAILURE and NO_PREROLL immediatly */
goto done;
- case GST_STATE_ASYNC:
+ case GST_STATE_CHANGE_ASYNC:
goto done;
default:
g_assert_not_reached ();
* added after this function completed. */
GST_STATE_LOCK (bin);
switch (ret) {
- case GST_STATE_SUCCESS:
+ case GST_STATE_CHANGE_SUCCESS:
/* we can commit the state */
gst_element_commit_state (element);
break;
- case GST_STATE_FAILURE:
+ case GST_STATE_CHANGE_FAILURE:
/* some element failed, abort the state change */
gst_element_abort_state (element);
break;
*/
/* FIXME, make me more elegant, want to use a topological sort algorithm
* based on indegrees (or outdegrees in our case) */
-static GstElementStateReturn
-gst_bin_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_bin_change_state (GstElement * element, GstStateChange transition)
{
GstBin *bin;
- GstElementStateReturn ret;
- GstElementState old_state, pending;
+ GstStateChangeReturn ret;
+ GstState old_state, pending;
gboolean have_async = FALSE;
gboolean have_no_preroll = FALSE;
GList *children;
gst_element_state_get_name (pending));
if (pending == GST_STATE_VOID_PENDING)
- return GST_STATE_SUCCESS;
+ return GST_STATE_CHANGE_SUCCESS;
/* Clear eosed element list on READY-> PAUSED */
- if (GST_STATE_TRANSITION (element) == GST_STATE_READY_TO_PAUSED) {
+ if (transition == GST_STATE_CHANGE_READY_TO_PAUSED) {
g_list_free (bin->eosed);
bin->eosed = NULL;
}
GST_UNLOCK (bin);
switch (ret) {
- case GST_STATE_SUCCESS:
+ case GST_STATE_CHANGE_SUCCESS:
GST_CAT_DEBUG (GST_CAT_STATES,
"child '%s' changed state to %d(%s) successfully",
GST_ELEMENT_NAME (qelement), pending,
gst_element_state_get_name (pending));
break;
- case GST_STATE_ASYNC:
+ case GST_STATE_CHANGE_ASYNC:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' is changing state asynchronously",
GST_ELEMENT_NAME (qelement));
have_async = TRUE;
break;
- case GST_STATE_FAILURE:
+ case GST_STATE_CHANGE_FAILURE:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' failed to go to state %d(%s)",
GST_ELEMENT_NAME (qelement),
pending, gst_element_state_get_name (pending));
- ret = GST_STATE_FAILURE;
+ ret = GST_STATE_CHANGE_FAILURE;
/* release refcount of element we popped off the queue */
gst_object_unref (qelement);
goto exit;
- case GST_STATE_NO_PREROLL:
+ case GST_STATE_CHANGE_NO_PREROLL:
GST_CAT_DEBUG (GST_CAT_STATES,
"child '%s' changed state to %d(%s) successfully without preroll",
GST_ELEMENT_NAME (qelement), pending,
}
if (have_no_preroll) {
- ret = GST_STATE_NO_PREROLL;
+ ret = GST_STATE_CHANGE_NO_PREROLL;
} else if (have_async) {
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
} else {
- ret = parent_class->change_state (element);
+ ret = parent_class->change_state (element, transition);
}
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
static void gst_element_dispose (GObject * object);
static void gst_element_finalize (GObject * object);
-static GstElementStateReturn gst_element_change_state (GstElement * element);
-static GstElementStateReturn gst_element_get_state_func (GstElement * element,
- GstElementState * state, GstElementState * pending, GTimeVal * timeout);
+static GstStateChangeReturn gst_element_change_state (GstElement * element,
+ GstStateChange transition);
+static GstStateChangeReturn gst_element_get_state_func (GstElement * element,
+ GstState * state, GstState * pending, GTimeVal * timeout);
static void gst_element_set_bus_func (GstElement * element, GstBus * bus);
#ifndef GST_DISABLE_LOADSAVE
* @old_state: the GST_STATE_XXX before the change
* @new_state: the GST_STATE_XXX after the change
*
- * the #GstElementState of the element has been changed
+ * the #GstState of the element has been changed
*/
gst_element_signals[STATE_CHANGE] =
g_signal_new ("state-changed", G_TYPE_FROM_CLASS (klass),
GST_ELEMENT_NAME (parent),
gst_element_state_get_name (GST_STATE (parent)));
- if (gst_element_set_state (element, GST_STATE (parent)) == GST_STATE_FAILURE) {
+ if (gst_element_set_state (element,
+ GST_STATE (parent)) == GST_STATE_CHANGE_FAILURE) {
return FALSE;
}
return TRUE;
}
/* MT safe */
-static GstElementStateReturn
+static GstStateChangeReturn
gst_element_get_state_func (GstElement * element,
- GstElementState * state, GstElementState * pending, GTimeVal * timeout)
+ GstState * state, GstState * pending, GTimeVal * timeout)
{
- GstElementStateReturn ret = GST_STATE_FAILURE;
- GstElementState old_pending;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
+ GstState old_pending;
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "getting state");
GST_STATE_LOCK (element);
/* we got an error, report immediatly */
if (GST_STATE_NO_PREROLL (element)) {
- ret = GST_STATE_NO_PREROLL;
+ ret = GST_STATE_CHANGE_NO_PREROLL;
goto done;
}
/* we got an error, report immediatly */
if (GST_STATE_ERROR (element)) {
- ret = GST_STATE_FAILURE;
+ ret = GST_STATE_CHANGE_FAILURE;
goto done;
}
if (!GST_STATE_TIMED_WAIT (element, timeval)) {
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "timeout");
/* timeout triggered */
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
} else {
/* could be success or failure */
if (old_pending == GST_STATE (element)) {
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "got success");
- ret = GST_STATE_SUCCESS;
+ ret = GST_STATE_CHANGE_SUCCESS;
} else {
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "got failure");
- ret = GST_STATE_FAILURE;
+ ret = GST_STATE_CHANGE_FAILURE;
}
}
}
/* if nothing is pending anymore we can return SUCCESS */
if (GST_STATE_PENDING (element) == GST_STATE_VOID_PENDING) {
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "nothing pending");
- ret = GST_STATE_SUCCESS;
+ ret = GST_STATE_CHANGE_SUCCESS;
}
done:
/**
* gst_element_get_state:
* @element: a #GstElement to get the state of.
- * @state: a pointer to #GstElementState to hold the state. Can be NULL.
- * @pending: a pointer to #GstElementState to hold the pending state.
+ * @state: a pointer to #GstState to hold the state. Can be NULL.
+ * @pending: a pointer to #GstState to hold the pending state.
* Can be NULL.
* @timeout: a #GTimeVal to specify the timeout for an async
* state change or NULL for infinite timeout.
* specified timeout value for the state change to complete.
* If the element completes the state change or goes into
* an error, this function returns immediatly with a return value of
- * GST_STATE_SUCCESS or GST_STATE_FAILURE respectively.
+ * GST_STATE_CHANGE_SUCCESS or GST_STATE_CHANGE_FAILURE respectively.
*
- * Returns: GST_STATE_SUCCESS if the element has no more pending state and
- * the last state change succeeded, GST_STATE_ASYNC
+ * Returns: GST_STATE_CHANGE_SUCCESS if the element has no more pending state and
+ * the last state change succeeded, GST_STATE_CHANGE_ASYNC
* if the element is still performing a state change or
- * GST_STATE_FAILURE if the last state change failed.
+ * GST_STATE_CHANGE_FAILURE if the last state change failed.
*
* MT safe.
*/
-GstElementStateReturn
+GstStateChangeReturn
gst_element_get_state (GstElement * element,
- GstElementState * state, GstElementState * pending, GTimeVal * timeout)
+ GstState * state, GstState * pending, GTimeVal * timeout)
{
GstElementClass *oclass;
- GstElementStateReturn result = GST_STATE_FAILURE;
+ GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE;
- g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
+ g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_CHANGE_FAILURE);
oclass = GST_ELEMENT_GET_CLASS (element);
void
gst_element_abort_state (GstElement * element)
{
- GstElementState pending;
+ GstState pending;
g_return_if_fail (GST_IS_ELEMENT (element));
if (pending != GST_STATE_VOID_PENDING && !GST_STATE_ERROR (element)) {
#ifndef GST_DISABLE_GST_DEBUG
- GstElementState old_state = GST_STATE (element);
+ GstState old_state = GST_STATE (element);
#endif
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
void
gst_element_commit_state (GstElement * element)
{
- GstElementState pending;
+ GstState pending;
GstMessage *message;
g_return_if_fail (GST_IS_ELEMENT (element));
pending = GST_STATE_PENDING (element);
if (pending != GST_STATE_VOID_PENDING) {
- GstElementState old_state = GST_STATE (element);
+ GstState old_state = GST_STATE (element);
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"commiting state from %s to %s", gst_element_state_get_name (old_state),
if (GST_STATE_PENDING (element) == GST_STATE_VOID_PENDING &&
!GST_STATE_ERROR (element)) {
- GstElementState current_state = GST_STATE (element);
+ GstState current_state = GST_STATE (element);
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"lost state of %s", gst_element_state_get_name (current_state));
/**
* gst_element_set_state:
* @element: a #GstElement to change state of.
- * @state: the element's new #GstElementState.
+ * @state: the element's new #GstState.
*
* Sets the state of the element. This function will try to set the
* requested state by going through all the intermediary states and calling
* the class's state change function for each.
*
- * Returns: Result of the state change using #GstElementStateReturn.
+ * Returns: Result of the state change using #GstStateChangeReturn.
*
* MT safe.
*/
-GstElementStateReturn
-gst_element_set_state (GstElement * element, GstElementState state)
+GstStateChangeReturn
+gst_element_set_state (GstElement * element, GstState state)
{
GstElementClass *oclass;
- GstElementState current;
- GstElementStateReturn return_val = GST_STATE_SUCCESS;
- GstElementStateReturn ret;
- GstElementState pending;
+ GstState current;
+ GstStateChangeReturn return_val = GST_STATE_CHANGE_SUCCESS;
+ GstStateChangeReturn ret;
+ GstState pending;
GTimeVal tv;
- g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
+ g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_CHANGE_FAILURE);
/* get current element state, need to call the method so that
* we call the virtual method and subclasses can implement their
GST_STATE_LOCK (element);
/* this is the state we should go to */
GST_STATE_FINAL (element) = state;
- if (ret == GST_STATE_ASYNC) {
+ if (ret == GST_STATE_CHANGE_ASYNC) {
gst_element_commit_state (element);
gst_element_lost_state (element);
}
* current state is equal to the required state. This is needed
* for bins that sync their children. */
do {
- GstElementState pending;
+ GstState pending;
/* calculate the pending state */
if (current < state)
- pending = current << 1;
+ pending = current + 1;
else if (current > state)
- pending = current >> 1;
+ pending = current - 1;
else
pending = current;
/* call the state change function so it can set the state */
if (oclass->change_state)
- return_val = (oclass->change_state) (element);
+ return_val = (oclass->change_state) (element, GST_STATE_CHANGE (element));
else
- return_val = GST_STATE_FAILURE;
+ return_val = GST_STATE_CHANGE_FAILURE;
/* clear the error and preroll flag, we need to do that after
* calling the virtual change_state function so that it can use the
GST_STATE_NO_PREROLL (element) = FALSE;
switch (return_val) {
- case GST_STATE_FAILURE:
+ case GST_STATE_CHANGE_FAILURE:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"have failed change_state return");
/* state change failure exits the loop */
gst_element_abort_state (element);
goto exit;
- case GST_STATE_ASYNC:
+ case GST_STATE_CHANGE_ASYNC:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"element will change state async");
/* an async state change exits the loop, we can only
* go to the next state change when this one completes. */
goto exit;
- case GST_STATE_SUCCESS:
+ case GST_STATE_CHANGE_SUCCESS:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"element changed state successfully");
/* we can commit the state now and proceed to the next state */
gst_element_commit_state (element);
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "commited state");
break;
- case GST_STATE_NO_PREROLL:
+ case GST_STATE_CHANGE_NO_PREROLL:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"element changed state successfully and can't preroll");
/* we can commit the state now and proceed to the next state */
/* somebody added a GST_STATE_ and forgot to do stuff here ! */
g_critical ("unknown return value %d from a state change function",
return_val);
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
}
}
/* is called with STATE_LOCK */
-static GstElementStateReturn
-gst_element_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_element_change_state (GstElement * element, GstStateChange transition)
{
- GstElementState old_state;
- gint old_pending, old_transition;
- GstElementStateReturn result = GST_STATE_SUCCESS;
+ GstState state, pending;
+ GstStateChangeReturn result = GST_STATE_CHANGE_SUCCESS;
- g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
+ g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_CHANGE_FAILURE);
- old_state = GST_STATE (element);
- old_pending = GST_STATE_PENDING (element);
- old_transition = GST_STATE_TRANSITION (element);
+ state = GST_STATE (element);
+ pending = GST_STATE_PENDING (element);
/* if the element already is in the given state, we just return success */
- if (old_pending == GST_STATE_VOID_PENDING ||
- old_state == GST_STATE_PENDING (element)) {
+ if (pending == GST_STATE_VOID_PENDING || state == GST_STATE_PENDING (element)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"element is already in the %s state",
- gst_element_state_get_name (old_state));
+ gst_element_state_get_name (state));
if (GST_STATE_NO_PREROLL (element))
- return GST_STATE_NO_PREROLL;
+ return GST_STATE_CHANGE_NO_PREROLL;
else
- return GST_STATE_SUCCESS;
+ return GST_STATE_CHANGE_SUCCESS;
}
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
"default handler tries setting state from %s to %s (%04x)",
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (old_pending), old_transition);
+ gst_element_state_get_name (state),
+ gst_element_state_get_name (pending), transition);
- switch (old_transition) {
- case GST_STATE_NULL_TO_READY:
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
if (!gst_element_pads_activate (element, TRUE)) {
- result = GST_STATE_FAILURE;
+ result = GST_STATE_CHANGE_FAILURE;
}
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_READY:
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_READY_TO_NULL:
/* deactivate pads in both cases, since they are activated on
ready->paused but the element might not have made it to paused */
if (!gst_element_pads_activate (element, FALSE)) {
- result = GST_STATE_FAILURE;
+ result = GST_STATE_CHANGE_FAILURE;
} else {
GST_LOCK (element);
element->base_time = 0;
* - somehow the element was asked to jump across an intermediate state
*/
g_warning ("Unhandled state change from %s to %s",
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (old_pending));
+ gst_element_state_get_name (state),
+ gst_element_state_get_name (pending));
break;
}
typedef struct _GstElement GstElement;
typedef struct _GstElementClass GstElementClass;
-/* gstmessage.h needs ElementState */
-#define GST_NUM_STATES 4
+/* gstmessage.h needs State */
typedef enum {
- GST_STATE_VOID_PENDING = 0,
- GST_STATE_NULL = (1 << 0),
- GST_STATE_READY = (1 << 1),
- GST_STATE_PAUSED = (1 << 2),
- GST_STATE_PLAYING = (1 << 3)
-} GstElementState;
+ GST_STATE_VOID_PENDING = 0, /* used for GstElement->pending_state when
+ there is no pending state */
+ GST_STATE_NULL = 1,
+ GST_STATE_READY = 2,
+ GST_STATE_PAUSED = 3,
+ GST_STATE_PLAYING = 4
+} GstState;
#include <gst/gstconfig.h>
#define GST_ELEMENT_CAST(obj) ((GstElement*)(obj))
typedef enum {
- GST_STATE_FAILURE = 0,
- GST_STATE_SUCCESS = 1,
- GST_STATE_ASYNC = 2,
- GST_STATE_NO_PREROLL = 3
-} GstElementStateReturn;
+ GST_STATE_CHANGE_FAILURE = 0,
+ GST_STATE_CHANGE_SUCCESS = 1,
+ GST_STATE_CHANGE_ASYNC = 2,
+ GST_STATE_CHANGE_NO_PREROLL = 3
+} GstStateChangeReturn;
/* NOTE: this probably should be done with an #ifdef to decide
* whether to safe-cast or to just do the non-checking cast.
#define GST_STATE_ERROR(obj) (GST_ELEMENT(obj)->state_error)
#define GST_STATE_NO_PREROLL(obj) (GST_ELEMENT(obj)->no_preroll)
-/* Note: using 8 bit shift mostly "just because", it leaves us enough room to grow <g> */
-#define GST_STATE_TRANSITION(obj) ((GST_STATE(obj)<<8) | GST_STATE_PENDING(obj))
-#define GST_STATE_NULL_TO_READY ((GST_STATE_NULL<<8) | GST_STATE_READY)
-#define GST_STATE_READY_TO_PAUSED ((GST_STATE_READY<<8) | GST_STATE_PAUSED)
-#define GST_STATE_PAUSED_TO_PLAYING ((GST_STATE_PAUSED<<8) | GST_STATE_PLAYING)
-#define GST_STATE_PLAYING_TO_PAUSED ((GST_STATE_PLAYING<<8) | GST_STATE_PAUSED)
-#define GST_STATE_PAUSED_TO_READY ((GST_STATE_PAUSED<<8) | GST_STATE_READY)
-#define GST_STATE_READY_TO_NULL ((GST_STATE_READY<<8) | GST_STATE_NULL)
+#ifndef GST_DEBUG_STATE_CHANGE
+#define GST_STATE_CHANGE(obj) ((1<<(GST_STATE(obj)+8)) | 1<<GST_STATE_PENDING(obj))
+#else
+inline GstStateChange
+_gst_element_get_state_change (GstElement *e)
+{
+ if (e->state < GST_STATE_NULL || e->state > GST_STATE_PLAYING)
+ g_assert_not_reached ();
+ if (e->pending_state < GST_STATE_NULL || e->pending_state > GST_STATE_PLAYING)
+ g_assert_not_reached ();
+ if (e->state - e->pending_state != 1 && e->pending_state - e->state != 1)
+ g_assert_not_reached ();
+ return (1<<(GST_STATE(obj)+8)) | 1<<GST_STATE_PENDING(obj);
+}
+#define GST_STATE_CHANGE(obj) _gst_element_get_state_change(obj)
+#endif
+
+/* FIXME: How to deal with lost_state ? */
+typedef enum
+{
+ GST_STATE_CHANGE_NULL_TO_READY = 1<<(GST_STATE_NULL+8) | 1<<GST_STATE_READY,
+ GST_STATE_CHANGE_READY_TO_PAUSED = 1<<(GST_STATE_READY+8) | 1<<GST_STATE_PAUSED,
+ GST_STATE_CHANGE_PAUSED_TO_PLAYING = 1<<(GST_STATE_PAUSED+8) | 1<<GST_STATE_PLAYING,
+ GST_STATE_CHANGE_PLAYING_TO_PAUSED = 1<<(GST_STATE_PLAYING+8) | 1<<GST_STATE_PAUSED,
+ GST_STATE_CHANGE_PAUSED_TO_READY = 1<<(GST_STATE_PAUSED+8) | 1<<GST_STATE_READY,
+ GST_STATE_CHANGE_READY_TO_NULL = 1<<(GST_STATE_READY+8) | 1<<GST_STATE_NULL
+} GstStateChange;
typedef enum
{
/*< private >*/
/* signal callbacks */
- void (*state_changed) (GstElement *element, GstElementState old, GstElementState state);
+ void (*state_changed) (GstElement *element, GstState old, GstState state);
void (*pad_added) (GstElement *element, GstPad *pad);
void (*pad_removed) (GstElement *element, GstPad *pad);
void (*no_more_pads) (GstElement *element);
void (*release_pad) (GstElement *element, GstPad *pad);
/* state changes */
- GstElementStateReturn (*get_state) (GstElement * element, GstElementState * state,
- GstElementState * pending, GTimeVal * timeout);
- GstElementStateReturn (*change_state) (GstElement *element);
+ GstStateChangeReturn (*get_state) (GstElement * element, GstState * state,
+ GstState * pending, GTimeVal * timeout);
+ GstStateChangeReturn (*change_state) (GstElement *element, GstStateChange transition);
/* bus */
void (*set_bus) (GstElement * element, GstBus * bus);
gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state);
gboolean gst_element_sync_state_with_parent (GstElement *element);
-GstElementStateReturn gst_element_get_state (GstElement * element,
- GstElementState * state,
- GstElementState * pending,
+GstStateChangeReturn gst_element_get_state (GstElement * element,
+ GstState * state,
+ GstState * pending,
GTimeVal * timeout);
-GstElementStateReturn gst_element_set_state (GstElement *element, GstElementState state);
+GstStateChangeReturn gst_element_set_state (GstElement *element, GstState state);
void gst_element_abort_state (GstElement * element);
void gst_element_commit_state (GstElement * element);
* MT safe.
*/
GstMessage *
-gst_message_new_state_changed (GstObject * src, GstElementState old,
- GstElementState new)
+gst_message_new_state_changed (GstObject * src, GstState old, GstState new)
{
GstMessage *message;
GstStructure *s;
* MT safe.
*/
void
-gst_message_parse_state_changed (GstMessage * message, GstElementState * old,
- GstElementState * new)
+gst_message_parse_state_changed (GstMessage * message, GstState * old,
+ GstState * new)
{
g_return_if_fail (GST_IS_MESSAGE (message));
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
GstMessage * gst_message_new_error (GstObject * src, GError * error, gchar * debug);
GstMessage * gst_message_new_warning (GstObject * src, GError * error, gchar * debug);
GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list);
-GstMessage * gst_message_new_state_changed (GstObject * src, GstElementState old_state,
- GstElementState new_state);
+GstMessage * gst_message_new_state_changed (GstObject * src, GstState old_state,
+ GstState new_state);
GstMessage * gst_message_new_segment_start (GstObject * src, GstClockTime timestamp);
GstMessage * gst_message_new_segment_done (GstObject * src, GstClockTime timestamp);
GstMessage * gst_message_new_custom (GstMessageType type,
void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug);
void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug);
void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
-void gst_message_parse_state_changed (GstMessage *message, GstElementState *old_state,
- GstElementState *new_state);
+void gst_message_parse_state_changed (GstMessage *message, GstState *old_state,
+ GstState *new_state);
void gst_message_parse_segment_start (GstMessage *message, GstClockTime *timestamp);
void gst_message_parse_segment_done (GstMessage *message, GstClockTime *timestamp);
GstEvent * event);
static GstClock *gst_pipeline_get_clock_func (GstElement * element);
-static GstElementStateReturn gst_pipeline_change_state (GstElement * element);
+static GstStateChangeReturn gst_pipeline_change_state (GstElement * element,
+ GstStateChange transition);
static GstBinClass *parent_class = NULL;
{
gboolean was_playing;
gboolean res;
- GstElementState state;
+ GstState state;
GstEventType event_type = GST_EVENT_TYPE (event);
GTimeVal timeout;
}
/* MT safe */
-static GstElementStateReturn
-gst_pipeline_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_pipeline_change_state (GstElement * element, GstStateChange transition)
{
- GstElementStateReturn result = GST_STATE_SUCCESS;
+ GstStateChangeReturn result = GST_STATE_CHANGE_SUCCESS;
GstPipeline *pipeline = GST_PIPELINE (element);
- gint transition = GST_STATE_TRANSITION (element);
GstClockTime play_timeout;
GstClock *clock;
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
GST_LOCK (element);
if (element->bus)
gst_bus_set_flushing (element->bus, FALSE);
GST_UNLOCK (element);
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
/* when going to playing, select a clock */
if ((clock = gst_element_get_clock (element))) {
GstClockTime start_time;
gst_element_set_base_time (element, 0);
}
break;
- case GST_STATE_PLAYING_TO_PAUSED:
- case GST_STATE_PAUSED_TO_READY:
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
}
- result = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ break;
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
gst_pipeline_set_new_stream_time (pipeline, 0);
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
GST_LOCK (element);
if ((clock = element->clock)) {
GstClockTime now;
}
GST_UNLOCK (element);
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
GST_LOCK (element);
if (element->bus) {
gst_bus_set_flushing (element->bus, TRUE);
break;
}
- if (result == GST_STATE_ASYNC) {
+ if (result == GST_STATE_CHANGE_ASYNC) {
GST_LOCK (pipeline);
play_timeout = pipeline->play_timeout;
GST_UNLOCK (pipeline);
}
result = gst_element_get_state (element, NULL, NULL, timeval);
- if (result == GST_STATE_ASYNC) {
+ if (result == GST_STATE_CHANGE_ASYNC) {
GST_WARNING_OBJECT (pipeline,
"timeout in PREROLL, forcing next state change");
g_warning ("timeout in PREROLL, forcing next state change");
- result = GST_STATE_SUCCESS;
+ result = GST_STATE_CHANGE_SUCCESS;
}
GST_STATE_LOCK (pipeline);
static gboolean gst_queue_src_activate_push (GstPad * pad, gboolean active);
static gboolean gst_queue_sink_activate_push (GstPad * pad, gboolean active);
-static GstElementStateReturn gst_queue_change_state (GstElement * element);
+static GstStateChangeReturn gst_queue_change_state (GstElement * element,
+ GstStateChange transition);
#define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ())
return result;
}
-static GstElementStateReturn
-gst_queue_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_queue_change_state (GstElement * element, GstStateChange transition)
{
GstQueue *queue;
- GstElementStateReturn ret = GST_STATE_SUCCESS;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
queue = GST_QUEUE (element);
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, "starting state change");
- switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ switch (transition) {
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
/**
* gst_element_state_get_name:
- * @state: a #GstElementState to get the name of.
+ * @state: a #GstState to get the name of.
*
* Gets a string representing the given state.
*
* Returns: a string with the name of the state.
*/
const gchar *
-gst_element_state_get_name (GstElementState state)
+gst_element_state_get_name (GstState state)
{
switch (state) {
#ifdef GST_DEBUG_COLOR
if (filter) {
GstElement *capsfilter;
GstObject *parent;
- GstElementState state, pending;
+ GstState state, pending;
GTimeVal tv;
capsfilter = gst_element_factory_make ("capsfilter", NULL);
static void
get_state_func (GstElement * element, gpointer unused)
{
- GstElementStateReturn ret = GST_STATE_ASYNC;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_ASYNC;
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"new thread waiting on state change");
/* wait indefinitely */
- while (ret == GST_STATE_ASYNC)
+ while (ret == GST_STATE_CHANGE_ASYNC)
ret = gst_element_get_state (element, NULL, NULL, NULL);
gst_object_unref (element);
*
* Spawns a thread calling gst_element_get_state on @bin with infinite timeout.
*
- * In practice this is done because if a bin returns %GST_STATE_ASYNC from a
+ * In practice this is done because if a bin returns %GST_STATE_CHANGE_ASYNC from a
* state change it will not commit its state until someone calls
* gst_element_get_state() on it. Thus having another thread checking the bin's
* state will ensure that a state-changed message gets posted on the bus
GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);
-G_CONST_RETURN gchar* gst_element_state_get_name (GstElementState state);
+G_CONST_RETURN gchar* gst_element_state_get_name (GstState state);
gboolean gst_element_link (GstElement *src, GstElement *dest);
gboolean gst_element_link_many (GstElement *element_1,
GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying to sync state of element with parent");
/* FIXME: it would be nice if we can figure out why it failed
(e.g. caps nego) and give an error about that instead. */
- if (gst_element_set_state (element, GST_STATE_PLAYING) == GST_STATE_FAILURE)
+ if (gst_element_set_state (element, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
}
} else {
static void gst_base_sink_get_times (GstBaseSink * basesink, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end);
-static GstElementStateReturn gst_base_sink_change_state (GstElement * element);
+static GstStateChangeReturn gst_base_sink_change_state (GstElement * element,
+ GstStateChange transition);
static GstFlowReturn gst_base_sink_chain (GstPad * pad, GstBuffer * buffer);
static void gst_base_sink_loop (GstPad * pad);
return result;
}
-static GstElementStateReturn
-gst_base_sink_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_base_sink_change_state (GstElement * element, GstStateChange transition)
{
- GstElementStateReturn ret = GST_STATE_SUCCESS;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstBaseSink *basesink = GST_BASE_SINK (element);
- GstElementState transition = GST_STATE_TRANSITION (element);
GstBaseSinkClass *bclass;
bclass = GST_BASE_SINK_GET_CLASS (basesink);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
if (bclass->start)
if (!bclass->start (basesink))
goto start_failed;
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
/* need to complete preroll before this state change completes, there
* is no data flow in READY so we can safely assume we need to preroll. */
basesink->offset = 0;
basesink->segment_rate = 1.0;
basesink->segment_start = 0;
basesink->segment_stop = 0;
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
{
GST_PREROLL_LOCK (basesink->sinkpad);
/* if we have EOS, we should empty the queue now as there will
/* don't need preroll, but do queue a commit_state */
basesink->need_preroll = FALSE;
basesink->playing_async = TRUE;
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
/* we know it's not waiting, no need to signal */
} else {
/* don't need the preroll anymore */
}
{
- GstElementStateReturn bret;
+ GstStateChangeReturn bret;
- bret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ bret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (bret != GST_STATE_SUCCESS)
+ if (bret != GST_STATE_CHANGE_SUCCESS)
goto activate_failed;
}
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
{
GstBaseSinkClass *bclass;
basesink->eos);
if (!basesink->have_preroll && !basesink->eos) {
basesink->need_preroll = TRUE;
- ret = GST_STATE_ASYNC;
+ ret = GST_STATE_CHANGE_ASYNC;
}
GST_PREROLL_UNLOCK (basesink->sinkpad);
break;
}
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
if (bclass->stop)
if (!bclass->stop (basesink)) {
GST_WARNING ("failed to stop");
start_failed:
{
GST_DEBUG ("failed to start");
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
activate_failed:
{
GST_DEBUG ("element failed to change states -- activation problem?");
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
}
static gboolean gst_base_src_start (GstBaseSrc * basesrc);
static gboolean gst_base_src_stop (GstBaseSrc * basesrc);
-static GstElementStateReturn gst_base_src_change_state (GstElement * element);
+static GstStateChangeReturn gst_base_src_change_state (GstElement * element,
+ GstStateChange transition);
static void gst_base_src_loop (GstPad * pad);
static gboolean gst_base_src_check_get_range (GstPad * pad);
}
}
-static GstElementStateReturn
-gst_base_src_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_base_src_change_state (GstElement * element, GstStateChange transition)
{
GstBaseSrc *basesrc;
- GstElementStateReturn result = GST_STATE_SUCCESS;
- GstElementStateReturn presult;
- GstElementState transition;
+ GstStateChangeReturn result = GST_STATE_CHANGE_SUCCESS;
+ GstStateChangeReturn presult;
basesrc = GST_BASE_SRC (element);
- transition = GST_STATE_TRANSITION (element);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_LIVE_LOCK (element);
if (basesrc->is_live) {
- result = GST_STATE_NO_PREROLL;
+ result = GST_STATE_CHANGE_NO_PREROLL;
basesrc->live_running = FALSE;
}
GST_LIVE_UNLOCK (element);
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
GST_LIVE_LOCK (element);
if (basesrc->is_live) {
basesrc->live_running = TRUE;
break;
}
- if ((presult = GST_ELEMENT_CLASS (parent_class)->change_state (element)) !=
- GST_STATE_SUCCESS) {
+ if ((presult =
+ GST_ELEMENT_CLASS (parent_class)->change_state (element,
+ transition)) != GST_STATE_CHANGE_SUCCESS) {
gst_base_src_stop (basesrc);
return presult;
}
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
GST_LIVE_LOCK (element);
if (basesrc->is_live) {
- result = GST_STATE_NO_PREROLL;
+ result = GST_STATE_CHANGE_NO_PREROLL;
basesrc->live_running = FALSE;
}
GST_LIVE_UNLOCK (element);
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
if (!gst_base_src_stop (basesrc))
- result = GST_STATE_FAILURE;
+ result = GST_STATE_CHANGE_FAILURE;
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
static gboolean gst_base_transform_get_unit_size (GstBaseTransform * trans,
GstCaps * caps, guint * size);
-static GstElementStateReturn gst_base_transform_change_state (GstElement *
- element);
+static GstStateChangeReturn gst_base_transform_change_state (GstElement *
+ element, GstStateChange transition);
static gboolean gst_base_transform_event (GstPad * pad, GstEvent * event);
static GstFlowReturn gst_base_transform_getrange (GstPad * pad, guint64 offset,
return result;
}
-static GstElementStateReturn
-gst_base_transform_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_base_transform_change_state (GstElement * element,
+ GstStateChange transition)
{
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
- GstElementState transition;
- GstElementStateReturn result;
+ GstStateChangeReturn result;
trans = GST_BASE_TRANSFORM (element);
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
- transition = GST_STATE_TRANSITION (element);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_LOCK (trans);
if (GST_PAD_CAPS (trans->sinkpad) && GST_PAD_CAPS (trans->srcpad))
trans->in_place = gst_caps_is_equal (GST_PAD_CAPS (trans->sinkpad),
trans->negotiated = FALSE;
GST_UNLOCK (trans);
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
- result = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
if (bclass->stop)
result = bclass->stop (trans);
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
GST_DEBUG ("teardown_element");
fail_unless (gst_element_set_state (element, GST_STATE_NULL) ==
- GST_STATE_SUCCESS, "could not set to null");
+ GST_STATE_CHANGE_SUCCESS, "could not set to null");
ASSERT_OBJECT_REFCOUNT (element, "element", 1);
gst_object_unref (element);
}
static void gst_fake_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_fake_sink_change_state (GstElement * element);
+static GstStateChangeReturn gst_fake_sink_change_state (GstElement * element,
+ GstStateChange transition);
static GstFlowReturn gst_fake_sink_preroll (GstBaseSink * bsink,
GstBuffer * buffer);
return GST_FLOW_OK;
}
-static GstElementStateReturn
-gst_fake_sink_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_fake_sink_change_state (GstElement * element, GstStateChange transition)
{
- GstElementStateReturn ret = GST_STATE_SUCCESS;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstFakeSink *fakesink = GST_FAKE_SINK (element);
- GstElementState transition = GST_STATE_TRANSITION (element);
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_NULL_READY)
goto error;
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_PAUSED)
goto error;
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PAUSED_PLAYING)
goto error;
break;
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PLAYING_PAUSED)
goto error;
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PAUSED_READY)
goto error;
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_NULL)
goto error;
g_free (fakesink->last_message);
break;
}
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
return ret;
error:
GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
static void gst_fdsrc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_fdsrc_change_state (GstElement * element);
+static GstStateChangeReturn gst_fdsrc_change_state (GstElement * element,
+ GstStateChange transition);
static GstFlowReturn gst_fdsrc_create (GstPushSrc * psrc, GstBuffer ** outbuf);
fdsrc->seq = 0;
}
-static GstElementStateReturn
-gst_fdsrc_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_fdsrc_change_state (GstElement * element, GstStateChange transition)
{
GstFdSrc *src = GST_FDSRC (element);
- switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
src->curoffset = 0;
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
default:
break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- return GST_STATE_SUCCESS;
+ return GST_STATE_CHANGE_SUCCESS;
}
static void gst_file_sink_uri_handler_init (gpointer g_iface,
gpointer iface_data);
-static GstElementStateReturn gst_file_sink_change_state (GstElement * element);
+static GstStateChangeReturn gst_file_sink_change_state (GstElement * element,
+ GstStateChange transition);
//static guint gst_file_sink_signals[LAST_SIGNAL] = { 0 };
return GST_FLOW_ERROR;
}
-static GstElementStateReturn
-gst_file_sink_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_file_sink_change_state (GstElement * element, GstStateChange transition)
{
- GstElementStateReturn ret;
- gint transition;
-
- transition = GST_STATE_TRANSITION (element);
+ GstStateChangeReturn ret;
switch (transition) {
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
if (!gst_file_sink_open_file (GST_FILE_SINK (element)))
goto open_error;
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_file_sink_close_file (GST_FILE_SINK (element));
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
open_error:
{
- return GST_STATE_FAILURE;
+ return GST_STATE_CHANGE_FAILURE;
}
}
/* the element must be stopped in order to do this */
GST_STATE_LOCK (src);
{
- GstElementState state;
+ GstState state;
state = GST_STATE (src);
if (state != GST_STATE_READY && state != GST_STATE_NULL)
static gboolean gst_queue_src_activate_push (GstPad * pad, gboolean active);
static gboolean gst_queue_sink_activate_push (GstPad * pad, gboolean active);
-static GstElementStateReturn gst_queue_change_state (GstElement * element);
+static GstStateChangeReturn gst_queue_change_state (GstElement * element,
+ GstStateChange transition);
#define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ())
return result;
}
-static GstElementStateReturn
-gst_queue_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_queue_change_state (GstElement * element, GstStateChange transition)
{
GstQueue *queue;
- GstElementStateReturn ret = GST_STATE_SUCCESS;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
queue = GST_QUEUE (element);
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, "starting state change");
- switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_PLAYING_TO_PAUSED:
+ switch (transition) {
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
guint64 offset, guint length, GstBuffer ** buffer);
static gboolean gst_type_find_element_checkgetrange (GstPad * srcpad);
-static GstElementStateReturn
-gst_type_find_element_change_state (GstElement * element);
+static GstStateChangeReturn
+gst_type_find_element_change_state (GstElement * element,
+ GstStateChange transition);
static gboolean gst_type_find_element_activate (GstPad * pad);
static gboolean
gst_type_find_element_activate_src_pull (GstPad * pad, gboolean active);
static void
stop_typefinding (GstTypeFindElement * typefind)
{
- GstElementState state;
+ GstState state;
gboolean push_cached_buffers;
gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, NULL);
}
}
-static GstElementStateReturn
-gst_type_find_element_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_type_find_element_change_state (GstElement * element,
+ GstStateChange transition)
{
- GstElementState transition;
- GstElementStateReturn ret;
+ GstStateChangeReturn ret;
GstTypeFindElement *typefind;
typefind = GST_TYPE_FIND_ELEMENT (element);
- transition = GST_STATE_TRANSITION (element);
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_caps_replace (&typefind->caps, NULL);
break;
default:
--- /dev/null
+#!/bin/bash
+
+set -e
+
+if test -z "$1" -o -n "$2"; then
+ echo "Usage: $0 FILE" >&2
+ exit 1
+fi
+
+file=$1
+
+if grep -q GstElementState $file; then
+ echo "$file: GstElementState->GstState"
+ perl -i -p -e 's/GstElementState/GstState/g' $file
+fi
+
+if grep -q GstStateReturn $file; then
+ echo "$file: GstStateReturn->GstStateChangeReturn"
+ perl -i -p -e 's/GstStateReturn/GstStateChangeReturn/g' $file
+fi
+
+if egrep 'GST_STATE_(ASYNC|SUCCESS|FAILURE|NO_PREROLL)' $file | grep -q -v 'NO_PREROLL ('; then
+ echo "$file: GST_STATE_SUCCESS -> GST_STATE_CHANGE_SUCCESS"
+ perl -i -p -e 's/GST_STATE_SUCCESS/GST_STATE_CHANGE_SUCCESS/g' $file
+ perl -i -p -e 's/GST_STATE_ASYNC/GST_STATE_CHANGE_ASYNC/g' $file
+ perl -i -p -e 's/GST_STATE_FAILURE/GST_STATE_CHANGE_FAILURE/g' $file
+ perl -i -p -e 's/GST_STATE_NO_PREROLL/GST_STATE_CHANGE_NO_PREROLL/g' $file
+ # hack around the overloaded macro in 0.9
+ perl -i -p -e 's/GST_STATE_CHANGE_NO_PREROLL \(/GST_STATE_NO_PREROLL (/g' $file
+fi
+
+if grep 'change_state (' $file | grep -q 'element)'; then
+ echo "$file: change_state (GstElement) -> change_state (GstElement, GstStateChange)"
+ perl -i -p -e 's/^(static.*)change_state \(GstElement \* element\);/$1change_state (GstElement * element,\n GstStateChange transition);/g' $file
+ perl -i -p -e 's/change_state \(GstElement \* element\)/change_state (GstElement * element, GstStateChange transition)/g' $file
+ perl -i -p -e 's/change_state \(element\)/change_state (element, transition)/g' $file
+ egrep -v '^[[:space:]]+GstState transition;' < $file > $file.tmp
+ mv $file.tmp $file
+ grep -v 'transition = ' < $file > $file.tmp
+ mv $file.tmp $file
+fi
+
+if grep -q GST_STATE_TRANSITION $file; then
+ echo "$file: CHECK ME: GST_STATE_TRANSITION (element) -> transition"
+ perl -i -p -e 's/GST_STATE_TRANSITION \(element\)/transition/g' $file
+fi
+
+if grep 'transition' $file | grep -q int; then
+ echo "$file: Removing ghetto int transitions"
+ egrep -v '^[[:space:]]+g?u?int.* transition;' < $file > $file.tmp
+ mv $file.tmp $file
+fi
+
+if egrep -q 'GST_STATE_[A-Z]+_TO_[A-Z]+' $file; then
+ echo "$file: GST_STATE_NULL_TO_READY -> GST_STATE_CHANGE_NULL_TO_READY"
+ perl -i -p -e 's/GST_STATE_([A-Z]+)_TO_([A-Z]+)/GST_STATE_CHANGE_$1_TO_$2/g' $file
+fi
+
+if grep -q GstStateReturn $file; then
+ echo "$file: GST_STATE_SUCCESS -> GST_STATE_CHANGE_SUCCESS"
+ perl -i -p -e 's/GstStateReturn/GstStateChangeReturn/g' $file
+ perl -i -p -e 's/GST_STATE_SUCCESS/GST_STATE_CHANGE_SUCCESS/g' $file
+ perl -i -p -e 's/GST_STATE_ASYNC/GST_STATE_CHANGE_ASYNC/g' $file
+ perl -i -p -e 's/GST_STATE_FAILURE/GST_STATE_CHANGE_FAILURE/g' $file
+ perl -i -p -e 's/GST_STATE_NO_PREROLL/GST_STATE_CHANGE_NO_PREROLL/g' $file
+fi
GST_TIME_ARGS (end - start), i);
start = gst_get_current_time ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
GST_TIME_ARGS (end - start), identities);
start = gst_get_current_time ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
src = setup_fakesrc ();
g_object_set (G_OBJECT (src), "num-buffers", 3, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
fail_unless (gst_element_set_state (src,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
while (!have_eos) {
g_usleep (1000);
identity = setup_identity ();
fail_unless (gst_element_set_state (identity,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing");
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
buffer = gst_buffer_new_and_alloc (4);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
GST_START_TEST (test_sink)
{
GstElement *sink;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GTimeVal tv;
sink = gst_element_factory_make ("fakesink", "sink");
ret = gst_element_set_state (sink, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_ASYNC, "no async state return");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_ASYNC, "no forced async state change");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no forced async state change");
GST_TIME_TO_TIMEVAL ((GstClockTime) 0, tv);
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
- fail_unless (ret == GST_STATE_ASYNC, "not changing state async");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
fail_unless (current == GST_STATE_PAUSED, "bad current state");
fail_unless (pending == GST_STATE_PLAYING, "bad pending state");
ret = gst_element_set_state (sink, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_ASYNC, "no async going back to paused");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async going back to paused");
ret = gst_element_set_state (sink, GST_STATE_READY);
- fail_unless (ret == GST_STATE_SUCCESS, "failed to go to ready");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to ready");
gst_object_unref (sink);
}
GST_START_TEST (test_src_sink)
{
GstElement *sink, *src, *pipeline;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GstPad *srcpad, *sinkpad;
pipeline = gst_pipeline_new ("pipeline");
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
ret = gst_element_get_state (pipeline, NULL, NULL, NULL);
- fail_unless (ret == GST_STATE_SUCCESS, "no success state return");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_SUCCESS, "cannot start play");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot start play");
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_SUCCESS, "not playing");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
fail_unless (current == GST_STATE_PLAYING, "not playing");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
}
GST_START_TEST (test_livesrc_remove)
{
GstElement *sink, *src, *pipeline;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GstPad *srcpad, *sinkpad;
GTimeVal tv;
gst_object_unref (sinkpad);
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_NO_PREROLL, "no no_preroll state return");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
+ "no no_preroll state return");
ret = gst_element_get_state (src, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
GST_TIME_TO_TIMEVAL (0, tv);
ret = gst_element_get_state (pipeline, ¤t, &pending, &tv);
- fail_unless (ret == GST_STATE_ASYNC, "not async");
+ fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
GST_START_TEST (test_livesrc_sink)
{
GstElement *sink, *src, *pipeline;
- GstElementStateReturn ret;
- GstElementState current, pending;
+ GstStateChangeReturn ret;
+ GstState current, pending;
GstPad *srcpad, *sinkpad;
pipeline = gst_pipeline_new ("pipeline");
gst_object_unref (sinkpad);
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
- fail_unless (ret == GST_STATE_NO_PREROLL, "no no_preroll state return");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
+ "no no_preroll state return");
ret = gst_element_get_state (src, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
+ fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
fail_unless (current == GST_STATE_PAUSED, "not paused");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_SUCCESS, "cannot force play");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot force play");
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
- fail_unless (ret == GST_STATE_SUCCESS, "not playing");
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
fail_unless (current == GST_STATE_PLAYING, "not playing");
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
}
* - second for bin, causing an incref on the bin */
GST_DEBUG ("setting bin to READY");
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
ASSERT_OBJECT_REFCOUNT (src, "src", 2);
ASSERT_OBJECT_REFCOUNT (bin, "bin", 2);
/* change state to READY, spawning three messages */
GST_DEBUG ("setting pipeline to READY");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by a message */
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
/* change state to PAUSED, spawning three messages */
GST_DEBUG ("setting pipeline to PAUSED");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by a message;
* base_sink_chain has taken a refcount on the sink, and is blocked on
/* change state to PLAYING, spawning three messages */
GST_DEBUG ("setting pipeline to PLAYING");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by one message
* sink might have an extra reference if it's still blocked on preroll */
/* go back to READY, spawning six messages */
GST_DEBUG ("setting pipeline to READY");
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* each object is referenced by two messages */
ASSERT_OBJECT_REFCOUNT (src, "src", 3);
/* setting pipeline to NULL flushes the bus automatically */
fail_unless (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
/* change state, spawning two times three messages, minus one async */
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED)
- == GST_STATE_ASYNC);
+ == GST_STATE_CHANGE_ASYNC);
pop_messages (bus, 5);
"Unexpected messages on bus");
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
pop_messages (bus, 3);
/* setting bin to NULL flushes the bus automatically */
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL)
- == GST_STATE_SUCCESS);
+ == GST_STATE_CHANGE_SUCCESS);
/* clean up */
gst_object_unref (bin);
assert_gstrefcount (isrc, 3); /* parent and gsrc */
fail_unless (gst_element_set_state (b1,
- GST_STATE_PLAYING) == GST_STATE_SUCCESS);
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
- fail_unless (gst_element_set_state (b1, GST_STATE_NULL) == GST_STATE_SUCCESS);
+ fail_unless (gst_element_set_state (b1,
+ GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
gst_object_unref (b1);
/* unreffing the bin will unref all elements, which will unlink and unparent
}
/* GST_MESSAGE_STATE_CHANGED */
{
- GstElementState oldstate, newstate;
+ GstState oldstate, newstate;
oldstate = GST_STATE_PAUSED;
newstate = GST_STATE_PLAYING;
/*
void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
- void gst_message_parse_state_changed (GstMessage *message, GstElementState *old_state,
- GstElementState *new_state);
+ void gst_message_parse_state_changed (GstMessage *message, GstState *old_state,
+ GstState *new_state);
void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug);
void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug);
*/
bus = gst_element_get_bus (pipe);
g_assert (bus);
- if (gst_element_set_state (pipe, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
+ if (gst_element_set_state (pipe,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS) {
g_critical ("Couldn't set pipeline to PLAYING");
goto done;
}
GST_TIME_ARGS (end - start), i);
start = gst_get_current_time ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
GST_TIME_ARGS (end - start), identities);
start = gst_get_current_time ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
make_pipeline ();
while (i < argc) {
- GstElementStateReturn sret;
- GstElementState state;
+ GstStateChangeReturn sret;
+ GstState state;
filename = argv[i];
g_object_set (source, "location", filename, NULL);
* otherwise the state change fails */
sret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
- if (GST_STATE_ASYNC == sret) {
- if (GST_STATE_FAILURE ==
+ if (GST_STATE_CHANGE_ASYNC == sret) {
+ if (GST_STATE_CHANGE_FAILURE ==
gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL)) {
g_print ("State change failed. Aborting");
break;
}
- } else if (sret != GST_STATE_SUCCESS) {
+ } else if (sret != GST_STATE_CHANGE_SUCCESS) {
g_print ("%s - Could not read file\n", argv[i]);
} else {
GstTagList *tags = NULL;
g_print ("No metadata found for %s\n", argv[i]);
sret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
- if (GST_STATE_ASYNC == sret) {
- if (GST_STATE_FAILURE ==
+ if (GST_STATE_CHANGE_ASYNC == sret) {
+ if (GST_STATE_CHANGE_FAILURE ==
gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL))
{
g_print ("State change failed. Aborting");
const GValue * value, GParamSpec * pspec);
static void gst_example_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_example_change_state (GstElement * element);
+static GstStateChangeReturn gst_example_change_state (GstElement * element,
+ GstStateChange transition);
/* The parent class pointer needs to be kept around for some object
* operations.
* The plugin can prepare itself and its internal data structures
* in the various state transitions.
*/
-static GstElementStateReturn
-gst_example_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_example_change_state (GstElement * element, GstStateChange transition)
{
GstExample *example;
/* we perform our actions based on the state transition
* of the element */
- switch (GST_STATE_TRANSITION (element)) {
+ switch (transition) {
/* The NULL to READY transition is used to
* create threads (if any), and/or open devices */
- case GST_STATE_NULL_TO_READY:
+ case GST_STATE_CHANGE_NULL_TO_READY:
break;
- case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
/* In the PAUSED to PLAYING state, the element should
* prepare itself for operation or continue after a PAUSE */
- case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
/* In the PLAYING to PAUSED state, the element should
* PAUSE itself and make sure it can resume operation */
- case GST_STATE_PLAYING_TO_PAUSED:
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
/* In the PAUSED to READY state, the element should reset
* its internal state and close any devices. */
- case GST_STATE_PAUSED_TO_READY:
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
/* The element should free all resources, terminate threads
* and put itself into its initial state again */
- case GST_STATE_READY_TO_NULL:
+ case GST_STATE_CHANGE_READY_TO_NULL:
break;
}
/* Then we call the parent state change handler */
- return parent_class->change_state (element);
+ return parent_class->change_state (element, transition);
}
g_assert (size >= MIN_SIZE);
g_assert (size <= MAX_SIZE);
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (gst_bin_iterate (GST_BIN (pipeline)));
static void gst_bstest_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_bstest_change_state (GstElement * element);
+static GstStateChangeReturn gst_bstest_change_state (GstElement * element,
+ GstStateChange transition);
static void gst_bstest_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
}
}
-static GstElementStateReturn
-gst_bstest_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_bstest_change_state (GstElement * element, GstStateChange transition)
{
GstBsTest *bstest;
- g_return_val_if_fail (GST_IS_BSTEST (element), GST_STATE_FAILURE);
+ g_return_val_if_fail (GST_IS_BSTEST (element), GST_STATE_CHANGE_FAILURE);
bstest = GST_BSTEST (element);
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- return GST_STATE_SUCCESS;
+ return GST_STATE_CHANGE_SUCCESS;
}
static gboolean
alarm(10); \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
if (gst_element_set_state (cur, GST_STATE_PLAYING) \
- == GST_STATE_FAILURE) { \
+ == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : " \
"pipeline could not be set to PLAYING\n", test, __LINE__); \
return -test; \
iterations = 0; \
while (gst_bin_iterate (GST_BIN (cur))) iterations++; \
if (gst_element_set_state (cur, GST_STATE_NULL) \
- == GST_STATE_FAILURE) { \
+ == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : " \
"pipeline could not be reset to state NULL\n", test, __LINE__); \
return -test; \
#define TEST_RUN(iters) G_STMT_START{ \
gint it = iters; \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
- if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
+ if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : pipeline could not be set to state PLAYING\n", test, __LINE__); \
return -test; \
} \
iterations++; \
it--; \
} \
- if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
+ if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : pipeline could not be reset to state NULL\n", test, __LINE__); \
return -test; \
} \
gst_element_link_pads (src, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_iterate (GST_BIN (pipeline));
gst_element_link_pads (src, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_iterate (GST_BIN (pipeline));
gst_bin_add_many (GST_BIN (pipeline), src, tee, enc, sink, NULL);
if (!gst_element_link_many (src, tee, enc, sink, NULL))
g_assert_not_reached ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
for (i = 0; i < 5; i++) {
g_print ("%d\n", i);
}
- if (gst_element_set_state (pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_element_unlink_many (tee, enc, sink, NULL);
gst_bin_remove_many (GST_BIN (pipeline), enc, sink, NULL);
gst_bin_add_many (GST_BIN (pipeline), enc, sink, NULL);
if (!gst_element_link_many (tee, enc, sink, NULL))
g_assert_not_reached ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
for (i = 5; i < 10; i++) {
while (i < 100) {
g_print ("running... (%d iterations)\n", i);
if (gst_element_set_state (pipeline,
- GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_element_link_many (src, id, sink, NULL);
for (j = 0; j < i; j++)
gst_bin_iterate (GST_BIN (pipeline));
- if (gst_element_set_state (pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_element_unlink_many (src, id, sink, NULL);
i++;
gst_bin_add_many (GST_BIN (pipeline), src, id1, NULL);
gst_element_link_pads (src, "src", id1, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (id2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (id2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (sink, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (sink,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_add_many (GST_BIN (pipeline), sink, NULL);
gst_element_link_pads (id1, "src", id2, "sink");
gst_element_link_pads (id2, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
gst_element_link_pads (queue, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
gst_element_link_pads (queue, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
}
g_assert (!bug);
- if (gst_element_set_state (pipeline2, GST_STATE_READY) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("relinking...\n");
gst_element_unlink_pads (id, "src", sink, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running again...\n");
gst_element_link_pads (src, "src", id1, "sink");
gst_element_link_pads (id2, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
gst_element_link_pads (queue, "src", id1, "sink");
gst_element_link_pads (id1, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("unlinking...\n");
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (i++ < 10 && gst_bin_iterate (GST_BIN (pipeline)));
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (gst_bin_iterate (GST_BIN (pipeline)));
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (pipeline && gst_bin_iterate (GST_BIN (pipeline)));
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (i < 100 && gst_bin_iterate (GST_BIN (pipeline)))
i++;
#include <gst/gst.h>
-#define RETURN_NAME(x) ((x) == GST_STATE_SUCCESS ? "GST_STATE_SUCCESS" : \
- (x) == GST_STATE_ASYNC ? "GST_STATE_ASYNC" : "GST_STATE_FAILURE")
+#define RETURN_NAME(x) ((x) == GST_STATE_CHANGE_SUCCESS ? "GST_STATE_CHANGE_SUCCESS" : \
+ (x) == GST_STATE_CHANGE_ASYNC ? "GST_STATE_CHANGE_ASYNC" : "GST_STATE_CHANGE_FAILURE")
static void
-assert_state (GstElement * element, GstElementState state)
+assert_state (GstElement * element, GstState state)
{
if (gst_element_get_state (element) != state) {
g_printerr ("%s: state is %s instead of %s",
}
static void
-assert_state_change (GstElement * element, GstElementState new_state,
- GstElementStateReturn result, GstElementState result_state)
+assert_state_change (GstElement * element, GstState new_state,
+ GstStateChangeReturn result, GstState result_state)
{
- GstElementStateReturn ret = gst_element_set_state (element, new_state);
+ GstStateChangeReturn ret = gst_element_set_state (element, new_state);
if (ret != result) {
g_printerr ("%s: change state to %s returned %s instead of %s",
/* Test the behaviour of empty bins. Since a bin's state is always the state
* of its highest child, nothing should change in here
* Return values when no error occured but the state didn't change should be
- * GST_STATE_ASYNC */
+ * GST_STATE_CHANGE_ASYNC */
GstElement *bin = gst_element_factory_make (bin_name, NULL);
/* obvious */
assert_state (bin, GST_STATE_NULL);
/* see above */
- assert_state_change (bin, GST_STATE_READY, GST_STATE_ASYNC, GST_STATE_NULL);
- assert_state_change (bin, GST_STATE_PAUSED, GST_STATE_ASYNC, GST_STATE_NULL);
- assert_state_change (bin, GST_STATE_PLAYING, GST_STATE_ASYNC, GST_STATE_NULL);
+ assert_state_change (bin, GST_STATE_READY, GST_STATE_CHANGE_ASYNC,
+ GST_STATE_NULL);
+ assert_state_change (bin, GST_STATE_PAUSED, GST_STATE_CHANGE_ASYNC,
+ GST_STATE_NULL);
+ assert_state_change (bin, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC,
+ GST_STATE_NULL);
}
static void
{
/* Tests behaviour of adding/removing elements to/from bins. It makes sure the
* state of the bin is always the highest of all contained children. */
- GstElementState test_states[] = { GST_STATE_READY, GST_STATE_PAUSED,
+ GstState test_states[] = { GST_STATE_READY, GST_STATE_PAUSED,
GST_STATE_PLAYING, GST_STATE_PAUSED, GST_STATE_READY, GST_STATE_NULL
};
GstElement *test = gst_element_factory_make ("identity", NULL);
- GstElementState bin_state = gst_element_get_state (bin);
+ GstState bin_state = gst_element_get_state (bin);
gint i;
g_assert (test);
gst_bin_add (GST_BIN (bin), test);
assert_state (bin, MAX (bin_state, GST_STATE_NULL));
for (i = 0; i < G_N_ELEMENTS (test_states); i++) {
- GstElementState test_state = test_states[i];
+ GstState test_state = test_states[i];
- assert_state_change (test, test_state, GST_STATE_SUCCESS, test_state);
+ assert_state_change (test, test_state, GST_STATE_CHANGE_SUCCESS,
+ test_state);
assert_state (test, test_state);
assert_state (bin, MAX (bin_state, test_state));
gst_bin_remove (GST_BIN (bin), test);
test_element_in_bin (gchar * bin_name)
{
gint i;
- GstElementState test_states[] = { GST_STATE_NULL, GST_STATE_READY,
+ GstState test_states[] = { GST_STATE_NULL, GST_STATE_READY,
GST_STATE_PAUSED, GST_STATE_PLAYING
};
GstElement *id, *bin = gst_element_factory_make (bin_name, NULL);
gst_bin_add (GST_BIN (bin), id);
/* test correct behaviour in bins which contain elements in various states */
for (i = 0; i < G_N_ELEMENTS (test_states); i++) {
- GstElementState test_state = test_states[i];
+ GstState test_state = test_states[i];
- assert_state_change (bin, test_state, GST_STATE_SUCCESS, test_state);
+ assert_state_change (bin, test_state, GST_STATE_CHANGE_SUCCESS, test_state);
assert_state (id, test_state);
test_adding_one_element (bin);
}
g_assert_not_reached ();
/* run a bit */
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
sleep (10000);
void
state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
- GstElementState state = gst_element_get_state (el);
+ GstState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
void
state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
- GstElementState state = gst_element_get_state (el);
+ GstState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
construct_pipeline (thread, i / 10 + 1);
g_print ("Setting thread to play with %d identities\n", i / 10 + 1);
- if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+ if (gst_element_set_state (thread,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
g_error ("Failed setting thread to play\n");
} else {
g_print ("Going into the main GStreamer loop\n");
void
state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
- GstElementState state = gst_element_get_state (el);
+ GstState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
g_print ("Setting thread to play with %d identities\n",
i / RUNS_PER_IDENTITY + 1);
done = FALSE;
- if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+ if (gst_element_set_state (thread,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
g_warning ("failed to go to PLAYING");
} else {
g_print ("Waiting for thread PLAYING->PAUSED\n");
g_assert_not_reached ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
for (i = 0; i < 100; i++) {
g_print ("%d\n", i);
}
- if (gst_element_set_state (pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_remove_many (GST_BIN (thread), queue, sink, NULL);
- if (gst_element_set_state (thread, GST_STATE_NULL) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (thread,
+ GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_remove (GST_BIN (pipeline), thread);
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
{
g_print ("identity handoff\n");
- if (gst_element_set_state (thread, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (thread,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (sink, GST_STATE_READY) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (sink, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_remove (GST_BIN (thread), src);
g_assert_not_reached ();
/* run a bit */
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
sleep (2);
#endif
static void
-cb_state (GstElement * element, GstElementState old_state,
- GstElementState new_state, gpointer data)
+cb_state (GstElement * element, GstState old_state,
+ GstState new_state, gpointer data)
{
g_print ("Changed state from %d to %d\n", old_state, new_state);
}
static gboolean
cb_play (gpointer data)
{
- GstElementStateReturn res;
+ GstStateChangeReturn res;
#if TESTNUM != 999999
g_print ("Setting state on fakesrc\n");
#endif
g_print ("Syncing state in pipeline\n");
res = gst_bin_sync_children_state (GST_BIN (data));
- g_assert (res == GST_STATE_SUCCESS);
+ g_assert (res == GST_STATE_CHANGE_SUCCESS);
g_print ("Set to playing correctly: %d\n", GST_STATE (pipeline));
/* once */
g_assert (size >= MIN_SIZE);
g_assert (size <= MAX_SIZE);
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (gst_bin_iterate (GST_BIN (pipeline)));
static void gst_bstest_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_bstest_change_state (GstElement * element);
+static GstStateChangeReturn gst_bstest_change_state (GstElement * element,
+ GstStateChange transition);
static void gst_bstest_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
}
}
-static GstElementStateReturn
-gst_bstest_change_state (GstElement * element)
+static GstStateChangeReturn
+gst_bstest_change_state (GstElement * element, GstStateChange transition)
{
GstBsTest *bstest;
- g_return_val_if_fail (GST_IS_BSTEST (element), GST_STATE_FAILURE);
+ g_return_val_if_fail (GST_IS_BSTEST (element), GST_STATE_CHANGE_FAILURE);
bstest = GST_BSTEST (element);
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- return GST_STATE_SUCCESS;
+ return GST_STATE_CHANGE_SUCCESS;
}
static gboolean
alarm(10); \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
if (gst_element_set_state (cur, GST_STATE_PLAYING) \
- == GST_STATE_FAILURE) { \
+ == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : " \
"pipeline could not be set to PLAYING\n", test, __LINE__); \
return -test; \
iterations = 0; \
while (gst_bin_iterate (GST_BIN (cur))) iterations++; \
if (gst_element_set_state (cur, GST_STATE_NULL) \
- == GST_STATE_FAILURE) { \
+ == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : " \
"pipeline could not be reset to state NULL\n", test, __LINE__); \
return -test; \
#define TEST_RUN(iters) G_STMT_START{ \
gint it = iters; \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
- if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
+ if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : pipeline could not be set to state PLAYING\n", test, __LINE__); \
return -test; \
} \
iterations++; \
it--; \
} \
- if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
+ if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) { \
g_print ("TEST %2d line %3d FAILED : pipeline could not be reset to state NULL\n", test, __LINE__); \
return -test; \
} \
gst_element_link_pads (src, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_iterate (GST_BIN (pipeline));
gst_element_link_pads (src, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_iterate (GST_BIN (pipeline));
gst_bin_add_many (GST_BIN (pipeline), src, tee, enc, sink, NULL);
if (!gst_element_link_many (src, tee, enc, sink, NULL))
g_assert_not_reached ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
for (i = 0; i < 5; i++) {
g_print ("%d\n", i);
}
- if (gst_element_set_state (pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_element_unlink_many (tee, enc, sink, NULL);
gst_bin_remove_many (GST_BIN (pipeline), enc, sink, NULL);
gst_bin_add_many (GST_BIN (pipeline), enc, sink, NULL);
if (!gst_element_link_many (tee, enc, sink, NULL))
g_assert_not_reached ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
for (i = 5; i < 10; i++) {
while (i < 100) {
g_print ("running... (%d iterations)\n", i);
if (gst_element_set_state (pipeline,
- GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_element_link_many (src, id, sink, NULL);
for (j = 0; j < i; j++)
gst_bin_iterate (GST_BIN (pipeline));
- if (gst_element_set_state (pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_element_unlink_many (src, id, sink, NULL);
i++;
gst_bin_add_many (GST_BIN (pipeline), src, id1, NULL);
gst_element_link_pads (src, "src", id1, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (id2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (id2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (sink, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (sink,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_add_many (GST_BIN (pipeline), sink, NULL);
gst_element_link_pads (id1, "src", id2, "sink");
gst_element_link_pads (id2, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
gst_element_link_pads (queue, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
gst_element_link_pads (queue, "src", id, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
}
g_assert (!bug);
- if (gst_element_set_state (pipeline2, GST_STATE_READY) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("relinking...\n");
gst_element_unlink_pads (id, "src", sink, "sink");
gst_element_link_pads (id, "src", sink, "sink");
- if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline2,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running again...\n");
gst_element_link_pads (src, "src", id1, "sink");
gst_element_link_pads (id2, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("running...\n");
gst_element_link_pads (queue, "src", id1, "sink");
gst_element_link_pads (id1, "src", sink, "sink");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
g_print ("unlinking...\n");
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (i++ < 10 && gst_bin_iterate (GST_BIN (pipeline)));
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (gst_bin_iterate (GST_BIN (pipeline)));
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (pipeline && gst_bin_iterate (GST_BIN (pipeline)));
/* run pipeline */
g_print ("running...\n");
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
while (i < 100 && gst_bin_iterate (GST_BIN (pipeline)))
i++;
#include <gst/gst.h>
-#define RETURN_NAME(x) ((x) == GST_STATE_SUCCESS ? "GST_STATE_SUCCESS" : \
- (x) == GST_STATE_ASYNC ? "GST_STATE_ASYNC" : "GST_STATE_FAILURE")
+#define RETURN_NAME(x) ((x) == GST_STATE_CHANGE_SUCCESS ? "GST_STATE_CHANGE_SUCCESS" : \
+ (x) == GST_STATE_CHANGE_ASYNC ? "GST_STATE_CHANGE_ASYNC" : "GST_STATE_CHANGE_FAILURE")
static void
-assert_state (GstElement * element, GstElementState state)
+assert_state (GstElement * element, GstState state)
{
if (gst_element_get_state (element) != state) {
g_printerr ("%s: state is %s instead of %s",
}
static void
-assert_state_change (GstElement * element, GstElementState new_state,
- GstElementStateReturn result, GstElementState result_state)
+assert_state_change (GstElement * element, GstState new_state,
+ GstStateChangeReturn result, GstState result_state)
{
- GstElementStateReturn ret = gst_element_set_state (element, new_state);
+ GstStateChangeReturn ret = gst_element_set_state (element, new_state);
if (ret != result) {
g_printerr ("%s: change state to %s returned %s instead of %s",
/* Test the behaviour of empty bins. Since a bin's state is always the state
* of its highest child, nothing should change in here
* Return values when no error occured but the state didn't change should be
- * GST_STATE_ASYNC */
+ * GST_STATE_CHANGE_ASYNC */
GstElement *bin = gst_element_factory_make (bin_name, NULL);
/* obvious */
assert_state (bin, GST_STATE_NULL);
/* see above */
- assert_state_change (bin, GST_STATE_READY, GST_STATE_ASYNC, GST_STATE_NULL);
- assert_state_change (bin, GST_STATE_PAUSED, GST_STATE_ASYNC, GST_STATE_NULL);
- assert_state_change (bin, GST_STATE_PLAYING, GST_STATE_ASYNC, GST_STATE_NULL);
+ assert_state_change (bin, GST_STATE_READY, GST_STATE_CHANGE_ASYNC,
+ GST_STATE_NULL);
+ assert_state_change (bin, GST_STATE_PAUSED, GST_STATE_CHANGE_ASYNC,
+ GST_STATE_NULL);
+ assert_state_change (bin, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC,
+ GST_STATE_NULL);
}
static void
{
/* Tests behaviour of adding/removing elements to/from bins. It makes sure the
* state of the bin is always the highest of all contained children. */
- GstElementState test_states[] = { GST_STATE_READY, GST_STATE_PAUSED,
+ GstState test_states[] = { GST_STATE_READY, GST_STATE_PAUSED,
GST_STATE_PLAYING, GST_STATE_PAUSED, GST_STATE_READY, GST_STATE_NULL
};
GstElement *test = gst_element_factory_make ("identity", NULL);
- GstElementState bin_state = gst_element_get_state (bin);
+ GstState bin_state = gst_element_get_state (bin);
gint i;
g_assert (test);
gst_bin_add (GST_BIN (bin), test);
assert_state (bin, MAX (bin_state, GST_STATE_NULL));
for (i = 0; i < G_N_ELEMENTS (test_states); i++) {
- GstElementState test_state = test_states[i];
+ GstState test_state = test_states[i];
- assert_state_change (test, test_state, GST_STATE_SUCCESS, test_state);
+ assert_state_change (test, test_state, GST_STATE_CHANGE_SUCCESS,
+ test_state);
assert_state (test, test_state);
assert_state (bin, MAX (bin_state, test_state));
gst_bin_remove (GST_BIN (bin), test);
test_element_in_bin (gchar * bin_name)
{
gint i;
- GstElementState test_states[] = { GST_STATE_NULL, GST_STATE_READY,
+ GstState test_states[] = { GST_STATE_NULL, GST_STATE_READY,
GST_STATE_PAUSED, GST_STATE_PLAYING
};
GstElement *id, *bin = gst_element_factory_make (bin_name, NULL);
gst_bin_add (GST_BIN (bin), id);
/* test correct behaviour in bins which contain elements in various states */
for (i = 0; i < G_N_ELEMENTS (test_states); i++) {
- GstElementState test_state = test_states[i];
+ GstState test_state = test_states[i];
- assert_state_change (bin, test_state, GST_STATE_SUCCESS, test_state);
+ assert_state_change (bin, test_state, GST_STATE_CHANGE_SUCCESS, test_state);
assert_state (id, test_state);
test_adding_one_element (bin);
}
g_assert_not_reached ();
/* run a bit */
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
sleep (10000);
void
state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
- GstElementState state = gst_element_get_state (el);
+ GstState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
void
state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
- GstElementState state = gst_element_get_state (el);
+ GstState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
construct_pipeline (thread, i / 10 + 1);
g_print ("Setting thread to play with %d identities\n", i / 10 + 1);
- if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+ if (gst_element_set_state (thread,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
g_error ("Failed setting thread to play\n");
} else {
g_print ("Going into the main GStreamer loop\n");
void
state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
- GstElementState state = gst_element_get_state (el);
+ GstState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
g_print ("Setting thread to play with %d identities\n",
i / RUNS_PER_IDENTITY + 1);
done = FALSE;
- if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+ if (gst_element_set_state (thread,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
g_warning ("failed to go to PLAYING");
} else {
g_print ("Waiting for thread PLAYING->PAUSED\n");
g_assert_not_reached ();
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
for (i = 0; i < 100; i++) {
g_print ("%d\n", i);
}
- if (gst_element_set_state (pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_remove_many (GST_BIN (thread), queue, sink, NULL);
- if (gst_element_set_state (thread, GST_STATE_NULL) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (thread,
+ GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_remove (GST_BIN (pipeline), thread);
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
{
g_print ("identity handoff\n");
- if (gst_element_set_state (thread, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (thread,
+ GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
- if (gst_element_set_state (sink, GST_STATE_READY) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (sink, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
gst_bin_remove (GST_BIN (thread), src);
g_assert_not_reached ();
/* run a bit */
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
sleep (2);
#endif
static void
-cb_state (GstElement * element, GstElementState old_state,
- GstElementState new_state, gpointer data)
+cb_state (GstElement * element, GstState old_state,
+ GstState new_state, gpointer data)
{
g_print ("Changed state from %d to %d\n", old_state, new_state);
}
static gboolean
cb_play (gpointer data)
{
- GstElementStateReturn res;
+ GstStateChangeReturn res;
#if TESTNUM != 999999
g_print ("Setting state on fakesrc\n");
#endif
g_print ("Syncing state in pipeline\n");
res = gst_bin_sync_children_state (GST_BIN (data));
- g_assert (res == GST_STATE_SUCCESS);
+ g_assert (res == GST_STATE_CHANGE_SUCCESS);
g_print ("Set to playing correctly: %d\n", GST_STATE (pipeline));
/* once */
return TRUE;
}
case GST_MESSAGE_STATE_CHANGED:{
- GstElementState old, new;
+ GstState old, new;
gst_message_parse_state_changed (message, &old, &new);
if (!(old == GST_STATE_PLAYING && new == GST_STATE_PAUSED &&
#endif
if (!savefile) {
- GstElementState state, pending;
- GstElementStateReturn ret;
+ GstState state, pending;
+ GstStateChangeReturn ret;
if (!GST_IS_BIN (pipeline)) {
GstElement *real_pipeline = gst_element_factory_make ("pipeline", NULL);
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
switch (ret) {
- case GST_STATE_FAILURE:
+ case GST_STATE_CHANGE_FAILURE:
fprintf (stderr, _("ERROR: pipeline doesn't want to pause.\n"));
res = -1;
goto end;
- case GST_STATE_NO_PREROLL:
+ case GST_STATE_CHANGE_NO_PREROLL:
fprintf (stderr, _("NO_PREROLL pipeline ...\n"));
break;
- case GST_STATE_ASYNC:
+ case GST_STATE_CHANGE_ASYNC:
fprintf (stderr, _("PREROLL pipeline ...\n"));
gst_element_get_state (pipeline, &state, &pending, NULL);
/* fallthrough */
- case GST_STATE_SUCCESS:
+ case GST_STATE_CHANGE_SUCCESS:
fprintf (stderr, _("PREROLLED pipeline ...\n"));
break;
}
fprintf (stderr, _("RUNNING pipeline ...\n"));
if (gst_element_set_state (pipeline,
- GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
fprintf (stderr, _("ERROR: pipeline doesn't want to play.\n"));
res = -1;
goto end;
return 1;
}
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS) {
g_warning ("pipeline doesn't want to play\n");
return 1;
}
G_CALLBACK (have_type_handler), NULL);
while (i < argc) {
- GstElementStateReturn sret;
- GstElementState state;
+ GstStateChangeReturn sret;
+ GstState state;
filename = argv[i];
g_object_set (source, "location", filename, NULL);
* otherwise the state change fails */
sret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
- if (GST_STATE_ASYNC == sret) {
- if (GST_STATE_FAILURE ==
+ if (GST_STATE_CHANGE_ASYNC == sret) {
+ if (GST_STATE_CHANGE_FAILURE ==
gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL))
break;
- } else if (sret != GST_STATE_SUCCESS)
+ } else if (sret != GST_STATE_CHANGE_SUCCESS)
g_print ("%s - No type found\n", argv[i]);
- if (GST_STATE_ASYNC ==
+ if (GST_STATE_CHANGE_ASYNC ==
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL)) {
- if (GST_STATE_FAILURE ==
+ if (GST_STATE_CHANGE_FAILURE ==
gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL))
break;
}
/* enumerations from "gstelement.h" */
GType
-gst_element_state_get_type (void)
+gst_state_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
- static const GFlagsValue values[] = {
- {GST_STATE_VOID_PENDING, "GST_STATE_VOID_PENDING", "state-void-pending"},
- {GST_STATE_NULL, "GST_STATE_NULL", "state-null"},
- {GST_STATE_READY, "GST_STATE_READY", "state-ready"},
- {GST_STATE_PAUSED, "GST_STATE_PAUSED", "state-paused"},
- {GST_STATE_PLAYING, "GST_STATE_PLAYING", "state-playing"},
+ static const GEnumValue values[] = {
+ {GST_STATE_VOID_PENDING, "GST_STATE_VOID_PENDING", "void-pending"},
+ {GST_STATE_NULL, "GST_STATE_NULL", "null"},
+ {GST_STATE_READY, "GST_STATE_READY", "ready"},
+ {GST_STATE_PAUSED, "GST_STATE_PAUSED", "paused"},
+ {GST_STATE_PLAYING, "GST_STATE_PLAYING", "playing"},
{0, NULL, NULL}
};
- etype = g_flags_register_static ("GstElementState", values);
+ etype = g_enum_register_static ("GstState", values);
}
return etype;
}
GType
-gst_element_state_return_get_type (void)
+gst_state_change_return_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
- {GST_STATE_FAILURE, "GST_STATE_FAILURE", "failure"},
- {GST_STATE_SUCCESS, "GST_STATE_SUCCESS", "success"},
- {GST_STATE_ASYNC, "GST_STATE_ASYNC", "async"},
- {GST_STATE_NO_PREROLL, "GST_STATE_NO_PREROLL", "no-preroll"},
+ {GST_STATE_CHANGE_FAILURE, "GST_STATE_CHANGE_FAILURE", "failure"},
+ {GST_STATE_CHANGE_SUCCESS, "GST_STATE_CHANGE_SUCCESS", "success"},
+ {GST_STATE_CHANGE_ASYNC, "GST_STATE_CHANGE_ASYNC", "async"},
+ {GST_STATE_CHANGE_NO_PREROLL, "GST_STATE_CHANGE_NO_PREROLL",
+ "no-preroll"},
+ {0, NULL, NULL}
+ };
+ etype = g_enum_register_static ("GstStateChangeReturn", values);
+ }
+ return etype;
+}
+
+GType
+gst_state_change_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GFlagsValue values[] = {
+ {GST_STATE_CHANGE_NULL_TO_READY, "GST_STATE_CHANGE_NULL_TO_READY",
+ "null-to-ready"},
+ {GST_STATE_CHANGE_READY_TO_PAUSED, "GST_STATE_CHANGE_READY_TO_PAUSED",
+ "ready-to-paused"},
+ {GST_STATE_CHANGE_PAUSED_TO_PLAYING, "GST_STATE_CHANGE_PAUSED_TO_PLAYING",
+ "paused-to-playing"},
+ {GST_STATE_CHANGE_PLAYING_TO_PAUSED, "GST_STATE_CHANGE_PLAYING_TO_PAUSED",
+ "playing-to-paused"},
+ {GST_STATE_CHANGE_PAUSED_TO_READY, "GST_STATE_CHANGE_PAUSED_TO_READY",
+ "paused-to-ready"},
+ {GST_STATE_CHANGE_READY_TO_NULL, "GST_STATE_CHANGE_READY_TO_NULL",
+ "ready-to-null"},
{0, NULL, NULL}
};
- etype = g_enum_register_static ("GstElementStateReturn", values);
+ etype = g_flags_register_static ("GstStateChange", values);
}
return etype;
}