Commit 711d1c66 authored by Wescoeur's avatar Wescoeur

feat(src/components/call/CallModel): add a `cameraFirstFrameReceived`

parent 5c564b1f
...@@ -104,6 +104,15 @@ void CallModel::updateStats (const shared_ptr<const linphone::CallStats> &callSt ...@@ -104,6 +104,15 @@ void CallModel::updateStats (const shared_ptr<const linphone::CallStats> &callSt
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallModel::notifyCameraFirstFrameReceived (unsigned int width, unsigned int height) {
if (mNotifyCameraFirstFrameReceived) {
mNotifyCameraFirstFrameReceived = false;
emit cameraFirstFrameReceived(width, height);
}
}
// -----------------------------------------------------------------------------
void CallModel::accept () { void CallModel::accept () {
stopAutoAnswerTimer(); stopAutoAnswerTimer();
...@@ -231,10 +240,12 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call, ...@@ -231,10 +240,12 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call,
break; break;
case linphone::CallStatePausedByRemote: case linphone::CallStatePausedByRemote:
mNotifyCameraFirstFrameReceived = true;
mPausedByRemote = true; mPausedByRemote = true;
break; break;
case linphone::CallStatePausing: case linphone::CallStatePausing:
mNotifyCameraFirstFrameReceived = true;
mPausedByUser = true; mPausedByUser = true;
break; break;
......
...@@ -98,6 +98,8 @@ public: ...@@ -98,6 +98,8 @@ public:
static void setRecordFile (std::shared_ptr<linphone::CallParams> &callParams); static void setRecordFile (std::shared_ptr<linphone::CallParams> &callParams);
void updateStats (const std::shared_ptr<const linphone::CallStats> &callStats); void updateStats (const std::shared_ptr<const linphone::CallStats> &callStats);
void notifyCameraFirstFrameReceived (unsigned int width, unsigned int height);
Q_INVOKABLE void accept (); Q_INVOKABLE void accept ();
Q_INVOKABLE void acceptWithVideo (); Q_INVOKABLE void acceptWithVideo ();
Q_INVOKABLE void terminate (); Q_INVOKABLE void terminate ();
...@@ -127,6 +129,8 @@ signals: ...@@ -127,6 +129,8 @@ signals:
void videoRequested (); void videoRequested ();
void securityUpdated (); void securityUpdated ();
void cameraFirstFrameReceived (unsigned int width, unsigned int height);
private: private:
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
...@@ -183,6 +187,8 @@ private: ...@@ -183,6 +187,8 @@ private:
bool mPausedByUser = false; bool mPausedByUser = false;
bool mRecording = false; bool mRecording = false;
bool mNotifyCameraFirstFrameReceived = true;
QString mCallError; QString mCallError;
QVariantList mAudioStats; QVariantList mAudioStats;
......
...@@ -104,8 +104,11 @@ void CameraRenderer::render () { ...@@ -104,8 +104,11 @@ void CameraRenderer::render () {
if (mIsPreview) if (mIsPreview)
coreManager->getCore()->previewOglRender(); coreManager->getCore()->previewOglRender();
else if (mCall) else if (mCall) {
mCall->oglRender(); mCall->oglRender();
if (mNotifyReceivedVideoSize && notifyReceivedVideoSize())
mNotifyReceivedVideoSize = false;
}
msFunctions->bind(nullptr); msFunctions->bind(nullptr);
coreManager->unlockVideoRender(); coreManager->unlockVideoRender();
...@@ -148,6 +151,26 @@ void CameraRenderer::updateWindowId () { ...@@ -148,6 +151,26 @@ void CameraRenderer::updateWindowId () {
mCall->setNativeVideoWindowId(mContextInfo); mCall->setNativeVideoWindowId(mContextInfo);
} }
bool CameraRenderer::notifyReceivedVideoSize () const {
shared_ptr<const linphone::VideoDefinition> 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<CallModel>("call-model");
QTimer::singleShot(0, callModel, [callModel, width, height] {
callModel->notifyCameraFirstFrameReceived(width, height);
});
return true;
}
return false;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) { Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) {
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
// ============================================================================= // =============================================================================
class CallModel; class CallModel;
class Camera;
struct ContextInfo; struct ContextInfo;
namespace linphone { namespace linphone {
...@@ -39,8 +38,6 @@ namespace linphone { ...@@ -39,8 +38,6 @@ namespace linphone {
} }
class CameraRenderer : public QQuickFramebufferObject::Renderer { class CameraRenderer : public QQuickFramebufferObject::Renderer {
friend class Camera;
public: public:
CameraRenderer (); CameraRenderer ();
~CameraRenderer (); ~CameraRenderer ();
...@@ -52,10 +49,12 @@ protected: ...@@ -52,10 +49,12 @@ protected:
private: private:
void updateWindowId (); void updateWindowId ();
bool notifyReceivedVideoSize () const;
ContextInfo *mContextInfo; ContextInfo *mContextInfo;
bool mUpdateContextInfo = false; bool mUpdateContextInfo = false;
bool mNotifyReceivedVideoSize = true;
bool mIsPreview = false; bool mIsPreview = false;
std::shared_ptr<linphone::Call> mCall; std::shared_ptr<linphone::Call> mCall;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment