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

📄 parse-launch.c

📁 gnash 在pc和嵌入式下开发需要的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
  /* checks: Link without sink element failes */  "fakesrc ! ",  /* checks: Link without src element failes */  " ! fakesink silent=true",  /* checks: Source URI for which no element exists is a failure */  "borky://fdaffd ! fakesink silent=true",  /* checks: Sink URI for which no element exists is a failure */  "fakesrc ! borky://fdaffd",  /* checks: Referencing non-existent source element by name can't link */  "fakesrc name=src fakesink silent=true name=sink noexiste. ! sink.",  /* checks: Referencing non-existent sink element by name can't link */  "fakesrc name=src fakesink silent=true name=sink src. ! noexiste.",  /* checks: Can't link 2 elements that only have sink pads */  "fakesink silent=true ! fakesink silent=true",  /* checks multi-chain link without src element fails. */  "! identity silent=true ! identity silent=true ! fakesink silent=true",  /* Empty bin not allowed */  "bin.( )",  /* bin with non-existent element counts as empty, and not allowed */  "bin.( non_existent_element )",  /* END: */  NULL};GST_START_TEST (expected_to_fail_pipes){  const gchar **s;  for (s = expected_failures; *s != NULL; s++) {    expected_fail_pipe (*s);  }}GST_END_TEST;static const gchar *leaking_failures[] = {  /* checks: Invalid pipeline syntax fails */  "fakesrc ! identity silent=true ! sgsdfagfd @ gfdgfdsgfsgSF",  /* checks: Attempting to link to a non-existent pad on an element    * created via URI handler should fail */  "fakesrc ! .foo file:///dev/null",  /* checks: That requesting an element which doesn't exist doesn't work */  "error-does-not-exist-src",  NULL};GST_START_TEST (leaking_fail_pipes){  const gchar **s;  for (s = leaking_failures; *s != NULL; s++) {    /* Uncomment if you want to try fixing the leaks */#if 0    g_print ("Trying pipe: %s\n", *s);    expected_fail_pipe (*s);#endif#ifdef HAVE_VALGRIND    VALGRIND_DO_LEAK_CHECK;#endif  }}GST_END_TEST;/* Helper function to test delayed linking support in parse_launch by creating * a test element based on bin, which contains a fakesrc and a sometimes  * pad-template, and trying to link to a fakesink. When the bin transitions * to paused it adds a pad, which should get linked to the fakesink */static voidrun_delayed_test (const gchar * pipe_str, const gchar * peer,    gboolean expect_link){  GstElement *pipe, *src, *sink;  GstPad *srcpad, *sinkpad, *peerpad = NULL;  pipe = setup_pipeline (pipe_str);  src = gst_bin_get_by_name (GST_BIN (pipe), "src");  fail_if (src == NULL, "Test source element was not created");  sink = gst_bin_get_by_name (GST_BIN (pipe), "sink");  fail_if (sink == NULL, "Test sink element was not created");  /* The src should not yet have a src pad */  srcpad = gst_element_get_pad (src, "src");  fail_unless (srcpad == NULL, "Source element already has a source pad");  /* Set the state to PAUSED and wait until the src at least reaches that   * state */  fail_if (gst_element_set_state (pipe, GST_STATE_PAUSED) ==      GST_STATE_CHANGE_FAILURE);  fail_if (gst_element_get_state (src, NULL, NULL, GST_CLOCK_TIME_NONE) ==      GST_STATE_CHANGE_FAILURE);  /* Now, the source element should have a src pad, and if "peer" was passed,    * then the src pad should have gotten linked to the 'sink' pad of that    * peer */  srcpad = gst_element_get_pad (src, "src");  fail_if (srcpad == NULL, "Source element did not create source pad");  peerpad = gst_pad_get_peer (srcpad);  if (expect_link == TRUE) {    fail_if (peerpad == NULL, "Source element pad did not get linked");  } else {    fail_if (peerpad != NULL,        "Source element pad got linked but should not have");  }  if (peerpad != NULL)    gst_object_unref (peerpad);  if (peer != NULL) {    GstElement *peer_elem = gst_bin_get_by_name (GST_BIN (pipe), peer);    fail_if (peer_elem == NULL, "Could not retrieve peer %s", peer);    sinkpad = gst_element_get_pad (peer_elem, "sink");    fail_if (sinkpad == NULL, "Peer element did not have a 'sink' pad");    fail_unless (peerpad == sinkpad,        "Source src pad got connected to the wrong peer");    gst_object_unref (sinkpad);  }  gst_object_unref (srcpad);  gst_object_unref (src);  gst_object_unref (sink);  gst_object_unref (pipe);}GST_START_TEST (delayed_link){  /* This tests the delayed linking support in parse_launch by creating   * a test element based on bin, which contains a fakesrc and a sometimes    * pad-template, and trying to link to a fakesink. When the bin transitions   * to paused it adds a pad, which should get linked to the fakesink */  run_delayed_test      ("parsetestelement name=src ! fakesink silent=true name=sink", "sink",      TRUE);  /* Test, but this time specifying both pad names */  run_delayed_test ("parsetestelement name=src .src ! "      ".sink fakesink silent=true name=sink", "sink", TRUE);  /* Now try with a caps filter, but not testing that   * the peerpad == sinkpad, because the peer will actually   * be a capsfilter */  run_delayed_test ("parsetestelement name=src ! application/x-test-caps ! "      "fakesink silent=true name=sink", NULL, TRUE);  /* Now try with mutually exclusive caps filters that    * will prevent linking, but only once gets around to happening -   * ie, the pipeline should create ok but fail to change state */  run_delayed_test ("parsetestelement name=src ! application/x-test-caps ! "      "identity silent=true ! application/x-other-caps ! "      "fakesink silent=true name=sink silent=true", NULL, FALSE);}GST_END_TEST;#define GST_TYPE_PARSE_TEST_ELEMENT (gst_parse_test_element_get_type())typedef struct _GstParseTestElement{  GstBin parent;  GstElement *fakesrc;} GstParseTestElement;typedef struct _GstParseTestElementClass{  GstBinClass parent;} GstParseTestElementClass;static GstStaticPadTemplate test_element_pad_template =GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC,    GST_PAD_SOMETIMES, GST_STATIC_CAPS ("application/x-test-caps"));GST_BOILERPLATE (GstParseTestElement, gst_parse_test_element, GstBin,    GST_TYPE_BIN);static GstStateChangeReturngst_parse_test_element_change_state (GstElement * element,    GstStateChange transition);static voidgst_parse_test_element_base_init (gpointer g_class){  static const GstElementDetails cdfoo_details =      GST_ELEMENT_DETAILS ("Test element for parse launch tests",      "Source",      "Test element for parse launch tests in core",      "GStreamer Devel <gstreamer-devel@lists.sf.net>");  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);  gst_element_class_set_details (element_class, &cdfoo_details);}static voidgst_parse_test_element_class_init (GstParseTestElementClass * klass){  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);  gst_element_class_add_pad_template (gstelement_class,      gst_static_pad_template_get (&test_element_pad_template));  gstelement_class->change_state = gst_parse_test_element_change_state;}static voidgst_parse_test_element_init (GstParseTestElement * src,    GstParseTestElementClass * klass){  /* Create a fakesrc and add it to ourselves */  src->fakesrc = gst_element_factory_make ("fakesrc", NULL);  if (src->fakesrc)    gst_bin_add (GST_BIN (src), src->fakesrc);}static GstStateChangeReturngst_parse_test_element_change_state (GstElement * element,    GstStateChange transition){  GstParseTestElement *src = (GstParseTestElement *) element;  if (transition == GST_STATE_CHANGE_READY_TO_PAUSED) {    /* Add our pad */    GstPad *pad;    GstPad *ghost;    if (src->fakesrc == NULL)      return GST_STATE_CHANGE_FAILURE;    pad = gst_element_get_pad (src->fakesrc, "src");    if (pad == NULL)      return GST_STATE_CHANGE_FAILURE;    ghost = gst_ghost_pad_new ("src", pad);    fail_if (ghost == NULL, "Failed to create ghost pad");    /* activate and add */    gst_pad_set_active (ghost, TRUE);    gst_element_add_pad (GST_ELEMENT (src), ghost);    gst_object_unref (pad);  }  return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);}static gbooleangst_register_parse_element (GstPlugin * plugin){  if (!gst_element_register (plugin, "parsetestelement", GST_RANK_NONE,          GST_TYPE_PARSE_TEST_ELEMENT))    return FALSE;  return TRUE;}GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR, GST_VERSION_MINOR,    "parsetestelement", "Test element for parse launch",    gst_register_parse_element, VERSION, GST_LICENSE, GST_PACKAGE_NAME,    GST_PACKAGE_ORIGIN);Suite *parse_suite (void){  Suite *s = suite_create ("Parse Launch syntax");  TCase *tc_chain = tcase_create ("parselaunch");  /* time out after 20s, not the default 3 */  tcase_set_timeout (tc_chain, 20);  suite_add_tcase (s, tc_chain);  tcase_add_test (tc_chain, test_launch_lines);  tcase_add_test (tc_chain, test_launch_lines2);  tcase_add_test (tc_chain, expected_to_fail_pipes);  tcase_add_test (tc_chain, leaking_fail_pipes);  tcase_add_test (tc_chain, delayed_link);  return s;}GST_CHECK_MAIN (parse);

⌨️ 快捷键说明

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