From b9b06defc76ae8c3bc6073cb81b4e31b94917a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Mon, 12 May 2014 14:38:09 +0200 Subject: Android: Don't expose java calls in the control classes. Makes the abstraction more clear. Change-Id: Ia9a7b0b157e1182158cd26b62775d13f6c5e1727 Reviewed-by: Yoann Lopes --- .../src/mediacapture/qandroidcamerasession.cpp | 30 ++--------------- .../src/mediacapture/qandroidcamerasession.h | 10 +----- .../src/mediacapture/qandroidcapturesession.cpp | 39 +++++++++------------- 3 files changed, 19 insertions(+), 60 deletions(-) (limited to 'src/plugins/android/src/mediacapture') diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp index f8633147d..a2eba13f3 100644 --- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp @@ -183,36 +183,10 @@ void QAndroidCameraSession::updateAvailableCameras() { g_availableCameras->clear(); - const QJNIObjectPrivate cameraInfo("android/hardware/Camera$CameraInfo"); - const int numCameras = QJNIObjectPrivate::callStaticMethod("android/hardware/Camera", - "getNumberOfCameras"); - + const int numCameras = AndroidCamera::getNumberOfCameras(); for (int i = 0; i < numCameras; ++i) { AndroidCameraInfo info; - - QJNIObjectPrivate::callStaticMethod("android/hardware/Camera", - "getCameraInfo", - "(ILandroid/hardware/Camera$CameraInfo;)V", - i, cameraInfo.object()); - - 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 AndroidCamera::CameraFacingBack: - info.name = QByteArray("back"); - info.description = QStringLiteral("Rear-facing camera"); - info.position = QCamera::BackFace; - break; - case AndroidCamera::CameraFacingFront: - info.name = QByteArray("front"); - info.description = QStringLiteral("Front-facing camera"); - info.position = QCamera::FrontFace; - break; - default: - break; - } + AndroidCamera::getCameraInfo(i, &info); if (!info.name.isNull()) g_availableCameras->append(info); diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.h b/src/plugins/android/src/mediacapture/qandroidcamerasession.h index 51aba4a9b..05765aa82 100644 --- a/src/plugins/android/src/mediacapture/qandroidcamerasession.h +++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.h @@ -48,21 +48,13 @@ #include #include #include +#include "androidcamera.h" QT_BEGIN_NAMESPACE -class AndroidCamera; class QAndroidVideoOutput; class QAndroidMediaVideoProbeControl; -struct AndroidCameraInfo -{ - QByteArray name; - QString description; - QCamera::Position position; - int orientation; -}; - class QAndroidCameraSession : public QObject { Q_OBJECT diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp index f8641073e..383af812a 100644 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp @@ -455,7 +455,7 @@ void QAndroidCaptureSession::onCameraOpened() for (int i = 0; i < 8; ++i) { CaptureProfile profile = getProfile(i); if (!profile.isNull) { - if (i == 1) // QUALITY_HIGH + if (i == AndroidCamcorderProfile::QUALITY_HIGH) m_defaultSettings = profile; if (!m_supportedResolutions.contains(profile.videoResolution)) @@ -474,30 +474,23 @@ void QAndroidCaptureSession::onCameraOpened() QAndroidCaptureSession::CaptureProfile QAndroidCaptureSession::getProfile(int id) { CaptureProfile profile; - bool hasProfile = QJNIObjectPrivate::callStaticMethod("android/media/CamcorderProfile", - "hasProfile", - "(II)Z", - m_cameraSession->camera()->cameraId(), - id); + const bool hasProfile = AndroidCamcorderProfile::hasProfile(m_cameraSession->camera()->cameraId(), + AndroidCamcorderProfile::Quality(id)); if (hasProfile) { - QJNIObjectPrivate obj = QJNIObjectPrivate::callStaticObjectMethod("android/media/CamcorderProfile", - "get", - "(II)Landroid/media/CamcorderProfile;", - m_cameraSession->camera()->cameraId(), - id); - - - 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 = AndroidMediaRecorder::VideoEncoder(obj.getField("videoCodec")); - profile.videoBitRate = obj.getField("videoBitRate"); - profile.videoFrameRate = obj.getField("videoFrameRate"); - profile.videoResolution = QSize(obj.getField("videoFrameWidth"), - obj.getField("videoFrameHeight")); + AndroidCamcorderProfile camProfile = AndroidCamcorderProfile::get(m_cameraSession->camera()->cameraId(), + AndroidCamcorderProfile::Quality(id)); + + profile.outputFormat = AndroidMediaRecorder::OutputFormat(camProfile.getValue(AndroidCamcorderProfile::fileFormat)); + profile.audioEncoder = AndroidMediaRecorder::AudioEncoder(camProfile.getValue(AndroidCamcorderProfile::audioCodec)); + profile.audioBitRate = camProfile.getValue(AndroidCamcorderProfile::audioBitRate); + profile.audioChannels = camProfile.getValue(AndroidCamcorderProfile::audioChannels); + profile.audioSampleRate = camProfile.getValue(AndroidCamcorderProfile::audioSampleRate); + profile.videoEncoder = AndroidMediaRecorder::VideoEncoder(camProfile.getValue(AndroidCamcorderProfile::videoCodec)); + profile.videoBitRate = camProfile.getValue(AndroidCamcorderProfile::videoBitRate); + profile.videoFrameRate = camProfile.getValue(AndroidCamcorderProfile::videoFrameRate); + profile.videoResolution = QSize(camProfile.getValue(AndroidCamcorderProfile::videoFrameWidth), + camProfile.getValue(AndroidCamcorderProfile::videoFrameHeight)); if (profile.outputFormat == AndroidMediaRecorder::MPEG_4) profile.outputFileExtension = QStringLiteral("mp4"); -- cgit v1.2.3