node-datachannel 0.4.3 → 0.5.0-dev
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/.github/workflows/build-linux.yml +10 -10
- package/.github/workflows/build-mac-m1.yml +5 -5
- package/.github/workflows/build-mac-x64.yml +5 -5
- package/.github/workflows/build-win.yml +11 -8
- package/.github/workflows/lint.yml +1 -1
- package/.github/workflows/npm-publish-manual.yml +1 -1
- package/{.prettierrc.js → .prettierrc.cjs} +1 -0
- package/BULDING.md +7 -3
- package/CMakeLists.txt +12 -22
- package/README.md +37 -33
- package/cmake/toolchain/arm64.cmake +1 -1
- package/examples/build/Dockerfile +30 -0
- package/examples/build/README.md +24 -0
- package/examples/client-server/README.md +22 -0
- package/examples/client-server/client-benchmark.js +11 -6
- package/examples/client-server/client-periodic.js +5 -6
- package/examples/client-server/client.js +4 -5
- package/examples/client-server/package-lock.json +311 -260
- package/examples/client-server/package.json +15 -14
- package/examples/client-server/signaling-server.js +1 -2
- package/examples/electron-demo/README.md +58 -0
- package/examples/electron-demo/forge.config.js +49 -0
- package/examples/electron-demo/package-lock.json +16287 -0
- package/examples/electron-demo/package.json +43 -0
- package/examples/electron-demo/src/index.css +7 -0
- package/examples/electron-demo/src/index.html +29 -0
- package/examples/electron-demo/src/main.js +53 -0
- package/examples/electron-demo/src/node-datachannel.js +123 -0
- package/examples/electron-demo/src/preload.js +28 -0
- package/examples/electron-demo/src/renderer.js +58 -0
- package/examples/electron-demo/webpack.main.config.js +11 -0
- package/examples/electron-demo/webpack.renderer.config.js +13 -0
- package/examples/electron-demo/webpack.rules.js +35 -0
- package/examples/media/README.md +3 -3
- package/examples/media/media.js +3 -4
- package/examples/simple-peer-usage/main.js +28 -0
- package/examples/simple-peer-usage/package-lock.json +317 -0
- package/examples/simple-peer-usage/package.json +16 -0
- package/lib/datachannel-stream.js +3 -4
- package/lib/index.d.ts +7 -4
- package/lib/index.js +6 -3
- package/node_modules/base64-js/package.json +19 -50
- package/node_modules/buffer/package.json +20 -54
- package/node_modules/chownr/package.json +16 -53
- package/node_modules/decompress-response/package.json +54 -89
- package/node_modules/deep-extend/package.json +32 -65
- package/node_modules/detect-libc/README.md +4 -1
- package/node_modules/detect-libc/index.d.ts +3 -0
- package/node_modules/detect-libc/lib/detect-libc.js +105 -4
- package/node_modules/detect-libc/lib/filesystem.js +41 -0
- package/node_modules/detect-libc/lib/process.js +3 -0
- package/node_modules/detect-libc/package.json +25 -60
- package/node_modules/end-of-stream/package.json +17 -49
- package/node_modules/expand-template/package.json +17 -51
- package/node_modules/fs-constants/package.json +11 -42
- package/node_modules/github-from-package/package.json +28 -60
- package/node_modules/ieee754/package.json +19 -54
- package/node_modules/inherits/package.json +12 -61
- package/node_modules/ini/package.json +19 -55
- package/node_modules/mimic-response/package.json +40 -75
- package/node_modules/minimist/.eslintrc +29 -0
- package/node_modules/minimist/.github/FUNDING.yml +12 -0
- package/node_modules/minimist/.nycrc +14 -0
- package/node_modules/minimist/CHANGELOG.md +298 -0
- package/node_modules/minimist/{readme.markdown → README.md} +34 -11
- package/node_modules/minimist/example/parse.js +2 -0
- package/node_modules/minimist/index.js +256 -242
- package/node_modules/minimist/package.json +73 -77
- package/node_modules/minimist/test/all_bool.js +26 -24
- package/node_modules/minimist/test/bool.js +146 -147
- package/node_modules/minimist/test/dash.js +33 -21
- package/node_modules/minimist/test/default_bool.js +26 -24
- package/node_modules/minimist/test/dotted.js +13 -11
- package/node_modules/minimist/test/kv_short.js +26 -10
- package/node_modules/minimist/test/long.js +28 -26
- package/node_modules/minimist/test/num.js +30 -28
- package/node_modules/minimist/test/parse.js +169 -157
- package/node_modules/minimist/test/parse_modified.js +7 -5
- package/node_modules/minimist/test/proto.js +41 -37
- package/node_modules/minimist/test/short.js +57 -55
- package/node_modules/minimist/test/stop_early.js +10 -8
- package/node_modules/minimist/test/unknown.js +83 -81
- package/node_modules/minimist/test/whitespace.js +6 -4
- package/node_modules/mkdirp-classic/package.json +11 -43
- package/node_modules/napi-build-utils/package.json +26 -57
- package/node_modules/node-abi/README.md +5 -3
- package/node_modules/node-abi/abi_registry.json +98 -8
- package/node_modules/node-abi/package.json +26 -57
- package/node_modules/once/package.json +14 -55
- package/node_modules/prebuild-install/CHANGELOG.md +18 -0
- package/node_modules/prebuild-install/README.md +6 -2
- package/node_modules/prebuild-install/log.js +26 -18
- package/node_modules/prebuild-install/package.json +36 -98
- package/node_modules/prebuild-install/rc.js +5 -1
- package/node_modules/prebuild-install/util.js +1 -1
- package/node_modules/pump/package.json +10 -49
- package/node_modules/rc/node_modules/strip-json-comments/package.json +42 -0
- package/node_modules/rc/package.json +18 -59
- package/node_modules/safe-buffer/index.js +3 -0
- package/node_modules/safe-buffer/package.json +20 -39
- package/node_modules/{node-abi/node_modules/semver → semver}/README.md +70 -1
- package/node_modules/{node-abi/node_modules/semver → semver}/bin/semver.js +16 -2
- package/node_modules/{node-abi/node_modules/semver → semver}/classes/comparator.js +39 -34
- package/node_modules/{node-abi/node_modules/semver → semver}/classes/range.js +48 -28
- package/node_modules/{node-abi/node_modules/semver → semver}/classes/semver.js +32 -17
- package/node_modules/{node-abi/node_modules/semver → semver}/functions/coerce.js +1 -1
- package/node_modules/semver/functions/diff.js +65 -0
- package/node_modules/{node-abi/node_modules/semver → semver}/functions/inc.js +3 -2
- package/node_modules/semver/functions/parse.js +16 -0
- package/node_modules/semver/index.js +89 -0
- package/node_modules/{node-abi/node_modules/semver → semver}/internal/constants.js +20 -2
- package/node_modules/semver/internal/parse-options.js +15 -0
- package/node_modules/{node-abi/node_modules/semver → semver}/internal/re.js +34 -4
- package/node_modules/semver/node_modules/lru-cache/package.json +34 -0
- package/node_modules/semver/node_modules/yallist/package.json +29 -0
- package/node_modules/semver/package.json +87 -0
- package/node_modules/{node-abi/node_modules/semver → semver}/ranges/intersects.js +1 -1
- package/node_modules/{node-abi/node_modules/semver → semver}/ranges/subset.js +6 -3
- package/node_modules/simple-concat/package.json +17 -45
- package/node_modules/simple-get/package.json +17 -45
- package/node_modules/{tar-stream → tar-fs}/node_modules/bl/package.json +20 -51
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/README.md +1 -1
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/_stream_duplex.js +12 -25
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/_stream_passthrough.js +2 -4
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/_stream_readable.js +176 -273
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/_stream_transform.js +26 -37
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/_stream_writable.js +118 -174
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/async_iterator.js +10 -37
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/buffer_list.js +20 -47
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/destroy.js +8 -17
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +1 -19
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/from.js +12 -24
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/pipeline.js +5 -16
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/state.js +2 -7
- package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/package.json +27 -60
- package/node_modules/tar-fs/node_modules/string_decoder/package.json +34 -0
- package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/extract.js +1 -1
- package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/headers.js +4 -2
- package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/package.json +22 -59
- package/node_modules/tar-fs/package.json +21 -51
- package/node_modules/tunnel-agent/package.json +12 -49
- package/node_modules/util-deprecate/package.json +14 -49
- package/node_modules/wrappy/package.json +16 -49
- package/package.json +85 -68
- package/polyfill/Events.d.ts +9 -0
- package/polyfill/Events.js +27 -0
- package/polyfill/README.md +41 -0
- package/polyfill/RTCCertificate.d.ts +7 -0
- package/polyfill/RTCCertificate.js +17 -0
- package/polyfill/RTCDataChannel.d.ts +35 -0
- package/polyfill/RTCDataChannel.js +175 -0
- package/polyfill/RTCDtlsTransport.d.ts +10 -0
- package/polyfill/RTCDtlsTransport.js +29 -0
- package/polyfill/RTCIceCandidate.d.ts +20 -0
- package/polyfill/RTCIceCandidate.js +126 -0
- package/polyfill/RTCIceTransport.d.ts +18 -0
- package/polyfill/RTCIceTransport.js +55 -0
- package/polyfill/RTCPeerConnection.d.ts +50 -0
- package/polyfill/RTCPeerConnection.js +348 -0
- package/polyfill/RTCSctpTransport.d.ts +10 -0
- package/polyfill/RTCSctpTransport.js +34 -0
- package/polyfill/RTCSessionDescription.d.ts +7 -0
- package/polyfill/RTCSessionDescription.js +37 -0
- package/polyfill/index.d.ts +14 -0
- package/polyfill/index.js +14 -0
- package/src/data-channel-wrapper.cpp +47 -6
- package/src/main.cpp +5 -5
- package/src/peer-connection-wrapper.cpp +141 -9
- package/src/peer-connection-wrapper.h +4 -0
- package/src/rtc-wrapper.cpp +14 -9
- package/src/thread-safe-callback.cpp +4 -10
- package/src/thread-safe-callback.h +3 -12
- package/test/connectivity.js +9 -4
- package/test/polyfill-connectivity.js +89 -0
- package/test/test.js +3 -3
- package/test/wpt.js +50 -0
- package/examples/README.md +0 -21
- package/node_modules/ansi-regex/index.js +0 -4
- package/node_modules/ansi-regex/package.json +0 -111
- package/node_modules/ansi-regex/readme.md +0 -39
- package/node_modules/aproba/LICENSE +0 -14
- package/node_modules/aproba/README.md +0 -94
- package/node_modules/aproba/index.js +0 -105
- package/node_modules/aproba/package.json +0 -65
- package/node_modules/code-point-at/index.js +0 -32
- package/node_modules/code-point-at/license +0 -21
- package/node_modules/code-point-at/package.json +0 -73
- package/node_modules/code-point-at/readme.md +0 -32
- package/node_modules/console-control-strings/LICENSE +0 -13
- package/node_modules/console-control-strings/README.md +0 -145
- package/node_modules/console-control-strings/README.md~ +0 -140
- package/node_modules/console-control-strings/index.js +0 -125
- package/node_modules/console-control-strings/package.json +0 -64
- package/node_modules/core-util-is/LICENSE +0 -19
- package/node_modules/core-util-is/README.md +0 -3
- package/node_modules/core-util-is/float.patch +0 -604
- package/node_modules/core-util-is/lib/util.js +0 -107
- package/node_modules/core-util-is/package.json +0 -70
- package/node_modules/core-util-is/test.js +0 -68
- package/node_modules/delegates/.npmignore +0 -1
- package/node_modules/delegates/History.md +0 -22
- package/node_modules/delegates/License +0 -20
- package/node_modules/delegates/Makefile +0 -8
- package/node_modules/delegates/Readme.md +0 -94
- package/node_modules/delegates/index.js +0 -121
- package/node_modules/delegates/package.json +0 -53
- package/node_modules/delegates/test/index.js +0 -94
- package/node_modules/has-unicode/LICENSE +0 -14
- package/node_modules/has-unicode/README.md +0 -43
- package/node_modules/has-unicode/index.js +0 -16
- package/node_modules/has-unicode/package.json +0 -62
- package/node_modules/is-fullwidth-code-point/index.js +0 -46
- package/node_modules/is-fullwidth-code-point/license +0 -21
- package/node_modules/is-fullwidth-code-point/package.json +0 -80
- package/node_modules/is-fullwidth-code-point/readme.md +0 -39
- package/node_modules/isarray/.npmignore +0 -1
- package/node_modules/isarray/.travis.yml +0 -4
- package/node_modules/isarray/Makefile +0 -6
- package/node_modules/isarray/README.md +0 -60
- package/node_modules/isarray/component.json +0 -19
- package/node_modules/isarray/index.js +0 -5
- package/node_modules/isarray/package.json +0 -77
- package/node_modules/isarray/test.js +0 -20
- package/node_modules/lru-cache/node_modules/yallist/package.json +0 -65
- package/node_modules/lru-cache/package.json +0 -73
- package/node_modules/minimist/.travis.yml +0 -8
- package/node_modules/node-abi/.circleci/config.yml +0 -63
- package/node_modules/node-abi/.github/workflows/update-abi.yml +0 -41
- package/node_modules/node-abi/.releaserc.json +0 -9
- package/node_modules/node-abi/CODE_OF_CONDUCT.md +0 -73
- package/node_modules/node-abi/CONTRIBUTING.md +0 -53
- package/node_modules/node-abi/node_modules/semver/functions/diff.js +0 -23
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +0 -33
- package/node_modules/node-abi/node_modules/semver/index.js +0 -48
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +0 -11
- package/node_modules/node-abi/node_modules/semver/package.json +0 -109
- package/node_modules/node-abi/scripts/update-abi-registry.js +0 -119
- package/node_modules/node-abi/test/index.js +0 -166
- package/node_modules/npmlog/CHANGELOG.md +0 -49
- package/node_modules/npmlog/LICENSE +0 -15
- package/node_modules/npmlog/README.md +0 -216
- package/node_modules/npmlog/log.js +0 -309
- package/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md +0 -37
- package/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE +0 -5
- package/node_modules/npmlog/node_modules/are-we-there-yet/README.md +0 -195
- package/node_modules/npmlog/node_modules/are-we-there-yet/index.js +0 -4
- package/node_modules/npmlog/node_modules/are-we-there-yet/package.json +0 -66
- package/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js +0 -11
- package/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js +0 -107
- package/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js +0 -36
- package/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js +0 -30
- package/node_modules/npmlog/node_modules/gauge/CHANGELOG.md +0 -160
- package/node_modules/npmlog/node_modules/gauge/LICENSE +0 -13
- package/node_modules/npmlog/node_modules/gauge/README.md +0 -399
- package/node_modules/npmlog/node_modules/gauge/base-theme.js +0 -14
- package/node_modules/npmlog/node_modules/gauge/error.js +0 -24
- package/node_modules/npmlog/node_modules/gauge/has-color.js +0 -12
- package/node_modules/npmlog/node_modules/gauge/index.js +0 -233
- package/node_modules/npmlog/node_modules/gauge/package.json +0 -94
- package/node_modules/npmlog/node_modules/gauge/plumbing.js +0 -48
- package/node_modules/npmlog/node_modules/gauge/process.js +0 -3
- package/node_modules/npmlog/node_modules/gauge/progress-bar.js +0 -35
- package/node_modules/npmlog/node_modules/gauge/render-template.js +0 -181
- package/node_modules/npmlog/node_modules/gauge/set-immediate.js +0 -7
- package/node_modules/npmlog/node_modules/gauge/set-interval.js +0 -3
- package/node_modules/npmlog/node_modules/gauge/spin.js +0 -5
- package/node_modules/npmlog/node_modules/gauge/template-item.js +0 -73
- package/node_modules/npmlog/node_modules/gauge/theme-set.js +0 -115
- package/node_modules/npmlog/node_modules/gauge/themes.js +0 -54
- package/node_modules/npmlog/node_modules/gauge/wide-truncate.js +0 -25
- package/node_modules/npmlog/package.json +0 -78
- package/node_modules/number-is-nan/index.js +0 -4
- package/node_modules/number-is-nan/license +0 -21
- package/node_modules/number-is-nan/package.json +0 -70
- package/node_modules/number-is-nan/readme.md +0 -28
- package/node_modules/object-assign/index.js +0 -90
- package/node_modules/object-assign/license +0 -21
- package/node_modules/object-assign/package.json +0 -77
- package/node_modules/object-assign/readme.md +0 -61
- package/node_modules/process-nextick-args/index.js +0 -45
- package/node_modules/process-nextick-args/license.md +0 -19
- package/node_modules/process-nextick-args/package.json +0 -53
- package/node_modules/process-nextick-args/readme.md +0 -18
- package/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/readable-stream/README.md +0 -58
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/node_modules/readable-stream/lib/_stream_writable.js +0 -687
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
- package/node_modules/readable-stream/package.json +0 -87
- package/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/readable-stream/readable-browser.js +0 -7
- package/node_modules/readable-stream/readable.js +0 -19
- package/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/set-blocking/CHANGELOG.md +0 -26
- package/node_modules/set-blocking/LICENSE.txt +0 -14
- package/node_modules/set-blocking/README.md +0 -31
- package/node_modules/set-blocking/index.js +0 -7
- package/node_modules/set-blocking/package.json +0 -73
- package/node_modules/signal-exit/CHANGELOG.md +0 -35
- package/node_modules/signal-exit/LICENSE.txt +0 -16
- package/node_modules/signal-exit/README.md +0 -39
- package/node_modules/signal-exit/index.js +0 -163
- package/node_modules/signal-exit/package.json +0 -71
- package/node_modules/signal-exit/signals.js +0 -53
- package/node_modules/string-width/index.js +0 -37
- package/node_modules/string-width/license +0 -21
- package/node_modules/string-width/package.json +0 -95
- package/node_modules/string-width/readme.md +0 -42
- package/node_modules/string_decoder/.travis.yml +0 -50
- package/node_modules/string_decoder/package.json +0 -64
- package/node_modules/strip-ansi/index.js +0 -6
- package/node_modules/strip-ansi/license +0 -21
- package/node_modules/strip-ansi/package.json +0 -107
- package/node_modules/strip-ansi/readme.md +0 -33
- package/node_modules/strip-json-comments/license +0 -21
- package/node_modules/strip-json-comments/package.json +0 -77
- package/node_modules/tar-stream/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/tar-stream/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/tar-stream/node_modules/readable-stream/LICENSE +0 -47
- package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/tar-stream/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/wide-align/LICENSE +0 -14
- package/node_modules/wide-align/README.md +0 -47
- package/node_modules/wide-align/align.js +0 -65
- package/node_modules/wide-align/package.json +0 -69
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/node_modules/{strip-json-comments → rc/node_modules/strip-json-comments}/index.js +0 -0
- /package/node_modules/{ansi-regex → rc/node_modules/strip-json-comments}/license +0 -0
- /package/node_modules/{strip-json-comments → rc/node_modules/strip-json-comments}/readme.md +0 -0
- /package/node_modules/{lru-cache → semver}/LICENSE +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/classes/index.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/clean.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/cmp.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/compare-build.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/compare-loose.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/compare.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/eq.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/gt.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/gte.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/lt.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/lte.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/major.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/minor.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/neq.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/patch.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/prerelease.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/rcompare.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/rsort.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/satisfies.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/sort.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/functions/valid.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/internal/debug.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/internal/identifiers.js +0 -0
- /package/node_modules/{lru-cache/node_modules/yallist → semver/node_modules/lru-cache}/LICENSE +0 -0
- /package/node_modules/{lru-cache → semver/node_modules/lru-cache}/README.md +0 -0
- /package/node_modules/{lru-cache → semver/node_modules/lru-cache}/index.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver/node_modules/yallist}/LICENSE +0 -0
- /package/node_modules/{lru-cache → semver}/node_modules/yallist/README.md +0 -0
- /package/node_modules/{lru-cache → semver}/node_modules/yallist/iterator.js +0 -0
- /package/node_modules/{lru-cache → semver}/node_modules/yallist/yallist.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/preload.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/range.bnf +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/gtr.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/ltr.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/max-satisfying.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/min-satisfying.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/min-version.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/outside.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/simplify.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/to-comparators.js +0 -0
- /package/node_modules/{node-abi/node_modules/semver → semver}/ranges/valid.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/.travis.yml +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/BufferList.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/LICENSE.md +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/README.md +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/bl.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/test/convert.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/test/indexOf.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/test/isBufferList.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/bl/test/test.js +0 -0
- /package/node_modules/{readable-stream → tar-fs/node_modules/readable-stream}/CONTRIBUTING.md +0 -0
- /package/node_modules/{readable-stream → tar-fs/node_modules/readable-stream}/GOVERNANCE.md +0 -0
- /package/node_modules/{readable-stream → tar-fs/node_modules/readable-stream}/LICENSE +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/errors-browser.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/errors.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/experimentalWarning.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/lib/internal/streams/from-browser.js +0 -0
- /package/node_modules/{readable-stream → tar-fs/node_modules/readable-stream}/lib/internal/streams/stream-browser.js +0 -0
- /package/node_modules/{readable-stream → tar-fs/node_modules/readable-stream}/lib/internal/streams/stream.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/readable-browser.js +0 -0
- /package/node_modules/{tar-stream → tar-fs}/node_modules/readable-stream/readable.js +0 -0
- /package/node_modules/{string_decoder → tar-fs/node_modules/string_decoder}/LICENSE +0 -0
- /package/node_modules/{string_decoder → tar-fs/node_modules/string_decoder}/README.md +0 -0
- /package/node_modules/{string_decoder → tar-fs/node_modules/string_decoder}/lib/string_decoder.js +0 -0
- /package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/LICENSE +0 -0
- /package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/README.md +0 -0
- /package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/index.js +0 -0
- /package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/pack.js +0 -0
- /package/node_modules/{tar-stream → tar-fs/node_modules/tar-stream}/sandbox.js +0 -0
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
#include "media-video-wrapper.h"
|
|
5
5
|
#include "media-audio-wrapper.h"
|
|
6
6
|
|
|
7
|
+
#include "plog/Log.h"
|
|
8
|
+
|
|
7
9
|
#include <cctype>
|
|
8
10
|
#include <sstream>
|
|
9
11
|
|
|
@@ -12,6 +14,7 @@ std::unordered_set<PeerConnectionWrapper *> PeerConnectionWrapper::instances;
|
|
|
12
14
|
|
|
13
15
|
void PeerConnectionWrapper::CloseAll()
|
|
14
16
|
{
|
|
17
|
+
PLOG_DEBUG << "CloseAll() called";
|
|
15
18
|
auto copy(instances);
|
|
16
19
|
for (auto inst : copy)
|
|
17
20
|
inst->doClose();
|
|
@@ -19,6 +22,7 @@ void PeerConnectionWrapper::CloseAll()
|
|
|
19
22
|
|
|
20
23
|
void PeerConnectionWrapper::ResetCallbacksAll()
|
|
21
24
|
{
|
|
25
|
+
PLOG_DEBUG << "ResetCallbacksAll() called";
|
|
22
26
|
auto copy(instances);
|
|
23
27
|
for (auto inst : copy)
|
|
24
28
|
inst->doResetCallbacks();
|
|
@@ -37,16 +41,19 @@ Napi::Object PeerConnectionWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
|
37
41
|
InstanceMethod("setLocalDescription", &PeerConnectionWrapper::setLocalDescription),
|
|
38
42
|
InstanceMethod("setRemoteDescription", &PeerConnectionWrapper::setRemoteDescription),
|
|
39
43
|
InstanceMethod("localDescription", &PeerConnectionWrapper::localDescription),
|
|
44
|
+
InstanceMethod("remoteDescription", &PeerConnectionWrapper::remoteDescription),
|
|
40
45
|
InstanceMethod("addRemoteCandidate", &PeerConnectionWrapper::addRemoteCandidate),
|
|
41
46
|
InstanceMethod("createDataChannel", &PeerConnectionWrapper::createDataChannel),
|
|
42
47
|
InstanceMethod("addTrack", &PeerConnectionWrapper::addTrack),
|
|
43
48
|
InstanceMethod("hasMedia", &PeerConnectionWrapper::hasMedia),
|
|
44
49
|
InstanceMethod("state", &PeerConnectionWrapper::state),
|
|
50
|
+
InstanceMethod("iceState", &PeerConnectionWrapper::iceState),
|
|
45
51
|
InstanceMethod("signalingState", &PeerConnectionWrapper::signalingState),
|
|
46
52
|
InstanceMethod("gatheringState", &PeerConnectionWrapper::gatheringState),
|
|
47
53
|
InstanceMethod("onLocalDescription", &PeerConnectionWrapper::onLocalDescription),
|
|
48
54
|
InstanceMethod("onLocalCandidate", &PeerConnectionWrapper::onLocalCandidate),
|
|
49
55
|
InstanceMethod("onStateChange", &PeerConnectionWrapper::onStateChange),
|
|
56
|
+
InstanceMethod("onIceStateChange", &PeerConnectionWrapper::onIceStateChange),
|
|
50
57
|
InstanceMethod("onSignalingStateChange", &PeerConnectionWrapper::onSignalingStateChange),
|
|
51
58
|
InstanceMethod("onGatheringStateChange", &PeerConnectionWrapper::onGatheringStateChange),
|
|
52
59
|
InstanceMethod("onDataChannel", &PeerConnectionWrapper::onDataChannel),
|
|
@@ -66,6 +73,7 @@ Napi::Object PeerConnectionWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
|
66
73
|
|
|
67
74
|
PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : Napi::ObjectWrap<PeerConnectionWrapper>(info)
|
|
68
75
|
{
|
|
76
|
+
PLOG_DEBUG << "Constructor called";
|
|
69
77
|
Napi::Env env = info.Env();
|
|
70
78
|
int length = info.Length();
|
|
71
79
|
|
|
@@ -172,7 +180,7 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
|
|
|
172
180
|
}
|
|
173
181
|
|
|
174
182
|
// bind address, libjuice only
|
|
175
|
-
if(config.Get("bindAddress").IsString())
|
|
183
|
+
if (config.Get("bindAddress").IsString())
|
|
176
184
|
rtcConfig.bindAddress = config.Get("bindAddress").As<Napi::String>().ToString();
|
|
177
185
|
|
|
178
186
|
// Port Ranges
|
|
@@ -228,6 +236,7 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
|
|
|
228
236
|
// Create peer-connection
|
|
229
237
|
try
|
|
230
238
|
{
|
|
239
|
+
PLOG_DEBUG << "Creating a new peer";
|
|
231
240
|
mRtcPeerConnPtr = std::make_unique<rtc::PeerConnection>(rtcConfig);
|
|
232
241
|
}
|
|
233
242
|
catch (std::exception &ex)
|
|
@@ -241,13 +250,16 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
|
|
|
241
250
|
|
|
242
251
|
PeerConnectionWrapper::~PeerConnectionWrapper()
|
|
243
252
|
{
|
|
253
|
+
PLOG_DEBUG << "Destructor called";
|
|
244
254
|
doDestroy();
|
|
245
255
|
}
|
|
246
256
|
|
|
247
257
|
void PeerConnectionWrapper::doClose()
|
|
248
258
|
{
|
|
259
|
+
PLOG_DEBUG << "doClose() called";
|
|
249
260
|
if (mRtcPeerConnPtr)
|
|
250
261
|
{
|
|
262
|
+
PLOG_DEBUG << "Closing...";
|
|
251
263
|
try
|
|
252
264
|
{
|
|
253
265
|
mRtcPeerConnPtr->close();
|
|
@@ -263,20 +275,24 @@ void PeerConnectionWrapper::doClose()
|
|
|
263
275
|
|
|
264
276
|
void PeerConnectionWrapper::close(const Napi::CallbackInfo &info)
|
|
265
277
|
{
|
|
278
|
+
PLOG_DEBUG << "close() called";
|
|
266
279
|
doClose();
|
|
267
280
|
}
|
|
268
281
|
|
|
269
282
|
void PeerConnectionWrapper::doDestroy()
|
|
270
283
|
{
|
|
284
|
+
PLOG_DEBUG << "doDestroy() called";
|
|
271
285
|
doClose();
|
|
272
286
|
doResetCallbacks();
|
|
273
287
|
}
|
|
274
288
|
|
|
275
289
|
void PeerConnectionWrapper::doResetCallbacks()
|
|
276
290
|
{
|
|
291
|
+
PLOG_DEBUG << "doResetCallbacks() called";
|
|
277
292
|
mOnLocalDescriptionCallback.reset();
|
|
278
293
|
mOnLocalCandidateCallback.reset();
|
|
279
294
|
mOnStateChangeCallback.reset();
|
|
295
|
+
mOnSignalingStateChangeCallback.reset();
|
|
280
296
|
mOnGatheringStateChangeCallback.reset();
|
|
281
297
|
mOnDataChannelCallback.reset();
|
|
282
298
|
mOnTrackCallback.reset();
|
|
@@ -286,11 +302,13 @@ void PeerConnectionWrapper::doResetCallbacks()
|
|
|
286
302
|
|
|
287
303
|
void PeerConnectionWrapper::destroy(const Napi::CallbackInfo &info)
|
|
288
304
|
{
|
|
305
|
+
PLOG_DEBUG << "destroy() called";
|
|
289
306
|
doDestroy();
|
|
290
307
|
}
|
|
291
308
|
|
|
292
309
|
void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
|
|
293
310
|
{
|
|
311
|
+
PLOG_DEBUG << "setLocalDescription() called";
|
|
294
312
|
Napi::Env env = info.Env();
|
|
295
313
|
int length = info.Length();
|
|
296
314
|
|
|
@@ -313,7 +331,7 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
|
|
|
313
331
|
std::string typeStr = info[0].As<Napi::String>().ToString();
|
|
314
332
|
|
|
315
333
|
// Accept uppercase first letter for backward compatibility
|
|
316
|
-
if(typeStr.size() > 0)
|
|
334
|
+
if (typeStr.size() > 0)
|
|
317
335
|
typeStr[0] = std::tolower(typeStr[0]);
|
|
318
336
|
|
|
319
337
|
if (typeStr == "answer")
|
|
@@ -331,6 +349,7 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
|
|
|
331
349
|
|
|
332
350
|
void PeerConnectionWrapper::setRemoteDescription(const Napi::CallbackInfo &info)
|
|
333
351
|
{
|
|
352
|
+
PLOG_DEBUG << "setRemoteDescription() called";
|
|
334
353
|
Napi::Env env = info.Env();
|
|
335
354
|
int length = info.Length();
|
|
336
355
|
|
|
@@ -363,12 +382,32 @@ void PeerConnectionWrapper::setRemoteDescription(const Napi::CallbackInfo &info)
|
|
|
363
382
|
|
|
364
383
|
Napi::Value PeerConnectionWrapper::localDescription(const Napi::CallbackInfo &info)
|
|
365
384
|
{
|
|
385
|
+
PLOG_DEBUG << "localDescription() called";
|
|
366
386
|
Napi::Env env = info.Env();
|
|
367
387
|
|
|
368
388
|
std::optional<rtc::Description> desc = mRtcPeerConnPtr ? mRtcPeerConnPtr->localDescription() : std::nullopt;
|
|
369
389
|
|
|
370
390
|
// Return JS null if no description
|
|
371
|
-
if (!desc.has_value())
|
|
391
|
+
if (!desc.has_value())
|
|
392
|
+
{
|
|
393
|
+
return env.Null();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
Napi::Object obj = Napi::Object::New(env);
|
|
397
|
+
obj.Set("type", desc->typeString());
|
|
398
|
+
obj.Set("sdp", desc.value());
|
|
399
|
+
return obj;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
Napi::Value PeerConnectionWrapper::remoteDescription(const Napi::CallbackInfo &info)
|
|
403
|
+
{
|
|
404
|
+
Napi::Env env = info.Env();
|
|
405
|
+
|
|
406
|
+
std::optional<rtc::Description> desc = mRtcPeerConnPtr ? mRtcPeerConnPtr->remoteDescription() : std::nullopt;
|
|
407
|
+
|
|
408
|
+
// Return JS null if no description
|
|
409
|
+
if (!desc.has_value())
|
|
410
|
+
{
|
|
372
411
|
return env.Null();
|
|
373
412
|
}
|
|
374
413
|
|
|
@@ -380,6 +419,7 @@ Napi::Value PeerConnectionWrapper::localDescription(const Napi::CallbackInfo &in
|
|
|
380
419
|
|
|
381
420
|
void PeerConnectionWrapper::addRemoteCandidate(const Napi::CallbackInfo &info)
|
|
382
421
|
{
|
|
422
|
+
PLOG_DEBUG << "addRemoteCandidate() called";
|
|
383
423
|
Napi::Env env = info.Env();
|
|
384
424
|
int length = info.Length();
|
|
385
425
|
|
|
@@ -410,6 +450,7 @@ void PeerConnectionWrapper::addRemoteCandidate(const Napi::CallbackInfo &info)
|
|
|
410
450
|
|
|
411
451
|
Napi::Value PeerConnectionWrapper::createDataChannel(const Napi::CallbackInfo &info)
|
|
412
452
|
{
|
|
453
|
+
PLOG_DEBUG << "createDataChannel() called";
|
|
413
454
|
Napi::Env env = info.Env();
|
|
414
455
|
int length = info.Length();
|
|
415
456
|
|
|
@@ -568,6 +609,7 @@ Napi::Value PeerConnectionWrapper::createDataChannel(const Napi::CallbackInfo &i
|
|
|
568
609
|
std::string label = info[0].As<Napi::String>().ToString();
|
|
569
610
|
std::shared_ptr<rtc::DataChannel> dataChannel = mRtcPeerConnPtr->createDataChannel(label, std::move(init));
|
|
570
611
|
auto instance = DataChannelWrapper::constructor.New({Napi::External<std::shared_ptr<rtc::DataChannel>>::New(info.Env(), &dataChannel)});
|
|
612
|
+
PLOG_DEBUG << "Data Channel created. Label: " << label;
|
|
571
613
|
return instance;
|
|
572
614
|
}
|
|
573
615
|
catch (std::exception &ex)
|
|
@@ -579,6 +621,7 @@ Napi::Value PeerConnectionWrapper::createDataChannel(const Napi::CallbackInfo &i
|
|
|
579
621
|
|
|
580
622
|
void PeerConnectionWrapper::onLocalDescription(const Napi::CallbackInfo &info)
|
|
581
623
|
{
|
|
624
|
+
PLOG_DEBUG << "onLocalDescription() called";
|
|
582
625
|
Napi::Env env = info.Env();
|
|
583
626
|
int length = info.Length();
|
|
584
627
|
|
|
@@ -597,9 +640,12 @@ void PeerConnectionWrapper::onLocalDescription(const Napi::CallbackInfo &info)
|
|
|
597
640
|
// Callback
|
|
598
641
|
mOnLocalDescriptionCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
599
642
|
|
|
600
|
-
mRtcPeerConnPtr->onLocalDescription([&](rtc::Description sdp)
|
|
643
|
+
mRtcPeerConnPtr->onLocalDescription([&](rtc::Description sdp)
|
|
644
|
+
{
|
|
645
|
+
PLOG_DEBUG << "onLocalDescription cb received from rtc";
|
|
601
646
|
if (mOnLocalDescriptionCallback)
|
|
602
647
|
mOnLocalDescriptionCallback->call([this, sdp = std::move(sdp)](Napi::Env env, std::vector<napi_value> &args) {
|
|
648
|
+
PLOG_DEBUG << "mOnLocalDescriptionCallback call(1)";
|
|
603
649
|
// Check the peer connection is not closed
|
|
604
650
|
if(instances.find(this) == instances.end())
|
|
605
651
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -609,11 +655,13 @@ void PeerConnectionWrapper::onLocalDescription(const Napi::CallbackInfo &info)
|
|
|
609
655
|
args = {
|
|
610
656
|
Napi::String::New(env, std::string(sdp)),
|
|
611
657
|
Napi::String::New(env, sdp.typeString())};
|
|
658
|
+
PLOG_DEBUG << "mOnLocalDescriptionCallback call(2)";
|
|
612
659
|
}); });
|
|
613
660
|
}
|
|
614
661
|
|
|
615
662
|
void PeerConnectionWrapper::onLocalCandidate(const Napi::CallbackInfo &info)
|
|
616
663
|
{
|
|
664
|
+
PLOG_DEBUG << "onLocalCandidate() called";
|
|
617
665
|
Napi::Env env = info.Env();
|
|
618
666
|
int length = info.Length();
|
|
619
667
|
|
|
@@ -632,9 +680,12 @@ void PeerConnectionWrapper::onLocalCandidate(const Napi::CallbackInfo &info)
|
|
|
632
680
|
// Callback
|
|
633
681
|
mOnLocalCandidateCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
634
682
|
|
|
635
|
-
mRtcPeerConnPtr->onLocalCandidate([&](rtc::Candidate cand)
|
|
683
|
+
mRtcPeerConnPtr->onLocalCandidate([&](rtc::Candidate cand)
|
|
684
|
+
{
|
|
685
|
+
PLOG_DEBUG << "onLocalCandidate cb received from rtc";
|
|
636
686
|
if (mOnLocalCandidateCallback)
|
|
637
687
|
mOnLocalCandidateCallback->call([this, cand = std::move(cand)](Napi::Env env, std::vector<napi_value> &args) {
|
|
688
|
+
PLOG_DEBUG << "mOnLocalCandidateCallback call(1)";
|
|
638
689
|
// Check the peer connection is not closed
|
|
639
690
|
if(instances.find(this) == instances.end())
|
|
640
691
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -644,11 +695,13 @@ void PeerConnectionWrapper::onLocalCandidate(const Napi::CallbackInfo &info)
|
|
|
644
695
|
args = {
|
|
645
696
|
Napi::String::New(env, std::string(cand)),
|
|
646
697
|
Napi::String::New(env, cand.mid())};
|
|
698
|
+
PLOG_DEBUG << "mOnLocalCandidateCallback call(2)";
|
|
647
699
|
}); });
|
|
648
700
|
}
|
|
649
701
|
|
|
650
702
|
void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
|
|
651
703
|
{
|
|
704
|
+
PLOG_DEBUG << "onStateChange() called";
|
|
652
705
|
Napi::Env env = info.Env();
|
|
653
706
|
int length = info.Length();
|
|
654
707
|
|
|
@@ -667,9 +720,12 @@ void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
|
|
|
667
720
|
// Callback
|
|
668
721
|
mOnStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
669
722
|
|
|
670
|
-
mRtcPeerConnPtr->onStateChange([&](rtc::PeerConnection::State state)
|
|
723
|
+
mRtcPeerConnPtr->onStateChange([&](rtc::PeerConnection::State state)
|
|
724
|
+
{
|
|
725
|
+
PLOG_DEBUG << "onStateChange cb received from rtc";
|
|
671
726
|
if (mOnStateChangeCallback)
|
|
672
727
|
mOnStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
|
|
728
|
+
PLOG_DEBUG << "mOnStateChangeCallback call(1)";
|
|
673
729
|
if(instances.find(this) == instances.end())
|
|
674
730
|
throw ThreadSafeCallback::CancelException();
|
|
675
731
|
|
|
@@ -678,11 +734,52 @@ void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
|
|
|
678
734
|
std::ostringstream stream;
|
|
679
735
|
stream << state;
|
|
680
736
|
args = {Napi::String::New(env, stream.str())};
|
|
737
|
+
PLOG_DEBUG << "mOnStateChangeCallback call(2)";
|
|
738
|
+
}); });
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
void PeerConnectionWrapper::onIceStateChange(const Napi::CallbackInfo &info)
|
|
742
|
+
{
|
|
743
|
+
PLOG_DEBUG << "onIceStateChange() called";
|
|
744
|
+
Napi::Env env = info.Env();
|
|
745
|
+
int length = info.Length();
|
|
746
|
+
|
|
747
|
+
if (!mRtcPeerConnPtr)
|
|
748
|
+
{
|
|
749
|
+
Napi::Error::New(env, "onIceStateChange() called on destroyed peer connection").ThrowAsJavaScriptException();
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (length < 1 || !info[0].IsFunction())
|
|
754
|
+
{
|
|
755
|
+
Napi::TypeError::New(env, "Function expected").ThrowAsJavaScriptException();
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// Callback
|
|
760
|
+
mOnIceStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
761
|
+
|
|
762
|
+
mRtcPeerConnPtr->onIceStateChange([&](rtc::PeerConnection::IceState state)
|
|
763
|
+
{
|
|
764
|
+
PLOG_DEBUG << "onIceStateChange cb received from rtc";
|
|
765
|
+
if (mOnIceStateChangeCallback)
|
|
766
|
+
mOnIceStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
|
|
767
|
+
PLOG_DEBUG << "mOnIceStateChangeCallback call(1)";
|
|
768
|
+
if(instances.find(this) == instances.end())
|
|
769
|
+
throw ThreadSafeCallback::CancelException();
|
|
770
|
+
|
|
771
|
+
// This will run in main thread and needs to construct the
|
|
772
|
+
// arguments for the call
|
|
773
|
+
std::ostringstream stream;
|
|
774
|
+
stream << state;
|
|
775
|
+
args = {Napi::String::New(env, stream.str())};
|
|
776
|
+
PLOG_DEBUG << "mOnIceStateChangeCallback call(2)";
|
|
681
777
|
}); });
|
|
682
778
|
}
|
|
683
779
|
|
|
684
780
|
void PeerConnectionWrapper::onSignalingStateChange(const Napi::CallbackInfo &info)
|
|
685
781
|
{
|
|
782
|
+
PLOG_DEBUG << "onSignalingStateChange() called";
|
|
686
783
|
Napi::Env env = info.Env();
|
|
687
784
|
int length = info.Length();
|
|
688
785
|
|
|
@@ -701,9 +798,12 @@ void PeerConnectionWrapper::onSignalingStateChange(const Napi::CallbackInfo &inf
|
|
|
701
798
|
// Callback
|
|
702
799
|
mOnSignalingStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
703
800
|
|
|
704
|
-
mRtcPeerConnPtr->onSignalingStateChange([&](rtc::PeerConnection::SignalingState state)
|
|
801
|
+
mRtcPeerConnPtr->onSignalingStateChange([&](rtc::PeerConnection::SignalingState state)
|
|
802
|
+
{
|
|
803
|
+
PLOG_DEBUG << "onSignalingStateChange cb received from rtc";
|
|
705
804
|
if (mOnSignalingStateChangeCallback)
|
|
706
805
|
mOnSignalingStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
|
|
806
|
+
PLOG_DEBUG << "mOnSignalingStateChangeCallback call(1)";
|
|
707
807
|
// Check the peer connection is not closed
|
|
708
808
|
if(instances.find(this) == instances.end())
|
|
709
809
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -713,11 +813,13 @@ void PeerConnectionWrapper::onSignalingStateChange(const Napi::CallbackInfo &inf
|
|
|
713
813
|
std::ostringstream stream;
|
|
714
814
|
stream << state;
|
|
715
815
|
args = {Napi::String::New(env, stream.str())};
|
|
816
|
+
PLOG_DEBUG << "mOnSignalingStateChangeCallback call(2)";
|
|
716
817
|
}); });
|
|
717
818
|
}
|
|
718
819
|
|
|
719
820
|
void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &info)
|
|
720
821
|
{
|
|
822
|
+
PLOG_DEBUG << "onGatheringStateChange() called";
|
|
721
823
|
Napi::Env env = info.Env();
|
|
722
824
|
int length = info.Length();
|
|
723
825
|
|
|
@@ -736,9 +838,12 @@ void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &inf
|
|
|
736
838
|
// Callback
|
|
737
839
|
mOnGatheringStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
738
840
|
|
|
739
|
-
mRtcPeerConnPtr->onGatheringStateChange([&](rtc::PeerConnection::GatheringState state)
|
|
841
|
+
mRtcPeerConnPtr->onGatheringStateChange([&](rtc::PeerConnection::GatheringState state)
|
|
842
|
+
{
|
|
843
|
+
PLOG_DEBUG << "onGatheringStateChange cb received from rtc";
|
|
740
844
|
if (mOnGatheringStateChangeCallback)
|
|
741
845
|
mOnGatheringStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
|
|
846
|
+
PLOG_DEBUG << "mOnGatheringStateChangeCallback call(1)";
|
|
742
847
|
// Check the peer connection is not closed
|
|
743
848
|
if(instances.find(this) == instances.end())
|
|
744
849
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -748,11 +853,13 @@ void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &inf
|
|
|
748
853
|
std::ostringstream stream;
|
|
749
854
|
stream << state;
|
|
750
855
|
args = {Napi::String::New(env, stream.str())};
|
|
856
|
+
PLOG_DEBUG << "mOnGatheringStateChangeCallback call(2)";
|
|
751
857
|
}); });
|
|
752
858
|
}
|
|
753
859
|
|
|
754
860
|
void PeerConnectionWrapper::onDataChannel(const Napi::CallbackInfo &info)
|
|
755
861
|
{
|
|
862
|
+
PLOG_DEBUG << "onDataChannel() called";
|
|
756
863
|
Napi::Env env = info.Env();
|
|
757
864
|
int length = info.Length();
|
|
758
865
|
|
|
@@ -773,8 +880,10 @@ void PeerConnectionWrapper::onDataChannel(const Napi::CallbackInfo &info)
|
|
|
773
880
|
|
|
774
881
|
mRtcPeerConnPtr->onDataChannel([&](std::shared_ptr<rtc::DataChannel> dc)
|
|
775
882
|
{
|
|
883
|
+
PLOG_DEBUG << "onDataChannel cb received from rtc";
|
|
776
884
|
if (mOnDataChannelCallback)
|
|
777
885
|
mOnDataChannelCallback->call([this, dc](Napi::Env env, std::vector<napi_value> &args) {
|
|
886
|
+
PLOG_DEBUG << "mOnDataChannelCallback call(1)";
|
|
778
887
|
// Check the peer connection is not closed
|
|
779
888
|
if(instances.find(this) == instances.end())
|
|
780
889
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -784,11 +893,13 @@ void PeerConnectionWrapper::onDataChannel(const Napi::CallbackInfo &info)
|
|
|
784
893
|
std::shared_ptr<rtc::DataChannel> dataChannel = dc;
|
|
785
894
|
auto instance = DataChannelWrapper::constructor.New({Napi::External<std::shared_ptr<rtc::DataChannel>>::New(env, &dataChannel)});
|
|
786
895
|
args = {instance};
|
|
896
|
+
PLOG_DEBUG << "mOnDataChannelCallback call(2)";
|
|
787
897
|
}); });
|
|
788
898
|
}
|
|
789
899
|
|
|
790
900
|
Napi::Value PeerConnectionWrapper::bytesSent(const Napi::CallbackInfo &info)
|
|
791
901
|
{
|
|
902
|
+
PLOG_DEBUG << "bytesSent() called";
|
|
792
903
|
Napi::Env env = info.Env();
|
|
793
904
|
|
|
794
905
|
if (!mRtcPeerConnPtr)
|
|
@@ -809,6 +920,7 @@ Napi::Value PeerConnectionWrapper::bytesSent(const Napi::CallbackInfo &info)
|
|
|
809
920
|
|
|
810
921
|
Napi::Value PeerConnectionWrapper::bytesReceived(const Napi::CallbackInfo &info)
|
|
811
922
|
{
|
|
923
|
+
PLOG_DEBUG << "bytesReceived() called";
|
|
812
924
|
Napi::Env env = info.Env();
|
|
813
925
|
|
|
814
926
|
if (!mRtcPeerConnPtr)
|
|
@@ -829,6 +941,7 @@ Napi::Value PeerConnectionWrapper::bytesReceived(const Napi::CallbackInfo &info)
|
|
|
829
941
|
|
|
830
942
|
Napi::Value PeerConnectionWrapper::rtt(const Napi::CallbackInfo &info)
|
|
831
943
|
{
|
|
944
|
+
PLOG_DEBUG << "rtt() called";
|
|
832
945
|
Napi::Env env = info.Env();
|
|
833
946
|
|
|
834
947
|
if (!mRtcPeerConnPtr)
|
|
@@ -849,6 +962,7 @@ Napi::Value PeerConnectionWrapper::rtt(const Napi::CallbackInfo &info)
|
|
|
849
962
|
|
|
850
963
|
Napi::Value PeerConnectionWrapper::getSelectedCandidatePair(const Napi::CallbackInfo &info)
|
|
851
964
|
{
|
|
965
|
+
PLOG_DEBUG << "getSelectedCandidatePair() called";
|
|
852
966
|
Napi::Env env = info.Env();
|
|
853
967
|
|
|
854
968
|
if (!mRtcPeerConnPtr)
|
|
@@ -890,6 +1004,7 @@ Napi::Value PeerConnectionWrapper::getSelectedCandidatePair(const Napi::Callback
|
|
|
890
1004
|
|
|
891
1005
|
std::string PeerConnectionWrapper::candidateTypeToString(const rtc::Candidate::Type &type)
|
|
892
1006
|
{
|
|
1007
|
+
PLOG_DEBUG << "candidateTypeToString() called";
|
|
893
1008
|
switch (type)
|
|
894
1009
|
{
|
|
895
1010
|
case rtc::Candidate::Type::Host:
|
|
@@ -907,6 +1022,7 @@ std::string PeerConnectionWrapper::candidateTypeToString(const rtc::Candidate::T
|
|
|
907
1022
|
|
|
908
1023
|
std::string PeerConnectionWrapper::candidateTransportTypeToString(const rtc::Candidate::TransportType &transportType)
|
|
909
1024
|
{
|
|
1025
|
+
PLOG_DEBUG << "candidateTransportTypeToString() called";
|
|
910
1026
|
switch (transportType)
|
|
911
1027
|
{
|
|
912
1028
|
case rtc::Candidate::TransportType::Udp:
|
|
@@ -926,6 +1042,7 @@ std::string PeerConnectionWrapper::candidateTransportTypeToString(const rtc::Can
|
|
|
926
1042
|
|
|
927
1043
|
Napi::Value PeerConnectionWrapper::addTrack(const Napi::CallbackInfo &info)
|
|
928
1044
|
{
|
|
1045
|
+
PLOG_DEBUG << "addTrack() called";
|
|
929
1046
|
Napi::Env env = info.Env();
|
|
930
1047
|
int length = info.Length();
|
|
931
1048
|
|
|
@@ -972,6 +1089,7 @@ Napi::Value PeerConnectionWrapper::addTrack(const Napi::CallbackInfo &info)
|
|
|
972
1089
|
|
|
973
1090
|
void PeerConnectionWrapper::onTrack(const Napi::CallbackInfo &info)
|
|
974
1091
|
{
|
|
1092
|
+
PLOG_DEBUG << "onTrack() called";
|
|
975
1093
|
Napi::Env env = info.Env();
|
|
976
1094
|
int length = info.Length();
|
|
977
1095
|
|
|
@@ -990,7 +1108,8 @@ void PeerConnectionWrapper::onTrack(const Napi::CallbackInfo &info)
|
|
|
990
1108
|
// Callback
|
|
991
1109
|
mOnTrackCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
992
1110
|
|
|
993
|
-
mRtcPeerConnPtr->onTrack([&](std::shared_ptr<rtc::Track> track)
|
|
1111
|
+
mRtcPeerConnPtr->onTrack([&](std::shared_ptr<rtc::Track> track)
|
|
1112
|
+
{
|
|
994
1113
|
if (mOnTrackCallback)
|
|
995
1114
|
mOnTrackCallback->call([this, track](Napi::Env env, std::vector<napi_value> &args) {
|
|
996
1115
|
// Check the peer connection is not closed
|
|
@@ -1007,20 +1126,32 @@ void PeerConnectionWrapper::onTrack(const Napi::CallbackInfo &info)
|
|
|
1007
1126
|
|
|
1008
1127
|
Napi::Value PeerConnectionWrapper::hasMedia(const Napi::CallbackInfo &info)
|
|
1009
1128
|
{
|
|
1129
|
+
PLOG_DEBUG << "hasMedia() called";
|
|
1010
1130
|
Napi::Env env = info.Env();
|
|
1011
1131
|
return Napi::Boolean::New(env, mRtcPeerConnPtr ? mRtcPeerConnPtr->hasMedia() : false);
|
|
1012
1132
|
}
|
|
1013
1133
|
|
|
1014
1134
|
Napi::Value PeerConnectionWrapper::state(const Napi::CallbackInfo &info)
|
|
1015
1135
|
{
|
|
1136
|
+
PLOG_DEBUG << "state() called";
|
|
1016
1137
|
Napi::Env env = info.Env();
|
|
1017
1138
|
std::ostringstream stream;
|
|
1018
1139
|
stream << (mRtcPeerConnPtr ? mRtcPeerConnPtr->state() : rtc::PeerConnection::State::Closed);
|
|
1019
1140
|
return Napi::String::New(env, stream.str());
|
|
1020
1141
|
}
|
|
1021
1142
|
|
|
1143
|
+
Napi::Value PeerConnectionWrapper::iceState(const Napi::CallbackInfo &info)
|
|
1144
|
+
{
|
|
1145
|
+
PLOG_DEBUG << "iceState() called";
|
|
1146
|
+
Napi::Env env = info.Env();
|
|
1147
|
+
std::ostringstream stream;
|
|
1148
|
+
stream << (mRtcPeerConnPtr ? mRtcPeerConnPtr->iceState() : rtc::PeerConnection::IceState::Closed);
|
|
1149
|
+
return Napi::String::New(env, stream.str());
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1022
1152
|
Napi::Value PeerConnectionWrapper::signalingState(const Napi::CallbackInfo &info)
|
|
1023
1153
|
{
|
|
1154
|
+
PLOG_DEBUG << "signalingState() called";
|
|
1024
1155
|
Napi::Env env = info.Env();
|
|
1025
1156
|
std::ostringstream stream;
|
|
1026
1157
|
stream << (mRtcPeerConnPtr ? mRtcPeerConnPtr->signalingState() : rtc::PeerConnection::SignalingState::Stable);
|
|
@@ -1029,6 +1160,7 @@ Napi::Value PeerConnectionWrapper::signalingState(const Napi::CallbackInfo &info
|
|
|
1029
1160
|
|
|
1030
1161
|
Napi::Value PeerConnectionWrapper::gatheringState(const Napi::CallbackInfo &info)
|
|
1031
1162
|
{
|
|
1163
|
+
PLOG_DEBUG << "gatheringState() called";
|
|
1032
1164
|
Napi::Env env = info.Env();
|
|
1033
1165
|
std::ostringstream stream;
|
|
1034
1166
|
stream << (mRtcPeerConnPtr ? mRtcPeerConnPtr->gatheringState() : rtc::PeerConnection::GatheringState::Complete);
|
|
@@ -26,11 +26,13 @@ public:
|
|
|
26
26
|
void setLocalDescription(const Napi::CallbackInfo &info);
|
|
27
27
|
void setRemoteDescription(const Napi::CallbackInfo &info);
|
|
28
28
|
Napi::Value localDescription(const Napi::CallbackInfo &info);
|
|
29
|
+
Napi::Value remoteDescription(const Napi::CallbackInfo &info);
|
|
29
30
|
void addRemoteCandidate(const Napi::CallbackInfo &info);
|
|
30
31
|
Napi::Value createDataChannel(const Napi::CallbackInfo &info);
|
|
31
32
|
Napi::Value addTrack(const Napi::CallbackInfo &info);
|
|
32
33
|
Napi::Value hasMedia(const Napi::CallbackInfo &info);
|
|
33
34
|
Napi::Value state(const Napi::CallbackInfo &info);
|
|
35
|
+
Napi::Value iceState(const Napi::CallbackInfo &info);
|
|
34
36
|
Napi::Value signalingState(const Napi::CallbackInfo &info);
|
|
35
37
|
Napi::Value gatheringState(const Napi::CallbackInfo &info);
|
|
36
38
|
|
|
@@ -38,6 +40,7 @@ public:
|
|
|
38
40
|
void onLocalDescription(const Napi::CallbackInfo &info);
|
|
39
41
|
void onLocalCandidate(const Napi::CallbackInfo &info);
|
|
40
42
|
void onStateChange(const Napi::CallbackInfo &info);
|
|
43
|
+
void onIceStateChange(const Napi::CallbackInfo &info);
|
|
41
44
|
void onSignalingStateChange(const Napi::CallbackInfo &info);
|
|
42
45
|
void onGatheringStateChange(const Napi::CallbackInfo &info);
|
|
43
46
|
void onDataChannel(const Napi::CallbackInfo &info);
|
|
@@ -70,6 +73,7 @@ private:
|
|
|
70
73
|
std::unique_ptr<ThreadSafeCallback> mOnLocalDescriptionCallback = nullptr;
|
|
71
74
|
std::unique_ptr<ThreadSafeCallback> mOnLocalCandidateCallback = nullptr;
|
|
72
75
|
std::unique_ptr<ThreadSafeCallback> mOnStateChangeCallback = nullptr;
|
|
76
|
+
std::unique_ptr<ThreadSafeCallback> mOnIceStateChangeCallback = nullptr;
|
|
73
77
|
std::unique_ptr<ThreadSafeCallback> mOnSignalingStateChangeCallback = nullptr;
|
|
74
78
|
std::unique_ptr<ThreadSafeCallback> mOnGatheringStateChangeCallback = nullptr;
|
|
75
79
|
std::unique_ptr<ThreadSafeCallback> mOnDataChannelCallback = nullptr;
|
package/src/rtc-wrapper.cpp
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
#include "data-channel-wrapper.h"
|
|
4
4
|
#include "media-track-wrapper.h"
|
|
5
5
|
|
|
6
|
+
#include "plog/Log.h"
|
|
7
|
+
|
|
6
8
|
#include <chrono>
|
|
7
9
|
#include <future>
|
|
8
10
|
|
|
@@ -20,6 +22,7 @@ Napi::Object RtcWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
|
20
22
|
|
|
21
23
|
void RtcWrapper::preload(const Napi::CallbackInfo &info)
|
|
22
24
|
{
|
|
25
|
+
PLOG_DEBUG << "preload() called";
|
|
23
26
|
Napi::Env env = info.Env();
|
|
24
27
|
try
|
|
25
28
|
{
|
|
@@ -73,7 +76,8 @@ void RtcWrapper::initLogger(const Napi::CallbackInfo &info)
|
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
78
|
logCallback = std::make_unique<ThreadSafeCallback>(info[1].As<Napi::Function>());
|
|
76
|
-
rtc::InitLogger(logLevel, [&](rtc::LogLevel level, std::string message)
|
|
79
|
+
rtc::InitLogger(logLevel, [&](rtc::LogLevel level, std::string message)
|
|
80
|
+
{
|
|
77
81
|
if (logCallback)
|
|
78
82
|
logCallback->call([level, message = std::move(message)](Napi::Env env, std::vector<napi_value> &args) {
|
|
79
83
|
// This will run in main thread and needs to construct the
|
|
@@ -93,10 +97,8 @@ void RtcWrapper::initLogger(const Napi::CallbackInfo &info)
|
|
|
93
97
|
if (level == rtc::LogLevel::Fatal)
|
|
94
98
|
logLevel = "Fatal";
|
|
95
99
|
args = {Napi::String::New(env, logLevel), Napi::String::New(env, message)};
|
|
96
|
-
});
|
|
97
|
-
});
|
|
100
|
+
}); });
|
|
98
101
|
}
|
|
99
|
-
|
|
100
102
|
}
|
|
101
103
|
catch (std::exception &ex)
|
|
102
104
|
{
|
|
@@ -107,6 +109,7 @@ void RtcWrapper::initLogger(const Napi::CallbackInfo &info)
|
|
|
107
109
|
|
|
108
110
|
void RtcWrapper::cleanup(const Napi::CallbackInfo &info)
|
|
109
111
|
{
|
|
112
|
+
PLOG_DEBUG << "cleanup() called";
|
|
110
113
|
Napi::Env env = info.Env();
|
|
111
114
|
try
|
|
112
115
|
{
|
|
@@ -115,14 +118,15 @@ void RtcWrapper::cleanup(const Napi::CallbackInfo &info)
|
|
|
115
118
|
TrackWrapper::CloseAll();
|
|
116
119
|
|
|
117
120
|
const auto timeout = std::chrono::seconds(10);
|
|
118
|
-
if(rtc::Cleanup().wait_for(std::chrono::seconds(timeout)) == std::future_status::timeout)
|
|
121
|
+
if (rtc::Cleanup().wait_for(std::chrono::seconds(timeout)) == std::future_status::timeout)
|
|
119
122
|
throw std::runtime_error("cleanup timeout (possible deadlock)");
|
|
120
|
-
|
|
121
|
-
// Clear Callbacks
|
|
123
|
+
|
|
124
|
+
// Clear Callbacks
|
|
122
125
|
PeerConnectionWrapper::ResetCallbacksAll();
|
|
123
126
|
|
|
124
|
-
if (logCallback)
|
|
125
|
-
|
|
127
|
+
if (logCallback)
|
|
128
|
+
logCallback.reset();
|
|
129
|
+
}
|
|
126
130
|
catch (std::exception &ex)
|
|
127
131
|
{
|
|
128
132
|
Napi::Error::New(env, std::string("libdatachannel error# ") + ex.what()).ThrowAsJavaScriptException();
|
|
@@ -132,6 +136,7 @@ void RtcWrapper::cleanup(const Napi::CallbackInfo &info)
|
|
|
132
136
|
|
|
133
137
|
void RtcWrapper::setSctpSettings(const Napi::CallbackInfo &info)
|
|
134
138
|
{
|
|
139
|
+
PLOG_DEBUG << "setSctpSettings() called";
|
|
135
140
|
Napi::Env env = info.Env();
|
|
136
141
|
int length = info.Length();
|
|
137
142
|
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
#include "thread-safe-callback.h"
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
#include <stdexcept>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
#else
|
|
8
|
-
|
|
9
|
-
const char* ThreadSafeCallback::CancelException::what() const throw()
|
|
5
|
+
const char *ThreadSafeCallback::CancelException::what() const throw()
|
|
10
6
|
{
|
|
11
7
|
return "ThreadSafeCallback cancelled";
|
|
12
8
|
}
|
|
@@ -45,7 +41,8 @@ void ThreadSafeCallback::callbackFunc(Napi::Env env,
|
|
|
45
41
|
Napi::Reference<Napi::Value> *context,
|
|
46
42
|
CallbackData *data)
|
|
47
43
|
{
|
|
48
|
-
if
|
|
44
|
+
// if env is gone this could mean cb fn has changed. See issue#176
|
|
45
|
+
if (!data || !env)
|
|
49
46
|
return;
|
|
50
47
|
|
|
51
48
|
arg_vector_t args;
|
|
@@ -64,6 +61,3 @@ void ThreadSafeCallback::callbackFunc(Napi::Env env,
|
|
|
64
61
|
if (env && callback)
|
|
65
62
|
callback.Call(context->Value(), args);
|
|
66
63
|
}
|
|
67
|
-
|
|
68
|
-
#endif
|
|
69
|
-
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
#ifndef THREAD_SAFE_CALLBACK_H
|
|
2
2
|
#define THREAD_SAFE_CALLBACK_H
|
|
3
3
|
|
|
4
|
-
#ifdef LEGACY_NAPI_THREAD_SAFE_CALLBACK
|
|
5
|
-
|
|
6
|
-
#include "napi-thread-safe-callback.hpp"
|
|
7
|
-
|
|
8
|
-
#else
|
|
9
|
-
|
|
10
4
|
#include <napi.h>
|
|
11
5
|
|
|
12
6
|
#include <vector>
|
|
@@ -24,14 +18,14 @@ public:
|
|
|
24
18
|
ThreadSafeCallback(const ThreadSafeCallback &) = delete;
|
|
25
19
|
ThreadSafeCallback(ThreadSafeCallback &&) = delete;
|
|
26
20
|
|
|
27
|
-
ThreadSafeCallback&
|
|
28
|
-
ThreadSafeCallback&
|
|
21
|
+
ThreadSafeCallback &operator=(const ThreadSafeCallback &) = delete;
|
|
22
|
+
ThreadSafeCallback &operator=(ThreadSafeCallback &&) = delete;
|
|
29
23
|
|
|
30
24
|
void call(arg_func_t argFunc);
|
|
31
25
|
|
|
32
26
|
class CancelException : public std::exception
|
|
33
27
|
{
|
|
34
|
-
const char*
|
|
28
|
+
const char *what() const throw();
|
|
35
29
|
};
|
|
36
30
|
|
|
37
31
|
private:
|
|
@@ -51,7 +45,4 @@ private:
|
|
|
51
45
|
tsfn_t tsfn;
|
|
52
46
|
};
|
|
53
47
|
|
|
54
|
-
#endif // LEGACY_NAPI_THREAD_SAFE_CALLBACK
|
|
55
|
-
|
|
56
48
|
#endif // THREAD_SAFE_CALLBACK_H
|
|
57
|
-
|