diff --git a/src/conference.cpp b/src/conference.cpp index 87d4303d08fac98327282aaf031d2db0b97535b3..b6d68128714942c14c3de33b988d26676b819f84 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -91,10 +91,9 @@ Conference::Conference(const std::shared_ptr<Account>& account) return attr.type_ == MediaType::MEDIA_VIDEO; }); // We are done if the video is disabled. - if (not videoEnabled_ || itVideo == hostSources_.end()) - return; - - videoMixer_ = std::make_shared<video::VideoMixer>(id_, itVideo->sourceUri_); + auto hasVideo = videoEnabled_ && itVideo != hostSources_.end(); + auto source = hasVideo ? itVideo->sourceUri_ : ""; + videoMixer_ = std::make_shared<video::VideoMixer>(id_, source, hasVideo); videoMixer_->setOnSourcesUpdated([this](std::vector<video::SourceInfo>&& infos) { runOnMainThread([w = weak(), infos = std::move(infos)] { auto shared = w.lock(); diff --git a/src/media/video/video_mixer.cpp b/src/media/video/video_mixer.cpp index 76f3b16583693ea81d07c6e37d1a570bd68f13dc..78f47c100545c6b43c8dd8a49ba39df444ee5203 100644 --- a/src/media/video/video_mixer.cpp +++ b/src/media/video/video_mixer.cpp @@ -81,14 +81,14 @@ private: static constexpr const auto MIXER_FRAMERATE = 30; static constexpr const auto FRAME_DURATION = std::chrono::duration<double>(1. / MIXER_FRAMERATE); -VideoMixer::VideoMixer(const std::string& id, const std::string& localInput) +VideoMixer::VideoMixer(const std::string& id, const std::string& localInput, bool attachHost) : VideoGenerator::VideoGenerator() , id_(id) , sink_(Manager::instance().createSinkClient(id, true)) , loop_([] { return true; }, std::bind(&VideoMixer::process, this), [] {}) { // Local video camera is the main participant - if (not localInput.empty()) { + if (not localInput.empty() && attachHost) { auto videoInput = getVideoInput(localInput); localInputs_.emplace_back(videoInput); attachVideo(videoInput.get(), @@ -300,7 +300,7 @@ VideoMixer::process() int i = 0; bool activeFound = false; bool needsUpdate = layoutUpdated_ > 0; - bool successfullyRendered = false; + bool successfullyRendered = audioOnlySources_.size() != 0 && sources_.size() == 0; std::vector<SourceInfo> sourcesInfo; sourcesInfo.reserve(sources_.size() + audioOnlySources_.size()); // add all audioonlysources diff --git a/src/media/video/video_mixer.h b/src/media/video/video_mixer.h index 9dcbce8be46ab02a9aee8d8fde449cc05c91d718..57e73713e7e857576b320dedb928b33a3f569738 100644 --- a/src/media/video/video_mixer.h +++ b/src/media/video/video_mixer.h @@ -37,7 +37,8 @@ namespace video { class SinkClient; -struct StreamInfo { +struct StreamInfo +{ std::string callId; std::string streamId; }; @@ -60,7 +61,7 @@ enum class Layout { GRID, ONE_BIG_WITH_SMALL, ONE_BIG }; class VideoMixer : public VideoGenerator, public VideoFramePassiveReader { public: - VideoMixer(const std::string& id, const std::string& localInput = {}); + VideoMixer(const std::string& id, const std::string& localInput = {}, bool attachHost = true); ~VideoMixer(); void setParameters(int width, int height, AVPixelFormat format = AV_PIX_FMT_YUV422P); @@ -93,10 +94,7 @@ public: updateLayout(); } - bool verifyActive(const std::string& id) - { - return activeStream_ == id; - } + bool verifyActive(const std::string& id) { return activeStream_ == id; } void setVideoLayout(Layout newLayout) { @@ -112,7 +110,8 @@ public: MediaStream getStream(const std::string& name) const; - std::shared_ptr<VideoFrameActiveWriter> getVideoLocal() const { + std::shared_ptr<VideoFrameActiveWriter> getVideoLocal() const + { if (!localInputs_.empty()) return *localInputs_.begin(); return {}; @@ -139,7 +138,9 @@ public: } } - void attachVideo(Observable<std::shared_ptr<MediaFrame>>* frame, const std::string& callId, const std::string& streamId); + void attachVideo(Observable<std::shared_ptr<MediaFrame>>* frame, + const std::string& callId, + const std::string& streamId); void detachVideo(Observable<std::shared_ptr<MediaFrame>>* frame); StreamInfo streamInfo(Observable<std::shared_ptr<MediaFrame>>* frame) const