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.
Initializing a publisher
– initWithDelegate:name:cameraResolution:cameraFrameRate:
Initialize a Publisher object.
- (instancetype)initWithDelegate:(id<OTPublisherKitDelegate>)delegate name:(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. |
Return Value
The pointer to the instance, or nil
if initialization failed.
Discussion
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.
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