Android: Update convenience macro defining JNI-accessible methods

Update the name of the macro to something more descriptive and use
variable length arguments to make it work better with autoformatting
tools.

BUG=None

Review-Url: https://codereview.webrtc.org/2998403002
Cr-Original-Commit-Position: refs/heads/master@{#19538}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 09f3f6eb268b7d84cc8aa2e36a84cf6380f74037
diff --git a/sdk/android/src/jni/androidhistogram_jni.cc b/sdk/android/src/jni/androidhistogram_jni.cc
index c3c9742..c94cc42 100644
--- a/sdk/android/src/jni/androidhistogram_jni.cc
+++ b/sdk/android/src/jni/androidhistogram_jni.cc
@@ -18,22 +18,36 @@
 // Enables collection of native histograms and creating them.
 namespace webrtc_jni {
 
-JOW(jlong, Histogram_nativeCreateCounts)
-(JNIEnv* jni, jclass, jstring j_name, jint min, jint max, jint buckets) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         Histogram_nativeCreateCounts,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_name,
+                         jint min,
+                         jint max,
+                         jint buckets) {
   std::string name = JavaToStdString(jni, j_name);
   return jlongFromPointer(
       webrtc::metrics::HistogramFactoryGetCounts(name, min, max, buckets));
 }
 
-JOW(jlong, Histogram_nativeCreateEnumeration)
-(JNIEnv* jni, jclass, jstring j_name, jint max) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         Histogram_nativeCreateEnumeration,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_name,
+                         jint max) {
   std::string name = JavaToStdString(jni, j_name);
   return jlongFromPointer(
       webrtc::metrics::HistogramFactoryGetEnumeration(name, max));
 }
 
-JOW(void, Histogram_nativeAddSample)
-(JNIEnv* jni, jclass, jlong histogram, jint sample) {
+JNI_FUNCTION_DECLARATION(void,
+                         Histogram_nativeAddSample,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong histogram,
+                         jint sample) {
   if (histogram) {
     HistogramAdd(reinterpret_cast<webrtc::metrics::Histogram*>(histogram),
                  sample);
diff --git a/sdk/android/src/jni/androidmediaencoder_jni.cc b/sdk/android/src/jni/androidmediaencoder_jni.cc
index 0aa5a51..a8ff753 100644
--- a/sdk/android/src/jni/androidmediaencoder_jni.cc
+++ b/sdk/android/src/jni/androidmediaencoder_jni.cc
@@ -1476,17 +1476,18 @@
   delete encoder;
 }
 
-JOW(void, MediaCodecVideoEncoder_nativeFillBuffer)
-(JNIEnv* jni,
- jclass,
- jlong native_encoder,
- jint input_buffer,
- jobject j_buffer_y,
- jint stride_y,
- jobject j_buffer_u,
- jint stride_u,
- jobject j_buffer_v,
- jint stride_v) {
+JNI_FUNCTION_DECLARATION(void,
+                         MediaCodecVideoEncoder_nativeFillBuffer,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_encoder,
+                         jint input_buffer,
+                         jobject j_buffer_y,
+                         jint stride_y,
+                         jobject j_buffer_u,
+                         jint stride_u,
+                         jobject j_buffer_v,
+                         jint stride_v) {
   uint8_t* buffer_y =
       static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_buffer_y));
   uint8_t* buffer_u =
diff --git a/sdk/android/src/jni/androidmetrics_jni.cc b/sdk/android/src/jni/androidmetrics_jni.cc
index 9da0792..b0e5deb 100644
--- a/sdk/android/src/jni/androidmetrics_jni.cc
+++ b/sdk/android/src/jni/androidmetrics_jni.cc
@@ -19,12 +19,15 @@
 // Enables collection of native histograms and creating them.
 namespace webrtc_jni {
 
-JOW(void, Metrics_nativeEnable)(JNIEnv* jni, jclass) {
+JNI_FUNCTION_DECLARATION(void, Metrics_nativeEnable, JNIEnv* jni, jclass) {
   webrtc::metrics::Enable();
 }
 
 // Gets and clears native histograms.
-JOW(jobject, Metrics_nativeGetAndReset)(JNIEnv* jni, jclass) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         Metrics_nativeGetAndReset,
+                         JNIEnv* jni,
+                         jclass) {
   jclass j_metrics_class = jni->FindClass("org/webrtc/Metrics");
   jmethodID j_add =
       GetMethodID(jni, j_metrics_class, "add",
diff --git a/sdk/android/src/jni/androidvideotracksource_jni.cc b/sdk/android/src/jni/androidvideotracksource_jni.cc
index 5633522..dfad301 100644
--- a/sdk/android/src/jni/androidvideotracksource_jni.cc
+++ b/sdk/android/src/jni/androidvideotracksource_jni.cc
@@ -14,11 +14,6 @@
 #include "webrtc/sdk/android/src/jni/androidvideotracksource.h"
 #include "webrtc/sdk/android/src/jni/classreferenceholder.h"
 
-// Identifiers are over 80 characters long so this is needed to fit them on one
-// line.
-#define JOW_OBSERVER_METHOD(rettype, name) \
-  JOW(rettype, AndroidVideoTrackSourceObserver_##name)
-
 static webrtc::VideoRotation jintToVideoRotation(jint rotation) {
   RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 ||
              rotation == 270);
@@ -34,16 +29,18 @@
       proxy_source->internal());
 }
 
-JOW_OBSERVER_METHOD(void, nativeOnByteBufferFrameCaptured)
-(JNIEnv* jni,
- jclass,
- jlong j_source,
- jbyteArray j_frame,
- jint length,
- jint width,
- jint height,
- jint rotation,
- jlong timestamp) {
+JNI_FUNCTION_DECLARATION(
+    void,
+    AndroidVideoTrackSourceObserver_nativeOnByteBufferFrameCaptured,
+    JNIEnv* jni,
+    jclass,
+    jlong j_source,
+    jbyteArray j_frame,
+    jint length,
+    jint width,
+    jint height,
+    jint rotation,
+    jlong timestamp) {
   webrtc::AndroidVideoTrackSource* source =
       AndroidVideoTrackSourceFromJavaProxy(j_source);
   jbyte* bytes = jni->GetByteArrayElements(j_frame, nullptr);
@@ -52,16 +49,18 @@
   jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT);
 }
 
-JOW_OBSERVER_METHOD(void, nativeOnTextureFrameCaptured)
-(JNIEnv* jni,
- jclass,
- jlong j_source,
- jint j_width,
- jint j_height,
- jint j_oes_texture_id,
- jfloatArray j_transform_matrix,
- jint j_rotation,
- jlong j_timestamp) {
+JNI_FUNCTION_DECLARATION(
+    void,
+    AndroidVideoTrackSourceObserver_nativeOnTextureFrameCaptured,
+    JNIEnv* jni,
+    jclass,
+    jlong j_source,
+    jint j_width,
+    jint j_height,
+    jint j_oes_texture_id,
+    jfloatArray j_transform_matrix,
+    jint j_rotation,
+    jlong j_timestamp) {
   webrtc::AndroidVideoTrackSource* source =
       AndroidVideoTrackSourceFromJavaProxy(j_source);
   source->OnTextureFrameCaptured(
@@ -69,15 +68,16 @@
       NativeHandleImpl(jni, j_oes_texture_id, j_transform_matrix));
 }
 
-JOW_OBSERVER_METHOD(void, nativeOnFrameCaptured)
-(JNIEnv* jni,
- jclass,
- jlong j_source,
- jint j_width,
- jint j_height,
- jint j_rotation,
- jlong j_timestamp_ns,
- jobject j_video_frame_buffer) {
+JNI_FUNCTION_DECLARATION(void,
+                         AndroidVideoTrackSourceObserver_nativeOnFrameCaptured,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_source,
+                         jint j_width,
+                         jint j_height,
+                         jint j_rotation,
+                         jlong j_timestamp_ns,
+                         jobject j_video_frame_buffer) {
   webrtc::AndroidVideoTrackSource* source =
       AndroidVideoTrackSourceFromJavaProxy(j_source);
   source->OnFrameCaptured(jni, j_width, j_height, j_timestamp_ns,
@@ -85,8 +85,12 @@
                           j_video_frame_buffer);
 }
 
-JOW_OBSERVER_METHOD(void, nativeCapturerStarted)
-(JNIEnv* jni, jclass, jlong j_source, jboolean j_success) {
+JNI_FUNCTION_DECLARATION(void,
+                         AndroidVideoTrackSourceObserver_nativeCapturerStarted,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_source,
+                         jboolean j_success) {
   LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStarted";
   webrtc::AndroidVideoTrackSource* source =
       AndroidVideoTrackSourceFromJavaProxy(j_source);
@@ -95,16 +99,25 @@
                        : webrtc::AndroidVideoTrackSource::SourceState::kEnded);
 }
 
-JOW_OBSERVER_METHOD(void, nativeCapturerStopped)
-(JNIEnv* jni, jclass, jlong j_source) {
+JNI_FUNCTION_DECLARATION(void,
+                         AndroidVideoTrackSourceObserver_nativeCapturerStopped,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_source) {
   LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStopped";
   webrtc::AndroidVideoTrackSource* source =
       AndroidVideoTrackSourceFromJavaProxy(j_source);
   source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kEnded);
 }
 
-JOW(void, VideoSource_nativeAdaptOutputFormat)
-(JNIEnv* jni, jclass, jlong j_source, jint j_width, jint j_height, jint j_fps) {
+JNI_FUNCTION_DECLARATION(void,
+                         VideoSource_nativeAdaptOutputFormat,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_source,
+                         jint j_width,
+                         jint j_height,
+                         jint j_fps) {
   LOG(LS_INFO) << "VideoSource_nativeAdaptOutputFormat";
   webrtc::AndroidVideoTrackSource* source =
       AndroidVideoTrackSourceFromJavaProxy(j_source);
diff --git a/sdk/android/src/jni/jni_helpers.h b/sdk/android/src/jni/jni_helpers.h
index e4c43a2..7400d32 100644
--- a/sdk/android/src/jni/jni_helpers.h
+++ b/sdk/android/src/jni/jni_helpers.h
@@ -36,20 +36,8 @@
 
 // Convenience macro defining JNI-accessible methods in the org.webrtc package.
 // Eliminates unnecessary boilerplate and line-wraps, reducing visual clutter.
-//
-// TODO(deadbeef): Rename this macro to something like
-// "JNI_FUNCTION_DECLARATION", and use variable length arguments, such that you
-// can write:
-//
-// JNI_FUNCTION_DECLARATION(void, nativeFoo, Type arg1, Type arg2) { ...
-//
-// Instead of:
-//
-// JNI_FUNCTION_DECLARATION(void, nativeFoo)(Type arg1, Type arg2) { ...
-//
-// The latter gets handled poorly by autoformatting tools.
-#define JOW(rettype, name) \
-  extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name
+#define JNI_FUNCTION_DECLARATION(rettype, name, ...) \
+  extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name(__VA_ARGS__)
 
 namespace webrtc_jni {
 
diff --git a/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc b/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc
index 383326f..6b27d84 100644
--- a/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc
+++ b/sdk/android/src/jni/pc/androidnetworkmonitor_jni.cc
@@ -389,18 +389,22 @@
   return new AndroidNetworkMonitor();
 }
 
-JOW(void, NetworkMonitor_nativeNotifyConnectionTypeChanged)
-(JNIEnv* jni, jobject j_monitor, jlong j_native_monitor) {
+JNI_FUNCTION_DECLARATION(void,
+                         NetworkMonitor_nativeNotifyConnectionTypeChanged,
+                         JNIEnv* jni,
+                         jobject j_monitor,
+                         jlong j_native_monitor) {
   rtc::NetworkMonitorInterface* network_monitor =
       reinterpret_cast<rtc::NetworkMonitorInterface*>(j_native_monitor);
   network_monitor->OnNetworksChanged();
 }
 
-JOW(void, NetworkMonitor_nativeNotifyOfActiveNetworkList)
-(JNIEnv* jni,
- jobject j_monitor,
- jlong j_native_monitor,
- jobjectArray j_network_infos) {
+JNI_FUNCTION_DECLARATION(void,
+                         NetworkMonitor_nativeNotifyOfActiveNetworkList,
+                         JNIEnv* jni,
+                         jobject j_monitor,
+                         jlong j_native_monitor,
+                         jobjectArray j_network_infos) {
   AndroidNetworkMonitor* network_monitor =
       reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor);
   std::vector<NetworkInformation> network_infos;
@@ -413,11 +417,12 @@
   network_monitor->SetNetworkInfos(network_infos);
 }
 
-JOW(void, NetworkMonitor_nativeNotifyOfNetworkConnect)
-(JNIEnv* jni,
- jobject j_monitor,
- jlong j_native_monitor,
- jobject j_network_info) {
+JNI_FUNCTION_DECLARATION(void,
+                         NetworkMonitor_nativeNotifyOfNetworkConnect,
+                         JNIEnv* jni,
+                         jobject j_monitor,
+                         jlong j_native_monitor,
+                         jobject j_network_info) {
   AndroidNetworkMonitor* network_monitor =
       reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor);
   NetworkInformation network_info =
@@ -425,8 +430,12 @@
   network_monitor->OnNetworkConnected(network_info);
 }
 
-JOW(void, NetworkMonitor_nativeNotifyOfNetworkDisconnect)
-(JNIEnv* jni, jobject j_monitor, jlong j_native_monitor, jlong network_handle) {
+JNI_FUNCTION_DECLARATION(void,
+                         NetworkMonitor_nativeNotifyOfNetworkDisconnect,
+                         JNIEnv* jni,
+                         jobject j_monitor,
+                         jlong j_native_monitor,
+                         jlong network_handle) {
   AndroidNetworkMonitor* network_monitor =
       reinterpret_cast<AndroidNetworkMonitor*>(j_native_monitor);
   network_monitor->OnNetworkDisconnected(
diff --git a/sdk/android/src/jni/pc/audiotrack_jni.cc b/sdk/android/src/jni/pc/audiotrack_jni.cc
index dbe64f0..84492e6 100644
--- a/sdk/android/src/jni/pc/audiotrack_jni.cc
+++ b/sdk/android/src/jni/pc/audiotrack_jni.cc
@@ -13,8 +13,12 @@
 
 namespace webrtc_jni {
 
-JOW(void, AudioTrack_nativeSetVolume)
-(JNIEnv*, jclass, jlong j_p, jdouble volume) {
+JNI_FUNCTION_DECLARATION(void,
+                         AudioTrack_nativeSetVolume,
+                         JNIEnv*,
+                         jclass,
+                         jlong j_p,
+                         jdouble volume) {
   rtc::scoped_refptr<webrtc::AudioSourceInterface> source(
       reinterpret_cast<webrtc::AudioTrackInterface*>(j_p)->GetSource());
   source->SetVolume(volume);
diff --git a/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc b/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc
index 42763b6..eeca185 100644
--- a/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc
+++ b/sdk/android/src/jni/pc/callsessionfilerotatinglogsink_jni.cc
@@ -13,8 +13,13 @@
 
 namespace webrtc_jni {
 
-JOW(jlong, CallSessionFileRotatingLogSink_nativeAddSink)
-(JNIEnv* jni, jclass, jstring j_dirPath, jint j_maxFileSize, jint j_severity) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         CallSessionFileRotatingLogSink_nativeAddSink,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_dirPath,
+                         jint j_maxFileSize,
+                         jint j_severity) {
   std::string dir_path = JavaToStdString(jni, j_dirPath);
   rtc::CallSessionFileRotatingLogSink* sink =
       new rtc::CallSessionFileRotatingLogSink(dir_path, j_maxFileSize);
@@ -30,16 +35,22 @@
   return (jlong)sink;
 }
 
-JOW(void, CallSessionFileRotatingLogSink_nativeDeleteSink)
-(JNIEnv* jni, jclass, jlong j_sink) {
+JNI_FUNCTION_DECLARATION(void,
+                         CallSessionFileRotatingLogSink_nativeDeleteSink,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_sink) {
   rtc::CallSessionFileRotatingLogSink* sink =
       reinterpret_cast<rtc::CallSessionFileRotatingLogSink*>(j_sink);
   rtc::LogMessage::RemoveLogToStream(sink);
   delete sink;
 }
 
-JOW(jbyteArray, CallSessionFileRotatingLogSink_nativeGetLogData)
-(JNIEnv* jni, jclass, jstring j_dirPath) {
+JNI_FUNCTION_DECLARATION(jbyteArray,
+                         CallSessionFileRotatingLogSink_nativeGetLogData,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_dirPath) {
   std::string dir_path = JavaToStdString(jni, j_dirPath);
   std::unique_ptr<rtc::CallSessionFileRotatingStream> stream(
       new rtc::CallSessionFileRotatingStream(dir_path));
diff --git a/sdk/android/src/jni/pc/datachannel_jni.cc b/sdk/android/src/jni/pc/datachannel_jni.cc
index 71621f5..1a19bce 100644
--- a/sdk/android/src/jni/pc/datachannel_jni.cc
+++ b/sdk/android/src/jni/pc/datachannel_jni.cc
@@ -24,49 +24,68 @@
   return reinterpret_cast<webrtc::DataChannelInterface*>(j_d);
 }
 
-JOW(jlong, DataChannel_registerObserverNative)
-(JNIEnv* jni, jobject j_dc, jobject j_observer) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         DataChannel_registerObserverNative,
+                         JNIEnv* jni,
+                         jobject j_dc,
+                         jobject j_observer) {
   std::unique_ptr<DataChannelObserverJni> observer(
       new DataChannelObserverJni(jni, j_observer));
   ExtractNativeDC(jni, j_dc)->RegisterObserver(observer.get());
   return jlongFromPointer(observer.release());
 }
 
-JOW(void, DataChannel_unregisterObserverNative)
-(JNIEnv* jni, jobject j_dc, jlong native_observer) {
+JNI_FUNCTION_DECLARATION(void,
+                         DataChannel_unregisterObserverNative,
+                         JNIEnv* jni,
+                         jobject j_dc,
+                         jlong native_observer) {
   ExtractNativeDC(jni, j_dc)->UnregisterObserver();
   delete reinterpret_cast<DataChannelObserverJni*>(native_observer);
 }
 
-JOW(jstring, DataChannel_label)(JNIEnv* jni, jobject j_dc) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         DataChannel_label,
+                         JNIEnv* jni,
+                         jobject j_dc) {
   return JavaStringFromStdString(jni, ExtractNativeDC(jni, j_dc)->label());
 }
 
-JOW(jint, DataChannel_id)(JNIEnv* jni, jobject j_dc) {
+JNI_FUNCTION_DECLARATION(jint, DataChannel_id, JNIEnv* jni, jobject j_dc) {
   int id = ExtractNativeDC(jni, j_dc)->id();
   RTC_CHECK_LE(id, std::numeric_limits<int32_t>::max())
       << "id overflowed jint!";
   return static_cast<jint>(id);
 }
 
-JOW(jobject, DataChannel_state)(JNIEnv* jni, jobject j_dc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         DataChannel_state,
+                         JNIEnv* jni,
+                         jobject j_dc) {
   return JavaEnumFromIndexAndClassName(jni, "DataChannel$State",
                                        ExtractNativeDC(jni, j_dc)->state());
 }
 
-JOW(jlong, DataChannel_bufferedAmount)(JNIEnv* jni, jobject j_dc) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         DataChannel_bufferedAmount,
+                         JNIEnv* jni,
+                         jobject j_dc) {
   uint64_t buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount();
   RTC_CHECK_LE(buffered_amount, std::numeric_limits<int64_t>::max())
       << "buffered_amount overflowed jlong!";
   return static_cast<jlong>(buffered_amount);
 }
 
-JOW(void, DataChannel_close)(JNIEnv* jni, jobject j_dc) {
+JNI_FUNCTION_DECLARATION(void, DataChannel_close, JNIEnv* jni, jobject j_dc) {
   ExtractNativeDC(jni, j_dc)->Close();
 }
 
-JOW(jboolean, DataChannel_sendNative)
-(JNIEnv* jni, jobject j_dc, jbyteArray data, jboolean binary) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         DataChannel_sendNative,
+                         JNIEnv* jni,
+                         jobject j_dc,
+                         jbyteArray data,
+                         jboolean binary) {
   jbyte* bytes = jni->GetByteArrayElements(data, NULL);
   bool ret = ExtractNativeDC(jni, j_dc)->Send(webrtc::DataBuffer(
       rtc::CopyOnWriteBuffer(bytes, jni->GetArrayLength(data)), binary));
@@ -74,7 +93,7 @@
   return ret;
 }
 
-JOW(void, DataChannel_dispose)(JNIEnv* jni, jobject j_dc) {
+JNI_FUNCTION_DECLARATION(void, DataChannel_dispose, JNIEnv* jni, jobject j_dc) {
   CHECK_RELEASE(ExtractNativeDC(jni, j_dc));
 }
 
diff --git a/sdk/android/src/jni/pc/dtmfsender_jni.cc b/sdk/android/src/jni/pc/dtmfsender_jni.cc
index 1b4a297..b304956 100644
--- a/sdk/android/src/jni/pc/dtmfsender_jni.cc
+++ b/sdk/android/src/jni/pc/dtmfsender_jni.cc
@@ -13,44 +13,60 @@
 
 namespace webrtc_jni {
 
-JOW(jboolean, DtmfSender_nativeCanInsertDtmf)
-(JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         DtmfSender_nativeCanInsertDtmf,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_dtmf_sender_pointer) {
   return reinterpret_cast<webrtc::DtmfSenderInterface*>(j_dtmf_sender_pointer)
       ->CanInsertDtmf();
 }
 
-JOW(jboolean, DtmfSender_nativeInsertDtmf)
-(JNIEnv* jni,
- jclass,
- jlong j_dtmf_sender_pointer,
- jstring tones,
- jint duration,
- jint inter_tone_gap) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         DtmfSender_nativeInsertDtmf,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_dtmf_sender_pointer,
+                         jstring tones,
+                         jint duration,
+                         jint inter_tone_gap) {
   return reinterpret_cast<webrtc::DtmfSenderInterface*>(j_dtmf_sender_pointer)
       ->InsertDtmf(JavaToStdString(jni, tones), duration, inter_tone_gap);
 }
 
-JOW(jstring, DtmfSender_nativeTones)
-(JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         DtmfSender_nativeTones,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_dtmf_sender_pointer) {
   return JavaStringFromStdString(
       jni, reinterpret_cast<webrtc::DtmfSenderInterface*>(j_dtmf_sender_pointer)
                ->tones());
 }
 
-JOW(jint, DtmfSender_nativeDuration)
-(JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jint,
+                         DtmfSender_nativeDuration,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_dtmf_sender_pointer) {
   return reinterpret_cast<webrtc::DtmfSenderInterface*>(j_dtmf_sender_pointer)
       ->duration();
 }
 
-JOW(jint, DtmfSender_nativeInterToneGap)
-(JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jint,
+                         DtmfSender_nativeInterToneGap,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_dtmf_sender_pointer) {
   return reinterpret_cast<webrtc::DtmfSenderInterface*>(j_dtmf_sender_pointer)
       ->inter_tone_gap();
 }
 
-JOW(void, DtmfSender_free)
-(JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) {
+JNI_FUNCTION_DECLARATION(void,
+                         DtmfSender_free,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_dtmf_sender_pointer) {
   reinterpret_cast<webrtc::DtmfSenderInterface*>(j_dtmf_sender_pointer)
       ->Release();
 }
diff --git a/sdk/android/src/jni/pc/logging_jni.cc b/sdk/android/src/jni/pc/logging_jni.cc
index d2ccb56..020eeed 100644
--- a/sdk/android/src/jni/pc/logging_jni.cc
+++ b/sdk/android/src/jni/pc/logging_jni.cc
@@ -17,8 +17,12 @@
 
 namespace webrtc_jni {
 
-JOW(void, Logging_nativeEnableTracing)
-(JNIEnv* jni, jclass, jstring j_path, jint nativeLevels) {
+JNI_FUNCTION_DECLARATION(void,
+                         Logging_nativeEnableTracing,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_path,
+                         jint nativeLevels) {
   std::string path = JavaToStdString(jni, j_path);
   if (nativeLevels != webrtc::kTraceNone) {
     webrtc::Trace::set_level_filter(nativeLevels);
@@ -34,24 +38,38 @@
   }
 }
 
-JOW(void, Logging_nativeEnableLogToDebugOutput)
-(JNIEnv* jni, jclass, jint nativeSeverity) {
+JNI_FUNCTION_DECLARATION(void,
+                         Logging_nativeEnableLogToDebugOutput,
+                         JNIEnv* jni,
+                         jclass,
+                         jint nativeSeverity) {
   if (nativeSeverity >= rtc::LS_SENSITIVE && nativeSeverity <= rtc::LS_NONE) {
     rtc::LogMessage::LogToDebug(
         static_cast<rtc::LoggingSeverity>(nativeSeverity));
   }
 }
 
-JOW(void, Logging_nativeEnableLogThreads)(JNIEnv* jni, jclass) {
+JNI_FUNCTION_DECLARATION(void,
+                         Logging_nativeEnableLogThreads,
+                         JNIEnv* jni,
+                         jclass) {
   rtc::LogMessage::LogThreads(true);
 }
 
-JOW(void, Logging_nativeEnableLogTimeStamps)(JNIEnv* jni, jclass) {
+JNI_FUNCTION_DECLARATION(void,
+                         Logging_nativeEnableLogTimeStamps,
+                         JNIEnv* jni,
+                         jclass) {
   rtc::LogMessage::LogTimestamps(true);
 }
 
-JOW(void, Logging_nativeLog)
-(JNIEnv* jni, jclass, jint j_severity, jstring j_tag, jstring j_message) {
+JNI_FUNCTION_DECLARATION(void,
+                         Logging_nativeLog,
+                         JNIEnv* jni,
+                         jclass,
+                         jint j_severity,
+                         jstring j_tag,
+                         jstring j_message) {
   std::string message = JavaToStdString(jni, j_message);
   std::string tag = JavaToStdString(jni, j_tag);
   LOG_TAG(static_cast<rtc::LoggingSeverity>(j_severity), tag) << message;
diff --git a/sdk/android/src/jni/pc/mediasource_jni.cc b/sdk/android/src/jni/pc/mediasource_jni.cc
index 1fc46b3..6e3150d 100644
--- a/sdk/android/src/jni/pc/mediasource_jni.cc
+++ b/sdk/android/src/jni/pc/mediasource_jni.cc
@@ -13,11 +13,15 @@
 
 namespace webrtc_jni {
 
-JOW(void, MediaSource_free)(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void, MediaSource_free, JNIEnv*, jclass, jlong j_p) {
   reinterpret_cast<rtc::RefCountInterface*>(j_p)->Release();
 }
 
-JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         MediaSource_nativeState,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_p) {
   rtc::scoped_refptr<webrtc::MediaSourceInterface> p(
       reinterpret_cast<webrtc::MediaSourceInterface*>(j_p));
   return JavaEnumFromIndexAndClassName(jni, "MediaSource$State", p->state());
diff --git a/sdk/android/src/jni/pc/mediastream_jni.cc b/sdk/android/src/jni/pc/mediastream_jni.cc
index b80f4e3..7204de2 100644
--- a/sdk/android/src/jni/pc/mediastream_jni.cc
+++ b/sdk/android/src/jni/pc/mediastream_jni.cc
@@ -13,36 +13,56 @@
 
 namespace webrtc_jni {
 
-JOW(jboolean, MediaStream_nativeAddAudioTrack)
-(JNIEnv* jni, jclass, jlong pointer, jlong j_audio_track_pointer) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         MediaStream_nativeAddAudioTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong pointer,
+                         jlong j_audio_track_pointer) {
   return reinterpret_cast<webrtc::MediaStreamInterface*>(pointer)->AddTrack(
       reinterpret_cast<webrtc::AudioTrackInterface*>(j_audio_track_pointer));
 }
 
-JOW(jboolean, MediaStream_nativeAddVideoTrack)
-(JNIEnv* jni, jclass, jlong pointer, jlong j_video_track_pointer) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         MediaStream_nativeAddVideoTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong pointer,
+                         jlong j_video_track_pointer) {
   return reinterpret_cast<webrtc::MediaStreamInterface*>(pointer)->AddTrack(
       reinterpret_cast<webrtc::VideoTrackInterface*>(j_video_track_pointer));
 }
 
-JOW(jboolean, MediaStream_nativeRemoveAudioTrack)
-(JNIEnv* jni, jclass, jlong pointer, jlong j_audio_track_pointer) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         MediaStream_nativeRemoveAudioTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong pointer,
+                         jlong j_audio_track_pointer) {
   return reinterpret_cast<webrtc::MediaStreamInterface*>(pointer)->RemoveTrack(
       reinterpret_cast<webrtc::AudioTrackInterface*>(j_audio_track_pointer));
 }
 
-JOW(jboolean, MediaStream_nativeRemoveVideoTrack)
-(JNIEnv* jni, jclass, jlong pointer, jlong j_video_track_pointer) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         MediaStream_nativeRemoveVideoTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong pointer,
+                         jlong j_video_track_pointer) {
   return reinterpret_cast<webrtc::MediaStreamInterface*>(pointer)->RemoveTrack(
       reinterpret_cast<webrtc::VideoTrackInterface*>(j_video_track_pointer));
 }
 
-JOW(jstring, MediaStream_nativeLabel)(JNIEnv* jni, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         MediaStream_nativeLabel,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_p) {
   return JavaStringFromStdString(
       jni, reinterpret_cast<webrtc::MediaStreamInterface*>(j_p)->label());
 }
 
-JOW(void, MediaStream_free)(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void, MediaStream_free, JNIEnv*, jclass, jlong j_p) {
   CHECK_RELEASE(reinterpret_cast<webrtc::MediaStreamInterface*>(j_p));
 }
 
diff --git a/sdk/android/src/jni/pc/mediastreamtrack_jni.cc b/sdk/android/src/jni/pc/mediastreamtrack_jni.cc
index 849cdbb..182c5e2 100644
--- a/sdk/android/src/jni/pc/mediastreamtrack_jni.cc
+++ b/sdk/android/src/jni/pc/mediastreamtrack_jni.cc
@@ -13,32 +13,56 @@
 
 namespace webrtc_jni {
 
-JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void,
+                         MediaStreamTrack_free,
+                         JNIEnv*,
+                         jclass,
+                         jlong j_p) {
   reinterpret_cast<webrtc::MediaStreamTrackInterface*>(j_p)->Release();
 }
 
-JOW(jstring, MediaStreamTrack_nativeId)(JNIEnv* jni, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         MediaStreamTrack_nativeId,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_p) {
   return JavaStringFromStdString(
       jni, reinterpret_cast<webrtc::MediaStreamTrackInterface*>(j_p)->id());
 }
 
-JOW(jstring, MediaStreamTrack_nativeKind)(JNIEnv* jni, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         MediaStreamTrack_nativeKind,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_p) {
   return JavaStringFromStdString(
       jni, reinterpret_cast<webrtc::MediaStreamTrackInterface*>(j_p)->kind());
 }
 
-JOW(jboolean, MediaStreamTrack_nativeEnabled)(JNIEnv* jni, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         MediaStreamTrack_nativeEnabled,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_p) {
   return reinterpret_cast<webrtc::MediaStreamTrackInterface*>(j_p)->enabled();
 }
 
-JOW(jobject, MediaStreamTrack_nativeState)(JNIEnv* jni, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         MediaStreamTrack_nativeState,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_p) {
   return JavaEnumFromIndexAndClassName(
       jni, "MediaStreamTrack$State",
       reinterpret_cast<webrtc::MediaStreamTrackInterface*>(j_p)->state());
 }
 
-JOW(jboolean, MediaStreamTrack_nativeSetEnabled)
-(JNIEnv* jni, jclass, jlong j_p, jboolean enabled) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         MediaStreamTrack_nativeSetEnabled,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_p,
+                         jboolean enabled) {
   return reinterpret_cast<webrtc::MediaStreamTrackInterface*>(j_p)->set_enabled(
       enabled);
 }
diff --git a/sdk/android/src/jni/pc/peerconnection_jni.cc b/sdk/android/src/jni/pc/peerconnection_jni.cc
index 5172df2..65ca2fd 100644
--- a/sdk/android/src/jni/pc/peerconnection_jni.cc
+++ b/sdk/android/src/jni/pc/peerconnection_jni.cc
@@ -57,30 +57,48 @@
       reinterpret_cast<webrtc::PeerConnectionInterface*>(j_p));
 }
 
-JOW(void, PeerConnection_freePeerConnection)(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_freePeerConnection,
+                         JNIEnv*,
+                         jclass,
+                         jlong j_p) {
   CHECK_RELEASE(reinterpret_cast<webrtc::PeerConnectionInterface*>(j_p));
 }
 
-JOW(void, PeerConnection_freeObserver)(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_freeObserver,
+                         JNIEnv*,
+                         jclass,
+                         jlong j_p) {
   PeerConnectionObserverJni* p =
       reinterpret_cast<PeerConnectionObserverJni*>(j_p);
   delete p;
 }
 
-JOW(jobject, PeerConnection_getLocalDescription)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_getLocalDescription,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   const webrtc::SessionDescriptionInterface* sdp =
       ExtractNativePC(jni, j_pc)->local_description();
   return sdp ? NativeToJavaSessionDescription(jni, sdp) : NULL;
 }
 
-JOW(jobject, PeerConnection_getRemoteDescription)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_getRemoteDescription,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   const webrtc::SessionDescriptionInterface* sdp =
       ExtractNativePC(jni, j_pc)->remote_description();
   return sdp ? NativeToJavaSessionDescription(jni, sdp) : NULL;
 }
 
-JOW(jobject, PeerConnection_createDataChannel)
-(JNIEnv* jni, jobject j_pc, jstring j_label, jobject j_init) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_createDataChannel,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jstring j_label,
+                         jobject j_init) {
   webrtc::DataChannelInit init = JavaToNativeDataChannelInit(jni, j_init);
   rtc::scoped_refptr<webrtc::DataChannelInterface> channel(
       ExtractNativePC(jni, j_pc)->CreateDataChannel(
@@ -105,8 +123,12 @@
   return j_channel;
 }
 
-JOW(void, PeerConnection_createOffer)
-(JNIEnv* jni, jobject j_pc, jobject j_observer, jobject j_constraints) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_createOffer,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_observer,
+                         jobject j_constraints) {
   MediaConstraintsJni* constraints =
       new MediaConstraintsJni(jni, j_constraints);
   rtc::scoped_refptr<CreateSdpObserverJni> observer(
@@ -115,8 +137,12 @@
   ExtractNativePC(jni, j_pc)->CreateOffer(observer, constraints);
 }
 
-JOW(void, PeerConnection_createAnswer)
-(JNIEnv* jni, jobject j_pc, jobject j_observer, jobject j_constraints) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_createAnswer,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_observer,
+                         jobject j_constraints) {
   MediaConstraintsJni* constraints =
       new MediaConstraintsJni(jni, j_constraints);
   rtc::scoped_refptr<CreateSdpObserverJni> observer(
@@ -125,24 +151,36 @@
   ExtractNativePC(jni, j_pc)->CreateAnswer(observer, constraints);
 }
 
-JOW(void, PeerConnection_setLocalDescription)
-(JNIEnv* jni, jobject j_pc, jobject j_observer, jobject j_sdp) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_setLocalDescription,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_observer,
+                         jobject j_sdp) {
   rtc::scoped_refptr<SetSdpObserverJni> observer(
       new rtc::RefCountedObject<SetSdpObserverJni>(jni, j_observer, nullptr));
   ExtractNativePC(jni, j_pc)->SetLocalDescription(
       observer, JavaToNativeSessionDescription(jni, j_sdp));
 }
 
-JOW(void, PeerConnection_setRemoteDescription)
-(JNIEnv* jni, jobject j_pc, jobject j_observer, jobject j_sdp) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_setRemoteDescription,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_observer,
+                         jobject j_sdp) {
   rtc::scoped_refptr<SetSdpObserverJni> observer(
       new rtc::RefCountedObject<SetSdpObserverJni>(jni, j_observer, nullptr));
   ExtractNativePC(jni, j_pc)->SetRemoteDescription(
       observer, JavaToNativeSessionDescription(jni, j_sdp));
 }
 
-JOW(jboolean, PeerConnection_nativeSetConfiguration)
-(JNIEnv* jni, jobject j_pc, jobject j_rtc_config, jlong native_observer) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         PeerConnection_nativeSetConfiguration,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_rtc_config,
+                         jlong native_observer) {
   // Need to merge constraints into RTCConfiguration again, which are stored
   // in the observer object.
   PeerConnectionObserverJni* observer =
@@ -154,12 +192,13 @@
   return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config);
 }
 
-JOW(jboolean, PeerConnection_nativeAddIceCandidate)
-(JNIEnv* jni,
- jobject j_pc,
- jstring j_sdp_mid,
- jint j_sdp_mline_index,
- jstring j_candidate_sdp) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         PeerConnection_nativeAddIceCandidate,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jstring j_sdp_mid,
+                         jint j_sdp_mline_index,
+                         jstring j_candidate_sdp) {
   std::string sdp_mid = JavaToStdString(jni, j_sdp_mid);
   std::string sdp = JavaToStdString(jni, j_candidate_sdp);
   std::unique_ptr<webrtc::IceCandidateInterface> candidate(
@@ -167,8 +206,11 @@
   return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get());
 }
 
-JOW(jboolean, PeerConnection_nativeRemoveIceCandidates)
-(JNIEnv* jni, jobject j_pc, jobjectArray j_candidates) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         PeerConnection_nativeRemoveIceCandidates,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobjectArray j_candidates) {
   std::vector<cricket::Candidate> candidates;
   size_t num_candidates = jni->GetArrayLength(j_candidates);
   for (size_t i = 0; i < num_candidates; ++i) {
@@ -178,20 +220,30 @@
   return ExtractNativePC(jni, j_pc)->RemoveIceCandidates(candidates);
 }
 
-JOW(jboolean, PeerConnection_nativeAddLocalStream)
-(JNIEnv* jni, jobject j_pc, jlong native_stream) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         PeerConnection_nativeAddLocalStream,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jlong native_stream) {
   return ExtractNativePC(jni, j_pc)->AddStream(
       reinterpret_cast<webrtc::MediaStreamInterface*>(native_stream));
 }
 
-JOW(void, PeerConnection_nativeRemoveLocalStream)
-(JNIEnv* jni, jobject j_pc, jlong native_stream) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_nativeRemoveLocalStream,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jlong native_stream) {
   ExtractNativePC(jni, j_pc)->RemoveStream(
       reinterpret_cast<webrtc::MediaStreamInterface*>(native_stream));
 }
 
-JOW(jobject, PeerConnection_nativeCreateSender)
-(JNIEnv* jni, jobject j_pc, jstring j_kind, jstring j_stream_id) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_nativeCreateSender,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jstring j_kind,
+                         jstring j_stream_id) {
   jclass j_rtp_sender_class = FindClass(jni, "org/webrtc/RtpSender");
   jmethodID j_rtp_sender_ctor =
       GetMethodID(jni, j_rtp_sender_class, "<init>", "(J)V");
@@ -213,7 +265,10 @@
   return j_sender;
 }
 
-JOW(jobject, PeerConnection_nativeGetSenders)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_nativeGetSenders,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   jclass j_array_list_class = FindClass(jni, "java/util/ArrayList");
   jmethodID j_array_list_ctor =
       GetMethodID(jni, j_array_list_class, "<init>", "()V");
@@ -241,7 +296,10 @@
   return j_senders;
 }
 
-JOW(jobject, PeerConnection_nativeGetReceivers)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_nativeGetReceivers,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   jclass j_array_list_class = FindClass(jni, "java/util/ArrayList");
   jmethodID j_array_list_ctor =
       GetMethodID(jni, j_array_list_class, "<init>", "()V");
@@ -268,8 +326,12 @@
   return j_receivers;
 }
 
-JOW(bool, PeerConnection_nativeOldGetStats)
-(JNIEnv* jni, jobject j_pc, jobject j_observer, jlong native_track) {
+JNI_FUNCTION_DECLARATION(bool,
+                         PeerConnection_nativeOldGetStats,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_observer,
+                         jlong native_track) {
   rtc::scoped_refptr<StatsObserverJni> observer(
       new rtc::RefCountedObject<StatsObserverJni>(jni, j_observer));
   return ExtractNativePC(jni, j_pc)->GetStats(
@@ -278,16 +340,24 @@
       webrtc::PeerConnectionInterface::kStatsOutputLevelStandard);
 }
 
-JOW(void, PeerConnection_nativeNewGetStats)
-(JNIEnv* jni, jobject j_pc, jobject j_callback) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_nativeNewGetStats,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_callback) {
   rtc::scoped_refptr<RTCStatsCollectorCallbackWrapper> callback(
       new rtc::RefCountedObject<RTCStatsCollectorCallbackWrapper>(jni,
                                                                   j_callback));
   ExtractNativePC(jni, j_pc)->GetStats(callback);
 }
 
-JOW(jboolean, PeerConnection_setBitrate)
-(JNIEnv* jni, jobject j_pc, jobject j_min, jobject j_current, jobject j_max) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         PeerConnection_setBitrate,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         jobject j_min,
+                         jobject j_current,
+                         jobject j_max) {
   webrtc::PeerConnectionInterface::BitrateParameters params;
   jclass j_integer_class = jni->FindClass("java/lang/Integer");
   jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I");
@@ -306,38 +376,57 @@
   return ExtractNativePC(jni, j_pc)->SetBitrate(params).ok();
 }
 
-JOW(bool, PeerConnection_nativeStartRtcEventLog)
-(JNIEnv* jni, jobject j_pc, int file_descriptor, int max_size_bytes) {
+JNI_FUNCTION_DECLARATION(bool,
+                         PeerConnection_nativeStartRtcEventLog,
+                         JNIEnv* jni,
+                         jobject j_pc,
+                         int file_descriptor,
+                         int max_size_bytes) {
   return ExtractNativePC(jni, j_pc)->StartRtcEventLog(file_descriptor,
                                                       max_size_bytes);
 }
 
-JOW(void, PeerConnection_nativeStopRtcEventLog)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_nativeStopRtcEventLog,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   ExtractNativePC(jni, j_pc)->StopRtcEventLog();
 }
 
-JOW(jobject, PeerConnection_signalingState)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_signalingState,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   webrtc::PeerConnectionInterface::SignalingState state =
       ExtractNativePC(jni, j_pc)->signaling_state();
   return JavaEnumFromIndexAndClassName(jni, "PeerConnection$SignalingState",
                                        state);
 }
 
-JOW(jobject, PeerConnection_iceConnectionState)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_iceConnectionState,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   webrtc::PeerConnectionInterface::IceConnectionState state =
       ExtractNativePC(jni, j_pc)->ice_connection_state();
   return JavaEnumFromIndexAndClassName(jni, "PeerConnection$IceConnectionState",
                                        state);
 }
 
-JOW(jobject, PeerConnection_iceGatheringState)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         PeerConnection_iceGatheringState,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   webrtc::PeerConnectionInterface::IceGatheringState state =
       ExtractNativePC(jni, j_pc)->ice_gathering_state();
   return JavaEnumFromIndexAndClassName(jni, "PeerConnection$IceGatheringState",
                                        state);
 }
 
-JOW(void, PeerConnection_close)(JNIEnv* jni, jobject j_pc) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnection_close,
+                         JNIEnv* jni,
+                         jobject j_pc) {
   ExtractNativePC(jni, j_pc)->Close();
   return;
 }
diff --git a/sdk/android/src/jni/pc/peerconnectionfactory_jni.cc b/sdk/android/src/jni/pc/peerconnectionfactory_jni.cc
index f6c45e2..52df977 100644
--- a/sdk/android/src/jni/pc/peerconnectionfactory_jni.cc
+++ b/sdk/android/src/jni/pc/peerconnectionfactory_jni.cc
@@ -47,13 +47,20 @@
 static bool factory_static_initialized = false;
 static bool video_hw_acceleration_enabled = true;
 
-JOW(jlong, PeerConnectionFactory_nativeCreateObserver)
-(JNIEnv* jni, jclass, jobject j_observer) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         PeerConnectionFactory_nativeCreateObserver,
+                         JNIEnv* jni,
+                         jclass,
+                         jobject j_observer) {
   return (jlong) new PeerConnectionObserverJni(jni, j_observer);
 }
 
-JOW(void, PeerConnectionFactory_nativeInitializeAndroidGlobals)
-(JNIEnv* jni, jclass, jobject context, jboolean video_hw_acceleration) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_nativeInitializeAndroidGlobals,
+                         JNIEnv* jni,
+                         jclass,
+                         jobject context,
+                         jboolean video_hw_acceleration) {
   video_hw_acceleration_enabled = video_hw_acceleration;
   if (!factory_static_initialized) {
     webrtc::JVM::Initialize(GetJVM());
@@ -61,8 +68,11 @@
   }
 }
 
-JOW(void, PeerConnectionFactory_initializeFieldTrials)
-(JNIEnv* jni, jclass, jstring j_trials_init_string) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_initializeFieldTrials,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_trials_init_string) {
   field_trials_init_string = NULL;
   if (j_trials_init_string != NULL) {
     const char* init_string =
@@ -76,18 +86,27 @@
   webrtc::field_trial::InitFieldTrialsFromString(field_trials_init_string);
 }
 
-JOW(void, PeerConnectionFactory_initializeInternalTracer)(JNIEnv* jni, jclass) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_initializeInternalTracer,
+                         JNIEnv* jni,
+                         jclass) {
   rtc::tracing::SetupInternalTracer();
 }
 
-JOW(jstring, PeerConnectionFactory_nativeFieldTrialsFindFullName)
-(JNIEnv* jni, jclass, jstring j_name) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         PeerConnectionFactory_nativeFieldTrialsFindFullName,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_name) {
   return JavaStringFromStdString(
       jni, webrtc::field_trial::FindFullName(JavaToStdString(jni, j_name)));
 }
 
-JOW(jboolean, PeerConnectionFactory_startInternalTracingCapture)
-(JNIEnv* jni, jclass, jstring j_event_tracing_filename) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         PeerConnectionFactory_startInternalTracingCapture,
+                         JNIEnv* jni,
+                         jclass,
+                         jstring j_event_tracing_filename) {
   if (!j_event_tracing_filename)
     return false;
 
@@ -99,21 +118,28 @@
   return ret;
 }
 
-JOW(void, PeerConnectionFactory_stopInternalTracingCapture)
-(JNIEnv* jni, jclass) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_stopInternalTracingCapture,
+                         JNIEnv* jni,
+                         jclass) {
   rtc::tracing::StopInternalCapture();
 }
 
-JOW(void, PeerConnectionFactory_shutdownInternalTracer)(JNIEnv* jni, jclass) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_shutdownInternalTracer,
+                         JNIEnv* jni,
+                         jclass) {
   rtc::tracing::ShutdownInternalTracer();
 }
 
-JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnectionFactory)
-(JNIEnv* jni,
- jclass,
- jobject joptions,
- jobject jencoder_factory,
- jobject jdecoder_factory) {
+JNI_FUNCTION_DECLARATION(
+    jlong,
+    PeerConnectionFactory_nativeCreatePeerConnectionFactory,
+    JNIEnv* jni,
+    jclass,
+    jobject joptions,
+    jobject jencoder_factory,
+    jobject jdecoder_factory) {
   // talk/ assumes pretty widely that the current Thread is ThreadManager'd, but
   // ThreadManager only WrapCurrentThread()s the thread where it is first
   // created.  Since the semantics around when auto-wrapping happens in
@@ -190,7 +216,11 @@
   return jlongFromPointer(owned_factory);
 }
 
-JOW(void, PeerConnectionFactory_nativeFreeFactory)(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_nativeFreeFactory,
+                         JNIEnv*,
+                         jclass,
+                         jlong j_p) {
   delete reinterpret_cast<OwnedFactoryAndThreads*>(j_p);
   if (field_trials_init_string) {
     webrtc::field_trial::InitFieldTrialsFromString(NULL);
@@ -200,15 +230,22 @@
   webrtc::Trace::ReturnTrace();
 }
 
-JOW(void, PeerConnectionFactory_nativeThreadsCallbacks)
-(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_nativeThreadsCallbacks,
+                         JNIEnv*,
+                         jclass,
+                         jlong j_p) {
   OwnedFactoryAndThreads* factory =
       reinterpret_cast<OwnedFactoryAndThreads*>(j_p);
   factory->InvokeJavaCallbacksOnFactoryThreads();
 }
 
-JOW(jlong, PeerConnectionFactory_nativeCreateLocalMediaStream)
-(JNIEnv* jni, jclass, jlong native_factory, jstring label) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         PeerConnectionFactory_nativeCreateLocalMediaStream,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory,
+                         jstring label) {
   rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
   rtc::scoped_refptr<webrtc::MediaStreamInterface> stream(
@@ -216,8 +253,12 @@
   return (jlong)stream.release();
 }
 
-JOW(jlong, PeerConnectionFactory_nativeCreateAudioSource)
-(JNIEnv* jni, jclass, jlong native_factory, jobject j_constraints) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         PeerConnectionFactory_nativeCreateAudioSource,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory,
+                         jobject j_constraints) {
   std::unique_ptr<MediaConstraintsJni> constraints(
       new MediaConstraintsJni(jni, j_constraints));
   rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
@@ -229,8 +270,13 @@
   return (jlong)source.release();
 }
 
-JOW(jlong, PeerConnectionFactory_nativeCreateAudioTrack)
-(JNIEnv* jni, jclass, jlong native_factory, jstring id, jlong native_source) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         PeerConnectionFactory_nativeCreateAudioTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory,
+                         jstring id,
+                         jlong native_source) {
   rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
   rtc::scoped_refptr<webrtc::AudioTrackInterface> track(
@@ -240,26 +286,34 @@
   return (jlong)track.release();
 }
 
-JOW(jboolean, PeerConnectionFactory_nativeStartAecDump)
-(JNIEnv* jni,
- jclass,
- jlong native_factory,
- jint file,
- jint filesize_limit_bytes) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         PeerConnectionFactory_nativeStartAecDump,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory,
+                         jint file,
+                         jint filesize_limit_bytes) {
   rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
   return factory->StartAecDump(file, filesize_limit_bytes);
 }
 
-JOW(void, PeerConnectionFactory_nativeStopAecDump)
-(JNIEnv* jni, jclass, jlong native_factory) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_nativeStopAecDump,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory) {
   rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
   factory->StopAecDump();
 }
 
-JOW(void, PeerConnectionFactory_nativeSetOptions)
-(JNIEnv* jni, jclass, jlong native_factory, jobject options) {
+JNI_FUNCTION_DECLARATION(void,
+                         PeerConnectionFactory_nativeSetOptions,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory,
+                         jobject options) {
   rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
   webrtc::PeerConnectionFactoryInterface::Options options_to_set =
@@ -277,13 +331,14 @@
   }
 }
 
-JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)
-(JNIEnv* jni,
- jclass,
- jlong factory,
- jobject j_rtc_config,
- jobject j_constraints,
- jlong observer_p) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         PeerConnectionFactory_nativeCreatePeerConnection,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong factory,
+                         jobject j_rtc_config,
+                         jobject j_constraints,
+                         jlong observer_p) {
   rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> f(
       reinterpret_cast<webrtc::PeerConnectionFactoryInterface*>(
           factoryFromJava(factory)));
diff --git a/sdk/android/src/jni/pc/rtpreceiver_jni.cc b/sdk/android/src/jni/pc/rtpreceiver_jni.cc
index 26148a8..6010404 100644
--- a/sdk/android/src/jni/pc/rtpreceiver_jni.cc
+++ b/sdk/android/src/jni/pc/rtpreceiver_jni.cc
@@ -15,16 +15,24 @@
 
 namespace webrtc_jni {
 
-JOW(jlong, RtpReceiver_nativeGetTrack)
-(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer, jlong j_track_pointer) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         RtpReceiver_nativeGetTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_receiver_pointer,
+                         jlong j_track_pointer) {
   return jlongFromPointer(
       reinterpret_cast<webrtc::RtpReceiverInterface*>(j_rtp_receiver_pointer)
           ->track()
           .release());
 }
 
-JOW(jboolean, RtpReceiver_nativeSetParameters)
-(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer, jobject j_parameters) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         RtpReceiver_nativeSetParameters,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_receiver_pointer,
+                         jobject j_parameters) {
   if (IsNull(jni, j_parameters)) {
     return false;
   }
@@ -34,30 +42,43 @@
       ->SetParameters(parameters);
 }
 
-JOW(jobject, RtpReceiver_nativeGetParameters)
-(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         RtpReceiver_nativeGetParameters,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_receiver_pointer) {
   webrtc::RtpParameters parameters =
       reinterpret_cast<webrtc::RtpReceiverInterface*>(j_rtp_receiver_pointer)
           ->GetParameters();
   return NativeToJavaRtpParameters(jni, parameters);
 }
 
-JOW(jstring, RtpReceiver_nativeId)
-(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         RtpReceiver_nativeId,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_receiver_pointer) {
   return JavaStringFromStdString(
       jni,
       reinterpret_cast<webrtc::RtpReceiverInterface*>(j_rtp_receiver_pointer)
           ->id());
 }
 
-JOW(void, RtpReceiver_free)
-(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
+JNI_FUNCTION_DECLARATION(void,
+                         RtpReceiver_free,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_receiver_pointer) {
   reinterpret_cast<webrtc::RtpReceiverInterface*>(j_rtp_receiver_pointer)
       ->Release();
 }
 
-JOW(jlong, RtpReceiver_nativeSetObserver)
-(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer, jobject j_observer) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         RtpReceiver_nativeSetObserver,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_receiver_pointer,
+                         jobject j_observer) {
   RtpReceiverObserverJni* rtpReceiverObserver =
       new RtpReceiverObserverJni(jni, j_observer);
   reinterpret_cast<webrtc::RtpReceiverInterface*>(j_rtp_receiver_pointer)
@@ -65,8 +86,12 @@
   return jlongFromPointer(rtpReceiverObserver);
 }
 
-JOW(void, RtpReceiver_nativeUnsetObserver)
-(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer, jlong j_observer_pointer) {
+JNI_FUNCTION_DECLARATION(void,
+                         RtpReceiver_nativeUnsetObserver,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_receiver_pointer,
+                         jlong j_observer_pointer) {
   reinterpret_cast<webrtc::RtpReceiverInterface*>(j_rtp_receiver_pointer)
       ->SetObserver(nullptr);
   RtpReceiverObserverJni* observer =
diff --git a/sdk/android/src/jni/pc/rtpsender_jni.cc b/sdk/android/src/jni/pc/rtpsender_jni.cc
index 36aad59..a9fe97d 100644
--- a/sdk/android/src/jni/pc/rtpsender_jni.cc
+++ b/sdk/android/src/jni/pc/rtpsender_jni.cc
@@ -14,31 +14,45 @@
 
 namespace webrtc_jni {
 
-JOW(jboolean, RtpSender_nativeSetTrack)
-(JNIEnv* jni, jclass, jlong j_rtp_sender_pointer, jlong j_track_pointer) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         RtpSender_nativeSetTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_sender_pointer,
+                         jlong j_track_pointer) {
   return reinterpret_cast<webrtc::RtpSenderInterface*>(j_rtp_sender_pointer)
       ->SetTrack(reinterpret_cast<webrtc::MediaStreamTrackInterface*>(
           j_track_pointer));
 }
 
-JOW(jlong, RtpSender_nativeGetTrack)
-(JNIEnv* jni, jclass, jlong j_rtp_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         RtpSender_nativeGetTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_sender_pointer) {
   return jlongFromPointer(
       reinterpret_cast<webrtc::RtpSenderInterface*>(j_rtp_sender_pointer)
           ->track()
           .release());
 }
 
-JOW(jlong, RtpSender_nativeGetDtmfSender)
-(JNIEnv* jni, jclass, jlong j_rtp_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         RtpSender_nativeGetDtmfSender,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_sender_pointer) {
   return jlongFromPointer(
       reinterpret_cast<webrtc::RtpSenderInterface*>(j_rtp_sender_pointer)
           ->GetDtmfSender()
           .release());
 }
 
-JOW(jboolean, RtpSender_nativeSetParameters)
-(JNIEnv* jni, jclass, jlong j_rtp_sender_pointer, jobject j_parameters) {
+JNI_FUNCTION_DECLARATION(jboolean,
+                         RtpSender_nativeSetParameters,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_sender_pointer,
+                         jobject j_parameters) {
   if (IsNull(jni, j_parameters)) {
     return false;
   }
@@ -48,22 +62,32 @@
       ->SetParameters(parameters);
 }
 
-JOW(jobject, RtpSender_nativeGetParameters)
-(JNIEnv* jni, jclass, jlong j_rtp_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jobject,
+                         RtpSender_nativeGetParameters,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_sender_pointer) {
   webrtc::RtpParameters parameters =
       reinterpret_cast<webrtc::RtpSenderInterface*>(j_rtp_sender_pointer)
           ->GetParameters();
   return NativeToJavaRtpParameters(jni, parameters);
 }
 
-JOW(jstring, RtpSender_nativeId)
-(JNIEnv* jni, jclass, jlong j_rtp_sender_pointer) {
+JNI_FUNCTION_DECLARATION(jstring,
+                         RtpSender_nativeId,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_sender_pointer) {
   return JavaStringFromStdString(
       jni, reinterpret_cast<webrtc::RtpSenderInterface*>(j_rtp_sender_pointer)
                ->id());
 }
 
-JOW(void, RtpSender_free)(JNIEnv* jni, jclass, jlong j_rtp_sender_pointer) {
+JNI_FUNCTION_DECLARATION(void,
+                         RtpSender_free,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_rtp_sender_pointer) {
   reinterpret_cast<webrtc::RtpSenderInterface*>(j_rtp_sender_pointer)
       ->Release();
 }
diff --git a/sdk/android/src/jni/pc/video_jni.cc b/sdk/android/src/jni/pc/video_jni.cc
index 2fb751c..5362c28 100644
--- a/sdk/android/src/jni/pc/video_jni.cc
+++ b/sdk/android/src/jni/pc/video_jni.cc
@@ -57,12 +57,13 @@
              : nullptr;
 }
 
-JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource)
-(JNIEnv* jni,
- jclass,
- jlong native_factory,
- jobject j_surface_texture_helper,
- jboolean is_screencast) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         PeerConnectionFactory_nativeCreateVideoSource,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory,
+                         jobject j_surface_texture_helper,
+                         jboolean is_screencast) {
   OwnedFactoryAndThreads* factory =
       reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
 
@@ -77,8 +78,13 @@
   return (jlong)proxy_source.release();
 }
 
-JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)
-(JNIEnv* jni, jclass, jlong native_factory, jstring id, jlong native_source) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         PeerConnectionFactory_nativeCreateVideoTrack,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong native_factory,
+                         jstring id,
+                         jlong native_source) {
   rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
   rtc::scoped_refptr<webrtc::VideoTrackInterface> track(
@@ -88,12 +94,14 @@
   return (jlong)track.release();
 }
 
-JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)
-(JNIEnv* jni,
- jclass,
- jlong native_factory,
- jobject local_egl_context,
- jobject remote_egl_context) {
+JNI_FUNCTION_DECLARATION(
+    void,
+    PeerConnectionFactory_nativeSetVideoHwAccelerationOptions,
+    JNIEnv* jni,
+    jclass,
+    jlong native_factory,
+    jobject local_egl_context,
+    jobject remote_egl_context) {
   OwnedFactoryAndThreads* owned_factory =
       reinterpret_cast<OwnedFactoryAndThreads*>(native_factory);
 
diff --git a/sdk/android/src/jni/video_renderer_jni.cc b/sdk/android/src/jni/video_renderer_jni.cc
index 4f6807a..7156fce 100644
--- a/sdk/android/src/jni/video_renderer_jni.cc
+++ b/sdk/android/src/jni/video_renderer_jni.cc
@@ -135,31 +135,42 @@
   ScopedGlobalRef<jclass> j_byte_buffer_class_;
 };
 
-JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) {
+JNI_FUNCTION_DECLARATION(void,
+                         VideoRenderer_freeWrappedVideoRenderer,
+                         JNIEnv*,
+                         jclass,
+                         jlong j_p) {
   delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p);
 }
 
-JOW(void, VideoRenderer_releaseNativeFrame)
-(JNIEnv* jni, jclass, jlong j_frame_ptr) {
+JNI_FUNCTION_DECLARATION(void,
+                         VideoRenderer_releaseNativeFrame,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_frame_ptr) {
   delete reinterpret_cast<const webrtc::VideoFrame*>(j_frame_ptr);
 }
 
-JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)
-(JNIEnv* jni, jclass, jobject j_callbacks) {
+JNI_FUNCTION_DECLARATION(jlong,
+                         VideoRenderer_nativeWrapVideoRenderer,
+                         JNIEnv* jni,
+                         jclass,
+                         jobject j_callbacks) {
   std::unique_ptr<JavaVideoRendererWrapper> renderer(
       new JavaVideoRendererWrapper(jni, j_callbacks));
   return (jlong)renderer.release();
 }
 
-JOW(void, VideoRenderer_nativeCopyPlane)
-(JNIEnv* jni,
- jclass,
- jobject j_src_buffer,
- jint width,
- jint height,
- jint src_stride,
- jobject j_dst_buffer,
- jint dst_stride) {
+JNI_FUNCTION_DECLARATION(void,
+                         VideoRenderer_nativeCopyPlane,
+                         JNIEnv* jni,
+                         jclass,
+                         jobject j_src_buffer,
+                         jint width,
+                         jint height,
+                         jint src_stride,
+                         jobject j_dst_buffer,
+                         jint dst_stride) {
   size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer);
   size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer);
   RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride;
diff --git a/sdk/android/src/jni/videodecoderwrapper.cc b/sdk/android/src/jni/videodecoderwrapper.cc
index 249d50b..3a64feb 100644
--- a/sdk/android/src/jni/videodecoderwrapper.cc
+++ b/sdk/android/src/jni/videodecoderwrapper.cc
@@ -299,13 +299,14 @@
   return qp;
 }
 
-JOW(void, VideoDecoderWrapperCallback_nativeOnDecodedFrame)
-(JNIEnv* jni,
- jclass,
- jlong jnative_decoder,
- jobject jframe,
- jobject jdecode_time_ms,
- jobject jqp) {
+JNI_FUNCTION_DECLARATION(void,
+                         VideoDecoderWrapperCallback_nativeOnDecodedFrame,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong jnative_decoder,
+                         jobject jframe,
+                         jobject jdecode_time_ms,
+                         jobject jqp) {
   VideoDecoderWrapper* native_decoder =
       reinterpret_cast<VideoDecoderWrapper*>(jnative_decoder);
   native_decoder->OnDecodedFrame(jni, jframe, jdecode_time_ms, jqp);
diff --git a/sdk/android/src/jni/wrapped_native_i420_buffer.cc b/sdk/android/src/jni/wrapped_native_i420_buffer.cc
index c5bbe5a..ea83597 100644
--- a/sdk/android/src/jni/wrapped_native_i420_buffer.cc
+++ b/sdk/android/src/jni/wrapped_native_i420_buffer.cc
@@ -46,13 +46,19 @@
   return j_wrapped_native_i420_buffer;
 }
 
-JOW(void, WrappedNativeI420Buffer_nativeAddRef)
-(JNIEnv* jni, jclass, jlong j_buffer_pointer) {
+JNI_FUNCTION_DECLARATION(void,
+                         WrappedNativeI420Buffer_nativeAddRef,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_buffer_pointer) {
   reinterpret_cast<webrtc::VideoFrameBuffer*>(j_buffer_pointer)->AddRef();
 }
 
-JOW(void, WrappedNativeI420Buffer_nativeRelease)
-(JNIEnv* jni, jclass, jlong j_buffer_pointer) {
+JNI_FUNCTION_DECLARATION(void,
+                         WrappedNativeI420Buffer_nativeRelease,
+                         JNIEnv* jni,
+                         jclass,
+                         jlong j_buffer_pointer) {
   reinterpret_cast<webrtc::VideoFrameBuffer*>(j_buffer_pointer)->Release();
 }