Package com.twilio.video
Class ScreenCapturer
- java.lang.Object
-
- com.twilio.video.ScreenCapturer
-
- All Implemented Interfaces:
VideoCapturer,VideoCapturer
public class ScreenCapturer extends java.lang.Object implements VideoCapturer
The ScreenCapturer class is used to provide video frames for aLocalVideoTrackfrom a device's screen. The frames are provided via theMediaProjectionapi. This capturer is only compatible withBuild.VERSION_CODES.LOLLIPOPor higher.This class represents an implementation of a
VideoCapturerinterface. Although public, these methods are not meant to be invoked directly.Note: This capturer can be reused, but cannot be shared across multiple
LocalVideoTracks simultaneously.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceScreenCapturer.ListenerInterface that provides events and errors related toScreenCapturer.
-
Constructor Summary
Constructors Constructor Description ScreenCapturer(android.content.Context context, int screenCaptureIntentResult, android.content.Intent screenCaptureIntentData, ScreenCapturer.Listener screenCapturerListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()This method provides an optional step to perform a final cleanup.VideoFormatgetCaptureFormat()voidinitialize(SurfaceTextureHelper surfaceTextureHelper, android.content.Context context, CapturerObserver capturerObserver)This function is used to initialize the camera thread, the android application context, and the capture observer.booleanisScreencast()Indicates that the screen capturer is a screencast.voidstartCapture(int width, int height, int framerate)Start capturing frames in a format that is as close as possible towidth x heightandframerate.voidstopCapture()Stops all frames being captured.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.twilio.video.VideoCapturer
changeCaptureFormat
-
-
-
-
Constructor Detail
-
ScreenCapturer
public ScreenCapturer(@NonNull android.content.Context context, int screenCaptureIntentResult, @NonNull android.content.Intent screenCaptureIntentData, @Nullable ScreenCapturer.Listener screenCapturerListener)
-
-
Method Detail
-
getCaptureFormat
public VideoFormat getCaptureFormat()
- Specified by:
getCaptureFormatin interfaceVideoCapturer
-
isScreencast
public boolean isScreencast()
Indicates that the screen capturer is a screencast.- Specified by:
isScreencastin interfaceVideoCapturer- Returns:
- true if-and-only-if this is a screen capturer.
-
initialize
public void initialize(@NonNull SurfaceTextureHelper surfaceTextureHelper, @NonNull android.content.Context context, @NonNull CapturerObserver capturerObserver)Description copied from interface:VideoCapturerThis function is used to initialize the camera thread, the android application context, and the capture observer. It will be called only once and before any startCapture() request. The camera thread is guaranteed to be valid until dispose() is called. If the VideoCapturer wants to deliver texture frames, it should do this by rendering on the SurfaceTexture insurfaceTextureHelper, register itself as a listener, and forward the frames to CapturerObserver.onFrameCaptured(). The caller still has ownership ofsurfaceTextureHelperand is responsible for making sure surfaceTextureHelper.dispose() is called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new VideoCapturer once the previous VideoCapturer has been disposed.- Specified by:
initializein interfaceVideoCapturer
-
startCapture
public void startCapture(int width, int height, int framerate)Description copied from interface:VideoCapturerStart capturing frames in a format that is as close as possible towidth x heightandframerate.- Specified by:
startCapturein interfaceVideoCapturer
-
stopCapture
public void stopCapture()
Stops all frames being captured.MediaProjectionshould be available for use upon completion.Note: This method is not meant to be invoked directly.
- Specified by:
stopCapturein interfaceVideoCapturer
-
dispose
public void dispose()
Description copied from interface:VideoCapturerThis method provides an optional step to perform a final cleanup.- Specified by:
disposein interfaceVideoCapturer- Specified by:
disposein interfaceVideoCapturer
-
-