[gst-devel] setting packet time on playbin

Alfred E. Heggestad aeh at db.org
Sun Oct 14 17:05:07 CEST 2007


René Stadler wrote:
> Am Samstag, den 06.10.2007, 15:49 +0200 schrieb Alfred E. Heggestad:
>> Hi
>>
>> I am using the 'playbin' source with my own fakesink callback function
>> to get the raw pcm data, which works fine.
>>
>>
>> static void handoff_handler(GstFakeSink *fakesink, GstBuffer *buffer,
>> 			    GstPad *pad, gpointer user_data)
>> {
>> 	/* ... */
>> }
>>
>>
>> void init(void)
>> {
>> 	/* Override audio-sink handoff handler */
>> 	g_object_set(G_OBJECT(g->sink), "signal-handoffs", TRUE, NULL);
>> 	g_signal_connect (g->sink, "handoff", G_CALLBACK (handoff_handler), g);
>> 	g_object_set(G_OBJECT(g->source), "audio-sink", g->sink, NULL);
>> }
>>
>>
>>
>> current the PCM data on the handoff_handler is 44.1kHz/2ch, which gives
>> 2304 samples each time the function is called. that corresponds to a packet
>> time of ~38 milliseconds.
>>
>>
>> my question is basically; is it possible to set the packet time so my
>> callback function is called with a packet time of e.g. 20 milliseconds
>> (i.e. 50 times per second). ?
>>
>>
>> Thanks for this great software
>>
>>
>> /alfred
> 
> In general, this is not possible.  If you are reading from a raw audio
> source that is derived from GstBaseSrc, you can set the "blocksize"
> property however.
> 
> You can also use GstAdapter in your app.  You would feed all buffers
> into the adapter and then read from there in any size you desire.
> 

thanks for your reply.

I tried the GstAdapter and it was working quite well..


What I am trying to do is to use "playbin" to play any source (http/file)
in any format (mp3/ogg/sid) etc., and pipe the raw PCM audio to my application
in this format:

   width:        16-bit signed
   samplerate:   8000 Hz, 16000 Hz or 32000 Hz
   channels:     1 or 2
   packet time:  20ms - 100ms


this is now working for mp3 streams, but I am using libsamplerate to
resample from 44100Hz to e.g. 8000Hz. Ideally I would also like to use
gstreamer for the whole pipeline.

the format of the buffer that is sent to my handler_handler() is dependant
on the source, I have seen 32-bits float for MP3 source and 16-bit int
for SID-tune source.


while it is possible to detect this in run-time using
gst_structure_get_int(s, "width", &width); on the Buffer's CAPS structure,
and decode accordingly, I would rather prefer to *always* get the format
of the GstBuffer in 16-bit signed int. Do you know if this is possible,
and how this can be achieved when setting up the pipeline, playbin etc?


thanks again for your help :)



/alfred




More information about the gstreamer-devel mailing list