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