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.
- (instancetype)initWithDelegate:(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:name:
Initialize a publisher object, and specify the delegate object and the stream’s name.
- (instancetype)initWithDelegate:(id<OTPublisherKitDelegate>)delegate name:(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
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. 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.
- (instancetype)initWithDelegate:(id<OTPublisherKitDelegate>)delegate name:(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
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, assign) id<OTPublisherKitDelegate> delegate
Declared In
OTPublisherKit.h
audioLevelDelegate
Periodically receives reports of audio levels for this publisher.
@property (nonatomic, assign) id<OTPublisherKitAudioLevelDelegate> 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
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
Name must be set at initialization, when you when you send the [OTPublisherKit initWithDelegate:name:] message.
This value defaults to an empty string.
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
Setting publisher device configuration
videoCapture
The OTVideoCapture instance used to capture video to stream to the OpenTok session.
@property (nonatomic, retain) id<OTVideoCapture> 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, retain) id<OTVideoRender> videoRender
Declared In
OTPublisherKit.h
Setting the audio-only fallback mode
audioFallbackEnabled
Whether the stream will use the 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
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