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

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

Issue 3009613002: Android: Replace webrtc_jni namespace with nested jni namespace (Closed)
Patch Set: Rebase Created 3 years, 3 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_PC_PEERCONNECTIONOBSERVER_JNI_H_ 11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONOBSERVER_JNI_H_
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONOBSERVER_JNI_H_ 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONOBSERVER_JNI_H_
13 13
14 #include <map> 14 #include <map>
15 #include <memory> 15 #include <memory>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/api/peerconnectioninterface.h" 18 #include "webrtc/api/peerconnectioninterface.h"
19 #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" 20 #include "webrtc/sdk/android/src/jni/pc/mediaconstraints_jni.h"
21 21
22 namespace webrtc_jni { 22 namespace webrtc {
23 namespace jni {
23 24
24 // Adapter between the C++ PeerConnectionObserver interface and the Java 25 // Adapter between the C++ PeerConnectionObserver interface and the Java
25 // PeerConnection.Observer interface. Wraps an instance of the Java interface 26 // PeerConnection.Observer interface. Wraps an instance of the Java interface
26 // and dispatches C++ callbacks to Java. 27 // and dispatches C++ callbacks to Java.
27 class PeerConnectionObserverJni : public webrtc::PeerConnectionObserver { 28 class PeerConnectionObserverJni : public PeerConnectionObserver {
28 public: 29 public:
29 PeerConnectionObserverJni(JNIEnv* jni, jobject j_observer); 30 PeerConnectionObserverJni(JNIEnv* jni, jobject j_observer);
30 virtual ~PeerConnectionObserverJni(); 31 virtual ~PeerConnectionObserverJni();
31 32
32 // Implementation of PeerConnectionObserver interface, which propagates 33 // Implementation of PeerConnectionObserver interface, which propagates
33 // the callbacks to the Java observer. 34 // the callbacks to the Java observer.
34 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; 35 void OnIceCandidate(const IceCandidateInterface* candidate) override;
35 void OnIceCandidatesRemoved( 36 void OnIceCandidatesRemoved(
36 const std::vector<cricket::Candidate>& candidates) override; 37 const std::vector<cricket::Candidate>& candidates) override;
37 void OnSignalingChange( 38 void OnSignalingChange(
38 webrtc::PeerConnectionInterface::SignalingState new_state) override; 39 PeerConnectionInterface::SignalingState new_state) override;
39 void OnIceConnectionChange( 40 void OnIceConnectionChange(
40 webrtc::PeerConnectionInterface::IceConnectionState new_state) override; 41 PeerConnectionInterface::IceConnectionState new_state) override;
41 void OnIceConnectionReceivingChange(bool receiving) override; 42 void OnIceConnectionReceivingChange(bool receiving) override;
42 void OnIceGatheringChange( 43 void OnIceGatheringChange(
43 webrtc::PeerConnectionInterface::IceGatheringState new_state) override; 44 PeerConnectionInterface::IceGatheringState new_state) override;
44 void OnAddStream( 45 void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
45 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override; 46 void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
46 void OnRemoveStream( 47 void OnDataChannel(rtc::scoped_refptr<DataChannelInterface> channel) override;
47 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
48 void OnDataChannel(
49 rtc::scoped_refptr<webrtc::DataChannelInterface> channel) override;
50 void OnRenegotiationNeeded() override; 48 void OnRenegotiationNeeded() override;
51 void OnAddTrack( 49 void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
52 rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver, 50 const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&
53 const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>& 51 streams) override;
54 streams) override;
55 52
56 void SetConstraints(MediaConstraintsJni* constraints); 53 void SetConstraints(MediaConstraintsJni* constraints);
57 const MediaConstraintsJni* constraints() { return constraints_.get(); } 54 const MediaConstraintsJni* constraints() { return constraints_.get(); }
58 55
59 private: 56 private:
60 typedef std::map<webrtc::MediaStreamInterface*, jobject> 57 typedef std::map<MediaStreamInterface*, jobject> NativeToJavaStreamsMap;
61 NativeToJavaStreamsMap; 58 typedef std::map<RtpReceiverInterface*, jobject> NativeToJavaRtpReceiverMap;
62 typedef std::map<webrtc::RtpReceiverInterface*, jobject>
63 NativeToJavaRtpReceiverMap;
64 59
65 void DisposeRemoteStream(const NativeToJavaStreamsMap::iterator& it); 60 void DisposeRemoteStream(const NativeToJavaStreamsMap::iterator& it);
66 void DisposeRtpReceiver(const NativeToJavaRtpReceiverMap::iterator& it); 61 void DisposeRtpReceiver(const NativeToJavaRtpReceiverMap::iterator& it);
67 62
68 // If the NativeToJavaStreamsMap contains the stream, return it. 63 // If the NativeToJavaStreamsMap contains the stream, return it.
69 // Otherwise, create a new Java MediaStream. 64 // Otherwise, create a new Java MediaStream.
70 jobject GetOrCreateJavaStream( 65 jobject GetOrCreateJavaStream(
71 const rtc::scoped_refptr<webrtc::MediaStreamInterface>& stream); 66 const rtc::scoped_refptr<MediaStreamInterface>& stream);
72 67
73 // Converts array of streams, creating or re-using Java streams as necessary. 68 // Converts array of streams, creating or re-using Java streams as necessary.
74 jobjectArray NativeToJavaMediaStreamArray( 69 jobjectArray NativeToJavaMediaStreamArray(
75 JNIEnv* jni, 70 JNIEnv* jni,
76 const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>& 71 const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams);
77 streams);
78 72
79 const ScopedGlobalRef<jobject> j_observer_global_; 73 const ScopedGlobalRef<jobject> j_observer_global_;
80 const ScopedGlobalRef<jclass> j_observer_class_; 74 const ScopedGlobalRef<jclass> j_observer_class_;
81 const ScopedGlobalRef<jclass> j_media_stream_class_; 75 const ScopedGlobalRef<jclass> j_media_stream_class_;
82 const jmethodID j_media_stream_ctor_; 76 const jmethodID j_media_stream_ctor_;
83 const ScopedGlobalRef<jclass> j_audio_track_class_; 77 const ScopedGlobalRef<jclass> j_audio_track_class_;
84 const jmethodID j_audio_track_ctor_; 78 const jmethodID j_audio_track_ctor_;
85 const ScopedGlobalRef<jclass> j_video_track_class_; 79 const ScopedGlobalRef<jclass> j_video_track_class_;
86 const jmethodID j_video_track_ctor_; 80 const jmethodID j_video_track_ctor_;
87 const ScopedGlobalRef<jclass> j_data_channel_class_; 81 const ScopedGlobalRef<jclass> j_data_channel_class_;
88 const jmethodID j_data_channel_ctor_; 82 const jmethodID j_data_channel_ctor_;
89 const ScopedGlobalRef<jclass> j_rtp_receiver_class_; 83 const ScopedGlobalRef<jclass> j_rtp_receiver_class_;
90 const jmethodID j_rtp_receiver_ctor_; 84 const jmethodID j_rtp_receiver_ctor_;
91 // C++ -> Java remote streams. The stored jobects are global refs and must be 85 // C++ -> Java remote streams. The stored jobects are global refs and must be
92 // manually deleted upon removal. Use DisposeRemoteStream(). 86 // manually deleted upon removal. Use DisposeRemoteStream().
93 NativeToJavaStreamsMap remote_streams_; 87 NativeToJavaStreamsMap remote_streams_;
94 NativeToJavaRtpReceiverMap rtp_receivers_; 88 NativeToJavaRtpReceiverMap rtp_receivers_;
95 std::unique_ptr<MediaConstraintsJni> constraints_; 89 std::unique_ptr<MediaConstraintsJni> constraints_;
96 }; 90 };
97 91
98 } // namespace webrtc_jni 92 } // namespace jni
93 } // namespace webrtc
99 94
100 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONOBSERVER_JNI_H_ 95 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONOBSERVER_JNI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698