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

Side by Side Diff: webrtc/sdk/android/src/jni/pc/sdpobserver_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_SDPOBSERVER_JNI_H_ 11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_PC_SDPOBSERVER_JNI_H_
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_PC_SDPOBSERVER_JNI_H_ 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_PC_SDPOBSERVER_JNI_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 16
17 #include "webrtc/api/peerconnectioninterface.h" 17 #include "webrtc/api/peerconnectioninterface.h"
18 #include "webrtc/sdk/android/src/jni/jni_helpers.h" 18 #include "webrtc/sdk/android/src/jni/jni_helpers.h"
19 #include "webrtc/sdk/android/src/jni/pc/mediaconstraints_jni.h" 19 #include "webrtc/sdk/android/src/jni/pc/mediaconstraints_jni.h"
20 20
21 namespace webrtc_jni { 21 namespace webrtc {
22 namespace jni {
22 23
23 // Adapter for a Java StatsObserver presenting a C++ 24 // Adapter for a Java StatsObserver presenting a C++
24 // CreateSessionDescriptionObserver or SetSessionDescriptionObserver and 25 // CreateSessionDescriptionObserver or SetSessionDescriptionObserver and
25 // dispatching the callback from C++ back to Java. 26 // dispatching the callback from C++ back to Java.
26 template <class T> // T is one of {Create,Set}SessionDescriptionObserver. 27 template <class T> // T is one of {Create,Set}SessionDescriptionObserver.
27 class SdpObserverJni : public T { 28 class SdpObserverJni : public T {
28 public: 29 public:
29 SdpObserverJni(JNIEnv* jni, 30 SdpObserverJni(JNIEnv* jni,
30 jobject j_observer, 31 jobject j_observer,
31 MediaConstraintsJni* constraints) 32 MediaConstraintsJni* constraints)
32 : constraints_(constraints), 33 : constraints_(constraints),
33 j_observer_global_(jni, j_observer), 34 j_observer_global_(jni, j_observer),
34 j_observer_class_(jni, GetObjectClass(jni, j_observer)) {} 35 j_observer_class_(jni, GetObjectClass(jni, j_observer)) {}
35 36
36 virtual ~SdpObserverJni() {} 37 virtual ~SdpObserverJni() {}
37 38
38 // Can't mark override because of templating. 39 // Can't mark override because of templating.
39 virtual void OnSuccess() { 40 virtual void OnSuccess() {
40 ScopedLocalRefFrame local_ref_frame(jni()); 41 ScopedLocalRefFrame local_ref_frame(jni());
41 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onSetSuccess", "()V"); 42 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onSetSuccess", "()V");
42 jni()->CallVoidMethod(*j_observer_global_, m); 43 jni()->CallVoidMethod(*j_observer_global_, m);
43 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; 44 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
44 } 45 }
45 46
46 // Can't mark override because of templating. 47 // Can't mark override because of templating.
47 virtual void OnSuccess(webrtc::SessionDescriptionInterface* desc) { 48 virtual void OnSuccess(SessionDescriptionInterface* desc) {
48 ScopedLocalRefFrame local_ref_frame(jni()); 49 ScopedLocalRefFrame local_ref_frame(jni());
49 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onCreateSuccess", 50 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onCreateSuccess",
50 "(Lorg/webrtc/SessionDescription;)V"); 51 "(Lorg/webrtc/SessionDescription;)V");
51 jobject j_sdp = NativeToJavaSessionDescription(jni(), desc); 52 jobject j_sdp = NativeToJavaSessionDescription(jni(), desc);
52 jni()->CallVoidMethod(*j_observer_global_, m, j_sdp); 53 jni()->CallVoidMethod(*j_observer_global_, m, j_sdp);
53 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; 54 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
54 // OnSuccess transfers ownership of the description (there's a TODO to make 55 // OnSuccess transfers ownership of the description (there's a TODO to make
55 // it use unique_ptr...). 56 // it use unique_ptr...).
56 delete desc; 57 delete desc;
57 } 58 }
(...skipping 11 matching lines...) Expand all
69 70
70 JNIEnv* jni() { return AttachCurrentThreadIfNeeded(); } 71 JNIEnv* jni() { return AttachCurrentThreadIfNeeded(); }
71 72
72 private: 73 private:
73 std::unique_ptr<MediaConstraintsJni> constraints_; 74 std::unique_ptr<MediaConstraintsJni> constraints_;
74 const ScopedGlobalRef<jobject> j_observer_global_; 75 const ScopedGlobalRef<jobject> j_observer_global_;
75 const ScopedGlobalRef<jclass> j_observer_class_; 76 const ScopedGlobalRef<jclass> j_observer_class_;
76 }; 77 };
77 78
78 class CreateSdpObserverJni 79 class CreateSdpObserverJni
79 : public SdpObserverJni<webrtc::CreateSessionDescriptionObserver> { 80 : public SdpObserverJni<CreateSessionDescriptionObserver> {
80 public: 81 public:
81 CreateSdpObserverJni(JNIEnv* jni, 82 CreateSdpObserverJni(JNIEnv* jni,
82 jobject j_observer, 83 jobject j_observer,
83 MediaConstraintsJni* constraints) 84 MediaConstraintsJni* constraints)
84 : SdpObserverJni(jni, j_observer, constraints) {} 85 : SdpObserverJni(jni, j_observer, constraints) {}
85 86
86 void OnFailure(const std::string& error) override { 87 void OnFailure(const std::string& error) override {
87 ScopedLocalRefFrame local_ref_frame(jni()); 88 ScopedLocalRefFrame local_ref_frame(jni());
88 SdpObserverJni::DoOnFailure(std::string("Create"), error); 89 SdpObserverJni::DoOnFailure(std::string("Create"), error);
89 } 90 }
90 }; 91 };
91 92
92 class SetSdpObserverJni 93 class SetSdpObserverJni : public SdpObserverJni<SetSessionDescriptionObserver> {
93 : public SdpObserverJni<webrtc::SetSessionDescriptionObserver> {
94 public: 94 public:
95 SetSdpObserverJni(JNIEnv* jni, 95 SetSdpObserverJni(JNIEnv* jni,
96 jobject j_observer, 96 jobject j_observer,
97 MediaConstraintsJni* constraints) 97 MediaConstraintsJni* constraints)
98 : SdpObserverJni(jni, j_observer, constraints) {} 98 : SdpObserverJni(jni, j_observer, constraints) {}
99 99
100 void OnFailure(const std::string& error) override { 100 void OnFailure(const std::string& error) override {
101 ScopedLocalRefFrame local_ref_frame(jni()); 101 ScopedLocalRefFrame local_ref_frame(jni());
102 SdpObserverJni::DoOnFailure(std::string("Set"), error); 102 SdpObserverJni::DoOnFailure(std::string("Set"), error);
103 } 103 }
104 }; 104 };
105 105
106 } // namespace webrtc_jni 106 } // namespace jni
107 } // namespace webrtc
107 108
108 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_PC_SDPOBSERVER_JNI_H_ 109 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_PC_SDPOBSERVER_JNI_H_
OLDNEW
« no previous file with comments | « webrtc/sdk/android/src/jni/pc/rtpsender_jni.cc ('k') | webrtc/sdk/android/src/jni/pc/statsobserver_jni.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698