Skip to content
Snippets Groups Projects
Commit 6419cde6 authored by Adrien Béraud's avatar Adrien Béraud Committed by Guillaume Roguez
Browse files

video sender: don't block for device params


Refs #67741

Change-Id: I985d07c4e1c913f7bcff6c6eeb029a673047ee43
Signed-off-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 45c2dcb3
No related branches found
No related tags found
No related merge requests found
......@@ -275,9 +275,12 @@ VideoInput::initFile(std::string path)
return true;
}
std::future<DeviceParams>
std::shared_future<DeviceParams>
VideoInput::switchInput(const std::string& resource)
{
if (resource == currentResource_)
return futureDecOpts_;
RING_DBG("MRL: '%s'", resource.c_str());
if (switchPending_) {
......@@ -285,6 +288,8 @@ VideoInput::switchInput(const std::string& resource)
return {};
}
currentResource_ = resource;
std::promise<DeviceParams> p;
foundDecOpts_.swap(p);
......@@ -294,7 +299,8 @@ VideoInput::switchInput(const std::string& resource)
switchPending_ = true;
if (!loop_.isRunning())
loop_.start();
return foundDecOpts_.get_future();
futureDecOpts_ = foundDecOpts_.get_future();
return futureDecOpts_;
}
// Supported MRL schemes
......@@ -323,16 +329,17 @@ VideoInput::switchInput(const std::string& resource)
valid = initFile(suffix);
}
/* Unsupported MRL or failed initialization */
if (valid) {
// Unsupported MRL or failed initialization
if (not valid) {
RING_ERR("Failed to init input for MRL '%s'\n", resource.c_str());
return {};
}
switchPending_ = true;
if (!loop_.isRunning())
loop_.start();
}
else
RING_ERR("Failed to init input for MRL '%s'\n", resource.c_str());
return valid ? foundDecOpts_.get_future() : std::future<DeviceParams> {};
futureDecOpts_ = foundDecOpts_.get_future().share();
return futureDecOpts_;
}
int VideoInput::getWidth() const
......
......@@ -63,17 +63,20 @@ public:
int getPixelFormat() const;
DeviceParams getParams() const;
std::future<DeviceParams> switchInput(const std::string& resource);
std::shared_future<DeviceParams> switchInput(const std::string& resource);
private:
NON_COPYABLE(VideoInput);
std::string currentResource_;
MediaDecoder *decoder_ = nullptr;
std::shared_ptr<SinkClient> sink_;
std::atomic<bool> switchPending_ = {false};
DeviceParams decOpts_;
std::promise<DeviceParams> foundDecOpts_;
std::shared_future<DeviceParams> futureDecOpts_;
bool emulateRate_ = false;
ThreadLoop loop_;
......
......@@ -49,6 +49,8 @@ namespace ring { namespace video {
using std::map;
using std::string;
constexpr static auto NEWPARAMS_TIMEOUT = std::chrono::milliseconds(1000);
VideoRtpSession::VideoRtpSession(const string &callID,
const DeviceParams& localVideoParams) :
RtpSession(callID), localVideoParams_(localVideoParams)
......@@ -68,12 +70,12 @@ void VideoRtpSession::startSender()
RING_WARN("Restarting video sender");
}
std::future<DeviceParams> newParams;
if (not conference_) {
videoLocal_ = getVideoCamera();
if (auto input = videoManager.videoInput.lock()) {
newParams = input->switchInput(input_);
if (newParams.valid())
auto newParams = input->switchInput(input_);
if (newParams.valid() &&
newParams.wait_for(NEWPARAMS_TIMEOUT) == std::future_status::ready)
localVideoParams_ = newParams.get();
else
RING_WARN("No valid new video parameters.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment