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

enthusiastic geek enthusiasticgeek at gmail.com
Wed Feb 6 10:10:25 PST 2013


I am trying to resume rtsp stream using EOS in bus message event handler and
a re connection timer. I close the stream src deliberately for testing. Then
I resume the stream. During reconnection attempt despite stream being active
I get the following message "Error: Could not read from resource.". My code
snippet looks as follows:
 
Message bus event handler

// This function is used to receive asynchronous messages in the main loop.
bool Video::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->pauseStream(index);
        //this->stopStream(index);
        //mainloop->quit();
		return true;
        //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->pauseStream(index);
        //this->stopStream(index);
        //mainloop->quit();
        return true;
        //return false;
    }
    default:
        break;
    }

    return true;
}


And my re-connection timer callback function looks like

bool timeoutCallback(Video* test)
{
  
  
    std::cout << "Checking for the stream connection ..." << std::endl;
    for (uint32_t stream_count = 0; stream_count < TOTAL_STREAMS;
stream_count++)
    {
        std::cout << "Stream " << stream_count << " is "<<
(test->getStreamStatus(stream_count)? "active": "inactive") << std::endl;

        if (test->getStreamStatus(stream_count)==false)
        {
			test->playStream(stream_count);        
        }
        
    }

    return true;
}


And my helper functions look as follows

void Video::startStream(uint32_t index)
{
    app->loop_[index]->run();
}

void Video::stopStream(uint32_t index)
{
    this->pauseStream(index);
	if(this->getState(index) != Gst::STATE_NULL){
    	app->pipeline_[index]->set_state(Gst::STATE_NULL);
	}
}

void Video::pauseStream(uint32_t index)
{
	if(this->getState(index) != Gst::STATE_PAUSED){
    	app->pipeline_[index]->set_state(Gst::STATE_PAUSED);
	}
	if(this->getState(index) != Gst::STATE_READY){
    	app->pipeline_[index]->set_state(Gst::STATE_READY);
	}
}

void Video::resumeStream(uint32_t index)
{
	if(this->getState(index) != Gst::STATE_READY){
    	app->pipeline_[index]->set_state(Gst::STATE_READY);
	}
	if(this->getState(index) != Gst::STATE_PAUSED){
    	app->pipeline_[index]->set_state(Gst::STATE_PAUSED);
	}
}

void Video::playStream(uint32_t index)
{
    this->resumeStream(index);
	if(this->getState(index) != Gst::STATE_PLAYING){
    	app->pipeline_[index]->set_state(Gst::STATE_PLAYING);
	}
}




--
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-tp4658402.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list