Changed to the new props API

Original commit message from CVS:
Changed to the new props API
Other small tuff.
This commit is contained in:
Wim Taymans 2002-03-30 17:06:26 +00:00
parent 23d4006837
commit 45dbf76d1b
7 changed files with 102 additions and 29 deletions

View file

@ -432,6 +432,14 @@ GST_CHECK_FEATURE(HTTP, [http plugins], gsthttpsrc, [
AC_SUBST(GST_HTTPSRC_GET_TYPE)
])
dnl *** Jack ***
translit(dnm, m, l) AM_CONDITIONAL(USE_LCS, true)
GST_CHECK_FEATURE(LCS, Lcs, lcs, [
PKG_CHECK_MODULES(LCS, lcs, HAVE_LCS="yes", HAVE_LCS="no")
AC_SUBST(LCS_CFLAGS)
AC_SUBST(LCS_LIBS)
])
dnl *** Jack ***
translit(dnm, m, l) AM_CONDITIONAL(USE_JACK, true)
GST_CHECK_FEATURE(JACK, Jack, jack, [
@ -796,6 +804,7 @@ ext/hermes/Makefile
ext/http/Makefile
ext/jack/Makefile
ext/jpeg/Makefile
ext/lcs/Makefile
ext/ladspa/Makefile
ext/lame/Makefile
ext/mad/Makefile

View file

@ -479,7 +479,7 @@ dvdsrc_loop (GstElement *element)
if( len == 0 ) {
fprintf( stderr, "Read failed for block %d\n", priv->cur_pack );
_close(priv);
gst_element_signal_eos (GST_ELEMENT (dvdsrc));
gst_element_set_eos (GST_ELEMENT (dvdsrc));
return;
}
assert( is_nav_pack( data ) );
@ -531,7 +531,7 @@ dvdsrc_loop (GstElement *element)
fprintf( stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack );
_close(priv);
gst_element_signal_eos (GST_ELEMENT (dvdsrc));
gst_element_set_eos (GST_ELEMENT (dvdsrc));
return;
}

View file

@ -365,8 +365,8 @@ gst_lame_sinkconnect (GstPad *pad, GstCaps *caps)
return GST_PAD_CONNECT_REFUSED;
}
lame->samplerate = gst_caps_get_int (caps, "rate");
lame->num_channels = gst_caps_get_int (caps, "channels");
gst_caps_get_int (caps, "rate", &lame->samplerate);
gst_caps_get_int (caps, "channels", &lame->num_channels);
g_object_freeze_notify (G_OBJECT (lame));
g_object_notify (G_OBJECT (lame), "frequency");

View file

@ -63,8 +63,11 @@ main (int argc, char *argv[])
"signed", GST_PROPS_BOOLEAN (TRUE),
"channels", GST_PROPS_INT (1)
);
caps->fixed = TRUE;
g_assert (caps != NULL);
g_object_set (G_OBJECT (src), "sizetype", 3,
"filltype", 3, NULL);
gst_element_set_state (pipeline, GST_STATE_READY);
g_print ("Setting caps on fakesrc's src pad\n");
if (! (gst_pad_try_set_caps (gst_element_get_pad (src, "src"), caps)))

View file

@ -54,9 +54,12 @@ struct _GstMad {
guint64 sync_point;
guint64 total_samples; /* the number of samples since the sync point */
gint64 seek_point;
/* info */
struct mad_header header;
gboolean new_header;
gboolean can_seek;
gint channels;
guint framecount;
gint vbr_average; /* average bitrate */
@ -138,6 +141,8 @@ static void gst_mad_set_property (GObject *object, guint prop_id,
static void gst_mad_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static gboolean gst_mad_src_event (GstPad *pad, GstEvent *event);
static void gst_mad_chain (GstPad *pad, GstBuffer *buffer);
static GstElementStateReturn
@ -228,6 +233,7 @@ gst_mad_init (GstMad *mad)
mad->srcpad = gst_pad_new_from_template(
GST_PADTEMPLATE_GET (mad_src_template_factory), "src");
gst_element_add_pad(GST_ELEMENT(mad),mad->srcpad);
gst_pad_set_event_function (mad->srcpad, GST_DEBUG_FUNCPTR(gst_mad_src_event));
mad->tempbuffer = g_malloc (MAD_BUFFER_MDLEN * 3);
mad->tempsize = 0;
@ -252,6 +258,30 @@ gst_mad_dispose (GObject *object)
g_free (mad->tempbuffer);
}
static gboolean
gst_mad_src_event (GstPad *pad, GstEvent *event)
{
gboolean res = TRUE;
GstMad *mad;
mad = GST_MAD (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
if (mad->can_seek) {
mad->seek_point = GST_EVENT_SEEK_OFFSET (event);
}
else {
res = FALSE;
}
break;
default:
break;
}
return res;
}
static inline signed int
scale (mad_fixed_t sample)
{
@ -385,6 +415,10 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
gst_buffer_unref (buffer);
return;
}
if (mad->sync_point == 0 && GST_BUFFER_TIMESTAMP (buffer) != -1) {
mad->sync_point = GST_BUFFER_TIMESTAMP (buffer);
mad->total_samples = 0;
}
while (size > 0) {
gint tocopy;
@ -408,6 +442,7 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
mad_fixed_t const *left_ch, *right_ch;
GstBuffer *outbuffer;
gint16 *outdata;
guint pad_slot, N;
mad_stream_buffer (&mad->stream, mad_input_buffer, mad->tempsize);
@ -420,10 +455,23 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
gst_element_error (GST_ELEMENT (mad), "fatal error decoding stream");
return;
}
else {
goto next;
}
/* recoverable errors pass */
}
/* calculate beginning of next frame */
pad_slot = (mad->frame.header.flags & MAD_FLAG_PADDING) ? 1 : 0;
if (mad->frame.header.layer == MAD_LAYER_I)
N = ((12 * mad->frame.header.bitrate / mad->frame.header.samplerate) + pad_slot) * 4;
else {
unsigned int slots_per_frame;
slots_per_frame = (mad->frame.header.layer == MAD_LAYER_III &&
(mad->frame.header.flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
N = (slots_per_frame * mad->frame.header.bitrate / mad->frame.header.samplerate) + pad_slot;
}
mad_synth_frame (&mad->synth, &mad->frame);
nchannels = MAD_NCHANNELS (&mad->frame.header);
@ -431,7 +479,8 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
left_ch = mad->synth.pcm.samples[0];
right_ch = mad->synth.pcm.samples[1];
mad->total_samples += nsamples;
/* at this point we can accept seek events */
mad->can_seek = TRUE;
gst_mad_update_info (mad, &mad->frame.header);
@ -439,15 +488,12 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
outdata = (gint16 *) GST_BUFFER_DATA (outbuffer) = g_malloc (nsamples * nchannels * 2);
GST_BUFFER_SIZE (outbuffer) = nsamples * nchannels * 2;
if (GST_BUFFER_TIMESTAMP (buffer) != -1) {
if (GST_BUFFER_TIMESTAMP (buffer) > mad->sync_point) {
mad->sync_point = GST_BUFFER_TIMESTAMP (buffer);
mad->total_samples = 0;
}
}
GST_BUFFER_TIMESTAMP (outbuffer) = mad->sync_point +
mad->total_samples * 1000000LL / mad->frame.header.samplerate;
mad->total_samples += nsamples;
/* end of new bit */
while (nsamples--) {
/* output sample(s) in 16-bit signed native-endian PCM */
@ -482,13 +528,20 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
}
gst_pad_push (mad->srcpad, outbuffer);
next:
/* figure out how many bytes mad consumed */
consumed = mad->stream.next_frame - mad_input_buffer;
/* move out pointer to where mad want the next data */
mad_input_buffer += consumed;
mad->tempsize -= consumed;
if (GST_BUFFER_TIMESTAMP (buffer) != -1) {
if (GST_BUFFER_TIMESTAMP (buffer) > mad->sync_point) {
mad->sync_point = GST_BUFFER_TIMESTAMP (buffer);
mad->total_samples = 0;
}
}
}
memmove (mad->tempbuffer, mad_input_buffer, mad->tempsize);
}
@ -510,7 +563,8 @@ gst_mad_change_state (GstElement *element)
mad_stream_init (&mad->stream);
mad_frame_init (&mad->frame);
mad_synth_init (&mad->synth);
mad->tempsize=0;
mad->tempsize = 0;
mad->can_seek = FALSE;
break;
case GST_STATE_PAUSED_TO_PLAYING:
/* do something to get out of the chain function faster */
@ -521,6 +575,8 @@ gst_mad_change_state (GstElement *element)
mad_synth_finish (&mad->synth);
mad_frame_finish (&mad->frame);
mad_stream_finish (&mad->stream);
mad->sync_point = 0;
mad->can_seek = FALSE;
break;
case GST_STATE_READY_TO_NULL:
break;

View file

@ -219,7 +219,7 @@ gst_mpeg2dec_vo_frame_draw (vo_frame_t * frame)
g_object_notify (G_OBJECT (mpeg2dec), "frame_rate");
}
pts = mpeg2dec->next_time;
pts = mpeg2dec->next_time - 3 * (1000000LL/video_rates[mpeg2dec->decoder->frame_rate_code]);
GST_BUFFER_TIMESTAMP (_frame->buffer) = pts;

View file

@ -40,8 +40,8 @@ gst_audio_frame_byte_size (GstPad* pad)
/* ERROR: could not get caps of pad */
return 0;
width = gst_caps_get_int (caps, "width");
channels = gst_caps_get_int (caps, "channels");
gst_caps_get_int (caps, "width", &width);
gst_caps_get_int (caps, "channels", &channels);
return (width / 8) * channels;
}
@ -73,6 +73,7 @@ gst_audio_frame_rate (GstPad *pad)
*/
{
GstCaps *caps = NULL;
gint rate;
/* get caps of pad */
caps = GST_PAD_CAPS (pad);
@ -80,8 +81,10 @@ gst_audio_frame_rate (GstPad *pad)
if (caps == NULL)
/* ERROR: could not get caps of pad */
return 0;
else
return gst_caps_get_int (caps, "rate");
else {
gst_caps_get_int (caps, "rate", &rate);
return rate;
}
}
double
@ -95,7 +98,7 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
long bytes = 0;
int width = 0;
int channels = 0;
long rate = 0L;
int rate = 0;
double length;
@ -111,9 +114,9 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
else
{
bytes = GST_BUFFER_SIZE (buf);
width = gst_caps_get_int (caps, "width");
channels = gst_caps_get_int (caps, "channels");
rate = gst_caps_get_int (caps, "rate");
gst_caps_get_int (caps, "width", &width);
gst_caps_get_int (caps, "channels", &channels);
gst_caps_get_int (caps, "rate", &rate);
length = (bytes * 8.0) / (double) (rate * channels * width);
}
@ -134,8 +137,10 @@ gst_audio_highest_sample_value (GstPad* pad)
/* FIXME : Please change this to a better warning method ! */
if (caps == NULL)
printf ("WARNING: gstaudio: could not get caps of pad !\n");
width = gst_caps_get_int (caps, "width");
is_signed = gst_caps_get_boolean (caps, "signed");
gst_caps_get_int (caps, "width", &width);
gst_caps_get_boolean (caps, "signed", &is_signed);
if (is_signed) --width;
/* example : 16 bit, signed : samples between -32768 and 32767 */
return ((long) (1 << width));