AW: [External] Re: Restarted stream contains legacy frames

Timtchenko, Michael Michael.Timtchenko at agcocorp.com
Mon Sep 7 07:02:51 UTC 2020


Hi Nicolas,

thanks for your response.

unfortunately the states "null" and "ready" didn't solve the problem. I also tried to completely re-initialize the pipeline and faced very a strange behavior. When I unref my pipeline and do the re-init afterwards, I can see the old frames. But when I do not unref the pipeline but simply "override" my references, only the new frames are displayed (as desired).

I've attached my simplified source code below, maybe you see what's wrong. Case (1) shows the working code (even if it leaks) case (2) does not work.

void Streamer::init()
{
    auto pipeline = gst_pipeline_new( "pipeline" );
    auto src = gst_element_factory_make( "udpsrc", "source" );
    auto depay = gst_element_factory_make( "rtph264depay", "depay" );
    auto dec = gst_element_factory_make( "avdec_h264", "dec" );
    auto convert = gst_element_factory_make( "videoconvert", "convert" );
    auto upload = gst_element_factory_make( "glupload", "upload" );
    auto sink = gst_element_factory_make( "appsink", "sink" );

    gst_app_sink_set_drop( sink, true );
    gst_app_sink_set_max_buffers( sink, 1 );
    gst_app_sink_set_emit_signals( sink, true );

    GstAppSinkCallbacks callbacks = { nullptr, newPreroll, newSample, nullptr };
    gst_app_sink_set_callbacks( m_data->sink, &callbacks, this, nullptr );

    gst_bin_add_many( GST_BIN( pipeline), src, depay, dec, convert, upload, sink, NULL );

    if( !gst_element_link_many( src, depay, dec, convert, NULL ) ) { return nullptr; }

    GstCaps* caps =  gst_caps_from_string( "video/x-raw, format=BGR" );

    if( !gst_element_link_filtered( convert, upload, caps ) ) { return nullptr; }

    if( !gst_element_link( upload, sink ) { return nullptr; }

    // Do further config ...

    // Inject gl context

    m_pipeline = pipeline;

    gst_element_set_state( m_pipeline, GST_STATE_PLAYING );
}

void Streamer::restart()
{
// Working (1)
gst_element_set_state( m_pipeline, GST_STATE_NULL );
init();

// Not working (2)
gst_element_set_state( m_pipeline, GST_STATE_NULL );
gst_unref_object(m_pipeline);
init();
}

Is it sufficient to call gst_unref_object ( m_pipeline ) in order to completely free all sources, or is it necessary to unref  all elements added to the pipeline manually? I'm not completely sure about this point.

As you can see above, I'm using static names for the GstElements added to the pipeline. In the doc it says that if no name is given, a unique name is generated. Is the name used internally for any referencing or sth like that?

I really thought, that if I create a new pipeline no frames will be buffered at all.

Thanks in advance
Michael


-----Ursprüngliche Nachricht-----
Von: gstreamer-devel [mailto:gstreamer-devel-bounces at lists.freedesktop.org] Im Auftrag von Nicolas Dufresne
Gesendet: Freitag, 4. September 2020 23:42
An: Discussion of the development of and with GStreamer <gstreamer-devel at lists.freedesktop.org>
Betreff: [External] Re: Restarted stream contains legacy frames

Le vendredi 04 septembre 2020 à 10:18 +0000, Timtchenko, Michael a écrit :
> Hi gstreamers,
>
> i’m facing a little problem regarding the stopping/resuming of my
> camera stream with gstreamer. When I restart the stream by a
> transition from GST_STATE_PLAYING (1) -> GST_STATE_PAUSING (2)
> ->GST_STATE_ PLAYING (3), the stream contains the last frames from
> (1).
>
> Is there a proper way to clear the pipeline? I don’t want to see any
> old frames when I restart my stream.

Pause state is not often used for live pipelines, it will just block the rendering. Best is to cycle through NULL, or perhaps ready.

>
> I’ve also tried to send flushing events, but without success. I did
> this by sending the events gst_event_new_flush_start() and
> gst_event_new_flush_stop().
>
> My pipeline looks like this:
>
> udpsrc port=55555 caps=\"application/x-rtp, media=(string)video,
> clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96\"

It might be wise to use rtpjitterbuffer here.

> ! rtph264depay
> ! avdec_h264
> ! decodebin
> ! videoconvert
> ! glupload
> ! appsink
>
> Advice is welcome.
>
> BR
> Michael
>
>
> Bitte beachten / Please note!
>
> *********************************************************************
> **********
> AGCO GmbH
> Sitz der AGCO GmbH: Johann-Georg-Fendt-Str.4, 87616 Marktoberdorf,
> Germany Registergericht Amtsgericht Kempten HRB 10327
> Geschäftsführer: Christoph Groeblinghoff, Ingrid Bussjaeger-Martin,
> Dr. Heribert Reiter, Ekkehart Glaeser Vorsitzender des Aufsichtsrates:
> Torsten Dehner
>
> *********************************************************************
> **********
> Diese E-Mail ist nur für den Empfänger bestimmt, an den es gerichtet
> ist und kann vertrauliches bzw. unter das Berufsgeheimnis fallendes
> Material enthalten. Jegliche darin enthaltene Ansicht oder
> Meinungsäußerung ist die des Autors und stellt nicht notwendigerweise
> die Ansicht oder Meinung von AGCO dar. Sind Sie nicht der Empfänger,
> so haben Sie diese E-Mail irrtümlich erhalten und jegliche Verwendung,
> Veröffentlichung, Weiterleitung, Abschrift oder jeglicher Druck dieser
> E-Mail ist strengstens untersagt. Weder AGCO noch der Absender
> übernehmen die Haftung für Viren; es obliegt Ihrer Verantwortung, die
> E-Mail und deren angehängte Dateien (sofern vorhanden) auf Viren zu
> überprüfen.
>
> *********************************************************************
> **********
> This email is intended solely for the use of the individual to whom it
> is addressed and may contain confidential and/or privileged material.
> Any views or opinions presented are solely those of the author and do
> not necessarily represent those of AGCO. If you are not the intended
> recipient, be advised that you have received this email in error and
> that any use, dissemination, forwarding, printing or copying of this
> email is strictly prohibited. Neither AGCO nor the sender accepts any
> responsibility for viruses and it is your responsibility to scan and
> virus check the email and its
> attachment(s) (if any).
>
> *********************************************************************
> **********
>
> This email is intended solely for the use of the individual to whom it
> is addressed and may contain confidential and/or privileged material.
> Any views or opinions presented are solely those of the author and do
> not necessarily represent those of AGCO. If you are not the intended
> recipient, be advised that you have received this email in error and
> that any use, dissemination, forwarding, printing or copying of this
> email is strictly prohibited. Neither AGCO nor the sender accepts any
> responsibility for viruses and it is your responsibility to scan and
> virus check the e-mail and its
> attachment(s) (if any).
>
>
>
>
> _______________________________________________
> 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

This email is intended solely for the use of the individual to whom it is addressed and may contain confidential and/or privileged material. Any views or opinions presented are solely those of the author and do not necessarily represent those of AGCO. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing or copying of this email is strictly prohibited. Neither AGCO nor the sender accepts any responsibility for viruses and it is your responsibility to scan and virus check the e-mail and its attachment(s) (if any).

This email is intended solely for the use of the individual to whom it is addressed and may contain confidential and/or privileged material. Any views or opinions presented are solely those of the author and do not necessarily represent those of AGCO. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing or copying of this email is strictly prohibited. Neither AGCO nor the sender accepts any responsibility for viruses and it is your responsibility to scan and virus check the e-mail and its attachment(s) (if any).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20200907/4c170522/attachment-0001.htm>


More information about the gstreamer-devel mailing list