OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include "webrtc/api/android/jni/classreferenceholder.h" |
| 12 #include "webrtc/api/androidvideotracksource.h" |
| 13 #include "webrtc/api/videosourceproxy.h" |
| 14 |
| 15 // Identifiers are over 80 characters long so this is needed to fit them on one |
| 16 // line. |
| 17 #define JOW_OBSERVER_METHOD(rettype, name) \ |
| 18 JOW(rettype, VideoCapturer_00024AndroidVideoTrackSourceObserver_##name) |
| 19 |
| 20 namespace webrtc_jni { |
| 21 |
| 22 static webrtc::AndroidVideoTrackSource* AndroidVideoTrackSourceFromJavaProxy( |
| 23 jlong j_proxy) { |
| 24 auto proxy_source = reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_proxy); |
| 25 return reinterpret_cast<webrtc::AndroidVideoTrackSource*>( |
| 26 proxy_source->internal()); |
| 27 } |
| 28 |
| 29 JOW_OBSERVER_METHOD(void, nativeOnByteBufferFrameCaptured) |
| 30 (JNIEnv* jni, |
| 31 jclass, |
| 32 jlong j_source, |
| 33 jbyteArray j_frame, |
| 34 jint length, |
| 35 jint width, |
| 36 jint height, |
| 37 jint rotation, |
| 38 jlong timestamp) { |
| 39 webrtc::AndroidVideoTrackSource* source = |
| 40 AndroidVideoTrackSourceFromJavaProxy(j_source); |
| 41 jbyte* bytes = jni->GetByteArrayElements(j_frame, nullptr); |
| 42 source->OnByteBufferFrameCaptured(bytes, length, width, height, rotation, |
| 43 timestamp); |
| 44 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); |
| 45 } |
| 46 |
| 47 JOW_OBSERVER_METHOD(void, nativeOnTextureFrameCaptured) |
| 48 (JNIEnv* jni, |
| 49 jclass, |
| 50 jlong j_source, |
| 51 jint j_width, |
| 52 jint j_height, |
| 53 jint j_oes_texture_id, |
| 54 jfloatArray j_transform_matrix, |
| 55 jint j_rotation, |
| 56 jlong j_timestamp) { |
| 57 webrtc::AndroidVideoTrackSource* source = |
| 58 AndroidVideoTrackSourceFromJavaProxy(j_source); |
| 59 source->OnTextureFrameCaptured( |
| 60 j_width, j_height, j_rotation, j_timestamp, |
| 61 NativeHandleImpl(jni, j_oes_texture_id, j_transform_matrix)); |
| 62 } |
| 63 |
| 64 JOW_OBSERVER_METHOD(void, nativeCapturerStarted) |
| 65 (JNIEnv* jni, jclass, jlong j_source, jboolean j_success) { |
| 66 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStarted"; |
| 67 webrtc::AndroidVideoTrackSource* source = |
| 68 AndroidVideoTrackSourceFromJavaProxy(j_source); |
| 69 source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kLive); |
| 70 } |
| 71 |
| 72 JOW_OBSERVER_METHOD(void, nativeCapturerStopped) |
| 73 (JNIEnv* jni, jclass, jlong j_source) { |
| 74 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStopped"; |
| 75 webrtc::AndroidVideoTrackSource* source = |
| 76 AndroidVideoTrackSourceFromJavaProxy(j_source); |
| 77 source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kEnded); |
| 78 } |
| 79 |
| 80 JOW_OBSERVER_METHOD(void, nativeOnOutputFormatRequest) |
| 81 (JNIEnv* jni, jclass, jlong j_source, jint j_width, jint j_height, jint j_fps) { |
| 82 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeOnOutputFormatRequest"; |
| 83 webrtc::AndroidVideoTrackSource* source = |
| 84 AndroidVideoTrackSourceFromJavaProxy(j_source); |
| 85 source->OnOutputFormatRequest(j_width, j_height, j_fps); |
| 86 } |
| 87 |
| 88 } // namespace webrtc_jni |
OLD | NEW |