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.
Files changed (59) hide show
  1. package/.clang-format +17 -0
  2. package/.prettierignore +3 -0
  3. package/API.md +30 -0
  4. package/BULDING.md +2 -1
  5. package/CMakeLists.txt +7 -2
  6. package/dist/cjs/lib/index.cjs +4 -1
  7. package/dist/cjs/lib/index.cjs.map +1 -1
  8. package/dist/cjs/polyfill/Events.cjs.map +1 -1
  9. package/dist/cjs/polyfill/RTCDataChannel.cjs +18 -5
  10. package/dist/cjs/polyfill/RTCDataChannel.cjs.map +1 -1
  11. package/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +1 -1
  12. package/dist/cjs/polyfill/RTCPeerConnection.cjs +6 -1
  13. package/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -1
  14. package/dist/cjs/polyfill/RTCSctpTransport.cjs.map +1 -1
  15. package/dist/esm/lib/index.mjs +4 -2
  16. package/dist/esm/lib/index.mjs.map +1 -1
  17. package/dist/esm/polyfill/Events.mjs.map +1 -1
  18. package/dist/esm/polyfill/RTCDataChannel.mjs +18 -5
  19. package/dist/esm/polyfill/RTCDataChannel.mjs.map +1 -1
  20. package/dist/esm/polyfill/RTCDtlsTransport.mjs.map +1 -1
  21. package/dist/esm/polyfill/RTCPeerConnection.mjs +6 -1
  22. package/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -1
  23. package/dist/esm/polyfill/RTCSctpTransport.mjs.map +1 -1
  24. package/dist/types/lib/index.d.ts +14 -3
  25. package/dist/types/lib/types.d.ts +24 -1
  26. package/dist/types/polyfill/RTCPeerConnection.d.ts +1 -2
  27. package/package.json +4 -2
  28. package/src/cpp/data-channel-wrapper.cpp +432 -411
  29. package/src/cpp/data-channel-wrapper.h +0 -2
  30. package/src/cpp/ice-udp-mux-listener-wrapper.cpp +157 -0
  31. package/src/cpp/ice-udp-mux-listener-wrapper.h +43 -0
  32. package/src/cpp/main.cpp +12 -10
  33. package/src/cpp/media-audio-wrapper.cpp +291 -294
  34. package/src/cpp/media-audio-wrapper.h +1 -3
  35. package/src/cpp/media-direction.cpp +32 -32
  36. package/src/cpp/media-direction.h +1 -1
  37. package/src/cpp/media-rtcpreceivingsession-wrapper.cpp +24 -28
  38. package/src/cpp/media-rtcpreceivingsession-wrapper.h +0 -5
  39. package/src/cpp/media-track-wrapper.cpp +350 -339
  40. package/src/cpp/media-track-wrapper.h +0 -3
  41. package/src/cpp/media-video-wrapper.cpp +312 -313
  42. package/src/cpp/media-video-wrapper.h +1 -3
  43. package/src/cpp/peer-connection-wrapper.cpp +1097 -984
  44. package/src/cpp/peer-connection-wrapper.h +1 -2
  45. package/src/cpp/rtc-wrapper.cpp +142 -138
  46. package/src/cpp/rtc-wrapper.h +8 -10
  47. package/src/cpp/thread-safe-callback.cpp +39 -50
  48. package/src/cpp/thread-safe-callback.h +26 -28
  49. package/src/cpp/web-socket-server-wrapper.cpp +205 -199
  50. package/src/cpp/web-socket-server-wrapper.h +0 -4
  51. package/src/cpp/web-socket-wrapper.cpp +625 -598
  52. package/src/cpp/web-socket-wrapper.h +0 -3
  53. package/src/lib/index.ts +14 -1
  54. package/src/lib/types.ts +26 -0
  55. package/src/polyfill/Events.ts +4 -1
  56. package/src/polyfill/RTCDataChannel.ts +24 -5
  57. package/src/polyfill/RTCDtlsTransport.ts +1 -1
  58. package/src/polyfill/RTCPeerConnection.ts +9 -3
  59. 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
- 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: