⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sinks.c

📁 gnash 在pc和嵌入式下开发需要的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
  gst_bin_add (GST_BIN (pipeline), src);  gst_bin_add (GST_BIN (pipeline), sink);  srcpad = gst_element_get_pad (src, "src");  sinkpad = gst_element_get_pad (sink, "sink");  gst_pad_link (srcpad, sinkpad);  gst_object_unref (srcpad);  gst_object_unref (sinkpad);  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  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");  /* and back down */  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_locked_sink){  GstElement *sink, *src, *pipeline;  GstStateChangeReturn ret;  GstState current, pending;  pipeline = gst_pipeline_new ("pipeline");  src = gst_element_factory_make ("fakesrc", "src");  g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);  sink = gst_element_factory_make ("fakesink", "sink");  gst_bin_add (GST_BIN (pipeline), src);  gst_bin_add (GST_BIN (pipeline), sink);  /* we don't link the elements */  ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,      "no NO_PREROLL state return");  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not no_preroll");  fail_unless (current == GST_STATE_PAUSED, "not paused");  fail_unless (pending == GST_STATE_VOID_PENDING, "have pending");  /* the sink is now async going from ready to paused */  ret = gst_element_get_state (sink, &current, &pending, 0);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");  fail_unless (current == GST_STATE_READY, "not ready");  fail_unless (pending == GST_STATE_PAUSED, "not paused");  /* lock the sink */  gst_element_set_locked_state (sink, TRUE);  /* move to PlAYING, the sink should remain ASYNC. The pipeline   * returns ASYNC */  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  /* back to PAUSED, we should get NO_PREROLL again */  ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,      "no NO_PREROLL state return");  /* unlock the sink */  gst_element_set_locked_state (sink, FALSE);  /* and now everything back down */  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_unlinked_live){  GstElement *sink, *src, *lsrc, *pipeline;  GstStateChangeReturn ret;  GstState current, pending;  GstPad *srcpad, *sinkpad;  pipeline = gst_pipeline_new ("pipeline");  src = gst_element_factory_make ("fakesrc", "src");  lsrc = gst_element_factory_make ("fakesrc", "lsrc");  g_object_set (G_OBJECT (lsrc), "is-live", TRUE, NULL);  sink = gst_element_factory_make ("fakesink", "sink");  gst_bin_add (GST_BIN (pipeline), src);  gst_bin_add (GST_BIN (pipeline), lsrc);  gst_bin_add (GST_BIN (pipeline), sink);  /* link non live source to sink */  srcpad = gst_element_get_pad (src, "src");  sinkpad = gst_element_get_pad (sink, "sink");  gst_pad_link (srcpad, sinkpad);  gst_object_unref (srcpad);  gst_object_unref (sinkpad);  /* we don't link the srcpad of the live source, it will not contribute to the   * NO_PREROLL. */  /* set state to PAUSED, this should return NO_PREROLL because there is a live   * source. since the only sink in this pipeline is linked to a non-live   * source, it will preroll eventually. */  ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,      "no NO_PREROLL state return");  /* wait till the sink is prerolled */  ret = gst_element_get_state (sink, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not success");  fail_unless (current == GST_STATE_PAUSED, "not paused");  fail_unless (pending == GST_STATE_VOID_PENDING, "have playing");  /* the pipeline should still return NO_PREROLL */  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not no_preroll");  fail_unless (current == GST_STATE_PAUSED, "not paused");  fail_unless (pending == GST_STATE_VOID_PENDING, "have playing");  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_delayed_async){  GstElement *sink, *src, *pipeline;  GstStateChangeReturn ret;  GstState current, pending;  GstPad *srcpad, *sinkpad;  pipeline = gst_pipeline_new ("pipeline");  src = gst_element_factory_make ("fakesrc", "src");  g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);  sink = gst_element_factory_make ("fakesink", "sink");  /* add source, don't add sink yet */  gst_bin_add (GST_BIN (pipeline), src);  ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,      "no NO_PREROLL state return");  /* add sink now and set to PAUSED */  gst_bin_add (GST_BIN (pipeline), sink);  /* This will make the bin notice an ASYNC element. */  ret = gst_element_set_state (sink, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  /* we should still be NO_PREROLL now although there is an async element in the   * pipeline. */  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL");  fail_unless (current == GST_STATE_PAUSED, "not paused");  fail_unless (pending == GST_STATE_VOID_PENDING, "have pending");  /* link live source to sink */  srcpad = gst_element_get_pad (src, "src");  sinkpad = gst_element_get_pad (sink, "sink");  gst_pad_link (srcpad, sinkpad);  gst_object_unref (srcpad);  gst_object_unref (sinkpad);  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  /* we should get SUCCESS now */  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not NO_PREROLL");  fail_unless (current == GST_STATE_PLAYING, "not PLAYING");  fail_unless (pending == GST_STATE_VOID_PENDING, "have pending");  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_added_async){  GstElement *sink, *src, *pipeline;  GstStateChangeReturn ret;  GstState current, pending;  GstPad *srcpad, *sinkpad;  pipeline = gst_pipeline_new ("pipeline");  src = gst_element_factory_make ("fakesrc", "src");  g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);  sink = gst_element_factory_make ("fakesink", "sink");  /* add source, don't add sink yet */  gst_bin_add (GST_BIN (pipeline), src);  ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,      "no NO_PREROLL state return");  /* set sink to PAUSED without adding it to the pipeline */  ret = gst_element_set_state (sink, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  /* add sink now, pipeline should notice the async element */  gst_bin_add (GST_BIN (pipeline), sink);  /* we should still be NO_PREROLL now although there is an async element in the   * pipeline. */  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL");  fail_unless (current == GST_STATE_PAUSED, "not paused");  fail_unless (pending == GST_STATE_VOID_PENDING, "have pending");  /* link live source to sink */  srcpad = gst_element_get_pad (src, "src");  sinkpad = gst_element_get_pad (sink, "sink");  gst_pad_link (srcpad, sinkpad);  gst_object_unref (srcpad);  gst_object_unref (sinkpad);  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  /* we should get SUCCESS now */  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not NO_PREROLL");  fail_unless (current == GST_STATE_PLAYING, "not PLAYING");  fail_unless (pending == GST_STATE_VOID_PENDING, "have pending");  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_added_async2){  GstElement *sink, *src, *pipeline;  GstStateChangeReturn ret;  GstState current, pending;  pipeline = gst_pipeline_new ("pipeline");  src = gst_element_factory_make ("fakesrc", "src");  sink = gst_element_factory_make ("fakesink", "sink");  /* add source, don't add sink yet */  gst_bin_add (GST_BIN (pipeline), src);  ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no SUCCESS state return");  /* set sink to PAUSED without adding it to the pipeline */  ret = gst_element_set_state (sink, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  /* add sink now, pipeline should notice the async element */  gst_bin_add (GST_BIN (pipeline), sink);  /* we should be ASYNC now because there is an async element in the   * pipeline. */  ret = gst_element_get_state (pipeline, &current, &pending, 0);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not ASYNC");  fail_unless (current == GST_STATE_PAUSED, "not paused");  fail_unless (pending == GST_STATE_PAUSED, "not paused");  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_add_live){  GstElement *sink, *src, *pipeline;  GstStateChangeReturn ret;  GstState current, pending;  pipeline = gst_pipeline_new ("pipeline");  src = gst_element_factory_make ("fakesrc", "src");  g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);  sink = gst_element_factory_make ("fakesink", "sink");  /* add sink, don't add sourc3 yet */  gst_bin_add (GST_BIN (pipeline), sink);  ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  /* set source to PAUSED without adding it to the pipeline */  ret = gst_element_set_state (src, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,      "no NO_PREROLL state return");  /* add source now, pipeline should notice the NO_PREROLL element */  gst_bin_add (GST_BIN (pipeline), src);  /* we should be NO_PREROLL now because there is a NO_PREROLL element in the   * pipeline. */  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL");  fail_unless (current == GST_STATE_PAUSED, "not paused");  fail_unless (pending == GST_STATE_VOID_PENDING, "have pending");  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");  gst_object_unref (pipeline);}GST_END_TEST;static GMutex *blocked_lock;static GCond *blocked_cond;static voidpad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data){  g_mutex_lock (blocked_lock);  GST_DEBUG ("srcpad blocked: %d, sending signal", blocked);  g_cond_signal (blocked_cond);  g_mutex_unlock (blocked_lock);}GST_START_TEST (test_add_live2){  GstElement *sink, *src, *pipeline;  GstStateChangeReturn ret;  GstState current, pending;  GstPad *srcpad, *sinkpad;  blocked_lock = g_mutex_new ();  blocked_cond = g_cond_new ();  pipeline = gst_pipeline_new ("pipeline");  src = gst_element_factory_make ("fakesrc", "src");  g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);  sink = gst_element_factory_make ("fakesink", "sink");  /* add sink, don't add source yet */  gst_bin_add (GST_BIN (pipeline), sink);  /* set the pipeline to PLAYING. This will return ASYNC on READY->PAUSED */  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);  fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return");  g_mutex_lock (blocked_lock);  GST_DEBUG ("blocking srcpad");  /* block source pad */  srcpad = gst_element_get_pad (src, "src");  gst_pad_set_blocked_async (srcpad, TRUE, pad_blocked_cb, NULL);  /* set source to PAUSED without adding it to the pipeline */  ret = gst_element_set_state (src, GST_STATE_PAUSED);  fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,      "no NO_PREROLL state return");  /* add source now, pipeline should notice the NO_PREROLL element. This   * should trigger as commit of the ASYNC pipeline and make it continue   * to PLAYING. We blocked the source pad so that we don't get an unlinked   * error. */  gst_bin_add (GST_BIN (pipeline), src);  /* wait for pad blocked, this means the source is now PLAYING. */  g_cond_wait (blocked_cond, blocked_lock);  g_mutex_unlock (blocked_lock);  GST_DEBUG ("linking pads");  /* link to sink */  sinkpad = gst_element_get_pad (sink, "sink");  gst_pad_link (srcpad, sinkpad);  gst_object_unref (srcpad);  gst_object_unref (sinkpad);  GST_DEBUG ("unblocking srcpad");  /* and unblock */  gst_pad_set_blocked_async (srcpad, FALSE, pad_blocked_cb, NULL);  GST_DEBUG ("getting state");  /* we should be SUCCESS now and PLAYING */  ret =      gst_element_get_state (pipeline, &current, &pending, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");  fail_unless (current == GST_STATE_PLAYING, "not PLAYING");  fail_unless (pending == GST_STATE_VOID_PENDING, "have pending");  ret = gst_element_set_state (pipeline, GST_STATE_NULL);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS");  g_cond_free (blocked_cond);  g_mutex_free (blocked_lock);  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_bin_live){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -