Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc

Issue 2998403002: Android: Update convenience macro defining JNI-accessible methods (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/video/video_rotation.h" 11 #include "webrtc/api/video/video_rotation.h"
12 #include "webrtc/api/videosourceproxy.h" 12 #include "webrtc/api/videosourceproxy.h"
13 #include "webrtc/rtc_base/logging.h" 13 #include "webrtc/rtc_base/logging.h"
14 #include "webrtc/sdk/android/src/jni/androidvideotracksource.h" 14 #include "webrtc/sdk/android/src/jni/androidvideotracksource.h"
15 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" 15 #include "webrtc/sdk/android/src/jni/classreferenceholder.h"
16 16
17 // Identifiers are over 80 characters long so this is needed to fit them on one
18 // line.
19 #define JOW_OBSERVER_METHOD(rettype, name) \
20 JOW(rettype, AndroidVideoTrackSourceObserver_##name)
21
22 static webrtc::VideoRotation jintToVideoRotation(jint rotation) { 17 static webrtc::VideoRotation jintToVideoRotation(jint rotation) {
23 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || 18 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 ||
24 rotation == 270); 19 rotation == 270);
25 return static_cast<webrtc::VideoRotation>(rotation); 20 return static_cast<webrtc::VideoRotation>(rotation);
26 } 21 }
27 22
28 namespace webrtc_jni { 23 namespace webrtc_jni {
29 24
30 static webrtc::AndroidVideoTrackSource* AndroidVideoTrackSourceFromJavaProxy( 25 static webrtc::AndroidVideoTrackSource* AndroidVideoTrackSourceFromJavaProxy(
31 jlong j_proxy) { 26 jlong j_proxy) {
32 auto proxy_source = reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_proxy); 27 auto proxy_source = reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_proxy);
33 return reinterpret_cast<webrtc::AndroidVideoTrackSource*>( 28 return reinterpret_cast<webrtc::AndroidVideoTrackSource*>(
34 proxy_source->internal()); 29 proxy_source->internal());
35 } 30 }
36 31
37 JOW_OBSERVER_METHOD(void, nativeOnByteBufferFrameCaptured) 32 JNI_FUNCTION_DECLARATION(
38 (JNIEnv* jni, 33 void,
39 jclass, 34 AndroidVideoTrackSourceObserver_nativeOnByteBufferFrameCaptured,
40 jlong j_source, 35 JNIEnv* jni,
41 jbyteArray j_frame, 36 jclass,
42 jint length, 37 jlong j_source,
43 jint width, 38 jbyteArray j_frame,
44 jint height, 39 jint length,
45 jint rotation, 40 jint width,
46 jlong timestamp) { 41 jint height,
42 jint rotation,
43 jlong timestamp) {
47 webrtc::AndroidVideoTrackSource* source = 44 webrtc::AndroidVideoTrackSource* source =
48 AndroidVideoTrackSourceFromJavaProxy(j_source); 45 AndroidVideoTrackSourceFromJavaProxy(j_source);
49 jbyte* bytes = jni->GetByteArrayElements(j_frame, nullptr); 46 jbyte* bytes = jni->GetByteArrayElements(j_frame, nullptr);
50 source->OnByteBufferFrameCaptured(bytes, length, width, height, 47 source->OnByteBufferFrameCaptured(bytes, length, width, height,
51 jintToVideoRotation(rotation), timestamp); 48 jintToVideoRotation(rotation), timestamp);
52 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); 49 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT);
53 } 50 }
54 51
55 JOW_OBSERVER_METHOD(void, nativeOnTextureFrameCaptured) 52 JNI_FUNCTION_DECLARATION(
56 (JNIEnv* jni, 53 void,
57 jclass, 54 AndroidVideoTrackSourceObserver_nativeOnTextureFrameCaptured,
58 jlong j_source, 55 JNIEnv* jni,
59 jint j_width, 56 jclass,
60 jint j_height, 57 jlong j_source,
61 jint j_oes_texture_id, 58 jint j_width,
62 jfloatArray j_transform_matrix, 59 jint j_height,
63 jint j_rotation, 60 jint j_oes_texture_id,
64 jlong j_timestamp) { 61 jfloatArray j_transform_matrix,
62 jint j_rotation,
63 jlong j_timestamp) {
65 webrtc::AndroidVideoTrackSource* source = 64 webrtc::AndroidVideoTrackSource* source =
66 AndroidVideoTrackSourceFromJavaProxy(j_source); 65 AndroidVideoTrackSourceFromJavaProxy(j_source);
67 source->OnTextureFrameCaptured( 66 source->OnTextureFrameCaptured(
68 j_width, j_height, jintToVideoRotation(j_rotation), j_timestamp, 67 j_width, j_height, jintToVideoRotation(j_rotation), j_timestamp,
69 NativeHandleImpl(jni, j_oes_texture_id, j_transform_matrix)); 68 NativeHandleImpl(jni, j_oes_texture_id, j_transform_matrix));
70 } 69 }
71 70
72 JOW_OBSERVER_METHOD(void, nativeOnFrameCaptured) 71 JNI_FUNCTION_DECLARATION(void,
73 (JNIEnv* jni, 72 AndroidVideoTrackSourceObserver_nativeOnFrameCaptured,
74 jclass, 73 JNIEnv* jni,
75 jlong j_source, 74 jclass,
76 jint j_width, 75 jlong j_source,
77 jint j_height, 76 jint j_width,
78 jint j_rotation, 77 jint j_height,
79 jlong j_timestamp_ns, 78 jint j_rotation,
80 jobject j_video_frame_buffer) { 79 jlong j_timestamp_ns,
80 jobject j_video_frame_buffer) {
81 webrtc::AndroidVideoTrackSource* source = 81 webrtc::AndroidVideoTrackSource* source =
82 AndroidVideoTrackSourceFromJavaProxy(j_source); 82 AndroidVideoTrackSourceFromJavaProxy(j_source);
83 source->OnFrameCaptured(jni, j_width, j_height, j_timestamp_ns, 83 source->OnFrameCaptured(jni, j_width, j_height, j_timestamp_ns,
84 jintToVideoRotation(j_rotation), 84 jintToVideoRotation(j_rotation),
85 j_video_frame_buffer); 85 j_video_frame_buffer);
86 } 86 }
87 87
88 JOW_OBSERVER_METHOD(void, nativeCapturerStarted) 88 JNI_FUNCTION_DECLARATION(void,
89 (JNIEnv* jni, jclass, jlong j_source, jboolean j_success) { 89 AndroidVideoTrackSourceObserver_nativeCapturerStarted,
90 JNIEnv* jni,
91 jclass,
92 jlong j_source,
93 jboolean j_success) {
90 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStarted"; 94 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStarted";
91 webrtc::AndroidVideoTrackSource* source = 95 webrtc::AndroidVideoTrackSource* source =
92 AndroidVideoTrackSourceFromJavaProxy(j_source); 96 AndroidVideoTrackSourceFromJavaProxy(j_source);
93 source->SetState(j_success 97 source->SetState(j_success
94 ? webrtc::AndroidVideoTrackSource::SourceState::kLive 98 ? webrtc::AndroidVideoTrackSource::SourceState::kLive
95 : webrtc::AndroidVideoTrackSource::SourceState::kEnded); 99 : webrtc::AndroidVideoTrackSource::SourceState::kEnded);
96 } 100 }
97 101
98 JOW_OBSERVER_METHOD(void, nativeCapturerStopped) 102 JNI_FUNCTION_DECLARATION(void,
99 (JNIEnv* jni, jclass, jlong j_source) { 103 AndroidVideoTrackSourceObserver_nativeCapturerStopped,
104 JNIEnv* jni,
105 jclass,
106 jlong j_source) {
100 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStopped"; 107 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStopped";
101 webrtc::AndroidVideoTrackSource* source = 108 webrtc::AndroidVideoTrackSource* source =
102 AndroidVideoTrackSourceFromJavaProxy(j_source); 109 AndroidVideoTrackSourceFromJavaProxy(j_source);
103 source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kEnded); 110 source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kEnded);
104 } 111 }
105 112
106 JOW(void, VideoSource_nativeAdaptOutputFormat) 113 JNI_FUNCTION_DECLARATION(void,
107 (JNIEnv* jni, jclass, jlong j_source, jint j_width, jint j_height, jint j_fps) { 114 VideoSource_nativeAdaptOutputFormat,
115 JNIEnv* jni,
116 jclass,
117 jlong j_source,
118 jint j_width,
119 jint j_height,
120 jint j_fps) {
108 LOG(LS_INFO) << "VideoSource_nativeAdaptOutputFormat"; 121 LOG(LS_INFO) << "VideoSource_nativeAdaptOutputFormat";
109 webrtc::AndroidVideoTrackSource* source = 122 webrtc::AndroidVideoTrackSource* source =
110 AndroidVideoTrackSourceFromJavaProxy(j_source); 123 AndroidVideoTrackSourceFromJavaProxy(j_source);
111 source->OnOutputFormatRequest(j_width, j_height, j_fps); 124 source->OnOutputFormatRequest(j_width, j_height, j_fps);
112 } 125 }
113 126
114 } // namespace webrtc_jni 127 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « webrtc/sdk/android/src/jni/androidmetrics_jni.cc ('k') | webrtc/sdk/android/src/jni/jni_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698