diff options
author | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-08-31 16:50:53 +0200 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-09-08 10:18:01 +0000 |
commit | 29ce8886b3bbc306a2ad52a4bc4ea89b3401658a (patch) | |
tree | fbff812178ba200f2c3515e1b30832dcbe90e01c /src/plugins/android/src | |
parent | edc415be476c7ef59f00914b2a6dfc6896d7a34d (diff) | |
download | qtmultimedia-29ce8886b3bbc306a2ad52a4bc4ea89b3401658a.tar.gz |
Android: allow to map video buffers.
Since we internally use a fbo, use QOpenGLFramebufferObject::toImage()
to grab the pixel data and enable the use of map() on frames retrieved
using QAbstractVideoFilter.
Change-Id: If96e992e12e26091524913bb24926fa21d9d58cc
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/plugins/android/src')
-rw-r--r-- | src/plugins/android/src/common/qandroidvideorendercontrol.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp index bf95c42f6..cd9c9d1d6 100644 --- a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp +++ b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp @@ -73,29 +73,60 @@ public: : QAbstractVideoBuffer(GLTextureHandle) , m_control(control) , m_textureUpdated(false) + , m_mapMode(NotMapped) { } virtual ~AndroidTextureVideoBuffer() {} - MapMode mapMode() const { return NotMapped; } - uchar *map(MapMode, int*, int*) { return 0; } - void unmap() {} + MapMode mapMode() const { return m_mapMode; } + + uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) + { + if (m_mapMode == NotMapped && mode == ReadOnly) { + updateFrame(); + m_mapMode = mode; + m_image = m_control->m_fbo->toImage(); + + if (numBytes) + *numBytes = m_image.byteCount(); + + if (bytesPerLine) + *bytesPerLine = m_image.bytesPerLine(); + + return m_image.bits(); + } else { + return 0; + } + } + + void unmap() + { + m_image = QImage(); + m_mapMode = NotMapped; + } QVariant handle() const { + AndroidTextureVideoBuffer *that = const_cast<AndroidTextureVideoBuffer*>(this); + that->updateFrame(); + return m_control->m_fbo->texture(); + } + +private: + void updateFrame() + { if (!m_textureUpdated) { // update the video texture (called from the render thread) m_control->renderFrameToFbo(); m_textureUpdated = true; } - - return m_control->m_fbo->texture(); } -private: - mutable QAndroidVideoRendererControl *m_control; - mutable bool m_textureUpdated; + QAndroidVideoRendererControl *m_control; + bool m_textureUpdated; + MapMode m_mapMode; + QImage m_image; }; QAndroidVideoRendererControl::QAndroidVideoRendererControl(QObject *parent) |