Commit 247e95be authored by Adrien Béraud's avatar Adrien Béraud Committed by Guillaume Roguez

video_input: don't satisfy the decOpts promise twice

Refs #69347

Change-Id: Ibf7c6c7693688f654393c11f16ab550f8db2daf3
Signed-off-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent bb756ae8
......@@ -154,7 +154,7 @@ void
VideoInput::createDecoder()
{
if (decOpts_.input.empty()) {
foundDecOpts_.set_value(decOpts_);
foundDecOpts(decOpts_);
return;
}
......@@ -170,7 +170,7 @@ VideoInput::createDecoder()
delete decoder_;
decoder_ = nullptr;
//foundDecOpts_.set_exception(std::runtime_error("Could not open input"));
foundDecOpts_.set_value(decOpts_);
foundDecOpts(decOpts_);
return;
}
......@@ -180,12 +180,12 @@ VideoInput::createDecoder()
delete decoder_;
decoder_ = nullptr;
//foundDecOpts_.set_exception(std::runtime_error("Could not read data"));
foundDecOpts_.set_value(decOpts_);
foundDecOpts(decOpts_);
return;
}
decOpts_.width = decoder_->getWidth();
decOpts_.height = decoder_->getHeight();
foundDecOpts_.set_value(decOpts_);
foundDecOpts(decOpts_);
}
void
......@@ -288,6 +288,7 @@ VideoInput::switchInput(const std::string& resource)
}
currentResource_ = resource;
decOptsFound_ = false;
std::promise<DeviceParams> p;
foundDecOpts_.swap(p);
......@@ -353,4 +354,13 @@ int VideoInput::getPixelFormat() const
DeviceParams VideoInput::getParams() const
{ return decOpts_; }
void
VideoInput::foundDecOpts(const DeviceParams& params)
{
if (not decOptsFound_) {
decOptsFound_ = true;
foundDecOpts_.set_value(params);
}
}
}} // namespace ring::video
......@@ -78,6 +78,9 @@ private:
std::promise<DeviceParams> foundDecOpts_;
std::shared_future<DeviceParams> futureDecOpts_;
std::atomic_bool decOptsFound_ {false};
void foundDecOpts(const DeviceParams& params);
bool emulateRate_ = false;
ThreadLoop loop_;
......
......@@ -74,11 +74,16 @@ void VideoRtpSession::startSender()
videoLocal_ = getVideoCamera();
if (auto input = videoManager.videoInput.lock()) {
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.");
try {
if (newParams.valid() &&
newParams.wait_for(NEWPARAMS_TIMEOUT) == std::future_status::ready)
localVideoParams_ = newParams.get();
else
RING_ERR("No valid new video parameters.");
} catch (const std::exception& e) {
RING_ERR("Exception during retriving video parameters: %s",
e.what());
}
} else {
RING_WARN("Can't lock video input");
}
......
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