ScreenCapturerAndroid

tee3.webrtc

## 类 ScreenCapturerAndroid

- java.lang.Object
- - tee3.webrtc.ScreenCapturerAndroid

- 所有已实现的接口:
    java.lang.Cloneable, SurfaceTextureHelper.OnTextureFrameAvailableListener, VideoCapturer

      public class ScreenCapturerAndroid
      extends java.lang.Object
      implements VideoCapturer, java.lang.Cloneable, SurfaceTextureHelper.OnTextureFrameAvailableListener

  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.

- - ### 嵌套类概要

    嵌套类
    限定符和类型 | 类和说明
    --- | ---
    `static interface` | `ScreenCapturerAndroid.TextureFrameAvailable`

    - ### 从接口继承的嵌套类/接口 tee3.webrtc.VideoCapturer

      `VideoCapturer.CapturerObserver`

  - ### 构造器概要

    构造器
    构造器和说明
    `ScreenCapturerAndroid(android.content.Intent mediaProjectionPermissionResultData, android.media.projection.MediaProjection.Callback mediaProjectionCallback)` Constructs a new Screen Capturer.

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `changeCaptureFormat(int width, int height, int ignoredFramerate)` Changes output video format.
    `static void` | `configureContext(android.content.Context weakContext)`
    `void` | `dispose()` Perform any final cleanup here.
    `long` | `getNumCapturedFrames()`
    `void` | `initialize(SurfaceTextureHelper surfaceTextureHelper, android.content.Context applicationContext, VideoCapturer.CapturerObserver capturerObserver)` This function is used to initialize the camera thread, the android application context, and the capture observer.
    `boolean` | `isScreencast()`
    `void` | `onTextureFrameAvailable(int oesTextureId, float[] transformMatrix, long timestampNs)`
    `void` | `setTextureFrameAvailableListener(ScreenCapturerAndroid.TextureFrameAvailable listener)`
    `void` | `startCapture(int width, int height, int maxFPS)` Start capturing frames in a format that is as close as possible to `width x height` and `framerate`.
    `void` | `stopCapture()` Stop capturing.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### ScreenCapturerAndroid

          public ScreenCapturerAndroid(android.content.Intent mediaProjectionPermissionResultData,
                                       android.media.projection.MediaProjection.Callback mediaProjectionCallback)

      Constructs a new Screen Capturer.
      参数:
        `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.

  - ### 方法详细资料

    - #### initialize

          public void initialize(SurfaceTextureHelper surfaceTextureHelper,
                                 android.content.Context applicationContext,
                                 VideoCapturer.CapturerObserver capturerObserver)

      从接口复制的说明: `VideoCapturer`
      This 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 in `surfaceTextureHelper`, register itself as a listener, and forward the frames to CapturerObserver.onFrameCaptured(). The caller still has ownership of `surfaceTextureHelper` and 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.
      指定者:
        `initialize` 在接口中 `VideoCapturer`

    - #### startCapture

          public void startCapture(int width,
                                   int height,
                                   int maxFPS)

      从接口复制的说明: `VideoCapturer`
      Start capturing frames in a format that is as close as possible to `width x height` and `framerate`.
      指定者:
        `startCapture` 在接口中 `VideoCapturer`

    - #### stopCapture

          public void stopCapture()

      从接口复制的说明: `VideoCapturer`
      Stop capturing. This function should block until capture is actually stopped.
      指定者:
        `stopCapture` 在接口中 `VideoCapturer`

    - #### dispose

          public void dispose()

      从接口复制的说明: `VideoCapturer`
      Perform any final cleanup here. No more capturing will be done after this call.
      指定者:
        `dispose` 在接口中 `VideoCapturer`

    - #### changeCaptureFormat

          public 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.
      指定者:
        `changeCaptureFormat` 在接口中 `VideoCapturer`
      参数:
        `width` - new output video width
        `height` - new output video height
        `ignoredFramerate` - ignored

    - #### onTextureFrameAvailable

          public void onTextureFrameAvailable(int oesTextureId,
                                              float[] transformMatrix,
                                              long timestampNs)

      指定者:
        `onTextureFrameAvailable` 在接口中 `SurfaceTextureHelper.OnTextureFrameAvailableListener`

    - #### configureContext

          public static void configureContext(android.content.Context weakContext)

    - #### isScreencast

          public boolean isScreencast()

      指定者:
        `isScreencast` 在接口中 `VideoCapturer`
      返回:
        true if-and-only-if this is a screen capturer.

    - #### getNumCapturedFrames

          public long getNumCapturedFrames()

    - #### setTextureFrameAvailableListener

          public void setTextureFrameAvailableListener(ScreenCapturerAndroid.TextureFrameAvailable listener)