• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "dcamera_handler.h"
17 
18 #include <functional>
19 
20 #include "anonymous_string.h"
21 #include "avcodec_info.h"
22 #include "avcodec_list.h"
23 #include "dcamera_manager_callback.h"
24 #include "dcamera_utils_tools.h"
25 #include "distributed_camera_constants.h"
26 #include "distributed_camera_errno.h"
27 #include "distributed_hardware_log.h"
28 #include "metadata_utils.h"
29 
30 namespace OHOS {
31 namespace DistributedHardware {
32 IMPLEMENT_SINGLE_INSTANCE(DCameraHandler);
33 
34 const int32_t MAXWIDTHSIZE = 65535;
35 
~DCameraHandler()36 DCameraHandler::~DCameraHandler()
37 {
38     DHLOGI("~DCameraHandler");
39 }
40 
Initialize()41 int32_t DCameraHandler::Initialize()
42 {
43     DHLOGI("start");
44     cameraManager_ = CameraStandard::CameraManager::GetInstance();
45     if (cameraManager_ == nullptr) {
46         DHLOGE("cameraManager getInstance failed");
47         return DCAMERA_INIT_ERR;
48     }
49     std::shared_ptr<DCameraManagerCallback> cameraMgrCallback = std::make_shared<DCameraManagerCallback>();
50     cameraManager_->SetCallback(cameraMgrCallback);
51     DHLOGI("success");
52     return DCAMERA_OK;
53 }
54 
QueryMeta()55 std::vector<DHItem> DCameraHandler::QueryMeta()
56 {
57     std::vector<DHItem> itemList;
58     CHECK_AND_RETURN_RET_LOG(cameraManager_ == nullptr, itemList, "cameraManager is null.");
59     std::vector<sptr<CameraStandard::CameraDevice>> cameraList = cameraManager_->GetSupportedCameras();
60     uint64_t listSize = static_cast<uint64_t>(cameraList.size());
61     DHLOGI("get %{public}" PRIu64" cameras", listSize);
62     if (cameraList.empty()) {
63         DHLOGE("no camera device");
64         return itemList;
65     }
66     for (auto& info : cameraList) {
67         if (info == nullptr) {
68             DHLOGE("camera info is null");
69             continue;
70         }
71         if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) {
72             DHLOGI("connection type: %{public}d", info->GetConnectionType());
73             continue;
74         }
75         DHLOGI("get %{public}s, position: %{public}d, cameraType: %{public}d",
76             GetAnonyString(info->GetID()).c_str(), info->GetPosition(), info->GetCameraType());
77         DHItem item;
78         if (CreateMetaDHItem(info, item) == DCAMERA_OK) {
79             itemList.emplace_back(item);
80         }
81     }
82     listSize = static_cast<uint64_t>(itemList.size());
83     DHLOGI("success, get %{public}" PRIu64" items", listSize);
84     return itemList;
85 }
86 
Query()87 std::vector<DHItem> DCameraHandler::Query()
88 {
89     std::vector<DHItem> itemList;
90     CHECK_AND_RETURN_RET_LOG(cameraManager_ == nullptr, itemList, "cameraManager is null.");
91     std::vector<sptr<CameraStandard::CameraDevice>> cameraList = cameraManager_->GetSupportedCameras();
92     uint64_t listSize = static_cast<uint64_t>(cameraList.size());
93     DHLOGI("get %{public}" PRIu64" cameras", listSize);
94     if (cameraList.empty()) {
95         DHLOGE("no camera device");
96         return itemList;
97     }
98     for (auto& info : cameraList) {
99         if (info == nullptr) {
100             DHLOGE("camera info is null");
101             continue;
102         }
103         if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) {
104             DHLOGI("connection type: %{public}d", info->GetConnectionType());
105             continue;
106         }
107 #ifdef DCAMERA_FRONT
108         std::string position = GetCameraPosition(info->GetPosition());
109         if (position != CAMERA_POSITION_FRONT) {
110             DHLOGI("filter camera position is: %{public}s", position.c_str());
111             continue;
112         }
113 #endif
114         DHLOGI("get %{public}s, position: %{public}d, cameraType: %{public}d",
115             GetAnonyString(info->GetID()).c_str(), info->GetPosition(), info->GetCameraType());
116         DHItem item;
117         if (CreateDHItem(info, item) == DCAMERA_OK) {
118             itemList.emplace_back(item);
119         }
120     }
121     listSize = static_cast<uint64_t>(itemList.size());
122     DHLOGI("success, get %{public}" PRIu64" items", listSize);
123     return itemList;
124 }
125 
QueryExtraInfo()126 std::map<std::string, std::string> DCameraHandler::QueryExtraInfo()
127 {
128     DHLOGI("enter");
129     std::map<std::string, std::string> extraInfo;
130     return extraInfo;
131 }
132 
IsSupportPlugin()133 bool DCameraHandler::IsSupportPlugin()
134 {
135     DHLOGI("enter");
136     return false;
137 }
138 
RegisterPluginListener(std::shared_ptr<PluginListener> listener)139 void DCameraHandler::RegisterPluginListener(std::shared_ptr<PluginListener> listener)
140 {
141     DHLOGI("enter");
142     if (listener == nullptr) {
143         DHLOGE("DCameraHandler unregistering plugin listener");
144     }
145     pluginListener_ = listener;
146 }
147 
UnRegisterPluginListener()148 void DCameraHandler::UnRegisterPluginListener()
149 {
150     DHLOGI("enter");
151     pluginListener_ = nullptr;
152 }
153 
GetCameras()154 std::vector<std::string> DCameraHandler::GetCameras()
155 {
156     std::vector<std::string> cameras;
157     std::vector<sptr<CameraStandard::CameraDevice>> cameraList = cameraManager_->GetSupportedCameras();
158     uint64_t listSize = static_cast<uint64_t>(cameraList.size());
159     DHLOGI("get %{public}" PRIu64" cameras", listSize);
160     if (cameraList.empty()) {
161         DHLOGE("no camera device");
162         return cameras;
163     }
164     for (auto& info : cameraList) {
165         sptr<CameraStandard::CameraOutputCapability> capability = cameraManager_->GetSupportedOutputCapability(info);
166         if (capability == nullptr) {
167             DHLOGI("get supported capability is null");
168             continue;
169         }
170         if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) {
171             DHLOGI("connection type: %{public}d", info->GetConnectionType());
172             continue;
173         }
174         DHLOGI("get %{public}s, position: %{public}d, cameraType: %{public}d",
175             GetAnonyString(info->GetID()).c_str(), info->GetPosition(), info->GetCameraType());
176         std::string dhId = CAMERA_ID_PREFIX + info->GetID();
177         cameras.emplace_back(dhId);
178     }
179     listSize = static_cast<uint64_t>(cameras.size());
180     DHLOGI("success, get %{public}" PRIu64" items", listSize);
181     return cameras;
182 }
183 
CreateAVCodecList(cJSON * root)184 int32_t DCameraHandler::CreateAVCodecList(cJSON *root)
185 {
186     DHLOGI("Create avCodecList start");
187     std::shared_ptr<MediaAVCodec::AVCodecList> avCodecList = MediaAVCodec::AVCodecListFactory::CreateAVCodecList();
188     if (avCodecList == nullptr) {
189         DHLOGI("Create avCodecList failed");
190         return DCAMERA_BAD_VALUE;
191     }
192     const std::vector<std::string> encoderName = {std::string(MediaAVCodec::CodecMimeType::VIDEO_AVC),
193                                                   std::string(MediaAVCodec::CodecMimeType::VIDEO_HEVC)};
194     cJSON *array = cJSON_CreateArray();
195     if (array == nullptr) {
196         DHLOGI("Create arrray failed");
197         return DCAMERA_BAD_VALUE;
198     }
199     cJSON_AddItemToObject(root, CAMERA_CODEC_TYPE_KEY.c_str(), array);
200     for (auto &coder : encoderName) {
201         MediaAVCodec::CapabilityData *capData = avCodecList->GetCapability(coder, true,
202             MediaAVCodec::AVCodecCategory::AVCODEC_HARDWARE);
203         if (capData == nullptr) {
204             DHLOGI("capData is nullptr");
205             continue;
206         }
207         std::string mimeType = capData->mimeType;
208         cJSON_AddItemToArray(array, cJSON_CreateString(mimeType.c_str()));
209         DHLOGI("codec name: %{public}s, mimeType: %{public}s", coder.c_str(), mimeType.c_str());
210     }
211     return DCAMERA_OK;
212 }
213 
CreateMetaDHItem(sptr<CameraStandard::CameraDevice> & info,DHItem & item)214 int32_t DCameraHandler::CreateMetaDHItem(sptr<CameraStandard::CameraDevice>& info, DHItem& item)
215 {
216     CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "CreateMetaDHItem info is null");
217     std::string id = info->GetID();
218     item.dhId = CAMERA_ID_PREFIX + id;
219     item.subtype = "camera";
220     DHLOGI("camera id: %{public}s", GetAnonyString(id).c_str());
221 
222     cJSON *root = cJSON_CreateObject();
223     CHECK_AND_RETURN_RET_LOG(root == nullptr, DCAMERA_BAD_VALUE, "Create cJSON object failed");
224     cJSON_AddStringToObject(root, CAMERA_METADATA_KEY.c_str(), CAMERA_METADATA_KEY.c_str());
225     char *jsonstr = cJSON_Print(root);
226     if (jsonstr == nullptr) {
227         cJSON_Delete(root);
228         return DCAMERA_BAD_VALUE;
229     }
230     item.attrs = jsonstr;
231     cJSON_free(jsonstr);
232     cJSON_Delete(root);
233     return DCAMERA_OK;
234 }
235 
CreateDHItem(sptr<CameraStandard::CameraDevice> & info,DHItem & item)236 int32_t DCameraHandler::CreateDHItem(sptr<CameraStandard::CameraDevice>& info, DHItem& item)
237 {
238     CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "CreateDHItem info is null");
239     std::string id = info->GetID();
240     item.dhId = CAMERA_ID_PREFIX + id;
241     item.subtype = "camera";
242 
243     cJSON *root = cJSON_CreateObject();
244     CHECK_AND_RETURN_RET_LOG(root == nullptr, DCAMERA_BAD_VALUE, "Create cJSON object failed");
245     cJSON_AddStringToObject(root, CAMERA_PROTOCOL_VERSION_KEY.c_str(), CAMERA_PROTOCOL_VERSION_VALUE.c_str());
246     cJSON_AddStringToObject(root, CAMERA_POSITION_KEY.c_str(), GetCameraPosition(info->GetPosition()).c_str());
247     int32_t ret = CreateAVCodecList(root);
248     CHECK_AND_FREE_RETURN_RET_LOG(ret != DCAMERA_OK, DCAMERA_BAD_VALUE, root, "CreateAVCodecList failed");
249     sptr<CameraStandard::CameraOutputCapability> capability = cameraManager_->GetSupportedOutputCapability(info);
250     CHECK_AND_FREE_RETURN_RET_LOG(capability == nullptr, DCAMERA_BAD_VALUE, root, "get supported capability is null");
251     std::vector<CameraStandard::Profile> photoProfiles = capability->GetPhotoProfiles();
252     ConfigFormatphoto(SNAPSHOT_FRAME, root, photoProfiles);
253 
254     std::vector<CameraStandard::Profile> previewProfiles = capability->GetPreviewProfiles();
255     ConfigFormatvideo(CONTINUOUS_FRAME, root, previewProfiles);
256 
257     std::vector<CameraStandard::SceneMode> supportedModes = cameraManager_->GetSupportedModes(info);
258     if (!supportedModes.empty()) {
259         cJSON *modeArray = cJSON_CreateArray();
260         CHECK_AND_FREE_RETURN_RET_LOG(modeArray == nullptr, DCAMERA_BAD_VALUE, root, "Create modeArray object failed");
261         cJSON_AddItemToObject(root, CAMERA_SUPPORT_MODE.c_str(), modeArray);
262         for (auto &mode : supportedModes) {
263             DHLOGI("The camera id: %{public}s, The supportedModes is : %{public}d", GetAnonyString(id).c_str(), mode);
264             cJSON_AddItemToArray(modeArray, cJSON_CreateNumber(mode));
265             auto capability = cameraManager_->GetSupportedOutputCapability(info, mode);
266             CHECK_AND_FREE_RETURN_RET_LOG(
267                 capability == nullptr, DCAMERA_BAD_VALUE, root, "supported capability is null");
268             cJSON *modeData = cJSON_CreateObject();
269             CHECK_AND_FREE_RETURN_RET_LOG(modeData == nullptr, DCAMERA_BAD_VALUE, root, "Create cJSON object failed");
270             std::vector<CameraStandard::Profile> photoProfiles = capability->GetPhotoProfiles();
271             ConfigFormatphoto(SNAPSHOT_FRAME, modeData, photoProfiles);
272 
273             std::vector<CameraStandard::Profile> previewProfiles = capability->GetPreviewProfiles();
274             ConfigFormatvideo(CONTINUOUS_FRAME, modeData, previewProfiles);
275 
276             cJSON_AddItemToObject(root, std::to_string(mode).c_str(), modeData);
277         }
278     }
279 
280     ret = CreateMeatdataStr(info, root);
281     CHECK_AND_FREE_RETURN_RET_LOG(ret != DCAMERA_OK, DCAMERA_BAD_VALUE, root, "CreateMeatdataStr failed");
282     char *jsonstr = cJSON_Print(root);
283     CHECK_AND_FREE_RETURN_RET_LOG(jsonstr == nullptr, DCAMERA_BAD_VALUE, root, "jsonstr is null");
284 
285     item.attrs = jsonstr;
286     cJSON_free(jsonstr);
287     cJSON_Delete(root);
288     return DCAMERA_OK;
289 }
290 
CreateMeatdataStr(sptr<CameraStandard::CameraDevice> & info,cJSON * root)291 int32_t DCameraHandler::CreateMeatdataStr(sptr<CameraStandard::CameraDevice>& info, cJSON *root)
292 {
293     CHECK_AND_RETURN_RET_LOG(cameraManager_ == nullptr, DCAMERA_BAD_VALUE, "cameraManager is null");
294     sptr<CameraStandard::CameraInput> cameraInput = nullptr;
295     int32_t rv = cameraManager_->CreateCameraInput(info, &cameraInput);
296     if (rv != DCAMERA_OK) {
297         DHLOGE("create cameraInput failed");
298         return DCAMERA_BAD_VALUE;
299     }
300     CHECK_AND_RETURN_RET_LOG(cameraInput == nullptr, DCAMERA_BAD_VALUE, "cameraInput is null");
301     std::hash<std::string> h;
302     std::string abilityStr = cameraInput->GetCameraSettings();
303     DHLOGI("abilityString hash: %{public}zu, length: %{public}zu", h(abilityStr), abilityStr.length());
304 
305     std::string encStr = Base64Encode(reinterpret_cast<const unsigned char*>(abilityStr.c_str()), abilityStr.length());
306     DHLOGI("encodeString hash: %zu, length: %zu", h(encStr), encStr.length());
307     cJSON_AddStringToObject(root, CAMERA_METADATA_KEY.c_str(), encStr.c_str());
308     CHECK_AND_LOG(cameraInput->Release() != DCAMERA_OK, "cameraInput Release failed");
309     return DCAMERA_OK;
310 }
311 
GetCameraPosition(CameraStandard::CameraPosition position)312 std::string DCameraHandler::GetCameraPosition(CameraStandard::CameraPosition position)
313 {
314     DHLOGI("position: %{public}d", position);
315     std::string ret = "";
316     switch (position) {
317         case CameraStandard::CameraPosition::CAMERA_POSITION_BACK: {
318             ret = CAMERA_POSITION_BACK;
319             break;
320         }
321         case CameraStandard::CameraPosition::CAMERA_POSITION_FRONT: {
322             ret = CAMERA_POSITION_FRONT;
323             break;
324         }
325         case CameraStandard::CameraPosition::CAMERA_POSITION_UNSPECIFIED: {
326             ret = CAMERA_POSITION_UNSPECIFIED;
327             break;
328         }
329         default: {
330             DHLOGE("unknown camera position");
331             break;
332         }
333     }
334     DHLOGI("success ret: %{public}s", ret.c_str());
335     return ret;
336 }
337 
ProcessProfile(const DCStreamType type,std::map<std::string,std::list<std::string>> & formatMap,std::vector<CameraStandard::Profile> & profileList,std::set<int32_t> & formatSet)338 void DCameraHandler::ProcessProfile(const DCStreamType type, std::map<std::string, std::list<std::string>>& formatMap,
339     std::vector<CameraStandard::Profile>& profileList, std::set<int32_t>& formatSet)
340 {
341     for (auto& profile : profileList) {
342         CameraStandard::CameraFormat format = profile.GetCameraFormat();
343         CameraStandard::Size picSize = profile.GetSize();
344         int32_t dformat = CovertToDcameraFormat(format);
345         if (dformat == INVALID_FORMAT) {
346             continue;
347         }
348         formatSet.insert(dformat);
349         DHLOGD("width: %{public}d, height: %{public}d, format: %{public}d", picSize.width, picSize.height, dformat);
350         std::string formatName = std::to_string(dformat);
351         if (IsValid(type, picSize)) {
352             std::string resolutionValue = std::to_string(picSize.width) + "*" + std::to_string(picSize.height);
353             formatMap[formatName].push_back(resolutionValue);
354         }
355     }
356 }
357 
ConfigFormatphoto(const DCStreamType type,cJSON * root,std::vector<CameraStandard::Profile> & profileList)358 void DCameraHandler::ConfigFormatphoto(const DCStreamType type, cJSON* root,
359     std::vector<CameraStandard::Profile>& profileList)
360 {
361     DHLOGI("type: %{public}d, size: %{public}zu", type, profileList.size());
362     std::set<int32_t> formatSet;
363     cJSON* formatphotoObj = cJSON_CreateObject();
364     if (formatphotoObj == nullptr) {
365         return;
366     }
367     cJSON_AddItemToObject(root, CAMERA_FORMAT_PHOTO.c_str(), formatphotoObj);
368     std::map<std::string, std::list<std::string>> formatMap;
369     ProcessProfile(type, formatMap, profileList, formatSet);
370     cJSON* resolutionObj = cJSON_CreateObject();
371     if (resolutionObj == nullptr) {
372         return;
373     }
374     for (auto &pair : formatMap) {
375         cJSON* array = cJSON_CreateArray();
376         cJSON_AddItemToObject(resolutionObj, pair.first.c_str(), array);
377         for (auto &value : pair.second) {
378             cJSON_AddItemToArray(array, cJSON_CreateString(value.c_str()));
379         }
380     }
381     cJSON_AddItemToObject(formatphotoObj, CAMERA_RESOLUTION_KEY.c_str(), resolutionObj);
382     cJSON* array = cJSON_CreateArray();
383     if (array == nullptr) {
384         return;
385     }
386     for (auto format : formatSet) {
387         cJSON_AddItemToArray(array, cJSON_CreateNumber(format));
388     }
389     cJSON_AddItemToObject(formatphotoObj, CAMERA_FORMAT_KEY.c_str(), array);
390 }
391 
ConfigFormatvideo(const DCStreamType type,cJSON * root,std::vector<CameraStandard::Profile> & profileList)392 void DCameraHandler::ConfigFormatvideo(const DCStreamType type, cJSON* root,
393     std::vector<CameraStandard::Profile>& profileList)
394 {
395     DHLOGI("type: %d, size: %{public}zu", type, profileList.size());
396     std::set<int32_t> formatSet;
397     cJSON* formatpreviewObj = cJSON_CreateObject();
398     if (formatpreviewObj == nullptr) {
399         return;
400     }
401     cJSON_AddItemToObject(root, CAMERA_FORMAT_PREVIEW.c_str(), formatpreviewObj);
402     std::map<std::string, std::list<std::string>> formatMap;
403     ProcessProfile(type, formatMap, profileList, formatSet);
404     cJSON* resolutionObj = cJSON_CreateObject();
405     if (resolutionObj == nullptr) {
406         return;
407     }
408     for (auto &pair : formatMap) {
409         cJSON* array = cJSON_CreateArray();
410         cJSON_AddItemToObject(resolutionObj, pair.first.c_str(), array);
411         for (auto &value : pair.second) {
412             cJSON_AddItemToArray(array, cJSON_CreateString(value.c_str()));
413         }
414     }
415     cJSON_AddItemToObject(formatpreviewObj, CAMERA_RESOLUTION_KEY.c_str(), resolutionObj);
416     cJSON* array = cJSON_CreateArray();
417     if (array == nullptr) {
418         return;
419     }
420     for (auto format : formatSet) {
421         cJSON_AddItemToArray(array, cJSON_CreateNumber(format));
422     }
423     cJSON_AddItemToObject(formatpreviewObj, CAMERA_FORMAT_KEY.c_str(), array);
424     cJSON* formatvideoObj = cJSON_Duplicate(formatpreviewObj, 1);
425     cJSON_AddItemToObject(root, CAMERA_FORMAT_VIDEO.c_str(), formatvideoObj);
426 }
427 
CovertToDcameraFormat(CameraStandard::CameraFormat format)428 int32_t DCameraHandler::CovertToDcameraFormat(CameraStandard::CameraFormat format)
429 {
430     DHLOGD("format: %{public}d", format);
431     int32_t ret = INVALID_FORMAT;
432     switch (format) {
433         case CameraStandard::CameraFormat::CAMERA_FORMAT_RGBA_8888:
434             ret = camera_format_t::OHOS_CAMERA_FORMAT_RGBA_8888;
435             break;
436         case CameraStandard::CameraFormat::CAMERA_FORMAT_YCBCR_420_888:
437             ret = camera_format_t::OHOS_CAMERA_FORMAT_YCBCR_420_888;
438             break;
439         case CameraStandard::CameraFormat::CAMERA_FORMAT_YUV_420_SP:
440             ret = camera_format_t::OHOS_CAMERA_FORMAT_YCRCB_420_SP;
441             break;
442         case CameraStandard::CameraFormat::CAMERA_FORMAT_JPEG:
443             ret = camera_format_t::OHOS_CAMERA_FORMAT_JPEG;
444             break;
445         case CameraStandard::CameraFormat::CAMERA_FORMAT_YCBCR_P010:
446             ret = camera_format_t::OHOS_CAMERA_FORMAT_YCBCR_P010;
447             break;
448         case CameraStandard::CameraFormat::CAMERA_FORMAT_YCRCB_P010:
449             ret = camera_format_t::OHOS_CAMERA_FORMAT_YCRCB_P010;
450             break;
451         default:
452             DHLOGE("invalid camera format");
453             break;
454     }
455     return ret;
456 }
457 
IsValid(const DCStreamType type,const CameraStandard::Size & size)458 bool DCameraHandler::IsValid(const DCStreamType type, const CameraStandard::Size& size)
459 {
460     bool ret = false;
461     switch (type) {
462         case CONTINUOUS_FRAME: {
463             ret = (size.width >= RESOLUTION_MIN_WIDTH) &&
464                     (size.height >= RESOLUTION_MIN_HEIGHT) &&
465                     (size.width <= RESOLUTION_MAX_WIDTH_CONTINUOUS) &&
466                     (size.height <= RESOLUTION_MAX_HEIGHT_CONTINUOUS);
467             break;
468         }
469         case SNAPSHOT_FRAME: {
470             if (size.width > MAXWIDTHSIZE) {
471                 DHLOGE("size width out of range.");
472                 return ret;
473             }
474             uint64_t dcResolution = static_cast<uint64_t>(size.width * size.width);
475             uint64_t dcMaxResolution = static_cast<uint64_t>(RESOLUTION_MAX_WIDTH_SNAPSHOT *
476                                                              RESOLUTION_MAX_HEIGHT_SNAPSHOT);
477             uint64_t dcMinResolution = static_cast<uint64_t>(RESOLUTION_MIN_WIDTH *
478                                                              RESOLUTION_MIN_HEIGHT);
479             ret = (dcResolution >= dcMinResolution) && (dcResolution <= dcMaxResolution);
480             break;
481         }
482         default: {
483             DHLOGE("unknown stream type");
484             break;
485         }
486     }
487     return ret;
488 }
489 
GetHardwareHandler()490 IHardwareHandler* GetHardwareHandler()
491 {
492     DHLOGI("DCameraHandler::GetHardwareHandler");
493     return &DCameraHandler::GetInstance();
494 }
495 } // namespace DistributedHardware
496 } // namespace OHOS