Skip to contentSkip to navigationSkip to topbar
Rate this page:

Specify Video Constraints for iOS v1.x


(warning)

Warning

This page is for reference only. We are no longer onboarding new customers to Programmable Video. Existing customers can continue to use the product until December 5, 2024(link takes you to an external page).
We recommend migrating your application to the API provided by our preferred video partner, Zoom. We've prepared this migration guide(link takes you to an external page) to assist you in minimizing any service disruption.

Deprecation Notice - all 1.x Versions
Please note that all Programmable Video iOS SDK 1.x versions are deprecated. Version 3.x is the latest version of the Programmable Video iOS SDK. Please see the Getting Started Guide for more information.

You can customize the properties of the video produced by a TVIVideoCapturer using TVIVideoConstraints. Constraints allow you to choose at runtime between one of the many TVIVideoFormats that are supported by the capturer. The included TVICameraCapturer class exposes formats based upon what your device's cameras are capable of.

Constraints allow you to filter by several criteria including size, frame rate, and aspect ratio. While constraints are used to resolve the actual capture format, the video sent to other Participants may be downscaled (temporally or spatially) in response to network and device conditions.

In Swift


_20
// Create camera object
_20
let camera = TVICameraCapturer(source: .frontCamera)
_20
_20
// Setup the video constraints
_20
let videoConstraints = TVIVideoConstraints { (constraints) in
_20
constraints.maxSize = TVIVideoConstraintsSize960x540
_20
constraints.minSize = TVIVideoConstraintsSize960x540
_20
constraints.maxFrameRate = TVIVideoConstraintsFrameRateNone
_20
constraints.minFrameRate = TVIVideoConstraintsFrameRateNone
_20
}
_20
_20
// Add local video track with camera and video constraints
_20
localVideoTrack = TVILocalVideoTrack(capturer: capturer,
_20
enabled: true,
_20
constraints: videoConstraints)
_20
_20
// If the constraints are not satisfied, a nil track will be returned.
_20
if (localVideoTrack == nil) {
_20
print ("Error: Failed to create a video track using the local camera.")
_20
}

In Objective-C


_21
// Create camera object
_21
TVICameraCapturer *camera = = [[TVICameraCapturer alloc] init];
_21
_21
// Setup the video constraints
_21
TVIVideoConstraints *videoConstraints = [TVIVideoConstraints constraintsWithBlock:
_21
^(TVIVideoConstraintsBuilder * _Nonnull builder) {
_21
builder.maxSize = TVIVideoConstraintsSize960x540;
_21
builder.minSize = TVIVideoConstraintsSize960x540;
_21
builder.maxFrameRate = TVIVideoConstraintsFrameRateNone;
_21
builder.minFrameRate = TVIVideoConstraintsFrameRateNone;
_21
}];
_21
_21
// Add local video track with camera and video constraints
_21
TVIVideoTrack *localVideoTrack = [TVILocalVideoTrack trackWithCapturer:camera
_21
enabled:YES
_21
constraints:videoConstraints];
_21
_21
// If the constraints are not satisfied, a nil track will be returned.
_21
if (localVideoTrack == nil) {
_21
NSLog(@"Error: Failed to create a video track using the local camera.");
_21
}


Rate this page: