Commit 19a3a788 authored by Guillaume Roguez's avatar Guillaume Roguez

#30251: video: safer VideoReceiveThread sink start/stop

parent 3b080df9
...@@ -57,7 +57,7 @@ VideoReceiveThread::VideoReceiveThread(const std::string& id, ...@@ -57,7 +57,7 @@ VideoReceiveThread::VideoReceiveThread(const std::string& id,
, stream_(args_["receiving_sdp"]) , stream_(args_["receiving_sdp"])
, sdpContext_(SDP_BUFFER_SIZE, false, &readFunction, 0, 0, this) , sdpContext_(SDP_BUFFER_SIZE, false, &readFunction, 0, 0, this)
, demuxContext_() , demuxContext_()
, sink_() , sink_(id+"_RX")
, requestKeyFrameCallback_(0) , requestKeyFrameCallback_(0)
{} {}
...@@ -139,6 +139,8 @@ bool VideoReceiveThread::setup() ...@@ -139,6 +139,8 @@ bool VideoReceiveThread::setup()
dstHeight_ = videoDecoder_->getHeight(); dstHeight_ = videoDecoder_->getHeight();
} }
EXIT_IF_FAIL(sink_.start(), "RX: sink startup failed");
auto conf = Manager::instance().getConferenceFromCallID(id_); auto conf = Manager::instance().getConferenceFromCallID(id_);
if (!conf) if (!conf)
exitConference(); exitConference();
...@@ -153,13 +155,13 @@ void VideoReceiveThread::cleanup() ...@@ -153,13 +155,13 @@ void VideoReceiveThread::cleanup()
{ {
if (detach(&sink_)) if (detach(&sink_))
Manager::instance().getVideoControls()->stoppedDecoding(id_+"RX", sink_.openedName()); Manager::instance().getVideoControls()->stoppedDecoding(id_+"RX", sink_.openedName());
sink_.stop();
if (videoDecoder_) if (videoDecoder_)
delete videoDecoder_; delete videoDecoder_;
if (demuxContext_) if (demuxContext_)
delete demuxContext_; delete demuxContext_;
} }
// This callback is used by libav internally to break out of blocking calls // This callback is used by libav internally to break out of blocking calls
...@@ -226,7 +228,7 @@ void VideoReceiveThread::enterConference() ...@@ -226,7 +228,7 @@ void VideoReceiveThread::enterConference()
if (detach(&sink_)) { if (detach(&sink_)) {
Manager::instance().getVideoControls()->stoppedDecoding(id_+"RX", sink_.openedName()); Manager::instance().getVideoControls()->stoppedDecoding(id_+"RX", sink_.openedName());
sink_.stop(); DEBUG("RX: shm sink <%s> detached", sink_.openedName().c_str());
} }
} }
...@@ -235,8 +237,7 @@ void VideoReceiveThread::exitConference() ...@@ -235,8 +237,7 @@ void VideoReceiveThread::exitConference()
if (!isRunning()) if (!isRunning())
return; return;
if (sink_.openedName().empty()) { if (dstWidth_ > 0 && dstHeight_ > 0) {
EXIT_IF_FAIL(sink_.start(), "RX: sink startup failed");
if (attach(&sink_)) { if (attach(&sink_)) {
Manager::instance().getVideoControls()->startedDecoding(id_+"RX", sink_.openedName(), dstWidth_, dstHeight_); Manager::instance().getVideoControls()->startedDecoding(id_+"RX", sink_.openedName(), dstWidth_, dstHeight_);
DEBUG("RX: shm sink <%s> started: size = %dx%d", DEBUG("RX: shm sink <%s> started: size = %dx%d",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment