Index: webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java |
diff --git a/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java b/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java |
index 2edd56e8413d2b17601a7ab8e4929e608cf6747f..8e3e11d9b93b8bdb0fcec74a77e9110f1ce0dead 100644 |
--- a/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java |
+++ b/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java |
@@ -111,8 +111,9 @@ public class PeerConnectionFactory { |
nativeCreateLocalMediaStream(nativeFactory, label)); |
} |
- // The VideoSource takes ownership of |capturer|, so capturer.release() should not be called |
- // manually after this. |
+ // The VideoSource takes ownership of |capturer|, so capturer.dispose() should not be called |
+ // manually after this. Video capturer is automatically started so there is no need to call |
+ // startCapture after this method. |
public VideoSource createVideoSource( |
VideoCapturer capturer, MediaConstraints constraints) { |
final EglBase.Context eglContext = |
@@ -121,6 +122,17 @@ public class PeerConnectionFactory { |
eglContext, capturer, constraints)); |
} |
+ public VideoSource createVideoSource(VideoCapturer capturer) { |
+ final EglBase.Context eglContext = |
+ localEglbase == null ? null : localEglbase.getEglBaseContext(); |
+ long nativeAndroidVideoTrackSource = nativeCreateVideoSource2(nativeFactory, eglContext); |
+ VideoCapturer.CapturerObserver capturerObserver |
+ = new VideoCapturer.AndroidVideoTrackSourceObserver(nativeAndroidVideoTrackSource); |
+ nativeInitializeVideoCapturer(nativeFactory, capturer, nativeAndroidVideoTrackSource, |
+ capturerObserver); |
+ return new VideoSource(nativeAndroidVideoTrackSource); |
+ } |
+ |
public VideoTrack createVideoTrack(String id, VideoSource source) { |
return new VideoTrack(nativeCreateVideoTrack( |
nativeFactory, id, source.nativeSource)); |
@@ -239,6 +251,13 @@ public class PeerConnectionFactory { |
long nativeFactory, EglBase.Context eglContext, VideoCapturer videoCapturer, |
MediaConstraints constraints); |
+ private static native long nativeCreateVideoSource2( |
+ long nativeFactory, EglBase.Context eglContext); |
+ |
+ private static native void nativeInitializeVideoCapturer( |
+ long native_factory, VideoCapturer j_video_capturer, long native_source, |
+ VideoCapturer.CapturerObserver j_frame_observer); |
+ |
private static native long nativeCreateVideoTrack( |
long nativeFactory, String id, long nativeVideoSource); |