kjellander | af71655 | 2016-02-11 12:21:45 -0800 | [diff] [blame] | 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 | |
Magnus Jedvert | 5e7834e | 2016-02-12 17:05:29 +0100 | [diff] [blame] | 13 | import android.content.Context; |
Magnus Jedvert | 5199c74 | 2016-02-18 13:09:54 +0100 | [diff] [blame] | 14 | import java.util.List; |
Magnus Jedvert | 5e7834e | 2016-02-12 17:05:29 +0100 | [diff] [blame] | 15 | |
| 16 | // Base interface for all VideoCapturers to implement. |
Magnus Jedvert | 5e7834e | 2016-02-12 17:05:29 +0100 | [diff] [blame] | 17 | public interface VideoCapturer { |
magjed | 0dc2316 | 2016-03-14 03:59:38 -0700 | [diff] [blame] | 18 | /** |
Magnus Jedvert | 27dcacd | 2016-07-07 10:00:22 +0200 | [diff] [blame] | 19 | * This function is used to initialize the camera thread, the android application context, and the |
| 20 | * capture observer. It will be called only once and before any startCapture() request. The |
| 21 | * camera thread is guaranteed to be valid until dispose() is called. If the VideoCapturer wants |
| 22 | * to deliver texture frames, it should do this by rendering on the SurfaceTexture in |
Magnus Jedvert | 26b9e12 | 2018-05-02 14:41:22 +0200 | [diff] [blame] | 23 | * {@code surfaceTextureHelper}, register itself as a listener, and forward the frames to |
| 24 | * CapturerObserver.onFrameCaptured(). The caller still has ownership of {@code |
| 25 | * surfaceTextureHelper} and is responsible for making sure surfaceTextureHelper.dispose() is |
| 26 | * called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new |
| 27 | * VideoCapturer once the previous VideoCapturer has been disposed. |
magjed | 0dc2316 | 2016-03-14 03:59:38 -0700 | [diff] [blame] | 28 | */ |
Sami Kalliomäki | 903bd41 | 2018-07-24 10:53:28 +0200 | [diff] [blame] | 29 | void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext, |
| 30 | CapturerObserver capturerObserver); |
Magnus Jedvert | 27dcacd | 2016-07-07 10:00:22 +0200 | [diff] [blame] | 31 | |
| 32 | /** |
Magnus Jedvert | 26b9e12 | 2018-05-02 14:41:22 +0200 | [diff] [blame] | 33 | * Start capturing frames in a format that is as close as possible to {@code width x height} and |
| 34 | * {@code framerate}. |
Magnus Jedvert | 27dcacd | 2016-07-07 10:00:22 +0200 | [diff] [blame] | 35 | */ |
| 36 | void startCapture(int width, int height, int framerate); |
Magnus Jedvert | 5e7834e | 2016-02-12 17:05:29 +0100 | [diff] [blame] | 37 | |
magjed | 0dc2316 | 2016-03-14 03:59:38 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Stop capturing. This function should block until capture is actually stopped. |
| 40 | */ |
Magnus Jedvert | 5e7834e | 2016-02-12 17:05:29 +0100 | [diff] [blame] | 41 | void stopCapture() throws InterruptedException; |
| 42 | |
sakal | 79ede03 | 2016-06-14 05:33:18 -0700 | [diff] [blame] | 43 | void changeCaptureFormat(int width, int height, int framerate); |
| 44 | |
magjed | 0dc2316 | 2016-03-14 03:59:38 -0700 | [diff] [blame] | 45 | /** |
| 46 | * Perform any final cleanup here. No more capturing will be done after this call. |
| 47 | */ |
Magnus Jedvert | 5e7834e | 2016-02-12 17:05:29 +0100 | [diff] [blame] | 48 | void dispose(); |
arsany | b75f254 | 2016-08-31 18:50:52 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * @return true if-and-only-if this is a screen capturer. |
| 52 | */ |
| 53 | boolean isScreencast(); |
kjellander | af71655 | 2016-02-11 12:21:45 -0800 | [diff] [blame] | 54 | } |