Agora Java API Reference for Android
Public Member Functions | List of all members
agora::rtmp::IRtmpConnection Class Referenceabstract

#include <NGIAgoraRtmpConnection.h>

Inheritance diagram for agora::rtmp::IRtmpConnection:

Public Member Functions

virtual int connect (const char *url)=0
 
virtual int disconnect ()=0
 
virtual RtmpConnectionInfo getConnectionInfo ()=0
 
virtual IRtmpUsergetUser ()=0
 
virtual int registerObserver (IRtmpConnectionObserver *observer)=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.

Member Function Documentation

◆ connect()

virtual int agora::rtmp::IRtmpConnection::connect ( const char *  url)
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
urlThe 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::rtmp::IRtmpConnection::disconnect ( )
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::rtmp::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.

◆ getUser()

virtual IRtmpUser* agora::rtmp::IRtmpConnection::getUser ( )
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::rtmp::IRtmpConnection::registerObserver ( IRtmpConnectionObserver observer)
pure virtual

Registers an IRtmpConnectionObserver object.

Parameters
observerA pointer to the IRtmpConnectionObserver object.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterObserver()

virtual int agora::rtmp::IRtmpConnection::unregisterObserver ( IRtmpConnectionObserver observer)
pure virtual

Releases the registered IRtmpConnectionObserver object.

Parameters
observerThe pointer to the IRtmpConnectionObserver object created by the registerObserver method.
Returns
  • 0: Success.
  • < 0: Failure.