Commit 02b7f39c authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/camera/Camera): supports preview

parent b580d24d
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#include <QOpenGLTexture> #include <QOpenGLTexture>
#include <QtMath>
#include "../core/CoreManager.hpp"
#include "Camera.hpp"
// ============================================================================= // =============================================================================
...@@ -52,8 +55,12 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & ...@@ -52,8 +55,12 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
shared_ptr<linphone::Call> linphone_call = m_camera->m_call->getLinphoneCall(); shared_ptr<linphone::Call> linphone_call = m_camera->m_call->getLinphoneCall();
linphone::CallState state = linphone_call->getState(); linphone::CallState state = linphone_call->getState();
if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) {
linphone_call->setNativeVideoWindowId(context_info); if (m_camera->m_is_preview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(context_info);
else
linphone_call->setNativeVideoWindowId(context_info);
}
return new QOpenGLFramebufferObject(size, format); return new QOpenGLFramebufferObject(size, format);
} }
...@@ -63,10 +70,10 @@ void CameraRenderer::render () { ...@@ -63,10 +70,10 @@ void CameraRenderer::render () {
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glClearColor(0.f, 0.f, 0.f, 1.f); f->glClearColor(0.f, 0.f, 0.f, 0.f);
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_camera->getCall()->getLinphoneCall()->oglRender(); m_camera->getCall()->getLinphoneCall()->oglRender(m_camera->m_is_preview);
update(); update();
} }
...@@ -91,14 +98,10 @@ QQuickFramebufferObject::Renderer *Camera::createRenderer () const { ...@@ -91,14 +98,10 @@ QQuickFramebufferObject::Renderer *Camera::createRenderer () const {
return new CameraRenderer(this); return new CameraRenderer(this);
} }
void Camera::hoverMoveEvent (QHoverEvent *) {}
void Camera::mousePressEvent (QMouseEvent *) { void Camera::mousePressEvent (QMouseEvent *) {
setFocus(true); setFocus(true);
} }
void Camera::keyPressEvent (QKeyEvent *) {}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CallModel *Camera::getCall () const { CallModel *Camera::getCall () const {
...@@ -111,8 +114,12 @@ void Camera::setCall (CallModel *call) { ...@@ -111,8 +114,12 @@ void Camera::setCall (CallModel *call) {
shared_ptr<linphone::Call> linphone_call = call->getLinphoneCall(); shared_ptr<linphone::Call> linphone_call = call->getLinphoneCall();
linphone::CallState state = linphone_call->getState(); linphone::CallState state = linphone_call->getState();
if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) {
linphone_call->setNativeVideoWindowId(m_context_info); if (m_is_preview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info);
else
linphone_call->setNativeVideoWindowId(m_context_info);
}
} }
m_call = call; m_call = call;
......
...@@ -32,6 +32,7 @@ class Camera : public QQuickFramebufferObject { ...@@ -32,6 +32,7 @@ class Camera : public QQuickFramebufferObject {
Q_OBJECT; Q_OBJECT;
Q_PROPERTY(CallModel * call READ getCall WRITE setCall NOTIFY callChanged); Q_PROPERTY(CallModel * call READ getCall WRITE setCall NOTIFY callChanged);
Q_PROPERTY(bool isPreview MEMBER m_is_preview NOTIFY isPreviewChanged);
public: public:
Camera (QQuickItem *parent = Q_NULLPTR); Camera (QQuickItem *parent = Q_NULLPTR);
...@@ -41,19 +42,17 @@ public: ...@@ -41,19 +42,17 @@ public:
signals: signals:
void callChanged (CallModel *call); void callChanged (CallModel *call);
void isPreviewChanged (bool is_preview);
protected: protected:
void hoverMoveEvent (QHoverEvent *event) override;
void mousePressEvent (QMouseEvent *event) override; void mousePressEvent (QMouseEvent *event) override;
void keyPressEvent (QKeyEvent *event) override;
private: private:
CallModel *getCall () const; CallModel *getCall () const;
void setCall (CallModel *call); void setCall (CallModel *call);
bool m_is_preview = false;
CallModel *m_call = nullptr; CallModel *m_call = nullptr;
ContextInfo *m_context_info; ContextInfo *m_context_info;
}; };
......
...@@ -14,6 +14,7 @@ CoreManager::CoreManager (QObject *parent) : QObject(parent), m_handlers(make_sh ...@@ -14,6 +14,7 @@ CoreManager::CoreManager (QObject *parent) : QObject(parent), m_handlers(make_sh
m_core = linphone::Factory::get()->createCore(m_handlers, Paths::getConfigFilepath(), ""); m_core = linphone::Factory::get()->createCore(m_handlers, Paths::getConfigFilepath(), "");
m_core->setVideoDisplayFilter("MSOGL"); m_core->setVideoDisplayFilter("MSOGL");
m_core->usePreviewWindow(true);
setDatabasesPaths(); setDatabasesPaths();
} }
......
...@@ -17,6 +17,7 @@ Rectangle { ...@@ -17,6 +17,7 @@ Rectangle {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
property var _contactObserver: SipAddressesModel.getContactObserver(sipAddress) property var _contactObserver: SipAddressesModel.getContactObserver(sipAddress)
property var _call: call
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -128,8 +129,6 @@ Rectangle { ...@@ -128,8 +129,6 @@ Rectangle {
Item { Item {
id: container id: container
property var _call: call
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.margins: CallStyle.container.margins Layout.margins: CallStyle.container.margins
...@@ -182,7 +181,7 @@ Rectangle { ...@@ -182,7 +181,7 @@ Rectangle {
Camera { Camera {
height: container.height height: container.height
width: container.width width: container.width
call: container._call call: incall._call
} }
} }
...@@ -239,11 +238,15 @@ Rectangle { ...@@ -239,11 +238,15 @@ Rectangle {
} }
} }
Item { Camera {
anchors.centerIn: parent anchors.centerIn: parent
height: CallStyle.actionArea.userVideo.height height: CallStyle.actionArea.userVideo.height
visible: Boolean(incall.width >= CallStyle.actionArea.lowWidth && call.videoOutputEnabled)
width: CallStyle.actionArea.userVideo.width width: CallStyle.actionArea.userVideo.width
isPreview: true
call: incall._call
visible: Boolean(incall.width >= CallStyle.actionArea.lowWidth && call.videoOutputEnabled)
} }
ActionBar { ActionBar {
......
linphone @ aa4d6d03
Subproject commit d398c2c61904dd2c128c830dfaa0936be35a039b Subproject commit aa4d6d035d292463f7d523f8fa947142c035ef71
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