Skip to content
Snippets Groups Projects
Commit 0f2e1666 authored by Philippe Gorley's avatar Philippe Gorley
Browse files

video: restart media receiver on manual quality

Fixes an issue where falling back to software decoding fails
if quality is not set to auto (no video).

Change-Id: I502558f82cbabdf90990cd9177a36674fb3df4d1
Tuleap: #1088
parent 8afce906
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,9 @@ VideoRtpSession::VideoRtpSession(const string &callID, ...@@ -55,6 +55,9 @@ VideoRtpSession::VideoRtpSession(const string &callID,
, rtcpCheckerThread_(std::bind(&VideoRtpSession::setupRtcpChecker, this), , rtcpCheckerThread_(std::bind(&VideoRtpSession::setupRtcpChecker, this),
std::bind(&VideoRtpSession::processRtcpChecker, this), std::bind(&VideoRtpSession::processRtcpChecker, this),
std::bind(&VideoRtpSession::cleanupRtcpChecker, this)) std::bind(&VideoRtpSession::cleanupRtcpChecker, this))
, receiverRestartThread_([]{ return true; },
[this]{ processReceiverRestart(); },
[]{})
{} {}
VideoRtpSession::~VideoRtpSession() VideoRtpSession::~VideoRtpSession()
...@@ -141,10 +144,12 @@ void VideoRtpSession::startReceiver() ...@@ -141,10 +144,12 @@ void VideoRtpSession::startReceiver()
* we decided so to disable them for the moment * we decided so to disable them for the moment
receiveThread_->setRequestKeyFrameCallback(&SIPVoIPLink::enqueueKeyframeRequest); receiveThread_->setRequestKeyFrameCallback(&SIPVoIPLink::enqueueKeyframeRequest);
*/ */
receiverRestartThread_.start();
receiveThread_->addIOContext(*socketPair_); receiveThread_->addIOContext(*socketPair_);
receiveThread_->startLoop(); receiveThread_->startLoop();
} else { } else {
RING_DBG("Video receiving disabled"); RING_DBG("Video receiving disabled");
receiverRestartThread_.join();
if (receiveThread_) if (receiveThread_)
receiveThread_->detach(videoMixer_.get()); receiveThread_->detach(videoMixer_.get());
receiveThread_.reset(); receiveThread_.reset();
...@@ -200,6 +205,7 @@ void VideoRtpSession::stop() ...@@ -200,6 +205,7 @@ void VideoRtpSession::stop()
{ {
std::lock_guard<std::recursive_mutex> lock(mutex_); std::lock_guard<std::recursive_mutex> lock(mutex_);
rtcpCheckerThread_.join(); rtcpCheckerThread_.join();
receiverRestartThread_.join();
if (videoLocal_) if (videoLocal_)
videoLocal_->detach(sender_.get()); videoLocal_->detach(sender_.get());
...@@ -558,7 +564,6 @@ VideoRtpSession::checkReceiver() ...@@ -558,7 +564,6 @@ VideoRtpSession::checkReceiver()
void void
VideoRtpSession::processRtcpChecker() VideoRtpSession::processRtcpChecker()
{ {
checkReceiver();
adaptQualityAndBitrate(); adaptQualityAndBitrate();
rtcpCheckerThread_.wait_for(std::chrono::seconds(RTCP_CHECKING_INTERVAL)); rtcpCheckerThread_.wait_for(std::chrono::seconds(RTCP_CHECKING_INTERVAL));
} }
...@@ -567,4 +572,11 @@ void ...@@ -567,4 +572,11 @@ void
VideoRtpSession::cleanupRtcpChecker() VideoRtpSession::cleanupRtcpChecker()
{} {}
void
VideoRtpSession::processReceiverRestart()
{
checkReceiver();
receiverRestartThread_.wait_for(std::chrono::seconds(RECEIVER_RESTART_INTERVAL));
}
}} // namespace ring::video }} // namespace ring::video
...@@ -118,6 +118,8 @@ private: ...@@ -118,6 +118,8 @@ private:
// max size of quality and bitrate historic // max size of quality and bitrate historic
static constexpr unsigned MAX_SIZE_HISTO_QUALITY_ {30}; static constexpr unsigned MAX_SIZE_HISTO_QUALITY_ {30};
static constexpr unsigned MAX_SIZE_HISTO_BITRATE_ {100}; static constexpr unsigned MAX_SIZE_HISTO_BITRATE_ {100};
// how long (in seconds) to wait before rechecking if the receiver needs to restart
const unsigned RECEIVER_RESTART_INTERVAL {4};
// 5 tries in a row // 5 tries in a row
static constexpr unsigned MAX_ADAPTATIVE_BITRATE_ITERATION {5}; static constexpr unsigned MAX_ADAPTATIVE_BITRATE_ITERATION {5};
...@@ -129,6 +131,9 @@ private: ...@@ -129,6 +131,9 @@ private:
bool setupRtcpChecker(); bool setupRtcpChecker();
void processRtcpChecker(); void processRtcpChecker();
void cleanupRtcpChecker(); void cleanupRtcpChecker();
InterruptedThreadLoop receiverRestartThread_;
void processReceiverRestart();
}; };
}} // namespace ring::video }} // namespace ring::video
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment