Agora Java API Reference for Android
IAgoraMediaStreamingSource.h
1 //
2 // Agora SDK
3 // Copyright (c) 2019 Agora.io. All rights reserved.
4 //
5 // Created by xiaohua.lu in 2020-03.
6 // CodeStyle: Google C++
7 //
8 
9 #pragma once // NOLINT(build/header_guard)
10 
11 
12 #include "AgoraBase.h"
13 #include "AgoraMediaBase.h"
14 #include "AgoraMediaPlayerTypes.h"
15 #include "AgoraRefPtr.h"
16 
17 namespace agora {
18 namespace rtc {
19 
20 
21 class IMediaStreamingSourceObserver;
22 
23 
28 enum STREAMING_SRC_ERR {
29  STREAMING_SRC_ERR_NONE = 0,
30  STREAMING_SRC_ERR_UNKNOWN = 1,
31  STREAMING_SRC_ERR_INVALID_PARAM = 2,
32  STREAMING_SRC_ERR_BAD_STATE = 3,
33  STREAMING_SRC_ERR_NO_MEM = 4,
34  STREAMING_SRC_ERR_BUFFER_OVERFLOW = 5,
35  STREAMING_SRC_ERR_BUFFER_UNDERFLOW = 6,
36  STREAMING_SRC_ERR_NOT_FOUND = 7,
37  STREAMING_SRC_ERR_TIMEOUT = 8,
38  STREAMING_SRC_ERR_EXPIRED = 9,
39  STREAMING_SRC_ERR_UNSUPPORTED = 10,
40  STREAMING_SRC_ERR_NOT_EXIST = 11,
41  STREAMING_SRC_ERR_EXIST = 12,
42  STREAMING_SRC_ERR_OPEN = 13,
43  STREAMING_SRC_ERR_CLOSE = 14,
44  STREAMING_SRC_ERR_READ = 15,
45  STREAMING_SRC_ERR_WRITE = 16,
46  STREAMING_SRC_ERR_SEEK = 17,
47  STREAMING_SRC_ERR_EOF = 18,
48  STREAMING_SRC_ERR_CODECOPEN = 19,
49  STREAMING_SRC_ERR_CODECCLOSE = 20,
50  STREAMING_SRC_ERR_CODECPROC = 21,
51 };
52 
53 
54 
59 enum STREAMING_SRC_STATE {
60  STREAMING_SRC_STATE_CLOSED = 0,
61  STREAMING_SRC_STATE_OPENING = 1,
62  STREAMING_SRC_STATE_IDLE = 2,
63  STREAMING_SRC_STATE_PLAYING = 3,
64  STREAMING_SRC_STATE_SEEKING = 4,
65  STREAMING_SRC_STATE_EOF = 5,
66  STREAMING_SRC_STATE_ERROR = 6,
67 };
68 
69 
74 struct InputSeiData {
75  int32_t type;
76  int64_t timestamp;
77  int64_t frame_index;
78  uint8_t* private_data;
79  int32_t data_size;
80 };
81 
82 
83 
90 public:
91  virtual ~IMediaStreamingSource() {};
92 
93 
103  virtual int open(const char* url, int64_t start_pos, bool auto_play = true) = 0;
104 
111  virtual int close() = 0;
112 
119  virtual int getSourceId() const = 0;
120 
125  virtual bool isVideoValid() = 0;
126 
131  virtual bool isAudioValid() = 0;
132 
140  virtual int getDuration(int64_t& duration) = 0;
141 
149  virtual int getStreamCount(int64_t& count) = 0;
150 
159  virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* out_info) = 0;
160 
171  virtual int setLoopCount(int64_t loop_count) = 0;
172 
179  virtual int play() = 0;
180 
187  virtual int pause() = 0;
188 
195  virtual int stop() = 0;
196 
205  virtual int seek(int64_t new_pos) = 0;
206 
214  virtual int getCurrPosition(int64_t& pos) = 0;
215 
220  virtual STREAMING_SRC_STATE getCurrState() = 0;
221 
232  virtual int appendSeiData(const InputSeiData& inSeiData) = 0;
233 
244 
253 
263  virtual int parseMediaInfo(const char* url,
264  media::base::PlayerStreamInfo& video_info,
265  media::base::PlayerStreamInfo& audio_info) = 0;
266 
267 };
268 
269 
270 
275  public:
276  virtual ~IMediaStreamingSourceObserver() {};
277 
278 
287  virtual void onStateChanged(STREAMING_SRC_STATE state, STREAMING_SRC_ERR err_code) = 0;
288 
294  virtual void onOpenDone(STREAMING_SRC_ERR err_code) = 0;
295 
301  virtual void onSeekDone(STREAMING_SRC_ERR err_code) = 0;
302 
308  virtual void onEofOnce(int64_t progress_ms, int64_t repeat_count) = 0;
309 
315  virtual void onProgress(int64_t position_ms) = 0;
316 
324  virtual void onMetaData(const void* data, int length) = 0;
325 
326 };
327 
328 
329 
330 } //namespace rtc
331 } // namespace agora
332 
agora::rtc::IMediaStreamingSource::seek
virtual int seek(int64_t new_pos)=0
Sets the playback position of the streaming source. After seek done, it will return to previous statu...
agora::rtc::IMediaStreamingSource::stop
virtual int stop()=0
Stop the playing & pushing of the streaming source, set the position to 0.
agora::rtc::InputSeiData::private_data
uint8_t * private_data
SEI really data.
Definition: IAgoraMediaStreamingSource.h:78
agora::rtc::InputSeiData::frame_index
int64_t frame_index
the frame index which be attached
Definition: IAgoraMediaStreamingSource.h:77
agora::rtc::InputSeiData
The input SEI data.
Definition: IAgoraMediaStreamingSource.h:74
agora::rtc::IMediaStreamingSource::setLoopCount
virtual int setLoopCount(int64_t loop_count)=0
Sets whether to loop the streaming source for playback.
agora::rtc::IMediaStreamingSource::registerObserver
virtual int registerObserver(IMediaStreamingSourceObserver *observer)=0
agora::rtc::InputSeiData::data_size
int32_t data_size
size of really data
Definition: IAgoraMediaStreamingSource.h:79
agora::rtc::InputSeiData::type
int32_t type
SEI type.
Definition: IAgoraMediaStreamingSource.h:75
agora::rtc::IMediaStreamingSource::close
virtual int close()=0
Close current media streaming source.
agora::rtc::InputSeiData::timestamp
int64_t timestamp
the frame timestamp which be attached
Definition: IAgoraMediaStreamingSource.h:76
agora::rtc::IMediaStreamingSourceObserver
This observer interface of media streaming source.
Definition: IAgoraMediaStreamingSource.h:274
agora::rtc::IMediaStreamingSource::unregisterObserver
virtual int unregisterObserver(IMediaStreamingSourceObserver *observer)=0
agora::rtc::IMediaStreamingSource::appendSeiData
virtual int appendSeiData(const InputSeiData &inSeiData)=0
append the SEI data which can be sent attached to video packet
agora::rtc::IMediaStreamingSource::getSourceId
virtual int getSourceId() const =0
Gets the unique source ID of the streaming source.
agora::rtc::IMediaStreamingSourceObserver::onSeekDone
virtual void onSeekDone(STREAMING_SRC_ERR err_code)=0
Triggered when seeking is done.
agora::rtc::IMediaStreamingSourceObserver::onOpenDone
virtual void onOpenDone(STREAMING_SRC_ERR err_code)=0
Triggered when file is opened.
agora::rtc::IMediaStreamingSource::getStreamCount
virtual int getStreamCount(int64_t &count)=0
Gets the number of the streming source.
agora::media::base::PlayerStreamInfo
The information of the media stream object.
Definition: AgoraMediaPlayerTypes.h:249
agora::rtc::IMediaStreamingSourceObserver::onMetaData
virtual void onMetaData(const void *data, int length)=0
Occurs when the metadata is received. The callback occurs when the player receives the media metadata...
agora::rtc::IMediaStreamingSource::getCurrPosition
virtual int getCurrPosition(int64_t &pos)=0
Gets the current playback position of the media file.
agora::rtc::IMediaStreamingSource::parseMediaInfo
virtual int parseMediaInfo(const char *url, media::base::PlayerStreamInfo &video_info, media::base::PlayerStreamInfo &audio_info)=0
Parse a media information with a specified URL.
agora::rtc::IMediaStreamingSourceObserver::onStateChanged
virtual void onStateChanged(STREAMING_SRC_STATE state, STREAMING_SRC_ERR err_code)=0
Reports the playback state change. When the state of the playback changes, the SDK triggers this call...
agora::rtc::IMediaStreamingSource
The IMediaStreamingSource class provides access to a media streaming source demuxer....
Definition: IAgoraMediaStreamingSource.h:89
agora::rtc::IMediaStreamingSource::getStreamInfo
virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo *out_info)=0
Gets the detailed information of a media stream.
agora::rtc::IMediaStreamingSource::open
virtual int open(const char *url, int64_t start_pos, bool auto_play=true)=0
Opens a media streaming source with a specified URL.
agora::rtc::IMediaStreamingSourceObserver::onEofOnce
virtual void onEofOnce(int64_t progress_ms, int64_t repeat_count)=0
Triggered when playing is EOF.
agora::rtc::IMediaStreamingSourceObserver::onProgress
virtual void onProgress(int64_t position_ms)=0
Reports current playback progress. The callback triggered once every one second during the playing st...
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::IMediaStreamingSource::isAudioValid
virtual bool isAudioValid()=0
Retrieve whether audio stream is valid.
agora::rtc::IMediaStreamingSource::pause
virtual int pause()=0
Pauses the playing & pushing of the streaming source, Keep current position.
agora::rtc::IMediaStreamingSource::getDuration
virtual int getDuration(int64_t &duration)=0
Gets the duration of the streaming source.
agora::rtc::IMediaStreamingSource::isVideoValid
virtual bool isVideoValid()=0
Retrieve whether video stream is valid.
agora::rtc::IMediaStreamingSource::play
virtual int play()=0
Play & push the streaming source.
agora::rtc::IMediaStreamingSource::getCurrState
virtual STREAMING_SRC_STATE getCurrState()=0