/

iOS Publisher


Included in the Red5 Pro iOS Streaming SDK is a R5VideoViewController which is an extension of the UIViewController and exposes an API to easily attach a stream for broadcasting. To complete the Publisher section of this example app, we will create an extension of the R5VideoViewController that will be responsible for creating a stream based on a custom configuration and expose an API to start and stop broadcsting.

Publisher Clean Slate

  1. Select the Main.storyboard of the project and expand the First View Controller. We will be modifying this View Controller to broadcast from the camera on the iOS device.
  2. Select the Tab Bar Item entry, and open the Attributes Inspector
  3. Give the Bar Item a title of 'Publish' show view
  4. Select all the UI content in the View of First View Controller and delete it. We will add custom UI a little later.

PublishViewController

  1. Drag a View Controller from the Object Library and drop it into the storyboard alongside the First View Controller
  2. ;With the View Controller selected, focus on the Identity Inspector and change the Custom Class field to PublishViewController
  3. ;Still within the Identity Inspector for the View Controller, assign a Storyboard ID of publishView
  4. ;From the Project Explorer Right-Click on the Red5ProStreaming folder and select New Fileā€¦
  5. ;Choose Object-C class from the wizard dialog and Next
  6. ;In the Class field, set PublishViewController and choose R5VideoViewController for Subclass of field
  7. ;Select Next and add to project at current location
  8. ;Open the PublishViewController.h header, define as an R5StreamDelegate and add start and stop methods to the interface

    @interface PublishViewController : R5VideoViewController<R5StreamDelegate>
    
    -(void)start;
    -(void)stop;
    
    @end
  9. Open the PublishViewController.m, import the R5Streaming header and add variables to the internal interface for an R5Configuration and R5Stream instance:

    #import "PublishViewController.h"
    #import <R5Streaming/R5Streaming.h>
    
    @interface PublishViewController () {
        R5Configuration *config;
        R5Stream *stream;
    }
    @end