OTPublisher
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.
Properties
| Name | Type | Description |
|---|---|---|
view |
UIView * | The view for this publisher. If this view becomes visible, it will display a preview of the active camera feed. |
viewScaleBehavior |
OTVideoViewScaleBehavior | 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. |
cameraPosition |
AVCaptureDevicePosition | 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. |
cameraTorch |
BOOL | 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. |
cameraZoomFactor |
float | 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. |
Methods
| Name | Description |
|---|---|
initWithDelegate:settings:(delegate, settings) → {instancetype} |
Initialize the publisher with settings defined by an OTPublisherSettings object. |
initWithDelegate:name:cameraResolution:cameraFrameRate:(delegate, name, cameraResolution, __attribute) → {instancetype} |
Initialize a Publisher object. |
initWithDelegate:settings:(delegate, settings) → {instancetype}
Initialize the publisher with settings defined by an OTPublisherSettings object.
Parameters:
| Name | Type | Description |
|---|---|---|
delegate |
id<OTPublisherKitDelegate> | The delegate (OTPublisherKitDelegate) object for the publisher. |
settings |
OTPublisherSettings * | The (OTPublisherSettings) object that defines settings for the publisher. |
Returns:
initWithDelegate:name:cameraResolution:cameraFrameRate:(delegate, name, cameraResolution, __attribute) → {instancetype}
Initialize a Publisher object.
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.
Parameters:
| Name | Type | Description |
|---|---|---|
delegate |
id<OTPublisherKitDelegate> | The delegate (OTPublisherKitDelegate) object for the publisher. |
name |
NSString * | The name to appear at the bottom of the video. |
cameraResolution |
OTCameraCaptureResolution | The resolution of the published video. Set this to a value defined in the OTCameraCaptureResolution enum. |
__attribute |
(deprecated(("Use initWithDelegate: settings: instead"))) |
Returns:
The pointer to the instance, or nil if initialization failed.