Resuming rtsp stream on receiving EOS signal on message bus using re-connection timer

enthusiastic geek enthusiasticgeek at gmail.com
Thu Feb 7 07:22:20 PST 2013


Hi Federico,
                 Thanks a lot for your reply. I got it to work! Here are the
few changes that I did to the code.

// This function is used to receive asynchronous messages in the main loop.
bool VideoBroadcast::on_bus_message(const Glib::RefPtr<Gst::Bus>& bus,
                                    const Glib::RefPtr<Gst::Message>&
message,
                                    Glib::RefPtr<Glib::MainLoop> mainloop,
                                    uint32_t index)
{
    switch (message->get_message_type()) {
    case Gst::MESSAGE_EOS:
    {
        std::cout << std::endl << "End of stream" << std::endl;
        this->setStreamStatus(index, false); // Set the stream status to
inactive
        this->stopStream(index);
        //mainloop->quit(); //Don't Quit Main Loop yet. Move this to clean
up routine.
        return false;
    }
    case Gst::MESSAGE_ERROR:
    {
        Glib::RefPtr<Gst::MessageError> msgError =
            Glib::RefPtr<Gst::MessageError>::cast_dynamic(message);

        if (msgError)
        {
            Glib::Error err;
            err = msgError->parse();
            std::cerr << "Error: " << err.what() << std::endl;
        } else {
            std::cerr << "Error." << std::endl;
        }
        this->setStreamStatus(index, false); // Set the stream status to
inactive
        this->stopStream(index);
        //mainloop->quit(); //mainloop->quit(); //Don't Quit Main Loop yet.
Move this to clean up routine.
        return false;
    }
    default:
        break;
    }

    return true;
}


As you can see I am not quitting the main loop


bool timeoutCallback(VideoBroadcast* test)
{
    std::cout << "Checking for the stream connection ..." << std::endl;
    for (uint32_t index = 0; index < TOTAL_STREAMS; index++)
    {
        std::cout << "Stream " << index << " is "<<
(test->getStreamStatus(index)? "active": "inactive") << std::endl;
        if (test->getStreamStatus(index)==false)
        {
            test->initializeStreamData(index); // No need to create mainloop
in this method again.
                                                            // Mainloop is
created in the constructor
            if (test->getState(index) == Gst::STATE_PLAYING)
            {
                test->setStreamStatus(index, true);
            }
        }
    }
    return true;
}


Since I didn't quit the mainloop, there was no need to recreate it, but I
had to reinitialize the pipeline with bins since I am using the following
API. Not sure if it has to do anything with it.

app->pipeline_[index] = Glib::RefPtr<Gst::Pipeline>::cast_dynamic(
Gst::Parse::launch(app->launch_string_[index]) );


I avoided reinitializing bins and waited for 5 minutes or so and the
pipeline wouldn't come up. That is when I decided to reinitialize (barring
creating the loop since I never quit it) and test the behavior.



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Resuming-rtsp-stream-on-receiving-EOS-signal-on-message-bus-using-re-connection-timer-tp4658402p4658418.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list