-
- All Implemented Interfaces:
-
com.twilio.video.Track,com.twilio.video.VideoCapturerObserver
public class LocalVideoTrack extends VideoTrack implements VideoCapturerObserver
A local video track that receives video frames from a VideoCapturer or .
When a local video track is created, the SDK will call and on the calling thread before returning the local video track instance. The capturer will be instructed to start capturing at the default video format of 640x480 at 30 FPS unless any of the following conditions are true:
- The caller provides a specific VideoFormat when creating the local video track. In this case, the tvi.webrtc.VideoCapturer is responsible for capturing at the provided VideoFormat.
- The capturer is an instance of VideoCapturer and no VideoFormat is provided when creating the local video track. In this case, the SDK will call with the result of .
-
-
Field Summary
Fields Modifier and Type Field Description private final VideoCapturervideoCapturerprivate final VideoFormatvideoFormatprivate final VideoSourcevideoSource
-
Method Summary
Modifier and Type Method Description VideoCapturergetVideoCapturer()Returns the tvi.webrtc.VideoCapturer associated with this video track. VideoFormatgetVideoFormat()Returns the video track's VideoFormat. VideoSourcegetVideoSource()Returns the tvi.webrtc.VideoSource associated with this video track. static LocalVideoTrackcreate(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer)Creates a local video track. static LocalVideoTrackcreate(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer, @Nullable() VideoFormat videoFormat)Creates a local video track. static LocalVideoTrackcreate(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer, @Nullable() String name)Creates a local video track. static LocalVideoTrackcreate(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer, @Nullable() VideoFormat videoFormat, @Nullable() String name)Creates a local video track. synchronized voidaddSink(@NonNull() VideoSink videoSink)Add a video sink to receive frames from the video track. synchronized voidremoveSink(@NonNull() VideoSink videoSink)Remove a video sink to stop receiving video from the video track. synchronized booleanisEnabled()Check if the local video track is enabled. StringgetName()Returns the local video track name. synchronized voidenable(boolean enabled)Sets the state of the local video track. synchronized voidrelease()Releases native memory owned by video track. voidonCaptureParametersChanged()-
-
Method Detail
-
getVideoCapturer
@NonNull() VideoCapturer getVideoCapturer()
Returns the tvi.webrtc.VideoCapturer associated with this video track.
-
getVideoFormat
@NonNull() VideoFormat getVideoFormat()
Returns the video track's VideoFormat.
-
getVideoSource
@NonNull() VideoSource getVideoSource()
Returns the tvi.webrtc.VideoSource associated with this video track.
-
create
@Nullable() static LocalVideoTrack create(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer)
Creates a local video track.
If the capturer is an instance of VideoCapturer then will be called with the result of getCaptureFormat. This behavior allows VideoCapturer implementations to provide a better default capture format. For example, the provides a resolution derived from the device's screen dimensions.
If the capturer is an instance of tvi.webrtc.VideoCapturer then the default formatof 640x480 at 30 FPS will be used.
- Parameters:
context- application context.enabled- initial state of video track.videoCapturer- capturer that provides video frames.
-
create
@Nullable() static LocalVideoTrack create(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer, @Nullable() VideoFormat videoFormat)
Creates a local video track.
The video capturer will be instructed to capture at the provided VideoFormat.
- Parameters:
context- application context.enabled- initial state of video track.videoCapturer- capturer that provides video frames.videoFormat- format to capture frames.
-
create
@Nullable() static LocalVideoTrack create(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer, @Nullable() String name)
Creates a local video track.
If the capturer is an instance of VideoCapturer then will be called with the result of getCaptureFormat. This behavior allows VideoCapturer implementations to provide a better default capture format. For example, the provides a resolution derived from the device's screen dimensions.
If the capturer is an instance of tvi.webrtc.VideoCapturer then the default formatof 640x480 at 30 FPS will be used.
- Parameters:
context- application context.enabled- initial state of video track.videoCapturer- capturer that provides video frames.name- video track name.
-
create
@Nullable() static LocalVideoTrack create(@NonNull() Context context, boolean enabled, @NonNull() VideoCapturer videoCapturer, @Nullable() VideoFormat videoFormat, @Nullable() String name)
Creates a local video track.
The video capturer will be instructed to capture at the provided VideoFormat.
- Parameters:
context- application context.enabled- initial state of video track.videoCapturer- capturer that provides video frames.videoFormat- format to capture frames.name- video track name.
-
addSink
synchronized void addSink(@NonNull() VideoSink videoSink)
Add a video sink to receive frames from the video track.
- Parameters:
videoSink- video sink that receives video.
-
removeSink
synchronized void removeSink(@NonNull() VideoSink videoSink)
Remove a video sink to stop receiving video from the video track.
- Parameters:
videoSink- the video sink that should no longer receive video.
-
isEnabled
synchronized boolean isEnabled()
Check if the local video track is enabled.
When the value is false, blank video frames are sent. When the value is true, frames fromthe video capturer are provided.
-
getName
@NonNull() String getName()
Returns the local video track name. A pseudo random string is returned if no track name wasspecified.
-
enable
synchronized void enable(boolean enabled)
Sets the state of the local video track. The results of this operation are signaled to otherParticipants in the same Room. When a video track is disabled, blank frames are sent in placeof video frames from a video capturer.
- Parameters:
enabled- the desired state of the local video track.
-
release
synchronized void release()
Releases native memory owned by video track.
-
onCaptureParametersChanged
void onCaptureParametersChanged()
-
-
-
-