node-datachannel 0.29.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.
Files changed (33) hide show
  1. package/.clang-format +17 -0
  2. package/CMakeLists.txt +5 -1
  3. package/dist/cjs/polyfill/RTCPeerConnection.cjs +6 -1
  4. package/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -1
  5. package/dist/esm/polyfill/RTCPeerConnection.mjs +6 -1
  6. package/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -1
  7. package/dist/types/polyfill/RTCPeerConnection.d.ts +1 -2
  8. package/package.json +3 -2
  9. package/src/cpp/data-channel-wrapper.cpp +432 -411
  10. package/src/cpp/data-channel-wrapper.h +0 -2
  11. package/src/cpp/ice-udp-mux-listener-wrapper.cpp +104 -97
  12. package/src/cpp/main.cpp +11 -11
  13. package/src/cpp/media-audio-wrapper.cpp +291 -294
  14. package/src/cpp/media-audio-wrapper.h +1 -3
  15. package/src/cpp/media-direction.cpp +32 -32
  16. package/src/cpp/media-direction.h +1 -1
  17. package/src/cpp/media-rtcpreceivingsession-wrapper.cpp +24 -28
  18. package/src/cpp/media-rtcpreceivingsession-wrapper.h +0 -5
  19. package/src/cpp/media-track-wrapper.cpp +350 -339
  20. package/src/cpp/media-track-wrapper.h +0 -3
  21. package/src/cpp/media-video-wrapper.cpp +312 -313
  22. package/src/cpp/media-video-wrapper.h +1 -3
  23. package/src/cpp/peer-connection-wrapper.cpp +1094 -1047
  24. package/src/cpp/peer-connection-wrapper.h +0 -2
  25. package/src/cpp/rtc-wrapper.cpp +142 -138
  26. package/src/cpp/rtc-wrapper.h +8 -10
  27. package/src/cpp/thread-safe-callback.cpp +39 -50
  28. package/src/cpp/thread-safe-callback.h +26 -28
  29. package/src/cpp/web-socket-server-wrapper.cpp +205 -199
  30. package/src/cpp/web-socket-server-wrapper.h +0 -4
  31. package/src/cpp/web-socket-wrapper.cpp +625 -598
  32. package/src/cpp/web-socket-wrapper.h +0 -3
  33. package/src/polyfill/RTCPeerConnection.ts +9 -3
@@ -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
- rtc::Description::Direction dir = rtc::Description::Direction::Unknown;
5
+ rtc::Description::Direction dir = rtc::Description::Direction::Unknown;
6
6
 
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;
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
- return dir;
16
+ return dir;
17
17
  }
18
18
 
19
19
  std::string directionToStr(rtc::Description::Direction dir)
20
20
  {
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;
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,6 +5,6 @@
5
5
  #include <rtc/rtc.hpp>
6
6
 
7
7
  rtc::Description::Direction strToDirection(const std::string dirAsStr);
8
- std::string directionToStr(rtc::Description::Direction dir);
8
+ std::string directionToStr(rtc::Description::Direction dir);
9
9
 
10
10
  #endif // MEDIA_DIRECTION_H
@@ -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
- Napi::HandleScope scope(env);
9
-
10
- Napi::Function func = Napi::ObjectWrap<RtcpReceivingSessionWrapper>::DefineClass(
11
- env,
12
- "RtcpReceivingSession",
13
- {
14
- // Instance Methods
15
- });
16
-
17
- // If this is not the first call, we don't want to reassign the constructor (hot-reload problem)
18
- if(constructor.IsEmpty())
19
- {
20
- constructor = Napi::Persistent(func);
21
- constructor.SuppressDestruct();
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) : Napi::ObjectWrap<RtcpReceivingSessionWrapper>(info)
26
+ RtcpReceivingSessionWrapper::RtcpReceivingSessionWrapper(const Napi::CallbackInfo &info)
27
+ : Napi::ObjectWrap<RtcpReceivingSessionWrapper>(info)
29
28
  {
30
- Napi::Env env = info.Env();
31
- mSessionPtr = std::make_unique<rtc::RtcpReceivingSession>();
32
- instances.insert(this);
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
- mSessionPtr.reset();
38
- instances.erase(this);
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: