force set camera enabled when accepting call (camera seems to be enabled by default on macos)

This commit is contained in:
gaelle.braud 2026-02-12 12:22:29 +01:00
parent 7e0a33766b
commit 0b1c081aaa
4 changed files with 24 additions and 4 deletions

View file

@ -112,7 +112,7 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &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<CallCore> 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<CallCore> me) {
mCallModelConnection->makeConnectToModel(&CallModel::stateChanged, [this](std::shared_ptr<linphone::Call> 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();
}
}

View file

@ -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<linphone::CallParams> &params
.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);
}

View file

@ -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

View file

@ -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