diff --git a/frameworks/taihe/BUILD.gn b/frameworks/taihe/BUILD.gn index e7ea3adeb42698ad94b8fdfffcea7d85298a714e..cc28a49b490ecb575003b278c40394f99fed2762 100644 --- a/frameworks/taihe/BUILD.gn +++ b/frameworks/taihe/BUILD.gn @@ -26,6 +26,7 @@ copy_taihe_idl("copy_camera_taihe") { "${multimedia_camera_framework_path}/frameworks/taihe/idl/ohos.multimedia.camera.context.taihe", "${multimedia_camera_framework_path}/frameworks/taihe/idl/ohos.multimedia.cameraPicker.taihe", "${multimedia_camera_framework_path}/frameworks/taihe/idl/ohos.multimedia.cameraPicker.context.taihe", ] + external_deps = [ "image_framework:copy_image_taihe"] } ohos_taihe("camera_run_taihe") { @@ -82,6 +83,7 @@ taihe_shared_library("camera_taihe") { "src/mode/video_session_for_sys_taihe.cpp", "src/mode/night_photo_session_taihe.cpp", "src/mode/slow_motion_video_session_taihe.cpp", + "src/photo_taihe.cpp", ] deps = [ @@ -102,8 +104,10 @@ taihe_shared_library("camera_taihe") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "image_framework:image_native", + "image_framework:image_taihe", "ipc:ipc_core", "media_library:media_library", + "media_library:medialibrary_ani_utils", ] sanitize = { @@ -143,6 +147,7 @@ taihe_shared_library("camera_picker_taihe") { include_dirs = [ "include", "include/picker", + "//drivers/peripheral/camera/interfaces/include", "${multimedia_camera_framework_path}/interfaces/inner_api/native/camera/include", ] @@ -156,6 +161,7 @@ taihe_shared_library("camera_picker_taihe") { ] deps = [ + ":camera_taihe", ":camera_picker_run_taihe", "${multimedia_camera_framework_path}/common:camera_utils", "${multimedia_camera_framework_path}/frameworks/native/camera:camera_framework", diff --git a/frameworks/taihe/idl/ohos.multimedia.camera.taihe b/frameworks/taihe/idl/ohos.multimedia.camera.taihe index b6d7be1facc7951ccbfd185732bb9a68d65cbc6a..cc76fabdd07939f0f88c12f15a59f0dbf099909e 100644 --- a/frameworks/taihe/idl/ohos.multimedia.camera.taihe +++ b/frameworks/taihe/idl/ohos.multimedia.camera.taihe @@ -19,6 +19,11 @@ static { loadLibrary("camera_taihe.z"); } """) +from ohos.multimedia.image.image use PixelMap; +from ohos.multimedia.image.image use Image; + +use ohos.multimedia.image as image; + enum CameraFormat : i32 { CAMERA_FORMAT_RGBA_8888 = 3, CAMERA_FORMAT_DNG = 4, @@ -409,11 +414,21 @@ struct SketchStatusData { interface DeferredPhotoProxy { + @gen_promise("getThumbnail") + GetThumbnailSync(): PixelMap; @gen_promise("release") ReleaseSync(): void; } interface Photo { + @set SetMain(main: Image): void; + @get GetMain(): Image; + @set SetRaw(raw: Optional): void; + @get GetRaw(): Optional; + @set SetDepthData(depthData: Optional): void; + @get GetDepthData(): Optional; + @set SetCaptureId(captureId: i32): void; + @get GetCaptureId(): i32; @gen_promise("release") ReleaseSync(): void; } @@ -1919,6 +1934,8 @@ interface DepthDataOutput : CameraOutput { } interface DepthData { + @get GetDepthMap(): PixelMap; + @get GetFormat(): CameraFormat; @get GetQualityLevel(): DepthDataQualityLevel; @@ -2017,8 +2034,12 @@ interface PhotoOutput : CameraOutput { this.onDeferredPhotoProxyAvailable(callback as (err: BusinessError, data: DeferredPhotoProxy)=> void); } else if (type === "offlineDeliveryFinished") { this.onOfflineDeliveryFinished(callback as ((err: BusinessError, data: undefined)=> void)); + } else if (type === "quickThumbnail") { + this.onQuickThumbnail(callback as ((err: BusinessError, data: image.PixelMap)=> void)); } else if (type === "error") { this.onError(callback as (err: BusinessError)=> void); + } else if(type === "photoAssetAvailable") { + this.onPhotoAssetAvailable(callback as ((err: BusinessError, data: photoAccessHelper.PhotoAsset)=> void)); } else { throw new Error(`Unknown type: ${type}`); } @@ -2045,8 +2066,12 @@ interface PhotoOutput : CameraOutput { this.offDeferredPhotoProxyAvailable(callback as (((err: BusinessError, data: DeferredPhotoProxy)=> void) | undefined)); } else if (type === "offlineDeliveryFinished") { this.offOfflineDeliveryFinished(callback as (((err: BusinessError, data: undefined)=> void) | undefined)); + } else if (type === "quickThumbnail") { + this.offQuickThumbnail(callback as (((err: BusinessError, data: image.PixelMap)=> void) | undefined)); } else if (type === "error") { this.offError(callback as (((err: BusinessError)=> void) | undefined)); + } else if (type === "photoAssetAvailable") { + this.offPhotoAssetAvailable(callback as (((err: BusinessError, data: photoAccessHelper.PhotoAsset)=> void) | undefined)); } else { throw new Error(`Unknown type: ${type}`); } @@ -2075,8 +2100,8 @@ interface PhotoOutput : CameraOutput { OffOfflineDeliveryFinished(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: @sts_type("undefined") Opaque)=> void>): void; OnPhotoAssetAvailable(callback: (err: @sts_type("BusinessError") Opaque, data: @sts_type("photoAccessHelper.PhotoAsset") Opaque)=> void): void; OffPhotoAssetAvailable(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: @sts_type("photoAccessHelper.PhotoAsset") Opaque)=> void>): void; - OnQuickThumbnail(callback: (err: @sts_type("BusinessError") Opaque, data: @sts_type("image.PixelMap") Opaque)=> void): void; - OffQuickThumbnail(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: @sts_type("image.PixelMap") Opaque)=> void>): void; + OnQuickThumbnail(callback: (err: @sts_type("BusinessError") Opaque, data: PixelMap)=> void): void; + OffQuickThumbnail(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: PixelMap)=> void>): void; @gen_async("capture") @gen_promise("capture") diff --git a/frameworks/taihe/include/camera_auto_ref_taihe.h b/frameworks/taihe/include/camera_auto_ref_taihe.h index da2e121c18e10baf8f0cd644983c5d4ef90b7191..d1aa34d4e66ee70af5c80ced2745539f9508e532 100644 --- a/frameworks/taihe/include/camera_auto_ref_taihe.h +++ b/frameworks/taihe/include/camera_auto_ref_taihe.h @@ -52,7 +52,7 @@ public: std::shared_ptr GetCallbackFunction() { if (env_ == nullptr || callbackRef_ == nullptr) { - MEDIA_ERR_LOG("env_ and callbackRef_ is nullptr"); + MEDIA_ERR_LOG("env_ or callbackRef_ is nullptr"); return nullptr; } return callbackRef_; diff --git a/frameworks/taihe/include/deferred_photo_proxy_taihe.h b/frameworks/taihe/include/deferred_photo_proxy_taihe.h index d494b1cd086a5f515da3fa603e31e254c8418e4e..3ec893865cccb743f8d5f5666baf305d9346c344 100644 --- a/frameworks/taihe/include/deferred_photo_proxy_taihe.h +++ b/frameworks/taihe/include/deferred_photo_proxy_taihe.h @@ -20,14 +20,17 @@ #include "taihe/runtime.hpp" #include "camera_log.h" #include "deferred_photo_proxy.h" +#include "image_taihe.h" +#include "pixel_map_taihe.h" namespace Ani::Camera { using namespace OHOS; +namespace ImageTaihe = ohos::multimedia::image::image; class DeferredPhotoProxyImpl { public: DeferredPhotoProxyImpl(sptr deferredPhotoProxy); ~DeferredPhotoProxyImpl() = default; - + ImageTaihe::PixelMap GetThumbnailSync(); void ReleaseSync(); private: sptr deferredPhotoProxy_ = nullptr; diff --git a/frameworks/taihe/include/output/depth_data_taihe.h b/frameworks/taihe/include/output/depth_data_taihe.h index f6226d2202245a6e865f2fd3f156405d3e0c9299..3f0654f639a57a5c6a030ab12df60ec29d76c8d0 100644 --- a/frameworks/taihe/include/output/depth_data_taihe.h +++ b/frameworks/taihe/include/output/depth_data_taihe.h @@ -21,24 +21,26 @@ #include "taihe/runtime.hpp" #include "camera_worker_queue_keeper_taihe.h" - +#include "pixel_map_taihe.h" #include "camera_output_capability.h" namespace Ani { namespace Camera { using namespace taihe; using namespace ohos::multimedia::camera; +namespace ImageTaihe = ohos::multimedia::image::image; class DepthDataImpl : public std::enable_shared_from_this { public: DepthDataImpl(OHOS::CameraStandard::CameraFormat format, OHOS::CameraStandard::DepthDataAccuracy dataAccuracy, - int32_t qualityLevel) : format_(format), dataAccuracy_(dataAccuracy), qualityLevel_(qualityLevel) {} + int32_t qualityLevel, ImageTaihe::PixelMap pixelMap) : format_(format), dataAccuracy_(dataAccuracy), + qualityLevel_(qualityLevel), pixelMap_(pixelMap) {} DepthDataImpl() = delete; ~DepthDataImpl() {} CameraFormat GetFormat(); DepthDataQualityLevel GetQualityLevel(); DepthDataAccuracy GetDataAccuracy(); - + ImageTaihe::PixelMap GetDepthMap(); void ReleaseSync(); inline int64_t GetSpecificImplPtr() @@ -52,6 +54,7 @@ private: OHOS::CameraStandard::DepthDataAccuracy dataAccuracy_ = OHOS::CameraStandard::DepthDataAccuracy::DEPTH_DATA_ACCURACY_INVALID; int32_t qualityLevel_ = 0; + ImageTaihe::PixelMap pixelMap_ = make_holder(); }; struct DepthDataTaiheAsyncContext : public TaiheAsyncContext { diff --git a/frameworks/taihe/include/output/photo_output_taihe.h b/frameworks/taihe/include/output/photo_output_taihe.h index 8eadd80047c75a33d554d5ae41b3e884919d1508..7f4b05a3672dde1bb5543922f0d60d5d9f8634e6 100644 --- a/frameworks/taihe/include/output/photo_output_taihe.h +++ b/frameworks/taihe/include/output/photo_output_taihe.h @@ -134,7 +134,7 @@ public: private: void UpdateJSCallback(sptr photoSurface) const; void UpdateMainPictureStageOneJSCallback(sptr surfaceBuffer, int64_t timestamp) const; - void UpdatePictureJSCallback(int32_t captureId, const string uri, int32_t cameraShotType, + void UpdatePictureJSCallback(int32_t captureId, const std::string uri, int32_t cameraShotType, const std::string burstKey) const; void ExecutePhoto(sptr surfaceBfuffer, int64_t timestamp) const; void ExecuteDeferredPhoto(sptr surfaceBuffer) const; @@ -143,6 +143,8 @@ private: void ExecutePhotoAsset(sptr surfaceBuffer, bool isHighQuality, int64_t timestamp) const; int32_t GetAuxiliaryPhotoCount(sptr surfaceBuffer); void AssembleAuxiliaryPhoto(int64_t timestamp, int32_t captureId); + void CreateMediaLibrary(sptr surfaceBuffer, BufferHandle* bufferHandle, bool isHighQuality, + std::string& uri, int32_t& cameraShotType, std::string &burstKey, int64_t timestamp) const; sptr photoSurface_ = nullptr; wptr photoOutput_ = nullptr; std::shared_ptr bufferProcessor_ = nullptr; @@ -198,7 +200,8 @@ public: sptr debugImageListener; }; -class ThumbnailListener : public IBufferConsumerListener, public ListenerBase { +class ThumbnailListener : public IBufferConsumerListener, public ListenerBase, + public std::enable_shared_from_this { public: explicit ThumbnailListener(ani_env* env, const sptr photoOutput); virtual ~ThumbnailListener(); @@ -208,7 +211,6 @@ public: std::mutex taskManagerMutex_; private: wptr photoOutput_; - void UpdateJSCallback(int32_t captureId, int64_t timestamp, std::unique_ptr) const; void UpdateJSCallbackAsync(int32_t captureId, int64_t timestamp, std::unique_ptr); void ExecuteDeepCopySurfaceBuffer(); @@ -241,7 +243,7 @@ class PhotoOutputImpl : public CameraOutputImpl, public CameraAniEventEmitter { public: PhotoOutputImpl(OHOS::sptr output); - ~PhotoOutputImpl() = default; + ~PhotoOutputImpl() {}; void ReleaseSync() override; @@ -267,8 +269,9 @@ public: void OffOfflineDeliveryFinished(optional_view> callback); void OnPhotoAssetAvailable(callback_view callback); void OffPhotoAssetAvailable(optional_view> callback); - void OnQuickThumbnail(callback_view callback); - void OffQuickThumbnail(optional_view> callback); + void OnQuickThumbnail(callback_view callback); + void OffQuickThumbnail( + optional_view> callback); void CaptureSync(); void CaptureSyncWithSetting(PhotoCaptureSetting const& setting); void BurstCaptureSync(PhotoCaptureSetting const& setting); diff --git a/frameworks/taihe/include/photo_taihe.h b/frameworks/taihe/include/photo_taihe.h index ba48bf603b14afe756fe959f72d2811215e52c93..0a5be9099b00f66fa3e7b0f140f3b98a97d235fa 100644 --- a/frameworks/taihe/include/photo_taihe.h +++ b/frameworks/taihe/include/photo_taihe.h @@ -17,19 +17,36 @@ #include "taihe/runtime.hpp" #include "camera_log.h" +#include "image_taihe.h" +#include "pixel_map_taihe.h" +#include "depth_data_taihe.h" namespace Ani::Camera { +using namespace taihe; +using namespace ohos::multimedia::camera; +namespace ImageTaihe = ohos::multimedia::image::image; class PhotoImpl { public: - PhotoImpl() { - // Don't forget to implement the constructor. - } - - ~PhotoImpl() { - // Don't forget to implement the constructor. - } - + PhotoImpl(ImageTaihe::Image mainImage); + ~PhotoImpl() = default; + void SetMain(ImageTaihe::weak::Image main); + ImageTaihe::Image GetMain(); + void SetRaw(optional_view raw); + optional GetRaw(); + void SetDepthData(optional_view depthData); + optional GetDepthData(); + void SetCaptureId(int32_t captureId); + int32_t GetCaptureId(); void ReleaseSync(); +private: + ImageTaihe::Image mainImage_ = make_holder(nullptr); + int32_t captureId_ = 0; + ImageTaihe::Image main_ = taihe::make_holder(); + ImageTaihe::Image raw_ = taihe::make_holder(); + DepthData depthData_ = taihe::make_holder( + OHOS::CameraStandard::CameraFormat::CAMERA_FORMAT_YCBCR_420_888, + OHOS::CameraStandard::DepthDataAccuracy::DEPTH_DATA_ACCURACY_RELATIVE, 0, + make_holder()); }; } // namespace Ani::Camera #endif //FRAMEWORKS_TAIHE_INCLUDE_PHOTO_TAIHE_H \ No newline at end of file diff --git a/frameworks/taihe/include/query/camera_query_taihe.h b/frameworks/taihe/include/query/camera_query_taihe.h index 41c69b06ff440b80f02a92a4f5bcecc47019bfd0..5d57e765ab8fd62f03b057142b2c9c46f6e7abdf 100644 --- a/frameworks/taihe/include/query/camera_query_taihe.h +++ b/frameworks/taihe/include/query/camera_query_taihe.h @@ -291,7 +291,7 @@ public: double GetPhysicalAperture(); }; -class EffectSuggestionImpl : public SessionBase { +class EffectSuggestionImpl : virtual public SessionBase { public: explicit EffectSuggestionImpl() {} virtual ~EffectSuggestionImpl() = default; @@ -316,7 +316,7 @@ public: void EnableMacro(bool enabled); }; -class ManualFocusImpl : public SessionBase { +class ManualFocusImpl : virtual public SessionBase { public: explicit ManualFocusImpl() {} virtual ~ManualFocusImpl() = default; diff --git a/frameworks/taihe/src/camera_utils_taihe.cpp b/frameworks/taihe/src/camera_utils_taihe.cpp index 3534e5bb7ea6132bbef2bdc17a221916cfaa29de..e84f31341cc46980e706e210c8a960b769f481fc 100644 --- a/frameworks/taihe/src/camera_utils_taihe.cpp +++ b/frameworks/taihe/src/camera_utils_taihe.cpp @@ -144,7 +144,7 @@ FocusTrackingMode CameraUtilsTaihe::ToTaiheFocusTrackingMode(OHOS::CameraStandar { auto itr = g_nativeToAniFocusTrackingMode.find(mode); if (itr == g_nativeToAniFocusTrackingMode.end()) { - CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "ToTaiheLightStatus fail"); + CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "ToTaiheFocusTrackingMode fail"); return FocusTrackingMode::key_t::AUTO; } return itr->second; @@ -200,9 +200,9 @@ array CameraUtilsTaihe::ToTaiheArrayPhysicalAperture( continue; } apertures.push_back(static_cast(physicalApertures[i][y])); - res.apertures = array(apertures); - apertures.clear(); } + res.apertures = array(apertures); + apertures.clear(); resVec.push_back(res); } return array(resVec); @@ -507,12 +507,11 @@ ani_object CameraUtilsTaihe::ToBusinessError(ani_env *env, int32_t code, const s int32_t CameraUtilsTaihe::EnumGetValueInt32(ani_env *env, ani_enum_item enumItem) { - CHECK_ERROR_RETURN_RET_LOG(env != nullptr, -1, "Invalid env"); - int32_t value = -1; + CHECK_ERROR_RETURN_RET_LOG(env == nullptr, -1, "Invalid env"); ani_int aniInt {}; CHECK_ERROR_RETURN_RET_LOG(ANI_OK != env->EnumItem_GetValue_Int(enumItem, &aniInt), -1, "EnumItem_GetValue_Int failed"); - return reinterpret_cast(value); + return static_cast(aniInt); } bool CameraUtilsTaihe::GetEnableSecureCamera() diff --git a/frameworks/taihe/src/deferred_photo_proxy_taihe.cpp b/frameworks/taihe/src/deferred_photo_proxy_taihe.cpp index 371118fc9953b0253ce057dea4144fb9b55fd8d8..5db411a544909b306efd18ae7ede67894873125a 100644 --- a/frameworks/taihe/src/deferred_photo_proxy_taihe.cpp +++ b/frameworks/taihe/src/deferred_photo_proxy_taihe.cpp @@ -20,11 +20,28 @@ using namespace OHOS; namespace Ani { namespace Camera { - +namespace ImageTaihe = ohos::multimedia::image::image; DeferredPhotoProxyImpl::DeferredPhotoProxyImpl(sptr deferredPhotoProxy) { deferredPhotoProxy_ = deferredPhotoProxy; } + +ImageTaihe::PixelMap DeferredPhotoProxyImpl::GetThumbnailSync() +{ + void* fdAddr = deferredPhotoProxy_->GetFileDataAddr(); + int32_t thumbnailWidth = deferredPhotoProxy_->GetWidth(); + int32_t thumbnailHeight = deferredPhotoProxy_->GetHeight(); + Media::InitializationOptions opts; + opts.srcPixelFormat = Media::PixelFormat::RGBA_8888; + opts.pixelFormat = Media::PixelFormat::RGBA_8888; + opts.size = { .width = thumbnailWidth, .height = thumbnailHeight }; + MEDIA_INFO_LOG("thumbnailWidth:%{public}d, thumbnailheight: %{public}d", + thumbnailWidth, thumbnailHeight); + auto pixelMap = Media::PixelMap::Create(static_cast(fdAddr), + thumbnailWidth * thumbnailHeight * 4, 0, thumbnailWidth, opts, true); + return ANI::Image::PixelMapImpl::CreatePixelMap(std::move(pixelMap)); +} + void DeferredPhotoProxyImpl::ReleaseSync() { if (deferredPhotoProxy_ != nullptr) { diff --git a/frameworks/taihe/src/input/camera_input_taihe.cpp b/frameworks/taihe/src/input/camera_input_taihe.cpp index adb0590305e5d8bf3104d19a4c672e7011fca158..fcf3ea237231a6f8851f97a68a4ec9268967809b 100644 --- a/frameworks/taihe/src/input/camera_input_taihe.cpp +++ b/frameworks/taihe/src/input/camera_input_taihe.cpp @@ -47,7 +47,7 @@ void ErrorCallbackListenerAni::OnErrorCallback(const int32_t errorType, const in void OcclusionDetectCallbackListenerAni::OnCameraOcclusionDetected(const uint8_t isCameraOcclusion, const uint8_t isCameraLensDirty) const { - MEDIA_DEBUG_LOG("OnError is called, isCameraOcclusion: %{public}d, isCameraLensDirty: %{public}d", + MEDIA_DEBUG_LOG("OnCameraOcclusionDetected is called, isCameraOcclusion: %{public}d, isCameraLensDirty: %{public}d", isCameraOcclusion, isCameraLensDirty); OnCameraOcclusionDetectedCallback(isCameraOcclusion, isCameraLensDirty); } diff --git a/frameworks/taihe/src/input/camera_manager_taihe.cpp b/frameworks/taihe/src/input/camera_manager_taihe.cpp index 9c3d5709d7583a4e97518d68cd9ca0f09dc21bae..25aeb1be501e219928e35ca8cf433c227067d971 100644 --- a/frameworks/taihe/src/input/camera_manager_taihe.cpp +++ b/frameworks/taihe/src/input/camera_manager_taihe.cpp @@ -209,7 +209,7 @@ array CameraManagerImpl::GetSupportedSceneModes(CameraDevice const& c sptr cameraDevice = cameraManager_->GetCameraDeviceFromId(std::string(camera.cameraId)); if (cameraDevice == nullptr) { - MEDIA_ERR_LOG("CameraManagerAni::GetSupportedModes get camera info fail"); + MEDIA_ERR_LOG("CameraManagerImpl::GetSupportedModes get camera info fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "Get camera info fail"); return array(nullptr, 0); } @@ -309,7 +309,7 @@ CameraOutputCapability CameraManagerImpl::GetSupportedOutputCapability(CameraDev MEDIA_INFO_LOG("GetSupportedOutputCapability SceneMode sceneMode = %{public}d ", sceneMode); if (cameraInfo == nullptr) { - MEDIA_ERR_LOG("CameraManagerAni::GetSupportedOutputCapability get camera info fail"); + MEDIA_ERR_LOG("CameraManagerImpl::GetSupportedOutputCapability get camera info fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "Get camera info fail"); return nullImpl; } @@ -447,7 +447,7 @@ void CameraManagerImpl::RegisterCameraMuteCallbackListener(const std::string& ev auto listener = CameraAniEventListener::RegisterCallbackListener( eventName, env, callback, isOnce); CHECK_ERROR_RETURN_LOG( - listener == nullptr, "CameraManagerAni::RegisterCameraMuteCallbackListener listener is null"); + listener == nullptr, "CameraManagerImpl::RegisterCameraMuteCallbackListener listener is null"); cameraManager_->RegisterCameraMuteListener(listener); } @@ -908,7 +908,7 @@ DepthDataOutput CameraManagerImpl::CreateDepthDataOutput(DepthProfile const& pro static_cast(profile.size.height) }; OHOS::CameraStandard::DepthProfile depthProfile(cameraFormat, depthDataAccuracy, size); MEDIA_INFO_LOG( - "CameraManagerAni::CreateDepthDataOutputInstance ParseDepthProfile " + "CameraManagerImpl::CreateDepthDataOutputInstance ParseDepthProfile " "size.width = %{public}d, size.height = %{public}d, format = %{public}d, dataAccuracy = %{public}d,", depthProfile.size_.width, depthProfile.size_.height, depthProfile.format_, depthProfile.dataAccuracy_); OHOS::sptr depthDataSurface = nullptr; diff --git a/frameworks/taihe/src/mode/photo_session_taihe.cpp b/frameworks/taihe/src/mode/photo_session_taihe.cpp index 3fd6f0e459e49e624f930974fccd5b91c620d8fb..72c841e6b05266798455eff123b376055414f4aa 100644 --- a/frameworks/taihe/src/mode/photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/photo_session_taihe.cpp @@ -53,7 +53,7 @@ array CreateFunctionsPhotoFunctionsArray( MEDIA_DEBUG_LOG("CreateFunctionsJSArray is called"); CHECK_ERROR_PRINT_LOG(functionsList.empty(), "functionsList is empty"); std::vector functionsArray; - for (auto i = 0; i < functionsList.size(); i++) { + for (size_t i = 0; i < functionsList.size(); i++) { functionsArray.push_back(make_holder(functionsList[i])); } return array(functionsArray); @@ -65,7 +65,7 @@ array CreateFunctionsPhotoConflictFunctionsArray( MEDIA_DEBUG_LOG("CreateFunctionsJSArray is called"); CHECK_ERROR_PRINT_LOG(conflictFunctionsList.empty(), "conflictFunctionsList is empty"); std::vector functionsArray; - for (auto i = 0; i < conflictFunctionsList.size(); i++) { + for (size_t i = 0; i < conflictFunctionsList.size(); i++) { functionsArray.push_back( make_holder(conflictFunctionsList[i])); } diff --git a/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp b/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp index 4be608567261620c2455b718a843619bba180281..2e14c7e933d13d0bf10f4ca500ef0e062c403682 100644 --- a/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp @@ -29,7 +29,7 @@ array CreateFunctionsPortraitPhotoFunctionsArray( MEDIA_DEBUG_LOG("CreateFunctionsJSArray is called"); CHECK_ERROR_PRINT_LOG(functionsList.empty(), "functionsList is empty"); std::vector functionsArray; - for (auto i = 0; i < functionsList.size(); i++) { + for (size_t i = 0; i < functionsList.size(); i++) { functionsArray.push_back(make_holder(functionsList[i])); } return array(functionsArray); @@ -41,7 +41,7 @@ array CreateFunctionsPortraitPhotoConflictFuncti MEDIA_DEBUG_LOG("CreateFunctionsJSArray is called"); CHECK_ERROR_PRINT_LOG(conflictFunctionsList.empty(), "conflictFunctionsList is empty"); std::vector functionsArray; - for (auto i = 0; i < conflictFunctionsList.size(); i++) { + for (size_t i = 0; i < conflictFunctionsList.size(); i++) { functionsArray.push_back( make_holder(conflictFunctionsList[i])); } diff --git a/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp b/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp index 6760e8c0731ec212d45d6d52140a08918213ac96..6996744370b67501206f30bf895b0db4108719b9 100644 --- a/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp +++ b/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp @@ -61,7 +61,7 @@ void SlowMotionVideoSessionImpl::UnregisterSlowMotionStateCb( const std::string& eventName, std::shared_ptr callback) { MEDIA_INFO_LOG("UnregisterSlowMotionStateCb is called"); - CHECK_ERROR_RETURN_LOG(slowMotionState_ == nullptr, "slowMotionStateListener_ is null"); + CHECK_ERROR_RETURN_LOG(slowMotionState_ == nullptr, "slowMotionState_ is null"); slowMotionState_->RemoveCallbackRef(eventName, callback); MEDIA_INFO_LOG("UnregisterSlowMotionStateCb success"); } diff --git a/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp b/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp index c75564f5a7cd8d83ea1f441b848d64cefc95d48b..51f24a031e67b424d961cf36eba94d77b28440ae 100644 --- a/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp @@ -228,7 +228,7 @@ array TimeLapsePhotoSessionImpl::GetSupportedTimeLapseIntervalRange() CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, array(nullptr, 0), "GetSupportedTimeLapseIntervalRange failed, timeLapsePhotoSession_ is nullptr!"); std::vector range; - int32_t retCode = timeLapsePhotoSession_->GetIsoRange(range); + int32_t retCode = timeLapsePhotoSession_->GetSupportedTimeLapseIntervalRange(range); CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); return array(range); } diff --git a/frameworks/taihe/src/mode/video_session_taihe.cpp b/frameworks/taihe/src/mode/video_session_taihe.cpp index 300676cfa44ec9c62ac82ec5900809df975d5b3f..65041cc831578fc774515690d0df25deb713c274 100644 --- a/frameworks/taihe/src/mode/video_session_taihe.cpp +++ b/frameworks/taihe/src/mode/video_session_taihe.cpp @@ -59,10 +59,10 @@ bool VideoSessionImpl::CanPreconfig(PreconfigType preconfigType, optional_view

CreateFunctionsVideoFunctionsArray( std::vector> functionsList) { - MEDIA_DEBUG_LOG("CreateFunctionsJSArray is called"); + MEDIA_DEBUG_LOG("CreateFunctionsVideoFunctionsArray is called"); CHECK_ERROR_PRINT_LOG(functionsList.empty(), "functionsList is empty"); std::vector functionsArray; - for (auto i = 0; i < functionsList.size(); i++) { + for (size_t i = 0; i < functionsList.size(); i++) { functionsArray.push_back(make_holder(functionsList[i])); } return array(functionsArray); @@ -71,10 +71,10 @@ array CreateFunctionsVideoFunctionsArray( array CreateFunctionsVideoConflictFunctionsArray( std::vector> conflictFunctionsList) { - MEDIA_DEBUG_LOG("CreateFunctionsJSArray is called"); + MEDIA_DEBUG_LOG("CreateFunctionsVideoConflictFunctionsArray is called"); CHECK_ERROR_PRINT_LOG(conflictFunctionsList.empty(), "conflictFunctionsList is empty"); std::vector functionsArray; - for (auto i = 0; i < conflictFunctionsList.size(); i++) { + for (size_t i = 0; i < conflictFunctionsList.size(); i++) { functionsArray.push_back( make_holder(conflictFunctionsList[i])); } diff --git a/frameworks/taihe/src/output/depth_data_output_taihe.cpp b/frameworks/taihe/src/output/depth_data_output_taihe.cpp index 2e5c533152897d73f2c538df589c4f9c7080f6da..ace8b7aeefe0cce029cd85e3839e6b9c9750ea4f 100644 --- a/frameworks/taihe/src/output/depth_data_output_taihe.cpp +++ b/frameworks/taihe/src/output/depth_data_output_taihe.cpp @@ -239,19 +239,22 @@ void DepthDataTaiheListener::ExecuteDepthData(OHOS::sptr su auto pixelMap = OHOS::Media::PixelMap::Create(static_cast(surfaceBuffer->GetVirAddr()), depthDataWidth * depthDataHeight * formatSize, 0, depthDataWidth, opts, true); CHECK_ERROR_PRINT_LOG(pixelMap == nullptr, "create pixelMap failed, pixelMap is null"); + std::shared_ptr sharedPtr = std::shared_ptr(pixelMap.release()); // depend on the implementation of PixelMapImpl - + auto pixelMapTaihe = make_holder(sharedPtr); OHOS::CameraStandard::CameraFormat nativeFormat = depthProfile_->GetCameraFormat(); OHOS::CameraStandard::DepthDataAccuracy nativeDataAccuracy = depthProfile_->GetDataAccuracy(); int32_t nativeQualityLevel = 0; surfaceBuffer->GetExtraData()->ExtraGet(OHOS::Camera::depthDataQualityLevel, nativeQualityLevel); - DepthData depthData = make_holder(nativeFormat, nativeDataAccuracy, nativeQualityLevel); - + DepthData depthData = make_holder( + nativeFormat, nativeDataAccuracy, nativeQualityLevel, pixelMapTaihe); auto sharePtr = shared_from_this(); - auto task = [depthData, sharePtr]() { - CHECK_EXECUTE(sharePtr != nullptr, - sharePtr->ExecuteAsyncCallback("depthDataAvailable", 0, "Callback is OK", depthData)); + auto task = [depthData, sharePtr, &surfaceBuffer]() { + CHECK_ERROR_RETURN_LOG(sharePtr == nullptr, "sharePtr is nullptr"); + sharePtr->ExecuteAsyncCallback("depthDataAvailable", 0, "Callback is OK", depthData); + CHECK_ERROR_RETURN_LOG(sharePtr->depthDataSurface_ == nullptr, "depthDataSurface_ is nullptr"); + sharePtr->depthDataSurface_->ReleaseBuffer(surfaceBuffer, -1); }; CHECK_ERROR_RETURN_LOG(mainHandler_ == nullptr, "callback failed, mainHandler_ is nullptr!"); mainHandler_->PostTask(task, "OnDepthDataAvailable", 0, OHOS::AppExecFwk::EventQueue::Priority::IMMEDIATE, {}); diff --git a/frameworks/taihe/src/output/depth_data_taihe.cpp b/frameworks/taihe/src/output/depth_data_taihe.cpp index 2879edae11a2a4b41b6cb529068c58588b052980..27a564b095e3cd34e19b6c2b2b798d515f8461d9 100644 --- a/frameworks/taihe/src/output/depth_data_taihe.cpp +++ b/frameworks/taihe/src/output/depth_data_taihe.cpp @@ -33,6 +33,9 @@ void DepthDataImpl::ReleaseSync() asyncContext->objectInfo = this; CAMERA_START_ASYNC_TRACE(asyncContext->funcName, asyncContext->taskId); CameraTaiheWorkerQueueKeeper::GetInstance()->ConsumeWorkerQueueTask(asyncContext->queueTask, [&asyncContext]() { + if (asyncContext->objectInfo != nullptr) { + asyncContext->objectInfo->pixelMap_->ReleaseSync(); + } CameraUtilsTaihe::CheckError(asyncContext->errorCode); }); CAMERA_FINISH_ASYNC_TRACE(asyncContext->funcName, asyncContext->taskId); @@ -50,5 +53,10 @@ DepthDataAccuracy DepthDataImpl::GetDataAccuracy() { return CameraUtilsTaihe::ToTaiheDepthDataAccuracy(dataAccuracy_); } + +ImageTaihe::PixelMap DepthDataImpl::GetDepthMap() +{ + return pixelMap_; +} } // namespace Camera } // namespace Ani \ No newline at end of file diff --git a/frameworks/taihe/src/output/photo_output_taihe.cpp b/frameworks/taihe/src/output/photo_output_taihe.cpp index 36923528b68b88b218920762529c8eaa21caa61c..ccda5e29a006be97d5c20d10ae675ef9af2bd5e4 100644 --- a/frameworks/taihe/src/output/photo_output_taihe.cpp +++ b/frameworks/taihe/src/output/photo_output_taihe.cpp @@ -27,9 +27,12 @@ #include "dp_utils.h" #include "deferred_photo_proxy_taihe.h" #include "video_key_info.h" +#include "image_taihe.h" #include "image_receiver.h" #include "hdr_type.h" - +#include "photo_taihe.h" +#include "pixel_map_taihe.h" +#include "media_library_comm_ani.h" #include "metadata_helper.h" #include @@ -622,9 +625,19 @@ void CleanAfterTransPicture(sptr photoOutput, photoOutput->captureIdHandleMap_.erase(captureId); } -void PhotoListenerAni::UpdatePictureJSCallback(int32_t captureId, const string uri, int32_t cameraShotType, +void PhotoListenerAni::UpdatePictureJSCallback(int32_t captureId, const std::string uri, int32_t cameraShotType, const std::string burstKey) const { + MEDIA_INFO_LOG("PhotoListener:UpdatePictureJSCallback called"); + ani_object photoAssetValue = + Media::MediaLibraryCommAni::CreatePhotoAssetAni(get_env(), uri, cameraShotType, captureId, burstKey); + auto sharePtr = shared_from_this(); + auto task = [photoAssetValue, sharePtr]() { + CHECK_EXECUTE(sharePtr != nullptr, sharePtr->ExecuteAsyncCallback( + CONST_CAPTURE_PHOTO_ASSET_AVAILABLE, 0, "success", reinterpret_cast(photoAssetValue))); + MEDIA_DEBUG_LOG("ExecuteCallback CONST_CAPTURE_PHOTO_ASSET_AVAILABLE X"); + }; + mainHandler_->PostTask(task, "UpdatePictureJSCallback", 0, OHOS::AppExecFwk::EventQueue::Priority::IMMEDIATE, {}); } void PhotoListenerAni::AssembleAuxiliaryPhoto(int64_t timestamp, int32_t captureId) __attribute__((no_sanitize("cfi"))) @@ -828,6 +841,21 @@ void PhotoListenerAni::UpdateJSCallback(sptr photoSurface) const void PhotoListenerAni::ExecutePhoto(sptr surfaceBuffer, int64_t timestamp) const { + MEDIA_INFO_LOG("ExecutePhoto"); + int32_t errCode = 0; + std::string message = "success"; + std::shared_ptr image = std::make_shared(surfaceBuffer, + bufferProcessor_, timestamp); + ohos::multimedia::image::image::Image mainImage = ANI::Image::ImageImpl::Create(image); + if (has_error()) { + reset_error(); + errCode = -1; + message = "ImageTaihe Create failed"; + } + Photo photoValue = make_holder(mainImage); + photoValue->SetCaptureId(GetCaptureId(surfaceBuffer)); + ExecuteAsyncCallback(CONST_CAPTURE_PHOTO_AVAILABLE, errCode, message, photoValue); + photoSurface_->ReleaseBuffer(surfaceBuffer, -1); } void PhotoListenerAni::ExecuteDeferredPhoto(sptr surfaceBuffer) const @@ -883,8 +911,93 @@ void PhotoListenerAni::ExecuteDeferredPhoto(sptr surfaceBuffer) c photoSurface_->ReleaseBuffer(surfaceBuffer, -1); } +void PhotoListenerAni::CreateMediaLibrary(sptr surfaceBuffer, BufferHandle *bufferHandle, + bool isHighQuality, std::string &uri, int32_t &cameraShotType, std::string &burstKey, int64_t timestamp) const +{ + CAMERA_SYNC_TRACE; + CHECK_ERROR_RETURN_LOG(bufferHandle == nullptr, "bufferHandle is nullptr"); + // get buffer handle and photo info + int32_t captureId; + surfaceBuffer->GetExtraData()->ExtraGet(OHOS::Camera::captureId, captureId); + int32_t burstSeqId = -1; + surfaceBuffer->GetExtraData()->ExtraGet(OHOS::Camera::burstSequenceId, burstSeqId); + int64_t imageId = 0; + surfaceBuffer->GetExtraData()->ExtraGet(OHOS::Camera::imageId, imageId); + int32_t deferredProcessingType; + surfaceBuffer->GetExtraData()->ExtraGet(OHOS::Camera::deferredProcessingType, deferredProcessingType); + MEDIA_INFO_LOG( + "PhotoListener ExecutePhotoAsset captureId:%{public}d " + "imageId:%{public}" PRId64 ", deferredProcessingType:%{public}d, burstSeqId:%{public}d", + captureId, imageId, deferredProcessingType, burstSeqId); + int32_t photoWidth; + int32_t photoHeight; + surfaceBuffer->GetExtraData()->ExtraGet(dataWidth, photoWidth); + surfaceBuffer->GetExtraData()->ExtraGet(dataHeight, photoHeight); + uint64_t size = static_cast(surfaceBuffer->GetSize()); + int32_t extraDataSize = 0; + auto res = surfaceBuffer->GetExtraData()->ExtraGet(OHOS::Camera::dataSize, extraDataSize); + if (res != 0) { + MEDIA_INFO_LOG("ExtraGet dataSize error %{public}d", res); + } else if (extraDataSize <= 0) { + MEDIA_INFO_LOG("ExtraGet dataSize Ok, but size <= 0"); + } else if (static_cast(extraDataSize) > size) { + MEDIA_INFO_LOG("ExtraGet dataSize Ok,but dataSize %{public}d is bigger than bufferSize %{public}" PRIu64, + extraDataSize, size); + } else { + MEDIA_INFO_LOG("ExtraGet dataSize %{public}d", extraDataSize); + size = static_cast(extraDataSize); + } + int32_t deferredImageFormat = 0; + res = surfaceBuffer->GetExtraData()->ExtraGet(OHOS::Camera::deferredImageFormat, deferredImageFormat); + MEDIA_INFO_LOG("deferredImageFormat:%{public}d, width:%{public}d, height:%{public}d, size:%{public}" PRId64, + deferredImageFormat, photoWidth, photoHeight, size); + int32_t format = bufferHandle->format; + sptr photoProxy; + std::string imageIdStr = std::to_string(imageId); + photoProxy = new(std::nothrow) OHOS::CameraStandard::CameraPhotoProxy(bufferHandle, format, photoWidth, photoHeight, + isHighQuality, captureId, burstSeqId); + CHECK_ERROR_RETURN_LOG(photoProxy == nullptr, "failed to new photoProxy"); + photoProxy->SetDeferredAttrs(imageIdStr, deferredProcessingType, size, deferredImageFormat); + auto photoOutput = photoOutput_.promote(); + if (photoOutput) { + auto settings = photoOutput->GetDefaultCaptureSetting(); + if (settings) { + auto location = std::make_shared(); + settings->GetLocation(location); + photoProxy->SetLocation(location->latitude, location->longitude); + } + photoOutput->CreateMediaLibrary(photoProxy, uri, cameraShotType, burstKey, timestamp); + } +} + void PhotoListenerAni::ExecutePhotoAsset(sptr surfaceBuffer, bool isHighQuality, int64_t timestamp) const { + CAMERA_SYNC_TRACE; + MEDIA_INFO_LOG("ExecutePhotoAsset"); + int32_t errCode = 0; + std::string message = "success"; + // deep copy buffer + sptr newSurfaceBuffer = SurfaceBuffer::Create(); + int32_t captureId = GetCaptureId(surfaceBuffer); + DeepCopyBuffer(newSurfaceBuffer, surfaceBuffer, 0); + BufferHandle* bufferHandle = newSurfaceBuffer->GetBufferHandle(); + if (bufferHandle == nullptr) { + errCode = OHOS::CameraStandard::CameraErrorCode::INVALID_ARGUMENT; + message = "invalid bufferHandle"; + } + newSurfaceBuffer->Map(); + std::string uri = ""; + int32_t cameraShotType = 0; + std::string burstKey = ""; + CreateMediaLibrary(surfaceBuffer, bufferHandle, isHighQuality, uri, cameraShotType, burstKey, timestamp); + MEDIA_INFO_LOG("CreateMediaLibrary result uri:%{public}s cameraShotType:%{public}d burstKey:%{public}s", + uri.c_str(), cameraShotType, burstKey.c_str()); + ani_object photoAssetValue = + Media::MediaLibraryCommAni::CreatePhotoAssetAni(get_env(), uri, cameraShotType, captureId, burstKey); + ExecuteAsyncCallback( + CONST_CAPTURE_PHOTO_ASSET_AVAILABLE, errCode, message, reinterpret_cast(photoAssetValue)); + // return buffer to buffer queue + photoSurface_->ReleaseBuffer(surfaceBuffer, -1); } void PhotoListenerAni::OnBufferAvailable() @@ -919,6 +1032,10 @@ void PhotoListenerAni::SaveCallback(const std::string eventName, std::shared_ptr CHECK_ERROR_RETURN_LOG(photoOutput_ == nullptr, "photoOutput_ is nullptr"); if (eventName == CONST_CAPTURE_PHOTO_AVAILABLE) { callbackFlag_ |= OHOS::CameraStandard::CAPTURE_PHOTO; + } else if (eventName == CONST_CAPTURE_PHOTO_ASSET_AVAILABLE) { + callbackFlag_ |= OHOS::CameraStandard::CAPTURE_PHOTO_ASSET; + } else if (eventName == CONST_CAPTURE_DEFERRED_PHOTO_AVAILABLE) { + callbackFlag_ |= OHOS::CameraStandard::CAPTURE_DEFERRED_PHOTO; } else { MEDIA_ERR_LOG("Incorrect photo callback event type received from JS"); return; @@ -960,6 +1077,19 @@ void RawPhotoListenerAni::OnBufferAvailable() void RawPhotoListenerAni::ExecuteRawPhoto(sptr surfaceBuffer) const { + MEDIA_INFO_LOG("ExecuteRawPhoto"); + int32_t errCode = 0; + std::string message = "success"; + std::shared_ptr image = std::make_shared(surfaceBuffer, bufferProcessor_); + ohos::multimedia::image::image::Image mainImage = ANI::Image::ImageImpl::Create(image); + if (has_error()) { + reset_error(); + errCode = -1; + message = "ImageTaihe Create failed"; + } + Photo photoValue = make_holder(mainImage); + ExecuteAsyncCallback(CONST_CAPTURE_PHOTO_AVAILABLE, errCode, message, photoValue); + rawPhotoSurface_->ReleaseBuffer(surfaceBuffer, -1); } void RawPhotoListenerAni::UpdateJSCallback(sptr rawPhotoSurface) const @@ -1226,11 +1356,16 @@ std::unique_ptr ThumbnailListener::SetPixelMapYuvInfo(sptr pixelMap) { -} - -void ThumbnailListener::UpdateJSCallback(int32_t captureId, int64_t timestamp, - std::unique_ptr pixelMap) const -{ + ohos::multimedia::image::image::PixelMap pixelMapVal = + make_holder(std::move(pixelMap)); + pixelMapVal->SetCaptureId(captureId); + pixelMapVal->SetTimestamp(timestamp); + auto sharePtr = shared_from_this(); + auto task = [pixelMapVal, sharePtr]() { + CHECK_EXECUTE(sharePtr != nullptr, + sharePtr->ExecuteAsyncCallback(CONST_CAPTURE_START_WITH_INFO, 0, "Callback is OK", pixelMapVal)); + }; + mainHandler_->PostTask(task, "UpdateJSCallbackAsync", 0, OHOS::AppExecFwk::EventQueue::Priority::IMMEDIATE, {}); } PhotoOutputImpl::PhotoOutputImpl(sptr output) : CameraOutputImpl(output) @@ -1759,11 +1894,13 @@ void PhotoOutputImpl::OffPhotoAssetAvailable(optional_view::Off(this, callback, CONST_CAPTURE_PHOTO_ASSET_AVAILABLE); } -void PhotoOutputImpl::OnQuickThumbnail(callback_view callback) +void PhotoOutputImpl::OnQuickThumbnail( + callback_view callback) { ListenerTemplate::On(this, callback, CONST_CAPTURE_QUICK_THUMBNAIL); } -void PhotoOutputImpl::OffQuickThumbnail(optional_view> callback) +void PhotoOutputImpl::OffQuickThumbnail( + optional_view> callback) { ListenerTemplate::Off(this, callback, CONST_CAPTURE_QUICK_THUMBNAIL); } diff --git a/frameworks/taihe/src/output/preview_output_taihe.cpp b/frameworks/taihe/src/output/preview_output_taihe.cpp index 4483c9f77606a3fb296010f05e104a811282cfc2..117509bd05bfba557d998c8f8808b4ec5e79fc4b 100644 --- a/frameworks/taihe/src/output/preview_output_taihe.cpp +++ b/frameworks/taihe/src/output/preview_output_taihe.cpp @@ -329,7 +329,7 @@ void PreviewOutputImpl::RegisterErrorCallbackListener(const std::string& eventNa auto listener = CameraAniEventListener::RegisterCallbackListener(eventName, env, callback, isOnce); CHECK_ERROR_RETURN_LOG( - listener == nullptr, "CameraManagerAni::RegisterErrorCallbackListener listener is null"); + listener == nullptr, "PreviewOutputImpl::RegisterErrorCallbackListener listener is null"); previewOutput_->SetCallback(listener); } @@ -342,7 +342,7 @@ void PreviewOutputImpl::RegisterFrameStartCallbackListener(const std::string& ev auto listener = CameraAniEventListener::RegisterCallbackListener(eventName, env, callback, isOnce); CHECK_ERROR_RETURN_LOG( - listener == nullptr, "CameraManagerAni::RegisterFrameStartCallbackListener listener is null"); + listener == nullptr, "PreviewOutputImpl::RegisterFrameStartCallbackListener listener is null"); previewOutput_->SetCallback(listener); } @@ -355,7 +355,7 @@ void PreviewOutputImpl::RegisterFrameEndCallbackListener(const std::string& even auto listener = CameraAniEventListener::RegisterCallbackListener(eventName, env, callback, isOnce); CHECK_ERROR_RETURN_LOG( - listener == nullptr, "CameraManagerAni::RegisterFrameEndCallbackListener listener is null"); + listener == nullptr, "PreviewOutputImpl::RegisterFrameEndCallbackListener listener is null"); previewOutput_->SetCallback(listener); } diff --git a/frameworks/taihe/src/output/video_output_taihe.cpp b/frameworks/taihe/src/output/video_output_taihe.cpp index fb2912208e4a70cc239eee2098288c793df4429e..01ccacfef6269d0183554eeb43026240418e4353 100644 --- a/frameworks/taihe/src/output/video_output_taihe.cpp +++ b/frameworks/taihe/src/output/video_output_taihe.cpp @@ -112,8 +112,6 @@ bool VideoOutputImpl::IsAutoVideoFrameRateSupported() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, "SystemApi IsAutoVideoFrameRateSupported is called!"); - CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, false, - "EnableAutoVideoFrameRate failed, videoOutput_ is nullptr"); if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::EnableAutoVideoFrameRate get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); @@ -126,7 +124,6 @@ void VideoOutputImpl::EnableAutoVideoFrameRate(bool enabled) { CHECK_ERROR_RETURN_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), "SystemApi EnableAutoVideoFrameRate is called!"); - CHECK_ERROR_RETURN_LOG(videoOutput_ == nullptr, "EnableAutoVideoFrameRate failed, videoOutput_ is nullptr"); if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::EnableAutoVideoFrameRate get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); @@ -243,7 +240,7 @@ void VideoOutputImpl::SetRotation(ImageRotation rotation) } int32_t retCode = videoOutput_->SetRotation(rotation.get_value()); CHECK_ERROR_PRINT_LOG(!CameraUtilsTaihe::CheckError(retCode), - "VideoOutputImpl::EnableAutoVideoFrameRate fail %{public}d", retCode); + "VideoOutputImpl::SetRotation fail %{public}d", retCode); } bool VideoOutputImpl::IsRotationSupported() diff --git a/frameworks/taihe/src/photo_taihe.cpp b/frameworks/taihe/src/photo_taihe.cpp index 6181cb08e13d575abd4668db7a4e171ead1a5651..67391c1444298b92a66af13400cfe9ec9c7d3a17 100644 --- a/frameworks/taihe/src/photo_taihe.cpp +++ b/frameworks/taihe/src/photo_taihe.cpp @@ -20,8 +20,60 @@ using namespace OHOS; namespace Ani { namespace Camera { +using namespace taihe; +using namespace ohos::multimedia::camera; +using namespace ohos::multimedia::image; +namespace ImageTaihe = ohos::multimedia::image::image; +PhotoImpl::PhotoImpl(ImageTaihe::Image mainImage) +{ + mainImage_ = mainImage; +} + +void PhotoImpl::SetMain(ImageTaihe::weak::Image main) +{ + main_ = main; +} + +ImageTaihe::Image PhotoImpl::GetMain() +{ + return main_; +} + +void PhotoImpl::SetRaw(optional_view raw) +{ + if (raw.has_value()) { + raw_ = raw.value(); + } +} + +optional PhotoImpl::GetRaw() +{ + return optional(std::in_place_t{}, raw_); +} + +void PhotoImpl::SetDepthData(optional_view depthData) +{ + if (depthData.has_value()) { + depthData_ = depthData.value(); + } +} + +optional PhotoImpl::GetDepthData() +{ + return optional(std::in_place_t{}, depthData_); +} + +void PhotoImpl::SetCaptureId(int32_t captureId) +{ + captureId_ = captureId; +} +int32_t PhotoImpl::GetCaptureId() +{ + return captureId_; +} void PhotoImpl::ReleaseSync() { + mainImage_->ReleaseSync(); } } // namespace Camera } // namespace Ani \ No newline at end of file diff --git a/frameworks/taihe/src/query/camera_query_taihe.cpp b/frameworks/taihe/src/query/camera_query_taihe.cpp index 427c60e489d567559de2f483b1edf574f0e5cd3c..f65db4164450b836ab30632dadd7ae9d89aae23a 100644 --- a/frameworks/taihe/src/query/camera_query_taihe.cpp +++ b/frameworks/taihe/src/query/camera_query_taihe.cpp @@ -433,7 +433,7 @@ double FocusImpl::GetFocalLength() void FocusImpl::SetFocusMode(FocusMode afMode) { MEDIA_DEBUG_LOG("SetFocusMode is called"); - CHECK_ERROR_RETURN_LOG(captureSession_ == nullptr, "FlashImpl::SetFocusMode captureSession_ is null!"); + CHECK_ERROR_RETURN_LOG(captureSession_ == nullptr, "FocusImpl::SetFocusMode captureSession_ is null!"); captureSession_->LockForControl(); int retCode = captureSession_-> SetFocusMode(static_cast(afMode.get_value())); @@ -676,8 +676,8 @@ ExposureMeteringMode AutoExposureImpl::GetExposureMeteringMode() { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not SetExposureMeteringMode in current session!"); - ExposureMeteringMode meteringMode = static_cast(-1); - return meteringMode; + ExposureMeteringMode meteringMode = static_cast(-1); + return meteringMode; } double AutoExposureImpl::GetExposureValue() @@ -783,16 +783,16 @@ array ColorManagementQueryImpl::GetSupportedColorSpaces() uintptr_t ColorManagementImpl::GetActiveColorSpace() { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, -1, "GetActiveColorSpace captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, 0, "GetActiveColorSpace captureSession_ is null"); OHOS::CameraStandard::ColorSpace colorSpace; int32_t retCode = captureSession_->GetActiveColorSpace(colorSpace); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), -1); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), 0); ani_enum aniEnum {}; ani_enum_item aniEnumItem {}; ani_env* env = get_env(); - CHECK_ERROR_RETURN_RET_LOG(env == nullptr, -1, "GetActiveColorSpace env is null"); + CHECK_ERROR_RETURN_RET_LOG(env == nullptr, 0, "GetActiveColorSpace env is null"); CHECK_ERROR_RETURN_RET_LOG(ANI_OK != env->Enum_GetEnumItemByIndex( - aniEnum, reinterpret_cast(static_cast(colorSpace)), &aniEnumItem), -1, "Find Enum item Fail"); + aniEnum, reinterpret_cast(static_cast(colorSpace)), &aniEnumItem), 0, "Find Enum item Fail"); return reinterpret_cast(aniEnumItem); }