createCameraVideoTrack static method
- String? cameraId,
- CustomVideoTrackConfig encoderConfig = CustomVideoTrackConfig.h720p_w1280p,
- FacingMode facingMode = FacingMode.user,
- bool multiStream = true,
- BitrateMode bitrateMode = BitrateMode.BALANCED,
- int maxLayer = 3,
Creates a camera-based video track with customizable capture and encoding configurations.
This method allows you to create a custom video track using a camera device with configurable resolution, frame rate, camera facing mode, and multi-stream support.
Parameters
-
cameraId(optional): The device ID of the camera from which the video should be captured. If not provided, the default camera will be used. -
encoderConfig(optional): The video encoder configuration to be used for the video track. Defaults to CustomVideoTrackConfig.h720p_w1280p.Note: These encoder configurations are valid for both landscape and portrait orientations.
-
facingMode(optional): Specifies which camera to use for video capture. Defaults to FacingMode.user.Allowed values:
-
multiStream(optional): Determines whether multiple resolution layers should be sent for the video stream. Defaults totrue.Info:
- For meetings with four or fewer participants, setting
multiStream: falseis recommended for better performance. - Available from SDK version
v1.0.9.
- For meetings with four or fewer participants, setting
-
bitrateMode(optional): Controls how the bitrate is managed for the video stream. Defaults to BitrateMode.BALANCED. -
maxLayer(optional): Specifies the maximum number of simulcast layers to publish. Valid values are between1and3. Defaults to3.
Returns
- A Future that resolves to a CustomTrack representing the
created video track, or
nullif video track creation fails.
Example
final CustomTrack? videoTrack =
await VideoSDK.createCameraVideoTrack(
encoderConfig: CustomVideoTrackConfig.h1440p_w1920p,
facingMode: FacingMode.user,
multiStream: false,
bitrateMode: BitrateMode.BALANCED,
maxLayer: 2,
);
if (videoTrack != null) {
print('Video track created successfully');
}
Implementation
static createCameraVideoTrack({
String? cameraId,
CustomVideoTrackConfig encoderConfig = CustomVideoTrackConfig.h720p_w1280p,
FacingMode facingMode = FacingMode.user,
bool multiStream = true,
BitrateMode bitrateMode = BitrateMode.BALANCED,
int maxLayer = 3,
}) =>
_createCameraVideoTrack(
cameraId: cameraId,
encoderConfig: encoderConfig,
facingMode: facingMode,
multiStream: multiStream,
bitrateMode: bitrateMode,
maxLayer: maxLayer);