Move VideoCapturer to video_api and cleanup.

This should only be landed after clients have been given time to
upgrade to the new interface.

Bug: webrtc:9496, webrtc:9181
Change-Id: Ideb37637d9f0b9a3a9748811879c263c64f81d11
Reviewed-on: https://webrtc-review.googlesource.com/87308
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Paulina Hensman <phensman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24080}
This commit is contained in:
Sami Kalliomäki
2018-07-24 10:53:28 +02:00
committed by Commit Bot
parent 213618e37e
commit 903bd4145f
7 changed files with 25 additions and 88 deletions

View File

@ -15,15 +15,13 @@ package org.webrtc;
* {@link VideoSource#getCapturerObserver}.
*
* All callbacks must be executed on a single thread.
*
* @note This will replace the deprecated VideoCapturer.CapturerObserver interface.
*/
public interface CapturerObserver extends VideoCapturer.CapturerObserver {
public interface CapturerObserver {
/** Notify if the capturer have been started successfully or not. */
@Override void onCapturerStarted(boolean success);
void onCapturerStarted(boolean success);
/** Notify that the capturer has been stopped. */
@Override void onCapturerStopped();
void onCapturerStopped();
/** Delivers a captured frame. */
@Override void onFrameCaptured(VideoFrame frame);
void onFrameCaptured(VideoFrame frame);
}

View File

@ -399,17 +399,6 @@ public class PeerConnectionFactory {
return new VideoSource(nativeCreateVideoSource(nativeFactory, isScreencast));
}
@Deprecated
public VideoSource createVideoSource(VideoCapturer capturer) {
final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create(
VIDEO_CAPTURER_THREAD_NAME, MediaCodecVideoEncoder.getEglContext());
final VideoSource videoSource = new VideoSource(
nativeCreateVideoSource(nativeFactory, capturer.isScreencast()), surfaceTextureHelper);
capturer.initialize(surfaceTextureHelper, ContextUtils.getApplicationContext(),
videoSource.getCapturerObserver());
return videoSource;
}
public VideoTrack createVideoTrack(String id, VideoSource source) {
return new VideoTrack(nativeCreateVideoTrack(nativeFactory, id, source.nativeSource));
}

View File

@ -15,25 +15,6 @@ import java.util.List;
// Base interface for all VideoCapturers to implement.
public interface VideoCapturer {
// Interface used for providing callbacks to an observer.
@Deprecated
public interface CapturerObserver {
// Notify if the camera have been started successfully or not.
// Called on a Java thread owned by VideoCapturer.
void onCapturerStarted(boolean success);
void onCapturerStopped();
// Delivers a captured frame. Called on a Java thread owned by VideoCapturer.
void onFrameCaptured(VideoFrame frame);
}
/** Deprecated, implementations should be update to implement the version below. */
@Deprecated
default void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
CapturerObserver capturerObserver) {
throw new UnsupportedOperationException("Not implemented.");
}
/**
* This function is used to initialize the camera thread, the android application context, and the
* capture observer. It will be called only once and before any startCapture() request. The
@ -45,12 +26,8 @@ public interface VideoCapturer {
* called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new
* VideoCapturer once the previous VideoCapturer has been disposed.
*/
// Our version of clang format doesn't understand default and messes up.
// clang-format off
default void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
org.webrtc.CapturerObserver capturerObserver) {
initialize(surfaceTextureHelper, applicationContext, (CapturerObserver) capturerObserver);
}
void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
CapturerObserver capturerObserver);
/**
* Start capturing frames in a format that is as close as possible to {@code width x height} and

View File

@ -23,13 +23,6 @@ public class VideoSource extends MediaSource {
this.capturerObserver = new NativeCapturerObserver(nativeGetInternalSource(nativeSource));
}
// TODO(bugs.webrtc.org/9181): Remove.
VideoSource(long nativeSource, SurfaceTextureHelper surfaceTextureHelper) {
super(nativeSource);
this.capturerObserver =
new NativeCapturerObserver(nativeGetInternalSource(nativeSource), surfaceTextureHelper);
}
/**
* Calling this function will cause frames to be scaled down to the requested resolution. Also,
* frames will be cropped to match the requested aspect ratio, and frames will be dropped to match
@ -44,12 +37,6 @@ public class VideoSource extends MediaSource {
return capturerObserver;
}
@Override
public void dispose() {
capturerObserver.dispose();
super.dispose();
}
// Returns source->internal() from webrtc::VideoTrackSourceProxy.
private static native long nativeGetInternalSource(long source);
private static native void nativeAdaptOutputFormat(long source, int width, int height, int fps);