OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 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 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_RTCSTATSCOLLECTORCALLBACKWRAPPER_H_ | 11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_PC_JAVA_NATIVE_CONVERSION_H_ |
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_RTCSTATSCOLLECTORCALLBACKWRAPPER_H_ | 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_PC_JAVA_NATIVE_CONVERSION_H_ |
13 | 13 |
14 #include <jni.h> | 14 #include <vector> |
15 | 15 |
| 16 #include "webrtc/api/datachannelinterface.h" |
| 17 #include "webrtc/api/jsep.h" |
| 18 #include "webrtc/api/jsepicecandidate.h" |
| 19 #include "webrtc/api/mediastreaminterface.h" |
| 20 #include "webrtc/api/mediatypes.h" |
16 #include "webrtc/api/peerconnectioninterface.h" | 21 #include "webrtc/api/peerconnectioninterface.h" |
| 22 #include "webrtc/api/rtpparameters.h" |
| 23 #include "webrtc/rtc_base/sslidentity.h" |
17 #include "webrtc/sdk/android/src/jni/jni_helpers.h" | 24 #include "webrtc/sdk/android/src/jni/jni_helpers.h" |
18 | 25 |
| 26 // This file contains helper methods for converting between simple C++ and Java |
| 27 // PeerConnection-related structures. Similar to some methods in jni_helpers.h, |
| 28 // but specifically for structures tied to the PeerConnection API. |
| 29 |
19 namespace webrtc_jni { | 30 namespace webrtc_jni { |
20 | 31 |
21 // Adapter for a Java RTCStatsCollectorCallback presenting a C++ | 32 webrtc::DataChannelInit JavaToNativeDataChannelInit(JNIEnv* jni, |
22 // RTCStatsCollectorCallback and dispatching the callback from C++ back to | 33 jobject j_init); |
23 // Java. | |
24 class RTCStatsCollectorCallbackWrapper | |
25 : public webrtc::RTCStatsCollectorCallback { | |
26 public: | |
27 RTCStatsCollectorCallbackWrapper(JNIEnv* jni, jobject j_callback); | |
28 | 34 |
29 void OnStatsDelivered( | 35 cricket::MediaType JavaToNativeMediaType(JNIEnv* jni, jobject j_media_type); |
30 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) override; | |
31 | 36 |
32 private: | 37 jobject NativeToJavaMediaType(JNIEnv* jni, cricket::MediaType media_type); |
33 // Helper functions for converting C++ RTCStatsReport to Java equivalent. | |
34 jobject ReportToJava( | |
35 JNIEnv* jni, | |
36 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report); | |
37 jobject StatsToJava(JNIEnv* jni, const webrtc::RTCStats& stats); | |
38 jobject MemberToJava(JNIEnv* jni, | |
39 const webrtc::RTCStatsMemberInterface* member); | |
40 | 38 |
41 const ScopedGlobalRef<jobject> j_callback_global_; | 39 cricket::Candidate JavaToNativeCandidate(JNIEnv* jni, jobject j_candidate); |
42 const ScopedGlobalRef<jclass> j_callback_class_; | 40 |
43 const jclass j_stats_report_class_; | 41 jobject NativeToJavaCandidate(JNIEnv* jni, |
44 const jmethodID j_stats_report_ctor_; | 42 jclass* candidate_class, |
45 const jclass j_stats_class_; | 43 const cricket::Candidate& candidate); |
46 const jmethodID j_stats_ctor_; | 44 |
47 const jclass j_linked_hash_map_class_; | 45 jobjectArray NativeToJavaCandidateArray( |
48 const jmethodID j_linked_hash_map_ctor_; | 46 JNIEnv* jni, |
49 const jmethodID j_linked_hash_map_put_; | 47 const std::vector<cricket::Candidate>& candidates); |
50 const jclass j_boolean_class_; | 48 |
51 const jmethodID j_boolean_ctor_; | 49 webrtc::SessionDescriptionInterface* JavaToNativeSessionDescription( |
52 const jclass j_integer_class_; | 50 JNIEnv* jni, |
53 const jmethodID j_integer_ctor_; | 51 jobject j_sdp); |
54 const jclass j_long_class_; | 52 |
55 const jmethodID j_long_ctor_; | 53 jobject NativeToJavaSessionDescription( |
56 const jclass j_big_integer_class_; | 54 JNIEnv* jni, |
57 const jmethodID j_big_integer_ctor_; | 55 const webrtc::SessionDescriptionInterface* desc); |
58 const jclass j_double_class_; | 56 |
59 const jmethodID j_double_ctor_; | 57 webrtc::PeerConnectionFactoryInterface::Options |
60 const jclass j_string_class_; | 58 JavaToNativePeerConnectionFactoryOptions(JNIEnv* jni, jobject options); |
61 }; | 59 |
| 60 /***************************************************** |
| 61 * Below are all things that go into RTCConfiguration. |
| 62 *****************************************************/ |
| 63 webrtc::PeerConnectionInterface::IceTransportsType |
| 64 JavaToNativeIceTransportsType(JNIEnv* jni, jobject j_ice_transports_type); |
| 65 |
| 66 webrtc::PeerConnectionInterface::BundlePolicy JavaToNativeBundlePolicy( |
| 67 JNIEnv* jni, |
| 68 jobject j_bundle_policy); |
| 69 |
| 70 webrtc::PeerConnectionInterface::RtcpMuxPolicy JavaToNativeRtcpMuxPolicy( |
| 71 JNIEnv* jni, |
| 72 jobject j_rtcp_mux_policy); |
| 73 |
| 74 webrtc::PeerConnectionInterface::TcpCandidatePolicy |
| 75 JavaToNativeTcpCandidatePolicy(JNIEnv* jni, jobject j_tcp_candidate_policy); |
| 76 |
| 77 webrtc::PeerConnectionInterface::CandidateNetworkPolicy |
| 78 JavaToNativeCandidateNetworkPolicy(JNIEnv* jni, |
| 79 jobject j_candidate_network_policy); |
| 80 |
| 81 rtc::KeyType JavaToNativeKeyType(JNIEnv* jni, jobject j_key_type); |
| 82 |
| 83 webrtc::PeerConnectionInterface::ContinualGatheringPolicy |
| 84 JavaToNativeContinualGatheringPolicy(JNIEnv* jni, jobject j_gathering_policy); |
| 85 |
| 86 webrtc::PeerConnectionInterface::TlsCertPolicy JavaToNativeTlsCertPolicy( |
| 87 JNIEnv* jni, |
| 88 jobject j_ice_server_tls_cert_policy); |
| 89 |
| 90 void JavaToNativeIceServers( |
| 91 JNIEnv* jni, |
| 92 jobject j_ice_servers, |
| 93 webrtc::PeerConnectionInterface::IceServers* ice_servers); |
| 94 |
| 95 void JavaToNativeRTCConfiguration( |
| 96 JNIEnv* jni, |
| 97 jobject j_rtc_config, |
| 98 webrtc::PeerConnectionInterface::RTCConfiguration* rtc_config); |
| 99 |
| 100 /********************************************************* |
| 101 * RtpParameters, used for RtpSender and RtpReceiver APIs. |
| 102 *********************************************************/ |
| 103 void JavaToNativeRtpParameters(JNIEnv* jni, |
| 104 jobject j_parameters, |
| 105 webrtc::RtpParameters* parameters); |
| 106 |
| 107 jobject NativeToJavaRtpParameters(JNIEnv* jni, |
| 108 const webrtc::RtpParameters& parameters); |
62 | 109 |
63 } // namespace webrtc_jni | 110 } // namespace webrtc_jni |
64 | 111 |
65 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_RTCSTATSCOLLECTORCALLBACKWRAPPER_H_ | 112 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_PC_JAVA_NATIVE_CONVERSION_H_ |
OLD | NEW |