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 [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 videoRender
Declared 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 audioFallbackEnabled
Discussion
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
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