From 02b7f39ca54972fccdc06ea73c7bc62a87009fd7 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 1 Feb 2017 14:26:27 +0100 Subject: [PATCH] feat(src/components/camera/Camera): supports preview --- .../src/components/camera/Camera.cpp | 29 ++++++++++++------- .../src/components/camera/Camera.hpp | 7 ++--- .../src/components/core/CoreManager.cpp | 1 + .../ui/views/App/Calls/Incall.qml | 13 +++++---- submodules/linphone | 2 +- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/linphone-desktop/src/components/camera/Camera.cpp b/linphone-desktop/src/components/camera/Camera.cpp index 39c07d346..fd52c5e1c 100644 --- a/linphone-desktop/src/components/camera/Camera.cpp +++ b/linphone-desktop/src/components/camera/Camera.cpp @@ -2,7 +2,10 @@ #include #include -#include + +#include "../core/CoreManager.hpp" + +#include "Camera.hpp" // ============================================================================= @@ -52,8 +55,12 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & shared_ptr linphone_call = m_camera->m_call->getLinphoneCall(); linphone::CallState state = linphone_call->getState(); - if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) - linphone_call->setNativeVideoWindowId(context_info); + if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) { + if (m_camera->m_is_preview) + CoreManager::getInstance()->getCore()->setNativePreviewWindowId(context_info); + else + linphone_call->setNativeVideoWindowId(context_info); + } return new QOpenGLFramebufferObject(size, format); } @@ -63,10 +70,10 @@ void CameraRenderer::render () { 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); - m_camera->getCall()->getLinphoneCall()->oglRender(); + m_camera->getCall()->getLinphoneCall()->oglRender(m_camera->m_is_preview); update(); } @@ -91,14 +98,10 @@ QQuickFramebufferObject::Renderer *Camera::createRenderer () const { return new CameraRenderer(this); } -void Camera::hoverMoveEvent (QHoverEvent *) {} - void Camera::mousePressEvent (QMouseEvent *) { setFocus(true); } -void Camera::keyPressEvent (QKeyEvent *) {} - // ----------------------------------------------------------------------------- CallModel *Camera::getCall () const { @@ -111,8 +114,12 @@ void Camera::setCall (CallModel *call) { shared_ptr linphone_call = call->getLinphoneCall(); linphone::CallState state = linphone_call->getState(); - if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) - linphone_call->setNativeVideoWindowId(m_context_info); + if (state == linphone::CallStateConnected || state == linphone::CallStateStreamsRunning) { + if (m_is_preview) + CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info); + else + linphone_call->setNativeVideoWindowId(m_context_info); + } } m_call = call; diff --git a/linphone-desktop/src/components/camera/Camera.hpp b/linphone-desktop/src/components/camera/Camera.hpp index dfc9e770f..3f0385c52 100644 --- a/linphone-desktop/src/components/camera/Camera.hpp +++ b/linphone-desktop/src/components/camera/Camera.hpp @@ -32,6 +32,7 @@ class Camera : public QQuickFramebufferObject { Q_OBJECT; Q_PROPERTY(CallModel * call READ getCall WRITE setCall NOTIFY callChanged); + Q_PROPERTY(bool isPreview MEMBER m_is_preview NOTIFY isPreviewChanged); public: Camera (QQuickItem *parent = Q_NULLPTR); @@ -41,19 +42,17 @@ public: signals: void callChanged (CallModel *call); + void isPreviewChanged (bool is_preview); protected: - void hoverMoveEvent (QHoverEvent *event) override; void mousePressEvent (QMouseEvent *event) override; - void keyPressEvent (QKeyEvent *event) override; - private: CallModel *getCall () const; void setCall (CallModel *call); + bool m_is_preview = false; CallModel *m_call = nullptr; - ContextInfo *m_context_info; }; diff --git a/linphone-desktop/src/components/core/CoreManager.cpp b/linphone-desktop/src/components/core/CoreManager.cpp index ceadd68e7..74d26b303 100644 --- a/linphone-desktop/src/components/core/CoreManager.cpp +++ b/linphone-desktop/src/components/core/CoreManager.cpp @@ -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->setVideoDisplayFilter("MSOGL"); + m_core->usePreviewWindow(true); setDatabasesPaths(); } diff --git a/linphone-desktop/ui/views/App/Calls/Incall.qml b/linphone-desktop/ui/views/App/Calls/Incall.qml index 41a029b77..c38651ae5 100644 --- a/linphone-desktop/ui/views/App/Calls/Incall.qml +++ b/linphone-desktop/ui/views/App/Calls/Incall.qml @@ -17,6 +17,7 @@ Rectangle { // --------------------------------------------------------------------------- property var _contactObserver: SipAddressesModel.getContactObserver(sipAddress) + property var _call: call // --------------------------------------------------------------------------- @@ -128,8 +129,6 @@ Rectangle { Item { id: container - property var _call: call - Layout.fillWidth: true Layout.fillHeight: true Layout.margins: CallStyle.container.margins @@ -182,7 +181,7 @@ Rectangle { Camera { height: container.height width: container.width - call: container._call + call: incall._call } } @@ -239,11 +238,15 @@ Rectangle { } } - Item { + Camera { anchors.centerIn: parent height: CallStyle.actionArea.userVideo.height - visible: Boolean(incall.width >= CallStyle.actionArea.lowWidth && call.videoOutputEnabled) width: CallStyle.actionArea.userVideo.width + + isPreview: true + + call: incall._call + visible: Boolean(incall.width >= CallStyle.actionArea.lowWidth && call.videoOutputEnabled) } ActionBar { diff --git a/submodules/linphone b/submodules/linphone index d398c2c61..aa4d6d035 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit d398c2c61904dd2c128c830dfaa0936be35a039b +Subproject commit aa4d6d035d292463f7d523f8fa947142c035ef71