OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 package org.webrtc; | 11 package org.webrtc; |
12 | 12 |
13 import android.content.Context; | 13 import android.content.Context; |
14 | 14 |
15 import java.util.List; | 15 import java.util.List; |
16 | 16 |
17 // Base interface for all VideoCapturers to implement. | 17 // Base interface for all VideoCapturers to implement. |
| 18 // All events will be fired on the camera thread. |
18 public interface VideoCapturer { | 19 public interface VideoCapturer { |
19 // Interface used for providing callbacks to an observer. | 20 // Interface used for providing callbacks to an observer. |
20 public interface CapturerObserver { | 21 public interface CapturerObserver { |
21 // Notify if the camera have been started successfully or not. | 22 // Notify if the camera have been started successfully or not. |
22 // Called on a Java thread owned by VideoCapturer. | |
23 void onCapturerStarted(boolean success); | 23 void onCapturerStarted(boolean success); |
| 24 |
24 void onCapturerStopped(); | 25 void onCapturerStopped(); |
25 | 26 |
26 // Delivers a captured frame. Called on a Java thread owned by VideoCapturer
. | 27 // Delivers a captured frame. |
27 void onByteBufferFrameCaptured(byte[] data, int width, int height, int rotat
ion, | 28 void onByteBufferFrameCaptured(byte[] data, int width, int height, int rotat
ion, |
28 long timeStamp); | 29 long timeStamp); |
29 | 30 |
30 // Delivers a captured frame in a texture with id |oesTextureId|. Called on
a Java thread | 31 // Delivers a captured frame in a texture with id |oesTextureId|. |
31 // owned by VideoCapturer. | |
32 void onTextureFrameCaptured( | 32 void onTextureFrameCaptured( |
33 int width, int height, int oesTextureId, float[] transformMatrix, int ro
tation, | 33 int width, int height, int oesTextureId, float[] transformMatrix, int ro
tation, |
34 long timestamp); | 34 long timestamp); |
35 | 35 |
36 // Requests an output format from the video capturer. Captured frames | 36 // Requests an output format from the video capturer. Captured frames |
37 // by the camera will be scaled/or dropped by the video capturer. | 37 // by the camera will be scaled/or dropped by the video capturer. |
38 // Called on a Java thread owned by VideoCapturer. | |
39 void onOutputFormatRequest(int width, int height, int framerate); | 38 void onOutputFormatRequest(int width, int height, int framerate); |
40 } | 39 } |
41 | 40 |
42 // An implementation of CapturerObserver that forwards all calls from | 41 // An implementation of CapturerObserver that forwards all calls from |
43 // Java to the C layer. | 42 // Java to the C layer. |
44 static class NativeObserver implements CapturerObserver { | 43 static class NativeObserver implements CapturerObserver { |
45 private final long nativeCapturer; | 44 private final long nativeCapturer; |
46 | 45 |
47 public NativeObserver(long nativeCapturer) { | 46 public NativeObserver(long nativeCapturer) { |
48 this.nativeCapturer = nativeCapturer; | 47 this.nativeCapturer = nativeCapturer; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 void initialize(SurfaceTextureHelper surfaceTextureHelper, Context application
Context, | 152 void initialize(SurfaceTextureHelper surfaceTextureHelper, Context application
Context, |
154 CapturerObserver capturerObserver); | 153 CapturerObserver capturerObserver); |
155 | 154 |
156 /** | 155 /** |
157 * Start capturing frames in a format that is as close as possible to |width|
x |height| and | 156 * Start capturing frames in a format that is as close as possible to |width|
x |height| and |
158 * |framerate|. | 157 * |framerate|. |
159 */ | 158 */ |
160 void startCapture(int width, int height, int framerate); | 159 void startCapture(int width, int height, int framerate); |
161 | 160 |
162 /** | 161 /** |
163 * Stop capturing. This function should block until capture is actually stoppe
d. | 162 * Stop capturing. No more frames/events will be delivered to the observer whe
n this method |
| 163 * returns. |
164 */ | 164 */ |
165 void stopCapture() throws InterruptedException; | 165 void stopCapture(); |
166 | 166 |
167 void onOutputFormatRequest(int width, int height, int framerate); | 167 void onOutputFormatRequest(int width, int height, int framerate); |
168 | 168 |
169 void changeCaptureFormat(int width, int height, int framerate); | 169 void changeCaptureFormat(int width, int height, int framerate); |
170 | 170 |
171 /** | 171 /** |
172 * Perform any final cleanup here. No more capturing will be done after this c
all. | 172 * Perform any final cleanup here. No more capturing will be done after this c
all. |
173 */ | 173 */ |
174 void dispose(); | 174 void dispose(); |
175 } | 175 } |
OLD | NEW |