Chromium Code Reviews| 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 public interface VideoCapturer { | 18 public interface VideoCapturer { |
| 19 // Interface used for providing callbacks to an observer. | 19 // Interface used for providing callbacks to an observer. |
| 20 public interface CapturerObserver { | 20 public interface CapturerObserver { |
| 21 // Notify if the camera have been started successfully or not. | 21 // Notify if the camera have been started successfully or not. |
| 22 // Called on a Java thread owned by VideoCapturer. | 22 // Called on a Java thread owned by VideoCapturer. |
| 23 void onCapturerStarted(boolean success); | 23 void onCapturerStarted(boolean success); |
| 24 void onCapturerStopped(); | 24 void onCapturerStopped(); |
| 25 | 25 |
| 26 // Delivers a captured frame. Called on a Java thread owned by VideoCapturer . | 26 // Delivers a captured frame. Called on a Java thread owned by VideoCapturer . |
| 27 void onByteBufferFrameCaptured(byte[] data, int width, int height, int rotat ion, | 27 void onByteBufferFrameCaptured( |
| 28 long timeStamp); | 28 byte[] data, int width, int height, int rotation, long timeStamp); |
| 29 | 29 |
| 30 // Delivers a captured frame in a texture with id |oesTextureId|. Called on a Java thread | 30 // Delivers a captured frame in a texture with id |oesTextureId|. Called on a Java thread |
| 31 // owned by VideoCapturer. | 31 // owned by VideoCapturer. |
| 32 void onTextureFrameCaptured( | 32 void onTextureFrameCaptured(int width, int height, int oesTextureId, float[] transformMatrix, |
| 33 int width, int height, int oesTextureId, float[] transformMatrix, int ro tation, | 33 int rotation, long timestamp); |
| 34 long timestamp); | |
| 35 | 34 |
| 36 // Requests an output format from the video capturer. Captured frames | 35 // Requests an output format from the video capturer. Captured frames |
| 37 // by the camera will be scaled/or dropped by the video capturer. | 36 // by the camera will be scaled/or dropped by the video capturer. |
| 38 // Called on a Java thread owned by VideoCapturer. | 37 // 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 AndroidVideoTrackSourceObserver implements CapturerObserver { | 43 static class AndroidVideoTrackSourceObserver implements CapturerObserver { |
| 45 // Pointer to VideoTrackSourceProxy proxying AndroidVideoTrackSource. | 44 // Pointer to VideoTrackSourceProxy proxying AndroidVideoTrackSource. |
| 46 private final long nativeSource; | 45 private final long nativeSource; |
| 47 | 46 |
| 48 public AndroidVideoTrackSourceObserver(long nativeSource) { | 47 public AndroidVideoTrackSourceObserver(long nativeSource) { |
| 49 this.nativeSource = nativeSource; | 48 this.nativeSource = nativeSource; |
| 50 } | 49 } |
| 51 | 50 |
| 52 @Override | 51 @Override |
| 53 public void onCapturerStarted(boolean success) { | 52 public void onCapturerStarted(boolean success) { |
| 54 nativeCapturerStarted(nativeSource, success); | 53 nativeCapturerStarted(nativeSource, success); |
| 55 } | 54 } |
| 56 | 55 |
| 57 @Override | 56 @Override |
| 58 public void onCapturerStopped() { | 57 public void onCapturerStopped() { |
| 59 nativeCapturerStopped(nativeSource); | 58 nativeCapturerStopped(nativeSource); |
| 60 } | 59 } |
| 61 | 60 |
| 62 @Override | 61 @Override |
| 63 public void onByteBufferFrameCaptured(byte[] data, int width, int height, | 62 public void onByteBufferFrameCaptured( |
| 64 int rotation, long timeStamp) { | 63 byte[] data, int width, int height, int rotation, long timeStamp) { |
| 65 nativeOnByteBufferFrameCaptured(nativeSource, data, data.length, width, he ight, rotation, | 64 nativeOnByteBufferFrameCaptured( |
| 66 timeStamp); | 65 nativeSource, data, data.length, width, height, rotation, timeStamp); |
| 67 } | 66 } |
| 68 | 67 |
| 69 @Override | 68 @Override |
| 70 public void onTextureFrameCaptured( | 69 public void onTextureFrameCaptured(int width, int height, int oesTextureId, |
| 71 int width, int height, int oesTextureId, float[] transformMatrix, int ro tation, | 70 float[] transformMatrix, int rotation, long timestamp) { |
| 72 long timestamp) { | 71 nativeOnTextureFrameCaptured( |
| 73 nativeOnTextureFrameCaptured(nativeSource, width, height, oesTextureId, tr ansformMatrix, | 72 nativeSource, width, height, oesTextureId, transformMatrix, rotation, timestamp); |
| 74 rotation, timestamp); | |
| 75 } | 73 } |
| 76 | 74 |
| 77 @Override | 75 @Override |
| 78 public void onOutputFormatRequest(int width, int height, int framerate) { | 76 public void onOutputFormatRequest(int width, int height, int framerate) { |
| 79 nativeOnOutputFormatRequest(nativeSource, width, height, framerate); | 77 nativeOnOutputFormatRequest(nativeSource, width, height, framerate); |
| 80 } | 78 } |
| 81 | 79 |
| 82 private native void nativeCapturerStarted(long nativeSource, | 80 private native void nativeCapturerStarted(long nativeSource, boolean success ); |
| 83 boolean success); | |
| 84 private native void nativeCapturerStopped(long nativeSource); | 81 private native void nativeCapturerStopped(long nativeSource); |
| 85 private native void nativeOnByteBufferFrameCaptured(long nativeSource, | 82 private native void nativeOnByteBufferFrameCaptured(long nativeSource, byte[ ] data, int length, |
| 86 byte[] data, int length, int width, int height, int rotation, long timeS tamp); | 83 int width, int height, int rotation, long timeStamp); |
| 87 private native void nativeOnTextureFrameCaptured(long nativeSource, int widt h, int height, | 84 private native void nativeOnTextureFrameCaptured(long nativeSource, int widt h, int height, |
| 88 int oesTextureId, float[] transformMatrix, int rotation, long timestamp) ; | 85 int oesTextureId, float[] transformMatrix, int rotation, long timestamp) ; |
| 89 private native void nativeOnOutputFormatRequest(long nativeSource, | 86 private native void nativeOnOutputFormatRequest( |
| 90 int width, int height, int framerate); | 87 long nativeSource, int width, int height, int framerate); |
| 91 } | 88 } |
| 92 | 89 |
| 93 /** | 90 /** |
| 94 * This function is used to initialize the camera thread, the android applicat ion context, and the | 91 * This function is used to initialize the camera thread, the android applicat ion context, and the |
| 95 * capture observer. It will be called only once and before any startCapture() request. The | 92 * capture observer. It will be called only once and before any startCapture() request. The |
| 96 * camera thread is guaranteed to be valid until dispose() is called. If the V ideoCapturer wants | 93 * camera thread is guaranteed to be valid until dispose() is called. If the V ideoCapturer wants |
| 97 * to deliver texture frames, it should do this by rendering on the SurfaceTex ture in | 94 * to deliver texture frames, it should do this by rendering on the SurfaceTex ture in |
| 98 * |surfaceTextureHelper|, register itself as a listener, and forward the text ure frames to | 95 * |surfaceTextureHelper|, register itself as a listener, and forward the text ure frames to |
| 99 * CapturerObserver.onTextureFrameCaptured(). | 96 * CapturerObserver.onTextureFrameCaptured(). |
| 100 */ | 97 */ |
| 101 void initialize(SurfaceTextureHelper surfaceTextureHelper, Context application Context, | 98 void initialize(SurfaceTextureHelper surfaceTextureHelper, Context application Context, |
| 102 CapturerObserver capturerObserver); | 99 CapturerObserver capturerObserver); |
| 103 | 100 |
| 104 /** | 101 /** |
| 105 * Start capturing frames in a format that is as close as possible to |width| x |height| and | 102 * Start capturing frames in a format that is as close as possible to |width| x |height| and |
| 106 * |framerate|. | 103 * |framerate|. |
| 107 */ | 104 */ |
| 108 void startCapture(int width, int height, int framerate); | 105 void startCapture(int width, int height, int framerate); |
| 109 | 106 |
| 110 /** | 107 /** |
| 111 * Stop capturing. This function should block until capture is actually stoppe d. | 108 * Stop capturing. This function should block until capture is actually stoppe d. |
| 112 */ | 109 */ |
| 113 void stopCapture() throws InterruptedException; | 110 void stopCapture() throws InterruptedException; |
| 114 | 111 |
| 115 /** | 112 /** |
| 116 * Use VideoSource.adaptOutputFormat() instead. | 113 * Use VideoSource.adaptOutputFormat() instead. |
| 117 */ | 114 */ |
| 118 @Deprecated | 115 @Deprecated void onOutputFormatRequest(int width, int height, int framerate); |
|
magjed_webrtc
2016/09/28 13:45:04
This looks strange. I'm about to delete it anyway
| |
| 119 void onOutputFormatRequest(int width, int height, int framerate); | |
| 120 | 116 |
| 121 void changeCaptureFormat(int width, int height, int framerate); | 117 void changeCaptureFormat(int width, int height, int framerate); |
| 122 | 118 |
| 123 /** | 119 /** |
| 124 * Perform any final cleanup here. No more capturing will be done after this c all. | 120 * Perform any final cleanup here. No more capturing will be done after this c all. |
| 125 */ | 121 */ |
| 126 void dispose(); | 122 void dispose(); |
| 127 | 123 |
| 128 /** | 124 /** |
| 129 * @return true if-and-only-if this is a screen capturer. | 125 * @return true if-and-only-if this is a screen capturer. |
| 130 */ | 126 */ |
| 131 boolean isScreencast(); | 127 boolean isScreencast(); |
| 132 } | 128 } |
| OLD | NEW |