diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2001-04-17 21:14:55 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2001-04-17 21:14:55 +0000 |
commit | 6bd5dcffab3a8b85ee1b981f5ecc40c6654874e5 (patch) | |
tree | 15b984b98c570a56c78b00091b981eb103b07b2d /testsuite | |
parent | a8ba9c4122139307a99d8703d7a06d34fd95889e (diff) |
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.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/capsnego/capsnego.c | 136 | ||||
-rw-r--r-- | testsuite/capsnego/converter.c | 177 | ||||
-rw-r--r-- | testsuite/capsnego/converter2.c | 186 | ||||
-rw-r--r-- | testsuite/capsnego/enum.c | 93 |
4 files changed, 353 insertions, 239 deletions
diff --git a/testsuite/capsnego/capsnego.c b/testsuite/capsnego/capsnego.c index 086649111..027440a93 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 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, -}; - -static GstCapsFactory sink_caps = { - "sink_caps", - "video/raw", - "height", GST_PROPS_INT (3000), - NULL -}; - -static GstCapsFactory src_caps = { - "src_caps", - "video/raw", - "height", GST_PROPS_INT (3000), - NULL -}; +static GstPadTemplate* +src_template_factory (void) +{ + static GstPadTemplate *templ = 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 GstPadTemplate *srctempl, *sinktempl; -static GstCaps *srccaps, *sinkcaps; +static GstPadTemplate* +sink_template_factory (void) +{ + static GstPadTemplate *templ = 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 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 df26338d1..83dd8d464 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 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 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 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 GstCapsFactory sink_caps = { - "sink_caps", - "audio/raw", - "rate", GST_PROPS_INT (6000), - NULL -}; - -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - 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 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 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 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 GstCaps* +sink_caps (void) +{ + return + gst_caps_new ( + "sink_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (6000), + 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 0532c7695..8b3ebb32e 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 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 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 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 GstCapsFactory sink_caps = { - "sink_caps", - "audio/raw", - "rate", GST_PROPS_INT (6000), - NULL -}; - -static GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - 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 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 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 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 GstCaps* +sink_caps (void) +{ + return + gst_caps_new ( + "sink_caps", + "audio/raw", + gst_props_new ( + "rate", GST_PROPS_INT (6000), + 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 e3959309e..343e08c10 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 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 GstCapsFactory src_caps = { - "src_caps", - "audio/raw", - "rate", GST_PROPS_INT (3000), - 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 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 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"); |