Convert elements to use gst_pad_use_explicit_caps() where appropriate.

Original commit message from CVS:
Convert elements to use gst_pad_use_explicit_caps() where appropriate.
This commit is contained in:
David Schleef 2004-01-02 07:09:23 +00:00
parent c07da957eb
commit 763b096ef2
10 changed files with 100 additions and 110 deletions

View file

@ -1,3 +1,55 @@
2004-01-01 David Schleef <ds@schleef.org>
Convert elements to use gst_pad_use_explicit_caps() where
appropriate:
* ext/a52dec/gsta52dec.c: (gst_a52dec_init), (gst_a52dec_reneg):
* ext/audiofile/gstafparse.c: (gst_afparse_init),
(gst_afparse_open_file):
* ext/audiofile/gstafsrc.c: (gst_afsrc_init),
(gst_afsrc_open_file):
* ext/esd/esdmon.c: (gst_esdmon_init), (gst_esdmon_get):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_chain):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_loop):
* ext/flac/gstflacdec.c: (gst_flacdec_init), (gst_flacdec_write):
* ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_init),
(gst_gdk_pixbuf_chain):
* ext/jpeg/gstjpegdec.c: (gst_jpegdec_init), (gst_jpegdec_link),
(gst_jpegdec_chain):
* ext/mad/gstmad.c: (gst_mad_init), (gst_mad_chain):
* ext/mikmod/gstmikmod.c: (gst_mikmod_init),
(gst_mikmod_negotiate):
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_init),
(gst_mpeg2dec_negotiate_format):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_push):
* ext/speex/gstspeexdec.c: (gst_speexdec_init),
(gst_speexdec_sinkconnect):
* ext/swfdec/gstswfdec.c: (gst_swfdec_loop), (gst_swfdec_init):
* ext/vorbis/vorbisfile.c: (gst_vorbisfile_init),
(gst_vorbisfile_new_link):
* gst/ac3parse/gstac3parse.c: (gst_ac3parse_init),
(gst_ac3parse_chain):
* gst/asfdemux/gstasfdemux.c: (gst_asf_demux_add_audio_stream),
(gst_asf_demux_setup_pad):
* gst/auparse/gstauparse.c: (gst_auparse_init),
(gst_auparse_chain):
* gst/id3/gstid3types.c: (gst_id3types_loop):
* gst/matroska/matroska-demux.c: (gst_matroska_demux_add_stream):
* gst/mpeg1videoparse/gstmp1videoparse.c: (gst_mp1videoparse_init),
(mp1videoparse_parse_seq):
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_init),
(bpf_from_header):
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_lpcm_set_caps):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_send_data):
* gst/qtdemux/qtdemux.c: (gst_qtdemux_loop_header),
(gst_qtdemux_add_stream):
* gst/realmedia/rmdemux.c: (gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_init),
(gst_wavparse_parse_fmt):
2004-01-01 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:

View file

@ -178,6 +178,7 @@ gst_a52dec_init (GstA52Dec * a52dec)
a52dec->srcpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (a52dec), "src"), "src");
gst_pad_use_explicit_caps (a52dec->srcpad);
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->srcpad);
a52dec->dynamic_range_compression = FALSE;
@ -365,17 +366,15 @@ gst_a52dec_reneg (GstPad * pad, int channels, int rate)
{
GST_INFO ( "a52dec: reneg channels:%d rate:%d\n", channels, rate);
if (gst_pad_try_set_caps (pad,
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, rate,
NULL)) <= 0) {
gst_element_error (GST_PAD_PARENT (pad), "could not set caps on source pad, aborting...");
}
gst_pad_set_explicit_caps (pad,
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, rate,
NULL));
}
static void

View file

@ -309,6 +309,7 @@ gst_mad_init (GstMad *mad)
gst_pad_set_query_type_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_get_query_types));
gst_pad_set_convert_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_convert_src));
gst_pad_set_formats_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_get_formats));
gst_pad_use_explicit_caps (mad->srcpad);
mad->tempbuffer = g_malloc (MAD_BUFFER_MDLEN * 3);
mad->tempsize = 0;
@ -1057,14 +1058,12 @@ gst_mad_chain (GstPad *pad, GstData *_data)
gst_mad_update_info (mad);
if (mad->channels != nchannels || mad->rate != rate) {
GstPadLinkReturn ret;
if (mad->stream.options & MAD_OPTION_HALFSAMPLERATE)
rate >>=1;
/* we set the caps even when the pad is not connected so they
* can be gotten for streaminfo */
ret = gst_pad_try_set_caps (mad->srcpad,
gst_pad_set_explicit_caps (mad->srcpad,
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
@ -1073,10 +1072,6 @@ gst_mad_chain (GstPad *pad, GstData *_data)
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, nchannels,
NULL));
if (GST_PAD_LINK_FAILED (ret)) {
gst_element_error (GST_ELEMENT (mad), "Could not set caps on source pad");
return;
}
mad->channels = nchannels;
mad->rate = rate;
}

View file

@ -197,6 +197,7 @@ gst_mpeg2dec_init (GstMpeg2dec *mpeg2dec)
mpeg2dec->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&src_template_factory), "src");
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->srcpad);
gst_pad_use_explicit_caps (mpeg2dec->srcpad);
gst_pad_set_formats_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_src_formats));
gst_pad_set_event_mask_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_src_event_masks));
gst_pad_set_event_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_event));
@ -328,7 +329,7 @@ gst_mpeg2dec_negotiate_format (GstMpeg2dec *mpeg2dec)
"framerate", G_TYPE_DOUBLE, 1. * GST_SECOND / mpeg2dec->frame_period,
NULL);
ret = gst_pad_try_set_caps (mpeg2dec->srcpad, caps);
ret = gst_pad_set_explicit_caps (mpeg2dec->srcpad, caps);
if (ret != GST_PAD_LINK_OK) return FALSE;
/* it worked, try to find what it was again */

View file

@ -194,6 +194,7 @@ gst_ac3parse_init (GstAc3Parse *ac3parse)
ac3parse->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_ac3parse_src_template), "src");
gst_pad_use_explicit_caps (ac3parse->srcpad);
gst_element_add_pad (GST_ELEMENT (ac3parse), ac3parse->srcpad);
ac3parse->partialbuf = NULL;
@ -341,11 +342,7 @@ gst_ac3parse_chain (GstPad *pad, GstData *_data)
newcaps = gst_caps_new_simple ("audio/x-ac3",
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, sample_rate, NULL);
if (gst_pad_try_set_caps (ac3parse->srcpad, newcaps) <= 0) {
gst_element_error (GST_ELEMENT (ac3parse),
"Ac3parse: failed to negotiate format with next element");
return;
}
gst_pad_set_explicit_caps (ac3parse->srcpad, newcaps);
}
offset += bpf;

View file

@ -78,7 +78,7 @@ static gboolean gst_asf_demux_add_audio_stream (GstASFDemux *asf_demu
guint16 id);
static gboolean gst_asf_demux_setup_pad (GstASFDemux *asf_demux,
GstPad *src_pad,
GstCaps *caps_list,
GstCaps *caps,
guint16 id);
static GstElementStateReturn gst_asf_demux_change_state (GstElement *element);
@ -1392,6 +1392,8 @@ gst_asf_demux_add_audio_stream (GstASFDemux *asf_demux,
src_pad = gst_pad_new_from_template (audiosrctempl, name);
g_free (name);
gst_pad_use_explicit_caps (src_pad);
/* Swallow up any left over data */
if (size_left) {
g_warning ("asfdemux: Audio header contains %d bytes of surplus data", size_left);
@ -1575,12 +1577,12 @@ gst_asf_demux_add_video_stream (GstASFDemux *asf_demux,
static gboolean
gst_asf_demux_setup_pad (GstASFDemux *asf_demux,
GstPad *src_pad,
GstCaps *caps_list,
GstCaps *caps,
guint16 id)
{
asf_stream_context *stream;
gst_pad_try_set_caps (src_pad, caps_list);
gst_pad_set_explicit_caps (src_pad, caps);
gst_pad_set_formats_function (src_pad, gst_asf_demux_get_src_formats);
gst_pad_set_event_mask_function (src_pad, gst_asf_demux_get_src_event_mask);
gst_pad_set_event_function (src_pad, gst_asf_demux_handle_src_event);

View file

@ -290,6 +290,7 @@ gst_mp3parse_init (GstMPEGAudioParse *mp3parse)
mp3parse->srcpad = gst_pad_new_from_template(
gst_static_pad_template_get (&mp3_src_template), "src");
gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->srcpad);
gst_pad_use_explicit_caps (mp3parse->srcpad);
/*gst_pad_set_type_id(mp3parse->srcpad, mp3frametype); */
mp3parse->partialbuf = NULL;
@ -465,10 +466,7 @@ bpf_from_header (GstMPEGAudioParse *parse, unsigned long header)
bitrate != parse->bit_rate) {
GstCaps *caps = mp3_caps_create (layer, channels, bitrate, rate);
if (gst_pad_try_set_caps(parse->srcpad, caps) <= 0) {
gst_element_error (GST_ELEMENT (parse),
"mp3parse: failed to negotiate format with next element");
}
gst_pad_set_explicit_caps(parse->srcpad, caps);
parse->channels = channels;
parse->layer = layer;

View file

@ -458,11 +458,7 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
outpad = &((*outstream)->pad);
*outpad = gst_pad_new_from_template (newtemp, name);
if (!caps) {
gst_pad_try_set_caps (*outpad, gst_pad_template_get_caps (newtemp));
} else {
gst_pad_try_set_caps (*outpad, caps);
}
gst_element_add_pad (GST_ELEMENT (mpeg_demux), (*outpad));
gst_pad_set_formats_function (*outpad, gst_mpeg_demux_get_src_formats);
gst_pad_set_convert_function (*outpad, gst_mpeg_parse_convert_src);
@ -470,8 +466,10 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
gst_pad_set_event_function (*outpad, gst_mpeg_demux_handle_src_event);
gst_pad_set_query_type_function (*outpad, gst_mpeg_parse_get_src_query_types);
gst_pad_set_query_function (*outpad, gst_mpeg_parse_handle_src_query);
gst_pad_use_explicit_caps (*outpad);
gst_pad_set_explicit_caps (*outpad, caps);
gst_element_add_pad (GST_ELEMENT (mpeg_demux), (*outpad));
gst_pad_set_element_private (*outpad, *outstream);
(*outstream)->size_bound = buf_byte_size_bound;
@ -910,18 +908,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
/* create the pad and add it to self */
*outpad = gst_pad_new_from_template (newtemp, name);
if (ps_id_code < 0xA0 || ps_id_code > 0xA7) {
if (!caps) {
gst_pad_try_set_caps (*outpad, gst_pad_template_get_caps (newtemp));
} else {
gst_pad_try_set_caps (*outpad, caps);
}
}
else {
gst_mpeg_demux_lpcm_set_caps(*outpad,
mpeg_demux->lpcm_sample_info[ps_id_code
- 0xA0]);
}
gst_element_add_pad(GST_ELEMENT(mpeg_demux), *outpad);
gst_pad_set_formats_function (*outpad, gst_mpeg_demux_get_src_formats);
gst_pad_set_convert_function (*outpad, gst_mpeg_parse_convert_src);
@ -929,8 +916,17 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
gst_pad_set_event_function (*outpad, gst_mpeg_demux_handle_src_event);
gst_pad_set_query_type_function (*outpad, gst_mpeg_parse_get_src_query_types);
gst_pad_set_query_function (*outpad, gst_mpeg_parse_handle_src_query);
gst_pad_use_explicit_caps (*outpad);
if (ps_id_code < 0xA0 || ps_id_code > 0xA7) {
gst_pad_set_explicit_caps (*outpad, caps);
}
else {
gst_mpeg_demux_lpcm_set_caps(*outpad,
mpeg_demux->lpcm_sample_info[ps_id_code
- 0xA0]);
}
gst_element_add_pad(GST_ELEMENT(mpeg_demux), *outpad);
gst_pad_set_element_private (*outpad, *outstream);
if (mpeg_demux->index)
@ -1023,7 +1019,7 @@ gst_mpeg_demux_lpcm_set_caps (GstPad *pad, guint8 sample_info)
"depth", G_TYPE_INT, width,
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, channels, NULL);
gst_pad_try_set_caps (pad, caps);
gst_pad_set_explicit_caps (pad, caps);
}
/**

View file

@ -194,6 +194,7 @@ gst_mpeg_parse_init (GstMPEGParse *mpeg_parse)
gst_pad_set_event_function (mpeg_parse->srcpad, gst_mpeg_parse_handle_src_event);
gst_pad_set_query_type_function (mpeg_parse->srcpad, gst_mpeg_parse_get_src_query_types);
gst_pad_set_query_function (mpeg_parse->srcpad, gst_mpeg_parse_handle_src_query);
gst_pad_use_explicit_caps (mpeg_parse->srcpad);
gst_element_set_loop_function (GST_ELEMENT (mpeg_parse), gst_mpeg_parse_loop);
@ -274,15 +275,11 @@ gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime
if (!GST_PAD_CAPS (mpeg_parse->srcpad)) {
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
if (gst_pad_try_set_caps (mpeg_parse->srcpad,
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL)) < 0)
{
gst_element_error (GST_ELEMENT (mpeg_parse), "could no set source caps");
return;
}
gst_pad_set_explicit_caps (mpeg_parse->srcpad,
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL));
}
GST_BUFFER_TIMESTAMP (data) = time;

View file

@ -462,47 +462,6 @@ static void gst_rmdemux_loop (GstElement *element)
}
static GstCaps *gst_rmdemux_src_getcaps(GstPad *pad)
{
GstRMDemux *rmdemux;
GstRMDemuxStream *stream;
GST_DEBUG ("gst_rmdemux_src_getcaps");
rmdemux = GST_RMDEMUX(gst_pad_get_parent(pad));
g_return_val_if_fail(GST_IS_RMDEMUX(rmdemux), NULL);
stream = GST_PAD_ELEMENT_PRIVATE (pad);
return gst_caps_copy(stream->caps);
}
#ifdef unused
/* This function is not useful currently */
static GstPadLinkReturn
gst_rmdemux_src_link(GstPad *pad, static GstCaps *caps)
{
GstRMDemux *rmdemux;
GstRMDemuxStream *stream;
int i;
GST_DEBUG ("gst_rmdemux_src_link");
rmdemux = GST_RMDEMUX(gst_pad_get_parent(pad));
GST_DEBUG ("looking for pad %p in rmdemux %p", pad, rmdemux);
g_return_val_if_fail(GST_IS_RMDEMUX(rmdemux), GST_PAD_LINK_REFUSED);
GST_DEBUG ("n_streams is %d\n", rmdemux->n_streams);
stream = GST_PAD_ELEMENT_PRIVATE (pad);
return GST_PAD_LINK_OK;
GST_DEBUG ("Couldn't find stream cooresponding to pad\n");
return GST_PAD_LINK_REFUSED;
}
#endif
static GstRMDemuxStream *gst_rmdemux_get_stream_by_id(GstRMDemux *rmdemux,
int id)
{
@ -551,20 +510,14 @@ void gst_rmdemux_add_stream(GstRMDemux *rmdemux, GstRMDemuxStream *stream)
g_print("n_streams is now %d\n", rmdemux->n_streams);
if(stream->pad){
gst_pad_set_getcaps_function(stream->pad, gst_rmdemux_src_getcaps);
#ifdef unused
gst_pad_set_link_function(stream->pad, gst_rmdemux_src_link);
#endif
gst_pad_use_explicit_caps (stream->pad);
g_print("adding pad %p to rmdemux %p\n", stream->pad, rmdemux);
gst_element_add_pad(GST_ELEMENT (rmdemux), stream->pad);
/* Note: we need to have everything set up before calling try_set_caps */
if(stream->caps){
GST_DEBUG_CAPS("setting caps",stream->caps);
GST_DEBUG_CAPS("setting caps",stream->caps);
gst_pad_try_set_caps(stream->pad, stream->caps);
}
gst_pad_set_explicit_caps(stream->pad, stream->caps);
}
}