OTPublisher Class Reference
Inherits from | OTPublisherKit : NSObject |
---|---|
Declared in | OTPublisher.h |
Overview
A publisher captures an audio-video stream from the device’s microphone and camera. 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.
Note that when testing in the iOS Simulator, an OTPublisher object uses a demo video, since the camera is not available in the Simulator.
Initializing a publisher
– initWithDelegate:settings:
Initialize the publisher with settings defined by an OTPublisherSettings object.
- (nullable instancetype)initWithDelegate:(nullable id<OTPublisherKitDelegate>)delegate settings:(nonnull OTPublisherSettings *)settings
Parameters
delegate |
The delegate (OTPublisherKitDelegate) object for the publisher. |
---|---|
settings |
The (OTPublisherSettings) object that defines settings for the publisher. |
Declared In
OTPublisher.h
– initWithDelegate:name:cameraResolution:cameraFrameRate:
Initialize a Publisher object.
- (nullable instancetype)initWithDelegate:(nullable id<OTPublisherKitDelegate>)delegate name:(nullable NSString *)name cameraResolution:(OTCameraCaptureResolution)cameraResolution cameraFrameRate:(OTCameraCaptureFrameRate)cameraFrameRate
Parameters
delegate |
The delegate (OTPublisherKitDelegate) object for the publisher. |
---|---|
name |
The name to appear at the bottom of the video. |
cameraResolution |
The resolution of the published video. Set this to a value defined in the OTCameraCaptureResolution enum. |
cameraFrameRate |
The frame rate of the published video. Set this to a value defined in the OTCameraCaptureFrameRate enum. If the device does not support the specified frame rate, it will set the frame rate to 30 frames per second. Note that in sessions that use the OpenTok Media Router (sessions with the media mode set to routed), lowering the frame rate proportionally reduces the bandwidth the stream uses. However, in sessions that have the media mode set to relayed, lowering the frame rate does not reduce the stream’s bandwidth. |
Return Value
The pointer to the instance, or nil
if initialization failed.
Discussion
This method is deprecated. Use [OTPublisher initWithDelegate:settings:] instead.
This method includes parameters for setting the resolution and the frame rate of the publisher’s video. If you use an initializer method inherited from OTPublisherKit, the resolution will be VGA, and the frame rate will be 30 frames per second.
For sessions that use the OpenTok Media Router (sessions with the media mode set to routed), lowering the frame rate or lowering the resolution reduces the maximum bandwidth the stream can use. However, in sessions with the media mode set to relayed, lowering the frame rate or resolution may not reduce the stream’s bandwidth.
Declared In
OTPublisher.h
Displaying the video
view
The view for this publisher. If this view becomes visible, it will display a preview of the active camera feed.
@property (readonly) UIView *view
Declared In
OTPublisher.h
viewScaleBehavior
The scaling of the rendered video, as defined by the OTVideoViewScaleBehavior enum. The default value is OTVideoViewScaleBehaviorFill. Set it to OTVideoViewScaleBehaviorFit to have the video shrink, as needed, so that the entire video is visible (with pillarboxing). This property only affects the local publisher’s video. Subscribers to the stream must set the [OTSubscriber viewScaleBehavior] property.
@property (nonatomic) OTVideoViewScaleBehavior viewScaleBehavior
Declared In
OTPublisher.h
Setting publisher device configuration
cameraPosition
The preferred camera position. When setting this property, if the change is possible, the publisher will use the camera with the specified position. If the publisher has begun publishing, getting this property returns the current camera position; if the publisher has not yet begun publishing, getting this property returns the preferred camera position.
@property (nonatomic) AVCaptureDevicePosition cameraPosition
Declared In
OTPublisher.h