1e0e9324cSopenharmony_ci/*
2e0e9324cSopenharmony_ci * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3e0e9324cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0e9324cSopenharmony_ci * you may not use this file except in compliance with the License.
5e0e9324cSopenharmony_ci * You may obtain a copy of the License at
6e0e9324cSopenharmony_ci *
7e0e9324cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0e9324cSopenharmony_ci *
9e0e9324cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0e9324cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0e9324cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0e9324cSopenharmony_ci * See the License for the specific language governing permissions and
13e0e9324cSopenharmony_ci * limitations under the License.
14e0e9324cSopenharmony_ci */
15e0e9324cSopenharmony_ci
16e0e9324cSopenharmony_ci#ifndef OHOS_SHARING_CONST_DEF_H
17e0e9324cSopenharmony_ci#define OHOS_SHARING_CONST_DEF_H
18e0e9324cSopenharmony_ci
19e0e9324cSopenharmony_ci#include <string>
20e0e9324cSopenharmony_ci
21e0e9324cSopenharmony_cinamespace OHOS {
22e0e9324cSopenharmony_cinamespace Sharing {
23e0e9324cSopenharmony_ci
24e0e9324cSopenharmony_cienum MediaType { MEDIA_TYPE_AV, MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO };
25e0e9324cSopenharmony_ci
26e0e9324cSopenharmony_cienum SceneType { FOREGROUND = 0, BACKGROUND = 1 };
27e0e9324cSopenharmony_ci
28e0e9324cSopenharmony_cienum VideoFormat {
29e0e9324cSopenharmony_ci    VIDEO_640X480_25 = 0,
30e0e9324cSopenharmony_ci    VIDEO_640X480_30,
31e0e9324cSopenharmony_ci    VIDEO_640X480_60,
32e0e9324cSopenharmony_ci    VIDEO_1280X720_25,
33e0e9324cSopenharmony_ci    VIDEO_1280X720_30,
34e0e9324cSopenharmony_ci    VIDEO_1280X720_60,
35e0e9324cSopenharmony_ci    VIDEO_1920X1080_25,
36e0e9324cSopenharmony_ci    VIDEO_1920X1080_30,
37e0e9324cSopenharmony_ci    VIDEO_1920X1080_60
38e0e9324cSopenharmony_ci};
39e0e9324cSopenharmony_ci
40e0e9324cSopenharmony_cienum AudioFormat {
41e0e9324cSopenharmony_ci    AUDIO_8000_8_1 = 0,
42e0e9324cSopenharmony_ci    AUDIO_8000_8_2,
43e0e9324cSopenharmony_ci    AUDIO_8000_16_1,
44e0e9324cSopenharmony_ci    AUDIO_8000_16_2,
45e0e9324cSopenharmony_ci
46e0e9324cSopenharmony_ci    AUDIO_11025_8_1 = 10,
47e0e9324cSopenharmony_ci    AUDIO_11025_8_2,
48e0e9324cSopenharmony_ci    AUDIO_11025_16_1,
49e0e9324cSopenharmony_ci    AUDIO_11025_16_2,
50e0e9324cSopenharmony_ci
51e0e9324cSopenharmony_ci    AUDIO_22050_8_1 = 20,
52e0e9324cSopenharmony_ci    AUDIO_22050_8_2,
53e0e9324cSopenharmony_ci    AUDIO_22050_16_1,
54e0e9324cSopenharmony_ci    AUDIO_22050_16_2,
55e0e9324cSopenharmony_ci
56e0e9324cSopenharmony_ci    AUDIO_44100_8_1 = 30,
57e0e9324cSopenharmony_ci    AUDIO_44100_8_2,
58e0e9324cSopenharmony_ci    AUDIO_44100_16_1,
59e0e9324cSopenharmony_ci    AUDIO_44100_16_2,
60e0e9324cSopenharmony_ci    AUDIO_44100_16_4,
61e0e9324cSopenharmony_ci
62e0e9324cSopenharmony_ci    AUDIO_48000_8_1 = 40,
63e0e9324cSopenharmony_ci    AUDIO_48000_8_2,
64e0e9324cSopenharmony_ci    AUDIO_48000_16_1,
65e0e9324cSopenharmony_ci    AUDIO_48000_16_2,
66e0e9324cSopenharmony_ci    AUDIO_48000_16_4
67e0e9324cSopenharmony_ci};
68e0e9324cSopenharmony_ci
69e0e9324cSopenharmony_ciconstexpr uint32_t WFD_MSEC_IN_SEC = 1000;
70e0e9324cSopenharmony_ci
71e0e9324cSopenharmony_ciconstexpr uint32_t AUDIO_SAMPLE_BIT_U8 = 8;
72e0e9324cSopenharmony_ciconstexpr uint32_t AUDIO_SAMPLE_BIT_S16LE = 16;
73e0e9324cSopenharmony_ciconstexpr uint32_t AUDIO_CHANNEL_STEREO = 2;
74e0e9324cSopenharmony_ciconstexpr uint32_t AUDIO_SAMPLE_RATE_44100 = 44100;
75e0e9324cSopenharmony_ciconstexpr uint32_t AUDIO_SAMPLE_RATE_48000 = 48000;
76e0e9324cSopenharmony_ciconstexpr uint32_t AUDIO_BIT_RATE_12800 = 128000;
77e0e9324cSopenharmony_ciconstexpr uint32_t SAMPLE_RATE_90K = 90000;
78e0e9324cSopenharmony_ci
79e0e9324cSopenharmony_ciconstexpr uint32_t INVALID_ID = 0;
80e0e9324cSopenharmony_ciconstexpr int32_t DEFAULT_CHANNEL = 2;
81e0e9324cSopenharmony_ciconstexpr int32_t DEFAULT_SAMPLERATE = 48000;
82e0e9324cSopenharmony_ci
83e0e9324cSopenharmony_ciconstexpr uint16_t MIN_PORT = 6700;
84e0e9324cSopenharmony_ciconstexpr uint16_t MAX_PORT = 7000;
85e0e9324cSopenharmony_ciconstexpr uint16_t DEFAULT_WFD_CTRLPORT = 7236;
86e0e9324cSopenharmony_ci
87e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_VIDEO_WIDTH = 1920;
88e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_VIDEO_HEIGHT = 1080;
89e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_WINDOW_WIDTH = 1920;
90e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_WINDOW_HEIGHT = 1080;
91e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_CAPTURE_VIDEO_WIDTH = 1280;
92e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_CAPTURE_VIDEO_HEIGHT = 720;
93e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_FRAME_RATE = 30;
94e0e9324cSopenharmony_ciconstexpr uint32_t DEFAULT_SAMPLE_BIT = 16;
95e0e9324cSopenharmony_ci
96e0e9324cSopenharmony_ciconstexpr int32_t MAX_CONTEXT_NUM = 20;
97e0e9324cSopenharmony_ciconstexpr int32_t MAX_SRC_AGENT_NUM = 20;
98e0e9324cSopenharmony_ciconstexpr int32_t MAX_SINK_AGENT_NUM = 20;
99e0e9324cSopenharmony_ciconstexpr int64_t MAX_YUV420_BUFFER_SIZE = 2560 * 1600 * (3 / 2) * 2;
100e0e9324cSopenharmony_ciconstexpr int32_t MAX_RTSP_PLAYER_NUM = 2;
101e0e9324cSopenharmony_ci
102e0e9324cSopenharmony_ciconstexpr int32_t SCREEN_CAPTURE_ENCODE_BITRATE = 2000000;
103e0e9324cSopenharmony_ciconstexpr uint64_t SCREEN_ID_INVALID = -1ULL;
104e0e9324cSopenharmony_ciconstexpr float DEFAULT_SCREEN_DENSITY = 2.0;
105e0e9324cSopenharmony_ciconstexpr int32_t DEFAULT_SCREEN_FLAGS = 0;
106e0e9324cSopenharmony_ci
107e0e9324cSopenharmony_ciconst std::string DUMMY_EMPTY = "";
108e0e9324cSopenharmony_ci
109e0e9324cSopenharmony_ciconstexpr int32_t MAX_RTP_PAYLOAD_SIZE = 1316;
110e0e9324cSopenharmony_ci
111e0e9324cSopenharmony_cienum TrackType { TRACK_INVALID = -1, TRACK_VIDEO = 0, TRACK_AUDIO, TRACK_TITLE, TRACK_APPLICATION, TRACK_MAX };
112e0e9324cSopenharmony_ci
113e0e9324cSopenharmony_ci#define CODEC_MAP(XX)                                                \
114e0e9324cSopenharmony_ci    XX(CODEC_DEFAULT, TRACK_VIDEO, 0, "default", PSI_STREAM_DEFAULT) \
115e0e9324cSopenharmony_ci    XX(CODEC_H264, TRACK_VIDEO, 1, "H264", PSI_STREAM_H264)          \
116e0e9324cSopenharmony_ci    XX(CODEC_H265, TRACK_VIDEO, 2, "H265", PSI_STREAM_H265)          \
117e0e9324cSopenharmony_ci    XX(CODEC_AAC, TRACK_AUDIO, 3, "mpeg4-generic", PSI_STREAM_AAC)   \
118e0e9324cSopenharmony_ci    XX(CODEC_G711A, TRACK_AUDIO, 4, "PCMA", PSI_STREAM_AUDIO_G711A)  \
119e0e9324cSopenharmony_ci    XX(CODEC_G711U, TRACK_AUDIO, 5, "PCMU", PSI_STREAM_AUDIO_G711U)  \
120e0e9324cSopenharmony_ci    XX(CODEC_OPUS, TRACK_AUDIO, 6, "opus", PSI_STREAM_AUDIO_OPUS)    \
121e0e9324cSopenharmony_ci    XX(CODEC_L16, TRACK_AUDIO, 7, "L16", PSI_STREAM_RESERVED)        \
122e0e9324cSopenharmony_ci    XX(CODEC_VP8, TRACK_VIDEO, 8, "VP8", PSI_STREAM_VP8)             \
123e0e9324cSopenharmony_ci    XX(CODEC_VP9, TRACK_VIDEO, 9, "VP9", PSI_STREAM_VP9)             \
124e0e9324cSopenharmony_ci    XX(CODEC_AV1, TRACK_VIDEO, 10, "AV1X", PSI_STREAM_AV1)           \
125e0e9324cSopenharmony_ci    XX(CODEC_PCM, TRACK_AUDIO, 11, "PCM_S16LE", PSI_STREAM_AUDIO_PCM_S16LE)
126e0e9324cSopenharmony_ci
127e0e9324cSopenharmony_citypedef enum {
128e0e9324cSopenharmony_ci    CODEC_NONE = -1,
129e0e9324cSopenharmony_ci#define XX(name, type, value, str, mpeg_id) name = (value),
130e0e9324cSopenharmony_ci    CODEC_MAP(XX)
131e0e9324cSopenharmony_ci#undef XX
132e0e9324cSopenharmony_ci        CODEC_MAX
133e0e9324cSopenharmony_ci} CodecId;
134e0e9324cSopenharmony_ci
135e0e9324cSopenharmony_ci#define ABSTRACT_ERR_BASE(errorCode) ((errorCode) / 100 * 100)
136e0e9324cSopenharmony_ci
137e0e9324cSopenharmony_cienum SharingErrorCode {
138e0e9324cSopenharmony_ci    // common
139e0e9324cSopenharmony_ci    ERR_OK = 0,
140e0e9324cSopenharmony_ci    // framework 18800001~18800099
141e0e9324cSopenharmony_ci    ERR_GENERAL_ERROR = 18800001,
142e0e9324cSopenharmony_ci    ERR_BAD_PARAMETER,
143e0e9324cSopenharmony_ci    ERR_INVALID_ID,
144e0e9324cSopenharmony_ci    ERR_SERVICE_LIMIT,
145e0e9324cSopenharmony_ci    ERR_STATE_EXCEPTION,
146e0e9324cSopenharmony_ci    ERR_CONNECTION_FAILURE,
147e0e9324cSopenharmony_ci    ERR_INTERACTION_FAILURE,
148e0e9324cSopenharmony_ci    ERR_CONNECTION_TIMEOUT,
149e0e9324cSopenharmony_ci    ERR_CONNECTION_REFUSED,
150e0e9324cSopenharmony_ci    ERR_BAD_PROTOCOL,
151e0e9324cSopenharmony_ci    ERR_NETWORK_ERROR,
152e0e9324cSopenharmony_ci    ERR_UNAUTHORIZED,
153e0e9324cSopenharmony_ci    ERR_INVALID_URL,
154e0e9324cSopenharmony_ci    ERR_REMOTE_DIED,
155e0e9324cSopenharmony_ci    ERR_TCP_KEEPALIVE_TIMEOUT,
156e0e9324cSopenharmony_ci    ERR_UDP_KEEPALIVE_TIMEOUT,
157e0e9324cSopenharmony_ci    ERR_PROTOCOL_INTERACTION_TIMEOUT,
158e0e9324cSopenharmony_ci    // interaction 18800101~18800199
159e0e9324cSopenharmony_ci    ERR_INVALID_SURFACE_ID = 18800101,
160e0e9324cSopenharmony_ci    ERR_SURFACE_FAILURE,
161e0e9324cSopenharmony_ci    // context + agent 18800201~18800299
162e0e9324cSopenharmony_ci    ERR_CONTEXT_AGENT_BASE = 18800200,
163e0e9324cSopenharmony_ci    ERR_CONTEXT_CREATE = 18800201,
164e0e9324cSopenharmony_ci    ERR_AGENT_CREATE,
165e0e9324cSopenharmony_ci    ERR_AGENT_START,
166e0e9324cSopenharmony_ci    ERR_AGENT_PAUSE,
167e0e9324cSopenharmony_ci    ERR_AGENT_RESUME,
168e0e9324cSopenharmony_ci    // session 18800301~18800399
169e0e9324cSopenharmony_ci    ERR_SESSION_BASE = 18800300,
170e0e9324cSopenharmony_ci    ERR_SESSION_CREATE = 18800301,
171e0e9324cSopenharmony_ci    ERR_SESSION_START,
172e0e9324cSopenharmony_ci    ERR_SESSION_PAUSE,
173e0e9324cSopenharmony_ci    ERR_SESSION_RESUME,
174e0e9324cSopenharmony_ci    ERR_INTAKE_TIMEOUT,
175e0e9324cSopenharmony_ci    // prosumer 18800501~18800599
176e0e9324cSopenharmony_ci    ERR_PROSUMER_BASE = 18800500,
177e0e9324cSopenharmony_ci    ERR_PROSUMER_INIT = 18800501,
178e0e9324cSopenharmony_ci    ERR_PROSUMER_CREATE,
179e0e9324cSopenharmony_ci    ERR_PROSUMER_START,
180e0e9324cSopenharmony_ci    ERR_PROSUMER_PAUSE,
181e0e9324cSopenharmony_ci    ERR_PROSUMER_RESUME,
182e0e9324cSopenharmony_ci    ERR_PROSUMER_TIMEOUT,
183e0e9324cSopenharmony_ci    ERR_PROSUMER_STOP,
184e0e9324cSopenharmony_ci    ERR_PROSUMER_DESTROY,
185e0e9324cSopenharmony_ci    ERR_PROSUMER_VIDEO_CAPTURE,
186e0e9324cSopenharmony_ci    ERR_PROSUMER_AUDIO_CAPTURE,
187e0e9324cSopenharmony_ci    // decode + encode + play 18800601~18800699
188e0e9324cSopenharmony_ci    ERR_DECODE_ERROR = 18800601,
189e0e9324cSopenharmony_ci    ERR_DECODE_FORMAT,
190e0e9324cSopenharmony_ci    ERR_DECODE_SCARCE_CAPACITY,
191e0e9324cSopenharmony_ci    ERR_DECODE_DISABLE_ACCELERATION,
192e0e9324cSopenharmony_ci    ERR_ENCODE_ERROR,
193e0e9324cSopenharmony_ci    ERR_ENCODE_FORMAT,
194e0e9324cSopenharmony_ci    ERR_ENCODE_SCARCE_CAPACITY,
195e0e9324cSopenharmony_ci    ERR_PLAY_START,
196e0e9324cSopenharmony_ci    ERR_PLAY_STOP,
197e0e9324cSopenharmony_ci
198e0e9324cSopenharmony_ci    // application: wfd 18802000~18802999
199e0e9324cSopenharmony_ci    ERR_WFD_START_CODE = 18802000,
200e0e9324cSopenharmony_ci    ERR_RECEIVING_LIMIT = SharingErrorCode::ERR_WFD_START_CODE + 101,
201e0e9324cSopenharmony_ci    ERR_P2P_SINK_DISCONNECTED,
202e0e9324cSopenharmony_ci    ERR_P2P_SOURCE_DISCONNECTED,
203e0e9324cSopenharmony_ci    ERR_P2P_SOURCE_HEARTBEAT_ERROR,
204e0e9324cSopenharmony_ci    ERR_P2P_DHCP_INVALID_IP,
205e0e9324cSopenharmony_ci};
206e0e9324cSopenharmony_ci
207e0e9324cSopenharmony_cienum SharingMsgId {
208e0e9324cSopenharmony_ci    // service: 0 ~ 999
209e0e9324cSopenharmony_ci    // chat: 1000 ~ 1999
210e0e9324cSopenharmony_ci    CHAT_MSG_ID_START = 1000,
211e0e9324cSopenharmony_ci    // wfd: 2000 ~ 2999
212e0e9324cSopenharmony_ci    WFD_MSG_ID_START = 2000,
213e0e9324cSopenharmony_ci    // player: 3000 ~ 3999
214e0e9324cSopenharmony_ci    PLAYER_MSG_ID_START = 3000,
215e0e9324cSopenharmony_ci    // any push: 4000 ~ 4999
216e0e9324cSopenharmony_ci    ANY_PUSH_MSG_ID_START = 4000
217e0e9324cSopenharmony_ci};
218e0e9324cSopenharmony_ci
219e0e9324cSopenharmony_ci} // namespace Sharing
220e0e9324cSopenharmony_ci} // namespace OHOS
221e0e9324cSopenharmony_ci#endif
222