node-datachannel 0.4.2 → 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 +29 -29
- 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 +38 -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 +8 -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 +145 -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/.github/workflows/build-linux-arm64-test.yml +0 -36
- 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
|
|
@@ -193,6 +201,10 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
|
|
|
193
201
|
if (config.Get("disableAutoNegotiation").IsBoolean())
|
|
194
202
|
rtcConfig.disableAutoNegotiation = config.Get("disableAutoNegotiation").As<Napi::Boolean>();
|
|
195
203
|
|
|
204
|
+
// forceMediaTransport option
|
|
205
|
+
if (config.Get("forceMediaTransport").IsBoolean())
|
|
206
|
+
rtcConfig.forceMediaTransport = config.Get("forceMediaTransport").As<Napi::Boolean>();
|
|
207
|
+
|
|
196
208
|
// Max Message Size
|
|
197
209
|
if (config.Get("maxMessageSize").IsNumber())
|
|
198
210
|
rtcConfig.maxMessageSize = config.Get("maxMessageSize").As<Napi::Number>().Int32Value();
|
|
@@ -224,6 +236,7 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
|
|
|
224
236
|
// Create peer-connection
|
|
225
237
|
try
|
|
226
238
|
{
|
|
239
|
+
PLOG_DEBUG << "Creating a new peer";
|
|
227
240
|
mRtcPeerConnPtr = std::make_unique<rtc::PeerConnection>(rtcConfig);
|
|
228
241
|
}
|
|
229
242
|
catch (std::exception &ex)
|
|
@@ -237,13 +250,16 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
|
|
|
237
250
|
|
|
238
251
|
PeerConnectionWrapper::~PeerConnectionWrapper()
|
|
239
252
|
{
|
|
253
|
+
PLOG_DEBUG << "Destructor called";
|
|
240
254
|
doDestroy();
|
|
241
255
|
}
|
|
242
256
|
|
|
243
257
|
void PeerConnectionWrapper::doClose()
|
|
244
258
|
{
|
|
259
|
+
PLOG_DEBUG << "doClose() called";
|
|
245
260
|
if (mRtcPeerConnPtr)
|
|
246
261
|
{
|
|
262
|
+
PLOG_DEBUG << "Closing...";
|
|
247
263
|
try
|
|
248
264
|
{
|
|
249
265
|
mRtcPeerConnPtr->close();
|
|
@@ -259,20 +275,24 @@ void PeerConnectionWrapper::doClose()
|
|
|
259
275
|
|
|
260
276
|
void PeerConnectionWrapper::close(const Napi::CallbackInfo &info)
|
|
261
277
|
{
|
|
278
|
+
PLOG_DEBUG << "close() called";
|
|
262
279
|
doClose();
|
|
263
280
|
}
|
|
264
281
|
|
|
265
282
|
void PeerConnectionWrapper::doDestroy()
|
|
266
283
|
{
|
|
284
|
+
PLOG_DEBUG << "doDestroy() called";
|
|
267
285
|
doClose();
|
|
268
286
|
doResetCallbacks();
|
|
269
287
|
}
|
|
270
288
|
|
|
271
289
|
void PeerConnectionWrapper::doResetCallbacks()
|
|
272
290
|
{
|
|
291
|
+
PLOG_DEBUG << "doResetCallbacks() called";
|
|
273
292
|
mOnLocalDescriptionCallback.reset();
|
|
274
293
|
mOnLocalCandidateCallback.reset();
|
|
275
294
|
mOnStateChangeCallback.reset();
|
|
295
|
+
mOnSignalingStateChangeCallback.reset();
|
|
276
296
|
mOnGatheringStateChangeCallback.reset();
|
|
277
297
|
mOnDataChannelCallback.reset();
|
|
278
298
|
mOnTrackCallback.reset();
|
|
@@ -282,11 +302,13 @@ void PeerConnectionWrapper::doResetCallbacks()
|
|
|
282
302
|
|
|
283
303
|
void PeerConnectionWrapper::destroy(const Napi::CallbackInfo &info)
|
|
284
304
|
{
|
|
305
|
+
PLOG_DEBUG << "destroy() called";
|
|
285
306
|
doDestroy();
|
|
286
307
|
}
|
|
287
308
|
|
|
288
309
|
void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
|
|
289
310
|
{
|
|
311
|
+
PLOG_DEBUG << "setLocalDescription() called";
|
|
290
312
|
Napi::Env env = info.Env();
|
|
291
313
|
int length = info.Length();
|
|
292
314
|
|
|
@@ -309,7 +331,7 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
|
|
|
309
331
|
std::string typeStr = info[0].As<Napi::String>().ToString();
|
|
310
332
|
|
|
311
333
|
// Accept uppercase first letter for backward compatibility
|
|
312
|
-
if(typeStr.size() > 0)
|
|
334
|
+
if (typeStr.size() > 0)
|
|
313
335
|
typeStr[0] = std::tolower(typeStr[0]);
|
|
314
336
|
|
|
315
337
|
if (typeStr == "answer")
|
|
@@ -327,6 +349,7 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
|
|
|
327
349
|
|
|
328
350
|
void PeerConnectionWrapper::setRemoteDescription(const Napi::CallbackInfo &info)
|
|
329
351
|
{
|
|
352
|
+
PLOG_DEBUG << "setRemoteDescription() called";
|
|
330
353
|
Napi::Env env = info.Env();
|
|
331
354
|
int length = info.Length();
|
|
332
355
|
|
|
@@ -359,12 +382,32 @@ void PeerConnectionWrapper::setRemoteDescription(const Napi::CallbackInfo &info)
|
|
|
359
382
|
|
|
360
383
|
Napi::Value PeerConnectionWrapper::localDescription(const Napi::CallbackInfo &info)
|
|
361
384
|
{
|
|
385
|
+
PLOG_DEBUG << "localDescription() called";
|
|
362
386
|
Napi::Env env = info.Env();
|
|
363
387
|
|
|
364
388
|
std::optional<rtc::Description> desc = mRtcPeerConnPtr ? mRtcPeerConnPtr->localDescription() : std::nullopt;
|
|
365
389
|
|
|
366
390
|
// Return JS null if no description
|
|
367
|
-
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
|
+
{
|
|
368
411
|
return env.Null();
|
|
369
412
|
}
|
|
370
413
|
|
|
@@ -376,6 +419,7 @@ Napi::Value PeerConnectionWrapper::localDescription(const Napi::CallbackInfo &in
|
|
|
376
419
|
|
|
377
420
|
void PeerConnectionWrapper::addRemoteCandidate(const Napi::CallbackInfo &info)
|
|
378
421
|
{
|
|
422
|
+
PLOG_DEBUG << "addRemoteCandidate() called";
|
|
379
423
|
Napi::Env env = info.Env();
|
|
380
424
|
int length = info.Length();
|
|
381
425
|
|
|
@@ -406,6 +450,7 @@ void PeerConnectionWrapper::addRemoteCandidate(const Napi::CallbackInfo &info)
|
|
|
406
450
|
|
|
407
451
|
Napi::Value PeerConnectionWrapper::createDataChannel(const Napi::CallbackInfo &info)
|
|
408
452
|
{
|
|
453
|
+
PLOG_DEBUG << "createDataChannel() called";
|
|
409
454
|
Napi::Env env = info.Env();
|
|
410
455
|
int length = info.Length();
|
|
411
456
|
|
|
@@ -564,6 +609,7 @@ Napi::Value PeerConnectionWrapper::createDataChannel(const Napi::CallbackInfo &i
|
|
|
564
609
|
std::string label = info[0].As<Napi::String>().ToString();
|
|
565
610
|
std::shared_ptr<rtc::DataChannel> dataChannel = mRtcPeerConnPtr->createDataChannel(label, std::move(init));
|
|
566
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;
|
|
567
613
|
return instance;
|
|
568
614
|
}
|
|
569
615
|
catch (std::exception &ex)
|
|
@@ -575,6 +621,7 @@ Napi::Value PeerConnectionWrapper::createDataChannel(const Napi::CallbackInfo &i
|
|
|
575
621
|
|
|
576
622
|
void PeerConnectionWrapper::onLocalDescription(const Napi::CallbackInfo &info)
|
|
577
623
|
{
|
|
624
|
+
PLOG_DEBUG << "onLocalDescription() called";
|
|
578
625
|
Napi::Env env = info.Env();
|
|
579
626
|
int length = info.Length();
|
|
580
627
|
|
|
@@ -593,9 +640,12 @@ void PeerConnectionWrapper::onLocalDescription(const Napi::CallbackInfo &info)
|
|
|
593
640
|
// Callback
|
|
594
641
|
mOnLocalDescriptionCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
595
642
|
|
|
596
|
-
mRtcPeerConnPtr->onLocalDescription([&](rtc::Description sdp)
|
|
643
|
+
mRtcPeerConnPtr->onLocalDescription([&](rtc::Description sdp)
|
|
644
|
+
{
|
|
645
|
+
PLOG_DEBUG << "onLocalDescription cb received from rtc";
|
|
597
646
|
if (mOnLocalDescriptionCallback)
|
|
598
647
|
mOnLocalDescriptionCallback->call([this, sdp = std::move(sdp)](Napi::Env env, std::vector<napi_value> &args) {
|
|
648
|
+
PLOG_DEBUG << "mOnLocalDescriptionCallback call(1)";
|
|
599
649
|
// Check the peer connection is not closed
|
|
600
650
|
if(instances.find(this) == instances.end())
|
|
601
651
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -605,11 +655,13 @@ void PeerConnectionWrapper::onLocalDescription(const Napi::CallbackInfo &info)
|
|
|
605
655
|
args = {
|
|
606
656
|
Napi::String::New(env, std::string(sdp)),
|
|
607
657
|
Napi::String::New(env, sdp.typeString())};
|
|
658
|
+
PLOG_DEBUG << "mOnLocalDescriptionCallback call(2)";
|
|
608
659
|
}); });
|
|
609
660
|
}
|
|
610
661
|
|
|
611
662
|
void PeerConnectionWrapper::onLocalCandidate(const Napi::CallbackInfo &info)
|
|
612
663
|
{
|
|
664
|
+
PLOG_DEBUG << "onLocalCandidate() called";
|
|
613
665
|
Napi::Env env = info.Env();
|
|
614
666
|
int length = info.Length();
|
|
615
667
|
|
|
@@ -628,9 +680,12 @@ void PeerConnectionWrapper::onLocalCandidate(const Napi::CallbackInfo &info)
|
|
|
628
680
|
// Callback
|
|
629
681
|
mOnLocalCandidateCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
630
682
|
|
|
631
|
-
mRtcPeerConnPtr->onLocalCandidate([&](rtc::Candidate cand)
|
|
683
|
+
mRtcPeerConnPtr->onLocalCandidate([&](rtc::Candidate cand)
|
|
684
|
+
{
|
|
685
|
+
PLOG_DEBUG << "onLocalCandidate cb received from rtc";
|
|
632
686
|
if (mOnLocalCandidateCallback)
|
|
633
687
|
mOnLocalCandidateCallback->call([this, cand = std::move(cand)](Napi::Env env, std::vector<napi_value> &args) {
|
|
688
|
+
PLOG_DEBUG << "mOnLocalCandidateCallback call(1)";
|
|
634
689
|
// Check the peer connection is not closed
|
|
635
690
|
if(instances.find(this) == instances.end())
|
|
636
691
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -640,11 +695,13 @@ void PeerConnectionWrapper::onLocalCandidate(const Napi::CallbackInfo &info)
|
|
|
640
695
|
args = {
|
|
641
696
|
Napi::String::New(env, std::string(cand)),
|
|
642
697
|
Napi::String::New(env, cand.mid())};
|
|
698
|
+
PLOG_DEBUG << "mOnLocalCandidateCallback call(2)";
|
|
643
699
|
}); });
|
|
644
700
|
}
|
|
645
701
|
|
|
646
702
|
void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
|
|
647
703
|
{
|
|
704
|
+
PLOG_DEBUG << "onStateChange() called";
|
|
648
705
|
Napi::Env env = info.Env();
|
|
649
706
|
int length = info.Length();
|
|
650
707
|
|
|
@@ -663,9 +720,51 @@ void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
|
|
|
663
720
|
// Callback
|
|
664
721
|
mOnStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
665
722
|
|
|
666
|
-
mRtcPeerConnPtr->onStateChange([&](rtc::PeerConnection::State state)
|
|
723
|
+
mRtcPeerConnPtr->onStateChange([&](rtc::PeerConnection::State state)
|
|
724
|
+
{
|
|
725
|
+
PLOG_DEBUG << "onStateChange cb received from rtc";
|
|
667
726
|
if (mOnStateChangeCallback)
|
|
668
727
|
mOnStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
|
|
728
|
+
PLOG_DEBUG << "mOnStateChangeCallback call(1)";
|
|
729
|
+
if(instances.find(this) == instances.end())
|
|
730
|
+
throw ThreadSafeCallback::CancelException();
|
|
731
|
+
|
|
732
|
+
// This will run in main thread and needs to construct the
|
|
733
|
+
// arguments for the call
|
|
734
|
+
std::ostringstream stream;
|
|
735
|
+
stream << state;
|
|
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)";
|
|
669
768
|
if(instances.find(this) == instances.end())
|
|
670
769
|
throw ThreadSafeCallback::CancelException();
|
|
671
770
|
|
|
@@ -674,11 +773,13 @@ void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
|
|
|
674
773
|
std::ostringstream stream;
|
|
675
774
|
stream << state;
|
|
676
775
|
args = {Napi::String::New(env, stream.str())};
|
|
776
|
+
PLOG_DEBUG << "mOnIceStateChangeCallback call(2)";
|
|
677
777
|
}); });
|
|
678
778
|
}
|
|
679
779
|
|
|
680
780
|
void PeerConnectionWrapper::onSignalingStateChange(const Napi::CallbackInfo &info)
|
|
681
781
|
{
|
|
782
|
+
PLOG_DEBUG << "onSignalingStateChange() called";
|
|
682
783
|
Napi::Env env = info.Env();
|
|
683
784
|
int length = info.Length();
|
|
684
785
|
|
|
@@ -697,9 +798,12 @@ void PeerConnectionWrapper::onSignalingStateChange(const Napi::CallbackInfo &inf
|
|
|
697
798
|
// Callback
|
|
698
799
|
mOnSignalingStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
699
800
|
|
|
700
|
-
mRtcPeerConnPtr->onSignalingStateChange([&](rtc::PeerConnection::SignalingState state)
|
|
801
|
+
mRtcPeerConnPtr->onSignalingStateChange([&](rtc::PeerConnection::SignalingState state)
|
|
802
|
+
{
|
|
803
|
+
PLOG_DEBUG << "onSignalingStateChange cb received from rtc";
|
|
701
804
|
if (mOnSignalingStateChangeCallback)
|
|
702
805
|
mOnSignalingStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
|
|
806
|
+
PLOG_DEBUG << "mOnSignalingStateChangeCallback call(1)";
|
|
703
807
|
// Check the peer connection is not closed
|
|
704
808
|
if(instances.find(this) == instances.end())
|
|
705
809
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -709,11 +813,13 @@ void PeerConnectionWrapper::onSignalingStateChange(const Napi::CallbackInfo &inf
|
|
|
709
813
|
std::ostringstream stream;
|
|
710
814
|
stream << state;
|
|
711
815
|
args = {Napi::String::New(env, stream.str())};
|
|
816
|
+
PLOG_DEBUG << "mOnSignalingStateChangeCallback call(2)";
|
|
712
817
|
}); });
|
|
713
818
|
}
|
|
714
819
|
|
|
715
820
|
void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &info)
|
|
716
821
|
{
|
|
822
|
+
PLOG_DEBUG << "onGatheringStateChange() called";
|
|
717
823
|
Napi::Env env = info.Env();
|
|
718
824
|
int length = info.Length();
|
|
719
825
|
|
|
@@ -732,9 +838,12 @@ void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &inf
|
|
|
732
838
|
// Callback
|
|
733
839
|
mOnGatheringStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
734
840
|
|
|
735
|
-
mRtcPeerConnPtr->onGatheringStateChange([&](rtc::PeerConnection::GatheringState state)
|
|
841
|
+
mRtcPeerConnPtr->onGatheringStateChange([&](rtc::PeerConnection::GatheringState state)
|
|
842
|
+
{
|
|
843
|
+
PLOG_DEBUG << "onGatheringStateChange cb received from rtc";
|
|
736
844
|
if (mOnGatheringStateChangeCallback)
|
|
737
845
|
mOnGatheringStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
|
|
846
|
+
PLOG_DEBUG << "mOnGatheringStateChangeCallback call(1)";
|
|
738
847
|
// Check the peer connection is not closed
|
|
739
848
|
if(instances.find(this) == instances.end())
|
|
740
849
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -744,11 +853,13 @@ void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &inf
|
|
|
744
853
|
std::ostringstream stream;
|
|
745
854
|
stream << state;
|
|
746
855
|
args = {Napi::String::New(env, stream.str())};
|
|
856
|
+
PLOG_DEBUG << "mOnGatheringStateChangeCallback call(2)";
|
|
747
857
|
}); });
|
|
748
858
|
}
|
|
749
859
|
|
|
750
860
|
void PeerConnectionWrapper::onDataChannel(const Napi::CallbackInfo &info)
|
|
751
861
|
{
|
|
862
|
+
PLOG_DEBUG << "onDataChannel() called";
|
|
752
863
|
Napi::Env env = info.Env();
|
|
753
864
|
int length = info.Length();
|
|
754
865
|
|
|
@@ -769,8 +880,10 @@ void PeerConnectionWrapper::onDataChannel(const Napi::CallbackInfo &info)
|
|
|
769
880
|
|
|
770
881
|
mRtcPeerConnPtr->onDataChannel([&](std::shared_ptr<rtc::DataChannel> dc)
|
|
771
882
|
{
|
|
883
|
+
PLOG_DEBUG << "onDataChannel cb received from rtc";
|
|
772
884
|
if (mOnDataChannelCallback)
|
|
773
885
|
mOnDataChannelCallback->call([this, dc](Napi::Env env, std::vector<napi_value> &args) {
|
|
886
|
+
PLOG_DEBUG << "mOnDataChannelCallback call(1)";
|
|
774
887
|
// Check the peer connection is not closed
|
|
775
888
|
if(instances.find(this) == instances.end())
|
|
776
889
|
throw ThreadSafeCallback::CancelException();
|
|
@@ -780,11 +893,13 @@ void PeerConnectionWrapper::onDataChannel(const Napi::CallbackInfo &info)
|
|
|
780
893
|
std::shared_ptr<rtc::DataChannel> dataChannel = dc;
|
|
781
894
|
auto instance = DataChannelWrapper::constructor.New({Napi::External<std::shared_ptr<rtc::DataChannel>>::New(env, &dataChannel)});
|
|
782
895
|
args = {instance};
|
|
896
|
+
PLOG_DEBUG << "mOnDataChannelCallback call(2)";
|
|
783
897
|
}); });
|
|
784
898
|
}
|
|
785
899
|
|
|
786
900
|
Napi::Value PeerConnectionWrapper::bytesSent(const Napi::CallbackInfo &info)
|
|
787
901
|
{
|
|
902
|
+
PLOG_DEBUG << "bytesSent() called";
|
|
788
903
|
Napi::Env env = info.Env();
|
|
789
904
|
|
|
790
905
|
if (!mRtcPeerConnPtr)
|
|
@@ -805,6 +920,7 @@ Napi::Value PeerConnectionWrapper::bytesSent(const Napi::CallbackInfo &info)
|
|
|
805
920
|
|
|
806
921
|
Napi::Value PeerConnectionWrapper::bytesReceived(const Napi::CallbackInfo &info)
|
|
807
922
|
{
|
|
923
|
+
PLOG_DEBUG << "bytesReceived() called";
|
|
808
924
|
Napi::Env env = info.Env();
|
|
809
925
|
|
|
810
926
|
if (!mRtcPeerConnPtr)
|
|
@@ -825,6 +941,7 @@ Napi::Value PeerConnectionWrapper::bytesReceived(const Napi::CallbackInfo &info)
|
|
|
825
941
|
|
|
826
942
|
Napi::Value PeerConnectionWrapper::rtt(const Napi::CallbackInfo &info)
|
|
827
943
|
{
|
|
944
|
+
PLOG_DEBUG << "rtt() called";
|
|
828
945
|
Napi::Env env = info.Env();
|
|
829
946
|
|
|
830
947
|
if (!mRtcPeerConnPtr)
|
|
@@ -845,6 +962,7 @@ Napi::Value PeerConnectionWrapper::rtt(const Napi::CallbackInfo &info)
|
|
|
845
962
|
|
|
846
963
|
Napi::Value PeerConnectionWrapper::getSelectedCandidatePair(const Napi::CallbackInfo &info)
|
|
847
964
|
{
|
|
965
|
+
PLOG_DEBUG << "getSelectedCandidatePair() called";
|
|
848
966
|
Napi::Env env = info.Env();
|
|
849
967
|
|
|
850
968
|
if (!mRtcPeerConnPtr)
|
|
@@ -886,6 +1004,7 @@ Napi::Value PeerConnectionWrapper::getSelectedCandidatePair(const Napi::Callback
|
|
|
886
1004
|
|
|
887
1005
|
std::string PeerConnectionWrapper::candidateTypeToString(const rtc::Candidate::Type &type)
|
|
888
1006
|
{
|
|
1007
|
+
PLOG_DEBUG << "candidateTypeToString() called";
|
|
889
1008
|
switch (type)
|
|
890
1009
|
{
|
|
891
1010
|
case rtc::Candidate::Type::Host:
|
|
@@ -903,6 +1022,7 @@ std::string PeerConnectionWrapper::candidateTypeToString(const rtc::Candidate::T
|
|
|
903
1022
|
|
|
904
1023
|
std::string PeerConnectionWrapper::candidateTransportTypeToString(const rtc::Candidate::TransportType &transportType)
|
|
905
1024
|
{
|
|
1025
|
+
PLOG_DEBUG << "candidateTransportTypeToString() called";
|
|
906
1026
|
switch (transportType)
|
|
907
1027
|
{
|
|
908
1028
|
case rtc::Candidate::TransportType::Udp:
|
|
@@ -922,6 +1042,7 @@ std::string PeerConnectionWrapper::candidateTransportTypeToString(const rtc::Can
|
|
|
922
1042
|
|
|
923
1043
|
Napi::Value PeerConnectionWrapper::addTrack(const Napi::CallbackInfo &info)
|
|
924
1044
|
{
|
|
1045
|
+
PLOG_DEBUG << "addTrack() called";
|
|
925
1046
|
Napi::Env env = info.Env();
|
|
926
1047
|
int length = info.Length();
|
|
927
1048
|
|
|
@@ -968,6 +1089,7 @@ Napi::Value PeerConnectionWrapper::addTrack(const Napi::CallbackInfo &info)
|
|
|
968
1089
|
|
|
969
1090
|
void PeerConnectionWrapper::onTrack(const Napi::CallbackInfo &info)
|
|
970
1091
|
{
|
|
1092
|
+
PLOG_DEBUG << "onTrack() called";
|
|
971
1093
|
Napi::Env env = info.Env();
|
|
972
1094
|
int length = info.Length();
|
|
973
1095
|
|
|
@@ -986,7 +1108,8 @@ void PeerConnectionWrapper::onTrack(const Napi::CallbackInfo &info)
|
|
|
986
1108
|
// Callback
|
|
987
1109
|
mOnTrackCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
988
1110
|
|
|
989
|
-
mRtcPeerConnPtr->onTrack([&](std::shared_ptr<rtc::Track> track)
|
|
1111
|
+
mRtcPeerConnPtr->onTrack([&](std::shared_ptr<rtc::Track> track)
|
|
1112
|
+
{
|
|
990
1113
|
if (mOnTrackCallback)
|
|
991
1114
|
mOnTrackCallback->call([this, track](Napi::Env env, std::vector<napi_value> &args) {
|
|
992
1115
|
// Check the peer connection is not closed
|
|
@@ -1003,20 +1126,32 @@ void PeerConnectionWrapper::onTrack(const Napi::CallbackInfo &info)
|
|
|
1003
1126
|
|
|
1004
1127
|
Napi::Value PeerConnectionWrapper::hasMedia(const Napi::CallbackInfo &info)
|
|
1005
1128
|
{
|
|
1129
|
+
PLOG_DEBUG << "hasMedia() called";
|
|
1006
1130
|
Napi::Env env = info.Env();
|
|
1007
1131
|
return Napi::Boolean::New(env, mRtcPeerConnPtr ? mRtcPeerConnPtr->hasMedia() : false);
|
|
1008
1132
|
}
|
|
1009
1133
|
|
|
1010
1134
|
Napi::Value PeerConnectionWrapper::state(const Napi::CallbackInfo &info)
|
|
1011
1135
|
{
|
|
1136
|
+
PLOG_DEBUG << "state() called";
|
|
1012
1137
|
Napi::Env env = info.Env();
|
|
1013
1138
|
std::ostringstream stream;
|
|
1014
1139
|
stream << (mRtcPeerConnPtr ? mRtcPeerConnPtr->state() : rtc::PeerConnection::State::Closed);
|
|
1015
1140
|
return Napi::String::New(env, stream.str());
|
|
1016
1141
|
}
|
|
1017
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
|
+
|
|
1018
1152
|
Napi::Value PeerConnectionWrapper::signalingState(const Napi::CallbackInfo &info)
|
|
1019
1153
|
{
|
|
1154
|
+
PLOG_DEBUG << "signalingState() called";
|
|
1020
1155
|
Napi::Env env = info.Env();
|
|
1021
1156
|
std::ostringstream stream;
|
|
1022
1157
|
stream << (mRtcPeerConnPtr ? mRtcPeerConnPtr->signalingState() : rtc::PeerConnection::SignalingState::Stable);
|
|
@@ -1025,6 +1160,7 @@ Napi::Value PeerConnectionWrapper::signalingState(const Napi::CallbackInfo &info
|
|
|
1025
1160
|
|
|
1026
1161
|
Napi::Value PeerConnectionWrapper::gatheringState(const Napi::CallbackInfo &info)
|
|
1027
1162
|
{
|
|
1163
|
+
PLOG_DEBUG << "gatheringState() called";
|
|
1028
1164
|
Napi::Env env = info.Env();
|
|
1029
1165
|
std::ostringstream stream;
|
|
1030
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
|
-
|