From 0b1c081aaab3e2e9075256a5de486dfc5b9dacac Mon Sep 17 00:00:00 2001 From: "gaelle.braud" Date: Thu, 12 Feb 2026 12:22:29 +0100 Subject: [PATCH] force set camera enabled when accepting call (camera seems to be enabled by default on macos) --- Linphone/core/call/CallCore.cpp | 19 +++++++++++++++---- Linphone/model/call/CallModel.cpp | 7 +++++++ .../view/Control/Display/Chat/ChatMessage.qml | 1 + Linphone/view/Control/Display/Sticker.qml | 1 + 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Linphone/core/call/CallCore.cpp b/Linphone/core/call/CallCore.cpp index 864b54ac3..24e8f4a73 100644 --- a/Linphone/core/call/CallCore.cpp +++ b/Linphone/core/call/CallCore.cpp @@ -112,7 +112,7 @@ CallCore::CallCore(const std::shared_ptr &call) : QObject(nullpt mLocalVideoEnabled = videoDirection == linphone::MediaDirection::SendOnly || videoDirection == linphone::MediaDirection::SendRecv; mCameraEnabled = mLocalVideoEnabled && callParams->cameraEnabled(); - qDebug() << "create call with camera enabled" << mLocalVideoEnabled << callParams->cameraEnabled(); + lDebug() << log().arg("create call with camera enabled") << mLocalVideoEnabled << callParams->cameraEnabled(); auto remoteParams = call->getRemoteParams(); videoDirection = remoteParams ? remoteParams->getVideoDirection() : linphone::MediaDirection::Inactive; mRemoteVideoEnabled = @@ -248,7 +248,10 @@ void CallCore::setSelf(QSharedPointer me) { mCallModelConnection->invokeToCore([this, enabled]() { setLocalVideoEnabled(enabled); }); }); mCallModelConnection->makeConnectToModel(&CallModel::cameraEnabledChanged, [this](bool enabled) { - mCallModelConnection->invokeToCore([this, enabled]() { setCameraEnabled(enabled); }); + mCallModelConnection->invokeToCore([this, enabled]() { + lDebug() << log().arg("Camera enabled changed") << enabled; + setCameraEnabled(enabled); + }); }); mCallModelConnection->makeConnectToModel(&CallModel::durationChanged, [this](int duration) { mCallModelConnection->invokeToCore([this, duration]() { setDuration(duration); }); @@ -264,10 +267,18 @@ void CallCore::setSelf(QSharedPointer me) { mCallModelConnection->makeConnectToModel(&CallModel::stateChanged, [this](std::shared_ptr call, linphone::Call::State state, const std::string &message) { + if (state == linphone::Call::State::Connected) { + lDebug() << log().arg("call connected, video direction") << (int)call->getParams()->getVideoDirection() + << call->getParams()->cameraEnabled(); + } bool isConf = call && call->getConference() != nullptr; auto subject = call->getConference() ? Utils::coreStringToAppString(call->getConference()->getSubject()) : ""; - mCallModelConnection->invokeToCore([this, state, subject, isConf]() { + bool cameraEnabled = call->getParams()->cameraEnabled(); + mCallModelConnection->invokeToCore([this, state, subject, isConf, cameraEnabled]() { lDebug() << log().arg("::onStateChanged") << LinphoneEnums::fromLinphone(state); + if (state == linphone::Call::State::Connected) { + setCameraEnabled(cameraEnabled); + } setRecordable(state == linphone::Call::State::StreamsRunning); setPaused(state == linphone::Call::State::Paused || state == linphone::Call::State::PausedByRemote); if (mConference) mConference->setSubject(subject); @@ -573,7 +584,7 @@ bool CallCore::getCameraEnabled() const { void CallCore::setCameraEnabled(bool enabled) { if (mCameraEnabled != enabled) { mCameraEnabled = enabled; - lDebug() << "CameraEnabled: " << mCameraEnabled; + lDebug() << "Set cameraEnabled: " << mCameraEnabled; emit cameraEnabledChanged(); } } diff --git a/Linphone/model/call/CallModel.cpp b/Linphone/model/call/CallModel.cpp index 366bbe86f..da760194d 100644 --- a/Linphone/model/call/CallModel.cpp +++ b/Linphone/model/call/CallModel.cpp @@ -66,7 +66,11 @@ void CallModel::accept(bool withVideo) { break; } } + lDebug() << log().arg("Accept with video") << withVideo; activateLocalVideo(params, withVideo); + params->enableCamera(withVideo); + lDebug() << log().arg("Accept call with video directon") << (int)params->getVideoDirection() + << "Camera enabled =" << params->cameraEnabled(); mMonitor->acceptWithParams(params); emit localVideoEnabledChanged(withVideo); emit cameraEnabledChanged(withVideo && params->cameraEnabled()); @@ -148,13 +152,16 @@ void CallModel::activateLocalVideo(std::shared_ptr ¶ms .arg((int)params->getVideoDirection()); params->enableVideo(SettingsModel::getInstance()->getVideoEnabled()); auto videoDirection = params->getVideoDirection(); + lDebug() << "Activate local video" << enable << "screen sharing enabled" << params->screenSharingEnabled(); params->setVideoDirection(enable || params->screenSharingEnabled() ? linphone::MediaDirection::SendRecv : linphone::MediaDirection::RecvOnly); + lDebug() << "video direction" << (int)params->getVideoDirection(); } void CallModel::setLocalVideoEnabled(bool enabled) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto params = CoreModel::getInstance()->getCore()->createCallParams(mMonitor); + lDebug() << log().arg(Q_FUNC_INFO) << "enabled =" << enabled; activateLocalVideo(params, enabled); mMonitor->update(params); } diff --git a/Linphone/view/Control/Display/Chat/ChatMessage.qml b/Linphone/view/Control/Display/Chat/ChatMessage.qml index 8134dea90..ea8c08d83 100644 --- a/Linphone/view/Control/Display/Chat/ChatMessage.qml +++ b/Linphone/view/Control/Display/Chat/ChatMessage.qml @@ -132,6 +132,7 @@ Control.Control { ? qsTr("chat_message_user_replied_to").arg(mainItem.chatMessage.core.repliedToName) //: You replied : qsTr("chat_message_user_replied") + textFormat: Text.RichText color: DefaultStyle.main2_600 font { pixelSize: Typography.p4.pixelSize diff --git a/Linphone/view/Control/Display/Sticker.qml b/Linphone/view/Control/Display/Sticker.qml index 0a1dd10e1..27c08bf77 100644 --- a/Linphone/view/Control/Display/Sticker.qml +++ b/Linphone/view/Control/Display/Sticker.qml @@ -61,6 +61,7 @@ Item { property bool videoEnabled: (previewEnabled && call && call.core.cameraEnabled) || (!previewEnabled && call && call.core.remoteVideoEnabled) || (participantDevice && participantDevice.core.videoEnabled) + onVideoEnabledChanged: console.log("Sticker : video enabled changed", videoEnabled, "preview enabled =", previewEnabled, "call core camera enabled =", call.core.cameraEnabled) property string qmlName property bool displayAll : !!mainItem.call property bool mutedStatus: participantDevice