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>)delegateParameters
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 *)settingsParameters
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 *)nameParameters
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)videoTrackParameters
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 delegateDiscussion
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 audioLevelDelegateDiscussion
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 networkStatsDelegateDiscussion
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 rtcStatsReportDelegateDeclared In
OTPublisherKit.h
session
The session that owns this publisher.
@property (readonly) OTSession *sessionDeclared In
OTPublisherKit.h
stream
The OTStream object associated with the publisher.
@property (readonly) OTStream *streamDeclared 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 *nameDiscussion
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)getRtcStatsReportDiscussion
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 publishAudioDiscussion
The default value is TRUE.
Declared In
OTPublisherKit.h
publishVideo
Whether to publish video.
@property (nonatomic) BOOL publishVideoDiscussion
The default value is TRUE.
Declared In
OTPublisherKit.h
publishCaptions
Whether to make captions active.
@property (nonatomic) BOOL publishCaptionsDiscussion
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 videoCaptureDeclared In
OTPublisherKit.h
videoType
Specifies the type of video for the published stream.
@property (nonatomic, assign) OTPublisherKitVideoType videoTypeDiscussion
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 [OTPublisherKit audioFallbackEnabled] property is 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 videoRenderDeclared In
OTPublisherKit.h
Setting the audio-only fallback mode
audioFallbackEnabled
Whether the stream will use the subscriber audio-fallback feature (YES) or
not (NO). The audio-fallback feature is available in sessions
that use the the OpenTok Media Router. With the audio-fallback feature
enabled, when the OpenTok Media Router determines that a stream’s quality has
degraded significantly for a specific subscriber, it disables the video in
that subscriber in order to preserve call quality.
@property (nonatomic, assign) BOOL audioFallbackEnabledDiscussion
This method is deprecated. Use [OTPublisherKitSettings subscriberAudioFallbackEnabled] instead.
The default setting is YES (the audio-fallback feature is
enabled) for publishers using the camera. To turn off the audio-fallback
feature, set this property to NO before calling the
[OTSession publish:error:] method. However, When using the
screen video type in a session that uses the OpenTok Media Server, the
audioFallbackEnabled property is set to NO by default; this disables the
audio-only fallback feature, so that the video does not drop out in
subscribers.
For more information, see [OTPublisherKit videoType], <[OTSubscriberKitDelegate subscriberVideoDisabled:reason:]>, OTSubscriberVideoEventReason, the OpenTok Media Router.
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 maxVideoBitrateDiscussion
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 videoBitratePresetDiscussion
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
Setting media transformers
videoTransformers
Array of OTVideoTransformer in the order to be applied to the stream.
@property (nonatomic, strong) NSArray *videoTransformersDeclared In
OTPublisherKit.h
audioTransformers
Array of OTAudioTransformer in the order to be applied to the stream.
@property (nonatomic, strong) NSArray *audioTransformersDeclared In
OTPublisherKit.h