Update examples to use the new VideoCapturer interface.

Bug: webrtc:9496
Change-Id: Ifbf06d644e3758d537757cdbbc7f61bdc0fe270d
Reviewed-on: https://webrtc-review.googlesource.com/87307
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23899}
This commit is contained in:
Sami Kalliomäki 2018-07-06 11:25:58 +02:00 committed by Commit Bot
parent 9bb8f80c40
commit a7a10a8b31
2 changed files with 14 additions and 5 deletions

View file

@ -63,17 +63,18 @@ import org.webrtc.SoftwareVideoDecoderFactory;
import org.webrtc.SoftwareVideoEncoderFactory;
import org.webrtc.StatsObserver;
import org.webrtc.StatsReport;
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.VideoCapturer;
import org.webrtc.VideoDecoderFactory;
import org.webrtc.VideoEncoderFactory;
import org.webrtc.VideoSink;
import org.webrtc.VideoSource;
import org.webrtc.VideoTrack;
import org.webrtc.audio.AudioDeviceModule;
import org.webrtc.audio.JavaAudioDeviceModule;
import org.webrtc.audio.JavaAudioDeviceModule.AudioRecordErrorCallback;
import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackErrorCallback;
import org.webrtc.audio.LegacyAudioDeviceModule;
import org.webrtc.audio.AudioDeviceModule;
import org.webrtc.voiceengine.WebRtcAudioManager;
import org.webrtc.voiceengine.WebRtcAudioRecord;
import org.webrtc.voiceengine.WebRtcAudioRecord.AudioRecordStartErrorCode;
@ -137,8 +138,8 @@ public class PeerConnectionClient {
private PeerConnection peerConnection;
@Nullable
private AudioSource audioSource;
@Nullable
private VideoSource videoSource;
@Nullable private SurfaceTextureHelper surfaceTextureHelper;
@Nullable private VideoSource videoSource;
private boolean preferIsac;
private boolean videoCapturerStopped;
private boolean isError;
@ -770,6 +771,10 @@ public class PeerConnectionClient {
videoSource.dispose();
videoSource = null;
}
if (surfaceTextureHelper != null) {
surfaceTextureHelper.dispose();
surfaceTextureHelper = null;
}
if (saveRecordedAudioToFile != null) {
Log.d(TAG, "Closing audio file for recorded input audio.");
saveRecordedAudioToFile.stop();
@ -985,7 +990,10 @@ public class PeerConnectionClient {
@Nullable
private VideoTrack createVideoTrack(VideoCapturer capturer) {
videoSource = factory.createVideoSource(capturer);
surfaceTextureHelper =
SurfaceTextureHelper.create("CaptureThread", rootEglBase.getEglBaseContext());
videoSource = factory.createVideoSource(capturer.isScreencast());
capturer.initialize(surfaceTextureHelper, appContext, videoSource.getCapturerObserver());
capturer.startCapture(videoWidth, videoHeight, videoFps);
localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource);

View file

@ -13,6 +13,7 @@ package org.webrtc.examples.androidnativeapi;
import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import org.webrtc.CapturerObserver;
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.VideoCapturer;
import org.webrtc.VideoSink;
@ -66,6 +67,6 @@ public class CallClient {
long nativeAndroidCallClient, VideoSink localSink, VideoSink remoteSink);
private static native void nativeHangup(long nativeAndroidCallClient);
private static native void nativeDelete(long nativeAndroidCallClient);
private static native VideoCapturer.CapturerObserver nativeGetJavaVideoCapturerObserver(
private static native CapturerObserver nativeGetJavaVideoCapturerObserver(
long nativeAndroidCallClient);
}