| 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/androidvideotracksource.h" | |
| 12 #include "webrtc/api/android/jni/classreferenceholder.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(j_success | |
| 70 ? webrtc::AndroidVideoTrackSource::SourceState::kLive | |
| 71 : webrtc::AndroidVideoTrackSource::SourceState::kEnded); | |
| 72 } | |
| 73 | |
| 74 JOW_OBSERVER_METHOD(void, nativeCapturerStopped) | |
| 75 (JNIEnv* jni, jclass, jlong j_source) { | |
| 76 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStopped"; | |
| 77 webrtc::AndroidVideoTrackSource* source = | |
| 78 AndroidVideoTrackSourceFromJavaProxy(j_source); | |
| 79 source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kEnded); | |
| 80 } | |
| 81 | |
| 82 JOW(void, VideoSource_nativeAdaptOutputFormat) | |
| 83 (JNIEnv* jni, jclass, jlong j_source, jint j_width, jint j_height, jint j_fps) { | |
| 84 LOG(LS_INFO) << "VideoSource_nativeAdaptOutputFormat"; | |
| 85 webrtc::AndroidVideoTrackSource* source = | |
| 86 AndroidVideoTrackSourceFromJavaProxy(j_source); | |
| 87 source->OnOutputFormatRequest(j_width, j_height, j_fps); | |
| 88 } | |
| 89 | |
| 90 } // namespace webrtc_jni | |
| OLD | NEW |