summaryrefslogtreecommitdiffstats
path: root/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2013-09-27 11:24:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-01 17:26:21 +0200
commitbe7a6241e77f67e4a19c63ac5683dd7fa566e9d2 (patch)
treeab8b66b5124d4a982d7690cf7893a40650bccc8d /src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
parent329d9d4563445d785284a02983e237ff1a07f5dd (diff)
Android: refactor video renderer.
Removed the overhead of having to create a shared OpenGL context in the GUI thread and pre-render the frame into a FBO. We now directly render the GL_TEXTURE_EXTERNAL_OES in the QtQuick render thread, using an Android-specific QSGVideoNode. We also use a callback from the render thread to create the texture from there and not have to create a separate shared OpenGL context. Change-Id: I6c8eb94b47d0a03329c912701b8af3fb5ebd1876 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src/plugins/android/src/mediacapture/qandroidcamerasession.cpp')
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcamerasession.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
index 761b716d1..ec86322a4 100644
--- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
@@ -52,12 +52,6 @@
QT_BEGIN_NAMESPACE
-static void textureReadyCallback(void *context)
-{
- if (context)
- reinterpret_cast<QAndroidCameraSession *>(context)->onSurfaceTextureReady();
-}
-
QAndroidCameraSession::QAndroidCameraSession(QObject *parent)
: QObject(parent)
, m_selectedCamera(0)
@@ -188,12 +182,17 @@ void QAndroidCameraSession::close()
emit statusChanged(m_status);
}
-void QAndroidCameraSession::setVideoPreview(QAndroidVideoOutput *videoOutput)
+void QAndroidCameraSession::setVideoPreview(QObject *videoOutput)
{
if (m_videoOutput)
m_videoOutput->stop();
- m_videoOutput = videoOutput;
+ if (videoOutput) {
+ connect(videoOutput, SIGNAL(readyChanged(bool)), this, SLOT(onVideoOutputReady(bool)));
+ m_videoOutput = qobject_cast<QAndroidVideoOutput *>(videoOutput);
+ } else {
+ m_videoOutput = 0;
+ }
}
void QAndroidCameraSession::adjustViewfinderSize(const QSize &captureSize, bool restartPreview)
@@ -243,12 +242,8 @@ void QAndroidCameraSession::startPreview()
applyImageSettings();
adjustViewfinderSize(m_imageSettings.resolution());
- if (m_videoOutput) {
- if (m_videoOutput->isTextureReady())
- m_camera->setPreviewTexture(m_videoOutput->surfaceTexture());
- else
- m_videoOutput->setTextureReadyCallback(textureReadyCallback, this);
- }
+ if (m_videoOutput && m_videoOutput->isReady())
+ onVideoOutputReady(true);
JMultimediaUtils::enableOrientationListener(true);
@@ -522,9 +517,9 @@ void QAndroidCameraSession::processCapturedImage(int id,
}
}
-void QAndroidCameraSession::onSurfaceTextureReady()
+void QAndroidCameraSession::onVideoOutputReady(bool ready)
{
- if (m_camera && m_videoOutput)
+ if (m_camera && m_videoOutput && ready)
m_camera->setPreviewTexture(m_videoOutput->surfaceTexture());
}