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