Merge "Camera: HAL1 recording batching support" into oc-dev
diff --git a/drm/libmediadrm/Android.mk b/drm/libmediadrm/Android.mk
index 590622e..5b56501 100644
--- a/drm/libmediadrm/Android.mk
+++ b/drm/libmediadrm/Android.mk
@@ -18,6 +18,7 @@
LOCAL_SRC_FILES += \
CasImpl.cpp \
DescramblerImpl.cpp \
+ DrmPluginPath.cpp \
DrmSessionManager.cpp \
ICrypto.cpp \
IDrm.cpp \
diff --git a/drm/libmediadrm/Crypto.cpp b/drm/libmediadrm/Crypto.cpp
index d93dad6..a5d7346 100644
--- a/drm/libmediadrm/Crypto.cpp
+++ b/drm/libmediadrm/Crypto.cpp
@@ -22,6 +22,7 @@
#include <binder/IMemory.h>
#include <media/Crypto.h>
+#include <media/DrmPluginPath.h>
#include <media/hardware/CryptoAPI.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AString.h>
@@ -102,7 +103,7 @@
}
// no luck, have to search
- String8 dirPath("/vendor/lib/mediadrm");
+ String8 dirPath(getDrmPluginPath());
String8 pluginPath;
DIR* pDir = opendir(dirPath.string());
diff --git a/drm/libmediadrm/Drm.cpp b/drm/libmediadrm/Drm.cpp
index e3176e3..1004eb8 100644
--- a/drm/libmediadrm/Drm.cpp
+++ b/drm/libmediadrm/Drm.cpp
@@ -21,6 +21,7 @@
#include <dirent.h>
#include <dlfcn.h>
+#include <media/DrmPluginPath.h>
#include <media/DrmSessionClientInterface.h>
#include <media/DrmSessionManager.h>
#include <media/Drm.h>
@@ -220,7 +221,7 @@
}
// no luck, have to search
- String8 dirPath("/vendor/lib/mediadrm");
+ String8 dirPath(getDrmPluginPath());
DIR* pDir = opendir(dirPath.string());
if (pDir == NULL) {
diff --git a/drm/libmediadrm/DrmPluginPath.cpp b/drm/libmediadrm/DrmPluginPath.cpp
new file mode 100644
index 0000000..c760825
--- /dev/null
+++ b/drm/libmediadrm/DrmPluginPath.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "DrmPluginPath"
+#include <utils/Log.h>
+
+#include <cutils/properties.h>
+#include <media/DrmPluginPath.h>
+
+namespace android {
+
+const char* getDrmPluginPath() {
+ char value[PROPERTY_VALUE_MAX];
+ if (property_get("drm.64bit.enabled", value, NULL) == 0) {
+ return "/vendor/lib/mediadrm";
+ } else {
+ return "/vendor/lib64/mediadrm";
+ }
+}
+
+} // namespace android
diff --git a/include/media/DrmPluginPath.h b/include/media/DrmPluginPath.h
new file mode 120000
index 0000000..06b12cf
--- /dev/null
+++ b/include/media/DrmPluginPath.h
@@ -0,0 +1 @@
+../../media/libmedia/include/DrmPluginPath.h
\ No newline at end of file
diff --git a/media/libmedia/include/DrmPluginPath.h b/media/libmedia/include/DrmPluginPath.h
new file mode 100644
index 0000000..51ba26e
--- /dev/null
+++ b/media/libmedia/include/DrmPluginPath.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DRM_PLUGIN_PATH_H_
+
+#define DRM_PLUGIN_PATH_H_
+
+namespace android {
+
+const char* getDrmPluginPath();
+
+} // namespace android
+
+#endif // DRM_PLUGIN_PATH_H_
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index f689ac9..95f378f 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -397,13 +397,13 @@
// Attempt to parse an float literal optionally surrounded by whitespace,
// returns true on success, false otherwise.
-static bool safe_strtof(const char *s, float *val) {
+static bool safe_strtod(const char *s, double *val) {
char *end;
// It is lame, but according to man page, we have to set errno to 0
- // before calling strtof().
+ // before calling strtod().
errno = 0;
- *val = strtof(s, &end);
+ *val = strtod(s, &end);
if (end == s || errno == ERANGE) {
return false;
@@ -706,13 +706,23 @@
return OK;
}
-status_t StagefrightRecorder::setParamCaptureFps(float fps) {
+status_t StagefrightRecorder::setParamCaptureFps(double fps) {
ALOGV("setParamCaptureFps: %.2f", fps);
- int64_t timeUs = (int64_t) (1000000.0 / fps + 0.5f);
+ constexpr int64_t k1E12 = 1000000000000ll;
+ int64_t fpsx1e12 = k1E12 * fps;
+ if (fpsx1e12 == 0) {
+ ALOGE("FPS is zero or too small");
+ return BAD_VALUE;
+ }
- // Not allowing time more than a day
- if (timeUs <= 0 || timeUs > 86400*1E6) {
+ // This does not overflow since 10^6 * 10^12 < 2^63
+ int64_t timeUs = 1000000ll * k1E12 / fpsx1e12;
+
+ // Not allowing time more than a day and a millisecond for error margin.
+ // Note: 1e12 / 86400 = 11574074.(074) and 1e18 / 11574074 = 86400000553;
+ // therefore 1 ms of margin should be sufficient.
+ if (timeUs <= 0 || timeUs > 86400001000ll) {
ALOGE("Time between frame capture (%lld) is out of range [0, 1 Day]", (long long)timeUs);
return BAD_VALUE;
}
@@ -846,8 +856,8 @@
return setParamCaptureFpsEnable(captureFpsEnable);
}
} else if (key == "time-lapse-fps") {
- float fps;
- if (safe_strtof(value.string(), &fps)) {
+ double fps;
+ if (safe_strtod(value.string(), &fps)) {
return setParamCaptureFps(fps);
}
} else {
@@ -2073,7 +2083,7 @@
mMaxFileSizeBytes = 0;
mTrackEveryTimeDurationUs = 0;
mCaptureFpsEnable = false;
- mCaptureFps = 0.0f;
+ mCaptureFps = 0.0;
mTimeBetweenCaptureUs = -1;
mCameraSourceTimeLapse = NULL;
mMetaDataStoredInVideoBuffers = kMetadataBufferTypeInvalid;
diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h
index 38377d2..9a6c4da 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.h
+++ b/media/libmediaplayerservice/StagefrightRecorder.h
@@ -122,7 +122,7 @@
int32_t mTotalBitRate;
bool mCaptureFpsEnable;
- float mCaptureFps;
+ double mCaptureFps;
int64_t mTimeBetweenCaptureUs;
sp<CameraSourceTimeLapse> mCameraSourceTimeLapse;
@@ -172,7 +172,7 @@
status_t setParamAudioSamplingRate(int32_t sampleRate);
status_t setParamAudioTimeScale(int32_t timeScale);
status_t setParamCaptureFpsEnable(int32_t timeLapseEnable);
- status_t setParamCaptureFps(float fps);
+ status_t setParamCaptureFps(double fps);
status_t setParamVideoEncodingBitRate(int32_t bitRate);
status_t setParamVideoIFramesInterval(int32_t seconds);
status_t setParamVideoEncoderProfile(int32_t profile);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp
index cb668e4..9a4bc8c 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp
@@ -294,6 +294,9 @@
return;
}
+ if (streamErr != ERROR_END_OF_STREAM) {
+ handleError(streamErr);
+ }
mReachedEOS = true;
if (mRenderer != NULL) {
mRenderer->queueEOS(true /* audio */, ERROR_END_OF_STREAM);
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 82e7a26..22df522 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -538,7 +538,7 @@
buffer->release();
buffer = NULL;
- return ERROR_END_OF_STREAM;
+ return (n < 0 ? n : ERROR_END_OF_STREAM);
}
uint32_t header = U32_AT((const uint8_t *)buffer->data());
@@ -582,7 +582,7 @@
buffer->release();
buffer = NULL;
- return ERROR_END_OF_STREAM;
+ return (n < 0 ? n : ERROR_END_OF_STREAM);
}
buffer->set_range(0, frame_size);
diff --git a/services/mediadrm/Android.mk b/services/mediadrm/Android.mk
index 87fddd4..1d5fa07 100644
--- a/services/mediadrm/Android.mk
+++ b/services/mediadrm/Android.mk
@@ -40,7 +40,13 @@
endif
LOCAL_MODULE:= mediadrmserver
+
+# TODO: Some legacy DRM plugins only support 32-bit. They need to be migrated to
+# 64-bit. (b/18948909) Once all of a device's legacy DRM plugins support 64-bit,
+# that device can turn on ENABLE_MEDIADRM_64 to build this service as 64-bit.
+ifneq ($(ENABLE_MEDIADRM_64), true)
LOCAL_32_BIT_ONLY := true
+endif
LOCAL_INIT_RC := mediadrmserver.rc