1 /*
2  *  Copyright 2013 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 package org.webrtc;
12 
13 import android.content.Context;
14 
15 // Base interface for all VideoCapturers to implement.
16 public interface VideoCapturer {
17   /**
18    * This function is used to initialize the camera thread, the android application context, and the
19    * capture observer. It will be called only once and before any startCapture() request. The
20    * camera thread is guaranteed to be valid until dispose() is called. If the VideoCapturer wants
21    * to deliver texture frames, it should do this by rendering on the SurfaceTexture in
22    * {@code surfaceTextureHelper}, register itself as a listener, and forward the frames to
23    * CapturerObserver.onFrameCaptured(). The caller still has ownership of {@code
24    * surfaceTextureHelper} and is responsible for making sure surfaceTextureHelper.dispose() is
25    * called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new
26    * VideoCapturer once the previous VideoCapturer has been disposed.
27    */
initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext, CapturerObserver capturerObserver)28   void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
29       CapturerObserver capturerObserver);
30 
31   /**
32    * Start capturing frames in a format that is as close as possible to {@code width x height} and
33    * {@code framerate}.
34    */
startCapture(int width, int height, int framerate)35   void startCapture(int width, int height, int framerate);
36 
37   /**
38    * Stop capturing. This function should block until capture is actually stopped.
39    */
stopCapture()40   void stopCapture() throws InterruptedException;
41 
changeCaptureFormat(int width, int height, int framerate)42   void changeCaptureFormat(int width, int height, int framerate);
43 
44   /**
45    * Perform any final cleanup here. No more capturing will be done after this call.
46    */
dispose()47   void dispose();
48 
49   /**
50    * @return true if-and-only-if this is a screen capturer.
51    */
isScreencast()52   boolean isScreencast();
53 }
54