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

📄 gstghostpad.c

📁 gnash 在pc和嵌入式下开发需要的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
  ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 3);     /* parent and gisrc */  ASSERT_OBJECT_REFCOUNT (gsink, "gsink", 2);   /* parent */  ASSERT_OBJECT_REFCOUNT (gsrc, "gsrc", 2);     /* parent */  ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 3);   /* parent and gisink */  ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 2);   /* parent */  ASSERT_OBJECT_REFCOUNT (isink, "isink", 3);   /* parent and gsink */  ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 2); /* parent */  ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 3);     /* parent and gsrc */  ret = gst_element_set_state (b1, GST_STATE_PLAYING);  ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS);  ret = gst_element_set_state (b1, GST_STATE_NULL);  ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE);  fail_unless (ret == GST_STATE_CHANGE_SUCCESS);  gst_object_unref (b1);  /* unreffing the bin will unref all elements, which will unlink and unparent   * all pads */  /* wait for thread to settle down */  while (GST_OBJECT_REFCOUNT_VALUE (fsrc) > 2)    THREAD_SWITCH ();  ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 1);  ASSERT_OBJECT_REFCOUNT (gsink, "gsink", 1);  ASSERT_OBJECT_REFCOUNT (gsrc, "gsink", 1);  ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 1);  ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 2);   /* gsink */  ASSERT_OBJECT_REFCOUNT (isink, "isink", 2);   /* gsink */  ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 2); /* gsrc */  ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 2);     /* gsrc */  gst_object_unref (gsink);  ASSERT_OBJECT_REFCOUNT (isink, "isink", 1);  ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 1);  ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 1);  gst_object_unref (gisrc);  ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 1);  gst_object_unref (gsrc);  ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 1);  ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 1);  ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 1);  gst_object_unref (gisink);  ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 1);  gst_object_unref (fsrc);  gst_object_unref (isrc);  gst_object_unref (isink);  gst_object_unref (fsink);}GST_END_TEST;GST_START_TEST (test_ghost_pads_bin){  GstBin *pipeline;  GstBin *srcbin;  GstBin *sinkbin;  GstElement *src;  GstElement *sink;  GstPad *srcpad, *srcghost, *target;  GstPad *sinkpad, *sinkghost;  pipeline = GST_BIN (gst_pipeline_new ("pipe"));  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);  srcbin = GST_BIN (gst_bin_new ("srcbin"));  gst_bin_add (pipeline, GST_ELEMENT (srcbin));  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);  sinkbin = GST_BIN (gst_bin_new ("sinkbin"));  gst_bin_add (pipeline, GST_ELEMENT (sinkbin));  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);  src = gst_element_factory_make ("fakesrc", "src");  gst_bin_add (srcbin, src);  srcpad = gst_element_get_pad (src, "src");  srcghost = gst_ghost_pad_new ("src", srcpad);  gst_object_unref (srcpad);  gst_element_add_pad (GST_ELEMENT (srcbin), srcghost);  sink = gst_element_factory_make ("fakesink", "sink");  gst_bin_add (sinkbin, sink);  sinkpad = gst_element_get_pad (sink, "sink");  sinkghost = gst_ghost_pad_new ("sink", sinkpad);  gst_object_unref (sinkpad);  gst_element_add_pad (GST_ELEMENT (sinkbin), sinkghost);  gst_element_link (GST_ELEMENT (srcbin), GST_ELEMENT (sinkbin));  fail_unless (GST_PAD_PEER (srcghost) != NULL);  fail_unless (GST_PAD_PEER (sinkghost) != NULL);  target = gst_ghost_pad_get_target (GST_GHOST_PAD (srcghost));  fail_unless (GST_PAD_PEER (target) != NULL);  gst_object_unref (target);  target = gst_ghost_pad_get_target (GST_GHOST_PAD (sinkghost));  fail_unless (GST_PAD_PEER (target) != NULL);  gst_object_unref (target);  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);  gst_object_unref (pipeline);}GST_END_TEST;typedef struct{  GMutex *mutex;  GCond *cond;} BlockData;static voidblock_callback (GstPad * pad, gboolean blocked, gpointer user_data){  BlockData *block_data = (BlockData *) user_data;  g_mutex_lock (block_data->mutex);  GST_DEBUG ("blocked\n");  g_cond_signal (block_data->cond);  g_mutex_unlock (block_data->mutex);}GST_START_TEST (test_ghost_pads_block){  GstBin *pipeline;  GstBin *srcbin;  GstElement *src;  GstPad *srcpad;  GstPad *srcghost;  BlockData block_data;  pipeline = GST_BIN (gst_pipeline_new ("pipeline"));  srcbin = GST_BIN (gst_bin_new ("srcbin"));  gst_bin_add (pipeline, GST_ELEMENT (srcbin));  src = gst_element_factory_make ("fakesrc", "src");  gst_bin_add (srcbin, src);  srcpad = gst_element_get_pad (src, "src");  srcghost = gst_ghost_pad_new ("src", srcpad);  gst_element_add_pad (GST_ELEMENT (srcbin), srcghost);  gst_object_unref (srcpad);  block_data.mutex = g_mutex_new ();  block_data.cond = g_cond_new ();  g_mutex_lock (block_data.mutex);  gst_pad_set_blocked_async (srcghost, TRUE, block_callback, &block_data);  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);  /* and wait now */  g_cond_wait (block_data.cond, block_data.mutex);  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);  g_mutex_unlock (block_data.mutex);  g_mutex_free (block_data.mutex);  g_cond_free (block_data.cond);  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_ghost_pads_probes){  GstBin *pipeline;  GstBin *srcbin;  GstElement *src;  GstPad *srcpad;  GstPad *srcghost;  BlockData block_data;  pipeline = GST_BIN (gst_pipeline_new ("pipeline"));  srcbin = GST_BIN (gst_bin_new ("srcbin"));  gst_bin_add (pipeline, GST_ELEMENT (srcbin));  src = gst_element_factory_make ("fakesrc", "src");  gst_bin_add (srcbin, src);  srcpad = gst_element_get_pad (src, "src");  srcghost = gst_ghost_pad_new ("src", srcpad);  gst_element_add_pad (GST_ELEMENT (srcbin), srcghost);  gst_object_unref (srcpad);  block_data.mutex = g_mutex_new ();  block_data.cond = g_cond_new ();  g_mutex_lock (block_data.mutex);  gst_pad_set_blocked_async (srcghost, TRUE, block_callback, &block_data);  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);  /* and wait now */  g_cond_wait (block_data.cond, block_data.mutex);  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);  g_mutex_unlock (block_data.mutex);  g_mutex_free (block_data.mutex);  g_cond_free (block_data.cond);  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);  gst_object_unref (pipeline);}GST_END_TEST;GST_START_TEST (test_ghost_pads_new_from_template){  GstPad *sinkpad, *ghostpad;  GstPadTemplate *padtempl, *ghosttempl;  GstCaps *padcaps, *ghostcaps, *newcaps;  padcaps = gst_caps_from_string ("some/caps");  fail_unless (padcaps != NULL);  ghostcaps = gst_caps_from_string ("some/caps;some/other-caps");  fail_unless (ghostcaps != NULL);  padtempl = gst_pad_template_new ("padtempl", GST_PAD_SINK,      GST_PAD_ALWAYS, padcaps);  fail_unless (padtempl != NULL);  ghosttempl = gst_pad_template_new ("ghosttempl", GST_PAD_SINK,      GST_PAD_ALWAYS, ghostcaps);  sinkpad = gst_pad_new_from_template (padtempl, "sinkpad");  fail_unless (sinkpad != NULL);  ghostpad = gst_ghost_pad_new_from_template ("ghostpad", sinkpad, ghosttempl);  fail_unless (ghostpad != NULL);  /* check template is properly set */  fail_unless (GST_PAD_PAD_TEMPLATE (ghostpad) == ghosttempl);  /* check ghostpad caps are from the sinkpad */  newcaps = gst_pad_get_caps (ghostpad);  fail_unless (newcaps != NULL);  fail_unless (gst_caps_is_equal (newcaps, padcaps));  gst_caps_unref (newcaps);  gst_caps_unref (padcaps);}GST_END_TEST;GST_START_TEST (test_ghost_pads_new_no_target_from_template){  GstPad *sinkpad, *ghostpad;  GstPadTemplate *padtempl, *ghosttempl;  GstCaps *padcaps, *ghostcaps, *newcaps;  padcaps = gst_caps_from_string ("some/caps");  fail_unless (padcaps != NULL);  ghostcaps = gst_caps_from_string ("some/caps;some/other-caps");  fail_unless (ghostcaps != NULL);  padtempl = gst_pad_template_new ("padtempl", GST_PAD_SINK,      GST_PAD_ALWAYS, padcaps);  fail_unless (padtempl != NULL);  ghosttempl = gst_pad_template_new ("ghosttempl", GST_PAD_SINK,      GST_PAD_ALWAYS, ghostcaps);  sinkpad = gst_pad_new_from_template (padtempl, "sinkpad");  fail_unless (sinkpad != NULL);  ghostpad = gst_ghost_pad_new_no_target_from_template ("ghostpad", ghosttempl);  fail_unless (ghostpad != NULL);  /* check template is properly set */  fail_unless (GST_PAD_PAD_TEMPLATE (ghostpad) == ghosttempl);  /* check ghostpad caps are from the ghostpad template */  newcaps = gst_pad_get_caps (ghostpad);  fail_unless (newcaps != NULL);  fail_unless (gst_caps_is_equal (newcaps, ghostcaps));  gst_caps_unref (newcaps);  fail_unless (gst_ghost_pad_set_target ((GstGhostPad *) ghostpad, sinkpad));  /* check ghostpad caps are now from the target pad */  newcaps = gst_pad_get_caps (ghostpad);  fail_unless (newcaps != NULL);  fail_unless (gst_caps_is_equal (newcaps, padcaps));  gst_caps_unref (newcaps);}GST_END_TEST;Suite *gst_ghost_pad_suite (void){  Suite *s = suite_create ("GstGhostPad");  TCase *tc_chain = tcase_create ("ghost pad tests");  suite_add_tcase (s, tc_chain);  tcase_add_test (tc_chain, test_remove1);  tcase_add_test (tc_chain, test_remove2);  tcase_add_test (tc_chain, test_link);  tcase_add_test (tc_chain, test_ghost_pads);  tcase_add_test (tc_chain, test_ghost_pads_bin);  tcase_add_test (tc_chain, test_ghost_pads_notarget);  tcase_add_test (tc_chain, test_ghost_pads_block);  tcase_add_test (tc_chain, test_ghost_pads_probes);  tcase_add_test (tc_chain, test_ghost_pads_new_from_template);  tcase_add_test (tc_chain, test_ghost_pads_new_no_target_from_template);  return s;}GST_CHECK_MAIN (gst_ghost_pad);

⌨️ 快捷键说明

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