Updated the padfactory test code.
authorWim Taymans <wim.taymans@gmail.com>
Mon, 16 Apr 2001 21:48:44 +0000 (21:48 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 16 Apr 2001 21:48:44 +0000 (21:48 +0000)
Original commit message from CVS:
Updated the padfactory test code.

tests/Makefile.am
tests/padfactory.c

index 27b8a74..709d5a9 100644 (file)
@@ -2,7 +2,7 @@ SUBDIRS = sched eos
 
 noinst_PROGRAMS = init loadall simplefake states caps queue registry \
 paranoia rip mp3encode autoplug props case4 markup load tee autoplug2 autoplug3 \
-capsconnect
+capsconnect padfactory
 
 # we have nothing but apps here, we can do this safely
 LIBS += $(GST_LIBS)
index 3fcb210..5bdcfec 100644 (file)
@@ -1,55 +1,93 @@
 #include <gst/gst.h>
 
-static GstCapsFactory mpeg2dec_sink_caps = {
-  "mpeg2deccaps",
-  "video/mpeg",
-  "mpegtype", GST_PROPS_LIST (
-                     GST_PROPS_INT(1),
-                     GST_PROPS_INT(2)
-               ),
-  NULL
-};
-
-static GstCapsFactory mpeg2dec_src_caps = {
-  "name",
-  "video/raw",
-  "fourcc",    GST_PROPS_LIST (
-                        GST_PROPS_FOURCC ('Y','V','1','2'), 
-                       GST_PROPS_FOURCC_INT (0x56595559)
-                       ),
-  "width",     GST_PROPS_INT_RANGE (16, 4096),
-  "height",    GST_PROPS_INT_RANGE (16, 4096),
-  NULL
-};
+static GstCaps*
+mpeg2dec_sink_caps (void)
+{
+  static GstCaps *caps;
 
-static GstCapsFactory raw_sink_caps = {
-  NULL
-};
+  if (!caps) {
+    caps = gst_caps_new (
+      "mpeg2deccaps",
+      "video/mpeg",
+      gst_props_new (
+        "mpegtype", GST_PROPS_LIST (
+                      GST_PROPS_INT(1),
+                      GST_PROPS_INT(2)
+                   ),
+       NULL));
+  }
+  return caps;
+}
 
-static GstPadFactory pad_caps = {
-  "src",
-  GST_PAD_FACTORY_SRC,
-  GST_PAD_FACTORY_ALWAYS,
-  GST_PAD_FACTORY_CAPS (
-    "videocaps",
+GST_CAPS_FACTORY (mpeg2dec_src_caps,
+  GST_CAPS_NEW (
+    "mpeg2dec_src_caps",
     "video/raw",
-    "fourcc",  GST_PROPS_LIST (
-                        GST_PROPS_FOURCC_INT (0x32315659),
-                        GST_PROPS_FOURCC ('Y','U','Y','V') 
-                       ),
-    "height",  GST_PROPS_INT_RANGE (16, 4096)
+      "fourcc",   GST_PROPS_LIST (
+                    GST_PROPS_FOURCC ( GST_MAKE_FOURCC ('Y','V','1','2')), 
+                   GST_PROPS_FOURCC (0x56595559)
+                 ),
+      "width",   GST_PROPS_INT_RANGE (16, 4096),
+      "height",          GST_PROPS_INT_RANGE (16, 4096)
   ),
-  GST_PAD_FACTORY_CAPS (
-    "videocaps2",
+  GST_CAPS_NEW (
+    "mpeg2dec_src_caps",
     "video/raw",
-    "fourcc",  GST_PROPS_LIST (
-                        GST_PROPS_FOURCC_INT (0x32315659)
+      "foo",   GST_PROPS_BOOLEAN (TRUE)
+  )
+)
+
+static GstPadTemplate*
+pad_caps (void)
+{
+  static GstPadTemplate *template = NULL;
+
+  if (!template) {
+    template = gst_padtemplate_new (
+      "src",
+      GST_PAD_SRC,
+      GST_PAD_ALWAYS,
+      gst_caps_new (
+        "videocaps",
+        "video/raw",
+       gst_props_new (
+          "fourcc",    GST_PROPS_LIST (
+                          GST_PROPS_FOURCC (0x32315659),
+                          GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')) 
                        ),
-    "height",  GST_PROPS_INT_RANGE (16, 256)
-  ),
-  NULL
-};
+          "height",    GST_PROPS_INT_RANGE (16, 4096),
+         NULL)),
+      gst_caps_new (
+        "videocaps2",
+        "video/raw",
+       gst_props_new (
+          "fourcc",    GST_PROPS_LIST (
+                          GST_PROPS_FOURCC (0x32315659)
+                       ),
+          "height",    GST_PROPS_INT_RANGE (16, 256),
+         NULL)),
+      NULL);
+  }
+  return template;
+}
 
+GST_PADTEMPLATE_FACTORY (testtempl,
+  "src",
+  GST_PAD_SRC,
+  GST_PAD_ALWAYS,
+  GST_CAPS_NEW (
+    "mycaps",
+    "audio/raw",
+      "format", GST_PROPS_INT (55),
+      "foo",   GST_PROPS_STRING ("bar")
+  ),
+  GST_CAPS_NEW (
+    "mycaps2",
+    "audio/float",
+      "format", GST_PROPS_INT (7),
+      "baz",   GST_PROPS_STRING ("toe")
+  )
+)
 
 static GstCaps *sinkcaps = NULL, 
                *rawcaps = NULL;
@@ -58,27 +96,29 @@ static GstPadTemplate *temp;
 
 int main(int argc,char *argv[]) 
 {
-  gboolean testret;
   xmlDocPtr doc;
   xmlNodePtr parent;
 
   doc = xmlNewDoc ("1.0");
   doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
 
-  _gst_type_initialize ();
+  gst_init (&argc, &argv);
 
-  sinkcaps = gst_caps_register (&mpeg2dec_sink_caps);
+  sinkcaps = mpeg2dec_sink_caps ();
   parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
   gst_caps_save_thyself (sinkcaps, parent);
 
-  rawcaps  = gst_caps_register (&mpeg2dec_src_caps);
+  rawcaps  = GST_CAPS_GET (mpeg2dec_src_caps);
   parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL);
   gst_caps_save_thyself (rawcaps, parent);
 
-  temp = gst_padtemplate_new (&pad_caps);
+  temp = pad_caps ();
   parent = xmlNewChild (doc->xmlRootNode, NULL, "Padtemplate", NULL);
   gst_padtemplate_save_thyself (temp, parent);
 
+  parent = xmlNewChild (doc->xmlRootNode, NULL, "Padtemplate2", NULL);
+  gst_padtemplate_save_thyself (GST_PADTEMPLATE_GET (testtempl), parent);
+
   xmlDocDump(stdout, doc);
 
   return 0;