1 /* 2 * Copyright (c) 2021-2022 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 58 const std::string ENCODE_TYPE_STR_H264 = "OMX_hisi_video_encoder_avc"; 59 const std::string ENCODE_TYPE_STR_H265 = "OMX_hisi_video_encoder_hevc"; 60 const std::string ENCODE_TYPE_STR_JPEG = "jpeg"; 61 const std::string DC_LOG_TITLE_TAG = "DCAMERA"; 62 constexpr int32_t LOG_MAX_LEN = 4096; 63 constexpr uint64_t SEC_TO_NSEC_TIMES = 1000000000; 64 65 typedef enum { 66 OHOS_CAMERA_FORMAT_INVALID = 0, 67 OHOS_CAMERA_FORMAT_RGBA_8888, 68 OHOS_CAMERA_FORMAT_YCBCR_420_888, 69 OHOS_CAMERA_FORMAT_YCRCB_420_SP, 70 OHOS_CAMERA_FORMAT_JPEG, 71 } DCameraFormat; 72 73 typedef enum { 74 DCAMERA_MESSAGE = 0, 75 DCAMERA_OPERATION = 1, 76 } DCameraEventType; 77 78 typedef enum { 79 DCAMERA_EVENT_CHANNEL_DISCONNECTED = 0, 80 DCAMERA_EVENT_CHANNEL_CONNECTED = 1, 81 DCAMERA_EVENT_CAMERA_SUCCESS = 2, 82 83 DCAMERA_EVENT_CAMERA_ERROR = -1, 84 DCAMERA_EVENT_OPEN_CHANNEL_ERROR = -2, 85 DCAMERA_EVENT_CLOSE_CHANNEL_ERROR = -3, 86 DCAMERA_EVENT_CONFIG_STREAMS_ERROR = -4, 87 DCAMERA_EVENT_RELEASE_STREAMS_ERROR = -5, 88 DCAMERA_EVENT_START_CAPTURE_ERROR = -6, 89 DCAMERA_EVENT_STOP_CAPTURE_ERROR = -7, 90 DCAMERA_EVENT_UPDATE_SETTINGS_ERROR = -8, 91 DCAMERA_EVENT_DEVICE_ERROR = -9, 92 DCAMERA_EVENT_DEVICE_PREEMPT = -10, 93 DCAMERA_EVENT_DEVICE_IN_USE = -11, 94 DCAMERA_EVENT_NO_PERMISSION = -12, 95 } DCameraEventResult; 96 97 enum DCameraBufferUsage : uint64_t { 98 CAMERA_USAGE_SW_READ_OFTEN = (1 << 0), 99 CAMERA_USAGE_SW_WRITE_OFTEN = (1 << 1), 100 CAMERA_USAGE_MEM_DMA = (1 << 2), 101 }; 102 103 using DCSceneType = enum _DCSceneType : int32_t { 104 PREVIEW = 0, 105 VIDEO = 1, 106 PHOTO = 2 107 }; 108 109 using RetCode = uint32_t; 110 enum Ret : uint32_t { 111 RC_OK = 0, 112 RC_ERROR, 113 }; 114 115 struct DCResolution { 116 int32_t width_; 117 int32_t height_; 118 DCResolutionDCResolution119 DCResolution() : width_(0), height_(0) {} 120 DCResolutionDCResolution121 DCResolution(int32_t width, int32_t height) : width_(width), height_(height) {} 122 123 bool operator ==(const DCResolution others) const 124 { 125 return (this->width_ == others.width_) && (this->height_ == others.height_); 126 } 127 128 bool operator <(const DCResolution others) const 129 { 130 return this->width_ < others.width_ || 131 (this->width_ == others.width_ && this->height_ < others.height_); 132 } 133 }; 134 } // namespace DistributedHardware 135 } // namespace OHOS 136 #endif // DISTRIBUTED_CONSTANTS_H 137