Add back AndroidVideoBuffer::CropAndScale

Now compatible with the recently added interface method
VideoFramebuffer::CropAndScale.

Bug: webrtc:11976
Change-Id: I461cf2de1d73ca953fda0ecad84d216b8b7ac879
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/187493
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32391}
This commit is contained in:
Niels Möller
2020-10-12 14:47:46 +02:00
committed by Commit Bot
parent 113326bbe9
commit 299c839919
3 changed files with 23 additions and 0 deletions

View File

@ -54,6 +54,7 @@ public class VideoFrame implements RefCounted {
* Crops a region defined by |cropx|, |cropY|, |cropWidth| and |cropHeight|. Scales it to size * Crops a region defined by |cropx|, |cropY|, |cropWidth| and |cropHeight|. Scales it to size
* |scaleWidth| x |scaleHeight|. * |scaleWidth| x |scaleHeight|.
*/ */
@CalledByNative("Buffer")
Buffer cropAndScale( Buffer cropAndScale(
int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight); int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight);
} }

View File

@ -152,6 +152,19 @@ const ScopedJavaGlobalRef<jobject>& AndroidVideoBuffer::video_frame_buffer()
return j_video_frame_buffer_; return j_video_frame_buffer_;
} }
rtc::scoped_refptr<VideoFrameBuffer> AndroidVideoBuffer::CropAndScale(
int crop_x,
int crop_y,
int crop_width,
int crop_height,
int scale_width,
int scale_height) {
JNIEnv* jni = AttachCurrentThreadIfNeeded();
return Adopt(jni, Java_Buffer_cropAndScale(jni, j_video_frame_buffer_, crop_x,
crop_y, crop_width, crop_height,
scale_width, scale_height));
}
VideoFrameBuffer::Type AndroidVideoBuffer::type() const { VideoFrameBuffer::Type AndroidVideoBuffer::type() const {
return Type::kNative; return Type::kNative;
} }

View File

@ -40,6 +40,15 @@ class AndroidVideoBuffer : public VideoFrameBuffer {
const ScopedJavaGlobalRef<jobject>& video_frame_buffer() const; const ScopedJavaGlobalRef<jobject>& video_frame_buffer() const;
// Crops a region defined by |crop_x|, |crop_y|, |crop_width| and
// |crop_height|. Scales it to size |scale_width| x |scale_height|.
rtc::scoped_refptr<VideoFrameBuffer> CropAndScale(int crop_x,
int crop_y,
int crop_width,
int crop_height,
int scale_width,
int scale_height) override;
protected: protected:
// Should not be called directly. Adopts the Java VideoFrame.Buffer. Use // Should not be called directly. Adopts the Java VideoFrame.Buffer. Use
// Create() or Adopt() instead for clarity. // Create() or Adopt() instead for clarity.