From bc4c1afd6c388e928e24fd1a874925eaffe4a0e1 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Tue, 16 Jul 2024 19:59:19 +0800 Subject: [PATCH] add mode Signed-off-by: chen0088 --- .../constants/distributed_camera_constants.h | 1 + .../base/include/dcamera_capture_info_cmd.h | 3 +- .../base/include/icamera_controller.h | 5 ++- .../base/src/dcamera_capture_info_cmd.cpp | 10 ++++- .../client/include/dcamera_client.h | 6 +-- .../client/include/icamera_operator.h | 4 +- .../client/src/dcamera_client.cpp | 15 +++---- .../cameraoperator/dcamera_client_test.cpp | 14 ++++--- .../handler/src/dcamera_handler.cpp | 41 ++++++++++++------- .../dcamera_sink_controller.h | 3 +- .../dcamera_sink_controller.cpp | 10 +++-- .../dcamera_sink_controller_test.cpp | 23 +++++++---- .../mock_camera_operator.h | 4 +- .../mock_dcamera_sink_controller.h | 4 +- .../distributedcameramgr/dcamera_source_dev.h | 1 + .../dcamera_source_controller.h | 2 +- .../dcamera_source_dev.cpp | 7 +++- .../dcamera_source_controller.cpp | 6 ++- .../dcamera_provider_callback_impl.cpp | 3 +- .../dcamera_source_controller_test.cpp | 9 ++-- .../mock_dcamera_source_controller.h | 4 +- 21 files changed, 113 insertions(+), 62 deletions(-) diff --git a/common/include/constants/distributed_camera_constants.h b/common/include/constants/distributed_camera_constants.h index 6be0dc73..ca57b9f6 100644 --- a/common/include/constants/distributed_camera_constants.h +++ b/common/include/constants/distributed_camera_constants.h @@ -111,6 +111,7 @@ const std::string CAMERA_FORMAT_PHOTO = "Photo"; const std::string CAMERA_RESOLUTION_KEY = "Resolution"; const std::string CAMERA_SURFACE_FORMAT = "CAMERA_SURFACE_FORMAT"; const std::string HDF_DCAMERA_EXT_SERVICE = "distributed_camera_provider_service"; +const std::string CAMERA_SUPPORT_MODE = "Mode"; constexpr static int8_t FRAME_HEAD = 0; const int32_t RESOLUTION_MAX_WIDTH_SNAPSHOT = 4096; diff --git a/services/cameraservice/base/include/dcamera_capture_info_cmd.h b/services/cameraservice/base/include/dcamera_capture_info_cmd.h index 5110fe6a..5e79e429 100644 --- a/services/cameraservice/base/include/dcamera_capture_info_cmd.h +++ b/services/cameraservice/base/include/dcamera_capture_info_cmd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -41,6 +41,7 @@ public: std::string dhId_; std::string command_; std::vector> value_; + int32_t sceneMode_; public: int32_t Marshal(std::string& jsonStr); diff --git a/services/cameraservice/base/include/icamera_controller.h b/services/cameraservice/base/include/icamera_controller.h index ddbbe162..79b6eb9a 100644 --- a/services/cameraservice/base/include/icamera_controller.h +++ b/services/cameraservice/base/include/icamera_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -30,7 +30,8 @@ public: ICameraController() = default; virtual ~ICameraController() = default; - virtual int32_t StartCapture(std::vector>& captureInfos) = 0; + virtual int32_t StartCapture(std::vector>& captureInfos, + int32_t sceneMode) = 0; virtual int32_t StopCapture() = 0; virtual int32_t ChannelNeg(std::shared_ptr& info) = 0; virtual int32_t DCameraNotify(std::shared_ptr& events) = 0; diff --git a/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp b/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp index 1a008f31..b65a1345 100644 --- a/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp +++ b/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -61,6 +61,7 @@ int32_t DCameraCaptureInfoCmd::Marshal(std::string& jsonStr) } cJSON_AddItemToObject(captureInfo, "CaptureSettings", captureSettings); } + cJSON_AddNumberToObject(rootValue, "mode", sceneMode_); char *data = cJSON_Print(rootValue); if (data == nullptr) { @@ -101,6 +102,13 @@ int32_t DCameraCaptureInfoCmd::Unmarshal(const std::string& jsonStr) command_ = command->valuestring; int32_t ret = UmarshalValue(rootValue); + + cJSON *mode = cJSON_GetObjectItemCaseSensitive(rootValue, "mode"); + if (mode == nullptr || !cJSON_IsNumber(mode)) { + sceneMode_ = 0; + } else { + sceneMode_ = mode->valueint; + } cJSON_Delete(rootValue); return ret; } diff --git a/services/cameraservice/cameraoperator/client/include/dcamera_client.h b/services/cameraservice/cameraoperator/client/include/dcamera_client.h index 164d43f4..09167840 100644 --- a/services/cameraservice/cameraoperator/client/include/dcamera_client.h +++ b/services/cameraservice/cameraoperator/client/include/dcamera_client.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -43,7 +43,7 @@ public: int32_t UnInit() override; int32_t UpdateSettings(std::vector>& settings) override; int32_t StartCapture(std::vector>& captureInfos, - sptr& surface) override; + sptr& surface, int32_t sceneMode) override; int32_t StopCapture() override; int32_t SetStateCallback(std::shared_ptr& callback) override; int32_t SetResultCallback(std::shared_ptr& callback) override; @@ -51,7 +51,7 @@ public: int32_t ResumeCapture() override; private: - int32_t ConfigCaptureSession(std::vector>& captureInfos); + int32_t ConfigCaptureSession(std::vector>& captureInfos, int32_t sceneMode); int32_t ConfigCaptureSessionInner(); int32_t CreateCaptureOutput(std::vector>& captureInfos); int32_t CreatePhotoOutput(std::shared_ptr& info); diff --git a/services/cameraservice/cameraoperator/client/include/icamera_operator.h b/services/cameraservice/cameraoperator/client/include/icamera_operator.h index 6682d041..0c0a2e40 100644 --- a/services/cameraservice/cameraoperator/client/include/icamera_operator.h +++ b/services/cameraservice/cameraoperator/client/include/icamera_operator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -58,7 +58,7 @@ public: virtual int32_t UnInit() = 0; virtual int32_t UpdateSettings(std::vector>& settings) = 0; virtual int32_t StartCapture(std::vector>& captureInfos, - sptr& surface) = 0; + sptr& surface, int32_t sceneMode) = 0; virtual int32_t StopCapture() = 0; virtual int32_t SetStateCallback(std::shared_ptr& callback) = 0; virtual int32_t SetResultCallback(std::shared_ptr& callback) = 0; diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp index ea2ea607..90dfa730 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -172,9 +172,9 @@ void DCameraClient::FindCameraMetadata(const std::string& metadataStr) } int32_t DCameraClient::StartCapture(std::vector>& captureInfos, - sptr& surface) + sptr& surface, int32_t sceneMode) { - DHLOGI("StartCapture cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); + DHLOGI("StartCapture cameraId: %{public}s, mode: %{public}d", GetAnonyString(cameraId_).c_str(), sceneMode); if ((photoOutput_ == nullptr) && (previewOutput_ == nullptr)) { DHLOGI("StartCapture %{public}s config capture session", GetAnonyString(cameraId_).c_str()); if (surface == nullptr) { @@ -182,7 +182,7 @@ int32_t DCameraClient::StartCapture(std::vector& callba return DCAMERA_OK; } -int32_t DCameraClient::ConfigCaptureSession(std::vector>& captureInfos) +int32_t DCameraClient::ConfigCaptureSession(std::vector>& captureInfos, + int32_t sceneMode) { DHLOGI("ConfigCaptureSession cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); CHECK_AND_RETURN_RET_LOG(cameraManager_ == nullptr, DCAMERA_BAD_VALUE, "cameraManager is null."); @@ -357,8 +358,8 @@ int32_t DCameraClient::ConfigCaptureSession(std::vectorCreateCaptureSession(&captureSession_); - if (rv != DCAMERA_OK) { + captureSession_ = cameraManager_->CreateCaptureSession(static_cast(sceneMode)); + if (captureSession_ == nullptr) { DHLOGE("ConfigCaptureSession %{public}s create captureSession failed", GetAnonyString(cameraId_).c_str()); return DCAMERA_BAD_VALUE; diff --git a/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp b/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp index fe8ddc19..235caa62 100644 --- a/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp +++ b/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp @@ -367,7 +367,8 @@ HWTEST_F(DCameraClientTest, dcamera_client_test_004, TestSize.Level1) captureInfos.push_back(videoInfo_true_); sptr bp = videoSurface->GetProducer(); sptr pSurface = Surface::CreateSurfaceAsProducer(bp); - ret = client_->StartCapture(captureInfos, pSurface); + int32_t mode = 0; + ret = client_->StartCapture(captureInfos, pSurface, mode); EXPECT_EQ(DCAMERA_OK, ret); ret = client_->PauseCapture(); @@ -431,7 +432,8 @@ HWTEST_F(DCameraClientTest, dcamera_client_test_005, TestSize.Level1) captureInfos.push_back(photoInfo_false_); sptr bp = videoSurface->GetProducer(); sptr pSurface = Surface::CreateSurfaceAsProducer(bp); - ret = client_->StartCapture(captureInfos, pSurface); + int32_t mode = 0; + ret = client_->StartCapture(captureInfos, pSurface, mode); EXPECT_EQ(DCAMERA_OK, ret); sleep(TEST_SLEEP_SEC); @@ -445,7 +447,7 @@ HWTEST_F(DCameraClientTest, dcamera_client_test_005, TestSize.Level1) captureInfos.clear(); captureInfos.push_back(videoInfo_false_); captureInfos.push_back(photoInfo_true_); - ret = client_->StartCapture(captureInfos, pSurface); + ret = client_->StartCapture(captureInfos, pSurface, mode); EXPECT_EQ(DCAMERA_OK, ret); sleep(TEST_SLEEP_SEC); @@ -625,7 +627,8 @@ HWTEST_F(DCameraClientTest, dcamera_client_test_013, TestSize.Level1) captureInfos.push_back(photoInfo_false_); sptr bp = videoSurface->GetProducer(); sptr pSurface = Surface::CreateSurfaceAsProducer(bp); - ret = client_->StartCapture(captureInfos, pSurface); + int32_t mode = 0; + ret = client_->StartCapture(captureInfos, pSurface, mode); EXPECT_EQ(DCAMERA_OK, ret); sleep(TEST_SLEEP_SEC); @@ -654,7 +657,8 @@ HWTEST_F(DCameraClientTest, dcamera_client_test_014, TestSize.Level1) DHLOGI("DCameraClientTest dcamera_client_test_014: test startCapture"); std::vector> captureInfos; sptr surface = nullptr; - int32_t ret = client_->StartCapture(captureInfos, surface); + int32_t mode = 0; + int32_t ret = client_->StartCapture(captureInfos, surface, mode); EXPECT_EQ(DCAMERA_BAD_VALUE, ret); } diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp index 5ab748d3..e0c0aabf 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp @@ -222,7 +222,6 @@ int32_t DCameraHandler::CreateDHItem(sptr& info, D std::string id = info->GetID(); item.dhId = CAMERA_ID_PREFIX + id; item.subtype = "camera"; - DHLOGI("camera id: %{public}s", GetAnonyString(id).c_str()); cJSON *root = cJSON_CreateObject(); CHECK_AND_RETURN_RET_LOG(root == nullptr, DCAMERA_BAD_VALUE, "Create cJSON object failed"); @@ -238,28 +237,42 @@ int32_t DCameraHandler::CreateDHItem(sptr& info, D std::vector previewProfiles = capability->GetPreviewProfiles(); ConfigFormatvideo(CONTINUOUS_FRAME, root, previewProfiles); + std::vector supportedModes = cameraManager_->GetSupportedModes(info); + cJSON *modeArray = cJSON_CreateArray(); + CHECK_AND_FREE_RETURN_RET_LOG(modeArray == nullptr, DCAMERA_BAD_VALUE, root, "Create modeArray object failed"); + cJSON_AddItemToObject(root, CAMERA_SUPPORT_MODE.c_str(), modeArray); + for (auto &mode : supportedModes) { + DHLOGI("The camera id: %{public}s, The supportedModes is : %{public}d", GetAnonyString(id).c_str(), mode); + cJSON_AddItemToArray(modeArray, cJSON_CreateNumber(mode)); + auto capability = cameraManager_->GetSupportedOutputCapability(info, mode); + CHECK_AND_FREE_RETURN_RET_LOG(capability == nullptr, DCAMERA_BAD_VALUE, root, "supported capability is null"); + cJSON *modeData = cJSON_CreateObject(); + CHECK_AND_FREE_RETURN_RET_LOG(modeData == nullptr, DCAMERA_BAD_VALUE, root, "Create cJSON object failed"); + std::vector photoProfiles = capability->GetPhotoProfiles(); + ConfigFormatphoto(SNAPSHOT_FRAME, modeData, photoProfiles); + + std::vector previewProfiles = capability->GetPreviewProfiles(); + ConfigFormatvideo(CONTINUOUS_FRAME, modeData, previewProfiles); + + cJSON_AddItemToObject(root, std::to_string(mode).c_str(), modeData); + } + sptr cameraInput = nullptr; int rv = cameraManager_->CreateCameraInput(info, &cameraInput); CHECK_AND_FREE_RETURN_RET_LOG(rv != DCAMERA_OK, DCAMERA_BAD_VALUE, root, "create cameraInput failed"); std::hash h; - std::string abilityString = cameraInput->GetCameraSettings(); - DHLOGI("abilityString hash: %{public}zu, length: %{public}zu", h(abilityString), abilityString.length()); + std::string abilityStr = cameraInput->GetCameraSettings(); + DHLOGI("abilityString hash: %{public}zu, length: %{public}zu", h(abilityStr), abilityStr.length()); - std::string encodeString = Base64Encode(reinterpret_cast(abilityString.c_str()), - abilityString.length()); - DHLOGI("encodeString hash: %zu, length: %zu", h(encodeString), encodeString.length()); - cJSON_AddStringToObject(root, CAMERA_METADATA_KEY.c_str(), encodeString.c_str()); + std::string encStr = Base64Encode(reinterpret_cast(abilityStr.c_str()), abilityStr.length()); + DHLOGI("encodeString hash: %zu, length: %zu", h(encStr), encStr.length()); + cJSON_AddStringToObject(root, CAMERA_METADATA_KEY.c_str(), encStr.c_str()); char *jsonstr = cJSON_Print(root); - if (jsonstr == nullptr) { - cJSON_Delete(root); - return DCAMERA_BAD_VALUE; - } + CHECK_AND_FREE_RETURN_RET_LOG(jsonstr == nullptr, DCAMERA_BAD_VALUE, root, "jsonstr is null"); item.attrs = jsonstr; - if (cameraInput->Release() != DCAMERA_OK) { - DHLOGE("cameraInput Release failed"); - } + CHECK_AND_LOG(cameraInput->Release() != DCAMERA_OK, "cameraInput Release failed"); cJSON_free(jsonstr); cJSON_Delete(root); return DCAMERA_OK; diff --git a/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h b/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h index db89b102..44d67ec1 100644 --- a/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h +++ b/services/cameraservice/sinkservice/include/distributedcameramgr/dcamera_sink_controller.h @@ -40,7 +40,7 @@ public: const sptr &sinkCallback); ~DCameraSinkController() override; - int32_t StartCapture(std::vector>& captureInfos) override; + int32_t StartCapture(std::vector>& captureInfos, int32_t sceneMode) override; int32_t StopCapture() override; int32_t ChannelNeg(std::shared_ptr& info) override; int32_t DCameraNotify(std::shared_ptr& events) override; @@ -102,6 +102,7 @@ private: bool isSensitive_ = false; bool isSameAccount_ = false; bool isCheckSecLevel_ = false; + int32_t sceneMode_ = 0; const std::string SESSION_FLAG = "control"; const std::string SRC_TYPE = "camera"; diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp index c94d88ea..573ed2ce 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_controller.cpp @@ -60,9 +60,10 @@ DCameraSinkController::~DCameraSinkController() } } -int32_t DCameraSinkController::StartCapture(std::vector>& captureInfos) +int32_t DCameraSinkController::StartCapture(std::vector>& captureInfos, + int32_t sceneMode) { - DHLOGI("StartCapture dhId: %{public}s", GetAnonyString(dhId_).c_str()); + DHLOGI("StartCapture dhId: %{public}s, mode: %{public}d", GetAnonyString(dhId_).c_str(), sceneMode); std::string accessType = ""; CHECK_AND_RETURN_RET_LOG(accessControl_ == nullptr, DCAMERA_BAD_VALUE, "accessControl_ is null."); if ((accessControl_->IsSensitiveSrcAccess(SRC_TYPE)) && @@ -535,7 +536,7 @@ int32_t DCameraSinkController::StartCaptureInner(std::vectorStartCapture(captureInfos, carrier.surface_); + ret = operator_->StartCapture(captureInfos, carrier.surface_, sceneMode_); if (ret != DCAMERA_OK) { DHLOGE("camera client start capture failed, dhId: %{public}s, ret: %{public}d", GetAnonyString(dhId_).c_str(), ret); @@ -588,7 +589,8 @@ int32_t DCameraSinkController::HandleReceivedData(std::shared_ptr& d GetAnonyString(dhId_).c_str(), ret); return ret; } - return StartCapture(captureInfoCmd.value_); + sceneMode_ = captureInfoCmd.sceneMode_; + return StartCapture(captureInfoCmd.value_, sceneMode_); } else if ((!command.empty()) && (command.compare(DCAMERA_PROTOCOL_CMD_UPDATE_METADATA) == 0)) { DCameraMetadataSettingCmd metadataSettingCmd; int ret = metadataSettingCmd.Unmarshal(jsonStr); diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/dcamera_sink_controller_test.cpp b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/dcamera_sink_controller_test.cpp index a7b0d8e6..dfb98e08 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/dcamera_sink_controller_test.cpp +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/dcamera_sink_controller_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -224,7 +224,8 @@ HWTEST_F(DCameraSinkControllerTest, dcamera_sink_controller_test_004, TestSize.L { DCameraCaptureInfoCmd cmd; cmd.Unmarshal(TEST_CAPTURE_INFO_CMD_JSON); - int32_t ret = controller_->StartCapture(cmd.value_); + int32_t mode = 0; + int32_t ret = controller_->StartCapture(cmd.value_, mode); EXPECT_EQ(DCAMERA_OK, ret); } @@ -239,7 +240,8 @@ HWTEST_F(DCameraSinkControllerTest, dcamera_sink_controller_test_005, TestSize.L SetTokenID(); DCameraCaptureInfoCmd cmd; cmd.Unmarshal(TEST_CAPTURE_INFO_CMD_JSON); - int32_t ret = controller_->StartCapture(cmd.value_); + int32_t mode = 0; + int32_t ret = controller_->StartCapture(cmd.value_, mode); EXPECT_EQ(DCAMERA_OK, ret); DCameraMetadataSettingCmd cmdMetadata; @@ -263,7 +265,8 @@ HWTEST_F(DCameraSinkControllerTest, dcamera_sink_controller_test_006, TestSize.L { DCameraCaptureInfoCmd cmd; cmd.Unmarshal(TEST_CAPTURE_INFO_CMD_JSON); - int32_t ret = controller_->StartCapture(cmd.value_); + int32_t mode = 0; + int32_t ret = controller_->StartCapture(cmd.value_, mode); EXPECT_EQ(DCAMERA_OK, ret); ret = controller_->StopCapture(); @@ -436,7 +439,8 @@ HWTEST_F(DCameraSinkControllerTest, dcamera_sink_controller_test_015, TestSize.L SetTokenID(); DCameraCaptureInfoCmd cmd; cmd.Unmarshal(TEST_CAPTURE_INFO_CMD_JSON); - int32_t ret = controller_->StartCapture(cmd.value_); + int32_t mode = 0; + int32_t ret = controller_->StartCapture(cmd.value_, mode); EXPECT_EQ(DCAMERA_OK, ret); DCameraMetadataSettingCmd cmdMetadata; @@ -525,7 +529,8 @@ HWTEST_F(DCameraSinkControllerTest, dcamera_sink_controller_test_021, TestSize.L DCameraCaptureInfoCmd cmd; cmd.Unmarshal(TEST_CAPTURE_INFO_CMD_JSON); g_outputStr = "test021"; - int32_t ret = controller_->StartCapture(cmd.value_); + int32_t mode = 0; + int32_t ret = controller_->StartCapture(cmd.value_, mode); EXPECT_EQ(DCAMERA_BAD_VALUE, ret); } @@ -541,7 +546,8 @@ HWTEST_F(DCameraSinkControllerTest, dcamera_sink_controller_test_022, TestSize.L cmd.Unmarshal(TEST_CAPTURE_INFO_CMD_JSON); g_outputStr = ""; g_operatorStr = "test022"; - int32_t ret = controller_->StartCapture(cmd.value_); + int32_t mode = 0; + int32_t ret = controller_->StartCapture(cmd.value_, mode); EXPECT_EQ(DCAMERA_ALLOC_ERROR, ret); } @@ -556,7 +562,8 @@ HWTEST_F(DCameraSinkControllerTest, dcamera_sink_controller_test_023, TestSize.L DCameraCaptureInfoCmd cmd; cmd.Unmarshal(TEST_CAPTURE_INFO_CMD_JSON); g_operatorStr = "test023"; - int32_t ret = controller_->StartCapture(cmd.value_); + int32_t mode = 0; + int32_t ret = controller_->StartCapture(cmd.value_, mode); EXPECT_EQ(DCAMERA_DEVICE_BUSY, ret); } diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h index 0e564fed..e3a28ded 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -67,7 +67,7 @@ public: } int32_t StartCapture(std::vector>& captureInfos, - sptr& surface) + sptr& surface, int32_t sceneMode) { if (g_operatorStr == "test022") { return DCAMERA_ALLOC_ERROR; diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h index f1a3887b..dec6dbd0 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -32,7 +32,7 @@ public: { } - int32_t StartCapture(std::vector>& captureInfos) + int32_t StartCapture(std::vector>& captureInfos, int32_t sceneMode) { return DCAMERA_OK; } diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h index 3e214d1d..eadc30ab 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h @@ -119,6 +119,7 @@ private: std::shared_ptr input_; std::atomic hicollieFlag_ = true; sptr hdiCallback_; + int32_t sceneMode_ = 0; std::map memberFuncMap_; std::map eventResultMap_; diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h index b46a54f3..03d0120c 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h @@ -35,7 +35,7 @@ public: DCameraSourceController(std::string devId, std::string dhId, std::shared_ptr& stateMachine, std::shared_ptr& camDev); ~DCameraSourceController() override; - int32_t StartCapture(std::vector>& captureInfos) override; + int32_t StartCapture(std::vector>& captureInfos, int32_t sceneMode) override; int32_t StopCapture() override; int32_t ChannelNeg(std::shared_ptr& info) override; int32_t DCameraNotify(std::shared_ptr& events) override; diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp index c3c3cc1d..dc7137c8 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp @@ -502,6 +502,10 @@ int32_t DCameraSourceDev::ConfigStreams(std::vectormode_; + break; + } int32_t ret = input_->ConfigStreams(streamInfos); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceDev Execute ConfigStreams ConfigStreams failed, ret: %{public}d, devId: %{public}s dhId: " @@ -603,7 +607,8 @@ int32_t DCameraSourceDev::StartCapture(std::vectorStartCapture(captures); + DHLOGI("startcapture sceneMode_: %{public}d", sceneMode_); + ret = controller_->StartCapture(captures, sceneMode_); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceDev Execute StartCapture StartCapture failed, ret: %{public}d, devId: %{public}s dhId: " "%{public}s", ret, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp index 7f75d017..20a69d04 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -61,7 +61,8 @@ DCameraSourceController::~DCameraSourceController() camHdiProvider_ = nullptr; } -int32_t DCameraSourceController::StartCapture(std::vector>& captureInfos) +int32_t DCameraSourceController::StartCapture(std::vector>& captureInfos, + int32_t sceneMode) { if (indexs_.size() > DCAMERA_MAX_NUM) { DHLOGE("StartCapture not support operate %{public}zu camera", indexs_.size()); @@ -77,6 +78,7 @@ int32_t DCameraSourceController::StartCapture(std::vectordataspace_ = iter->dataspace_; stream->encodeType_ = iter->encodeType_; stream->type_ = iter->type_; + stream->mode_ = iter->mode_; streams.push_back(stream); } int32_t ret = sourceDev->ConfigCameraStreams(streams); diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_controller_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_controller_test.cpp index 7698aa7d..f289abf0 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_controller_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_controller_test.cpp @@ -138,7 +138,8 @@ HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_003, TestSi index1.devId_ = TEST_DEVICE_ID; index1.dhId_ = TEST_CAMERA_DH_ID_0; controller_->indexs_.push_back(index1); - ret = controller_->StartCapture(captureInfos); + int32_t mode = 0; + ret = controller_->StartCapture(captureInfos, mode); controller_->UnInit(); EXPECT_EQ(ret, DCAMERA_OK); } @@ -166,7 +167,8 @@ HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_004, TestSi index1.devId_ = TEST_DEVICE_ID; index1.dhId_ = TEST_CAMERA_DH_ID_0; controller_->indexs_.push_back(index1); - ret = controller_->StartCapture(captureInfos); + int32_t mode = 0; + ret = controller_->StartCapture(captureInfos, mode); ret = controller_->StopCapture(); controller_->UnInit(); @@ -542,7 +544,8 @@ HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_020, TestSi int32_t ret = controller_->Init(indexs_); EXPECT_EQ(ret, DCAMERA_INIT_ERR); - ret = controller_->StartCapture(captureInfos); + int32_t mode = 0; + ret = controller_->StartCapture(captureInfos, mode); EXPECT_EQ(ret, DCAMERA_BAD_OPERATE); ret = controller_->StopCapture(); EXPECT_EQ(ret, DCAMERA_BAD_OPERATE); diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/mock_dcamera_source_controller.h b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/mock_dcamera_source_controller.h index 629a812a..87627d47 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/mock_dcamera_source_controller.h +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/mock_dcamera_source_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -33,7 +33,7 @@ public: { } - int32_t StartCapture(std::vector>& captureInfos) + int32_t StartCapture(std::vector>& captureInfos, int32_t sceneMode) { return DCAMERA_OK; } -- Gitee