-
Notifications
You must be signed in to change notification settings - Fork 457
/
peer_connection_factory.h
84 lines (59 loc) · 2.2 KB
/
peer_connection_factory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Copyright (c) 2019 The node-webrtc project authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be found
* in the LICENSE.md file in the root of the source tree. All contributing
* project authors may be found in the AUTHORS file in the root of the source
* tree.
*/
#pragma once
#include <memory>
#include <mutex>
#include <node-addon-api/napi.h>
#include <webrtc/api/peer_connection_interface.h>
#include <webrtc/api/scoped_refptr.h>
#include <webrtc/modules/audio_device/include/audio_device.h>
#include "src/functional/maybe.h"
namespace rtc {
class NetworkManager;
class PacketSocketFactory;
class Thread;
} // namespace rtc
namespace webrtc {
class PeerConnectionFactoryInterface;
} // namespace webrtc
namespace node_webrtc {
class PeerConnectionFactory
: public Napi::ObjectWrap<PeerConnectionFactory> {
public:
explicit PeerConnectionFactory(const Napi::CallbackInfo&);
~PeerConnectionFactory();
/**
* Get or create the default PeerConnectionFactory. The default uses
* webrtc::AudioDeviceModule::AudioLayer::kDummyAudio. Call {@link Release} when done.
*/
static PeerConnectionFactory* GetOrCreateDefault();
/**
* Release a reference to the default PeerConnectionFactory.
*/
static void Release();
/**
* Get the underlying webrtc::PeerConnectionFactoryInterface.
*/
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory() { return _factory; }
rtc::NetworkManager* getNetworkManager() { return _networkManager.get(); }
rtc::PacketSocketFactory* getSocketFactory() { return _socketFactory.get(); }
static void Init(Napi::Env, Napi::Object);
static Napi::FunctionReference& constructor();
static void Dispose();
std::unique_ptr<rtc::Thread> _signalingThread;
std::unique_ptr<rtc::Thread> _workerThread;
private:
static PeerConnectionFactory* _default;
static std::mutex _mutex;
static int _references;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> _factory;
rtc::scoped_refptr<webrtc::AudioDeviceModule> _audioDeviceModule;
std::unique_ptr<rtc::NetworkManager> _networkManager;
std::unique_ptr<rtc::PacketSocketFactory> _socketFactory;
};
} // namespace node_webrtc