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
cameraTorch
The preferred flashlight (torch) mode for the camera. Setting this property to YES or NO indicates whether the publisher should enable or disable the camera’s flashlight when available. Note that this is a preference and may not take effect if the active camera does not support flashlight functionality (for example, the front camera typically does not support a flashlight). If the publisher camera is enabled, getting this property returns the current flashlight mode; if the publisher camera is not enabled, getting this property returns the preferred flashlight mode.
@property (nonatomic) BOOL cameraTorch
Declared In
OTPublisher.h
cameraZoomFactor
The preferred zoom factor (ratio) for the camera. A value of 1.0 represents no zoom (the default view). The value ranges from 0.5 to the maximum zoom factor. Values between 0.5 and 1.0 represent ultra-wide-angle (zoom out) and values between 1.0 and the maximum zoom factor represent zooming in. The actual zoom factor applied is automatically clamped to the range supported by the active camera’s configuration — if the camera does not support ultra-wide-angle, zoom factors set below 1.0 will not take effect and no zoom will be applied. For values over the maximum zoom factor supported by the camera, the zoom factor will be set with the max value. If the publisher camera is enabled, getting this property returns the current zoom factor; if the publisher camera is not enabled, getting this property returns the preferred zoom factor.
@property (nonatomic) float cameraZoomFactor
Declared In
OTPublisher.h