Agora C++ API Reference for All Platforms

Public Member Functions | List of all members
agora::rtc::IRtmpConnection Class Referenceabstract

Inherits agora::RefCountInterface.

Inherited by agora::rtc::IRtmpConnectionEx.

## Public Member Functions
| ~IRtmpConnection ()
virtual int | connect (const char *url, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | disconnect (aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual RtmpConnectionInfo | getConnectionInfo ()=0
virtual IRtmpLocalUser * | getRtmpLocalUser ()=0
virtual int | registerObserver (IRtmpConnectionObserver *observer, void(*safeDeleter)(IRtmpConnectionObserver *)=NULL, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | unregisterObserver (IRtmpConnectionObserver *observer)=0
Public Member Functions inherited from agora::RefCountInterface
virtual void | AddRef () const =0
virtual RefCountReleaseStatus | Release () const =0
virtual bool | HasOneRef () const =0

## Additional Inherited Members
Protected Member Functions inherited from agora::RefCountInterface
virtual | ~RefCountInterface ()

## Detailed Description

The IRtmpConnection class.

With this class, an app can establish a connection to a RTMP server. Once connected, the app gets an RtmpUser object, which can publish media streams to the RTMP server.

Connecting to the server is done asynchronous, and apps can listen for the connection states or events with IRtmpConnectionObserver.

## Constructor & Destructor Documentation

## ◆ ~IRtmpConnection()

agora::rtc::IRtmpConnection::~IRtmpConnection | ( |  | ) |
| inline

## Member Function Documentation

## ◆ connect()

virtual int agora::rtc::IRtmpConnection::connect | ( | const char * | url,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Connects to a RTMP server.

When the method call succeeds, the RTMP connection state changes to STATE_CONNECTING(2).

Depending on the success or failure of the connection establishment, the RTMP connection will make a second state transition to either STATE_CONNECTED(3) or STATE_FAILED(5). You will also be notified with the either onConnected() or onDisconnected().

Parameters

  url | The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters.

Returns
  - 0: Success.
  - < 0: Failure.
    - ERR_INVALID_ARGUMENT: The passed in argument is invalid.
    - ERR_INVALID_STATE: The current connection state is not STATE_DISCONNECTED(3).

## ◆ disconnect()

virtual int agora::rtc::IRtmpConnection::disconnect | ( | aosl_ref_t | ares = `AOSL_REF_INVALID` | ) |
| pure virtual

Disconnects from the RTMP server.

A successful call of this method changes the connection state to STATE_DISCONNECTED(4). You will be notified with the callback onDisconnected.

## ◆ getConnectionInfo()

virtual RtmpConnectionInfo agora::rtc::IRtmpConnection::getConnectionInfo | ( |  | ) |
| pure virtual

Gets the current connection information.

Returns
  - A pointer to the RtmpConnectionInfo object, if the method call succeeds.
  - An empty pointer NULL, if the method call fails.

## ◆ getRtmpLocalUser()

virtual IRtmpLocalUser* agora::rtc::IRtmpConnection::getRtmpLocalUser | ( |  | ) |
| pure virtual

Gets the IRtmpUser object.

Returns
  - A pointer to the IRtmpUser object, if the method call succeeds.
  - An empty pointer NULL, if the method call fails.

## ◆ registerObserver()

virtual int agora::rtc::IRtmpConnection::registerObserver | ( | IRtmpConnectionObserver * | observer,
|  | void(*)(IRtmpConnectionObserver *) | safeDeleter = `NULL`,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Registers an IRtmpConnectionObserver object.

Parameters

  observer | A pointer to the IRtmpConnectionObserver object.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ unregisterObserver()

virtual int agora::rtc::IRtmpConnection::unregisterObserver | ( | IRtmpConnectionObserver * | observer | ) |
| pure virtual

Releases the registered IRtmpConnectionObserver object.

Parameters

  observer | The pointer to the IRtmpConnectionObserver object created by the registerObserver method.

Returns
  - 0: Success.
  - < 0: Failure.