gstreamer/tests/old/testsuite/states/locked.c

106 lines
3.1 KiB
C
Raw Normal View History

/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "unistd.h"
#include <gst/gst.h>
static GMainLoop *loop;
static gboolean
message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
{
g_print ("message %p\n", message);
if (message->type == GST_MESSAGE_EOS) {
g_print ("EOS!!\n");
if (g_main_loop_is_running (loop))
g_main_loop_quit (loop);
}
gst_message_unref (message);
return TRUE;
}
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *fakesrc1, *fakesink1;
GstElement *fakesrc2, *fakesink2;
GstBus *bus;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
loop = g_main_loop_new (NULL, FALSE);
bus = gst_element_get_bus (pipeline);
gst_bus_add_watch (bus, GST_MESSAGE_EOS, (GstBusFunc) message_received,
(gpointer) pipeline);
gst_object_unref (bus);
fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
gst_bin_add (GST_BIN (pipeline), fakesrc1);
gst_bin_add (GST_BIN (pipeline), fakesink1);
gst_pad_link (gst_element_get_pad (fakesrc1, "src"),
gst_element_get_pad (fakesink1, "sink"));
fakesrc2 = gst_element_factory_make ("fakesrc", "fakesrc2");
g_object_set (G_OBJECT (fakesrc2), "num_buffers", 5, NULL);
fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
gst_bin_add (GST_BIN (pipeline), fakesrc2);
gst_bin_add (GST_BIN (pipeline), fakesink2);
gst_pad_link (gst_element_get_pad (fakesrc2, "src"),
gst_element_get_pad (fakesink2, "sink"));
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (gst_object_default_deep_notify), NULL);
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition Original commit message from CVS: * check/gst/gstbin.c: (GST_START_TEST): * docs/gst/gstreamer-sections.txt: * gst/base/gstbasesink.c: (gst_base_sink_init): * gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_get_range), (gst_base_src_check_get_range), (gst_base_src_start), (gst_base_src_stop): * gst/base/gstbasesrc.h: * gst/elements/gstfakesrc.c: (gst_fake_src_set_property): * gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func), (bin_element_is_sink), (reset_degree), (gst_bin_element_set_state), (bin_bus_handler): * gst/gstbin.h: * gst/gstbuffer.h: * gst/gstbus.c: (gst_bus_post), (gst_bus_set_flushing): * gst/gstbus.h: * gst/gstelement.c: (gst_element_is_locked_state), (gst_element_set_locked_state), (gst_element_commit_state), (gst_element_set_state): * gst/gstelement.h: * gst/gstindex.c: (gst_index_init): * gst/gstindex.h: * gst/gstminiobject.h: * gst/gstobject.c: (gst_object_init), (gst_object_sink), (gst_object_set_parent): * gst/gstobject.h: * gst/gstpad.c: (gst_pad_set_blocked_async), (gst_pad_is_blocked), (gst_pad_get_caps_unlocked), (gst_pad_set_caps): * gst/gstpad.h: * gst/gstpadtemplate.h: * gst/gstpipeline.c: (gst_pipeline_provide_clock_func), (gst_pipeline_use_clock), (gst_pipeline_auto_clock): * gst/gstpipeline.h: * gst/indexers/gstfileindex.c: (gst_file_index_load), (gst_file_index_commit): * testsuite/bytestream/filepadsink.c: (gst_fp_sink_init): * testsuite/pad/link.c: (gst_test_src_init), (gst_test_filter_init), (gst_test_sink_init): * testsuite/states/locked.c: (main): renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
2005-10-12 14:28:39 +00:00
GST_OBJECT_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
GST_OBJECT_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
g_print ("play..\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_main_loop_run (loop);
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
gst_element_set_state (pipeline, GST_STATE_READY);
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition Original commit message from CVS: * check/gst/gstbin.c: (GST_START_TEST): * docs/gst/gstreamer-sections.txt: * gst/base/gstbasesink.c: (gst_base_sink_init): * gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_get_range), (gst_base_src_check_get_range), (gst_base_src_start), (gst_base_src_stop): * gst/base/gstbasesrc.h: * gst/elements/gstfakesrc.c: (gst_fake_src_set_property): * gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func), (bin_element_is_sink), (reset_degree), (gst_bin_element_set_state), (bin_bus_handler): * gst/gstbin.h: * gst/gstbuffer.h: * gst/gstbus.c: (gst_bus_post), (gst_bus_set_flushing): * gst/gstbus.h: * gst/gstelement.c: (gst_element_is_locked_state), (gst_element_set_locked_state), (gst_element_commit_state), (gst_element_set_state): * gst/gstelement.h: * gst/gstindex.c: (gst_index_init): * gst/gstindex.h: * gst/gstminiobject.h: * gst/gstobject.c: (gst_object_init), (gst_object_sink), (gst_object_set_parent): * gst/gstobject.h: * gst/gstpad.c: (gst_pad_set_blocked_async), (gst_pad_is_blocked), (gst_pad_get_caps_unlocked), (gst_pad_set_caps): * gst/gstpad.h: * gst/gstpadtemplate.h: * gst/gstpipeline.c: (gst_pipeline_provide_clock_func), (gst_pipeline_use_clock), (gst_pipeline_auto_clock): * gst/gstpipeline.h: * gst/indexers/gstfileindex.c: (gst_file_index_load), (gst_file_index_commit): * testsuite/bytestream/filepadsink.c: (gst_fp_sink_init): * testsuite/pad/link.c: (gst_test_src_init), (gst_test_filter_init), (gst_test_sink_init): * testsuite/states/locked.c: (main): renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
2005-10-12 14:28:39 +00:00
GST_OBJECT_FLAG_UNSET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
GST_OBJECT_FLAG_UNSET (fakesink2, GST_ELEMENT_LOCKED_STATE);
g_print ("play..\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_main_loop_run (loop);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}