From bc44affb444dc1968052dc18debd6598aa48f740 Mon Sep 17 00:00:00 2001 From: Sharad Sangle Date: Fri, 24 Jul 2015 11:19:31 +0530 Subject: [PATCH 01/20] audiopolicy: make audio policy extensible make function virtual or protected so that they can be extended in custom audio policy. audio policy: move output handle to AudioOutputDescriptor base class Change-Id: I96ef9fd1c5a94874acb897245501ba2f9c9ab0c0 Change-Id: Ida7992f6b327491fab1f4ea376e85e8eb34b89ca --- .../managerdefinitions/include/AudioOutputDescriptor.h | 2 +- .../managerdefinitions/src/AudioOutputDescriptor.cpp | 4 ++-- .../audiopolicy/managerdefault/AudioPolicyManager.h | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h index c09cb5a942..ddee177423 100644 --- a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +++ b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h @@ -78,6 +78,7 @@ class AudioOutputDescriptor: public AudioPortConfig sp mPort; audio_devices_t mDevice; // current device this output is routed to + audio_io_handle_t mIoHandle; // output handle uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output nsecs_t mStopTime[AUDIO_STREAM_CNT]; float mCurVolume[AUDIO_STREAM_CNT]; // current stream volume in dB @@ -123,7 +124,6 @@ class SwAudioOutputDescriptor: public AudioOutputDescriptor virtual void toAudioPort(struct audio_port *port) const; const sp mProfile; // I/O profile this output derives from - audio_io_handle_t mIoHandle; // output handle uint32_t mLatency; // audio_output_flags_t mFlags; // AudioMix *mPolicyMix; // non NULL when used by a dynamic policy diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp index 8593444aba..e29e0efaa3 100644 --- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp @@ -33,7 +33,7 @@ namespace android { AudioOutputDescriptor::AudioOutputDescriptor(const sp& port, AudioPolicyClientInterface *clientInterface) - : mPort(port), mDevice(AUDIO_DEVICE_NONE), + : mPort(port), mDevice(AUDIO_DEVICE_NONE), mIoHandle(0), mClientInterface(clientInterface), mPatchHandle(AUDIO_PATCH_HANDLE_NONE), mId(0) { // clear usage count for all stream types @@ -221,7 +221,7 @@ void AudioOutputDescriptor::log(const char* indent) SwAudioOutputDescriptor::SwAudioOutputDescriptor(const sp& profile, AudioPolicyClientInterface *clientInterface) : AudioOutputDescriptor(profile, clientInterface), - mProfile(profile), mIoHandle(0), mLatency(0), + mProfile(profile), mLatency(0), mFlags((audio_output_flags_t)0), mPolicyMix(NULL), mOutput1(0), mOutput2(0), mDirectOpenCount(0), mDirectClientSession(AUDIO_SESSION_NONE), mGlobalRefCount(0) diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h index c831d46a14..03e476dc83 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.h +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h @@ -482,12 +482,12 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage // if argument "device" is different from AUDIO_DEVICE_NONE, startSource() will force // the re-evaluation of the output device. - status_t startSource(const sp& outputDesc, + virtual status_t startSource(const sp& outputDesc, audio_stream_type_t stream, audio_devices_t device, const char *address, uint32_t *delayMs); - status_t stopSource(const sp& outputDesc, + virtual status_t stopSource(const sp& outputDesc, audio_stream_type_t stream, bool forceDeviceUpdate); @@ -592,7 +592,7 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage // Audio Policy Engine Interface. AudioPolicyManagerInterface *mEngine; -private: +protected: // Add or remove AC3 DTS encodings based on user preferences. void filterSurroundFormats(FormatVector *formatsPtr); void filterSurroundChannelMasks(ChannelsVector *channelMasksPtr); @@ -624,7 +624,7 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage SortedVector& outputs /*out*/); uint32_t curAudioPortGeneration() const { return mAudioPortGeneration; } // internal method to return the output handle for the given device and format - audio_io_handle_t getOutputForDevice( + virtual audio_io_handle_t getOutputForDevice( audio_devices_t device, audio_session_t session, audio_stream_type_t stream, @@ -660,7 +660,7 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage AudioMix **policyMix = NULL); // Called by setDeviceConnectionState(). - status_t setDeviceConnectionStateInt(audio_devices_t device, + virtual status_t setDeviceConnectionStateInt(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address, const char *device_name); From 375747a9dba23e4a38d0ebe97442ffd0b9866176 Mon Sep 17 00:00:00 2001 From: Ethan Chen Date: Wed, 28 Oct 2015 16:30:51 -0700 Subject: [PATCH 02/20] camera: Allow devices to load custom CameraParameter code * Some devices need additional code to load their cameras. Add a hook for extra classes and symbols to be included. Change-Id: Ifbe79e25b7ab47c5d468f5179032a4283b3f0df5 (cherry picked from commit 38681625992c0029d32eec98fc7e89d71b855b0e) --- camera/Android.mk | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/camera/Android.mk b/camera/Android.mk index 91d87edad5..c0bdea8826 100644 --- a/camera/Android.mk +++ b/camera/Android.mk @@ -38,7 +38,6 @@ LOCAL_SRC_FILES := \ LOCAL_SRC_FILES += \ Camera.cpp \ CameraMetadata.cpp \ - CameraParameters.cpp \ CaptureResult.cpp \ CameraParameters2.cpp \ ICamera.cpp \ @@ -73,6 +72,21 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ LOCAL_CFLAGS += -Werror -Wall -Wextra +ifneq ($(TARGET_SPECIFIC_CAMERA_PARAMETER_LIBRARY),) +LOCAL_WHOLE_STATIC_LIBRARIES += $(TARGET_SPECIFIC_CAMERA_PARAMETER_LIBRARY) +else +LOCAL_WHOLE_STATIC_LIBRARIES += libcamera_parameters +endif + LOCAL_MODULE:= libcamera_client include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + CameraParameters.cpp + +LOCAL_MODULE := libcamera_parameters + +include $(BUILD_STATIC_LIBRARY) From 0e41363fa1eeacbf5fb86f8fdee70a8317c09654 Mon Sep 17 00:00:00 2001 From: Bill Chen Date: Sat, 1 Apr 2017 21:05:56 +0800 Subject: [PATCH 03/20] stagefright: Fix SurfaceMediaSource buffer search condition when buffer return Refer to commit 3e328782f1e1061d08ea0c45b855cc418a2d9ea6, buffer handle stored in MediaBuffer had changed, but the buffer return code did not change correspondingly, so returned buffer can't be found in list and lead to crash. This commit fix it and make wifidisplay working now. Change-Id: Ic0d99f471f5f246087946367726d7e76a689fe1f --- media/libstagefright/SurfaceMediaSource.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp index d0d82b3fdb..057e3b6de8 100644 --- a/media/libstagefright/SurfaceMediaSource.cpp +++ b/media/libstagefright/SurfaceMediaSource.cpp @@ -389,7 +389,7 @@ void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) { buffer_handle_t bufferHandle = getMediaBufferHandle(buffer); for (size_t i = 0; i < mCurrentBuffers.size(); i++) { - if (mCurrentBuffers[i]->handle == bufferHandle) { + if ((buffer_handle_t)mCurrentBuffers[i]->getNativeBuffer() == bufferHandle) { mCurrentBuffers.removeAt(i); foundBuffer = true; break; @@ -405,7 +405,7 @@ void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) { continue; } - if (bufferHandle == mSlots[id].mGraphicBuffer->handle) { + if (bufferHandle == (buffer_handle_t)mSlots[id].mGraphicBuffer->getNativeBuffer()) { ALOGV("Slot %d returned, matches handle = %p", id, mSlots[id].mGraphicBuffer->handle); From 30493742918fce6bc270c967ab332e40a1df17cb Mon Sep 17 00:00:00 2001 From: Arne Coucheron Date: Sun, 9 Oct 2016 06:18:47 +0200 Subject: [PATCH 04/20] stagefright: omx: Don't signal dataspace change on legacy QCOM This isn't supported in legacy media HAL, and causes things like screen recording and wifi display to fail when setting up the encoder. Change-Id: Icb3f7b7dfefcfd72939037241568f28c01fc11ed --- media/libstagefright/omx/Android.mk | 4 ++++ media/libstagefright/omx/GraphicBufferSource.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/media/libstagefright/omx/Android.mk b/media/libstagefright/omx/Android.mk index 29e2ccc83b..b3f58abdfe 100644 --- a/media/libstagefright/omx/Android.mk +++ b/media/libstagefright/omx/Android.mk @@ -56,6 +56,10 @@ LOCAL_EXPORT_C_INCLUDES := \ LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := \ android.hidl.memory@1.0 +ifneq ($(filter msm7x27a msm7x30 msm8660 msm8960,$(TARGET_BOARD_PLATFORM)),) +LOCAL_CFLAGS += -DQCOM_BSP_LEGACY +endif + LOCAL_MODULE:= libstagefright_omx LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-documentation LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow cfi diff --git a/media/libstagefright/omx/GraphicBufferSource.cpp b/media/libstagefright/omx/GraphicBufferSource.cpp index 47d80bb756..152eeefecc 100644 --- a/media/libstagefright/omx/GraphicBufferSource.cpp +++ b/media/libstagefright/omx/GraphicBufferSource.cpp @@ -774,11 +774,13 @@ status_t GraphicBufferSource::submitBuffer_l(const VideoBuffer &item) { return UNKNOWN_ERROR; } +#ifndef QCOM_BSP_LEGACY if ((android_dataspace)item.mDataspace != mLastDataspace) { onDataspaceChanged_l( item.mDataspace, (android_pixel_format)item.mBuffer->getGraphicBuffer()->format); } +#endif std::shared_ptr buffer = item.mBuffer; // use a GraphicBuffer for now as OMXNodeInstance is using GraphicBuffers to hold references From df54f6a113934c110ef675c028a9eabe29e08be0 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 17 Aug 2015 09:58:47 +0200 Subject: [PATCH 05/20] libstagefright: Add support for NV21 color format This adds the native color format 'OMX_SEC_COLOR_FormatNV21Linear' of exynos5 which is NV21 and needed for the camera. You can turn it on with: BOARD_USE_SAMSUNG_COLORFORMAT_NV21 := true It requires const char CameraParameters::PIXEL_FORMAT_YUV420SP_NV21[] = "nv21"; to be specified in CameraExtraParameters.h. Change-Id: I64ca86d074468b1e7a2958a73c3c0380e64a9fc0 Signed-off-by: Andreas Schneider --- media/libstagefright/Android.mk | 8 ++++++++ media/libstagefright/CameraSource.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 372b11a94f..14709e8e4a 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -126,6 +126,14 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libmedia +ifeq ($(BOARD_USE_SAMSUNG_CAMERAFORMAT_NV21), true) +# This needs flag requires the following string constant in +# CameraParametersExtra.h: +# +# const char CameraParameters::PIXEL_FORMAT_YUV420SP_NV21[] = "nv21"; +LOCAL_CFLAGS += -DUSE_SAMSUNG_CAMERAFORMAT_NV21 +endif + LOCAL_CFLAGS += -Wno-multichar -Werror -Wno-error=deprecated-declarations -Wall # enable experiments only in userdebug and eng builds diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index a569f5d265..9ca1b95c9e 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -146,6 +146,13 @@ static int32_t getColorFormat(const char* colorFormat) { return OMX_COLOR_FormatYUV420SemiPlanar; } +#ifdef USE_SAMSUNG_CAMERAFORMAT_NV21 + if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV420SP_NV21)) { + static const int OMX_SEC_COLOR_FormatNV21Linear = 0x7F000011; + return OMX_SEC_COLOR_FormatNV21Linear; + } +#endif /* USE_SAMSUNG_CAMERAFORMAT_NV21 */ + if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV422I)) { return OMX_COLOR_FormatYCbYCr; } From 3253801ecbb43fb894106d0304b8163e591799ad Mon Sep 17 00:00:00 2001 From: Martinusbe Date: Tue, 12 Sep 2017 08:55:37 +0200 Subject: [PATCH 06/20] Revert "libstagefright: Add support for NV21 color format" This reverts commit df54f6a113934c110ef675c028a9eabe29e08be0. --- media/libstagefright/Android.mk | 8 -------- media/libstagefright/CameraSource.cpp | 7 ------- 2 files changed, 15 deletions(-) diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 14709e8e4a..372b11a94f 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -126,14 +126,6 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libmedia -ifeq ($(BOARD_USE_SAMSUNG_CAMERAFORMAT_NV21), true) -# This needs flag requires the following string constant in -# CameraParametersExtra.h: -# -# const char CameraParameters::PIXEL_FORMAT_YUV420SP_NV21[] = "nv21"; -LOCAL_CFLAGS += -DUSE_SAMSUNG_CAMERAFORMAT_NV21 -endif - LOCAL_CFLAGS += -Wno-multichar -Werror -Wno-error=deprecated-declarations -Wall # enable experiments only in userdebug and eng builds diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index 9ca1b95c9e..a569f5d265 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -146,13 +146,6 @@ static int32_t getColorFormat(const char* colorFormat) { return OMX_COLOR_FormatYUV420SemiPlanar; } -#ifdef USE_SAMSUNG_CAMERAFORMAT_NV21 - if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV420SP_NV21)) { - static const int OMX_SEC_COLOR_FormatNV21Linear = 0x7F000011; - return OMX_SEC_COLOR_FormatNV21Linear; - } -#endif /* USE_SAMSUNG_CAMERAFORMAT_NV21 */ - if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV422I)) { return OMX_COLOR_FormatYCbYCr; } From 2f447427550d6104a3d35b25fc1e02c41a2c1ae7 Mon Sep 17 00:00:00 2001 From: irii Date: Sun, 11 Sep 2016 16:51:37 +0200 Subject: [PATCH 07/20] libcameraservice: Don't pass NULL args on setCallbacks call *This fixes the torch light for cameras with hal 1 *This fix works on the htc m7ul *Fixed line length *Fixed unused parameter names [AdrianDC] * Adapt for 8.0.0 by adding dataCallbackTimestampBatch with matching data_callback_timestamp_batch function signature Change-Id: I89c6112546e36dbcca099f4d5cd70371b2c5340a (cherry picked from commit 3f6bb688b22b184b0bfc2739cda3c3cf0dd06a14) Signed-off-by: Adrian DC --- .../libcameraservice/CameraFlashlight.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index e06a81fb23..2bd71aa68f 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -514,6 +514,23 @@ status_t CameraHardwareInterfaceFlashControl::initializePreviewWindow( return device->setPreviewWindow(mSurface); } +static void notifyCallback(int32_t, int32_t, int32_t, void*) { + /* Empty */ +} + +static void dataCallback(int32_t, const sp&, camera_frame_metadata_t*, void*) { + /* Empty */ +} + +static void dataCallbackTimestamp(nsecs_t, int32_t, const sp&, void*) { + /* Empty */ +} + +static void dataCallbackTimestampBatch(int32_t, const std::vector&, + void*) { + /* Empty */ +} + status_t CameraHardwareInterfaceFlashControl::connectCameraDevice( const String8& cameraId) { sp device = @@ -527,7 +544,8 @@ status_t CameraHardwareInterfaceFlashControl::connectCameraDevice( } // need to set __get_memory in set_callbacks(). - device->setCallbacks(NULL, NULL, NULL, NULL, NULL); + device->setCallbacks(notifyCallback, dataCallback, dataCallbackTimestamp, + dataCallbackTimestampBatch, this); mParameters = device->getParameters(); From 8ac0db3adee4e09047beaeefe2aa65bffd9f1b72 Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Thu, 6 Oct 2016 20:25:32 +1100 Subject: [PATCH 08/20] camera/media: Support for legacy camera HALv1 Pre 7.0 camera HALv1 can not share its video buffers across different processes, which requires us to disable this security feature. This change allows devices to re-integrate cameraserver and mediaserver which is the first step to support older prebuilt camera HALs. A follow-up change will add back support for legacy buffer handling. To enable: TARGET_HAS_LEGACY_CAMERA_HAL1 := true media.stagefright.legacyencoder=true media.stagefright.less-secure=true Change-Id: I4fcc8907ea235b7e83af26122b4da97ca5117816 mediaserver: Update HALv1 dependencies for 8.0.0 * Add libcameraservice shared library dependency * Add new android.hardware.camera.common@1.0 and android.hardware.camera.provider@2.4 shared libraries and exported headers HAL dependencies * Add libarect static library dependency * When TARGET_HAS_LEGACY_CAMERA_HAL1 is set, the mediaserver includes CameraService.h but exported headers are missing * Error upon build due to missing libcameraservice linkage: fatal error: 'android/hardware/BnCameraService.h' file not found Change-Id: Ib6bb8a4e9ef18606c64e2dff13504d2eeaac13b1 Signed-off-by: Adrian DC --- camera/cameraserver/Android.mk | 4 ++++ media/mediaserver/Android.mk | 12 ++++++++++++ media/mediaserver/main_mediaserver.cpp | 6 ++++++ services/camera/libcameraservice/Android.mk | 4 ++++ services/camera/libcameraservice/CameraService.cpp | 6 ++++++ 5 files changed, 32 insertions(+) diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk index d32e2526b0..1df66d891a 100644 --- a/camera/cameraserver/Android.mk +++ b/camera/cameraserver/Android.mk @@ -14,6 +14,9 @@ LOCAL_PATH:= $(call my-dir) +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) +$(warning Target has integrated cameraserver into mediaserver. This is weakening security measures introduced in 7.0) +else include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ @@ -41,3 +44,4 @@ LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter LOCAL_INIT_RC := cameraserver.rc include $(BUILD_EXECUTABLE) +endif diff --git a/media/mediaserver/Android.mk b/media/mediaserver/Android.mk index f7597db816..fdf0ca3d76 100644 --- a/media/mediaserver/Android.mk +++ b/media/mediaserver/Android.mk @@ -38,4 +38,16 @@ LOCAL_INIT_RC := mediaserver.rc LOCAL_CFLAGS := -Werror -Wall +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) + LOCAL_CFLAGS += -DNO_CAMERA_SERVER + + LOCAL_SHARED_LIBRARIES += \ + libcameraservice \ + android.hardware.camera.common@1.0 \ + android.hardware.camera.provider@2.4 + + LOCAL_STATIC_LIBRARIES += \ + libarect +endif + include $(BUILD_EXECUTABLE) diff --git a/media/mediaserver/main_mediaserver.cpp b/media/mediaserver/main_mediaserver.cpp index ecddc48272..0abe6ac959 100644 --- a/media/mediaserver/main_mediaserver.cpp +++ b/media/mediaserver/main_mediaserver.cpp @@ -25,6 +25,9 @@ #include "RegisterExtensions.h" // from LOCAL_C_INCLUDES +#ifdef NO_CAMERA_SERVER +#include "CameraService.h" +#endif #include "IcuUtils.h" #include "MediaPlayerService.h" #include "ResourceManagerService.h" @@ -41,6 +44,9 @@ int main(int argc __unused, char **argv __unused) InitializeIcuOrDie(); MediaPlayerService::instantiate(); ResourceManagerService::instantiate(); +#ifdef NO_CAMERA_SERVER + CameraService::instantiate(); +#endif registerExtensions(); ProcessState::self()->startThreadPool(); IPCThreadState::self()->joinThreadPool(); diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk index 502ac5d86e..80c04b9e2e 100644 --- a/services/camera/libcameraservice/Android.mk +++ b/services/camera/libcameraservice/Android.mk @@ -91,6 +91,10 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ LOCAL_CFLAGS += -Wall -Wextra -Werror +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) + LOCAL_CFLAGS += -DNO_CAMERA_SERVER +endif + LOCAL_MODULE:= libcameraservice include $(BUILD_SHARED_LIBRARY) diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index c2b71a2372..0d856e6be7 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -739,7 +739,11 @@ int32_t CameraService::mapToInterface(StatusInternal status) { Status CameraService::initializeShimMetadata(int cameraId) { int uid = getCallingUid(); +#ifdef NO_CAMERA_SERVER + String16 internalPackageName("media"); +#else String16 internalPackageName("cameraserver"); +#endif String8 id = String8::format("%d", cameraId); Status ret = Status::ok(); sp tmp = nullptr; @@ -820,7 +824,9 @@ Status CameraService::getLegacyParametersLazy(int cameraId, static bool isTrustedCallingUid(uid_t uid) { switch (uid) { case AID_MEDIA: // mediaserver +#ifndef NO_CAMERA_SERVER case AID_CAMERASERVER: // cameraserver +#endif case AID_RADIO: // telephony return true; default: From 6147530a5ebf90bad7bfff4879559b6e2a161806 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Tue, 18 Oct 2016 20:56:33 +0200 Subject: [PATCH 09/20] libstagefright: Support for legacy camera/encoder buffers Since Android 7.0, the default way of passing buffers between camera HAL, encoder and framework is via Android Native Window (ANW) buffers. Pre 7.0 devices did this using buffer_handle_t buffers allocated by gralloc HAL. Since many devices do not have the source code for their camera HALs or the encoder libraries available, introduce this hack. [AdrianDC] * Forward-port to AOSP 8.0.0 stragefright changes Change-Id: I202051ab5d7273a33be0aa32b0bfdbbb1f53693f Signed-off-by: Adrian DC --- media/libstagefright/Android.mk | 4 +++ media/libstagefright/CameraSource.cpp | 4 +++ media/libstagefright/SurfaceMediaSource.cpp | 37 +++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 372b11a94f..ebb83b64da 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -126,6 +126,10 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libmedia +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) +LOCAL_CFLAGS += -DCAMCORDER_GRALLOC_SOURCE +endif + LOCAL_CFLAGS += -Wno-multichar -Werror -Wno-error=deprecated-declarations -Wall # enable experiments only in userdebug and eng builds diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index a569f5d265..d25550f97d 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -1367,6 +1367,10 @@ void CameraSource::processBufferQueueFrame(BufferItem& buffer) { MetadataBufferType CameraSource::metaDataStoredInVideoBuffers() const { ALOGV("metaDataStoredInVideoBuffers"); +#ifdef CAMCORDER_GRALLOC_SOURCE + return kMetadataBufferTypeGrallocSource; +#endif + // Output buffers will contain metadata if camera sends us buffer in metadata mode or via // buffer queue. switch (mVideoBufferMode) { diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp index 057e3b6de8..8b169724cd 100644 --- a/media/libstagefright/SurfaceMediaSource.cpp +++ b/media/libstagefright/SurfaceMediaSource.cpp @@ -128,7 +128,11 @@ status_t SurfaceMediaSource::setFrameRate(int32_t fps) MetadataBufferType SurfaceMediaSource::metaDataStoredInVideoBuffers() const { ALOGV("isMetaDataStoredInVideoBuffers"); +#ifdef CAMCORDER_GRALLOC_SOURCE + return kMetadataBufferTypeGrallocSource; +#else return kMetadataBufferTypeANWBuffer; +#endif } int32_t SurfaceMediaSource::getFrameRate( ) const { @@ -249,6 +253,35 @@ sp SurfaceMediaSource::getFormat() return meta; } +#ifdef CAMCORDER_GRALLOC_SOURCE +// Pass the data to the MediaBuffer. Pass in only the metadata +// The metadata passed consists of two parts: +// 1. First, there is an integer indicating that it is a GRAlloc +// source (kMetadataBufferTypeGrallocSource) +// 2. This is followed by the buffer_handle_t that is a handle to the +// GRalloc buffer. The encoder needs to interpret this GRalloc handle +// and encode the frames. +// -------------------------------------------------------------- +// | kMetadataBufferTypeGrallocSource | sizeof(buffer_handle_t) | +// -------------------------------------------------------------- +// Note: Call only when you have the lock +static void passMetadataBuffer(MediaBuffer **buffer, + buffer_handle_t bufferHandle) { + *buffer = new MediaBuffer(4 + sizeof(buffer_handle_t)); + char *data = (char *)(*buffer)->data(); + if (data == NULL) { + ALOGE("Cannot allocate memory for metadata buffer!"); + return; + } + OMX_U32 type = kMetadataBufferTypeGrallocSource; + memcpy(data, &type, 4); + memcpy(data + 4, &bufferHandle, sizeof(buffer_handle_t)); + + ALOGV("handle = %p, , offset = %zu, length = %zu", + bufferHandle, (*buffer)->range_length(), (*buffer)->range_offset()); +} +#endif + // Pass the data to the MediaBuffer. Pass in only the metadata // Note: Call only when you have the lock void SurfaceMediaSource::passMetadataBuffer_l(MediaBuffer **buffer, @@ -351,7 +384,11 @@ status_t SurfaceMediaSource::read( mNumFramesEncoded++; // Pass the data to the MediaBuffer. Pass in only the metadata +#ifdef CAMCORDER_GRALLOC_SOURCE + passMetadataBuffer(buffer, mSlots[mCurrentSlot].mGraphicBuffer->handle); +#else passMetadataBuffer_l(buffer, mSlots[mCurrentSlot].mGraphicBuffer->getNativeBuffer()); +#endif (*buffer)->setObserver(this); (*buffer)->add_ref(); From e927fff1f3fcb9c947ef3ba560cdabe7ca68793d Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 11 Nov 2016 19:10:42 +0100 Subject: [PATCH 10/20] OMXNodeInstance: Fix legacy HAL1 after merge of android-7.1.0_r7 [AdrianDC] * Forward-port to AOSP 8.0.0 libstagefright changes Change-Id: I53985a966b891b902437f71d4ebccbd68138329e Signed-off-by: Adrian DC --- media/libstagefright/omx/Android.mk | 6 ++++++ media/libstagefright/omx/OMXNodeInstance.cpp | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/media/libstagefright/omx/Android.mk b/media/libstagefright/omx/Android.mk index b3f58abdfe..922f1d4aeb 100644 --- a/media/libstagefright/omx/Android.mk +++ b/media/libstagefright/omx/Android.mk @@ -60,6 +60,12 @@ ifneq ($(filter msm7x27a msm7x30 msm8660 msm8960,$(TARGET_BOARD_PLATFORM)),) LOCAL_CFLAGS += -DQCOM_BSP_LEGACY endif +ifneq ($(TARGET_USES_MEDIA_EXTENSIONS),true) +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) +LOCAL_CFLAGS += -DCAMCORDER_GRALLOC_SOURCE +endif +endif + LOCAL_MODULE:= libstagefright_omx LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-documentation LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow cfi diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp index db99ef2851..78b5a3df34 100644 --- a/media/libstagefright/omx/OMXNodeInstance.cpp +++ b/media/libstagefright/omx/OMXNodeInstance.cpp @@ -1632,10 +1632,30 @@ status_t OMXNodeInstance::emptyBuffer_l( BufferMeta *buffer_meta = static_cast(header->pAppPrivate); +#ifndef CAMCORDER_GRALLOC_SOURCE // set up proper filled length if component is configured for gralloc metadata mode // ignore rangeOffset in this case (as client may be assuming ANW meta buffers). if (mMetadataType[kPortIndexInput] == kMetadataBufferTypeGrallocSource) { header->nFilledLen = rangeLength ? sizeof(VideoGrallocMetadata) : 0; +#else + sp backup = buffer_meta->getBuffer(header, false /* limit */); + sp codec = buffer_meta->getBuffer(header, false /* limit */); + + // convert incoming ANW meta buffers if component is configured for gralloc metadata mode + // ignore rangeOffset in this case + if (mMetadataType[kPortIndexInput] == kMetadataBufferTypeGrallocSource + && backup->capacity() >= sizeof(VideoNativeMetadata) + && codec->capacity() >= sizeof(VideoGrallocMetadata) + && ((VideoNativeMetadata *)backup->base())->eType + == kMetadataBufferTypeANWBuffer) { + VideoNativeMetadata &backupMeta = *(VideoNativeMetadata *)backup->base(); + VideoGrallocMetadata &codecMeta = *(VideoGrallocMetadata *)codec->base(); + CLOG_BUFFER(emptyBuffer, "converting ANWB %p to handle %p", + backupMeta.pBuffer, backupMeta.pBuffer->handle); + codecMeta.pHandle = backupMeta.pBuffer != NULL ? backupMeta.pBuffer->handle : NULL; + codecMeta.eType = kMetadataBufferTypeGrallocSource; + header->nFilledLen = rangeLength ? sizeof(codecMeta) : 0; +#endif header->nOffset = 0; } else { // rangeLength and rangeOffset must be a subset of the allocated data in the buffer. From 26ec628d7c734247dccd3411d966d8e8a9af92d9 Mon Sep 17 00:00:00 2001 From: Roman Birg Date: Tue, 3 May 2016 11:54:28 -0700 Subject: [PATCH 11/20] soundtrigger: fill in default extras from dsp We seem to get an improper offset when getting the value from the DSP (offset 100, data size 1), when this happens, return a new phrase event with valid extras which are initialized to some default values. Change-Id: Ie041f78fec6bdbcd82286b54a7b7fb0c98c740f5 Signed-off-by: Roman Birg --- .../soundtrigger/SoundTriggerHwService.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/services/soundtrigger/SoundTriggerHwService.cpp b/services/soundtrigger/SoundTriggerHwService.cpp index 5b8d990704..4a9b329164 100644 --- a/services/soundtrigger/SoundTriggerHwService.cpp +++ b/services/soundtrigger/SoundTriggerHwService.cpp @@ -254,6 +254,37 @@ void SoundTriggerHwService::sendRecognitionEvent(struct sound_trigger_recognitio if (module == NULL) { return; } + if (event-> type == SOUND_MODEL_TYPE_KEYPHRASE && event->data_size != 0 + && event->data_offset != sizeof(struct sound_trigger_phrase_recognition_event)) { + // set some defaults for the phrase if the recognition event won't be parsed properly + // TODO: read defaults from the config + + struct sound_trigger_phrase_recognition_event newEvent; + memset(&newEvent, 0, sizeof(struct sound_trigger_phrase_recognition_event)); + + sp model = module->getModel(event->model); + + newEvent.num_phrases = 1; + newEvent.phrase_extras[0].id = 100; + newEvent.phrase_extras[0].recognition_modes = RECOGNITION_MODE_VOICE_TRIGGER; + newEvent.phrase_extras[0].confidence_level = 100; + newEvent.phrase_extras[0].num_levels = 1; + newEvent.phrase_extras[0].levels[0].level = 100; + newEvent.phrase_extras[0].levels[0].user_id = 100; + newEvent.common.status = event->status; + newEvent.common.type = event->type; + newEvent.common.model = event->model; + newEvent.common.capture_available = event->capture_available; + newEvent.common.capture_session = event->capture_session; + newEvent.common.capture_delay_ms = event->capture_delay_ms; + newEvent.common.capture_preamble_ms = event->capture_preamble_ms; + newEvent.common.trigger_in_data = event->trigger_in_data; + newEvent.common.audio_config = event->audio_config; + newEvent.common.data_size = event->data_size; + newEvent.common.data_offset = sizeof(struct sound_trigger_phrase_recognition_event); + + event = &newEvent.common; + } sp eventMemory = prepareRecognitionEvent_l(event); if (eventMemory == 0) { return; From 9bd20dfa42cd032023d639630ddafe1bd277ec88 Mon Sep 17 00:00:00 2001 From: Sam Mortimer Date: Fri, 9 Dec 2016 13:36:25 -0800 Subject: [PATCH 12/20] soundtrigger: fix memory corruption Fixes hotword on angler. Change-Id: Ic15a617c0f79f03785feaddd2dfa6deb90842a06 --- services/soundtrigger/SoundTriggerHwService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/soundtrigger/SoundTriggerHwService.cpp b/services/soundtrigger/SoundTriggerHwService.cpp index 4a9b329164..5c01fad450 100644 --- a/services/soundtrigger/SoundTriggerHwService.cpp +++ b/services/soundtrigger/SoundTriggerHwService.cpp @@ -254,12 +254,12 @@ void SoundTriggerHwService::sendRecognitionEvent(struct sound_trigger_recognitio if (module == NULL) { return; } + struct sound_trigger_phrase_recognition_event newEvent; if (event-> type == SOUND_MODEL_TYPE_KEYPHRASE && event->data_size != 0 && event->data_offset != sizeof(struct sound_trigger_phrase_recognition_event)) { // set some defaults for the phrase if the recognition event won't be parsed properly // TODO: read defaults from the config - struct sound_trigger_phrase_recognition_event newEvent; memset(&newEvent, 0, sizeof(struct sound_trigger_phrase_recognition_event)); sp model = module->getModel(event->model); From 78056e7bd5238e31e11e9ae830494b7cf81c9c46 Mon Sep 17 00:00:00 2001 From: Karthik Reddy Katta Date: Thu, 14 Apr 2016 16:00:52 +0530 Subject: [PATCH 13/20] frameworks/av : Add diag permissions Add diag permissions to audioserver to enable QACT connectivty. Change-Id: I78a1a372769b90f0e59a4b0fcb78d197b3f040b4 --- media/audioserver/audioserver.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/audioserver/audioserver.rc b/media/audioserver/audioserver.rc index 9d42bce069..5308e7df59 100644 --- a/media/audioserver/audioserver.rc +++ b/media/audioserver/audioserver.rc @@ -2,7 +2,7 @@ service audioserver /system/bin/audioserver class main user audioserver # media gid needed for /dev/fm (radio) and for /data/misc/media (tee) - group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct + group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct qcom_diag ioprio rt 4 writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks onrestart restart audio-hal-2-0 From 07d5acb272e6f781b3934906cde0f2d741061daa Mon Sep 17 00:00:00 2001 From: Vinay Verma Date: Fri, 21 Jul 2017 11:08:41 +0530 Subject: [PATCH 14/20] Use AID OEM DIAG instead of qcom_diag Change-Id: Id9eb5c771080b9758ab4193948deea131c92afb3 --- media/audioserver/audioserver.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/audioserver/audioserver.rc b/media/audioserver/audioserver.rc index 5308e7df59..be87c8329d 100644 --- a/media/audioserver/audioserver.rc +++ b/media/audioserver/audioserver.rc @@ -2,7 +2,7 @@ service audioserver /system/bin/audioserver class main user audioserver # media gid needed for /dev/fm (radio) and for /data/misc/media (tee) - group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct qcom_diag + group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct oem_2901 ioprio rt 4 writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks onrestart restart audio-hal-2-0 From 5490e5fa32dda393ee43493af2ddf6302893051c Mon Sep 17 00:00:00 2001 From: Sauhard Pande Date: Thu, 11 May 2017 20:05:50 +0530 Subject: [PATCH 15/20] Camera: CameraHardwareInterface changes to support Extended FD Added QDataCallback definition to pass the extended QCameraFrameMetadata fields from HIDL to framework. Change-Id: Idece64f22dd6ee3713c7db658b8583854086a1d8 --- camera/cameraserver/Android.mk | 1 + services/camera/libcameraservice/Android.mk | 1 + .../device1/CameraHardwareInterface.cpp | 14 ++++++++++++++ .../device1/CameraHardwareInterface.h | 7 ++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk index 1df66d891a..2cf07b7e46 100644 --- a/camera/cameraserver/Android.mk +++ b/camera/cameraserver/Android.mk @@ -33,6 +33,7 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.camera.common@1.0 \ android.hardware.camera.provider@2.4 \ android.hardware.camera.device@1.0 \ + vendor.qti.hardware.camera.device@1.0 \ android.hardware.camera.device@3.2 \ android.hidl.manager@1.0 diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk index 80c04b9e2e..9881d7f2d9 100644 --- a/services/camera/libcameraservice/Android.mk +++ b/services/camera/libcameraservice/Android.mk @@ -77,6 +77,7 @@ LOCAL_SHARED_LIBRARIES:= \ android.hardware.camera.common@1.0 \ android.hardware.camera.provider@2.4 \ android.hardware.camera.device@1.0 \ + vendor.qti.hardware.camera.device@1.0 \ android.hardware.camera.device@3.2 \ android.hidl.manager@1.0 diff --git a/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp b/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp index 469c86c55e..9a1ec29799 100644 --- a/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp +++ b/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp @@ -137,6 +137,20 @@ hardware::Return CameraHardwareInterface::dataCallback( return hardware::Void(); } +hardware::Return CameraHardwareInterface::QDataCallback( + DataCallbackMsg msgType, uint32_t data, uint32_t bufferIndex, + const vendor::qti::hardware::camera::device::V1_0::QCameraFrameMetadata& metadata) { + if (mHidlMemPoolMap.count(data) == 0) { + ALOGE("%s: memory pool ID %d not found", __FUNCTION__, data); + return hardware::Void(); + } + camera_frame_metadata_t md; + md.number_of_faces = metadata.faces.size(); + md.faces = (camera_face_t*) metadata.faces.data(); + sDataCb((int32_t) msgType, mHidlMemPoolMap.at(data), bufferIndex, &md, this); + return hardware::Void(); +} + hardware::Return CameraHardwareInterface::dataCallbackTimestamp( DataCallbackMsg msgType, uint32_t data, uint32_t bufferIndex, int64_t timestamp) { diff --git a/services/camera/libcameraservice/device1/CameraHardwareInterface.h b/services/camera/libcameraservice/device1/CameraHardwareInterface.h index 1c38d0023c..42d88b80c4 100644 --- a/services/camera/libcameraservice/device1/CameraHardwareInterface.h +++ b/services/camera/libcameraservice/device1/CameraHardwareInterface.h @@ -29,6 +29,7 @@ #include #include +#include namespace android { @@ -85,7 +86,7 @@ typedef void (*data_callback_timestamp_batch)( class CameraHardwareInterface : public virtual RefBase, - public virtual hardware::camera::device::V1_0::ICameraDeviceCallback, + public virtual vendor::qti::hardware::camera::device::V1_0::IQCameraDeviceCallback, public virtual hardware::camera::device::V1_0::ICameraDevicePreviewCallback { public: @@ -432,6 +433,10 @@ class CameraHardwareInterface : hardware::camera::device::V1_0::DataCallbackMsg msgType, const hardware::hidl_vec< hardware::camera::device::V1_0::HandleTimestampMessage>&) override; + hardware::Return QDataCallback( + hardware::camera::device::V1_0::DataCallbackMsg msgType, + uint32_t data, uint32_t bufferIndex, + const vendor::qti::hardware::camera::device::V1_0::QCameraFrameMetadata& metadata) override; /** * Implementation of android::hardware::camera::device::V1_0::ICameraDevicePreviewCallback From bf9a71eaf7979bb1dc63b62adb967b2fae4b7da4 Mon Sep 17 00:00:00 2001 From: Mansoor Aftab Date: Thu, 9 Feb 2017 12:59:42 -0800 Subject: [PATCH 16/20] Revert "update stune group for cameraserver to top-app" This reverts commit 052c4955b8d31f7dc3484d40ee14cf18caccdae1. The original change is device specific removing from common frameworks location Change-Id: Ie80e8aae4afb9f3f2655680600553cf26d6f63f3 --- camera/cameraserver/cameraserver.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camera/cameraserver/cameraserver.rc b/camera/cameraserver/cameraserver.rc index fea5a1d5c6..9b637b2127 100644 --- a/camera/cameraserver/cameraserver.rc +++ b/camera/cameraserver/cameraserver.rc @@ -3,4 +3,4 @@ service cameraserver /system/bin/cameraserver user cameraserver group audio camera input drmrpc ioprio rt 4 - writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks + writepid /dev/cpuset/camera-daemon/tasks /dev/stune/foreground/tasks From 8ffb906f8f94ebfca031082b43920a3e38f1783a Mon Sep 17 00:00:00 2001 From: Martinusbe Date: Thu, 14 Sep 2017 21:54:12 +0200 Subject: [PATCH 17/20] Revert "Camera: CameraHardwareInterface changes to support Extended FD" This reverts commit 5490e5fa32dda393ee43493af2ddf6302893051c. --- camera/cameraserver/Android.mk | 1 - services/camera/libcameraservice/Android.mk | 1 - .../device1/CameraHardwareInterface.cpp | 14 -------------- .../device1/CameraHardwareInterface.h | 7 +------ 4 files changed, 1 insertion(+), 22 deletions(-) diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk index 2cf07b7e46..1df66d891a 100644 --- a/camera/cameraserver/Android.mk +++ b/camera/cameraserver/Android.mk @@ -33,7 +33,6 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.camera.common@1.0 \ android.hardware.camera.provider@2.4 \ android.hardware.camera.device@1.0 \ - vendor.qti.hardware.camera.device@1.0 \ android.hardware.camera.device@3.2 \ android.hidl.manager@1.0 diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk index 9881d7f2d9..80c04b9e2e 100644 --- a/services/camera/libcameraservice/Android.mk +++ b/services/camera/libcameraservice/Android.mk @@ -77,7 +77,6 @@ LOCAL_SHARED_LIBRARIES:= \ android.hardware.camera.common@1.0 \ android.hardware.camera.provider@2.4 \ android.hardware.camera.device@1.0 \ - vendor.qti.hardware.camera.device@1.0 \ android.hardware.camera.device@3.2 \ android.hidl.manager@1.0 diff --git a/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp b/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp index 9a1ec29799..469c86c55e 100644 --- a/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp +++ b/services/camera/libcameraservice/device1/CameraHardwareInterface.cpp @@ -137,20 +137,6 @@ hardware::Return CameraHardwareInterface::dataCallback( return hardware::Void(); } -hardware::Return CameraHardwareInterface::QDataCallback( - DataCallbackMsg msgType, uint32_t data, uint32_t bufferIndex, - const vendor::qti::hardware::camera::device::V1_0::QCameraFrameMetadata& metadata) { - if (mHidlMemPoolMap.count(data) == 0) { - ALOGE("%s: memory pool ID %d not found", __FUNCTION__, data); - return hardware::Void(); - } - camera_frame_metadata_t md; - md.number_of_faces = metadata.faces.size(); - md.faces = (camera_face_t*) metadata.faces.data(); - sDataCb((int32_t) msgType, mHidlMemPoolMap.at(data), bufferIndex, &md, this); - return hardware::Void(); -} - hardware::Return CameraHardwareInterface::dataCallbackTimestamp( DataCallbackMsg msgType, uint32_t data, uint32_t bufferIndex, int64_t timestamp) { diff --git a/services/camera/libcameraservice/device1/CameraHardwareInterface.h b/services/camera/libcameraservice/device1/CameraHardwareInterface.h index 42d88b80c4..1c38d0023c 100644 --- a/services/camera/libcameraservice/device1/CameraHardwareInterface.h +++ b/services/camera/libcameraservice/device1/CameraHardwareInterface.h @@ -29,7 +29,6 @@ #include #include -#include namespace android { @@ -86,7 +85,7 @@ typedef void (*data_callback_timestamp_batch)( class CameraHardwareInterface : public virtual RefBase, - public virtual vendor::qti::hardware::camera::device::V1_0::IQCameraDeviceCallback, + public virtual hardware::camera::device::V1_0::ICameraDeviceCallback, public virtual hardware::camera::device::V1_0::ICameraDevicePreviewCallback { public: @@ -433,10 +432,6 @@ class CameraHardwareInterface : hardware::camera::device::V1_0::DataCallbackMsg msgType, const hardware::hidl_vec< hardware::camera::device::V1_0::HandleTimestampMessage>&) override; - hardware::Return QDataCallback( - hardware::camera::device::V1_0::DataCallbackMsg msgType, - uint32_t data, uint32_t bufferIndex, - const vendor::qti::hardware::camera::device::V1_0::QCameraFrameMetadata& metadata) override; /** * Implementation of android::hardware::camera::device::V1_0::ICameraDevicePreviewCallback From 70386b66076033a4298f42fe6ab555808cd86211 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Sat, 23 Sep 2017 18:29:21 +0100 Subject: [PATCH 18/20] camera: include: Don't override possible overlayed header * If targets define a specific header path, then let it be the case and don't override it to avoid mismatched headers in the modules. * This only became an issue since O due to moved camera headers (commit e2b43843fd12783188edd2c54188ea8d26864788). Change-Id: I6bf7d1da7448d71f7821d40501db971f837781db --- camera/include/camera/CameraParameters2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camera/include/camera/CameraParameters2.h b/camera/include/camera/CameraParameters2.h index f691cd6ea0..5fae079376 100644 --- a/camera/include/camera/CameraParameters2.h +++ b/camera/include/camera/CameraParameters2.h @@ -19,7 +19,7 @@ #include #include -#include "CameraParameters.h" +#include namespace android { From ed12b77e52d7594fa2fa5119b80004aacf016d3a Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Mon, 14 Aug 2017 17:37:31 +0300 Subject: [PATCH 19/20] CameraClient: MTK Support Return on MTK hardware, the HAL does this internally and duplicating it here causes an infinite loop. Change-Id: I5bdb925ddb49980747b58dfae4543f812cef4c7d Signed-off-by: Simao Gomes Viana --- services/camera/libcameraservice/api1/CameraClient.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index 075c2e3166..3c5afb46cb 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -779,6 +779,9 @@ void CameraClient::disableMsgType(int32_t msgType) { #define CHECK_MESSAGE_INTERVAL 10 // 10ms bool CameraClient::lockIfMessageWanted(int32_t msgType) { +#ifdef MTK_HARDWARE + return true; +#endif int sleepCount = 0; while (mMsgEnabled & msgType) { if (mLock.tryLock() == NO_ERROR) { From 787dff487130b06cb91ec6738d822b64acfebb91 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 14 Aug 2017 17:30:14 +0300 Subject: [PATCH 20/20] libstagefright: mtk: Use vendor extensions to check if we should fixup cropping For mediatek video codecs, validate that the current cropped rectangle is valid and use the full frame size otherwise. This fixes a bug where format changes in the same native window would preserve the previous cropping and cause most of the image to be off-screen. Change-Id: If56ca11453f5d2e04a4138b2efe28203f30ba569 Ticket: PORRIDGE-440 Signed-off-by: Simao Gomes Viana --- media/libstagefright/ACodec.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 9f1be2296b..07ca944734 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -4833,7 +4833,16 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp ¬ify) { rect.nWidth = videoDef->nFrameWidth; rect.nHeight = videoDef->nFrameHeight; } - +#ifdef MTK_HARDWARE + if (!strncmp(mComponentName.c_str(), "OMX.MTK.", 8) && mOMX->getConfig( + mNode, (OMX_INDEXTYPE) 0x7f00001c /* OMX_IndexVendorMtkOmxVdecGetCropInfo */, + &rect, sizeof(rect)) != OK) { + rect.nLeft = 0; + rect.nTop = 0; + rect.nWidth = videoDef->nFrameWidth; + rect.nHeight = videoDef->nFrameHeight; + } +#endif if (rect.nLeft < 0 || rect.nTop < 0 || rect.nLeft + rect.nWidth > videoDef->nFrameWidth ||