From 074da4bf98affb0a4cd9e16f5d42b833426f4b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=8B=B1=E7=BE=BD?= Date: Wed, 20 Aug 2025 07:01:50 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20fram?= =?UTF-8?q?eworks/native/ndk/impl/camera=5Fmanager=5Fimpl.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../native/ndk/impl/camera_manager_impl.cpp | 986 ------------------ 1 file changed, 986 deletions(-) delete mode 100644 frameworks/native/ndk/impl/camera_manager_impl.cpp diff --git a/frameworks/native/ndk/impl/camera_manager_impl.cpp b/frameworks/native/ndk/impl/camera_manager_impl.cpp deleted file mode 100644 index 83ec75cac..000000000 --- a/frameworks/native/ndk/impl/camera_manager_impl.cpp +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "camera_manager_impl.h" - -#include - -#include "camera_device.h" -#include "camera_log.h" -#include "camera_util.h" -#include "image_receiver.h" -#include "securec.h" -#include "surface_utils.h" - -using namespace std; -using namespace OHOS; -using namespace OHOS::CameraStandard; -const char* DEFAULT_SURFACEID = "photoOutput"; -thread_local OHOS::sptr Camera_Manager::photoSurface_ = nullptr; -NDKCallbackMap - Camera_Manager::cameraStatusCallbackMap_; - -NDKCallbackMap - Camera_Manager::cameraFoldStatusCallbackMap_; - -NDKCallbackMap - Camera_Manager::torchStatusCallbackMap_; - -const std::unordered_map g_fwModeToNdk_ = { - {SceneMode::CAPTURE, Camera_SceneMode::NORMAL_PHOTO}, - {SceneMode::VIDEO, Camera_SceneMode::NORMAL_VIDEO}, - {SceneMode::SECURE, Camera_SceneMode::SECURE_PHOTO}, -}; -const std::unordered_map g_ndkToFwMode_ = { - {Camera_SceneMode::NORMAL_PHOTO, SceneMode::CAPTURE}, - {Camera_SceneMode::NORMAL_VIDEO, SceneMode::VIDEO}, - {Camera_SceneMode::SECURE_PHOTO, SceneMode::SECURE}, -}; -const std::unordered_map g_FwkCameraPositionToNdk_ = { - {CameraPosition::CAMERA_POSITION_UNSPECIFIED, Camera_Position::CAMERA_POSITION_UNSPECIFIED}, - {CameraPosition::CAMERA_POSITION_BACK, Camera_Position::CAMERA_POSITION_BACK}, - {CameraPosition::CAMERA_POSITION_FRONT, Camera_Position::CAMERA_POSITION_FRONT}, -}; -const std::unordered_map g_NdkCameraPositionToFwk_ = { - {Camera_Position::CAMERA_POSITION_UNSPECIFIED, CameraPosition::CAMERA_POSITION_UNSPECIFIED}, - {Camera_Position::CAMERA_POSITION_BACK, CameraPosition::CAMERA_POSITION_BACK}, - {Camera_Position::CAMERA_POSITION_FRONT, CameraPosition::CAMERA_POSITION_FRONT}, -}; -const std::unordered_map g_ndkToFwTorchMode_ = { - {Camera_TorchMode::OFF, TorchMode::TORCH_MODE_OFF}, - {Camera_TorchMode::ON, TorchMode::TORCH_MODE_ON}, - {Camera_TorchMode::AUTO, TorchMode::TORCH_MODE_AUTO} -}; - -namespace OHOS::CameraStandard { -class InnerCameraManagerCameraStatusCallback : public CameraManagerCallback { -public: - InnerCameraManagerCameraStatusCallback(Camera_Manager* cameraManager, CameraManager_Callbacks* callback) - : cameraManager_(cameraManager), callback_(*callback) - {} - ~InnerCameraManagerCameraStatusCallback() {} - - void OnCameraStatusChanged(const CameraStatusInfo& cameraStatusInfo) const override - { - MEDIA_DEBUG_LOG("OnCameraStatusChanged is called!"); - Camera_StatusInfo statusInfo; - Camera_Device cameraDevice; - statusInfo.camera = &cameraDevice; - string cameraId = cameraStatusInfo.cameraDevice->GetID(); - statusInfo.camera->cameraId = cameraId.data(); - MEDIA_INFO_LOG("cameraId is %{public}s", statusInfo.camera->cameraId); - statusInfo.camera->cameraPosition = static_cast(cameraStatusInfo.cameraDevice->GetPosition()); - statusInfo.camera->cameraType = static_cast(cameraStatusInfo.cameraDevice->GetCameraType()); - statusInfo.camera->connectionType = - static_cast(cameraStatusInfo.cameraDevice->GetConnectionType()); - statusInfo.status = static_cast(cameraStatusInfo.cameraStatus); - CHECK_EXECUTE(cameraManager_ != nullptr && callback_.onCameraStatus != nullptr, - callback_.onCameraStatus(cameraManager_, &statusInfo)); - } - - void OnFlashlightStatusChanged(const std::string& cameraID, const FlashStatus flashStatus) const override - { - MEDIA_DEBUG_LOG("OnFlashlightStatusChanged is called!"); - (void)cameraID; - (void)flashStatus; - } - -private: - Camera_Manager* cameraManager_; - CameraManager_Callbacks callback_; -}; - -class InnerCameraManagerTorchStatusCallback : public TorchListener { -public: - InnerCameraManagerTorchStatusCallback( - Camera_Manager* cameraManager, OH_CameraManager_TorchStatusCallback torchStatusCallback) - : cameraManager_(cameraManager), torchStatusCallback_(torchStatusCallback) {}; - ~InnerCameraManagerTorchStatusCallback() = default; - - void OnTorchStatusChange(const TorchStatusInfo& torchStatusInfo) const override - { - MEDIA_DEBUG_LOG("OnTorchStatusChange is called!"); - if (cameraManager_ != nullptr && torchStatusCallback_ != nullptr) { - Camera_TorchStatusInfo statusInfo; - statusInfo.isTorchAvailable = torchStatusInfo.isTorchAvailable; - statusInfo.isTorchActive = torchStatusInfo.isTorchActive; - statusInfo.torchLevel = torchStatusInfo.torchLevel; - torchStatusCallback_(cameraManager_, &statusInfo); - } - } - -private: - Camera_Manager* cameraManager_; - OH_CameraManager_TorchStatusCallback torchStatusCallback_ = nullptr; -}; - -class InnerCameraManagerFoldStatusCallback : public FoldListener { -public: - InnerCameraManagerFoldStatusCallback( - Camera_Manager* cameraManager, OH_CameraManager_OnFoldStatusInfoChange foldStatusCallback) - : cameraManager_(cameraManager), foldStatusCallback_(foldStatusCallback) {}; - ~InnerCameraManagerFoldStatusCallback() = default; - - void OnFoldStatusChanged(const FoldStatusInfo& foldStatusInfo) const override - { - MEDIA_DEBUG_LOG("OnFoldStatusChanged is called!"); - if (cameraManager_ != nullptr && (foldStatusCallback_ != nullptr)) { - Camera_FoldStatusInfo statusInfo; - auto cameraSize = foldStatusInfo.supportedCameras.size(); - CHECK_RETURN_ELOG(cameraSize <= 0, "Invalid size."); - Camera_Device supportedCameras[cameraSize]; - Camera_Device* supportedCamerasPtr[cameraSize]; - uint32_t outSize = 0; - string cameraIds[cameraSize]; - for (size_t index = 0; index < cameraSize; index++) { - Camera_Device* cameraDevice = &supportedCameras[outSize]; - cameraDevice->cameraPosition = - static_cast(foldStatusInfo.supportedCameras[index]->GetPosition()); - cameraIds[outSize] = foldStatusInfo.supportedCameras[index]->GetID(); - cameraDevice->cameraId = cameraIds[outSize].data(); - cameraDevice->cameraType = - static_cast(foldStatusInfo.supportedCameras[index]->GetCameraType()); - cameraDevice->connectionType = - static_cast(foldStatusInfo.supportedCameras[index]->GetConnectionType()); - supportedCamerasPtr[outSize] = cameraDevice; - outSize++; - } - statusInfo.supportedCameras = supportedCamerasPtr; - statusInfo.cameraSize = outSize; - statusInfo.foldStatus = (Camera_FoldStatus)foldStatusInfo.foldStatus; - foldStatusCallback_(cameraManager_, &statusInfo); - } - } - -private: - Camera_Manager* cameraManager_; - OH_CameraManager_OnFoldStatusInfoChange foldStatusCallback_ = nullptr; -}; -} // namespace OHOS::CameraStandard - -Camera_Manager::Camera_Manager() -{ - MEDIA_DEBUG_LOG("Camera_Manager Constructor is called"); - cameraManager_ = CameraManager::GetInstance(); -} - -Camera_Manager::~Camera_Manager() -{ - MEDIA_DEBUG_LOG("~Camera_Manager is called"); - CHECK_RETURN(!cameraManager_); - cameraManager_ = nullptr; -} - -Camera_ErrorCode Camera_Manager::RegisterCallback(CameraManager_Callbacks* cameraStatusCallback) -{ - auto innerCallback = make_shared(this, cameraStatusCallback); - if (cameraStatusCallbackMap_.SetMapValue(cameraStatusCallback, innerCallback)) { - cameraManager_->RegisterCameraStatusCallback(innerCallback); - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::UnregisterCallback(CameraManager_Callbacks* cameraStatusCallback) -{ - auto callback = cameraStatusCallbackMap_.RemoveValue(cameraStatusCallback); - if (callback != nullptr) { - cameraManager_->UnregisterCameraStatusCallback(callback); - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::RegisterTorchStatusCallback(OH_CameraManager_TorchStatusCallback torchStatusCallback) -{ - auto innerTorchStatusCallback = make_shared(this, torchStatusCallback); - if (torchStatusCallbackMap_.SetMapValue(torchStatusCallback, innerTorchStatusCallback)) { - cameraManager_->RegisterTorchListener(innerTorchStatusCallback); - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::UnregisterTorchStatusCallback(OH_CameraManager_TorchStatusCallback torchStatusCallback) -{ - auto callback = torchStatusCallbackMap_.RemoveValue(torchStatusCallback); - if (callback != nullptr) { - cameraManager_->UnregisterTorchListener(callback); - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedCameras(Camera_Device** cameras, uint32_t* size) -{ - std::vector> cameraObjList = CameraManager::GetInstance()->GetSupportedCameras(); - uint32_t cameraSize = cameraObjList.size(); - uint32_t cameraMaxSize = 32; - CHECK_RETURN_RET_ELOG(cameraSize == 0 || cameraSize > cameraMaxSize, CAMERA_INVALID_ARGUMENT, - "Invalid camera size."); - Camera_Device* outCameras = new Camera_Device[cameraSize]; - for (size_t index = 0; index < cameraSize; index++) { - const string cameraGetID = cameraObjList[index]->GetID(); - size_t dstSize = cameraGetID.size() + 1; - char* dst = new char[dstSize]; - if (!dst) { - MEDIA_ERR_LOG("Allocate memory for cameraId Failed!"); - for (size_t i = 0; i < index; ++i) { - delete[] outCameras[index].cameraId; - } - delete[] dst; - delete[] outCameras; - return CAMERA_SERVICE_FATAL_ERROR; - } - strlcpy(dst, cameraGetID.c_str(), dstSize); - outCameras[index].cameraId = dst; - outCameras[index].cameraPosition = static_cast(cameraObjList[index]->GetPosition()); - outCameras[index].cameraType = static_cast(cameraObjList[index]->GetCameraType()); - outCameras[index].connectionType = static_cast(cameraObjList[index]->GetConnectionType()); - } - *size = cameraSize; - *cameras = outCameras; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::DeleteSupportedCameras(Camera_Device* cameras, uint32_t size) -{ - if (cameras != nullptr) { - for (size_t index = 0; index < size; index++) { - if (&cameras[index] != nullptr) { - delete[] cameras[index].cameraId; - } - } - delete[] cameras; - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedCameraOutputCapability(const Camera_Device* camera, - Camera_OutputCapability** cameraOutputCapability) -{ - sptr cameraDevice = CameraManager::GetInstance()->GetCameraDeviceFromId(camera->cameraId); - CHECK_RETURN_RET_ELOG(cameraDevice == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::GetSupportedCameraOutputCapability get cameraDevice fail!"); - Camera_OutputCapability* outCapability = new Camera_OutputCapability; - CHECK_RETURN_RET_ELOG(outCapability == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::GetSupportedCameraOutputCapability failed to allocate memory for outCapability!"); - - sptr innerCameraOutputCapability = - CameraManager::GetInstance()->GetSupportedOutputCapability(cameraDevice); - if (innerCameraOutputCapability == nullptr) { - MEDIA_ERR_LOG("Camera_Manager::GetSupportedCameraOutputCapability innerCameraOutputCapability is null!"); - delete outCapability; - return CAMERA_INVALID_ARGUMENT; - } - std::vector previewProfiles = innerCameraOutputCapability->GetPreviewProfiles(); - std::vector photoProfiles = innerCameraOutputCapability->GetPhotoProfiles(); - std::vector videoProfiles = innerCameraOutputCapability->GetVideoProfiles(); - - std::vector metadataTypeList = innerCameraOutputCapability->GetSupportedMetadataObjectType(); - - std::vector uniquePreviewProfiles; - for (const auto& profile : previewProfiles) { - if (std::find(uniquePreviewProfiles.begin(), uniquePreviewProfiles.end(), - profile) == uniquePreviewProfiles.end()) { - uniquePreviewProfiles.push_back(profile); - } - } - GetSupportedPreviewProfiles(outCapability, uniquePreviewProfiles); - GetSupportedPhotoProfiles(outCapability, photoProfiles); - GetSupportedVideoProfiles(outCapability, videoProfiles); - GetSupportedMetadataTypeList(outCapability, metadataTypeList); - - *cameraOutputCapability = outCapability; - MEDIA_INFO_LOG("GetSupportedCameraOutputCapability success."); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedPreviewProfiles(Camera_OutputCapability* outCapability, - std::vector &previewProfiles) -{ - outCapability->previewProfilesSize = previewProfiles.size(); - if (previewProfiles.size() == 0) { - MEDIA_ERR_LOG("Invalid preview profiles size."); - outCapability->previewProfiles = nullptr; - return CAMERA_INVALID_ARGUMENT; - } - outCapability->previewProfiles = new Camera_Profile* [previewProfiles.size()]; - CHECK_PRINT_ELOG(!outCapability->previewProfiles, "Failed to allocate memory for preview profiles"); - MEDIA_DEBUG_LOG("GetSupportedCameraOutputCapability previewOutput size enter"); - for (size_t index = 0; index < previewProfiles.size(); index++) { - Camera_Profile* outPreviewProfile = new Camera_Profile; - CHECK_PRINT_ELOG(!outPreviewProfile, "Failed to allocate memory for PreviewProfile"); - outPreviewProfile->format = static_cast(previewProfiles[index].GetCameraFormat()); - outPreviewProfile->size.width = previewProfiles[index].GetSize().width; - outPreviewProfile->size.height = previewProfiles[index].GetSize().height; - outCapability->previewProfiles[index] = outPreviewProfile; - } - MEDIA_DEBUG_LOG("GetSupportedCameraOutputCapability previewOutput size exit"); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedPhotoProfiles(Camera_OutputCapability* outCapability, - std::vector &photoProfiles) -{ - outCapability->photoProfilesSize = photoProfiles.size(); - if (photoProfiles.size() == 0) { - MEDIA_ERR_LOG("Invalid photo profiles size."); - outCapability->photoProfiles = nullptr; - return CAMERA_INVALID_ARGUMENT; - } - outCapability->photoProfiles = new Camera_Profile* [photoProfiles.size()]; - CHECK_PRINT_ELOG(!outCapability->photoProfiles, "Failed to allocate memory for photo profiles"); - for (size_t index = 0; index < photoProfiles.size(); index++) { - Camera_Profile* outPhotoProfile = new Camera_Profile; - CHECK_PRINT_ELOG(!outPhotoProfile, "Failed to allocate memory for PhotoProfile"); - outPhotoProfile->format = static_cast(photoProfiles[index].GetCameraFormat()); - outPhotoProfile->size.width = photoProfiles[index].GetSize().width; - outPhotoProfile->size.height = photoProfiles[index].GetSize().height; - outCapability->photoProfiles[index] = outPhotoProfile; - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedVideoProfiles(Camera_OutputCapability* outCapability, - std::vector &videoProfiles) -{ - outCapability->videoProfilesSize = videoProfiles.size(); - if (videoProfiles.size() == 0) { - MEDIA_ERR_LOG("Invalid video profiles size."); - outCapability->videoProfiles = nullptr; - return CAMERA_INVALID_ARGUMENT; - } - outCapability->videoProfiles = new Camera_VideoProfile* [videoProfiles.size()]; - CHECK_PRINT_ELOG(!outCapability->videoProfiles, "Failed to allocate memory for video profiles"); - for (size_t index = 0; index < videoProfiles.size(); index++) { - Camera_VideoProfile* outVideoProfile = new Camera_VideoProfile; - CHECK_PRINT_ELOG(!outVideoProfile, "Failed to allocate memory for VideoProfile"); - outVideoProfile->format = static_cast(videoProfiles[index].GetCameraFormat()); - outVideoProfile->size.width = videoProfiles[index].GetSize().width; - outVideoProfile->size.height = videoProfiles[index].GetSize().height; - outVideoProfile->range.min = static_cast(videoProfiles[index].framerates_[0]); - outVideoProfile->range.max = static_cast(videoProfiles[index].framerates_[1]); - outCapability->videoProfiles[index] = outVideoProfile; - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedMetadataTypeList(Camera_OutputCapability* outCapability, - std::vector &metadataTypeList) -{ - outCapability->metadataProfilesSize = metadataTypeList.size(); - if (metadataTypeList.size() == 0) { - MEDIA_ERR_LOG("Invalid metadata type size."); - outCapability->supportedMetadataObjectTypes = nullptr; - return CAMERA_INVALID_ARGUMENT; - } - outCapability->supportedMetadataObjectTypes = new Camera_MetadataObjectType* [metadataTypeList.size()]; - CHECK_PRINT_ELOG(!outCapability->supportedMetadataObjectTypes, - "Failed to allocate memory for supportedMetadataObjectTypes"); - for (size_t index = 0; index < metadataTypeList.size(); index++) { - Camera_MetadataObjectType* outmetadataObject = new Camera_MetadataObjectType {}; - *outmetadataObject = static_cast(metadataTypeList[index]); - outCapability->supportedMetadataObjectTypes[index] = outmetadataObject; - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedCameraOutputCapabilityWithSceneMode(const Camera_Device* camera, - Camera_SceneMode sceneMode, Camera_OutputCapability** cameraOutputCapability) -{ - sptr cameraDevice = CameraManager::GetInstance()->GetCameraDeviceFromId(camera->cameraId); - CHECK_RETURN_RET_ELOG(cameraDevice == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::GetSupportedCameraOutputCapabilityWithSceneMode get cameraDevice fail!"); - - auto itr = g_ndkToFwMode_.find(static_cast(sceneMode)); - CHECK_RETURN_RET_ELOG(itr == g_ndkToFwMode_.end(), CAMERA_INVALID_ARGUMENT, - "Camera_Manager::GetSupportedCameraOutputCapabilityWithSceneMode " - "sceneMode = %{public}d not supported!", sceneMode); - - SceneMode innerSceneMode = static_cast(itr->second); - sptr innerCameraOutputCapability = - CameraManager::GetInstance()->GetSupportedOutputCapability(cameraDevice, innerSceneMode); - CHECK_RETURN_RET_ELOG(innerCameraOutputCapability == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::GetSupportedCameraOutputCapabilityWithSceneMode innerCameraOutputCapability is null!"); - - Camera_OutputCapability* outCapability = new Camera_OutputCapability; - CHECK_RETURN_RET_ELOG(outCapability == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::GetSupportedCameraOutputCapabilityWithSceneMode failed to allocate memory for outCapability!"); - std::vector previewProfiles = innerCameraOutputCapability->GetPreviewProfiles(); - std::vector uniquePreviewProfiles; - for (const auto& profile : previewProfiles) { - if (std::find(uniquePreviewProfiles.begin(), uniquePreviewProfiles.end(), - profile) == uniquePreviewProfiles.end()) { - uniquePreviewProfiles.push_back(profile); - } - } - std::vector photoProfiles = innerCameraOutputCapability->GetPhotoProfiles(); - std::vector videoProfiles = innerCameraOutputCapability->GetVideoProfiles(); - std::vector metadataTypeList = - innerCameraOutputCapability->GetSupportedMetadataObjectType(); - GetSupportedPreviewProfiles(outCapability, uniquePreviewProfiles); - GetSupportedPhotoProfiles(outCapability, photoProfiles); - GetSupportedVideoProfiles(outCapability, videoProfiles); - GetSupportedMetadataTypeList(outCapability, metadataTypeList); - *cameraOutputCapability = outCapability; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::DeleteSupportedCameraOutputCapability(Camera_OutputCapability* cameraOutputCapability) -{ - CHECK_RETURN_RET_ELOG(cameraOutputCapability == nullptr, CAMERA_OK, - "Camera_Manager::DeleteSupportedCameraOutputCapability cameraOutputCapability is nullptr"); - - if (cameraOutputCapability->previewProfiles != nullptr) { - for (size_t index = 0; index < cameraOutputCapability->previewProfilesSize; index++) { - if (cameraOutputCapability->previewProfiles[index] != nullptr) { - delete cameraOutputCapability->previewProfiles[index]; - } - } - delete[] cameraOutputCapability->previewProfiles; - } - - if (cameraOutputCapability->photoProfiles != nullptr) { - for (size_t index = 0; index < cameraOutputCapability->photoProfilesSize; index++) { - if (cameraOutputCapability->photoProfiles[index] != nullptr) { - delete cameraOutputCapability->photoProfiles[index]; - } - } - delete[] cameraOutputCapability->photoProfiles; - } - - if (cameraOutputCapability->videoProfiles != nullptr) { - for (size_t index = 0; index < cameraOutputCapability->videoProfilesSize; index++) { - if (cameraOutputCapability->videoProfiles[index] != nullptr) { - delete cameraOutputCapability->videoProfiles[index]; - } - } - delete[] cameraOutputCapability->videoProfiles; - } - - if (cameraOutputCapability->supportedMetadataObjectTypes != nullptr) { - for (size_t index = 0; index < cameraOutputCapability->metadataProfilesSize; index++) { - if (cameraOutputCapability->supportedMetadataObjectTypes[index] != nullptr) { - delete cameraOutputCapability->supportedMetadataObjectTypes[index]; - } - } - delete[] cameraOutputCapability->supportedMetadataObjectTypes; - } - delete cameraOutputCapability; - return CAMERA_OK; -} -Camera_ErrorCode Camera_Manager::IsCameraMuted(bool* isCameraMuted) -{ - MEDIA_ERR_LOG("Camera_Manager IsCameraMuted is called"); - *isCameraMuted = CameraManager::GetInstance()->IsCameraMuted(); - MEDIA_ERR_LOG("IsCameraMuted is %{public}d", *isCameraMuted); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreateCaptureSession(Camera_CaptureSession** captureSession) -{ - sptr innerCaptureSession = CameraManager::GetInstance()->CreateCaptureSession(SceneMode::NORMAL); - CHECK_RETURN_RET_ELOG(innerCaptureSession == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::CreateCaptureSession create innerCaptureSession fail!"); - Camera_CaptureSession* outSession = new Camera_CaptureSession(innerCaptureSession); - *captureSession = outSession; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreateCameraInput(const Camera_Device* camera, Camera_Input** cameraInput) -{ - MEDIA_INFO_LOG("CameraId is: %{public}s", camera->cameraId); - sptr cameraDevice = CameraManager::GetInstance()->GetCameraDeviceFromId(camera->cameraId); - CHECK_RETURN_RET_ELOG(cameraDevice == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::CreateCameraInput get cameraDevice fail!"); - - sptr innerCameraInput = nullptr; - int32_t retCode = CameraManager::GetInstance()->CreateCameraInput(cameraDevice, &innerCameraInput); - CHECK_RETURN_RET(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR); - Camera_Input* outInput = new Camera_Input(innerCameraInput); - *cameraInput = outInput; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreateCameraInputWithPositionAndType(Camera_Position position, Camera_Type type, - Camera_Input** cameraInput) -{ - MEDIA_ERR_LOG("Camera_Manager CreateCameraInputWithPositionAndType is called"); - sptr innerCameraInput = nullptr; - CameraPosition innerPosition = CameraPosition::CAMERA_POSITION_UNSPECIFIED; - auto itr = g_NdkCameraPositionToFwk_.find(position); - CHECK_RETURN_RET_ELOG(itr == g_NdkCameraPositionToFwk_.end(), CAMERA_INVALID_ARGUMENT, - "Camera_Manager::CreateCameraInputWithPositionAndType innerPosition not found!"); - innerPosition = itr->second; - CameraType innerType = static_cast(type); - - innerCameraInput = CameraManager::GetInstance()->CreateCameraInput(innerPosition, innerType); - CHECK_RETURN_RET_ELOG(innerCameraInput == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Failed to CreateCameraInputWithPositionAndType"); - - Camera_Input* outInput = new Camera_Input(innerCameraInput); - *cameraInput = outInput; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreatePreviewOutput(const Camera_Profile* profile, - const char* surfaceId, Camera_PreviewOutput** previewOutput) -{ - sptr innerPreviewOutput = nullptr; - Size size; - size.width = profile->size.width; - size.height = profile->size.height; - Profile innerProfile(static_cast(profile->format), size); - - uint64_t iSurfaceId; - std::istringstream iss(surfaceId); - iss >> iSurfaceId; - sptr surface = SurfaceUtils::GetInstance()->GetSurface(iSurfaceId); - surface = surface == nullptr ? Media::ImageReceiver::getSurfaceById(surfaceId) : surface; - CHECK_RETURN_RET_ELOG(surface == nullptr, CAMERA_INVALID_ARGUMENT, "Failed to get previewOutput surface"); - - surface->SetUserData(CameraManager::surfaceFormat, std::to_string(innerProfile.GetCameraFormat())); - int32_t retCode = CameraManager::GetInstance()->CreatePreviewOutput(innerProfile, surface, &innerPreviewOutput); - CHECK_RETURN_RET(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR); - Camera_PreviewOutput* out = new Camera_PreviewOutput(innerPreviewOutput); - *previewOutput = out; - MEDIA_ERR_LOG("Camera_Manager::CreatePreviewOutput"); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreatePreviewOutputUsedInPreconfig(const char* surfaceId, - Camera_PreviewOutput** previewOutput) -{ - sptr innerPreviewOutput = nullptr; - uint64_t iSurfaceId; - std::istringstream iss(surfaceId); - iss >> iSurfaceId; - sptr surface = SurfaceUtils::GetInstance()->GetSurface(iSurfaceId); - surface = surface == nullptr ? Media::ImageReceiver::getSurfaceById(surfaceId) : surface; - CHECK_RETURN_RET_ELOG(surface == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::CreatePreviewOutputUsedInPreconfig get previewOutput surface fail!"); - int32_t retCode = CameraManager::GetInstance()->CreatePreviewOutputWithoutProfile(surface, &innerPreviewOutput); - CHECK_RETURN_RET_ELOG(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::CreatePreviewOutputUsedInPreconfig create innerPreviewOutput fail!"); - CHECK_RETURN_RET_ELOG(innerPreviewOutput == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::CreatePreviewOutputUsedInPreconfig create innerPreviewOutput fail!"); - Camera_PreviewOutput* out = new Camera_PreviewOutput(innerPreviewOutput); - *previewOutput = out; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreatePhotoOutput(const Camera_Profile* profile, - const char* surfaceId, Camera_PhotoOutput** photoOutput) -{ - sptr innerPhotoOutput = nullptr; - Size size; - size.width = profile->size.width; - size.height = profile->size.height; - Profile innerProfile(static_cast(profile->format), size); - sptr surface = Media::ImageReceiver::getSurfaceById(surfaceId); - CHECK_RETURN_RET_ELOG(surface == nullptr, CAMERA_INVALID_ARGUMENT, "Failed to get photoOutput surface"); - surface->SetUserData(CameraManager::surfaceFormat, std::to_string(innerProfile.GetCameraFormat())); - sptr surfaceProducer = surface->GetProducer(); - int32_t retCode = - CameraManager::GetInstance()->CreatePhotoOutput(innerProfile, surfaceProducer, &innerPhotoOutput, surface); - CHECK_RETURN_RET(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR); - Camera_PhotoOutput* out = new Camera_PhotoOutput(innerPhotoOutput); - *photoOutput = out; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreatePhotoOutputWithoutSurface(const Camera_Profile* profile, - Camera_PhotoOutput** photoOutput) -{ - sptr innerPhotoOutput = nullptr; - Size size; - size.width = profile->size.width; - size.height = profile->size.height; - Profile innerProfile(static_cast(profile->format), size); - int32_t retCode = CameraManager::GetInstance()->CreatePhotoOutput(innerProfile, &innerPhotoOutput); - CHECK_RETURN_RET_ELOG((retCode != CameraErrorCode::SUCCESS || innerPhotoOutput == nullptr), - CAMERA_SERVICE_FATAL_ERROR, "Create photo output failed"); - - innerPhotoOutput->SetNativeSurface(true); - Camera_PhotoOutput* out = new Camera_PhotoOutput(innerPhotoOutput); - CHECK_RETURN_RET_ELOG(out == nullptr, CAMERA_SERVICE_FATAL_ERROR, "Create Camera_PhotoOutput failed"); - *photoOutput = out; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreatePhotoOutputUsedInPreconfig(const char* surfaceId, - Camera_PhotoOutput** photoOutput) -{ - sptr innerPhotoOutput = nullptr; - int32_t retCode = CAMERA_OK; - if (strcmp(surfaceId, "")) { - sptr surface = Media::ImageReceiver::getSurfaceById(surfaceId); - CHECK_RETURN_RET_ELOG(surface == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::CreatePhotoOutputUsedInPreconfig get photoOutput surface fail!"); - sptr surfaceProducer = surface->GetProducer(); - CHECK_RETURN_RET_ELOG(surfaceProducer == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::CreatePhotoOutputUsedInPreconfig get surfaceProducer fail!"); - retCode = - CameraManager::GetInstance()->CreatePhotoOutputWithoutProfile(surfaceProducer, &innerPhotoOutput); - } else { - retCode = CameraManager::GetInstance()->CreatePhotoOutputWithoutProfile(&innerPhotoOutput); - } - CHECK_RETURN_RET_ELOG(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::CreatePhotoOutputUsedInPreconfig create innerPhotoOutput fail!"); - CHECK_RETURN_RET_ELOG(innerPhotoOutput == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::CreatePhotoOutputUsedInPreconfig create innerPhotoOutput fail!"); - Camera_PhotoOutput* out = new Camera_PhotoOutput(innerPhotoOutput); - *photoOutput = out; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreateVideoOutput(const Camera_VideoProfile* profile, - const char* surfaceId, Camera_VideoOutput** videoOutput) -{ - sptr innerVideoOutput = nullptr; - Size size; - size.width = profile->size.width; - size.height = profile->size.height; - std::vector framerates = {profile->range.min, profile->range.max}; - VideoProfile innerProfile(static_cast(profile->format), size, framerates); - - uint64_t iSurfaceId; - std::istringstream iss(surfaceId); - iss >> iSurfaceId; - sptr surface = SurfaceUtils::GetInstance()->GetSurface(iSurfaceId); - surface = surface == nullptr ? Media::ImageReceiver::getSurfaceById(surfaceId) : surface; - CHECK_RETURN_RET_ELOG(surface == nullptr, CAMERA_INVALID_ARGUMENT, "Failed to get videoOutput surface"); - - surface->SetUserData(CameraManager::surfaceFormat, std::to_string(innerProfile.GetCameraFormat())); - int32_t retCode = CameraManager::GetInstance()->CreateVideoOutput(innerProfile, surface, &innerVideoOutput); - CHECK_RETURN_RET(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR); - Camera_VideoOutput* out = new Camera_VideoOutput(innerVideoOutput); - *videoOutput = out; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreateVideoOutputUsedInPreconfig(const char* surfaceId, - Camera_VideoOutput** videoOutput) -{ - sptr innerVideoOutput = nullptr; - uint64_t iSurfaceId; - std::istringstream iss(surfaceId); - iss >> iSurfaceId; - sptr surface = SurfaceUtils::GetInstance()->GetSurface(iSurfaceId); - CHECK_RETURN_RET_ELOG(surface == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::CreateVideoOutputUsedInPreconfig get videoOutput surface fail!"); - int32_t retCode = CameraManager::GetInstance()->CreateVideoOutputWithoutProfile(surface, &innerVideoOutput); - CHECK_RETURN_RET_ELOG(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::CreateVideoOutputUsedInPreconfig create innerVideoOutput fail!"); - CHECK_RETURN_RET_ELOG(innerVideoOutput == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::CreateVideoOutputUsedInPreconfig create innerVideoOutput fail!"); - Camera_VideoOutput* out = new Camera_VideoOutput(innerVideoOutput); - *videoOutput = out; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::CreateMetadataOutput(const Camera_MetadataObjectType* type, - Camera_MetadataOutput** metadataOutput) -{ - MEDIA_ERR_LOG("Camera_Manager CreateMetadataOutput is called"); - sptr innerMetadataOutput = nullptr; - vector metadataObjectTypes = { MetadataObjectType::FACE }; - int32_t retCode = CameraManager::GetInstance()->CreateMetadataOutput(innerMetadataOutput, metadataObjectTypes); - CHECK_RETURN_RET(retCode != CameraErrorCode::SUCCESS, CAMERA_SERVICE_FATAL_ERROR); - Camera_MetadataOutput* out = new Camera_MetadataOutput(innerMetadataOutput); - *metadataOutput = out; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetCameraOrientation(Camera_Device* camera, uint32_t* orientation) -{ - sptr cameraDevice = nullptr; - std::vector> cameraObjList = CameraManager::GetInstance()->GetSupportedCameras(); - MEDIA_DEBUG_LOG("the cameraObjList size is %{public}zu", - cameraObjList.size()); - for (size_t index = 0; index < cameraObjList.size(); index++) { - sptr innerCameraDevice = cameraObjList[index]; - bool isCameraMatched = innerCameraDevice != nullptr && innerCameraDevice->GetID() == camera->cameraId; - if (isCameraMatched) { - cameraDevice = innerCameraDevice; - break; - } - } - - CHECK_RETURN_RET(cameraDevice == nullptr, CAMERA_SERVICE_FATAL_ERROR); - *orientation = cameraDevice->GetCameraOrientation(); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetHostDeviceName(Camera_Device* camera, char** hostDeviceName) -{ - CameraDevice* device = nullptr; - auto cameras = CameraManager::GetInstance()->GetSupportedCameras(); - MEDIA_DEBUG_LOG("the cameraObjList size is %{public}zu", cameras.size()); - for (auto& innerCamera : cameras) { - if (innerCamera->GetID() == std::string(camera->cameraId)) { - device = innerCamera; - break; - } - } - - CHECK_RETURN_RET(device == nullptr, CAMERA_SERVICE_FATAL_ERROR); - std::string deviceName = device->GetHostName(); - *hostDeviceName = (char*)malloc(deviceName.size() + 1); - if (memcpy_s(*hostDeviceName, deviceName.size() + 1, deviceName.c_str(), deviceName.size()) != EOK) { - free(*hostDeviceName); - *hostDeviceName = nullptr; - return CAMERA_SERVICE_FATAL_ERROR; - } - (*hostDeviceName)[deviceName.size()] = '\0'; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetHostDeviceType(Camera_Device* camera, Camera_HostDeviceType* hostDeviceType) -{ - CameraDevice* device = nullptr; - auto cameras = CameraManager::GetInstance()->GetSupportedCameras(); - MEDIA_DEBUG_LOG("the cameraObjList size is %{public}zu", cameras.size()); - for (auto& innerCamera : cameras) { - if (innerCamera->GetID() == std::string(camera->cameraId)) { - device = innerCamera; - break; - } - } - - CHECK_RETURN_RET(device == nullptr, CAMERA_SERVICE_FATAL_ERROR); - switch (device->GetDeviceType()) { - case Camera_HostDeviceType::HOST_DEVICE_TYPE_PHONE: - *hostDeviceType = Camera_HostDeviceType::HOST_DEVICE_TYPE_PHONE; - break; - case Camera_HostDeviceType::HOST_DEVICE_TYPE_TABLET: - *hostDeviceType = Camera_HostDeviceType::HOST_DEVICE_TYPE_TABLET; - break; - default: - *hostDeviceType = Camera_HostDeviceType::HOST_DEVICE_TYPE_UNKNOWN_TYPE; - break; - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetSupportedSceneModes(Camera_Device* camera, - Camera_SceneMode** sceneModes, uint32_t* size) -{ - sptr cameraDevice = CameraManager::GetInstance()->GetCameraDeviceFromId(camera->cameraId); - CHECK_RETURN_RET_ELOG(cameraDevice == nullptr, CAMERA_INVALID_ARGUMENT, - "Camera_Manager::GetSupportedSceneModes get cameraDevice fail!"); - - std::vector innerSceneMode = CameraManager::GetInstance()->GetSupportedModes(cameraDevice); - for (auto it = innerSceneMode.begin(); it != innerSceneMode.end(); it++) { - if (*it == SCAN) { - innerSceneMode.erase(it); - break; - } - } - if (innerSceneMode.empty()) { - innerSceneMode.emplace_back(CAPTURE); - innerSceneMode.emplace_back(VIDEO); - } - MEDIA_INFO_LOG("Camera_Manager::GetSupportedSceneModes size = [%{public}zu]", innerSceneMode.size()); - - std::vector cameraSceneMode; - for (size_t index = 0; index < innerSceneMode.size(); index++) { - auto itr = g_fwModeToNdk_.find(static_cast(innerSceneMode[index])); - CHECK_EXECUTE(itr != g_fwModeToNdk_.end(), - cameraSceneMode.push_back(static_cast(itr->second))); - } - - Camera_SceneMode* sceneMode = new Camera_SceneMode[cameraSceneMode.size()]; - CHECK_RETURN_RET_ELOG(sceneMode == nullptr, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::GetSupportedSceneModes allocate memory for sceneMode fail!"); - for (size_t index = 0; index < cameraSceneMode.size(); index++) { - sceneMode[index] = cameraSceneMode[index]; - } - - *sceneModes = sceneMode; - *size = cameraSceneMode.size(); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::DeleteSceneModes(Camera_SceneMode* sceneModes) -{ - delete[] sceneModes; - sceneModes = nullptr; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::IsTorchSupported(bool* isTorchSupported) -{ - MEDIA_DEBUG_LOG("Camera_Manager::IsTorchSupported is called"); - - *isTorchSupported = CameraManager::GetInstance()->IsTorchSupported(); - MEDIA_DEBUG_LOG("IsTorchSupported[%{public}d]", *isTorchSupported); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::IsTorchSupportedByTorchMode(Camera_TorchMode torchMode, bool* isTorchSupported) -{ - MEDIA_DEBUG_LOG("Camera_Manager::IsTorchSupportedByTorchMode is called"); - - auto itr = g_ndkToFwTorchMode_.find(torchMode); - CHECK_RETURN_RET_ELOG(itr == g_ndkToFwTorchMode_.end(), CAMERA_INVALID_ARGUMENT, - "torchMode[%{public}d] is invalid", torchMode); - *isTorchSupported = CameraManager::GetInstance()->IsTorchModeSupported(itr->second); - MEDIA_DEBUG_LOG("IsTorchSupportedByTorchMode[%{public}d]", *isTorchSupported); - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::SetTorchMode(Camera_TorchMode torchMode) -{ - MEDIA_DEBUG_LOG("Camera_Manager::SetTorchMode is called"); - - auto itr = g_ndkToFwTorchMode_.find(torchMode); - CHECK_RETURN_RET_ELOG(itr == g_ndkToFwTorchMode_.end(), CAMERA_INVALID_ARGUMENT, - "torchMode[%{public}d] is invalid", torchMode); - int32_t ret = CameraManager::GetInstance()->SetTorchMode(itr->second); - return FrameworkToNdkCameraError(ret); -} - -Camera_ErrorCode Camera_Manager::GetCameraDevice(Camera_Position position, Camera_Type type, Camera_Device *camera) -{ - MEDIA_DEBUG_LOG("Camera_Manager::GetCameraDevice is called"); - - CameraPosition innerPosition = CameraPosition::CAMERA_POSITION_UNSPECIFIED; - auto itr = g_NdkCameraPositionToFwk_.find(position); - CHECK_RETURN_RET_ELOG(itr == g_NdkCameraPositionToFwk_.end(), CAMERA_INVALID_ARGUMENT, - "Camera_Manager::CreateCameraInputWithPositionAndType innerPosition not found!"); - innerPosition = itr->second; - - CameraType innerType = static_cast(type); - - sptr cameraInfo = nullptr; - std::vector> cameraObjList = CameraManager::GetInstance()->GetSupportedCameras(); - CHECK_RETURN_RET_ELOG(cameraObjList.size() == 0, CAMERA_SERVICE_FATAL_ERROR, - "Camera_Manager::GetSupportedCameras fail!"); - for (size_t i = 0; i < cameraObjList.size(); i++) { - sptr cameraDevice = cameraObjList[i]; - bool isFindCameraDevice = cameraDevice != nullptr && cameraDevice->GetPosition() == innerPosition - && cameraDevice->GetCameraType() == innerType; - if (isFindCameraDevice) { - cameraInfo = cameraDevice; - break; - } - } - - CHECK_RETURN_RET_ELOG( - cameraInfo == nullptr, CAMERA_SERVICE_FATAL_ERROR, "Camera_Manager::GetCameraDevice cameraInfo is null!"); - Camera_Device* outCameras = new Camera_Device; - outCameras->cameraId = cameraInfo->GetID().data(); - outCameras->cameraPosition = position; - outCameras->cameraType = type; - outCameras->connectionType = static_cast(cameraInfo->GetConnectionType()); - camera = outCameras; - outCameras = nullptr; - - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::GetCameraConcurrentInfos(const Camera_Device *camera, uint32_t deviceSize, - Camera_ConcurrentInfo **CameraConcurrentInfo, uint32_t *infoSize) -{ - MEDIA_DEBUG_LOG("Camera_Manager::GetCameraConcurrentInfos is called"); - std::vectorcameraIdv = {}; - std::vector cameraConcurrentType = {}; - std::vector> modes = {}; - std::vector>> outputCapabilities = {}; - vector> cameraDeviceArrray = {}; - for (uint32_t i = 0; i < deviceSize; i++) { - string str(camera[i].cameraId); - cameraIdv.push_back(str); - } - for (auto cameraidonly : cameraIdv) { - cameraDeviceArrray.push_back(CameraManager::GetInstance()->GetCameraDeviceFromId(cameraidonly)); - } - bool issupported = CameraManager::GetInstance()->GetConcurrentType(cameraDeviceArrray, cameraConcurrentType); - CHECK_RETURN_RET_ELOG(!issupported, CAMERA_SERVICE_FATAL_ERROR, - "CamagerManager::GetCameraConcurrentInfos GetConcurrentType not supported"); - issupported = CameraManager::GetInstance()->CheckConcurrentExecution(cameraDeviceArrray); - CHECK_RETURN_RET_ELOG(!issupported, CAMERA_SERVICE_FATAL_ERROR, - "CamagerManager::GetCameraConcurrentInfos CheckConcurrentExe not supported"); - CameraManager::GetInstance()->GetCameraConcurrentInfos(cameraDeviceArrray, - cameraConcurrentType, modes, outputCapabilities); - Camera_ConcurrentInfo *CameraConcurrentInfothis = new Camera_ConcurrentInfo[deviceSize]; - SetCameraConcurrentInfothis(camera, deviceSize, CameraConcurrentInfothis, cameraConcurrentType, modes, - outputCapabilities); - *CameraConcurrentInfo = CameraConcurrentInfothis; - *infoSize = deviceSize; - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::SetCameraConcurrentInfothis(const Camera_Device *camera, uint32_t deviceSize, - Camera_ConcurrentInfo *CameraConcurrentInfothis, - std::vector &cameraConcurrentType, std::vector> &modes, - std::vector>> &outputCapabilities) -{ - for (int i = 0; i < deviceSize; i++) { - CameraConcurrentInfothis[i].camera = camera[i]; - if (cameraConcurrentType[i] == false) { - CameraConcurrentInfothis[i].type = CONCURRENT_TYPE_LIMITED_CAPABILITY; - } else { - CameraConcurrentInfothis[i].type = CONCURRENT_TYPE_FULL_CAPABILITY; - } - Camera_SceneMode* newmodes = new Camera_SceneMode[modes.size()]; - for (uint32_t j = 0; j < modes[i].size(); j++) { - auto itr = g_fwModeToNdk_.find(modes[i][j]); - newmodes[j] = itr->second; - } - CameraConcurrentInfothis[i].sceneModes = newmodes; - CameraConcurrentInfothis[i].modeAndCapabilitySize = outputCapabilities[i].size(); - Camera_OutputCapability* newOutputCapability = new Camera_OutputCapability[outputCapabilities[i].size()]; - for (uint32_t j = 0; j < outputCapabilities[i].size(); j++) { - std::vector previewProfiles = outputCapabilities[i][j]->GetPreviewProfiles(); - std::vector photoProfiles = outputCapabilities[i][j]->GetPhotoProfiles(); - std::vector videoProfiles = outputCapabilities[i][j]->GetVideoProfiles(); - std::vector metadataTypeList = - outputCapabilities[i][j]->GetSupportedMetadataObjectType(); - std::vector uniquePreviewProfiles; - for (const auto& profile : previewProfiles) { - if (std::find(uniquePreviewProfiles.begin(), uniquePreviewProfiles.end(), - profile) == uniquePreviewProfiles.end()) { - uniquePreviewProfiles.push_back(profile); - } - } - GetSupportedPreviewProfiles(&newOutputCapability[j], uniquePreviewProfiles); - GetSupportedPhotoProfiles(&newOutputCapability[j], photoProfiles); - GetSupportedVideoProfiles(&newOutputCapability[j], videoProfiles); - GetSupportedMetadataTypeList(&newOutputCapability[j], metadataTypeList); - } - CameraConcurrentInfothis[i].outputCapabilities = newOutputCapability; - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::RegisterFoldStatusCallback(OH_CameraManager_OnFoldStatusInfoChange foldStatusCallback) -{ - auto innerFoldStatusCallback = make_shared(this, foldStatusCallback); - CHECK_RETURN_RET_ELOG( - innerFoldStatusCallback == nullptr, CAMERA_SERVICE_FATAL_ERROR, "create innerFoldStatusCallback failed!"); - if (cameraFoldStatusCallbackMap_.SetMapValue(foldStatusCallback, innerFoldStatusCallback)) { - cameraManager_->RegisterFoldListener(innerFoldStatusCallback); - } - return CAMERA_OK; -} - -Camera_ErrorCode Camera_Manager::UnregisterFoldStatusCallback( - OH_CameraManager_OnFoldStatusInfoChange foldStatusCallback) -{ - auto callback = cameraFoldStatusCallbackMap_.RemoveValue(foldStatusCallback); - if (callback != nullptr) { - cameraManager_->UnregisterFoldListener(callback); - } - return CAMERA_OK; -} \ No newline at end of file -- Gitee From cfab21f219c55c352e5105723d88041cc96c045a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=8B=B1=E7=BE=BD?= Date: Wed, 20 Aug 2025 07:02:05 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20inte?= =?UTF-8?q?rfaces/kits/native/include/camera/camera.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/native/include/camera/camera.h | 1241 ----------------- 1 file changed, 1241 deletions(-) delete mode 100644 interfaces/kits/native/include/camera/camera.h diff --git a/interfaces/kits/native/include/camera/camera.h b/interfaces/kits/native/include/camera/camera.h deleted file mode 100644 index eec320de0..000000000 --- a/interfaces/kits/native/include/camera/camera.h +++ /dev/null @@ -1,1241 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup OH_Camera - * @{ - * - * @brief Provide the definition of the C interface for the camera module. - * - * @syscap SystemCapability.Multimedia.Camera.Core - * - * @since 11 - * @version 1.0 - */ - -/** - * @file camera.h - * - * @brief Declare the camera base concepts. - * - * @library libohcamera.so - * @kit CameraKit - * @syscap SystemCapability.Multimedia.Camera.Core - * @since 11 - * @version 1.0 - */ - -#ifndef NATIVE_INCLUDE_CAMERA_CAMERA_H -#define NATIVE_INCLUDE_CAMERA_CAMERA_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief camera manager object. - * - * A pointer can be created using {@link OH_Camera_GetCameraManager} method. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_Manager Camera_Manager; - -/** - * @brief Enum for camera error code. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_ErrorCode { - /** - * Camera result is ok. - */ - CAMERA_OK = 0, - - /** - * Parameter missing or parameter type incorrect. - */ - CAMERA_INVALID_ARGUMENT = 7400101, - - /** - * Operation not allowed. - */ - CAMERA_OPERATION_NOT_ALLOWED = 7400102, - - /** - * Session not config. - */ - CAMERA_SESSION_NOT_CONFIG = 7400103, - - /** - * Session not running. - */ - CAMERA_SESSION_NOT_RUNNING = 7400104, - - /** - * Session config locked. - */ - CAMERA_SESSION_CONFIG_LOCKED = 7400105, - - /** - * Device setting locked. - */ - CAMERA_DEVICE_SETTING_LOCKED = 7400106, - - /** - * Can not use camera cause of conflict. - */ - CAMERA_CONFLICT_CAMERA = 7400107, - - /** - * Camera disabled cause of security reason. - */ - CAMERA_DEVICE_DISABLED = 7400108, - - /** - * Can not use camera cause of preempted. - */ - CAMERA_DEVICE_PREEMPTED = 7400109, - - /** - * Unresolved conflicts with current configurations. - * @since 12 - */ - CAMERA_UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS = 7400110, - - /** - * Camera service fatal error. - */ - CAMERA_SERVICE_FATAL_ERROR = 7400201 -} Camera_ErrorCode; - -/** - * @brief Enum for camera status. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_Status { - /** - * Appear status. - */ - CAMERA_STATUS_APPEAR = 0, - - /** - * Disappear status. - */ - CAMERA_STATUS_DISAPPEAR = 1, - - /** - * Available status. - */ - CAMERA_STATUS_AVAILABLE = 2, - - /** - * Unavailable status. - */ - CAMERA_STATUS_UNAVAILABLE = 3 -} Camera_Status; - -/** - * @brief Enum for scence mode. - * - * @since 12 - * @version 1.0 - */ -typedef enum Camera_SceneMode { - /** - * Normal photo mode. - */ - NORMAL_PHOTO = 1, - - /** - * Normal video mode. - */ - NORMAL_VIDEO = 2, - - /** - * Secure photo mode. - */ - SECURE_PHOTO = 12 -} Camera_SceneMode; - -/** - * @brief Enum for camera position. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_Position { - /** - * Unspecified position. - */ - CAMERA_POSITION_UNSPECIFIED = 0, - - /** - * Back position. - */ - CAMERA_POSITION_BACK = 1, - - /** - * Front position. - */ - CAMERA_POSITION_FRONT = 2 -} Camera_Position; - -/** - * @brief Enum for camera type. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_Type { - /** - * Default camera type. - */ - CAMERA_TYPE_DEFAULT = 0, - - /** - * Wide camera. - */ - CAMERA_TYPE_WIDE_ANGLE = 1, - - /** - * Ultra wide camera. - */ - CAMERA_TYPE_ULTRA_WIDE = 2, - - /** - * Telephoto camera. - */ - CAMERA_TYPE_TELEPHOTO = 3, - - /** - * True depth camera. - */ - CAMERA_TYPE_TRUE_DEPTH = 4 -} Camera_Type; - -/** - * @brief Enum for camera connection type. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_Connection { - /** - * Built-in camera. - */ - CAMERA_CONNECTION_BUILT_IN = 0, - - /** - * Camera connected using USB. - */ - CAMERA_CONNECTION_USB_PLUGIN = 1, - - /** - * Remote camera. - */ - CAMERA_CONNECTION_REMOTE = 2 -} Camera_Connection; - -/** - * @brief Enum for camera format type. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_Format { - /** - * RGBA 8888 Format. - */ - CAMERA_FORMAT_RGBA_8888 = 3, - - /** - * YUV 420 Format. - */ - CAMERA_FORMAT_YUV_420_SP = 1003, - - /** - * JPEG Format. - */ - CAMERA_FORMAT_JPEG = 2000, - - /** - * YCBCR P010 Format. - * @since 12 - */ - CAMERA_FORMAT_YCBCR_P010 = 2001, - - /** - * YCRCB P010 Format. - * @since 12 - */ - CAMERA_FORMAT_YCRCB_P010 = 2002, - - /** - * MJPEG Format. - */ - CAMERA_FORMAT_MJPEG = 2003 -} Camera_Format; - -/** - * @brief Enum for flash mode. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_FlashMode { - /** - * Close mode. - */ - FLASH_MODE_CLOSE = 0, - - /** - * Open mode. - */ - FLASH_MODE_OPEN = 1, - - /** - * Auto mode. - */ - FLASH_MODE_AUTO = 2, - - /** - * Always open mode. - */ - FLASH_MODE_ALWAYS_OPEN = 3 -} Camera_FlashMode; - -/** - * @brief Enum for exposure mode. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_ExposureMode { - /** - * Lock exposure mode. - */ - EXPOSURE_MODE_LOCKED = 0, - - /** - * Auto exposure mode. - */ - EXPOSURE_MODE_AUTO = 1, - - /** - * Continuous automatic exposure. - */ - EXPOSURE_MODE_CONTINUOUS_AUTO = 2 -} Camera_ExposureMode; - -/** - * @brief Enum for focus mode. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_FocusMode { - /** - * Manual mode. - */ - FOCUS_MODE_MANUAL = 0, - - /** - * Continuous auto mode. - */ - FOCUS_MODE_CONTINUOUS_AUTO = 1, - - /** - * Auto mode. - */ - FOCUS_MODE_AUTO = 2, - - /** - * Locked mode. - */ - FOCUS_MODE_LOCKED = 3 -} Camera_FocusMode; - -/** - * @brief Enum for focus state. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_FocusState { - /** - * Scan state. - */ - FOCUS_STATE_SCAN = 0, - - /** - * Focused state. - */ - FOCUS_STATE_FOCUSED = 1, - - /** - * Unfocused state. - */ - FOCUS_STATE_UNFOCUSED = 2 -} Camera_FocusState; - -/** - * @brief Enum for video stabilization mode. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_VideoStabilizationMode { - /** - * Turn off video stablization. - */ - STABILIZATION_MODE_OFF = 0, - - /** - * LOW mode provides basic stabilization effect. - */ - STABILIZATION_MODE_LOW = 1, - - /** - * MIDDLE mode means algorithms can achieve better effects than LOW mode. - */ - STABILIZATION_MODE_MIDDLE = 2, - - /** - * HIGH mode means algorithms can achieve better effects than MIDDLE mode. - */ - STABILIZATION_MODE_HIGH = 3, - - /** - * Camera HDF can select mode automatically. - */ - STABILIZATION_MODE_AUTO = 4 -} Camera_VideoStabilizationMode; - -/** - * @brief Enum for the image rotation angles. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_ImageRotation { - /** - * The capture image rotates 0 degrees. - */ - IAMGE_ROTATION_0 = 0, - - /** - * The capture image rotates 90 degrees. - */ - IAMGE_ROTATION_90 = 90, - - /** - * The capture image rotates 180 degrees. - */ - IAMGE_ROTATION_180 = 180, - - /** - * The capture image rotates 270 degrees. - */ - IAMGE_ROTATION_270 = 270 -} Camera_ImageRotation; - -/** - * @brief Enum for the image quality levels. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_QualityLevel { - /** - * High image quality. - */ - QUALITY_LEVEL_HIGH = 0, - - /** - * Medium image quality. - */ - QUALITY_LEVEL_MEDIUM = 1, - - /** - * Low image quality. - */ - QUALITY_LEVEL_LOW = 2 -} Camera_QualityLevel; - -/** - * @brief Enum for metadata object type. - * - * @since 11 - * @version 1.0 - */ -typedef enum Camera_MetadataObjectType { - /** - * Face detection. - */ - FACE_DETECTION = 0 -} Camera_MetadataObjectType; - -/** - * @brief Enum for torch mode. - * - * @since 12 - * @version 1.0 - */ -typedef enum Camera_TorchMode { - /** - * The device torch is always off. - */ - OFF = 0, - - /** - * The device torch is always on. - */ - ON = 1, - - /** - * The device continuously monitors light levels and - * uses the torch when necessary. - */ - AUTO = 2 -} Camera_TorchMode; - -/** - * @brief Enum for smooth zoom mode. - * - * @since 12 - * @version 1.0 - */ -typedef enum Camera_SmoothZoomMode { - /** - * Normal zoom mode. - */ - NORMAL = 0 -} Camera_SmoothZoomMode; - -/** - * @brief Enum for preconfig type. - * - * @since 12 - * @version 1.0 - */ -typedef enum Camera_PreconfigType { - /** - * The preconfig type is 720P. - */ - PRECONFIG_720P = 0, - - /** - * The preconfig type is 1080P. - */ - PRECONFIG_1080P = 1, - - /** - * The preconfig type is 4K. - */ - PRECONFIG_4K = 2, - - /** - * The preconfig type is high quality. - */ - PRECONFIG_HIGH_QUALITY = 3 -} Camera_PreconfigType; - -/** - * @brief Enum for preconfig ratio. - * - * @since 12 - * @version 1.0 - */ -typedef enum Camera_PreconfigRatio { - /** - * The preconfig ratio is 1:1. - */ - PRECONFIG_RATIO_1_1 = 0, - - /** - * The preconfig ratio 4:3. - */ - PRECONFIG_RATIO_4_3 = 1, - - /** - * The preconfig ratio 16:9. - */ - PRECONFIG_RATIO_16_9 = 2 -} Camera_PreconfigRatio; - -/** - * @brief Enum for remote camera device type. - * - * @since 12 - * @version 1.0 - */ -typedef enum Camera_HostDeviceType { - /** - * Indicates an unknown device camera. - */ - HOST_DEVICE_TYPE_UNKNOWN_TYPE = 0, - - /** - * Indicates a smartphone camera. - */ - HOST_DEVICE_TYPE_PHONE = 0x0E, - - /** - * Indicates tablet camera. - */ - HOST_DEVICE_TYPE_TABLET = 0x11 -} Camera_HostDeviceType; - -/** - * @brief Size parameter. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_Size { - /** - * Width. - */ - uint32_t width; - - /** - * Height. - */ - uint32_t height; -} Camera_Size; - -/** - * @brief Profile for camera streams. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_Profile { - /** - * Camera format. - */ - Camera_Format format; - - /** - * Picture size. - */ - Camera_Size size; -} Camera_Profile; - -/** - * @brief Frame rate range. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_FrameRateRange { - /** - * Min frame rate. - */ - uint32_t min; - - /** - * Max frame rate. - */ - uint32_t max; -} Camera_FrameRateRange; - -/** - * @brief Video profile. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_VideoProfile { - /** - * Camera format. - */ - Camera_Format format; - - /** - * Picture size. - */ - Camera_Size size; - - /** - * Frame rate in unit fps (frames per second). - */ - Camera_FrameRateRange range; -} Camera_VideoProfile; - -/** - * @brief Camera output capability. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_OutputCapability { - /** - * Preview profiles list. - */ - Camera_Profile** previewProfiles; - - /** - * Size of preview profiles list. - */ - uint32_t previewProfilesSize; - - /** - * Photo profiles list. - */ - Camera_Profile** photoProfiles; - - /** - * Size of photo profiles list. - */ - uint32_t photoProfilesSize; - - /** - * Video profiles list. - */ - Camera_VideoProfile** videoProfiles; - - /** - * Size of video profiles list. - */ - uint32_t videoProfilesSize; - - /** - * Metadata object types list. - */ - Camera_MetadataObjectType** supportedMetadataObjectTypes; - - /** - * Size of metadata object types list. - */ - uint32_t metadataProfilesSize; -} Camera_OutputCapability; - -/** - * @brief Camera device object. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_Device { - /** - * Camera id attribute. - */ - char* cameraId; - - /** - * Camera position attribute. - */ - Camera_Position cameraPosition; - - /** - * Camera type attribute. - */ - Camera_Type cameraType; - - /** - * Camera connection type attribute. - */ - Camera_Connection connectionType; -} Camera_Device; - -/** - * @brief Camera status info. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_StatusInfo { - /** - * Camera instance. - */ - Camera_Device* camera; - - /** - * Current camera status. - */ - Camera_Status status; -} Camera_StatusInfo; - -/** - * @brief Point parameter. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_Point { - /** - * X co-ordinate. - */ - double x; - - /** - * Y co-ordinate. - */ - double y; -} Camera_Point; - -/** - * @brief Photo capture location. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_Location { - /** - * Latitude. - */ - double latitude; - - /** - * Longitude. - */ - double longitude; - - /** - * Altitude. - */ - double altitude; -} Camera_Location; - -/** - * @brief Photo capture options to set. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_PhotoCaptureSetting { - /** - * Photo image quality. - */ - Camera_QualityLevel quality; - - /** - * Photo rotation. - */ - Camera_ImageRotation rotation; - - /** - * Photo location. - */ - Camera_Location* location; - - /** - * Set the mirror photo function switch, default to false. - */ - bool mirror; -} Camera_PhotoCaptureSetting; - -/** - * @brief Frame shutter callback info. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_FrameShutterInfo { - /** - * Capture id. - */ - int32_t captureId; - - /** - * Timestamp for frame. - */ - uint64_t timestamp; -} Camera_FrameShutterInfo; - -/** - * @brief Capture end info. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_CaptureEndInfo { - /** - * Capture id. - */ - int32_t captureId; - - /** - * Frame count. - */ - int64_t frameCount; -} Camera_CaptureEndInfo; - -/** - * @brief Rectangle definition. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_Rect { - /** - * X coordinator of top left point. - */ - int32_t topLeftX; - - /** - * Y coordinator of top left point. - */ - int32_t topLeftY; - - /** - * Width of this rectangle. - */ - int32_t width; - - /** - * Height of this rectangle. - */ - int32_t height; -} Camera_Rect; - -/** - * @brief Metadata object basis. - * - * @since 11 - * @version 1.0 - */ -typedef struct Camera_MetadataObject { - /** - * Metadata object type. - */ - Camera_MetadataObjectType type; - - /** - * Metadata object timestamp in milliseconds. - */ - int64_t timestamp; - - /** - * The axis-aligned bounding box of detected metadata object. - */ - Camera_Rect* boundingBox; -} Camera_MetadataObject; - -/** - * @brief Torch Status Info. - * - * @since 12 - * @version 1.0 - */ -typedef struct Camera_TorchStatusInfo { - /** - * is torch available. - */ - bool isTorchAvailable; - - /** - * is torch active. - */ - bool isTorchActive; - - /** - * the current torch brightness level. - */ - float torchLevel; -} Camera_TorchStatusInfo; - -/** - * @brief SmoothZoomInfo object. - * - * @since 12 - * @version 1.0 - */ -typedef struct Camera_SmoothZoomInfo { - /** - * The duration of smooth zoom. - */ - int32_t duration; -} Camera_SmoothZoomInfo; - -/** - * @brief Capture start info. - * - * @since 12 - * @version 1.0 - */ -typedef struct Camera_CaptureStartInfo { - /** - * Capture id. - */ - int32_t captureId; - - /** - * Time(in milliseconds) is the shutter time for the photo. - */ - int64_t time; -} Camera_CaptureStartInfo; - -/** - * @brief Frame shutter end callback info. - * - * @since 12 - * @version 1.0 - */ -typedef struct Camera_FrameShutterEndInfo { - /** - * Capture id. - */ - int32_t captureId; -} Camera_FrameShutterEndInfo; - -/** -* @brief Enum for fold status. -* -* @since 13 -* @version 1.0 -*/ -typedef enum Camera_FoldStatus { - /** - * Non_foldable status. - */ - NON_FOLDABLE = 0, - - /** - * Expanded status. - */ - EXPANDED = 1, - - /** - * Folded status. - */ - FOLDED = 2 -} Camera_FoldStatus; - -/** - * @brief Fold status info. - * - * @since 13 - * @version 1.0 - */ -typedef struct Camera_FoldStatusInfo { - /** - * Camera instance list. - */ - Camera_Device** supportedCameras; - - /** - * Size of camera list. - */ - uint32_t cameraSize; - - /** - * Current fold status. - */ - Camera_FoldStatus foldStatus; -} Camera_FoldStatusInfo; - -/** - * @brief Auto device switch status info. - * - * @since 13 - * @version 1.0 - */ -typedef struct Camera_AutoDeviceSwitchStatusInfo { - /** - * is device switched. - */ - bool isDeviceSwitched; - - /** - * is device capability changed. - */ - bool isDeviceCapabilityChanged; -} Camera_AutoDeviceSwitchStatusInfo; - -/** - * @brief Creates a CameraManager instance. - * - * @param cameraManager the output {@link Camera_Manager} cameraManager will be created - * if the method call succeeds. - * @return {@link #CAMERA_OK} if the method call succeeds. - * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. - * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. - * @since 11 - */ -Camera_ErrorCode OH_Camera_GetCameraManager(Camera_Manager** cameraManager); - -/** - * @brief Delete the CameraManager instance. - * - * @param cameraManager the {@link Camera_Manager} cameraManager instance to be deleted. - * @return {@link #CAMERA_OK} if the method call succeeds. - * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. - * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. - * @since 11 - */ -Camera_ErrorCode OH_Camera_DeleteCameraManager(Camera_Manager* cameraManager); - -/** - * @brief Enum for quality prioritization. - * - * @since 14 - * @version 1.0 - */ -typedef enum Camera_QualityPrioritization { - /** - * Hight quality priority. - */ - HIGH_QUALITY = 0, - - /** - * Power balance priority. - */ - POWER_BALANCE = 1 -} Camera_QualityPrioritization; - -/** - * @brief Enum for camera concurrency type. - * - * @since 16 - * @version 1.0 - */ -typedef enum Camera_ConcurrentType { - /** - * Hight quality priority. - */ - CONCURRENT_TYPE_LIMITED_CAPABILITY = 0, - - /** - * Power balance priority. - */ - CONCURRENT_TYPE_FULL_CAPABILITY = 1 -} Camera_ConcurrentType; - -/** - * @brief Concurrency capability infos. - * - * @since 16 - * @version 1.0 - */ -typedef struct Camera_ConcurrentInfo { - /** - * Device. - */ - Camera_Device camera; - - /** - * Concurrent type. - */ - Camera_ConcurrentType type; - - /** - * Supported Modes. - */ - Camera_SceneMode* sceneModes; - - /** - * Supported profiles set - */ - Camera_OutputCapability* outputCapabilities; - - /** - * Supported profiles set - */ - uint32_t modeAndCapabilitySize; -} Camera_ConcurrentInfo; - -/** - * @brief Enum for system pressure level. - * - * @since 20 - * @version 1.0 - */ -typedef enum Camera_SystemPressureLevel { - /** - * System pressure normal. - */ - SYSTEM_PRESSURE_NORMAL = 0, - - /** - * System pressure mild. - */ - SYSTEM_PRESSURE_MILD = 1, - - /** - * System pressure severe. - */ - SYSTEM_PRESSURE_SEVERE = 2, - - /** - * System pressure critical. - */ - SYSTEM_PRESSURE_CRITICAL = 3, - - /** - * System pressure shutdown. - */ - SYSTEM_PRESSURE_SHUTDOWN = 4 -} Camera_SystemPressureLevel; - -typedef enum Camera_ControlCenterEffectType { - /** - * Control center beauty effect type. - */ - CONTROL_CENTER_EFFECT_TYPE_BEAUTY = 0, - - /** - * Control center portrait effect type. - */ - CONTROL_CENTER_EFFECT_TYPE_PORTRAIT = 1 -} Camera_ControlCenterEffectType; - -/** - * @brief Control center status info. - * - * @since 20 - * @version 1.0 - */ -typedef struct Camera_ControlCenterStatusInfo { - /** - * Control center effect type. - */ - Camera_ControlCenterEffectType effectType; - - /** - * IsActive - */ - bool isActive; -} Camera_ControlCenterStatusInfo; - -typedef enum Camera_WhiteBalanceMode { - /** - * Auto white balance mode. - */ - CAMERA_WHITE_BALANCE_MODE_AUTO = 0, - CAMERA_WHITE_BALANCE_MODE_CLOUDY = 1, - CAMERA_WHITE_BALANCE_MODE_INCANDESCENT = 2, - CAMERA_WHITE_BALANCE_MODE_FLUORESCENT = 3, - CAMERA_WHITE_BALANCE_MODE_DAYLIGHT = 4, - CAMERA_WHITE_BALANCE_MODE_MANUAL = 5, - CAMERA_WHITE_BALANCE_MODE_LOCKED = 6 -} Camera_WhiteBalanceMode; - -#ifdef __cplusplus -} -#endif - -#endif // NATIVE_INCLUDE_CAMERA_CAMERA_H -/** @} */ \ No newline at end of file -- Gitee