Skip to content
Snippets Groups Projects
Commit 44edd0c5 authored by Adrien Béraud's avatar Adrien Béraud Committed by Adrien Béraud
Browse files

video_mixer: cleanup

Change-Id: I480edbe0fb14f4b4758a681fb789cb30385d4982
parent 912aa59a
No related branches found
No related tags found
No related merge requests found
......@@ -114,27 +114,29 @@ VideoMixer::switchInputs(const std::vector<std::string>& inputs)
// But only detach it to get new index
std::lock_guard lk(localInputsMtx_);
decltype(localInputs_) newInputs;
for (auto i = 0u; i != inputs.size(); ++i) {
auto videoInput = getVideoInput(inputs[i]);
newInputs.reserve(inputs.size());
for (const auto& input : inputs) {
auto videoInput = getVideoInput(input);
// Note, video can be a previously stopped device (eg. restart a screen sharing)
// in this case, the videoInput will be found and must be restarted
videoInput->restart();
auto onlyDetach = false;
auto it = std::find(localInputs_.cbegin(), localInputs_.cend(), videoInput);
onlyDetach = it != localInputs_.cend();
newInputs.emplace_back(videoInput);
auto onlyDetach = it != localInputs_.cend();
if (onlyDetach) {
videoInput->detach(this);
localInputs_.erase(it);
}
newInputs.emplace_back(std::move(videoInput));
}
// Stop other video inputs
stopInputs();
localInputs_ = std::move(newInputs);
// Re-attach videoInput to mixer
for (auto i = 0u; i != localInputs_.size(); ++i)
attachVideo(localInputs_[i].get(), "", sip_utils::streamId("", fmt::format("video_{}", i)));
for (size_t i = 0; i < localInputs_.size(); ++i) {
auto& input = localInputs_[i];
attachVideo(input.get(), "", sip_utils::streamId("", fmt::format("video_{}", i)));
}
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment