Trying to send timestamped audio via RTP

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to send timestamped audio via RTP

pderocco
I'm a gstreamer newbie, and I'm trying to do something really simple: send fixed-sized packets of data via RTP over UDP. Each packet has a timestamp that was obtained from the system clock by the original source of the audio.

The pipeline is built with gst_parse_launch, with the following string:
appsrc name=appsrc
! audio/x-raw,format=S16LE,layout=interleaved,channels=2,depth=16,rate=16000
! audioconvert
! rtpL16pay pt=96
! rtpjitterbuffer latency=10
! udpsink host=10.90.90.100 port=4000
The pipeline timing is set to the system clock.
gst_pipeline_use_clock((GstPipeline*)pipe, gst_system_clock_obtain());
The appsrc is set to live mode, with nanosecond time format:
appsrc = gst_bin_get_by_name(GST_BIN(pipe), "appsrc");
g_object_set(G_OBJECT(appsrc), 
    "stream-type", GST_APP_STREAM_TYPE_STREAM,
    "is-live", TRUE,
    "format", GST_FORMAT_TIME,
    NULL);
Signal handlers are attached to the pipeline, and it is set to the playing state.

I send a 160-sample (10ms) stereo buffer like this:
buf = gst_buffer_new_allocate(NULL, 4 * 160, NULL);
GST_BUFFER_TIMESTAMP(buf) = audio_timestamp;
GST_BUFFER_DURATION(buf) = 62500 * 160;
GstMapInfo map;
gst_buffer_map(buf, &map, GST_MAP_WRITE);
memcpy(map.data, audio_data, 4 * 160);
gst_buffer_unmap(buf, &map);
gst_app_src_push_buffer(GST_APP_SRC(appsrc), buf);
The data pile up in some pipeline element, and are never sent. I can see the memory consumption grow.

If I comment out the second line, so that every buffer has a timestamp of zero, the data gets through, and memory isn't consumed. This suggests that something is blocking the data because it thinks the timestamps are in the future. In fact, the timestamps are derived from the same system clock that the pipeline is tied to, so they are always slightly in the past.

How do I send timestamped buffers, while ensuring that the buffers are sent as soon as I give them to the pipeline?
Reply | Threaded
Open this post in threaded view
|

Re: Trying to send timestamped audio via RTP

pderocco
No answer? Well, after a bunch of reading and experimenting, I figured out that I needed to do set the pipeline clock to NULL rather than to the system clock. That apparently prevents the pipeline from doing any time-related processing, like throwing away data from the past or delaying data for the future.