Plugin dev Timestamp

Duchassin Frederic duchassin at sefram.fr
Thu May 31 13:30:39 UTC 2018


Hello All,

I think my timestamp should be correct.
I believe the problem come from latency which is not emitted by my element.
Someone can explain me how to emit this latency ?

Fredéric



-----Message d'origine-----
De : gstreamer-devel [mailto:gstreamer-devel-bounces at lists.freedesktop.org] De la part de Duchassin Frederic
Envoyé : jeudi 31 mai 2018 11:47
À : gstreamer-devel at lists.freedesktop.org
Objet : RE: Plugin dev Timestamp

Hi Tim,

This is my whole pipeline :

gst-launch-1.0 -v udpsrc address=239.0.0.10 port=1234 buffer-size=300000000 ! t2mi pid=4096 plpid=0 ! tsdemux name=d d. ! queue max-size-bytes=100000000 max-size-time=0 ! vpudec ! queue max-size-bytes=100000000 max-size-time=0 ! imxipuvideosink ts-offset=500000000 force-aspect-ratio=false d. ! queue max-size-bytes=100000000 max-size-time=0 ! decodebin ! queue max-size-bytes=100000000 max-size-time=0 ! audioconvert ! volume volume=10 ! alsasink ts-offset=500000000

As you can see my source is live source.

This is my CHAIN function of my plugin :

static GstBuffer * gst_my_filter_process_data(Gstt2mi *filter, GstBuffer * Inbuf)
{
    GstBuffer * Outbuf = nullptr;
    GstMemory * memory;
    GstMapInfo map_info;
    ts::TSPacket ts;
    std::deque<ts::TSPacket>  * TSOutFifo;
    GstClockTime pts = GST_BUFFER_PTS(Inbuf);
    GstClockTime dts = GST_BUFFER_DTS(Inbuf);

    if (filter->silent == FALSE)
        g_print ("Treatment of IN data.\n");

    memory = gst_buffer_get_all_memory(Inbuf);
    gst_memory_map(memory, &map_info, GST_MAP_READ);

    if (filter->silent == FALSE)
        g_print ("map_info.size=%d\n", map_info.size);

    for (int i=0; i<map_info.size; i+=188)
    {
        memcpy(&ts.b[0], &map_info.data[i], 188);// fill temporary "ts" variable
        t2mi.ProcessInputPacket(ts);
    }

    gst_memory_unmap(memory, &map_info);
    gst_memory_unref(memory);

    TSOutFifo = t2mi.GetTSQueue();

    if (filter->silent == FALSE)
        g_print ("TSOutFifo->size()=%d\n", TSOutFifo->size());

    if(TSOutFifo->size()>0)
    {
        //make a big buffer contaninig all ts data
        GstMemory *mem;
        GstMapInfo info;

        /* make empty buffer */
        Outbuf = gst_buffer_new ();

        /* make memory holding 100 bytes */
        mem = gst_allocator_alloc (NULL, TSOutFifo->size()*188, NULL);
        //mem = gst_allocator_alloc (NULL, size*188 , NULL);

        /* add the buffer */
        gst_buffer_append_memory (Outbuf, mem);

        GST_BUFFER_PTS(Outbuf) = pts;
        GST_BUFFER_DTS(Outbuf) = dts;

        /* get WRITE access to the memory and fill with TS */
        gst_buffer_map (Outbuf, &info, GST_MAP_WRITE);

        for (int i=0; i<TSOutFifo->size(); i++)
        {
            //memcpy(info.data+(i*188), ts::NullPacket.b, 188);
            memcpy(info.data+(i*188), TSOutFifo->at(i).b, 188);
        }

        gst_buffer_unmap (Outbuf, &info);
    }

    TSOutFifo->clear();

    return Outbuf;
}

As you can see if I get data in my fifo, I send the same timestamp than my last buffer received.

Frederic


-----Message d'origine-----
De : gstreamer-devel [mailto:gstreamer-devel-bounces at lists.freedesktop.org] De la part de Tim Müller
Envoyé : jeudi 31 mai 2018 11:37
À : gstreamer-devel at lists.freedesktop.org
Objet : Re: Plugin dev Timestamp

On Thu, 2018-05-31 at 08:50 +0000, Duchassin Frédéric wrote:

Hi Frédéric,

> This plugin receive a t2mi stream and buffer each packet. When a
> complete t2mi packet is receive, the packet is demuxed and send to
> sink pad for the next gstreamer element.
> My problem is how to set timestamp of the send buffer ?  (PTS, DTS
> and duration) I don’t really understand the basic concept of these
> timestamp.
> My source is live source.

If your source is a live source, it will send a segment event in TIME
format to your element, and it will send timestamped buffers to your
element.

What elements are upstream of your element?

You likely will get buffers with pts=dts in your case or with one of
them unset.

In any case your element should pass through the segment event from
upstream and it should pass through the timestamps it gets from
upstream (this doesn't have to be 1:1, but you basically need to
maintain upstream's notion of time, so if upstream starts sending you
buffers with first timestamp 10 seconds your first output buffer should
also be timestamped as ~10 seconds, you shouldn't just start
timestamping as you like, or from 0.

You might find some useful talks on https://gstconf.ubicast.tv/search/
if you look for "time and synchronisation".

Cheers
-Tim

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list