From 6bd5dcffab3a8b85ee1b981f5ecc40c6654874e5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 17 Apr 2001 21:14:55 +0000 Subject: [PATCH] The first wave of docs updates Original commit message from CVS: The first wave of docs updates Added a little more comments about the API usage in the api docs. Some fixes for the capsnego testsuite. --- configure.in | 2 + docs/gst/gstreamer-sections.txt | 20 +- docs/gst/gstreamer.hierarchy | 1 - docs/gst/tmpl/gst.sgml | 21 ++ docs/gst/tmpl/gstautoplug.sgml | 86 ++++++- docs/gst/tmpl/gstbin.sgml | 4 +- docs/gst/tmpl/gstbuffer.sgml | 17 ++ docs/gst/tmpl/gstcaps.sgml | 72 ++++-- docs/gst/tmpl/gstfakesink.sgml | 5 + docs/gst/tmpl/gsthttpsrc.sgml | 11 - docs/gst/tmpl/gstpad.sgml | 79 ++++++- docs/gst/tmpl/gstprops.sgml | 33 ++- docs/gst/tmpl/gstreamer-unused.sgml | 263 ++++++++++++---------- gst/gstcaps.c | 4 +- gst/gstobject.c | 9 + gst/gstpad.c | 11 +- tests/old/testsuite/capsnego/capsnego.c | 130 +++++++---- tests/old/testsuite/capsnego/converter.c | 167 ++++++++------ tests/old/testsuite/capsnego/converter2.c | 176 +++++++++------ tests/old/testsuite/capsnego/enum.c | 89 +++++--- testsuite/capsnego/capsnego.c | 130 +++++++---- testsuite/capsnego/converter.c | 167 ++++++++------ testsuite/capsnego/converter2.c | 176 +++++++++------ testsuite/capsnego/enum.c | 89 +++++--- 24 files changed, 1126 insertions(+), 636 deletions(-) diff --git a/configure.in b/configure.in index 3a0a7af16f..32f7d24298 100644 --- a/configure.in +++ b/configure.in @@ -837,6 +837,7 @@ plugins/filters/passthrough/Makefile plugins/filters/adder/Makefile plugins/filters/colorspace/Makefile plugins/filters/volenv/Makefile +plugins/filters/adder/Makefile plugins/icecast/Makefile plugins/icecast/icecastsend/Makefile plugins/effects/Makefile @@ -884,6 +885,7 @@ examples/queue2/Makefile examples/queue3/Makefile examples/queue4/Makefile examples/thread/Makefile +examples/mixer/Makefile examples/launch/Makefile examples/xml/Makefile examples/plugins/Makefile diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index ca9923f14c..c370add9fa 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -27,6 +27,9 @@ cothread_get_data gst_init gst_main gst_main_quit +GST_VERSION_MICRO +GST_VERSION_MAJOR +GST_VERSION_MINOR @@ -136,9 +139,13 @@ GST_BUFFER_SIZE GST_BUFFER_OFFSET GST_BUFFER_MAXSIZE GST_BUFFER_TIMESTAMP +GST_BUFFER_BUFFERPOOL +GST_BUFFER_POOL_PRIVATE GST_BUFFER_LOCK GST_BUFFER_TRYLOCK GST_BUFFER_UNLOCK + + GstBufferFlags GstBuffer gst_buffer_new @@ -367,12 +374,11 @@ GstPadGetRegionFunction GstPadQoSFunction GstPadEOSFunction GstPadNewCapsFunction - +GstPadBufferPoolFunction GstPadNegotiateReturn GstPadNegotiateFunction - GstPadPushFunction GstPadPullFunction GstRegionType @@ -391,6 +397,7 @@ gst_pad_set_negotiate_function gst_pad_set_qos_function gst_pad_set_eos_function gst_pad_set_newcaps_function +gst_pad_set_bufferpool_function gst_pad_set_caps gst_pad_get_caps gst_pad_check_compatibility @@ -410,6 +417,7 @@ gst_pad_disconnect gst_pad_push gst_pad_pull gst_pad_pullregion +gst_pad_get_bufferpool gst_pad_set_eos gst_pad_handle_qos gst_pad_eos @@ -439,6 +447,7 @@ GST_RPAD_QOSFUNC GST_RPAD_EOSFUNC GST_RPAD_NEGOTIATEFUNC GST_RPAD_NEWCAPSFUNC +GST_RPAD_BUFFERPOOLFUNC GST_GPAD_REALPAD GstGhostPad @@ -450,6 +459,9 @@ GST_PADTEMPLATE_CAPS GST_PADTEMPLATE_DIRECTION GST_PADTEMPLATE_NAME_TEMPLATE GST_PADTEMPLATE_PRESENCE +GST_PADTEMPLATE_NEW +GST_PADTEMPLATE_FACTORY +GST_PADTEMPLATE_GET gst_padtemplate_new gst_padtemplate_load_thyself gst_padtemplate_save_thyself @@ -615,6 +627,9 @@ gst_typefactory_save_thyself GST_CAPS_LOCK GST_CAPS_TRYLOCK GST_CAPS_UNLOCK +GST_CAPS_NEW +GST_CAPS_FACTORY +GST_CAPS_GET GstCaps gst_caps_new gst_caps_destroy @@ -622,6 +637,7 @@ gst_caps_ref gst_caps_unref gst_caps_copy gst_caps_copy_on_write +gst_caps_chain gst_caps_append gst_caps_prepend gst_caps_set_name diff --git a/docs/gst/gstreamer.hierarchy b/docs/gst/gstreamer.hierarchy index 3fcebbbbf3..247904e9da 100644 --- a/docs/gst/gstreamer.hierarchy +++ b/docs/gst/gstreamer.hierarchy @@ -9,7 +9,6 @@ GtkObject GstFakeSrc GstFakeSink GstDiskSrc - GstHttpSrc GstFdSrc GstSineSrc GstFdSink diff --git a/docs/gst/tmpl/gst.sgml b/docs/gst/tmpl/gst.sgml index c254b7790a..546b49c682 100644 --- a/docs/gst/tmpl/gst.sgml +++ b/docs/gst/tmpl/gst.sgml @@ -53,3 +53,24 @@ pipeline and Microsoft's DirectShow for some background. + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/gst/tmpl/gstautoplug.sgml b/docs/gst/tmpl/gstautoplug.sgml index 528b68724e..ff407eac19 100644 --- a/docs/gst/tmpl/gstautoplug.sgml +++ b/docs/gst/tmpl/gstautoplug.sgml @@ -7,12 +7,92 @@ Automatically create and connect elements GstAutoplug is an abstract class that is used for constructing and -connecting elements. +connecting elements. Two types og autopluggers exist: renderer ones and non +renderer ones. the renderer autopluggers will not have any src pads while the +non renderer ones do. + + + +You first need to create a suitable autoplugger with gst_autoplugfactory_make(). +The name of the autoplugger must be one of the registered autopluggers +(see #GstStaticAutoplug and #GstStaticAutoplugRender). + + +A list of all available autopluggers can be obtained with gst_autoplugfactory_get_list(). + + +If the autoplugger supports the RENDERER API, use gst_autoplug_to_renderers() call to +create a bin that connectes the src caps to the specified rendrer elements. You can +then add the bin to a pipeline and run it. + + + GstAutoplug *autoplug; + GstElement *element; + GstElement *sink; + + /* create a static autoplugger */ + autoplug = gst_autoplugfactory_make ("staticrender"); + + /* create an osssink */ + sink = gst_elementfactory_make ("osssink", "our_sink"); + + /* create an element that can play audio/mp3 through osssink */ + element = gst_autoplug_to_renderers (autoplug, + gst_caps_new ( + "sink_audio_caps", + "audio/mp3", + NULL + ), + sink, + NULL); + + /* add the element to a bin and connect the sink pad */ + ... + + + +If the autoplugger supports the CAPS API, use gst_autoplug_to_caps() call to +connect the src caps to the destination caps. The created bin will have src pads +compatible with the provided sink caps. + + + GstAutoplug *autoplug; + GstElement *element; + + /* create a static autoplugger */ + autoplug = gst_autoplugfactory_make ("static"); + + /* create an element that converts audio/mp3 to audio/raw */ + element = gst_autoplug_to_caps (autoplug, + gst_caps_new ( + "sink_audio_caps", + "audio/mp3", + NULL + ), + gst_caps_new ( + "src_audio_caps", + "audio/raw", + NULL + ), + NULL); + + /* add the element to a bin and connect the src/sink pads */ + ... + + + + +Optionally you can get a notification when a new object is added to the created +pipeline with a gtk_signal_connect to the "new_object" signal. + + + +Use the regular gst_object_destroy() call to destroy the autoplugger. - +GstStaticAutoplug, GstStaticAutoplugRender @@ -24,7 +104,7 @@ connecting elements. - +The type of the autoplugger. @GST_AUTOPLUG_TO_CAPS: diff --git a/docs/gst/tmpl/gstbin.sgml b/docs/gst/tmpl/gstbin.sgml index f4840c4968..4669eb4ee0 100644 --- a/docs/gst/tmpl/gstbin.sgml +++ b/docs/gst/tmpl/gstbin.sgml @@ -43,10 +43,10 @@ Flags for a bin. - +Free the memory allocated by this bin -@bin: +@bin: the bin to free diff --git a/docs/gst/tmpl/gstbuffer.sgml b/docs/gst/tmpl/gstbuffer.sgml index 9e6f6a2913..288a588dba 100644 --- a/docs/gst/tmpl/gstbuffer.sgml +++ b/docs/gst/tmpl/gstbuffer.sgml @@ -102,6 +102,22 @@ Get the timestamp for this buffer. @buf: GstBuffer + + +Get the bufferpool for this buffer. + + +@buf: GstBuffer + + + + +Get the bufferpool private data. + + +@buf: GstBuffer + + This macro will obtain a lock on the object, making serialization @@ -160,6 +176,7 @@ used when data in a stream has been skipped @metas: @parent: @pool: +@pool_private: diff --git a/docs/gst/tmpl/gstcaps.sgml b/docs/gst/tmpl/gstcaps.sgml index 9f1e9f3fc4..6f8a9e5a12 100644 --- a/docs/gst/tmpl/gstcaps.sgml +++ b/docs/gst/tmpl/gstcaps.sgml @@ -39,6 +39,34 @@ Unlock the caps structure @caps: The caps structure to unlock + + +A convenience macro to create a new GstCaps structure. + + +@name: the name of the caps structure +@type: the mime type of the caps structure +@a...: the properties of this caps stucture. + + + + +A convenience macro to create a GstCaps factory. + + +@factoryname: the name of the factory +@a...: the caps to create with this factory, usualy specified +with GST_CAPS_NEW() + + + + +A convenience macro to get a GstCaps from the given capsfactory. + + +@fact: the factory to use. + + @@ -76,6 +104,7 @@ Unlock the caps structure @caps: +@Returns: @@ -84,6 +113,7 @@ Unlock the caps structure @caps: +@Returns: @@ -104,6 +134,16 @@ Unlock the caps structure @Returns: + + + + + +@caps: +@Varargs: +@Returns: + + @@ -212,21 +252,21 @@ Unlock the caps structure - +Set a property of a caps structure. -@caps: -@name: -@args...: +@caps: the caps structure to modify +@name: the name of the property to change +@args...: the new value of the property - +Get the value of the named property as a boolean. -@caps: -@name: +@caps: the caps to query +@name: the name of the property to get @@ -241,29 +281,29 @@ Unlock the caps structure - +Get the value of the named property as a fourcc. -@caps: -@name: +@caps: the caps to query +@name: the name of the property to get - +Get the value of the named property as an int. -@caps: -@name: +@caps: the caps to query +@name: the name of the property to get - +Get the value of the named property as a string. -@caps: -@name: +@caps: the caps to query +@name: the name of the property to get diff --git a/docs/gst/tmpl/gstfakesink.sgml b/docs/gst/tmpl/gstfakesink.sgml index 9d405d62f4..091729ef4a 100644 --- a/docs/gst/tmpl/gstfakesink.sgml +++ b/docs/gst/tmpl/gstfakesink.sgml @@ -28,3 +28,8 @@ with the buffer. (fakesink) + + + + + diff --git a/docs/gst/tmpl/gsthttpsrc.sgml b/docs/gst/tmpl/gsthttpsrc.sgml index f1c74b859a..2ba4a00e8d 100644 --- a/docs/gst/tmpl/gsthttpsrc.sgml +++ b/docs/gst/tmpl/gsthttpsrc.sgml @@ -14,14 +14,3 @@ Reads data from a URL. - - -Specify the location of the file. The location must be a fully qualified URL. - - - - -Specify how many bytes to read at a time. - - - diff --git a/docs/gst/tmpl/gstpad.sgml b/docs/gst/tmpl/gstpad.sgml index bc51b8eb22..b243f14d7a 100644 --- a/docs/gst/tmpl/gstpad.sgml +++ b/docs/gst/tmpl/gstpad.sgml @@ -157,11 +157,22 @@ The function that will be called in an EOS case. - +The function that will be called when the caps of the pad has +changed. -@pad: -@caps: +@pad: The pad that has its caps changed +@caps: the new caps of the pad + + + + +The function that will be called when a bufferpool is requested +from this pad. + + +@pad: the pad with the bufferpool +@Returns: the GstBufferPool associated with this pad. @@ -180,10 +191,8 @@ The function that will be called when negotiating. @pad: The pad that is being negotiated @caps: The current caps that are being negotiated -@data: +@data: A generic gpointer that can be used to store user_data @Returns: The result of the negotiation process - -@count: A counter to keep track of the negotiation process @@ -349,6 +358,15 @@ Destroy the pad. @newcaps: + + + + + +@pad: +@bufpool: + + @@ -530,6 +548,15 @@ Destroy the pad. @size: + + + + + +@pad: +@Returns: + + @@ -657,6 +684,7 @@ Call the EOS function of the pad @pullregionfunc: @negotiatefunc: @newcapsfunc: +@bufferpoolfunc: @ghostpads: @@ -771,6 +799,14 @@ Get the EOS function of the real pad. @pad: + + + + + +@pad: + + Get the real pad of this ghost pad. @@ -849,6 +885,37 @@ Indicates when this pad will become available. @templ: + + + + + +@padname: +@dir: +@pres: +@a...: + + + + + + + +@name: +@padname: +@dir: +@pres: +@a...: + + + + + + + +@fact: + + diff --git a/docs/gst/tmpl/gstprops.sgml b/docs/gst/tmpl/gstprops.sgml index 2c5f0eaf16..ed99e9a333 100644 --- a/docs/gst/tmpl/gstprops.sgml +++ b/docs/gst/tmpl/gstprops.sgml @@ -26,13 +26,14 @@ GstCaps - +Create a FOURCC value that can easily be used to construct +a fourcc property. -@a: -@b: -@c: -@d: +@a: first fourcc byte +@b: second fourcc byte +@c: third fourcc byte +@d: fourth fourcc byte @@ -65,11 +66,7 @@ Create an integer range property. Construct a fourcc property out of four bytes. -@a: first byte - -@b: second byte -@c: third byte -@d: fourth byte +@a: a fourcc value usualy created with GST_FOURCC_MAKE () @@ -82,27 +79,27 @@ Create a boolean property. - +Create a string value. -@a: +@a: the string value. - +Create a floating point value. -@a: +@a: the float value - +Create a float range value. -@a: -@b: +@a: lower float bounds +@b: upper float bounds @@ -113,8 +110,6 @@ Create a boolean property. @firstname: @Varargs: @Returns: - -@entry: diff --git a/docs/gst/tmpl/gstreamer-unused.sgml b/docs/gst/tmpl/gstreamer-unused.sgml index c750b5e1da..5fa58aa49d 100644 --- a/docs/gst/tmpl/gstreamer-unused.sgml +++ b/docs/gst/tmpl/gstreamer-unused.sgml @@ -67,14 +67,6 @@ Query the element for the current mime type - - - - - -@pad: -@buf: - @@ -83,7 +75,7 @@ Query the element for the current mime type @pad: @parent: - + @@ -91,7 +83,13 @@ Query the element for the current mime type @pad: @buf: - + + +Specify the location of the file. The location must be a fully qualified URL. + + + + @@ -106,6 +104,14 @@ Query the element for the current mime type @Returns: + + + + + +@pad: +@buf: + @@ -200,6 +206,12 @@ the stream. @gstsrc: the object which received the signal. @arg1: the object which received the signal + + + + + + @@ -207,12 +219,6 @@ the stream. @Returns: - - - - - - @@ -366,16 +372,16 @@ subclass use this to start their flag enumeration @audiosink: @channels: + +Generic connection between elements. + + - -Generic connection between elements. - - @@ -655,13 +661,13 @@ Specify the current offset in the file. @sheight: @bytes_per_line: - + - + @@ -695,17 +701,24 @@ Specify the current offset in the file. @name: @Returns: + + + + + + - + +@src: @@ -715,13 +728,6 @@ Specify the current offset in the file. @id: @sink: - - - - - -@src: - @@ -1135,13 +1141,6 @@ GstFilter @obj: - - - - - -@Returns: - @@ -1149,6 +1148,13 @@ GstFilter @obj: + + + + + +@Returns: + @@ -1157,6 +1163,13 @@ GstFilter @pad: @Returns: + + + + + +@thread: + @@ -1167,13 +1180,6 @@ GstFilter @y1: @y2: - - - - - -@thread: - Flags for the GstSrc element @@ -1249,13 +1255,6 @@ Defines an entry for a padfactory. @obj: - - - - - -@klass: - @@ -1263,6 +1262,13 @@ Defines an entry for a padfactory. @Returns: + + + + + +@klass: + Indicates a sinkpad for the padfactory. @@ -1298,6 +1304,12 @@ Indicates a sinkpad for the padfactory. @pad: @Returns: + + + + + + @@ -1306,12 +1318,6 @@ Indicates a sinkpad for the padfactory. @name: @Returns: - - - - - - @@ -1421,12 +1427,6 @@ This macro sets the given flags. @flag: Flag to set, can by any number of bits in guint32. @obj: GstSrc to set flag in. - - - - - - @@ -1434,6 +1434,12 @@ This macro sets the given flags. @a: + + + + + + @@ -1455,16 +1461,16 @@ This macro sets the given flags. + +GstSink + + A flag indicating that MMX instructions are supported. - -GstSink - - @@ -1602,6 +1608,13 @@ Indicates a srcpad for the padfactory. @obj: + + +Specify how many bytes to read at a time. + + + + @@ -1771,13 +1784,6 @@ or a video card. - - - - - -@Returns: - @@ -1785,6 +1791,13 @@ or a video card. @obj: + + + + + +@Returns: + @@ -1805,6 +1818,12 @@ Query whether this object has multiple input pads. @obj: Element to query for multiple input pads. + + + + + + @@ -1813,12 +1832,6 @@ Query whether this object has multiple input pads. @format: @args...: - - - - - - @@ -2236,6 +2249,13 @@ this in the factory definition. @audiosink: + + + + + +@obj: + This macro unsets the given state on the element. @@ -2244,13 +2264,6 @@ This macro unsets the given state on the element. @obj: Element to unset state of. @flag: State to unset, can be any number of bits in guint32. - - - - - -@obj: - @@ -2323,13 +2336,6 @@ The number of bytes per read. @obj: - - - - - -@Returns: - @@ -2340,6 +2346,13 @@ The number of bytes per read. @format: @args...: + + + + + +@Returns: + @@ -2444,14 +2457,9 @@ This macro sets the given state on the element. @obj: - - + +Information about video buffers. - - -@src: -@offset: -@size: @@ -2460,9 +2468,14 @@ This macro sets the given state on the element. @Returns: - -Information about video buffers. + + + + +@src: +@offset: +@size: @@ -2566,13 +2579,13 @@ A flag indicating that SSE instructions are supported. @obj: - + - + @@ -2653,6 +2666,12 @@ Information about audio buffers. + + + + + + @@ -2661,12 +2680,6 @@ Information about audio buffers. @factory: @Returns: - - - - - - Specify the location of the file to read. @@ -2730,13 +2743,6 @@ the offset. - - - - - -@obj: - @@ -2745,6 +2751,13 @@ the offset. @name: @Returns: + + + + + +@obj: + Get the current number of bytes read. @@ -2793,13 +2806,6 @@ plugin @klass: - - - - - -@obj: - @@ -2807,6 +2813,13 @@ plugin @klass: + + + + + +@obj: + Indicates this pad is active diff --git a/gst/gstcaps.c b/gst/gstcaps.c index d2b231f846..df122b58b2 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -120,7 +120,7 @@ gst_caps_destroy (GstCaps *caps) * Decrease the refcount of this caps structure, * destroying it when the refcount is 0 * - * Retruns: caps or NULL if the refcount reached 0 + * Returns: caps or NULL if the refcount reached 0 */ GstCaps* gst_caps_unref (GstCaps *caps) @@ -153,7 +153,7 @@ gst_caps_unref (GstCaps *caps) * * Increase the refcount of this caps structure * - * Returnns: the caps with the refcount incremented + * Returns: the caps with the refcount incremented */ GstCaps* gst_caps_ref (GstCaps *caps) diff --git a/gst/gstobject.c b/gst/gstobject.c index c26744f8e0..2e7eafb885 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -336,6 +336,15 @@ gst_object_sink (GstObject *object) } #endif /* gst_object_sink */ +/** + * gst_object_save_thyself: + * @object: GstObject to save + * @parent: The parent XML node to save the object into + * + * Saves the given object into the parent XML node. + * + * Returns: the new xmlNodePtr with the saved object + */ xmlNodePtr gst_object_save_thyself (GstObject *object, xmlNodePtr parent) { diff --git a/gst/gstpad.c b/gst/gstpad.c index 7d9786bcd4..54c9a8e6e9 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -452,7 +452,7 @@ gst_pad_set_newcaps_function (GstPad *pad, /** * gst_pad_set_bufferpool_function: * @pad: the pad to set the bufferpool function for - * @newcaps: the bufferpool function + * @bufpool: the bufferpool function * * Set the given bufferpool function for the pad. */ @@ -916,6 +916,15 @@ gst_pad_get_peer (GstPad *pad) return GST_PAD(GST_PAD_PEER(pad)); } +/** + * gst_pad_get_buffer_pool: + * @pad: the pad to get the bufferpool from + * + * Gst the bufferpool of the peer pad of the given + * pad + * + * Returns: The GstBufferPool or NULL. + */ GstBufferPool* gst_pad_get_bufferpool (GstPad *pad) { diff --git a/tests/old/testsuite/capsnego/capsnego.c b/tests/old/testsuite/capsnego/capsnego.c index 0866491118..027440a936 100644 --- a/tests/old/testsuite/capsnego/capsnego.c +++ b/tests/old/testsuite/capsnego/capsnego.c @@ -4,53 +4,87 @@ GstPad *srcpad, *sinkpad; GstPad *srcpadtempl, *sinkpadtempl; -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "video/raw", - "height", GST_PROPS_INT_RANGE (16, 4096) - ), - NULL, -}; +static GstPadTemplate* +src_template_factory (void) +{ + static GstPadTemplate *templ = NULL; -static GstPadFactory sink_factory = { - "sink", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_sink", - "video/raw", - "height", GST_PROPS_INT_RANGE (16, 8192) - ), - NULL, -}; + if (!templ) { + templ = gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT_RANGE (16, 4096), + NULL)), + NULL); + } + return templ; +} -static GstCapsFactory sink_caps = { - "sink_caps", - "video/raw", - "height", GST_PROPS_INT (3000), - NULL -}; +static GstPadTemplate* +sink_template_factory (void) +{ + static GstPadTemplate *templ = NULL; -static GstCapsFactory src_caps = { - "src_caps", - "video/raw", - "height", GST_PROPS_INT (3000), - NULL -}; + if (!templ) { + templ = gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_sink", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT_RANGE (16, 8192), + NULL)), + NULL); + } + return templ; +} -static GstPadTemplate *srctempl, *sinktempl; -static GstCaps *srccaps, *sinkcaps; +static GstCaps* +sink_caps_factory (void) +{ + static GstCaps *caps = NULL; + + if (!caps) { + caps = gst_caps_new ( + "sink_caps", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT (3000), + NULL)); + } + return caps; +} + +static GstCaps* +src_caps_factory (void) +{ + static GstCaps *caps = NULL; + + if (!caps) { + caps = gst_caps_new ( + "src_caps", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT (3000), + NULL)); + } + return caps; +} static GstPadNegotiateReturn -negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">"); - if (counter == 0) { + if (*data == NULL) { + *data = GINT_TO_POINTER (TRUE); *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -61,10 +95,11 @@ negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<"); - if (counter == 0) { + if (*data == NULL) { + *data = GINT_TO_POINTER (TRUE); *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -74,6 +109,9 @@ negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) return GST_PAD_NEGOTIATE_FAIL; } +static GstPadTemplate *srctempl, *sinktempl; +static GstCaps *srccaps, *sinkcaps; + static gboolean perform_check (void) { @@ -121,14 +159,14 @@ main (int argc, char *argv[]) srcpad = gst_pad_new ("src", GST_PAD_SRC); sinkpad = gst_pad_new ("sink", GST_PAD_SINK); - srctempl = gst_padtemplate_new (&src_factory); - sinktempl = gst_padtemplate_new (&sink_factory); + srctempl = src_template_factory (); + sinktempl = sink_template_factory (); - srcpadtempl = gst_pad_new_from_template (srctempl, "src"); - sinkpadtempl = gst_pad_new_from_template (sinktempl, "sink"); + srcpadtempl = gst_pad_new_from_template (src_template_factory (), "src"); + sinkpadtempl = gst_pad_new_from_template (sink_template_factory (), "sink"); - sinkcaps = gst_caps_register (&sink_caps); - srccaps = gst_caps_register (&src_caps); + sinkcaps = sink_caps_factory (); + srccaps = src_caps_factory (); g_print ("*** compatible caps/templates ***\n"); diff --git a/tests/old/testsuite/capsnego/converter.c b/tests/old/testsuite/capsnego/converter.c index df26338d1f..83dd8d4648 100644 --- a/tests/old/testsuite/capsnego/converter.c +++ b/tests/old/testsuite/capsnego/converter.c @@ -3,82 +3,112 @@ GstPad *srcpad, *sinkpad; GstPad *srcconvpad, *sinkconvpad; -GstPad *srcpadtempl, *sinkpadtempl; -GstPad *srcconvtempl, *sinkconvtempl; +GstPadTemplate *srcpadtempl, *sinkpadtempl; +GstPadTemplate *srcconvtempl, *sinkconvtempl; gint converter_in = -1, converter_out = -1; -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory src_conv_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_conv_factory = { - "src", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_factory = { - "sink", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_sink", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_factory (void) +{ + return + gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_sink", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstCapsFactory sink_caps = { - "sink_caps", - "audio/raw", - "rate", GST_PROPS_INT (6000), - NULL -}; +static GstCaps* +sink_caps (void) +{ + return + gst_caps_new ( + "sink_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (6000), + NULL)); +} -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - NULL -}; +static GstCaps* +src_caps (void) +{ + return + gst_caps_new ( + "src_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (3000), + NULL)); +} static GstPadTemplate *srctempl, *sinktempl; static GstCaps *srccaps, *sinkcaps; static GstPadNegotiateReturn -negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">"); - if (counter == 0) { + if (data == NULL) { *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -91,10 +121,10 @@ negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<"); - if (counter == 0) { + if (data == NULL) { *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -114,21 +144,22 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - srctempl = gst_padtemplate_new (&src_factory); - sinktempl = gst_padtemplate_new (&sink_factory); + srctempl = src_factory (); + sinktempl = sink_factory (); srcpad = gst_pad_new_from_template (srctempl, "src"); sinkpad = gst_pad_new_from_template (sinktempl, "sink"); - srcconvtempl = gst_padtemplate_new (&src_conv_factory); - sinkconvtempl = gst_padtemplate_new (&sink_conv_factory); + srcconvtempl = src_conv_factory (); + sinkconvtempl = sink_conv_factory (); srcconvpad = gst_pad_new_from_template (srcconvtempl, "src"); sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "sink"); gst_pad_set_negotiate_function (srcconvpad, negotiate_src); gst_pad_set_negotiate_function (sinkconvpad, negotiate_sink); - sinkcaps = gst_caps_register (&sink_caps); - srccaps = gst_caps_register (&src_caps); + sinkcaps = sink_caps (); + srccaps = src_caps (); + result = gst_pad_set_caps (srcpad, srccaps); g_print ("set caps on src: %d\n", result); g_print ("initial converter status: %d %d\n", converter_in, converter_out); diff --git a/tests/old/testsuite/capsnego/converter2.c b/tests/old/testsuite/capsnego/converter2.c index 0532c76956..8b3ebb32ea 100644 --- a/tests/old/testsuite/capsnego/converter2.c +++ b/tests/old/testsuite/capsnego/converter2.c @@ -3,83 +3,113 @@ GstPad *srcpad, *sinkpad; GstPad *srcconvpad, *sinkconvpad; -GstPad *srcpadtempl, *sinkpadtempl; -GstPad *srcconvtempl, *sinkconvtempl; +GstPadTemplate *srcpadtempl, *sinkpadtempl; +GstPadTemplate *srcconvtempl, *sinkconvtempl; gint converter_in = -1, converter_out = -1; gint target_rate = 2000; -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory src_conv_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_conv_factory = { - "src", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_factory = { - "sink", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_sink", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_factory (void) +{ + return + gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_sink", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstCapsFactory sink_caps = { - "sink_caps", - "audio/raw", - "rate", GST_PROPS_INT (6000), - NULL -}; +static GstCaps* +sink_caps (void) +{ + return + gst_caps_new ( + "sink_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (6000), + NULL)); +} -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - NULL -}; +static GstCaps* +src_caps (void) +{ + return + gst_caps_new ( + "src_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (3000), + NULL)); +} static GstPadTemplate *srctempl, *sinktempl; static GstCaps *srccaps, *sinkcaps; static GstPadNegotiateReturn -converter_negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +converter_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">"); - if (counter == 0) { + if (*data == NULL) { *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -92,19 +122,19 @@ converter_negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -converter_negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +converter_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<"); - if (counter == 0) { + if (*data == NULL) { *caps = GST_PAD_CAPS (srcconvpad); return GST_PAD_NEGOTIATE_TRY; } if (*caps) { converter_in = gst_caps_get_int (*caps, "rate"); - if (counter == 1) { + if (*data == 1) { converter_out = gst_caps_get_int (*caps, "rate"); - return gst_pad_negotiate_proxy (pad, srcconvpad, caps, counter); + return gst_pad_negotiate_proxy (pad, srcconvpad, caps); } return GST_PAD_NEGOTIATE_AGREE; } @@ -113,11 +143,11 @@ converter_negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -target_negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +target_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("{"); - if (counter == 0) { - *caps = gst_caps_new_with_props ( + if (*data == NULL) { + *caps = gst_caps_new ( "target_caps", "audio/raw", gst_props_new ( @@ -143,13 +173,13 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - srctempl = gst_padtemplate_new (&src_factory); - sinktempl = gst_padtemplate_new (&sink_factory); + srctempl = src_factory (); + sinktempl = sink_factory (); srcpad = gst_pad_new_from_template (srctempl, "src"); sinkpad = gst_pad_new_from_template (sinktempl, "sink"); - srcconvtempl = gst_padtemplate_new (&src_conv_factory); - sinkconvtempl = gst_padtemplate_new (&sink_conv_factory); + srcconvtempl = src_conv_factory (); + sinkconvtempl = sink_conv_factory (); srcconvpad = gst_pad_new_from_template (srcconvtempl, "csrc"); sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "csink"); @@ -157,8 +187,8 @@ main (int argc, char *argv[]) gst_pad_set_negotiate_function (sinkconvpad, converter_negotiate_sink); gst_pad_set_negotiate_function (sinkpad, target_negotiate_sink); - sinkcaps = gst_caps_register (&sink_caps); - srccaps = gst_caps_register (&src_caps); + sinkcaps = sink_caps (); + srccaps = src_caps (); g_print ("-------) (-----------) (----- \n"); g_print (" ! ! converter ! ! \n"); diff --git a/tests/old/testsuite/capsnego/enum.c b/tests/old/testsuite/capsnego/enum.c index e3959309e9..343e08c10d 100644 --- a/tests/old/testsuite/capsnego/enum.c +++ b/tests/old/testsuite/capsnego/enum.c @@ -4,36 +4,51 @@ GstPad *srcconvpad, *sinkconvpad; GstPadTemplate *srcconvtempl, *sinkconvtempl; -static GstPadFactory src_conv_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_conv_factory = { - "src", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_conv_factory (void) +{ + return + gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - NULL -}; +static GstCaps* +src_caps (void) +{ + return + gst_caps_new ( + "src_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (3000), + NULL)); +} static GstCaps *srccaps, *sinkcaps; @@ -41,14 +56,14 @@ static gint src_rate = 140; static gint sink_rate = 100; static GstPadNegotiateReturn -negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">(%d:%d)", src_rate, (*caps)->refcount); src_rate++; - if (counter == 0 || caps == NULL) { + if (*data == NULL || caps == NULL) { g_print ("*"); - *caps = gst_caps_new_with_props ( + *caps = gst_caps_new ( "src_caps", "audio/raw", gst_props_new ( @@ -77,15 +92,15 @@ negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<(%d:%d:%p)", sink_rate, (*caps)->refcount, *caps); sink_rate++; - if (counter == 0 || *caps == NULL) { + if (*data == NULL || *caps == NULL) { g_print ("*"); - *caps = gst_caps_new_with_props ( + *caps = gst_caps_new ( "sink_caps", "audio/raw", gst_props_new ( @@ -126,15 +141,15 @@ main (int argc, char *argv[]) g_mem_chunk_info(); - srcconvtempl = gst_padtemplate_new (&src_conv_factory); - sinkconvtempl = gst_padtemplate_new (&sink_conv_factory); + srcconvtempl = src_conv_factory (); + sinkconvtempl = sink_conv_factory (); srcconvpad = gst_pad_new_from_template (srcconvtempl, "src"); sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "sink"); gst_pad_set_negotiate_function (srcconvpad, negotiate_src); gst_pad_set_negotiate_function (sinkconvpad, negotiate_sink); - srccaps = gst_caps_register (&src_caps); + srccaps = src_caps (); sinkcaps = gst_caps_copy (srccaps); g_print ("The wild goose chase...\n"); diff --git a/testsuite/capsnego/capsnego.c b/testsuite/capsnego/capsnego.c index 0866491118..027440a936 100644 --- a/testsuite/capsnego/capsnego.c +++ b/testsuite/capsnego/capsnego.c @@ -4,53 +4,87 @@ GstPad *srcpad, *sinkpad; GstPad *srcpadtempl, *sinkpadtempl; -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "video/raw", - "height", GST_PROPS_INT_RANGE (16, 4096) - ), - NULL, -}; +static GstPadTemplate* +src_template_factory (void) +{ + static GstPadTemplate *templ = NULL; -static GstPadFactory sink_factory = { - "sink", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_sink", - "video/raw", - "height", GST_PROPS_INT_RANGE (16, 8192) - ), - NULL, -}; + if (!templ) { + templ = gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT_RANGE (16, 4096), + NULL)), + NULL); + } + return templ; +} -static GstCapsFactory sink_caps = { - "sink_caps", - "video/raw", - "height", GST_PROPS_INT (3000), - NULL -}; +static GstPadTemplate* +sink_template_factory (void) +{ + static GstPadTemplate *templ = NULL; -static GstCapsFactory src_caps = { - "src_caps", - "video/raw", - "height", GST_PROPS_INT (3000), - NULL -}; + if (!templ) { + templ = gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_sink", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT_RANGE (16, 8192), + NULL)), + NULL); + } + return templ; +} -static GstPadTemplate *srctempl, *sinktempl; -static GstCaps *srccaps, *sinkcaps; +static GstCaps* +sink_caps_factory (void) +{ + static GstCaps *caps = NULL; + + if (!caps) { + caps = gst_caps_new ( + "sink_caps", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT (3000), + NULL)); + } + return caps; +} + +static GstCaps* +src_caps_factory (void) +{ + static GstCaps *caps = NULL; + + if (!caps) { + caps = gst_caps_new ( + "src_caps", + "video/raw", + gst_props_new ( + "height", GST_PROPS_INT (3000), + NULL)); + } + return caps; +} static GstPadNegotiateReturn -negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">"); - if (counter == 0) { + if (*data == NULL) { + *data = GINT_TO_POINTER (TRUE); *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -61,10 +95,11 @@ negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<"); - if (counter == 0) { + if (*data == NULL) { + *data = GINT_TO_POINTER (TRUE); *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -74,6 +109,9 @@ negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) return GST_PAD_NEGOTIATE_FAIL; } +static GstPadTemplate *srctempl, *sinktempl; +static GstCaps *srccaps, *sinkcaps; + static gboolean perform_check (void) { @@ -121,14 +159,14 @@ main (int argc, char *argv[]) srcpad = gst_pad_new ("src", GST_PAD_SRC); sinkpad = gst_pad_new ("sink", GST_PAD_SINK); - srctempl = gst_padtemplate_new (&src_factory); - sinktempl = gst_padtemplate_new (&sink_factory); + srctempl = src_template_factory (); + sinktempl = sink_template_factory (); - srcpadtempl = gst_pad_new_from_template (srctempl, "src"); - sinkpadtempl = gst_pad_new_from_template (sinktempl, "sink"); + srcpadtempl = gst_pad_new_from_template (src_template_factory (), "src"); + sinkpadtempl = gst_pad_new_from_template (sink_template_factory (), "sink"); - sinkcaps = gst_caps_register (&sink_caps); - srccaps = gst_caps_register (&src_caps); + sinkcaps = sink_caps_factory (); + srccaps = src_caps_factory (); g_print ("*** compatible caps/templates ***\n"); diff --git a/testsuite/capsnego/converter.c b/testsuite/capsnego/converter.c index df26338d1f..83dd8d4648 100644 --- a/testsuite/capsnego/converter.c +++ b/testsuite/capsnego/converter.c @@ -3,82 +3,112 @@ GstPad *srcpad, *sinkpad; GstPad *srcconvpad, *sinkconvpad; -GstPad *srcpadtempl, *sinkpadtempl; -GstPad *srcconvtempl, *sinkconvtempl; +GstPadTemplate *srcpadtempl, *sinkpadtempl; +GstPadTemplate *srcconvtempl, *sinkconvtempl; gint converter_in = -1, converter_out = -1; -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory src_conv_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_conv_factory = { - "src", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_factory = { - "sink", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_sink", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_factory (void) +{ + return + gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_sink", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstCapsFactory sink_caps = { - "sink_caps", - "audio/raw", - "rate", GST_PROPS_INT (6000), - NULL -}; +static GstCaps* +sink_caps (void) +{ + return + gst_caps_new ( + "sink_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (6000), + NULL)); +} -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - NULL -}; +static GstCaps* +src_caps (void) +{ + return + gst_caps_new ( + "src_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (3000), + NULL)); +} static GstPadTemplate *srctempl, *sinktempl; static GstCaps *srccaps, *sinkcaps; static GstPadNegotiateReturn -negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">"); - if (counter == 0) { + if (data == NULL) { *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -91,10 +121,10 @@ negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<"); - if (counter == 0) { + if (data == NULL) { *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -114,21 +144,22 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - srctempl = gst_padtemplate_new (&src_factory); - sinktempl = gst_padtemplate_new (&sink_factory); + srctempl = src_factory (); + sinktempl = sink_factory (); srcpad = gst_pad_new_from_template (srctempl, "src"); sinkpad = gst_pad_new_from_template (sinktempl, "sink"); - srcconvtempl = gst_padtemplate_new (&src_conv_factory); - sinkconvtempl = gst_padtemplate_new (&sink_conv_factory); + srcconvtempl = src_conv_factory (); + sinkconvtempl = sink_conv_factory (); srcconvpad = gst_pad_new_from_template (srcconvtempl, "src"); sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "sink"); gst_pad_set_negotiate_function (srcconvpad, negotiate_src); gst_pad_set_negotiate_function (sinkconvpad, negotiate_sink); - sinkcaps = gst_caps_register (&sink_caps); - srccaps = gst_caps_register (&src_caps); + sinkcaps = sink_caps (); + srccaps = src_caps (); + result = gst_pad_set_caps (srcpad, srccaps); g_print ("set caps on src: %d\n", result); g_print ("initial converter status: %d %d\n", converter_in, converter_out); diff --git a/testsuite/capsnego/converter2.c b/testsuite/capsnego/converter2.c index 0532c76956..8b3ebb32ea 100644 --- a/testsuite/capsnego/converter2.c +++ b/testsuite/capsnego/converter2.c @@ -3,83 +3,113 @@ GstPad *srcpad, *sinkpad; GstPad *srcconvpad, *sinkconvpad; -GstPad *srcpadtempl, *sinkpadtempl; -GstPad *srcconvtempl, *sinkconvtempl; +GstPadTemplate *srcpadtempl, *sinkpadtempl; +GstPadTemplate *srcconvtempl, *sinkconvtempl; gint converter_in = -1, converter_out = -1; gint target_rate = 2000; -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory src_conv_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_conv_factory = { - "src", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_factory = { - "sink", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_sink", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_factory (void) +{ + return + gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_sink", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstCapsFactory sink_caps = { - "sink_caps", - "audio/raw", - "rate", GST_PROPS_INT (6000), - NULL -}; +static GstCaps* +sink_caps (void) +{ + return + gst_caps_new ( + "sink_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (6000), + NULL)); +} -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - NULL -}; +static GstCaps* +src_caps (void) +{ + return + gst_caps_new ( + "src_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (3000), + NULL)); +} static GstPadTemplate *srctempl, *sinktempl; static GstCaps *srccaps, *sinkcaps; static GstPadNegotiateReturn -converter_negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +converter_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">"); - if (counter == 0) { + if (*data == NULL) { *caps = NULL; return GST_PAD_NEGOTIATE_TRY; } @@ -92,19 +122,19 @@ converter_negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -converter_negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +converter_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<"); - if (counter == 0) { + if (*data == NULL) { *caps = GST_PAD_CAPS (srcconvpad); return GST_PAD_NEGOTIATE_TRY; } if (*caps) { converter_in = gst_caps_get_int (*caps, "rate"); - if (counter == 1) { + if (*data == 1) { converter_out = gst_caps_get_int (*caps, "rate"); - return gst_pad_negotiate_proxy (pad, srcconvpad, caps, counter); + return gst_pad_negotiate_proxy (pad, srcconvpad, caps); } return GST_PAD_NEGOTIATE_AGREE; } @@ -113,11 +143,11 @@ converter_negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -target_negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +target_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("{"); - if (counter == 0) { - *caps = gst_caps_new_with_props ( + if (*data == NULL) { + *caps = gst_caps_new ( "target_caps", "audio/raw", gst_props_new ( @@ -143,13 +173,13 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - srctempl = gst_padtemplate_new (&src_factory); - sinktempl = gst_padtemplate_new (&sink_factory); + srctempl = src_factory (); + sinktempl = sink_factory (); srcpad = gst_pad_new_from_template (srctempl, "src"); sinkpad = gst_pad_new_from_template (sinktempl, "sink"); - srcconvtempl = gst_padtemplate_new (&src_conv_factory); - sinkconvtempl = gst_padtemplate_new (&sink_conv_factory); + srcconvtempl = src_conv_factory (); + sinkconvtempl = sink_conv_factory (); srcconvpad = gst_pad_new_from_template (srcconvtempl, "csrc"); sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "csink"); @@ -157,8 +187,8 @@ main (int argc, char *argv[]) gst_pad_set_negotiate_function (sinkconvpad, converter_negotiate_sink); gst_pad_set_negotiate_function (sinkpad, target_negotiate_sink); - sinkcaps = gst_caps_register (&sink_caps); - srccaps = gst_caps_register (&src_caps); + sinkcaps = sink_caps (); + srccaps = src_caps (); g_print ("-------) (-----------) (----- \n"); g_print (" ! ! converter ! ! \n"); diff --git a/testsuite/capsnego/enum.c b/testsuite/capsnego/enum.c index e3959309e9..343e08c10d 100644 --- a/testsuite/capsnego/enum.c +++ b/testsuite/capsnego/enum.c @@ -4,36 +4,51 @@ GstPad *srcconvpad, *sinkconvpad; GstPadTemplate *srcconvtempl, *sinkconvtempl; -static GstPadFactory src_conv_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +src_conv_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstPadFactory sink_conv_factory = { - "src", - GST_PAD_FACTORY_SINK, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "test_src", - "audio/raw", - "rate", GST_PROPS_INT_RANGE (16, 20000) - ), - NULL, -}; +static GstPadTemplate* +sink_conv_factory (void) +{ + return + gst_padtemplate_new ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + gst_caps_new ( + "test_src", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT_RANGE (16, 20000), + NULL)), + NULL); +} -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - NULL -}; +static GstCaps* +src_caps (void) +{ + return + gst_caps_new ( + "src_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (3000), + NULL)); +} static GstCaps *srccaps, *sinkcaps; @@ -41,14 +56,14 @@ static gint src_rate = 140; static gint sink_rate = 100; static GstPadNegotiateReturn -negotiate_src (GstPad *pad, GstCaps **caps, gint counter) +negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) { g_print (">(%d:%d)", src_rate, (*caps)->refcount); src_rate++; - if (counter == 0 || caps == NULL) { + if (*data == NULL || caps == NULL) { g_print ("*"); - *caps = gst_caps_new_with_props ( + *caps = gst_caps_new ( "src_caps", "audio/raw", gst_props_new ( @@ -77,15 +92,15 @@ negotiate_src (GstPad *pad, GstCaps **caps, gint counter) } static GstPadNegotiateReturn -negotiate_sink (GstPad *pad, GstCaps **caps, gint counter) +negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) { g_print ("<(%d:%d:%p)", sink_rate, (*caps)->refcount, *caps); sink_rate++; - if (counter == 0 || *caps == NULL) { + if (*data == NULL || *caps == NULL) { g_print ("*"); - *caps = gst_caps_new_with_props ( + *caps = gst_caps_new ( "sink_caps", "audio/raw", gst_props_new ( @@ -126,15 +141,15 @@ main (int argc, char *argv[]) g_mem_chunk_info(); - srcconvtempl = gst_padtemplate_new (&src_conv_factory); - sinkconvtempl = gst_padtemplate_new (&sink_conv_factory); + srcconvtempl = src_conv_factory (); + sinkconvtempl = sink_conv_factory (); srcconvpad = gst_pad_new_from_template (srcconvtempl, "src"); sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "sink"); gst_pad_set_negotiate_function (srcconvpad, negotiate_src); gst_pad_set_negotiate_function (sinkconvpad, negotiate_sink); - srccaps = gst_caps_register (&src_caps); + srccaps = src_caps (); sinkcaps = gst_caps_copy (srccaps); g_print ("The wild goose chase...\n");