mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-20 21:28:07 +00:00
feat(src/components/camera/Camera): supports preview
This commit is contained in:
parent
b580d24dc7
commit
02b7f39ca5
5 changed files with 31 additions and 21 deletions
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QtMath>
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
|
||||
#include "Camera.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -52,8 +55,12 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
|
|||
shared_ptr<linphone::Call> 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> 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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit d398c2c61904dd2c128c830dfaa0936be35a039b
|
||||
Subproject commit aa4d6d035d292463f7d523f8fa947142c035ef71
|
||||
Loading…
Add table
Reference in a new issue