From 9c3e685352f7c6fc8cd763644090e993fdf9a0d4 Mon Sep 17 00:00:00 2001 From: Zhang Xingtao Date: Tue, 25 Mar 2014 23:22:57 +0800 Subject: [PATCH 1/9] Doc: fix two typos Change-Id: I5f417384ce75d8dc2063f92d0116f516f261e4aa Reviewed-by: Frederik Gladhorn Reviewed-by: Yoann Lopes --- src/imports/multimedia/qdeclarativeaudio.cpp | 2 +- src/imports/multimedia/qdeclarativecamerarecorder.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 589c45da..16828a4d 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -1188,7 +1188,7 @@ void QDeclarativeAudio::_q_statusChanged() } VideoOutput { - anchors: parent.fill + anchors.fill: parent source: mediaplayer } diff --git a/src/imports/multimedia/qdeclarativecamerarecorder.cpp b/src/imports/multimedia/qdeclarativecamerarecorder.cpp index 0f400467..896470b7 100644 --- a/src/imports/multimedia/qdeclarativecamerarecorder.cpp +++ b/src/imports/multimedia/qdeclarativecamerarecorder.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE settings and metadata for videos. It should not be constructed separately, instead the - \c videRecorder property of a \l Camera should be used. + \c videoRecorder property of a \l Camera should be used. \qml Camera { From 5869d484415168692f6ca9513beacf6f69c92c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 27 Mar 2014 10:56:16 +0100 Subject: [PATCH 2/9] Android: Fix reload check in onStateChanged(). The condition was missing the Uninitialized flag. Change-Id: I555f4eae6cc33bee0a4925e626dd56041e4b0471 Reviewed-by: Yoann Lopes --- .../android/src/mediaplayer/qandroidmediaplayercontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp index 4b836ddf..f6780834 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp +++ b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp @@ -510,8 +510,10 @@ void QAndroidMediaPlayerControl::onVideoSizeChanged(qint32 width, qint32 height) void QAndroidMediaPlayerControl::onStateChanged(qint32 state) { // If reloading, don't report state changes unless the new state is Prepared or Error. - if ((mState & JMediaPlayer::Stopped) && !(state & (JMediaPlayer::Prepared | JMediaPlayer::Error))) + if ((mState & JMediaPlayer::Stopped) + && (state & (JMediaPlayer::Prepared | JMediaPlayer::Error | JMediaPlayer::Uninitialized)) == 0) { return; + } mState = state; switch (mState) { From 09e3d8a28e3e1d4903043f38553aed9d34bcde09 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 4 Feb 2014 14:59:44 +0100 Subject: [PATCH 3/9] Blackberry: implement QCameraInfoControl. We also now correctly report the default camera to be the rear camera. Change-Id: Ie96b2950344194637c8feace77246f036c9a3757 Reviewed-by: Fabian Bumberger --- src/plugins/qnx/bbserviceplugin.cpp | 16 +++- src/plugins/qnx/bbserviceplugin.h | 5 ++ .../qnx/camera/bbcamerainfocontrol.cpp | 83 +++++++++++++++++++ src/plugins/qnx/camera/bbcamerainfocontrol.h | 65 +++++++++++++++ src/plugins/qnx/camera/bbcameraservice.cpp | 4 + src/plugins/qnx/camera/bbcameraservice.h | 2 + .../camera/bbvideodeviceselectorcontrol.cpp | 5 +- .../qnx/camera/bbvideodeviceselectorcontrol.h | 1 + src/plugins/qnx/camera/camera.pri | 2 + 9 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 src/plugins/qnx/camera/bbcamerainfocontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcamerainfocontrol.h diff --git a/src/plugins/qnx/bbserviceplugin.cpp b/src/plugins/qnx/bbserviceplugin.cpp index 2351e573..a0eade60 100644 --- a/src/plugins/qnx/bbserviceplugin.cpp +++ b/src/plugins/qnx/bbserviceplugin.cpp @@ -40,7 +40,9 @@ ****************************************************************************/ #include "bbserviceplugin.h" +#include "bbcamerainfocontrol.h" #include "bbcameraservice.h" +#include "bbcamerasession.h" #include "bbvideodeviceselectorcontrol.h" #include "mmrenderermediaplayerservice.h" @@ -120,8 +122,20 @@ void BbServicePlugin::updateDevices() const if (m_cameraDevices.isEmpty()) { qWarning() << "No camera devices found"; } else { - m_defaultCameraDevice = m_cameraDevices.first(); + m_defaultCameraDevice = m_cameraDevices.contains(BbCameraSession::cameraIdentifierRear()) + ? BbCameraSession::cameraIdentifierRear() + : m_cameraDevices.first(); } } +QCamera::Position BbServicePlugin::cameraPosition(const QByteArray &device) const +{ + return BbCameraInfoControl::position(device); +} + +int BbServicePlugin::cameraOrientation(const QByteArray &device) const +{ + return BbCameraInfoControl::orientation(device); +} + QT_END_NAMESPACE diff --git a/src/plugins/qnx/bbserviceplugin.h b/src/plugins/qnx/bbserviceplugin.h index 45ea4cc6..f6a20b8f 100644 --- a/src/plugins/qnx/bbserviceplugin.h +++ b/src/plugins/qnx/bbserviceplugin.h @@ -49,11 +49,13 @@ class BbServicePlugin : public QMediaServiceProviderPlugin, public QMediaServiceSupportedDevicesInterface, public QMediaServiceDefaultDeviceInterface, + public QMediaServiceCameraInfoInterface, public QMediaServiceFeaturesInterface { Q_OBJECT Q_INTERFACES(QMediaServiceSupportedDevicesInterface) Q_INTERFACES(QMediaServiceDefaultDeviceInterface) + Q_INTERFACES(QMediaServiceCameraInfoInterface) Q_INTERFACES(QMediaServiceFeaturesInterface) Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "blackberry_mediaservice.json") public: @@ -68,6 +70,9 @@ public: QString deviceDescription(const QByteArray &service, const QByteArray &device) Q_DECL_OVERRIDE; QVariant deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property) Q_DECL_OVERRIDE; + QCamera::Position cameraPosition(const QByteArray &device) const Q_DECL_OVERRIDE; + int cameraOrientation(const QByteArray &device) const Q_DECL_OVERRIDE; + private: void updateDevices() const; diff --git a/src/plugins/qnx/camera/bbcamerainfocontrol.cpp b/src/plugins/qnx/camera/bbcamerainfocontrol.cpp new file mode 100644 index 00000000..366495dd --- /dev/null +++ b/src/plugins/qnx/camera/bbcamerainfocontrol.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 "bbcamerainfocontrol.h" + +#include "bbcamerasession.h" + +QT_BEGIN_NAMESPACE + +BbCameraInfoControl::BbCameraInfoControl(QObject *parent) + : QCameraInfoControl(parent) +{ +} + +QCamera::Position BbCameraInfoControl::position(const QString &deviceName) +{ + if (deviceName == QString::fromUtf8(BbCameraSession::cameraIdentifierFront())) + return QCamera::FrontFace; + else if (deviceName == QString::fromUtf8(BbCameraSession::cameraIdentifierRear())) + return QCamera::BackFace; + else + return QCamera::UnspecifiedPosition; +} + +int BbCameraInfoControl::orientation(const QString &deviceName) +{ + // The camera sensor orientation could be retrieved with camera_get_native_orientation() + // but since the sensor angular offset is compensated with camera_set_videovf_property() and + // camera_set_photovf_property() we should always return 0 here. + Q_UNUSED(deviceName); + return 0; +} + +QCamera::Position BbCameraInfoControl::cameraPosition(const QString &deviceName) const +{ + return position(deviceName); +} + +int BbCameraInfoControl::cameraOrientation(const QString &deviceName) const +{ + return orientation(deviceName); +} + +QT_END_NAMESPACE + diff --git a/src/plugins/qnx/camera/bbcamerainfocontrol.h b/src/plugins/qnx/camera/bbcamerainfocontrol.h new file mode 100644 index 00000000..a083bbf3 --- /dev/null +++ b/src/plugins/qnx/camera/bbcamerainfocontrol.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 BBCAMERAINFOCONTROL_H +#define BBCAMERAINFOCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraInfoControl : public QCameraInfoControl +{ + Q_OBJECT +public: + explicit BbCameraInfoControl(QObject *parent = 0); + + QCamera::Position cameraPosition(const QString &deviceName) const; + int cameraOrientation(const QString &deviceName) const; + + static QCamera::Position position(const QString &deviceName); + static int orientation(const QString &deviceName); +}; + +QT_END_NAMESPACE + +#endif // BBCAMERAINFOCONTROL_H + diff --git a/src/plugins/qnx/camera/bbcameraservice.cpp b/src/plugins/qnx/camera/bbcameraservice.cpp index d9adc7c9..98feee5a 100644 --- a/src/plugins/qnx/camera/bbcameraservice.cpp +++ b/src/plugins/qnx/camera/bbcameraservice.cpp @@ -49,6 +49,7 @@ #include "bbcamerafocuscontrol.h" #include "bbcameraimagecapturecontrol.h" #include "bbcameraimageprocessingcontrol.h" +#include "bbcamerainfocontrol.h" #include "bbcameralockscontrol.h" #include "bbcameramediarecordercontrol.h" #include "bbcamerasession.h" @@ -76,6 +77,7 @@ BbCameraService::BbCameraService(QObject *parent) , m_cameraFocusControl(new BbCameraFocusControl(m_cameraSession, this)) , m_cameraImageCaptureControl(new BbCameraImageCaptureControl(m_cameraSession, this)) , m_cameraImageProcessingControl(new BbCameraImageProcessingControl(m_cameraSession, this)) + , m_cameraInfoControl(new BbCameraInfoControl(this)) , m_cameraLocksControl(new BbCameraLocksControl(m_cameraSession, this)) , m_cameraMediaRecorderControl(new BbCameraMediaRecorderControl(m_cameraSession, this)) , m_cameraVideoEncoderSettingsControl(new BbCameraVideoEncoderSettingsControl(m_cameraSession, this)) @@ -101,6 +103,8 @@ QMediaControl* BbCameraService::requestControl(const char *name) return m_cameraCaptureDestinationControl; else if (qstrcmp(name, QCameraControl_iid) == 0) return m_cameraControl; + else if (qstrcmp(name, QCameraInfoControl_iid) == 0) + return m_cameraInfoControl; else if (qstrcmp(name, QCameraExposureControl_iid) == 0) return m_cameraExposureControl; else if (qstrcmp(name, QCameraFlashControl_iid) == 0) diff --git a/src/plugins/qnx/camera/bbcameraservice.h b/src/plugins/qnx/camera/bbcameraservice.h index 374d03c3..f87dd0ab 100644 --- a/src/plugins/qnx/camera/bbcameraservice.h +++ b/src/plugins/qnx/camera/bbcameraservice.h @@ -56,6 +56,7 @@ class BbCameraFlashControl; class BbCameraFocusControl; class BbCameraImageCaptureControl; class BbCameraImageProcessingControl; +class BbCameraInfoControl; class BbCameraLocksControl; class BbCameraMediaRecorderControl; class BbCameraSession; @@ -89,6 +90,7 @@ private: BbCameraFocusControl* m_cameraFocusControl; BbCameraImageCaptureControl* m_cameraImageCaptureControl; BbCameraImageProcessingControl* m_cameraImageProcessingControl; + BbCameraInfoControl* m_cameraInfoControl; BbCameraLocksControl* m_cameraLocksControl; BbCameraMediaRecorderControl* m_cameraMediaRecorderControl; BbCameraVideoEncoderSettingsControl* m_cameraVideoEncoderSettingsControl; diff --git a/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.cpp b/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.cpp index 6a6e9d3c..f0221e10 100644 --- a/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.cpp +++ b/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.cpp @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE BbVideoDeviceSelectorControl::BbVideoDeviceSelectorControl(BbCameraSession *session, QObject *parent) : QVideoDeviceSelectorControl(parent) , m_session(session) + , m_default(0) , m_selected(0) { enumerateDevices(&m_devices, &m_descriptions); @@ -56,7 +57,7 @@ BbVideoDeviceSelectorControl::BbVideoDeviceSelectorControl(BbCameraSession *sess // pre-select the rear camera const int index = m_devices.indexOf(BbCameraSession::cameraIdentifierRear()); if (index != -1) - m_selected = index; + m_default = m_selected = index; } int BbVideoDeviceSelectorControl::deviceCount() const @@ -82,7 +83,7 @@ QString BbVideoDeviceSelectorControl::deviceDescription(int index) const int BbVideoDeviceSelectorControl::defaultDevice() const { - return 0; + return m_default; } int BbVideoDeviceSelectorControl::selectedDevice() const diff --git a/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.h b/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.h index 1987f549..24396154 100644 --- a/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.h +++ b/src/plugins/qnx/camera/bbvideodeviceselectorcontrol.h @@ -71,6 +71,7 @@ private: QList m_devices; QStringList m_descriptions; + int m_default; int m_selected; }; diff --git a/src/plugins/qnx/camera/camera.pri b/src/plugins/qnx/camera/camera.pri index 6665573b..7e5fbeb3 100644 --- a/src/plugins/qnx/camera/camera.pri +++ b/src/plugins/qnx/camera/camera.pri @@ -10,6 +10,7 @@ HEADERS += \ $$PWD/bbcamerafocuscontrol.h \ $$PWD/bbcameraimagecapturecontrol.h \ $$PWD/bbcameraimageprocessingcontrol.h \ + $$PWD/bbcamerainfocontrol.h \ $$PWD/bbcameralockscontrol.h \ $$PWD/bbcameramediarecordercontrol.h \ $$PWD/bbcameraorientationhandler.h \ @@ -33,6 +34,7 @@ SOURCES += \ $$PWD/bbcamerafocuscontrol.cpp \ $$PWD/bbcameraimagecapturecontrol.cpp \ $$PWD/bbcameraimageprocessingcontrol.cpp \ + $$PWD/bbcamerainfocontrol.cpp \ $$PWD/bbcameralockscontrol.cpp \ $$PWD/bbcameramediarecordercontrol.cpp \ $$PWD/bbcameraorientationhandler.cpp \ From 3c3e2c324b9030570588b29f962a3e34bc48be1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Wed, 26 Mar 2014 12:13:49 +0100 Subject: [PATCH 4/9] Android: Don't call release() unless it's necessary. If the mediaplayer is in either Idle or Uninitialized state, then there is no need to call release again. Change-Id: Idb6f2d9ea7aad7a9036e7e9a534c3bd296324068 Reviewed-by: Yoann Lopes --- .../android/src/mediaplayer/qandroidmediaplayercontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp index f6780834..f5614a57 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp +++ b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp @@ -289,7 +289,9 @@ void QAndroidMediaPlayerControl::setMedia(const QMediaContent &mediaContent, mMediaStream = stream; } - mMediaPlayer->release(); + // Release the mediaplayer if it's not in in Idle or Uninitialized state + if ((mState & (JMediaPlayer::Idle | JMediaPlayer::Uninitialized)) == 0) + mMediaPlayer->release(); if (mediaContent.isNull()) { setMediaStatus(QMediaPlayer::NoMedia); From cc41c7df3ca3daf3fe7e9ef3e1d74ca96724d821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Wed, 19 Mar 2014 13:48:19 +0100 Subject: [PATCH 5/9] Android: Fix QtSurfaceTexture Don't extend SurfaceTexture as this causes ART to fail when it doesn't find the postEventFromNative() function. The postEventFromNative() function was implemented sometime after API 11, so to avoid this situation we can use composition instead. Task-number: QTBUG-37605 Change-Id: Ie1013d218291ba0035f1bb18a0c0655fd2170bfd Reviewed-by: Yoann Lopes --- src/plugins/android/jar/jar.pri | 2 +- ...ure.java => QtSurfaceTextureListener.java} | 8 +- .../src/common/qandroidvideorendercontrol.cpp | 16 ++-- .../src/common/qandroidvideorendercontrol.h | 3 +- .../src/qandroidmediaserviceplugin.cpp | 5 +- .../android/src/wrappers/jsurfacetexture.cpp | 83 +++++++++++++------ .../android/src/wrappers/jsurfacetexture.h | 6 +- .../src/wrappers/jsurfacetextureholder.cpp | 65 --------------- .../src/wrappers/jsurfacetextureholder.h | 59 ------------- src/plugins/android/src/wrappers/wrappers.pri | 2 - 10 files changed, 80 insertions(+), 169 deletions(-) rename src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/{QtSurfaceTexture.java => QtSurfaceTextureListener.java} (90%) delete mode 100644 src/plugins/android/src/wrappers/jsurfacetextureholder.cpp delete mode 100644 src/plugins/android/src/wrappers/jsurfacetextureholder.h diff --git a/src/plugins/android/jar/jar.pri b/src/plugins/android/jar/jar.pri index 9e235144..e56e3d96 100644 --- a/src/plugins/android/jar/jar.pri +++ b/src/plugins/android/jar/jar.pri @@ -7,7 +7,7 @@ JAVACLASSPATH += $$PWD/src JAVASOURCES += $$PWD/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java \ $$PWD/src/org/qtproject/qt5/android/multimedia/QtCamera.java \ - $$PWD/src/org/qtproject/qt5/android/multimedia/QtSurfaceTexture.java \ + $$PWD/src/org/qtproject/qt5/android/multimedia/QtSurfaceTextureListener.java \ $$PWD/src/org/qtproject/qt5/android/multimedia/QtSurfaceTextureHolder.java \ $$PWD/src/org/qtproject/qt5/android/multimedia/QtMultimediaUtils.java \ $$PWD/src/org/qtproject/qt5/android/multimedia/QtMediaRecorder.java diff --git a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtSurfaceTexture.java b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtSurfaceTextureListener.java similarity index 90% rename from src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtSurfaceTexture.java rename to src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtSurfaceTextureListener.java index 7632abd2..00619b72 100644 --- a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtSurfaceTexture.java +++ b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtSurfaceTextureListener.java @@ -43,15 +43,13 @@ package org.qtproject.qt5.android.multimedia; import android.graphics.SurfaceTexture; -public class QtSurfaceTexture extends SurfaceTexture implements SurfaceTexture.OnFrameAvailableListener +public class QtSurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener { - private int texID; + private final int texID; - public QtSurfaceTexture(int texName) + public QtSurfaceTextureListener(int texName) { - super(texName); texID = texName; - setOnFrameAvailableListener(this); } @Override diff --git a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp index b737e8a4..5f14a469 100644 --- a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp +++ b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp @@ -42,7 +42,6 @@ #include "qandroidvideorendercontrol.h" #include -#include "jsurfacetextureholder.h" #include #include #include @@ -51,6 +50,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -177,7 +177,7 @@ bool QAndroidVideoRendererControl::initSurfaceTexture() m_surfaceTexture = new JSurfaceTexture(m_externalTex); - if (m_surfaceTexture->isValid()) { + if (m_surfaceTexture->object()) { connect(m_surfaceTexture, SIGNAL(frameAvailable()), this, SLOT(onFrameAvailable())); } else { delete m_surfaceTexture; @@ -193,12 +193,12 @@ bool QAndroidVideoRendererControl::initSurfaceTexture() void QAndroidVideoRendererControl::clearSurfaceTexture() { if (m_surfaceTexture) { - m_surfaceTexture->callMethod("release"); delete m_surfaceTexture; m_surfaceTexture = 0; } if (m_androidSurface) { - m_androidSurface->callMethod("release"); + if (QtAndroidPrivate::androidSdkVersion() > 13) + m_androidSurface->callMethod("release"); delete m_androidSurface; m_androidSurface = 0; } @@ -215,10 +215,12 @@ jobject QAndroidVideoRendererControl::surfaceHolder() if (!m_surfaceHolder) { m_androidSurface = new QJNIObjectPrivate("android/view/Surface", - "(Landroid/graphics/SurfaceTexture;)V", - m_surfaceTexture->object()); + "(Landroid/graphics/SurfaceTexture;)V", + m_surfaceTexture->object()); - m_surfaceHolder = new JSurfaceTextureHolder(m_androidSurface->object()); + m_surfaceHolder = new QJNIObjectPrivate("org/qtproject/qt5/android/multimedia/QtSurfaceTextureHolder", + "(Landroid/view/Surface;)V", + m_androidSurface->object()); } return m_surfaceHolder->object(); diff --git a/src/plugins/android/src/common/qandroidvideorendercontrol.h b/src/plugins/android/src/common/qandroidvideorendercontrol.h index 56407d5d..75fd7ef1 100644 --- a/src/plugins/android/src/common/qandroidvideorendercontrol.h +++ b/src/plugins/android/src/common/qandroidvideorendercontrol.h @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE -class JSurfaceTextureHolder; class QOpenGLTexture; class QOpenGLFramebufferObject; class QOpenGLShaderProgram; @@ -115,7 +114,7 @@ private: QJNIObjectPrivate *m_androidSurface; JSurfaceTexture *m_surfaceTexture; - JSurfaceTextureHolder *m_surfaceHolder; + QJNIObjectPrivate *m_surfaceHolder; quint32 m_externalTex; QOpenGLFramebufferObject *m_fbo; diff --git a/src/plugins/android/src/qandroidmediaserviceplugin.cpp b/src/plugins/android/src/qandroidmediaserviceplugin.cpp index 005def8c..b05a4ae0 100644 --- a/src/plugins/android/src/qandroidmediaserviceplugin.cpp +++ b/src/plugins/android/src/qandroidmediaserviceplugin.cpp @@ -48,7 +48,6 @@ #include "qandroidcamerasession.h" #include "jmediaplayer.h" #include "jsurfacetexture.h" -#include "jsurfacetextureholder.h" #include "jcamera.h" #include "jmultimediautils.h" #include "jmediarecorder.h" @@ -165,14 +164,14 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) JNIEnv *jniEnv = uenv.nativeEnvironment; if (!JMediaPlayer::initJNI(jniEnv) || - !JSurfaceTexture::initJNI(jniEnv) || - !JSurfaceTextureHolder::initJNI(jniEnv) || !JCamera::initJNI(jniEnv) || !JMultimediaUtils::initJNI(jniEnv) || !JMediaRecorder::initJNI(jniEnv)) { return JNI_ERR; } + JSurfaceTexture::initJNI(jniEnv); + return JNI_VERSION_1_4; } diff --git a/src/plugins/android/src/wrappers/jsurfacetexture.cpp b/src/plugins/android/src/wrappers/jsurfacetexture.cpp index 47487f10..2b16ebd6 100644 --- a/src/plugins/android/src/wrappers/jsurfacetexture.cpp +++ b/src/plugins/android/src/wrappers/jsurfacetexture.cpp @@ -41,10 +41,11 @@ #include "jsurfacetexture.h" #include +#include QT_BEGIN_NAMESPACE -static jclass g_qtSurfaceTextureClass = 0; +static jclass g_qtSurfaceTextureListenerClass = 0; static QMap g_objectMap; // native method for QtSurfaceTexture.java @@ -57,37 +58,75 @@ static void notifyFrameAvailable(JNIEnv* , jobject, int id) JSurfaceTexture::JSurfaceTexture(unsigned int texName) : QObject() - , QJNIObjectPrivate(g_qtSurfaceTextureClass, "(I)V", jint(texName)) , m_texID(int(texName)) { - if (isValid()) - g_objectMap.insert(int(texName), this); - else // If the class is not available, it means the Android version is < 3.0 + // API level 11 or higher is required + if (QtAndroidPrivate::androidSdkVersion() < 11) { qWarning("Camera preview and video playback require Android 3.0 (API level 11) or later."); + return; + } + + QJNIEnvironmentPrivate env; + m_surfaceTexture = QJNIObjectPrivate("android/graphics/SurfaceTexture", "(I)V", jint(texName)); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif // QT_DEBUG + env->ExceptionClear(); + } + + if (m_surfaceTexture.isValid()) + g_objectMap.insert(int(texName), this); + + QJNIObjectPrivate listener(g_qtSurfaceTextureListenerClass, "(I)V", jint(texName)); + m_surfaceTexture.callMethod("setOnFrameAvailableListener", + "(Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;)V", + listener.object()); } JSurfaceTexture::~JSurfaceTexture() { - if (isValid()) + if (m_surfaceTexture.isValid()) { + release(); g_objectMap.remove(m_texID); + } } QMatrix4x4 JSurfaceTexture::getTransformMatrix() { + QMatrix4x4 matrix; + if (!m_surfaceTexture.isValid()) + return matrix; + QJNIEnvironmentPrivate env; - QMatrix4x4 matrix; jfloatArray array = env->NewFloatArray(16); - callMethod("getTransformMatrix", "([F)V", array); + m_surfaceTexture.callMethod("getTransformMatrix", "([F)V", array); env->GetFloatArrayRegion(array, 0, 16, matrix.data()); env->DeleteLocalRef(array); return matrix; } +void JSurfaceTexture::release() +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return; + + m_surfaceTexture.callMethod("release"); +} + void JSurfaceTexture::updateTexImage() { - callMethod("updateTexImage"); + if (!m_surfaceTexture.isValid()) + return; + + m_surfaceTexture.callMethod("updateTexImage"); +} + +jobject JSurfaceTexture::object() +{ + return m_surfaceTexture.object(); } static JNINativeMethod methods[] = { @@ -96,24 +135,20 @@ static JNINativeMethod methods[] = { bool JSurfaceTexture::initJNI(JNIEnv *env) { - // SurfaceTexture is available since API 11, try to find it first before loading - // our custom class - jclass surfaceTextureClass = env->FindClass("android/graphics/SurfaceTexture"); + // SurfaceTexture is available since API 11. + if (QtAndroidPrivate::androidSdkVersion() < 11) + return false; + + jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtSurfaceTextureListener"); if (env->ExceptionCheck()) env->ExceptionClear(); - if (surfaceTextureClass) { - jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtSurfaceTexture"); - if (env->ExceptionCheck()) - env->ExceptionClear(); - - if (clazz) { - g_qtSurfaceTextureClass = static_cast(env->NewGlobalRef(clazz)); - if (env->RegisterNatives(g_qtSurfaceTextureClass, - methods, - sizeof(methods) / sizeof(methods[0])) < 0) { - return false; - } + if (clazz) { + g_qtSurfaceTextureListenerClass = static_cast(env->NewGlobalRef(clazz)); + if (env->RegisterNatives(g_qtSurfaceTextureListenerClass, + methods, + sizeof(methods) / sizeof(methods[0])) < 0) { + return false; } } diff --git a/src/plugins/android/src/wrappers/jsurfacetexture.h b/src/plugins/android/src/wrappers/jsurfacetexture.h index ea53b68b..d53290a7 100644 --- a/src/plugins/android/src/wrappers/jsurfacetexture.h +++ b/src/plugins/android/src/wrappers/jsurfacetexture.h @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -class JSurfaceTexture : public QObject, public QJNIObjectPrivate +class JSurfaceTexture : public QObject { Q_OBJECT public: @@ -57,7 +57,10 @@ public: ~JSurfaceTexture(); int textureID() const { return m_texID; } + jobject object(); + QMatrix4x4 getTransformMatrix(); + void release(); // API level 14 void updateTexImage(); static bool initJNI(JNIEnv *env); @@ -67,6 +70,7 @@ Q_SIGNALS: private: int m_texID; + QJNIObjectPrivate m_surfaceTexture; }; QT_END_NAMESPACE diff --git a/src/plugins/android/src/wrappers/jsurfacetextureholder.cpp b/src/plugins/android/src/wrappers/jsurfacetextureholder.cpp deleted file mode 100644 index b6d1433d..00000000 --- a/src/plugins/android/src/wrappers/jsurfacetextureholder.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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) - : QJNIObjectPrivate(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(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 deleted file mode 100644 index 556cb4a4..00000000 --- a/src/plugins/android/src/wrappers/jsurfacetextureholder.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** 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 - -QT_BEGIN_NAMESPACE - -class JSurfaceTextureHolder : public QJNIObjectPrivate -{ -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 index b2faa5b7..126cfd0c 100644 --- a/src/plugins/android/src/wrappers/wrappers.pri +++ b/src/plugins/android/src/wrappers/wrappers.pri @@ -5,7 +5,6 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/jmediaplayer.h \ $$PWD/jsurfacetexture.h \ - $$PWD/jsurfacetextureholder.h \ $$PWD/jmediametadataretriever.h \ $$PWD/jcamera.h \ $$PWD/jmultimediautils.h \ @@ -14,7 +13,6 @@ HEADERS += \ SOURCES += \ $$PWD/jmediaplayer.cpp \ $$PWD/jsurfacetexture.cpp \ - $$PWD/jsurfacetextureholder.cpp \ $$PWD/jmediametadataretriever.cpp \ $$PWD/jcamera.cpp \ $$PWD/jmultimediautils.cpp \ From 4ba7b223909d69fc443f1d536e0a884518227d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 20 Mar 2014 00:38:11 +0100 Subject: [PATCH 6/9] Android: Fix MetadataRetriver wrapper The QJNIObject was never intended to be used as a base class. Change-Id: Ic4effd5e1c89a08515c756bd5092fb1e1eead688 Reviewed-by: Yoann Lopes --- .../qandroidmetadatareadercontrol.cpp | 7 +--- .../src/wrappers/jmediametadataretriever.cpp | 41 +++++++++++-------- .../src/wrappers/jmediametadataretriever.h | 4 +- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp index b6ef6c4b..dcc3dfbe 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp +++ b/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp @@ -74,13 +74,8 @@ static const char* qt_ID3GenreNames[] = QAndroidMetaDataReaderControl::QAndroidMetaDataReaderControl(QObject *parent) : QMetaDataReaderControl(parent) , m_available(false) - , m_retriever(0) + , m_retriever(new JMediaMetadataRetriever) { - m_retriever = new JMediaMetadataRetriever; - if (!m_retriever->isValid()) { - delete m_retriever; - m_retriever = 0; - } } QAndroidMetaDataReaderControl::~QAndroidMetaDataReaderControl() diff --git a/src/plugins/android/src/wrappers/jmediametadataretriever.cpp b/src/plugins/android/src/wrappers/jmediametadataretriever.cpp index 91c40905..93b77ecb 100644 --- a/src/plugins/android/src/wrappers/jmediametadataretriever.cpp +++ b/src/plugins/android/src/wrappers/jmediametadataretriever.cpp @@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE JMediaMetadataRetriever::JMediaMetadataRetriever() - : QJNIObjectPrivate("android/media/MediaMetadataRetriever") { + m_metadataRetriever = QJNIObjectPrivate("android/media/MediaMetadataRetriever"); } JMediaMetadataRetriever::~JMediaMetadataRetriever() @@ -59,9 +59,9 @@ QString JMediaMetadataRetriever::extractMetadata(MetadataKey key) { QString value; - QJNIObjectPrivate metadata = callObjectMethod("extractMetadata", - "(I)Ljava/lang/String;", - jint(key)); + QJNIObjectPrivate metadata = m_metadataRetriever.callObjectMethod("extractMetadata", + "(I)Ljava/lang/String;", + jint(key)); if (metadata.isValid()) value = metadata.toString(); @@ -70,28 +70,34 @@ QString JMediaMetadataRetriever::extractMetadata(MetadataKey key) void JMediaMetadataRetriever::release() { - callMethod("release"); + if (!m_metadataRetriever.isValid()) + return; + + m_metadataRetriever.callMethod("release"); } bool JMediaMetadataRetriever::setDataSource(const QUrl &url) { + if (!m_metadataRetriever.isValid()) + return false; + QJNIEnvironmentPrivate env; bool loaded = false; QJNIObjectPrivate string = QJNIObjectPrivate::fromString(url.toString()); - QJNIObjectPrivate uri = callStaticObjectMethod("android/net/Uri", - "parse", - "(Ljava/lang/String;)Landroid/net/Uri;", - string.object()); + QJNIObjectPrivate uri = m_metadataRetriever.callStaticObjectMethod("android/net/Uri", + "parse", + "(Ljava/lang/String;)Landroid/net/Uri;", + string.object()); if (env->ExceptionCheck()) { env->ExceptionClear(); } else { - callMethod("setDataSource", - "(Landroid/content/Context;Landroid/net/Uri;)V", - QtAndroidPrivate::activity(), - uri.object()); + m_metadataRetriever.callMethod("setDataSource", + "(Landroid/content/Context;Landroid/net/Uri;)V", + QtAndroidPrivate::activity(), + uri.object()); if (env->ExceptionCheck()) env->ExceptionClear(); else @@ -103,13 +109,16 @@ bool JMediaMetadataRetriever::setDataSource(const QUrl &url) bool JMediaMetadataRetriever::setDataSource(const QString &path) { + if (!m_metadataRetriever.isValid()) + return false; + QJNIEnvironmentPrivate env; bool loaded = false; - callMethod("setDataSource", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(path).object()); + m_metadataRetriever.callMethod("setDataSource", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(path).object()); if (env->ExceptionCheck()) env->ExceptionClear(); else diff --git a/src/plugins/android/src/wrappers/jmediametadataretriever.h b/src/plugins/android/src/wrappers/jmediametadataretriever.h index 7b22c955..7b0340c0 100644 --- a/src/plugins/android/src/wrappers/jmediametadataretriever.h +++ b/src/plugins/android/src/wrappers/jmediametadataretriever.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE -class JMediaMetadataRetriever : public QJNIObjectPrivate +class JMediaMetadataRetriever { public: enum MetadataKey { @@ -84,6 +84,8 @@ public: bool setDataSource(const QUrl &url); bool setDataSource(const QString &path); +private: + QJNIObjectPrivate m_metadataRetriever; }; QT_END_NAMESPACE From ccce4e3da24653f8ebd5f32f969cd67e875a22e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 27 Mar 2014 12:21:23 +0100 Subject: [PATCH 7/9] Android: Clean-up in jmultimediautils class. Remove unused code. Change-Id: I2c0db45dd95e6a79387bba1b1ccd4b62b7d22aec Reviewed-by: Yoann Lopes --- .../src/qandroidmediaserviceplugin.cpp | 1 - .../android/src/wrappers/jmultimediautils.cpp | 43 ++++++------------- .../android/src/wrappers/jmultimediautils.h | 7 +-- 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/plugins/android/src/qandroidmediaserviceplugin.cpp b/src/plugins/android/src/qandroidmediaserviceplugin.cpp index b05a4ae0..0af43210 100644 --- a/src/plugins/android/src/qandroidmediaserviceplugin.cpp +++ b/src/plugins/android/src/qandroidmediaserviceplugin.cpp @@ -165,7 +165,6 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) if (!JMediaPlayer::initJNI(jniEnv) || !JCamera::initJNI(jniEnv) || - !JMultimediaUtils::initJNI(jniEnv) || !JMediaRecorder::initJNI(jniEnv)) { return JNI_ERR; } diff --git a/src/plugins/android/src/wrappers/jmultimediautils.cpp b/src/plugins/android/src/wrappers/jmultimediautils.cpp index a20d5447..d1b0830c 100644 --- a/src/plugins/android/src/wrappers/jmultimediautils.cpp +++ b/src/plugins/android/src/wrappers/jmultimediautils.cpp @@ -45,51 +45,36 @@ QT_BEGIN_NAMESPACE -static jclass g_qtMultimediaUtilsClass = 0; - -JMultimediaUtils::JMultimediaUtils() - : QObject() - , QJNIObjectPrivate(g_qtMultimediaUtilsClass) -{ -} void JMultimediaUtils::enableOrientationListener(bool enable) { - callStaticMethod(g_qtMultimediaUtilsClass, "enableOrientationListener", "(Z)V", enable); + QJNIObjectPrivate::callStaticMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", + "enableOrientationListener", + "(Z)V", + enable); } int JMultimediaUtils::getDeviceOrientation() { - return callStaticMethod(g_qtMultimediaUtilsClass, "getDeviceOrientation"); + return QJNIObjectPrivate::callStaticMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", + "getDeviceOrientation"); } QString JMultimediaUtils::getDefaultMediaDirectory(MediaType type) { - QJNIObjectPrivate path = callStaticObjectMethod(g_qtMultimediaUtilsClass, - "getDefaultMediaDirectory", - "(I)Ljava/lang/String;", - jint(type)); + QJNIObjectPrivate path = QJNIObjectPrivate::callStaticObjectMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", + "getDefaultMediaDirectory", + "(I)Ljava/lang/String;", + jint(type)); return path.toString(); } void JMultimediaUtils::registerMediaFile(const QString &file) { - callStaticMethod(g_qtMultimediaUtilsClass, - "registerMediaFile", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(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(env->NewGlobalRef(clazz)); - - return true; + QJNIObjectPrivate::callStaticMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", + "registerMediaFile", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(file).object()); } QT_END_NAMESPACE diff --git a/src/plugins/android/src/wrappers/jmultimediautils.h b/src/plugins/android/src/wrappers/jmultimediautils.h index 9896f7f3..b80ef423 100644 --- a/src/plugins/android/src/wrappers/jmultimediautils.h +++ b/src/plugins/android/src/wrappers/jmultimediautils.h @@ -47,9 +47,8 @@ QT_BEGIN_NAMESPACE -class JMultimediaUtils : public QObject, public QJNIObjectPrivate +class JMultimediaUtils { - Q_OBJECT public: enum MediaType { Music = 0, @@ -58,14 +57,10 @@ public: 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 From 5c09bba97942bad4862644a9589bd62f6e6aa2d7 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Thu, 27 Mar 2014 09:29:38 -0700 Subject: [PATCH 8/9] CoreAudio: Mismatched new[]/delete in several places. The CoreAudio plugin code in QtMultimedia had several different places where an array was allocated with "new[]" and deleted with "delete". Fixed by deleting with "delete[]". Task-number: QTBUG-37861 Change-Id: Id85bc07a054ad161b0403cc0fe5c56ec5b41d4e3 Reviewed-by: Andy Nichols --- src/plugins/coreaudio/coreaudiodeviceinfo.mm | 6 +++--- src/plugins/coreaudio/coreaudioutils.mm | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreaudio/coreaudiodeviceinfo.mm b/src/plugins/coreaudio/coreaudiodeviceinfo.mm index 74a692c1..56765caf 100644 --- a/src/plugins/coreaudio/coreaudiodeviceinfo.mm +++ b/src/plugins/coreaudio/coreaudiodeviceinfo.mm @@ -110,7 +110,7 @@ QAudioFormat CoreAudioDeviceInfo::preferredFormat() const } } - delete streams; + delete[] streams; } } #else //iOS @@ -180,7 +180,7 @@ QList CoreAudioDeviceInfo::supportedSampleRates() } } - delete vr; + delete[] vr; } } #else //iOS @@ -380,7 +380,7 @@ QList CoreAudioDeviceInfo::availableDevices(QAudio::Mode mode) } } - delete audioDevices; + delete[] audioDevices; } } #else //iOS diff --git a/src/plugins/coreaudio/coreaudioutils.mm b/src/plugins/coreaudio/coreaudioutils.mm index d43303a1..e626561d 100644 --- a/src/plugins/coreaudio/coreaudioutils.mm +++ b/src/plugins/coreaudio/coreaudioutils.mm @@ -125,7 +125,7 @@ CoreAudioRingBuffer::CoreAudioRingBuffer(int bufferSize): CoreAudioRingBuffer::~CoreAudioRingBuffer() { - delete m_buffer; + delete[] m_buffer; } CoreAudioRingBuffer::Region CoreAudioRingBuffer::acquireReadRegion(int size) From 9a4dd5fe8ed778b456de1241cabdf3a089caa499 Mon Sep 17 00:00:00 2001 From: Zhang Xingtao Date: Fri, 28 Mar 2014 13:59:05 +0800 Subject: [PATCH 9/9] fix: 'm_state' was not declared in this scope Error occurred when building with DEBUG_PLAYBIN defined. It should be m_currentState from context. Change-Id: Iad59966ca19c9d1b589fc8641599494436a0a5f3 Reviewed-by: Liang Qi Reviewed-by: Jing Bai --- src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp index e028e6d7..ff99aa3f 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp @@ -630,7 +630,7 @@ void QGstreamerPlayerControl::popAndNotifyState() if (m_stateStack.isEmpty()) { if (m_currentState != oldState) { #ifdef DEBUG_PLAYBIN - qDebug() << "State changed:" << m_state; + qDebug() << "State changed:" << m_currentState; #endif emit stateChanged(m_currentState); }