From 04f3997fd9dd873a1e0232403614ea3c4a846694 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 2 Nov 2022 10:38:43 +0100 Subject: [PATCH] Update Active Speaker API (fix synchronizations) --- .../conference/ConferenceListener.cpp | 5 +++ .../conference/ConferenceListener.hpp | 3 ++ .../components/conference/ConferenceModel.cpp | 4 +++ .../components/conference/ConferenceModel.hpp | 3 +- .../conferenceInfo/ConferenceInfoModel.hpp | 1 - .../ParticipantDeviceListModel.cpp | 33 ++++++++--------- .../ParticipantDeviceListModel.hpp | 7 ++-- .../ParticipantDeviceProxyModel.cpp | 23 ++++++------ .../ParticipantDeviceProxyModel.hpp | 9 +++-- linphone-app/src/utils/LinphoneEnums.hpp | 3 +- .../ui/modules/Linphone/Contact/Contact.qml | 4 ++- .../views/App/Calls/IncallActiveSpeaker.qml | 35 +++++-------------- linphone-sdk | 2 +- 13 files changed, 66 insertions(+), 66 deletions(-) diff --git a/linphone-app/src/components/conference/ConferenceListener.cpp b/linphone-app/src/components/conference/ConferenceListener.cpp index 32a5a55f1..19f65c159 100644 --- a/linphone-app/src/components/conference/ConferenceListener.cpp +++ b/linphone-app/src/components/conference/ConferenceListener.cpp @@ -41,6 +41,11 @@ ConferenceListener::~ConferenceListener(){ //----------------------------------------------------------------------------------------------------------------------- // LINPHONE LISTENERS //----------------------------------------------------------------------------------------------------------------------- +void ConferenceListener::onActiveSpeakerParticipantDevice(const std::shared_ptr & conference, const std::shared_ptr & participantDevice) { + qDebug() << "onActiveSpeakerParticipantDevice: " << participantDevice->getAddress()->asString().c_str(); + emit activeSpeakerParticipantDevice(participantDevice); +} + void ConferenceListener::onParticipantAdded(const std::shared_ptr & conference, const std::shared_ptr & participant){ qDebug() << "onParticipantAdded: " << participant->getAddress()->asString().c_str(); emit participantAdded(participant); diff --git a/linphone-app/src/components/conference/ConferenceListener.hpp b/linphone-app/src/components/conference/ConferenceListener.hpp index 7ad651fb3..8b80dbd47 100644 --- a/linphone-app/src/components/conference/ConferenceListener.hpp +++ b/linphone-app/src/components/conference/ConferenceListener.hpp @@ -35,6 +35,7 @@ public: virtual ~ConferenceListener(); // LINPHONE LISTENERS + virtual void onActiveSpeakerParticipantDevice(const std::shared_ptr & conference, const std::shared_ptr & participantDevice) override; virtual void onParticipantAdded(const std::shared_ptr & conference, const std::shared_ptr & participant) override; virtual void onParticipantRemoved(const std::shared_ptr & conference, const std::shared_ptr & participant) override; virtual void onParticipantAdminStatusChanged(const std::shared_ptr & conference, const std::shared_ptr & participant) override; @@ -50,6 +51,7 @@ public: //--------------------------------------------------------------------------- signals: + void activeSpeakerParticipantDevice(const std::shared_ptr & participantDevice); void participantAdded(const std::shared_ptr & participant); void participantRemoved(const std::shared_ptr & participant); void participantAdminStatusChanged(const std::shared_ptr & participant); @@ -61,6 +63,7 @@ signals: void participantDeviceIsSpeakingChanged(const std::shared_ptr & participantDevice, bool isSpeaking); void conferenceStateChanged(linphone::Conference::State newState); void subjectChanged(const std::string & subject); + }; diff --git a/linphone-app/src/components/conference/ConferenceModel.cpp b/linphone-app/src/components/conference/ConferenceModel.cpp index aad85a9ac..e09a7d510 100644 --- a/linphone-app/src/components/conference/ConferenceModel.cpp +++ b/linphone-app/src/components/conference/ConferenceModel.cpp @@ -37,6 +37,7 @@ #include "components/Components.hpp" void ConferenceModel::connectTo(ConferenceListener * listener){ + connect(listener, &ConferenceListener::activeSpeakerParticipantDevice, this, &ConferenceModel::onActiveSpeakerParticipantDevice); connect(listener, &ConferenceListener::participantAdded, this, &ConferenceModel::onParticipantAdded); connect(listener, &ConferenceListener::participantRemoved, this, &ConferenceModel::onParticipantRemoved); connect(listener, &ConferenceListener::participantAdminStatusChanged, this, &ConferenceModel::onParticipantAdminStatusChanged); @@ -140,6 +141,9 @@ void ConferenceModel::setIsReady(bool state){ //----------------------------------------------------------------------------------------------------------------------- // LINPHONE LISTENERS //----------------------------------------------------------------------------------------------------------------------- +void ConferenceModel::onActiveSpeakerParticipantDevice(const std::shared_ptr & participantDevice){ + emit activeSpeakerParticipantDevice(participantDevice); +} void ConferenceModel::onParticipantAdded(const std::shared_ptr & participant){ qDebug() << "Added call, participant count: " << getParticipantList().size() << ". Me devices : " << mConference->getMe()->getDevices().size(); updateLocalParticipant(); diff --git a/linphone-app/src/components/conference/ConferenceModel.hpp b/linphone-app/src/components/conference/ConferenceModel.hpp index f5936b8ef..214681e2a 100644 --- a/linphone-app/src/components/conference/ConferenceModel.hpp +++ b/linphone-app/src/components/conference/ConferenceModel.hpp @@ -62,7 +62,7 @@ public: void setIsReady(bool state); - + virtual void onActiveSpeakerParticipantDevice(const std::shared_ptr & participantDevice); virtual void onParticipantAdded(const std::shared_ptr & participant); virtual void onParticipantRemoved(const std::shared_ptr & participant); virtual void onParticipantAdminStatusChanged(const std::shared_ptr & participant); @@ -77,6 +77,7 @@ public: //--------------------------------------------------------------------------- signals: + void activeSpeakerParticipantDevice(const std::shared_ptr & participantDevice); void localParticipantChanged(); void participantAdded(const std::shared_ptr & participant); void participantRemoved(const std::shared_ptr & participant); diff --git a/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp b/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp index 17087a240..fa92147fa 100644 --- a/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp +++ b/linphone-app/src/components/conferenceInfo/ConferenceInfoModel.hpp @@ -100,7 +100,6 @@ public: virtual void onStateChanged(linphone::ConferenceScheduler::State state); virtual void onInvitationsSent(const std::list> & failedInvitations); - signals: void timeZoneModelChanged(); void dateTimeChanged(); diff --git a/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp b/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp index 05f132cd9..ebb5234b1 100644 --- a/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp +++ b/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp @@ -58,6 +58,7 @@ void ParticipantDeviceListModel::initConferenceModel(){ updateDevices(conferenceModel->getConference()->getParticipantDeviceList(), false); qDebug() << "Conference have " << mList.size() << " devices"; + connect(conferenceModel.get(), &ConferenceModel::activeSpeakerParticipantDevice, this, &ParticipantDeviceListModel::onActiveSpeakerParticipantDevice); connect(conferenceModel.get(), &ConferenceModel::participantAdded, this, &ParticipantDeviceListModel::onParticipantAdded); connect(conferenceModel.get(), &ConferenceModel::participantRemoved, this, &ParticipantDeviceListModel::onParticipantRemoved); connect(conferenceModel.get(), &ConferenceModel::participantDeviceAdded, this, &ParticipantDeviceListModel::onParticipantDeviceAdded); @@ -116,6 +117,9 @@ bool ParticipantDeviceListModel::add(std::shared_ptr()->getDevice()))){ + mActiveSpeaker = mList.back().objectCast(); + emit activeSpeakerChanged(); } return true; } @@ -126,7 +130,6 @@ bool ParticipantDeviceListModel::remove(std::shared_ptr(); if( device->getDevice() == deviceToRemove){ device->updateVideoEnabled(); - mActiveSpeakers.removeAll(device.get()); removeRow(row); return true; }else @@ -163,14 +166,8 @@ QSharedPointer ParticipantDeviceListModel::getMe(int * i return nullptr; } -ParticipantDeviceModel* ParticipantDeviceListModel::getLastActiveSpeaking() const{ - if( mActiveSpeakers.size() == 0){ - if( mList.size() == 0) - return getMe().get(); - else - return mList.back().objectCast().get(); - }else - return mActiveSpeakers.first(); +ParticipantDeviceModel* ParticipantDeviceListModel::getActiveSpeakerModel() const{ + return mActiveSpeaker.get(); } bool ParticipantDeviceListModel::isMe(std::shared_ptr deviceToCheck)const{ @@ -280,6 +277,13 @@ void ParticipantDeviceListModel::onParticipantDeviceMediaAvailabilityChanged(con else onParticipantDeviceAdded(participantDevice); } +void ParticipantDeviceListModel::onActiveSpeakerParticipantDevice(const std::shared_ptr& participantDevice){ + auto device = get(participantDevice); + if( device){ + mActiveSpeaker = device; + emit activeSpeakerChanged(); + } +} void ParticipantDeviceListModel::onParticipantDeviceIsSpeakingChanged(const std::shared_ptr & participantDevice, bool isSpeaking){ auto device = get(participantDevice); @@ -288,14 +292,5 @@ void ParticipantDeviceListModel::onParticipantDeviceIsSpeakingChanged(const std: } void ParticipantDeviceListModel::onParticipantDeviceSpeaking(){ - auto deviceModel = qobject_cast(sender()); - bool changed = false; - // Me should not be in the list. - if( !deviceModel->isMe() && (mActiveSpeakers.size() == 0 || deviceModel->getIsSpeaking())) {// Ensure to have at least one last active speaker - changed = mActiveSpeakers.removeAll(deviceModel) > 0; - mActiveSpeakers.push_front(deviceModel); - changed = true; - } - if(changed) - emit participantSpeaking(deviceModel); + } diff --git a/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp b/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp index 318e46730..ed5edc3c1 100644 --- a/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp +++ b/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp @@ -47,12 +47,13 @@ public: bool remove(std::shared_ptr deviceToAdd); QSharedPointer get(std::shared_ptr deviceToGet, int * index = nullptr); QSharedPointer getMe(int * index = nullptr)const; - ParticipantDeviceModel* getLastActiveSpeaking() const; + ParticipantDeviceModel* getActiveSpeakerModel() const; bool isMe(std::shared_ptr device)const; bool isMeAlone() const; public slots: + void onActiveSpeakerParticipantDevice(const std::shared_ptr& participantDevice); void onConferenceModelChanged (); void onSecurityLevelChanged(std::shared_ptr device); void onParticipantAdded(const std::shared_ptr & participant); @@ -66,6 +67,7 @@ public slots: void onParticipantDeviceSpeaking(); signals: + void activeSpeakerChanged(); void securityLevelChanged(std::shared_ptr device); void participantSpeaking(ParticipantDeviceModel *speakingDevice); void conferenceCreated(); @@ -73,7 +75,8 @@ signals: private: CallModel * mCallModel = nullptr; - QList mActiveSpeakers;// First item is last speaker + QSharedPointer mActiveSpeaker; + //QList mActiveSpeakers;// First item is last speaker bool mInitialized = false; }; diff --git a/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp b/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp index b05c9129d..272c25480 100644 --- a/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp +++ b/linphone-app/src/components/participant/ParticipantDeviceProxyModel.cpp @@ -57,9 +57,9 @@ ParticipantDeviceModel *ParticipantDeviceProxyModel::getAt(int row){ return sourceModel()->data(sourceIndex).value(); } -ParticipantDeviceModel* ParticipantDeviceProxyModel::getLastActiveSpeaking(){ +ParticipantDeviceModel* ParticipantDeviceProxyModel::getActiveSpeakerModel(){ auto listModel = qobject_cast(sourceModel()); - return listModel ? listModel->getLastActiveSpeaking() : nullptr; + return listModel ? listModel->getActiveSpeakerModel() : nullptr; } CallModel * ParticipantDeviceProxyModel::getCallModel() const{ @@ -74,15 +74,19 @@ ParticipantDeviceModel * ParticipantDeviceProxyModel::getMe() const{ bool ParticipantDeviceProxyModel::isShowMe() const{ return mShowMe; } - + +void ParticipantDeviceProxyModel::connectTo(ParticipantDeviceListModel* model){ + connect(model, &ParticipantDeviceListModel::countChanged, this, &ParticipantDeviceProxyModel::onCountChanged); + connect(model, &ParticipantDeviceListModel::participantSpeaking, this, &ParticipantDeviceProxyModel::onParticipantSpeaking); + connect(model, &ParticipantDeviceListModel::conferenceCreated, this, &ParticipantDeviceProxyModel::conferenceCreated); + connect(model, &ParticipantDeviceListModel::meChanged, this, &ParticipantDeviceProxyModel::meChanged); + connect(model, &ParticipantDeviceListModel::activeSpeakerChanged, this, &ParticipantDeviceProxyModel::activeSpeakerChanged); +} void ParticipantDeviceProxyModel::setCallModel(CallModel * callModel){ setFilterType(1); mCallModel = callModel; auto sourceModel = new ParticipantDeviceListModel(mCallModel); - connect(sourceModel, &ParticipantDeviceListModel::countChanged, this, &ParticipantDeviceProxyModel::onCountChanged); - connect(sourceModel, &ParticipantDeviceListModel::participantSpeaking, this, &ParticipantDeviceProxyModel::onParticipantSpeaking); - connect(sourceModel, &ParticipantDeviceListModel::conferenceCreated, this, &ParticipantDeviceProxyModel::conferenceCreated); - connect(sourceModel, &ParticipantDeviceListModel::meChanged, this, &ParticipantDeviceProxyModel::meChanged); + connectTo(sourceModel); setSourceModel(sourceModel); emit countChanged(); emit meChanged(); @@ -91,10 +95,7 @@ void ParticipantDeviceProxyModel::setCallModel(CallModel * callModel){ void ParticipantDeviceProxyModel::setParticipant(ParticipantModel * participant){ setFilterType(0); auto sourceModel = participant->getParticipantDevices().get(); - connect(sourceModel, &ParticipantDeviceListModel::countChanged, this, &ParticipantDeviceProxyModel::countChanged); - connect(sourceModel, &ParticipantDeviceListModel::participantSpeaking, this, &ParticipantDeviceProxyModel::onParticipantSpeaking); - connect(sourceModel, &ParticipantDeviceListModel::conferenceCreated, this, &ParticipantDeviceProxyModel::conferenceCreated); - connect(sourceModel, &ParticipantDeviceListModel::meChanged, this, &ParticipantDeviceProxyModel::meChanged); + connectTo(sourceModel); setSourceModel(sourceModel); emit countChanged(); emit meChanged(); diff --git a/linphone-app/src/components/participant/ParticipantDeviceProxyModel.hpp b/linphone-app/src/components/participant/ParticipantDeviceProxyModel.hpp index ecdedfd02..9a939ac53 100644 --- a/linphone-app/src/components/participant/ParticipantDeviceProxyModel.hpp +++ b/linphone-app/src/components/participant/ParticipantDeviceProxyModel.hpp @@ -42,12 +42,14 @@ public: Q_PROPERTY(CallModel * callModel READ getCallModel WRITE setCallModel NOTIFY callModelChanged) Q_PROPERTY(bool showMe READ isShowMe WRITE setShowMe NOTIFY showMeChanged) Q_PROPERTY(ParticipantDeviceModel * me READ getMe NOTIFY meChanged) + Q_PROPERTY(ParticipantDeviceModel* activeSpeaker READ getActiveSpeakerModel NOTIFY activeSpeakerChanged) ParticipantDeviceProxyModel (QObject *parent = nullptr); Q_INVOKABLE ParticipantDeviceModel* getAt(int row); - Q_INVOKABLE ParticipantDeviceModel* getLastActiveSpeaking(); - ParticipantDeviceModel * getMe() const; + ParticipantDeviceModel* getActiveSpeakerModel(); + ParticipantDeviceModel* getMe() const; + CallModel * getCallModel() const; bool isShowMe() const; @@ -56,11 +58,14 @@ public: void setParticipant(ParticipantModel * participant); void setShowMe(const bool& show); + void connectTo(ParticipantDeviceListModel* model); + public slots: void onCountChanged(); void onParticipantSpeaking(ParticipantDeviceModel * speakingDevice); signals: + void activeSpeakerChanged(); void callModelChanged(); void showMeChanged(); void meChanged(); diff --git a/linphone-app/src/utils/LinphoneEnums.hpp b/linphone-app/src/utils/LinphoneEnums.hpp index 806bf3139..16af1fae9 100644 --- a/linphone-app/src/utils/LinphoneEnums.hpp +++ b/linphone-app/src/utils/LinphoneEnums.hpp @@ -189,6 +189,7 @@ void fromString(const QString& transportType, LinphoneEnums::TransportType *tran Q_DECLARE_METATYPE(LinphoneEnums::CallStatus) + Q_DECLARE_METATYPE(LinphoneEnums::ChatMessageState) Q_DECLARE_METATYPE(LinphoneEnums::ConferenceLayout) Q_DECLARE_METATYPE(LinphoneEnums::ConferenceInfoState) @@ -198,6 +199,6 @@ Q_DECLARE_METATYPE(LinphoneEnums::MediaEncryption) Q_DECLARE_METATYPE(LinphoneEnums::ParticipantDeviceState) Q_DECLARE_METATYPE(LinphoneEnums::RecorderState) Q_DECLARE_METATYPE(LinphoneEnums::TunnelMode) - +Q_DECLARE_METATYPE(LinphoneEnums::TransportType) #endif diff --git a/linphone-app/ui/modules/Linphone/Contact/Contact.qml b/linphone-app/ui/modules/Linphone/Contact/Contact.qml index ae90b0a1a..e71f3a53a 100644 --- a/linphone-app/ui/modules/Linphone/Contact/Contact.qml +++ b/linphone-app/ui/modules/Linphone/Contact/Contact.qml @@ -107,7 +107,9 @@ Rectangle { ? item.organizer ? item.organizer : entry.sipAddress || entry.fullPeerAddress || entry.peerAddress || '' - : entry.participants.addressesToString + : entry.participants + ? entry.participants.addressesToString + : '' : '' } diff --git a/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml b/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml index 8d6626699..47d84a931 100644 --- a/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml +++ b/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml @@ -29,30 +29,12 @@ Item { property int participantCount: callModel.isConference ? allDevices.count + 1 : 2 // +me. allDevices==0 if !conference - onParticipantCountChanged: {Qt.callLater(allDevices.updateCurrentDevice)} - property ParticipantDeviceProxyModel participantDevices : ParticipantDeviceProxyModel { id: allDevices callModel: mainItem.callModel - showMe: false - - onParticipantSpeaking: updateCurrentDevice() - + showMe: false onConferenceCreated: cameraView.resetCamera() - function updateCurrentDevice(){ - if( callModel ){ - if( callModel.isConference) { - var device = getLastActiveSpeaking() - if(device) // Get - cameraView.currentDevice = device - } - } - } - onMeChanged: if(cameraView.isPreview) { - cameraView.currentDevice = me - cameraView.resetCamera() - } } function clearAll(layoutMode){ @@ -67,6 +49,11 @@ Item { anchors.leftMargin: isRightReducedLayout || isLeftReducedLayout? 30 : 140 anchors.rightMargin: isRightReducedLayout ? 10 : 140 callModel: mainItem.callModel + currentDevice: isPreview + ? allDevices.me + : callModel.isConference + ? allDevices.activeSpeaker + : null deactivateCamera: isPreview && callModel.pausedByUser ? true : callModel.isConference @@ -79,14 +66,7 @@ Item { isVideoEnabled: !deactivateCamera isPreview: !preview.visible && mainItem.participantCount == 1 - onIsPreviewChanged: { - if( isPreview){ - currentDevice = allDevices.me - cameraView.resetCamera() - }else - allDevices.updateCurrentDevice() - cameraView.resetCamera() - } + onIsPreviewChanged: {cameraView.resetCamera() } isCameraFromDevice: isPreview isPaused: isPreview && callModel.pausedByUser ? false @@ -193,3 +173,4 @@ Item { } } + diff --git a/linphone-sdk b/linphone-sdk index b5cc94b43..11f72d4e2 160000 --- a/linphone-sdk +++ b/linphone-sdk @@ -1 +1 @@ -Subproject commit b5cc94b43b9ad5644f5d7ec8bd8f9f7a81127a54 +Subproject commit 11f72d4e254a2a8305a9400e38cb44f125c18873