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;
53 enum MEDIA_PLAYER_STATE {
58 PLAYER_STATE_IDLE = 0,
62 PLAYER_STATE_OPENING,
66 PLAYER_STATE_OPEN_COMPLETED,
70 PLAYER_STATE_PLAYING,
74 PLAYER_STATE_PAUSED,
78 PLAYER_STATE_PLAYBACK_COMPLETED,
82 PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED,
86 PLAYER_STATE_STOPPED,
89 PLAYER_STATE_PAUSING_INTERNAL = 50,
92 PLAYER_STATE_STOPPING_INTERNAL,
95 PLAYER_STATE_SEEKING_INTERNAL,
98 PLAYER_STATE_GETTING_INTERNAL,
101 PLAYER_STATE_NONE_INTERNAL,
104 PLAYER_STATE_DO_NOTHING_INTERNAL,
107 PLAYER_STATE_SET_TRACK_INTERNAL,
111 PLAYER_STATE_FAILED = 100,
112 };
116 enum MEDIA_PLAYER_REASON {
120 PLAYER_REASON_NONE = 0,
124 PLAYER_REASON_INVALID_ARGUMENTS = -1,
128 PLAYER_REASON_INTERNAL = -2,
132 PLAYER_REASON_NO_RESOURCE = -3,
136 PLAYER_REASON_INVALID_MEDIA_SOURCE = -4,
140 PLAYER_REASON_UNKNOWN_STREAM_TYPE = -5,
144 PLAYER_REASON_OBJ_NOT_INITIALIZED = -6,
148 PLAYER_REASON_CODEC_NOT_SUPPORTED = -7,
152 PLAYER_REASON_VIDEO_RENDER_FAILED = -8,
156 PLAYER_REASON_INVALID_STATE = -9,
160 PLAYER_REASON_URL_NOT_FOUND = -10,
164 PLAYER_REASON_INVALID_CONNECTION_STATE = -11,
168 PLAYER_REASON_SRC_BUFFER_UNDERFLOW = -12,
172 PLAYER_REASON_INTERRUPTED = -13,
176 PLAYER_REASON_NOT_SUPPORTED = -14,
179 PLAYER_REASON_TOKEN_EXPIRED = -15,
182 PLAYER_REASON_IP_EXPIRED = -16,
186 PLAYER_REASON_UNKNOWN = -17,
187 };
188
192 enum MEDIA_STREAM_TYPE {
196 STREAM_TYPE_UNKNOWN = 0,
200 STREAM_TYPE_VIDEO = 1,
204 STREAM_TYPE_AUDIO = 2,
208 STREAM_TYPE_SUBTITLE = 3,
209 };
210
214 enum MEDIA_PLAYER_EVENT {
218 PLAYER_EVENT_SEEK_BEGIN = 0,
222 PLAYER_EVENT_SEEK_COMPLETE = 1,
226 PLAYER_EVENT_SEEK_ERROR = 2,
230 PLAYER_EVENT_AUDIO_TRACK_CHANGED = 5,
234 PLAYER_EVENT_BUFFER_LOW = 6,
238 PLAYER_EVENT_BUFFER_RECOVER = 7,
242 PLAYER_EVENT_FREEZE_START = 8,
246 PLAYER_EVENT_FREEZE_STOP = 9,
250 PLAYER_EVENT_SWITCH_BEGIN = 10,
254 PLAYER_EVENT_SWITCH_COMPLETE = 11,
258 PLAYER_EVENT_SWITCH_ERROR = 12,
262 PLAYER_EVENT_FIRST_DISPLAYED = 13,
266 PLAYER_EVENT_REACH_CACHE_FILE_MAX_COUNT = 14,
270 PLAYER_EVENT_REACH_CACHE_FILE_MAX_SIZE = 15,
273 PLAYER_EVENT_TRY_OPEN_START = 16,
276 PLAYER_EVENT_TRY_OPEN_SUCCEED = 17,
279 PLAYER_EVENT_TRY_OPEN_FAILED = 18,
283 PLAYER_EVENT_HTTP_REDIRECT = 19,
284 };
285
289 enum PLAYER_PRELOAD_EVENT {
293 PLAYER_PRELOAD_EVENT_BEGIN = 0,
297 PLAYER_PRELOAD_EVENT_COMPLETE = 1,
301 PLAYER_PRELOAD_EVENT_ERROR = 2,
302 };
303
307 struct PlayerStreamInfo {
311 int streamIndex;
312
316 MEDIA_STREAM_TYPE streamType;
317
321 char codecName[kMaxCharBufferLength];
322
326 char language[kMaxCharBufferLength];
327
331 int videoFrameRate;
332
336 int videoBitRate;
337
341 int videoWidth;
342
346 int videoHeight;
347
351 int videoRotation;
352
356 int audioSampleRate;
357
361 int audioChannels;
362
367 int audioBitsPerSample;
368
372 int64_t duration;
373
374 PlayerStreamInfo() : streamIndex(0),
375 streamType(STREAM_TYPE_UNKNOWN),
376 videoFrameRate(0),
377 videoBitRate(0),
378 videoWidth(0),
379 videoHeight(0),
380 videoRotation(0),
381 audioSampleRate(0),
382 audioChannels(0),
383 audioBitsPerSample(0),
384 duration(0) {
385 memset(codecName, 0, sizeof(codecName));
386 memset(language, 0, sizeof(language));
387 }
388 };
389
393 struct SrcInfo {
397 int bitrateInKbps;
398
402 const char* name;
403
404 };
405
409 enum MEDIA_PLAYER_METADATA_TYPE {
413 PLAYER_METADATA_TYPE_UNKNOWN = 0,
417 PLAYER_METADATA_TYPE_SEI = 1,
418 };
419
423 struct CacheStatistics {
427 int64_t fileSize;
431 int64_t cacheSize;
435 int64_t downloadSize;
436 };
437
441 struct PlayerPlaybackStats {
445 int videoFps;
449 int videoBitrateInKbps;
453 int audioBitrateInKbps;
457 int totalBitrateInKbps;
458 };
459
463 struct PlayerUpdatedInfo {
466 const char* internalPlayerUuid;
470 const char* deviceId;
474 int videoHeight;
478 int videoWidth;
482 int audioSampleRate;
486 int audioChannels;
490 int audioBitsPerSample;
491
492 PlayerUpdatedInfo()
493 : internalPlayerUuid(NULL),
494 deviceId(NULL),
495 videoHeight(0),
496 videoWidth(0),
497 audioSampleRate(0),
498 audioChannels(0),
499 audioBitsPerSample(0) {}
500 };
501
505 class IMediaPlayerCustomDataProvider {
506 public:
507
524 virtual int onReadData(unsigned char *buffer, int bufferSize) = 0;
525
551 virtual int64_t onSeek(int64_t offset, int whence) = 0;
552
553 virtual ~IMediaPlayerCustomDataProvider() {}
554 };
555
560 struct MediaSource {
567 const char* url;
571 const char* uri;
575 int64_t startPos;
583 bool autoPlay;
598 bool enableCache;
607 bool enableMultiAudioTrack;
619 Optional<bool> isAgoraSource;
629 Optional<bool> isLiveSource;
636 IMediaPlayerCustomDataProvider* provider;
637
638 MediaSource() : url(NULL), uri(NULL), startPos(0), autoPlay(true), enableCache(false),
639 enableMultiAudioTrack(false), provider(NULL){
640 }
641 };
642
643 } // namespace base
644 } // namespace media
645 } // namespace agora
agora::media::base::PlayerUpdatedInfo::audioBitsPerSample
int audioBitsPerSample
Definition: AgoraMediaPlayerTypes.h:490
agora::media::base::PlayerStreamInfo::videoFrameRate
int videoFrameRate
Definition: AgoraMediaPlayerTypes.h:331
agora::media::base::PlayerPlaybackStats::videoBitrateInKbps
int videoBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:449
agora::media::base::MediaSource::enableCache
bool enableCache
Definition: AgoraMediaPlayerTypes.h:598
agora::media::base::PlayerStreamInfo::streamType
MEDIA_STREAM_TYPE streamType
Definition: AgoraMediaPlayerTypes.h:316
agora::media::base::IMediaPlayerCustomDataProvider::onReadData
virtual int onReadData(unsigned char *buffer, int bufferSize)=0
Occurs when the SDK reads the media resource data.
agora::media::base::PlayerStreamInfo::videoRotation
int videoRotation
Definition: AgoraMediaPlayerTypes.h:351
agora::media::base::CacheStatistics
Statistics about the media files being cached.
Definition: AgoraMediaPlayerTypes.h:423
agora::media::base::PlayerStreamInfo::videoWidth
int videoWidth
Definition: AgoraMediaPlayerTypes.h:341
agora::media::base::MediaSource::url
const char * url
Definition: AgoraMediaPlayerTypes.h:567
agora::media::base::PlayerUpdatedInfo
Information related to the media player.
Definition: AgoraMediaPlayerTypes.h:463
agora::media::base::PlayerPlaybackStats::totalBitrateInKbps
int totalBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:457
agora::media::base::MediaSource::enableMultiAudioTrack
bool enableMultiAudioTrack
Definition: AgoraMediaPlayerTypes.h:607
agora::media::base::PlayerUpdatedInfo::audioChannels
int audioChannels
Definition: AgoraMediaPlayerTypes.h:486
agora::media::base::PlayerStreamInfo::audioChannels
int audioChannels
Definition: AgoraMediaPlayerTypes.h:361
agora::media::base::MediaSource::autoPlay
bool autoPlay
Definition: AgoraMediaPlayerTypes.h:583
agora::media::base::MediaSource::provider
IMediaPlayerCustomDataProvider * provider
Definition: AgoraMediaPlayerTypes.h:636
agora::media::base::MediaSource::isAgoraSource
Optional< bool > isAgoraSource
Definition: AgoraMediaPlayerTypes.h:619
agora::media::base::IMediaPlayerCustomDataProvider
Definition: AgoraMediaPlayerTypes.h:505
agora::media::base::PlayerUpdatedInfo::videoHeight
int videoHeight
Definition: AgoraMediaPlayerTypes.h:474
agora::media::base::PlayerStreamInfo::audioBitsPerSample
int audioBitsPerSample
Definition: AgoraMediaPlayerTypes.h:367
agora::media::base::PlayerUpdatedInfo::videoWidth
int videoWidth
Definition: AgoraMediaPlayerTypes.h:478
agora::media::base::PlayerStreamInfo::streamIndex
int streamIndex
Definition: AgoraMediaPlayerTypes.h:311
agora::media::base::PlayerPlaybackStats::videoFps
int videoFps
Definition: AgoraMediaPlayerTypes.h:445
agora::media::base::MediaSource::startPos
int64_t startPos
Definition: AgoraMediaPlayerTypes.h:575
agora::media::base::MediaSource::isLiveSource
Optional< bool > isLiveSource
Definition: AgoraMediaPlayerTypes.h:629
agora::media::base::PlayerStreamInfo::videoBitRate
int videoBitRate
Definition: AgoraMediaPlayerTypes.h:336
agora::media::base::PlayerUpdatedInfo::audioSampleRate
int audioSampleRate
Definition: AgoraMediaPlayerTypes.h:482
agora::media::base::PlayerStreamInfo
The detailed information of the media stream.
Definition: AgoraMediaPlayerTypes.h:307
agora::media::base::CacheStatistics::downloadSize
int64_t downloadSize
Definition: AgoraMediaPlayerTypes.h:435
agora::media::base::PlayerUpdatedInfo::internalPlayerUuid
const char * internalPlayerUuid
Definition: AgoraMediaPlayerTypes.h:466
agora::media::base::IMediaPlayerCustomDataProvider::onSeek
virtual int64_t onSeek(int64_t offset, int whence)=0
Occurs when the SDK seeks the media resource data.
agora::media::base::SrcInfo::name
const char * name
Definition: AgoraMediaPlayerTypes.h:402
agora::media::base::SrcInfo::bitrateInKbps
int bitrateInKbps
Definition: AgoraMediaPlayerTypes.h:397
agora::media::base::MediaSource
Information related to the media file to be played and the playback scenario configurations.
Definition: AgoraMediaPlayerTypes.h:560
agora::media::base::PlayerPlaybackStats
The information of the media file being played.
Definition: AgoraMediaPlayerTypes.h:441
agora::media::base::PlayerStreamInfo::duration
int64_t duration
Definition: AgoraMediaPlayerTypes.h:372
agora::media::base::MediaSource::uri
const char * uri
Definition: AgoraMediaPlayerTypes.h:571
agora::media::base::PlayerUpdatedInfo::deviceId
const char * deviceId
Definition: AgoraMediaPlayerTypes.h:470
agora::media::base::PlayerStreamInfo::audioSampleRate
int audioSampleRate
Definition: AgoraMediaPlayerTypes.h:356
agora::media::base::PlayerStreamInfo::language
char language[kMaxCharBufferLength]
Definition: AgoraMediaPlayerTypes.h:326
agora::media::base::PlayerPlaybackStats::audioBitrateInKbps
int audioBitrateInKbps
Definition: AgoraMediaPlayerTypes.h:453
agora::media::base::SrcInfo
Information about the video bitrate of the media resource being played.
Definition: AgoraMediaPlayerTypes.h:393
agora::media::base::CacheStatistics::cacheSize
int64_t cacheSize
Definition: AgoraMediaPlayerTypes.h:431
agora::media::base::CacheStatistics::fileSize
int64_t fileSize
Definition: AgoraMediaPlayerTypes.h:427
agora::media::base::PlayerStreamInfo::codecName
char codecName[kMaxCharBufferLength]
Definition: AgoraMediaPlayerTypes.h:321
agora::media::base::PlayerStreamInfo::videoHeight
int videoHeight
Definition: AgoraMediaPlayerTypes.h:346
agora::Optional< bool >