Agora C++ API Reference for All Platforms

IAgoraMediaPlayerSource.h
1 //
2 // Agora SDK
3 //
4 // Copyright (c) 2018 Agora.io. All rights reserved.
5 //
6 #pragma once // NOLINT(build/header_guard)
7
8 #include "AgoraBase.h"
9 #include "AgoraMediaBase.h"
10 #include "AgoraMediaPlayerTypes.h"
11 #include "AgoraRefPtr.h"
12
13 namespace agora {
14 namespace rtc {
15
16 class IMediaPlayerSourceObserver;
17
22 class IMediaPlayerSource : public RefCountInterface {
23 protected:
24 virtual ~IMediaPlayerSource() {}
25
26 public:
27
34 virtual int getSourceId() const = 0;
35
44 virtual int open(const char* url, int64_t startPos) = 0;
45
53 virtual int openWithMediaSource(const media::base::MediaSource &source) = 0;
54
61 virtual int play() = 0;
62
69 virtual int pause() = 0;
70
77 virtual int stop() = 0;
78
85 virtual int resume() = 0;
86
94 virtual int seek(int64_t newPos) = 0;
95
103 virtual int getDuration(int64_t& duration) = 0;
104
112 virtual int getPlayPosition(int64_t& pos) = 0;
113
121 virtual int getStreamCount(int64_t& count) = 0;
122
131 virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* info) = 0;
132
143 virtual int setLoopCount(int64_t loopCount) = 0;
144
152 virtual int setPlaybackSpeed(int speed) = 0;
153
161 virtual int selectAudioTrack(int64_t index) = 0;
162
178 virtual int selectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex) = 0;
179
188 virtual int setPlayerOption(const char* key, int64_t value) = 0;
189
198 virtual int setPlayerOption(const char* key, const char* value) = 0;
199
207 virtual int takeScreenshot(const char* filename) = 0;
208
216 virtual int selectInternalSubtitle(int64_t index) = 0;
217
225 virtual int setExternalSubtitle(const char* url) = 0;
226
231 virtual media::base::MEDIA_PLAYER_STATE getState() = 0;
232
242 virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0;
243
251 virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0;
252
261 virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0;
262
270 virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0;
271
280 virtual int openWithAgoraCDNSrc(const char* src, int64_t startPos) = 0;
281
288 virtual int getAgoraCDNLineCount() = 0;
289
290
298 virtual int switchAgoraCDNLineByIndex(int index) = 0;
299
306 virtual int getCurrentAgoraCDNIndex() = 0;
307
315 virtual int enableAutoSwitchAgoraCDN(bool enable) = 0;
316
325 virtual int renewAgoraCDNSrcToken(const char* token, int64_t ts) = 0;
326
335 virtual int switchAgoraCDNSrc(const char* src, bool syncPts = false) = 0;
336
345 virtual int switchSrc(const char* src, bool syncPts) = 0;
346
355 virtual int preloadSrc(const char* src, int64_t startPos) = 0;
356
364 virtual int unloadSrc(const char* src) = 0;
365
373 virtual int playPreloadedSrc(const char* src) = 0;
374
375 };
376
380 class IMediaPlayerSourceObserver {
381 public:
382 virtual ~IMediaPlayerSourceObserver() {}
383
391 virtual void onPlayerSourceStateChanged(media::base::MEDIA_PLAYER_STATE state,
392 media::base::MEDIA_PLAYER_REASON reason) = 0;
393
401 virtual void onPositionChanged(int64_t positionMs, int64_t timestampMs) = 0;
402
413 virtual void onPlayerEvent(media::base::MEDIA_PLAYER_EVENT eventCode, int64_t elapsedTime, const char* message) = 0;
414
422 virtual void onMetaData(const void* data, int length) = 0;
423
424
430 virtual void onPlayBufferUpdated(int64_t playCachedBuffer) = 0;
431
432
438 virtual void onPreloadEvent(const char* src, media::base::PLAYER_PRELOAD_EVENT event) = 0;
439
443 virtual void onCompleted() = 0;
444
448 virtual void onAgoraCDNTokenWillExpire() = 0;
449
457 virtual void onPlayerSrcInfoChanged(const media::base::SrcInfo& from, const media::base::SrcInfo& to) = 0;
458
464 virtual void onPlayerInfoUpdated(const media::base::PlayerUpdatedInfo& info) = 0;
465
471 virtual void onPlayerCacheStats(const media::base::CacheStatistics& stats) {
472 (void)stats;
473 }
474
480 virtual void onPlayerPlaybackStats(const media::base::PlayerPlaybackStats& stats) {
481 (void)stats;
482 }
483
489 virtual void onAudioVolumeIndication(int volume) = 0;
490 };
491
492 } //namespace rtc
493 } // namespace agora
agora::rtc::IMediaPlayerSourceObserver::onPlayerInfoUpdated
virtual void onPlayerInfoUpdated(const media::base::PlayerUpdatedInfo &info)=0
Triggered when media player information updated.
agora::media::IAudioPcmFrameSink
Definition: AgoraMediaBase.h:1250
agora::rtc::IMediaPlayerSource::enableAutoSwitchAgoraCDN
virtual int enableAutoSwitchAgoraCDN(bool enable)=0
agora::rtc::IMediaPlayerSource::~IMediaPlayerSource
virtual ~IMediaPlayerSource()
Definition: IAgoraMediaPlayerSource.h:24
agora::rtc::IMediaPlayerSource::getPlayPosition
virtual int getPlayPosition(int64_t &pos)=0
agora::rtc::IMediaPlayerSource::openWithMediaSource
virtual int openWithMediaSource(const media::base::MediaSource &source)=0
agora::rtc::IMediaPlayerSource::switchAgoraCDNSrc
virtual int switchAgoraCDNSrc(const char *src, bool syncPts=false)=0
agora::rtc::IMediaPlayerSource
Definition: IAgoraMediaPlayerSource.h:22
agora::rtc::IMediaPlayerSource::selectMultiAudioTrack
virtual int selectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex)=0
agora::rtc::IMediaPlayerSource::seek
virtual int seek(int64_t newPos)=0
agora::rtc::IMediaPlayerSource::switchAgoraCDNLineByIndex
virtual int switchAgoraCDNLineByIndex(int index)=0
agora::media::base::CacheStatistics
Definition: AgoraMediaPlayerTypes.h:352
agora::rtc::IMediaPlayerSourceObserver
Definition: IAgoraMediaPlayerSource.h:380
agora::rtc::IMediaPlayerSource::playPreloadedSrc
virtual int playPreloadedSrc(const char *src)=0
agora::rtc::IMediaPlayerSource::setPlayerOption
virtual int setPlayerOption(const char *key, int64_t value)=0
agora::media::base::MEDIA_PLAYER_REASON
MEDIA_PLAYER_REASON
Player error code.
Definition: AgoraMediaPlayerTypes.h:108
agora::rtc::IMediaPlayerSource::registerAudioFrameObserver
virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink *observer)=0
agora::media::base::PlayerUpdatedInfo
The updated information of media player.
Definition: AgoraMediaPlayerTypes.h:387
agora::rtc::IMediaPlayerSourceObserver::onPlayerEvent
virtual void onPlayerEvent(media::base::MEDIA_PLAYER_EVENT eventCode, int64_t elapsedTime, const char *message)=0
Reports the playback event.
agora::rtc::IMediaPlayerSource::open
virtual int open(const char *url, int64_t startPos)=0
agora
Definition: AgoraAtomicOps.h:21
agora::rtc::IMediaPlayerSource::getCurrentAgoraCDNIndex
virtual int getCurrentAgoraCDNIndex()=0
agora::rtc::IMediaPlayerSource::pause
virtual int pause()=0
agora::rtc::IMediaPlayerSource::getStreamInfo
virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo *info)=0
agora::rtc::IMediaPlayerSourceObserver::onPositionChanged
virtual void onPositionChanged(int64_t positionMs, int64_t timestampMs)=0
Reports current playback progress.
agora::rtc::IMediaPlayerSourceObserver::onAudioVolumeIndication
virtual void onAudioVolumeIndication(int volume)=0
Triggered every 200 millisecond ,update player current volume range [0,255].
agora::rtc::IMediaPlayerSource::stop
virtual int stop()=0
agora::rtc::IMediaPlayerSourceObserver::onPlayerPlaybackStats
virtual void onPlayerPlaybackStats(const media::base::PlayerPlaybackStats &stats)
Triggered every 1 second, reports the statistics of the media stream being played.
Definition: IAgoraMediaPlayerSource.h:480
agora::rtc::IMediaPlayerSourceObserver::onPlayerCacheStats
virtual void onPlayerCacheStats(const media::base::CacheStatistics &stats)
Triggered every 1 second, reports the statistics of the files being cached.
Definition: IAgoraMediaPlayerSource.h:471
agora::rtc::IMediaPlayerSource::setPlayerOption
virtual int setPlayerOption(const char *key, const char *value)=0
agora::rtc::IMediaPlayerSourceObserver::onMetaData
virtual void onMetaData(const void *data, int length)=0
Occurs when the metadata is received.
agora::rtc::IMediaPlayerSourceObserver::onPlayerSourceStateChanged
virtual void onPlayerSourceStateChanged(media::base::MEDIA_PLAYER_STATE state, media::base::MEDIA_PLAYER_REASON reason)=0
Reports the playback state change.
agora::rtc::IMediaPlayerSourceObserver::onAgoraCDNTokenWillExpire
virtual void onAgoraCDNTokenWillExpire()=0
AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken(const char* src).
agora::media::base::MEDIA_PLAYER_STATE
MEDIA_PLAYER_STATE
The playback state.
Definition: AgoraMediaPlayerTypes.h:54
agora::media::base::PlayerStreamInfo
The information of the media stream object.
Definition: AgoraMediaPlayerTypes.h:266
agora::rtc::IMediaPlayerSource::getState
virtual media::base::MEDIA_PLAYER_STATE getState()=0
agora::rtc::IMediaPlayerSource::unloadSrc
virtual int unloadSrc(const char *src)=0
agora::rtc::IMediaPlayerSource::getSourceId
virtual int getSourceId() const =0
agora::rtc::IMediaPlayerSourceObserver::onCompleted
virtual void onCompleted()=0
Occurs when one playback of the media file is completed.
agora::rtc::IMediaPlayerSource::getStreamCount
virtual int getStreamCount(int64_t &count)=0
agora::rtc::IMediaPlayerSource::setExternalSubtitle
virtual int setExternalSubtitle(const char *url)=0
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::rtc::IMediaPlayerSource::setPlaybackSpeed
virtual int setPlaybackSpeed(int speed)=0
agora::rtc::IMediaPlayerSource::selectAudioTrack
virtual int selectAudioTrack(int64_t index)=0
agora::rtc::IMediaPlayerSource::getAgoraCDNLineCount
virtual int getAgoraCDNLineCount()=0
agora::rtc::IMediaPlayerSource::preloadSrc
virtual int preloadSrc(const char *src, int64_t startPos)=0
agora::rtc::IMediaPlayerSource::switchSrc
virtual int switchSrc(const char *src, bool syncPts)=0
agora::rtc::IMediaPlayerSource::takeScreenshot
virtual int takeScreenshot(const char *filename)=0
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::media::base::SrcInfo
The information of the media stream object.
Definition: AgoraMediaPlayerTypes.h:326
agora::rtc::IMediaPlayerSource::registerPlayerSourceObserver
virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver *observer)=0
agora::media::base::MEDIA_PLAYER_EVENT
MEDIA_PLAYER_EVENT
The playback event.
Definition: AgoraMediaPlayerTypes.h:188
agora::rtc::IMediaPlayerSourceObserver::onPlayerSrcInfoChanged
virtual void onPlayerSrcInfoChanged(const media::base::SrcInfo &from, const media::base::SrcInfo &to)=0
Reports current playback source bitrate changed.
agora::rtc::IMediaPlayerSource::selectInternalSubtitle
virtual int selectInternalSubtitle(int64_t index)=0
agora::rtc::IMediaPlayerSource::resume
virtual int resume()=0
agora::rtc::IMediaPlayerSource::getDuration
virtual int getDuration(int64_t &duration)=0
agora::rtc::IMediaPlayerSource::play
virtual int play()=0
agora::rtc::IMediaPlayerSourceObserver::onPlayBufferUpdated
virtual void onPlayBufferUpdated(int64_t playCachedBuffer)=0
Triggered when play buffer updated, once every 1 second.
agora::media::base::PLAYER_PRELOAD_EVENT
PLAYER_PRELOAD_EVENT
The play preload another source event.
Definition: AgoraMediaPlayerTypes.h:250
agora::rtc::IMediaPlayerSource::unregisterPlayerSourceObserver
virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver *observer)=0
agora::rtc::IMediaPlayerSource::renewAgoraCDNSrcToken
virtual int renewAgoraCDNSrcToken(const char *token, int64_t ts)=0
agora::rtc::IMediaPlayerSourceObserver::~IMediaPlayerSourceObserver
virtual ~IMediaPlayerSourceObserver()
Definition: IAgoraMediaPlayerSource.h:382
agora::rtc::IMediaPlayerSourceObserver::onPreloadEvent
virtual void onPreloadEvent(const char *src, media::base::PLAYER_PRELOAD_EVENT event)=0
Triggered when the player preloadSrc.
agora::rtc::IMediaPlayerSource::setLoopCount
virtual int setLoopCount(int64_t loopCount)=0
agora::rtc::IMediaPlayerSource::openWithAgoraCDNSrc
virtual int openWithAgoraCDNSrc(const char *src, int64_t startPos)=0
rtc
Definition: video_node_i.h:28
agora::rtc::IMediaPlayerSource::unregisterAudioFrameObserver
virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink *observer)=0