Live stream with Wowza GoCoder SDK for iOS

Learn how to start, stop, and monitor a live stream broadcast with Wowza GoCoder™ SDK for iOS.

Contents


Start streaming
Stop streaming
Monitor the status of the live stream
More resources

Start streaming


Use the startStreaming method in the WowzaGoCoder class to initiate a live stream.

//Make sure streaming isn't already active
if (!self.goCoder.isStreaming)
  // Start the live stream
  [self.goCoder startStreaming:statusCallback];

Note: If you start a broadcast and get the message, "Limited Bandwidth," it means you're using a bitrate that's too large for the current network conditions. The broadcaster will start buffering frames to preserve the quality of the playback and any recordings, but this will increase playback latency. To minimize latency, try using a lower bitrate instead.

Stop streaming


Use the endStreaming method in the WowzaGoCoder class to stop a live stream.

if (self.goCoder.isStreaming)
  // Stop the live stream
  [self.goCoder endStreaming:statusCallback];

Monitor the status of the live stream


Use the statusCallback argument for the startStreaming and endStreaming methods to implement the WOWZStatusCallback interface. This interface defines the following callbacks that are invoked for a live stream broadcast:

Property Description
WOWZStateIdle The stream is inactive. This is the state before and after the broadcast.
WOWZStateStarting The audio and video inputs are initializing and connecting to a Wowza Streaming Engine server or to the Wowza Streaming Cloud live stream.
WOWZStateRunning The broadcast is streaming.
WOWZStateStopping The streaming connection is closing. After the connection closes, the broadcast state returns to WOWZStateIdle.

The following example shows successful state transitions as well as an error:

//
// Methods implemented for the WOWZStatusCallback protocol
//

// A successful status transition has been reported by the GoCoder SDK  
- (void) onSuccess:(WZStatus *) goCoderStatus {
    switch (goCoderStatus.state) {
  case WOWZStateIdle:
      NSLog(@"SDK State: %@",
    "There is no active streaming broadcast session");
      break;

  case WOWZStateStarting:
      NSLog(@"SDK State: %@",
    "A streaming broadcast session is starting up");
      break;

  case WOWZStateRunning:
      NSLog(@"SDK State: %@",
    "A streaming broadcast session is running");
      break;

  case WOWZStateStopping:
      NSLog(@"SDK State: %@",
    "A streaming broadcast session is shutting down");
      break;
    }
}

// If an error is reported by the GoCoder SDK, display an alert
// that contains the error details   
- (void) onError:(WOWZStatus *) goCoderStatus {
    // Run this on the U/I thread
    dispatch_async(dispatch_get_main_queue(), ^{
  UIAlertView *alertDialog =
      [[UIAlertView alloc] initWithTitle:@"Live Streaming Error"
        message:goCoderStatus.description
        delegate:nil
    cancelButtonTitle:@"OK"
    otherButtonTitles:nil];
  [alertDialog show];    
    });
}

More resources