diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h index 5efe7702328de6d474134816892bbe391148273f..1669fe608910331b2ca6cbcc5c529fd93d4bd8a4 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h @@ -17,6 +17,7 @@ #define OHOS_DCAMERA_INPUT_CALLBACK_H #include "camera_input.h" +#include "capture_session.h" #include diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h index 6d2aa46d15394ff0720c292ddab58f95f5740b54..f3f4b2befff90ab28ebfb5608e858a37dadec56f 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h @@ -24,7 +24,7 @@ class DCameraManagerCallback : public CameraStandard::CameraManagerCallback { public: void OnCameraStatusChanged(const CameraStandard::CameraStatusInfo &cameraStatusInfo) const override; void OnFlashlightStatusChanged(const std::string &cameraID, - const CameraStandard::FlashlightStatus flashStatus) const override; + const CameraStandard::FlashStatus flashStatus) const override; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h index 9e8bd2118d58bb71f40a4879a444962b8caf544f..1268ab0def8cd49ceaf287310cc1b40fd0fea37f 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h @@ -22,7 +22,7 @@ namespace OHOS { namespace DistributedHardware { -class DCameraPhotoCallback : public CameraStandard::PhotoCallback { +class DCameraPhotoCallback : public CameraStandard::PhotoStateCallback { public: explicit DCameraPhotoCallback(const std::shared_ptr& callback); void OnCaptureStarted(const int32_t captureID) const override; diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h index fad4a5014ad17a5334e0550d5174fdaec603278f..4550b499d96cc3f0b2ea6b16125a9a6bb0956ea1 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { -class DCameraPreviewCallback : public CameraStandard::PreviewCallback { +class DCameraPreviewCallback : public CameraStandard::PreviewStateCallback { public: explicit DCameraPreviewCallback(const std::shared_ptr& callback); void OnFrameStarted() const override; diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h index ff7cdec1d96bafe010c4470c6339bf63ebca9a59..0e45b03e7a87db255663fc8df6a409e3cc8569e4 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h @@ -22,7 +22,7 @@ namespace OHOS { namespace DistributedHardware { -class DCameraVideoCallback : public CameraStandard::VideoCallback { +class DCameraVideoCallback : public CameraStandard::VideoStateCallback { public: explicit DCameraVideoCallback(const std::shared_ptr& callback); void OnFrameStarted() const override; diff --git a/services/cameraservice/cameraoperator/client/include/dcamera_client.h b/services/cameraservice/cameraoperator/client/include/dcamera_client.h index d0b1df0da7aec34bdc17ac65a1774b4f08adf261..e2b53474ad326f7ccd457c03882a89ae4d39fcc6 100644 --- a/services/cameraservice/cameraoperator/client/include/dcamera_client.h +++ b/services/cameraservice/cameraoperator/client/include/dcamera_client.h @@ -23,6 +23,7 @@ #include "camera_info.h" #include "camera_input.h" #include "camera_manager.h" +#include "camera_output_capability.h" #include "capture_input.h" #include "capture_output.h" #include "capture_session.h" @@ -66,6 +67,7 @@ private: std::shared_ptr& photoCaptureSetting); void ReleaseCaptureSession(); int32_t CameraServiceErrorType(const int32_t errorType); + CameraStandard::CameraFormat ConvertToCameraFormat(int32_t format); void UpdateSettingCache(const std::string& metadataStr); private: @@ -76,7 +78,7 @@ private: std::queue cameraMetadatas_; sptr photoSurface_; sptr videoSurface_; - sptr cameraInfo_; + sptr cameraInfo_; sptr cameraManager_; sptr captureSession_; sptr cameraInput_; diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp index f65adf08f51fca3840e0b403266a38d565a5a91d..da9d73c03c3f891214b020adb13578a974fcae40 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp @@ -27,7 +27,7 @@ void DCameraManagerCallback::OnCameraStatusChanged(const CameraStandard::CameraS } void DCameraManagerCallback::OnFlashlightStatusChanged(const std::string &cameraID, - const CameraStandard::FlashlightStatus flashStatus) const + const CameraStandard::FlashStatus flashStatus) const { DHLOGI("DCameraManagerCallback::OnFlashlightStatusChanged, cameraID: %s, flashStatus: %d", GetAnonyString(cameraID).c_str(), flashStatus); diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp index d44c313b5a58c682d1d75df9b93ee3d857a510de..ea56fc4248ea22e21cd2ad270841b87978a3b9ae 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp @@ -55,7 +55,7 @@ int32_t DCameraClient::Init() } cameraManager_->SetCallback(std::make_shared()); - std::vector> cameraList = cameraManager_->GetCameras(); + std::vector> cameraList = cameraManager_->GetSupportedCameras(); DHLOGI("DCameraClient::Init camera size: %d", cameraList.size()); for (auto& info : cameraList) { if (info->GetID() == cameraId_) { @@ -106,12 +106,12 @@ int32_t DCameraClient::UpdateSettings(std::vector &)cameraInput_)->SetCameraSettings(metadataStr); - if (ret != DCAMERA_OK) { - DHLOGE("DCameraClient::UpdateSettings %s update metadata settings failed, ret: %d", - GetAnonyString(cameraId_).c_str(), ret); - return ret; - } + // int32_t ret = ((sptr &)cameraInput_)->SetCameraSettings(metadataStr); + // if (ret != DCAMERA_OK) { + // DHLOGE("DCameraClient::UpdateSettings %s update metadata settings failed, ret: %d", + // GetAnonyString(cameraId_).c_str(), ret); + // return ret; + // } break; } default: { @@ -302,9 +302,6 @@ int32_t DCameraClient::ConfigCaptureSession(std::vector inputCallback = std::make_shared(stateCallback_); - ((sptr &)cameraInput_)->SetErrorCallback(inputCallback); - ((sptr &)cameraInput_)->SetFocusCallback(inputCallback); while (!cameraMetadatas_.empty()) { std::string metadataStr = cameraMetadatas_.front(); @@ -324,6 +321,10 @@ int32_t DCameraClient::ConfigCaptureSession(std::vector inputCallback = std::make_shared(stateCallback_); + ((sptr &)cameraInput_)->SetErrorCallback(inputCallback); + captureSession_->SetFocusCallback(inputCallback); captureSession_->SetCallback(std::make_shared(stateCallback_)); int32_t ret = CreateCaptureOutput(captureInfos); @@ -427,7 +428,10 @@ int32_t DCameraClient::CreatePhotoOutput(std::shared_ptr& in photoSurface_->SetUserData(CAMERA_SURFACE_FORMAT, std::to_string(info->format_)); photoListener_ = new DCameraPhotoSurfaceListener(photoSurface_, resultCallback_); photoSurface_->RegisterConsumerListener((sptr &)photoListener_); - photoOutput_ = cameraManager_->CreatePhotoOutput(photoSurface_); + CameraStandard::CameraFormat photoFormat = ConvertToCameraFormat(info->format_); + CameraStandard::Size photoSize = {info->height_, info->width_}; + CameraStandard::Profile photoProfile(photoFormat, photoSize); + photoOutput_ = cameraManager_->CreatePhotoOutput(photoProfile, photoSurface_); if (photoOutput_ == nullptr) { DHLOGE("DCameraClient::CreatePhotoOutput %s create photo output failed", GetAnonyString(cameraId_).c_str()); return DCAMERA_BAD_VALUE; @@ -448,7 +452,11 @@ int32_t DCameraClient::CreateVideoOutput(std::shared_ptr& in videoSurface_->SetUserData(CAMERA_SURFACE_FORMAT, std::to_string(info->format_)); videoListener_ = new DCameraVideoSurfaceListener(videoSurface_, resultCallback_); videoSurface_->RegisterConsumerListener((sptr &)videoListener_); - videoOutput_ = cameraManager_->CreateVideoOutput(videoSurface_); + CameraStandard::CameraFormat videoFormat = ConvertToCameraFormat(info->format_); + CameraStandard::Size videoSize = {info->height_, info->width_}; + std::vector framerates = {}; + CameraStandard::VideoProfile videoProfile(videoFormat, videoSize, framerates); + videoOutput_ = cameraManager_->CreateVideoOutput(videoProfile, videoSurface_); if (videoOutput_ == nullptr) { DHLOGE("DCameraClient::CreateVideoOutput %s create video output failed", GetAnonyString(cameraId_).c_str()); return DCAMERA_BAD_VALUE; @@ -459,6 +467,29 @@ int32_t DCameraClient::CreateVideoOutput(std::shared_ptr& in return DCAMERA_OK; } +CameraStandard::CameraFormat DCameraClient::ConvertToCameraFormat(int32_t format) +{ + CameraStandard::CameraFormat ret = CameraStandard::CameraFormat::CAMERA_FORMAT_INVALID; + DCameraFormat df = static_cast(format); + switch (df) { + case OHOS_CAMERA_FORMAT_RGBA_8888: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_RGBA_8888; + break; + case OHOS_CAMERA_FORMAT_YCBCR_420_888: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_YCBCR_420_888; + break; + case OHOS_CAMERA_FORMAT_YCRCB_420_SP: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_YUV_420_SP; + break; + case OHOS_CAMERA_FORMAT_JPEG: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_JPEG; + break; + default: + break; + } + return ret; +} + int32_t DCameraClient::StartCaptureInner(std::shared_ptr& info) { switch (info->streamType_) { diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp index c2f351d856e483d432e4b221decc8d7a6c9f9a2d..e0adbd9c0e8a5efc78cf7c0af6adde850a18c65a 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client_common.cpp @@ -55,7 +55,7 @@ int32_t DCameraClient::Init() } cameraManager_->SetCallback(std::make_shared()); - std::vector> cameraList = cameraManager_->GetCameras(); + std::vector> cameraList = cameraManager_->GetSupportedCameras(); DHLOGI("DCameraClientCommon::Init camera size: %d", cameraList.size()); for (auto& info : cameraList) { if (info->GetID() == cameraId_) { @@ -107,12 +107,12 @@ int32_t DCameraClient::UpdateSettings(std::vector &)cameraInput_)->SetCameraSettings(metadataStr); - if (ret != DCAMERA_OK) { - DHLOGE("DCameraClientCommon::UpdateSettings %s update metadata settings failed, ret: %d", - GetAnonyString(cameraId_).c_str(), ret); - return ret; - } + // int32_t ret = ((sptr &)cameraInput_)->SetCameraSettings(metadataStr); + // if (ret != DCAMERA_OK) { + // DHLOGE("DCameraClientCommon::UpdateSettings %s update metadata settings failed, ret: %d", + // GetAnonyString(cameraId_).c_str(), ret); + // return ret; + // } break; } default: { @@ -261,9 +261,6 @@ int32_t DCameraClient::ConfigCaptureSession(std::vector inputCallback = std::make_shared(stateCallback_); - ((sptr &)cameraInput_)->SetErrorCallback(inputCallback); - ((sptr &)cameraInput_)->SetFocusCallback(inputCallback); captureSession_ = cameraManager_->CreateCaptureSession(); if (captureSession_ == nullptr) { @@ -271,6 +268,10 @@ int32_t DCameraClient::ConfigCaptureSession(std::vector inputCallback = std::make_shared(stateCallback_); + ((sptr &)cameraInput_)->SetErrorCallback(inputCallback); + captureSession_->SetFocusCallback(inputCallback); captureSession_->SetCallback(std::make_shared(stateCallback_)); int32_t ret = CreateCaptureOutput(captureInfos); @@ -375,7 +376,10 @@ int32_t DCameraClient::CreatePhotoOutput(std::shared_ptr& in photoSurface_->SetUserData(CAMERA_SURFACE_FORMAT, std::to_string(camera_format_t::OHOS_CAMERA_FORMAT_RGBA_8888)); photoListener_ = new DCameraPhotoSurfaceListener(photoSurface_, resultCallback_); photoSurface_->RegisterConsumerListener((sptr &)photoListener_); - photoOutput_ = cameraManager_->CreatePhotoOutput(photoSurface_); + CameraStandard::CameraFormat photoFormat = ConvertToCameraFormat(info->format_); + CameraStandard::Size photoSize = {info->height_, info->width_}; + CameraStandard::Profile photoProfile(photoFormat, photoSize); + photoOutput_ = cameraManager_->CreatePhotoOutput(photoProfile, photoSurface_); if (photoOutput_ == nullptr) { DHLOGE("DCameraClientCommon::CreatePhotoOutput %s create photo output failed", GetAnonyString(cameraId_).c_str()); @@ -397,7 +401,10 @@ int32_t DCameraClient::CreateVideoOutput(std::shared_ptr& in videoSurface_->SetUserData(CAMERA_SURFACE_FORMAT, std::to_string(camera_format_t::OHOS_CAMERA_FORMAT_RGBA_8888)); videoListener_ = new DCameraVideoSurfaceListener(videoSurface_, resultCallback_); videoSurface_->RegisterConsumerListener((sptr &)videoListener_); - previewOutput_ = cameraManager_->CreateCustomPreviewOutput(videoSurface_, info->width_, info->height_); + CameraStandard::CameraFormat previewFormat = ConvertToCameraFormat(info->format_); + CameraStandard::Size previewSize = {info->height_, info->width_}; + CameraStandard::Profile previewProfile(previewFormat, previewSize); + previewOutput_ = cameraManager_->CreatePreviewOutput(previewProfile, videoSurface_); if (previewOutput_ == nullptr) { DHLOGE("DCameraClientCommon::CreatePreviewOutput %s create preview output failed", GetAnonyString(cameraId_).c_str()); @@ -409,6 +416,29 @@ int32_t DCameraClient::CreateVideoOutput(std::shared_ptr& in return DCAMERA_OK; } +CameraStandard::CameraFormat DCameraClient::ConvertToCameraFormat(int32_t format) +{ + CameraStandard::CameraFormat ret = CameraStandard::CameraFormat::CAMERA_FORMAT_INVALID; + DCameraFormat df = static_cast(format); + switch (df) { + case DCameraFormat::OHOS_CAMERA_FORMAT_RGBA_8888: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_RGBA_8888; + break; + case DCameraFormat::OHOS_CAMERA_FORMAT_YCBCR_420_888: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_YCBCR_420_888; + break; + case DCameraFormat::OHOS_CAMERA_FORMAT_YCRCB_420_SP: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_YUV_420_SP; + break; + case DCameraFormat::OHOS_CAMERA_FORMAT_JPEG: + ret = CameraStandard::CameraFormat::CAMERA_FORMAT_JPEG; + break; + default: + break; + } + return ret; +} + int32_t DCameraClient::StartCaptureInner(std::shared_ptr& info) { switch (info->streamType_) { diff --git a/services/cameraservice/cameraoperator/client/test/sample/dcamera_client_demo.h b/services/cameraservice/cameraoperator/client/test/sample/dcamera_client_demo.h index a97e8c470277828dfda35a4c20d21bdcd6601f64..f99edea93b2a2c0e3a16840a53b83f406afec172 100644 --- a/services/cameraservice/cameraoperator/client/test/sample/dcamera_client_demo.h +++ b/services/cameraservice/cameraoperator/client/test/sample/dcamera_client_demo.h @@ -20,10 +20,10 @@ #include "anonymous_string.h" #include "camera_device_ability_items.h" -#include "camera_info.h" #include "camera_input.h" #include "camera_manager.h" #include "camera_metadata_operator.h" +#include "camera_output_capability.h" #include "capture_input.h" #include "capture_output.h" #include "capture_session.h" @@ -192,7 +192,7 @@ protected: } }; -class DemoDCameraPhotoCallback : public CameraStandard::PhotoCallback { +class DemoDCameraPhotoCallback : public CameraStandard::PhotoStateCallback { public: void OnCaptureStarted(const int32_t captureID) const { @@ -215,7 +215,7 @@ public: } }; -class DemoDCameraPreviewCallback : public CameraStandard::PreviewCallback { +class DemoDCameraPreviewCallback : public CameraStandard::PreviewStateCallback { public: void OnFrameStarted() const { @@ -233,7 +233,7 @@ public: } }; -class DemoDCameraVideoCallback : public CameraStandard::VideoCallback { +class DemoDCameraVideoCallback : public CameraStandard::VideoStateCallback { public: void OnFrameStarted() const { @@ -272,7 +272,7 @@ public: } void OnFlashlightStatusChanged(const std::string &cameraID, - const CameraStandard::FlashlightStatus flashStatus) const + const CameraStandard::FlashStatus flashStatus) const { DHLOGI("DemoDCameraManagerCallback::OnFlashlightStatusChanged cameraID: %s, flashStatus: %d", GetAnonyString(cameraID).c_str(), flashStatus); diff --git a/services/cameraservice/cameraoperator/client/test/sample/main.cpp b/services/cameraservice/cameraoperator/client/test/sample/main.cpp index b519e37feb1f66212d3c03817057d2fdb2f75b32..5ce3b9b57de4033663ee29996fe38f370290ad3b 100644 --- a/services/cameraservice/cameraoperator/client/test/sample/main.cpp +++ b/services/cameraservice/cameraoperator/client/test/sample/main.cpp @@ -32,7 +32,7 @@ constexpr int32_t VIDEO_HEIGTH = 480; constexpr int32_t SLEEP_FIVE_SECOND = 5; constexpr int32_t SLEEP_TWENTY_SECOND = 20; -static sptr g_cameraInfo = nullptr; +static sptr g_cameraInfo = nullptr; static sptr g_cameraManager = nullptr; static sptr g_cameraInput = nullptr; static sptr g_photoOutput = nullptr; @@ -61,13 +61,13 @@ static int32_t InitCameraStandard() g_captureSession = g_cameraManager->CreateCaptureSession(); g_captureSession->SetCallback(std::make_shared()); - std::vector> cameraObjList = g_cameraManager->GetCameras(); + std::vector> cameraObjList = g_cameraManager->GetSupportedCameras(); for (auto info : cameraObjList) { DHLOGI("Camera: %s, position: %d, camera type: %d, connection type: %d", GetAnonyString(info->GetID()).c_str(), info->GetPosition(), info->GetCameraType(), info->GetConnectionType()); // OHOS_CAMERA_POSITION_FRONT or OHOS_CAMERA_POSITION_BACK - if ((info->GetPosition() == OHOS_CAMERA_POSITION_FRONT) && - (info->GetConnectionType() == OHOS_CAMERA_CONNECTION_TYPE_REMOTE)) { + if ((info->GetPosition() == CameraPosition::CAMERA_POSITION_FRONT) && + (info->GetConnectionType() == ConnectionType::CAMERA_CONNECTION_REMOTE)) { g_cameraInfo = info; break; } @@ -81,7 +81,7 @@ static int32_t InitCameraStandard() g_cameraInput = g_cameraManager->CreateCameraInput(g_cameraInfo); std::shared_ptr inputCallback = std::make_shared(); ((sptr &)g_cameraInput)->SetErrorCallback(inputCallback); - ((sptr &)g_cameraInput)->SetFocusCallback(inputCallback); + g_captureSession->SetFocusCallback(inputCallback); return DCAMERA_OK; } @@ -103,6 +103,29 @@ static void InitCaptureInfo() g_videoInfo->format_ = VIDEO_FORMAT; } +static CameraFormat ConvertToCameraFormat(int32_t format) +{ + CameraFormat ret = CameraFormat::CAMERA_FORMAT_INVALID; + DCameraFormat df = static_cast(format); + switch (df) { + case DCameraFormat::OHOS_CAMERA_FORMAT_RGBA_8888: + ret = CameraFormat::CAMERA_FORMAT_RGBA_8888; + break; + case DCameraFormat::OHOS_CAMERA_FORMAT_YCBCR_420_888: + ret = CameraFormat::CAMERA_FORMAT_YCBCR_420_888; + break; + case DCameraFormat::OHOS_CAMERA_FORMAT_YCRCB_420_SP: + ret = CameraFormat::CAMERA_FORMAT_YUV_420_SP; + break; + case DCameraFormat::OHOS_CAMERA_FORMAT_JPEG: + ret = CameraFormat::CAMERA_FORMAT_JPEG; + break; + default: + break; + } + return ret; +} + static void InitPhotoOutput() { DHLOGI("Distributed Camera Demo: Create PhotoOutput, width = %d, height = %d, format = %d", @@ -112,7 +135,10 @@ static void InitPhotoOutput() photoSurface->SetDefaultWidthAndHeight(g_photoInfo->width_, g_photoInfo->height_); photoSurface->SetUserData(CAMERA_SURFACE_FORMAT, std::to_string(g_photoInfo->format_)); photoSurface->RegisterConsumerListener(photoListener); - g_photoOutput = g_cameraManager->CreatePhotoOutput(photoSurface); + CameraFormat photoFormat = ConvertToCameraFormat(g_photoInfo->format_); + Size photoSize = {g_photoInfo->height_, g_photoInfo->width_}; + Profile photoProfile(photoFormat, photoSize); + g_photoOutput = g_cameraManager->CreatePhotoOutput(photoProfile, photoSurface); ((sptr &)g_photoOutput)->SetCallback(std::make_shared()); } @@ -125,7 +151,10 @@ static void InitPreviewOutput() previewSurface->SetDefaultWidthAndHeight(g_previewInfo->width_, g_previewInfo->height_); previewSurface->SetUserData(CAMERA_SURFACE_FORMAT, std::to_string(g_previewInfo->format_)); previewSurface->RegisterConsumerListener(previewListener); - g_previewOutput = g_cameraManager->CreatePreviewOutput(previewSurface); + CameraFormat previewFormat = ConvertToCameraFormat(g_previewInfo->format_); + Size previewSize = {g_previewInfo->height_, g_previewInfo->width_}; + Profile previewProfile(previewFormat, previewSize); + g_previewOutput = g_cameraManager->CreatePreviewOutput(previewProfile, previewSurface); ((sptr &)g_previewOutput)->SetCallback(std::make_shared()); } @@ -138,7 +167,11 @@ static void InitVideoOutput() videoSurface->SetDefaultWidthAndHeight(g_videoInfo->width_, g_videoInfo->height_); videoSurface->SetUserData(CAMERA_SURFACE_FORMAT, std::to_string(g_videoInfo->format_)); videoSurface->RegisterConsumerListener(videoListener); - g_videoOutput = g_cameraManager->CreateVideoOutput(videoSurface); + CameraFormat videoFormat = ConvertToCameraFormat(g_videoInfo->format_); + Size videoSize = {g_videoInfo->height_, g_videoInfo->width_}; + std::vector framerates = {}; + VideoProfile videoProfile(videoFormat, videoSize, framerates); + g_videoOutput = g_cameraManager->CreateVideoOutput(videoProfile, videoSurface); ((sptr &)g_videoOutput)->SetCallback(std::make_shared()); } @@ -160,19 +193,19 @@ static void ConfigCaptureSession() static void ConfigFocusAndExposure() { - ((sptr &)g_cameraInput)->LockForControl(); - camera_focus_mode_enum_t focusMode = OHOS_CAMERA_FOCUS_MODE_AUTO; - camera_exposure_mode_enum_t exposureMode = OHOS_CAMERA_EXPOSURE_MODE_AUTO; + g_captureSession->LockForControl(); + FocusMode focusMode = FOCUS_MODE_CONTINUOUS_AUTO; + ExposureMode exposureMode = EXPOSURE_MODE_AUTO; int32_t exposureValue = 0; - std::vector biasRange = ((sptr &)g_cameraInput)->GetExposureBiasRange(); + std::vector biasRange = g_captureSession->GetExposureBiasRange(); if (!biasRange.empty()) { DHLOGI("Distributed Camera Demo: get %d exposure compensation range", biasRange.size()); exposureValue = biasRange[0]; } - ((sptr &)g_cameraInput)->SetFocusMode(focusMode); - ((sptr &)g_cameraInput)->SetExposureMode(exposureMode); - ((sptr &)g_cameraInput)->SetExposureBias(exposureValue); - ((sptr &)g_cameraInput)->UnlockForControl(); + g_captureSession->SetFocusMode(focusMode); + g_captureSession->SetExposureMode(exposureMode); + g_captureSession->SetExposureBias(exposureValue); + g_captureSession->UnlockForControl(); } static std::shared_ptr ConfigPhotoCaptureSetting() @@ -182,7 +215,7 @@ static std::shared_ptr ConfigPhotoCaptureSetting() PhotoCaptureSetting::RotationConfig rotation = PhotoCaptureSetting::RotationConfig::Rotation_0; photoCaptureSettings->SetRotation(rotation); // QualityLevel - PhotoCaptureSetting::QualityLevel quality = PhotoCaptureSetting::QualityLevel::HIGH_QUALITY; + PhotoCaptureSetting::QualityLevel quality = PhotoCaptureSetting::QualityLevel::QUALITY_LEVEL_HIGH; photoCaptureSettings->SetQuality(quality); // Location std::unique_ptr location = std::make_unique(); diff --git a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h index 83a77072c3f3cd283820e7952f356357356a0053..d0dcbeef1cecccca3381c60bd87606085873763f 100644 --- a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h +++ b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h @@ -23,6 +23,7 @@ #include "camera_info.h" #include "camera_input.h" #include "camera_manager.h" +#include "camera_output_capability.h" #include "json/json.h" #include "single_instance.h" #include "v1_0/dcamera_types.h" @@ -30,11 +31,6 @@ namespace OHOS { namespace DistributedHardware { using namespace OHOS::HDI::DistributedCamera::V1_0; -struct ConfigInfo { - DCStreamType type; - std::string formatKey; - sptr cameraInput; -}; class DCameraHandler : public IHardwareHandler { DECLARE_SINGLE_INSTANCE_BASE(DCameraHandler); @@ -53,11 +49,11 @@ private: ~DCameraHandler(); private: - DHItem CreateDHItem(sptr& info); - std::string GetCameraPosition(camera_position_enum_t position); - void ConfigFormatAndResolution(ConfigInfo& info, Json::Value& outputFormat, Json::Value& resolution, - std::vector& formatList, std::set& formatSet); - bool IsValid(const DCStreamType type, const CameraStandard::CameraPicSize& size); + DHItem CreateDHItem(sptr& info); + std::string GetCameraPosition(CameraStandard::CameraPosition position); + void ConfigFormatAndResolution(const DCStreamType type, Json::Value& root, + std::vector& profileList); + bool IsValid(const DCStreamType type, const CameraStandard::Size& size); sptr cameraManager_; std::shared_ptr pluginListener_; diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp index cd3355714a24f1ded9fcd869614380ddcbebf189..5ef858695cd081131ecac82d9eb167d89cb7c9bf 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp @@ -53,21 +53,21 @@ int32_t DCameraHandler::Initialize() std::vector DCameraHandler::Query() { std::vector itemList; - std::vector> cameraList = cameraManager_->GetCameras(); + std::vector> cameraList = cameraManager_->GetSupportedCameras(); DHLOGI("DCameraHandler::Query get %d cameras", cameraList.size()); if (cameraList.empty()) { DHLOGE("DCameraHandler::Query no camera device"); return itemList; } for (auto& info : cameraList) { - if (info->GetConnectionType() != OHOS_CAMERA_CONNECTION_TYPE_BUILTIN) { + if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { DHLOGI("DCameraHandler::Query connection type: %d", info->GetConnectionType()); continue; } - if ((info->GetPosition() == OHOS_CAMERA_POSITION_OTHER) || - (info->GetPosition() == OHOS_CAMERA_POSITION_FRONT) || - (info->GetPosition() == OHOS_CAMERA_POSITION_BACK && - info->GetCameraType() == OHOS_CAMERA_TYPE_LOGICAL)) { + if ((info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_UNSPECIFIED) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_FRONT) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_BACK && + info->GetCameraType() == static_cast(OHOS_CAMERA_TYPE_LOGICAL))) { DHItem item = CreateDHItem(info); itemList.emplace_back(item); } @@ -107,21 +107,21 @@ void DCameraHandler::UnRegisterPluginListener() std::vector DCameraHandler::GetCameras() { std::vector cameras; - std::vector> cameraList = cameraManager_->GetCameras(); + std::vector> cameraList = cameraManager_->GetSupportedCameras(); DHLOGI("DCameraHandler::GetCameras get %d cameras", cameraList.size()); if (cameraList.empty()) { DHLOGE("DCameraHandler::GetCameras no camera device"); return cameras; } for (auto& info : cameraList) { - if (info->GetConnectionType() != OHOS_CAMERA_CONNECTION_TYPE_BUILTIN) { + if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { DHLOGI("DCameraHandler::GetCameras connection type: %d", info->GetConnectionType()); continue; } - if ((info->GetPosition() == OHOS_CAMERA_POSITION_OTHER) || - (info->GetPosition() == OHOS_CAMERA_POSITION_FRONT) || - (info->GetPosition() == OHOS_CAMERA_POSITION_BACK && - info->GetCameraType() == OHOS_CAMERA_TYPE_LOGICAL)) { + if ((info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_UNSPECIFIED) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_FRONT) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_BACK && + info->GetCameraType() == static_cast(OHOS_CAMERA_TYPE_LOGICAL))) { std::string dhId = CAMERA_ID_PREFIX + info->GetID(); cameras.emplace_back(dhId); } @@ -130,7 +130,7 @@ std::vector DCameraHandler::GetCameras() return cameras; } -DHItem DCameraHandler::CreateDHItem(sptr& info) +DHItem DCameraHandler::CreateDHItem(sptr& info) { DHItem item; std::string id = info->GetID(); @@ -150,61 +150,49 @@ DHItem DCameraHandler::CreateDHItem(sptr& info) DHLOGI("DCameraHandler::CreateDHItem codec type: %s", name.c_str()); } + sptr capability = cameraManager_->GetSupportedOutputCapability(info); + std::vector photoProfiles = capability->GetPhotoProfiles(); + ConfigFormatAndResolution(SNAPSHOT_FRAME, root, photoProfiles); + + std::vector previewProfiles = capability->GetPreviewProfiles(); + ConfigFormatAndResolution(CONTINUOUS_FRAME, root, previewProfiles); + sptr cameraInput = cameraManager_->CreateCameraInput(info); if (cameraInput == nullptr) { DHLOGE("DCameraHandler::CreateDHItem create cameraInput failed"); return item; } - Json::Value outputFormat; - Json::Value resolution; - std::set formatSet; - - std::vector videoFormats = cameraInput->GetSupportedVideoFormats(); - ConfigInfo videoConfig = {CONTINUOUS_FRAME, CAMERA_FORMAT_VIDEO, cameraInput}; - ConfigFormatAndResolution(videoConfig, outputFormat, resolution, videoFormats, formatSet); - - std::vector previewFormats = cameraInput->GetSupportedPreviewFormats(); - ConfigInfo previewInfo = {CONTINUOUS_FRAME, CAMERA_FORMAT_PREVIEW, cameraInput}; - ConfigFormatAndResolution(previewInfo, outputFormat, resolution, previewFormats, formatSet); - - std::vector photoFormats = cameraInput->GetSupportedPhotoFormats(); - ConfigInfo photoConfig = {SNAPSHOT_FRAME, CAMERA_FORMAT_PHOTO, cameraInput}; - ConfigFormatAndResolution(photoConfig, outputFormat, resolution, photoFormats, formatSet); + // std::hash h; + // std::string abilityString = cameraInput->GetCameraSettings(); + // DHLOGI("DCameraHandler::CreateDHItem abilityString hash: %zu, length: %zu", + // h(abilityString), abilityString.length()); - root[CAMERA_FORMAT_KEY] = outputFormat; - root[CAMERA_RESOLUTION_KEY] = resolution; - - std::hash h; - std::string abilityString = cameraInput->GetCameraSettings(); - DHLOGI("DCameraHandler::CreateDHItem abilityString hash: %zu, length: %zu", - h(abilityString), abilityString.length()); - - std::string encodeString = Base64Encode(reinterpret_cast(abilityString.c_str()), - abilityString.length()); - DHLOGI("DCameraHandler::CreateDHItem encodeString hash: %zu, length: %zu", - h(encodeString), encodeString.length()); - root[CAMERA_METADATA_KEY] = Json::Value(encodeString); + // std::string encodeString = Base64Encode(reinterpret_cast(abilityString.c_str()), + // abilityString.length()); + // DHLOGI("DCameraHandler::CreateDHItem encodeString hash: %zu, length: %zu", + // h(encodeString), encodeString.length()); + // root[CAMERA_METADATA_KEY] = Json::Value(encodeString); item.attrs = root.toStyledString(); cameraInput->Release(); return item; } -std::string DCameraHandler::GetCameraPosition(camera_position_enum_t position) +std::string DCameraHandler::GetCameraPosition(CameraStandard::CameraPosition position) { DHLOGI("DCameraHandler::GetCameraPosition position: %d", position); std::string ret = ""; switch (position) { - case OHOS_CAMERA_POSITION_BACK: { + case CameraStandard::CameraPosition::CAMERA_POSITION_BACK: { ret = CAMERA_POSITION_BACK; break; } - case OHOS_CAMERA_POSITION_FRONT: { + case CameraStandard::CameraPosition::CAMERA_POSITION_FRONT: { ret = CAMERA_POSITION_FRONT; break; } - case OHOS_CAMERA_POSITION_OTHER: { + case CameraStandard::CameraPosition::CAMERA_POSITION_UNSPECIFIED: { ret = CAMERA_POSITION_UNSPECIFIED; break; } @@ -217,29 +205,38 @@ std::string DCameraHandler::GetCameraPosition(camera_position_enum_t position) return ret; } -void DCameraHandler::ConfigFormatAndResolution(ConfigInfo& info, Json::Value& outputFormat, Json::Value& resolution, - std::vector& formatList, std::set& formatSet) +void DCameraHandler::ConfigFormatAndResolution(const DCStreamType type, Json::Value& root, + std::vector& profileList) { - DHLOGI("DCameraHandler::ConfigFormatAndResolution camera format size: %d", formatList.size()); - for (auto& format : formatList) { - DHLOGI("DCameraHandler::ConfigFormatAndResolution %s format: %d", info.formatKey.c_str(), format); - outputFormat[info.formatKey].append(format); - if (formatSet.insert(format).second) { - std::vector picSizes = info.cameraInput->getSupportedSizes(format); - std::string keyName = std::to_string(format); - DHLOGI("DCameraHandler::ConfigFormatAndResolution get %d supported camera pic size", picSizes.size()); - for (auto& size : picSizes) { - if (IsValid(info.type, size)) { - std::string value = std::to_string(size.width) + "*" + std::to_string(size.height); - resolution[keyName].append(value); - DHLOGI("DCameraHandler::ConfigFormatAndResolution format %d resolution %s", format, value.c_str()); - } + DHLOGI("DCameraHandler::ConfigFormatAndResolution camera Profile size: %d", profileList.size()); + std::set formatSet; + for (auto& profile : profileList) { + CameraStandard::CameraFormat format = profile.GetCameraFormat(); + CameraStandard::Size picSize = profile.GetSize(); + formatSet.insert(format); + std::string formatName = std::to_string(format); + if (IsValid(type, picSize)) { + std::string resolutionValue = std::to_string(picSize.width) + "*" + std::to_string(picSize.height); + if (type == SNAPSHOT_FRAME) { + root[CAMERA_FORMAT_PHOTO][CAMERA_RESOLUTION_KEY][formatName].append(resolutionValue); + } else if (type == CONTINUOUS_FRAME) { + root[CAMERA_FORMAT_PREVIEW][CAMERA_RESOLUTION_KEY][formatName].append(resolutionValue); + root[CAMERA_FORMAT_VIDEO][CAMERA_RESOLUTION_KEY][formatName].append(resolutionValue); } } } + + for (auto format : formatSet) { + if (type == SNAPSHOT_FRAME) { + root[CAMERA_FORMAT_PHOTO][CAMERA_FORMAT_KEY].append(format); + } else if (type == CONTINUOUS_FRAME) { + root[CAMERA_FORMAT_PREVIEW][CAMERA_FORMAT_KEY].append(format); + root[CAMERA_FORMAT_VIDEO][CAMERA_FORMAT_KEY].append(format); + } + } } -bool DCameraHandler::IsValid(const DCStreamType type, const CameraStandard::CameraPicSize& size) +bool DCameraHandler::IsValid(const DCStreamType type, const CameraStandard::Size& size) { bool ret = false; switch (type) { diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp index 414fc97c9963378fca0869328ab454203beb598f..a738bdb940b6c2924dd3af969d7ae29a25d3a248 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler_common.cpp @@ -53,21 +53,21 @@ int32_t DCameraHandler::Initialize() std::vector DCameraHandler::Query() { std::vector itemList; - std::vector> cameraList = cameraManager_->GetCameras(); + std::vector> cameraList = cameraManager_->GetSupportedCameras(); DHLOGI("DCameraHandlerCommon::Query get %d cameras", cameraList.size()); if (cameraList.empty()) { DHLOGE("DCameraHandlerCommon::Query no camera device"); return itemList; } for (auto& info : cameraList) { - if (info->GetConnectionType() != OHOS_CAMERA_CONNECTION_TYPE_BUILTIN) { + if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { DHLOGI("DCameraHandlerCommon::Query connection type: %d", info->GetConnectionType()); continue; } - if ((info->GetPosition() == OHOS_CAMERA_POSITION_OTHER) || - (info->GetPosition() == OHOS_CAMERA_POSITION_FRONT) || - (info->GetPosition() == OHOS_CAMERA_POSITION_BACK && - info->GetCameraType() == OHOS_CAMERA_TYPE_LOGICAL)) { + if ((info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_UNSPECIFIED) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_FRONT) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_BACK && + info->GetCameraType() == static_cast(OHOS_CAMERA_TYPE_LOGICAL))) { DHItem item = CreateDHItem(info); itemList.emplace_back(item); } @@ -107,21 +107,21 @@ void DCameraHandler::UnRegisterPluginListener() std::vector DCameraHandler::GetCameras() { std::vector cameras; - std::vector> cameraList = cameraManager_->GetCameras(); + std::vector> cameraList = cameraManager_->GetSupportedCameras(); DHLOGI("DCameraHandlerCommon::GetCameras get %d cameras", cameraList.size()); if (cameraList.empty()) { DHLOGE("DCameraHandlerCommon::GetCameras no camera device"); return cameras; } for (auto& info : cameraList) { - if (info->GetConnectionType() != OHOS_CAMERA_CONNECTION_TYPE_BUILTIN) { + if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { DHLOGI("DCameraHandlerCommon::GetCameras connection type: %d", info->GetConnectionType()); continue; } - if ((info->GetPosition() == OHOS_CAMERA_POSITION_OTHER) || - (info->GetPosition() == OHOS_CAMERA_POSITION_FRONT) || - (info->GetPosition() == OHOS_CAMERA_POSITION_BACK && - info->GetCameraType() == OHOS_CAMERA_TYPE_LOGICAL)) { + if ((info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_UNSPECIFIED) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_FRONT) || + (info->GetPosition() == CameraStandard::CameraPosition::CAMERA_POSITION_BACK && + info->GetCameraType() == static_cast(OHOS_CAMERA_TYPE_LOGICAL))) { std::string dhId = CAMERA_ID_PREFIX + info->GetID(); cameras.emplace_back(dhId); } @@ -130,7 +130,7 @@ std::vector DCameraHandler::GetCameras() return cameras; } -DHItem DCameraHandler::CreateDHItem(sptr& info) +DHItem DCameraHandler::CreateDHItem(sptr& info) { DHItem item; std::string id = info->GetID(); @@ -148,58 +148,43 @@ DHItem DCameraHandler::CreateDHItem(sptr& info) return item; } - Json::Value outputFormat; - Json::Value resolution; - std::set formatSet; + sptr capability = cameraManager_->GetSupportedOutputCapability(info); + std::vector photoProfiles = capability->GetPhotoProfiles(); + ConfigFormatAndResolution(SNAPSHOT_FRAME, root, photoProfiles); - std::vector videoFormats; - videoFormats.emplace_back(camera_format_t::OHOS_CAMERA_FORMAT_RGBA_8888); - ConfigInfo videoConfig = {CONTINUOUS_FRAME, CAMERA_FORMAT_VIDEO, cameraInput}; - ConfigFormatAndResolution(videoConfig, outputFormat, resolution, videoFormats, formatSet); + std::vector previewProfiles = capability->GetPreviewProfiles(); + ConfigFormatAndResolution(CONTINUOUS_FRAME, root, previewProfiles); - std::vector previewFormats; - previewFormats.emplace_back(camera_format_t::OHOS_CAMERA_FORMAT_RGBA_8888); - ConfigInfo previewInfo = {CONTINUOUS_FRAME, CAMERA_FORMAT_PREVIEW, cameraInput}; - ConfigFormatAndResolution(previewInfo, outputFormat, resolution, previewFormats, formatSet); + // std::hash h; + // std::string abilityString = cameraInput->GetCameraSettings(); + // DHLOGI("DCameraHandlerCommon::CreateDHItem abilityString hash: %zu, length: %zu", + // h(abilityString), abilityString.length()); - std::vector photoFormats; - photoFormats.emplace_back(camera_format_t::OHOS_CAMERA_FORMAT_RGBA_8888); - ConfigInfo photoConfig = {SNAPSHOT_FRAME, CAMERA_FORMAT_PHOTO, cameraInput}; - ConfigFormatAndResolution(photoConfig, outputFormat, resolution, photoFormats, formatSet); - - root[CAMERA_FORMAT_KEY] = outputFormat; - root[CAMERA_RESOLUTION_KEY] = resolution; - - std::hash h; - std::string abilityString = cameraInput->GetCameraSettings(); - DHLOGI("DCameraHandlerCommon::CreateDHItem abilityString hash: %zu, length: %zu", - h(abilityString), abilityString.length()); - - std::string encodeString = Base64Encode(reinterpret_cast(abilityString.c_str()), - abilityString.length()); - DHLOGI("DCameraHandlerCommon::CreateDHItem encodeString hash: %zu, length: %zu", - h(encodeString), encodeString.length()); - root[CAMERA_METADATA_KEY] = Json::Value(encodeString); + // std::string encodeString = Base64Encode(reinterpret_cast(abilityString.c_str()), + // abilityString.length()); + // DHLOGI("DCameraHandlerCommon::CreateDHItem encodeString hash: %zu, length: %zu", + // h(encodeString), encodeString.length()); + // root[CAMERA_METADATA_KEY] = Json::Value(encodeString); item.attrs = root.toStyledString(); cameraInput->Release(); return item; } -std::string DCameraHandler::GetCameraPosition(camera_position_enum_t position) +std::string DCameraHandler::GetCameraPosition(CameraStandard::CameraPosition position) { DHLOGI("DCameraHandler::GetCameraPosition position: %d", position); std::string ret = ""; switch (position) { - case OHOS_CAMERA_POSITION_BACK: { + case CameraStandard::CameraPosition::CAMERA_POSITION_BACK: { ret = CAMERA_POSITION_BACK; break; } - case OHOS_CAMERA_POSITION_FRONT: { + case CameraStandard::CameraPosition::CAMERA_POSITION_FRONT: { ret = CAMERA_POSITION_FRONT; break; } - case OHOS_CAMERA_POSITION_OTHER: { + case CameraStandard::CameraPosition::CAMERA_POSITION_UNSPECIFIED: { ret = CAMERA_POSITION_UNSPECIFIED; break; } @@ -212,21 +197,35 @@ std::string DCameraHandler::GetCameraPosition(camera_position_enum_t position) return ret; } -void DCameraHandler::ConfigFormatAndResolution(ConfigInfo& info, Json::Value& outputFormat, Json::Value& resolution, - std::vector& formatList, std::set& formatSet) +void DCameraHandler::ConfigFormatAndResolution(const DCStreamType type, Json::Value& root, + std::vector& profileList) { - DHLOGI("DCameraHandlerCommon::ConfigFormatAndResolution camera format size: %d", formatList.size()); - for (auto& format : formatList) { - DHLOGI("DCameraHandlerCommon::ConfigFormatAndResolution %s format: %d", info.formatKey.c_str(), format); - outputFormat[info.formatKey].append(format); - if (formatSet.insert(format).second) { - std::string keyName = std::to_string(format); - resolution[keyName].append("640*480"); + DHLOGI("DCameraHandler::ConfigFormatAndResolution camera Profile size: %d", profileList.size()); + std::set formatSet; + for (auto& profile : profileList) { + CameraStandard::CameraFormat format = profile.GetCameraFormat(); + // CameraStandard::Size picSize = profile.GetSize(); + formatSet.insert(format); + std::string formatName = std::to_string(format); + if (type == SNAPSHOT_FRAME) { + root[CAMERA_FORMAT_PHOTO][CAMERA_RESOLUTION_KEY][formatName].append("640*480"); + } else if (type == CONTINUOUS_FRAME) { + root[CAMERA_FORMAT_PREVIEW][CAMERA_RESOLUTION_KEY][formatName].append("640*480"); + root[CAMERA_FORMAT_VIDEO][CAMERA_RESOLUTION_KEY][formatName].append("640*480"); + } + } + + for (auto format : formatSet) { + if (type == SNAPSHOT_FRAME) { + root[CAMERA_FORMAT_PHOTO][CAMERA_FORMAT_KEY].append(format); + } else if (type == CONTINUOUS_FRAME) { + root[CAMERA_FORMAT_PREVIEW][CAMERA_FORMAT_KEY].append(format); + root[CAMERA_FORMAT_VIDEO][CAMERA_FORMAT_KEY].append(format); } } } -bool DCameraHandler::IsValid(const DCStreamType type, const CameraStandard::CameraPicSize& size) +bool DCameraHandler::IsValid(const DCStreamType type, const CameraStandard::Size& size) { bool ret = false; switch (type) {