Appsink misses last buffer

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Appsink misses last buffer

dingoegret
This post was updated on .
I have a simple pipeline of the following:

udpsrc -> rtppcmudepay -> appsink

I am grabbing buffers from appsink via:

g_signal_connect(appsink, "new-sample", G_CALLBACK(new_sample), NULL);

and my callback is:

static GstFlowReturn new_sample(GstElement *sink) {
    GstSample *sample;
    g_signal_emit_by_name(sink, "pull-sample", &sample, NULL);
    if (sample) {
        GstBuffer *buffer = gst_sample_get_buffer(sample);
        GstBuffer *app_buffer = gst_buffer_copy (buffer);

        gst_sample_unref(sample);

        GstMapInfo info;
        gst_buffer_map(app_buffer , &info, GST_MAP_READ);

        fwrite(info.data, sizeof(unsigned char), info.size, file);

        gst_buffer_unmap(app_buffer, &info);
    }

    return GST_FLOW_OK;
}


I send a stream of audio to this pipeline via:

gst-launch-1.0 filesrc location=sample.wav ! wavparse ! audioconvert ! mulawenc ! rtppcmupay ! udpsink host=127.0.0.1 port=6000

I am able to open the saved file that fwrite wrote to and it plays fine, but it is always missing the last second of audio. It cuts off. But if I include a mulawdec in my pipeline:

udpsrc -> rtppcmudepay -> mulawdec -> appsink

Then I get that very last second of audio that before was missing when using the mulaw pipeline attempt. If I replace appsink with filesink

udpsrc -> rtppcmudepay -> filesink

then I everything plays fine also and I also get the last second of audio. What is going on?
Loading...