Android: Generate Java -> C++ JNI code for VideoEncoder

This is the first CL that tries generating Java -> C++ JNI code.

Bug: webrtc:8278
Change-Id: I1ff0df10db0f80a3c84a61a4e82be8f713690a69
Reviewed-on: https://webrtc-review.googlesource.com/20873
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20592}
This commit is contained in:
Magnus Jedvert
2017-11-07 17:34:38 +01:00
committed by Commit Bot
parent 3f2634eadc
commit 18ce0f006d
6 changed files with 44 additions and 24 deletions

View File

@ -0,0 +1,31 @@
/*
* Copyright 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @NativeClassQualifiedName is used by the JNI generator to create the necessary JNI
* bindings to call into the specified native class name.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface NativeClassQualifiedName {
/*
* Tells which native class the method is going to be bound to.
* The first parameter of the annotated method must be an int nativePtr pointing to
* an instance of this class.
*/
public String value();
}

View File

@ -69,12 +69,13 @@ class VideoEncoderWrapper {
@CalledByNative
static VideoEncoder.Callback createEncoderCallback(final long nativeEncoder) {
return (EncodedImage frame, VideoEncoder.CodecSpecificInfo info)
-> onEncodedFrame(nativeEncoder, frame.buffer, frame.encodedWidth,
-> nativeOnEncodedFrame(nativeEncoder, frame.buffer, frame.encodedWidth,
frame.encodedHeight, frame.captureTimeNs, frame.frameType.getNative(),
frame.rotation, frame.completeFrame, frame.qp);
}
private static native void onEncodedFrame(long nativeEncoder, ByteBuffer buffer, int encodedWidth,
int encodedHeight, long captureTimeNs, int frameType, int rotation, boolean completeFrame,
Integer qp);
@NativeClassQualifiedName("webrtc::jni::VideoEncoderWrapper")
private static native void nativeOnEncodedFrame(long nativeEncoder, ByteBuffer buffer,
int encodedWidth, int encodedHeight, long captureTimeNs, int frameType, int rotation,
boolean completeFrame, Integer qp);
}