mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
Removed the old capsnego tests
Original commit message from CVS: Removed the old capsnego tests
This commit is contained in:
parent
f064c9f566
commit
5c10feaf48
16 changed files with 4 additions and 2172 deletions
|
@ -1,5 +1,5 @@
|
||||||
# FIXME : refcounting threads bytestream
|
# FIXME : refcounting threads bytestream
|
||||||
SUBDIRS = caps capsnego plugin cleanup
|
SUBDIRS = caps plugin cleanup
|
||||||
|
|
||||||
testprogs = test_gst_init
|
testprogs = test_gst_init
|
||||||
|
|
||||||
|
@ -12,4 +12,4 @@ LIBS = $(GST_LIBS)
|
||||||
CFLAGS = $(GST_CFLAGS)
|
CFLAGS = $(GST_CFLAGS)
|
||||||
|
|
||||||
# FIXME : refcounting threadds
|
# FIXME : refcounting threadds
|
||||||
DIST_SUBDIRS = caps capsnego plugin bytestream cleanup
|
DIST_SUBDIRS = caps plugin bytestream cleanup
|
||||||
|
|
11
tests/old/testsuite/capsnego/.gitignore
vendored
11
tests/old/testsuite/capsnego/.gitignore
vendored
|
@ -1,11 +0,0 @@
|
||||||
Makefile
|
|
||||||
Makefile.in
|
|
||||||
*.o
|
|
||||||
*.lo
|
|
||||||
*.la
|
|
||||||
.deps
|
|
||||||
.libs
|
|
||||||
capsnego
|
|
||||||
converter
|
|
||||||
converter2
|
|
||||||
enum
|
|
|
@ -1,8 +0,0 @@
|
||||||
testprogs = converter compatibility # enum capsnego converter2
|
|
||||||
|
|
||||||
TESTS = $(testprogs)
|
|
||||||
|
|
||||||
check_PROGRAMS = $(testprogs)
|
|
||||||
|
|
||||||
AM_CFLAGS = $(GST_CFLAGS)
|
|
||||||
LIBS = $(GST_LIBS)
|
|
|
@ -1,182 +0,0 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
|
||||||
GstPad *srcpadtempl, *sinkpadtempl;
|
|
||||||
|
|
||||||
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*
|
|
||||||
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, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">");
|
|
||||||
|
|
||||||
if (*data == NULL) {
|
|
||||||
*data = GINT_TO_POINTER (TRUE);
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps)
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("<");
|
|
||||||
if (*data == NULL) {
|
|
||||||
*data = GINT_TO_POINTER (TRUE);
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps)
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadTemplate *srctempl, *sinktempl;
|
|
||||||
static GstCaps *srccaps, *sinkcaps;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
perform_check (void)
|
|
||||||
{
|
|
||||||
gboolean result, overall = TRUE;
|
|
||||||
|
|
||||||
gint i, j;
|
|
||||||
|
|
||||||
g_print ("ABC: A=pad caps, B=pad template, C=negotiate function\n");
|
|
||||||
|
|
||||||
for (j=0; j<8; j++) {
|
|
||||||
GstPad *srctest, *sinktest;
|
|
||||||
|
|
||||||
for (i=0; i<8; i++) {
|
|
||||||
|
|
||||||
(j & 0x2 ? (sinktest = sinkpadtempl) : (sinktest = sinkpad));
|
|
||||||
(j & 0x4 ? (gst_pad_set_caps (sinktest, sinkcaps)) : (gst_pad_set_caps (sinktest, NULL)));
|
|
||||||
(j & 0x1 ? (gst_pad_set_negotiate_function (sinktest, negotiate_sink)) :
|
|
||||||
gst_pad_set_negotiate_function (sinktest, NULL));
|
|
||||||
|
|
||||||
(i & 0x2 ? (srctest = srcpadtempl) : (srctest = srcpad));
|
|
||||||
(i & 0x4 ? (gst_pad_set_caps (srctest, srccaps)) : (gst_pad_set_caps (srctest, NULL)));
|
|
||||||
(i & 0x1 ? (gst_pad_set_negotiate_function (srctest, negotiate_src)) :
|
|
||||||
gst_pad_set_negotiate_function (srctest, NULL));
|
|
||||||
|
|
||||||
|
|
||||||
g_print ("%d%d%d -> %d%d%d ..", (i&4)>>2, (i&2)>>1, i&1, (j&4)>>2, (j&2)>>1, j&1);
|
|
||||||
result = gst_pad_try_connect (srctest, sinktest);
|
|
||||||
|
|
||||||
g_print (".. %s\n", (result? "ok":"fail"));
|
|
||||||
if (result) gst_pad_disconnect (srctest, sinktest);
|
|
||||||
|
|
||||||
overall &= result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return overall;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
|
||||||
sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
|
||||||
|
|
||||||
srctempl = src_template_factory ();
|
|
||||||
sinktempl = sink_template_factory ();
|
|
||||||
|
|
||||||
srcpadtempl = gst_pad_new_from_template (src_template_factory (), "src");
|
|
||||||
sinkpadtempl = gst_pad_new_from_template (sink_template_factory (), "sink");
|
|
||||||
|
|
||||||
sinkcaps = sink_caps_factory ();
|
|
||||||
srccaps = src_caps_factory ();
|
|
||||||
|
|
||||||
g_print ("*** compatible caps/templates ***\n");
|
|
||||||
|
|
||||||
overall &= perform_check ();
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "height", GST_PROPS_INT (9000));
|
|
||||||
|
|
||||||
g_print ("*** incompatible caps ***\n");
|
|
||||||
overall &= perform_check ();
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
|
@ -1,188 +0,0 @@
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
mpeg2dec_sink_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"mpeg2dec_sink",
|
|
||||||
"video/mpeg",
|
|
||||||
gst_props_new (
|
|
||||||
"mpegtype", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_INT(1),
|
|
||||||
GST_PROPS_INT(2)
|
|
||||||
),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
mp1parse_src_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"mp1parse_src",
|
|
||||||
"video/mpeg",
|
|
||||||
gst_props_new (
|
|
||||||
"mpegtype", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_INT(1)
|
|
||||||
),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
mpeg2dec_src_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"mpeg2dec_src",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')),
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2'))
|
|
||||||
),
|
|
||||||
"width", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
raw_sink_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"raw_sink_caps",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2'))
|
|
||||||
),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 256),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
raw2_sink_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"raw2_sink_caps",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')),
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2'))
|
|
||||||
),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
get_testcaps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"raw2_sink_caps",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')),
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V'))
|
|
||||||
),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *sinkcaps = NULL,
|
|
||||||
*rawcaps = NULL,
|
|
||||||
*rawcaps2 = NULL,
|
|
||||||
*rawcaps3 = NULL,
|
|
||||||
*mp1parsecaps = NULL;
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean testret;
|
|
||||||
xmlDocPtr doc;
|
|
||||||
xmlNodePtr parent;
|
|
||||||
|
|
||||||
doc = xmlNewDoc ("1.0");
|
|
||||||
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
sinkcaps = mpeg2dec_sink_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
|
|
||||||
gst_caps_save_thyself (sinkcaps, parent);
|
|
||||||
|
|
||||||
rawcaps = mpeg2dec_src_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL);
|
|
||||||
gst_caps_save_thyself (rawcaps, parent);
|
|
||||||
|
|
||||||
rawcaps2 = raw_sink_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities3", NULL);
|
|
||||||
gst_caps_save_thyself (rawcaps2, parent);
|
|
||||||
|
|
||||||
mp1parsecaps = mp1parse_src_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities4", NULL);
|
|
||||||
gst_caps_save_thyself (mp1parsecaps, parent);
|
|
||||||
|
|
||||||
rawcaps3 = raw2_sink_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL);
|
|
||||||
gst_caps_save_thyself (rawcaps3, parent);
|
|
||||||
|
|
||||||
xmlDocDump(stdout, doc);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (mp1parsecaps, rawcaps);
|
|
||||||
g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (mp1parsecaps, sinkcaps);
|
|
||||||
g_print ("4 <-> 1 == %d (valid, subset)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (sinkcaps, mp1parsecaps);
|
|
||||||
g_print ("1 <-> 4 == %d (invalid, superset)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps, rawcaps2);
|
|
||||||
g_print ("2 <-> 3 == %d (invalid, ranges)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps, rawcaps3);
|
|
||||||
g_print ("2 <-> 5 == %d (valid)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps3, rawcaps);
|
|
||||||
g_print ("5 <-> 2 == %d (invalid)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps2, rawcaps3);
|
|
||||||
g_print ("3 <-> 5 == %d (valid)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps2, rawcaps);
|
|
||||||
g_print ("3 <-> 2 == %d (invalid, property missing in source)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps, rawcaps);
|
|
||||||
g_print ("2 <-> 2 == %d (valid, same caps)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
g_print ("caps test successful\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,199 +0,0 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
|
||||||
GstPad *srcconvpad, *sinkconvpad;
|
|
||||||
GstPadTemplate *srcpadtempl, *sinkpadtempl;
|
|
||||||
GstPadTemplate *srcconvtempl, *sinkconvtempl;
|
|
||||||
|
|
||||||
gint converter_in = -1, converter_out = -1;
|
|
||||||
|
|
||||||
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, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">");
|
|
||||||
|
|
||||||
if (data == NULL) {
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_out = gst_caps_get_int (*caps, "rate");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("<");
|
|
||||||
if (data == NULL) {
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_in = gst_caps_get_int (*caps, "rate");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
gboolean result;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
srctempl = src_factory ();
|
|
||||||
sinktempl = sink_factory ();
|
|
||||||
srcpad = gst_pad_new_from_template (srctempl, "src");
|
|
||||||
sinkpad = gst_pad_new_from_template (sinktempl, "sink");
|
|
||||||
|
|
||||||
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 = 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);
|
|
||||||
|
|
||||||
result = gst_pad_try_connect (srcpad, sinkconvpad);
|
|
||||||
g_print ("pad connect 1: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
result = gst_pad_try_connect (srcconvpad, sinkpad);
|
|
||||||
g_print ("pad connect 2: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
|
|
||||||
g_print ("after connect, converter status: %d %d\n", converter_in, converter_out);
|
|
||||||
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("src pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (4000));
|
|
||||||
result = gst_pad_renegotiate (srcpad);
|
|
||||||
g_print ("sink pad renegotiate caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (9000));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
|
@ -1,254 +0,0 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
|
||||||
GstPad *srcconvpad, *sinkconvpad;
|
|
||||||
GstPadTemplate *srcpadtempl, *sinkpadtempl;
|
|
||||||
GstPadTemplate *srcconvtempl, *sinkconvtempl;
|
|
||||||
|
|
||||||
gint converter_in = -1, converter_out = -1;
|
|
||||||
gint target_rate = 2000;
|
|
||||||
|
|
||||||
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, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">");
|
|
||||||
|
|
||||||
if (*data == NULL) {
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_out = gst_caps_get_int (*caps, "rate");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
converter_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("<");
|
|
||||||
if (*data == NULL) {
|
|
||||||
*caps = GST_PAD_CAPS (srcconvpad);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_in = gst_caps_get_int (*caps, "rate");
|
|
||||||
|
|
||||||
if (*data == 1) {
|
|
||||||
converter_out = gst_caps_get_int (*caps, "rate");
|
|
||||||
return gst_pad_negotiate_proxy (pad, srcconvpad, caps);
|
|
||||||
}
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
target_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("{");
|
|
||||||
if (*data == NULL) {
|
|
||||||
*caps = gst_caps_new (
|
|
||||||
"target_caps",
|
|
||||||
"audio/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"rate", GST_PROPS_INT (target_rate),
|
|
||||||
NULL)
|
|
||||||
);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
target_rate = gst_caps_get_int (*caps, "rate");
|
|
||||||
g_print ("target set %d\n", target_rate);
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
gboolean result;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
srctempl = src_factory ();
|
|
||||||
sinktempl = sink_factory ();
|
|
||||||
srcpad = gst_pad_new_from_template (srctempl, "src");
|
|
||||||
sinkpad = gst_pad_new_from_template (sinktempl, "sink");
|
|
||||||
|
|
||||||
srcconvtempl = src_conv_factory ();
|
|
||||||
sinkconvtempl = sink_conv_factory ();
|
|
||||||
srcconvpad = gst_pad_new_from_template (srcconvtempl, "csrc");
|
|
||||||
sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "csink");
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, converter_negotiate_src);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, converter_negotiate_sink);
|
|
||||||
gst_pad_set_negotiate_function (sinkpad, target_negotiate_sink);
|
|
||||||
|
|
||||||
sinkcaps = sink_caps ();
|
|
||||||
srccaps = src_caps ();
|
|
||||||
|
|
||||||
g_print ("-------) (-----------) (----- \n");
|
|
||||||
g_print (" ! ! converter ! ! \n");
|
|
||||||
g_print (" src -- csink csrc -- sink \n");
|
|
||||||
g_print ("-------) (-----------) (----- \n\n");
|
|
||||||
g_print ("The convertor first tries to proxy the caps received\n");
|
|
||||||
g_print ("on its csink pad to its csrc pad, when that fails, it\n");
|
|
||||||
g_print ("sets up the conversion.\n\n");
|
|
||||||
|
|
||||||
|
|
||||||
g_print ("sink pad set caps (rate=%d), converter status: %d %d\n", target_rate,
|
|
||||||
converter_in, converter_out);
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (target_rate));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("result: %d, converter status: %d %d, target: %d\n\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
result = gst_pad_try_connect (srcpad, sinkconvpad);
|
|
||||||
g_print ("pad connect 1: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
result = gst_pad_try_connect (srcconvpad, sinkpad);
|
|
||||||
g_print ("pad connect 2: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
|
|
||||||
g_print ("after connect, converter status: %d %d, target %d\n\n", converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
g_print ("src pad set caps (rate=%d), converter status: %d %d, target %d \n", gst_caps_get_int (srccaps, "rate"),
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("result %d, converter status: %d %d, target %d\n\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
g_print ("sink pad set caps (rate=2000), converter status: %d %d, target %d \n",
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
target_rate = 2000;
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (target_rate));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("result %d, converter status: %d %d, target: %d\n\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (4000));
|
|
||||||
result = gst_pad_renegotiate (srcpad);
|
|
||||||
g_print ("sink pad renegotiate caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
target_rate = 9000;
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (target_rate));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
|
@ -1,242 +0,0 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
GstPad *srcconvpad, *sinkconvpad;
|
|
||||||
GstPadTemplate *srcconvtempl, *sinkconvtempl;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
static gint src_rate = 140;
|
|
||||||
static gint sink_rate = 100;
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">(%d:%d)", src_rate, (*caps)->refcount);
|
|
||||||
src_rate++;
|
|
||||||
|
|
||||||
if (*data == NULL || caps == NULL) {
|
|
||||||
g_print ("*");
|
|
||||||
*caps = gst_caps_new (
|
|
||||||
"src_caps",
|
|
||||||
"audio/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"rate", GST_PROPS_INT (src_rate),
|
|
||||||
NULL)
|
|
||||||
);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
gint in_rate = gst_caps_get_int (*caps, "rate");
|
|
||||||
g_print ("(%d)", in_rate);
|
|
||||||
|
|
||||||
if (in_rate > 140 && in_rate < 300) {
|
|
||||||
g_print ("A");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*caps = gst_caps_copy_on_write (*caps);
|
|
||||||
gst_caps_set (*caps, "rate", GST_PROPS_INT (src_rate));
|
|
||||||
g_print ("T");
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print ("F");
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
|
|
||||||
g_print ("<(%d:%d:%p)", sink_rate, (*caps)->refcount, *caps);
|
|
||||||
sink_rate++;
|
|
||||||
|
|
||||||
if (*data == NULL || *caps == NULL) {
|
|
||||||
g_print ("*");
|
|
||||||
*caps = gst_caps_new (
|
|
||||||
"sink_caps",
|
|
||||||
"audio/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"rate", GST_PROPS_INT (sink_rate),
|
|
||||||
NULL)
|
|
||||||
);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
gint in_rate = gst_caps_get_int (*caps, "rate");
|
|
||||||
g_print ("(%d)", in_rate);
|
|
||||||
|
|
||||||
if (in_rate >= 100 && in_rate < 140) {
|
|
||||||
g_print ("A");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*caps = gst_caps_copy_on_write (*caps);
|
|
||||||
g_print ("%p", *caps);
|
|
||||||
gst_caps_set (*caps, "rate", GST_PROPS_INT (sink_rate));
|
|
||||||
|
|
||||||
g_print ("T");
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print ("F");
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
gboolean result;
|
|
||||||
GstElement *queue;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
g_mem_chunk_info();
|
|
||||||
|
|
||||||
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 = src_caps ();
|
|
||||||
sinkcaps = gst_caps_copy (srccaps);
|
|
||||||
|
|
||||||
g_print ("The wild goose chase...\n");
|
|
||||||
|
|
||||||
result = gst_pad_try_connect (srcconvpad, sinkconvpad);
|
|
||||||
g_print ("pad connect 1: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
|
|
||||||
result = gst_pad_set_caps (srcconvpad, srccaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
g_print ("with the src negotiate function disabled...\n");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, NULL);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (120));
|
|
||||||
result = gst_pad_set_caps (srcconvpad, srccaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
|
|
||||||
g_print ("with the sink negotiate function disabled...\n");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, negotiate_src);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, NULL);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (170));
|
|
||||||
result = gst_pad_set_caps (sinkconvpad, sinkcaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
g_print ("without negotiate functions...\n");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, NULL);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, NULL);
|
|
||||||
|
|
||||||
sinkcaps = gst_caps_copy (sinkcaps);
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (150));
|
|
||||||
result = gst_pad_set_caps (sinkconvpad, sinkcaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
|
|
||||||
sinkcaps = gst_caps_copy (sinkcaps);
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (160));
|
|
||||||
result = gst_pad_set_caps (sinkconvpad, sinkcaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
g_print ("with a proxy element in between...\n");
|
|
||||||
|
|
||||||
gst_pad_disconnect (srcconvpad, sinkconvpad);
|
|
||||||
|
|
||||||
queue = gst_elementfactory_make ("queue", "queue");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, negotiate_src);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, negotiate_sink);
|
|
||||||
|
|
||||||
gst_pad_connect (srcconvpad, gst_element_get_pad (queue, "sink"));
|
|
||||||
gst_pad_connect (gst_element_get_pad (queue, "src"), sinkconvpad);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (50));
|
|
||||||
result = gst_pad_set_caps (srcconvpad, srccaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
# FIXME : refcounting threads bytestream
|
# FIXME : refcounting threads bytestream
|
||||||
SUBDIRS = caps capsnego plugin cleanup
|
SUBDIRS = caps plugin cleanup
|
||||||
|
|
||||||
testprogs = test_gst_init
|
testprogs = test_gst_init
|
||||||
|
|
||||||
|
@ -12,4 +12,4 @@ LIBS = $(GST_LIBS)
|
||||||
CFLAGS = $(GST_CFLAGS)
|
CFLAGS = $(GST_CFLAGS)
|
||||||
|
|
||||||
# FIXME : refcounting threadds
|
# FIXME : refcounting threadds
|
||||||
DIST_SUBDIRS = caps capsnego plugin bytestream cleanup
|
DIST_SUBDIRS = caps plugin bytestream cleanup
|
||||||
|
|
11
testsuite/capsnego/.gitignore
vendored
11
testsuite/capsnego/.gitignore
vendored
|
@ -1,11 +0,0 @@
|
||||||
Makefile
|
|
||||||
Makefile.in
|
|
||||||
*.o
|
|
||||||
*.lo
|
|
||||||
*.la
|
|
||||||
.deps
|
|
||||||
.libs
|
|
||||||
capsnego
|
|
||||||
converter
|
|
||||||
converter2
|
|
||||||
enum
|
|
|
@ -1,8 +0,0 @@
|
||||||
testprogs = converter compatibility # enum capsnego converter2
|
|
||||||
|
|
||||||
TESTS = $(testprogs)
|
|
||||||
|
|
||||||
check_PROGRAMS = $(testprogs)
|
|
||||||
|
|
||||||
AM_CFLAGS = $(GST_CFLAGS)
|
|
||||||
LIBS = $(GST_LIBS)
|
|
|
@ -1,182 +0,0 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
|
||||||
GstPad *srcpadtempl, *sinkpadtempl;
|
|
||||||
|
|
||||||
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*
|
|
||||||
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, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">");
|
|
||||||
|
|
||||||
if (*data == NULL) {
|
|
||||||
*data = GINT_TO_POINTER (TRUE);
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps)
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("<");
|
|
||||||
if (*data == NULL) {
|
|
||||||
*data = GINT_TO_POINTER (TRUE);
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps)
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadTemplate *srctempl, *sinktempl;
|
|
||||||
static GstCaps *srccaps, *sinkcaps;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
perform_check (void)
|
|
||||||
{
|
|
||||||
gboolean result, overall = TRUE;
|
|
||||||
|
|
||||||
gint i, j;
|
|
||||||
|
|
||||||
g_print ("ABC: A=pad caps, B=pad template, C=negotiate function\n");
|
|
||||||
|
|
||||||
for (j=0; j<8; j++) {
|
|
||||||
GstPad *srctest, *sinktest;
|
|
||||||
|
|
||||||
for (i=0; i<8; i++) {
|
|
||||||
|
|
||||||
(j & 0x2 ? (sinktest = sinkpadtempl) : (sinktest = sinkpad));
|
|
||||||
(j & 0x4 ? (gst_pad_set_caps (sinktest, sinkcaps)) : (gst_pad_set_caps (sinktest, NULL)));
|
|
||||||
(j & 0x1 ? (gst_pad_set_negotiate_function (sinktest, negotiate_sink)) :
|
|
||||||
gst_pad_set_negotiate_function (sinktest, NULL));
|
|
||||||
|
|
||||||
(i & 0x2 ? (srctest = srcpadtempl) : (srctest = srcpad));
|
|
||||||
(i & 0x4 ? (gst_pad_set_caps (srctest, srccaps)) : (gst_pad_set_caps (srctest, NULL)));
|
|
||||||
(i & 0x1 ? (gst_pad_set_negotiate_function (srctest, negotiate_src)) :
|
|
||||||
gst_pad_set_negotiate_function (srctest, NULL));
|
|
||||||
|
|
||||||
|
|
||||||
g_print ("%d%d%d -> %d%d%d ..", (i&4)>>2, (i&2)>>1, i&1, (j&4)>>2, (j&2)>>1, j&1);
|
|
||||||
result = gst_pad_try_connect (srctest, sinktest);
|
|
||||||
|
|
||||||
g_print (".. %s\n", (result? "ok":"fail"));
|
|
||||||
if (result) gst_pad_disconnect (srctest, sinktest);
|
|
||||||
|
|
||||||
overall &= result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return overall;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
|
||||||
sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
|
||||||
|
|
||||||
srctempl = src_template_factory ();
|
|
||||||
sinktempl = sink_template_factory ();
|
|
||||||
|
|
||||||
srcpadtempl = gst_pad_new_from_template (src_template_factory (), "src");
|
|
||||||
sinkpadtempl = gst_pad_new_from_template (sink_template_factory (), "sink");
|
|
||||||
|
|
||||||
sinkcaps = sink_caps_factory ();
|
|
||||||
srccaps = src_caps_factory ();
|
|
||||||
|
|
||||||
g_print ("*** compatible caps/templates ***\n");
|
|
||||||
|
|
||||||
overall &= perform_check ();
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "height", GST_PROPS_INT (9000));
|
|
||||||
|
|
||||||
g_print ("*** incompatible caps ***\n");
|
|
||||||
overall &= perform_check ();
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
|
@ -1,188 +0,0 @@
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
mpeg2dec_sink_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"mpeg2dec_sink",
|
|
||||||
"video/mpeg",
|
|
||||||
gst_props_new (
|
|
||||||
"mpegtype", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_INT(1),
|
|
||||||
GST_PROPS_INT(2)
|
|
||||||
),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
mp1parse_src_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"mp1parse_src",
|
|
||||||
"video/mpeg",
|
|
||||||
gst_props_new (
|
|
||||||
"mpegtype", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_INT(1)
|
|
||||||
),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
mpeg2dec_src_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"mpeg2dec_src",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')),
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2'))
|
|
||||||
),
|
|
||||||
"width", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
raw_sink_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"raw_sink_caps",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2'))
|
|
||||||
),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 256),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
raw2_sink_caps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"raw2_sink_caps",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')),
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2'))
|
|
||||||
),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static GstCaps*
|
|
||||||
get_testcaps (void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
gst_caps_new (
|
|
||||||
"raw2_sink_caps",
|
|
||||||
"video/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"fourcc", GST_PROPS_LIST (
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')),
|
|
||||||
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V'))
|
|
||||||
),
|
|
||||||
"height", GST_PROPS_INT_RANGE (16, 4096),
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *sinkcaps = NULL,
|
|
||||||
*rawcaps = NULL,
|
|
||||||
*rawcaps2 = NULL,
|
|
||||||
*rawcaps3 = NULL,
|
|
||||||
*mp1parsecaps = NULL;
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean testret;
|
|
||||||
xmlDocPtr doc;
|
|
||||||
xmlNodePtr parent;
|
|
||||||
|
|
||||||
doc = xmlNewDoc ("1.0");
|
|
||||||
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
sinkcaps = mpeg2dec_sink_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
|
|
||||||
gst_caps_save_thyself (sinkcaps, parent);
|
|
||||||
|
|
||||||
rawcaps = mpeg2dec_src_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL);
|
|
||||||
gst_caps_save_thyself (rawcaps, parent);
|
|
||||||
|
|
||||||
rawcaps2 = raw_sink_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities3", NULL);
|
|
||||||
gst_caps_save_thyself (rawcaps2, parent);
|
|
||||||
|
|
||||||
mp1parsecaps = mp1parse_src_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities4", NULL);
|
|
||||||
gst_caps_save_thyself (mp1parsecaps, parent);
|
|
||||||
|
|
||||||
rawcaps3 = raw2_sink_caps ();
|
|
||||||
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL);
|
|
||||||
gst_caps_save_thyself (rawcaps3, parent);
|
|
||||||
|
|
||||||
xmlDocDump(stdout, doc);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (mp1parsecaps, rawcaps);
|
|
||||||
g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (mp1parsecaps, sinkcaps);
|
|
||||||
g_print ("4 <-> 1 == %d (valid, subset)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (sinkcaps, mp1parsecaps);
|
|
||||||
g_print ("1 <-> 4 == %d (invalid, superset)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps, rawcaps2);
|
|
||||||
g_print ("2 <-> 3 == %d (invalid, ranges)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps, rawcaps3);
|
|
||||||
g_print ("2 <-> 5 == %d (valid)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps3, rawcaps);
|
|
||||||
g_print ("5 <-> 2 == %d (invalid)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps2, rawcaps3);
|
|
||||||
g_print ("3 <-> 5 == %d (valid)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps2, rawcaps);
|
|
||||||
g_print ("3 <-> 2 == %d (invalid, property missing in source)\n", testret);
|
|
||||||
if (testret != 0) exit (-1);
|
|
||||||
|
|
||||||
testret = gst_caps_check_compatibility (rawcaps, rawcaps);
|
|
||||||
g_print ("2 <-> 2 == %d (valid, same caps)\n", testret);
|
|
||||||
if (testret != 1) exit (-1);
|
|
||||||
|
|
||||||
g_print ("caps test successful\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,199 +0,0 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
|
||||||
GstPad *srcconvpad, *sinkconvpad;
|
|
||||||
GstPadTemplate *srcpadtempl, *sinkpadtempl;
|
|
||||||
GstPadTemplate *srcconvtempl, *sinkconvtempl;
|
|
||||||
|
|
||||||
gint converter_in = -1, converter_out = -1;
|
|
||||||
|
|
||||||
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, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">");
|
|
||||||
|
|
||||||
if (data == NULL) {
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_out = gst_caps_get_int (*caps, "rate");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("<");
|
|
||||||
if (data == NULL) {
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_in = gst_caps_get_int (*caps, "rate");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
gboolean result;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
srctempl = src_factory ();
|
|
||||||
sinktempl = sink_factory ();
|
|
||||||
srcpad = gst_pad_new_from_template (srctempl, "src");
|
|
||||||
sinkpad = gst_pad_new_from_template (sinktempl, "sink");
|
|
||||||
|
|
||||||
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 = 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);
|
|
||||||
|
|
||||||
result = gst_pad_try_connect (srcpad, sinkconvpad);
|
|
||||||
g_print ("pad connect 1: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
result = gst_pad_try_connect (srcconvpad, sinkpad);
|
|
||||||
g_print ("pad connect 2: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
|
|
||||||
g_print ("after connect, converter status: %d %d\n", converter_in, converter_out);
|
|
||||||
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("src pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (4000));
|
|
||||||
result = gst_pad_renegotiate (srcpad);
|
|
||||||
g_print ("sink pad renegotiate caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (9000));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d\n", result, converter_in, converter_out);
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
|
@ -1,254 +0,0 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
|
||||||
GstPad *srcconvpad, *sinkconvpad;
|
|
||||||
GstPadTemplate *srcpadtempl, *sinkpadtempl;
|
|
||||||
GstPadTemplate *srcconvtempl, *sinkconvtempl;
|
|
||||||
|
|
||||||
gint converter_in = -1, converter_out = -1;
|
|
||||||
gint target_rate = 2000;
|
|
||||||
|
|
||||||
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, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">");
|
|
||||||
|
|
||||||
if (*data == NULL) {
|
|
||||||
*caps = NULL;
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_out = gst_caps_get_int (*caps, "rate");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
converter_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("<");
|
|
||||||
if (*data == NULL) {
|
|
||||||
*caps = GST_PAD_CAPS (srcconvpad);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
converter_in = gst_caps_get_int (*caps, "rate");
|
|
||||||
|
|
||||||
if (*data == 1) {
|
|
||||||
converter_out = gst_caps_get_int (*caps, "rate");
|
|
||||||
return gst_pad_negotiate_proxy (pad, srcconvpad, caps);
|
|
||||||
}
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
target_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print ("{");
|
|
||||||
if (*data == NULL) {
|
|
||||||
*caps = gst_caps_new (
|
|
||||||
"target_caps",
|
|
||||||
"audio/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"rate", GST_PROPS_INT (target_rate),
|
|
||||||
NULL)
|
|
||||||
);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
target_rate = gst_caps_get_int (*caps, "rate");
|
|
||||||
g_print ("target set %d\n", target_rate);
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
gboolean result;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
srctempl = src_factory ();
|
|
||||||
sinktempl = sink_factory ();
|
|
||||||
srcpad = gst_pad_new_from_template (srctempl, "src");
|
|
||||||
sinkpad = gst_pad_new_from_template (sinktempl, "sink");
|
|
||||||
|
|
||||||
srcconvtempl = src_conv_factory ();
|
|
||||||
sinkconvtempl = sink_conv_factory ();
|
|
||||||
srcconvpad = gst_pad_new_from_template (srcconvtempl, "csrc");
|
|
||||||
sinkconvpad = gst_pad_new_from_template (sinkconvtempl, "csink");
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, converter_negotiate_src);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, converter_negotiate_sink);
|
|
||||||
gst_pad_set_negotiate_function (sinkpad, target_negotiate_sink);
|
|
||||||
|
|
||||||
sinkcaps = sink_caps ();
|
|
||||||
srccaps = src_caps ();
|
|
||||||
|
|
||||||
g_print ("-------) (-----------) (----- \n");
|
|
||||||
g_print (" ! ! converter ! ! \n");
|
|
||||||
g_print (" src -- csink csrc -- sink \n");
|
|
||||||
g_print ("-------) (-----------) (----- \n\n");
|
|
||||||
g_print ("The convertor first tries to proxy the caps received\n");
|
|
||||||
g_print ("on its csink pad to its csrc pad, when that fails, it\n");
|
|
||||||
g_print ("sets up the conversion.\n\n");
|
|
||||||
|
|
||||||
|
|
||||||
g_print ("sink pad set caps (rate=%d), converter status: %d %d\n", target_rate,
|
|
||||||
converter_in, converter_out);
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (target_rate));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("result: %d, converter status: %d %d, target: %d\n\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
result = gst_pad_try_connect (srcpad, sinkconvpad);
|
|
||||||
g_print ("pad connect 1: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
result = gst_pad_try_connect (srcconvpad, sinkpad);
|
|
||||||
g_print ("pad connect 2: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
|
|
||||||
g_print ("after connect, converter status: %d %d, target %d\n\n", converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
g_print ("src pad set caps (rate=%d), converter status: %d %d, target %d \n", gst_caps_get_int (srccaps, "rate"),
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("result %d, converter status: %d %d, target %d\n\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
g_print ("sink pad set caps (rate=2000), converter status: %d %d, target %d \n",
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
target_rate = 2000;
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (target_rate));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("result %d, converter status: %d %d, target: %d\n\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (4000));
|
|
||||||
result = gst_pad_renegotiate (srcpad);
|
|
||||||
g_print ("sink pad renegotiate caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (srcpad, srccaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (40000));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
target_rate = 9000;
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (target_rate));
|
|
||||||
result = gst_pad_set_caps (sinkpad, sinkcaps);
|
|
||||||
g_print ("sink pad set caps %d, converter status: %d %d, target: %d\n", result,
|
|
||||||
converter_in, converter_out, target_rate);
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
|
@ -1,242 +0,0 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
GstPad *srcconvpad, *sinkconvpad;
|
|
||||||
GstPadTemplate *srcconvtempl, *sinkconvtempl;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
static gint src_rate = 140;
|
|
||||||
static gint sink_rate = 100;
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
g_print (">(%d:%d)", src_rate, (*caps)->refcount);
|
|
||||||
src_rate++;
|
|
||||||
|
|
||||||
if (*data == NULL || caps == NULL) {
|
|
||||||
g_print ("*");
|
|
||||||
*caps = gst_caps_new (
|
|
||||||
"src_caps",
|
|
||||||
"audio/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"rate", GST_PROPS_INT (src_rate),
|
|
||||||
NULL)
|
|
||||||
);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
gint in_rate = gst_caps_get_int (*caps, "rate");
|
|
||||||
g_print ("(%d)", in_rate);
|
|
||||||
|
|
||||||
if (in_rate > 140 && in_rate < 300) {
|
|
||||||
g_print ("A");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*caps = gst_caps_copy_on_write (*caps);
|
|
||||||
gst_caps_set (*caps, "rate", GST_PROPS_INT (src_rate));
|
|
||||||
g_print ("T");
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print ("F");
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadNegotiateReturn
|
|
||||||
negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
|
|
||||||
{
|
|
||||||
|
|
||||||
g_print ("<(%d:%d:%p)", sink_rate, (*caps)->refcount, *caps);
|
|
||||||
sink_rate++;
|
|
||||||
|
|
||||||
if (*data == NULL || *caps == NULL) {
|
|
||||||
g_print ("*");
|
|
||||||
*caps = gst_caps_new (
|
|
||||||
"sink_caps",
|
|
||||||
"audio/raw",
|
|
||||||
gst_props_new (
|
|
||||||
"rate", GST_PROPS_INT (sink_rate),
|
|
||||||
NULL)
|
|
||||||
);
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
if (*caps) {
|
|
||||||
gint in_rate = gst_caps_get_int (*caps, "rate");
|
|
||||||
g_print ("(%d)", in_rate);
|
|
||||||
|
|
||||||
if (in_rate >= 100 && in_rate < 140) {
|
|
||||||
g_print ("A");
|
|
||||||
return GST_PAD_NEGOTIATE_AGREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*caps = gst_caps_copy_on_write (*caps);
|
|
||||||
g_print ("%p", *caps);
|
|
||||||
gst_caps_set (*caps, "rate", GST_PROPS_INT (sink_rate));
|
|
||||||
|
|
||||||
g_print ("T");
|
|
||||||
return GST_PAD_NEGOTIATE_TRY;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print ("F");
|
|
||||||
return GST_PAD_NEGOTIATE_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean overall = TRUE;
|
|
||||||
gboolean result;
|
|
||||||
GstElement *queue;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
g_mem_chunk_info();
|
|
||||||
|
|
||||||
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 = src_caps ();
|
|
||||||
sinkcaps = gst_caps_copy (srccaps);
|
|
||||||
|
|
||||||
g_print ("The wild goose chase...\n");
|
|
||||||
|
|
||||||
result = gst_pad_try_connect (srcconvpad, sinkconvpad);
|
|
||||||
g_print ("pad connect 1: %d\n", result);
|
|
||||||
overall &= (result == TRUE);
|
|
||||||
|
|
||||||
result = gst_pad_set_caps (srcconvpad, srccaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
g_print ("with the src negotiate function disabled...\n");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, NULL);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (120));
|
|
||||||
result = gst_pad_set_caps (srcconvpad, srccaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
|
|
||||||
g_print ("with the sink negotiate function disabled...\n");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, negotiate_src);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, NULL);
|
|
||||||
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (170));
|
|
||||||
result = gst_pad_set_caps (sinkconvpad, sinkcaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
g_print ("without negotiate functions...\n");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, NULL);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, NULL);
|
|
||||||
|
|
||||||
sinkcaps = gst_caps_copy (sinkcaps);
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (150));
|
|
||||||
result = gst_pad_set_caps (sinkconvpad, sinkcaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
|
|
||||||
sinkcaps = gst_caps_copy (sinkcaps);
|
|
||||||
gst_caps_set (sinkcaps, "rate", GST_PROPS_INT (160));
|
|
||||||
result = gst_pad_set_caps (sinkconvpad, sinkcaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
g_print ("with a proxy element in between...\n");
|
|
||||||
|
|
||||||
gst_pad_disconnect (srcconvpad, sinkconvpad);
|
|
||||||
|
|
||||||
queue = gst_elementfactory_make ("queue", "queue");
|
|
||||||
|
|
||||||
GST_PAD_CAPS (srcconvpad) = NULL;
|
|
||||||
GST_PAD_CAPS (sinkconvpad) = NULL;
|
|
||||||
src_rate = 140;
|
|
||||||
sink_rate = 100;
|
|
||||||
|
|
||||||
gst_pad_set_negotiate_function (srcconvpad, negotiate_src);
|
|
||||||
gst_pad_set_negotiate_function (sinkconvpad, negotiate_sink);
|
|
||||||
|
|
||||||
gst_pad_connect (srcconvpad, gst_element_get_pad (queue, "sink"));
|
|
||||||
gst_pad_connect (gst_element_get_pad (queue, "src"), sinkconvpad);
|
|
||||||
|
|
||||||
gst_caps_set (srccaps, "rate", GST_PROPS_INT (50));
|
|
||||||
result = gst_pad_set_caps (srcconvpad, srccaps);
|
|
||||||
g_print ("\nset caps on src: %d, final rate: %d\n", result,
|
|
||||||
gst_caps_get_int (gst_pad_get_caps (srcconvpad), "rate"));
|
|
||||||
|
|
||||||
|
|
||||||
exit (!overall);
|
|
||||||
}
|
|
Loading…
Reference in a new issue