Navigation:  Communication Libary >

Creating RTMP (RTMPS) Connection

Previous pageReturn to chapter overviewNext page

Creating a connection with an RTMP server requires three parameters:

 

1.RTMP (RTMPS) server host name or IP address - the host name or IP address must be visible from the network the device is connected to. For the public Wi-Fi and 3G networks, the host name or IP address of the server must be publicly accessible. For the private Wi-Fi connections, the server must be on the same subnet.
2.RTMP (RTMPS) server port - the default port for many RTMP servers is 1935, some other servers may use 2037 or define a custom port.
3.Application name - all RTMP servers support the concept of an RTMP application. Typically this is a scope which maintains a collection of client connections and any RTMP resources created within the scope (for instance remote shared objects, media streams, etc).

 

Below is a sample code for connecting to the "MyApp" application on a server running at 192.168.0.11, on port 2037:

 

Header file:

RTMPClient *rtmpClient;

Class implementation file:

-(void)doConnect:(id)sender {                                
   rtmpClient = [[RTMPClient alloc] init];
   rtmpClient.delegate = self; // must be an instance of IRTMPClientDelegate
   [rtmpClient connect:@"rtmp://192.168.0.11:2037/MyApp"];
}

Class implementation file in case with a connection over RTMPS (notice the protocol in the URL - rtmps://) :

-(void)doConnect:(id)sender {                                
   rtmpClient = [[RTMPClient alloc] init];
   rtmpClient.delegate = self; // must be an instance of IRTMPClientDelegate
   [rtmpClient connect:@"rtmps://192.168.0.11:2037/MySecureApp"];
}

 

The reference assigned to the delegate property is self, it enables the client code to receive callbacks from the library for the events delivered via IRTMPClientDelegate. In the example above, the implementation class implements the IRTMPClientDelegate protocol, thus is the reference to self.