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

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

Issue 2854123003: Build WebRTC with data channel only. (Closed)
Patch Set: Replace the rtc_ prefix with webrtc_ to avoid naming conflict. 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 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_OWNEDFACTORYANDTHREADS_H_
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_OWNEDFACTORYANDTHREADS_H_
13
14 #include <jni.h>
15 #include <memory>
16 #include <utility>
17
18 #include "webrtc/api/peerconnectioninterface.h"
19 #include "webrtc/base/bind.h"
20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/logging.h"
22 #include "webrtc/base/thread.h"
23 #include "webrtc/base/thread_checker.h"
24
25 using cricket::WebRtcVideoDecoderFactory;
26 using cricket::WebRtcVideoEncoderFactory;
27 using rtc::Bind;
28 using rtc::Thread;
29 using webrtc::PeerConnectionFactoryInterface;
30 using webrtc::PeerConnectionInterface;
31
32 namespace webrtc_jni {
33
34 PeerConnectionFactoryInterface* factoryFromJava(jlong j_p);
35
36 // Helper struct for working around the fact that CreatePeerConnectionFactory()
37 // comes in two flavors: either entirely automagical (constructing its own
38 // threads and deleting them on teardown, but no external codec factory support)
39 // or entirely manual (requires caller to delete threads after factory
40 // teardown). This struct takes ownership of its ctor's arguments to present a
41 // single thing for Java to hold and eventually free.
42 class OwnedFactoryAndThreads {
43 public:
44 OwnedFactoryAndThreads(std::unique_ptr<Thread> network_thread,
45 std::unique_ptr<Thread> worker_thread,
46 std::unique_ptr<Thread> signaling_thread,
47 WebRtcVideoEncoderFactory* encoder_factory,
48 WebRtcVideoDecoderFactory* decoder_factory,
49 rtc::NetworkMonitorFactory* network_monitor_factory,
50 PeerConnectionFactoryInterface* factory)
51 : network_thread_(std::move(network_thread)),
52 worker_thread_(std::move(worker_thread)),
53 signaling_thread_(std::move(signaling_thread)),
54 encoder_factory_(encoder_factory),
55 decoder_factory_(decoder_factory),
56 network_monitor_factory_(network_monitor_factory),
57 factory_(factory) {}
58
59 ~OwnedFactoryAndThreads();
60
61 PeerConnectionFactoryInterface* factory() { return factory_; }
62 Thread* signaling_thread() { return signaling_thread_.get(); }
63 Thread* worker_thread() { return worker_thread_.get(); }
64 WebRtcVideoEncoderFactory* encoder_factory() { return encoder_factory_; }
65 WebRtcVideoDecoderFactory* decoder_factory() { return decoder_factory_; }
66 rtc::NetworkMonitorFactory* network_monitor_factory() {
67 return network_monitor_factory_;
68 }
69 void clear_network_monitor_factory() { network_monitor_factory_ = nullptr; }
70 void InvokeJavaCallbacksOnFactoryThreads();
71
72 private:
73 void JavaCallbackOnFactoryThreads();
74
75 const std::unique_ptr<Thread> network_thread_;
76 const std::unique_ptr<Thread> worker_thread_;
77 const std::unique_ptr<Thread> signaling_thread_;
78 WebRtcVideoEncoderFactory* encoder_factory_;
79 WebRtcVideoDecoderFactory* decoder_factory_;
80 rtc::NetworkMonitorFactory* network_monitor_factory_;
81 PeerConnectionFactoryInterface* factory_; // Const after ctor except dtor.
82 };
83
84 } // namespace webrtc_jni
85
86 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_OWNEDFACTORYANDTHREADS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698