Android JNI generation: Set JNI namespace in build files

This CL removes the use of the @JNINamespace annotation and instead
sets the correct JNI namespace in the build file.

Bug: webrtc:8278
Change-Id: Ia4490399e45a97d56b02c260fd80df4edfa092bf
Reviewed-on: https://webrtc-review.googlesource.com/76440
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23299}
This commit is contained in:
Magnus Jedvert
2018-05-18 12:13:56 +02:00
committed by Commit Bot
parent 7e6fcea7de
commit c7da266cb8
72 changed files with 131 additions and 240 deletions

View File

@ -19,7 +19,6 @@ package org.webrtc;
* Histogram.createCounts("WebRTC.Video.SomeMetric", 1, 10000, 50);
* someMetricHistogram.addSample(someVariable);
*/
@JNINamespace("webrtc::jni")
class Histogram {
private final long handle;

View File

@ -1,26 +0,0 @@
/*
* 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;
/**
* @JNINamespace is used by the JNI generator to create the necessary JNI
* bindings and expose this method to native code using the specified namespace.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface JNINamespace {
public String value();
}

View File

@ -13,7 +13,6 @@ package org.webrtc;
import java.nio.ByteBuffer;
/** Class with static JNI helper functions that are used in many places. */
@JNINamespace("webrtc::jni")
public class JniCommon {
/** Functions to increment/decrement an rtc::RefCountInterface pointer. */
public static native void nativeAddRef(long refCountedPointer);

View File

@ -13,7 +13,6 @@ package org.webrtc;
import java.nio.ByteBuffer;
import javax.annotation.Nullable;
@JNINamespace("webrtc::jni")
public class NV12Buffer implements VideoFrame.Buffer {
private final int width;
private final int height;

View File

@ -14,7 +14,6 @@ import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable;
@JNINamespace("webrtc::jni")
public class NV21Buffer implements VideoFrame.Buffer {
private final byte[] data;
private final int width;

View File

@ -16,7 +16,6 @@ import javax.annotation.Nullable;
* Implements VideoCapturer.CapturerObserver and feeds frames to
* webrtc::jni::AndroidVideoTrackSource.
*/
@JNINamespace("webrtc::jni")
class NativeCapturerObserver implements VideoCapturer.CapturerObserver {
// Pointer to webrtc::jni::AndroidVideoTrackSource.
private final long nativeSource;

View File

@ -1,31 +0,0 @@
/*
* 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

@ -10,7 +10,6 @@
package org.webrtc;
@JNINamespace("webrtc::jni")
class VP8Decoder extends WrappedNativeVideoDecoder {
@Override
long createNativeDecoder() {

View File

@ -10,7 +10,6 @@
package org.webrtc;
@JNINamespace("webrtc::jni")
class VP8Encoder extends WrappedNativeVideoEncoder {
@Override
long createNativeEncoder() {

View File

@ -10,7 +10,6 @@
package org.webrtc;
@JNINamespace("webrtc::jni")
class VP9Decoder extends WrappedNativeVideoDecoder {
@Override
long createNativeDecoder() {

View File

@ -10,7 +10,6 @@
package org.webrtc;
@JNINamespace("webrtc::jni")
class VP9Encoder extends WrappedNativeVideoEncoder {
@Override
long createNativeEncoder() {

View File

@ -22,7 +22,6 @@ class VideoDecoderWrapper {
Integer qp) -> nativeOnDecodedFrame(nativeDecoder, frame, decodeTimeMs, qp);
}
@NativeClassQualifiedName("webrtc::jni::VideoDecoderWrapper")
private static native void nativeOnDecodedFrame(
long nativeDecoder, VideoFrame frame, Integer decodeTimeMs, Integer qp);
long nativeVideoDecoderWrapper, VideoFrame frame, Integer decodeTimeMs, Integer qp);
}

View File

@ -44,8 +44,7 @@ class VideoEncoderWrapper {
frame.rotation, frame.completeFrame, frame.qp);
}
@NativeClassQualifiedName("webrtc::jni::VideoEncoderWrapper")
private static native void nativeOnEncodedFrame(long nativeEncoder, ByteBuffer buffer,
private static native void nativeOnEncodedFrame(long nativeVideoEncoderWrapper, ByteBuffer buffer,
int encodedWidth, int encodedHeight, long captureTimeNs, int frameType, int rotation,
boolean completeFrame, Integer qp);
}

View File

@ -24,7 +24,6 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.webrtc.CalledByNative;
import org.webrtc.Logging;
import org.webrtc.NativeClassQualifiedName;
import org.webrtc.ThreadUtils;
import org.webrtc.audio.JavaAudioDeviceModule.AudioRecordErrorCallback;
import org.webrtc.audio.JavaAudioDeviceModule.AudioRecordStartErrorCode;
@ -321,11 +320,9 @@ class WebRtcAudioRecord {
return (channels == 1 ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO);
}
@NativeClassQualifiedName("webrtc::android_adm::AudioRecordJni")
private native void nativeCacheDirectBufferAddress(long nativeAudioRecord, ByteBuffer byteBuffer);
@NativeClassQualifiedName("webrtc::android_adm::AudioRecordJni")
private native void nativeDataIsRecorded(long nativeAudioRecord, int bytes);
private native void nativeCacheDirectBufferAddress(
long nativeAudioRecordJni, ByteBuffer byteBuffer);
private native void nativeDataIsRecorded(long nativeAudioRecordJni, int bytes);
// Sets all recorded samples to zero if |mute| is true, i.e., ensures that
// the microphone is muted.

View File

@ -26,7 +26,6 @@ import org.webrtc.ThreadUtils;
import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackErrorCallback;
import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackStartErrorCode;
import org.webrtc.CalledByNative;
import org.webrtc.NativeClassQualifiedName;
class WebRtcAudioTrack {
private static final String TAG = "WebRtcAudioTrackExternal";
@ -443,12 +442,9 @@ class WebRtcAudioTrack {
return (channels == 1 ? AudioFormat.CHANNEL_OUT_MONO : AudioFormat.CHANNEL_OUT_STEREO);
}
@NativeClassQualifiedName("webrtc::android_adm::AudioTrackJni")
private static native void nativeCacheDirectBufferAddress(
long nativeAudioRecord, ByteBuffer byteBuffer);
@NativeClassQualifiedName("webrtc::android_adm::AudioTrackJni")
private static native void nativeGetPlayoutData(long nativeAudioRecord, int bytes);
long nativeAudioTrackJni, ByteBuffer byteBuffer);
private static native void nativeGetPlayoutData(long nativeAudioTrackJni, int bytes);
// Sets all samples to be played out to zero if |mute| is true, i.e.,
// ensures that the speaker is muted.

View File

@ -18,7 +18,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
enum AudioDeviceMessageType : uint32_t {
kMessageOutputStreamDisconnected,
@ -241,6 +241,6 @@ void AAudioPlayer::HandleStreamDisconnected() {
StartPlayout();
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -29,7 +29,7 @@ namespace webrtc {
class AudioDeviceBuffer;
class FineAudioBuffer;
namespace android_adm {
namespace jni {
// Implements low-latency 16-bit mono PCM audio output support for Android
// using the C based AAudio API.
@ -146,7 +146,7 @@ class AAudioPlayer final : public AudioOutput,
double latency_millis_ RTC_GUARDED_BY(thread_checker_aaudio_) = 0;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -21,7 +21,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
enum AudioDeviceMessageType : uint32_t {
kMessageInputStreamDisconnected,
@ -230,6 +230,6 @@ void AAudioRecorder::HandleStreamDisconnected() {
StartRecording();
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -27,7 +27,7 @@ namespace webrtc {
class FineAudioBuffer;
class AudioDeviceBuffer;
namespace android_adm {
namespace jni {
// Implements low-latency 16-bit mono PCM audio input support for Android
// using the C based AAudio API.
@ -126,7 +126,7 @@ class AAudioRecorder : public AudioInput,
bool first_data_callback_ = true;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -33,7 +33,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
namespace {
@ -496,6 +496,6 @@ bool AAudioWrapper::OptimizeBuffers() {
return true;
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -18,7 +18,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
// AAudio callback interface for audio transport to/from the AAudio stream.
// The interface also contains an error callback method for notifications of
@ -122,7 +122,7 @@ class AAudioWrapper {
int32_t frames_per_burst_ = 0;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -13,7 +13,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
const int kDefaultSampleRate = 44100;
// Delay estimates for the two different supported modes. These values are based
@ -25,7 +25,7 @@ const int kDefaultSampleRate = 44100;
const int kLowLatencyModeDelayEstimateInMilliseconds = 50;
const int kHighLatencyModeDelayEstimateInMilliseconds = 150;
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -20,8 +20,7 @@
#include "system_wrappers/include/metrics.h"
namespace webrtc {
namespace android_adm {
namespace jni {
namespace {
@ -632,6 +631,5 @@ rtc::scoped_refptr<AudioDeviceModule> CreateAudioDeviceModuleFromInputAndOutput(
playout_delay_ms, std::move(audio_input), std::move(audio_output));
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -18,8 +18,7 @@
#include "sdk/android/native_api/jni/scoped_java_ref.h"
namespace webrtc {
namespace android_adm {
namespace jni {
class AudioInput {
public:
@ -91,7 +90,7 @@ rtc::scoped_refptr<AudioDeviceModule> CreateAudioDeviceModuleFromInputAndOutput(
std::unique_ptr<AudioInput> audio_input,
std::unique_ptr<AudioOutput> audio_output);
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -26,7 +26,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
namespace {
// Scoped class which logs its time of life as a UMA statistic. It generates
@ -243,6 +243,6 @@ void AudioRecordJni::DataIsRecorded(JNIEnv* env,
}
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -21,7 +21,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
// Implements 16-bit mono PCM audio input support for Android using the Java
// AudioRecord interface. Most of the work is done by its Java counterpart in
@ -131,7 +131,7 @@ class AudioRecordJni : public AudioInput {
AudioDeviceBuffer* audio_device_buffer_;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -22,7 +22,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
ScopedJavaLocalRef<jobject> AudioTrackJni::CreateJavaWebRtcAudioTrack(
JNIEnv* env,
@ -216,6 +216,6 @@ void AudioTrackJni::GetPlayoutData(JNIEnv* env,
RTC_DCHECK_EQ(length, bytes_per_frame * samples);
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -23,7 +23,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
// Implements 16-bit mono PCM audio output support for Android using the Java
// AudioTrack interface. Most of the work is done by its Java counterpart in
@ -123,7 +123,7 @@ class AudioTrackJni : public AudioOutput {
AudioDeviceBuffer* audio_device_buffer_;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -28,22 +28,20 @@ static jlong JNI_JavaAudioDeviceModule_CreateAudioDeviceModule(
jboolean j_use_stereo_output) {
AudioParameters input_parameters;
AudioParameters output_parameters;
android_adm::GetAudioParameters(env, j_context, j_audio_manager, sample_rate,
j_use_stereo_input, j_use_stereo_output,
&input_parameters, &output_parameters);
auto audio_input = rtc::MakeUnique<android_adm::AudioRecordJni>(
env, input_parameters,
android_adm::kHighLatencyModeDelayEstimateInMilliseconds,
GetAudioParameters(env, j_context, j_audio_manager, sample_rate,
j_use_stereo_input, j_use_stereo_output, &input_parameters,
&output_parameters);
auto audio_input = rtc::MakeUnique<AudioRecordJni>(
env, input_parameters, kHighLatencyModeDelayEstimateInMilliseconds,
j_webrtc_audio_record);
auto audio_output = rtc::MakeUnique<android_adm::AudioTrackJni>(
env, output_parameters, j_webrtc_audio_track);
return jlongFromPointer(
CreateAudioDeviceModuleFromInputAndOutput(
AudioDeviceModule::kAndroidJavaAudio, j_use_stereo_input,
j_use_stereo_output,
android_adm::kHighLatencyModeDelayEstimateInMilliseconds,
std::move(audio_input), std::move(audio_output))
.release());
auto audio_output = rtc::MakeUnique<AudioTrackJni>(env, output_parameters,
j_webrtc_audio_track);
return jlongFromPointer(CreateAudioDeviceModuleFromInputAndOutput(
AudioDeviceModule::kAndroidJavaAudio,
j_use_stereo_input, j_use_stereo_output,
kHighLatencyModeDelayEstimateInMilliseconds,
std::move(audio_input), std::move(audio_output))
.release());
}
} // namespace jni

View File

@ -17,7 +17,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
// Returns a string representation given an integer SL_RESULT_XXX code.
// The mapping can be found in <SLES/OpenSLES.h>.
@ -140,6 +140,6 @@ SLObjectItf OpenSLEngineManager::GetOpenSLEngine() {
return engine_object_.Get();
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -20,7 +20,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
// Returns a string representation given an integer SL_RESULT_XXX code.
// The mapping can be found in <SLES/OpenSLES.h>.
@ -83,7 +83,7 @@ class OpenSLEngineManager {
ScopedSLObjectItf engine_object_;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -40,7 +40,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
OpenSLESPlayer::OpenSLESPlayer(
const AudioParameters& audio_parameters,
@ -441,6 +441,6 @@ SLuint32 OpenSLESPlayer::GetPlayState() const {
return state;
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -29,7 +29,7 @@ namespace webrtc {
class FineAudioBuffer;
namespace android_adm {
namespace jni {
// Implements 16-bit mono PCM audio output support for Android using the
// C based OpenSL ES API. No calls from C/C++ to Java using JNI is done.
@ -188,7 +188,7 @@ class OpenSLESPlayer : public AudioOutput {
uint32_t last_play_time_;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -41,7 +41,7 @@
namespace webrtc {
namespace android_adm {
namespace jni {
OpenSLESRecorder::OpenSLESRecorder(const AudioParameters& audio_parameters,
OpenSLEngineManager* engine_manager)
@ -441,6 +441,6 @@ SLuint32 OpenSLESRecorder::GetBufferCount() {
return state.count;
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -29,7 +29,7 @@ namespace webrtc {
class FineAudioBuffer;
namespace android_adm {
namespace jni {
// Implements 16-bit mono PCM audio input support for Android using the
// C based OpenSL ES API. No calls from C/C++ to Java using JNI is done.
@ -185,7 +185,7 @@ class OpenSLESRecorder : public AudioInput {
uint32_t last_rec_time_;
};
} // namespace android_adm
} // namespace jni
} // namespace webrtc