diff --git a/linphone-desktop/src/components/call/CallModel.cpp b/linphone-desktop/src/components/call/CallModel.cpp index 3bdda49d6..827c72306 100644 --- a/linphone-desktop/src/components/call/CallModel.cpp +++ b/linphone-desktop/src/components/call/CallModel.cpp @@ -104,6 +104,15 @@ void CallModel::updateStats (const shared_ptr &callSt // ----------------------------------------------------------------------------- +void CallModel::notifyCameraFirstFrameReceived (unsigned int width, unsigned int height) { + if (mNotifyCameraFirstFrameReceived) { + mNotifyCameraFirstFrameReceived = false; + emit cameraFirstFrameReceived(width, height); + } +} + +// ----------------------------------------------------------------------------- + void CallModel::accept () { stopAutoAnswerTimer(); @@ -231,10 +240,12 @@ void CallModel::handleCallStateChanged (const shared_ptr &call, break; case linphone::CallStatePausedByRemote: + mNotifyCameraFirstFrameReceived = true; mPausedByRemote = true; break; case linphone::CallStatePausing: + mNotifyCameraFirstFrameReceived = true; mPausedByUser = true; break; diff --git a/linphone-desktop/src/components/call/CallModel.hpp b/linphone-desktop/src/components/call/CallModel.hpp index 03d3c0cc7..738ec0c34 100644 --- a/linphone-desktop/src/components/call/CallModel.hpp +++ b/linphone-desktop/src/components/call/CallModel.hpp @@ -98,6 +98,8 @@ public: static void setRecordFile (std::shared_ptr &callParams); void updateStats (const std::shared_ptr &callStats); + void notifyCameraFirstFrameReceived (unsigned int width, unsigned int height); + Q_INVOKABLE void accept (); Q_INVOKABLE void acceptWithVideo (); Q_INVOKABLE void terminate (); @@ -127,6 +129,8 @@ signals: void videoRequested (); void securityUpdated (); + void cameraFirstFrameReceived (unsigned int width, unsigned int height); + private: void handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state); @@ -183,6 +187,8 @@ private: bool mPausedByUser = false; bool mRecording = false; + bool mNotifyCameraFirstFrameReceived = true; + QString mCallError; QVariantList mAudioStats; diff --git a/linphone-desktop/src/components/camera/Camera.cpp b/linphone-desktop/src/components/camera/Camera.cpp index a11db40f2..50bc5d066 100644 --- a/linphone-desktop/src/components/camera/Camera.cpp +++ b/linphone-desktop/src/components/camera/Camera.cpp @@ -104,8 +104,11 @@ void CameraRenderer::render () { if (mIsPreview) coreManager->getCore()->previewOglRender(); - else if (mCall) + else if (mCall) { mCall->oglRender(); + if (mNotifyReceivedVideoSize && notifyReceivedVideoSize()) + mNotifyReceivedVideoSize = false; + } msFunctions->bind(nullptr); coreManager->unlockVideoRender(); @@ -148,6 +151,26 @@ void CameraRenderer::updateWindowId () { mCall->setNativeVideoWindowId(mContextInfo); } +bool CameraRenderer::notifyReceivedVideoSize () const { + shared_ptr videoDefinition = mCall->getCurrentParams()->getReceivedVideoDefinition(); + unsigned int width = videoDefinition->getWidth(); + unsigned int height = videoDefinition->getHeight(); + + if (width && height) { + qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Received video size (width: %1, height: %2):") + .arg(width).arg(height) << mContextInfo; + + CallModel *callModel = &mCall->getData("call-model"); + QTimer::singleShot(0, callModel, [callModel, width, height] { + callModel->notifyCameraFirstFrameReceived(width, height); + }); + + return true; + } + + return false; +} + // ----------------------------------------------------------------------------- Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) { diff --git a/linphone-desktop/src/components/camera/Camera.hpp b/linphone-desktop/src/components/camera/Camera.hpp index a7526da24..cc27a62fb 100644 --- a/linphone-desktop/src/components/camera/Camera.hpp +++ b/linphone-desktop/src/components/camera/Camera.hpp @@ -31,7 +31,6 @@ // ============================================================================= class CallModel; -class Camera; struct ContextInfo; namespace linphone { @@ -39,8 +38,6 @@ namespace linphone { } class CameraRenderer : public QQuickFramebufferObject::Renderer { - friend class Camera; - public: CameraRenderer (); ~CameraRenderer (); @@ -52,10 +49,12 @@ protected: private: void updateWindowId (); + bool notifyReceivedVideoSize () const; ContextInfo *mContextInfo; bool mUpdateContextInfo = false; + bool mNotifyReceivedVideoSize = true; bool mIsPreview = false; std::shared_ptr mCall;