Class ScreenCapturerAndroidCustom
-
- All Implemented Interfaces:
-
hms.webrtc.VideoCapturer,hms.webrtc.VideoSink
public class ScreenCapturerAndroidCustom implements VideoCapturer, VideoSinkAn implementation of VideoCapturer to capture the screen content as a video stream. Capturing is done by
MediaProjectionon aSurfaceTexture. We interact with thisSurfaceTextureusing aSurfaceTextureHelper. TheSurfaceTextureHelperis created by the native code and passed to this capturer inVideoCapturer.initialize(). On receiving a new frame, this capturer passes it as a texture to the native code viaCapturerObserver.onFrameCaptured(). This takes place on the HandlerThread of the givenSurfaceTextureHelper. When done with each frame, the native code returns the buffer to theSurfaceTextureHelperto be used for new frames. At any time, at most one frame is being processed.
-
-
Field Summary
Fields Modifier and Type Field Description public longnumCapturedFramespublic MediaProjectionmediaProjection
-
Constructor Summary
Constructors Constructor Description ScreenCapturerAndroidCustom(Intent mediaProjectionPermissionResultData, MediaProjection.Callback mediaProjectionCallback)Constructs a new Screen Capturer.
-
Method Summary
Modifier and Type Method Description longgetNumCapturedFrames()MediaProjectiongetMediaProjection()synchronized voidinitialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext, CapturerObserver capturerObserver)synchronized voidstartCapture(int width, int height, int ignoredFramerate)synchronized voidstopCapture()synchronized voiddispose()synchronized voidchangeCaptureFormat(int width, int height, int ignoredFramerate)Changes output video format. voidonFrame(VideoFrame frame)booleanisScreencast()-
-
Constructor Detail
-
ScreenCapturerAndroidCustom
ScreenCapturerAndroidCustom(Intent mediaProjectionPermissionResultData, MediaProjection.Callback mediaProjectionCallback)
Constructs a new Screen Capturer.- Parameters:
mediaProjectionPermissionResultData- the result data of MediaProjection permission activity; the calling app must validate that result code is Activity.RESULT_OK before calling this method.mediaProjectionCallback- MediaProjection callback to implement application specific logic in events such as when the user revokes a previously granted capture permission.
-
-
Method Detail
-
getNumCapturedFrames
long getNumCapturedFrames()
-
getMediaProjection
@Nullable() MediaProjection getMediaProjection()
-
initialize
synchronized void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext, CapturerObserver capturerObserver)
-
startCapture
synchronized void startCapture(int width, int height, int ignoredFramerate)
-
stopCapture
synchronized void stopCapture()
-
dispose
synchronized void dispose()
-
changeCaptureFormat
synchronized void changeCaptureFormat(int width, int height, int ignoredFramerate)
Changes output video format. This method can be used to scale the output video, or to change orientation when the captured screen is rotated for example.
- Parameters:
width- new output video widthheight- new output video heightignoredFramerate- ignored
-
onFrame
void onFrame(VideoFrame frame)
-
isScreencast
boolean isScreencast()
-
-
-
-