Agora C++ API Reference for All Platforms

Loading...
Searching...
No Matches
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
17namespace agora {
18namespace rtc {
19
20
21class 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 {
98public:
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::RefCountInterface
Definition AgoraRefPtr.h:31
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::play
virtual int play()=0
Play & push the streaming source.
agora::rtc::IMediaStreamingSource::getCurrState
virtual STREAMING_SRC_STATE getCurrState()=0
agora::rtc::IMediaStreamingSource::setLoopCount
virtual int setLoopCount(int64_t loop_count)=0
Sets whether to loop the streaming source for playback.
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::IMediaStreamingSource::stop
virtual int stop()=0
Stop the playing & pushing of the streaming source, set the position to 0.
agora::rtc::IMediaStreamingSource::isVideoValid
virtual bool isVideoValid()=0
Retrieve whether video stream is valid.
agora::rtc::IMediaStreamingSource::getDuration
virtual int getDuration(int64_t &duration)=0
Gets the duration of the streaming source.
agora::rtc::IMediaStreamingSource::unregisterObserver
virtual int unregisterObserver(IMediaStreamingSourceObserver *observer)=0
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::IMediaStreamingSource::getSourceId
virtual int getSourceId() const =0
Gets the unique source ID of the streaming source.
agora::rtc::IMediaStreamingSource::getCurrPosition
virtual int getCurrPosition(int64_t &pos)=0
Gets the current playback position of the media file.
agora::rtc::IMediaStreamingSource::isAudioValid
virtual bool isAudioValid()=0
Retrieve whether audio stream is valid.
agora::rtc::IMediaStreamingSource::~IMediaStreamingSource
virtual ~IMediaStreamingSource()
Definition IAgoraMediaStreamingSource.h:99
agora::rtc::IMediaStreamingSource::pause
virtual int pause()=0
Pauses the playing & pushing of the streaming source, Keep current position.
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::appendSeiData
virtual int appendSeiData(const InputSeiData &inSeiData)=0
append the SEI data which can be sent attached to video packet
agora::rtc::IMediaStreamingSource::registerObserver
virtual int registerObserver(IMediaStreamingSourceObserver *observer)=0
agora::rtc::IMediaStreamingSource::getStreamCount
virtual int getStreamCount(int64_t &count)=0
Gets the number of the streming source.
agora::rtc::IMediaStreamingSource::close
virtual int close()=0
Close current media streaming source.
agora::rtc::IMediaStreamingSourceObserver
This observer interface of media streaming source.
Definition IAgoraMediaStreamingSource.h:284
agora::rtc::IMediaStreamingSourceObserver::onOpenDone
virtual void onOpenDone(STREAMING_SRC_ERR err_code)=0
Triggered when file is opened.
agora::rtc::IMediaStreamingSourceObserver::onSeekDone
virtual void onSeekDone(STREAMING_SRC_ERR err_code)=0
Triggered when seeking is done.
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::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::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::rtc::IMediaStreamingSourceObserver::~IMediaStreamingSourceObserver
virtual ~IMediaStreamingSourceObserver()
Definition IAgoraMediaStreamingSource.h:286
agora::rtc::IMediaStreamingSourceObserver::onEofOnce
virtual void onEofOnce(int64_t progress_ms, int64_t repeat_count)=0
Triggered when playing is EOF.
agora::rtc
Definition AgoraExtensions.h:5
agora::rtc::STREAMING_SRC_ERR
STREAMING_SRC_ERR
The error code of streaming source.
Definition IAgoraMediaStreamingSource.h:30
agora::rtc::STREAMING_SRC_ERR_CLOSE
@ STREAMING_SRC_ERR_CLOSE
fail to IO close
Definition IAgoraMediaStreamingSource.h:45
agora::rtc::STREAMING_SRC_ERR_EXPIRED
@ STREAMING_SRC_ERR_EXPIRED
expired
Definition IAgoraMediaStreamingSource.h:40
agora::rtc::STREAMING_SRC_ERR_EOF
@ STREAMING_SRC_ERR_EOF
reach to IO EOF, can do nothing
Definition IAgoraMediaStreamingSource.h:49
agora::rtc::STREAMING_SRC_ERR_CODECOPEN
@ STREAMING_SRC_ERR_CODECOPEN
fail to codec open
Definition IAgoraMediaStreamingSource.h:50
agora::rtc::STREAMING_SRC_ERR_CODECPROC
@ STREAMING_SRC_ERR_CODECPROC
fail to codec process
Definition IAgoraMediaStreamingSource.h:52
agora::rtc::STREAMING_SRC_ERR_NOT_FOUND
@ STREAMING_SRC_ERR_NOT_FOUND
buffer underflow
Definition IAgoraMediaStreamingSource.h:38
agora::rtc::STREAMING_SRC_ERR_WRITE
@ STREAMING_SRC_ERR_WRITE
fail to IO write
Definition IAgoraMediaStreamingSource.h:47
agora::rtc::STREAMING_SRC_ERR_NO_MEM
@ STREAMING_SRC_ERR_NO_MEM
not enough memory
Definition IAgoraMediaStreamingSource.h:35
agora::rtc::STREAMING_SRC_ERR_TIMEOUT
@ STREAMING_SRC_ERR_TIMEOUT
buffer underflow
Definition IAgoraMediaStreamingSource.h:39
agora::rtc::STREAMING_SRC_ERR_UNSUPPORTED
@ STREAMING_SRC_ERR_UNSUPPORTED
unsupported
Definition IAgoraMediaStreamingSource.h:41
agora::rtc::STREAMING_SRC_ERR_NOT_EXIST
@ STREAMING_SRC_ERR_NOT_EXIST
component not exist
Definition IAgoraMediaStreamingSource.h:42
agora::rtc::STREAMING_SRC_ERR_BAD_STATE
@ STREAMING_SRC_ERR_BAD_STATE
bad status
Definition IAgoraMediaStreamingSource.h:34
agora::rtc::STREAMING_SRC_ERR_SEEK
@ STREAMING_SRC_ERR_SEEK
fail to IO seek
Definition IAgoraMediaStreamingSource.h:48
agora::rtc::STREAMING_SRC_ERR_READ
@ STREAMING_SRC_ERR_READ
fail to IO read
Definition IAgoraMediaStreamingSource.h:46
agora::rtc::STREAMING_SRC_ERR_NONE
@ STREAMING_SRC_ERR_NONE
no error
Definition IAgoraMediaStreamingSource.h:31
agora::rtc::STREAMING_SRC_ERR_INVALID_PARAM
@ STREAMING_SRC_ERR_INVALID_PARAM
invalid parameter
Definition IAgoraMediaStreamingSource.h:33
agora::rtc::STREAMING_SRC_ERR_UNKNOWN
@ STREAMING_SRC_ERR_UNKNOWN
unknown error
Definition IAgoraMediaStreamingSource.h:32
agora::rtc::STREAMING_SRC_ERR_BUFFER_UNDERFLOW
@ STREAMING_SRC_ERR_BUFFER_UNDERFLOW
buffer underflow
Definition IAgoraMediaStreamingSource.h:37
agora::rtc::STREAMING_SRC_ERR_EXIST
@ STREAMING_SRC_ERR_EXIST
component already exist
Definition IAgoraMediaStreamingSource.h:43
agora::rtc::STREAMING_SRC_ERR_CODECCLOSE
@ STREAMING_SRC_ERR_CODECCLOSE
fail to codec close
Definition IAgoraMediaStreamingSource.h:51
agora::rtc::STREAMING_SRC_ERR_BUFFER_OVERFLOW
@ STREAMING_SRC_ERR_BUFFER_OVERFLOW
buffer overflow
Definition IAgoraMediaStreamingSource.h:36
agora::rtc::STREAMING_SRC_ERR_OPEN
@ STREAMING_SRC_ERR_OPEN
fail to IO open
Definition IAgoraMediaStreamingSource.h:44
agora::rtc::STREAMING_SRC_STATE
STREAMING_SRC_STATE
The state machine of Streaming Source.
Definition IAgoraMediaStreamingSource.h:63
agora::rtc::STREAMING_SRC_STATE_ERROR
@ STREAMING_SRC_STATE_ERROR
The error status and can do nothing except close.
Definition IAgoraMediaStreamingSource.h:70
agora::rtc::STREAMING_SRC_STATE_PLAYING
@ STREAMING_SRC_STATE_PLAYING
after call play() method, playing & pushing the AV data
Definition IAgoraMediaStreamingSource.h:67
agora::rtc::STREAMING_SRC_STATE_CLOSED
@ STREAMING_SRC_STATE_CLOSED
streaming source still closed, can do nothing
Definition IAgoraMediaStreamingSource.h:64
agora::rtc::STREAMING_SRC_STATE_EOF
@ STREAMING_SRC_STATE_EOF
The position is located at end, can NOT playing.
Definition IAgoraMediaStreamingSource.h:69
agora::rtc::STREAMING_SRC_STATE_IDLE
@ STREAMING_SRC_STATE_IDLE
streaming source is ready waiting for play
Definition IAgoraMediaStreamingSource.h:66
agora::rtc::STREAMING_SRC_STATE_OPENING
@ STREAMING_SRC_STATE_OPENING
after call open() method and start parsing streaming source
Definition IAgoraMediaStreamingSource.h:65
agora::rtc::STREAMING_SRC_STATE_SEEKING
@ STREAMING_SRC_STATE_SEEKING
after call seek() method, start seeking poisition
Definition IAgoraMediaStreamingSource.h:68
agora
Definition AgoraAtomicOps.h:21
agora::media::base::PlayerStreamInfo
The detailed information of the media stream.
Definition AgoraMediaPlayerTypes.h:307
agora::rtc::InputSeiData
The input SEI data.
Definition IAgoraMediaStreamingSource.h:80
agora::rtc::InputSeiData::timestamp
int64_t timestamp
the frame timestamp which be attached
Definition IAgoraMediaStreamingSource.h:82
agora::rtc::InputSeiData::frame_index
int64_t frame_index
the frame index which be attached
Definition IAgoraMediaStreamingSource.h:83
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::InputSeiData::private_data
uint8_t * private_data
SEI really data.
Definition IAgoraMediaStreamingSource.h:84