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

@ -28,6 +28,7 @@ generate_jni("generated_jni") {
"java/org/webrtc/examples/androidnativeapi/CallClient.java",
]
jni_package = ""
namespace = "webrtc_examples"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}

View File

@ -13,13 +13,10 @@ package org.webrtc.examples.androidnativeapi;
import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import org.webrtc.JNINamespace;
import org.webrtc.NativeClassQualifiedName;
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.VideoCapturer;
import org.webrtc.VideoSink;
@JNINamespace("webrtc_examples")
public class CallClient {
private static final String TAG = "CallClient";
private static final int CAPTURE_WIDTH = 640;
@ -65,13 +62,10 @@ public class CallClient {
}
private static native long nativeCreateClient();
@NativeClassQualifiedName("webrtc_examples::AndroidCallClient")
private static native void nativeCall(long nativePtr, VideoSink localSink, VideoSink remoteSink);
@NativeClassQualifiedName("webrtc_examples::AndroidCallClient")
private static native void nativeHangup(long nativePtr);
@NativeClassQualifiedName("webrtc_examples::AndroidCallClient")
private static native void nativeDelete(long nativePtr);
@NativeClassQualifiedName("webrtc_examples::AndroidCallClient")
private static native void nativeCall(
long nativeAndroidCallClient, VideoSink localSink, VideoSink remoteSink);
private static native void nativeHangup(long nativeAndroidCallClient);
private static native void nativeDelete(long nativeAndroidCallClient);
private static native VideoCapturer.CapturerObserver nativeGetJavaVideoCapturerObserver(
long nativePtr);
long nativeAndroidCallClient);
}

View File

@ -42,6 +42,7 @@ generate_jni("generated_base_jni") {
"src/java/org/webrtc/JniCommon.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -252,6 +253,7 @@ generate_jni("generated_audio_device_module_base_jni") {
"src/java/org/webrtc/audio/WebRtcAudioManager.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -261,6 +263,7 @@ generate_jni("generated_java_audio_device_module_native_jni") {
"src/java/org/webrtc/audio/WebRtcAudioTrack.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -297,6 +300,7 @@ generate_jni("generated_video_jni") {
sources += [ "api/org/webrtc/HardwareVideoEncoderFactory.java" ] # TODO(andersc): This currently depends on SoftwareVideoEncoderFactory
}
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -418,6 +422,7 @@ generate_jni("generated_vp8_jni") {
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -440,6 +445,7 @@ generate_jni("generated_vp9_jni") {
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -509,6 +515,7 @@ generate_jni("generated_peerconnection_jni") {
"api/org/webrtc/TurnCustomizer.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -628,6 +635,7 @@ generate_jni("generated_metrics_jni") {
"api/org/webrtc/Metrics.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -734,8 +742,6 @@ rtc_android_library("base_java") {
"src/java/org/webrtc/Histogram.java",
"src/java/org/webrtc/JniCommon.java",
"src/java/org/webrtc/JniHelper.java",
"src/java/org/webrtc/JNINamespace.java",
"src/java/org/webrtc/NativeClassQualifiedName.java",
"src/java/org/webrtc/RefCountDelegate.java",
"src/java/org/webrtc/WebRtcClassLoader.java",
]
@ -827,6 +833,7 @@ generate_jni("generated_java_audio_jni") {
"api/org/webrtc/audio/JavaAudioDeviceModule.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -1138,6 +1145,7 @@ generate_jni("generated_native_api_jni") {
"src/java/org/webrtc/WebRtcClassLoader.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
@ -1252,6 +1260,7 @@ generate_jni("generated_native_unittests_jni") {
"native_unittests/org/webrtc/PeerConnectionFactoryInitializationHelper.java",
]
jni_package = ""
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}

View File

@ -11,7 +11,6 @@
package org.webrtc;
/** Java wrapper for a C++ AudioTrackInterface */
@JNINamespace("webrtc::jni")
public class AudioTrack extends MediaStreamTrack {
public AudioTrack(long nativeTrack) {
super(nativeTrack);

View File

@ -10,7 +10,6 @@
package org.webrtc;
@JNINamespace("webrtc::jni")
public class CallSessionFileRotatingLogSink {
private long nativeSink;

View File

@ -13,7 +13,6 @@ package org.webrtc;
import java.nio.ByteBuffer;
/** Java wrapper for a C++ DataChannelInterface. */
@JNINamespace("webrtc::jni")
public class DataChannel {
/** Java wrapper for WebIDL RTCDataChannel. */
public static class Init {

View File

@ -11,7 +11,6 @@
package org.webrtc;
/** Java wrapper for a C++ DtmfSenderInterface. */
@JNINamespace("webrtc::jni")
public class DtmfSender {
final long nativeDtmfSender;

View File

@ -26,7 +26,6 @@ import javax.annotation.Nullable;
/** Factory for android hardware video encoders. */
@SuppressWarnings("deprecation") // API 16 requires the use of deprecated methods.
@JNINamespace("webrtc::jni")
public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
private static final String TAG = "HardwareVideoEncoderFactory";

View File

@ -37,7 +37,6 @@ import org.webrtc.VideoFrame;
// This class is an implementation detail of the Java PeerConnection API.
@TargetApi(19)
@SuppressWarnings("deprecation")
@JNINamespace("webrtc::jni")
public class MediaCodecVideoEncoder {
// This class is constructed, operated, and destroyed by its C++ incarnation,
// so the class and its methods have non-public visibility. The API this

View File

@ -11,7 +11,6 @@
package org.webrtc;
/** Java wrapper for a C++ MediaSourceInterface. */
@JNINamespace("webrtc::jni")
public class MediaSource {
/** Tracks MediaSourceInterface.SourceState */
public enum State {

View File

@ -15,7 +15,6 @@ import java.util.List;
import java.util.Iterator;
/** Java wrapper for a C++ MediaStreamInterface. */
@JNINamespace("webrtc::jni")
public class MediaStream {
private static final String TAG = "MediaStream";

View File

@ -13,7 +13,6 @@ package org.webrtc;
import javax.annotation.Nullable;
/** Java wrapper for a C++ MediaStreamTrackInterface. */
@JNINamespace("webrtc::jni")
public class MediaStreamTrack {
public static final String AUDIO_TRACK_KIND = "audio";
public static final String VIDEO_TRACK_KIND = "video";

View File

@ -28,7 +28,6 @@ import java.util.Map;
// Most histograms are not updated frequently (e.g. most video metrics are an
// average over the call and recorded when a stream is removed).
// The metrics can for example be retrieved when a peer connection is closed.
@JNINamespace("webrtc::jni")
public class Metrics {
private static final String TAG = "Metrics";

View File

@ -278,18 +278,13 @@ public class NetworkMonitor {
return connectionType != ConnectionType.CONNECTION_NONE;
}
@NativeClassQualifiedName("webrtc::jni::AndroidNetworkMonitor")
private native void nativeNotifyConnectionTypeChanged(long nativePtr);
@NativeClassQualifiedName("webrtc::jni::AndroidNetworkMonitor")
private native void nativeNotifyOfNetworkConnect(long nativePtr, NetworkInformation networkInfo);
@NativeClassQualifiedName("webrtc::jni::AndroidNetworkMonitor")
private native void nativeNotifyOfNetworkDisconnect(long nativePtr, long networkHandle);
@NativeClassQualifiedName("webrtc::jni::AndroidNetworkMonitor")
private native void nativeNotifyConnectionTypeChanged(long nativeAndroidNetworkMonitor);
private native void nativeNotifyOfNetworkConnect(
long nativeAndroidNetworkMonitor, NetworkInformation networkInfo);
private native void nativeNotifyOfNetworkDisconnect(
long nativeAndroidNetworkMonitor, long networkHandle);
private native void nativeNotifyOfActiveNetworkList(
long nativePtr, NetworkInformation[] networkInfos);
long nativeAndroidNetworkMonitor, NetworkInformation[] networkInfos);
// For testing only.
@Nullable

View File

@ -21,7 +21,6 @@ import javax.annotation.Nullable;
* JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and
* http://www.w3.org/TR/mediacapture-streams/
*/
@JNINamespace("webrtc::jni")
public class PeerConnection {
/** Tracks PeerConnectionInterface::IceGatheringState */
public enum IceGatheringState {

View File

@ -20,7 +20,6 @@ import org.webrtc.audio.LegacyAudioDeviceModule;
* Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to
* the PeerConnection API for clients.
*/
@JNINamespace("webrtc::jni")
public class PeerConnectionFactory {
public static final String TRIAL_ENABLED = "Enabled";
@Deprecated public static final String VIDEO_FRAME_EMIT_TRIAL = "VideoFrameEmit";

View File

@ -14,7 +14,6 @@ import javax.annotation.Nullable;
import org.webrtc.MediaStreamTrack;
/** Java wrapper for a C++ RtpReceiverInterface. */
@JNINamespace("webrtc::jni")
public class RtpReceiver {
/** Java wrapper for a C++ RtpReceiverObserverInterface*/
public static interface Observer {

View File

@ -13,7 +13,6 @@ package org.webrtc;
import javax.annotation.Nullable;
/** Java wrapper for a C++ RtpSenderInterface. */
@JNINamespace("webrtc::jni")
public class RtpSender {
final long nativeRtpSender;

View File

@ -31,7 +31,6 @@ import org.webrtc.RtpParameters.Encoding;
* <p>WebRTC specification for RTCRtpTransceiver, the JavaScript analog:
* https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver
*/
@JNINamespace("webrtc::jni")
public class RtpTransceiver {
/** Java version of webrtc::RtpTransceiverDirection - the ordering must be kept in sync. */
public enum RtpTransceiverDirection {

View File

@ -11,7 +11,6 @@
package org.webrtc;
/** Java wrapper for a C++ TurnCustomizer. */
@JNINamespace("webrtc::jni")
public class TurnCustomizer {
final long nativeTurnCustomizer;

View File

@ -13,7 +13,6 @@ package org.webrtc;
/**
* A combined video decoder that falls back on a secondary decoder if the primary decoder fails.
*/
@JNINamespace("webrtc::jni")
public class VideoDecoderFallback extends WrappedNativeVideoDecoder {
private final VideoDecoder fallback;
private final VideoDecoder primary;

View File

@ -13,7 +13,6 @@ package org.webrtc;
/**
* A combined video encoder that falls back on a secondary encoder if the primary encoder fails.
*/
@JNINamespace("webrtc::jni")
public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
private final VideoEncoder fallback;
private final VideoEncoder primary;

View File

@ -24,7 +24,6 @@ import java.util.concurrent.LinkedBlockingQueue;
/**
* Can be used to save the video frames to file.
*/
@JNINamespace("webrtc::jni")
public class VideoFileRenderer implements VideoSink {
private static final String TAG = "VideoFileRenderer";

View File

@ -26,7 +26,6 @@ import javax.annotation.Nullable;
* format and serves as a fallback for video sinks that can only handle I420, e.g. the internal
* WebRTC software encoders.
*/
@JNINamespace("webrtc::jni")
public class VideoFrame implements RefCounted {
/**
* Implements image storage medium. Might be for example an OpenGL texture or a memory region

View File

@ -21,7 +21,6 @@ import javax.annotation.Nullable;
* drawer.drawYuv depending on the type of the buffer. The frame will be rendered with rotation
* taken into account. You can supply an additional render matrix for custom transformations.
*/
@JNINamespace("webrtc::jni")
public class VideoFrameDrawer {
/**
* Draws a VideoFrame.TextureBuffer. Calls either drawer.drawOes or drawer.drawRgb

View File

@ -20,7 +20,6 @@ import org.webrtc.VideoFrame;
* class also provides a createGui() method for creating a GUI-rendering window
* on various platforms.
*/
@JNINamespace("webrtc::jni")
public class VideoRenderer {
/**
* Java version of webrtc::VideoFrame. Frames are only constructed from native code and test

View File

@ -15,7 +15,6 @@ import javax.annotation.Nullable;
/**
* Java wrapper of native AndroidVideoTrackSource.
*/
@JNINamespace("webrtc::jni")
public class VideoSource extends MediaSource {
private final NativeCapturerObserver capturerObserver;

View File

@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.List;
/** Java version of VideoTrackInterface. */
@JNINamespace("webrtc::jni")
public class VideoTrack extends MediaStreamTrack {
private final List<VideoRenderer> renderers = new ArrayList<>();
private final IdentityHashMap<VideoSink, Long> sinks = new IdentityHashMap<VideoSink, Long>();

View File

@ -13,7 +13,6 @@ package org.webrtc;
import java.nio.ByteBuffer;
/** Wraps libyuv methods to Java. All passed byte buffers must be direct byte buffers. */
@JNINamespace("webrtc::jni")
public class YuvHelper {
/** Helper method for copying I420 to tightly packed destination buffer. */
public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU,

View File

@ -12,7 +12,6 @@ package org.webrtc.audio;
import android.media.AudioManager;
import android.content.Context;
import org.webrtc.JNINamespace;
import org.webrtc.JniCommon;
import org.webrtc.Logging;
@ -20,7 +19,6 @@ import org.webrtc.Logging;
* AudioDeviceModule implemented using android.media.AudioRecord as input and
* android.media.AudioTrack as output.
*/
@JNINamespace("webrtc::jni")
public class JavaAudioDeviceModule implements AudioDeviceModule {
private static final String TAG = "JavaAudioDeviceModule";

View File

@ -36,13 +36,12 @@ void GetDefaultAudioParameters(JNIEnv* env,
AudioParameters* output_parameters) {
const JavaParamRef<jobject> j_context(application_context);
const ScopedJavaLocalRef<jobject> j_audio_manager =
android_adm::GetAudioManager(env, j_context);
const int sample_rate =
android_adm::GetDefaultSampleRate(env, j_audio_manager);
android_adm::GetAudioParameters(env, j_context, j_audio_manager, sample_rate,
false /* use_stereo_input */,
false /* use_stereo_output */,
input_parameters, output_parameters);
jni::GetAudioManager(env, j_context);
const int sample_rate = jni::GetDefaultSampleRate(env, j_audio_manager);
jni::GetAudioParameters(env, j_context, j_audio_manager, sample_rate,
false /* use_stereo_input */,
false /* use_stereo_output */, input_parameters,
output_parameters);
}
} // namespace
@ -61,9 +60,9 @@ rtc::scoped_refptr<AudioDeviceModule> CreateAAudioAudioDeviceModule(
return CreateAudioDeviceModuleFromInputAndOutput(
AudioDeviceModule::kAndroidAAudioAudio, false /* use_stereo_input */,
false /* use_stereo_output */,
android_adm::kLowLatencyModeDelayEstimateInMilliseconds,
rtc::MakeUnique<android_adm::AAudioRecorder>(input_parameters),
rtc::MakeUnique<android_adm::AAudioPlayer>(output_parameters));
jni::kLowLatencyModeDelayEstimateInMilliseconds,
rtc::MakeUnique<jni::AAudioRecorder>(input_parameters),
rtc::MakeUnique<jni::AAudioPlayer>(output_parameters));
}
#endif
@ -74,26 +73,25 @@ rtc::scoped_refptr<AudioDeviceModule> CreateJavaAudioDeviceModule(
// Get default audio input/output parameters.
const JavaParamRef<jobject> j_context(application_context);
const ScopedJavaLocalRef<jobject> j_audio_manager =
android_adm::GetAudioManager(env, j_context);
jni::GetAudioManager(env, j_context);
AudioParameters input_parameters;
AudioParameters output_parameters;
GetDefaultAudioParameters(env, application_context, &input_parameters,
&output_parameters);
// Create ADM from AudioRecord and AudioTrack.
auto audio_input = rtc::MakeUnique<android_adm::AudioRecordJni>(
env, input_parameters,
android_adm::kHighLatencyModeDelayEstimateInMilliseconds,
android_adm::AudioRecordJni::CreateJavaWebRtcAudioRecord(
env, j_context, j_audio_manager));
auto audio_output = rtc::MakeUnique<android_adm::AudioTrackJni>(
auto audio_input = rtc::MakeUnique<jni::AudioRecordJni>(
env, input_parameters, jni::kHighLatencyModeDelayEstimateInMilliseconds,
jni::AudioRecordJni::CreateJavaWebRtcAudioRecord(env, j_context,
j_audio_manager));
auto audio_output = rtc::MakeUnique<jni::AudioTrackJni>(
env, output_parameters,
android_adm::AudioTrackJni::CreateJavaWebRtcAudioTrack(env, j_context,
j_audio_manager));
jni::AudioTrackJni::CreateJavaWebRtcAudioTrack(env, j_context,
j_audio_manager));
return CreateAudioDeviceModuleFromInputAndOutput(
AudioDeviceModule::kAndroidJavaAudio, false /* use_stereo_input */,
false /* use_stereo_output */,
android_adm::kHighLatencyModeDelayEstimateInMilliseconds,
std::move(audio_input), std::move(audio_output));
jni::kHighLatencyModeDelayEstimateInMilliseconds, std::move(audio_input),
std::move(audio_output));
}
rtc::scoped_refptr<AudioDeviceModule> CreateOpenSLESAudioDeviceModule(
@ -106,16 +104,16 @@ rtc::scoped_refptr<AudioDeviceModule> CreateOpenSLESAudioDeviceModule(
GetDefaultAudioParameters(env, application_context, &input_parameters,
&output_parameters);
// Create ADM from OpenSLESRecorder and OpenSLESPlayer.
auto engine_manager = rtc::MakeUnique<android_adm::OpenSLEngineManager>();
auto audio_input = rtc::MakeUnique<android_adm::OpenSLESRecorder>(
auto engine_manager = rtc::MakeUnique<jni::OpenSLEngineManager>();
auto audio_input = rtc::MakeUnique<jni::OpenSLESRecorder>(
input_parameters, engine_manager.get());
auto audio_output = rtc::MakeUnique<android_adm::OpenSLESPlayer>(
auto audio_output = rtc::MakeUnique<jni::OpenSLESPlayer>(
output_parameters, std::move(engine_manager));
return CreateAudioDeviceModuleFromInputAndOutput(
AudioDeviceModule::kAndroidOpenSLESAudio, false /* use_stereo_input */,
false /* use_stereo_output */,
android_adm::kLowLatencyModeDelayEstimateInMilliseconds,
std::move(audio_input), std::move(audio_output));
jni::kLowLatencyModeDelayEstimateInMilliseconds, std::move(audio_input),
std::move(audio_output));
}
rtc::scoped_refptr<AudioDeviceModule>
@ -125,24 +123,23 @@ CreateJavaInputAndOpenSLESOutputAudioDeviceModule(JNIEnv* env,
// Get default audio input/output parameters.
const JavaParamRef<jobject> j_context(application_context);
const ScopedJavaLocalRef<jobject> j_audio_manager =
android_adm::GetAudioManager(env, j_context);
jni::GetAudioManager(env, j_context);
AudioParameters input_parameters;
AudioParameters output_parameters;
GetDefaultAudioParameters(env, application_context, &input_parameters,
&output_parameters);
// Create ADM from AudioRecord and OpenSLESPlayer.
auto audio_input = rtc::MakeUnique<android_adm::AudioRecordJni>(
env, input_parameters,
android_adm::kLowLatencyModeDelayEstimateInMilliseconds,
android_adm::AudioRecordJni::CreateJavaWebRtcAudioRecord(
env, j_context, j_audio_manager));
auto audio_output = rtc::MakeUnique<android_adm::OpenSLESPlayer>(
output_parameters, rtc::MakeUnique<android_adm::OpenSLEngineManager>());
auto audio_input = rtc::MakeUnique<jni::AudioRecordJni>(
env, input_parameters, jni::kLowLatencyModeDelayEstimateInMilliseconds,
jni::AudioRecordJni::CreateJavaWebRtcAudioRecord(env, j_context,
j_audio_manager));
auto audio_output = rtc::MakeUnique<jni::OpenSLESPlayer>(
output_parameters, rtc::MakeUnique<jni::OpenSLEngineManager>());
return CreateAudioDeviceModuleFromInputAndOutput(
AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio,
false /* use_stereo_input */, false /* use_stereo_output */,
android_adm::kLowLatencyModeDelayEstimateInMilliseconds,
std::move(audio_input), std::move(audio_output));
jni::kLowLatencyModeDelayEstimateInMilliseconds, std::move(audio_input),
std::move(audio_output));
}
} // namespace webrtc

View File

@ -32,7 +32,7 @@ namespace {
class ClassLoader {
public:
explicit ClassLoader(JNIEnv* env)
: class_loader_(Java_WebRtcClassLoader_getClassLoader(env)) {
: class_loader_(jni::Java_WebRtcClassLoader_getClassLoader(env)) {
class_loader_class_ = reinterpret_cast<jclass>(
env->NewGlobalRef(env->FindClass("java/lang/ClassLoader")));
CHECK_EXCEPTION(env);

View File

@ -112,13 +112,13 @@ Iterable GetJavaMapEntrySet(JNIEnv* jni, const JavaRef<jobject>& j_map) {
ScopedJavaLocalRef<jobject> GetJavaMapEntryKey(
JNIEnv* jni,
const JavaRef<jobject>& j_entry) {
return Java_JniHelper_getKey(jni, j_entry);
return jni::Java_JniHelper_getKey(jni, j_entry);
}
ScopedJavaLocalRef<jobject> GetJavaMapEntryValue(
JNIEnv* jni,
const JavaRef<jobject>& j_entry) {
return Java_JniHelper_getValue(jni, j_entry);
return jni::Java_JniHelper_getValue(jni, j_entry);
}
int64_t JavaToNativeLong(JNIEnv* env, const JavaRef<jobject>& j_long) {
@ -143,7 +143,7 @@ rtc::Optional<int32_t> JavaToNativeOptionalInt(
// Given a jstring, reinterprets it to a new native string.
std::string JavaToNativeString(JNIEnv* jni, const JavaRef<jstring>& j_string) {
const ScopedJavaLocalRef<jbyteArray> j_byte_array =
Java_JniHelper_getStringBytes(jni, j_string);
jni::Java_JniHelper_getStringBytes(jni, j_string);
const size_t len = jni->GetArrayLength(j_byte_array.obj());
CHECK_EXCEPTION(jni) << "error during GetArrayLength";
@ -243,7 +243,8 @@ ScopedJavaLocalRef<jobjectArray> NativeToJavaStringArray(
&NativeToJavaString;
return NativeToJavaObjectArray(
env, container,
static_cast<jclass>(Java_JniHelper_getStringClass(env).obj()), convert);
static_cast<jclass>(jni::Java_JniHelper_getStringClass(env).obj()),
convert);
}
JavaListBuilder::JavaListBuilder(JNIEnv* env)

View File

@ -50,7 +50,7 @@ using ::testing::Return;
namespace webrtc {
namespace android_adm {
namespace jni {
// Number of callbacks (input or output) the tests waits for before we set
// an event indicating that the test was OK.
@ -1135,6 +1135,6 @@ TEST_F(AudioDeviceTest, DISABLED_MeasureLoopbackLatency) {
latency_audio_stream->PrintResults();
}
} // namespace android_adm
} // namespace jni
} // namespace webrtc

View File

@ -21,7 +21,7 @@ namespace {
TEST(JavaTypesTest, TestJavaToNativeStringMap) {
JNIEnv* env = AttachCurrentThreadIfNeeded();
ScopedJavaLocalRef<jobject> j_map =
Java_JavaTypesTestHelper_createTestStringMap(env);
jni::Java_JavaTypesTestHelper_createTestStringMap(env);
std::map<std::string, std::string> output = JavaToNativeStringMap(env, j_map);

View File

@ -61,7 +61,8 @@ TEST(PeerConnectionFactoryTest, NativeToJavaPeerConnectionFactory) {
JNIEnv* jni = AttachCurrentThreadIfNeeded();
RTC_LOG(INFO) << "Initializing java peer connection factory.";
Java_PeerConnectionFactoryInitializationHelper_initializeFactoryForTests(jni);
jni::Java_PeerConnectionFactoryInitializationHelper_initializeFactoryForTests(
jni);
RTC_LOG(INFO) << "Java peer connection factory initialized.";
// Create threads.

View File

@ -62,10 +62,10 @@ TEST(JavaVideoSourceTest, OnFrameCapturedFrameIsDeliveredToSink) {
false /* is_screencast */);
video_track_source->AddOrUpdateSink(&test_video_sink, rtc::VideoSinkWants());
Java_JavaVideoSourceTestHelper_startCapture(
jni::Java_JavaVideoSourceTestHelper_startCapture(
env, video_track_source->GetJavaVideoCapturerObserver(env),
true /* success */);
Java_JavaVideoSourceTestHelper_deliverFrame(
jni::Java_JavaVideoSourceTestHelper_deliverFrame(
env, video_track_source->GetJavaVideoCapturerObserver(env));
std::vector<VideoFrame> frames = test_video_sink.GetFrames();
@ -86,7 +86,7 @@ TEST(JavaVideoSourceTest, CapturerStartedSuccessStateBecomesLive) {
rtc::ThreadManager::Instance()->CurrentThread(),
false /* is_screencast */);
Java_JavaVideoSourceTestHelper_startCapture(
jni::Java_JavaVideoSourceTestHelper_startCapture(
env, video_track_source->GetJavaVideoCapturerObserver(env),
true /* success */);
@ -104,7 +104,7 @@ TEST(JavaVideoSourceTest, CapturerStartedFailureStateBecomesEnded) {
rtc::ThreadManager::Instance()->CurrentThread(),
false /* is_screencast */);
Java_JavaVideoSourceTestHelper_startCapture(
jni::Java_JavaVideoSourceTestHelper_startCapture(
env, video_track_source->GetJavaVideoCapturerObserver(env),
false /* success */);
@ -122,10 +122,10 @@ TEST(JavaVideoSourceTest, CapturerStoppedStateBecomesEnded) {
rtc::ThreadManager::Instance()->CurrentThread(),
false /* is_screencast */);
Java_JavaVideoSourceTestHelper_startCapture(
jni::Java_JavaVideoSourceTestHelper_startCapture(
env, video_track_source->GetJavaVideoCapturerObserver(env),
true /* success */);
Java_JavaVideoSourceTestHelper_stopCapture(
jni::Java_JavaVideoSourceTestHelper_stopCapture(
env, video_track_source->GetJavaVideoCapturerObserver(env));
EXPECT_EQ(VideoTrackSourceInterface::SourceState::kEnded,

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