Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.h

Issue 2989323002: Revert of Break peerconnection_jni.cc into multiple files, in "pc" directory. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 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 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_ANDROIDNETWORKMONITOR_JNI_H_
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_ANDROIDNETWORKMONITOR_JNI_H_
13
14 #include "webrtc/rtc_base/networkmonitor.h"
15
16 #include <stdint.h>
17
18 #include <map>
19
20 #include "webrtc/rtc_base/thread_checker.h"
21 #include "webrtc/sdk/android/src/jni/jni_helpers.h"
22
23 namespace webrtc_jni {
24
25 typedef int64_t NetworkHandle;
26
27 // c++ equivalent of java NetworkMonitorAutoDetect.ConnectionType.
28 enum NetworkType {
29 NETWORK_UNKNOWN,
30 NETWORK_ETHERNET,
31 NETWORK_WIFI,
32 NETWORK_4G,
33 NETWORK_3G,
34 NETWORK_2G,
35 NETWORK_UNKNOWN_CELLULAR,
36 NETWORK_BLUETOOTH,
37 NETWORK_NONE
38 };
39
40 // The information is collected from Android OS so that the native code can get
41 // the network type and handle (Android network ID) for each interface.
42 struct NetworkInformation {
43 std::string interface_name;
44 NetworkHandle handle;
45 NetworkType type;
46 std::vector<rtc::IPAddress> ip_addresses;
47
48 std::string ToString() const;
49 };
50
51 class AndroidNetworkMonitor : public rtc::NetworkMonitorBase,
52 public rtc::NetworkBinderInterface {
53 public:
54 AndroidNetworkMonitor();
55
56 // TODO(sakal): Remove once down stream dependencies have been updated.
57 static void SetAndroidContext(JNIEnv* jni, jobject context) {}
58
59 void Start() override;
60 void Stop() override;
61
62 rtc::NetworkBindingResult BindSocketToNetwork(
63 int socket_fd,
64 const rtc::IPAddress& address) override;
65 rtc::AdapterType GetAdapterType(const std::string& if_name) override;
66 void OnNetworkConnected(const NetworkInformation& network_info);
67 void OnNetworkDisconnected(NetworkHandle network_handle);
68 // Always expected to be called on the network thread.
69 void SetNetworkInfos(const std::vector<NetworkInformation>& network_infos);
70
71 private:
72 static jobject application_context_;
73 static int android_sdk_int_;
74 JNIEnv* jni() { return AttachCurrentThreadIfNeeded(); }
75
76 void OnNetworkConnected_w(const NetworkInformation& network_info);
77 void OnNetworkDisconnected_w(NetworkHandle network_handle);
78
79 ScopedGlobalRef<jclass> j_network_monitor_class_;
80 ScopedGlobalRef<jobject> j_network_monitor_;
81 rtc::ThreadChecker thread_checker_;
82 bool started_ = false;
83 std::map<std::string, rtc::AdapterType> adapter_type_by_name_;
84 std::map<rtc::IPAddress, NetworkHandle> network_handle_by_address_;
85 std::map<NetworkHandle, NetworkInformation> network_info_by_handle_;
86 };
87
88 class AndroidNetworkMonitorFactory : public rtc::NetworkMonitorFactory {
89 public:
90 AndroidNetworkMonitorFactory() {}
91
92 rtc::NetworkMonitorInterface* CreateNetworkMonitor() override;
93 };
94
95 } // namespace webrtc_jni
96
97 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_ANDROIDNETWORKMONITOR_JNI_H_
OLDNEW
« no previous file with comments | « webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc ('k') | webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698