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:24 +00:00
parent 7709f4acba
commit 8693a11ba2
10 changed files with 39 additions and 34 deletions

View file

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

View file

@ -150,7 +150,6 @@ gst_a52dec_init (GstA52Dec * a52dec)
/* create the sink and src pads */ /* create the sink and src pads */
a52dec->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (sink_factory), "sink"); a52dec->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->sinkpad); gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->sinkpad);
gst_pad_set_caps (a52dec->sinkpad, gst_pad_get_padtemplate_caps (a52dec->sinkpad));
gst_element_set_loop_function ((GstElement *) a52dec, gst_a52dec_loop); gst_element_set_loop_function ((GstElement *) a52dec, gst_a52dec_loop);
a52dec->srcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (src_factory), "src"); a52dec->srcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (src_factory), "src");
@ -341,17 +340,18 @@ gst_a52dec_reneg (GstPad * pad, int channels, int rate)
{ {
GST_INFO (GST_CAT_PLUGIN_INFO, "a52dec: reneg channels:%d rate:%d\n", channels, rate); GST_INFO (GST_CAT_PLUGIN_INFO, "a52dec: reneg channels:%d rate:%d\n", channels, rate);
gst_pad_set_caps (pad, gst_caps_new ("a52dec_src_caps", gst_pad_try_set_caps (pad,
"audio/raw", GST_CAPS_NEW ("a52dec_src_caps",
gst_props_new ("format", GST_PROPS_STRING ("int"), "audio/raw",
"law", GST_PROPS_INT (0), "format", GST_PROPS_STRING ("int"),
"endianness", GST_PROPS_INT (G_BYTE_ORDER), "law", GST_PROPS_INT (0),
"signed", GST_PROPS_BOOLEAN (TRUE), "endianness", GST_PROPS_INT (G_BYTE_ORDER),
"width", GST_PROPS_INT (16), "signed", GST_PROPS_BOOLEAN (TRUE),
"depth", GST_PROPS_INT (16), "width", GST_PROPS_INT (16),
"channels", GST_PROPS_INT (channels), "depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT (rate), NULL) "channels", GST_PROPS_INT (channels),
)); "rate", GST_PROPS_INT (rate))
);
} }
static void static void

View file

@ -323,13 +323,16 @@ gst_lame_class_init (GstLameClass *klass)
gstelement_class->change_state = gst_lame_change_state; gstelement_class->change_state = gst_lame_change_state;
} }
static void static GstPadConnectReturn
gst_lame_newcaps (GstPad *pad, GstCaps *caps) gst_lame_sinkconnect (GstPad *pad, GstCaps *caps)
{ {
GstLame *lame; GstLame *lame;
lame = GST_LAME (gst_pad_get_parent (pad)); lame = GST_LAME (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
lame->samplerate = gst_caps_get_int (caps, "rate"); lame->samplerate = gst_caps_get_int (caps, "rate");
lame->num_channels = gst_caps_get_int (caps, "channels"); lame->num_channels = gst_caps_get_int (caps, "channels");
@ -347,6 +350,10 @@ gst_lame_newcaps (GstPad *pad, GstCaps *caps)
gst_element_error (GST_ELEMENT (lame), "could not initialize encoder (wrong parameters?)"); gst_element_error (GST_ELEMENT (lame), "could not initialize encoder (wrong parameters?)");
lame->initialized = FALSE; lame->initialized = FALSE;
} }
if (lame->initialized)
return GST_PAD_CONNECT_OK;
return GST_PAD_CONNECT_REFUSED;
} }
static void static void
@ -357,11 +364,10 @@ gst_lame_init (GstLame *lame)
lame->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (gst_lame_sink_factory), "sink"); lame->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (gst_lame_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (lame), lame->sinkpad); gst_element_add_pad (GST_ELEMENT (lame), lame->sinkpad);
gst_pad_set_chain_function (lame->sinkpad, gst_lame_chain); gst_pad_set_chain_function (lame->sinkpad, gst_lame_chain);
gst_pad_set_newcaps_function (lame->sinkpad, gst_lame_newcaps); gst_pad_set_connect_function (lame->sinkpad, gst_lame_sinkconnect);
lame->srcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (gst_lame_src_factory), "src"); lame->srcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (gst_lame_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (lame), lame->srcpad); gst_element_add_pad (GST_ELEMENT (lame), lame->srcpad);
gst_pad_set_caps (lame->srcpad, gst_pad_get_padtemplate_caps (lame->srcpad));
GST_DEBUG (0, "setting up lame encoder\n"); GST_DEBUG (0, "setting up lame encoder\n");
lame->lgf = lame_init (); lame->lgf = lame_init ();

View file

@ -129,7 +129,6 @@ gst_mad_init (GstMad *mad)
mad->sinkpad = gst_pad_new_from_template( mad->sinkpad = gst_pad_new_from_template(
GST_PADTEMPLATE_GET (mad_sink_template_factory), "sink"); GST_PADTEMPLATE_GET (mad_sink_template_factory), "sink");
gst_element_add_pad(GST_ELEMENT(mad),mad->sinkpad); gst_element_add_pad(GST_ELEMENT(mad),mad->sinkpad);
gst_pad_set_caps (mad->sinkpad, gst_pad_get_padtemplate_caps (mad->sinkpad));
gst_pad_set_chain_function (mad->sinkpad, GST_DEBUG_FUNCPTR(gst_mad_chain)); gst_pad_set_chain_function (mad->sinkpad, GST_DEBUG_FUNCPTR(gst_mad_chain));
mad->srcpad = gst_pad_new_from_template( mad->srcpad = gst_pad_new_from_template(
@ -272,7 +271,7 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
} }
} }
if (GST_PAD_CAPS (mad->srcpad) == NULL) { if (GST_PAD_CAPS (mad->srcpad) == NULL) {
gst_pad_set_caps (mad->srcpad, gst_pad_try_set_caps (mad->srcpad,
gst_caps_new ( gst_caps_new (
"mad_src", "mad_src",
"audio/raw", "audio/raw",
@ -292,7 +291,7 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
NULL))); NULL)));
} }
if (GST_PAD_CONNECTED (mad->srcpad)) if (GST_PAD_IS_CONNECTED (mad->srcpad))
gst_pad_push (mad->srcpad, outbuffer); gst_pad_push (mad->srcpad, outbuffer);
else else
gst_buffer_unref (outbuffer); gst_buffer_unref (outbuffer);

View file

@ -248,7 +248,7 @@ gst_mpeg2dec_vo_setup (vo_instance_t * instance, int width, int height)
mpeg2dec->width = width; mpeg2dec->width = width;
mpeg2dec->height = height; mpeg2dec->height = height;
gst_pad_set_caps (mpeg2dec->srcpad, gst_pad_try_set_caps (mpeg2dec->srcpad,
gst_caps_new ( gst_caps_new (
"mpeg2dec_caps", "mpeg2dec_caps",
"video/raw", "video/raw",

View file

@ -374,7 +374,7 @@ gst_siddec_loop (GstElement *element)
if (siddec->tune->load (siddec->tune_buffer, siddec->tune_len)) { if (siddec->tune->load (siddec->tune_buffer, siddec->tune_len)) {
if (sidEmuInitializeSong (*siddec->engine, *siddec->tune, siddec->tune_number)) { if (sidEmuInitializeSong (*siddec->engine, *siddec->tune, siddec->tune_number)) {
gst_pad_set_caps (siddec->srcpad, gst_pad_try_set_caps (siddec->srcpad,
GST_CAPS_NEW ( GST_CAPS_NEW (
"siddec_src", "siddec_src",
"audio/raw", "audio/raw",

View file

@ -256,7 +256,7 @@ gst_ac3parse_chain (GstPad *pad, GstBuffer *buf)
outbuf = gst_buffer_create_sub(ac3parse->partialbuf,offset,bpf); outbuf = gst_buffer_create_sub(ac3parse->partialbuf,offset,bpf);
offset += bpf; offset += bpf;
if (ac3parse->skip == 0 && GST_PAD_CONNECTED(ac3parse->srcpad)) { if (ac3parse->skip == 0 && GST_PAD_IS_CONNECTED(ac3parse->srcpad)) {
GST_DEBUG (0,"ac3parse: pushing buffer of %d bytes\n",GST_BUFFER_SIZE(outbuf)); GST_DEBUG (0,"ac3parse: pushing buffer of %d bytes\n",GST_BUFFER_SIZE(outbuf));
gst_pad_push(ac3parse->srcpad,outbuf); gst_pad_push(ac3parse->srcpad,outbuf);
} }

View file

@ -142,7 +142,6 @@ static void
gst_mp3parse_init (GstMPEGAudioParse *mp3parse) gst_mp3parse_init (GstMPEGAudioParse *mp3parse)
{ {
mp3parse->sinkpad = gst_pad_new_from_template(sink_temp, "sink"); mp3parse->sinkpad = gst_pad_new_from_template(sink_temp, "sink");
//gst_pad_set_caps(mp3parse->sinkpad, gst_pad_get_padtemplate_caps (mp3parse->sinkpad));
gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->sinkpad); gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->sinkpad);
#if 1 // set this to one to use the old chaining code #if 1 // set this to one to use the old chaining code

View file

@ -353,7 +353,7 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
*/ */
if (outpad && *outpad == NULL) { if (outpad && *outpad == NULL) {
*outpad = gst_pad_new_from_template (newtemp, name); *outpad = gst_pad_new_from_template (newtemp, name);
gst_pad_set_caps (*outpad, gst_pad_get_padtemplate_caps (*outpad)); gst_pad_try_set_caps (*outpad, gst_pad_get_padtemplate_caps (*outpad));
gst_element_add_pad (GST_ELEMENT (mpeg_demux), (*outpad)); gst_element_add_pad (GST_ELEMENT (mpeg_demux), (*outpad));
} }
else { else {
@ -540,7 +540,7 @@ done:
} }
/* create the buffer and send it off to the Other Side */ /* create the buffer and send it off to the Other Side */
if (GST_PAD_CONNECTED(*outpad) && datalen > 0) { if (GST_PAD_IS_CONNECTED(*outpad) && datalen > 0) {
/* if this is part of the buffer, create a subbuffer */ /* if this is part of the buffer, create a subbuffer */
GST_DEBUG (0,"mpeg_demux::parse_packet: creating subbuffer len %d\n", datalen); GST_DEBUG (0,"mpeg_demux::parse_packet: creating subbuffer len %d\n", datalen);
@ -737,7 +737,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
if (newtemp) { if (newtemp) {
/* create the pad and add it to self */ /* create the pad and add it to self */
(*outpad) = gst_pad_new_from_template (newtemp, name); (*outpad) = gst_pad_new_from_template (newtemp, name);
gst_pad_set_caps((*outpad), gst_pad_get_padtemplate_caps (*outpad)); gst_pad_try_set_caps ((*outpad), gst_pad_get_padtemplate_caps (*outpad));
gst_element_add_pad(GST_ELEMENT(mpeg_demux),(*outpad)); gst_element_add_pad(GST_ELEMENT(mpeg_demux),(*outpad));
} }
else { else {
@ -748,7 +748,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
} }
/* create the buffer and send it off to the Other Side */ /* create the buffer and send it off to the Other Side */
if (GST_PAD_CONNECTED(*outpad)) { if (GST_PAD_IS_CONNECTED(*outpad)) {
/* if this is part of the buffer, create a subbuffer */ /* if this is part of the buffer, create a subbuffer */
GST_DEBUG (0,"mpeg_demux: creating subbuffer len %d\n", datalen); GST_DEBUG (0,"mpeg_demux: creating subbuffer len %d\n", datalen);
@ -788,30 +788,30 @@ _forall_pads (GstMPEGDemux *mpeg_demux, GFunc fun, gpointer user_data)
for (i=0;i<NUM_PRIVATE_1_PADS;i++) for (i=0;i<NUM_PRIVATE_1_PADS;i++)
{ {
pad = mpeg_demux->private_1_pad[i]; pad = mpeg_demux->private_1_pad[i];
if (pad && GST_PAD_CONNECTED(pad)) if (pad && GST_PAD_IS_CONNECTED(pad))
(*fun) (pad, user_data); (*fun) (pad, user_data);
} }
for (i=0;i<NUM_SUBTITLE_PADS;i++) for (i=0;i<NUM_SUBTITLE_PADS;i++)
{ {
pad = mpeg_demux->subtitle_pad[i]; pad = mpeg_demux->subtitle_pad[i];
if (pad && GST_PAD_CONNECTED(pad)) if (pad && GST_PAD_IS_CONNECTED(pad))
(*fun) (pad, user_data); (*fun) (pad, user_data);
} }
pad = mpeg_demux->private_2_pad; pad = mpeg_demux->private_2_pad;
if (pad && GST_PAD_CONNECTED(pad)) if (pad && GST_PAD_IS_CONNECTED(pad))
(*fun) (pad, user_data); (*fun) (pad, user_data);
for (i=0;i<NUM_VIDEO_PADS;i++) for (i=0;i<NUM_VIDEO_PADS;i++)
{ {
pad = mpeg_demux->video_pad[i]; pad = mpeg_demux->video_pad[i];
if (pad && GST_PAD_CONNECTED(pad)) if (pad && GST_PAD_IS_CONNECTED(pad))
(*fun) (pad, user_data); (*fun) (pad, user_data);
} }
for (i=0;i<NUM_AUDIO_PADS;i++) for (i=0;i<NUM_AUDIO_PADS;i++)
{ {
pad = mpeg_demux->audio_pad[i]; pad = mpeg_demux->audio_pad[i];
if (pad && GST_PAD_CONNECTED(pad)) if (pad && GST_PAD_IS_CONNECTED(pad))
(*fun) (pad, user_data); (*fun) (pad, user_data);
} }
} }

View file

@ -172,7 +172,7 @@ gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data)
if (!GST_PAD_CAPS (mpeg_parse->srcpad)) { if (!GST_PAD_CAPS (mpeg_parse->srcpad)) {
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize); gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
gst_pad_set_caps (mpeg_parse->srcpad, gst_pad_try_set_caps (mpeg_parse->srcpad,
GST_CAPS_NEW ( GST_CAPS_NEW (
"mpeg_parse_src", "mpeg_parse_src",
"video/mpeg", "video/mpeg",