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 a VideoCapturer or VideoCapturer.

When a local video track is created, the SDK will call VideoCapturer.initialize(SurfaceTextureHelper, Context, CapturerObserver) and VideoCapturer.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:

See Also:
  • Method Details

    • 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 then VideoCapturer.startCapture(int, int, int) will be called with the result of VideoCapturer.getCaptureFormat(). This behavior allows VideoCapturer implementations to provide a better default capture format. For example, the ScreenCapturer 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 String name)
      Creates a local video track.

      If the capturer is an instance of VideoCapturer then VideoCapturer.startCapture(int, int, int) will be called with the result of VideoCapturer.getCaptureFormat(). This behavior allows VideoCapturer implementations to provide a better default capture format. For example, the ScreenCapturer 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 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 the VideoCapturer associated with this video track.
    • getVideoFormat

      @NonNull public VideoFormat getVideoFormat()
      Returns the video track's VideoFormat.
    • getVideoSource

      @NonNull public VideoSource getVideoSource()
      Returns the VideoSource 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 class VideoTrack
      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 class VideoTrack
      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 interface Track
      Overrides:
      isEnabled in class VideoTrack
      Returns:
      true if the local video is enabled.
    • getName

      @NonNull public String getName()
      Returns the local video track name. A pseudo random string is returned if no track name was specified.
      Specified by:
      getName in interface Track
      Overrides:
      getName in class VideoTrack
    • 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 interface VideoCapturerObserver