Class ScreenCapturerAndroidCustom

  • All Implemented Interfaces:
    hms.webrtc.VideoCapturer , hms.webrtc.VideoSink

    
    public class ScreenCapturerAndroidCustom
     implements VideoCapturer, VideoSink
                        

    An implementation of VideoCapturer to capture the screen content as a video stream. Capturing is done by MediaProjection on a SurfaceTexture. We interact with this SurfaceTexture using a SurfaceTextureHelper. The SurfaceTextureHelper is created by the native code and passed to this capturer in VideoCapturer.initialize(). On receiving a new frame, this capturer passes it as a texture to the native code via CapturerObserver.onFrameCaptured(). This takes place on the HandlerThread of the given SurfaceTextureHelper. When done with each frame, the native code returns the buffer to the SurfaceTextureHelper to be used for new frames. At any time, at most one frame is being processed.

    • 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

      • initialize

         synchronized void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext, CapturerObserver capturerObserver)
      • startCapture

         synchronized void startCapture(int width, int height, int ignoredFramerate)
      • 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 width
        height - new output video height
        ignoredFramerate - ignored
      • onFrame

         void onFrame(VideoFrame frame)