# OTPublisherKit Class Reference

Inherits from | NSObject
Declared in | OTPublisherKit.h

## Overview

A publisher captures an audio-video stream from the sources you specify. You can then publish the audio-video stream to an OpenTok session by sending the [OTSession publish:error:] message.

The OpenTok iOS SDK supports publishing on all multi-core iOS devices. See “Developer and client requirements” in the README file for the OpenTok iOS SDK.

## Initializing a publisher

### `– initWithDelegate:`

Initialize a publisher object and specify the delegate object.

`- (nullable instancetype)initWithDelegate:(nullable id<OTPublisherKitDelegate>)delegate`

#### Parameters

`delegate` | The delegate (OTPublisherKitDelegate) object for the publisher.

#### Return Value

The pointer to the instance, or `nil` if initialization failed.

#### Discussion

When running in the XCode iOS Simulator, this method returns `nil`.

#### Declared In

`OTPublisherKit.h`

### `– initWithDelegate:settings:`

Initialize the publisher with settings defined by an OTPublisherKitSettings object.

`- (nullable instancetype)initWithDelegate:(nullable id<OTPublisherKitDelegate>)delegate settings:(nonnull OTPublisherKitSettings *)settings`

#### Parameters

`delegate` | The delegate (OTPublisherKitDelegate) object for the publisher.
`settings` | The (OTPublisherKitSettings) object that defines settings for the publisher.

#### Declared In

`OTPublisherKit.h`

### `– initWithDelegate:name:`

Initialize a publisher object, and specify the delegate object and the stream’s name.

`- (nullable instancetype)initWithDelegate:(nullable id<OTPublisherKitDelegate>)delegate name:(nullable NSString *)name`

#### Parameters

`delegate` | The delegate (OTPublisherKitDelegate) object for the publisher.
`name` | The name of the publisher video. The [OTStream name] property for a stream published by this publisher will be set to this value (on all clients).

#### Return Value

The pointer to the instance, or `nil` if initialization failed.

#### Discussion

This method is deprecated. Use [OTPublisherKit initWithDelegate:settings:] instead.

When running in the XCode iOS Simulator, this method returns `nil`.

#### Declared In

`OTPublisherKit.h`

### `– initWithDelegate:name:audioTrack:videoTrack:`

Initialize the publisher, and specify whether audio and video will be enabled for this instance.

`- (nullable instancetype)initWithDelegate:(nullable id<OTPublisherKitDelegate>)delegate name:(nullable NSString *)name audioTrack:(BOOL)audioTrack videoTrack:(BOOL)videoTrack`

#### Parameters

`delegate` | The delegate (OTPublisherKitDelegate) object for the publisher.
`name` | The name of the publisher video. The [OTStream name] property for a stream published by this publisher will be set to this value (on all clients).
`audioTrack` | Whether to publish audio (YES) or not (NO).
`videoTrack` | Whether to publish video (YES) or not (NO).

#### Discussion

This method is deprecated. Use [OTPublisherKit initWithDelegate:settings:] instead.

If either audioTrack or videoTrack are set to NO, the respective subsystem will not be initialized, and setting the corresponding [OTPublisherKit publishAudio] and [OTPublisherKit publishVideo] properties will have no effect.

If your application does not require the use of audio or video, it is recommended to set these values rather than use the [OTPublisherKit publishAudio] and [OTPublisherKit publishVideo] properties, which only temporarily disable the tracks.

#### Declared In

`OTPublisherKit.h`

## Getting information about the publisher

### `delegate`

The OTPublisherDelegate object, which is the delegate for the OTPublisher object.

`@property (nonatomic, weak) id<OTPublisherKitDelegate> _Nullable delegate`

#### Discussion

See also [OTPublisherKit audioLevelDelegate], [OTPublisherKit networkStatsDelegate], and [OTPublisherKit rtcStatsReportDelegate].

#### Declared In

`OTPublisherKit.h`

### `audioLevelDelegate`

Periodically receives reports of audio levels for this publisher.

`@property (nonatomic, weak) id<OTPublisherKitAudioLevelDelegate> _Nullable audioLevelDelegate`

#### Discussion

This is a separate delegate object from that set as the delegate property (the OTPublisherKitDelegate object).

If you do not set this property, the audio sampling subsystem is disabled.

#### Declared In

`OTPublisherKit.h`

### `networkStatsDelegate`

The OTPublisherKitNetworkStatsDelegate object that periodically receives publisher quality statistics.

`@property (nonatomic, weak) id<OTPublisherKitNetworkStatsDelegate> _Nullable networkStatsDelegate`

#### Discussion

This delegate object is sent messages reporting the following:

- Total audio and video packets lost
- Total audio and video packets received
- Total audio and video bytes received

This is a separate delegate object from that set as the [OTPublisherKit delegate] property (the OTPublisherKitDelegate object).

Also see [OTPublisherKit rtcStatsReportDelegate].

#### Declared In

`OTPublisherKit.h`

### `rtcStatsReportDelegate`

The OTPublisherKitRtcStatsReportDelegate that reports RTC stats for the publisher. The [OTPublisherKitRtcStatsReportDelegate publisher:rtcStatsReport:] message is sent in reponse to calling the [OTPublisherKit getRtcStatsReport] method.

`@property (nonatomic, weak) id<OTPublisherKitRtcStatsReportDelegate> _Nullable rtcStatsReportDelegate`

#### Declared In

`OTPublisherKit.h`

### `session`

The session that owns this publisher.

`@property (readonly) OTSession *session`

#### Declared In

`OTPublisherKit.h`

### `stream`

The OTStream object associated with the publisher.

`@property (readonly) OTStream *stream`

#### Declared In

`OTPublisherKit.h`

### `name`

A string that will be associated with this publisher’s stream. This string is displayed at the bottom of subscriber videos associated with the published stream, if an overlay to display the name exists.

`@property (readonly) NSString *name`

#### Discussion

The name must be set at initialization, when you when you send the [OTPublisherKit initWithDelegate:settings:] message.

This value defaults to an empty string.

#### Declared In

`OTPublisherKit.h`

### `– getRtcStatsReport`

Gets the RTC stats report for the publisher. This is an asynchronous operation. Set the [OTPublisherKit rtcStatsReportDelegate] property and implement the [OTPublisherKitRtcStatsReportDelegate publisher:rtcStatsReport:] method prior to calling this method. When the stats are available, the implementation of the [OTPublisherKitRtcStatsReportDelegate publisher:rtcStatsReport:] message is sent.

`- (void)getRtcStatsReport`

#### Discussion

Also see [OTPublisherKit networkStatsDelegate] and [OTSubscriberKit getRtcStatsReport].

#### Declared In

`OTPublisherKit.h`

## Controlling audio and video output for a publisher

### `publishAudio`

Whether to publish audio.

`@property (nonatomic) BOOL publishAudio`

#### Discussion

The default value is TRUE.

#### Declared In

`OTPublisherKit.h`

### `publishVideo`

Whether to publish video.

`@property (nonatomic) BOOL publishVideo`

#### Discussion

The default value is TRUE.

#### Declared In

`OTPublisherKit.h`

### `publishCaptions`

Whether to make captions active.

`@property (nonatomic) BOOL publishCaptions`

#### Discussion

The default value is FALSE.

#### Declared In

`OTPublisherKit.h`

## Setting publisher device configuration

### `videoCapture`

The OTVideoCapture instance used to capture video to stream to the OpenTok session.

`@property (nonatomic, strong) id<OTVideoCapture> _Nullable videoCapture`

#### Declared In

`OTPublisherKit.h`

### `videoType`

Specifies the type of video for the published stream.

`@property (nonatomic, assign) OTPublisherKitVideoType videoType`

#### Discussion

Set this to one of the following values:

- `OTPublisherKitVideoTypeScreen` — Optimizes the video encoding for screen sharing. To publish a screen-sharing stream, you need to implement a custom video capturer for the OTPublisherKit object. See [OTPublisherKit videoCapture]. It is recommended to use a low frame rate (5 frames per second or lower) with this video type. When using the screen video type in a session that uses the OpenTok Media Server, the OTPublisherKitSettings audio fallback properties are set to NO by default; this disables the audio-only fallback feature, so that the video does not drop out in subscribers. See the OpenTok Media Router.

- `OTPublisherKitVideoTypeCamera` — This is the default setting, which you should use when using a camera as the video source.

#### Declared In

`OTPublisherKit.h`

### `videoRender`

The OTVideoRender instance used to render video to stream to the OpenTok session.

`@property (nonatomic, strong) id<OTVideoRender> _Nullable videoRender`

#### Declared In

`OTPublisherKit.h`

## Controlling the Publisher’s Video Bitrate Preset

### `maxVideoBitrate`

The maximum video bitrate for the publisher’s video stream, in bits per second (bps).

`@property (nonatomic) int maxVideoBitrate`

#### Discussion

This property sets an explicit upper limit on the publisher’s video bitrate, between 5,000 and 10,000,000. Setting this property to `0` clears any manual cap and reverts to the default preset-based adaptive bitrate behavior with no explicit limit.

When reading this property, it returns the currently configured maximum bitrate in bps. If no manual bitrate has been set, or if a bitrate preset is active, the value is `0`.

A value of `0` indicates that no explicit bitrate limit is applied and the stream operates under adaptive preset rules to optimize quality.

Also see [OTPublisherKit videoBitratePreset] and Publisher Max Bitrate.

#### Declared In

`OTPublisherKit.h`

### `videoBitratePreset`

The video bitrate preset strategy applied to the publisher’s video stream.

`@property (nonatomic) OTVideoBitratePreset videoBitratePreset`

#### Discussion

This property configures a predefined bitrate strategy to balance video quality and bandwidth usage. Available presets include default behavior, moderate bandwidth saving, and aggressive bandwidth saving modes. Preset strategies allow control over encoder behavior without specifying explicit bitrate values.

Preset configurations and manual bitrate settings are mutually exclusive. Setting `maxVideoBitrate` will override any preset and automatically change this property’s value to `OTVideoBitratePresetCustom`.

Reading this property returns the currently active preset. If a custom bitrate has been manually set, the value will be `OTVideoBitratePresetCustom`.

The default value is `OTVideoBitratePresetDefault`.

Also see [OTPublisherKit maxVideoBitrate] and Publisher Max Bitrate.

#### Declared In

`OTPublisherKit.h`

### `degradationPreference`

The preferred policy that the video engine will follow when adjusting frame rate and resolution to limited bandwidth and CPU conditions. See OTDegradationPreference for a description of the possible values.

`@property (nonatomic) OTDegradationPreference degradationPreference`

#### Declared In

`OTPublisherKit.h`

### `targetScalabilityMode`

The target scalability mode that was explicitly set via setTargetScalabilityMode:error:. Returns the last value passed to the setter, or null if the setter has never been called. This reflects the user’s intent, not the mode actually applied (which may differ due to codec-dependent fallback).

`@property (nonatomic, readonly) NSString *targetScalabilityMode`

#### Discussion

This is a beta feature.

#### Declared In

`OTPublisherKit.h`

### `– setTargetScalabilityMode:error:`

The target scalability mode (SVC - Scalable Video Coding) for this publisher. The scalability mode controls the number of spatial (resolution) and temporal (frame rate) layers that WebRTC encodes. The mode is applied to the Media Router media path.

`- (void)setTargetScalabilityMode:(NSString *_Nullable)mode error:(NSError *_Nullable *_Nullable)error`

#### Parameters

`mode` | The desired scalability mode string (e.g. @“L1T3”). Must be one of: L1T1, L1T2, L1T3, L2T1, L2T2, L2T3, L3T1, L3T2, L3T3.
`error` | On failure, set to an OTError with domain OT_PUBLISHER_ERROR_DOMAIN and code OTPublisherInvalidScalabilityMode.

#### Discussion

The setter may be called at any time — it does not require the media path negotiation to have completed. The mode will be applied once the Media Router media path is established.

If a non-SVC codec (VP8, H.264) is negotiated on the Media Router media path, the closest applicable mode is used: spatial layers are forced to 1, preserving the temporal dimension (e.g. L2T2 → L1T2 when VP8 is negotiated).

#### Declared In

`OTPublisherKit.h`

## Setting media transformers

### `videoTransformers`

Array of OTVideoTransformer in the order to be applied to the stream.

`@property (nonatomic, strong) NSArray *videoTransformers`

#### Declared In

`OTPublisherKit.h`

### `audioTransformers`

Array of OTAudioTransformer in the order to be applied to the stream.

`@property (nonatomic, strong) NSArray *audioTransformers`

#### Declared In

`OTPublisherKit.h`