Agora Java API Reference for Android

AgoraMediaPlayerTypes.h
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 #include <stdint.h>
11
12 #include "AgoraOptional.h"
13
18 #define KEY_PLAYER_REAL_TIME_STREAM_ANALYZE_DURATION "analyze_duration"
19
24 #define KEY_PLAYER_ENABLE_AUDIO "enable_audio"
25
30 #define KEY_PLAYER_ENABLE_VIDEO "enable_video"
31
36 #define KEY_PLAYER_ENABLE_SEARCH_METADATA "enable_search_metadata"
37
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;
54 enum MEDIA_PLAYER_STATE {
57 PLAYER_STATE_IDLE = 0,
60 PLAYER_STATE_OPENING,
63 PLAYER_STATE_OPEN_COMPLETED,
66 PLAYER_STATE_PLAYING,
69 PLAYER_STATE_PAUSED,
72 PLAYER_STATE_PLAYBACK_COMPLETED,
75 PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED,
78 PLAYER_STATE_STOPPED,
81 PLAYER_STATE_PAUSING_INTERNAL = 50,
84 PLAYER_STATE_STOPPING_INTERNAL,
87 PLAYER_STATE_SEEKING_INTERNAL,
90 PLAYER_STATE_GETTING_INTERNAL,
93 PLAYER_STATE_NONE_INTERNAL,
96 PLAYER_STATE_DO_NOTHING_INTERNAL,
99 PLAYER_STATE_SET_TRACK_INTERNAL,
102 PLAYER_STATE_FAILED = 100,
103 };
108 enum MEDIA_PLAYER_REASON {
111 PLAYER_REASON_NONE = 0,
114 PLAYER_REASON_INVALID_ARGUMENTS = -1,
117 PLAYER_REASON_INTERNAL = -2,
120 PLAYER_REASON_NO_RESOURCE = -3,
123 PLAYER_REASON_INVALID_MEDIA_SOURCE = -4,
126 PLAYER_REASON_UNKNOWN_STREAM_TYPE = -5,
129 PLAYER_REASON_OBJ_NOT_INITIALIZED = -6,
132 PLAYER_REASON_CODEC_NOT_SUPPORTED = -7,
135 PLAYER_REASON_VIDEO_RENDER_FAILED = -8,
138 PLAYER_REASON_INVALID_STATE = -9,
141 PLAYER_REASON_URL_NOT_FOUND = -10,
144 PLAYER_REASON_INVALID_CONNECTION_STATE = -11,
147 PLAYER_REASON_SRC_BUFFER_UNDERFLOW = -12,
150 PLAYER_REASON_INTERRUPTED = -13,
153 PLAYER_REASON_NOT_SUPPORTED = -14,
156 PLAYER_REASON_TOKEN_EXPIRED = -15,
159 PLAYER_REASON_IP_EXPIRED = -16,
162 PLAYER_REASON_UNKNOWN = -17,
163 };
164
169 enum MEDIA_STREAM_TYPE {
172 STREAM_TYPE_UNKNOWN = 0,
175 STREAM_TYPE_VIDEO = 1,
178 STREAM_TYPE_AUDIO = 2,
181 STREAM_TYPE_SUBTITLE = 3,
182 };
183
188 enum MEDIA_PLAYER_EVENT {
191 PLAYER_EVENT_SEEK_BEGIN = 0,
194 PLAYER_EVENT_SEEK_COMPLETE = 1,
197 PLAYER_EVENT_SEEK_ERROR = 2,
200 PLAYER_EVENT_AUDIO_TRACK_CHANGED = 5,
203 PLAYER_EVENT_BUFFER_LOW = 6,
206 PLAYER_EVENT_BUFFER_RECOVER = 7,
209 PLAYER_EVENT_FREEZE_START = 8,
212 PLAYER_EVENT_FREEZE_STOP = 9,
215 PLAYER_EVENT_SWITCH_BEGIN = 10,
218 PLAYER_EVENT_SWITCH_COMPLETE = 11,
221 PLAYER_EVENT_SWITCH_ERROR = 12,
224 PLAYER_EVENT_FIRST_DISPLAYED = 13,
227 PLAYER_EVENT_REACH_CACHE_FILE_MAX_COUNT = 14,
230 PLAYER_EVENT_REACH_CACHE_FILE_MAX_SIZE = 15,
233 PLAYER_EVENT_TRY_OPEN_START = 16,
236 PLAYER_EVENT_TRY_OPEN_SUCCEED = 17,
239 PLAYER_EVENT_TRY_OPEN_FAILED = 18,
243 PLAYER_EVENT_HTTP_REDIRECT = 19,
244 };
245
250 enum PLAYER_PRELOAD_EVENT {
253 PLAYER_PRELOAD_EVENT_BEGIN = 0,
256 PLAYER_PRELOAD_EVENT_COMPLETE = 1,
259 PLAYER_PRELOAD_EVENT_ERROR = 2,
260 };
261
266 struct PlayerStreamInfo {
268 int streamIndex;
269
271 MEDIA_STREAM_TYPE streamType;
272
274 char codecName[kMaxCharBufferLength];
275
277 char language[kMaxCharBufferLength];
278
280 int videoFrameRate;
281
283 int videoBitRate;
284
286 int videoWidth;
287
289 int videoHeight;
290
292 int videoRotation;
293
295 int audioSampleRate;
296
298 int audioChannels;
299
301 int audioBitsPerSample;
302
304 int64_t duration;
305
306 PlayerStreamInfo() : streamIndex(0),
307 streamType(STREAM_TYPE_UNKNOWN),
308 videoFrameRate(0),
309 videoBitRate(0),
310 videoWidth(0),
311 videoHeight(0),
312 videoRotation(0),
313 audioSampleRate(0),
314 audioChannels(0),
315 audioBitsPerSample(0),
316 duration(0) {
317 memset(codecName, 0, sizeof(codecName));
318 memset(language, 0, sizeof(language));
319 }
320 };
321
326 struct SrcInfo {
330 int bitrateInKbps;
331
335 const char* name;
336
337 };
338
343 enum MEDIA_PLAYER_METADATA_TYPE {
346 PLAYER_METADATA_TYPE_UNKNOWN = 0,
349 PLAYER_METADATA_TYPE_SEI = 1,
350 };
351
352 struct CacheStatistics {
355 int64_t fileSize;
358 int64_t cacheSize;
361 int64_t downloadSize;
362 };
363
368 struct PlayerPlaybackStats {
371 int videoFps;
374 int videoBitrateInKbps;
377 int audioBitrateInKbps;
380 int totalBitrateInKbps;
381 };
382
387 struct PlayerUpdatedInfo {
390 const char* internalPlayerUuid;
393 const char* deviceId;
396 int videoHeight;
399 int videoWidth;
402 int audioSampleRate;
405 int audioChannels;
408 int audioBitsPerSample;
409
410 PlayerUpdatedInfo()
411 : internalPlayerUuid(NULL),
412 deviceId(NULL),
413 videoHeight(0),
414 videoWidth(0),
415 audioSampleRate(0),
416 audioChannels(0),
417 audioBitsPerSample(0) {}
418 };
419
423 class IMediaPlayerCustomDataProvider {
424 public:
425
432 virtual int onReadData(unsigned char *buffer, int bufferSize) = 0;
433
446 virtual int64_t onSeek(int64_t offset, int whence) = 0;
447
448 virtual ~IMediaPlayerCustomDataProvider() {}
449 };
450
451 struct MediaSource {
455 const char* url;
462 const char* uri;
466 int64_t startPos;
472 bool autoPlay;
484 bool enableCache;
495 bool enableMultiAudioTrack;
501 Optional<bool> isAgoraSource;
507 Optional<bool> isLiveSource;
511 IMediaPlayerCustomDataProvider* provider;
512
513 MediaSource() : url(NULL), uri(NULL), startPos(0), autoPlay(true), enableCache(false),
514 enableMultiAudioTrack(false), provider(NULL){
515 }
516 };
517
518 } // namespace base
519 } // namespace media
520 } // namespace agora
agora::media::base::PlayerUpdatedInfo::audioBitsPerSample
int audioBitsPerSample
Definition: AgoraMediaPlayerTypes.h:408
agora::media::base::PlayerStreamInfo::videoFrameRate
int videoFrameRate
Definition: AgoraMediaPlayerTypes.h:280
agora::media::base::PlayerPlaybackStats::videoBitrateInKbps
int videoBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:374
agora::media::base::MediaSource::enableCache
bool enableCache
Definition: AgoraMediaPlayerTypes.h:484
agora::media::base::PlayerStreamInfo::streamType
MEDIA_STREAM_TYPE streamType
Definition: AgoraMediaPlayerTypes.h:271
agora::media::base::IMediaPlayerCustomDataProvider::onReadData
virtual int onReadData(unsigned char *buffer, int bufferSize)=0
The player requests to read the data callback, you need to fill the specified length of data into the...
agora::media::base::PlayerStreamInfo::videoRotation
int videoRotation
Definition: AgoraMediaPlayerTypes.h:292
agora::media::base::CacheStatistics
Definition: AgoraMediaPlayerTypes.h:352
agora::media::base::PlayerStreamInfo::videoWidth
int videoWidth
Definition: AgoraMediaPlayerTypes.h:286
agora::media::base::MediaSource::url
const char * url
Definition: AgoraMediaPlayerTypes.h:455
agora::media::base::PlayerUpdatedInfo
The updated information of media player.
Definition: AgoraMediaPlayerTypes.h:387
agora::media::base::PlayerPlaybackStats::totalBitrateInKbps
int totalBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:380
agora::media::base::MediaSource::enableMultiAudioTrack
bool enableMultiAudioTrack
Definition: AgoraMediaPlayerTypes.h:495
agora::media::base::PlayerUpdatedInfo::audioChannels
int audioChannels
Definition: AgoraMediaPlayerTypes.h:405
agora::media::base::PlayerStreamInfo::audioChannels
int audioChannels
Definition: AgoraMediaPlayerTypes.h:298
agora::media::base::MediaSource::autoPlay
bool autoPlay
Definition: AgoraMediaPlayerTypes.h:472
agora::media::base::MediaSource::provider
IMediaPlayerCustomDataProvider * provider
Definition: AgoraMediaPlayerTypes.h:511
agora::media::base::MediaSource::isAgoraSource
Optional< bool > isAgoraSource
Definition: AgoraMediaPlayerTypes.h:501
agora::media::base::IMediaPlayerCustomDataProvider
Definition: AgoraMediaPlayerTypes.h:423
agora::media::base::PlayerUpdatedInfo::videoHeight
int videoHeight
Definition: AgoraMediaPlayerTypes.h:396
agora::media::base::PlayerStreamInfo::audioBitsPerSample
int audioBitsPerSample
Definition: AgoraMediaPlayerTypes.h:301
agora::media::base::PlayerUpdatedInfo::videoWidth
int videoWidth
Definition: AgoraMediaPlayerTypes.h:399
agora::media::base::PlayerStreamInfo::streamIndex
int streamIndex
Definition: AgoraMediaPlayerTypes.h:268
agora::media::base::PlayerPlaybackStats::videoFps
int videoFps
Definition: AgoraMediaPlayerTypes.h:371
agora::media::base::MediaSource::startPos
int64_t startPos
Definition: AgoraMediaPlayerTypes.h:466
agora::media::base::MediaSource::isLiveSource
Optional< bool > isLiveSource
Definition: AgoraMediaPlayerTypes.h:507
agora::media::base::PlayerStreamInfo::videoBitRate
int videoBitRate
Definition: AgoraMediaPlayerTypes.h:283
agora::media::base::PlayerUpdatedInfo::audioSampleRate
int audioSampleRate
Definition: AgoraMediaPlayerTypes.h:402
agora::media::base::PlayerStreamInfo
The information of the media stream object.
Definition: AgoraMediaPlayerTypes.h:266
agora::media::base::CacheStatistics::downloadSize
int64_t downloadSize
Definition: AgoraMediaPlayerTypes.h:361
agora::media::base::PlayerUpdatedInfo::internalPlayerUuid
const char * internalPlayerUuid
Definition: AgoraMediaPlayerTypes.h:390
agora::media::base::IMediaPlayerCustomDataProvider::onSeek
virtual int64_t onSeek(int64_t offset, int whence)=0
The Player seek event callback, you need to operate the corresponding stream seek operation,...
agora::media::base::SrcInfo::name
const char * name
Definition: AgoraMediaPlayerTypes.h:335
agora::media::base::SrcInfo::bitrateInKbps
int bitrateInKbps
Definition: AgoraMediaPlayerTypes.h:330
agora::media::base::MediaSource
Definition: AgoraMediaPlayerTypes.h:451
agora::media::base::PlayerPlaybackStats
The real time statistics of the media stream being played.
Definition: AgoraMediaPlayerTypes.h:368
agora::media::base::PlayerStreamInfo::duration
int64_t duration
Definition: AgoraMediaPlayerTypes.h:304
agora::media::base::MediaSource::uri
const char * uri
Definition: AgoraMediaPlayerTypes.h:462
agora::media::base::PlayerUpdatedInfo::deviceId
const char * deviceId
Definition: AgoraMediaPlayerTypes.h:393
agora::media::base::PlayerStreamInfo::audioSampleRate
int audioSampleRate
Definition: AgoraMediaPlayerTypes.h:295
agora::media::base::PlayerStreamInfo::language
char language[kMaxCharBufferLength]
Definition: AgoraMediaPlayerTypes.h:277
agora::media::base::PlayerPlaybackStats::audioBitrateInKbps
int audioBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:377
agora::media::base::SrcInfo
The information of the media stream object.
Definition: AgoraMediaPlayerTypes.h:326
agora::media::base::CacheStatistics::cacheSize
int64_t cacheSize
Definition: AgoraMediaPlayerTypes.h:358
agora::media::base::CacheStatistics::fileSize
int64_t fileSize
Definition: AgoraMediaPlayerTypes.h:355
agora::media::base::PlayerStreamInfo::codecName
char codecName[kMaxCharBufferLength]
Definition: AgoraMediaPlayerTypes.h:274
agora::media::base::PlayerStreamInfo::videoHeight
int videoHeight
Definition: AgoraMediaPlayerTypes.h:289
agora::Optional< bool >