1 /* 2 * Copyright (c) 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 OHOS_AV_TRANSPORT_TYPES_H 17 #define OHOS_AV_TRANSPORT_TYPES_H 18 19 #include <string> 20 #include <unistd.h> 21 22 namespace OHOS { 23 namespace DistributedHardware { 24 const std::string OWNER_NAME_D_CAMERA = "ohos.dhardware.dcamera"; 25 const std::string OWNER_NAME_D_SCREEN = "ohos.dhardware.dscreen"; 26 const std::string OWNER_NAME_D_MIC = "ohos.dhardware.daudio.dmic"; 27 const std::string OWNER_NAME_D_SPEAKER = "ohos.dhardware.daudio.dspeaker"; 28 const std::string OWNER_NAME_D_VIRMODEM_MIC = "ohos.dhardware.dcall.dmic"; 29 const std::string OWNER_NAME_D_VIRMODEM_SPEAKER = "ohos.dhardware.dcall.dspeaker"; 30 31 const std::string SCENE_TYPE_D_MIC = "dmic_stream"; 32 const std::string SCENE_TYPE_D_SCREEN = "dscreen_stream"; 33 const std::string SCENE_TYPE_D_SPEAKER = "dspeaker_stream"; 34 const std::string SCENE_TYPE_D_CAMERA_STR = "dcamera_stream"; 35 const std::string SCENE_TYPE_D_CAMERA_PIC = "dcamera_picture"; 36 37 const std::string PKG_NAME_DH_FWK = "ohos.dhardware"; 38 const std::string PKG_NAME_D_AUDIO = "ohos.dhardware.daudio"; 39 const std::string PKG_NAME_D_CALL = "ohos.dhardware.dcall"; 40 const std::string PKG_NAME_D_CAMERA = "ohos.dhardware.dcamera"; 41 const std::string PKG_NAME_D_SCREEN = "ohos.dhardware.dscreen"; 42 43 const std::string MIME_VIDEO_RAW = "video/raw"; 44 const std::string MIME_VIDEO_H264 = "video/avc"; 45 const std::string MIME_VIDEO_H265 = "video/hevc"; 46 47 const std::string VIDEO_FORMAT_NV12 = "nv12"; 48 const std::string VIDEO_FORMAT_NV21 = "nv21"; 49 const std::string VIDEO_FORMAT_JEPG = "jpeg"; 50 const std::string VIDEO_FORMAT_YUVI420 = "yuvi420"; 51 const std::string VIDEO_FORMAT_RGBA8888 = "rgba8888"; 52 53 enum struct TransRole : uint32_t { 54 AV_SENDER = 0, 55 AV_RECEIVER = 1, 56 UNKNOWN = 2 57 }; 58 59 enum struct AvSyncFlag : uint32_t { 60 MASTER = 0, 61 SLAVE = 1, 62 UNKNOWN = 2 63 }; 64 65 enum struct TransStrategy : uint32_t { 66 LOW_LATANCY_STRATEGY, 67 LOW_JITTER_STRATEGY 68 }; 69 70 struct ChannelAttribute { 71 TransStrategy strategy; 72 }; 73 74 enum struct BufferDataType : uint32_t { 75 AUDIO = 0, 76 VIDEO_STREAM, 77 PICTURE, 78 UNKNOW, 79 }; 80 81 enum struct StateId : uint32_t { 82 IDLE = 0, 83 INITIALIZED = 1, 84 CH_CREATED = 2, 85 STARTED = 3, 86 PLAYING = 4, 87 STOPPED = 5, 88 BUTT, 89 }; 90 91 enum struct TagSection : uint8_t { 92 REGULAR = 1, 93 D_AUDIO = 2, 94 D_VIDEO = 3, 95 MAX_SECTION = 64 96 }; 97 98 enum struct AVTransTag : uint32_t { 99 INVALID = 0, 100 SECTION_REGULAR_START = static_cast<uint8_t>(TagSection::REGULAR) << 16U, 101 SECTION_D_AUDIO_START = static_cast<uint8_t>(TagSection::D_AUDIO) << 16U, 102 SECTION_D_VIDEO_START = static_cast<uint8_t>(TagSection::D_VIDEO) << 16U, 103 104 /* -------------------- regular tag -------------------- */ 105 FRAME_NUMBER = SECTION_REGULAR_START + 1, 106 BUFFER_DATA_TYPE, 107 PRE_TIMESTAMP, 108 CUR_TIMESTAMP, 109 ENGINE_READY, 110 ENGINE_PAUSE, 111 ENGINE_RESUME, 112 START_AV_SYNC, 113 STOP_AV_SYNC, 114 TIME_SYNC_RESULT, 115 SHARED_MEMORY_FD, 116 117 /* -------------------- d_audio tag -------------------- */ 118 AUDIO_CHANNELS = SECTION_D_AUDIO_START + 1, 119 AUDIO_SAMPLE_RATE, 120 AUDIO_CODEC_TYPE, 121 AUDIO_CHANNEL_MASK, 122 AUDIO_SAMPLE_FORMAT, 123 AUDIO_FRAME_SIZE, 124 AUDIO_STREAM_USAGE, 125 AUDIO_RENDER_FLAGS, 126 AUDIO_CONTENT_TYPE, 127 AUDIO_CHANNEL_LAYOUT, 128 AUDIO_BIT_RATE, 129 130 /* -------------------- d_video tag -------------------- */ 131 VIDEO_WIDTH = SECTION_D_VIDEO_START + 1, 132 VIDEO_HEIGHT, 133 VIDEO_CODEC_TYPE, 134 VIDEO_PIXEL_FORMAT, 135 VIDEO_FRAME_RATE, 136 VIDEO_BIT_RATE, 137 }; 138 139 enum struct EventType : uint32_t { 140 EVENT_CHANNEL_OPENED = 0, 141 EVENT_CHANNEL_OPEN_FAIL = 1, 142 EVENT_CHANNEL_CLOSED = 2, 143 EVENT_START_SUCCESS = 3, 144 EVENT_START_FAIL = 4, 145 EVENT_STOP_SUCCESS = 5, 146 EVENT_STOP_FAIL = 6, 147 EVENT_ENGINE_ERROR = 7, 148 EVENT_REMOTE_ERROR = 8, 149 EVENT_DATA_RECEIVED = 9, 150 EVENT_TIME_SYNC_RESULT = 10, 151 EVENT_ADD_STREAM = 11, 152 EVENT_REMOVE_STREAM = 12, 153 }; 154 155 struct AVTransEvent { 156 EventType type; 157 std::string content; 158 std::string peerDevId; 159 }; 160 161 struct AVStreamInfo { 162 std::string sceneType; 163 std::string peerDevId; 164 }; 165 } // namespace DistributedHardware 166 } // namespace OHOS 167 #endif // OHOS_AV_TRANSPORT_TYPES_H