diff --git a/services/cameraservice/cameraoperator/client/include/dcamera_client.h b/services/cameraservice/cameraoperator/client/include/dcamera_client.h index 87c231f6f6850cd761fec243a890375898dd8901..e973bfad2c42b264309ee531238afa7fb36cd0ee 100644 --- a/services/cameraservice/cameraoperator/client/include/dcamera_client.h +++ b/services/cameraservice/cameraoperator/client/include/dcamera_client.h @@ -65,8 +65,9 @@ private: void ReleaseCaptureSession(); int32_t CameraServiceErrorType(const int32_t errorType); - bool isInit_; - std::string cameraId_; + bool isInit_ = false; + std::string cameraId_ = ""; + std::string latestCameraMetadata_ = ""; sptr photoSurface_; sptr videoSurface_; sptr cameraInfo_; diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp index 8d241716031f2cdb12ff4b9a7bfc7bd6f251aeee..25f717a99f3c5a7db5d21a8c636f603a76a4bed1 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp @@ -102,6 +102,7 @@ int32_t DCameraClient::UpdateSettings(std::vector &)cameraInput_)->SetErrorCallback(inputCallback); ((sptr &)cameraInput_)->SetFocusCallback(inputCallback); + if (!latestCameraMetadata_.empty()) { + FindCameraMetadata(latestCameraMetadata_); + int32_t ret = ((sptr &)cameraInput_)->SetCameraSettings(latestCameraMetadata_); + latestCameraMetadata_ = ""; + if (ret != DCAMERA_OK) { + DHLOGE("DCameraClient::ConfigCaptureSession %s set camera settings failed, ret: %d", + GetAnonyString(cameraId_).c_str(), ret); + return ret; + } + } + captureSession_ = cameraManager_->CreateCaptureSession(); if (captureSession_ == nullptr) { DHLOGE("DCameraClient::ConfigCaptureSession %s create captureSession failed", diff --git a/services/cameraservice/cameraoperator/client/test/sample/main.cpp b/services/cameraservice/cameraoperator/client/test/sample/main.cpp index 7e268cbbe05caf3d8d1bea4d821d30548d6fe226..80c51044bcfcb7124a97cb6f6f6cd3e1bcd77c50 100644 --- a/services/cameraservice/cameraoperator/client/test/sample/main.cpp +++ b/services/cameraservice/cameraoperator/client/test/sample/main.cpp @@ -142,6 +142,22 @@ static void InitVideoOutput() ((sptr &)g_videoOutput)->SetCallback(std::make_shared()); } +static void ConfigCaptureSession() +{ + g_captureSession->BeginConfig(); + g_captureSession->AddInput(g_cameraInput); + g_captureSession->AddOutput(g_previewOutput); + g_captureSession->AddOutput(g_videoOutput); + g_captureSession->AddOutput(g_photoOutput); + + std::vector stabilizationModes = g_captureSession->GetSupportedStabilizationMode(); + for (auto mode : stabilizationModes) { + DHLOGI("Distributed Camera Demo: video stabilization mode %d", mode); + } + g_captureSession->SetVideoStabilizationMode(stabilizationModes.back()); + g_captureSession->CommitConfig(); +} + static void ConfigFocusAndExposure() { ((sptr &)g_cameraInput)->LockForControl(); @@ -190,22 +206,11 @@ int main() InitPhotoOutput(); InitPreviewOutput(); InitVideoOutput(); + ConfigCaptureSession(); - g_captureSession->BeginConfig(); - g_captureSession->AddInput(g_cameraInput); - g_captureSession->AddOutput(g_previewOutput); - g_captureSession->AddOutput(g_videoOutput); - g_captureSession->AddOutput(g_photoOutput); - g_captureSession->CommitConfig(); g_captureSession->Start(); sleep(SLEEP_FIVE_SECOND); - std::vector stabilizationModes = g_captureSession->GetSupportedStabilizationMode(); - for (auto mode : stabilizationModes) { - DHLOGI("Distributed Camera Demo: video stabilization mode %d", mode); - } - g_captureSession->SetVideoStabilizationMode(stabilizationModes.back()); - ((sptr &)g_videoOutput)->Start(); sleep(SLEEP_FIVE_SECOND);