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

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

Issue 2992103002: Relanding: Break peerconnection_jni.cc into multiple files, in "pc" directory. (Closed)
Patch Set: Add jni/androidnetworkmonitor_jni.h include for backwards comaptibility. 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
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_PEERCONNECTIONOBSERVER_JNI_H_
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_RTCSTATSCOLLECTORCALLBACKWRAPPER_H_ 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONOBSERVER_JNI_H_
13 13
14 #include <jni.h> 14 #include <map>
15 #include <memory>
16 #include <vector>
15 17
16 #include "webrtc/api/peerconnectioninterface.h" 18 #include "webrtc/api/peerconnectioninterface.h"
17 #include "webrtc/sdk/android/src/jni/jni_helpers.h" 19 #include "webrtc/sdk/android/src/jni/jni_helpers.h"
20 #include "webrtc/sdk/android/src/jni/pc/mediaconstraints_jni.h"
18 21
19 namespace webrtc_jni { 22 namespace webrtc_jni {
20 23
21 // Adapter for a Java RTCStatsCollectorCallback presenting a C++ 24 // Adapter between the C++ PeerConnectionObserver interface and the Java
22 // RTCStatsCollectorCallback and dispatching the callback from C++ back to 25 // PeerConnection.Observer interface. Wraps an instance of the Java interface
23 // Java. 26 // and dispatches C++ callbacks to Java.
24 class RTCStatsCollectorCallbackWrapper 27 class PeerConnectionObserverJni : public webrtc::PeerConnectionObserver {
25 : public webrtc::RTCStatsCollectorCallback {
26 public: 28 public:
27 RTCStatsCollectorCallbackWrapper(JNIEnv* jni, jobject j_callback); 29 PeerConnectionObserverJni(JNIEnv* jni, jobject j_observer);
30 virtual ~PeerConnectionObserverJni();
28 31
29 void OnStatsDelivered( 32 // Implementation of PeerConnectionObserver interface, which propagates
30 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) override; 33 // the callbacks to the Java observer.
34 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
35 void OnIceCandidatesRemoved(
36 const std::vector<cricket::Candidate>& candidates) override;
37 void OnSignalingChange(
38 webrtc::PeerConnectionInterface::SignalingState new_state) override;
39 void OnIceConnectionChange(
40 webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
41 void OnIceConnectionReceivingChange(bool receiving) override;
42 void OnIceGatheringChange(
43 webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
44 void OnAddStream(
45 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
46 void OnRemoveStream(
47 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
48 void OnDataChannel(
49 rtc::scoped_refptr<webrtc::DataChannelInterface> channel) override;
50 void OnRenegotiationNeeded() override;
51 void OnAddTrack(
52 rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver,
53 const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&
54 streams) override;
55
56 void SetConstraints(MediaConstraintsJni* constraints);
57 const MediaConstraintsJni* constraints() { return constraints_.get(); }
31 58
32 private: 59 private:
33 // Helper functions for converting C++ RTCStatsReport to Java equivalent. 60 typedef std::map<webrtc::MediaStreamInterface*, jobject>
34 jobject ReportToJava( 61 NativeToJavaStreamsMap;
62 typedef std::map<webrtc::RtpReceiverInterface*, jobject>
63 NativeToJavaRtpReceiverMap;
64
65 void DisposeRemoteStream(const NativeToJavaStreamsMap::iterator& it);
66 void DisposeRtpReceiver(const NativeToJavaRtpReceiverMap::iterator& it);
67
68 // If the NativeToJavaStreamsMap contains the stream, return it.
69 // Otherwise, create a new Java MediaStream.
70 jobject GetOrCreateJavaStream(
71 const rtc::scoped_refptr<webrtc::MediaStreamInterface>& stream);
72
73 // Converts array of streams, creating or re-using Java streams as necessary.
74 jobjectArray NativeToJavaMediaStreamArray(
35 JNIEnv* jni, 75 JNIEnv* jni,
36 const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report); 76 const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&
37 jobject StatsToJava(JNIEnv* jni, const webrtc::RTCStats& stats); 77 streams);
38 jobject MemberToJava(JNIEnv* jni,
39 const webrtc::RTCStatsMemberInterface* member);
40 78
41 const ScopedGlobalRef<jobject> j_callback_global_; 79 const ScopedGlobalRef<jobject> j_observer_global_;
42 const ScopedGlobalRef<jclass> j_callback_class_; 80 const ScopedGlobalRef<jclass> j_observer_class_;
43 const jclass j_stats_report_class_; 81 const ScopedGlobalRef<jclass> j_media_stream_class_;
44 const jmethodID j_stats_report_ctor_; 82 const jmethodID j_media_stream_ctor_;
45 const jclass j_stats_class_; 83 const ScopedGlobalRef<jclass> j_audio_track_class_;
46 const jmethodID j_stats_ctor_; 84 const jmethodID j_audio_track_ctor_;
47 const jclass j_linked_hash_map_class_; 85 const ScopedGlobalRef<jclass> j_video_track_class_;
48 const jmethodID j_linked_hash_map_ctor_; 86 const jmethodID j_video_track_ctor_;
49 const jmethodID j_linked_hash_map_put_; 87 const ScopedGlobalRef<jclass> j_data_channel_class_;
50 const jclass j_boolean_class_; 88 const jmethodID j_data_channel_ctor_;
51 const jmethodID j_boolean_ctor_; 89 const ScopedGlobalRef<jclass> j_rtp_receiver_class_;
52 const jclass j_integer_class_; 90 const jmethodID j_rtp_receiver_ctor_;
53 const jmethodID j_integer_ctor_; 91 // C++ -> Java remote streams. The stored jobects are global refs and must be
54 const jclass j_long_class_; 92 // manually deleted upon removal. Use DisposeRemoteStream().
55 const jmethodID j_long_ctor_; 93 NativeToJavaStreamsMap remote_streams_;
56 const jclass j_big_integer_class_; 94 NativeToJavaRtpReceiverMap rtp_receivers_;
57 const jmethodID j_big_integer_ctor_; 95 std::unique_ptr<MediaConstraintsJni> constraints_;
58 const jclass j_double_class_;
59 const jmethodID j_double_ctor_;
60 const jclass j_string_class_;
61 }; 96 };
62 97
63 } // namespace webrtc_jni 98 } // namespace webrtc_jni
64 99
65 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_RTCSTATSCOLLECTORCALLBACKWRAPPER_H_ 100 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONOBSERVER_JNI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698