Add a spinner for joining participants on stickers.

Add callbacks on device state changes.
This commit is contained in:
Julien Wadel 2022-08-19 17:42:11 +02:00
parent 1d60009fc6
commit e648b40db6
5 changed files with 57 additions and 3 deletions

View file

@ -44,6 +44,7 @@ ParticipantDeviceModel::ParticipantDeviceModel (CallModel * callModel, std::shar
mParticipantDeviceListener = std::make_shared<ParticipantDeviceListener>(nullptr);
connectTo(mParticipantDeviceListener.get());
device->addListener(mParticipantDeviceListener);
mState = device->getState();
}
mCall = callModel;
if(mCall)
@ -105,7 +106,11 @@ bool ParticipantDeviceModel::getIsMuted() const{
return mParticipantDevice ? mParticipantDevice->getIsMuted() : false;
}
std::shared_ptr<linphone::ParticipantDevice> ParticipantDeviceModel::getDevice(){
LinphoneEnums::ParticipantDeviceState ParticipantDeviceModel::getState() const{
return LinphoneEnums::fromLinphone(mState);
}
std::shared_ptr<linphone::ParticipantDevice> ParticipantDeviceModel::getDevice(){
return mParticipantDevice;
}
@ -127,6 +132,14 @@ void ParticipantDeviceModel::setIsSpeaking(bool speaking){
}
}
void ParticipantDeviceModel::setState(LinphoneEnums::ParticipantDeviceState state){
auto newState = LinphoneEnums::toLinphone(state);
if(mState != newState){
mState = newState;
emit stateChanged();
}
}
void ParticipantDeviceModel::updateVideoEnabled(){
bool enabled = (mParticipantDevice && mParticipantDevice->isInConference() && mParticipantDevice->getStreamAvailability(linphone::StreamType::Video) &&
( mParticipantDevice->getStreamCapability(linphone::StreamType::Video) == linphone::MediaDirection::SendRecv
@ -175,6 +188,7 @@ void ParticipantDeviceModel::onStateChanged(const std::shared_ptr<linphone::Part
case linphone::ParticipantDeviceState::MutedByFocus: break;
default:{}
}
setState(LinphoneEnums::fromLinphone(state));
updateVideoEnabled();
}
void ParticipantDeviceModel::onStreamCapabilityChanged(const std::shared_ptr<linphone::ParticipantDevice> & participantDevice, linphone::MediaDirection direction, linphone::StreamType streamType) {

View file

@ -23,6 +23,8 @@
#include <linphone++/linphone.hh>
#include "utils/LinphoneEnums.hpp"
// =============================================================================
#include <QObject>
#include <QDateTime>
@ -52,6 +54,7 @@ public:
Q_PROPERTY(bool isPaused READ getPaused WRITE setPaused NOTIFY isPausedChanged)
Q_PROPERTY(bool isSpeaking READ getIsSpeaking WRITE setIsSpeaking NOTIFY isSpeakingChanged)
Q_PROPERTY(bool isMuted READ getIsMuted NOTIFY isMutedChanged)
Q_PROPERTY(LinphoneEnums::ParticipantDeviceState state READ getState WRITE setState NOTIFY stateChanged)
QString getName() const;
QString getDisplayName() const;
@ -63,11 +66,13 @@ public:
bool getPaused() const;
bool getIsSpeaking() const;
bool getIsMuted() const;
LinphoneEnums::ParticipantDeviceState getState() const;
std::shared_ptr<linphone::ParticipantDevice> getDevice();
void setPaused(bool paused);
void setIsSpeaking(bool speaking);
void setState(LinphoneEnums::ParticipantDeviceState state);
virtual void onIsSpeakingChanged(const std::shared_ptr<linphone::ParticipantDevice> & participantDevice, bool isSpeaking);
virtual void onIsMuted(const std::shared_ptr<linphone::ParticipantDevice> & participantDevice, bool isMuted);
@ -87,6 +92,7 @@ signals:
void isPausedChanged();
void isSpeakingChanged();
void isMutedChanged();
void stateChanged();
private:
@ -94,6 +100,7 @@ private:
bool mIsVideoEnabled;
bool mIsPaused = false;
bool mIsSpeaking = false;
linphone::ParticipantDeviceState mState;
std::shared_ptr<linphone::ParticipantDevice> mParticipantDevice;
std::shared_ptr<ParticipantDeviceListener> mParticipantDeviceListener; // This is passed to linpĥone object and must be in shared_ptr

View file

@ -78,6 +78,14 @@ LinphoneEnums::ConferenceLayout LinphoneEnums::fromLinphone(const linphone::Conf
return static_cast<LinphoneEnums::ConferenceLayout>(layout);
}
linphone::ParticipantDeviceState LinphoneEnums::toLinphone(const LinphoneEnums::ParticipantDeviceState& state){
return static_cast<linphone::ParticipantDeviceState>(state);
}
LinphoneEnums::ParticipantDeviceState LinphoneEnums::fromLinphone(const linphone::ParticipantDeviceState& state){
return static_cast<LinphoneEnums::ParticipantDeviceState>(state);
}
linphone::Tunnel::Mode LinphoneEnums::toLinphone(const LinphoneEnums::TunnelMode& data){
return static_cast<linphone::Tunnel::Mode>(data);
}

View file

@ -121,6 +121,25 @@ Q_ENUM_NS(ConferenceLayout)
linphone::ConferenceLayout toLinphone(const LinphoneEnums::ConferenceLayout& layout);
LinphoneEnums::ConferenceLayout fromLinphone(const linphone::ConferenceLayout& layout);
enum ParticipantDeviceState {
ParticipantDeviceStateJoining = int(linphone::ParticipantDeviceState::Joining),
ParticipantDeviceStatePresent = int(linphone::ParticipantDeviceState::Present),
ParticipantDeviceStateLeaving = int(linphone::ParticipantDeviceState::Leaving),
ParticipantDeviceStateLeft = int(linphone::ParticipantDeviceState::Left),
ParticipantDeviceStateScheduledForJoining = int(linphone::ParticipantDeviceState::ScheduledForJoining),
ParticipantDeviceStateScheduledForLeaving = int(linphone::ParticipantDeviceState::ScheduledForLeaving),
ParticipantDeviceStateOnHold = int(linphone::ParticipantDeviceState::OnHold),
ParticipantDeviceStateAlerting = int(linphone::ParticipantDeviceState::Alerting),
ParticipantDeviceStateMutedByFocus = int(linphone::ParticipantDeviceState::MutedByFocus),
};
Q_ENUM_NS(ParticipantDeviceState)
linphone::ParticipantDeviceState toLinphone(const LinphoneEnums::ParticipantDeviceState& state);
LinphoneEnums::ParticipantDeviceState fromLinphone(const linphone::ParticipantDeviceState& state);
enum TunnelMode {
TunnelModeDisable = int(linphone::Tunnel::Mode::Disable),
TunnelModeEnable= int(linphone::Tunnel::Mode::Enable),

View file

@ -6,6 +6,7 @@ import App.Styles 1.0
import Common 1.0
import Common.Styles 1.0
import Linphone 1.0
import LinphoneEnums 1.0
import Linphone.Styles 1.0
import 'qrc:/ui/scripts/Utils/utils.js' as Utils
@ -124,8 +125,8 @@ Item{
}
Rectangle{// Mute
visible: mainItem.currentDevice && mainItem.currentDevice.isMuted
height: DecorationStickerStyle.isMuted.button.iconSize
width: height
Layout.preferredHeight: DecorationStickerStyle.isMuted.button.iconSize
Layout.preferredWidth: DecorationStickerStyle.isMuted.button.iconSize
radius: width/2
color: DecorationStickerStyle.isMuted.button.backgroundNormalColor
Icon{
@ -135,5 +136,10 @@ Item{
iconSize: DecorationStickerStyle.isMuted.button.iconSize
}
}
BusyIndicator{// Joining spinner
Layout.preferredHeight: 20
Layout.preferredWidth: 20
running: mainItem.currentDevice && (mainItem.currentDevice.state == LinphoneEnums.ParticipantDeviceStateJoining || mainItem.currentDevice.state == LinphoneEnums.ParticipantDeviceStateScheduledForJoining || mainItem.currentDevice.state == LinphoneEnums.ParticipantDeviceStateAlerting)
}
}
}