diff --git a/src/call.cpp b/src/call.cpp index a151c0bff9c567922795add5a10992b65c442736..f2826f141ea87adf44bb4d2bfd431ef616c881be 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -692,8 +692,6 @@ Call::setConferenceInfo(const std::string& msg) if (confID_.empty()) { // confID_ empty -> participant set confInfo with the received one confInfo_ = std::move(newInfo); - // Create sink for each participant - createSinks(confInfo_); // Inform client that layout has changed jami::emitSignal<DRing::CallSignal::OnConferenceInfosUpdated>( id_, confInfo_.toVectorMapStringString()); diff --git a/src/call.h b/src/call.h index 972860cd69d401fa99a09087754888125ad77e59..890a146e139551cfed21ebca55ee5986aa542969 100644 --- a/src/call.h +++ b/src/call.h @@ -386,7 +386,6 @@ public: // media management virtual void exitConference() = 0; virtual std::shared_ptr<Observable<std::shared_ptr<MediaFrame>>> getReceiveVideoFrameActiveWriter() = 0; - virtual void createSinks(const ConfInfo& infos) = 0; std::vector<std::map<std::string, std::string>> getConferenceInfos() const { diff --git a/src/conference.cpp b/src/conference.cpp index 1fd0a86039a9b07dab6969e2495c57a1eab049b9..ca82808611da08b5e30cb826ff97394d3a4abe24 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -71,7 +71,6 @@ Conference::Conference() // Handle participants showing their video std::unique_lock<std::mutex> lk(shared->videoToCallMtx_); for (const auto& info : infos) { - auto deviceId = ""; std::string uri = ""; auto it = shared->videoToCall_.find(info.source); if (it == shared->videoToCall_.end()) @@ -100,10 +99,8 @@ Conference::Conference() isLocalMuted = shared->isMediaSourceMuted(MediaType::MEDIA_AUDIO); } auto isModeratorMuted = shared->isMuted(peerID); - auto sinkId = shared->getConfID() + peerID + deviceId; newInfo.emplace_back(ParticipantInfo {std::move(uri), - std::move(deviceId), - std::move(sinkId), + "", active, info.x, info.y, @@ -121,29 +118,17 @@ Conference::Conference() lk.unlock(); // Handle participants not present in the video mixer for (const auto& subCall : subCalls) { - auto deviceId = ""; std::string uri = ""; if (auto call = getCall(subCall)) uri = call->getPeerNumber(); auto isModerator = shared->isModerator(uri); - auto sinkId = shared->getConfID() + string_remove_suffix(uri, '@') + deviceId; - newInfo.emplace_back(ParticipantInfo {std::move(uri), - std::move(deviceId), - std::move(sinkId), - false, - 0, - 0, - 0, - 0, - true, - false, - false, - isModerator}); + newInfo.emplace_back(ParticipantInfo { + std::move(uri), "", false, 0, 0, 0, 0, true, false, false, isModerator}); } // Add host in confInfo with audio and video muted if detached if (shared->getState() == State::ACTIVE_DETACHED) newInfo.emplace_back( - ParticipantInfo {"", "", "", false, 0, 0, 0, 0, true, true, false, true}); + ParticipantInfo {"", "", false, 0, 0, 0, 0, true, true, false, true}); shared->updateConferenceInfo(std::move(newInfo)); }); @@ -181,12 +166,6 @@ Conference::~Conference() call->peerRecording(true); } } - for (auto it = confSinksMap_.begin(); it != confSinksMap_.end();) { - if (videoMixer_) - videoMixer_->detach(it->second.get()); - it->second->stop(); - it = confSinksMap_.erase(it); - } #endif // ENABLE_VIDEO #ifdef ENABLE_PLUGIN { @@ -532,28 +511,10 @@ Conference::sendConferenceInfos() } } - auto confInfo = getConfInfoHostUri("", ""); - createSinks(confInfo); - // Inform client that layout has changed jami::emitSignal<DRing::CallSignal::OnConferenceInfosUpdated>(id_, - confInfo.toVectorMapStringString()); -} - -void -Conference::createSinks(const ConfInfo& infos) -{ -#ifdef ENABLE_VIDEO - std::lock_guard<std::mutex> lk(sinksMtx_); - if (!videoMixer_) - return; - - Manager::instance().createSinkClients(getConfID(), - infos, - std::static_pointer_cast<video::VideoGenerator>( - videoMixer_), - confSinksMap_); -#endif + getConfInfoHostUri("", "") + .toVectorMapStringString()); } void diff --git a/src/conference.h b/src/conference.h index ce631b4df04a9504e3ea21ad28190924ffb97242..8fcb915d7e471dd5dd103628cf7ecb383663b42b 100644 --- a/src/conference.h +++ b/src/conference.h @@ -42,10 +42,6 @@ #include "plugin/streamdata.h" #endif -#ifdef ENABLE_VIDEO -#include <video/sinkclient.h> -#endif - namespace jami { class Call; @@ -60,7 +56,6 @@ struct ParticipantInfo { std::string uri; std::string device; - std::string sinkId; bool active {false}; int x {0}; int y {0}; @@ -75,7 +70,6 @@ struct ParticipantInfo { uri = v["uri"].asString(); device = v["device"].asString(); - sinkId = v["sinkId"].asString(); active = v["active"].asBool(); x = v["x"].asInt(); y = v["y"].asInt(); @@ -92,7 +86,6 @@ struct ParticipantInfo Json::Value val; val["uri"] = uri; val["device"] = device; - val["sinkId"] = sinkId; val["active"] = active; val["x"] = x; val["y"] = y; @@ -109,7 +102,6 @@ struct ParticipantInfo { return {{"uri", uri}, {"device", device}, - {"sinkId", sinkId}, {"active", active ? "true" : "false"}, {"x", std::to_string(x)}, {"y", std::to_string(y)}, @@ -123,10 +115,9 @@ struct ParticipantInfo friend bool operator==(const ParticipantInfo& p1, const ParticipantInfo& p2) { - return p1.uri == p2.uri and p1.device == p2.device and p1.sinkId == p2.sinkId - and p1.active == p2.active and p1.x == p2.x and p1.y == p2.y and p1.w == p2.w - and p1.h == p2.h and p1.videoMuted == p2.videoMuted - and p1.audioLocalMuted == p2.audioLocalMuted + return p1.uri == p2.uri and p1.device == p2.device and p1.active == p2.active + and p1.x == p2.x and p1.y == p2.y and p1.w == p2.w and p1.h == p2.h + and p1.videoMuted == p2.videoMuted and p1.audioLocalMuted == p2.audioLocalMuted and p1.audioModeratorMuted == p2.audioModeratorMuted and p1.isModerator == p2.isModerator; } @@ -321,7 +312,7 @@ public: } void updateConferenceInfo(ConfInfo confInfo); - void createSinks(const ConfInfo& infos); + void setModerator(const std::string& uri, const bool& state); void muteParticipant(const std::string& uri, const bool& state); void hangupParticipant(const std::string& participant_id); @@ -357,7 +348,6 @@ private: std::string mediaInput_ {}; std::string mediaSecondaryInput_ {}; std::shared_ptr<video::VideoMixer> videoMixer_; - std::map<std::string, std::shared_ptr<video::SinkClient>> confSinksMap_ {}; #endif std::shared_ptr<jami::AudioInput> audioMixer_; @@ -394,8 +384,6 @@ private: std::string_view findHostforRemoteParticipant(std::string_view uri); std::shared_ptr<Call> getCallFromPeerID(std::string_view peerID); - std::mutex sinksMtx_ {}; - #ifdef ENABLE_PLUGIN /** * Call Streams and some typedefs diff --git a/src/manager.cpp b/src/manager.cpp index 4ff465a891d75dda7e013d0c86194d65b5c74cd9..c5fc12dbc34ce51f2a166077afa2e5a615582cf2 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -86,7 +86,6 @@ using random_device = dht::crypto::random_device; #include "libav_utils.h" #include "video/sinkclient.h" -#include "video/video_base.h" #include "media/video/video_mixer.h" #include "audio/tonecontrol.h" @@ -3396,59 +3395,6 @@ Manager::createSinkClient(const std::string& id, bool mixer) return sink; } -void -Manager::createSinkClients(const std::string& callId, - const ConfInfo& infos, - const std::shared_ptr<video::VideoGenerator>& videoStream, - std::map<std::string, std::shared_ptr<video::SinkClient>>& sinksMap) -{ - std::set<std::string> sinkIdsList {}; - - // create video sinks - for (const auto& participant : infos) { - std::string sinkId = participant.sinkId; - if (sinkId.empty()) { - sinkId = callId; - sinkId += string_remove_suffix(participant.uri, '@') + participant.device; - } - if (participant.w && participant.h) { - auto currentSink = getSinkClient(sinkId); - if (currentSink) { - videoStream->detach(currentSink.get()); - currentSink->stop(); - currentSink->start(); - currentSink->setFramePosition(participant.x, participant.y); - currentSink->setFrameSize(participant.w, participant.h); - videoStream->attach(currentSink.get()); - sinkIdsList.emplace(sinkId); - continue; - } - auto newSink = createSinkClient(sinkId); - newSink->start(); - newSink->setFramePosition(participant.x, participant.y); - newSink->setFrameSize(participant.w, participant.h); - - videoStream->attach(newSink.get()); - - sinksMap.emplace(sinkId, newSink); - sinkIdsList.emplace(sinkId); - } else { - sinkIdsList.erase(sinkId); - } - } - - // remove any non used video sink - for (auto it = sinksMap.begin(); it != sinksMap.end();) { - if (sinkIdsList.find(it->first) == sinkIdsList.end()) { - videoStream->detach(it->second.get()); - it->second->stop(); - it = sinksMap.erase(it); - } else { - it++; - } - } -} - std::shared_ptr<video::SinkClient> Manager::getSinkClient(const std::string& id) { diff --git a/src/manager.h b/src/manager.h index b7b9b14e50ee4d0be25d674f421a32754c4d56b4..3fb56f22b0fa138037bc300a33b3c002472602ff 100644 --- a/src/manager.h +++ b/src/manager.h @@ -54,7 +54,6 @@ class io_context; namespace jami { namespace video { class SinkClient; -class VideoGenerator; } class ChannelSocket; class RingBufferPool; @@ -981,19 +980,6 @@ public: std::shared_ptr<video::SinkClient> createSinkClient(const std::string& id = "", bool mixer = false); - /** - * Create a SinkClient instance for each participant in a conference, store it in an internal - * cache as a weak_ptr and populates sinksMap with sink ids and shared_ptrs. - * @param callId - * @param infos ConferenceInfos that will create the sinks - * @param videoStream the the VideoGenerator to with the sinks should be attached - * @param sinksMap A map between sink ids and the respective shared pointer. - */ - void createSinkClients(const std::string& callId, - const ConfInfo& infos, - const std::shared_ptr<video::VideoGenerator>& videoStream, - std::map<std::string, std::shared_ptr<video::SinkClient>>& sinksMap); - /** * Return an existing SinkClient instance as a shared_ptr associated to the given identifier. * Return an empty shared_ptr (nullptr) if nothing found. diff --git a/src/media/video/sinkclient.cpp b/src/media/video/sinkclient.cpp index 75ed7bc925238b0e7cea187b1b349c9968a1695e..5249d94f9bb5a7b09162658736e5c6de39fd573b 100644 --- a/src/media/video/sinkclient.cpp +++ b/src/media/video/sinkclient.cpp @@ -286,7 +286,6 @@ bool SinkClient::stop() noexcept { setFrameSize(0, 0); - setFramePosition(0, 0); shm_.reset(); return true; } @@ -309,7 +308,6 @@ bool SinkClient::stop() noexcept { setFrameSize(0, 0); - setFramePosition(0, 0); return true; } @@ -345,16 +343,6 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/, if (avTarget_.push) { auto outFrame = std::make_unique<VideoFrame>(); outFrame->copyFrom(*std::static_pointer_cast<VideoFrame>(frame_p)); - if (height_ != outFrame->pointer()->height) { - outFrame->pointer()->crop_top = y_; - outFrame->pointer()->crop_bottom = outFrame->pointer()->height - y_ - height_; - } - if (width_ != outFrame->pointer()->width) { - outFrame->pointer()->crop_left = x_; - outFrame->pointer()->crop_right = outFrame->pointer()->width - x_ - width_; - } - av_frame_apply_cropping(outFrame->pointer(), AV_FRAME_CROP_UNALIGNED); - avTarget_.push(std::move(outFrame)); } @@ -364,7 +352,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/, #endif if (doTransfer) { - std::shared_ptr<VideoFrame> frame = std::make_shared<VideoFrame>(); + std::shared_ptr<VideoFrame> frame; #ifdef RING_ACCEL auto desc = av_pix_fmt_desc_get( (AVPixelFormat)(std::static_pointer_cast<VideoFrame>(frame_p))->format()); @@ -377,28 +365,17 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/, JAMI_ERR("Accel failure: %s", e.what()); return; } - } else -#endif - frame->copyFrom(*std::static_pointer_cast<VideoFrame>(frame_p)); - - if (height_ != frame->pointer()->height) { - frame->pointer()->crop_top = y_; - frame->pointer()->crop_bottom = frame->pointer()->height - y_ - height_; - } - if (width_ != frame->pointer()->width) { - frame->pointer()->crop_left = x_; - frame->pointer()->crop_right = frame->pointer()->width - x_ - width_; } - - av_frame_apply_cropping(frame->pointer(), AV_FRAME_CROP_UNALIGNED); - + else +#endif + frame = std::static_pointer_cast<VideoFrame>(frame_p); int angle = frame->getOrientation(); if (angle != rotation_) { filter_ = getTransposeFilter(angle, FILTER_INPUT_NAME, frame->width(), frame->height(), - frame->format(), + AV_PIX_FMT_RGB32, false); rotation_ = angle; } @@ -407,7 +384,6 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/, frame = std::static_pointer_cast<VideoFrame>( std::shared_ptr<MediaFrame>(filter_->readOutput())); } - if (frame->height() != height_ || frame->width() != width_) { setFrameSize(0, 0); setFrameSize(frame->width(), frame->height()); @@ -460,12 +436,5 @@ SinkClient::setFrameSize(int width, int height) } } -void -SinkClient::setFramePosition(int x, int y) -{ - x_ = x; - y_ = y; -} - } // namespace video } // namespace jami diff --git a/src/media/video/sinkclient.h b/src/media/video/sinkclient.h index fab57d0ee2a4a03a2de24f7305da30d7143b224a..85571ca3e85131ea4c6637f3e4fb793b0dc39813 100644 --- a/src/media/video/sinkclient.h +++ b/src/media/video/sinkclient.h @@ -74,7 +74,6 @@ public: bool stop() noexcept; void setFrameSize(int width, int height); - void setFramePosition(int x, int y); void registerTarget(const DRing::SinkTarget& target) noexcept { target_ = target; } void registerAVTarget(const DRing::AVSinkTarget& target) noexcept { avTarget_ = target; } @@ -84,8 +83,6 @@ private: const bool mixer_; int width_ {0}; int height_ {0}; - int x_ {0}; - int y_ {0}; bool started_ {false}; // used to arbitrate client's stop signal. int rotation_ {0}; DRing::SinkTarget target_; diff --git a/src/media/video/video_receive_thread.cpp b/src/media/video/video_receive_thread.cpp index 3a0deda02cfbfe8e6eb80b9d214b7c78e4021df1..690377af133f7e5c01603eb47f7391f1a81d02cf 100644 --- a/src/media/video/video_receive_thread.cpp +++ b/src/media/video/video_receive_thread.cpp @@ -85,7 +85,6 @@ VideoReceiveThread::setup() videoDecoder_->setResolutionChangedCallback([this] (int width, int height){ dstWidth_ = width; dstHeight_ = height; - sink_->setFrameSize(dstWidth_, dstHeight_); }); dstWidth_ = args_.width; diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 819b0fdfacdae4ffeaf70f6af678d4ce0ef1df25..cb48e52772084b7fcaaceef90024489fd82832c8 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -53,7 +53,6 @@ #include "jami/videomanager_interface.h" #include <chrono> #include <libavutil/display.h> -#include <video/sinkclient.h> #endif #include "audio/ringbufferpool.h" #include "jamidht/channeled_transport.h" @@ -2066,17 +2065,6 @@ SIPCall::stopAllMedia() audioRtp->stop(); #ifdef ENABLE_VIDEO auto const& videoRtp = getVideoRtp(); - - for (auto it = callSinksMap_.begin(); it != callSinksMap_.end();) { - auto& videoReceive = videoRtp->getVideoReceive(); - if (videoReceive) { - videoReceive->detach(it->second.get()); - } - - it->second->stop(); - it = callSinksMap_.erase(it); - } - if (videoRtp) videoRtp->stop(); #endif @@ -2750,27 +2738,6 @@ SIPCall::addDummyVideoRtpSession() return {}; } -void -SIPCall::createSinks(const ConfInfo& infos) -{ -#ifdef ENABLE_VIDEO - if (!hasVideo()) - return; - - std::lock_guard<std::mutex> lk(sinksMtx_); - auto videoRtp = getVideoRtp(); - auto& videoReceive = videoRtp->getVideoReceive(); - if (!videoReceive) - return; - auto id = getConfId().empty() ? getCallId() : getConfId(); - Manager::instance().createSinkClients(id, - infos, - std::static_pointer_cast<video::VideoGenerator>( - videoReceive), - callSinksMap_); -#endif -} - std::shared_ptr<AudioRtpSession> SIPCall::getAudioRtp() const { diff --git a/src/sip/sipcall.h b/src/sip/sipcall.h index cd10259bf799c95305fb8342bed96bf7a6ad7278..0ae5430191aaebecc0afd2a7dfaf65f58fca1873 100644 --- a/src/sip/sipcall.h +++ b/src/sip/sipcall.h @@ -155,9 +155,6 @@ public: void exitConference() override; std::shared_ptr<Observable<std::shared_ptr<MediaFrame>>> getReceiveVideoFrameActiveWriter() override; - std::mutex sinksMtx_; - void createSinks(const ConfInfo& infos) override; - std::map<std::string, std::shared_ptr<video::SinkClient>> callSinksMap_ {}; bool hasVideo() const override; bool isCaptureDeviceMuted(const MediaType& mediaType) const override; bool isSrtpEnabled() const { return srtpEnabled_; } diff --git a/test/unitTest/call/conference.cpp b/test/unitTest/call/conference.cpp index 1b12ad9e6ba8feef6fff7d41ffebe2fa16a5d13e..6fb142b88f61b34f2716e7e08e77a017ef129855 100644 --- a/test/unitTest/call/conference.cpp +++ b/test/unitTest/call/conference.cpp @@ -31,7 +31,6 @@ #include "account_const.h" #include "common.h" #include "media_const.h" -#include "video/sinkclient.h" using namespace DRing::Account; @@ -71,14 +70,12 @@ private: void testGetConference(); void testModeratorMuteUpdateParticipantsInfos(); void testAudioVideoMutedStates(); - void testCreateParticipantsSinks(); void testMuteStatusAfterRemove(); CPPUNIT_TEST_SUITE(ConferenceTest); CPPUNIT_TEST(testGetConference); CPPUNIT_TEST(testModeratorMuteUpdateParticipantsInfos); CPPUNIT_TEST(testAudioVideoMutedStates); - CPPUNIT_TEST(testCreateParticipantsSinks); CPPUNIT_TEST(testMuteStatusAfterRemove); CPPUNIT_TEST_SUITE_END(); @@ -247,7 +244,6 @@ ConferenceTest::testGetConference() hangupConference(); CPPUNIT_ASSERT(Manager::instance().getConferenceList().size() == 0); - DRing::unregisterSignalHandlers(); } @@ -255,7 +251,6 @@ void ConferenceTest::testModeratorMuteUpdateParticipantsInfos() { registerSignalHandlers(); - auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); @@ -271,7 +266,6 @@ ConferenceTest::testModeratorMuteUpdateParticipantsInfos() cv.wait_for(lk, std::chrono::seconds(5), [&] { return !bobCall.moderatorMuted.load(); })); hangupConference(); - DRing::unregisterSignalHandlers(); } @@ -321,38 +315,6 @@ ConferenceTest::testAudioVideoMutedStates() })); hangupConference(); - - DRing::unregisterSignalHandlers(); -} - -void -ConferenceTest::testCreateParticipantsSinks() -{ - registerSignalHandlers(); - - auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); - auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); - auto bobUri = bobAccount->getUsername(); - auto carlaUri = carlaAccount->getUsername(); - - startConference(); - - auto infos = Manager::instance().getConferenceInfos(confId); - - CPPUNIT_ASSERT(cv.wait_for(lk, std::chrono::seconds(5), [&] { - bool sinksStatus = true; - for (auto& info : infos) { - if (info["uri"] == bobUri) { - sinksStatus &= (Manager::instance().getSinkClient(info["sinkId"]) != nullptr); - } else if (info["uri"] == carlaUri) { - sinksStatus &= (Manager::instance().getSinkClient(info["sinkId"]) != nullptr); - } - } - return sinksStatus; - })); - - hangupConference(); - DRing::unregisterSignalHandlers(); } @@ -360,15 +322,12 @@ void ConferenceTest::testMuteStatusAfterRemove() { registerSignalHandlers(); - auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto daviUri = daviAccount->getUsername(); - startConference(); - JAMI_INFO("Start call between Alice and Davi"); auto call1 = aliceAccount->newOutgoingCall(daviUri); CPPUNIT_ASSERT( @@ -377,16 +336,13 @@ ConferenceTest::testMuteStatusAfterRemove() CPPUNIT_ASSERT( cv.wait_for(lk, std::chrono::seconds(20), [&] { return daviCall.state == "CURRENT"; })); Manager::instance().addParticipant(daviCall.callId, confId); - Manager::instance().muteParticipant(confId, daviUri, true); CPPUNIT_ASSERT( cv.wait_for(lk, std::chrono::seconds(5), [&] { return daviCall.moderatorMuted.load(); })); - Manager::instance().hangupCall(daviCall.callId); CPPUNIT_ASSERT( cv.wait_for(lk, std::chrono::seconds(20), [&] { return daviCall.state == "OVER"; })); daviCall.reset(); - auto call2 = aliceAccount->newOutgoingCall(daviUri); CPPUNIT_ASSERT( cv.wait_for(lk, std::chrono::seconds(20), [&] { return !daviCall.callId.empty(); })); @@ -394,17 +350,15 @@ ConferenceTest::testMuteStatusAfterRemove() CPPUNIT_ASSERT( cv.wait_for(lk, std::chrono::seconds(20), [&] { return daviCall.state == "CURRENT"; })); Manager::instance().addParticipant(daviCall.callId, confId); - CPPUNIT_ASSERT( cv.wait_for(lk, std::chrono::seconds(5), [&] { return !daviCall.moderatorMuted.load(); })); - Manager::instance().hangupCall(daviCall.callId); CPPUNIT_ASSERT( cv.wait_for(lk, std::chrono::seconds(20), [&] { return daviCall.state == "OVER"; })); hangupConference(); - DRing::unregisterSignalHandlers(); } + } // namespace test } // namespace jami