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/wrappers/jni/androidmediarecorder.cpp | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp') diff --git a/src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp b/src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp index 3683c9aa5..71f88213f 100644 --- a/src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp +++ b/src/plugins/android/src/wrappers/jni/androidmediarecorder.cpp @@ -47,6 +47,80 @@ QT_BEGIN_NAMESPACE +typedef QMap CamcorderProfiles; +Q_GLOBAL_STATIC(CamcorderProfiles, g_camcorderProfiles) + +static QString profileKey() +{ + return QStringLiteral("%1-%2"); +} + +bool AndroidCamcorderProfile::hasProfile(jint cameraId, Quality quality) +{ + if (g_camcorderProfiles->contains(profileKey().arg(cameraId).arg(quality))) + return true; + + return QJNIObjectPrivate::callStaticMethod("android/media/CamcorderProfile", + "hasProfile", + "(II)Z", + cameraId, + quality); +} + +AndroidCamcorderProfile AndroidCamcorderProfile::get(jint cameraId, Quality quality) +{ + const QString key = profileKey().arg(cameraId).arg(quality); + QMap::const_iterator it = g_camcorderProfiles->constFind(key); + + if (it != g_camcorderProfiles->constEnd()) + return AndroidCamcorderProfile(*it); + + QJNIObjectPrivate camProfile = QJNIObjectPrivate::callStaticObjectMethod("android/media/CamcorderProfile", + "get", + "(II)Landroid/media/CamcorderProfile;", + cameraId, + quality); + + return AndroidCamcorderProfile((*g_camcorderProfiles)[key] = camProfile); +} + +int AndroidCamcorderProfile::getValue(AndroidCamcorderProfile::Field field) const +{ + switch (field) { + case audioBitRate: + return m_camcorderProfile.getField("audioBitRate"); + case audioChannels: + return m_camcorderProfile.getField("audioChannels"); + case audioCodec: + return m_camcorderProfile.getField("audioCodec"); + case audioSampleRate: + return m_camcorderProfile.getField("audioSampleRate"); + case duration: + return m_camcorderProfile.getField("duration"); + case fileFormat: + return m_camcorderProfile.getField("fileFormat"); + case quality: + return m_camcorderProfile.getField("quality"); + case videoBitRate: + return m_camcorderProfile.getField("videoBitRate"); + case videoCodec: + return m_camcorderProfile.getField("videoCodec"); + case videoFrameHeight: + return m_camcorderProfile.getField("videoFrameHeight"); + case videoFrameRate: + return m_camcorderProfile.getField("videoFrameRate"); + case videoFrameWidth: + return m_camcorderProfile.getField("videoFrameWidth"); + } + + return 0; +} + +AndroidCamcorderProfile::AndroidCamcorderProfile(const QJNIObjectPrivate &camcorderProfile) +{ + m_camcorderProfile = camcorderProfile; +} + static jclass g_qtMediaRecorderListenerClass = 0; typedef QMap MediaRecorderMap; Q_GLOBAL_STATIC(MediaRecorderMap, mediaRecorders) -- cgit v1.2.3