Agora RTC Objective-C API Reference Refactor

NGIAgoraRtmpConnection.h
Go to the documentation of this file.
1 //
2 // Agora RTMP connection
3 //
4 // Created by Haonong Yu in 2020-02.
5 // Copyright (c) 2020 Agora.io. All rights reserved.
6 //
7
8 #pragma once // NOLINT(build/header_guard)
9
10 #include "AgoraBase.h"
11 #include "AgoraRefPtr.h"
12
13 namespace agora {
14 namespace rtc {
15
16 class IRtmpLocalUser;
17
21 struct RtmpStreamingAudioConfiguration {
25 int sampleRateHz;
26
30 int bytesPerSample;
31
35 int numberOfChannels;
36
41 int bitrate;
42
43 RtmpStreamingAudioConfiguration(): sampleRateHz(44100), bytesPerSample(2),
44 numberOfChannels(1), bitrate(48000) {}
45 };
46
50 struct RtmpStreamingVideoConfiguration {
59 int width;
60
69 int height;
70
75 int framerate;
76
81 int bitrate;
82
87 int maxBitrate;
88
93 int minBitrate;
94
99 unsigned int gopInMs;
100
108 int encoderHwSwMode;
109
116 int encoderBitrateControlMode;
117
122 ORIENTATION_MODE orientationMode;
123
124 RtmpStreamingVideoConfiguration(): width(640), height(360), framerate(15),
125 bitrate(800), maxBitrate(960), minBitrate(600), gopInMs(2000), encoderHwSwMode(0),encoderBitrateControlMode(0),
126 orientationMode(ORIENTATION_MODE_ADAPTIVE) {}
127 };
128
129
133 enum RTMP_CONNECTION_ERROR {
137 RTMP_CONNECTION_ERR_OK = 0,
138
142 RTMP_CONNECTION_ERR_FAILED = 1,
143
147 RTMP_CONNECTION_ERR_INVALID_URL = 2,
148
152 RTMP_CONNECTION_ERR_BAD_NAME = 3,
153 };
154
158 enum RTMP_CONNECTION_STATE {
170 STATE_DISCONNECTED = 1,
171
183 STATE_CONNECTING = 2,
184
195 STATE_CONNECTED = 3,
196
205 STATE_RECONNECTING = 4,
206
214 STATE_FAILED = 5,
215
224 STATE_RECONNECTED = 6
225 };
226
230 struct RtmpConnectionConfiguration {
231 RtmpStreamingAudioConfiguration audioConfig;
232 RtmpStreamingVideoConfiguration videoConfig;
233 bool enableWriteFlvFile;
234 bool audioOnly;
235 RtmpConnectionConfiguration() : enableWriteFlvFile(false),
236 audioOnly(false) {}
237 };
238
242 struct RtmpConnectionInfo {
246 RTMP_CONNECTION_STATE state;
247
248 RtmpConnectionInfo() : state(STATE_DISCONNECTED) {}
249 };
250
251
255 class IRtmpConnectionObserver {
256 public:
262 virtual void onConnected(const RtmpConnectionInfo& connectionInfo) = 0;
263
269 virtual void onDisconnected(const RtmpConnectionInfo& connectionInfo) = 0;
270
276 virtual void onReconnecting(const RtmpConnectionInfo& connectionInfo) = 0;
277
283 virtual void onReconnected(const RtmpConnectionInfo& connectionInfo) = 0;
284
291 virtual void onConnectionFailure(const RtmpConnectionInfo& connectionInfo,
292 RTMP_CONNECTION_ERROR errCode) = 0;
293
303 virtual void onTransferStatistics(uint64_t video_width, uint64_t video_height, uint64_t video_bitrate, uint64_t audio_bitrate, uint64_t video_frame_rate, uint64_t push_video_frame_cnt, uint64_t pop_video_frame_cnt) = 0;
304
305 virtual ~IRtmpConnectionObserver() {}
306 };
307
318 class IRtmpConnection : public RefCountInterface {
319 public:
320 ~IRtmpConnection() {}
321
341 virtual int connect(const char* url) = 0;
342
350 virtual int disconnect() = 0;
351
359 virtual RtmpConnectionInfo getConnectionInfo() = 0;
360
368 virtual IRtmpLocalUser* getRtmpLocalUser() = 0;
369
378 virtual int registerObserver(IRtmpConnectionObserver* observer, void(*safeDeleter)(IRtmpConnectionObserver*) = NULL) = 0;
379
389 virtual int unregisterObserver(IRtmpConnectionObserver* observer) = 0;
390 };
391
392 } // namespace rtc
393 } // namespace agora
agora::rtc::IRtmpConnection::unregisterObserver
virtual int unregisterObserver(IRtmpConnectionObserver *observer)=0
AgoraBase.h
agora::rtc::RtmpStreamingVideoConfiguration::bitrate
int bitrate
Definition: NGIAgoraRtmpConnection.h:81
agora::rtc::RtmpStreamingVideoConfiguration::height
int height
Definition: NGIAgoraRtmpConnection.h:69
agora::rtc::RTMP_CONNECTION_ERR_INVALID_URL
@ RTMP_CONNECTION_ERR_INVALID_URL
Definition: NGIAgoraRtmpConnection.h:147
agora::rtc::RTMP_CONNECTION_ERROR
RTMP_CONNECTION_ERROR
Definition: NGIAgoraRtmpConnection.h:133
agora::rtc::RTMP_CONNECTION_ERR_FAILED
@ RTMP_CONNECTION_ERR_FAILED
Definition: NGIAgoraRtmpConnection.h:142
agora::rtc::RTMP_CONNECTION_STATE
RTMP_CONNECTION_STATE
Definition: NGIAgoraRtmpConnection.h:158
agora::rtc::RtmpStreamingVideoConfiguration::orientationMode
ORIENTATION_MODE orientationMode
Definition: NGIAgoraRtmpConnection.h:122
agora::rtc::STATE_DISCONNECTED
@ STATE_DISCONNECTED
Definition: NGIAgoraRtmpConnection.h:170
agora::rtc::IRtmpConnectionObserver::onDisconnected
virtual void onDisconnected(const RtmpConnectionInfo &connectionInfo)=0
agora::rtc::IRtmpConnection::getRtmpLocalUser
virtual IRtmpLocalUser * getRtmpLocalUser()=0
agora::rtc::RtmpStreamingVideoConfiguration::maxBitrate
int maxBitrate
Definition: NGIAgoraRtmpConnection.h:87
agora::rtc::IRtmpConnection::disconnect
virtual int disconnect()=0
agora::rtc::RtmpConnectionInfo::RtmpConnectionInfo
RtmpConnectionInfo()
Definition: NGIAgoraRtmpConnection.h:248
agora::rtc::IRtmpConnection::~IRtmpConnection
~IRtmpConnection()
Definition: NGIAgoraRtmpConnection.h:320
agora::rtc::IRtmpConnection
Definition: NGIAgoraRtmpConnection.h:318
agora::rtc::RtmpConnectionConfiguration
Definition: NGIAgoraRtmpConnection.h:230
agora::rtc::RtmpConnectionInfo
Definition: NGIAgoraRtmpConnection.h:242
agora
Definition: AgoraAtomicOps.h:21
agora::rtc::RtmpConnectionConfiguration::audioOnly
bool audioOnly
Definition: NGIAgoraRtmpConnection.h:234
agora::rtc::RtmpConnectionConfiguration::enableWriteFlvFile
bool enableWriteFlvFile
Definition: NGIAgoraRtmpConnection.h:233
agora::rtc::RtmpStreamingAudioConfiguration::bitrate
int bitrate
Definition: NGIAgoraRtmpConnection.h:41
agora::rtc::RtmpStreamingVideoConfiguration::RtmpStreamingVideoConfiguration
RtmpStreamingVideoConfiguration()
Definition: NGIAgoraRtmpConnection.h:124
agora::rtc::RtmpStreamingVideoConfiguration::minBitrate
int minBitrate
Definition: NGIAgoraRtmpConnection.h:93
agora::rtc::IRtmpConnection::getConnectionInfo
virtual RtmpConnectionInfo getConnectionInfo()=0
agora::rtc::IRtmpConnectionObserver::onReconnecting
virtual void onReconnecting(const RtmpConnectionInfo &connectionInfo)=0
agora::rtc::RtmpStreamingVideoConfiguration
Definition: NGIAgoraRtmpConnection.h:50
agora::rtc::RTMP_CONNECTION_ERR_BAD_NAME
@ RTMP_CONNECTION_ERR_BAD_NAME
Definition: NGIAgoraRtmpConnection.h:152
agora::rtc::RtmpConnectionConfiguration::RtmpConnectionConfiguration
RtmpConnectionConfiguration()
Definition: NGIAgoraRtmpConnection.h:235
agora::rtc::IRtmpConnection::connect
virtual int connect(const char *url)=0
agora::rtc::RtmpConnectionInfo::state
RTMP_CONNECTION_STATE state
Definition: NGIAgoraRtmpConnection.h:246
agora::rtc::IRtmpConnectionObserver::onConnected
virtual void onConnected(const RtmpConnectionInfo &connectionInfo)=0
agora::rtc::RtmpStreamingAudioConfiguration::RtmpStreamingAudioConfiguration
RtmpStreamingAudioConfiguration()
Definition: NGIAgoraRtmpConnection.h:43
agora::rtc::IRtmpConnectionObserver::~IRtmpConnectionObserver
virtual ~IRtmpConnectionObserver()
Definition: NGIAgoraRtmpConnection.h:305
agora::rtc::STATE_CONNECTED
@ STATE_CONNECTED
Definition: NGIAgoraRtmpConnection.h:195
agora::rtc::RtmpStreamingAudioConfiguration
Definition: NGIAgoraRtmpConnection.h:21
agora::rtc::IRtmpConnection::registerObserver
virtual int registerObserver(IRtmpConnectionObserver *observer, void(*safeDeleter)(IRtmpConnectionObserver *)=NULL)=0
agora::rtc::IRtmpConnectionObserver::onTransferStatistics
virtual void onTransferStatistics(uint64_t video_width, uint64_t video_height, uint64_t video_bitrate, uint64_t audio_bitrate, uint64_t video_frame_rate, uint64_t push_video_frame_cnt, uint64_t pop_video_frame_cnt)=0
agora::rtc::RtmpStreamingVideoConfiguration::encoderBitrateControlMode
int encoderBitrateControlMode
Definition: NGIAgoraRtmpConnection.h:116
agora::rtc::RtmpStreamingAudioConfiguration::numberOfChannels
int numberOfChannels
Definition: NGIAgoraRtmpConnection.h:35
agora::rtc::RtmpStreamingVideoConfiguration::framerate
int framerate
Definition: NGIAgoraRtmpConnection.h:75
agora::rtc::RtmpStreamingAudioConfiguration::bytesPerSample
int bytesPerSample
Definition: NGIAgoraRtmpConnection.h:30
agora::rtc::RtmpStreamingVideoConfiguration::encoderHwSwMode
int encoderHwSwMode
Definition: NGIAgoraRtmpConnection.h:108
AgoraRefPtr.h
agora::rtc::RtmpConnectionConfiguration::videoConfig
RtmpStreamingVideoConfiguration videoConfig
Definition: NGIAgoraRtmpConnection.h:232
agora::rtc::ORIENTATION_MODE
ORIENTATION_MODE
Definition: AgoraBase.h:1018
agora::rtc::IRtmpConnectionObserver::onReconnected
virtual void onReconnected(const RtmpConnectionInfo &connectionInfo)=0
agora::rtc::STATE_RECONNECTING
@ STATE_RECONNECTING
Definition: NGIAgoraRtmpConnection.h:205
agora::rtc::STATE_CONNECTING
@ STATE_CONNECTING
Definition: NGIAgoraRtmpConnection.h:183
agora::rtc::RtmpStreamingVideoConfiguration::gopInMs
unsigned int gopInMs
Definition: NGIAgoraRtmpConnection.h:99
agora::rtc::RtmpConnectionConfiguration::audioConfig
RtmpStreamingAudioConfiguration audioConfig
Definition: NGIAgoraRtmpConnection.h:231
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::ORIENTATION_MODE_ADAPTIVE
@ ORIENTATION_MODE_ADAPTIVE
Definition: AgoraBase.h:1026
agora::rtc::IRtmpLocalUser
Definition: NGIAgoraRtmpLocalUser.h:117
agora::rtc::STATE_RECONNECTED
@ STATE_RECONNECTED
Definition: NGIAgoraRtmpConnection.h:224
agora::rtc::RtmpStreamingVideoConfiguration::width
int width
Definition: NGIAgoraRtmpConnection.h:59
agora::rtc::RTMP_CONNECTION_ERR_OK
@ RTMP_CONNECTION_ERR_OK
Definition: NGIAgoraRtmpConnection.h:137
agora::rtc::STATE_FAILED
@ STATE_FAILED
Definition: NGIAgoraRtmpConnection.h:214
agora::rtc::IRtmpConnectionObserver::onConnectionFailure
virtual void onConnectionFailure(const RtmpConnectionInfo &connectionInfo, RTMP_CONNECTION_ERROR errCode)=0
agora::rtc::IRtmpConnectionObserver
Definition: NGIAgoraRtmpConnection.h:255
agora::rtc::RtmpStreamingAudioConfiguration::sampleRateHz
int sampleRateHz
Definition: NGIAgoraRtmpConnection.h:25