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
- 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.
- Select the Tab Bar Item entry, and open the Attributes Inspector
- Give the Bar Item a title of ‘Publish’
- Select all the UI content in the View of First View Controller and delete it. We will add custom UI a little later.
PublishViewController
-
Drag a View Controller from the Object Library and drop it into the storyboard alongside the First View Controller
-
;With the View Controller selected, focus on the Identity Inspector and change the Custom Class field to
PublishViewController
-
;Still within the Identity Inspector for the View Controller, assign a Storyboard ID of
publishView
-
;From the Project Explorer Right-Click on the Red5ProStreaming folder and select New File…
-
;Choose Object-C class from the wizard dialog and Next
-
;In the Class field, set
PublishViewController
and chooseR5VideoViewController
for Subclass of field -
;Select Next and add to project at current location
-
;Open the PublishViewController.h header, define as an R5StreamDelegate and add
start
andstop
methods to the interface@interface PublishViewController : R5VideoViewController<R5StreamDelegate> -(void)start; -(void)stop; @end
-
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