Move frame adaptation inside video processor.

Bug: webrtc:10530
Change-Id: Iba6a91bf3e1ec4b2821b554e9e28fd2ead662723
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131947
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27542}
This commit is contained in:
Sami Kalliomäki
2019-04-10 13:44:58 +02:00
committed by Commit Bot
parent bd167cf140
commit c21cf04618
5 changed files with 86 additions and 59 deletions

View File

@ -12,6 +12,7 @@ package org.webrtc;
import android.support.annotation.Nullable;
import org.webrtc.VideoFrame;
import org.webrtc.VideoProcessor;
/**
* This class is meant to be a simple layer that only handles the JNI wrapping of a C++
@ -25,28 +26,6 @@ class NativeAndroidVideoTrackSource {
// Pointer to webrtc::jni::AndroidVideoTrackSource.
private final long nativeAndroidVideoTrackSource;
public static class FrameAdaptationParameters {
public final int cropX;
public final int cropY;
public final int cropWidth;
public final int cropHeight;
public final int scaleWidth;
public final int scaleHeight;
public final long timestampNs;
@CalledByNative("FrameAdaptationParameters")
FrameAdaptationParameters(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth,
int scaleHeight, long timestampNs) {
this.cropX = cropX;
this.cropY = cropY;
this.cropWidth = cropWidth;
this.cropHeight = cropHeight;
this.scaleWidth = scaleWidth;
this.scaleHeight = scaleHeight;
this.timestampNs = timestampNs;
}
}
public NativeAndroidVideoTrackSource(long nativeAndroidVideoTrackSource) {
this.nativeAndroidVideoTrackSource = nativeAndroidVideoTrackSource;
}
@ -66,7 +45,7 @@ class NativeAndroidVideoTrackSource {
* adaptation parameters before calling onFrameCaptured().
*/
@Nullable
public FrameAdaptationParameters adaptFrame(VideoFrame frame) {
public VideoProcessor.FrameAdaptationParameters adaptFrame(VideoFrame frame) {
return nativeAdaptFrame(nativeAndroidVideoTrackSource, frame.getBuffer().getWidth(),
frame.getBuffer().getHeight(), frame.getRotation(), frame.getTimestampNs());
}
@ -93,13 +72,21 @@ class NativeAndroidVideoTrackSource {
targetPortraitAspectRatio.height, maxPortraitPixelCount, maxFps);
}
@CalledByNative
static VideoProcessor.FrameAdaptationParameters createFrameAdaptationParameters(int cropX,
int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight, long timestampNs,
boolean drop) {
return new VideoProcessor.FrameAdaptationParameters(
cropX, cropY, cropWidth, cropHeight, scaleWidth, scaleHeight, timestampNs, drop);
}
private static native void nativeSetState(long nativeAndroidVideoTrackSource, boolean isLive);
private static native void nativeAdaptOutputFormat(long nativeAndroidVideoTrackSource,
int landscapeWidth, int landscapeHeight, @Nullable Integer maxLandscapePixelCount,
int portraitWidth, int portraitHeight, @Nullable Integer maxPortraitPixelCount,
@Nullable Integer maxFps);
@Nullable
private static native FrameAdaptationParameters nativeAdaptFrame(
private static native VideoProcessor.FrameAdaptationParameters nativeAdaptFrame(
long nativeAndroidVideoTrackSource, int width, int height, int rotation, long timestampNs);
private static native void nativeOnFrameCaptured(
long nativeAndroidVideoTrackSource, int rotation, long timestampNs, VideoFrame.Buffer buffer);