From 8693a11ba238309b76e46410f39aae7d33d94b81 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 13 Jan 2002 22:27:24 +0000 Subject: [PATCH] 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... --- ext/Makefile.am | 3 ++- ext/a52dec/gsta52dec.c | 24 ++++++++++++------------ ext/lame/gstlame.c | 14 ++++++++++---- ext/mad/gstmad.c | 5 ++--- ext/mpeg2dec/gstmpeg2dec.c | 2 +- ext/sidplay/gstsiddec.cc | 2 +- gst/ac3parse/gstac3parse.c | 2 +- gst/mpegaudioparse/gstmpegaudioparse.c | 1 - gst/mpegstream/gstmpegdemux.c | 18 +++++++++--------- gst/mpegstream/gstmpegparse.c | 2 +- 10 files changed, 39 insertions(+), 34 deletions(-) diff --git a/ext/Makefile.am b/ext/Makefile.am index bd24b63787..4676b25ba0 100644 --- a/ext/Makefile.am +++ b/ext/Makefile.am @@ -151,7 +151,8 @@ RTP_DIR= endif if USE_SDL -SDL_DIR=sdl +#SDL_DIR=sdl +SDL_DIR= else SDL_DIR= endif diff --git a/ext/a52dec/gsta52dec.c b/ext/a52dec/gsta52dec.c index 924528ed8a..b7f36a89fc 100644 --- a/ext/a52dec/gsta52dec.c +++ b/ext/a52dec/gsta52dec.c @@ -150,7 +150,6 @@ gst_a52dec_init (GstA52Dec * a52dec) /* create the sink and src pads */ a52dec->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (sink_factory), "sink"); 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); 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_pad_set_caps (pad, gst_caps_new ("a52dec_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), - "channels", GST_PROPS_INT (channels), - "rate", GST_PROPS_INT (rate), NULL) - )); + gst_pad_try_set_caps (pad, + GST_CAPS_NEW ("a52dec_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), + "channels", GST_PROPS_INT (channels), + "rate", GST_PROPS_INT (rate)) + ); } static void diff --git a/ext/lame/gstlame.c b/ext/lame/gstlame.c index b90a6fcce7..a5c74795c4 100644 --- a/ext/lame/gstlame.c +++ b/ext/lame/gstlame.c @@ -323,13 +323,16 @@ gst_lame_class_init (GstLameClass *klass) gstelement_class->change_state = gst_lame_change_state; } -static void -gst_lame_newcaps (GstPad *pad, GstCaps *caps) +static GstPadConnectReturn +gst_lame_sinkconnect (GstPad *pad, GstCaps *caps) { GstLame *lame; 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->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?)"); lame->initialized = FALSE; } + if (lame->initialized) + return GST_PAD_CONNECT_OK; + + return GST_PAD_CONNECT_REFUSED; } 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"); gst_element_add_pad (GST_ELEMENT (lame), lame->sinkpad); 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"); 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"); lame->lgf = lame_init (); diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index b727f28cb5..bba6e671a1 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -129,7 +129,6 @@ gst_mad_init (GstMad *mad) mad->sinkpad = gst_pad_new_from_template( GST_PADTEMPLATE_GET (mad_sink_template_factory), "sink"); 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)); 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) { - gst_pad_set_caps (mad->srcpad, + gst_pad_try_set_caps (mad->srcpad, gst_caps_new ( "mad_src", "audio/raw", @@ -292,7 +291,7 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer) NULL))); } - if (GST_PAD_CONNECTED (mad->srcpad)) + if (GST_PAD_IS_CONNECTED (mad->srcpad)) gst_pad_push (mad->srcpad, outbuffer); else gst_buffer_unref (outbuffer); diff --git a/ext/mpeg2dec/gstmpeg2dec.c b/ext/mpeg2dec/gstmpeg2dec.c index c720917226..77172bef8f 100644 --- a/ext/mpeg2dec/gstmpeg2dec.c +++ b/ext/mpeg2dec/gstmpeg2dec.c @@ -248,7 +248,7 @@ gst_mpeg2dec_vo_setup (vo_instance_t * instance, int width, int height) mpeg2dec->width = width; mpeg2dec->height = height; - gst_pad_set_caps (mpeg2dec->srcpad, + gst_pad_try_set_caps (mpeg2dec->srcpad, gst_caps_new ( "mpeg2dec_caps", "video/raw", diff --git a/ext/sidplay/gstsiddec.cc b/ext/sidplay/gstsiddec.cc index dd6d9f0108..93c57d825e 100644 --- a/ext/sidplay/gstsiddec.cc +++ b/ext/sidplay/gstsiddec.cc @@ -374,7 +374,7 @@ gst_siddec_loop (GstElement *element) if (siddec->tune->load (siddec->tune_buffer, siddec->tune_len)) { 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 ( "siddec_src", "audio/raw", diff --git a/gst/ac3parse/gstac3parse.c b/gst/ac3parse/gstac3parse.c index ab2fe7ac6d..ef1b5045e4 100644 --- a/gst/ac3parse/gstac3parse.c +++ b/gst/ac3parse/gstac3parse.c @@ -256,7 +256,7 @@ gst_ac3parse_chain (GstPad *pad, GstBuffer *buf) outbuf = gst_buffer_create_sub(ac3parse->partialbuf,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_pad_push(ac3parse->srcpad,outbuf); } diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c index 220d6dd2e3..9e19b319d7 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.c +++ b/gst/mpegaudioparse/gstmpegaudioparse.c @@ -142,7 +142,6 @@ static void gst_mp3parse_init (GstMPEGAudioParse *mp3parse) { 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); #if 1 // set this to one to use the old chaining code diff --git a/gst/mpegstream/gstmpegdemux.c b/gst/mpegstream/gstmpegdemux.c index e8c3deddd5..9d14aa1363 100644 --- a/gst/mpegstream/gstmpegdemux.c +++ b/gst/mpegstream/gstmpegdemux.c @@ -353,7 +353,7 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer) */ if (outpad && *outpad == NULL) { *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)); } else { @@ -540,7 +540,7 @@ done: } /* 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 */ 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) { /* create the pad and add it to self */ (*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)); } 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 */ - if (GST_PAD_CONNECTED(*outpad)) { + if (GST_PAD_IS_CONNECTED(*outpad)) { /* if this is part of the buffer, create a subbuffer */ 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;iprivate_1_pad[i]; - if (pad && GST_PAD_CONNECTED(pad)) + if (pad && GST_PAD_IS_CONNECTED(pad)) (*fun) (pad, user_data); } for (i=0;isubtitle_pad[i]; - if (pad && GST_PAD_CONNECTED(pad)) + if (pad && GST_PAD_IS_CONNECTED(pad)) (*fun) (pad, user_data); } pad = mpeg_demux->private_2_pad; - if (pad && GST_PAD_CONNECTED(pad)) + if (pad && GST_PAD_IS_CONNECTED(pad)) (*fun) (pad, user_data); for (i=0;ivideo_pad[i]; - if (pad && GST_PAD_CONNECTED(pad)) + if (pad && GST_PAD_IS_CONNECTED(pad)) (*fun) (pad, user_data); } for (i=0;iaudio_pad[i]; - if (pad && GST_PAD_CONNECTED(pad)) + if (pad && GST_PAD_IS_CONNECTED(pad)) (*fun) (pad, user_data); } } diff --git a/gst/mpegstream/gstmpegparse.c b/gst/mpegstream/gstmpegparse.c index 43c5477cf8..0db9f68087 100644 --- a/gst/mpegstream/gstmpegparse.c +++ b/gst/mpegstream/gstmpegparse.c @@ -172,7 +172,7 @@ gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data) if (!GST_PAD_CAPS (mpeg_parse->srcpad)) { 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 ( "mpeg_parse_src", "video/mpeg",