|
| 1 | +// |
| 2 | +// Agora Engine SDK |
| 3 | +// |
| 4 | +// Created by Sting Feng in 2020-05. |
| 5 | +// Copyright (c) 2017 Agora.io. All rights reserved. |
| 6 | + |
| 7 | +#pragma once // NOLINT(build/header_guard) |
| 8 | + |
| 9 | +#include <cstring> |
| 10 | +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) |
| 11 | +#include <cstdint> |
| 12 | +#endif |
| 13 | + |
| 14 | +/** |
| 15 | + * set analyze duration for real time stream |
| 16 | + * @example "setPlayerOption(KEY_PLAYER_REAL_TIME_STREAM_ANALYZE_DURATION,1000000)" |
| 17 | + */ |
| 18 | +#define KEY_PLAYER_REAL_TIME_STREAM_ANALYZE_DURATION "analyze_duration" |
| 19 | + |
| 20 | +/** |
| 21 | + * make the player to enable audio or not |
| 22 | + * @example "setPlayerOption(KEY_PLAYER_ENABLE_AUDIO,0)" |
| 23 | + */ |
| 24 | +#define KEY_PLAYER_ENABLE_AUDIO "enable_audio" |
| 25 | + |
| 26 | +/** |
| 27 | + * make the player to enable video or not |
| 28 | + * @example "setPlayerOption(KEY_PLAYER_ENABLE_VIDEO,0)" |
| 29 | + */ |
| 30 | +#define KEY_PLAYER_ENABLE_VIDEO "enable_video" |
| 31 | + |
| 32 | +/** |
| 33 | + * set the player enable to search metadata |
| 34 | + * @example "setPlayerOption(KEY_PLAYER_DISABLE_SEARCH_METADATA,0)" |
| 35 | + */ |
| 36 | +#define KEY_PLAYER_ENABLE_SEARCH_METADATA "enable_search_metadata" |
| 37 | + |
| 38 | +/** |
| 39 | + * set the player sei filter type |
| 40 | + * @example "setPlayerOption(KEY_PLAYER_SEI_FILTER_TYPE,"5")" |
| 41 | + */ |
| 42 | +#define KEY_PLAYER_SEI_FILTER_TYPE "set_sei_filter_type" |
| 43 | + |
| 44 | +namespace agora { |
| 45 | + |
| 46 | +namespace media { |
| 47 | + |
| 48 | +namespace base { |
| 49 | +static const uint8_t kMaxCharBufferLength = 50; |
| 50 | +/** |
| 51 | + * @brief The playback state. |
| 52 | + * |
| 53 | + */ |
| 54 | +enum MEDIA_PLAYER_STATE { |
| 55 | + /** Default state. |
| 56 | + */ |
| 57 | + PLAYER_STATE_IDLE = 0, |
| 58 | + /** Opening the media file. |
| 59 | + */ |
| 60 | + PLAYER_STATE_OPENING, |
| 61 | + /** The media file is opened successfully. |
| 62 | + */ |
| 63 | + PLAYER_STATE_OPEN_COMPLETED, |
| 64 | + /** Playing the media file. |
| 65 | + */ |
| 66 | + PLAYER_STATE_PLAYING, |
| 67 | + /** The playback is paused. |
| 68 | + */ |
| 69 | + PLAYER_STATE_PAUSED, |
| 70 | + /** The playback is completed. |
| 71 | + */ |
| 72 | + PLAYER_STATE_PLAYBACK_COMPLETED, |
| 73 | + /** All loops are completed. |
| 74 | + */ |
| 75 | + PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED, |
| 76 | + /** The playback is stopped. |
| 77 | + */ |
| 78 | + PLAYER_STATE_STOPPED, |
| 79 | + /** Player pausing (internal) |
| 80 | + */ |
| 81 | + PLAYER_STATE_PAUSING_INTERNAL = 50, |
| 82 | + /** Player stopping (internal) |
| 83 | + */ |
| 84 | + PLAYER_STATE_STOPPING_INTERNAL, |
| 85 | + /** Player seeking state (internal) |
| 86 | + */ |
| 87 | + PLAYER_STATE_SEEKING_INTERNAL, |
| 88 | + /** Player getting state (internal) |
| 89 | + */ |
| 90 | + PLAYER_STATE_GETTING_INTERNAL, |
| 91 | + /** None state for state machine (internal) |
| 92 | + */ |
| 93 | + PLAYER_STATE_NONE_INTERNAL, |
| 94 | + /** Do nothing state for state machine (internal) |
| 95 | + */ |
| 96 | + PLAYER_STATE_DO_NOTHING_INTERNAL, |
| 97 | + /** The playback fails. |
| 98 | + */ |
| 99 | + PLAYER_STATE_FAILED = 100, |
| 100 | +}; |
| 101 | +/** |
| 102 | + * @brief Player error code |
| 103 | + * |
| 104 | + */ |
| 105 | +enum MEDIA_PLAYER_ERROR { |
| 106 | + /** No error. |
| 107 | + */ |
| 108 | + PLAYER_ERROR_NONE = 0, |
| 109 | + /** The parameter is invalid. |
| 110 | + */ |
| 111 | + PLAYER_ERROR_INVALID_ARGUMENTS = -1, |
| 112 | + /** Internel error. |
| 113 | + */ |
| 114 | + PLAYER_ERROR_INTERNAL = -2, |
| 115 | + /** No resource. |
| 116 | + */ |
| 117 | + PLAYER_ERROR_NO_RESOURCE = -3, |
| 118 | + /** Invalid media source. |
| 119 | + */ |
| 120 | + PLAYER_ERROR_INVALID_MEDIA_SOURCE = -4, |
| 121 | + /** The type of the media stream is unknown. |
| 122 | + */ |
| 123 | + PLAYER_ERROR_UNKNOWN_STREAM_TYPE = -5, |
| 124 | + /** The object is not initialized. |
| 125 | + */ |
| 126 | + PLAYER_ERROR_OBJ_NOT_INITIALIZED = -6, |
| 127 | + /** The codec is not supported. |
| 128 | + */ |
| 129 | + PLAYER_ERROR_CODEC_NOT_SUPPORTED = -7, |
| 130 | + /** Invalid renderer. |
| 131 | + */ |
| 132 | + PLAYER_ERROR_VIDEO_RENDER_FAILED = -8, |
| 133 | + /** An error occurs in the internal state of the player. |
| 134 | + */ |
| 135 | + PLAYER_ERROR_INVALID_STATE = -9, |
| 136 | + /** The URL of the media file cannot be found. |
| 137 | + */ |
| 138 | + PLAYER_ERROR_URL_NOT_FOUND = -10, |
| 139 | + /** Invalid connection between the player and the Agora server. |
| 140 | + */ |
| 141 | + PLAYER_ERROR_INVALID_CONNECTION_STATE = -11, |
| 142 | + /** The playback buffer is insufficient. |
| 143 | + */ |
| 144 | + PLAYER_ERROR_SRC_BUFFER_UNDERFLOW = -12, |
| 145 | + /** The audio mixing file playback is interrupted. |
| 146 | + */ |
| 147 | + PLAYER_ERROR_INTERRUPTED = -13, |
| 148 | +}; |
| 149 | + |
| 150 | +/** |
| 151 | + * @brief The playback speed. |
| 152 | + * |
| 153 | + */ |
| 154 | +enum MEDIA_PLAYER_PLAYBACK_SPEED { |
| 155 | + /** The original playback speed. |
| 156 | + */ |
| 157 | + PLAYBACK_SPEED_ORIGINAL = 100, |
| 158 | + /** 0.5 times the original playback speed. |
| 159 | + */ |
| 160 | + PLAYBACK_SPEED_50_PERCENT = 50, |
| 161 | + /** 0.75 times the original playback speed. |
| 162 | + */ |
| 163 | + PLAYBACK_SPEED_75_PERCENT = 75, |
| 164 | + /** 1.25 times the original playback speed. |
| 165 | + */ |
| 166 | + PLAYBACK_SPEED_125_PERCENT = 125, |
| 167 | + /** 1.5 times the original playback speed. |
| 168 | + */ |
| 169 | + PLAYBACK_SPEED_150_PERCENT = 150, |
| 170 | + /** 2.0 times the original playback. |
| 171 | + */ |
| 172 | + PLAYBACK_SPEED_200_PERCENT = 200, |
| 173 | +}; |
| 174 | + |
| 175 | +/** |
| 176 | + * @brief The type of the media stream. |
| 177 | + * |
| 178 | + */ |
| 179 | +enum MEDIA_STREAM_TYPE { |
| 180 | + /** The type is unknown. |
| 181 | + */ |
| 182 | + STREAM_TYPE_UNKNOWN = 0, |
| 183 | + /** The video stream. |
| 184 | + */ |
| 185 | + STREAM_TYPE_VIDEO = 1, |
| 186 | + /** The audio stream. |
| 187 | + */ |
| 188 | + STREAM_TYPE_AUDIO = 2, |
| 189 | + /** The subtitle stream. |
| 190 | + */ |
| 191 | + STREAM_TYPE_SUBTITLE = 3, |
| 192 | +}; |
| 193 | + |
| 194 | +/** |
| 195 | + * @brief The playback event. |
| 196 | + * |
| 197 | + */ |
| 198 | +enum MEDIA_PLAYER_EVENT { |
| 199 | + /** The player begins to seek to the new playback position. |
| 200 | + */ |
| 201 | + PLAYER_EVENT_SEEK_BEGIN = 0, |
| 202 | + /** The seek operation completes. |
| 203 | + */ |
| 204 | + PLAYER_EVENT_SEEK_COMPLETE = 1, |
| 205 | + /** An error occurs during the seek operation. |
| 206 | + */ |
| 207 | + PLAYER_EVENT_SEEK_ERROR = 2, |
| 208 | + /** The player publishes a video track. |
| 209 | + */ |
| 210 | + PLAYER_EVENT_VIDEO_PUBLISHED = 3, |
| 211 | + /** The player publishes an audio track. |
| 212 | + */ |
| 213 | + PLAYER_EVENT_AUDIO_PUBLISHED = 4, |
| 214 | + /** The player changes the audio track for playback. |
| 215 | + */ |
| 216 | + PLAYER_EVENT_AUDIO_TRACK_CHANGED = 5, |
| 217 | + /** player buffer low |
| 218 | + */ |
| 219 | + PLAYER_EVENT_BUFFER_LOW = 6, |
| 220 | + /** player buffer recover |
| 221 | + */ |
| 222 | + PLAYER_EVENT_BUFFER_RECOVER = 7, |
| 223 | + /** The video or audio is interrupted |
| 224 | + */ |
| 225 | + PLAYER_EVENT_FREEZE_START = 8, |
| 226 | + /** Interrupt at the end of the video or audio |
| 227 | + */ |
| 228 | + PLAYER_EVENT_FREEZE_STOP = 9, |
| 229 | +}; |
| 230 | + |
| 231 | +/** |
| 232 | + * @brief The information of the media stream object. |
| 233 | + * |
| 234 | + */ |
| 235 | +struct PlayerStreamInfo { |
| 236 | + /** The index of the media stream. */ |
| 237 | + int streamIndex; |
| 238 | + |
| 239 | + /** The type of the media stream. See {@link MEDIA_STREAM_TYPE}. */ |
| 240 | + MEDIA_STREAM_TYPE streamType; |
| 241 | + |
| 242 | + /** The codec of the media stream. */ |
| 243 | + char codecName[kMaxCharBufferLength]; |
| 244 | + |
| 245 | + /** The language of the media stream. */ |
| 246 | + char language[kMaxCharBufferLength]; |
| 247 | + |
| 248 | + /** The frame rate (fps) if the stream is video. */ |
| 249 | + int videoFrameRate; |
| 250 | + |
| 251 | + /** The video bitrate (bps) if the stream is video. */ |
| 252 | + int videoBitRate; |
| 253 | + |
| 254 | + /** The video width (pixel) if the stream is video. */ |
| 255 | + int videoWidth; |
| 256 | + |
| 257 | + /** The video height (pixel) if the stream is video. */ |
| 258 | + int videoHeight; |
| 259 | + |
| 260 | + /** The rotation angle if the steam is video. */ |
| 261 | + int videoRotation; |
| 262 | + |
| 263 | + /** The sample rate if the stream is audio. */ |
| 264 | + int audioSampleRate; |
| 265 | + |
| 266 | + /** The number of audio channels if the stream is audio. */ |
| 267 | + int audioChannels; |
| 268 | + |
| 269 | + /** The number of bits per sample if the stream is audio. */ |
| 270 | + int audioBitsPerSample; |
| 271 | + |
| 272 | + /** The total duration (second) of the media stream. */ |
| 273 | + int64_t duration; |
| 274 | + |
| 275 | + PlayerStreamInfo() : streamIndex(0), |
| 276 | + streamType(STREAM_TYPE_UNKNOWN), |
| 277 | + videoFrameRate(0), |
| 278 | + videoBitRate(0), |
| 279 | + videoWidth(0), |
| 280 | + videoHeight(0), |
| 281 | + videoRotation(0), |
| 282 | + audioSampleRate(0), |
| 283 | + audioChannels(0), |
| 284 | + audioBitsPerSample(0), |
| 285 | + duration(0) { |
| 286 | + memset(codecName, 0, sizeof(codecName)); |
| 287 | + memset(language, 0, sizeof(language)); |
| 288 | + } |
| 289 | +}; |
| 290 | + |
| 291 | +/** |
| 292 | + * @brief The type of the media metadata. |
| 293 | + * |
| 294 | + */ |
| 295 | +enum MEDIA_PLAYER_METADATA_TYPE { |
| 296 | + /** The type is unknown. |
| 297 | + */ |
| 298 | + PLAYER_METADATA_TYPE_UNKNOWN = 0, |
| 299 | + /** The type is SEI. |
| 300 | + */ |
| 301 | + PLAYER_METADATA_TYPE_SEI = 1, |
| 302 | +}; |
| 303 | + |
| 304 | +} // namespace base |
| 305 | +} // namespace media |
| 306 | +} // namespace agora |
0 commit comments