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

Side by Side Diff: webrtc/sdk/android/src/jni/ownedfactoryandthreads.cc

Issue 2854123003: Build WebRTC with data channel only. (Closed)
Patch Set: Fix the issue on the trybots. Created 3 years, 6 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 2017 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 #include "webrtc/sdk/android/src/jni/ownedfactoryandthreads.h"
12
13 #include "webrtc/sdk/android/src/jni/classreferenceholder.h"
14 #include "webrtc/sdk/android/src/jni/jni_helpers.h"
15
16 namespace webrtc_jni {
17
18 PeerConnectionFactoryInterface* factoryFromJava(jlong j_p) {
19 return reinterpret_cast<OwnedFactoryAndThreads*>(j_p)->factory();
20 }
21
22 OwnedFactoryAndThreads::~OwnedFactoryAndThreads() {
23 CHECK_RELEASE(factory_);
24 if (network_monitor_factory_ != nullptr) {
25 rtc::NetworkMonitorFactory::ReleaseFactory(network_monitor_factory_);
26 }
27 }
28
29 void OwnedFactoryAndThreads::JavaCallbackOnFactoryThreads() {
30 JNIEnv* jni = AttachCurrentThreadIfNeeded();
31 ScopedLocalRefFrame local_ref_frame(jni);
32 jclass j_factory_class = FindClass(jni, "org/webrtc/PeerConnectionFactory");
33 jmethodID m = nullptr;
34 if (network_thread_->IsCurrent()) {
35 LOG(LS_INFO) << "Network thread JavaCallback";
36 m = GetStaticMethodID(jni, j_factory_class, "onNetworkThreadReady", "()V");
37 }
38 if (worker_thread_->IsCurrent()) {
39 LOG(LS_INFO) << "Worker thread JavaCallback";
40 m = GetStaticMethodID(jni, j_factory_class, "onWorkerThreadReady", "()V");
41 }
42 if (signaling_thread_->IsCurrent()) {
43 LOG(LS_INFO) << "Signaling thread JavaCallback";
44 m = GetStaticMethodID(jni, j_factory_class, "onSignalingThreadReady",
45 "()V");
46 }
47 if (m != nullptr) {
48 jni->CallStaticVoidMethod(j_factory_class, m);
49 CHECK_EXCEPTION(jni) << "error during JavaCallback::CallStaticVoidMethod";
50 }
51 }
52
53 void OwnedFactoryAndThreads::InvokeJavaCallbacksOnFactoryThreads() {
54 LOG(LS_INFO) << "InvokeJavaCallbacksOnFactoryThreads.";
55 network_thread_->Invoke<void>(RTC_FROM_HERE,
56 [this] { JavaCallbackOnFactoryThreads(); });
57 worker_thread_->Invoke<void>(RTC_FROM_HERE,
58 [this] { JavaCallbackOnFactoryThreads(); });
59 signaling_thread_->Invoke<void>(RTC_FROM_HERE,
60 [this] { JavaCallbackOnFactoryThreads(); });
61 }
62
63 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698