From 92147420124f28c4c844b4603de7ab412e084d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Fri, 9 May 2014 17:32:28 +0200 Subject: Android: Rename the wrapper classes Change-Id: I2ce15c8475da3186f128ba59b7c58f9b5b0a67e1 Reviewed-by: Yoann Lopes --- .../src/common/qandroidvideorendercontrol.cpp | 5 +- .../src/common/qandroidvideorendercontrol.h | 4 +- .../mediacapture/qandroidcameraexposurecontrol.cpp | 2 +- .../mediacapture/qandroidcameraflashcontrol.cpp | 2 +- .../mediacapture/qandroidcamerafocuscontrol.cpp | 2 +- .../qandroidcameraimageprocessingcontrol.cpp | 2 +- .../mediacapture/qandroidcameralockscontrol.cpp | 2 +- .../src/mediacapture/qandroidcamerasession.cpp | 32 +- .../src/mediacapture/qandroidcamerasession.h | 6 +- .../src/mediacapture/qandroidcamerazoomcontrol.cpp | 2 +- .../src/mediacapture/qandroidcapturesession.cpp | 77 +- .../src/mediacapture/qandroidcapturesession.h | 24 +- .../mediacapture/qandroidimageencodercontrol.cpp | 2 +- .../qandroidvideodeviceselectorcontrol.cpp | 2 +- .../src/mediaplayer/qandroidmediaplayercontrol.cpp | 156 +-- .../src/mediaplayer/qandroidmediaplayercontrol.h | 4 +- .../mediaplayer/qandroidmetadatareadercontrol.cpp | 38 +- .../mediaplayer/qandroidmetadatareadercontrol.h | 4 +- .../android/src/qandroidmediaserviceplugin.cpp | 20 +- src/plugins/android/src/src.pro | 2 +- src/plugins/android/src/wrappers/jcamera.cpp | 1366 -------------------- src/plugins/android/src/wrappers/jcamera.h | 187 --- .../src/wrappers/jmediametadataretriever.cpp | 130 -- .../android/src/wrappers/jmediametadataretriever.h | 93 -- src/plugins/android/src/wrappers/jmediaplayer.cpp | 266 ---- src/plugins/android/src/wrappers/jmediaplayer.h | 135 -- .../android/src/wrappers/jmediarecorder.cpp | 299 ----- src/plugins/android/src/wrappers/jmediarecorder.h | 135 -- .../android/src/wrappers/jmultimediautils.cpp | 80 -- .../android/src/wrappers/jmultimediautils.h | 68 - .../android/src/wrappers/jni/androidcamera.cpp | 1366 ++++++++++++++++++++ .../android/src/wrappers/jni/androidcamera.h | 187 +++ .../wrappers/jni/androidmediametadataretriever.cpp | 130 ++ .../wrappers/jni/androidmediametadataretriever.h | 93 ++ .../src/wrappers/jni/androidmediaplayer.cpp | 266 ++++ .../android/src/wrappers/jni/androidmediaplayer.h | 135 ++ .../src/wrappers/jni/androidmediarecorder.cpp | 299 +++++ .../src/wrappers/jni/androidmediarecorder.h | 135 ++ .../src/wrappers/jni/androidmultimediautils.cpp | 80 ++ .../src/wrappers/jni/androidmultimediautils.h | 68 + .../src/wrappers/jni/androidsurfacetexture.cpp | 158 +++ .../src/wrappers/jni/androidsurfacetexture.h | 78 ++ src/plugins/android/src/wrappers/jni/jni.pri | 19 + .../android/src/wrappers/jsurfacetexture.cpp | 158 --- src/plugins/android/src/wrappers/jsurfacetexture.h | 78 -- src/plugins/android/src/wrappers/wrappers.pri | 19 - 46 files changed, 3208 insertions(+), 3208 deletions(-) delete mode 100644 src/plugins/android/src/wrappers/jcamera.cpp delete mode 100644 src/plugins/android/src/wrappers/jcamera.h delete mode 100644 src/plugins/android/src/wrappers/jmediametadataretriever.cpp delete mode 100644 src/plugins/android/src/wrappers/jmediametadataretriever.h delete mode 100644 src/plugins/android/src/wrappers/jmediaplayer.cpp delete mode 100644 src/plugins/android/src/wrappers/jmediaplayer.h delete mode 100644 src/plugins/android/src/wrappers/jmediarecorder.cpp delete mode 100644 src/plugins/android/src/wrappers/jmediarecorder.h delete mode 100644 src/plugins/android/src/wrappers/jmultimediautils.cpp delete mode 100644 src/plugins/android/src/wrappers/jmultimediautils.h create mode 100644 src/plugins/android/src/wrappers/jni/androidcamera.cpp create mode 100644 src/plugins/android/src/wrappers/jni/androidcamera.h create mode 100644 src/plugins/android/src/wrappers/jni/androidmediametadataretriever.cpp create mode 100644 src/plugins/android/src/wrappers/jni/androidmediametadataretriever.h create mode 100644 src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp create mode 100644 src/plugins/android/src/wrappers/jni/androidmediaplayer.h create mode 100644 src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp create mode 100644 src/plugins/android/src/wrappers/jni/androidmediarecorder.h create mode 100644 src/plugins/android/src/wrappers/jni/androidmultimediautils.cpp create mode 100644 src/plugins/android/src/wrappers/jni/androidmultimediautils.h create mode 100644 src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp create mode 100644 src/plugins/android/src/wrappers/jni/androidsurfacetexture.h create mode 100644 src/plugins/android/src/wrappers/jni/jni.pri delete mode 100644 src/plugins/android/src/wrappers/jsurfacetexture.cpp delete mode 100644 src/plugins/android/src/wrappers/jsurfacetexture.h delete mode 100644 src/plugins/android/src/wrappers/wrappers.pri (limited to 'src/plugins/android') diff --git a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp index 1891e9d10..dfeea33c1 100644 --- a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp +++ b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp @@ -40,8 +40,8 @@ ****************************************************************************/ #include "qandroidvideorendercontrol.h" +#include "androidsurfacetexture.h" -#include #include #include #include @@ -50,7 +50,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE @@ -175,7 +174,7 @@ bool QAndroidVideoRendererControl::initSurfaceTexture() return false; } - m_surfaceTexture = new JSurfaceTexture(m_externalTex); + m_surfaceTexture = new AndroidSurfaceTexture(m_externalTex); if (m_surfaceTexture->object()) { connect(m_surfaceTexture, SIGNAL(frameAvailable()), this, SLOT(onFrameAvailable())); diff --git a/src/plugins/android/src/common/qandroidvideorendercontrol.h b/src/plugins/android/src/common/qandroidvideorendercontrol.h index 75fd7ef12..83d57a437 100644 --- a/src/plugins/android/src/common/qandroidvideorendercontrol.h +++ b/src/plugins/android/src/common/qandroidvideorendercontrol.h @@ -45,13 +45,13 @@ #include #include #include "qandroidvideooutput.h" -#include "jsurfacetexture.h" QT_BEGIN_NAMESPACE class QOpenGLTexture; class QOpenGLFramebufferObject; class QOpenGLShaderProgram; +class AndroidSurfaceTexture; class OpenGLResourcesDeleter : public QObject { @@ -113,7 +113,7 @@ private: QSize m_nativeSize; QJNIObjectPrivate *m_androidSurface; - JSurfaceTexture *m_surfaceTexture; + AndroidSurfaceTexture *m_surfaceTexture; QJNIObjectPrivate *m_surfaceHolder; quint32 m_externalTex; diff --git a/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.cpp index 03bbadb93..57057ebd7 100644 --- a/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidcameraexposurecontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.cpp index 253b1baa5..de8e521ee 100644 --- a/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidcameraflashcontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp index 345a29174..0b6ab80fc 100644 --- a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidcamerafocuscontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.cpp index ec5a3bcbf..4e4a416dd 100644 --- a/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidcameraimageprocessingcontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.cpp index d9f20ec04..bfb48d06e 100644 --- a/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidcameralockscontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp index 53fb2f516..f8633147d 100644 --- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp @@ -41,8 +41,8 @@ #include "qandroidcamerasession.h" -#include "jcamera.h" -#include "jmultimediautils.h" +#include "androidcamera.h" +#include "androidmultimediautils.h" #include "qandroidvideooutput.h" #include "qandroidmediavideoprobecontrol.h" #include "qandroidmultimediautils.h" @@ -113,7 +113,7 @@ QAndroidCameraSession::QAndroidCameraSession(QObject *parent) { m_mediaStorageLocation.addStorageLocation( QMediaStorageLocation::Pictures, - JMultimediaUtils::getDefaultMediaDirectory(JMultimediaUtils::DCIM)); + AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM)); if (qApp) { connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), @@ -195,17 +195,17 @@ void QAndroidCameraSession::updateAvailableCameras() "(ILandroid/hardware/Camera$CameraInfo;)V", i, cameraInfo.object()); - JCamera::CameraFacing facing = JCamera::CameraFacing(cameraInfo.getField("facing")); + AndroidCamera::CameraFacing facing = AndroidCamera::CameraFacing(cameraInfo.getField("facing")); // The orientation provided by Android is counter-clockwise, we need it clockwise info.orientation = (360 - cameraInfo.getField("orientation")) % 360; switch (facing) { - case JCamera::CameraFacingBack: + case AndroidCamera::CameraFacingBack: info.name = QByteArray("back"); info.description = QStringLiteral("Rear-facing camera"); info.position = QCamera::BackFace; break; - case JCamera::CameraFacingFront: + case AndroidCamera::CameraFacingFront: info.name = QByteArray("front"); info.description = QStringLiteral("Front-facing camera"); info.position = QCamera::FrontFace; @@ -234,7 +234,7 @@ bool QAndroidCameraSession::open() m_status = QCamera::LoadingStatus; emit statusChanged(m_status); - m_camera = JCamera::open(m_selectedCamera); + m_camera = AndroidCamera::open(m_selectedCamera); if (m_camera) { connect(m_camera, SIGNAL(pictureExposed()), this, SLOT(onCameraPictureExposed())); @@ -250,8 +250,8 @@ bool QAndroidCameraSession::open() m_status = QCamera::LoadedStatus; - if (m_camera->getPreviewFormat() != JCamera::NV21) - m_camera->setPreviewFormat(JCamera::NV21); + if (m_camera->getPreviewFormat() != AndroidCamera::NV21) + m_camera->setPreviewFormat(AndroidCamera::NV21); m_camera->fetchEachFrame(m_videoProbes.count()); @@ -356,7 +356,7 @@ void QAndroidCameraSession::startPreview() if (m_videoOutput && m_videoOutput->isReady()) onVideoOutputReady(true); - JMultimediaUtils::enableOrientationListener(true); + AndroidMultimediaUtils::enableOrientationListener(true); m_camera->startPreview(); m_previewStarted = true; @@ -370,7 +370,7 @@ void QAndroidCameraSession::stopPreview() m_status = QCamera::StoppingStatus; emit statusChanged(m_status); - JMultimediaUtils::enableOrientationListener(false); + AndroidMultimediaUtils::enableOrientationListener(false); m_camera->stopPreview(); m_camera->setPreviewSize(QSize()); @@ -407,8 +407,8 @@ int QAndroidCameraSession::currentCameraRotation() const // subtract natural camera orientation and physical device orientation int rotation = 0; - int deviceOrientation = (JMultimediaUtils::getDeviceOrientation() + 45) / 90 * 90; - if (m_camera->getFacing() == JCamera::CameraFacingFront) + int deviceOrientation = (AndroidMultimediaUtils::getDeviceOrientation() + 45) / 90 * 90; + if (m_camera->getFacing() == AndroidCamera::CameraFacingFront) rotation = (m_nativeOrientation - deviceOrientation + 360) % 360; else // back-facing camera rotation = (m_nativeOrientation + deviceOrientation) % 360; @@ -658,9 +658,9 @@ void QAndroidCameraSession::processCapturedImage(int id, // if the picture is saved into the standard picture location, register it // with the Android media scanner so it appears immediately in apps // such as the gallery. - QString standardLoc = JMultimediaUtils::getDefaultMediaDirectory(JMultimediaUtils::DCIM); + QString standardLoc = AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM); if (actualFileName.startsWith(standardLoc)) - JMultimediaUtils::registerMediaFile(actualFileName); + AndroidMultimediaUtils::registerMediaFile(actualFileName); emit imageSaved(id, actualFileName); } else { @@ -697,7 +697,7 @@ QImage QAndroidCameraSession::prepareImageFromPreviewData(const QByteArray &data // Preview display of front-facing cameras is flipped horizontally, but the frame data // we get here is not. Flip it ourselves if the camera is front-facing to match what the user // sees on the viewfinder. - if (m_camera->getFacing() == JCamera::CameraFacingFront) + if (m_camera->getFacing() == AndroidCamera::CameraFacingFront) transform.scale(-1, 1); transform.rotate(rotation); diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.h b/src/plugins/android/src/mediacapture/qandroidcamerasession.h index 4c58cab9e..51aba4a9b 100644 --- a/src/plugins/android/src/mediacapture/qandroidcamerasession.h +++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE -class JCamera; +class AndroidCamera; class QAndroidVideoOutput; class QAndroidMediaVideoProbeControl; @@ -73,7 +73,7 @@ public: static const QList &availableCameras(); void setSelectedCamera(int cameraId) { m_selectedCamera = cameraId; } - JCamera *camera() const { return m_camera; } + AndroidCamera *camera() const { return m_camera; } QCamera::State state() const { return m_state; } void setState(QCamera::State state); @@ -154,7 +154,7 @@ private: const QString &fileName); int m_selectedCamera; - JCamera *m_camera; + AndroidCamera *m_camera; int m_nativeOrientation; QAndroidVideoOutput *m_videoOutput; diff --git a/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.cpp index b7030e56b..385cd942a 100644 --- a/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidcamerazoomcontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" #include "qandroidmultimediautils.h" #include diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp index 4b1c58255..f8641073e 100644 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp @@ -41,11 +41,10 @@ #include "qandroidcapturesession.h" -#include "jcamera.h" +#include "androidcamera.h" #include "qandroidcamerasession.h" -#include "jmultimediautils.h" +#include "androidmultimediautils.h" #include "qandroidmultimediautils.h" -#include QT_BEGIN_NAMESPACE @@ -53,7 +52,7 @@ QAndroidCaptureSession::QAndroidCaptureSession(QAndroidCameraSession *cameraSess : QObject() , m_mediaRecorder(0) , m_cameraSession(cameraSession) - , m_audioSource(JMediaRecorder::DefaultAudioSource) + , m_audioSource(AndroidMediaRecorder::DefaultAudioSource) , m_duration(0) , m_state(QMediaRecorder::StoppedState) , m_status(QMediaRecorder::UnloadedStatus) @@ -61,17 +60,17 @@ QAndroidCaptureSession::QAndroidCaptureSession(QAndroidCameraSession *cameraSess , m_containerFormatDirty(true) , m_videoSettingsDirty(true) , m_audioSettingsDirty(true) - , m_outputFormat(JMediaRecorder::DefaultOutputFormat) - , m_audioEncoder(JMediaRecorder::DefaultAudioEncoder) - , m_videoEncoder(JMediaRecorder::DefaultVideoEncoder) + , m_outputFormat(AndroidMediaRecorder::DefaultOutputFormat) + , m_audioEncoder(AndroidMediaRecorder::DefaultAudioEncoder) + , m_videoEncoder(AndroidMediaRecorder::DefaultVideoEncoder) { m_mediaStorageLocation.addStorageLocation( QMediaStorageLocation::Movies, - JMultimediaUtils::getDefaultMediaDirectory(JMultimediaUtils::DCIM)); + AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM)); m_mediaStorageLocation.addStorageLocation( QMediaStorageLocation::Sounds, - JMultimediaUtils::getDefaultMediaDirectory(JMultimediaUtils::Sounds)); + AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::Sounds)); connect(this, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(updateStatus())); @@ -103,19 +102,19 @@ void QAndroidCaptureSession::setAudioInput(const QString &input) m_audioInput = input; if (m_audioInput == QLatin1String("default")) - m_audioSource = JMediaRecorder::DefaultAudioSource; + m_audioSource = AndroidMediaRecorder::DefaultAudioSource; else if (m_audioInput == QLatin1String("mic")) - m_audioSource = JMediaRecorder::Mic; + m_audioSource = AndroidMediaRecorder::Mic; else if (m_audioInput == QLatin1String("voice_uplink")) - m_audioSource = JMediaRecorder::VoiceUplink; + m_audioSource = AndroidMediaRecorder::VoiceUplink; else if (m_audioInput == QLatin1String("voice_downlink")) - m_audioSource = JMediaRecorder::VoiceDownlink; + m_audioSource = AndroidMediaRecorder::VoiceDownlink; else if (m_audioInput == QLatin1String("voice_call")) - m_audioSource = JMediaRecorder::VoiceCall; + m_audioSource = AndroidMediaRecorder::VoiceCall; else if (m_audioInput == QLatin1String("voice_recognition")) - m_audioSource = JMediaRecorder::VoiceRecognition; + m_audioSource = AndroidMediaRecorder::VoiceRecognition; else - m_audioSource = JMediaRecorder::DefaultAudioSource; + m_audioSource = AndroidMediaRecorder::DefaultAudioSource; emit audioInputChanged(m_audioInput); } @@ -184,7 +183,7 @@ bool QAndroidCaptureSession::start() m_mediaRecorder->release(); delete m_mediaRecorder; } - m_mediaRecorder = new JMediaRecorder; + m_mediaRecorder = new AndroidMediaRecorder; connect(m_mediaRecorder, SIGNAL(error(int,int)), this, SLOT(onError(int,int))); connect(m_mediaRecorder, SIGNAL(info(int,int)), this, SLOT(onInfo(int,int))); @@ -193,8 +192,8 @@ bool QAndroidCaptureSession::start() updateViewfinder(); m_cameraSession->camera()->unlock(); m_mediaRecorder->setCamera(m_cameraSession->camera()); - m_mediaRecorder->setAudioSource(JMediaRecorder::Camcorder); - m_mediaRecorder->setVideoSource(JMediaRecorder::Camera); + m_mediaRecorder->setAudioSource(AndroidMediaRecorder::Camcorder); + m_mediaRecorder->setVideoSource(AndroidMediaRecorder::Camera); } else { m_mediaRecorder->setAudioSource(m_audioSource); } @@ -280,10 +279,10 @@ void QAndroidCaptureSession::stop(bool error) // with the Android media scanner so it appears immediately in apps // such as the gallery. QString mediaPath = m_actualOutputLocation.toLocalFile(); - QString standardLoc = m_cameraSession ? JMultimediaUtils::getDefaultMediaDirectory(JMultimediaUtils::DCIM) - : JMultimediaUtils::getDefaultMediaDirectory(JMultimediaUtils::Sounds); + QString standardLoc = m_cameraSession ? AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM) + : AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::Sounds); if (mediaPath.startsWith(standardLoc)) - JMultimediaUtils::registerMediaFile(mediaPath); + AndroidMultimediaUtils::registerMediaFile(mediaPath); m_actualOutputLocation = m_usedOutputLocation; emit actualLocationChanged(m_actualOutputLocation); @@ -347,14 +346,14 @@ void QAndroidCaptureSession::applySettings() m_containerFormat = m_defaultSettings.outputFileExtension; m_outputFormat = m_defaultSettings.outputFormat; } else if (m_containerFormat == QLatin1String("3gp")) { - m_outputFormat = JMediaRecorder::THREE_GPP; + m_outputFormat = AndroidMediaRecorder::THREE_GPP; } else if (!m_cameraSession && m_containerFormat == QLatin1String("amr")) { - m_outputFormat = JMediaRecorder::AMR_NB_Format; + m_outputFormat = AndroidMediaRecorder::AMR_NB_Format; } else if (!m_cameraSession && m_containerFormat == QLatin1String("awb")) { - m_outputFormat = JMediaRecorder::AMR_WB_Format; + m_outputFormat = AndroidMediaRecorder::AMR_WB_Format; } else { m_containerFormat = QStringLiteral("mp4"); - m_outputFormat = JMediaRecorder::MPEG_4; + m_outputFormat = AndroidMediaRecorder::MPEG_4; } m_containerFormatDirty = false; @@ -372,11 +371,11 @@ void QAndroidCaptureSession::applySettings() if (m_audioSettings.codec().isEmpty()) m_audioEncoder = m_defaultSettings.audioEncoder; else if (m_audioSettings.codec() == QLatin1String("aac")) - m_audioEncoder = JMediaRecorder::AAC; + m_audioEncoder = AndroidMediaRecorder::AAC; else if (m_audioSettings.codec() == QLatin1String("amr-nb")) - m_audioEncoder = JMediaRecorder::AMR_NB_Encoder; + m_audioEncoder = AndroidMediaRecorder::AMR_NB_Encoder; else if (m_audioSettings.codec() == QLatin1String("amr-wb")) - m_audioEncoder = JMediaRecorder::AMR_WB_Encoder; + m_audioEncoder = AndroidMediaRecorder::AMR_WB_Encoder; else m_audioEncoder = m_defaultSettings.audioEncoder; @@ -410,11 +409,11 @@ void QAndroidCaptureSession::applySettings() if (m_videoSettings.codec().isEmpty()) m_videoEncoder = m_defaultSettings.videoEncoder; else if (m_videoSettings.codec() == QLatin1String("h263")) - m_videoEncoder = JMediaRecorder::H263; + m_videoEncoder = AndroidMediaRecorder::H263; else if (m_videoSettings.codec() == QLatin1String("h264")) - m_videoEncoder = JMediaRecorder::H264; + m_videoEncoder = AndroidMediaRecorder::H264; else if (m_videoSettings.codec() == QLatin1String("mpeg4_sp")) - m_videoEncoder = JMediaRecorder::MPEG_4_SP; + m_videoEncoder = AndroidMediaRecorder::MPEG_4_SP; else m_videoEncoder = m_defaultSettings.videoEncoder; @@ -489,24 +488,24 @@ QAndroidCaptureSession::CaptureProfile QAndroidCaptureSession::getProfile(int id id); - profile.outputFormat = JMediaRecorder::OutputFormat(obj.getField("fileFormat")); - profile.audioEncoder = JMediaRecorder::AudioEncoder(obj.getField("audioCodec")); + profile.outputFormat = AndroidMediaRecorder::OutputFormat(obj.getField("fileFormat")); + profile.audioEncoder = AndroidMediaRecorder::AudioEncoder(obj.getField("audioCodec")); profile.audioBitRate = obj.getField("audioBitRate"); profile.audioChannels = obj.getField("audioChannels"); profile.audioSampleRate = obj.getField("audioSampleRate"); - profile.videoEncoder = JMediaRecorder::VideoEncoder(obj.getField("videoCodec")); + profile.videoEncoder = AndroidMediaRecorder::VideoEncoder(obj.getField("videoCodec")); profile.videoBitRate = obj.getField("videoBitRate"); profile.videoFrameRate = obj.getField("videoFrameRate"); profile.videoResolution = QSize(obj.getField("videoFrameWidth"), obj.getField("videoFrameHeight")); - if (profile.outputFormat == JMediaRecorder::MPEG_4) + if (profile.outputFormat == AndroidMediaRecorder::MPEG_4) profile.outputFileExtension = QStringLiteral("mp4"); - else if (profile.outputFormat == JMediaRecorder::THREE_GPP) + else if (profile.outputFormat == AndroidMediaRecorder::THREE_GPP) profile.outputFileExtension = QStringLiteral("3gp"); - else if (profile.outputFormat == JMediaRecorder::AMR_NB_Format) + else if (profile.outputFormat == AndroidMediaRecorder::AMR_NB_Format) profile.outputFileExtension = QStringLiteral("amr"); - else if (profile.outputFormat == JMediaRecorder::AMR_WB_Format) + else if (profile.outputFormat == AndroidMediaRecorder::AMR_WB_Format) profile.outputFileExtension = QStringLiteral("awb"); profile.isNull = false; diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.h b/src/plugins/android/src/mediacapture/qandroidcapturesession.h index 4b6121dfa..4ff2cb145 100644 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.h +++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.h @@ -48,7 +48,7 @@ #include #include #include -#include "jmediarecorder.h" +#include "androidmediarecorder.h" QT_BEGIN_NAMESPACE @@ -106,15 +106,15 @@ private Q_SLOTS: private: struct CaptureProfile { - JMediaRecorder::OutputFormat outputFormat; + AndroidMediaRecorder::OutputFormat outputFormat; QString outputFileExtension; - JMediaRecorder::AudioEncoder audioEncoder; + AndroidMediaRecorder::AudioEncoder audioEncoder; int audioBitRate; int audioChannels; int audioSampleRate; - JMediaRecorder::VideoEncoder videoEncoder; + AndroidMediaRecorder::VideoEncoder videoEncoder; int videoBitRate; int videoFrameRate; QSize videoResolution; @@ -122,13 +122,13 @@ private: bool isNull; CaptureProfile() - : outputFormat(JMediaRecorder::MPEG_4) + : outputFormat(AndroidMediaRecorder::MPEG_4) , outputFileExtension(QLatin1String("mp4")) - , audioEncoder(JMediaRecorder::DefaultAudioEncoder) + , audioEncoder(AndroidMediaRecorder::DefaultAudioEncoder) , audioBitRate(128000) , audioChannels(2) , audioSampleRate(44100) - , videoEncoder(JMediaRecorder::DefaultVideoEncoder) + , videoEncoder(AndroidMediaRecorder::DefaultVideoEncoder) , videoBitRate(1) , videoFrameRate(-1) , videoResolution(320, 240) @@ -146,11 +146,11 @@ private: void updateViewfinder(); void restartViewfinder(); - JMediaRecorder *m_mediaRecorder; + AndroidMediaRecorder *m_mediaRecorder; QAndroidCameraSession *m_cameraSession; QString m_audioInput; - JMediaRecorder::AudioSource m_audioSource; + AndroidMediaRecorder::AudioSource m_audioSource; QMediaStorageLocation m_mediaStorageLocation; @@ -173,9 +173,9 @@ private: bool m_containerFormatDirty; bool m_videoSettingsDirty; bool m_audioSettingsDirty; - JMediaRecorder::OutputFormat m_outputFormat; - JMediaRecorder::AudioEncoder m_audioEncoder; - JMediaRecorder::VideoEncoder m_videoEncoder; + AndroidMediaRecorder::OutputFormat m_outputFormat; + AndroidMediaRecorder::AudioEncoder m_audioEncoder; + AndroidMediaRecorder::VideoEncoder m_videoEncoder; QList m_supportedResolutions; QList m_supportedFramerates; diff --git a/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.cpp b/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.cpp index 79e0651a3..a239f510b 100644 --- a/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidimageencodercontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.cpp index 3fcb199f7..17a349d9d 100644 --- a/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.cpp +++ b/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.cpp @@ -42,7 +42,7 @@ #include "qandroidvideodeviceselectorcontrol.h" #include "qandroidcamerasession.h" -#include "jcamera.h" +#include "androidcamera.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp index 68fb5e473..2d49e78b1 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp +++ b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.cpp @@ -40,14 +40,14 @@ ****************************************************************************/ #include "qandroidmediaplayercontrol.h" -#include "jmediaplayer.h" +#include "androidmediaplayer.h" #include "qandroidvideooutput.h" QT_BEGIN_NAMESPACE QAndroidMediaPlayerControl::QAndroidMediaPlayerControl(QObject *parent) : QMediaPlayerControl(parent), - mMediaPlayer(new JMediaPlayer), + mMediaPlayer(new AndroidMediaPlayer), mCurrentState(QMediaPlayer::StoppedState), mCurrentMediaStatus(QMediaPlayer::NoMedia), mMediaStream(0), @@ -58,7 +58,7 @@ QAndroidMediaPlayerControl::QAndroidMediaPlayerControl(QObject *parent) mAudioAvailable(false), mVideoAvailable(false), mBuffering(false), - mState(JMediaPlayer::Uninitialized), + mState(AndroidMediaPlayer::Uninitialized), mPendingState(-1), mPendingPosition(-1), mPendingSetMedia(false), @@ -99,11 +99,11 @@ QMediaPlayer::MediaStatus QAndroidMediaPlayerControl::mediaStatus() const qint64 QAndroidMediaPlayerControl::duration() const { - if ((mState & (JMediaPlayer::Prepared - | JMediaPlayer::Started - | JMediaPlayer::Paused - | JMediaPlayer::Stopped - | JMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Prepared + | AndroidMediaPlayer::Started + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::Stopped + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { return 0; } @@ -115,13 +115,13 @@ qint64 QAndroidMediaPlayerControl::position() const if (mCurrentMediaStatus == QMediaPlayer::EndOfMedia) return duration(); - if ((mState & (JMediaPlayer::Idle - | JMediaPlayer::Initialized - | JMediaPlayer::Prepared - | JMediaPlayer::Started - | JMediaPlayer::Paused - | JMediaPlayer::Stopped - | JMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Idle + | AndroidMediaPlayer::Initialized + | AndroidMediaPlayer::Prepared + | AndroidMediaPlayer::Started + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::Stopped + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { return (mPendingPosition == -1) ? 0 : mPendingPosition; } @@ -135,10 +135,10 @@ void QAndroidMediaPlayerControl::setPosition(qint64 position) const int seekPosition = (position > INT_MAX) ? INT_MAX : position; - if ((mState & (JMediaPlayer::Prepared - | JMediaPlayer::Started - | JMediaPlayer::Paused - | JMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Prepared + | AndroidMediaPlayer::Started + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { if (mPendingPosition != seekPosition) { mPendingPosition = seekPosition; Q_EMIT positionChanged(seekPosition); @@ -165,13 +165,13 @@ int QAndroidMediaPlayerControl::volume() const void QAndroidMediaPlayerControl::setVolume(int volume) { - if ((mState & (JMediaPlayer::Idle - | JMediaPlayer::Initialized - | JMediaPlayer::Stopped - | JMediaPlayer::Prepared - | JMediaPlayer::Started - | JMediaPlayer::Paused - | JMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Idle + | AndroidMediaPlayer::Initialized + | AndroidMediaPlayer::Stopped + | AndroidMediaPlayer::Prepared + | AndroidMediaPlayer::Started + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { if (mPendingVolume != volume) { mPendingVolume = volume; Q_EMIT volumeChanged(volume); @@ -196,13 +196,13 @@ bool QAndroidMediaPlayerControl::isMuted() const void QAndroidMediaPlayerControl::setMuted(bool muted) { - if ((mState & (JMediaPlayer::Idle - | JMediaPlayer::Initialized - | JMediaPlayer::Stopped - | JMediaPlayer::Prepared - | JMediaPlayer::Started - | JMediaPlayer::Paused - | JMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Idle + | AndroidMediaPlayer::Initialized + | AndroidMediaPlayer::Stopped + | AndroidMediaPlayer::Prepared + | AndroidMediaPlayer::Started + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { if (mPendingMute != muted) { mPendingMute = muted; Q_EMIT mutedChanged(muted); @@ -291,7 +291,7 @@ void QAndroidMediaPlayerControl::setMedia(const QMediaContent &mediaContent, } // Release the mediaplayer if it's not in in Idle or Uninitialized state - if ((mState & (JMediaPlayer::Idle | JMediaPlayer::Uninitialized)) == 0) + if ((mState & (AndroidMediaPlayer::Idle | AndroidMediaPlayer::Uninitialized)) == 0) mMediaPlayer->release(); if (mediaContent.isNull()) { @@ -353,16 +353,16 @@ void QAndroidMediaPlayerControl::setVideoOutput(QObject *videoOutput) void QAndroidMediaPlayerControl::play() { // We need to prepare the mediaplayer again. - if ((mState & JMediaPlayer::Stopped) && !mMediaContent.isNull()) { + if ((mState & AndroidMediaPlayer::Stopped) && !mMediaContent.isNull()) { setMedia(mMediaContent, mMediaStream); } setState(QMediaPlayer::PlayingState); - if ((mState & (JMediaPlayer::Prepared - | JMediaPlayer::Started - | JMediaPlayer::Paused - | JMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Prepared + | AndroidMediaPlayer::Started + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { mPendingState = QMediaPlayer::PlayingState; return; } @@ -374,9 +374,9 @@ void QAndroidMediaPlayerControl::pause() { setState(QMediaPlayer::PausedState); - if ((mState & (JMediaPlayer::Started - | JMediaPlayer::Paused - | JMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Started + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { mPendingState = QMediaPlayer::PausedState; return; } @@ -388,12 +388,12 @@ void QAndroidMediaPlayerControl::stop() { setState(QMediaPlayer::StoppedState); - if ((mState & (JMediaPlayer::Prepared - | JMediaPlayer::Started - | JMediaPlayer::Stopped - | JMediaPlayer::Paused - | JMediaPlayer::PlaybackCompleted)) == 0) { - if ((mState & (JMediaPlayer::Idle | JMediaPlayer::Uninitialized | JMediaPlayer::Error)) == 0) + if ((mState & (AndroidMediaPlayer::Prepared + | AndroidMediaPlayer::Started + | AndroidMediaPlayer::Stopped + | AndroidMediaPlayer::Paused + | AndroidMediaPlayer::PlaybackCompleted)) == 0) { + if ((mState & (AndroidMediaPlayer::Idle | AndroidMediaPlayer::Uninitialized | AndroidMediaPlayer::Error)) == 0) mPendingState = QMediaPlayer::StoppedState; return; } @@ -405,28 +405,28 @@ void QAndroidMediaPlayerControl::onInfo(qint32 what, qint32 extra) { Q_UNUSED(extra); switch (what) { - case JMediaPlayer::MEDIA_INFO_UNKNOWN: + case AndroidMediaPlayer::MEDIA_INFO_UNKNOWN: break; - case JMediaPlayer::MEDIA_INFO_VIDEO_TRACK_LAGGING: + case AndroidMediaPlayer::MEDIA_INFO_VIDEO_TRACK_LAGGING: // IGNORE break; - case JMediaPlayer::MEDIA_INFO_VIDEO_RENDERING_START: + case AndroidMediaPlayer::MEDIA_INFO_VIDEO_RENDERING_START: break; - case JMediaPlayer::MEDIA_INFO_BUFFERING_START: + case AndroidMediaPlayer::MEDIA_INFO_BUFFERING_START: mPendingState = mCurrentState; setState(QMediaPlayer::PausedState); setMediaStatus(QMediaPlayer::StalledMedia); break; - case JMediaPlayer::MEDIA_INFO_BUFFERING_END: + case AndroidMediaPlayer::MEDIA_INFO_BUFFERING_END: if (mCurrentState != QMediaPlayer::StoppedState) flushPendingStates(); break; - case JMediaPlayer::MEDIA_INFO_BAD_INTERLEAVING: + case AndroidMediaPlayer::MEDIA_INFO_BAD_INTERLEAVING: break; - case JMediaPlayer::MEDIA_INFO_NOT_SEEKABLE: + case AndroidMediaPlayer::MEDIA_INFO_NOT_SEEKABLE: setSeekable(false); break; - case JMediaPlayer::MEDIA_INFO_METADATA_UPDATE: + case AndroidMediaPlayer::MEDIA_INFO_METADATA_UPDATE: Q_EMIT metaDataUpdated(); break; } @@ -438,44 +438,44 @@ void QAndroidMediaPlayerControl::onError(qint32 what, qint32 extra) QMediaPlayer::Error error = QMediaPlayer::ResourceError; switch (what) { - case JMediaPlayer::MEDIA_ERROR_UNKNOWN: + case AndroidMediaPlayer::MEDIA_ERROR_UNKNOWN: errorString = QLatin1String("Error:"); break; - case JMediaPlayer::MEDIA_ERROR_SERVER_DIED: + case AndroidMediaPlayer::MEDIA_ERROR_SERVER_DIED: errorString = QLatin1String("Error: Server died"); error = QMediaPlayer::ServiceMissingError; break; - case JMediaPlayer::MEDIA_ERROR_INVALID_STATE: + case AndroidMediaPlayer::MEDIA_ERROR_INVALID_STATE: errorString = QLatin1String("Error: Invalid state"); error = QMediaPlayer::ServiceMissingError; break; } switch (extra) { - case JMediaPlayer::MEDIA_ERROR_IO: // Network OR file error + case AndroidMediaPlayer::MEDIA_ERROR_IO: // Network OR file error errorString += QLatin1String(" (I/O operation failed)"); error = QMediaPlayer::NetworkError; setMediaStatus(QMediaPlayer::InvalidMedia); break; - case JMediaPlayer::MEDIA_ERROR_MALFORMED: + case AndroidMediaPlayer::MEDIA_ERROR_MALFORMED: errorString += QLatin1String(" (Malformed bitstream)"); error = QMediaPlayer::FormatError; setMediaStatus(QMediaPlayer::InvalidMedia); break; - case JMediaPlayer::MEDIA_ERROR_UNSUPPORTED: + case AndroidMediaPlayer::MEDIA_ERROR_UNSUPPORTED: errorString += QLatin1String(" (Unsupported media)"); error = QMediaPlayer::FormatError; setMediaStatus(QMediaPlayer::InvalidMedia); break; - case JMediaPlayer::MEDIA_ERROR_TIMED_OUT: + case AndroidMediaPlayer::MEDIA_ERROR_TIMED_OUT: errorString += QLatin1String(" (Timed out)"); break; - case JMediaPlayer::MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK: + case AndroidMediaPlayer::MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK: errorString += QLatin1String(" (Unable to start progressive playback')"); error = QMediaPlayer::FormatError; setMediaStatus(QMediaPlayer::InvalidMedia); break; - case JMediaPlayer::MEDIA_ERROR_BAD_THINGS_ARE_GOING_TO_HAPPEN: + case AndroidMediaPlayer::MEDIA_ERROR_BAD_THINGS_ARE_GOING_TO_HAPPEN: errorString += QLatin1String(" (Unknown error/Insufficient resources)"); error = QMediaPlayer::ServiceMissingError; break; @@ -512,21 +512,21 @@ 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 | JMediaPlayer::Uninitialized)) == 0) { + if ((mState & AndroidMediaPlayer::Stopped) + && (state & (AndroidMediaPlayer::Prepared | AndroidMediaPlayer::Error | AndroidMediaPlayer::Uninitialized)) == 0) { return; } mState = state; switch (mState) { - case JMediaPlayer::Idle: + case AndroidMediaPlayer::Idle: break; - case JMediaPlayer::Initialized: + case AndroidMediaPlayer::Initialized: break; - case JMediaPlayer::Preparing: + case AndroidMediaPlayer::Preparing: setMediaStatus(QMediaPlayer::LoadingMedia); break; - case JMediaPlayer::Prepared: + case AndroidMediaPlayer::Prepared: setMediaStatus(QMediaPlayer::LoadedMedia); if (mBuffering) { setMediaStatus(mBufferPercent == 100 ? QMediaPlayer::BufferedMedia @@ -537,7 +537,7 @@ void QAndroidMediaPlayerControl::onStateChanged(qint32 state) setAudioAvailable(true); flushPendingStates(); break; - case JMediaPlayer::Started: + case AndroidMediaPlayer::Started: setState(QMediaPlayer::PlayingState); if (mBuffering) { setMediaStatus(mBufferPercent == 100 ? QMediaPlayer::BufferedMedia @@ -546,25 +546,25 @@ void QAndroidMediaPlayerControl::onStateChanged(qint32 state) setMediaStatus(QMediaPlayer::BufferedMedia); } break; - case JMediaPlayer::Paused: + case AndroidMediaPlayer::Paused: setState(QMediaPlayer::PausedState); break; - case JMediaPlayer::Error: + case AndroidMediaPlayer::Error: setState(QMediaPlayer::StoppedState); setMediaStatus(QMediaPlayer::UnknownMediaStatus); mMediaPlayer->release(); break; - case JMediaPlayer::Stopped: + case AndroidMediaPlayer::Stopped: setState(QMediaPlayer::StoppedState); setMediaStatus(QMediaPlayer::LoadedMedia); setPosition(0); break; - case JMediaPlayer::PlaybackCompleted: + case AndroidMediaPlayer::PlaybackCompleted: setState(QMediaPlayer::StoppedState); setPosition(0); setMediaStatus(QMediaPlayer::EndOfMedia); break; - case JMediaPlayer::Uninitialized: + case AndroidMediaPlayer::Uninitialized: // reset some properties resetBufferingProgress(); mPendingPosition = -1; @@ -579,7 +579,7 @@ void QAndroidMediaPlayerControl::onStateChanged(qint32 state) break; } - if ((mState & (JMediaPlayer::Stopped | JMediaPlayer::Uninitialized)) != 0) { + if ((mState & (AndroidMediaPlayer::Stopped | AndroidMediaPlayer::Uninitialized)) != 0) { mMediaPlayer->setDisplay(0); if (mVideoOutput) { mVideoOutput->stop(); diff --git a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h index 27e6afc12..5744c11b8 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h +++ b/src/plugins/android/src/mediaplayer/qandroidmediaplayercontrol.h @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -class JMediaPlayer; +class AndroidMediaPlayer; class QAndroidVideoOutput; class QAndroidMediaPlayerControl : public QMediaPlayerControl @@ -98,7 +98,7 @@ private Q_SLOTS: void onStateChanged(qint32 state); private: - JMediaPlayer *mMediaPlayer; + AndroidMediaPlayer *mMediaPlayer; QMediaPlayer::State mCurrentState; QMediaPlayer::MediaStatus mCurrentMediaStatus; QMediaContent mMediaContent; diff --git a/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp b/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp index dcc3dfbe0..82bd74997 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp +++ b/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.cpp @@ -41,7 +41,7 @@ #include "qandroidmetadatareadercontrol.h" -#include "jmediametadataretriever.h" +#include "androidmediametadataretriever.h" #include #include #include @@ -74,7 +74,7 @@ static const char* qt_ID3GenreNames[] = QAndroidMetaDataReaderControl::QAndroidMetaDataReaderControl(QObject *parent) : QMetaDataReaderControl(parent) , m_available(false) - , m_retriever(new JMediaMetadataRetriever) + , m_retriever(new AndroidMediaMetadataRetriever) { } @@ -124,56 +124,56 @@ void QAndroidMetaDataReaderControl::updateData() if (!m_mediaContent.isNull()) { if (m_retriever->setDataSource(m_mediaContent.canonicalUrl())) { - QString mimeType = m_retriever->extractMetadata(JMediaMetadataRetriever::MimeType); + QString mimeType = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::MimeType); if (!mimeType.isNull()) m_metadata.insert(QMediaMetaData::MediaType, mimeType); - bool isVideo = !m_retriever->extractMetadata(JMediaMetadataRetriever::HasVideo).isNull() + bool isVideo = !m_retriever->extractMetadata(AndroidMediaMetadataRetriever::HasVideo).isNull() || mimeType.startsWith(QStringLiteral("video")); - QString string = m_retriever->extractMetadata(JMediaMetadataRetriever::Album); + QString string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Album); if (!string.isNull()) m_metadata.insert(QMediaMetaData::AlbumTitle, string); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::AlbumArtist); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::AlbumArtist); if (!string.isNull()) m_metadata.insert(QMediaMetaData::AlbumArtist, string); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Artist); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Artist); if (!string.isNull()) { m_metadata.insert(isVideo ? QMediaMetaData::LeadPerformer : QMediaMetaData::ContributingArtist, string.split('/', QString::SkipEmptyParts)); } - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Author); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Author); if (!string.isNull()) m_metadata.insert(QMediaMetaData::Author, string.split('/', QString::SkipEmptyParts)); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Bitrate); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Bitrate); if (!string.isNull()) { m_metadata.insert(isVideo ? QMediaMetaData::VideoBitRate : QMediaMetaData::AudioBitRate, string.toInt()); } - string = m_retriever->extractMetadata(JMediaMetadataRetriever::CDTrackNumber); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::CDTrackNumber); if (!string.isNull()) m_metadata.insert(QMediaMetaData::TrackNumber, string.toInt()); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Composer); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Composer); if (!string.isNull()) m_metadata.insert(QMediaMetaData::Composer, string.split('/', QString::SkipEmptyParts)); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Date); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Date); if (!string.isNull()) m_metadata.insert(QMediaMetaData::Date, QDateTime::fromString(string, QStringLiteral("yyyyMMddTHHmmss.zzzZ")).date()); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Duration); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Duration); if (!string.isNull()) m_metadata.insert(QMediaMetaData::Duration, string.toLongLong()); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Genre); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Genre); if (!string.isNull()) { // The genre can be returned as an ID3v2 id, get the name for it in that case if (string.startsWith('(') && string.endsWith(')')) { @@ -185,22 +185,22 @@ void QAndroidMetaDataReaderControl::updateData() m_metadata.insert(QMediaMetaData::Genre, string); } - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Title); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Title); if (!string.isNull()) m_metadata.insert(QMediaMetaData::Title, string); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::VideoHeight); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::VideoHeight); if (!string.isNull()) { int height = string.toInt(); - int width = m_retriever->extractMetadata(JMediaMetadataRetriever::VideoWidth).toInt(); + int width = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::VideoWidth).toInt(); m_metadata.insert(QMediaMetaData::Resolution, QSize(width, height)); } - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Writer); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Writer); if (!string.isNull()) m_metadata.insert(QMediaMetaData::Writer, string.split('/', QString::SkipEmptyParts)); - string = m_retriever->extractMetadata(JMediaMetadataRetriever::Year); + string = m_retriever->extractMetadata(AndroidMediaMetadataRetriever::Year); if (!string.isNull()) m_metadata.insert(QMediaMetaData::Year, string.toInt()); } diff --git a/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.h b/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.h index 7ea736ffd..67b92f1eb 100644 --- a/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.h +++ b/src/plugins/android/src/mediaplayer/qandroidmetadatareadercontrol.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE -class JMediaMetadataRetriever; +class AndroidMediaMetadataRetriever; class QAndroidMetaDataReaderControl : public QMetaDataReaderControl { @@ -72,7 +72,7 @@ private: bool m_available; QVariantMap m_metadata; - JMediaMetadataRetriever *m_retriever; + AndroidMediaMetadataRetriever *m_retriever; }; QT_END_NAMESPACE diff --git a/src/plugins/android/src/qandroidmediaserviceplugin.cpp b/src/plugins/android/src/qandroidmediaserviceplugin.cpp index 6c1515308..4d777ce97 100644 --- a/src/plugins/android/src/qandroidmediaserviceplugin.cpp +++ b/src/plugins/android/src/qandroidmediaserviceplugin.cpp @@ -46,11 +46,11 @@ #include "qandroidaudioinputselectorcontrol.h" #include "qandroidcamerainfocontrol.h" #include "qandroidcamerasession.h" -#include "jmediaplayer.h" -#include "jsurfacetexture.h" -#include "jcamera.h" -#include "jmultimediautils.h" -#include "jmediarecorder.h" +#include "androidmediaplayer.h" +#include "androidsurfacetexture.h" +#include "androidcamera.h" +#include "androidmultimediautils.h" +#include "androidmediarecorder.h" #include QT_BEGIN_NAMESPACE @@ -149,6 +149,7 @@ int QAndroidMediaServicePlugin::cameraOrientation(const QByteArray &device) cons QT_END_NAMESPACE +#ifndef Q_OS_ANDROID_NO_SDK Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) { QT_USE_NAMESPACE @@ -165,13 +166,14 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) JNIEnv *jniEnv = uenv.nativeEnvironment; - if (!JMediaPlayer::initJNI(jniEnv) || - !JCamera::initJNI(jniEnv) || - !JMediaRecorder::initJNI(jniEnv)) { + if (!AndroidMediaPlayer::initJNI(jniEnv) || + !AndroidCamera::initJNI(jniEnv) || + !AndroidMediaRecorder::initJNI(jniEnv)) { return JNI_ERR; } - JSurfaceTexture::initJNI(jniEnv); + AndroidSurfaceTexture::initJNI(jniEnv); return JNI_VERSION_1_4; } +#endif // Q_OS_ANDROID_NO_SDK diff --git a/src/plugins/android/src/src.pro b/src/plugins/android/src/src.pro index d071f6fcd..6a472a0a8 100644 --- a/src/plugins/android/src/src.pro +++ b/src/plugins/android/src/src.pro @@ -11,7 +11,7 @@ HEADERS += \ SOURCES += \ qandroidmediaserviceplugin.cpp -include (wrappers/wrappers.pri) +include (wrappers/jni/jni.pri) include (common/common.pri) include (mediaplayer/mediaplayer.pri) include (mediacapture/mediacapture.pri) diff --git a/src/plugins/android/src/wrappers/jcamera.cpp b/src/plugins/android/src/wrappers/jcamera.cpp deleted file mode 100644 index 5401e6d1f..000000000 --- a/src/plugins/android/src/wrappers/jcamera.cpp +++ /dev/null @@ -1,1366 +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 "jcamera.h" - -#include -#include -#include "qandroidmultimediautils.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -static jclass g_qtCameraListenerClass = 0; -static QMutex g_cameraMapMutex; -typedef QMap CameraMap; -Q_GLOBAL_STATIC(CameraMap, g_cameraMap) - -static QRect areaToRect(jobject areaObj) -{ - QJNIObjectPrivate area(areaObj); - QJNIObjectPrivate rect = area.getObjectField("rect", "Landroid/graphics/Rect;"); - - return QRect(rect.getField("left"), - rect.getField("top"), - rect.callMethod("width"), - rect.callMethod("height")); -} - -static QJNIObjectPrivate rectToArea(const QRect &rect) -{ - QJNIObjectPrivate jrect("android/graphics/Rect", - "(IIII)V", - rect.left(), rect.top(), rect.right(), rect.bottom()); - - QJNIObjectPrivate area("android/hardware/Camera$Area", - "(Landroid/graphics/Rect;I)V", - jrect.object(), 500); - - return area; -} - -// native method for QtCameraLisener.java -static void notifyAutoFocusComplete(JNIEnv* , jobject, int id, jboolean success) -{ - QMutexLocker locker(&g_cameraMapMutex); - JCamera *obj = g_cameraMap->value(id, 0); - if (obj) - Q_EMIT obj->autoFocusComplete(success); -} - -static void notifyPictureExposed(JNIEnv* , jobject, int id) -{ - QMutexLocker locker(&g_cameraMapMutex); - JCamera *obj = g_cameraMap->value(id, 0); - if (obj) - Q_EMIT obj->pictureExposed(); -} - -static void notifyPictureCaptured(JNIEnv *env, jobject, int id, jbyteArray data) -{ - QMutexLocker locker(&g_cameraMapMutex); - JCamera *obj = g_cameraMap->value(id, 0); - if (obj) { - const int arrayLength = env->GetArrayLength(data); - QByteArray bytes(arrayLength, Qt::Uninitialized); - env->GetByteArrayRegion(data, 0, arrayLength, (jbyte*)bytes.data()); - Q_EMIT obj->pictureCaptured(bytes); - } -} - -static void notifyFrameFetched(JNIEnv *env, jobject, int id, jbyteArray data) -{ - QMutexLocker locker(&g_cameraMapMutex); - JCamera *obj = g_cameraMap->value(id, 0); - if (obj) { - const int arrayLength = env->GetArrayLength(data); - QByteArray bytes(arrayLength, Qt::Uninitialized); - env->GetByteArrayRegion(data, 0, arrayLength, (jbyte*)bytes.data()); - - Q_EMIT obj->frameFetched(bytes); - } -} - -class JCameraPrivate : public QObject -{ - Q_OBJECT -public: - JCameraPrivate(); - ~JCameraPrivate(); - - Q_INVOKABLE bool init(int cameraId); - - Q_INVOKABLE void release(); - Q_INVOKABLE void lock(); - Q_INVOKABLE void unlock(); - Q_INVOKABLE void reconnect(); - - Q_INVOKABLE JCamera::CameraFacing getFacing(); - Q_INVOKABLE int getNativeOrientation(); - - Q_INVOKABLE QSize getPreferredPreviewSizeForVideo(); - Q_INVOKABLE QList getSupportedPreviewSizes(); - - Q_INVOKABLE JCamera::ImageFormat getPreviewFormat(); - Q_INVOKABLE void setPreviewFormat(JCamera::ImageFormat fmt); - - Q_INVOKABLE QSize previewSize() const { return m_previewSize; } - Q_INVOKABLE void updatePreviewSize(); - Q_INVOKABLE void setPreviewTexture(void *surfaceTexture); - - Q_INVOKABLE bool isZoomSupported(); - Q_INVOKABLE int getMaxZoom(); - Q_INVOKABLE QList getZoomRatios(); - Q_INVOKABLE int getZoom(); - Q_INVOKABLE void setZoom(int value); - - Q_INVOKABLE QString getFlashMode(); - Q_INVOKABLE void setFlashMode(const QString &value); - - Q_INVOKABLE QString getFocusMode(); - Q_INVOKABLE void setFocusMode(const QString &value); - - Q_INVOKABLE int getMaxNumFocusAreas(); - Q_INVOKABLE QList getFocusAreas(); - Q_INVOKABLE void setFocusAreas(const QList &areas); - - Q_INVOKABLE void autoFocus(); - Q_INVOKABLE void cancelAutoFocus(); - - Q_INVOKABLE bool isAutoExposureLockSupported(); - Q_INVOKABLE bool getAutoExposureLock(); - Q_INVOKABLE void setAutoExposureLock(bool toggle); - - Q_INVOKABLE bool isAutoWhiteBalanceLockSupported(); - Q_INVOKABLE bool getAutoWhiteBalanceLock(); - Q_INVOKABLE void setAutoWhiteBalanceLock(bool toggle); - - Q_INVOKABLE int getExposureCompensation(); - Q_INVOKABLE void setExposureCompensation(int value); - Q_INVOKABLE float getExposureCompensationStep(); - Q_INVOKABLE int getMinExposureCompensation(); - Q_INVOKABLE int getMaxExposureCompensation(); - - Q_INVOKABLE QString getSceneMode(); - Q_INVOKABLE void setSceneMode(const QString &value); - - Q_INVOKABLE QString getWhiteBalance(); - Q_INVOKABLE void setWhiteBalance(const QString &value); - - Q_INVOKABLE void updateRotation(); - - Q_INVOKABLE QList getSupportedPictureSizes(); - Q_INVOKABLE void setPictureSize(const QSize &size); - Q_INVOKABLE void setJpegQuality(int quality); - - Q_INVOKABLE void startPreview(); - Q_INVOKABLE void stopPreview(); - - Q_INVOKABLE void takePicture(); - - Q_INVOKABLE void fetchEachFrame(bool fetch); - Q_INVOKABLE void fetchLastPreviewFrame(); - - Q_INVOKABLE void applyParameters(); - - Q_INVOKABLE QStringList callParametersStringListMethod(const QByteArray &methodName); - - int m_cameraId; - QMutex m_parametersMutex; - QSize m_previewSize; - int m_rotation; - QJNIObjectPrivate m_info; - QJNIObjectPrivate m_parameters; - QJNIObjectPrivate m_camera; - QJNIObjectPrivate m_cameraListener; - -Q_SIGNALS: - void previewSizeChanged(); - void previewStarted(); - void previewStopped(); - - void autoFocusStarted(); - - void whiteBalanceChanged(); - - void previewFetched(const QByteArray &preview); -}; - -JCamera::JCamera(JCameraPrivate *d, QThread *worker) - : QObject(), - d_ptr(d), - m_worker(worker) - -{ - qRegisterMetaType >(); - qRegisterMetaType >(); - qRegisterMetaType >(); - - connect(d, &JCameraPrivate::previewSizeChanged, this, &JCamera::previewSizeChanged); - connect(d, &JCameraPrivate::previewStarted, this, &JCamera::previewStarted); - connect(d, &JCameraPrivate::previewStopped, this, &JCamera::previewStopped); - connect(d, &JCameraPrivate::autoFocusStarted, this, &JCamera::autoFocusStarted); - connect(d, &JCameraPrivate::whiteBalanceChanged, this, &JCamera::whiteBalanceChanged); - connect(d, &JCameraPrivate::previewFetched, this, &JCamera::previewFetched); -} - -JCamera::~JCamera() -{ - Q_D(JCamera); - if (d->m_camera.isValid()) { - g_cameraMapMutex.lock(); - g_cameraMap->remove(d->m_cameraId); - g_cameraMapMutex.unlock(); - } - - release(); - m_worker->exit(); - m_worker->wait(5000); -} - -JCamera *JCamera::open(int cameraId) -{ - JCameraPrivate *d = new JCameraPrivate(); - QThread *worker = new QThread; - worker->start(); - d->moveToThread(worker); - connect(worker, &QThread::finished, d, &JCameraPrivate::deleteLater); - bool ok = false; - QMetaObject::invokeMethod(d, "init", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, ok), Q_ARG(int, cameraId)); - if (!ok) { - worker->quit(); - worker->wait(5000); - delete d; - delete worker; - return 0; - } - - JCamera *q = new JCamera(d, worker); - g_cameraMapMutex.lock(); - g_cameraMap->insert(cameraId, q); - g_cameraMapMutex.unlock(); - return q; -} - -int JCamera::cameraId() const -{ - Q_D(const JCamera); - return d->m_cameraId; -} - -void JCamera::lock() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "lock", Qt::BlockingQueuedConnection); -} - -void JCamera::unlock() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "unlock", Qt::BlockingQueuedConnection); -} - -void JCamera::reconnect() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "reconnect"); -} - -void JCamera::release() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "release", Qt::BlockingQueuedConnection); -} - -JCamera::CameraFacing JCamera::getFacing() -{ - Q_D(JCamera); - return d->getFacing(); -} - -int JCamera::getNativeOrientation() -{ - Q_D(JCamera); - return d->getNativeOrientation(); -} - -QSize JCamera::getPreferredPreviewSizeForVideo() -{ - Q_D(JCamera); - return d->getPreferredPreviewSizeForVideo(); -} - -QList JCamera::getSupportedPreviewSizes() -{ - Q_D(JCamera); - return d->getSupportedPreviewSizes(); -} - -JCamera::ImageFormat JCamera::getPreviewFormat() -{ - Q_D(JCamera); - return d->getPreviewFormat(); -} - -void JCamera::setPreviewFormat(ImageFormat fmt) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setPreviewFormat", Q_ARG(JCamera::ImageFormat, fmt)); -} - -QSize JCamera::previewSize() const -{ - Q_D(const JCamera); - return d->m_previewSize; -} - -void JCamera::setPreviewSize(const QSize &size) -{ - Q_D(JCamera); - d->m_parametersMutex.lock(); - bool areParametersValid = d->m_parameters.isValid(); - d->m_parametersMutex.unlock(); - if (!areParametersValid) - return; - - d->m_previewSize = size; - QMetaObject::invokeMethod(d, "updatePreviewSize"); -} - -void JCamera::setPreviewTexture(jobject surfaceTexture) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setPreviewTexture", Qt::BlockingQueuedConnection, Q_ARG(void *, surfaceTexture)); -} - -bool JCamera::isZoomSupported() -{ - Q_D(JCamera); - return d->isZoomSupported(); -} - -int JCamera::getMaxZoom() -{ - Q_D(JCamera); - return d->getMaxZoom(); -} - -QList JCamera::getZoomRatios() -{ - Q_D(JCamera); - return d->getZoomRatios(); -} - -int JCamera::getZoom() -{ - Q_D(JCamera); - return d->getZoom(); -} - -void JCamera::setZoom(int value) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setZoom", Q_ARG(int, value)); -} - -QStringList JCamera::getSupportedFlashModes() -{ - Q_D(JCamera); - return d->callParametersStringListMethod("getSupportedFlashModes"); -} - -QString JCamera::getFlashMode() -{ - Q_D(JCamera); - return d->getFlashMode(); -} - -void JCamera::setFlashMode(const QString &value) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setFlashMode", Q_ARG(QString, value)); -} - -QStringList JCamera::getSupportedFocusModes() -{ - Q_D(JCamera); - return d->callParametersStringListMethod("getSupportedFocusModes"); -} - -QString JCamera::getFocusMode() -{ - Q_D(JCamera); - return d->getFocusMode(); -} - -void JCamera::setFocusMode(const QString &value) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setFocusMode", Q_ARG(QString, value)); -} - -int JCamera::getMaxNumFocusAreas() -{ - Q_D(JCamera); - return d->getMaxNumFocusAreas(); -} - -QList JCamera::getFocusAreas() -{ - Q_D(JCamera); - return d->getFocusAreas(); -} - -void JCamera::setFocusAreas(const QList &areas) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setFocusAreas", Q_ARG(QList, areas)); -} - -void JCamera::autoFocus() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "autoFocus"); -} - -void JCamera::cancelAutoFocus() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "cancelAutoFocus", Qt::QueuedConnection); -} - -bool JCamera::isAutoExposureLockSupported() -{ - Q_D(JCamera); - return d->isAutoExposureLockSupported(); -} - -bool JCamera::getAutoExposureLock() -{ - Q_D(JCamera); - return d->getAutoExposureLock(); -} - -void JCamera::setAutoExposureLock(bool toggle) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setAutoExposureLock", Q_ARG(bool, toggle)); -} - -bool JCamera::isAutoWhiteBalanceLockSupported() -{ - Q_D(JCamera); - return d->isAutoWhiteBalanceLockSupported(); -} - -bool JCamera::getAutoWhiteBalanceLock() -{ - Q_D(JCamera); - return d->getAutoWhiteBalanceLock(); -} - -void JCamera::setAutoWhiteBalanceLock(bool toggle) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setAutoWhiteBalanceLock", Q_ARG(bool, toggle)); -} - -int JCamera::getExposureCompensation() -{ - Q_D(JCamera); - return d->getExposureCompensation(); -} - -void JCamera::setExposureCompensation(int value) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setExposureCompensation", Q_ARG(int, value)); -} - -float JCamera::getExposureCompensationStep() -{ - Q_D(JCamera); - return d->getExposureCompensationStep(); -} - -int JCamera::getMinExposureCompensation() -{ - Q_D(JCamera); - return d->getMinExposureCompensation(); -} - -int JCamera::getMaxExposureCompensation() -{ - Q_D(JCamera); - return d->getMaxExposureCompensation(); -} - -QStringList JCamera::getSupportedSceneModes() -{ - Q_D(JCamera); - return d->callParametersStringListMethod("getSupportedSceneModes"); -} - -QString JCamera::getSceneMode() -{ - Q_D(JCamera); - return d->getSceneMode(); -} - -void JCamera::setSceneMode(const QString &value) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setSceneMode", Q_ARG(QString, value)); -} - -QStringList JCamera::getSupportedWhiteBalance() -{ - Q_D(JCamera); - return d->callParametersStringListMethod("getSupportedWhiteBalance"); -} - -QString JCamera::getWhiteBalance() -{ - Q_D(JCamera); - return d->getWhiteBalance(); -} - -void JCamera::setWhiteBalance(const QString &value) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setWhiteBalance", Q_ARG(QString, value)); -} - -void JCamera::setRotation(int rotation) -{ - Q_D(JCamera); - //We need to do it here and not in worker class because we cache rotation - d->m_parametersMutex.lock(); - bool areParametersValid = d->m_parameters.isValid(); - d->m_parametersMutex.unlock(); - if (!areParametersValid) - return; - - d->m_rotation = rotation; - QMetaObject::invokeMethod(d, "updateRotation"); -} - -int JCamera::getRotation() const -{ - Q_D(const JCamera); - return d->m_rotation; -} - -QList JCamera::getSupportedPictureSizes() -{ - Q_D(JCamera); - return d->getSupportedPictureSizes(); -} - -void JCamera::setPictureSize(const QSize &size) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setPictureSize", Q_ARG(QSize, size)); -} - -void JCamera::setJpegQuality(int quality) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "setJpegQuality", Q_ARG(int, quality)); -} - -void JCamera::takePicture() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "takePicture", Qt::BlockingQueuedConnection); -} - -void JCamera::fetchEachFrame(bool fetch) -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "fetchEachFrame", Q_ARG(bool, fetch)); -} - -void JCamera::fetchLastPreviewFrame() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "fetchLastPreviewFrame"); -} - -QJNIObjectPrivate JCamera::getCameraObject() -{ - Q_D(JCamera); - return d->m_camera; -} - -void JCamera::startPreview() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "startPreview"); -} - -void JCamera::stopPreview() -{ - Q_D(JCamera); - QMetaObject::invokeMethod(d, "stopPreview"); -} - -JCameraPrivate::JCameraPrivate() - : QObject(), - m_parametersMutex(QMutex::Recursive) -{ -} - -JCameraPrivate::~JCameraPrivate() -{ -} - -bool JCameraPrivate::init(int cameraId) -{ - m_cameraId = cameraId; - m_camera = QJNIObjectPrivate::callStaticObjectMethod("android/hardware/Camera", - "open", - "(I)Landroid/hardware/Camera;", - cameraId); - - if (!m_camera.isValid()) - return false; - - m_cameraListener = QJNIObjectPrivate(g_qtCameraListenerClass, "(I)V", m_cameraId); - m_info = QJNIObjectPrivate("android/hardware/Camera$CameraInfo"); - m_camera.callStaticMethod("android/hardware/Camera", - "getCameraInfo", - "(ILandroid/hardware/Camera$CameraInfo;)V", - cameraId, - m_info.object()); - - QJNIObjectPrivate params = m_camera.callObjectMethod("getParameters", - "()Landroid/hardware/Camera$Parameters;"); - m_parameters = QJNIObjectPrivate(params); - - return true; -} - -void JCameraPrivate::release() -{ - m_previewSize = QSize(); - m_parametersMutex.lock(); - m_parameters = QJNIObjectPrivate(); - m_parametersMutex.unlock(); - if (m_camera.isValid()) - m_camera.callMethod("release"); -} - -void JCameraPrivate::lock() -{ - m_camera.callMethod("lock"); -} - -void JCameraPrivate::unlock() -{ - m_camera.callMethod("unlock"); -} - -void JCameraPrivate::reconnect() -{ - QJNIEnvironmentPrivate env; - m_camera.callMethod("reconnect"); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif // QT_DEBUG - env->ExceptionDescribe(); - } -} - -JCamera::CameraFacing JCameraPrivate::getFacing() -{ - return JCamera::CameraFacing(m_info.getField("facing")); -} - -int JCameraPrivate::getNativeOrientation() -{ - return m_info.getField("orientation"); -} - -QSize JCameraPrivate::getPreferredPreviewSizeForVideo() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return QSize(); - - QJNIObjectPrivate size = m_parameters.callObjectMethod("getPreferredPreviewSizeForVideo", - "()Landroid/hardware/Camera$Size;"); - - return QSize(size.getField("width"), size.getField("height")); -} - -QList JCameraPrivate::getSupportedPreviewSizes() -{ - QList list; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (m_parameters.isValid()) { - QJNIObjectPrivate sizeList = m_parameters.callObjectMethod("getSupportedPreviewSizes", - "()Ljava/util/List;"); - int count = sizeList.callMethod("size"); - for (int i = 0; i < count; ++i) { - QJNIObjectPrivate size = sizeList.callObjectMethod("get", - "(I)Ljava/lang/Object;", - i); - list.append(QSize(size.getField("width"), size.getField("height"))); - } - - qSort(list.begin(), list.end(), qt_sizeLessThan); - } - - return list; -} - -JCamera::ImageFormat JCameraPrivate::getPreviewFormat() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return JCamera::Unknown; - - return JCamera::ImageFormat(m_parameters.callMethod("getPreviewFormat")); -} - -void JCameraPrivate::setPreviewFormat(JCamera::ImageFormat fmt) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setPreviewFormat", "(I)V", jint(fmt)); - applyParameters(); -} - -void JCameraPrivate::updatePreviewSize() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (m_previewSize.isValid()) { - m_parameters.callMethod("setPreviewSize", "(II)V", m_previewSize.width(), m_previewSize.height()); - applyParameters(); - } - - emit previewSizeChanged(); -} - -void JCameraPrivate::setPreviewTexture(void *surfaceTexture) -{ - m_camera.callMethod("setPreviewTexture", - "(Landroid/graphics/SurfaceTexture;)V", - static_cast(surfaceTexture)); -} - -bool JCameraPrivate::isZoomSupported() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return false; - - return m_parameters.callMethod("isZoomSupported"); -} - -int JCameraPrivate::getMaxZoom() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return 0; - - return m_parameters.callMethod("getMaxZoom"); -} - -QList JCameraPrivate::getZoomRatios() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - QList ratios; - - if (m_parameters.isValid()) { - QJNIObjectPrivate ratioList = m_parameters.callObjectMethod("getZoomRatios", - "()Ljava/util/List;"); - int count = ratioList.callMethod("size"); - for (int i = 0; i < count; ++i) { - QJNIObjectPrivate zoomRatio = ratioList.callObjectMethod("get", - "(I)Ljava/lang/Object;", - i); - - ratios.append(zoomRatio.callMethod("intValue")); - } - } - - return ratios; -} - -int JCameraPrivate::getZoom() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return 0; - - return m_parameters.callMethod("getZoom"); -} - -void JCameraPrivate::setZoom(int value) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setZoom", "(I)V", value); - applyParameters(); -} - -QString JCameraPrivate::getFlashMode() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - QString value; - - if (m_parameters.isValid()) { - QJNIObjectPrivate flashMode = m_parameters.callObjectMethod("getFlashMode", - "()Ljava/lang/String;"); - if (flashMode.isValid()) - value = flashMode.toString(); - } - - return value; -} - -void JCameraPrivate::setFlashMode(const QString &value) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setFlashMode", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(value).object()); - applyParameters(); -} - -QString JCameraPrivate::getFocusMode() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - QString value; - - if (m_parameters.isValid()) { - QJNIObjectPrivate focusMode = m_parameters.callObjectMethod("getFocusMode", - "()Ljava/lang/String;"); - if (focusMode.isValid()) - value = focusMode.toString(); - } - - return value; -} - -void JCameraPrivate::setFocusMode(const QString &value) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setFocusMode", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(value).object()); - applyParameters(); -} - -int JCameraPrivate::getMaxNumFocusAreas() -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return 0; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return 0; - - return m_parameters.callMethod("getMaxNumFocusAreas"); -} - -QList JCameraPrivate::getFocusAreas() -{ - QList areas; - - if (QtAndroidPrivate::androidSdkVersion() < 14) - return areas; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (m_parameters.isValid()) { - QJNIObjectPrivate list = m_parameters.callObjectMethod("getFocusAreas", - "()Ljava/util/List;"); - - if (list.isValid()) { - int count = list.callMethod("size"); - for (int i = 0; i < count; ++i) { - QJNIObjectPrivate area = list.callObjectMethod("get", - "(I)Ljava/lang/Object;", - i); - - areas.append(areaToRect(area.object())); - } - } - } - - return areas; -} - -void JCameraPrivate::setFocusAreas(const QList &areas) -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - QJNIObjectPrivate list; - - if (!areas.isEmpty()) { - QJNIEnvironmentPrivate env; - QJNIObjectPrivate arrayList("java/util/ArrayList", "(I)V", areas.size()); - for (int i = 0; i < areas.size(); ++i) { - arrayList.callMethod("add", - "(Ljava/lang/Object;)Z", - rectToArea(areas.at(i)).object()); - if (env->ExceptionCheck()) - env->ExceptionClear(); - } - list = arrayList; - } - - m_parameters.callMethod("setFocusAreas", "(Ljava/util/List;)V", list.object()); - - applyParameters(); -} - -void JCameraPrivate::autoFocus() -{ - m_camera.callMethod("autoFocus", - "(Landroid/hardware/Camera$AutoFocusCallback;)V", - m_cameraListener.object()); - emit autoFocusStarted(); -} - -void JCameraPrivate::cancelAutoFocus() -{ - m_camera.callMethod("cancelAutoFocus"); -} - -bool JCameraPrivate::isAutoExposureLockSupported() -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return false; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return false; - - return m_parameters.callMethod("isAutoExposureLockSupported"); -} - -bool JCameraPrivate::getAutoExposureLock() -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return false; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return false; - - return m_parameters.callMethod("getAutoExposureLock"); -} - -void JCameraPrivate::setAutoExposureLock(bool toggle) -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setAutoExposureLock", "(Z)V", toggle); - applyParameters(); -} - -bool JCameraPrivate::isAutoWhiteBalanceLockSupported() -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return false; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return false; - - return m_parameters.callMethod("isAutoWhiteBalanceLockSupported"); -} - -bool JCameraPrivate::getAutoWhiteBalanceLock() -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return false; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return false; - - return m_parameters.callMethod("getAutoWhiteBalanceLock"); -} - -void JCameraPrivate::setAutoWhiteBalanceLock(bool toggle) -{ - if (QtAndroidPrivate::androidSdkVersion() < 14) - return; - - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setAutoWhiteBalanceLock", "(Z)V", toggle); - applyParameters(); -} - -int JCameraPrivate::getExposureCompensation() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return 0; - - return m_parameters.callMethod("getExposureCompensation"); -} - -void JCameraPrivate::setExposureCompensation(int value) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setExposureCompensation", "(I)V", value); - applyParameters(); -} - -float JCameraPrivate::getExposureCompensationStep() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return 0; - - return m_parameters.callMethod("getExposureCompensationStep"); -} - -int JCameraPrivate::getMinExposureCompensation() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return 0; - - return m_parameters.callMethod("getMinExposureCompensation"); -} - -int JCameraPrivate::getMaxExposureCompensation() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return 0; - - return m_parameters.callMethod("getMaxExposureCompensation"); -} - -QString JCameraPrivate::getSceneMode() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - QString value; - - if (m_parameters.isValid()) { - QJNIObjectPrivate sceneMode = m_parameters.callObjectMethod("getSceneMode", - "()Ljava/lang/String;"); - if (sceneMode.isValid()) - value = sceneMode.toString(); - } - - return value; -} - -void JCameraPrivate::setSceneMode(const QString &value) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setSceneMode", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(value).object()); - applyParameters(); -} - -QString JCameraPrivate::getWhiteBalance() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - QString value; - - if (m_parameters.isValid()) { - QJNIObjectPrivate wb = m_parameters.callObjectMethod("getWhiteBalance", - "()Ljava/lang/String;"); - if (wb.isValid()) - value = wb.toString(); - } - - return value; -} - -void JCameraPrivate::setWhiteBalance(const QString &value) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setWhiteBalance", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(value).object()); - applyParameters(); - - emit whiteBalanceChanged(); -} - -void JCameraPrivate::updateRotation() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - m_parameters.callMethod("setRotation", "(I)V", m_rotation); - applyParameters(); -} - -QList JCameraPrivate::getSupportedPictureSizes() -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - QList list; - - if (m_parameters.isValid()) { - QJNIObjectPrivate sizeList = m_parameters.callObjectMethod("getSupportedPictureSizes", - "()Ljava/util/List;"); - int count = sizeList.callMethod("size"); - for (int i = 0; i < count; ++i) { - QJNIObjectPrivate size = sizeList.callObjectMethod("get", - "(I)Ljava/lang/Object;", - i); - list.append(QSize(size.getField("width"), size.getField("height"))); - } - - qSort(list.begin(), list.end(), qt_sizeLessThan); - } - - return list; -} - -void JCameraPrivate::setPictureSize(const QSize &size) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setPictureSize", "(II)V", size.width(), size.height()); - applyParameters(); -} - -void JCameraPrivate::setJpegQuality(int quality) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - if (!m_parameters.isValid()) - return; - - m_parameters.callMethod("setJpegQuality", "(I)V", quality); - applyParameters(); -} - -void JCameraPrivate::startPreview() -{ - //We need to clear preview buffers queue here, but there is no method to do it - //Though just resetting preview callback do the trick - m_camera.callMethod("setPreviewCallbackWithBuffer", - "(Landroid/hardware/Camera$PreviewCallback;)V", - jobject(0)); - m_cameraListener.callMethod("preparePreviewBuffer", "(Landroid/hardware/Camera;)V", m_camera.object()); - QJNIObjectPrivate buffer = m_cameraListener.callObjectMethod("callbackBuffer"); - m_camera.callMethod("addCallbackBuffer", "([B)V", buffer.object()); - m_camera.callMethod("setPreviewCallbackWithBuffer", - "(Landroid/hardware/Camera$PreviewCallback;)V", - m_cameraListener.object()); - m_camera.callMethod("startPreview"); - emit previewStarted(); -} - -void JCameraPrivate::stopPreview() -{ - m_camera.callMethod("stopPreview"); - emit previewStopped(); -} - -void JCameraPrivate::takePicture() -{ - m_camera.callMethod("takePicture", "(Landroid/hardware/Camera$ShutterCallback;" - "Landroid/hardware/Camera$PictureCallback;" - "Landroid/hardware/Camera$PictureCallback;)V", - m_cameraListener.object(), - jobject(0), - m_cameraListener.object()); -} - -void JCameraPrivate::fetchEachFrame(bool fetch) -{ - m_cameraListener.callMethod("fetchEachFrame", "(Z)V", fetch); -} - -void JCameraPrivate::fetchLastPreviewFrame() -{ - QJNIEnvironmentPrivate env; - QJNIObjectPrivate data = m_cameraListener.callObjectMethod("lockAndFetchPreviewBuffer", "()[B"); - if (!data.isValid()) { - m_cameraListener.callMethod("unlockPreviewBuffer"); - return; - } - const int arrayLength = env->GetArrayLength(static_cast(data.object())); - QByteArray bytes(arrayLength, Qt::Uninitialized); - env->GetByteArrayRegion(static_cast(data.object()), - 0, - arrayLength, - reinterpret_cast(bytes.data())); - m_cameraListener.callMethod("unlockPreviewBuffer"); - - emit previewFetched(bytes); -} - -void JCameraPrivate::applyParameters() -{ - m_camera.callMethod("setParameters", - "(Landroid/hardware/Camera$Parameters;)V", - m_parameters.object()); -} - -QStringList JCameraPrivate::callParametersStringListMethod(const QByteArray &methodName) -{ - QMutexLocker parametersLocker(&m_parametersMutex); - - QStringList stringList; - - if (m_parameters.isValid()) { - QJNIObjectPrivate list = m_parameters.callObjectMethod(methodName.constData(), - "()Ljava/util/List;"); - - if (list.isValid()) { - int count = list.callMethod("size"); - for (int i = 0; i < count; ++i) { - QJNIObjectPrivate string = list.callObjectMethod("get", - "(I)Ljava/lang/Object;", - i); - stringList.append(string.toString()); - } - } - } - - return stringList; -} - -static JNINativeMethod methods[] = { - {"notifyAutoFocusComplete", "(IZ)V", (void *)notifyAutoFocusComplete}, - {"notifyPictureExposed", "(I)V", (void *)notifyPictureExposed}, - {"notifyPictureCaptured", "(I[B)V", (void *)notifyPictureCaptured}, - {"notifyFrameFetched", "(I[B)V", (void *)notifyFrameFetched} -}; - -bool JCamera::initJNI(JNIEnv *env) -{ - jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtCameraListener"); - if (env->ExceptionCheck()) - env->ExceptionClear(); - - if (clazz) { - g_qtCameraListenerClass = static_cast(env->NewGlobalRef(clazz)); - if (env->RegisterNatives(g_qtCameraListenerClass, - methods, - sizeof(methods) / sizeof(methods[0])) < 0) { - return false; - } - } - - return true; -} - -QT_END_NAMESPACE - -#include "jcamera.moc" diff --git a/src/plugins/android/src/wrappers/jcamera.h b/src/plugins/android/src/wrappers/jcamera.h deleted file mode 100644 index ec5bcc3c7..000000000 --- a/src/plugins/android/src/wrappers/jcamera.h +++ /dev/null @@ -1,187 +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 JCAMERA_H -#define JCAMERA_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QThread; - -class JCameraPrivate; - -class JCamera : public QObject -{ - Q_OBJECT - Q_ENUMS(CameraFacing) - Q_ENUMS(ImageFormat) -public: - enum CameraFacing { - CameraFacingBack = 0, - CameraFacingFront = 1 - }; - - enum ImageFormat { // same values as in android.graphics.ImageFormat Java class - Unknown = 0, - RGB565 = 4, - NV16 = 16, - NV21 = 17, - YUY2 = 20, - JPEG = 256, - YV12 = 842094169 - }; - - ~JCamera(); - - static JCamera *open(int cameraId); - - int cameraId() const; - - void lock(); - void unlock(); - void reconnect(); - void release(); - - CameraFacing getFacing(); - int getNativeOrientation(); - - QSize getPreferredPreviewSizeForVideo(); - QList getSupportedPreviewSizes(); - - ImageFormat getPreviewFormat(); - void setPreviewFormat(ImageFormat fmt); - - QSize previewSize() const; - void setPreviewSize(const QSize &size); - void setPreviewTexture(jobject surfaceTexture); - - bool isZoomSupported(); - int getMaxZoom(); - QList 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 getFocusAreas(); - void setFocusAreas(const QList &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); - int getRotation() const; - - QList getSupportedPictureSizes(); - void setPictureSize(const QSize &size); - void setJpegQuality(int quality); - - void startPreview(); - void stopPreview(); - - void takePicture(); - - void fetchEachFrame(bool fetch); - void fetchLastPreviewFrame(); - QJNIObjectPrivate getCameraObject(); - - static bool initJNI(JNIEnv *env); - -Q_SIGNALS: - void previewSizeChanged(); - void previewStarted(); - void previewStopped(); - - void autoFocusStarted(); - void autoFocusComplete(bool success); - - void whiteBalanceChanged(); - - void pictureExposed(); - void pictureCaptured(const QByteArray &data); - void previewFetched(const QByteArray &preview); - void frameFetched(const QByteArray &frame); - -private: - JCamera(JCameraPrivate *d, QThread *worker); - - Q_DECLARE_PRIVATE(JCamera) - JCameraPrivate *d_ptr; - QScopedPointer m_worker; -}; - -QT_END_NAMESPACE - -#endif // JCAMERA_H diff --git a/src/plugins/android/src/wrappers/jmediametadataretriever.cpp b/src/plugins/android/src/wrappers/jmediametadataretriever.cpp deleted file mode 100644 index 93b77ecb1..000000000 --- a/src/plugins/android/src/wrappers/jmediametadataretriever.cpp +++ /dev/null @@ -1,130 +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 "jmediametadataretriever.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -JMediaMetadataRetriever::JMediaMetadataRetriever() -{ - m_metadataRetriever = QJNIObjectPrivate("android/media/MediaMetadataRetriever"); -} - -JMediaMetadataRetriever::~JMediaMetadataRetriever() -{ -} - -QString JMediaMetadataRetriever::extractMetadata(MetadataKey key) -{ - QString value; - - QJNIObjectPrivate metadata = m_metadataRetriever.callObjectMethod("extractMetadata", - "(I)Ljava/lang/String;", - jint(key)); - if (metadata.isValid()) - value = metadata.toString(); - - return value; -} - -void JMediaMetadataRetriever::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 = m_metadataRetriever.callStaticObjectMethod("android/net/Uri", - "parse", - "(Ljava/lang/String;)Landroid/net/Uri;", - string.object()); - if (env->ExceptionCheck()) { - env->ExceptionClear(); - } else { - m_metadataRetriever.callMethod("setDataSource", - "(Landroid/content/Context;Landroid/net/Uri;)V", - QtAndroidPrivate::activity(), - uri.object()); - if (env->ExceptionCheck()) - env->ExceptionClear(); - else - loaded = true; - } - - return loaded; -} - -bool JMediaMetadataRetriever::setDataSource(const QString &path) -{ - if (!m_metadataRetriever.isValid()) - return false; - - QJNIEnvironmentPrivate env; - - bool loaded = false; - - m_metadataRetriever.callMethod("setDataSource", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(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 deleted file mode 100644 index 7b0340c0d..000000000 --- a/src/plugins/android/src/wrappers/jmediametadataretriever.h +++ /dev/null @@ -1,93 +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 JMEDIAMETADATARETRIEVER_H -#define JMEDIAMETADATARETRIEVER_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class JMediaMetadataRetriever -{ -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); - -private: - QJNIObjectPrivate m_metadataRetriever; -}; - -QT_END_NAMESPACE - -#endif // JMEDIAMETADATARETRIEVER_H diff --git a/src/plugins/android/src/wrappers/jmediaplayer.cpp b/src/plugins/android/src/wrappers/jmediaplayer.cpp deleted file mode 100644 index 98ccbfd5a..000000000 --- a/src/plugins/android/src/wrappers/jmediaplayer.cpp +++ /dev/null @@ -1,266 +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 "jmediaplayer.h" - -#include -#include -#include -#include - -static jclass mediaPlayerClass = Q_NULLPTR; -typedef QMap MediaPlayerMap; -Q_GLOBAL_STATIC(MediaPlayerMap, mediaPlayers) - -QT_BEGIN_NAMESPACE - -JMediaPlayer::JMediaPlayer() - : QObject() -{ - - const jlong id = reinterpret_cast(this); - mMediaPlayer = QJNIObjectPrivate(mediaPlayerClass, - "(Landroid/app/Activity;J)V", - QtAndroidPrivate::activity(), - id); - (*mediaPlayers)[id] = this; -} - -JMediaPlayer::~JMediaPlayer() -{ - mediaPlayers->remove(reinterpret_cast(this)); -} - -void JMediaPlayer::release() -{ - mMediaPlayer.callMethod("release"); -} - -void JMediaPlayer::reset() -{ - mMediaPlayer.callMethod("reset"); -} - -int JMediaPlayer::getCurrentPosition() -{ - return mMediaPlayer.callMethod("getCurrentPosition"); -} - -int JMediaPlayer::getDuration() -{ - return mMediaPlayer.callMethod("getDuration"); -} - -bool JMediaPlayer::isPlaying() -{ - return mMediaPlayer.callMethod("isPlaying"); -} - -int JMediaPlayer::volume() -{ - return mMediaPlayer.callMethod("getVolume"); -} - -bool JMediaPlayer::isMuted() -{ - return mMediaPlayer.callMethod("isMuted"); -} - -jobject JMediaPlayer::display() -{ - return mMediaPlayer.callObjectMethod("display", "()Landroid/view/SurfaceHolder;").object(); -} - -void JMediaPlayer::play() -{ - mMediaPlayer.callMethod("start"); -} - -void JMediaPlayer::pause() -{ - mMediaPlayer.callMethod("pause"); -} - -void JMediaPlayer::stop() -{ - mMediaPlayer.callMethod("stop"); -} - -void JMediaPlayer::seekTo(qint32 msec) -{ - mMediaPlayer.callMethod("seekTo", "(I)V", jint(msec)); -} - -void JMediaPlayer::setMuted(bool mute) -{ - mMediaPlayer.callMethod("mute", "(Z)V", jboolean(mute)); -} - -void JMediaPlayer::setDataSource(const QString &path) -{ - QJNIObjectPrivate string = QJNIObjectPrivate::fromString(path); - mMediaPlayer.callMethod("setDataSource", "(Ljava/lang/String;)V", string.object()); -} - -void JMediaPlayer::prepareAsync() -{ - mMediaPlayer.callMethod("prepareAsync"); -} - -void JMediaPlayer::setVolume(int volume) -{ - mMediaPlayer.callMethod("setVolume", "(I)V", jint(volume)); -} - -void JMediaPlayer::setDisplay(jobject surfaceHolder) -{ - mMediaPlayer.callMethod("setDisplay", "(Landroid/view/SurfaceHolder;)V", surfaceHolder); -} - -static void onErrorNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - JMediaPlayer *const mp = (*mediaPlayers)[id]; - if (!mp) - return; - - Q_EMIT mp->error(what, extra); -} - -static void onBufferingUpdateNative(JNIEnv *env, jobject thiz, jint percent, jlong id) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - JMediaPlayer *const mp = (*mediaPlayers)[id]; - if (!mp) - return; - - Q_EMIT mp->bufferingChanged(percent); -} - -static void onProgressUpdateNative(JNIEnv *env, jobject thiz, jint progress, jlong id) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - JMediaPlayer *const mp = (*mediaPlayers)[id]; - if (!mp) - return; - - Q_EMIT mp->progressChanged(progress); -} - -static void onDurationChangedNative(JNIEnv *env, jobject thiz, jint duration, jlong id) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - JMediaPlayer *const mp = (*mediaPlayers)[id]; - if (!mp) - return; - - Q_EMIT mp->durationChanged(duration); -} - -static void onInfoNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - JMediaPlayer *const mp = (*mediaPlayers)[id]; - if (!mp) - return; - - Q_EMIT mp->info(what, extra); -} - -static void onStateChangedNative(JNIEnv *env, jobject thiz, jint state, jlong id) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - JMediaPlayer *const mp = (*mediaPlayers)[id]; - if (!mp) - return; - - Q_EMIT mp->stateChanged(state); -} - -static void onVideoSizeChangedNative(JNIEnv *env, - jobject thiz, - jint width, - jint height, - jlong id) -{ - Q_UNUSED(env); - Q_UNUSED(thiz); - JMediaPlayer *const mp = (*mediaPlayers)[id]; - if (!mp) - return; - - Q_EMIT mp->videoSizeChanged(width, height); -} - -bool JMediaPlayer::initJNI(JNIEnv *env) -{ - jclass jClass = env->FindClass("org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer"); - - if (jClass) { - mediaPlayerClass = static_cast(env->NewGlobalRef(jClass)); - - JNINativeMethod methods[] = { - {"onErrorNative", "(IIJ)V", reinterpret_cast(onErrorNative)}, - {"onBufferingUpdateNative", "(IJ)V", reinterpret_cast(onBufferingUpdateNative)}, - {"onProgressUpdateNative", "(IJ)V", reinterpret_cast(onProgressUpdateNative)}, - {"onDurationChangedNative", "(IJ)V", reinterpret_cast(onDurationChangedNative)}, - {"onInfoNative", "(IIJ)V", reinterpret_cast(onInfoNative)}, - {"onVideoSizeChangedNative", "(IIJ)V", reinterpret_cast(onVideoSizeChangedNative)}, - {"onStateChangedNative", "(IJ)V", reinterpret_cast(onStateChangedNative)} - }; - - 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 deleted file mode 100644 index cd469e677..000000000 --- a/src/plugins/android/src/wrappers/jmediaplayer.h +++ /dev/null @@ -1,135 +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 QANDROIDMEDIAPLAYER_H -#define QANDROIDMEDIAPLAYER_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class JMediaPlayer : public QObject -{ - Q_OBJECT -public: - JMediaPlayer(); - ~JMediaPlayer(); - - enum MediaError - { - // What - MEDIA_ERROR_UNKNOWN = 1, - MEDIA_ERROR_SERVER_DIED = 100, - MEDIA_ERROR_INVALID_STATE = -38, // Undocumented - // 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, - MEDIA_ERROR_BAD_THINGS_ARE_GOING_TO_HAPPEN = -2147483648 // Undocumented - }; - - 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 MediaPlayerState - { - Uninitialized = 0x1, /* End */ - Idle = 0x2, - Preparing = 0x4, - Prepared = 0x8, - Initialized = 0x10, - Started = 0x20, - Stopped = 0x40, - Paused = 0x80, - PlaybackCompleted = 0x100, - Error = 0x200 - }; - - void release(); - void reset(); - - int getCurrentPosition(); - int getDuration(); - bool isPlaying(); - int volume(); - bool isMuted(); - jobject display(); - - void play(); - void pause(); - void stop(); - void seekTo(qint32 msec); - void setMuted(bool mute); - void setDataSource(const QString &path); - void prepareAsync(); - void setVolume(int volume); - void setDisplay(jobject surfaceHolder); - - static bool initJNI(JNIEnv *env); - -Q_SIGNALS: - void error(qint32 what, qint32 extra); - void bufferingChanged(qint32 percent); - void durationChanged(qint64 duration); - void progressChanged(qint64 progress); - void stateChanged(qint32 state); - void info(qint32 what, qint32 extra); - void videoSizeChanged(qint32 width, qint32 height); - -private: - QJNIObjectPrivate mMediaPlayer; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDMEDIAPLAYER_H diff --git a/src/plugins/android/src/wrappers/jmediarecorder.cpp b/src/plugins/android/src/wrappers/jmediarecorder.cpp deleted file mode 100644 index 0b1498d99..000000000 --- a/src/plugins/android/src/wrappers/jmediarecorder.cpp +++ /dev/null @@ -1,299 +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 "jmediarecorder.h" - -#include "jcamera.h" -#include -#include - -QT_BEGIN_NAMESPACE - -static jclass g_qtMediaRecorderListenerClass = 0; -typedef QMap MediaRecorderMap; -Q_GLOBAL_STATIC(MediaRecorderMap, mediaRecorders) - -static void notifyError(JNIEnv* , jobject, jlong id, jint what, jint extra) -{ - JMediaRecorder *obj = mediaRecorders->value(id, 0); - if (obj) - emit obj->error(what, extra); -} - -static void notifyInfo(JNIEnv* , jobject, jlong id, jint what, jint extra) -{ - JMediaRecorder *obj = mediaRecorders->value(id, 0); - if (obj) - emit obj->info(what, extra); -} - -JMediaRecorder::JMediaRecorder() - : QObject() - , m_id(reinterpret_cast(this)) -{ - m_mediaRecorder = QJNIObjectPrivate("android/media/MediaRecorder"); - if (m_mediaRecorder.isValid()) { - QJNIObjectPrivate listener(g_qtMediaRecorderListenerClass, "(J)V", m_id); - m_mediaRecorder.callMethod("setOnErrorListener", - "(Landroid/media/MediaRecorder$OnErrorListener;)V", - listener.object()); - m_mediaRecorder.callMethod("setOnInfoListener", - "(Landroid/media/MediaRecorder$OnInfoListener;)V", - listener.object()); - mediaRecorders->insert(m_id, this); - } -} - -JMediaRecorder::~JMediaRecorder() -{ - mediaRecorders->remove(m_id); -} - -void JMediaRecorder::release() -{ - m_mediaRecorder.callMethod("release"); -} - -bool JMediaRecorder::prepare() -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("prepare"); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - return false; - } - return true; -} - -void JMediaRecorder::reset() -{ - m_mediaRecorder.callMethod("reset"); -} - -bool JMediaRecorder::start() -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("start"); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - return false; - } - return true; -} - -void JMediaRecorder::stop() -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("stop"); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setAudioChannels(int numChannels) -{ - m_mediaRecorder.callMethod("setAudioChannels", "(I)V", numChannels); -} - -void JMediaRecorder::setAudioEncoder(AudioEncoder encoder) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setAudioEncoder", "(I)V", int(encoder)); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setAudioEncodingBitRate(int bitRate) -{ - m_mediaRecorder.callMethod("setAudioEncodingBitRate", "(I)V", bitRate); -} - -void JMediaRecorder::setAudioSamplingRate(int samplingRate) -{ - m_mediaRecorder.callMethod("setAudioSamplingRate", "(I)V", samplingRate); -} - -void JMediaRecorder::setAudioSource(AudioSource source) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setAudioSource", "(I)V", int(source)); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setCamera(JCamera *camera) -{ - QJNIObjectPrivate cam = camera->getCameraObject(); - m_mediaRecorder.callMethod("setCamera", "(Landroid/hardware/Camera;)V", cam.object()); -} - -void JMediaRecorder::setVideoEncoder(VideoEncoder encoder) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setVideoEncoder", "(I)V", int(encoder)); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setVideoEncodingBitRate(int bitRate) -{ - m_mediaRecorder.callMethod("setVideoEncodingBitRate", "(I)V", bitRate); -} - -void JMediaRecorder::setVideoFrameRate(int rate) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setVideoFrameRate", "(I)V", rate); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setVideoSize(const QSize &size) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setVideoSize", "(II)V", size.width(), size.height()); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setVideoSource(VideoSource source) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setVideoSource", "(I)V", int(source)); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setOrientationHint(int degrees) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setOrientationHint", "(I)V", degrees); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setOutputFormat(OutputFormat format) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setOutputFormat", "(I)V", int(format)); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - } -} - -void JMediaRecorder::setOutputFile(const QString &path) -{ - QJNIEnvironmentPrivate env; - m_mediaRecorder.callMethod("setOutputFile", - "(Ljava/lang/String;)V", - QJNIObjectPrivate::fromString(path).object()); - if (env->ExceptionCheck()) { -#ifdef QT_DEBUG - env->ExceptionDescribe(); -#endif - 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/QtMediaRecorderListener"); - if (env->ExceptionCheck()) - env->ExceptionClear(); - - if (clazz) { - g_qtMediaRecorderListenerClass = static_cast(env->NewGlobalRef(clazz)); - if (env->RegisterNatives(g_qtMediaRecorderListenerClass, - 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 deleted file mode 100644 index 3a83e7e16..000000000 --- a/src/plugins/android/src/wrappers/jmediarecorder.h +++ /dev/null @@ -1,135 +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 JMEDIARECORDER_H -#define JMEDIARECORDER_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class JCamera; - -class JMediaRecorder : public QObject -{ - 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; - QJNIObjectPrivate m_mediaRecorder; -}; - -QT_END_NAMESPACE - -#endif // JMEDIARECORDER_H diff --git a/src/plugins/android/src/wrappers/jmultimediautils.cpp b/src/plugins/android/src/wrappers/jmultimediautils.cpp deleted file mode 100644 index d1b0830c7..000000000 --- a/src/plugins/android/src/wrappers/jmultimediautils.cpp +++ /dev/null @@ -1,80 +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 "jmultimediautils.h" - -#include - -QT_BEGIN_NAMESPACE - - -void JMultimediaUtils::enableOrientationListener(bool enable) -{ - QJNIObjectPrivate::callStaticMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", - "enableOrientationListener", - "(Z)V", - enable); -} - -int JMultimediaUtils::getDeviceOrientation() -{ - return QJNIObjectPrivate::callStaticMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", - "getDeviceOrientation"); -} - -QString JMultimediaUtils::getDefaultMediaDirectory(MediaType 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) -{ - 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 deleted file mode 100644 index b80ef4236..000000000 --- a/src/plugins/android/src/wrappers/jmultimediautils.h +++ /dev/null @@ -1,68 +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 JMULTIMEDIAUTILS_H -#define JMULTIMEDIAUTILS_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class JMultimediaUtils -{ -public: - enum MediaType { - Music = 0, - Movies = 1, - DCIM = 2, - Sounds = 3 - }; - - static void enableOrientationListener(bool enable); - static int getDeviceOrientation(); - static QString getDefaultMediaDirectory(MediaType type); - static void registerMediaFile(const QString &file); -}; - -QT_END_NAMESPACE - -#endif // JMULTIMEDIAUTILS_H diff --git a/src/plugins/android/src/wrappers/jni/androidcamera.cpp b/src/plugins/android/src/wrappers/jni/androidcamera.cpp new file mode 100644 index 000000000..af017c392 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidcamera.cpp @@ -0,0 +1,1366 @@ +/**************************************************************************** +** +** 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 "androidcamera.h" + +#include +#include +#include "qandroidmultimediautils.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static jclass g_qtCameraListenerClass = 0; +static QMutex g_cameraMapMutex; +typedef QMap CameraMap; +Q_GLOBAL_STATIC(CameraMap, g_cameraMap) + +static QRect areaToRect(jobject areaObj) +{ + QJNIObjectPrivate area(areaObj); + QJNIObjectPrivate rect = area.getObjectField("rect", "Landroid/graphics/Rect;"); + + return QRect(rect.getField("left"), + rect.getField("top"), + rect.callMethod("width"), + rect.callMethod("height")); +} + +static QJNIObjectPrivate rectToArea(const QRect &rect) +{ + QJNIObjectPrivate jrect("android/graphics/Rect", + "(IIII)V", + rect.left(), rect.top(), rect.right(), rect.bottom()); + + QJNIObjectPrivate area("android/hardware/Camera$Area", + "(Landroid/graphics/Rect;I)V", + jrect.object(), 500); + + return area; +} + +// native method for QtCameraLisener.java +static void notifyAutoFocusComplete(JNIEnv* , jobject, int id, jboolean success) +{ + QMutexLocker locker(&g_cameraMapMutex); + AndroidCamera *obj = g_cameraMap->value(id, 0); + if (obj) + Q_EMIT obj->autoFocusComplete(success); +} + +static void notifyPictureExposed(JNIEnv* , jobject, int id) +{ + QMutexLocker locker(&g_cameraMapMutex); + AndroidCamera *obj = g_cameraMap->value(id, 0); + if (obj) + Q_EMIT obj->pictureExposed(); +} + +static void notifyPictureCaptured(JNIEnv *env, jobject, int id, jbyteArray data) +{ + QMutexLocker locker(&g_cameraMapMutex); + AndroidCamera *obj = g_cameraMap->value(id, 0); + if (obj) { + const int arrayLength = env->GetArrayLength(data); + QByteArray bytes(arrayLength, Qt::Uninitialized); + env->GetByteArrayRegion(data, 0, arrayLength, (jbyte*)bytes.data()); + Q_EMIT obj->pictureCaptured(bytes); + } +} + +static void notifyFrameFetched(JNIEnv *env, jobject, int id, jbyteArray data) +{ + QMutexLocker locker(&g_cameraMapMutex); + AndroidCamera *obj = g_cameraMap->value(id, 0); + if (obj) { + const int arrayLength = env->GetArrayLength(data); + QByteArray bytes(arrayLength, Qt::Uninitialized); + env->GetByteArrayRegion(data, 0, arrayLength, (jbyte*)bytes.data()); + + Q_EMIT obj->frameFetched(bytes); + } +} + +class AndroidCameraPrivate : public QObject +{ + Q_OBJECT +public: + AndroidCameraPrivate(); + ~AndroidCameraPrivate(); + + Q_INVOKABLE bool init(int cameraId); + + Q_INVOKABLE void release(); + Q_INVOKABLE void lock(); + Q_INVOKABLE void unlock(); + Q_INVOKABLE void reconnect(); + + Q_INVOKABLE AndroidCamera::CameraFacing getFacing(); + Q_INVOKABLE int getNativeOrientation(); + + Q_INVOKABLE QSize getPreferredPreviewSizeForVideo(); + Q_INVOKABLE QList getSupportedPreviewSizes(); + + Q_INVOKABLE AndroidCamera::ImageFormat getPreviewFormat(); + Q_INVOKABLE void setPreviewFormat(AndroidCamera::ImageFormat fmt); + + Q_INVOKABLE QSize previewSize() const { return m_previewSize; } + Q_INVOKABLE void updatePreviewSize(); + Q_INVOKABLE void setPreviewTexture(void *surfaceTexture); + + Q_INVOKABLE bool isZoomSupported(); + Q_INVOKABLE int getMaxZoom(); + Q_INVOKABLE QList getZoomRatios(); + Q_INVOKABLE int getZoom(); + Q_INVOKABLE void setZoom(int value); + + Q_INVOKABLE QString getFlashMode(); + Q_INVOKABLE void setFlashMode(const QString &value); + + Q_INVOKABLE QString getFocusMode(); + Q_INVOKABLE void setFocusMode(const QString &value); + + Q_INVOKABLE int getMaxNumFocusAreas(); + Q_INVOKABLE QList getFocusAreas(); + Q_INVOKABLE void setFocusAreas(const QList &areas); + + Q_INVOKABLE void autoFocus(); + Q_INVOKABLE void cancelAutoFocus(); + + Q_INVOKABLE bool isAutoExposureLockSupported(); + Q_INVOKABLE bool getAutoExposureLock(); + Q_INVOKABLE void setAutoExposureLock(bool toggle); + + Q_INVOKABLE bool isAutoWhiteBalanceLockSupported(); + Q_INVOKABLE bool getAutoWhiteBalanceLock(); + Q_INVOKABLE void setAutoWhiteBalanceLock(bool toggle); + + Q_INVOKABLE int getExposureCompensation(); + Q_INVOKABLE void setExposureCompensation(int value); + Q_INVOKABLE float getExposureCompensationStep(); + Q_INVOKABLE int getMinExposureCompensation(); + Q_INVOKABLE int getMaxExposureCompensation(); + + Q_INVOKABLE QString getSceneMode(); + Q_INVOKABLE void setSceneMode(const QString &value); + + Q_INVOKABLE QString getWhiteBalance(); + Q_INVOKABLE void setWhiteBalance(const QString &value); + + Q_INVOKABLE void updateRotation(); + + Q_INVOKABLE QList getSupportedPictureSizes(); + Q_INVOKABLE void setPictureSize(const QSize &size); + Q_INVOKABLE void setJpegQuality(int quality); + + Q_INVOKABLE void startPreview(); + Q_INVOKABLE void stopPreview(); + + Q_INVOKABLE void takePicture(); + + Q_INVOKABLE void fetchEachFrame(bool fetch); + Q_INVOKABLE void fetchLastPreviewFrame(); + + Q_INVOKABLE void applyParameters(); + + Q_INVOKABLE QStringList callParametersStringListMethod(const QByteArray &methodName); + + int m_cameraId; + QMutex m_parametersMutex; + QSize m_previewSize; + int m_rotation; + QJNIObjectPrivate m_info; + QJNIObjectPrivate m_parameters; + QJNIObjectPrivate m_camera; + QJNIObjectPrivate m_cameraListener; + +Q_SIGNALS: + void previewSizeChanged(); + void previewStarted(); + void previewStopped(); + + void autoFocusStarted(); + + void whiteBalanceChanged(); + + void previewFetched(const QByteArray &preview); +}; + +AndroidCamera::AndroidCamera(AndroidCameraPrivate *d, QThread *worker) + : QObject(), + d_ptr(d), + m_worker(worker) + +{ + qRegisterMetaType >(); + qRegisterMetaType >(); + qRegisterMetaType >(); + + connect(d, &AndroidCameraPrivate::previewSizeChanged, this, &AndroidCamera::previewSizeChanged); + connect(d, &AndroidCameraPrivate::previewStarted, this, &AndroidCamera::previewStarted); + connect(d, &AndroidCameraPrivate::previewStopped, this, &AndroidCamera::previewStopped); + connect(d, &AndroidCameraPrivate::autoFocusStarted, this, &AndroidCamera::autoFocusStarted); + connect(d, &AndroidCameraPrivate::whiteBalanceChanged, this, &AndroidCamera::whiteBalanceChanged); + connect(d, &AndroidCameraPrivate::previewFetched, this, &AndroidCamera::previewFetched); +} + +AndroidCamera::~AndroidCamera() +{ + Q_D(AndroidCamera); + if (d->m_camera.isValid()) { + g_cameraMapMutex.lock(); + g_cameraMap->remove(d->m_cameraId); + g_cameraMapMutex.unlock(); + } + + release(); + m_worker->exit(); + m_worker->wait(5000); +} + +AndroidCamera *AndroidCamera::open(int cameraId) +{ + AndroidCameraPrivate *d = new AndroidCameraPrivate(); + QThread *worker = new QThread; + worker->start(); + d->moveToThread(worker); + connect(worker, &QThread::finished, d, &AndroidCameraPrivate::deleteLater); + bool ok = false; + QMetaObject::invokeMethod(d, "init", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, ok), Q_ARG(int, cameraId)); + if (!ok) { + worker->quit(); + worker->wait(5000); + delete d; + delete worker; + return 0; + } + + AndroidCamera *q = new AndroidCamera(d, worker); + g_cameraMapMutex.lock(); + g_cameraMap->insert(cameraId, q); + g_cameraMapMutex.unlock(); + return q; +} + +int AndroidCamera::cameraId() const +{ + Q_D(const AndroidCamera); + return d->m_cameraId; +} + +void AndroidCamera::lock() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "lock", Qt::BlockingQueuedConnection); +} + +void AndroidCamera::unlock() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "unlock", Qt::BlockingQueuedConnection); +} + +void AndroidCamera::reconnect() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "reconnect"); +} + +void AndroidCamera::release() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "release", Qt::BlockingQueuedConnection); +} + +AndroidCamera::CameraFacing AndroidCamera::getFacing() +{ + Q_D(AndroidCamera); + return d->getFacing(); +} + +int AndroidCamera::getNativeOrientation() +{ + Q_D(AndroidCamera); + return d->getNativeOrientation(); +} + +QSize AndroidCamera::getPreferredPreviewSizeForVideo() +{ + Q_D(AndroidCamera); + return d->getPreferredPreviewSizeForVideo(); +} + +QList AndroidCamera::getSupportedPreviewSizes() +{ + Q_D(AndroidCamera); + return d->getSupportedPreviewSizes(); +} + +AndroidCamera::ImageFormat AndroidCamera::getPreviewFormat() +{ + Q_D(AndroidCamera); + return d->getPreviewFormat(); +} + +void AndroidCamera::setPreviewFormat(ImageFormat fmt) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setPreviewFormat", Q_ARG(AndroidCamera::ImageFormat, fmt)); +} + +QSize AndroidCamera::previewSize() const +{ + Q_D(const AndroidCamera); + return d->m_previewSize; +} + +void AndroidCamera::setPreviewSize(const QSize &size) +{ + Q_D(AndroidCamera); + d->m_parametersMutex.lock(); + bool areParametersValid = d->m_parameters.isValid(); + d->m_parametersMutex.unlock(); + if (!areParametersValid) + return; + + d->m_previewSize = size; + QMetaObject::invokeMethod(d, "updatePreviewSize"); +} + +void AndroidCamera::setPreviewTexture(jobject surfaceTexture) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setPreviewTexture", Qt::BlockingQueuedConnection, Q_ARG(void *, surfaceTexture)); +} + +bool AndroidCamera::isZoomSupported() +{ + Q_D(AndroidCamera); + return d->isZoomSupported(); +} + +int AndroidCamera::getMaxZoom() +{ + Q_D(AndroidCamera); + return d->getMaxZoom(); +} + +QList AndroidCamera::getZoomRatios() +{ + Q_D(AndroidCamera); + return d->getZoomRatios(); +} + +int AndroidCamera::getZoom() +{ + Q_D(AndroidCamera); + return d->getZoom(); +} + +void AndroidCamera::setZoom(int value) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setZoom", Q_ARG(int, value)); +} + +QStringList AndroidCamera::getSupportedFlashModes() +{ + Q_D(AndroidCamera); + return d->callParametersStringListMethod("getSupportedFlashModes"); +} + +QString AndroidCamera::getFlashMode() +{ + Q_D(AndroidCamera); + return d->getFlashMode(); +} + +void AndroidCamera::setFlashMode(const QString &value) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setFlashMode", Q_ARG(QString, value)); +} + +QStringList AndroidCamera::getSupportedFocusModes() +{ + Q_D(AndroidCamera); + return d->callParametersStringListMethod("getSupportedFocusModes"); +} + +QString AndroidCamera::getFocusMode() +{ + Q_D(AndroidCamera); + return d->getFocusMode(); +} + +void AndroidCamera::setFocusMode(const QString &value) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setFocusMode", Q_ARG(QString, value)); +} + +int AndroidCamera::getMaxNumFocusAreas() +{ + Q_D(AndroidCamera); + return d->getMaxNumFocusAreas(); +} + +QList AndroidCamera::getFocusAreas() +{ + Q_D(AndroidCamera); + return d->getFocusAreas(); +} + +void AndroidCamera::setFocusAreas(const QList &areas) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setFocusAreas", Q_ARG(QList, areas)); +} + +void AndroidCamera::autoFocus() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "autoFocus"); +} + +void AndroidCamera::cancelAutoFocus() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "cancelAutoFocus", Qt::QueuedConnection); +} + +bool AndroidCamera::isAutoExposureLockSupported() +{ + Q_D(AndroidCamera); + return d->isAutoExposureLockSupported(); +} + +bool AndroidCamera::getAutoExposureLock() +{ + Q_D(AndroidCamera); + return d->getAutoExposureLock(); +} + +void AndroidCamera::setAutoExposureLock(bool toggle) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setAutoExposureLock", Q_ARG(bool, toggle)); +} + +bool AndroidCamera::isAutoWhiteBalanceLockSupported() +{ + Q_D(AndroidCamera); + return d->isAutoWhiteBalanceLockSupported(); +} + +bool AndroidCamera::getAutoWhiteBalanceLock() +{ + Q_D(AndroidCamera); + return d->getAutoWhiteBalanceLock(); +} + +void AndroidCamera::setAutoWhiteBalanceLock(bool toggle) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setAutoWhiteBalanceLock", Q_ARG(bool, toggle)); +} + +int AndroidCamera::getExposureCompensation() +{ + Q_D(AndroidCamera); + return d->getExposureCompensation(); +} + +void AndroidCamera::setExposureCompensation(int value) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setExposureCompensation", Q_ARG(int, value)); +} + +float AndroidCamera::getExposureCompensationStep() +{ + Q_D(AndroidCamera); + return d->getExposureCompensationStep(); +} + +int AndroidCamera::getMinExposureCompensation() +{ + Q_D(AndroidCamera); + return d->getMinExposureCompensation(); +} + +int AndroidCamera::getMaxExposureCompensation() +{ + Q_D(AndroidCamera); + return d->getMaxExposureCompensation(); +} + +QStringList AndroidCamera::getSupportedSceneModes() +{ + Q_D(AndroidCamera); + return d->callParametersStringListMethod("getSupportedSceneModes"); +} + +QString AndroidCamera::getSceneMode() +{ + Q_D(AndroidCamera); + return d->getSceneMode(); +} + +void AndroidCamera::setSceneMode(const QString &value) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setSceneMode", Q_ARG(QString, value)); +} + +QStringList AndroidCamera::getSupportedWhiteBalance() +{ + Q_D(AndroidCamera); + return d->callParametersStringListMethod("getSupportedWhiteBalance"); +} + +QString AndroidCamera::getWhiteBalance() +{ + Q_D(AndroidCamera); + return d->getWhiteBalance(); +} + +void AndroidCamera::setWhiteBalance(const QString &value) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setWhiteBalance", Q_ARG(QString, value)); +} + +void AndroidCamera::setRotation(int rotation) +{ + Q_D(AndroidCamera); + //We need to do it here and not in worker class because we cache rotation + d->m_parametersMutex.lock(); + bool areParametersValid = d->m_parameters.isValid(); + d->m_parametersMutex.unlock(); + if (!areParametersValid) + return; + + d->m_rotation = rotation; + QMetaObject::invokeMethod(d, "updateRotation"); +} + +int AndroidCamera::getRotation() const +{ + Q_D(const AndroidCamera); + return d->m_rotation; +} + +QList AndroidCamera::getSupportedPictureSizes() +{ + Q_D(AndroidCamera); + return d->getSupportedPictureSizes(); +} + +void AndroidCamera::setPictureSize(const QSize &size) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setPictureSize", Q_ARG(QSize, size)); +} + +void AndroidCamera::setJpegQuality(int quality) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "setJpegQuality", Q_ARG(int, quality)); +} + +void AndroidCamera::takePicture() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "takePicture", Qt::BlockingQueuedConnection); +} + +void AndroidCamera::fetchEachFrame(bool fetch) +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "fetchEachFrame", Q_ARG(bool, fetch)); +} + +void AndroidCamera::fetchLastPreviewFrame() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "fetchLastPreviewFrame"); +} + +QJNIObjectPrivate AndroidCamera::getCameraObject() +{ + Q_D(AndroidCamera); + return d->m_camera; +} + +void AndroidCamera::startPreview() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "startPreview"); +} + +void AndroidCamera::stopPreview() +{ + Q_D(AndroidCamera); + QMetaObject::invokeMethod(d, "stopPreview"); +} + +AndroidCameraPrivate::AndroidCameraPrivate() + : QObject(), + m_parametersMutex(QMutex::Recursive) +{ +} + +AndroidCameraPrivate::~AndroidCameraPrivate() +{ +} + +bool AndroidCameraPrivate::init(int cameraId) +{ + m_cameraId = cameraId; + m_camera = QJNIObjectPrivate::callStaticObjectMethod("android/hardware/Camera", + "open", + "(I)Landroid/hardware/Camera;", + cameraId); + + if (!m_camera.isValid()) + return false; + + m_cameraListener = QJNIObjectPrivate(g_qtCameraListenerClass, "(I)V", m_cameraId); + m_info = QJNIObjectPrivate("android/hardware/Camera$CameraInfo"); + m_camera.callStaticMethod("android/hardware/Camera", + "getCameraInfo", + "(ILandroid/hardware/Camera$CameraInfo;)V", + cameraId, + m_info.object()); + + QJNIObjectPrivate params = m_camera.callObjectMethod("getParameters", + "()Landroid/hardware/Camera$Parameters;"); + m_parameters = QJNIObjectPrivate(params); + + return true; +} + +void AndroidCameraPrivate::release() +{ + m_previewSize = QSize(); + m_parametersMutex.lock(); + m_parameters = QJNIObjectPrivate(); + m_parametersMutex.unlock(); + if (m_camera.isValid()) + m_camera.callMethod("release"); +} + +void AndroidCameraPrivate::lock() +{ + m_camera.callMethod("lock"); +} + +void AndroidCameraPrivate::unlock() +{ + m_camera.callMethod("unlock"); +} + +void AndroidCameraPrivate::reconnect() +{ + QJNIEnvironmentPrivate env; + m_camera.callMethod("reconnect"); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif // QT_DEBUG + env->ExceptionDescribe(); + } +} + +AndroidCamera::CameraFacing AndroidCameraPrivate::getFacing() +{ + return AndroidCamera::CameraFacing(m_info.getField("facing")); +} + +int AndroidCameraPrivate::getNativeOrientation() +{ + return m_info.getField("orientation"); +} + +QSize AndroidCameraPrivate::getPreferredPreviewSizeForVideo() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return QSize(); + + QJNIObjectPrivate size = m_parameters.callObjectMethod("getPreferredPreviewSizeForVideo", + "()Landroid/hardware/Camera$Size;"); + + return QSize(size.getField("width"), size.getField("height")); +} + +QList AndroidCameraPrivate::getSupportedPreviewSizes() +{ + QList list; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (m_parameters.isValid()) { + QJNIObjectPrivate sizeList = m_parameters.callObjectMethod("getSupportedPreviewSizes", + "()Ljava/util/List;"); + int count = sizeList.callMethod("size"); + for (int i = 0; i < count; ++i) { + QJNIObjectPrivate size = sizeList.callObjectMethod("get", + "(I)Ljava/lang/Object;", + i); + list.append(QSize(size.getField("width"), size.getField("height"))); + } + + qSort(list.begin(), list.end(), qt_sizeLessThan); + } + + return list; +} + +AndroidCamera::ImageFormat AndroidCameraPrivate::getPreviewFormat() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return AndroidCamera::Unknown; + + return AndroidCamera::ImageFormat(m_parameters.callMethod("getPreviewFormat")); +} + +void AndroidCameraPrivate::setPreviewFormat(AndroidCamera::ImageFormat fmt) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setPreviewFormat", "(I)V", jint(fmt)); + applyParameters(); +} + +void AndroidCameraPrivate::updatePreviewSize() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (m_previewSize.isValid()) { + m_parameters.callMethod("setPreviewSize", "(II)V", m_previewSize.width(), m_previewSize.height()); + applyParameters(); + } + + emit previewSizeChanged(); +} + +void AndroidCameraPrivate::setPreviewTexture(void *surfaceTexture) +{ + m_camera.callMethod("setPreviewTexture", + "(Landroid/graphics/SurfaceTexture;)V", + static_cast(surfaceTexture)); +} + +bool AndroidCameraPrivate::isZoomSupported() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return false; + + return m_parameters.callMethod("isZoomSupported"); +} + +int AndroidCameraPrivate::getMaxZoom() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return 0; + + return m_parameters.callMethod("getMaxZoom"); +} + +QList AndroidCameraPrivate::getZoomRatios() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + QList ratios; + + if (m_parameters.isValid()) { + QJNIObjectPrivate ratioList = m_parameters.callObjectMethod("getZoomRatios", + "()Ljava/util/List;"); + int count = ratioList.callMethod("size"); + for (int i = 0; i < count; ++i) { + QJNIObjectPrivate zoomRatio = ratioList.callObjectMethod("get", + "(I)Ljava/lang/Object;", + i); + + ratios.append(zoomRatio.callMethod("intValue")); + } + } + + return ratios; +} + +int AndroidCameraPrivate::getZoom() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return 0; + + return m_parameters.callMethod("getZoom"); +} + +void AndroidCameraPrivate::setZoom(int value) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setZoom", "(I)V", value); + applyParameters(); +} + +QString AndroidCameraPrivate::getFlashMode() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + QString value; + + if (m_parameters.isValid()) { + QJNIObjectPrivate flashMode = m_parameters.callObjectMethod("getFlashMode", + "()Ljava/lang/String;"); + if (flashMode.isValid()) + value = flashMode.toString(); + } + + return value; +} + +void AndroidCameraPrivate::setFlashMode(const QString &value) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setFlashMode", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(value).object()); + applyParameters(); +} + +QString AndroidCameraPrivate::getFocusMode() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + QString value; + + if (m_parameters.isValid()) { + QJNIObjectPrivate focusMode = m_parameters.callObjectMethod("getFocusMode", + "()Ljava/lang/String;"); + if (focusMode.isValid()) + value = focusMode.toString(); + } + + return value; +} + +void AndroidCameraPrivate::setFocusMode(const QString &value) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setFocusMode", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(value).object()); + applyParameters(); +} + +int AndroidCameraPrivate::getMaxNumFocusAreas() +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return 0; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return 0; + + return m_parameters.callMethod("getMaxNumFocusAreas"); +} + +QList AndroidCameraPrivate::getFocusAreas() +{ + QList areas; + + if (QtAndroidPrivate::androidSdkVersion() < 14) + return areas; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (m_parameters.isValid()) { + QJNIObjectPrivate list = m_parameters.callObjectMethod("getFocusAreas", + "()Ljava/util/List;"); + + if (list.isValid()) { + int count = list.callMethod("size"); + for (int i = 0; i < count; ++i) { + QJNIObjectPrivate area = list.callObjectMethod("get", + "(I)Ljava/lang/Object;", + i); + + areas.append(areaToRect(area.object())); + } + } + } + + return areas; +} + +void AndroidCameraPrivate::setFocusAreas(const QList &areas) +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + QJNIObjectPrivate list; + + if (!areas.isEmpty()) { + QJNIEnvironmentPrivate env; + QJNIObjectPrivate arrayList("java/util/ArrayList", "(I)V", areas.size()); + for (int i = 0; i < areas.size(); ++i) { + arrayList.callMethod("add", + "(Ljava/lang/Object;)Z", + rectToArea(areas.at(i)).object()); + if (env->ExceptionCheck()) + env->ExceptionClear(); + } + list = arrayList; + } + + m_parameters.callMethod("setFocusAreas", "(Ljava/util/List;)V", list.object()); + + applyParameters(); +} + +void AndroidCameraPrivate::autoFocus() +{ + m_camera.callMethod("autoFocus", + "(Landroid/hardware/Camera$AutoFocusCallback;)V", + m_cameraListener.object()); + emit autoFocusStarted(); +} + +void AndroidCameraPrivate::cancelAutoFocus() +{ + m_camera.callMethod("cancelAutoFocus"); +} + +bool AndroidCameraPrivate::isAutoExposureLockSupported() +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return false; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return false; + + return m_parameters.callMethod("isAutoExposureLockSupported"); +} + +bool AndroidCameraPrivate::getAutoExposureLock() +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return false; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return false; + + return m_parameters.callMethod("getAutoExposureLock"); +} + +void AndroidCameraPrivate::setAutoExposureLock(bool toggle) +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setAutoExposureLock", "(Z)V", toggle); + applyParameters(); +} + +bool AndroidCameraPrivate::isAutoWhiteBalanceLockSupported() +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return false; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return false; + + return m_parameters.callMethod("isAutoWhiteBalanceLockSupported"); +} + +bool AndroidCameraPrivate::getAutoWhiteBalanceLock() +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return false; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return false; + + return m_parameters.callMethod("getAutoWhiteBalanceLock"); +} + +void AndroidCameraPrivate::setAutoWhiteBalanceLock(bool toggle) +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return; + + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setAutoWhiteBalanceLock", "(Z)V", toggle); + applyParameters(); +} + +int AndroidCameraPrivate::getExposureCompensation() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return 0; + + return m_parameters.callMethod("getExposureCompensation"); +} + +void AndroidCameraPrivate::setExposureCompensation(int value) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setExposureCompensation", "(I)V", value); + applyParameters(); +} + +float AndroidCameraPrivate::getExposureCompensationStep() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return 0; + + return m_parameters.callMethod("getExposureCompensationStep"); +} + +int AndroidCameraPrivate::getMinExposureCompensation() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return 0; + + return m_parameters.callMethod("getMinExposureCompensation"); +} + +int AndroidCameraPrivate::getMaxExposureCompensation() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return 0; + + return m_parameters.callMethod("getMaxExposureCompensation"); +} + +QString AndroidCameraPrivate::getSceneMode() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + QString value; + + if (m_parameters.isValid()) { + QJNIObjectPrivate sceneMode = m_parameters.callObjectMethod("getSceneMode", + "()Ljava/lang/String;"); + if (sceneMode.isValid()) + value = sceneMode.toString(); + } + + return value; +} + +void AndroidCameraPrivate::setSceneMode(const QString &value) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setSceneMode", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(value).object()); + applyParameters(); +} + +QString AndroidCameraPrivate::getWhiteBalance() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + QString value; + + if (m_parameters.isValid()) { + QJNIObjectPrivate wb = m_parameters.callObjectMethod("getWhiteBalance", + "()Ljava/lang/String;"); + if (wb.isValid()) + value = wb.toString(); + } + + return value; +} + +void AndroidCameraPrivate::setWhiteBalance(const QString &value) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setWhiteBalance", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(value).object()); + applyParameters(); + + emit whiteBalanceChanged(); +} + +void AndroidCameraPrivate::updateRotation() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + m_parameters.callMethod("setRotation", "(I)V", m_rotation); + applyParameters(); +} + +QList AndroidCameraPrivate::getSupportedPictureSizes() +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + QList list; + + if (m_parameters.isValid()) { + QJNIObjectPrivate sizeList = m_parameters.callObjectMethod("getSupportedPictureSizes", + "()Ljava/util/List;"); + int count = sizeList.callMethod("size"); + for (int i = 0; i < count; ++i) { + QJNIObjectPrivate size = sizeList.callObjectMethod("get", + "(I)Ljava/lang/Object;", + i); + list.append(QSize(size.getField("width"), size.getField("height"))); + } + + qSort(list.begin(), list.end(), qt_sizeLessThan); + } + + return list; +} + +void AndroidCameraPrivate::setPictureSize(const QSize &size) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setPictureSize", "(II)V", size.width(), size.height()); + applyParameters(); +} + +void AndroidCameraPrivate::setJpegQuality(int quality) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + if (!m_parameters.isValid()) + return; + + m_parameters.callMethod("setJpegQuality", "(I)V", quality); + applyParameters(); +} + +void AndroidCameraPrivate::startPreview() +{ + //We need to clear preview buffers queue here, but there is no method to do it + //Though just resetting preview callback do the trick + m_camera.callMethod("setPreviewCallbackWithBuffer", + "(Landroid/hardware/Camera$PreviewCallback;)V", + jobject(0)); + m_cameraListener.callMethod("preparePreviewBuffer", "(Landroid/hardware/Camera;)V", m_camera.object()); + QJNIObjectPrivate buffer = m_cameraListener.callObjectMethod("callbackBuffer"); + m_camera.callMethod("addCallbackBuffer", "([B)V", buffer.object()); + m_camera.callMethod("setPreviewCallbackWithBuffer", + "(Landroid/hardware/Camera$PreviewCallback;)V", + m_cameraListener.object()); + m_camera.callMethod("startPreview"); + emit previewStarted(); +} + +void AndroidCameraPrivate::stopPreview() +{ + m_camera.callMethod("stopPreview"); + emit previewStopped(); +} + +void AndroidCameraPrivate::takePicture() +{ + m_camera.callMethod("takePicture", "(Landroid/hardware/Camera$ShutterCallback;" + "Landroid/hardware/Camera$PictureCallback;" + "Landroid/hardware/Camera$PictureCallback;)V", + m_cameraListener.object(), + jobject(0), + m_cameraListener.object()); +} + +void AndroidCameraPrivate::fetchEachFrame(bool fetch) +{ + m_cameraListener.callMethod("fetchEachFrame", "(Z)V", fetch); +} + +void AndroidCameraPrivate::fetchLastPreviewFrame() +{ + QJNIEnvironmentPrivate env; + QJNIObjectPrivate data = m_cameraListener.callObjectMethod("lockAndFetchPreviewBuffer", "()[B"); + if (!data.isValid()) { + m_cameraListener.callMethod("unlockPreviewBuffer"); + return; + } + const int arrayLength = env->GetArrayLength(static_cast(data.object())); + QByteArray bytes(arrayLength, Qt::Uninitialized); + env->GetByteArrayRegion(static_cast(data.object()), + 0, + arrayLength, + reinterpret_cast(bytes.data())); + m_cameraListener.callMethod("unlockPreviewBuffer"); + + emit previewFetched(bytes); +} + +void AndroidCameraPrivate::applyParameters() +{ + m_camera.callMethod("setParameters", + "(Landroid/hardware/Camera$Parameters;)V", + m_parameters.object()); +} + +QStringList AndroidCameraPrivate::callParametersStringListMethod(const QByteArray &methodName) +{ + QMutexLocker parametersLocker(&m_parametersMutex); + + QStringList stringList; + + if (m_parameters.isValid()) { + QJNIObjectPrivate list = m_parameters.callObjectMethod(methodName.constData(), + "()Ljava/util/List;"); + + if (list.isValid()) { + int count = list.callMethod("size"); + for (int i = 0; i < count; ++i) { + QJNIObjectPrivate string = list.callObjectMethod("get", + "(I)Ljava/lang/Object;", + i); + stringList.append(string.toString()); + } + } + } + + return stringList; +} + +static JNINativeMethod methods[] = { + {"notifyAutoFocusComplete", "(IZ)V", (void *)notifyAutoFocusComplete}, + {"notifyPictureExposed", "(I)V", (void *)notifyPictureExposed}, + {"notifyPictureCaptured", "(I[B)V", (void *)notifyPictureCaptured}, + {"notifyFrameFetched", "(I[B)V", (void *)notifyFrameFetched} +}; + +bool AndroidCamera::initJNI(JNIEnv *env) +{ + jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtCameraListener"); + if (env->ExceptionCheck()) + env->ExceptionClear(); + + if (clazz) { + g_qtCameraListenerClass = static_cast(env->NewGlobalRef(clazz)); + if (env->RegisterNatives(g_qtCameraListenerClass, + methods, + sizeof(methods) / sizeof(methods[0])) < 0) { + return false; + } + } + + return true; +} + +QT_END_NAMESPACE + +#include "androidcamera.moc" diff --git a/src/plugins/android/src/wrappers/jni/androidcamera.h b/src/plugins/android/src/wrappers/jni/androidcamera.h new file mode 100644 index 000000000..de97f5767 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidcamera.h @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** 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 ANDROIDCAMERA_H +#define ANDROIDCAMERA_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QThread; + +class AndroidCameraPrivate; + +class AndroidCamera : public QObject +{ + Q_OBJECT + Q_ENUMS(CameraFacing) + Q_ENUMS(ImageFormat) +public: + enum CameraFacing { + CameraFacingBack = 0, + CameraFacingFront = 1 + }; + + enum ImageFormat { // same values as in android.graphics.ImageFormat Java class + Unknown = 0, + RGB565 = 4, + NV16 = 16, + NV21 = 17, + YUY2 = 20, + JPEG = 256, + YV12 = 842094169 + }; + + ~AndroidCamera(); + + static AndroidCamera *open(int cameraId); + + int cameraId() const; + + void lock(); + void unlock(); + void reconnect(); + void release(); + + CameraFacing getFacing(); + int getNativeOrientation(); + + QSize getPreferredPreviewSizeForVideo(); + QList getSupportedPreviewSizes(); + + ImageFormat getPreviewFormat(); + void setPreviewFormat(ImageFormat fmt); + + QSize previewSize() const; + void setPreviewSize(const QSize &size); + void setPreviewTexture(jobject surfaceTexture); + + bool isZoomSupported(); + int getMaxZoom(); + QList 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 getFocusAreas(); + void setFocusAreas(const QList &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); + int getRotation() const; + + QList getSupportedPictureSizes(); + void setPictureSize(const QSize &size); + void setJpegQuality(int quality); + + void startPreview(); + void stopPreview(); + + void takePicture(); + + void fetchEachFrame(bool fetch); + void fetchLastPreviewFrame(); + QJNIObjectPrivate getCameraObject(); + + static bool initJNI(JNIEnv *env); + +Q_SIGNALS: + void previewSizeChanged(); + void previewStarted(); + void previewStopped(); + + void autoFocusStarted(); + void autoFocusComplete(bool success); + + void whiteBalanceChanged(); + + void pictureExposed(); + void pictureCaptured(const QByteArray &data); + void previewFetched(const QByteArray &preview); + void frameFetched(const QByteArray &frame); + +private: + AndroidCamera(AndroidCameraPrivate *d, QThread *worker); + + Q_DECLARE_PRIVATE(AndroidCamera) + AndroidCameraPrivate *d_ptr; + QScopedPointer m_worker; +}; + +QT_END_NAMESPACE + +#endif // ANDROIDCAMERA_H diff --git a/src/plugins/android/src/wrappers/jni/androidmediametadataretriever.cpp b/src/plugins/android/src/wrappers/jni/androidmediametadataretriever.cpp new file mode 100644 index 000000000..7dfc6a6e3 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmediametadataretriever.cpp @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** 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 "androidmediametadataretriever.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +AndroidMediaMetadataRetriever::AndroidMediaMetadataRetriever() +{ + m_metadataRetriever = QJNIObjectPrivate("android/media/MediaMetadataRetriever"); +} + +AndroidMediaMetadataRetriever::~AndroidMediaMetadataRetriever() +{ +} + +QString AndroidMediaMetadataRetriever::extractMetadata(MetadataKey key) +{ + QString value; + + QJNIObjectPrivate metadata = m_metadataRetriever.callObjectMethod("extractMetadata", + "(I)Ljava/lang/String;", + jint(key)); + if (metadata.isValid()) + value = metadata.toString(); + + return value; +} + +void AndroidMediaMetadataRetriever::release() +{ + if (!m_metadataRetriever.isValid()) + return; + + m_metadataRetriever.callMethod("release"); +} + +bool AndroidMediaMetadataRetriever::setDataSource(const QUrl &url) +{ + if (!m_metadataRetriever.isValid()) + return false; + + QJNIEnvironmentPrivate env; + + bool loaded = false; + + QJNIObjectPrivate string = QJNIObjectPrivate::fromString(url.toString()); + + QJNIObjectPrivate uri = m_metadataRetriever.callStaticObjectMethod("android/net/Uri", + "parse", + "(Ljava/lang/String;)Landroid/net/Uri;", + string.object()); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + } else { + m_metadataRetriever.callMethod("setDataSource", + "(Landroid/content/Context;Landroid/net/Uri;)V", + QtAndroidPrivate::activity(), + uri.object()); + if (env->ExceptionCheck()) + env->ExceptionClear(); + else + loaded = true; + } + + return loaded; +} + +bool AndroidMediaMetadataRetriever::setDataSource(const QString &path) +{ + if (!m_metadataRetriever.isValid()) + return false; + + QJNIEnvironmentPrivate env; + + bool loaded = false; + + m_metadataRetriever.callMethod("setDataSource", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(path).object()); + if (env->ExceptionCheck()) + env->ExceptionClear(); + else + loaded = true; + + return loaded; +} + +QT_END_NAMESPACE diff --git a/src/plugins/android/src/wrappers/jni/androidmediametadataretriever.h b/src/plugins/android/src/wrappers/jni/androidmediametadataretriever.h new file mode 100644 index 000000000..f18cec11d --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmediametadataretriever.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 ANDROIDMEDIAMETADATARETRIEVER_H +#define ANDROIDMEDIAMETADATARETRIEVER_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class AndroidMediaMetadataRetriever +{ +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 + }; + + AndroidMediaMetadataRetriever(); + ~AndroidMediaMetadataRetriever(); + + QString extractMetadata(MetadataKey key); + void release(); + bool setDataSource(const QUrl &url); + bool setDataSource(const QString &path); + +private: + QJNIObjectPrivate m_metadataRetriever; +}; + +QT_END_NAMESPACE + +#endif // ANDROIDMEDIAMETADATARETRIEVER_H diff --git a/src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp b/src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp new file mode 100644 index 000000000..9c9f685cb --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmediaplayer.cpp @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** 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 "androidmediaplayer.h" + +#include +#include +#include +#include + +static jclass mediaPlayerClass = Q_NULLPTR; +typedef QMap MediaPlayerMap; +Q_GLOBAL_STATIC(MediaPlayerMap, mediaPlayers) + +QT_BEGIN_NAMESPACE + +AndroidMediaPlayer::AndroidMediaPlayer() + : QObject() +{ + + const jlong id = reinterpret_cast(this); + mMediaPlayer = QJNIObjectPrivate(mediaPlayerClass, + "(Landroid/app/Activity;J)V", + QtAndroidPrivate::activity(), + id); + (*mediaPlayers)[id] = this; +} + +AndroidMediaPlayer::~AndroidMediaPlayer() +{ + mediaPlayers->remove(reinterpret_cast(this)); +} + +void AndroidMediaPlayer::release() +{ + mMediaPlayer.callMethod("release"); +} + +void AndroidMediaPlayer::reset() +{ + mMediaPlayer.callMethod("reset"); +} + +int AndroidMediaPlayer::getCurrentPosition() +{ + return mMediaPlayer.callMethod("getCurrentPosition"); +} + +int AndroidMediaPlayer::getDuration() +{ + return mMediaPlayer.callMethod("getDuration"); +} + +bool AndroidMediaPlayer::isPlaying() +{ + return mMediaPlayer.callMethod("isPlaying"); +} + +int AndroidMediaPlayer::volume() +{ + return mMediaPlayer.callMethod("getVolume"); +} + +bool AndroidMediaPlayer::isMuted() +{ + return mMediaPlayer.callMethod("isMuted"); +} + +jobject AndroidMediaPlayer::display() +{ + return mMediaPlayer.callObjectMethod("display", "()Landroid/view/SurfaceHolder;").object(); +} + +void AndroidMediaPlayer::play() +{ + mMediaPlayer.callMethod("start"); +} + +void AndroidMediaPlayer::pause() +{ + mMediaPlayer.callMethod("pause"); +} + +void AndroidMediaPlayer::stop() +{ + mMediaPlayer.callMethod("stop"); +} + +void AndroidMediaPlayer::seekTo(qint32 msec) +{ + mMediaPlayer.callMethod("seekTo", "(I)V", jint(msec)); +} + +void AndroidMediaPlayer::setMuted(bool mute) +{ + mMediaPlayer.callMethod("mute", "(Z)V", jboolean(mute)); +} + +void AndroidMediaPlayer::setDataSource(const QString &path) +{ + QJNIObjectPrivate string = QJNIObjectPrivate::fromString(path); + mMediaPlayer.callMethod("setDataSource", "(Ljava/lang/String;)V", string.object()); +} + +void AndroidMediaPlayer::prepareAsync() +{ + mMediaPlayer.callMethod("prepareAsync"); +} + +void AndroidMediaPlayer::setVolume(int volume) +{ + mMediaPlayer.callMethod("setVolume", "(I)V", jint(volume)); +} + +void AndroidMediaPlayer::setDisplay(jobject surfaceHolder) +{ + mMediaPlayer.callMethod("setDisplay", "(Landroid/view/SurfaceHolder;)V", surfaceHolder); +} + +static void onErrorNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id) +{ + Q_UNUSED(env); + Q_UNUSED(thiz); + AndroidMediaPlayer *const mp = (*mediaPlayers)[id]; + if (!mp) + return; + + Q_EMIT mp->error(what, extra); +} + +static void onBufferingUpdateNative(JNIEnv *env, jobject thiz, jint percent, jlong id) +{ + Q_UNUSED(env); + Q_UNUSED(thiz); + AndroidMediaPlayer *const mp = (*mediaPlayers)[id]; + if (!mp) + return; + + Q_EMIT mp->bufferingChanged(percent); +} + +static void onProgressUpdateNative(JNIEnv *env, jobject thiz, jint progress, jlong id) +{ + Q_UNUSED(env); + Q_UNUSED(thiz); + AndroidMediaPlayer *const mp = (*mediaPlayers)[id]; + if (!mp) + return; + + Q_EMIT mp->progressChanged(progress); +} + +static void onDurationChangedNative(JNIEnv *env, jobject thiz, jint duration, jlong id) +{ + Q_UNUSED(env); + Q_UNUSED(thiz); + AndroidMediaPlayer *const mp = (*mediaPlayers)[id]; + if (!mp) + return; + + Q_EMIT mp->durationChanged(duration); +} + +static void onInfoNative(JNIEnv *env, jobject thiz, jint what, jint extra, jlong id) +{ + Q_UNUSED(env); + Q_UNUSED(thiz); + AndroidMediaPlayer *const mp = (*mediaPlayers)[id]; + if (!mp) + return; + + Q_EMIT mp->info(what, extra); +} + +static void onStateChangedNative(JNIEnv *env, jobject thiz, jint state, jlong id) +{ + Q_UNUSED(env); + Q_UNUSED(thiz); + AndroidMediaPlayer *const mp = (*mediaPlayers)[id]; + if (!mp) + return; + + Q_EMIT mp->stateChanged(state); +} + +static void onVideoSizeChangedNative(JNIEnv *env, + jobject thiz, + jint width, + jint height, + jlong id) +{ + Q_UNUSED(env); + Q_UNUSED(thiz); + AndroidMediaPlayer *const mp = (*mediaPlayers)[id]; + if (!mp) + return; + + Q_EMIT mp->videoSizeChanged(width, height); +} + +bool AndroidMediaPlayer::initJNI(JNIEnv *env) +{ + jclass jClass = env->FindClass("org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer"); + + if (jClass) { + mediaPlayerClass = static_cast(env->NewGlobalRef(jClass)); + + JNINativeMethod methods[] = { + {"onErrorNative", "(IIJ)V", reinterpret_cast(onErrorNative)}, + {"onBufferingUpdateNative", "(IJ)V", reinterpret_cast(onBufferingUpdateNative)}, + {"onProgressUpdateNative", "(IJ)V", reinterpret_cast(onProgressUpdateNative)}, + {"onDurationChangedNative", "(IJ)V", reinterpret_cast(onDurationChangedNative)}, + {"onInfoNative", "(IIJ)V", reinterpret_cast(onInfoNative)}, + {"onVideoSizeChangedNative", "(IIJ)V", reinterpret_cast(onVideoSizeChangedNative)}, + {"onStateChangedNative", "(IJ)V", reinterpret_cast(onStateChangedNative)} + }; + + 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/jni/androidmediaplayer.h b/src/plugins/android/src/wrappers/jni/androidmediaplayer.h new file mode 100644 index 000000000..b2cab805e --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmediaplayer.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 ANDROIDMEDIAPLAYER_H +#define ANDROIDMEDIAPLAYER_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class AndroidMediaPlayer : public QObject +{ + Q_OBJECT +public: + AndroidMediaPlayer(); + ~AndroidMediaPlayer(); + + enum MediaError + { + // What + MEDIA_ERROR_UNKNOWN = 1, + MEDIA_ERROR_SERVER_DIED = 100, + MEDIA_ERROR_INVALID_STATE = -38, // Undocumented + // 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, + MEDIA_ERROR_BAD_THINGS_ARE_GOING_TO_HAPPEN = -2147483648 // Undocumented + }; + + 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 MediaPlayerState + { + Uninitialized = 0x1, /* End */ + Idle = 0x2, + Preparing = 0x4, + Prepared = 0x8, + Initialized = 0x10, + Started = 0x20, + Stopped = 0x40, + Paused = 0x80, + PlaybackCompleted = 0x100, + Error = 0x200 + }; + + void release(); + void reset(); + + int getCurrentPosition(); + int getDuration(); + bool isPlaying(); + int volume(); + bool isMuted(); + jobject display(); + + void play(); + void pause(); + void stop(); + void seekTo(qint32 msec); + void setMuted(bool mute); + void setDataSource(const QString &path); + void prepareAsync(); + void setVolume(int volume); + void setDisplay(jobject surfaceHolder); + + static bool initJNI(JNIEnv *env); + +Q_SIGNALS: + void error(qint32 what, qint32 extra); + void bufferingChanged(qint32 percent); + void durationChanged(qint64 duration); + void progressChanged(qint64 progress); + void stateChanged(qint32 state); + void info(qint32 what, qint32 extra); + void videoSizeChanged(qint32 width, qint32 height); + +private: + QJNIObjectPrivate mMediaPlayer; +}; + +QT_END_NAMESPACE + +#endif // ANDROIDMEDIAPLAYER_H diff --git a/src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp b/src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp new file mode 100644 index 000000000..3683c9aa5 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp @@ -0,0 +1,299 @@ +/**************************************************************************** +** +** 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 "androidmediarecorder.h" + +#include "androidcamera.h" +#include +#include + +QT_BEGIN_NAMESPACE + +static jclass g_qtMediaRecorderListenerClass = 0; +typedef QMap MediaRecorderMap; +Q_GLOBAL_STATIC(MediaRecorderMap, mediaRecorders) + +static void notifyError(JNIEnv* , jobject, jlong id, jint what, jint extra) +{ + AndroidMediaRecorder *obj = mediaRecorders->value(id, 0); + if (obj) + emit obj->error(what, extra); +} + +static void notifyInfo(JNIEnv* , jobject, jlong id, jint what, jint extra) +{ + AndroidMediaRecorder *obj = mediaRecorders->value(id, 0); + if (obj) + emit obj->info(what, extra); +} + +AndroidMediaRecorder::AndroidMediaRecorder() + : QObject() + , m_id(reinterpret_cast(this)) +{ + m_mediaRecorder = QJNIObjectPrivate("android/media/MediaRecorder"); + if (m_mediaRecorder.isValid()) { + QJNIObjectPrivate listener(g_qtMediaRecorderListenerClass, "(J)V", m_id); + m_mediaRecorder.callMethod("setOnErrorListener", + "(Landroid/media/MediaRecorder$OnErrorListener;)V", + listener.object()); + m_mediaRecorder.callMethod("setOnInfoListener", + "(Landroid/media/MediaRecorder$OnInfoListener;)V", + listener.object()); + mediaRecorders->insert(m_id, this); + } +} + +AndroidMediaRecorder::~AndroidMediaRecorder() +{ + mediaRecorders->remove(m_id); +} + +void AndroidMediaRecorder::release() +{ + m_mediaRecorder.callMethod("release"); +} + +bool AndroidMediaRecorder::prepare() +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("prepare"); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + return false; + } + return true; +} + +void AndroidMediaRecorder::reset() +{ + m_mediaRecorder.callMethod("reset"); +} + +bool AndroidMediaRecorder::start() +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("start"); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + return false; + } + return true; +} + +void AndroidMediaRecorder::stop() +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("stop"); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setAudioChannels(int numChannels) +{ + m_mediaRecorder.callMethod("setAudioChannels", "(I)V", numChannels); +} + +void AndroidMediaRecorder::setAudioEncoder(AudioEncoder encoder) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setAudioEncoder", "(I)V", int(encoder)); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setAudioEncodingBitRate(int bitRate) +{ + m_mediaRecorder.callMethod("setAudioEncodingBitRate", "(I)V", bitRate); +} + +void AndroidMediaRecorder::setAudioSamplingRate(int samplingRate) +{ + m_mediaRecorder.callMethod("setAudioSamplingRate", "(I)V", samplingRate); +} + +void AndroidMediaRecorder::setAudioSource(AudioSource source) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setAudioSource", "(I)V", int(source)); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setCamera(AndroidCamera *camera) +{ + QJNIObjectPrivate cam = camera->getCameraObject(); + m_mediaRecorder.callMethod("setCamera", "(Landroid/hardware/Camera;)V", cam.object()); +} + +void AndroidMediaRecorder::setVideoEncoder(VideoEncoder encoder) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setVideoEncoder", "(I)V", int(encoder)); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setVideoEncodingBitRate(int bitRate) +{ + m_mediaRecorder.callMethod("setVideoEncodingBitRate", "(I)V", bitRate); +} + +void AndroidMediaRecorder::setVideoFrameRate(int rate) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setVideoFrameRate", "(I)V", rate); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setVideoSize(const QSize &size) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setVideoSize", "(II)V", size.width(), size.height()); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setVideoSource(VideoSource source) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setVideoSource", "(I)V", int(source)); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setOrientationHint(int degrees) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setOrientationHint", "(I)V", degrees); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setOutputFormat(OutputFormat format) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setOutputFormat", "(I)V", int(format)); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +void AndroidMediaRecorder::setOutputFile(const QString &path) +{ + QJNIEnvironmentPrivate env; + m_mediaRecorder.callMethod("setOutputFile", + "(Ljava/lang/String;)V", + QJNIObjectPrivate::fromString(path).object()); + if (env->ExceptionCheck()) { +#ifdef QT_DEBUG + env->ExceptionDescribe(); +#endif + env->ExceptionClear(); + } +} + +static JNINativeMethod methods[] = { + {"notifyError", "(JII)V", (void *)notifyError}, + {"notifyInfo", "(JII)V", (void *)notifyInfo} +}; + +bool AndroidMediaRecorder::initJNI(JNIEnv *env) +{ + jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtMediaRecorderListener"); + if (env->ExceptionCheck()) + env->ExceptionClear(); + + if (clazz) { + g_qtMediaRecorderListenerClass = static_cast(env->NewGlobalRef(clazz)); + if (env->RegisterNatives(g_qtMediaRecorderListenerClass, + methods, + sizeof(methods) / sizeof(methods[0])) < 0) { + return false; + } + } + + return true; +} + +QT_END_NAMESPACE diff --git a/src/plugins/android/src/wrappers/jni/androidmediarecorder.h b/src/plugins/android/src/wrappers/jni/androidmediarecorder.h new file mode 100644 index 000000000..1ab1b9026 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmediarecorder.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 ANDROIDMEDIARECORDER_H +#define ANDROIDMEDIARECORDER_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class AndroidCamera; + +class AndroidMediaRecorder : public QObject +{ + 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 + }; + + AndroidMediaRecorder(); + ~AndroidMediaRecorder(); + + 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(AndroidCamera *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; + QJNIObjectPrivate m_mediaRecorder; +}; + +QT_END_NAMESPACE + +#endif // ANDROIDMEDIARECORDER_H diff --git a/src/plugins/android/src/wrappers/jni/androidmultimediautils.cpp b/src/plugins/android/src/wrappers/jni/androidmultimediautils.cpp new file mode 100644 index 000000000..5c2f19a06 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmultimediautils.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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 "androidmultimediautils.h" + +#include + +QT_BEGIN_NAMESPACE + + +void AndroidMultimediaUtils::enableOrientationListener(bool enable) +{ + QJNIObjectPrivate::callStaticMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", + "enableOrientationListener", + "(Z)V", + enable); +} + +int AndroidMultimediaUtils::getDeviceOrientation() +{ + return QJNIObjectPrivate::callStaticMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", + "getDeviceOrientation"); +} + +QString AndroidMultimediaUtils::getDefaultMediaDirectory(MediaType type) +{ + QJNIObjectPrivate path = QJNIObjectPrivate::callStaticObjectMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils", + "getDefaultMediaDirectory", + "(I)Ljava/lang/String;", + jint(type)); + return path.toString(); +} + +void AndroidMultimediaUtils::registerMediaFile(const QString &file) +{ + 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/jni/androidmultimediautils.h b/src/plugins/android/src/wrappers/jni/androidmultimediautils.h new file mode 100644 index 000000000..4617b08f8 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidmultimediautils.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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 ANDROIDMULTIMEDIAUTILS_H +#define ANDROIDMULTIMEDIAUTILS_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class AndroidMultimediaUtils +{ +public: + enum MediaType { + Music = 0, + Movies = 1, + DCIM = 2, + Sounds = 3 + }; + + static void enableOrientationListener(bool enable); + static int getDeviceOrientation(); + static QString getDefaultMediaDirectory(MediaType type); + static void registerMediaFile(const QString &file); +}; + +QT_END_NAMESPACE + +#endif // ANDROIDMULTIMEDIAUTILS_H diff --git a/src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp new file mode 100644 index 000000000..8c334a060 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** 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 "androidsurfacetexture.h" +#include +#include + +QT_BEGIN_NAMESPACE + +static jclass g_qtSurfaceTextureListenerClass = 0; +static QMap g_objectMap; + +// native method for QtSurfaceTexture.java +static void notifyFrameAvailable(JNIEnv* , jobject, int id) +{ + AndroidSurfaceTexture *obj = g_objectMap.value(id, 0); + if (obj) + Q_EMIT obj->frameAvailable(); +} + +AndroidSurfaceTexture::AndroidSurfaceTexture(unsigned int texName) + : QObject() + , m_texID(int(texName)) +{ + // 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()); +} + +AndroidSurfaceTexture::~AndroidSurfaceTexture() +{ + if (m_surfaceTexture.isValid()) { + release(); + g_objectMap.remove(m_texID); + } +} + +QMatrix4x4 AndroidSurfaceTexture::getTransformMatrix() +{ + QMatrix4x4 matrix; + if (!m_surfaceTexture.isValid()) + return matrix; + + QJNIEnvironmentPrivate env; + + jfloatArray array = env->NewFloatArray(16); + m_surfaceTexture.callMethod("getTransformMatrix", "([F)V", array); + env->GetFloatArrayRegion(array, 0, 16, matrix.data()); + env->DeleteLocalRef(array); + + return matrix; +} + +void AndroidSurfaceTexture::release() +{ + if (QtAndroidPrivate::androidSdkVersion() < 14) + return; + + m_surfaceTexture.callMethod("release"); +} + +void AndroidSurfaceTexture::updateTexImage() +{ + if (!m_surfaceTexture.isValid()) + return; + + m_surfaceTexture.callMethod("updateTexImage"); +} + +jobject AndroidSurfaceTexture::object() +{ + return m_surfaceTexture.object(); +} + +static JNINativeMethod methods[] = { + {"notifyFrameAvailable", "(I)V", (void *)notifyFrameAvailable} +}; + +bool AndroidSurfaceTexture::initJNI(JNIEnv *env) +{ + // 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 (clazz) { + g_qtSurfaceTextureListenerClass = static_cast(env->NewGlobalRef(clazz)); + if (env->RegisterNatives(g_qtSurfaceTextureListenerClass, + methods, + sizeof(methods) / sizeof(methods[0])) < 0) { + return false; + } + } + + return true; +} + +QT_END_NAMESPACE diff --git a/src/plugins/android/src/wrappers/jni/androidsurfacetexture.h b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.h new file mode 100644 index 000000000..5898096fc --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 ANDROIDSURFACETEXTURE_H +#define ANDROIDSURFACETEXTURE_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class AndroidSurfaceTexture : public QObject +{ + Q_OBJECT +public: + explicit AndroidSurfaceTexture(unsigned int texName); + ~AndroidSurfaceTexture(); + + int textureID() const { return m_texID; } + jobject object(); + + QMatrix4x4 getTransformMatrix(); + void release(); // API level 14 + void updateTexImage(); + + static bool initJNI(JNIEnv *env); + +Q_SIGNALS: + void frameAvailable(); + +private: + int m_texID; + QJNIObjectPrivate m_surfaceTexture; +}; + +QT_END_NAMESPACE + +#endif // ANDROIDSURFACETEXTURE_H diff --git a/src/plugins/android/src/wrappers/jni/jni.pri b/src/plugins/android/src/wrappers/jni/jni.pri new file mode 100644 index 000000000..ba2ad0801 --- /dev/null +++ b/src/plugins/android/src/wrappers/jni/jni.pri @@ -0,0 +1,19 @@ +QT += platformsupport-private + +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/androidmediaplayer.h \ + $$PWD/androidsurfacetexture.h \ + $$PWD/androidmediametadataretriever.h \ + $$PWD/androidcamera.h \ + $$PWD/androidmultimediautils.h \ + $$PWD/androidmediarecorder.h + +SOURCES += \ + $$PWD/androidmediaplayer.cpp \ + $$PWD/androidsurfacetexture.cpp \ + $$PWD/androidmediametadataretriever.cpp \ + $$PWD/androidcamera.cpp \ + $$PWD/androidmultimediautils.cpp \ + $$PWD/androidmediarecorder.cpp diff --git a/src/plugins/android/src/wrappers/jsurfacetexture.cpp b/src/plugins/android/src/wrappers/jsurfacetexture.cpp deleted file mode 100644 index 2b16ebd66..000000000 --- a/src/plugins/android/src/wrappers/jsurfacetexture.cpp +++ /dev/null @@ -1,158 +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 "jsurfacetexture.h" -#include -#include - -QT_BEGIN_NAMESPACE - -static jclass g_qtSurfaceTextureListenerClass = 0; -static QMap 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() - , m_texID(int(texName)) -{ - // 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 (m_surfaceTexture.isValid()) { - release(); - g_objectMap.remove(m_texID); - } -} - -QMatrix4x4 JSurfaceTexture::getTransformMatrix() -{ - QMatrix4x4 matrix; - if (!m_surfaceTexture.isValid()) - return matrix; - - QJNIEnvironmentPrivate env; - - jfloatArray array = env->NewFloatArray(16); - 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() -{ - if (!m_surfaceTexture.isValid()) - return; - - m_surfaceTexture.callMethod("updateTexImage"); -} - -jobject JSurfaceTexture::object() -{ - return m_surfaceTexture.object(); -} - -static JNINativeMethod methods[] = { - {"notifyFrameAvailable", "(I)V", (void *)notifyFrameAvailable} -}; - -bool JSurfaceTexture::initJNI(JNIEnv *env) -{ - // 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 (clazz) { - g_qtSurfaceTextureListenerClass = static_cast(env->NewGlobalRef(clazz)); - if (env->RegisterNatives(g_qtSurfaceTextureListenerClass, - 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 deleted file mode 100644 index d53290a71..000000000 --- a/src/plugins/android/src/wrappers/jsurfacetexture.h +++ /dev/null @@ -1,78 +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 JSURFACETEXTURE_H -#define JSURFACETEXTURE_H - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class JSurfaceTexture : public QObject -{ - Q_OBJECT -public: - explicit JSurfaceTexture(unsigned int texName); - ~JSurfaceTexture(); - - int textureID() const { return m_texID; } - jobject object(); - - QMatrix4x4 getTransformMatrix(); - void release(); // API level 14 - void updateTexImage(); - - static bool initJNI(JNIEnv *env); - -Q_SIGNALS: - void frameAvailable(); - -private: - int m_texID; - QJNIObjectPrivate m_surfaceTexture; -}; - -QT_END_NAMESPACE - -#endif // JSURFACETEXTURE_H diff --git a/src/plugins/android/src/wrappers/wrappers.pri b/src/plugins/android/src/wrappers/wrappers.pri deleted file mode 100644 index 126cfd0c1..000000000 --- a/src/plugins/android/src/wrappers/wrappers.pri +++ /dev/null @@ -1,19 +0,0 @@ -QT += platformsupport-private - -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/jmediaplayer.h \ - $$PWD/jsurfacetexture.h \ - $$PWD/jmediametadataretriever.h \ - $$PWD/jcamera.h \ - $$PWD/jmultimediautils.h \ - $$PWD/jmediarecorder.h - -SOURCES += \ - $$PWD/jmediaplayer.cpp \ - $$PWD/jsurfacetexture.cpp \ - $$PWD/jmediametadataretriever.cpp \ - $$PWD/jcamera.cpp \ - $$PWD/jmultimediautils.cpp \ - $$PWD/jmediarecorder.cpp -- cgit v1.2.3