Class LocalVideoTrack
- java.lang.Object
-
- com.twilio.video.VideoTrack
-
- com.twilio.video.LocalVideoTrack
-
- All Implemented Interfaces:
Track
,VideoCapturerObserver
public class LocalVideoTrack extends VideoTrack implements VideoCapturerObserver
A local video track that receives video frames from aVideoCapturer
orVideoCapturer
.When a local video track is created, the SDK will call
VideoCapturer.initialize(SurfaceTextureHelper, Context, CapturerObserver)
andVideoCapturer.startCapture(int, int, int)
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, theVideoCapturer
is responsible for capturing at the providedVideoFormat
. - The capturer is an instance of
VideoCapturer
and noVideoFormat
is provided when creating the local video track. In this case, the SDK will callVideoCapturer.startCapture(int, int, int)
with the result ofVideoCapturer.getCaptureFormat()
.
- See Also:
VideoCapturer
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSink(VideoSink videoSink)
Add a video sink to receive frames from the video track.static LocalVideoTrack
create(android.content.Context context, boolean enabled, VideoCapturer videoCapturer)
Creates a local video track.static LocalVideoTrack
create(android.content.Context context, boolean enabled, VideoCapturer videoCapturer, VideoFormat videoFormat)
Creates a local video track.static LocalVideoTrack
create(android.content.Context context, boolean enabled, VideoCapturer videoCapturer, VideoFormat videoFormat, java.lang.String name)
Creates a local video track.static LocalVideoTrack
create(android.content.Context context, boolean enabled, VideoCapturer videoCapturer, java.lang.String name)
Creates a local video track.void
enable(boolean enabled)
Sets the state of the local video track.java.lang.String
getName()
Returns the local video track name.VideoCapturer
getVideoCapturer()
Returns theVideoCapturer
associated with this video track.VideoFormat
getVideoFormat()
Returns the video track'sVideoFormat
.VideoSource
getVideoSource()
Returns theVideoSource
associated with this video track.boolean
isEnabled()
Check if the local video track is enabled.void
onCaptureParametersChanged()
void
release()
Releases native memory owned by video track.void
removeSink(VideoSink videoSink)
Remove a video sink to stop receiving video from the video track.-
Methods inherited from class com.twilio.video.VideoTrack
getSinks
-
-
-
-
Method Detail
-
create
@Nullable public static LocalVideoTrack create(@NonNull android.content.Context context, boolean enabled, @NonNull VideoCapturer videoCapturer)
Creates a local video track.If the capturer is an instance of
VideoCapturer
thenVideoCapturer.startCapture(int, int, int)
will be called with the result ofVideoCapturer.getCaptureFormat()
. This behavior allowsVideoCapturer
implementations to provide a better default capture format. For example, theScreenCapturer
provides a resolution derived from the device's screen dimensions.If the capturer is an instance of
VideoCapturer
then the default format of 640x480 at 30 FPS will be used.- Parameters:
context
- application context.enabled
- initial state of video track.videoCapturer
- capturer that provides video frames.- Returns:
- local video track if successfully added or
null
if video track could not be created.
-
create
@Nullable public static LocalVideoTrack create(@NonNull android.content.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.- Returns:
- local video track if successfully added or null if video track could not be created.
-
create
@Nullable public static LocalVideoTrack create(@NonNull android.content.Context context, boolean enabled, @NonNull VideoCapturer videoCapturer, @Nullable java.lang.String name)
Creates a local video track.If the capturer is an instance of
VideoCapturer
thenVideoCapturer.startCapture(int, int, int)
will be called with the result ofVideoCapturer.getCaptureFormat()
. This behavior allowsVideoCapturer
implementations to provide a better default capture format. For example, theScreenCapturer
provides a resolution derived from the device's screen dimensions.If the capturer is an instance of
VideoCapturer
then the default format of 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.- Returns:
- local video track if successfully added or null if video track could not be created.
-
create
@Nullable public static LocalVideoTrack create(@NonNull android.content.Context context, boolean enabled, @NonNull VideoCapturer videoCapturer, @Nullable VideoFormat videoFormat, @Nullable java.lang.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.- Returns:
- local video track if successfully added or null if video track could not be created.
-
getVideoCapturer
@NonNull public VideoCapturer getVideoCapturer()
Returns theVideoCapturer
associated with this video track.
-
getVideoFormat
@NonNull public VideoFormat getVideoFormat()
Returns the video track'sVideoFormat
.
-
getVideoSource
@NonNull public VideoSource getVideoSource()
Returns theVideoSource
associated with this video track.
-
addSink
public void addSink(@NonNull VideoSink videoSink)
Description copied from class:VideoTrack
Add a video sink to receive frames from the video track.- Overrides:
addSink
in classVideoTrack
- Parameters:
videoSink
- video sink that receives video.
-
removeSink
public void removeSink(@NonNull VideoSink videoSink)
Description copied from class:VideoTrack
Remove a video sink to stop receiving video from the video track.- Overrides:
removeSink
in classVideoTrack
- Parameters:
videoSink
- the video sink that should no longer receive video.
-
isEnabled
public 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 from the video capturer are provided.
- Specified by:
isEnabled
in interfaceTrack
- Overrides:
isEnabled
in classVideoTrack
- Returns:
- true if the local video is enabled.
-
getName
@NonNull public java.lang.String getName()
Returns the local video track name. A pseudo random string is returned if no track name was specified.- Specified by:
getName
in interfaceTrack
- Overrides:
getName
in classVideoTrack
-
enable
public void enable(boolean enabled)
Sets the state of the local video track. The results of this operation are signaled to other Participants in the same Room. When a video track is disabled, blank frames are sent in place of video frames from a video capturer.- Parameters:
enabled
- the desired state of the local video track.
-
release
public void release()
Releases native memory owned by video track.
-
onCaptureParametersChanged
public void onCaptureParametersChanged()
- Specified by:
onCaptureParametersChanged
in interfaceVideoCapturerObserver
-
-