Bring the plugins in sync with the new core capsnego system.

Original commit message from CVS:
Bring the plugins in sync with the new core capsnego system.
Added some features, enhancements...
This commit is contained in:
Wim Taymans 2002-01-13 22:27:25 +00:00
parent bd1031d310
commit 5455dbbf3d
12 changed files with 87 additions and 104 deletions

View file

@ -151,7 +151,8 @@ RTP_DIR=
endif
if USE_SDL
SDL_DIR=sdl
#SDL_DIR=sdl
SDL_DIR=
else
SDL_DIR=
endif

View file

@ -57,7 +57,7 @@ static GstPad* gst_alsa_request_new_pad (GstElement *element, GstPadTemplate *te
static void gst_alsa_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_alsa_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static GstElementStateReturn gst_alsa_change_state(GstElement *element);
static GstPadNegotiateReturn gst_alsa_negotiate(GstPad *pad, GstCaps **caps, gpointer *user_data);
//static GstPadNegotiateReturn gst_alsa_negotiate(GstPad *pad, GstCaps **caps, gpointer *user_data);
static GstCaps* gst_alsa_caps (GstAlsa *this);
@ -305,7 +305,7 @@ gst_alsa_init(GstAlsa *this)
gst_element_add_pad(GST_ELEMENT(this), GST_ALSA_PAD(this->pads)->pad);
gst_pad_set_negotiate_function(GST_ALSA_PAD(this->pads)->pad, gst_alsa_negotiate);
//gst_pad_set_negotiate_function(GST_ALSA_PAD(this->pads)->pad, gst_alsa_negotiate);
gst_element_set_loop_function(GST_ELEMENT(this), gst_alsa_loop);
}
@ -358,7 +358,7 @@ gst_alsa_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
pad->channel = channel;
pad->pad = gst_pad_new_from_template (templ, newname);
gst_element_add_pad (GST_ELEMENT (this), pad->pad);
gst_pad_set_negotiate_function(pad->pad, gst_alsa_negotiate);
//gst_pad_set_negotiate_function(pad->pad, gst_alsa_negotiate);
if (this->data_interleaved && this->pads) {
gst_element_remove_pad (GST_ELEMENT (this), GST_ALSA_PAD(this->pads)->pad);
@ -715,6 +715,7 @@ gst_alsa_caps (GstAlsa *this)
/*
* Negotiates the caps, "borrowed" from gstosssink.c
*/
#if 0
GstPadNegotiateReturn
gst_alsa_negotiate(GstPad *pad, GstCaps **caps, gpointer *user_data)
{
@ -766,6 +767,7 @@ gst_alsa_negotiate(GstPad *pad, GstCaps **caps, gpointer *user_data)
return GST_PAD_NEGOTIATE_FAIL;
}
#endif
/* shamelessly stolen from pbd's audioengine. thanks, paul! */
static void
@ -878,7 +880,7 @@ gst_alsa_src_process (GstAlsa *this, snd_pcm_uframes_t frames)
caps = gst_alsa_caps(this);
l = this->pads;
while (l) {
if (!gst_pad_set_caps (GST_ALSA_PAD(l)->pad, caps)) {
if (!gst_pad_try_set_caps (GST_ALSA_PAD(l)->pad, caps)) {
g_print ("DANGER WILL ROBINSON!\n");
sleep(1);
return FALSE;

View file

@ -242,7 +242,6 @@ cdparanoia_init (CDParanoia *cdparanoia)
cdparanoia->srcpad = gst_pad_new_from_template (
GST_PADTEMPLATE_GET (cdparanoia_src_factory), "src");
gst_pad_set_get_function (cdparanoia->srcpad, cdparanoia_get);
gst_pad_set_caps (cdparanoia->srcpad, gst_pad_get_padtemplate_caps (cdparanoia->srcpad));
gst_element_add_pad (GST_ELEMENT (cdparanoia), cdparanoia->srcpad);
cdparanoia->device = "/dev/cdrom";

View file

@ -300,18 +300,18 @@ gst_vorbisdec_loop (GstElement * element)
gst_event_new_info ("bitrate_window", GST_PROPS_INT (vi.bitrate_window), NULL));
}
gst_pad_set_caps (vorbisdec->srcpad,
gst_caps_new ("vorbisdec_src",
gst_pad_try_set_caps (vorbisdec->srcpad,
GST_CAPS_NEW ("vorbisdec_src",
"audio/raw",
gst_props_new ("format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT (vi.rate),
"channels", GST_PROPS_INT (vi.channels),
NULL)));
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT (vi.rate),
"channels", GST_PROPS_INT (vi.channels)
));
vorbisdec->convsize = 4096 / vi.channels;

View file

@ -109,17 +109,25 @@ gst_vorbisenc_class_init (VorbisEncClass * klass)
gobject_class->get_property = gst_vorbisenc_get_property;
}
static void
gst_vorbisenc_newcaps (GstPad * pad, GstCaps * caps)
static GstPadConnectReturn
gst_vorbisenc_sinkconnect (GstPad * pad, GstCaps * caps)
{
VorbisEnc *vorbisenc;
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
vorbisenc->channels = gst_caps_get_int (caps, "channels");
vorbisenc->frequency = gst_caps_get_int (caps, "rate");
gst_vorbisenc_setup (vorbisenc);
if (vorbisenc->setup)
return GST_PAD_CONNECT_OK;
return GST_PAD_CONNECT_REFUSED;
}
static void
@ -128,10 +136,9 @@ gst_vorbisenc_init (VorbisEnc * vorbisenc)
vorbisenc->sinkpad = gst_pad_new_from_template (enc_sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->sinkpad);
gst_pad_set_chain_function (vorbisenc->sinkpad, gst_vorbisenc_chain);
gst_pad_set_newcaps_function (vorbisenc->sinkpad, gst_vorbisenc_newcaps);
gst_pad_set_connect_function (vorbisenc->sinkpad, gst_vorbisenc_sinkconnect);
vorbisenc->srcpad = gst_pad_new_from_template (enc_src_template, "src");
gst_pad_set_caps (vorbisenc->srcpad, gst_pad_get_padtemplate_caps (vorbisenc->srcpad));
gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->srcpad);
vorbisenc->channels = 2;

View file

@ -161,40 +161,8 @@ gst_audioscale_class_init (AudioscaleClass *klass)
}
static GstPadNegotiateReturn
audioscale_negotiate_src (GstPad * pad, GstCaps ** caps, gpointer * data)
{
Audioscale *audioscale = GST_AUDIOSCALE (gst_pad_get_parent (pad));
g_print ("audioscale_negotiate_src\n");
if (*caps == NULL)
return GST_PAD_NEGOTIATE_FAIL;
*caps = gst_caps_copy_on_write (*caps);
gst_caps_set (*caps, "rate", GST_PROPS_INT_RANGE (8000, 48000));
return gst_pad_negotiate_proxy (pad, audioscale->sinkpad, caps);
}
static GstPadNegotiateReturn
audioscale_negotiate_sink (GstPad * pad, GstCaps ** caps, gpointer * data)
{
Audioscale *audioscale = GST_AUDIOSCALE (gst_pad_get_parent (pad));
g_print ("audioscale_negotiate_sink\n");
if (*caps == NULL)
return GST_PAD_NEGOTIATE_FAIL;
*caps = gst_caps_copy_on_write (*caps);
gst_caps_set (*caps, "rate", GST_PROPS_INT (audioscale->targetfrequency));
return gst_pad_negotiate_proxy (pad, audioscale->srcpad, caps);
}
static void
gst_audioscale_newcaps (GstPad * pad, GstCaps * caps)
static GstPadConnectReturn
gst_audioscale_sinkconnect (GstPad * pad, GstCaps * caps)
{
Audioscale *audioscale;
resample_t *r;
@ -208,6 +176,7 @@ gst_audioscale_newcaps (GstPad * pad, GstCaps * caps)
resample_reinit(r);
//g_print("audioscale: unsupported scaling method %d\n", audioscale->method);
return GST_PAD_CONNECT_OK;
}
static void *
@ -228,13 +197,11 @@ gst_audioscale_init (Audioscale *audioscale)
resample_t *r;
audioscale->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (sink_template), "sink");
gst_pad_set_negotiate_function (audioscale->sinkpad, audioscale_negotiate_sink);
gst_element_add_pad(GST_ELEMENT(audioscale),audioscale->sinkpad);
gst_pad_set_chain_function(audioscale->sinkpad,gst_audioscale_chain);
gst_pad_set_newcaps_function (audioscale->sinkpad, gst_audioscale_newcaps);
gst_pad_set_connect_function (audioscale->sinkpad, gst_audioscale_sinkconnect);
audioscale->srcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (src_template), "src");
gst_pad_set_negotiate_function (audioscale->srcpad, audioscale_negotiate_src);
gst_element_add_pad(GST_ELEMENT(audioscale),audioscale->srcpad);

View file

@ -76,7 +76,7 @@ GST_PADTEMPLATE_FACTORY (sinesrc_src_factory,
static void gst_sinesrc_class_init (GstSineSrcClass *klass);
static void gst_sinesrc_init (GstSineSrc *src);
static void gst_sinesrc_newcaps (GstPad *pad, GstCaps *caps);
static void gst_sinesrc_sinkconnect (GstPad *pad, GstCaps *caps);
static void gst_sinesrc_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void gst_sinesrc_get_property (GObject *object, guint prop_id,
@ -162,7 +162,6 @@ gst_sinesrc_init (GstSineSrc *src)
src->srcpad = gst_pad_new_from_template (
GST_PADTEMPLATE_GET (sinesrc_src_factory), "src");
gst_element_add_pad(GST_ELEMENT(src), src->srcpad);
gst_pad_set_newcaps_function (src->srcpad, gst_sinesrc_newcaps);
gst_pad_set_get_function(src->srcpad, gst_sinesrc_get);
@ -204,17 +203,6 @@ gst_sinesrc_init (GstSineSrc *src)
}
static void
gst_sinesrc_newcaps (GstPad *pad, GstCaps *caps)
{
GstSineSrc *src;
g_return_if_fail (pad != NULL);
g_return_if_fail (caps != NULL);
src = GST_SINESRC(gst_pad_get_parent (pad));
src->samplerate = gst_caps_get_int (caps, "rate");
gst_sinesrc_update_table_inc(src);
}
static GstBuffer *
gst_sinesrc_get(GstPad *pad)
{
@ -410,23 +398,20 @@ gst_sinesrc_force_caps(GstSineSrc *src) {
src->newcaps=FALSE;
caps = gst_caps_new (
"sinesrc_src_caps",
"audio/raw",
gst_props_new (
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT (src->samplerate),
"channels", GST_PROPS_INT (1),
NULL
)
);
caps = GST_CAPS_NEW (
"sinesrc_src_caps",
"audio/raw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT (src->samplerate),
"channels", GST_PROPS_INT (1)
);
gst_pad_set_caps (src->srcpad, caps);
gst_pad_try_set_caps (src->srcpad, caps);
}
static gboolean

View file

@ -145,6 +145,7 @@ gst_videoscale_class_init (GstVideoscaleClass *klass)
}
/*
static GstPadNegotiateReturn
videoscale_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
{
@ -176,15 +177,20 @@ videoscale_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
return GST_PAD_NEGOTIATE_AGREE;
}
*/
static void
gst_videoscale_newcaps (GstPad *pad, GstCaps *caps)
static GstPadConnectReturn
gst_videoscale_sinkconnect (GstPad *pad, GstCaps *caps)
{
GstVideoscale *videoscale;
GST_DEBUG(0,"gst_videoscale_newcaps\n");
GST_DEBUG(0,"gst_videoscale_sinkconnect\n");
videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) {
return GST_PAD_CONNECT_DELAYED;
}
videoscale->width = gst_caps_get_int (caps, "width");
videoscale->height = gst_caps_get_int (caps, "height");
videoscale->format = gst_caps_get_int (caps, "format");
@ -195,7 +201,7 @@ gst_videoscale_newcaps (GstPad *pad, GstCaps *caps)
videoscale->targetheight);
GST_DEBUG(0,"width %d\n",videoscale->targetwidth);
gst_pad_set_caps (videoscale->srcpad,
gst_pad_try_set_caps (videoscale->srcpad,
GST_CAPS_NEW (
"videoscale_src",
"video/raw",
@ -203,6 +209,8 @@ gst_videoscale_newcaps (GstPad *pad, GstCaps *caps)
"width", GST_PROPS_INT (videoscale->targetwidth),
"height", GST_PROPS_INT (videoscale->targetheight)
));
return GST_PAD_CONNECT_OK;
}
static void
@ -211,14 +219,14 @@ gst_videoscale_init (GstVideoscale *videoscale)
GST_DEBUG(0,"gst_videoscale_init\n");
videoscale->sinkpad = gst_pad_new_from_template (
GST_PADTEMPLATE_GET (sink_templ), "sink");
gst_pad_set_negotiate_function(videoscale->sinkpad,videoscale_negotiate_sink);
//gst_pad_set_negotiate_function(videoscale->sinkpad,videoscale_negotiate_sink);
gst_element_add_pad(GST_ELEMENT(videoscale),videoscale->sinkpad);
gst_pad_set_chain_function(videoscale->sinkpad,gst_videoscale_chain);
gst_pad_set_newcaps_function(videoscale->sinkpad,gst_videoscale_newcaps);
gst_pad_set_connect_function(videoscale->sinkpad,gst_videoscale_sinkconnect);
videoscale->srcpad = gst_pad_new_from_template (
GST_PADTEMPLATE_GET (src_templ), "src");
gst_pad_set_negotiate_function(videoscale->srcpad,videoscale_negotiate_src);
//gst_pad_set_negotiate_function(videoscale->srcpad,videoscale_negotiate_src);
gst_element_add_pad(GST_ELEMENT(videoscale),videoscale->srcpad);
videoscale->targetwidth = -1;

View file

@ -108,6 +108,7 @@ volume_get_bufferpool (GstPad *pad)
return gst_pad_get_bufferpool (filter->srcpad);
}
/*
static GstPadNegotiateReturn
volume_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
{
@ -135,6 +136,7 @@ volume_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
return gst_pad_negotiate_proxy(pad,filter->srcpad,caps);
}
*/
static gint
volume_parse_caps (GstVolume *filter, GstCaps *caps)
@ -231,10 +233,10 @@ static void
volume_init (GstVolume *filter)
{
filter->sinkpad = gst_pad_new_from_template(volume_sink_factory (),"sink");
gst_pad_set_negotiate_function(filter->sinkpad,volume_negotiate_sink);
//gst_pad_set_negotiate_function(filter->sinkpad,volume_negotiate_sink);
gst_pad_set_bufferpool_function(filter->sinkpad,volume_get_bufferpool);
filter->srcpad = gst_pad_new_from_template(volume_src_factory (),"src");
gst_pad_set_negotiate_function(filter->srcpad,volume_negotiate_src);
//gst_pad_set_negotiate_function(filter->srcpad,volume_negotiate_src);
gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);

View file

@ -155,14 +155,17 @@ gst_v4lmjpegsink_class_init (GstV4lMjpegSinkClass *klass)
gstelement_class->change_state = gst_v4lmjpegsink_change_state;
}
static void
gst_v4lmjpegsink_newcaps (GstPad *pad,
static GstPadConnectReturn
gst_v4lmjpegsink_sinkconnect (GstPad *pad,
GstCaps *caps)
{
GstV4lMjpegSink *v4lmjpegsink;
v4lmjpegsink = GST_V4LMJPEGSINK (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
v4lmjpegsink->width = gst_caps_get_int (caps, "width");
v4lmjpegsink->height = gst_caps_get_int (caps, "height");
@ -173,6 +176,8 @@ gst_v4lmjpegsink_newcaps (GstPad *pad,
g_signal_emit (G_OBJECT (v4lmjpegsink), gst_v4lmjpegsink_signals[SIGNAL_HAVE_SIZE], 0,
v4lmjpegsink->width, v4lmjpegsink->height);
return GST_PAD_CONNECT_OK;
}
@ -182,7 +187,7 @@ gst_v4lmjpegsink_init (GstV4lMjpegSink *v4lmjpegsink)
v4lmjpegsink->sinkpad = gst_pad_new_from_template(GST_PADTEMPLATE_GET (sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (v4lmjpegsink), v4lmjpegsink->sinkpad);
gst_pad_set_chain_function (v4lmjpegsink->sinkpad, gst_v4lmjpegsink_chain);
gst_pad_set_newcaps_function (v4lmjpegsink->sinkpad, gst_v4lmjpegsink_newcaps);
gst_pad_set_connect_function (v4lmjpegsink->sinkpad, gst_v4lmjpegsink_sinkconnect);
v4lmjpegsink->clock = gst_clock_get_system();
gst_clock_register(v4lmjpegsink->clock, GST_OBJECT(v4lmjpegsink));

View file

@ -57,9 +57,11 @@ static void gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass *
static void gst_v4lmjpegsrc_init (GstV4lMjpegSrc *v4lmjpegsrc);
/* pad/buffer functions */
/*
static GstPadNegotiateReturn gst_v4lmjpegsrc_negotiate (GstPad *pad,
GstCaps **caps,
gpointer *user_data);
*/
static GstCaps* gst_v4lmjpegsrc_create_caps (GstV4lMjpegSrc *v4lmjpegsrc);
static GstBuffer* gst_v4lmjpegsrc_get (GstPad *pad);
@ -176,7 +178,7 @@ gst_v4lmjpegsrc_init (GstV4lMjpegSrc *v4lmjpegsrc)
gst_element_add_pad(GST_ELEMENT(v4lmjpegsrc), v4lmjpegsrc->srcpad);
gst_pad_set_get_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_get);
gst_pad_set_negotiate_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_negotiate);
//gst_pad_set_negotiate_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_negotiate);
v4lmjpegsrc->bufferpool = gst_buffer_pool_new();
gst_buffer_pool_set_buffer_new_function(v4lmjpegsrc->bufferpool, gst_v4lmjpegsrc_buffer_new);
@ -205,6 +207,7 @@ gst_v4lmjpegsrc_init (GstV4lMjpegSrc *v4lmjpegsrc)
/*
static GstPadNegotiateReturn
gst_v4lmjpegsrc_negotiate (GstPad *pad,
GstCaps **caps,
@ -223,6 +226,7 @@ gst_v4lmjpegsrc_negotiate (GstPad *pad,
return GST_PAD_NEGOTIATE_FAIL;
}
*/
static GstCaps*
@ -253,7 +257,7 @@ gst_v4lmjpegsrc_get (GstPad *pad)
v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
if (v4lmjpegsrc->init) {
gst_pad_set_caps (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_create_caps (v4lmjpegsrc));
gst_pad_try_set_caps (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_create_caps (v4lmjpegsrc));
v4lmjpegsrc->init = FALSE;
}
else {

View file

@ -54,9 +54,10 @@ static void gst_v4lsrc_class_init (GstV4lSrcClass *klass);
static void gst_v4lsrc_init (GstV4lSrc *v4lsrc);
/* pad/buffer functions */
static GstPadNegotiateReturn gst_v4lsrc_negotiate (GstPad *pad,
/*static GstPadNegotiateReturn gst_v4lsrc_negotiate (GstPad *pad,
GstCaps **caps,
gpointer *user_data);
*/
static GstCaps* gst_v4lsrc_create_caps (GstV4lSrc *v4lsrc);
static GstBuffer* gst_v4lsrc_get (GstPad *pad);
@ -154,7 +155,7 @@ gst_v4lsrc_init (GstV4lSrc *v4lsrc)
gst_element_add_pad(GST_ELEMENT(v4lsrc), v4lsrc->srcpad);
gst_pad_set_get_function (v4lsrc->srcpad, gst_v4lsrc_get);
gst_pad_set_negotiate_function (v4lsrc->srcpad, gst_v4lsrc_negotiate);
//gst_pad_set_negotiate_function (v4lsrc->srcpad, gst_v4lsrc_negotiate);
v4lsrc->bufferpool = gst_buffer_pool_new();
gst_buffer_pool_set_buffer_new_function(v4lsrc->bufferpool, gst_v4lsrc_buffer_new);
@ -171,6 +172,7 @@ gst_v4lsrc_init (GstV4lSrc *v4lsrc)
}
#if 0
static GstPadNegotiateReturn
gst_v4lsrc_negotiate (GstPad *pad,
GstCaps **caps,
@ -255,6 +257,7 @@ gst_v4lsrc_negotiate (GstPad *pad,
return GST_PAD_NEGOTIATE_FAIL;
}
#endif
static GstCaps*
@ -361,7 +364,7 @@ gst_v4lsrc_get (GstPad *pad)
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
if (v4lsrc->init) {
gst_pad_set_caps (v4lsrc->srcpad, gst_v4lsrc_create_caps (v4lsrc));
gst_pad_try_set_caps (v4lsrc->srcpad, gst_v4lsrc_create_caps (v4lsrc));
v4lsrc->init = FALSE;
}
else {