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 namespace webrtc_jni { | |
16 | |
17 static webrtc::AndroidVideoTrackSource* AndroidVideoTrackSourceFromJavaProxy( | |
18 jlong j_proxy) { | |
19 auto proxy_source = reinterpret_cast<webrtc::VideoTrackSourceProxy*>(j_proxy); | |
20 return reinterpret_cast<webrtc::AndroidVideoTrackSource*>( | |
21 proxy_source->internal()); | |
22 } | |
23 | |
24 JOW(void, | |
25 VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeOnByteBufferFrameCa ptured) | |
26 (JNIEnv* jni, | |
27 jclass, | |
28 jlong j_source, | |
29 jbyteArray j_frame, | |
30 jint length, | |
31 jint width, | |
32 jint height, | |
33 jint rotation, | |
34 jlong timestamp) { | |
35 auto source = AndroidVideoTrackSourceFromJavaProxy(j_source); | |
magjed_webrtc
2016/07/19 14:42:28
I prefer 'webrtc::AndroidVideoTrackSource*' over a
sakal
2016/07/20 08:06:28
Done.
| |
36 jbyte* bytes = jni->GetByteArrayElements(j_frame, nullptr); | |
37 source->OnByteBufferFrameCaptured(bytes, length, width, height, rotation, | |
38 timestamp); | |
39 jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT); | |
40 } | |
41 | |
42 JOW(void, | |
43 VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeOnTextureFrameCaptu red) | |
44 (JNIEnv* jni, | |
45 jclass, | |
46 jlong j_source, | |
47 jint j_width, | |
48 jint j_height, | |
49 jint j_oes_texture_id, | |
50 jfloatArray j_transform_matrix, | |
51 jint j_rotation, | |
52 jlong j_timestamp) { | |
53 auto source = AndroidVideoTrackSourceFromJavaProxy(j_source); | |
54 source->OnTextureFrameCaptured( | |
55 j_width, j_height, j_rotation, j_timestamp, | |
56 NativeHandleImpl(jni, j_oes_texture_id, j_transform_matrix)); | |
57 } | |
58 | |
59 JOW(void, | |
60 VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeCapturerStarted) | |
61 (JNIEnv* jni, jclass, jlong j_source, jboolean j_success) { | |
62 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStarted"; | |
63 auto source = AndroidVideoTrackSourceFromJavaProxy(j_source); | |
64 source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kLive); | |
65 } | |
66 | |
67 JOW(void, | |
68 VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeCapturerStopped) | |
69 (JNIEnv* jni, jclass, jlong j_source) { | |
70 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeCapturerStopped"; | |
71 auto source = AndroidVideoTrackSourceFromJavaProxy(j_source); | |
72 source->SetState(webrtc::AndroidVideoTrackSource::SourceState::kEnded); | |
73 } | |
74 | |
75 JOW(void, | |
76 VideoCapturer_00024AndroidVideoTrackSourceObserver_nativeOnOutputFormatReque st) | |
77 (JNIEnv* jni, jclass, jlong j_source, jint j_width, jint j_height, jint j_fps) { | |
78 LOG(LS_INFO) << "AndroidVideoTrackSourceObserve_nativeOnOutputFormatRequest"; | |
79 auto source = AndroidVideoTrackSourceFromJavaProxy(j_source); | |
80 source->OnOutputFormatRequest(j_width, j_height, j_fps); | |
81 } | |
82 | |
83 } // namespace webrtc_jni | |
OLD | NEW |