diff --git a/sdk/android/api/org/webrtc/VideoFrame.java b/sdk/android/api/org/webrtc/VideoFrame.java index 49c75facfd..a0a0d4eecb 100644 --- a/sdk/android/api/org/webrtc/VideoFrame.java +++ b/sdk/android/api/org/webrtc/VideoFrame.java @@ -54,6 +54,7 @@ public class VideoFrame implements RefCounted { * Crops a region defined by |cropx|, |cropY|, |cropWidth| and |cropHeight|. Scales it to size * |scaleWidth| x |scaleHeight|. */ + @CalledByNative("Buffer") Buffer cropAndScale( int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight); } diff --git a/sdk/android/src/jni/video_frame.cc b/sdk/android/src/jni/video_frame.cc index ca33c5c009..860eebe5e2 100644 --- a/sdk/android/src/jni/video_frame.cc +++ b/sdk/android/src/jni/video_frame.cc @@ -152,6 +152,19 @@ const ScopedJavaGlobalRef& AndroidVideoBuffer::video_frame_buffer() return j_video_frame_buffer_; } +rtc::scoped_refptr 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 { return Type::kNative; } diff --git a/sdk/android/src/jni/video_frame.h b/sdk/android/src/jni/video_frame.h index cb0ff0e11a..5e39b8a770 100644 --- a/sdk/android/src/jni/video_frame.h +++ b/sdk/android/src/jni/video_frame.h @@ -40,6 +40,15 @@ class AndroidVideoBuffer : public VideoFrameBuffer { const ScopedJavaGlobalRef& 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 CropAndScale(int crop_x, + int crop_y, + int crop_width, + int crop_height, + int scale_width, + int scale_height) override; + protected: // Should not be called directly. Adopts the Java VideoFrame.Buffer. Use // Create() or Adopt() instead for clarity.