Chromium Code Reviews| Index: webrtc/api/android/jni/androidvideotracksource_jni.cc |
| diff --git a/webrtc/api/android/jni/androidvideotracksource_jni.cc b/webrtc/api/android/jni/androidvideotracksource_jni.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2bbae25fcfcd5f7af377a6c279147c67c1eb1c89 |
| --- /dev/null |
| +++ b/webrtc/api/android/jni/androidvideotracksource_jni.cc |
| @@ -0,0 +1,92 @@ |
| +/* |
| + * Copyright (c) 2016 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. |
| + */ |
| + |
| +#include "webrtc/api/android/jni/classreferenceholder.h" |
| +#include "webrtc/api/androidvideotracksource.h" |
| +#include "webrtc/api/videosourceproxy.h" |
| + |
| +namespace webrtc_jni { |
| + |
| +JOW(void, |
| + VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeOnByteBufferFrameCaptured) |
| +(JNIEnv* jni, |
| + jclass, |
| + jlong j_source, |
| + jbyteArray j_frame, |
| + jint length, |
| + jint width, |
| + jint height, |
| + jint rotation, |
| + jlong timestamp) { |
| + auto proxy_source = |
|
magjed_webrtc
2016/07/19 12:57:46
Add a static helper method in this file for conver
sakal
2016/07/19 13:46:23
Done.
|
| + reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_source); |
| + auto source = reinterpret_cast<webrtc::AndroidVideoTrackSource*>( |
| + proxy_source->internal()); |
| + jboolean is_copy = true; |
| + jbyte* bytes = jni->GetByteArrayElements(j_frame, &is_copy); |
|
magjed_webrtc
2016/07/19 12:57:46
Remove is_copy and pass nullptr instead.
sakal
2016/07/19 13:46:23
Done.
|
| + source->OnByteBufferFrameCaptured(bytes, length, width, height, rotation, |
| + timestamp); |
| + jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); |
| +} |
| + |
| +JOW(void, |
| + VideoCapturer_00024AndroidVideoTrackSourceObserver_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) { |
| + auto proxy_source = |
| + reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_source); |
| + auto source = reinterpret_cast<webrtc::AndroidVideoTrackSource*>( |
| + proxy_source->internal()); |
| + source->OnTextureFrameCaptured( |
| + j_width, j_height, j_rotation, j_timestamp, |
| + NativeHandleImpl(jni, j_oes_texture_id, j_transform_matrix)); |
| +} |
| + |
| +JOW(void, |
| + VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeCapturerStarted) |
| +(JNIEnv* jni, jclass, jlong j_source, jboolean j_success) { |
| + LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStarted"; |
| + auto proxy_source = |
| + reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_source); |
| + auto source = reinterpret_cast<webrtc::AndroidVideoTrackSource*>( |
| + proxy_source->internal()); |
| + source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kLive); |
| +} |
| + |
| +JOW(void, |
| + VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeCapturerStopped) |
| +(JNIEnv* jni, jclass, jlong j_source) { |
| + LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStopped"; |
| + auto proxy_source = |
| + reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_source); |
| + auto source = reinterpret_cast<webrtc::AndroidVideoTrackSource*>( |
| + proxy_source->internal()); |
| + source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kEnded); |
| +} |
| + |
| +JOW(void, |
| + VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeOnOutputFormatRequest) |
| +(JNIEnv* jni, jclass, jlong j_source, jint j_width, jint j_height, jint j_fps) { |
| + LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeOnOutputFormatRequest"; |
| + auto proxy_source = |
| + reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_source); |
| + auto source = reinterpret_cast<webrtc::AndroidVideoTrackSource*>( |
| + proxy_source->internal()); |
| + source->OnOutputFormatRequest(j_width, j_height, j_fps); |
| +} |
| + |
| +} // namespace webrtc_jni |