1 /*
2 * Copyright 2021 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "api/video/i420_buffer.h"
12 #include "sdk/android/src/jni/jni_helpers.h"
13 #include "sdk/android/src/jni/video_frame.h"
14 #include "sdk/android/src/jni/wrapped_native_i420_buffer.h"
15
16 namespace webrtc {
17 namespace jni {
18
JNI_FUNCTION_DECLARATION(jint,VideoFrameBufferTest_nativeGetBufferType,JNIEnv * jni,jclass,jobject video_frame_buffer)19 JNI_FUNCTION_DECLARATION(jint,
20 VideoFrameBufferTest_nativeGetBufferType,
21 JNIEnv* jni,
22 jclass,
23 jobject video_frame_buffer) {
24 const JavaParamRef<jobject> j_video_frame_buffer(video_frame_buffer);
25 rtc::scoped_refptr<VideoFrameBuffer> buffer =
26 JavaToNativeFrameBuffer(jni, j_video_frame_buffer);
27 return static_cast<jint>(buffer->type());
28 }
29
JNI_FUNCTION_DECLARATION(jobject,VideoFrameBufferTest_nativeGetNativeI420Buffer,JNIEnv * jni,jclass,jobject i420_buffer)30 JNI_FUNCTION_DECLARATION(jobject,
31 VideoFrameBufferTest_nativeGetNativeI420Buffer,
32 JNIEnv* jni,
33 jclass,
34 jobject i420_buffer) {
35 const JavaParamRef<jobject> j_i420_buffer(i420_buffer);
36 rtc::scoped_refptr<VideoFrameBuffer> buffer =
37 JavaToNativeFrameBuffer(jni, j_i420_buffer);
38 const I420BufferInterface* inputBuffer = buffer->GetI420();
39 RTC_DCHECK(inputBuffer != nullptr);
40 rtc::scoped_refptr<I420Buffer> outputBuffer = I420Buffer::Copy(*inputBuffer);
41 return WrapI420Buffer(jni, outputBuffer).Release();
42 }
43
44 } // namespace jni
45 } // namespace webrtc
46