Navigation:  Media Library >

Video and Audio Streaming (Device to Server)

Previous pageReturn to chapter overviewNext page

The BroadcastStreamClient class is responsible for streaming data to a media server.

 

Below is a sample code for video and audio streaming to the "MyApp" application on a server running at 192.168.0.11, port 2037. Notice the publishType:PUBLISH_LIVE argument in the stream call on an instance of BroadcastStreamClient.

 

Header file:

UIImageView *drawImage;
BroadcastStreamClient *upstream;
RTMPClient *rtmpClient;

Class Implementation file:

-(void) initConnection {
 rtmpClient = [[RTMPClient alloc] init];
 rtmpClient.delegate = self;
 [rtmpClient connect:@"rtmp://192.168.0.11:2037/MyApp"];
}
 
-(void)connect:(id)sender {        
         upstream = [[BroadcastStreamClient alloc] initWithClient:rtmpClient];
         upstream.imageView = drawImage; // contains the current video frame
         upstream.delegate = self // must be an instance of IBroadcastStreamClientDelegate
 [upstream stream:@"MyStream" publishType:PUBLISH_LIVE];
}
 
-(void)disconnect:(id)sender {        
   [upstream disconnect];
   upstream = nil;
}
 
-(void)startPublish {
   [upstream start];
}
 
-(void)stopPublish {  
   [upstream stop];
}
 
-(void)pausePublish {
   [upstream pause];
}

 

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

 

Default streaming settings are shown below:

 

Audio:

    codec - Nelly Mozer 16KHz, mono

    bitrate - 128000

 

Video:

    codec - H.263 (Sorenson)

    bitrate - 200000

    resolution - 192x144px

    fps = 25

    intra frame - 10

 

Currently the library does not provide an instrument to control the stream quality. This is planned for a future release.