Inherits from NSObject
Declared in OTSubscriberKit.h

Overview

An OTSubscriberKit (subscriber) object renders media data bound to an OTStream. The OTSubscriberKit class lets you set a custom video renderer for the video stream. Use this class if you are interested in providing your own video processing and rendering implementation. Otherwise, use the OTSubscriber class, which includes a pre-built video processor and renderer.

The stream property references the stream that you have subscribed to. The OTSubscriberKit class includes methods that let you disable and enable local audio and video playback for the subscribed stream.

Tasks

Getting basic information about a Subscriber

  •   session

    The OTSession object that owns this subscriber. An instance will have one and only one OTSession associated with it, and this property is immutable.

    property
  •   stream

    The stream this subscriber is bound to. Any media channels on the stream should be available for display/playback with this instance.

    property
  •   delegate

    The OTSubscriberKitDelegate object that serves as a delegate, handling events for this OTSubscriber object.

    property
  •   subscribeToAudio

    Whether to subscribe to the stream’s audio.

    property
  •   subscribeToVideo

    Whether to subscribe to the stream’s video. Setting this property only has an affect if you do so immediately after initializing the OTSubscriber object.

    property
  •   videoRender

    The video renderer for this instance.

    property

Initializing a Subscriber

Properties

delegate

The OTSubscriberKitDelegate object that serves as a delegate, handling events for this OTSubscriber object.

@property (nonatomic, assign) id<OTSubscriberKitDelegate> delegate

Declared In

OTSubscriberKit.h

session

The OTSession object that owns this subscriber. An instance will have one and only one OTSession associated with it, and this property is immutable.

@property (readonly) OTSession *session

Declared In

OTSubscriberKit.h

stream

The stream this subscriber is bound to. Any media channels on the stream should be available for display/playback with this instance.

@property (readonly) OTStream *stream

Declared In

OTSubscriberKit.h

subscribeToAudio

Whether to subscribe to the stream’s audio.

@property (nonatomic) BOOL subscribeToAudio

Discussion

The default value is YES.

Setting this property has no effect if the [OTStream hasAudio] property is set to NO.

Declared In

OTSubscriberKit.h

subscribeToVideo

Whether to subscribe to the stream’s video. Setting this property only has an affect if you do so immediately after initializing the OTSubscriber object.

@property (nonatomic) BOOL subscribeToVideo

Discussion

The default value is YES.

Setting this property has no effect if the [OTStream hasVideo] property is set to NO.

Declared In

OTSubscriberKit.h

videoRender

The video renderer for this instance.

@property (nonatomic, retain) id<OTVideoRender> videoRender

Declared In

OTSubscriberKit.h

Instance Methods

initWithStream:delegate:

Initializes a subscriber and binds it to an OTStream instance. Once initialized, the instance is permanently bound to the stream.

- (id)initWithStream:(OTStream *)stream delegate:(id<OTSubscriberKitDelegate>)delegate

Parameters

stream

The OTStream object to bind this instance to.

delegate

The delegate (OTSubscriberKitDelegate) that will handle events generated by this instance.

Discussion

The OpenTok iOS SDK supports a limited number of simultaneous audio-video streams in an app:

  • On iPad 2 and iPad 3, the limit is four streams. An app can have up to four simultaneous subscribers, or one publisher and up to three subscribers.
  • On all other supported iOS devices, the limit is two streams. An app can have up to two subscribers, or one publisher and one subscriber.

Initializing a subscriber causes it to start streaming data from the OpenTok server, regardless of whether the view of the subscriber object is added to a superview.

You can stream audio only (without subscribing to the video stream) by setting the [OTSubscriberKit subscribeToVideo] property to NO immediately after initializing the OTSubscriber object. You can stream video only (without subscribing to the audio stream) by setting the [OTSubscriberKit subscribeToAudio] property to NO immediately after initializing the OTSubscriber object.

When the subscriber connects to the stream, the [OTSubscriberKitDelegate subscriberDidConnectToStream:] message is sent.

For an OTSubscriber object, when the first frame of video has been decoded, the [OTSubscriberDelegate subscriberVideoDataReceived:] message is sent.

If the subscriber fails to connect to the stream, the [OTSubscriberKitDelegate subscriber:didFailWithError:] message is sent.

Declared In

OTSubscriberKit.h