node-datachannel 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.clang-format +17 -0
- package/.prettierignore +3 -0
- package/API.md +30 -0
- package/BULDING.md +2 -1
- package/CMakeLists.txt +7 -2
- package/dist/cjs/lib/index.cjs +4 -1
- package/dist/cjs/lib/index.cjs.map +1 -1
- package/dist/cjs/polyfill/Events.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCDataChannel.cjs +18 -5
- package/dist/cjs/polyfill/RTCDataChannel.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCPeerConnection.cjs +6 -1
- package/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCSctpTransport.cjs.map +1 -1
- package/dist/esm/lib/index.mjs +4 -2
- package/dist/esm/lib/index.mjs.map +1 -1
- package/dist/esm/polyfill/Events.mjs.map +1 -1
- package/dist/esm/polyfill/RTCDataChannel.mjs +18 -5
- package/dist/esm/polyfill/RTCDataChannel.mjs.map +1 -1
- package/dist/esm/polyfill/RTCDtlsTransport.mjs.map +1 -1
- package/dist/esm/polyfill/RTCPeerConnection.mjs +6 -1
- package/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -1
- package/dist/esm/polyfill/RTCSctpTransport.mjs.map +1 -1
- package/dist/types/lib/index.d.ts +14 -3
- package/dist/types/lib/types.d.ts +24 -1
- package/dist/types/polyfill/RTCPeerConnection.d.ts +1 -2
- package/package.json +4 -2
- package/src/cpp/data-channel-wrapper.cpp +432 -411
- package/src/cpp/data-channel-wrapper.h +0 -2
- package/src/cpp/ice-udp-mux-listener-wrapper.cpp +157 -0
- package/src/cpp/ice-udp-mux-listener-wrapper.h +43 -0
- package/src/cpp/main.cpp +12 -10
- package/src/cpp/media-audio-wrapper.cpp +291 -294
- package/src/cpp/media-audio-wrapper.h +1 -3
- package/src/cpp/media-direction.cpp +32 -32
- package/src/cpp/media-direction.h +1 -1
- package/src/cpp/media-rtcpreceivingsession-wrapper.cpp +24 -28
- package/src/cpp/media-rtcpreceivingsession-wrapper.h +0 -5
- package/src/cpp/media-track-wrapper.cpp +350 -339
- package/src/cpp/media-track-wrapper.h +0 -3
- package/src/cpp/media-video-wrapper.cpp +312 -313
- package/src/cpp/media-video-wrapper.h +1 -3
- package/src/cpp/peer-connection-wrapper.cpp +1097 -984
- package/src/cpp/peer-connection-wrapper.h +1 -2
- package/src/cpp/rtc-wrapper.cpp +142 -138
- package/src/cpp/rtc-wrapper.h +8 -10
- package/src/cpp/thread-safe-callback.cpp +39 -50
- package/src/cpp/thread-safe-callback.h +26 -28
- package/src/cpp/web-socket-server-wrapper.cpp +205 -199
- package/src/cpp/web-socket-server-wrapper.h +0 -4
- package/src/cpp/web-socket-wrapper.cpp +625 -598
- package/src/cpp/web-socket-wrapper.h +0 -3
- package/src/lib/index.ts +14 -1
- package/src/lib/types.ts +26 -0
- package/src/polyfill/Events.ts +4 -1
- package/src/polyfill/RTCDataChannel.ts +24 -5
- package/src/polyfill/RTCDtlsTransport.ts +1 -1
- package/src/polyfill/RTCPeerConnection.ts +9 -3
- package/src/polyfill/RTCSctpTransport.ts +2 -2
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
#include <napi.h>
|
|
7
7
|
#include <rtc/rtc.hpp>
|
|
8
8
|
|
|
9
|
-
#include "thread-safe-callback.h"
|
|
10
|
-
|
|
11
9
|
class AudioWrapper : public Napi::ObjectWrap<AudioWrapper>
|
|
12
10
|
{
|
|
13
11
|
public:
|
|
@@ -51,4 +49,4 @@ private:
|
|
|
51
49
|
std::shared_ptr<rtc::Description::Audio> mAudioPtr = nullptr;
|
|
52
50
|
};
|
|
53
51
|
|
|
54
|
-
#endif // MEDIA_AUDIO_WRAPPER_H
|
|
52
|
+
#endif // MEDIA_AUDIO_WRAPPER_H
|
|
@@ -2,42 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
rtc::Description::Direction strToDirection(const std::string dirAsStr)
|
|
4
4
|
{
|
|
5
|
-
|
|
5
|
+
rtc::Description::Direction dir = rtc::Description::Direction::Unknown;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
if (dirAsStr == "SendOnly")
|
|
8
|
+
dir = rtc::Description::Direction::SendOnly;
|
|
9
|
+
if (dirAsStr == "SendRecv")
|
|
10
|
+
dir = rtc::Description::Direction::SendRecv;
|
|
11
|
+
if (dirAsStr == "RecvOnly")
|
|
12
|
+
dir = rtc::Description::Direction::RecvOnly;
|
|
13
|
+
if (dirAsStr == "Inactive")
|
|
14
|
+
dir = rtc::Description::Direction::Inactive;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
return dir;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
std::string directionToStr(rtc::Description::Direction dir)
|
|
20
20
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
std::string dirAsStr;
|
|
22
|
+
switch (dir)
|
|
23
|
+
{
|
|
24
|
+
case rtc::Description::Direction::Unknown:
|
|
25
|
+
dirAsStr = "Unknown";
|
|
26
|
+
break;
|
|
27
|
+
case rtc::Description::Direction::SendOnly:
|
|
28
|
+
dirAsStr = "SendOnly";
|
|
29
|
+
break;
|
|
30
|
+
case rtc::Description::Direction::RecvOnly:
|
|
31
|
+
dirAsStr = "RecvOnly";
|
|
32
|
+
break;
|
|
33
|
+
case rtc::Description::Direction::SendRecv:
|
|
34
|
+
dirAsStr = "SendRecv";
|
|
35
|
+
break;
|
|
36
|
+
case rtc::Description::Direction::Inactive:
|
|
37
|
+
dirAsStr = "Inactive";
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
dirAsStr = "UNKNOWN_DIR_TYPE";
|
|
41
|
+
}
|
|
42
|
+
return dirAsStr;
|
|
43
43
|
}
|
|
@@ -5,40 +5,36 @@ std::unordered_set<RtcpReceivingSessionWrapper *> RtcpReceivingSessionWrapper::i
|
|
|
5
5
|
|
|
6
6
|
Napi::Object RtcpReceivingSessionWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
7
7
|
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.Set("RtcpReceivingSession", func);
|
|
25
|
-
return exports;
|
|
8
|
+
Napi::HandleScope scope(env);
|
|
9
|
+
|
|
10
|
+
Napi::Function func = Napi::ObjectWrap<RtcpReceivingSessionWrapper>::DefineClass(env, "RtcpReceivingSession",
|
|
11
|
+
{
|
|
12
|
+
// Instance Methods
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// If this is not the first call, we don't want to reassign the constructor (hot-reload problem)
|
|
16
|
+
if (constructor.IsEmpty())
|
|
17
|
+
{
|
|
18
|
+
constructor = Napi::Persistent(func);
|
|
19
|
+
constructor.SuppressDestruct();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.Set("RtcpReceivingSession", func);
|
|
23
|
+
return exports;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
RtcpReceivingSessionWrapper::RtcpReceivingSessionWrapper(const Napi::CallbackInfo &info)
|
|
26
|
+
RtcpReceivingSessionWrapper::RtcpReceivingSessionWrapper(const Napi::CallbackInfo &info)
|
|
27
|
+
: Napi::ObjectWrap<RtcpReceivingSessionWrapper>(info)
|
|
29
28
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
Napi::Env env = info.Env();
|
|
30
|
+
mSessionPtr = std::make_unique<rtc::RtcpReceivingSession>();
|
|
31
|
+
instances.insert(this);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
RtcpReceivingSessionWrapper::~RtcpReceivingSessionWrapper()
|
|
36
35
|
{
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
mSessionPtr.reset();
|
|
37
|
+
instances.erase(this);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
std::shared_ptr<rtc::RtcpReceivingSession> RtcpReceivingSessionWrapper::getSessionInstance()
|
|
42
|
-
{
|
|
43
|
-
return mSessionPtr;
|
|
44
|
-
}
|
|
40
|
+
std::shared_ptr<rtc::RtcpReceivingSession> RtcpReceivingSessionWrapper::getSessionInstance() { return mSessionPtr; }
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
#ifndef MEDIA_RTCPRECEIVINGSESSION_WRAPPER_H
|
|
2
2
|
#define MEDIA_RTCPRECEIVINGSESSION_WRAPPER_H
|
|
3
3
|
|
|
4
|
-
#include <iostream>
|
|
5
|
-
#include <string>
|
|
6
|
-
#include <variant>
|
|
7
4
|
#include <memory>
|
|
8
5
|
#include <unordered_set>
|
|
9
6
|
|
|
10
7
|
#include <napi.h>
|
|
11
8
|
#include <rtc/rtc.hpp>
|
|
12
9
|
|
|
13
|
-
#include "thread-safe-callback.h"
|
|
14
|
-
|
|
15
10
|
class RtcpReceivingSessionWrapper : public Napi::ObjectWrap<RtcpReceivingSessionWrapper>
|
|
16
11
|
{
|
|
17
12
|
public:
|