Plugin dev Timestamp

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

Plugin dev Timestamp

Duchassin Frederic

 

 

Hello,

 

I need your help because I try to write my own plugin.

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.

 

Thanks I advance for your help.

 

Frederic

 


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Plugin dev Timestamp

Tim Müller
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Plugin dev Timestamp

Duchassin Frederic
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:[hidden email]] De la part de Tim Müller
Envoyé : jeudi 31 mai 2018 11:37
À : [hidden email]
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Plugin dev Timestamp

Duchassin Frederic
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:[hidden email]] De la part de Duchassin Frederic
Envoyé : jeudi 31 mai 2018 11:47
À : [hidden email]
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:[hidden email]] De la part de Tim Müller
Envoyé : jeudi 31 mai 2018 11:37
À : [hidden email]
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Plugin dev Timestamp

Tim Müller
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Plugin dev Timestamp

Duchassin Frederic
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:[hidden email]] De la part de Tim Müller
Envoyé : jeudi 31 mai 2018 16:01
À : [hidden email]
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Plugin dev Timestamp

Duchassin Frederic
Hello all,

This is what i get on alsasink when I get hashed audio output :


latency=10137333
0:00:38.864469338  2338   0xb6ccc0 WARN           audiobasesink gstaudiobasesink.c:1803:gst_audio_base_sink_get_alignment:<alsasink0> Unexpected discontinuity in audio timestamps of +0:00:00.098895833, resyncing
latency=10610333
0:00:40.664616338  2338   0xb6ccc0 WARN           audiobasesink gstaudiobasesink.c:1803:gst_audio_base_sink_get_alignment:<alsasink0> Unexpected discontinuity in audio timestamps of +0:00:00.101041666, resyncing

Latency is the time between 2 packets at output of my element.
I hope it could be a clue.

Frederic






-----Message d'origine-----
De : gstreamer-devel [mailto:[hidden email]] De la part de Duchassin Frederic
Envoyé : jeudi 31 mai 2018 16:54
À : [hidden email]
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:[hidden email]] De la part de Tim Müller
Envoyé : jeudi 31 mai 2018 16:01
À : [hidden email]
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Plugin dev Timestamp

Duchassin Frederic
In reply to this post by Duchassin Frederic
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:[hidden email]] De la part de Duchassin Frederic
Envoyé : jeudi 31 mai 2018 16:54
À : [hidden email]
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:[hidden email]] De la part de Tim Müller
Envoyé : jeudi 31 mai 2018 16:01
À : [hidden email]
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Plugin dev Timestamp

Duchassin Frederic
In reply to this post by Duchassin Frederic
Hello Nobody have an idea about what I can do to avoid such audio problem ?
Timestamp or latency seems bad in my plugin because :
        - using my plugin to send the stream in a file and after, reading this file, all is correct.

BR

Frederic


-----Message d'origine-----
De : gstreamer-devel [mailto:[hidden email]] De la part de Duchassin Frederic
Envoyé : vendredi 1 juin 2018 09:57
À : [hidden email]
Objet : RE: Plugin dev Timestamp

Hello all,

This is what i get on alsasink when I get hashed audio output :


latency=10137333
0:00:38.864469338  2338   0xb6ccc0 WARN           audiobasesink gstaudiobasesink.c:1803:gst_audio_base_sink_get_alignment:<alsasink0> Unexpected discontinuity in audio timestamps of +0:00:00.098895833, resyncing
latency=10610333
0:00:40.664616338  2338   0xb6ccc0 WARN           audiobasesink gstaudiobasesink.c:1803:gst_audio_base_sink_get_alignment:<alsasink0> Unexpected discontinuity in audio timestamps of +0:00:00.101041666, resyncing

Latency is the time between 2 packets at output of my element.
I hope it could be a clue.

Frederic






-----Message d'origine-----
De : gstreamer-devel [mailto:[hidden email]] De la part de Duchassin Frederic
Envoyé : jeudi 31 mai 2018 16:54
À : [hidden email]
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:[hidden email]] De la part de Tim Müller
Envoyé : jeudi 31 mai 2018 16:01
À : [hidden email]
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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel