1 /* 2 * Copyright (c) 2021-2023 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 #ifndef DISTRIBUTED_CONSTANTS_H 17 #define DISTRIBUTED_CONSTANTS_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace DistributedHardware { 24 const uint32_t YUV_WIDTH_RATIO = 3; 25 const uint32_t YUV_HEIGHT_RATIO = 2; 26 27 const uint32_t DEVID_MAX_LENGTH = 256; 28 const uint32_t DHID_MAX_LENGTH = 256; 29 const uint32_t CONTAINER_CAPACITY_MAX_SIZE = 50 * 1024 * 1024; 30 const uint32_t METADATA_CAPACITY_MAX_SIZE = 50 * 1024 * 1024; 31 const int32_t STREAM_HEIGHT_MAX_SIZE = 10000; 32 const int32_t STREAM_WIDTH_MAX_SIZE = 10000; 33 const int32_t JPEG_MAX_SIZE = 24 * 1024 * 1024; 34 35 constexpr size_t DEFAULT_ENTRY_CAPACITY = 100; 36 constexpr size_t DEFAULT_DATA_CAPACITY = 2000; 37 38 const uint32_t SIZE_FMT_LEN = 2; 39 const uint32_t MAX_SUPPORT_PREVIEW_WIDTH = 1920; 40 const uint32_t MAX_SUPPORT_PREVIEW_HEIGHT = 1080; 41 const uint32_t MAX_SUPPORT_PHOTO_WIDTH = 4096; 42 const uint32_t MAX_SUPPORT_PHOTO_HEIGHT = 3072; 43 const std::string STAR_SEPARATOR = "*"; 44 45 const uint32_t MIN_SUPPORT_DEFAULT_FPS = 15; 46 const uint32_t MAX_SUPPORT_DEFAULT_FPS = 30; 47 48 const int64_t MAX_FRAME_DURATION = 1000000000LL / 10; 49 50 const uint32_t BUFFER_QUEUE_SIZE = 8; 51 52 const uint32_t DEGREE_180 = 180; 53 const uint32_t DEGREE_240 = 240; 54 55 const uint32_t INGNORE_STR_LEN = 2; 56 57 const uint32_t WAIT_OPEN_TIMEOUT_SEC = 5; 58 const uint32_t BUFFER_SYNC_FENCE_TIMEOUT = 100; 59 60 const std::string ENCODE_TYPE_STR_H264 = "video/avc"; 61 const std::string ENCODE_TYPE_STR_H265 = "video/hevc"; 62 const std::string ENCODE_TYPE_STR_JPEG = "jpeg"; 63 const std::string ENCODE_TYPE_STR_MPEG4_ES = "video/mp4v-es"; 64 const std::string DC_LOG_TITLE_TAG = "DCAMERA"; 65 constexpr int32_t LOG_MAX_LEN = 4096; 66 constexpr uint64_t SEC_TO_NSEC_TIMES = 1000000000; 67 68 typedef enum { 69 OHOS_CAMERA_FORMAT_INVALID = 0, 70 OHOS_CAMERA_FORMAT_RGBA_8888, 71 OHOS_CAMERA_FORMAT_YCBCR_420_888, 72 OHOS_CAMERA_FORMAT_YCRCB_420_SP, 73 OHOS_CAMERA_FORMAT_JPEG, 74 } DCameraFormat; 75 76 typedef enum { 77 DCAMERA_MESSAGE = 0, 78 DCAMERA_OPERATION = 1, 79 } DCameraEventType; 80 81 typedef enum { 82 DCAMERA_EVENT_CHANNEL_DISCONNECTED = 0, 83 DCAMERA_EVENT_CHANNEL_CONNECTED = 1, 84 DCAMERA_EVENT_CAMERA_SUCCESS = 2, 85 86 DCAMERA_EVENT_CAMERA_ERROR = -1, 87 DCAMERA_EVENT_OPEN_CHANNEL_ERROR = -2, 88 DCAMERA_EVENT_CLOSE_CHANNEL_ERROR = -3, 89 DCAMERA_EVENT_CONFIG_STREAMS_ERROR = -4, 90 DCAMERA_EVENT_RELEASE_STREAMS_ERROR = -5, 91 DCAMERA_EVENT_START_CAPTURE_ERROR = -6, 92 DCAMERA_EVENT_STOP_CAPTURE_ERROR = -7, 93 DCAMERA_EVENT_UPDATE_SETTINGS_ERROR = -8, 94 DCAMERA_EVENT_DEVICE_ERROR = -9, 95 DCAMERA_EVENT_DEVICE_PREEMPT = -10, 96 DCAMERA_EVENT_DEVICE_IN_USE = -11, 97 DCAMERA_EVENT_NO_PERMISSION = -12, 98 } DCameraEventResult; 99 100 enum DCameraBufferUsage : uint64_t { 101 CAMERA_USAGE_SW_READ_OFTEN = (1 << 0), 102 CAMERA_USAGE_SW_WRITE_OFTEN = (1 << 1), 103 CAMERA_USAGE_MEM_DMA = (1 << 2), 104 }; 105 106 using DCSceneType = enum _DCSceneType : int32_t { 107 PREVIEW = 0, 108 VIDEO = 1, 109 PHOTO = 2 110 }; 111 112 using RetCode = uint32_t; 113 enum Ret : uint32_t { 114 RC_OK = 0, 115 RC_ERROR, 116 }; 117 118 struct DCResolution { 119 int32_t width_; 120 int32_t height_; 121 DCResolutionDCResolution122 DCResolution() : width_(0), height_(0) {} 123 DCResolutionDCResolution124 DCResolution(int32_t width, int32_t height) : width_(width), height_(height) {} 125 126 bool operator ==(const DCResolution others) const 127 { 128 return (this->width_ == others.width_) && (this->height_ == others.height_); 129 } 130 131 bool operator <(const DCResolution others) const 132 { 133 return this->width_ < others.width_ || 134 (this->width_ == others.width_ && this->height_ < others.height_); 135 } 136 }; 137 } // namespace DistributedHardware 138 } // namespace OHOS 139 #endif // DISTRIBUTED_CONSTANTS_H 140