summaryrefslogtreecommitdiffstats
path: root/src/plugins/android/src/wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/android/src/wrappers')
-rw-r--r--src/plugins/android/src/wrappers/jcamera.cpp712
-rw-r--r--src/plugins/android/src/wrappers/jcamera.h166
-rw-r--r--src/plugins/android/src/wrappers/jmediametadataretriever.cpp126
-rw-r--r--src/plugins/android/src/wrappers/jmediametadataretriever.h91
-rw-r--r--src/plugins/android/src/wrappers/jmediaplayer.cpp270
-rw-r--r--src/plugins/android/src/wrappers/jmediaplayer.h135
-rw-r--r--src/plugins/android/src/wrappers/jmediarecorder.cpp242
-rw-r--r--src/plugins/android/src/wrappers/jmediarecorder.h134
-rw-r--r--src/plugins/android/src/wrappers/jmultimediautils.cpp95
-rw-r--r--src/plugins/android/src/wrappers/jmultimediautils.h73
-rw-r--r--src/plugins/android/src/wrappers/jsurfacetexture.cpp113
-rw-r--r--src/plugins/android/src/wrappers/jsurfacetexture.h73
-rw-r--r--src/plugins/android/src/wrappers/jsurfacetextureholder.cpp65
-rw-r--r--src/plugins/android/src/wrappers/jsurfacetextureholder.h59
-rw-r--r--src/plugins/android/src/wrappers/wrappers.pri21
15 files changed, 2375 insertions, 0 deletions
diff --git a/src/plugins/android/src/wrappers/jcamera.cpp b/src/plugins/android/src/wrappers/jcamera.cpp
new file mode 100644
index 000000000..9005ac6e0
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jcamera.cpp
@@ -0,0 +1,712 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "jcamera.h"
+
+#include <QtPlatformSupport/private/qjnihelpers_p.h>
+#include <qstringlist.h>
+#include <qdebug.h>
+#include "qandroidmultimediautils.h"
+
+QT_BEGIN_NAMESPACE
+
+static jclass g_qtCameraClass = 0;
+static QMap<int, JCamera*> g_objectMap;
+
+static QRect areaToRect(jobject areaObj)
+{
+ QJNIObject area(areaObj);
+ QJNILocalRef<jobject> rectRef = area.getObjectField<jobject>("rect", "android/graphics/Rect");
+ QJNIObject rect(rectRef.object());
+
+ return QRect(rect.getField<jint>("left"),
+ rect.getField<jint>("top"),
+ rect.callMethod<jint>("width"),
+ rect.callMethod<jint>("height"));
+}
+
+static QJNILocalRef<jobject> rectToArea(const QRect &rect)
+{
+ QJNIObject jrect("android/graphics/Rect",
+ "(IIII)V",
+ rect.left(), rect.top(), rect.right(), rect.bottom());
+
+ QJNIObject area("android/hardware/Camera$Area",
+ "(Landroid/graphics/Rect;I)V",
+ jrect.object(), 500);
+
+ return QJNILocalRef<jobject>(QAttachedJNIEnv()->NewLocalRef(area.object()));
+}
+
+// native method for QtCamera.java
+static void notifyAutoFocusComplete(JNIEnv* , jobject, int id, jboolean success)
+{
+ JCamera *obj = g_objectMap.value(id, 0);
+ if (obj)
+ Q_EMIT obj->autoFocusComplete(success);
+}
+
+static void notifyPictureExposed(JNIEnv* , jobject, int id)
+{
+ JCamera *obj = g_objectMap.value(id, 0);
+ if (obj)
+ Q_EMIT obj->pictureExposed();
+}
+
+static void notifyPictureCaptured(JNIEnv *env, jobject, int id, jbyteArray data)
+{
+ JCamera *obj = g_objectMap.value(id, 0);
+ if (obj) {
+ QByteArray bytes;
+ int arrayLength = env->GetArrayLength(data);
+ bytes.resize(arrayLength);
+ env->GetByteArrayRegion(data, 0, arrayLength, (jbyte*)bytes.data());
+ Q_EMIT obj->pictureCaptured(bytes);
+ }
+}
+
+JCamera::JCamera(int cameraId, jobject cam)
+ : QObject()
+ , QJNIObject(cam)
+ , m_cameraId(cameraId)
+ , m_info(0)
+ , m_parameters(0)
+ , m_hasAPI14(false)
+{
+ if (isValid()) {
+ g_objectMap.insert(cameraId, this);
+
+ m_info = new QJNIObject("android/hardware/Camera$CameraInfo");
+ callStaticMethod<void>("android/hardware/Camera",
+ "getCameraInfo",
+ "(ILandroid/hardware/Camera$CameraInfo;)V",
+ cameraId, m_info->object());
+
+ QJNILocalRef<jobject> params = callObjectMethod<jobject>("getParameters",
+ "()Landroid/hardware/Camera$Parameters;");
+ m_parameters = new QJNIObject(params.object());
+
+ // Check if API 14 is available
+ QAttachedJNIEnv env;
+ jclass clazz = env->FindClass("android/hardware/Camera");
+ if (env->ExceptionCheck()) {
+ clazz = 0;
+ env->ExceptionClear();
+ }
+ if (clazz) {
+ // startFaceDetection() was added in API 14
+ jmethodID id = env->GetMethodID(clazz, "startFaceDetection", "()V");
+ if (env->ExceptionCheck()) {
+ id = 0;
+ env->ExceptionClear();
+ }
+ m_hasAPI14 = bool(id);
+ }
+ }
+}
+
+JCamera::~JCamera()
+{
+ if (isValid())
+ g_objectMap.remove(m_cameraId);
+ delete m_parameters;
+ delete m_info;
+}
+
+JCamera *JCamera::open(int cameraId)
+{
+ QAttachedJNIEnv env;
+
+ QJNILocalRef<jobject> camera = callStaticObjectMethod<jobject>(g_qtCameraClass,
+ "open",
+ "(I)Lorg/qtproject/qt5/android/multimedia/QtCamera;",
+ cameraId);
+
+ if (camera.isNull())
+ return 0;
+ else
+ return new JCamera(cameraId, camera.object());
+}
+
+void JCamera::lock()
+{
+ callMethod<void>("lock");
+}
+
+void JCamera::unlock()
+{
+ callMethod<void>("unlock");
+}
+
+void JCamera::reconnect()
+{
+ callMethod<void>("reconnect");
+}
+
+void JCamera::release()
+{
+ m_previewSize = QSize();
+ delete m_parameters;
+ m_parameters = 0;
+ callMethod<void>("release");
+}
+
+JCamera::CameraFacing JCamera::getFacing()
+{
+ return CameraFacing(m_info->getField<jint>("facing"));
+}
+
+int JCamera::getNativeOrientation()
+{
+ return m_info->getField<jint>("orientation");
+}
+
+QSize JCamera::getPreferredPreviewSizeForVideo()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return QSize();
+
+ QJNILocalRef<jobject> sizeRef = m_parameters->callObjectMethod<jobject>("getPreferredPreviewSizeForVideo",
+ "()Landroid/hardware/Camera$Size;");
+
+ QJNIObject size(sizeRef.object());
+ return QSize(size.getField<jint>("width"), size.getField<jint>("height"));
+}
+
+QList<QSize> JCamera::getSupportedPreviewSizes()
+{
+ QList<QSize> list;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jobject> sizeListRef = m_parameters->callObjectMethod<jobject>("getSupportedPreviewSizes",
+ "()Ljava/util/List;");
+ QJNIObject sizeList(sizeListRef.object());
+ int count = sizeList.callMethod<jint>("size");
+ for (int i = 0; i < count; ++i) {
+ QJNILocalRef<jobject> sizeRef = sizeList.callObjectMethod<jobject>("get",
+ "(I)Ljava/lang/Object;",
+ i);
+ QJNIObject size(sizeRef.object());
+ list.append(QSize(size.getField<jint>("width"), size.getField<jint>("height")));
+ }
+
+ qSort(list.begin(), list.end(), qt_sizeLessThan);
+ }
+
+ return list;
+}
+
+void JCamera::setPreviewSize(const QSize &size)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_previewSize = size;
+
+ m_parameters->callMethod<void>("setPreviewSize", "(II)V", size.width(), size.height());
+ applyParameters();
+
+ emit previewSizeChanged();
+}
+
+void JCamera::setPreviewTexture(jobject surfaceTexture)
+{
+ callMethod<void>("setPreviewTexture", "(Landroid/graphics/SurfaceTexture;)V", surfaceTexture);
+}
+
+bool JCamera::isZoomSupported()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return false;
+
+ return m_parameters->callMethod<jboolean>("isZoomSupported");
+}
+
+int JCamera::getMaxZoom()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return 0;
+
+ return m_parameters->callMethod<jint>("getMaxZoom");
+}
+
+QList<int> JCamera::getZoomRatios()
+{
+ QList<int> ratios;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jobject> ratioListRef = m_parameters->callObjectMethod<jobject>("getZoomRatios",
+ "()Ljava/util/List;");
+ QJNIObject ratioList(ratioListRef.object());
+ int count = ratioList.callMethod<jint>("size");
+ for (int i = 0; i < count; ++i) {
+ QJNILocalRef<jobject> zoomRatioRef = ratioList.callObjectMethod<jobject>("get",
+ "(I)Ljava/lang/Object;",
+ i);
+
+ QJNIObject zoomRatio(zoomRatioRef.object());
+ ratios.append(zoomRatio.callMethod<jint>("intValue"));
+ }
+ }
+
+ return ratios;
+}
+
+int JCamera::getZoom()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return 0;
+
+ return m_parameters->callMethod<jint>("getZoom");
+}
+
+void JCamera::setZoom(int value)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setZoom", "(I)V", value);
+ applyParameters();
+}
+
+QStringList JCamera::getSupportedFlashModes()
+{
+ return callStringListMethod("getSupportedFlashModes");
+}
+
+QString JCamera::getFlashMode()
+{
+ QString value;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jstring> flashMode = m_parameters->callObjectMethod<jstring>("getFlashMode",
+ "()Ljava/lang/String;");
+ if (!flashMode.isNull())
+ value = qt_convertJString(flashMode.object());
+ }
+
+ return value;
+}
+
+void JCamera::setFlashMode(const QString &value)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setFlashMode",
+ "(Ljava/lang/String;)V",
+ qt_toJString(value).object());
+ applyParameters();
+}
+
+QStringList JCamera::getSupportedFocusModes()
+{
+ return callStringListMethod("getSupportedFocusModes");
+}
+
+QString JCamera::getFocusMode()
+{
+ QString value;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jstring> focusMode = m_parameters->callObjectMethod<jstring>("getFocusMode",
+ "()Ljava/lang/String;");
+ if (!focusMode.isNull())
+ value = qt_convertJString(focusMode.object());
+ }
+
+ return value;
+}
+
+void JCamera::setFocusMode(const QString &value)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setFocusMode",
+ "(Ljava/lang/String;)V",
+ qt_toJString(value).object());
+ applyParameters();
+}
+
+int JCamera::getMaxNumFocusAreas()
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return 0;
+
+ return m_parameters->callMethod<jint>("getMaxNumFocusAreas");
+}
+
+QList<QRect> JCamera::getFocusAreas()
+{
+ QList<QRect> areas;
+
+ if (m_hasAPI14 && m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jobject> listRef = m_parameters->callObjectMethod<jobject>("getFocusAreas",
+ "()Ljava/util/List;");
+
+ if (!listRef.isNull()) {
+ QJNIObject list(listRef.object());
+ int count = list.callMethod<jint>("size");
+ for (int i = 0; i < count; ++i) {
+ QJNILocalRef<jobject> areaRef = list.callObjectMethod<jobject>("get",
+ "(I)Ljava/lang/Object;",
+ i);
+
+ areas.append(areaToRect(areaRef.object()));
+ }
+ }
+ }
+
+ return areas;
+}
+
+void JCamera::setFocusAreas(const QList<QRect> &areas)
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return;
+
+ QJNILocalRef<jobject> list(0);
+
+ if (!areas.isEmpty()) {
+ QAttachedJNIEnv env;
+ QJNIObject arrayList("java/util/ArrayList", "(I)V", areas.size());
+ for (int i = 0; i < areas.size(); ++i) {
+ arrayList.callMethod<jboolean>("add",
+ "(Ljava/lang/Object;)Z",
+ rectToArea(areas.at(i)).object());
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+ }
+ list = env->NewLocalRef(arrayList.object());
+ }
+
+ m_parameters->callMethod<void>("setFocusAreas", "(Ljava/util/List;)V", list.object());
+
+ applyParameters();
+}
+
+void JCamera::autoFocus()
+{
+ callMethod<void>("autoFocus");
+ emit autoFocusStarted();
+}
+
+void JCamera::cancelAutoFocus()
+{
+ callMethod<void>("cancelAutoFocus");
+}
+
+bool JCamera::isAutoExposureLockSupported()
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return false;
+
+ return m_parameters->callMethod<jboolean>("isAutoExposureLockSupported");
+}
+
+bool JCamera::getAutoExposureLock()
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return false;
+
+ return m_parameters->callMethod<jboolean>("getAutoExposureLock");
+}
+
+void JCamera::setAutoExposureLock(bool toggle)
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setAutoExposureLock", "(Z)V", toggle);
+ applyParameters();
+}
+
+bool JCamera::isAutoWhiteBalanceLockSupported()
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return false;
+
+ return m_parameters->callMethod<jboolean>("isAutoWhiteBalanceLockSupported");
+}
+
+bool JCamera::getAutoWhiteBalanceLock()
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return false;
+
+ return m_parameters->callMethod<jboolean>("getAutoWhiteBalanceLock");
+}
+
+void JCamera::setAutoWhiteBalanceLock(bool toggle)
+{
+ if (!m_hasAPI14 || !m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setAutoWhiteBalanceLock", "(Z)V", toggle);
+ applyParameters();
+}
+
+int JCamera::getExposureCompensation()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return 0;
+
+ return m_parameters->callMethod<jint>("getExposureCompensation");
+}
+
+void JCamera::setExposureCompensation(int value)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setExposureCompensation", "(I)V", value);
+ applyParameters();
+}
+
+float JCamera::getExposureCompensationStep()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return 0;
+
+ return m_parameters->callMethod<jfloat>("getExposureCompensationStep");
+}
+
+int JCamera::getMinExposureCompensation()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return 0;
+
+ return m_parameters->callMethod<jint>("getMinExposureCompensation");
+}
+
+int JCamera::getMaxExposureCompensation()
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return 0;
+
+ return m_parameters->callMethod<jint>("getMaxExposureCompensation");
+}
+
+QStringList JCamera::getSupportedSceneModes()
+{
+ return callStringListMethod("getSupportedSceneModes");
+}
+
+QString JCamera::getSceneMode()
+{
+ QString value;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jstring> sceneMode = m_parameters->callObjectMethod<jstring>("getSceneMode",
+ "()Ljava/lang/String;");
+ if (!sceneMode.isNull())
+ value = qt_convertJString(sceneMode.object());
+ }
+
+ return value;
+}
+
+void JCamera::setSceneMode(const QString &value)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setSceneMode",
+ "(Ljava/lang/String;)V",
+ qt_toJString(value).object());
+ applyParameters();
+}
+
+QStringList JCamera::getSupportedWhiteBalance()
+{
+ return callStringListMethod("getSupportedWhiteBalance");
+}
+
+QString JCamera::getWhiteBalance()
+{
+ QString value;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jstring> wb = m_parameters->callObjectMethod<jstring>("getWhiteBalance",
+ "()Ljava/lang/String;");
+ if (!wb.isNull())
+ value = qt_convertJString(wb.object());
+ }
+
+ return value;
+}
+
+void JCamera::setWhiteBalance(const QString &value)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setWhiteBalance",
+ "(Ljava/lang/String;)V",
+ qt_toJString(value).object());
+ applyParameters();
+
+ emit whiteBalanceChanged();
+}
+
+void JCamera::setRotation(int rotation)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setRotation", "(I)V", rotation);
+ applyParameters();
+}
+
+QList<QSize> JCamera::getSupportedPictureSizes()
+{
+ QList<QSize> list;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jobject> sizeListRef = m_parameters->callObjectMethod<jobject>("getSupportedPictureSizes",
+ "()Ljava/util/List;");
+ QJNIObject sizeList(sizeListRef.object());
+ int count = sizeList.callMethod<jint>("size");
+ for (int i = 0; i < count; ++i) {
+ QJNILocalRef<jobject> sizeRef = sizeList.callObjectMethod<jobject>("get",
+ "(I)Ljava/lang/Object;",
+ i);
+ QJNIObject size(sizeRef.object());
+ list.append(QSize(size.getField<jint>("width"), size.getField<jint>("height")));
+ }
+
+ qSort(list.begin(), list.end(), qt_sizeLessThan);
+ }
+
+ return list;
+}
+
+void JCamera::setPictureSize(const QSize &size)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setPictureSize", "(II)V", size.width(), size.height());
+ applyParameters();
+}
+
+void JCamera::setJpegQuality(int quality)
+{
+ if (!m_parameters || !m_parameters->isValid())
+ return;
+
+ m_parameters->callMethod<void>("setJpegQuality", "(I)V", quality);
+ applyParameters();
+}
+
+void JCamera::takePicture()
+{
+ callMethod<void>("takePicture");
+}
+
+void JCamera::startPreview()
+{
+ callMethod<void>("startPreview");
+}
+
+void JCamera::stopPreview()
+{
+ callMethod<void>("stopPreview");
+}
+
+void JCamera::applyParameters()
+{
+ callMethod<void>("setParameters",
+ "(Landroid/hardware/Camera$Parameters;)V",
+ m_parameters->object());
+}
+
+QStringList JCamera::callStringListMethod(const char *methodName)
+{
+ QStringList stringList;
+
+ if (m_parameters && m_parameters->isValid()) {
+ QJNILocalRef<jobject> listRef = m_parameters->callObjectMethod<jobject>(methodName,
+ "()Ljava/util/List;");
+
+ if (!listRef.isNull()) {
+ QJNIObject list(listRef.object());
+ int count = list.callMethod<jint>("size");
+ for (int i = 0; i < count; ++i) {
+ QJNILocalRef<jobject> stringRef = list.callObjectMethod<jobject>("get",
+ "(I)Ljava/lang/Object;",
+ i);
+
+ QJNIObject string(stringRef.object());
+ stringList.append(qt_convertJString(string.callObjectMethod<jstring>("toString").object()));
+ }
+ }
+ }
+
+ return stringList;
+}
+
+static JNINativeMethod methods[] = {
+ {"notifyAutoFocusComplete", "(IZ)V", (void *)notifyAutoFocusComplete},
+ {"notifyPictureExposed", "(I)V", (void *)notifyPictureExposed},
+ {"notifyPictureCaptured", "(I[B)V", (void *)notifyPictureCaptured}
+};
+
+bool JCamera::initJNI(JNIEnv *env)
+{
+ jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtCamera");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+
+ if (clazz) {
+ g_qtCameraClass = static_cast<jclass>(env->NewGlobalRef(clazz));
+ if (env->RegisterNatives(g_qtCameraClass,
+ methods,
+ sizeof(methods) / sizeof(methods[0])) < 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/android/src/wrappers/jcamera.h b/src/plugins/android/src/wrappers/jcamera.h
new file mode 100644
index 000000000..100628721
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jcamera.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef JCAMERA_H
+#define JCAMERA_H
+
+#include <qobject.h>
+#include <QtPlatformSupport/private/qjniobject_p.h>
+#include <qsize.h>
+#include <qrect.h>
+
+QT_BEGIN_NAMESPACE
+
+class JCamera : public QObject, public QJNIObject
+{
+ Q_OBJECT
+public:
+ enum CameraFacing {
+ CameraFacingBack = 0,
+ CameraFacingFront = 1
+ };
+
+ ~JCamera();
+
+ static JCamera *open(int cameraId);
+
+ int cameraId() const { return m_cameraId; }
+
+ void lock();
+ void unlock();
+ void reconnect();
+ void release();
+
+ CameraFacing getFacing();
+ int getNativeOrientation();
+
+ QSize getPreferredPreviewSizeForVideo();
+ QList<QSize> getSupportedPreviewSizes();
+
+ QSize previewSize() const { return m_previewSize; }
+ void setPreviewSize(const QSize &size);
+ void setPreviewTexture(jobject surfaceTexture);
+
+ bool isZoomSupported();
+ int getMaxZoom();
+ QList<int> getZoomRatios();
+ int getZoom();
+ void setZoom(int value);
+
+ QStringList getSupportedFlashModes();
+ QString getFlashMode();
+ void setFlashMode(const QString &value);
+
+ QStringList getSupportedFocusModes();
+ QString getFocusMode();
+ void setFocusMode(const QString &value);
+
+ int getMaxNumFocusAreas();
+ QList<QRect> getFocusAreas();
+ void setFocusAreas(const QList<QRect> &areas);
+
+ void autoFocus();
+ void cancelAutoFocus();
+
+ bool isAutoExposureLockSupported();
+ bool getAutoExposureLock();
+ void setAutoExposureLock(bool toggle);
+
+ bool isAutoWhiteBalanceLockSupported();
+ bool getAutoWhiteBalanceLock();
+ void setAutoWhiteBalanceLock(bool toggle);
+
+ int getExposureCompensation();
+ void setExposureCompensation(int value);
+ float getExposureCompensationStep();
+ int getMinExposureCompensation();
+ int getMaxExposureCompensation();
+
+ QStringList getSupportedSceneModes();
+ QString getSceneMode();
+ void setSceneMode(const QString &value);
+
+ QStringList getSupportedWhiteBalance();
+ QString getWhiteBalance();
+ void setWhiteBalance(const QString &value);
+
+ void setRotation(int rotation);
+
+ QList<QSize> getSupportedPictureSizes();
+ void setPictureSize(const QSize &size);
+ void setJpegQuality(int quality);
+
+ void startPreview();
+ void stopPreview();
+
+ void takePicture();
+
+ static bool initJNI(JNIEnv *env);
+
+Q_SIGNALS:
+ void previewSizeChanged();
+
+ void autoFocusStarted();
+ void autoFocusComplete(bool success);
+
+ void whiteBalanceChanged();
+
+ void pictureExposed();
+ void pictureCaptured(const QByteArray &data);
+
+private:
+ JCamera(int cameraId, jobject cam);
+ void applyParameters();
+
+ QStringList callStringListMethod(const char *methodName);
+
+ int m_cameraId;
+ QJNIObject *m_info;
+ QJNIObject *m_parameters;
+
+ QSize m_previewSize;
+
+ bool m_hasAPI14;
+};
+
+QT_END_NAMESPACE
+
+#endif // JCAMERA_H
diff --git a/src/plugins/android/src/wrappers/jmediametadataretriever.cpp b/src/plugins/android/src/wrappers/jmediametadataretriever.cpp
new file mode 100644
index 000000000..ae5abcf43
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmediametadataretriever.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "jmediametadataretriever.h"
+
+#include <QtPlatformSupport/private/qjnihelpers_p.h>
+#include <qpa/qplatformnativeinterface.h>
+#include <qguiapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+static jobject g_activity = 0;
+
+JMediaMetadataRetriever::JMediaMetadataRetriever()
+ : QJNIObject("android/media/MediaMetadataRetriever")
+{
+ if (!g_activity) {
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ g_activity = static_cast<jobject>(nativeInterface->nativeResourceForIntegration("QtActivity"));
+ }
+}
+
+JMediaMetadataRetriever::~JMediaMetadataRetriever()
+{
+}
+
+QString JMediaMetadataRetriever::extractMetadata(MetadataKey key)
+{
+ QString value;
+
+ QJNILocalRef<jstring> metadata = callObjectMethod<jstring>("extractMetadata",
+ "(I)Ljava/lang/String;",
+ jint(key));
+ if (!metadata.isNull())
+ value = qt_convertJString(metadata.object());
+
+ return value;
+}
+
+void JMediaMetadataRetriever::release()
+{
+ callMethod<void>("release");
+}
+
+bool JMediaMetadataRetriever::setDataSource(const QUrl &url)
+{
+ QAttachedJNIEnv env;
+
+ bool loaded = false;
+
+ QJNILocalRef<jstring> string = qt_toJString(url.toString());
+
+ QJNILocalRef<jobject> uri = callStaticObjectMethod<jobject>("android/net/Uri",
+ "parse",
+ "(Ljava/lang/String;)Landroid/net/Uri;",
+ string.object());
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ } else {
+ callMethod<void>("setDataSource",
+ "(Landroid/content/Context;Landroid/net/Uri;)V",
+ g_activity,
+ uri.object());
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+ else
+ loaded = true;
+ }
+
+ return loaded;
+}
+
+bool JMediaMetadataRetriever::setDataSource(const QString &path)
+{
+ QAttachedJNIEnv env;
+
+ bool loaded = false;
+
+ callMethod<void>("setDataSource", "(Ljava/lang/String;)V", qt_toJString(path).object());
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+ else
+ loaded = true;
+
+ return loaded;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/android/src/wrappers/jmediametadataretriever.h b/src/plugins/android/src/wrappers/jmediametadataretriever.h
new file mode 100644
index 000000000..dd63e0d87
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmediametadataretriever.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef JMEDIAMETADATARETRIEVER_H
+#define JMEDIAMETADATARETRIEVER_H
+
+#include <QtPlatformSupport/private/qjniobject_p.h>
+#include <qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+class JMediaMetadataRetriever : public QJNIObject
+{
+public:
+ enum MetadataKey {
+ Album = 1,
+ AlbumArtist = 13,
+ Artist = 2,
+ Author = 3,
+ Bitrate = 20,
+ CDTrackNumber = 0,
+ Compilation = 15,
+ Composer = 4,
+ Date = 5,
+ DiscNumber = 14,
+ Duration = 9,
+ Genre = 6,
+ HasAudio = 16,
+ HasVideo = 17,
+ Location = 23,
+ MimeType = 12,
+ NumTracks = 10,
+ Title = 7,
+ VideoHeight = 19,
+ VideoWidth = 18,
+ VideoRotation = 24,
+ Writer = 11,
+ Year = 8
+ };
+
+ JMediaMetadataRetriever();
+ ~JMediaMetadataRetriever();
+
+ QString extractMetadata(MetadataKey key);
+ void release();
+ bool setDataSource(const QUrl &url);
+ bool setDataSource(const QString &path);
+
+};
+
+QT_END_NAMESPACE
+
+#endif // JMEDIAMETADATARETRIEVER_H
diff --git a/src/plugins/android/src/wrappers/jmediaplayer.cpp b/src/plugins/android/src/wrappers/jmediaplayer.cpp
new file mode 100644
index 000000000..f6e03ee22
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmediaplayer.cpp
@@ -0,0 +1,270 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "jmediaplayer.h"
+
+#include <QString>
+#include <qpa/qplatformnativeinterface.h>
+#include <qguiapplication.h>
+#include <QtPlatformSupport/private/qjnihelpers_p.h>
+
+namespace {
+
+jclass mediaPlayerClass = 0;
+
+QMap<jlong, JMediaPlayer *> mplayers;
+
+}
+
+QT_BEGIN_NAMESPACE
+
+bool JMediaPlayer::mActivitySet = false;
+
+JMediaPlayer::JMediaPlayer()
+ : QObject()
+ , QJNIObject(mediaPlayerClass, "(J)V", reinterpret_cast<jlong>(this))
+ , mId(reinterpret_cast<jlong>(this))
+ , mDisplay(0)
+{
+ mplayers.insert(mId, this);
+
+ if (!mActivitySet) {
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ jobject activity = static_cast<jobject>(nativeInterface->nativeResourceForIntegration("QtActivity"));
+ QJNIObject::callStaticMethod<void>(mediaPlayerClass,
+ "setActivity",
+ "(Landroid/app/Activity;)V",
+ activity);
+ mActivitySet = true;
+ }
+}
+
+JMediaPlayer::~JMediaPlayer()
+{
+ mplayers.remove(mId);
+}
+
+void JMediaPlayer::release()
+{
+ callMethod<void>("release");
+}
+
+void JMediaPlayer::onError(qint32 what, qint32 extra)
+{
+ Q_EMIT error(what, extra);
+}
+
+void JMediaPlayer::onBufferingUpdate(qint32 percent)
+{
+ Q_EMIT bufferingUpdate(percent);
+}
+
+void JMediaPlayer::onInfo(qint32 what, qint32 extra)
+{
+ Q_EMIT info(what, extra);
+}
+
+void JMediaPlayer::onMediaPlayerInfo(qint32 what, qint32 extra)
+{
+ Q_EMIT mediaPlayerInfo(what, extra);
+}
+
+void JMediaPlayer::onVideoSizeChanged(qint32 width, qint32 height)
+{
+ Q_EMIT videoSizeChanged(width, height);
+}
+
+int JMediaPlayer::getCurrentPosition()
+{
+ return callMethod<jint>("getCurrentPosition");
+}
+
+int JMediaPlayer::getDuration()
+{
+ return callMethod<jint>("getDuration");
+}
+
+bool JMediaPlayer::isPlaying()
+{
+ return callMethod<jboolean>("isPlaying");
+}
+
+int JMediaPlayer::volume()
+{
+ return callMethod<jint>("getVolume");
+}
+
+bool JMediaPlayer::isMuted()
+{
+ return callMethod<jboolean>("isMuted");
+}
+
+void JMediaPlayer::play()
+{
+ callMethod<void>("start");
+}
+
+void JMediaPlayer::pause()
+{
+ callMethod<void>("pause");
+}
+
+void JMediaPlayer::stop()
+{
+ callMethod<void>("stop");
+}
+
+void JMediaPlayer::seekTo(qint32 msec)
+{
+ callMethod<void>("seekTo", "(I)V", jint(msec));
+}
+
+void JMediaPlayer::setMuted(bool mute)
+{
+ callMethod<void>("mute", "(Z)V", jboolean(mute));
+}
+
+void JMediaPlayer::setDataSource(const QString &path)
+{
+ QJNILocalRef<jstring> string = qt_toJString(path);
+ callMethod<void>("setMediaPath", "(Ljava/lang/String;)V", string.object());
+}
+
+void JMediaPlayer::setVolume(int volume)
+{
+ callMethod<void>("setVolume", "(I)V", jint(volume));
+}
+
+void JMediaPlayer::setDisplay(jobject surfaceHolder)
+{
+ mDisplay = surfaceHolder;
+ callMethod<void>("setDisplay", "(Landroid/view/SurfaceHolder;)V", mDisplay);
+}
+
+QT_END_NAMESPACE
+
+static void onErrorNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id)
+{
+ Q_UNUSED(env);
+ Q_UNUSED(thiz);
+ JMediaPlayer *const mp = mplayers[id];
+ if (!mp)
+ return;
+
+ mp->onError(what, extra);
+}
+
+static void onBufferingUpdateNative(JNIEnv *env, jobject thiz, jint percent, jlong id)
+{
+ Q_UNUSED(env);
+ Q_UNUSED(thiz);
+ JMediaPlayer *const mp = mplayers[id];
+ if (!mp)
+ return;
+
+ mp->onBufferingUpdate(percent);
+}
+
+static void onInfoNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id)
+{
+ Q_UNUSED(env);
+ Q_UNUSED(thiz);
+ JMediaPlayer *const mp = mplayers[id];
+ if (!mp)
+ return;
+
+ mp->onInfo(what, extra);
+}
+
+static void onMediaPlayerInfoNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id)
+{
+ Q_UNUSED(env);
+ Q_UNUSED(thiz);
+ JMediaPlayer *const mp = mplayers[id];
+ if (!mp)
+ return;
+
+ mp->onMediaPlayerInfo(what, extra);
+}
+
+static void onVideoSizeChangedNative(JNIEnv *env,
+ jobject thiz,
+ jint width,
+ jint height,
+ jlong id)
+{
+ Q_UNUSED(env);
+ Q_UNUSED(thiz);
+ JMediaPlayer *const mp = mplayers[id];
+ if (!mp)
+ return;
+
+ mp->onVideoSizeChanged(width, height);
+}
+
+QT_BEGIN_NAMESPACE
+
+bool JMediaPlayer::initJNI(JNIEnv *env)
+{
+ jclass jClass = env->FindClass("org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer");
+
+ if (jClass) {
+ mediaPlayerClass = static_cast<jclass>(env->NewGlobalRef(jClass));
+
+ JNINativeMethod methods[] = {
+ {"onErrorNative", "(IIJ)V", reinterpret_cast<void *>(onErrorNative)},
+ {"onBufferingUpdateNative", "(IJ)V", reinterpret_cast<void *>(onBufferingUpdateNative)},
+ {"onInfoNative", "(IIJ)V", reinterpret_cast<void *>(onInfoNative)},
+ {"onMediaPlayerInfoNative", "(IIJ)V", reinterpret_cast<void *>(onMediaPlayerInfoNative)},
+ {"onVideoSizeChangedNative", "(IIJ)V", reinterpret_cast<void *>(onVideoSizeChangedNative)}
+ };
+
+ if (env->RegisterNatives(mediaPlayerClass,
+ methods,
+ sizeof(methods) / sizeof(methods[0])) < 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/android/src/wrappers/jmediaplayer.h b/src/plugins/android/src/wrappers/jmediaplayer.h
new file mode 100644
index 000000000..710246b9a
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmediaplayer.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QANDROIDMEDIAPLAYER_H
+#define QANDROIDMEDIAPLAYER_H
+
+#include <QObject>
+#include <QtPlatformSupport/private/qjniobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class JMediaPlayer : public QObject, public QJNIObject
+{
+ Q_OBJECT
+public:
+ JMediaPlayer();
+ ~JMediaPlayer();
+
+ enum MediaError
+ {
+ // What
+ MEDIA_ERROR_UNKNOWN = 1,
+ MEDIA_ERROR_SERVER_DIED = 100,
+ // Extra
+ MEDIA_ERROR_IO = -1004,
+ MEDIA_ERROR_MALFORMED = -1007,
+ MEDIA_ERROR_UNSUPPORTED = -1010,
+ MEDIA_ERROR_TIMED_OUT = -110,
+ MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200
+ };
+
+ enum MediaInfo
+ {
+ MEDIA_INFO_UNKNOWN = 1,
+ MEDIA_INFO_VIDEO_TRACK_LAGGING = 700,
+ MEDIA_INFO_VIDEO_RENDERING_START = 3,
+ MEDIA_INFO_BUFFERING_START = 701,
+ MEDIA_INFO_BUFFERING_END = 702,
+ MEDIA_INFO_BAD_INTERLEAVING = 800,
+ MEDIA_INFO_NOT_SEEKABLE = 801,
+ MEDIA_INFO_METADATA_UPDATE = 802
+ };
+
+ enum MediaPlayerInfo
+ {
+ MEDIA_PLAYER_INVALID_STATE = 1,
+ MEDIA_PLAYER_PREPARING = 2,
+ MEDIA_PLAYER_READY = 3,
+ MEDIA_PLAYER_DURATION = 4,
+ MEDIA_PLAYER_PROGRESS = 5,
+ MEDIA_PLAYER_FINISHED = 6
+ };
+
+ void release();
+
+ int getCurrentPosition();
+ int getDuration();
+ bool isPlaying();
+ int volume();
+ bool isMuted();
+ jobject display() { return mDisplay; }
+
+ void play();
+ void pause();
+ void stop();
+ void seekTo(qint32 msec);
+ void setMuted(bool mute);
+ void setDataSource(const QString &path);
+ void setVolume(int volume);
+ void setDisplay(jobject surfaceHolder);
+
+ void onError(qint32 what, qint32 extra);
+ void onBufferingUpdate(qint32 percent);
+ void onInfo(qint32 what, qint32 extra);
+ void onMediaPlayerInfo(qint32 what, qint32 extra);
+ void onVideoSizeChanged(qint32 width, qint32 height);
+
+ static bool initJNI(JNIEnv *env);
+
+Q_SIGNALS:
+ void error(qint32 what, qint32 extra);
+ void bufferingUpdate(qint32 percent);
+ void completion();
+ void info(qint32 what, qint32 extra);
+ void mediaPlayerInfo(qint32 what, qint32 extra);
+ void videoSizeChanged(qint32 width, qint32 height);
+
+private:
+ jlong mId;
+ jobject mDisplay;
+
+ static bool mActivitySet;
+};
+
+QT_END_NAMESPACE
+
+#endif // QANDROIDMEDIAPLAYER_H
diff --git a/src/plugins/android/src/wrappers/jmediarecorder.cpp b/src/plugins/android/src/wrappers/jmediarecorder.cpp
new file mode 100644
index 000000000..b7cbe5724
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmediarecorder.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "jmediarecorder.h"
+
+#include "jcamera.h"
+#include <QtPlatformSupport/private/qjnihelpers_p.h>
+#include <qmap.h>
+
+QT_BEGIN_NAMESPACE
+
+static jclass g_qtMediaRecorderClass = 0;
+static QMap<jlong, JMediaRecorder*> g_objectMap;
+
+static void notifyError(JNIEnv* , jobject, jlong id, jint what, jint extra)
+{
+ JMediaRecorder *obj = g_objectMap.value(id, 0);
+ if (obj)
+ emit obj->error(what, extra);
+}
+
+static void notifyInfo(JNIEnv* , jobject, jlong id, jint what, jint extra)
+{
+ JMediaRecorder *obj = g_objectMap.value(id, 0);
+ if (obj)
+ emit obj->info(what, extra);
+}
+
+JMediaRecorder::JMediaRecorder()
+ : QObject()
+ , QJNIObject(g_qtMediaRecorderClass, "(J)V", reinterpret_cast<jlong>(this))
+ , m_id(reinterpret_cast<jlong>(this))
+{
+ if (isValid())
+ g_objectMap.insert(m_id, this);
+}
+
+JMediaRecorder::~JMediaRecorder()
+{
+ g_objectMap.remove(m_id);
+}
+
+void JMediaRecorder::release()
+{
+ callMethod<void>("release");
+}
+
+bool JMediaRecorder::prepare()
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("prepare");
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ return false;
+ }
+ return true;
+}
+
+void JMediaRecorder::reset()
+{
+ callMethod<void>("reset");
+}
+
+bool JMediaRecorder::start()
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("start");
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ return false;
+ }
+ return true;
+}
+
+void JMediaRecorder::stop()
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("stop");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setAudioChannels(int numChannels)
+{
+ callMethod<void>("setAudioChannels", "(I)V", numChannels);
+}
+
+void JMediaRecorder::setAudioEncoder(AudioEncoder encoder)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setAudioEncoder", "(I)V", int(encoder));
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setAudioEncodingBitRate(int bitRate)
+{
+ callMethod<void>("setAudioEncodingBitRate", "(I)V", bitRate);
+}
+
+void JMediaRecorder::setAudioSamplingRate(int samplingRate)
+{
+ callMethod<void>("setAudioSamplingRate", "(I)V", samplingRate);
+}
+
+void JMediaRecorder::setAudioSource(AudioSource source)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setAudioSource", "(I)V", int(source));
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setCamera(JCamera *camera)
+{
+ QJNILocalRef<jobject> cam = camera->getObjectField<jobject>("m_camera", "Landroid/hardware/Camera;");
+ callMethod<void>("setCamera", "(Landroid/hardware/Camera;)V", cam.object());
+}
+
+void JMediaRecorder::setVideoEncoder(VideoEncoder encoder)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setVideoEncoder", "(I)V", int(encoder));
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setVideoEncodingBitRate(int bitRate)
+{
+ callMethod<void>("setVideoEncodingBitRate", "(I)V", bitRate);
+}
+
+void JMediaRecorder::setVideoFrameRate(int rate)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setVideoFrameRate", "(I)V", rate);
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setVideoSize(const QSize &size)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setVideoSize", "(II)V", size.width(), size.height());
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setVideoSource(VideoSource source)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setVideoSource", "(I)V", int(source));
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setOrientationHint(int degrees)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setOrientationHint", "(I)V", degrees);
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setOutputFormat(OutputFormat format)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setOutputFormat", "(I)V", int(format));
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+void JMediaRecorder::setOutputFile(const QString &path)
+{
+ QAttachedJNIEnv env;
+ callMethod<void>("setOutputFile", "(Ljava/lang/String;)V", qt_toJString(path).object());
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+}
+
+static JNINativeMethod methods[] = {
+ {"notifyError", "(JII)V", (void *)notifyError},
+ {"notifyInfo", "(JII)V", (void *)notifyInfo}
+};
+
+bool JMediaRecorder::initJNI(JNIEnv *env)
+{
+ jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtMediaRecorder");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+
+ if (clazz) {
+ g_qtMediaRecorderClass = static_cast<jclass>(env->NewGlobalRef(clazz));
+ if (env->RegisterNatives(g_qtMediaRecorderClass,
+ methods,
+ sizeof(methods) / sizeof(methods[0])) < 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/android/src/wrappers/jmediarecorder.h b/src/plugins/android/src/wrappers/jmediarecorder.h
new file mode 100644
index 000000000..ef26b8a72
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmediarecorder.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef JMEDIARECORDER_H
+#define JMEDIARECORDER_H
+
+#include <qobject.h>
+#include <QtPlatformSupport/private/qjniobject_p.h>
+#include <qsize.h>
+
+QT_BEGIN_NAMESPACE
+
+class JCamera;
+
+class JMediaRecorder : public QObject, public QJNIObject
+{
+ Q_OBJECT
+public:
+ enum AudioEncoder {
+ DefaultAudioEncoder = 0,
+ AMR_NB_Encoder = 1,
+ AMR_WB_Encoder = 2,
+ AAC = 3
+ };
+
+ enum AudioSource {
+ DefaultAudioSource = 0,
+ Mic = 1,
+ VoiceUplink = 2,
+ VoiceDownlink = 3,
+ VoiceCall = 4,
+ Camcorder = 5,
+ VoiceRecognition = 6
+ };
+
+ enum VideoEncoder {
+ DefaultVideoEncoder = 0,
+ H263 = 1,
+ H264 = 2,
+ MPEG_4_SP = 3
+ };
+
+ enum VideoSource {
+ DefaultVideoSource = 0,
+ Camera = 1
+ };
+
+ enum OutputFormat {
+ DefaultOutputFormat = 0,
+ THREE_GPP = 1,
+ MPEG_4 = 2,
+ AMR_NB_Format = 3,
+ AMR_WB_Format = 4
+ };
+
+ JMediaRecorder();
+ ~JMediaRecorder();
+
+ void release();
+ bool prepare();
+ void reset();
+
+ bool start();
+ void stop();
+
+ void setAudioChannels(int numChannels);
+ void setAudioEncoder(AudioEncoder encoder);
+ void setAudioEncodingBitRate(int bitRate);
+ void setAudioSamplingRate(int samplingRate);
+ void setAudioSource(AudioSource source);
+
+ void setCamera(JCamera *camera);
+ void setVideoEncoder(VideoEncoder encoder);
+ void setVideoEncodingBitRate(int bitRate);
+ void setVideoFrameRate(int rate);
+ void setVideoSize(const QSize &size);
+ void setVideoSource(VideoSource source);
+
+ void setOrientationHint(int degrees);
+
+ void setOutputFormat(OutputFormat format);
+ void setOutputFile(const QString &path);
+
+ static bool initJNI(JNIEnv *env);
+
+Q_SIGNALS:
+ void error(int what, int extra);
+ void info(int what, int extra);
+
+private:
+ jlong m_id;
+};
+
+QT_END_NAMESPACE
+
+#endif // JMEDIARECORDER_H
diff --git a/src/plugins/android/src/wrappers/jmultimediautils.cpp b/src/plugins/android/src/wrappers/jmultimediautils.cpp
new file mode 100644
index 000000000..6832e6b6e
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmultimediautils.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "jmultimediautils.h"
+
+#include <QtPlatformSupport/private/qjnihelpers_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static jclass g_qtMultimediaUtilsClass = 0;
+
+JMultimediaUtils::JMultimediaUtils()
+ : QObject()
+ , QJNIObject(g_qtMultimediaUtilsClass)
+{
+}
+
+void JMultimediaUtils::enableOrientationListener(bool enable)
+{
+ callStaticMethod<void>(g_qtMultimediaUtilsClass, "enableOrientationListener", "(Z)V", enable);
+}
+
+int JMultimediaUtils::getDeviceOrientation()
+{
+ return callStaticMethod<jint>(g_qtMultimediaUtilsClass, "getDeviceOrientation");
+}
+
+QString JMultimediaUtils::getDefaultMediaDirectory(MediaType type)
+{
+ QJNILocalRef<jstring> path = callStaticObjectMethod<jstring>(g_qtMultimediaUtilsClass,
+ "getDefaultMediaDirectory",
+ "(I)Ljava/lang/String;",
+ jint(type));
+ return qt_convertJString(path.object());
+}
+
+void JMultimediaUtils::registerMediaFile(const QString &file)
+{
+ callStaticMethod<void>(g_qtMultimediaUtilsClass,
+ "registerMediaFile",
+ "(Ljava/lang/String;)V",
+ qt_toJString(file).object());
+}
+
+bool JMultimediaUtils::initJNI(JNIEnv *env)
+{
+ jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtMultimediaUtils");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+
+ if (clazz)
+ g_qtMultimediaUtilsClass = static_cast<jclass>(env->NewGlobalRef(clazz));
+
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/android/src/wrappers/jmultimediautils.h b/src/plugins/android/src/wrappers/jmultimediautils.h
new file mode 100644
index 000000000..909f5c155
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jmultimediautils.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef JMULTIMEDIAUTILS_H
+#define JMULTIMEDIAUTILS_H
+
+#include <qobject.h>
+#include <QtPlatformSupport/private/qjniobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class JMultimediaUtils : public QObject, public QJNIObject
+{
+ Q_OBJECT
+public:
+ enum MediaType {
+ Music = 0,
+ Movies = 1,
+ DCIM = 2,
+ Sounds = 3
+ };
+
+ JMultimediaUtils();
+
+ static void enableOrientationListener(bool enable);
+ static int getDeviceOrientation();
+ static QString getDefaultMediaDirectory(MediaType type);
+ static void registerMediaFile(const QString &file);
+
+ static bool initJNI(JNIEnv *env);
+};
+
+QT_END_NAMESPACE
+
+#endif // JMULTIMEDIAUTILS_H
diff --git a/src/plugins/android/src/wrappers/jsurfacetexture.cpp b/src/plugins/android/src/wrappers/jsurfacetexture.cpp
new file mode 100644
index 000000000..60c85cdf0
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jsurfacetexture.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "jsurfacetexture.h"
+#include <QtPlatformSupport/private/qjnihelpers_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static jclass g_qtSurfaceTextureClass = 0;
+static QMap<int, JSurfaceTexture*> g_objectMap;
+
+// native method for QtSurfaceTexture.java
+static void notifyFrameAvailable(JNIEnv* , jobject, int id)
+{
+ JSurfaceTexture *obj = g_objectMap.value(id, 0);
+ if (obj)
+ Q_EMIT obj->frameAvailable();
+}
+
+JSurfaceTexture::JSurfaceTexture(unsigned int texName)
+ : QObject()
+ , QJNIObject(g_qtSurfaceTextureClass, "(I)V", jint(texName))
+ , m_texID(int(texName))
+{
+ if (isValid())
+ g_objectMap.insert(int(texName), this);
+}
+
+JSurfaceTexture::~JSurfaceTexture()
+{
+ if (isValid())
+ g_objectMap.remove(m_texID);
+}
+
+QMatrix4x4 JSurfaceTexture::getTransformMatrix()
+{
+ QAttachedJNIEnv env;
+
+ QMatrix4x4 matrix;
+ jfloatArray array = env->NewFloatArray(16);
+ callMethod<void>("getTransformMatrix", "([F)V", array);
+ env->GetFloatArrayRegion(array, 0, 16, matrix.data());
+ env->DeleteLocalRef(array);
+
+ return matrix;
+}
+
+void JSurfaceTexture::updateTexImage()
+{
+ callMethod<void>("updateTexImage");
+}
+
+static JNINativeMethod methods[] = {
+ {"notifyFrameAvailable", "(I)V", (void *)notifyFrameAvailable}
+};
+
+bool JSurfaceTexture::initJNI(JNIEnv *env)
+{
+ jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtSurfaceTexture");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+
+ if (clazz) {
+ g_qtSurfaceTextureClass = static_cast<jclass>(env->NewGlobalRef(clazz));
+ if (env->RegisterNatives(g_qtSurfaceTextureClass,
+ methods,
+ sizeof(methods) / sizeof(methods[0])) < 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/android/src/wrappers/jsurfacetexture.h b/src/plugins/android/src/wrappers/jsurfacetexture.h
new file mode 100644
index 000000000..2a2f27ae3
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jsurfacetexture.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef JSURFACETEXTURE_H
+#define JSURFACETEXTURE_H
+
+#include <qobject.h>
+#include <QtPlatformSupport/private/qjniobject_p.h>
+
+#include <QMatrix4x4>
+
+QT_BEGIN_NAMESPACE
+
+class JSurfaceTexture : public QObject, public QJNIObject
+{
+ Q_OBJECT
+public:
+ explicit JSurfaceTexture(unsigned int texName);
+ ~JSurfaceTexture();
+
+ QMatrix4x4 getTransformMatrix();
+ void updateTexImage();
+
+ static bool initJNI(JNIEnv *env);
+
+Q_SIGNALS:
+ void frameAvailable();
+
+private:
+ int m_texID;
+};
+
+QT_END_NAMESPACE
+
+#endif // JSURFACETEXTURE_H
diff --git a/src/plugins/android/src/wrappers/jsurfacetextureholder.cpp b/src/plugins/android/src/wrappers/jsurfacetextureholder.cpp
new file mode 100644
index 000000000..4ec8935c2
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jsurfacetextureholder.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "jsurfacetextureholder.h"
+
+QT_BEGIN_NAMESPACE
+
+static jclass g_qtSurfaceTextureHolderClass = 0;
+
+JSurfaceTextureHolder::JSurfaceTextureHolder(jobject surface)
+ : QJNIObject(g_qtSurfaceTextureHolderClass, "(Landroid/view/Surface;)V", surface)
+{
+}
+
+bool JSurfaceTextureHolder::initJNI(JNIEnv *env)
+{
+ jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtSurfaceTextureHolder");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+
+ if (clazz)
+ g_qtSurfaceTextureHolderClass = static_cast<jclass>(env->NewGlobalRef(clazz));
+
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/android/src/wrappers/jsurfacetextureholder.h b/src/plugins/android/src/wrappers/jsurfacetextureholder.h
new file mode 100644
index 000000000..5b567de3a
--- /dev/null
+++ b/src/plugins/android/src/wrappers/jsurfacetextureholder.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef JSURFACETEXTUREHOLDER_H
+#define JSURFACETEXTUREHOLDER_H
+
+#include <QtPlatformSupport/private/qjniobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class JSurfaceTextureHolder : public QJNIObject
+{
+public:
+ JSurfaceTextureHolder(jobject surface);
+
+ static bool initJNI(JNIEnv *env);
+};
+
+QT_END_NAMESPACE
+
+#endif // JSURFACETEXTUREHOLDER_H
diff --git a/src/plugins/android/src/wrappers/wrappers.pri b/src/plugins/android/src/wrappers/wrappers.pri
new file mode 100644
index 000000000..b2faa5b79
--- /dev/null
+++ b/src/plugins/android/src/wrappers/wrappers.pri
@@ -0,0 +1,21 @@
+QT += platformsupport-private
+
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/jmediaplayer.h \
+ $$PWD/jsurfacetexture.h \
+ $$PWD/jsurfacetextureholder.h \
+ $$PWD/jmediametadataretriever.h \
+ $$PWD/jcamera.h \
+ $$PWD/jmultimediautils.h \
+ $$PWD/jmediarecorder.h
+
+SOURCES += \
+ $$PWD/jmediaplayer.cpp \
+ $$PWD/jsurfacetexture.cpp \
+ $$PWD/jsurfacetextureholder.cpp \
+ $$PWD/jmediametadataretriever.cpp \
+ $$PWD/jcamera.cpp \
+ $$PWD/jmultimediautils.cpp \
+ $$PWD/jmediarecorder.cpp