Agora RTC Objective-C API Reference Refactor

Public Member Functions
IRtmpConnection Class Referenceabstract

Inherits RefCountInterface.

## Public Member Functions
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

## 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()

~IRtmpConnection | ( |  | ) |
| inline

## Member Function Documentation

## ◆ connect()

virtual int 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 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 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* 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 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 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.

## ◆ AddRef()

virtual void AddRef | ( |  | ) | const
| pure virtual inherited

## ◆ Release()

virtual RefCountReleaseStatus Release | ( |  | ) | const
| pure virtual inherited

## ◆ HasOneRef()

virtual bool HasOneRef | ( |  | ) | const
| pure virtual inherited