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,
240 };
241 
246 enum PLAYER_PRELOAD_EVENT {
249  PLAYER_PRELOAD_EVENT_BEGIN = 0,
252  PLAYER_PRELOAD_EVENT_COMPLETE = 1,
255  PLAYER_PRELOAD_EVENT_ERROR = 2,
256 };
257 
265 
267  MEDIA_STREAM_TYPE streamType;
268 
270  char codecName[kMaxCharBufferLength];
271 
273  char language[kMaxCharBufferLength];
274 
277 
280 
283 
286 
289 
292 
295 
298 
300  int64_t duration;
301 
303  streamType(STREAM_TYPE_UNKNOWN),
304  videoFrameRate(0),
305  videoBitRate(0),
306  videoWidth(0),
307  videoHeight(0),
308  videoRotation(0),
309  audioSampleRate(0),
310  audioChannels(0),
312  duration(0) {
313  memset(codecName, 0, sizeof(codecName));
314  memset(language, 0, sizeof(language));
315  }
316 };
317 
322 struct SrcInfo {
327 
331  const char* name;
332 
333 };
334 
339 enum MEDIA_PLAYER_METADATA_TYPE {
342  PLAYER_METADATA_TYPE_UNKNOWN = 0,
345  PLAYER_METADATA_TYPE_SEI = 1,
346 };
347 
351  int64_t fileSize;
354  int64_t cacheSize;
357  int64_t downloadSize;
358 };
359 
367  int videoFps;
377 };
378 
386  const char* internalPlayerUuid;
389  const char* deviceId;
405 
407  : internalPlayerUuid(NULL),
408  deviceId(NULL),
409  videoHeight(0),
410  videoWidth(0),
411  audioSampleRate(0),
412  audioChannels(0),
413  audioBitsPerSample(0) {}
414 };
415 
420 public:
421 
428  virtual int onReadData(unsigned char *buffer, int bufferSize) = 0;
429 
442  virtual int64_t onSeek(int64_t offset, int whence) = 0;
443 
444  virtual ~IMediaPlayerCustomDataProvider() {}
445 };
446 
447 struct MediaSource {
451  const char* url;
458  const char* uri;
462  int64_t startPos;
468  bool autoPlay;
508 
509  MediaSource() : url(NULL), uri(NULL), startPos(0), autoPlay(true), enableCache(false),
510  enableMultiAudioTrack(false), provider(NULL){
511  }
512 };
513 
514 } // namespace base
515 } // namespace media
516 } // namespace agora
agora::media::base::PlayerUpdatedInfo::audioBitsPerSample
int audioBitsPerSample
Definition: AgoraMediaPlayerTypes.h:404
agora::media::base::PlayerStreamInfo::videoFrameRate
int videoFrameRate
Definition: AgoraMediaPlayerTypes.h:276
agora::media::base::PlayerPlaybackStats::videoBitrateInKbps
int videoBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:370
agora::media::base::MediaSource::enableCache
bool enableCache
Definition: AgoraMediaPlayerTypes.h:480
agora::media::base::PlayerStreamInfo::streamType
MEDIA_STREAM_TYPE streamType
Definition: AgoraMediaPlayerTypes.h:267
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:288
agora::media::base::CacheStatistics
Definition: AgoraMediaPlayerTypes.h:348
agora::media::base::PlayerStreamInfo::videoWidth
int videoWidth
Definition: AgoraMediaPlayerTypes.h:282
agora::media::base::MediaSource::url
const char * url
Definition: AgoraMediaPlayerTypes.h:451
agora::media::base::PlayerUpdatedInfo
The updated information of media player.
Definition: AgoraMediaPlayerTypes.h:383
agora::media::base::PlayerPlaybackStats::totalBitrateInKbps
int totalBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:376
agora::media::base::MediaSource::enableMultiAudioTrack
bool enableMultiAudioTrack
Definition: AgoraMediaPlayerTypes.h:491
agora::media::base::PlayerUpdatedInfo::audioChannels
int audioChannels
Definition: AgoraMediaPlayerTypes.h:401
agora::media::base::PlayerStreamInfo::audioChannels
int audioChannels
Definition: AgoraMediaPlayerTypes.h:294
agora::media::base::MediaSource::autoPlay
bool autoPlay
Definition: AgoraMediaPlayerTypes.h:468
agora::media::base::MediaSource::provider
IMediaPlayerCustomDataProvider * provider
Definition: AgoraMediaPlayerTypes.h:507
agora::media::base::MediaSource::isAgoraSource
Optional< bool > isAgoraSource
Definition: AgoraMediaPlayerTypes.h:497
agora::media::base::IMediaPlayerCustomDataProvider
Definition: AgoraMediaPlayerTypes.h:419
agora::media::base::PlayerUpdatedInfo::videoHeight
int videoHeight
Definition: AgoraMediaPlayerTypes.h:392
agora::media::base::PlayerStreamInfo::audioBitsPerSample
int audioBitsPerSample
Definition: AgoraMediaPlayerTypes.h:297
agora::media::base::PlayerUpdatedInfo::videoWidth
int videoWidth
Definition: AgoraMediaPlayerTypes.h:395
agora::media::base::PlayerStreamInfo::streamIndex
int streamIndex
Definition: AgoraMediaPlayerTypes.h:264
agora::media::base::PlayerPlaybackStats::videoFps
int videoFps
Definition: AgoraMediaPlayerTypes.h:367
agora::media::base::MediaSource::startPos
int64_t startPos
Definition: AgoraMediaPlayerTypes.h:462
agora::media::base::MediaSource::isLiveSource
Optional< bool > isLiveSource
Definition: AgoraMediaPlayerTypes.h:503
agora::media::base::PlayerStreamInfo::videoBitRate
int videoBitRate
Definition: AgoraMediaPlayerTypes.h:279
agora::media::base::PlayerUpdatedInfo::audioSampleRate
int audioSampleRate
Definition: AgoraMediaPlayerTypes.h:398
agora::media::base::PlayerStreamInfo
The information of the media stream object.
Definition: AgoraMediaPlayerTypes.h:262
agora::media::base::CacheStatistics::downloadSize
int64_t downloadSize
Definition: AgoraMediaPlayerTypes.h:357
agora::media::base::PlayerUpdatedInfo::internalPlayerUuid
const char * internalPlayerUuid
Definition: AgoraMediaPlayerTypes.h:386
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:331
agora::media::base::SrcInfo::bitrateInKbps
int bitrateInKbps
Definition: AgoraMediaPlayerTypes.h:326
agora::media::base::MediaSource
Definition: AgoraMediaPlayerTypes.h:447
agora::media::base::PlayerPlaybackStats
The real time statistics of the media stream being played.
Definition: AgoraMediaPlayerTypes.h:364
agora::media::base::PlayerStreamInfo::duration
int64_t duration
Definition: AgoraMediaPlayerTypes.h:300
agora::media::base::MediaSource::uri
const char * uri
Definition: AgoraMediaPlayerTypes.h:458
agora::media::base::PlayerUpdatedInfo::deviceId
const char * deviceId
Definition: AgoraMediaPlayerTypes.h:389
agora::media::base::PlayerStreamInfo::audioSampleRate
int audioSampleRate
Definition: AgoraMediaPlayerTypes.h:291
agora::media::base::PlayerStreamInfo::language
char language[kMaxCharBufferLength]
Definition: AgoraMediaPlayerTypes.h:273
agora::media::base::PlayerPlaybackStats::audioBitrateInKbps
int audioBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:373
agora::media::base::SrcInfo
The information of the media stream object.
Definition: AgoraMediaPlayerTypes.h:322
agora::media::base::CacheStatistics::cacheSize
int64_t cacheSize
Definition: AgoraMediaPlayerTypes.h:354
agora::media::base::CacheStatistics::fileSize
int64_t fileSize
Definition: AgoraMediaPlayerTypes.h:351
agora::media::base::PlayerStreamInfo::codecName
char codecName[kMaxCharBufferLength]
Definition: AgoraMediaPlayerTypes.h:270
agora::media::base::PlayerStreamInfo::videoHeight
int videoHeight
Definition: AgoraMediaPlayerTypes.h:285
agora::Optional< bool >