mirror of
https://github.com/openharmony/distributed_camera.git
synced 2026-07-21 04:05:22 -04:00
!96 分布式相机codex清理:函数体超过50行
Merge pull request !96 from wangchaole/master
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
@@ -62,7 +62,8 @@ private:
|
||||
void Init(const std::string &abilityInfo);
|
||||
DCamRetCode CreateDStreamOperator();
|
||||
std::string GenerateCameraId(const std::shared_ptr<DHBase> &dhBase);
|
||||
|
||||
void NotifyStartCaptureError();
|
||||
void NotifyCameraError(const std::shared_ptr<DCameraHDFEvent> &event);
|
||||
private:
|
||||
bool isOpened_;
|
||||
std::string dCameraId_;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
@@ -391,28 +391,11 @@ DCamRetCode DCameraDevice::Notify(const std::shared_ptr<DCameraHDFEvent> &event)
|
||||
}
|
||||
case DCameraEventResult::DCAMERA_EVENT_CONFIG_STREAMS_ERROR:
|
||||
case DCameraEventResult::DCAMERA_EVENT_START_CAPTURE_ERROR: {
|
||||
if (dCameraDeviceCallback_ != nullptr) {
|
||||
dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0);
|
||||
}
|
||||
std::shared_ptr<DCameraProvider> provider = DCameraProvider::GetInstance();
|
||||
if ((provider != nullptr) && (dCameraStreamOperator_ != nullptr)) {
|
||||
std::vector<int> streamIds = dCameraStreamOperator_->GetStreamIds();
|
||||
provider->StopCapture(dhBase_, streamIds);
|
||||
}
|
||||
if (dCameraStreamOperator_ != nullptr) {
|
||||
dCameraStreamOperator_->Release();
|
||||
}
|
||||
NotifyStartCaptureError();
|
||||
break;
|
||||
}
|
||||
case DCameraEventResult::DCAMERA_EVENT_CAMERA_ERROR: {
|
||||
std::shared_ptr<DCameraHost> dCameraHost = DCameraHost::GetInstance();
|
||||
if (dCameraHost != nullptr) {
|
||||
dCameraHost->NotifyDCameraStatus(dhBase_, event->result_);
|
||||
}
|
||||
if (dCameraDeviceCallback_ != nullptr) {
|
||||
dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0);
|
||||
Close();
|
||||
}
|
||||
NotifyCameraError(event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -421,6 +404,33 @@ DCamRetCode DCameraDevice::Notify(const std::shared_ptr<DCameraHDFEvent> &event)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void DCameraDevice::NotifyStartCaptureError()
|
||||
{
|
||||
if (dCameraDeviceCallback_ != nullptr) {
|
||||
dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0);
|
||||
}
|
||||
std::shared_ptr<DCameraProvider> provider = DCameraProvider::GetInstance();
|
||||
if ((provider != nullptr) && (dCameraStreamOperator_ != nullptr)) {
|
||||
std::vector<int> streamIds = dCameraStreamOperator_->GetStreamIds();
|
||||
provider->StopCapture(dhBase_, streamIds);
|
||||
}
|
||||
if (dCameraStreamOperator_ != nullptr) {
|
||||
dCameraStreamOperator_->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void DCameraDevice::NotifyCameraError(const std::shared_ptr<DCameraHDFEvent> &event)
|
||||
{
|
||||
std::shared_ptr<DCameraHost> dCameraHost = DCameraHost::GetInstance();
|
||||
if (dCameraHost != nullptr) {
|
||||
dCameraHost->NotifyDCameraStatus(dhBase_, event->result_);
|
||||
}
|
||||
if (dCameraDeviceCallback_ != nullptr) {
|
||||
dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void DCameraDevice::SetProviderCallback(const OHOS::sptr<IDCameraProviderCallback> &callback)
|
||||
{
|
||||
dCameraProviderCallback_ = callback;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 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
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
@@ -97,7 +97,7 @@ int32_t DistributedCameraSinkService::InitSink(const std::string& params)
|
||||
DHLOGE("DistributedCameraSinkService::InitSink no camera device");
|
||||
return DCAMERA_BAD_VALUE;
|
||||
}
|
||||
g_camDump.camNumber = cameras.size();
|
||||
g_camDump.camNumber = static_cast<int32_t>(cameras.size());
|
||||
for (auto& dhId : cameras) {
|
||||
std::shared_ptr<DCameraSinkDev> sinkDevice = std::make_shared<DCameraSinkDev>(dhId);
|
||||
ret = sinkDevice->Init();
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 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
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
@@ -238,7 +238,7 @@ int DistributedCameraSourceService::Dump(int32_t fd, const std::vector<std::u16s
|
||||
|
||||
void DistributedCameraSourceService::GetDumpInfo(CameraDumpInfo& camDump)
|
||||
{
|
||||
camDump.regNumber = camerasMap_.size();
|
||||
camDump.regNumber = static_cast<int32_t>(camerasMap_.size());
|
||||
std::map<std::string, int32_t> curState;
|
||||
for (auto it = camerasMap_.begin(); it != camerasMap_.end(); it++) {
|
||||
DCameraIndex cam = it->first;
|
||||
|
||||
Reference in New Issue
Block a user