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
30 enum STREAMING_SRC_ERR {
31 STREAMING_SRC_ERR_NONE = 0,
32 STREAMING_SRC_ERR_UNKNOWN = 1,
33 STREAMING_SRC_ERR_INVALID_PARAM = 2,
34 STREAMING_SRC_ERR_BAD_STATE = 3,
35 STREAMING_SRC_ERR_NO_MEM = 4,
36 STREAMING_SRC_ERR_BUFFER_OVERFLOW = 5,
37 STREAMING_SRC_ERR_BUFFER_UNDERFLOW = 6,
38 STREAMING_SRC_ERR_NOT_FOUND = 7,
39 STREAMING_SRC_ERR_TIMEOUT = 8,
40 STREAMING_SRC_ERR_EXPIRED = 9,
41 STREAMING_SRC_ERR_UNSUPPORTED = 10,
42 STREAMING_SRC_ERR_NOT_EXIST = 11,
43 STREAMING_SRC_ERR_EXIST = 12,
44 STREAMING_SRC_ERR_OPEN = 13,
45 STREAMING_SRC_ERR_CLOSE = 14,
46 STREAMING_SRC_ERR_READ = 15,
47 STREAMING_SRC_ERR_WRITE = 16,
48 STREAMING_SRC_ERR_SEEK = 17,
49 STREAMING_SRC_ERR_EOF = 18,
50 STREAMING_SRC_ERR_CODECOPEN = 19,
51 STREAMING_SRC_ERR_CODECCLOSE = 20,
52 STREAMING_SRC_ERR_CODECPROC = 21,
53 };
54
55
56
63 enum STREAMING_SRC_STATE {
64 STREAMING_SRC_STATE_CLOSED = 0,
65 STREAMING_SRC_STATE_OPENING = 1,
66 STREAMING_SRC_STATE_IDLE = 2,
67 STREAMING_SRC_STATE_PLAYING = 3,
68 STREAMING_SRC_STATE_SEEKING = 4,
69 STREAMING_SRC_STATE_EOF = 5,
70 STREAMING_SRC_STATE_ERROR = 6,
71 };
72
73
80 struct InputSeiData {
81 int32_t type;
82 int64_t timestamp;
83 int64_t frame_index;
84 uint8_t* private_data;
85 int32_t data_size;
86 };
87
88
89
97 class IMediaStreamingSource : public RefCountInterface {
98 public:
99 virtual ~IMediaStreamingSource() {};
100
101
111 virtual int open(const char* url, int64_t start_pos, bool auto_play = true) = 0;
112
119 virtual int close() = 0;
120
127 virtual int getSourceId() const = 0;
128
133 virtual bool isVideoValid() = 0;
134
139 virtual bool isAudioValid() = 0;
140
148 virtual int getDuration(int64_t& duration) = 0;
149
157 virtual int getStreamCount(int64_t& count) = 0;
158
167 virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* out_info) = 0;
168
179 virtual int setLoopCount(int64_t loop_count) = 0;
180
187 virtual int play() = 0;
188
195 virtual int pause() = 0;
196
203 virtual int stop() = 0;
204
213 virtual int seek(int64_t new_pos) = 0;
214
222 virtual int getCurrPosition(int64_t& pos) = 0;
223
228 virtual STREAMING_SRC_STATE getCurrState() = 0;
229
240 virtual int appendSeiData(const InputSeiData& inSeiData) = 0;
241
251 virtual int registerObserver(IMediaStreamingSourceObserver* observer) = 0;
252
260 virtual int unregisterObserver(IMediaStreamingSourceObserver* observer) = 0;
261
271 virtual int parseMediaInfo(const char* url,
272 media::base::PlayerStreamInfo& video_info,
273 media::base::PlayerStreamInfo& audio_info) = 0;
274
275 };
276
277
278
284 class IMediaStreamingSourceObserver {
285 public:
286 virtual ~IMediaStreamingSourceObserver() {};
287
288
297 virtual void onStateChanged(STREAMING_SRC_STATE state, STREAMING_SRC_ERR err_code) = 0;
298
304 virtual void onOpenDone(STREAMING_SRC_ERR err_code) = 0;
305
311 virtual void onSeekDone(STREAMING_SRC_ERR err_code) = 0;
312
318 virtual void onEofOnce(int64_t progress_ms, int64_t repeat_count) = 0;
319
325 virtual void onProgress(int64_t position_ms) = 0;
326
334 virtual void onMetaData(const void* data, int length) = 0;
335
336 };
337
338
339
340 } //namespace rtc
341 } // namespace agora
342
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:84
agora::rtc::InputSeiData::frame_index
int64_t frame_index
the frame index which be attached
Definition: IAgoraMediaStreamingSource.h:83
agora::rtc::InputSeiData
The input SEI data.
Definition: IAgoraMediaStreamingSource.h:80
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:85
agora::rtc::InputSeiData::type
int32_t type
SEI type.
Definition: IAgoraMediaStreamingSource.h:81
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:82
agora::rtc::IMediaStreamingSourceObserver
This observer interface of media streaming source.
Definition: IAgoraMediaStreamingSource.h:284
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 detailed information of the media stream.
Definition: AgoraMediaPlayerTypes.h:307
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:97
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