Android: Generate JNI code for androidvideotracksource
Bug: webrtc:8278 Change-Id: I43b53c68ebaf2c3f9c27ea7ef510d7b016c1df93 Reviewed-on: https://webrtc-review.googlesource.com/23243 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20795}
This commit is contained in:

committed by
Commit Bot

parent
36de62e830
commit
202be3957d
@ -51,6 +51,7 @@ public class VideoFrame {
|
||||
* 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);
|
||||
}
|
||||
|
@ -36,12 +36,6 @@ AndroidVideoTrackSource::AndroidVideoTrackSource(
|
||||
is_screencast_(is_screencast) {
|
||||
RTC_LOG(LS_INFO) << "AndroidVideoTrackSource ctor";
|
||||
camera_thread_checker_.DetachFromThread();
|
||||
|
||||
jclass j_video_frame_buffer_class =
|
||||
FindClass(jni, "org/webrtc/VideoFrame$Buffer");
|
||||
j_crop_and_scale_id_ =
|
||||
jni->GetMethodID(j_video_frame_buffer_class, "cropAndScale",
|
||||
"(IIIIII)Lorg/webrtc/VideoFrame$Buffer;");
|
||||
}
|
||||
|
||||
void AndroidVideoTrackSource::SetState(SourceState state) {
|
||||
@ -183,12 +177,10 @@ void AndroidVideoTrackSource::OnFrameCaptured(JNIEnv* jni,
|
||||
return;
|
||||
}
|
||||
|
||||
jobject j_adapted_video_frame_buffer = jni->CallObjectMethod(
|
||||
j_video_frame_buffer, j_crop_and_scale_id_, crop_x, crop_y, crop_width,
|
||||
crop_height, adapted_width, adapted_height);
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> buffer =
|
||||
AndroidVideoBuffer::Adopt(jni, j_adapted_video_frame_buffer);
|
||||
AndroidVideoBuffer::Create(jni, j_video_frame_buffer)
|
||||
->CropAndScale(jni, crop_x, crop_y, crop_width, crop_height,
|
||||
adapted_width, adapted_height);
|
||||
|
||||
// AdaptedVideoTrackSource handles applying rotation for I420 frames.
|
||||
if (apply_rotation() && rotation != kVideoRotation_0) {
|
||||
|
@ -85,8 +85,6 @@ class AndroidVideoTrackSource : public rtc::AdaptedVideoTrackSource {
|
||||
I420BufferPool buffer_pool_;
|
||||
rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper_;
|
||||
const bool is_screencast_;
|
||||
|
||||
jmethodID j_crop_and_scale_id_;
|
||||
};
|
||||
|
||||
} // namespace jni
|
||||
|
@ -311,6 +311,19 @@ jobject AndroidVideoBuffer::video_frame_buffer() const {
|
||||
return *j_video_frame_buffer_;
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<AndroidVideoBuffer> AndroidVideoBuffer::CropAndScale(
|
||||
JNIEnv* jni,
|
||||
int crop_x,
|
||||
int crop_y,
|
||||
int crop_width,
|
||||
int crop_height,
|
||||
int scale_width,
|
||||
int scale_height) {
|
||||
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;
|
||||
}
|
||||
|
@ -120,6 +120,16 @@ class AndroidVideoBuffer : public AndroidVideoFrameBuffer {
|
||||
|
||||
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<AndroidVideoBuffer> CropAndScale(JNIEnv* jni,
|
||||
int crop_x,
|
||||
int crop_y,
|
||||
int crop_width,
|
||||
int crop_height,
|
||||
int scale_width,
|
||||
int scale_height);
|
||||
|
||||
// Returns an instance of VideoRenderer.I420Frame (deprecated)
|
||||
jobject ToJavaI420Frame(JNIEnv* jni, int rotation);
|
||||
|
||||
|
Reference in New Issue
Block a user