Plugin dev Timestamp

Duchassin Frederic duchassin at sefram.fr
Tue Jun 5 14:56:50 UTC 2018


Hello All,


Is someone can have a look in my t2mi chain function in order to see if there is a big mistake :


static GstBuffer * gst_my_filter_process_data(Gstt2mi *filter, GstBuffer * Inbuf)
{
    GstBuffer * Outbuf = nullptr;
    GstMemory * memory;
    GstMapInfo map_info;
    ts::TSPacket ts;
    TSFifo *  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();  //récup le pointeur vers l'objet
    int taille = TSOutFifo->size();

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

    if(taille>0)
    {

        //make a big buffer contaninig all ts data
        GstMemory *mem;
        GstMapInfo info;

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

        /* make memory holding xxx bytes */
        mem = gst_allocator_alloc (NULL, taille*188, NULL);

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

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


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

        for (int i=0; i<taille; i++)
        {
            ts::TSPacket ts_tmp = TSOutFifo->read_front();

            //memcpy(info.data+(i*188), ts::NullPacket.b, 188);
            memcpy(info.data+(i*188), ts_tmp.b, 188);
        }

        gst_buffer_unmap (Outbuf, &info);

    }

    return Outbuf;
}

The problem is that I get message that my stream is not correctly time stamped. (alsasink give clock skew).

Thanks in advance

Frederic




-----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 16:54
À : gstreamer-devel at lists.freedesktop.org
Objet : RE: Plugin dev Timestamp

It works correctly during 2 or 3 seconds and after I get blank on the sound every seconds (the sound is hashed) and I get debug message that frame are dropped : 

../../../../gstreamer-1.6.3/libs/gst/base/gstbasesink.c(2846): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstImxIpuVideoSink:imxipuvideosink0:
There may be a timestamping problem, or this computer is too slow.
WARNING: from element /GstPipeline:pipeline0/GstImxIpuVideoSink:imxipuvideosink0: A lot of buffers are being dropped.
Additional debug info:
../../../../gstreamer-1.6.3/libs/gst/base/gstbasesink.c(2846): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstImxIpuVideoSink:imxipuvideosink0:
There may be a timestamping problem, or this computer is too slow.


This problem doesn't appear on filesrc. That's why I think it's a latency or timestamp problem...

Ok about query handler, I just have a look at it and quickly add my own handler :


static gboolean gst_my_filter_src_query (GstPad  *pad, GstObject *parent, GstQuery  *query)
{
    gboolean ret;
    Gstt2mi *filter = GST_T2MI (parent);

    gboolean live;
    GstClockTime min_latency, max_latency;

    //  const char * query_name = gst_query_type_get_name(GST_QUERY_TYPE (query));
    //  g_print (query_name); g_print ("\n");

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_LATENCY:
        //g_print ("GST_QUERY_LATENCY\n");
        gst_query_parse_latency (query, &live, &min_latency, &max_latency);

        g_print ("GST_QUERY_LATENCY live=%d ; min_latency=%lld max_latency=%lld\n", live, min_latency, max_latency);

        min_latency += 400000;	//fixed latency

        gst_query_set_latency (query, live, min_latency, max_latency);

        break;
    default:
        /* just call the default handler */
        ret = gst_pad_query_default (pad, parent, query);
        break;
    }
    return ret;
}

But it doesn't work !
Do you know where I can find example about this ? I try to read gstream plugin's writer guide but I can't really found example about latency query.


Many many thanks for helping me.

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 16:01
À : gstreamer-devel at lists.freedesktop.org
Objet : Re: Plugin dev Timestamp

On Thu, 2018-05-31 at 15:30 +0200, Duchassin Frederic wrote:

Hi,

> I think my timestamp should be correct.
> I believe the problem come from latency which is not emitted by my
> element.

What is "the problem" exactly? How does it manifest itself?

> Someone can explain me how to emit this latency ?

You would add a query handler to your source pad and handle the LATENCY
query. When such a query comes in, you first pass it to upstream, and
then (if it was successful) you read it out and your own latency and
set the new values back on it before returning from the query handler.

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