electron-cast 0.4.0 → 0.5.0-next.1
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/CHANGELOG.md +280 -0
- package/CONTRIBUTING.md +305 -0
- package/README.md +211 -165
- package/SECURITY.md +324 -0
- package/dist/cjs/client/auth/build-time.js +1 -1
- package/dist/cjs/client/auth/cast-auth.d.ts +2 -0
- package/dist/cjs/client/auth/cast-auth.js.map +1 -1
- package/dist/cjs/dial/dial-registry.d.ts +104 -0
- package/dist/cjs/dial/dial-registry.js +301 -0
- package/dist/cjs/dial/dial-registry.js.map +1 -0
- package/dist/cjs/dial/dial-sink-service.d.ts +108 -0
- package/dist/cjs/dial/dial-sink-service.js +314 -0
- package/dist/cjs/dial/dial-sink-service.js.map +1 -0
- package/dist/cjs/dial/http.d.ts +40 -0
- package/dist/cjs/dial/http.js +172 -0
- package/dist/cjs/dial/http.js.map +1 -0
- package/dist/cjs/dial/index.d.ts +63 -0
- package/dist/cjs/dial/index.js +134 -0
- package/dist/cjs/dial/index.js.map +1 -0
- package/dist/cjs/dial/origins.d.ts +4 -0
- package/dist/cjs/dial/origins.js +36 -0
- package/dist/cjs/dial/origins.js.map +1 -0
- package/dist/cjs/dial/parse.d.ts +101 -0
- package/dist/cjs/dial/parse.js +296 -0
- package/dist/cjs/dial/parse.js.map +1 -0
- package/dist/cjs/dial/route-provider.d.ts +96 -0
- package/dist/cjs/dial/route-provider.js +376 -0
- package/dist/cjs/dial/route-provider.js.map +1 -0
- package/dist/cjs/dial/ssdp-socket.d.ts +34 -0
- package/dist/cjs/dial/ssdp-socket.js +72 -0
- package/dist/cjs/dial/ssdp-socket.js.map +1 -0
- package/dist/cjs/dial/xml.d.ts +13 -0
- package/dist/cjs/dial/xml.js +208 -0
- package/dist/cjs/dial/xml.js.map +1 -0
- package/dist/cjs/discovery/cast-discovery.d.ts +2 -0
- package/dist/cjs/discovery/cast-discovery.js.map +1 -1
- package/dist/cjs/discovery/device-cache.d.ts +9 -0
- package/dist/cjs/discovery/device-cache.js.map +1 -1
- package/dist/cjs/discovery/index.d.ts +1 -0
- package/dist/cjs/discovery/index.js +1 -0
- package/dist/cjs/discovery/index.js.map +1 -1
- package/dist/cjs/discovery/ip-policy.d.ts +20 -0
- package/dist/cjs/discovery/ip-policy.js +109 -0
- package/dist/cjs/discovery/ip-policy.js.map +1 -0
- package/dist/cjs/discovery/udp-socket.d.ts +3 -0
- package/dist/cjs/discovery/udp-socket.js +3 -0
- package/dist/cjs/discovery/udp-socket.js.map +1 -1
- package/dist/cjs/electron/access-code.d.ts +221 -0
- package/dist/cjs/electron/access-code.js +586 -0
- package/dist/cjs/electron/access-code.js.map +1 -0
- package/dist/cjs/electron/app-discovery.d.ts +82 -0
- package/dist/cjs/electron/app-discovery.js +219 -0
- package/dist/cjs/electron/app-discovery.js.map +1 -0
- package/dist/cjs/electron/default-presentation.d.ts +38 -0
- package/dist/cjs/electron/default-presentation.js +88 -0
- package/dist/cjs/electron/default-presentation.js.map +1 -0
- package/dist/cjs/electron/main.d.ts +98 -11
- package/dist/cjs/electron/main.js +602 -20
- package/dist/cjs/electron/main.js.map +1 -1
- package/dist/cjs/electron/manager-api.d.ts +200 -18
- package/dist/cjs/electron/manager-api.js +199 -4
- package/dist/cjs/electron/manager-api.js.map +1 -1
- package/dist/cjs/electron/media-controller.d.ts +79 -0
- package/dist/cjs/electron/media-controller.js +251 -0
- package/dist/cjs/electron/media-controller.js.map +1 -0
- package/dist/cjs/electron/network-monitor.d.ts +61 -0
- package/dist/cjs/electron/network-monitor.js +124 -0
- package/dist/cjs/electron/network-monitor.js.map +1 -0
- package/dist/cjs/electron/preload.js.map +1 -1
- package/dist/cjs/electron/presentation-handler.d.ts +39 -4
- package/dist/cjs/electron/presentation-handler.js +191 -47
- package/dist/cjs/electron/presentation-handler.js.map +1 -1
- package/dist/cjs/electron/presentation-source.d.ts +76 -0
- package/dist/cjs/electron/presentation-source.js +132 -0
- package/dist/cjs/electron/presentation-source.js.map +1 -0
- package/dist/cjs/electron/session-service.d.ts +198 -24
- package/dist/cjs/electron/session-service.js +630 -248
- package/dist/cjs/electron/session-service.js.map +1 -1
- package/dist/cjs/electron/session-tracker.d.ts +82 -0
- package/dist/cjs/electron/session-tracker.js +225 -0
- package/dist/cjs/electron/session-tracker.js.map +1 -0
- package/dist/cjs/electron/sink-service.d.ts +246 -0
- package/dist/cjs/electron/sink-service.js +606 -0
- package/dist/cjs/electron/sink-service.js.map +1 -0
- package/dist/cjs/electron/wired-display/controller.d.ts +76 -0
- package/dist/cjs/electron/wired-display/controller.js +198 -0
- package/dist/cjs/electron/wired-display/controller.js.map +1 -0
- package/dist/cjs/electron/wired-display/displays.d.ts +44 -0
- package/dist/cjs/electron/wired-display/displays.js +98 -0
- package/dist/cjs/electron/wired-display/displays.js.map +1 -0
- package/dist/cjs/electron/wired-display/electron-windows.d.ts +111 -0
- package/dist/cjs/electron/wired-display/electron-windows.js +306 -0
- package/dist/cjs/electron/wired-display/electron-windows.js.map +1 -0
- package/dist/cjs/electron/wired-display/index.d.ts +90 -0
- package/dist/cjs/electron/wired-display/index.js +115 -0
- package/dist/cjs/electron/wired-display/index.js.map +1 -0
- package/dist/cjs/electron/wired-display/local-presentation.d.ts +98 -0
- package/dist/cjs/electron/wired-display/local-presentation.js +234 -0
- package/dist/cjs/electron/wired-display/local-presentation.js.map +1 -0
- package/dist/cjs/electron/wired-display/provider.d.ts +112 -0
- package/dist/cjs/electron/wired-display/provider.js +202 -0
- package/dist/cjs/electron/wired-display/provider.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mirroring/backend.d.ts +76 -0
- package/dist/cjs/mirroring/backend.js +21 -0
- package/dist/cjs/mirroring/backend.js.map +1 -0
- package/dist/cjs/mirroring/electron/agent-protocol.d.ts +158 -0
- package/dist/cjs/mirroring/electron/agent-protocol.js +11 -0
- package/dist/cjs/mirroring/electron/agent-protocol.js.map +1 -0
- package/dist/cjs/mirroring/electron/agent-source.d.ts +20 -0
- package/dist/cjs/mirroring/electron/agent-source.js +621 -0
- package/dist/cjs/mirroring/electron/agent-source.js.map +1 -0
- package/dist/cjs/mirroring/electron/engine-process.d.ts +87 -0
- package/dist/cjs/mirroring/electron/engine-process.js +81 -0
- package/dist/cjs/mirroring/electron/engine-process.js.map +1 -0
- package/dist/cjs/mirroring/electron/host.d.ts +89 -0
- package/dist/cjs/mirroring/electron/host.js +321 -0
- package/dist/cjs/mirroring/electron/host.js.map +1 -0
- package/dist/cjs/mirroring/electron/port-backend.d.ts +107 -0
- package/dist/cjs/mirroring/electron/port-backend.js +446 -0
- package/dist/cjs/mirroring/electron/port-backend.js.map +1 -0
- package/dist/cjs/mirroring/encoding-support.d.ts +66 -0
- package/dist/cjs/mirroring/encoding-support.js +89 -0
- package/dist/cjs/mirroring/encoding-support.js.map +1 -0
- package/dist/cjs/mirroring/engine.d.ts +16 -0
- package/dist/cjs/mirroring/engine.js +78 -0
- package/dist/cjs/mirroring/engine.js.map +1 -0
- package/dist/cjs/mirroring/mirror-settings.d.ts +101 -0
- package/dist/cjs/mirroring/mirror-settings.js +140 -0
- package/dist/cjs/mirroring/mirror-settings.js.map +1 -0
- package/dist/cjs/mirroring/mirroring-activity.d.ts +207 -0
- package/dist/cjs/mirroring/mirroring-activity.js +367 -0
- package/dist/cjs/mirroring/mirroring-activity.js.map +1 -0
- package/dist/cjs/mirroring/mirroring-manager.d.ts +134 -0
- package/dist/cjs/mirroring/mirroring-manager.js +286 -0
- package/dist/cjs/mirroring/mirroring-manager.js.map +1 -0
- package/dist/cjs/mirroring/protocol/answer.d.ts +87 -0
- package/dist/cjs/mirroring/protocol/answer.js +233 -0
- package/dist/cjs/mirroring/protocol/answer.js.map +1 -0
- package/dist/cjs/mirroring/protocol/constants.d.ts +64 -0
- package/dist/cjs/mirroring/protocol/constants.js +70 -0
- package/dist/cjs/mirroring/protocol/constants.js.map +1 -0
- package/dist/cjs/mirroring/protocol/errors.d.ts +25 -0
- package/dist/cjs/mirroring/protocol/errors.js +34 -0
- package/dist/cjs/mirroring/protocol/errors.js.map +1 -0
- package/dist/cjs/mirroring/protocol/frame-id.d.ts +9 -0
- package/dist/cjs/mirroring/protocol/frame-id.js +24 -0
- package/dist/cjs/mirroring/protocol/frame-id.js.map +1 -0
- package/dist/cjs/mirroring/protocol/messenger.d.ts +42 -0
- package/dist/cjs/mirroring/protocol/messenger.js +122 -0
- package/dist/cjs/mirroring/protocol/messenger.js.map +1 -0
- package/dist/cjs/mirroring/protocol/offer.d.ts +109 -0
- package/dist/cjs/mirroring/protocol/offer.js +192 -0
- package/dist/cjs/mirroring/protocol/offer.js.map +1 -0
- package/dist/cjs/mirroring/protocol/recommendations.d.ts +28 -0
- package/dist/cjs/mirroring/protocol/recommendations.js +103 -0
- package/dist/cjs/mirroring/protocol/recommendations.js.map +1 -0
- package/dist/cjs/mirroring/routing.d.ts +60 -0
- package/dist/cjs/mirroring/routing.js +147 -0
- package/dist/cjs/mirroring/routing.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/ntp.d.ts +27 -0
- package/dist/cjs/mirroring/rtcp/ntp.js +62 -0
- package/dist/cjs/mirroring/rtcp/ntp.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/parser.d.ts +50 -0
- package/dist/cjs/mirroring/rtcp/parser.js +270 -0
- package/dist/cjs/mirroring/rtcp/parser.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/sender-report.d.ts +32 -0
- package/dist/cjs/mirroring/rtcp/sender-report.js +56 -0
- package/dist/cjs/mirroring/rtcp/sender-report.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/wire.d.ts +54 -0
- package/dist/cjs/mirroring/rtcp/wire.js +73 -0
- package/dist/cjs/mirroring/rtcp/wire.js.map +1 -0
- package/dist/cjs/mirroring/rtp/frame-crypto.d.ts +11 -0
- package/dist/cjs/mirroring/rtp/frame-crypto.js +39 -0
- package/dist/cjs/mirroring/rtp/frame-crypto.js.map +1 -0
- package/dist/cjs/mirroring/rtp/frame.d.ts +23 -0
- package/dist/cjs/mirroring/rtp/frame.js +3 -0
- package/dist/cjs/mirroring/rtp/frame.js.map +1 -0
- package/dist/cjs/mirroring/rtp/packetizer.d.ts +27 -0
- package/dist/cjs/mirroring/rtp/packetizer.js +92 -0
- package/dist/cjs/mirroring/rtp/packetizer.js.map +1 -0
- package/dist/cjs/mirroring/sender/audio-sender.d.ts +23 -0
- package/dist/cjs/mirroring/sender/audio-sender.js +52 -0
- package/dist/cjs/mirroring/sender/audio-sender.js.map +1 -0
- package/dist/cjs/mirroring/sender/bandwidth-estimator.d.ts +26 -0
- package/dist/cjs/mirroring/sender/bandwidth-estimator.js +107 -0
- package/dist/cjs/mirroring/sender/bandwidth-estimator.js.map +1 -0
- package/dist/cjs/mirroring/sender/capture-size-oracle.d.ts +121 -0
- package/dist/cjs/mirroring/sender/capture-size-oracle.js +440 -0
- package/dist/cjs/mirroring/sender/capture-size-oracle.js.map +1 -0
- package/dist/cjs/mirroring/sender/frame-sender.d.ts +103 -0
- package/dist/cjs/mirroring/sender/frame-sender.js +217 -0
- package/dist/cjs/mirroring/sender/frame-sender.js.map +1 -0
- package/dist/cjs/mirroring/sender/packet-router.d.ts +74 -0
- package/dist/cjs/mirroring/sender/packet-router.js +196 -0
- package/dist/cjs/mirroring/sender/packet-router.js.map +1 -0
- package/dist/cjs/mirroring/sender/sender-session.d.ts +85 -0
- package/dist/cjs/mirroring/sender/sender-session.js +240 -0
- package/dist/cjs/mirroring/sender/sender-session.js.map +1 -0
- package/dist/cjs/mirroring/sender/sender.d.ts +120 -0
- package/dist/cjs/mirroring/sender/sender.js +457 -0
- package/dist/cjs/mirroring/sender/sender.js.map +1 -0
- package/dist/cjs/mirroring/sender/video-encoder-metrics.d.ts +29 -0
- package/dist/cjs/mirroring/sender/video-encoder-metrics.js +64 -0
- package/dist/cjs/mirroring/sender/video-encoder-metrics.js.map +1 -0
- package/dist/cjs/mirroring/sender/video-sender.d.ts +95 -0
- package/dist/cjs/mirroring/sender/video-sender.js +183 -0
- package/dist/cjs/mirroring/sender/video-sender.js.map +1 -0
- package/dist/cjs/mirroring/session-host.d.ts +185 -0
- package/dist/cjs/mirroring/session-host.js +630 -0
- package/dist/cjs/mirroring/session-host.js.map +1 -0
- package/dist/cjs/mirroring/stats/clock-offset-estimator.d.ts +11 -0
- package/dist/cjs/mirroring/stats/clock-offset-estimator.js +123 -0
- package/dist/cjs/mirroring/stats/clock-offset-estimator.js.map +1 -0
- package/dist/cjs/mirroring/stats/openscreen-stats-client.d.ts +12 -0
- package/dist/cjs/mirroring/stats/openscreen-stats-client.js +21 -0
- package/dist/cjs/mirroring/stats/openscreen-stats-client.js.map +1 -0
- package/dist/cjs/mirroring/stats/sorted-map.d.ts +23 -0
- package/dist/cjs/mirroring/stats/sorted-map.js +70 -0
- package/dist/cjs/mirroring/stats/sorted-map.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-analyzer.d.ts +50 -0
- package/dist/cjs/mirroring/stats/statistics-analyzer.js +339 -0
- package/dist/cjs/mirroring/stats/statistics-analyzer.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-collector.d.ts +29 -0
- package/dist/cjs/mirroring/stats/statistics-collector.js +53 -0
- package/dist/cjs/mirroring/stats/statistics-collector.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-common.d.ts +61 -0
- package/dist/cjs/mirroring/stats/statistics-common.js +45 -0
- package/dist/cjs/mirroring/stats/statistics-common.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-dispatcher.d.ts +28 -0
- package/dist/cjs/mirroring/stats/statistics-dispatcher.js +104 -0
- package/dist/cjs/mirroring/stats/statistics-dispatcher.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics.d.ts +84 -0
- package/dist/cjs/mirroring/stats/statistics.js +147 -0
- package/dist/cjs/mirroring/stats/statistics.js.map +1 -0
- package/dist/cjs/mirroring/transport/udp-environment.d.ts +40 -0
- package/dist/cjs/mirroring/transport/udp-environment.js +97 -0
- package/dist/cjs/mirroring/transport/udp-environment.js.map +1 -0
- package/dist/cjs/polyfill/bridge-types.d.ts +11 -0
- package/dist/cjs/polyfill/presentation-receiver.d.ts +12 -0
- package/dist/cjs/polyfill/presentation-receiver.js +369 -0
- package/dist/cjs/polyfill/presentation-receiver.js.map +1 -0
- package/dist/cjs/polyfill/presentation-standin.js +157 -15
- package/dist/cjs/polyfill/presentation-standin.js.map +1 -1
- package/dist/cjs/protocol/framing.d.ts +1 -1
- package/dist/cjs/protocol/framing.js +1 -1
- package/dist/cjs/protocol/framing.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +56 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/auth/build-time.js +1 -1
- package/dist/client/auth/cast-auth.d.ts +2 -0
- package/dist/client/auth/cast-auth.js.map +1 -1
- package/dist/dial/dial-registry.d.ts +104 -0
- package/dist/dial/dial-registry.js +297 -0
- package/dist/dial/dial-registry.js.map +1 -0
- package/dist/dial/dial-sink-service.d.ts +108 -0
- package/dist/dial/dial-sink-service.js +310 -0
- package/dist/dial/dial-sink-service.js.map +1 -0
- package/dist/dial/http.d.ts +40 -0
- package/dist/dial/http.js +165 -0
- package/dist/dial/http.js.map +1 -0
- package/dist/dial/index.d.ts +63 -0
- package/dist/dial/index.js +115 -0
- package/dist/dial/index.js.map +1 -0
- package/dist/dial/origins.d.ts +4 -0
- package/dist/dial/origins.js +32 -0
- package/dist/dial/origins.js.map +1 -0
- package/dist/dial/parse.d.ts +101 -0
- package/dist/dial/parse.js +281 -0
- package/dist/dial/parse.js.map +1 -0
- package/dist/dial/route-provider.d.ts +96 -0
- package/dist/dial/route-provider.js +369 -0
- package/dist/dial/route-provider.js.map +1 -0
- package/dist/dial/ssdp-socket.d.ts +34 -0
- package/dist/dial/ssdp-socket.js +65 -0
- package/dist/dial/ssdp-socket.js.map +1 -0
- package/dist/dial/xml.d.ts +13 -0
- package/dist/dial/xml.js +204 -0
- package/dist/dial/xml.js.map +1 -0
- package/dist/dial-test/cli-main.d.ts +17 -0
- package/dist/dial-test/cli-main.js +130 -0
- package/dist/dial-test/cli-main.js.map +1 -0
- package/dist/dial-test/report.d.ts +55 -0
- package/dist/dial-test/report.js +77 -0
- package/dist/dial-test/report.js.map +1 -0
- package/dist/dial-test/runner.d.ts +42 -0
- package/dist/dial-test/runner.js +566 -0
- package/dist/dial-test/runner.js.map +1 -0
- package/dist/dial-test/scrub.d.ts +14 -0
- package/dist/dial-test/scrub.js +73 -0
- package/dist/dial-test/scrub.js.map +1 -0
- package/dist/discovery/cast-discovery.d.ts +2 -0
- package/dist/discovery/cast-discovery.js.map +1 -1
- package/dist/discovery/device-cache.d.ts +9 -0
- package/dist/discovery/device-cache.js.map +1 -1
- package/dist/discovery/index.d.ts +1 -0
- package/dist/discovery/index.js +1 -0
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/ip-policy.d.ts +20 -0
- package/dist/discovery/ip-policy.js +103 -0
- package/dist/discovery/ip-policy.js.map +1 -0
- package/dist/discovery/udp-socket.d.ts +3 -0
- package/dist/discovery/udp-socket.js +3 -0
- package/dist/discovery/udp-socket.js.map +1 -1
- package/dist/electron/access-code.d.ts +221 -0
- package/dist/electron/access-code.js +577 -0
- package/dist/electron/access-code.js.map +1 -0
- package/dist/electron/app-discovery.d.ts +82 -0
- package/dist/electron/app-discovery.js +215 -0
- package/dist/electron/app-discovery.js.map +1 -0
- package/dist/electron/default-presentation.d.ts +38 -0
- package/dist/electron/default-presentation.js +83 -0
- package/dist/electron/default-presentation.js.map +1 -0
- package/dist/electron/main.d.ts +98 -11
- package/dist/electron/main.js +597 -21
- package/dist/electron/main.js.map +1 -1
- package/dist/electron/manager-api.d.ts +200 -18
- package/dist/electron/manager-api.js +196 -4
- package/dist/electron/manager-api.js.map +1 -1
- package/dist/electron/media-controller.d.ts +79 -0
- package/dist/electron/media-controller.js +248 -0
- package/dist/electron/media-controller.js.map +1 -0
- package/dist/electron/network-monitor.d.ts +61 -0
- package/dist/electron/network-monitor.js +117 -0
- package/dist/electron/network-monitor.js.map +1 -0
- package/dist/electron/preload.js.map +1 -1
- package/dist/electron/presentation-handler.d.ts +39 -4
- package/dist/electron/presentation-handler.js +192 -48
- package/dist/electron/presentation-handler.js.map +1 -1
- package/dist/electron/presentation-source.d.ts +76 -0
- package/dist/electron/presentation-source.js +125 -0
- package/dist/electron/presentation-source.js.map +1 -0
- package/dist/electron/session-service.d.ts +198 -24
- package/dist/electron/session-service.js +629 -248
- package/dist/electron/session-service.js.map +1 -1
- package/dist/electron/session-tracker.d.ts +82 -0
- package/dist/electron/session-tracker.js +219 -0
- package/dist/electron/session-tracker.js.map +1 -0
- package/dist/electron/sink-service.d.ts +246 -0
- package/dist/electron/sink-service.js +602 -0
- package/dist/electron/sink-service.js.map +1 -0
- package/dist/electron/wired-display/controller.d.ts +76 -0
- package/dist/electron/wired-display/controller.js +194 -0
- package/dist/electron/wired-display/controller.js.map +1 -0
- package/dist/electron/wired-display/displays.d.ts +44 -0
- package/dist/electron/wired-display/displays.js +91 -0
- package/dist/electron/wired-display/displays.js.map +1 -0
- package/dist/electron/wired-display/electron-windows.d.ts +111 -0
- package/dist/electron/wired-display/electron-windows.js +301 -0
- package/dist/electron/wired-display/electron-windows.js.map +1 -0
- package/dist/electron/wired-display/index.d.ts +90 -0
- package/dist/electron/wired-display/index.js +99 -0
- package/dist/electron/wired-display/index.js.map +1 -0
- package/dist/electron/wired-display/local-presentation.d.ts +98 -0
- package/dist/electron/wired-display/local-presentation.js +228 -0
- package/dist/electron/wired-display/local-presentation.js.map +1 -0
- package/dist/electron/wired-display/provider.d.ts +112 -0
- package/dist/electron/wired-display/provider.js +197 -0
- package/dist/electron/wired-display/provider.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mirroring/backend.d.ts +76 -0
- package/dist/mirroring/backend.js +18 -0
- package/dist/mirroring/backend.js.map +1 -0
- package/dist/mirroring/electron/agent-protocol.d.ts +158 -0
- package/dist/mirroring/electron/agent-protocol.js +10 -0
- package/dist/mirroring/electron/agent-protocol.js.map +1 -0
- package/dist/mirroring/electron/agent-source.d.ts +20 -0
- package/dist/mirroring/electron/agent-source.js +618 -0
- package/dist/mirroring/electron/agent-source.js.map +1 -0
- package/dist/mirroring/electron/engine-process.d.ts +87 -0
- package/dist/mirroring/electron/engine-process.js +78 -0
- package/dist/mirroring/electron/engine-process.js.map +1 -0
- package/dist/mirroring/electron/host.d.ts +89 -0
- package/dist/mirroring/electron/host.js +318 -0
- package/dist/mirroring/electron/host.js.map +1 -0
- package/dist/mirroring/electron/port-backend.d.ts +107 -0
- package/dist/mirroring/electron/port-backend.js +441 -0
- package/dist/mirroring/electron/port-backend.js.map +1 -0
- package/dist/mirroring/encoding-support.d.ts +66 -0
- package/dist/mirroring/encoding-support.js +81 -0
- package/dist/mirroring/encoding-support.js.map +1 -0
- package/dist/mirroring/engine.d.ts +16 -0
- package/dist/mirroring/engine.js +75 -0
- package/dist/mirroring/engine.js.map +1 -0
- package/dist/mirroring/mirror-settings.d.ts +101 -0
- package/dist/mirroring/mirror-settings.js +134 -0
- package/dist/mirroring/mirror-settings.js.map +1 -0
- package/dist/mirroring/mirroring-activity.d.ts +207 -0
- package/dist/mirroring/mirroring-activity.js +362 -0
- package/dist/mirroring/mirroring-activity.js.map +1 -0
- package/dist/mirroring/mirroring-manager.d.ts +134 -0
- package/dist/mirroring/mirroring-manager.js +281 -0
- package/dist/mirroring/mirroring-manager.js.map +1 -0
- package/dist/mirroring/protocol/answer.d.ts +87 -0
- package/dist/mirroring/protocol/answer.js +226 -0
- package/dist/mirroring/protocol/answer.js.map +1 -0
- package/dist/mirroring/protocol/constants.d.ts +64 -0
- package/dist/mirroring/protocol/constants.js +66 -0
- package/dist/mirroring/protocol/constants.js.map +1 -0
- package/dist/mirroring/protocol/errors.d.ts +25 -0
- package/dist/mirroring/protocol/errors.js +29 -0
- package/dist/mirroring/protocol/errors.js.map +1 -0
- package/dist/mirroring/protocol/frame-id.d.ts +9 -0
- package/dist/mirroring/protocol/frame-id.js +20 -0
- package/dist/mirroring/protocol/frame-id.js.map +1 -0
- package/dist/mirroring/protocol/messenger.d.ts +42 -0
- package/dist/mirroring/protocol/messenger.js +118 -0
- package/dist/mirroring/protocol/messenger.js.map +1 -0
- package/dist/mirroring/protocol/offer.d.ts +109 -0
- package/dist/mirroring/protocol/offer.js +176 -0
- package/dist/mirroring/protocol/offer.js.map +1 -0
- package/dist/mirroring/protocol/recommendations.d.ts +28 -0
- package/dist/mirroring/protocol/recommendations.js +99 -0
- package/dist/mirroring/protocol/recommendations.js.map +1 -0
- package/dist/mirroring/routing.d.ts +60 -0
- package/dist/mirroring/routing.js +130 -0
- package/dist/mirroring/routing.js.map +1 -0
- package/dist/mirroring/rtcp/ntp.d.ts +27 -0
- package/dist/mirroring/rtcp/ntp.js +57 -0
- package/dist/mirroring/rtcp/ntp.js.map +1 -0
- package/dist/mirroring/rtcp/parser.d.ts +50 -0
- package/dist/mirroring/rtcp/parser.js +265 -0
- package/dist/mirroring/rtcp/parser.js.map +1 -0
- package/dist/mirroring/rtcp/sender-report.d.ts +32 -0
- package/dist/mirroring/rtcp/sender-report.js +51 -0
- package/dist/mirroring/rtcp/sender-report.js.map +1 -0
- package/dist/mirroring/rtcp/wire.d.ts +54 -0
- package/dist/mirroring/rtcp/wire.js +68 -0
- package/dist/mirroring/rtcp/wire.js.map +1 -0
- package/dist/mirroring/rtp/frame-crypto.d.ts +11 -0
- package/dist/mirroring/rtp/frame-crypto.js +35 -0
- package/dist/mirroring/rtp/frame-crypto.js.map +1 -0
- package/dist/mirroring/rtp/frame.d.ts +23 -0
- package/dist/mirroring/rtp/frame.js +2 -0
- package/dist/mirroring/rtp/frame.js.map +1 -0
- package/dist/mirroring/rtp/packetizer.d.ts +27 -0
- package/dist/mirroring/rtp/packetizer.js +88 -0
- package/dist/mirroring/rtp/packetizer.js.map +1 -0
- package/dist/mirroring/sender/audio-sender.d.ts +23 -0
- package/dist/mirroring/sender/audio-sender.js +54 -0
- package/dist/mirroring/sender/audio-sender.js.map +1 -0
- package/dist/mirroring/sender/bandwidth-estimator.d.ts +26 -0
- package/dist/mirroring/sender/bandwidth-estimator.js +103 -0
- package/dist/mirroring/sender/bandwidth-estimator.js.map +1 -0
- package/dist/mirroring/sender/capture-size-oracle.d.ts +121 -0
- package/dist/mirroring/sender/capture-size-oracle.js +433 -0
- package/dist/mirroring/sender/capture-size-oracle.js.map +1 -0
- package/dist/mirroring/sender/frame-sender.d.ts +103 -0
- package/dist/mirroring/sender/frame-sender.js +212 -0
- package/dist/mirroring/sender/frame-sender.js.map +1 -0
- package/dist/mirroring/sender/packet-router.d.ts +74 -0
- package/dist/mirroring/sender/packet-router.js +191 -0
- package/dist/mirroring/sender/packet-router.js.map +1 -0
- package/dist/mirroring/sender/sender-session.d.ts +85 -0
- package/dist/mirroring/sender/sender-session.js +235 -0
- package/dist/mirroring/sender/sender-session.js.map +1 -0
- package/dist/mirroring/sender/sender.d.ts +120 -0
- package/dist/mirroring/sender/sender.js +452 -0
- package/dist/mirroring/sender/sender.js.map +1 -0
- package/dist/mirroring/sender/video-encoder-metrics.d.ts +29 -0
- package/dist/mirroring/sender/video-encoder-metrics.js +58 -0
- package/dist/mirroring/sender/video-encoder-metrics.js.map +1 -0
- package/dist/mirroring/sender/video-sender.d.ts +95 -0
- package/dist/mirroring/sender/video-sender.js +190 -0
- package/dist/mirroring/sender/video-sender.js.map +1 -0
- package/dist/mirroring/session-host.d.ts +185 -0
- package/dist/mirroring/session-host.js +625 -0
- package/dist/mirroring/session-host.js.map +1 -0
- package/dist/mirroring/stats/clock-offset-estimator.d.ts +11 -0
- package/dist/mirroring/stats/clock-offset-estimator.js +120 -0
- package/dist/mirroring/stats/clock-offset-estimator.js.map +1 -0
- package/dist/mirroring/stats/openscreen-stats-client.d.ts +12 -0
- package/dist/mirroring/stats/openscreen-stats-client.js +17 -0
- package/dist/mirroring/stats/openscreen-stats-client.js.map +1 -0
- package/dist/mirroring/stats/sorted-map.d.ts +23 -0
- package/dist/mirroring/stats/sorted-map.js +66 -0
- package/dist/mirroring/stats/sorted-map.js.map +1 -0
- package/dist/mirroring/stats/statistics-analyzer.d.ts +50 -0
- package/dist/mirroring/stats/statistics-analyzer.js +335 -0
- package/dist/mirroring/stats/statistics-analyzer.js.map +1 -0
- package/dist/mirroring/stats/statistics-collector.d.ts +29 -0
- package/dist/mirroring/stats/statistics-collector.js +49 -0
- package/dist/mirroring/stats/statistics-collector.js.map +1 -0
- package/dist/mirroring/stats/statistics-common.d.ts +61 -0
- package/dist/mirroring/stats/statistics-common.js +39 -0
- package/dist/mirroring/stats/statistics-common.js.map +1 -0
- package/dist/mirroring/stats/statistics-dispatcher.d.ts +28 -0
- package/dist/mirroring/stats/statistics-dispatcher.js +100 -0
- package/dist/mirroring/stats/statistics-dispatcher.js.map +1 -0
- package/dist/mirroring/stats/statistics.d.ts +84 -0
- package/dist/mirroring/stats/statistics.js +141 -0
- package/dist/mirroring/stats/statistics.js.map +1 -0
- package/dist/mirroring/transport/udp-environment.d.ts +40 -0
- package/dist/mirroring/transport/udp-environment.js +93 -0
- package/dist/mirroring/transport/udp-environment.js.map +1 -0
- package/dist/polyfill/bridge-types.d.ts +11 -0
- package/dist/polyfill/presentation-receiver.d.ts +12 -0
- package/dist/polyfill/presentation-receiver.js +366 -0
- package/dist/polyfill/presentation-receiver.js.map +1 -0
- package/dist/polyfill/presentation-standin.js +157 -15
- package/dist/polyfill/presentation-standin.js.map +1 -1
- package/dist/protocol/framing.d.ts +1 -1
- package/dist/protocol/framing.js +1 -1
- package/dist/protocol/framing.js.map +1 -1
- package/docs/API.md +724 -0
- package/docs/ARCHITECTURE.md +242 -0
- package/docs/CHROMIUM-MAP.md +176 -0
- package/docs/DESIGN.md +1189 -0
- package/docs/FAQ.md +123 -0
- package/docs/GETTING-STARTED.md +248 -0
- package/docs/MAIN-API.md +524 -0
- package/docs/TROUBLESHOOTING.md +283 -0
- package/docs/guides/audio-and-groups.md +75 -0
- package/docs/guides/custom-receivers.md +109 -0
- package/docs/guides/device-authentication.md +145 -0
- package/docs/guides/device-picker.md +176 -0
- package/docs/guides/index.md +17 -0
- package/docs/guides/low-level-client.md +103 -0
- package/docs/guides/restart-rejoin.md +172 -0
- package/docs/guides/testing.md +162 -0
- package/docs/guides/windows-and-iframes.md +116 -0
- package/docs/readme/badges/dependencies.svg +1 -0
- package/docs/readme/badges/electron.svg +1 -0
- package/docs/readme/badges/license.svg +1 -0
- package/docs/readme/badges/node.svg +1 -0
- package/docs/readme/board.jpg +0 -0
- package/docs/readme/hero-dark.jpg +0 -0
- package/docs/readme/hero-light.jpg +0 -0
- package/docs/readme/nosignal.jpg +0 -0
- package/docs/readme/parity.jpg +0 -0
- package/docs/readme/trace.svg +22 -0
- package/package.json +21 -5
- package/src/cli.ts +57 -0
- package/src/client/auth/cast-auth.ts +2 -0
- package/src/dial/dial-registry.ts +316 -0
- package/src/dial/dial-sink-service.ts +343 -0
- package/src/dial/http.ts +200 -0
- package/src/dial/index.ts +135 -0
- package/src/dial/origins.ts +31 -0
- package/src/dial/parse.ts +319 -0
- package/src/dial/route-provider.ts +429 -0
- package/src/dial/ssdp-socket.ts +79 -0
- package/src/dial/xml.ts +180 -0
- package/src/dial-test/cli-main.ts +146 -0
- package/src/dial-test/report.ts +109 -0
- package/src/dial-test/runner.ts +615 -0
- package/src/dial-test/scrub.ts +74 -0
- package/src/discovery/cast-discovery.ts +2 -0
- package/src/discovery/device-cache.ts +5 -0
- package/src/discovery/index.ts +1 -0
- package/src/discovery/ip-policy.ts +97 -0
- package/src/discovery/udp-socket.ts +3 -0
- package/src/electron/access-code.ts +681 -0
- package/src/electron/app-discovery.ts +244 -0
- package/src/electron/default-presentation.ts +104 -0
- package/src/electron/main.ts +664 -29
- package/src/electron/manager-api.ts +367 -15
- package/src/electron/media-controller.ts +313 -0
- package/src/electron/network-monitor.ts +140 -0
- package/src/electron/preload.ts +1 -1
- package/src/electron/presentation-handler.ts +195 -48
- package/src/electron/presentation-source.ts +155 -0
- package/src/electron/session-service.ts +693 -238
- package/src/electron/session-tracker.ts +248 -0
- package/src/electron/sink-service.ts +726 -0
- package/src/electron/wired-display/controller.ts +212 -0
- package/src/electron/wired-display/displays.ts +107 -0
- package/src/electron/wired-display/electron-windows.ts +386 -0
- package/src/electron/wired-display/index.ts +181 -0
- package/src/electron/wired-display/local-presentation.ts +286 -0
- package/src/electron/wired-display/provider.ts +276 -0
- package/src/index.ts +1 -0
- package/src/mirroring/backend.ts +103 -0
- package/src/mirroring/electron/agent-protocol.ts +84 -0
- package/src/mirroring/electron/agent-source.ts +619 -0
- package/src/mirroring/electron/engine-process.ts +131 -0
- package/src/mirroring/electron/host.ts +361 -0
- package/src/mirroring/electron/port-backend.ts +466 -0
- package/src/mirroring/encoding-support.ts +146 -0
- package/src/mirroring/engine.ts +91 -0
- package/src/mirroring/mirror-settings.ts +174 -0
- package/src/mirroring/mirroring-activity.ts +466 -0
- package/src/mirroring/mirroring-manager.ts +342 -0
- package/src/mirroring/protocol/answer.ts +285 -0
- package/src/mirroring/protocol/constants.ts +75 -0
- package/src/mirroring/protocol/errors.ts +36 -0
- package/src/mirroring/protocol/frame-id.ts +20 -0
- package/src/mirroring/protocol/messenger.ts +128 -0
- package/src/mirroring/protocol/offer.ts +275 -0
- package/src/mirroring/protocol/recommendations.ts +135 -0
- package/src/mirroring/routing.ts +160 -0
- package/src/mirroring/rtcp/ntp.ts +61 -0
- package/src/mirroring/rtcp/parser.ts +292 -0
- package/src/mirroring/rtcp/sender-report.ts +88 -0
- package/src/mirroring/rtcp/wire.ts +76 -0
- package/src/mirroring/rtp/frame-crypto.ts +38 -0
- package/src/mirroring/rtp/frame.ts +25 -0
- package/src/mirroring/rtp/packetizer.ts +95 -0
- package/src/mirroring/sender/audio-sender.ts +59 -0
- package/src/mirroring/sender/bandwidth-estimator.ts +111 -0
- package/src/mirroring/sender/capture-size-oracle.ts +476 -0
- package/src/mirroring/sender/frame-sender.ts +293 -0
- package/src/mirroring/sender/packet-router.ts +228 -0
- package/src/mirroring/sender/sender-session.ts +306 -0
- package/src/mirroring/sender/sender.ts +497 -0
- package/src/mirroring/sender/video-encoder-metrics.ts +64 -0
- package/src/mirroring/sender/video-sender.ts +243 -0
- package/src/mirroring/session-host.ts +725 -0
- package/src/mirroring/stats/clock-offset-estimator.ts +139 -0
- package/src/mirroring/stats/openscreen-stats-client.ts +19 -0
- package/src/mirroring/stats/sorted-map.ts +68 -0
- package/src/mirroring/stats/statistics-analyzer.ts +388 -0
- package/src/mirroring/stats/statistics-collector.ts +69 -0
- package/src/mirroring/stats/statistics-common.ts +112 -0
- package/src/mirroring/stats/statistics-dispatcher.ts +133 -0
- package/src/mirroring/stats/statistics.ts +170 -0
- package/src/mirroring/transport/udp-environment.ts +100 -0
- package/src/polyfill/bridge-types.ts +11 -0
- package/src/polyfill/presentation-receiver.ts +350 -0
- package/src/polyfill/presentation-standin.ts +147 -15
- package/src/protocol/framing.ts +1 -1
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaRouteError = void 0;
|
|
3
|
+
exports.createAccessCodeSink = exports.AccessCodeCastDisabledError = exports.wiredDisplaySinks = exports.availableDisplays = exports.isWiredDisplaySource = exports.createReceiverWindows = exports.MediaRouteError = void 0;
|
|
4
4
|
exports.createCastManager = createCastManager;
|
|
5
5
|
const session_service_ts_1 = require("./session-service.js");
|
|
6
6
|
const index_ts_1 = require("../discovery/index.js");
|
|
7
7
|
const index_ts_2 = require("../client/index.js");
|
|
8
8
|
const presentation_handler_ts_1 = require("./presentation-handler.js");
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
10
|
const manager_api_ts_1 = require("./manager-api.js");
|
|
11
|
+
const presentation_envelope_ts_1 = require("./presentation-envelope.js");
|
|
12
|
+
const default_presentation_ts_1 = require("./default-presentation.js");
|
|
13
|
+
const local_presentation_ts_1 = require("./wired-display/local-presentation.js");
|
|
14
|
+
const index_ts_3 = require("./wired-display/index.js");
|
|
15
|
+
const network_monitor_ts_1 = require("./network-monitor.js");
|
|
16
|
+
const mirroring_manager_ts_1 = require("../mirroring/mirroring-manager.js");
|
|
17
|
+
const host_ts_1 = require("../mirroring/electron/host.js");
|
|
18
|
+
const index_ts_4 = require("../dial/index.js");
|
|
19
|
+
const parse_ts_1 = require("../dial/parse.js");
|
|
10
20
|
/**
|
|
11
21
|
* The methods a page may call over IPC: the bridge's own. The service also handles methods that only main calls
|
|
12
22
|
* (joinRunningSession, from the presentation handler), which a page must not reach directly.
|
|
@@ -17,6 +27,14 @@ const PAGE_METHODS = new Set([
|
|
|
17
27
|
]);
|
|
18
28
|
var manager_api_ts_2 = require("./manager-api.js");
|
|
19
29
|
Object.defineProperty(exports, "MediaRouteError", { enumerable: true, get: function () { return manager_api_ts_2.MediaRouteError; } });
|
|
30
|
+
var index_ts_5 = require("./wired-display/index.js");
|
|
31
|
+
Object.defineProperty(exports, "createReceiverWindows", { enumerable: true, get: function () { return index_ts_5.createReceiverWindows; } });
|
|
32
|
+
Object.defineProperty(exports, "isWiredDisplaySource", { enumerable: true, get: function () { return index_ts_5.isWiredDisplaySource; } });
|
|
33
|
+
Object.defineProperty(exports, "availableDisplays", { enumerable: true, get: function () { return index_ts_5.availableDisplays; } });
|
|
34
|
+
Object.defineProperty(exports, "wiredDisplaySinks", { enumerable: true, get: function () { return index_ts_5.wiredDisplaySinks; } });
|
|
35
|
+
var access_code_ts_1 = require("./access-code.js");
|
|
36
|
+
Object.defineProperty(exports, "AccessCodeCastDisabledError", { enumerable: true, get: function () { return access_code_ts_1.AccessCodeCastDisabledError; } });
|
|
37
|
+
Object.defineProperty(exports, "createAccessCodeSink", { enumerable: true, get: function () { return access_code_ts_1.createAccessCodeSink; } });
|
|
20
38
|
/** Availability watches kept per frame; the page never releases one, so the oldest are dropped. */
|
|
21
39
|
const MAX_WATCHES_PER_PAGE = 32;
|
|
22
40
|
/** Sender ids of subframes start here, far above any webContents id (a main frame's sender id is its webContents id). */
|
|
@@ -44,19 +62,136 @@ function originOf(frame) {
|
|
|
44
62
|
* a sender that leaves its sessions when it is destroyed or navigates. Unless
|
|
45
63
|
* `presentation: false` it also serves `<channel>:presentation` (see {@link CastManagerOptions.presentation}).
|
|
46
64
|
*/
|
|
65
|
+
/**
|
|
66
|
+
* A mirroring activity's view of the device's shared channel. Chrome runs every activity on a sink over its one
|
|
67
|
+
* `CastSocket`; here the activity's `connect()` only checks that channel is open and `close()` detaches the activity
|
|
68
|
+
* (its listeners go quiet) without closing the channel the other sessions and the session tracker use.
|
|
69
|
+
*/
|
|
70
|
+
function sharedChannelClient(deviceId, channel) {
|
|
71
|
+
let attached = true;
|
|
72
|
+
const need = () => {
|
|
73
|
+
if (channel === undefined || !channel.connected)
|
|
74
|
+
throw new Error(`no open channel to ${deviceId}`);
|
|
75
|
+
if (channel.senderId === undefined)
|
|
76
|
+
throw new Error("the Cast client has no senderId, which mirroring needs");
|
|
77
|
+
return channel;
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
get senderId() {
|
|
81
|
+
return channel?.senderId ?? "";
|
|
82
|
+
},
|
|
83
|
+
async connect() {
|
|
84
|
+
need();
|
|
85
|
+
},
|
|
86
|
+
close() {
|
|
87
|
+
attached = false;
|
|
88
|
+
},
|
|
89
|
+
send: (namespace, destinationId, payload) => {
|
|
90
|
+
if (attached)
|
|
91
|
+
need().send(namespace, destinationId, payload);
|
|
92
|
+
},
|
|
93
|
+
launch: (appId) => need().launch(appId),
|
|
94
|
+
stop: (sessionId) => need().stop(sessionId),
|
|
95
|
+
connectTransport: (transportId) => need().connectTransport(transportId),
|
|
96
|
+
closeTransport: (transportId) => need().closeTransport(transportId),
|
|
97
|
+
on(event, listener) {
|
|
98
|
+
channel?.on(event, (...args) => {
|
|
99
|
+
if (attached)
|
|
100
|
+
listener(...args);
|
|
101
|
+
});
|
|
102
|
+
return this;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** How long starting a default request on a DIAL sink waits for its app info, as a page's request does. */
|
|
107
|
+
const DIAL_APP_WAIT_MS = 5000;
|
|
108
|
+
/**
|
|
109
|
+
* The first `cast-dial:` URL, in order, whose app the DIAL sink has for a page at `origin`. Apps not known yet are
|
|
110
|
+
* asked about and the answers waited for (up to 5 s), as the Cast path asks the device (`checkAppAvailability`).
|
|
111
|
+
*/
|
|
112
|
+
async function dialUrlFor(dial, device, urls, origin) {
|
|
113
|
+
const candidates = urls.map((url) => ({ url, app: (0, parse_ts_1.isDialSource)(url) ? (0, parse_ts_1.appNameFromDialSource)(url) : "" })).filter((c) => c.app !== "");
|
|
114
|
+
const first = () => candidates.find((c) => dial.availableFor(c.app, origin).some((d) => d.id === device.id))?.url ?? null;
|
|
115
|
+
if (candidates.length === 0 || first() !== null)
|
|
116
|
+
return first();
|
|
117
|
+
const releases = candidates.map((c) => dial.monitorApp(c.app, origin)).filter((r) => r !== null);
|
|
118
|
+
if (releases.length === 0)
|
|
119
|
+
return null;
|
|
120
|
+
try {
|
|
121
|
+
await new Promise((resolve) => {
|
|
122
|
+
const done = () => {
|
|
123
|
+
clearTimeout(timer);
|
|
124
|
+
dial.off("change", check);
|
|
125
|
+
resolve();
|
|
126
|
+
};
|
|
127
|
+
const check = () => {
|
|
128
|
+
if (first() !== null)
|
|
129
|
+
done();
|
|
130
|
+
};
|
|
131
|
+
const timer = setTimeout(done, DIAL_APP_WAIT_MS);
|
|
132
|
+
dial.on("change", check);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
for (const release of releases)
|
|
137
|
+
release();
|
|
138
|
+
}
|
|
139
|
+
return first();
|
|
140
|
+
}
|
|
47
141
|
function createCastManager(options) {
|
|
48
142
|
const channel = options.channel ?? "electron-cast";
|
|
49
143
|
if (options.presentation !== false && (typeof options.ipcMain.on !== "function" || typeof options.ipcMain.removeListener !== "function")) {
|
|
50
144
|
throw new TypeError("presentation mode needs ipcMain.on and ipcMain.removeListener");
|
|
51
145
|
}
|
|
52
146
|
const discovery = options.discovery ?? new index_ts_1.CastDiscovery();
|
|
53
|
-
const
|
|
147
|
+
const networkMonitor = options.networkMonitor === false ? undefined
|
|
148
|
+
: options.networkMonitor ?? (options.discovery === undefined ? new network_monitor_ts_1.DiscoveryNetworkMonitor() : undefined);
|
|
149
|
+
const createClient = options.createClient ?? ((d, params) => new index_ts_2.CastClient({
|
|
150
|
+
host: d.host,
|
|
151
|
+
port: d.port,
|
|
152
|
+
verifyDevice: options.verifyDevices !== false,
|
|
153
|
+
connectTimeoutMs: params.connectTimeoutMs,
|
|
154
|
+
heartbeatTimeoutMs: params.livenessTimeoutMs,
|
|
155
|
+
heartbeatIntervalMs: params.pingIntervalMs,
|
|
156
|
+
}));
|
|
157
|
+
// The receiver labels of Cast and DIAL routes are hashed with one per-process token, as in Chrome.
|
|
158
|
+
const hashToken = (0, node_crypto_1.randomBytes)(16).toString("hex");
|
|
159
|
+
const dialOption = options.dial ?? (options.discovery === undefined);
|
|
160
|
+
// A DIAL sink whose processed UDN is a Cast sink's id is removed: CastMediaSinkServiceImpl removes it from the DIAL
|
|
161
|
+
// sink service when the Cast channel opens (OnChannelOpenSucceeded) and when the DIAL sink comes after the Cast one
|
|
162
|
+
// (TryConnectDialDiscoveredSink), and only DIAL discovery adds it back. A Cast sink is a device with an open, authenticated channel, not one mDNS merely
|
|
163
|
+
// heard, so this asks the session service; `service` exists before DIAL is started.
|
|
164
|
+
let castSinks = () => [];
|
|
165
|
+
const dial = dialOption === false ? undefined : new index_ts_4.DialService({
|
|
166
|
+
hashToken,
|
|
167
|
+
isCastDevice: (uuid) => castSinks().some((d) => (0, parse_ts_1.processDeviceUuid)(d.id) === uuid),
|
|
168
|
+
...(typeof dialOption === "object" ? dialOption : {}),
|
|
169
|
+
});
|
|
170
|
+
const routeListeners = new Set();
|
|
171
|
+
const notifyRoutes = () => {
|
|
172
|
+
for (const l of [...routeListeners])
|
|
173
|
+
l();
|
|
174
|
+
};
|
|
175
|
+
dial?.provider.on("routes", notifyRoutes);
|
|
176
|
+
// DIAL discovery follows the connection itself, as Chrome's DialRegistry observes the NetworkConnectionTracker.
|
|
177
|
+
const unobserveDialNetwork = dial === undefined || networkMonitor === undefined ? () => { }
|
|
178
|
+
: networkMonitor.observe((networkId) => dial.networksChanged(networkId !== network_monitor_ts_1.NETWORK_ID_DISCONNECTED));
|
|
179
|
+
/** The DIAL sinks as a device source: their one change event stands for a changed device. */
|
|
180
|
+
const dialSource = dial === undefined ? undefined : {
|
|
181
|
+
devices: () => dial.devices(),
|
|
182
|
+
on: (event, listener) => (event === "deviceChanged" ? dial.on("change", listener) : undefined),
|
|
183
|
+
off: (event, listener) => (event === "deviceChanged" ? dial.off("change", listener) : undefined),
|
|
184
|
+
};
|
|
54
185
|
const senders = new Map();
|
|
55
186
|
const subframeIds = new Map(); // frameTreeNodeId -> sender id
|
|
56
187
|
const watched = new Set(); // webContents ids
|
|
57
188
|
let nextSubframeId = SUBFRAME_ID_BASE;
|
|
58
189
|
let sweepTimer;
|
|
59
190
|
let handler;
|
|
191
|
+
/** Each window's default presentation request (Chrome keeps it per WebContents, from its outermost frame only). */
|
|
192
|
+
const defaults = new default_presentation_ts_1.DefaultPresentationRequests();
|
|
193
|
+
/** The route each window's main frame launched last (CastActivityManager's routes_by_frame_). */
|
|
194
|
+
const launchedFrom = new Map();
|
|
60
195
|
const findFrame = (wc, frameTreeNodeId) => {
|
|
61
196
|
try {
|
|
62
197
|
return wc.mainFrame?.framesInSubtree.find((f) => f.frameTreeNodeId === frameTreeNodeId);
|
|
@@ -145,11 +280,42 @@ function createCastManager(options) {
|
|
|
145
280
|
// the webContents or frame was destroyed between the check and the send
|
|
146
281
|
}
|
|
147
282
|
};
|
|
283
|
+
/**
|
|
284
|
+
* Starts whose URLs a display and a Cast device can both serve, while their picker is open. The one picker lists both kinds
|
|
285
|
+
* of sink, as Chrome's dialog does; a display chosen in it is recorded here and the Cast flow is told the user cancelled.
|
|
286
|
+
*/
|
|
287
|
+
const mixedStarts = new Map();
|
|
288
|
+
/** Tab and desktop mirroring, when the `mirroring` option is given (set up once the service exists). */
|
|
289
|
+
let mirroring;
|
|
148
290
|
const service = new session_service_ts_1.CastSessionService({
|
|
149
291
|
devices: discovery,
|
|
150
292
|
createClient,
|
|
151
|
-
|
|
293
|
+
// a mirroring route's session, or one being launched on the sink, is a local activity
|
|
294
|
+
ownsSession: (sessionId, sinkId) => mirroring?.routes().some((r) => r.sinkId === sinkId && (r.sessionId === sessionId || r.sessionId === "")) ?? false,
|
|
295
|
+
async selectDevice(devices, request, picker) {
|
|
296
|
+
const mixed = mixedStarts.get(request.senderId);
|
|
297
|
+
const choice = await options.selectDevice(devices, mixed === undefined ? request : { ...request, displays: mixed.displays }, picker);
|
|
298
|
+
if (typeof choice === "object" && choice !== null && "display" in choice) {
|
|
299
|
+
if (mixed !== undefined && mixed.displays.some((d) => d.id === choice.display))
|
|
300
|
+
mixed.chosen = choice.display;
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
return choice;
|
|
304
|
+
},
|
|
152
305
|
allowOrigin: options.allowOrigin,
|
|
306
|
+
sinks: options.sinks,
|
|
307
|
+
...(dial !== undefined && dialSource !== undefined ? {
|
|
308
|
+
dial: {
|
|
309
|
+
source: dialSource,
|
|
310
|
+
available: (app, origin) => dial.availableFor(app, origin),
|
|
311
|
+
monitor: (app, origin) => dial.monitorApp(app, origin),
|
|
312
|
+
},
|
|
313
|
+
} : {}),
|
|
314
|
+
accessCode: options.accessCode,
|
|
315
|
+
...(networkMonitor !== undefined ? { networkMonitor } : {}),
|
|
316
|
+
// The same one-route-per-frame rule (`routes_by_frame_`) from the other side: a page's Cast SDK or Presentation API
|
|
317
|
+
// session ends a mirroring route of that page. Subframe sender ids never match a tab, as only the main frame is one.
|
|
318
|
+
onSessionLaunched: (senderId) => mirroring?.stopMirroringRoutesOfTab(senderId),
|
|
153
319
|
emit(senderId, event) {
|
|
154
320
|
try {
|
|
155
321
|
handler?.onServiceEvent(senderId, event);
|
|
@@ -171,6 +337,7 @@ function createCastManager(options) {
|
|
|
171
337
|
for (const id of subframes())
|
|
172
338
|
dropSubframe(id);
|
|
173
339
|
presentation?.senderGone(wc.id);
|
|
340
|
+
defaults.forget(wc.id);
|
|
174
341
|
senders.delete(wc.id);
|
|
175
342
|
service.senderGone(wc.id);
|
|
176
343
|
});
|
|
@@ -209,12 +376,13 @@ function createCastManager(options) {
|
|
|
209
376
|
const id = registerSender(event.sender, event.senderFrame);
|
|
210
377
|
return service.handle({ id, origin }, method, params);
|
|
211
378
|
});
|
|
379
|
+
const wired = options.wiredDisplay !== undefined && options.presentation !== false ? (0, index_ts_3.createWiredDisplay)(options.wiredDisplay) : undefined;
|
|
212
380
|
/** Presentation mode: IPC for the page's stand-in Presentation API, answered by a CastPresentationHandler. */
|
|
213
381
|
const setUpPresentation = () => {
|
|
214
382
|
const ipc = options.ipcMain;
|
|
215
383
|
const on = ipc.on.bind(ipc);
|
|
216
384
|
const off = ipc.removeListener.bind(ipc);
|
|
217
|
-
const h = new presentation_handler_ts_1.CastPresentationHandler({ service });
|
|
385
|
+
const h = new presentation_handler_ts_1.CastPresentationHandler({ service, token: hashToken, ...(dial !== undefined ? { dial } : {}), dialRoutesChanged: notifyRoutes });
|
|
218
386
|
handler = h;
|
|
219
387
|
const connections = new Map();
|
|
220
388
|
const watches = new Map();
|
|
@@ -225,7 +393,9 @@ function createCastManager(options) {
|
|
|
225
393
|
const isId = (v) => typeof v === "string" && v !== "" && v.length <= 256;
|
|
226
394
|
const isUrls = (v) => Array.isArray(v) && v.length > 0 && v.length <= 16 && v.every((u) => typeof u === "string");
|
|
227
395
|
/** Finish a start/reconnect: register the connection and route its traffic to the page. */
|
|
228
|
-
const open = async (sid, connectionId, opening
|
|
396
|
+
const open = async (sid, connectionId, opening,
|
|
397
|
+
/** Runs once the connection exists and before any of its messages reach the page; false declines it. */
|
|
398
|
+
opened) => {
|
|
229
399
|
if (connections.has(connectionId))
|
|
230
400
|
return invalid("connectionId in use");
|
|
231
401
|
const slot = { conn: null, sid };
|
|
@@ -246,15 +416,77 @@ function createCastManager(options) {
|
|
|
246
416
|
return { ok: false, code: "AbortError", description: "The page went away" };
|
|
247
417
|
}
|
|
248
418
|
slot.conn = conn;
|
|
419
|
+
// A wired display connection starts out connecting, as Blink's does, and connects when the receiver page is ready
|
|
420
|
+
const local = conn;
|
|
421
|
+
if (typeof local.connecting === "boolean") {
|
|
422
|
+
conn.onconnect = () => sendTo(sid, { type: "statechange", connectionId, state: "connected" });
|
|
423
|
+
}
|
|
249
424
|
conn.onclose = (state) => {
|
|
250
425
|
if (connections.get(connectionId) === slot)
|
|
251
426
|
connections.delete(connectionId);
|
|
252
427
|
sendTo(sid, { type: "statechange", connectionId, state });
|
|
253
428
|
};
|
|
429
|
+
if (opened?.(conn) === false) {
|
|
430
|
+
// Declined (OnPresentationResponse hands a connection only to the request it answers): the session stays, but the
|
|
431
|
+
// connection belongs to nobody, so nothing of it reaches the page that has the sender id now
|
|
432
|
+
connections.delete(connectionId);
|
|
433
|
+
conn.onclose = null;
|
|
434
|
+
conn.onmessage = () => { };
|
|
435
|
+
return { ok: true, value: { id: conn.id, url: conn.url } };
|
|
436
|
+
}
|
|
254
437
|
// The stand-in registered this connectionId before calling, so it buffers anything sent before the reply.
|
|
255
|
-
|
|
256
|
-
|
|
438
|
+
if (typeof local.connecting === "boolean") {
|
|
439
|
+
conn.onmessage = (data) => sendTo(sid, { type: "message", connectionId, ...(0, local_presentation_ts_1.messageFields)(data) });
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
conn.onmessage = (data) => sendTo(sid, { type: "message", connectionId, data });
|
|
443
|
+
}
|
|
444
|
+
return { ok: true, value: { id: conn.id, url: conn.url, ...(local.connecting === true ? { state: "connecting" } : {}), ...(typeof local.connecting === "boolean" ? { local: true } : {}) } };
|
|
445
|
+
};
|
|
446
|
+
/** A start() whose URLs only a display can show: the app picks a display, a window opens on it. */
|
|
447
|
+
const startOnDisplay = async (sid, origin, urls) => {
|
|
448
|
+
const w = wired;
|
|
449
|
+
const wc = senders.get(sid)?.wc;
|
|
450
|
+
const sinks = w.sinksFor(wc);
|
|
451
|
+
const request = { urls: [...urls], origin, senderId: sid, observeSinks: (l) => w.observeSinksFor(wc, l) };
|
|
452
|
+
const choice = await w.selectDisplay(sinks, request);
|
|
453
|
+
if (choice === null)
|
|
454
|
+
throw new presentation_handler_ts_1.PresentationError("AbortError", "The user cancelled the request");
|
|
455
|
+
return w.controllers.start(request, choice);
|
|
456
|
+
};
|
|
457
|
+
/** A URL the Cast provider serves (a Cast app URL), or the DIAL provider (a `cast-dial:` URL, when DIAL is on). */
|
|
458
|
+
const providerUrl = (u) => (0, presentation_envelope_ts_1.parsePresentationUrl)(u) !== null || (dial !== undefined && (0, parse_ts_1.isDialSource)(u));
|
|
459
|
+
/** The URLs of a request that the Cast and DIAL providers serve. */
|
|
460
|
+
const castUrlsOf = (urls) => urls.filter(providerUrl);
|
|
461
|
+
/**
|
|
462
|
+
* A start() whose URLs a display and a Cast device can both serve: one picker offers both kinds and the sink it returns
|
|
463
|
+
* decides (a display starts a wired display presentation, a device the Cast flow). With no displays or no devices there
|
|
464
|
+
* is nothing to choose between and the flow of the one kind that exists runs.
|
|
465
|
+
*/
|
|
466
|
+
const startMixed = async (sid, origin, urls) => {
|
|
467
|
+
const w = wired;
|
|
468
|
+
const wc = senders.get(sid)?.wc;
|
|
469
|
+
const displays = w.sinksFor(wc);
|
|
470
|
+
const castUrls = castUrlsOf(urls);
|
|
471
|
+
if (displays.length === 0 || service.devices().length + (dial?.devices().length ?? 0) === 0) {
|
|
472
|
+
return displays.length > 0 ? startOnDisplay(sid, origin, urls) : h.startPresentation({ urls: castUrls, origin, senderId: sid });
|
|
473
|
+
}
|
|
474
|
+
const mixed = { displays, chosen: null };
|
|
475
|
+
mixedStarts.set(sid, mixed);
|
|
476
|
+
try {
|
|
477
|
+
return await h.startPresentation({ urls: castUrls, origin, senderId: sid });
|
|
478
|
+
}
|
|
479
|
+
catch (err) {
|
|
480
|
+
if (mixed.chosen === null)
|
|
481
|
+
throw err;
|
|
482
|
+
return w.controllers.start({ urls: [...urls], origin, senderId: sid }, mixed.chosen);
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
mixedStarts.delete(sid);
|
|
486
|
+
}
|
|
257
487
|
};
|
|
488
|
+
/** Only a display serves these URLs: one is a standard presentation source and none is a Cast or DIAL one. */
|
|
489
|
+
const displayOnly = (urls) => wired !== undefined && urls.some((u) => (0, index_ts_3.isWiredDisplaySource)(u)) && !urls.some(providerUrl);
|
|
258
490
|
ipc.handle(`${channel}:presentation`, async (event, method, params) => {
|
|
259
491
|
const origin = originOf(event.senderFrame);
|
|
260
492
|
if (origin === null || event.senderFrame === null)
|
|
@@ -281,6 +513,41 @@ function createCastManager(options) {
|
|
|
281
513
|
}
|
|
282
514
|
const ac = new AbortController();
|
|
283
515
|
watches.set(watchId, { ac, sid });
|
|
516
|
+
if (wired !== undefined && p.urls.some((u) => (0, index_ts_3.isWiredDisplaySource)(u))) {
|
|
517
|
+
// Blink ORs the sources of a request: available when displays exist for a standard source, or the
|
|
518
|
+
// request's Cast URLs have a device. Displays are not hidden here (only the dialog hides one).
|
|
519
|
+
const castUrls = p.urls.filter((u) => !(0, index_ts_3.isWiredDisplaySource)(u));
|
|
520
|
+
let displays = false;
|
|
521
|
+
let cast = false;
|
|
522
|
+
let ready = false;
|
|
523
|
+
let last = false;
|
|
524
|
+
const update = () => {
|
|
525
|
+
const next = displays || cast;
|
|
526
|
+
if (!ready || next === last)
|
|
527
|
+
return;
|
|
528
|
+
last = next;
|
|
529
|
+
sendTo(sid, { type: "availability", watchId, value: next });
|
|
530
|
+
};
|
|
531
|
+
const stop = wired.provider.observeSinks((sinks) => {
|
|
532
|
+
displays = sinks.length > 0;
|
|
533
|
+
update();
|
|
534
|
+
});
|
|
535
|
+
ac.signal.addEventListener("abort", stop, { once: true });
|
|
536
|
+
if (ac.signal.aborted)
|
|
537
|
+
stop();
|
|
538
|
+
if (castUrls.length > 0) {
|
|
539
|
+
cast = await h.getAvailability({
|
|
540
|
+
urls: castUrls, origin, senderId: sid, signal: ac.signal,
|
|
541
|
+
onchange: (value) => {
|
|
542
|
+
cast = value;
|
|
543
|
+
update();
|
|
544
|
+
},
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
ready = true;
|
|
548
|
+
last = displays || cast;
|
|
549
|
+
return { ok: true, value: { available: last } };
|
|
550
|
+
}
|
|
284
551
|
const available = await h.getAvailability({
|
|
285
552
|
urls: p.urls,
|
|
286
553
|
origin,
|
|
@@ -290,6 +557,16 @@ function createCastManager(options) {
|
|
|
290
557
|
});
|
|
291
558
|
return { ok: true, value: { available } };
|
|
292
559
|
}
|
|
560
|
+
case "setDefaultRequest": {
|
|
561
|
+
// Blink's Presentation::setDefaultRequest sends the URLs on every set (none when it is cleared)
|
|
562
|
+
if (!Array.isArray(p.urls) || p.urls.length > 16 || !p.urls.every((u) => typeof u === "string" && u.length <= 4096)) {
|
|
563
|
+
return invalid("setDefaultRequest expects { urls }");
|
|
564
|
+
}
|
|
565
|
+
// PresentationServiceImpl::SetDefaultPresentationUrls ignores a frame that is not the outermost document
|
|
566
|
+
if (isMainFrame(event.senderFrame))
|
|
567
|
+
defaults.set(event.sender.id, p.urls, origin);
|
|
568
|
+
return { ok: true, value: undefined };
|
|
569
|
+
}
|
|
293
570
|
case "stopWatching": {
|
|
294
571
|
const w = isId(p.watchId) ? watches.get(p.watchId) : undefined;
|
|
295
572
|
if (w !== undefined && w.sid === sid) {
|
|
@@ -307,7 +584,17 @@ function createCastManager(options) {
|
|
|
307
584
|
}
|
|
308
585
|
{
|
|
309
586
|
const urls = p.urls;
|
|
310
|
-
|
|
587
|
+
// A display-only request opens a window on a display; a request a display and a sink can both serve goes to
|
|
588
|
+
// the one picker; the rest is the Cast (and DIAL) provider's
|
|
589
|
+
if (displayOnly(urls))
|
|
590
|
+
return await open(sid, p.connectionId, () => startOnDisplay(sid, origin, urls));
|
|
591
|
+
const started = wired !== undefined && urls.some((u) => (0, index_ts_3.isWiredDisplaySource)(u))
|
|
592
|
+
? await open(sid, p.connectionId, () => startMixed(sid, origin, urls))
|
|
593
|
+
: await open(sid, p.connectionId, () => h.startPresentation({ urls, origin, senderId: sid }));
|
|
594
|
+
// CastActivityManager's earlier-route rule is for Cast sessions only
|
|
595
|
+
if (started.ok && started.value.id.startsWith("cast-session_"))
|
|
596
|
+
launchedFrom.set(sid, started.value.id.slice("cast-session_".length));
|
|
597
|
+
return started;
|
|
311
598
|
}
|
|
312
599
|
case "reconnect":
|
|
313
600
|
if (!isId(p.connectionId) || !isUrls(p.urls) || !isId(p.presentationId)) {
|
|
@@ -315,7 +602,12 @@ function createCastManager(options) {
|
|
|
315
602
|
}
|
|
316
603
|
{
|
|
317
604
|
const { urls, presentationId } = p;
|
|
318
|
-
|
|
605
|
+
// A local presentation (a display) is joined again from any page, by its id; for a URL only a display
|
|
606
|
+
// serves, an id that is not local is the provider's unknown error, which the page sees as NotFoundError
|
|
607
|
+
if (wired !== undefined && (displayOnly(urls) || wired.provider.local.isLocalPresentation(presentationId))) {
|
|
608
|
+
return await open(sid, p.connectionId, async () => wired.controllers.reconnect({ urls, senderId: sid }, presentationId));
|
|
609
|
+
}
|
|
610
|
+
return await open(sid, p.connectionId, () => h.reconnectPresentation({ urls: wired !== undefined && castUrlsOf(urls).length > 0 ? castUrlsOf(urls) : urls, origin, senderId: sid, presentationId }));
|
|
319
611
|
}
|
|
320
612
|
case "close":
|
|
321
613
|
case "terminate": {
|
|
@@ -337,20 +629,35 @@ function createCastManager(options) {
|
|
|
337
629
|
}
|
|
338
630
|
});
|
|
339
631
|
const onSend = (event, connectionId, data) => {
|
|
340
|
-
if (typeof connectionId !== "string"
|
|
632
|
+
if (typeof connectionId !== "string")
|
|
341
633
|
return;
|
|
342
634
|
const c = connections.get(connectionId);
|
|
343
635
|
if (c === undefined || c.sid !== senderIdOf(event.sender, event.senderFrame) || c.conn === null)
|
|
344
636
|
return;
|
|
345
|
-
|
|
637
|
+
const isLocal = typeof c.conn.connecting === "boolean";
|
|
638
|
+
if (typeof data === "string") {
|
|
639
|
+
// The stand-in refuses an oversized send() with a RangeError; this is for a page that does not use it
|
|
640
|
+
if (data.length <= (isLocal ? local_presentation_ts_1.MAX_MESSAGE_SIZE : MAX_MESSAGE_CHARS))
|
|
641
|
+
c.conn.send(data);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const bytes = (0, local_presentation_ts_1.asBytes)(data);
|
|
645
|
+
if (bytes === null || bytes.byteLength > local_presentation_ts_1.MAX_MESSAGE_SIZE)
|
|
346
646
|
return;
|
|
347
|
-
|
|
647
|
+
// A wired display carries bytes (PresentationConnectionMessage.data). A Cast connection drops them, as Chrome's
|
|
648
|
+
// CastSessionClientImpl::OnMessage does with anything that is not text.
|
|
649
|
+
if (isLocal)
|
|
650
|
+
c.conn.send(bytes);
|
|
348
651
|
};
|
|
349
652
|
on(`${channel}:presentation:send`, onSend);
|
|
350
653
|
return {
|
|
351
654
|
/** Close the page's connections and watches before the service drops it. */
|
|
352
655
|
senderGone(sid) {
|
|
656
|
+
// PresentationServiceImpl::Reset (navigation, frame gone): the frame's default request goes with it
|
|
657
|
+
defaults.clear(sid);
|
|
658
|
+
launchedFrom.delete(sid);
|
|
353
659
|
h.senderGone(sid);
|
|
660
|
+
wired?.controllers.senderGone(sid);
|
|
354
661
|
for (const [id, c] of connections)
|
|
355
662
|
if (c.sid === sid)
|
|
356
663
|
connections.delete(id);
|
|
@@ -361,6 +668,96 @@ function createCastManager(options) {
|
|
|
361
668
|
watches.delete(id);
|
|
362
669
|
}
|
|
363
670
|
},
|
|
671
|
+
/**
|
|
672
|
+
* MediaRouterUI::StartCasting(sink, PRESENTATION) on the window's default request: MediaRouteStarter's
|
|
673
|
+
* CreateRouteParameters, MediaRouter::CreateRoute, then WebContentsPresentationManager::OnPresentationResponse.
|
|
674
|
+
*/
|
|
675
|
+
async startDefaultPresentation(webContentsId, sinkId) {
|
|
676
|
+
const request = defaults.get(webContentsId);
|
|
677
|
+
const serial = defaults.serialOf(webContentsId);
|
|
678
|
+
// No source for the sink (no default request, or its URLs do not suit the sink): CreateRouteParameters is null
|
|
679
|
+
const unable = (why) => new manager_api_ts_1.MediaRouteError("unable_to_cast", why);
|
|
680
|
+
if (request === null)
|
|
681
|
+
throw unable("the window has no default presentation request");
|
|
682
|
+
// The dialog's sinks are the Cast sinks and the DIAL sinks (QueryResultManager observes each URL's source, and
|
|
683
|
+
// the DIAL provider serves the cast-dial: ones)
|
|
684
|
+
const device = [...service.devices(), ...(dial?.devices() ?? [])].find((d) => d.id === sinkId);
|
|
685
|
+
if (device === undefined)
|
|
686
|
+
throw unable(`no sink ${sinkId}`);
|
|
687
|
+
// GetSourceForCastModeAndSink: the first URL, in order, the sink is compatible with. A Cast sink is a source's
|
|
688
|
+
// once the device says the app is there (CastAppAvailabilityTracker::GetAvailableSinks); a DIAL sink once its
|
|
689
|
+
// DIAL server says so for the page's origin (DialMediaSinkServiceImpl, DialMediaRouteProvider::GetOrigins).
|
|
690
|
+
let url = null;
|
|
691
|
+
if (device.dial !== undefined) {
|
|
692
|
+
url = dial === undefined ? null : await dialUrlFor(dial, device, request.presentationUrls, request.frameOrigin);
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
for (const candidate of request.presentationUrls) {
|
|
696
|
+
const parsed = (0, presentation_envelope_ts_1.parsePresentationUrl)(candidate);
|
|
697
|
+
if (parsed === null || (0, manager_api_ts_1.presentationUrlForDevice)(device, [candidate]) === null)
|
|
698
|
+
continue;
|
|
699
|
+
if (await service.checkAppAvailability(device, parsed.appId)) {
|
|
700
|
+
url = candidate;
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (url === null)
|
|
706
|
+
throw unable("the sink cannot run the default presentation request's URLs");
|
|
707
|
+
// the page navigated or cleared its request while the device was asked
|
|
708
|
+
if (defaults.serialOf(webContentsId) !== serial) {
|
|
709
|
+
throw new manager_api_ts_1.MediaRouteError("cancelled", "the window's default presentation request changed while the device was asked");
|
|
710
|
+
}
|
|
711
|
+
// CastActivityManager::DoLaunchSession stops the route this frame launched before, then launches
|
|
712
|
+
const earlier = launchedFrom.get(webContentsId);
|
|
713
|
+
if (earlier !== undefined && routes().some((r) => r.id === earlier))
|
|
714
|
+
void service.terminateSession(earlier);
|
|
715
|
+
if (!senders.has(webContentsId))
|
|
716
|
+
throw unable("the window is gone");
|
|
717
|
+
const connectionId = (0, node_crypto_1.randomUUID)();
|
|
718
|
+
let failure;
|
|
719
|
+
const result = await open(webContentsId, connectionId, () => h.startPresentation({
|
|
720
|
+
urls: [url, ...request.presentationUrls.filter((u) => u !== url)],
|
|
721
|
+
origin: request.frameOrigin,
|
|
722
|
+
senderId: webContentsId,
|
|
723
|
+
deviceId: device.id,
|
|
724
|
+
}).catch((err) => {
|
|
725
|
+
failure = err;
|
|
726
|
+
throw err;
|
|
727
|
+
}), (conn) => {
|
|
728
|
+
// OnPresentationResponse hands the connection to the page only while the request it answers is still the default one
|
|
729
|
+
const current = defaults.get(webContentsId);
|
|
730
|
+
if (current === null || !(0, default_presentation_ts_1.samePresentationRequest)(current, request))
|
|
731
|
+
return false;
|
|
732
|
+
sendTo(webContentsId, { type: "connectionavailable", connectionId, id: conn.id, url: conn.url });
|
|
733
|
+
return true;
|
|
734
|
+
});
|
|
735
|
+
if (!result.ok) {
|
|
736
|
+
// RouteRequestResultCode, from the cause the handler saw
|
|
737
|
+
const bridge = failure?.bridgeCode;
|
|
738
|
+
const code = bridge === "timeout" ? "timed_out"
|
|
739
|
+
: bridge === "cancel" || (failure === undefined && result.code === "AbortError") ? "cancelled"
|
|
740
|
+
: bridge === "receiver_unavailable" ? "sink_not_found"
|
|
741
|
+
: bridge === "extension_missing" ? "invalid_origin"
|
|
742
|
+
: bridge === "invalid_parameter" ? "redundant_request"
|
|
743
|
+
: "unknown_error";
|
|
744
|
+
throw new manager_api_ts_1.MediaRouteError(code, result.description);
|
|
745
|
+
}
|
|
746
|
+
if (device.dial !== undefined) {
|
|
747
|
+
// A DIAL route's id is MediaRoute::GetMediaRouteId(presentation id, sink id, source)
|
|
748
|
+
const prefix = `urn:x-org.chromium:media:route:${result.value.id}/`;
|
|
749
|
+
const dialRoute = routes().find((r) => r.providerId === "dial" && r.id.startsWith(prefix));
|
|
750
|
+
if (dialRoute === undefined)
|
|
751
|
+
throw new manager_api_ts_1.MediaRouteError("route_not_found", `no route for ${result.value.id}`);
|
|
752
|
+
return dialRoute;
|
|
753
|
+
}
|
|
754
|
+
const sessionId = result.value.id.slice("cast-session_".length);
|
|
755
|
+
launchedFrom.set(webContentsId, sessionId);
|
|
756
|
+
const route = routes().find((r) => r.id === sessionId);
|
|
757
|
+
if (route === undefined)
|
|
758
|
+
throw new manager_api_ts_1.MediaRouteError("route_not_found", `no route ${sessionId}`);
|
|
759
|
+
return route;
|
|
760
|
+
},
|
|
364
761
|
dispose() {
|
|
365
762
|
ipc.removeHandler(`${channel}:presentation`);
|
|
366
763
|
off(`${channel}:presentation:send`, onSend);
|
|
@@ -375,25 +772,210 @@ function createCastManager(options) {
|
|
|
375
772
|
// The service knows frames by sender id (an iframe has a synthetic one); the API speaks of windows, so a route's
|
|
376
773
|
// pages are reported as `webContents.id`s, once each however many of its frames hold the route.
|
|
377
774
|
const windowIds = (ids) => [...new Set(ids.map((id) => senders.get(id)?.wc.id ?? id))];
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
775
|
+
// Tab and desktop mirroring: MirroringActivity, a CastActivity that runs on the device's one channel
|
|
776
|
+
let disposeMirroring;
|
|
777
|
+
if (options.mirroring !== undefined) {
|
|
778
|
+
const m = options.mirroring;
|
|
779
|
+
let createService;
|
|
780
|
+
if ("createService" in m) {
|
|
781
|
+
createService = m.createService;
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
const electron = (0, host_ts_1.createElectronMirroringServiceFactory)(m);
|
|
785
|
+
createService = electron.factory;
|
|
786
|
+
disposeMirroring = () => electron.dispose();
|
|
787
|
+
}
|
|
788
|
+
mirroring = new mirroring_manager_ts_1.MirroringManager({
|
|
789
|
+
// only a sink (an open, authenticated channel) can be cast to
|
|
790
|
+
findDevice: (id) => service.devices().find((d) => d.id === id),
|
|
791
|
+
createClient: (d) => sharedChannelClient(d.id, service.channelClient(d.id)),
|
|
792
|
+
createService,
|
|
793
|
+
terminateRoutesOfPage: (wcId) => {
|
|
794
|
+
for (const id of service.sessionsLaunchedBy(wcId))
|
|
795
|
+
void service.terminateSession(id);
|
|
796
|
+
},
|
|
797
|
+
commandLine: "electron" in m ? m.electron.app?.commandLine : undefined,
|
|
798
|
+
log: (level, message) => (level === "error" ? console.error : console.debug)(`electron-cast mirroring: ${message}`),
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
const dialRoutes = () => (dial?.provider.routes() ?? []).map((r) => {
|
|
802
|
+
const members = windowIds(handler?.dialMembers(r.id) ?? []);
|
|
803
|
+
return {
|
|
804
|
+
id: r.id,
|
|
805
|
+
providerId: "dial",
|
|
806
|
+
mediaSource: r.mediaSource,
|
|
807
|
+
sinkId: r.sinkId,
|
|
808
|
+
sinkName: dial?.devices().find((d) => d.id === r.sinkId)?.name ?? "",
|
|
809
|
+
isLocal: true,
|
|
810
|
+
description: r.appName,
|
|
811
|
+
appId: "",
|
|
812
|
+
displayName: r.appName,
|
|
813
|
+
origin: r.origin,
|
|
814
|
+
volume: { level: null, muted: null },
|
|
815
|
+
members,
|
|
816
|
+
parkedSenders: [],
|
|
817
|
+
parked: members.length === 0,
|
|
818
|
+
};
|
|
384
819
|
});
|
|
820
|
+
const mirroringRoutes = () => (mirroring?.routes() ?? []).map((r) => ({
|
|
821
|
+
id: r.id,
|
|
822
|
+
providerId: "cast",
|
|
823
|
+
mediaSource: r.mediaSource,
|
|
824
|
+
sinkId: r.sinkId,
|
|
825
|
+
sinkName: service.devices().find((d) => d.id === r.sinkId)?.name ?? "",
|
|
826
|
+
isLocal: true,
|
|
827
|
+
description: r.description,
|
|
828
|
+
appId: r.appId,
|
|
829
|
+
displayName: r.displayName,
|
|
830
|
+
origin: "",
|
|
831
|
+
volume: { level: null, muted: null },
|
|
832
|
+
members: r.webContentsId === undefined ? [] : [r.webContentsId],
|
|
833
|
+
parkedSenders: [],
|
|
834
|
+
parked: false,
|
|
835
|
+
freezeInfo: r.freezeInfo,
|
|
836
|
+
}));
|
|
837
|
+
const routes = () => [
|
|
838
|
+
...service.mediaRoutes().map((r) => ({ ...r, members: windowIds(r.members), parkedSenders: windowIds(r.parkedSenders) })),
|
|
839
|
+
...dialRoutes(),
|
|
840
|
+
...mirroringRoutes(),
|
|
841
|
+
];
|
|
842
|
+
const isMirroringRoute = (id) => mirroring?.routes().some((r) => r.id === id) ?? false;
|
|
843
|
+
const isDialRoute = (id) => dial?.provider.routes().some((r) => r.id === id) ?? false;
|
|
844
|
+
const notDial = { ok: false, code: "invalid_parameter", description: "A DIAL route has no volume or media control" };
|
|
845
|
+
const castDevices = service.deviceSource();
|
|
846
|
+
const api = (0, manager_api_ts_1.createManagerApi)((0, manager_api_ts_1.createSinksObservers)(dialSource === undefined ? castDevices : (0, manager_api_ts_1.combineSources)(castDevices, dialSource), {
|
|
847
|
+
cached: (d, appId) => service.cachedAppAvailability(d, appId),
|
|
848
|
+
check: (d, appId) => service.checkAppAvailability(d, appId),
|
|
849
|
+
...(dial === undefined ? {} : {
|
|
850
|
+
dial: {
|
|
851
|
+
available: (d, app, origin) => dial.availableFor(app, origin).some((x) => x.id === d.id),
|
|
852
|
+
monitor: (app, origin) => dial.monitorApp(app, origin),
|
|
853
|
+
},
|
|
854
|
+
}),
|
|
855
|
+
}), {
|
|
856
|
+
mediaRoutes: routes,
|
|
857
|
+
observeSessions: (l) => {
|
|
858
|
+
const off = service.observeSessions(l);
|
|
859
|
+
const offMirroring = mirroring?.observe(l);
|
|
860
|
+
routeListeners.add(l);
|
|
861
|
+
return () => {
|
|
862
|
+
off();
|
|
863
|
+
offMirroring?.();
|
|
864
|
+
routeListeners.delete(l);
|
|
865
|
+
};
|
|
866
|
+
},
|
|
867
|
+
async terminateSession(id) {
|
|
868
|
+
if (mirroring?.terminate(id) === true)
|
|
869
|
+
return { ok: true, value: undefined };
|
|
870
|
+
if (!isDialRoute(id))
|
|
871
|
+
return service.terminateSession(id);
|
|
872
|
+
try {
|
|
873
|
+
await dial.provider.terminateRoute(id);
|
|
874
|
+
return { ok: true, value: undefined };
|
|
875
|
+
}
|
|
876
|
+
catch (err) {
|
|
877
|
+
const e = err;
|
|
878
|
+
return { ok: false, code: typeof e.code === "string" ? e.code : "session_error", description: String(e.message ?? err) };
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
setSessionVolume: async (id, v) => (isDialRoute(id) ? notDial : service.setSessionVolume(id, v)),
|
|
882
|
+
startCasting: mirroring === undefined
|
|
883
|
+
? undefined
|
|
884
|
+
: async (sinkId, o) => {
|
|
885
|
+
const m = mirroring;
|
|
886
|
+
try {
|
|
887
|
+
const route = await m.startMirroring(sinkId, o);
|
|
888
|
+
const listed = routes().find((r) => r.id === route.id);
|
|
889
|
+
if (listed === undefined)
|
|
890
|
+
throw new manager_api_ts_1.MediaRouteError("route_not_found", `no route ${route.id}`);
|
|
891
|
+
return listed;
|
|
892
|
+
}
|
|
893
|
+
catch (err) {
|
|
894
|
+
if (err instanceof mirroring_manager_ts_1.MirroringRouteError)
|
|
895
|
+
throw new manager_api_ts_1.MediaRouteError(err.code, err.message);
|
|
896
|
+
throw err;
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
detachSession(id) {
|
|
900
|
+
if (isMirroringRoute(id))
|
|
901
|
+
return { ok: false, code: "invalid_parameter", description: "A mirroring route cannot be detached" };
|
|
902
|
+
if (!isDialRoute(id))
|
|
903
|
+
return service.detachSession(id);
|
|
904
|
+
handler?.detachDialRoute(id);
|
|
905
|
+
return { ok: true, value: undefined };
|
|
906
|
+
},
|
|
907
|
+
sendSessionMessage: (id, ns, m) => (isDialRoute(id) ? notDial : service.sendSessionMessage(id, ns, m)),
|
|
908
|
+
observeSessionStatus: (l) => service.observeSessionStatus(l),
|
|
909
|
+
observeMediaStatus: (l) => service.observeMediaStatus(l),
|
|
910
|
+
sessionVolume: (id) => service.sessionVolume(id),
|
|
911
|
+
switchMirroringSourceTab: mirroring === undefined
|
|
912
|
+
? undefined
|
|
913
|
+
: (id, webContentsId) => {
|
|
914
|
+
try {
|
|
915
|
+
mirroring.switchMirroringSourceTab(id, webContentsId);
|
|
916
|
+
}
|
|
917
|
+
catch (err) {
|
|
918
|
+
if (err instanceof mirroring_manager_ts_1.MirroringRouteError)
|
|
919
|
+
throw new manager_api_ts_1.MediaRouteError(err.code, err.message);
|
|
920
|
+
throw err;
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
freezeRoute: (id) => mirroring?.freezeRoute(id) ?? false,
|
|
924
|
+
unfreezeRoute: (id) => mirroring?.unfreezeRoute(id) ?? false,
|
|
925
|
+
mirroringStats: mirroring === undefined
|
|
926
|
+
? undefined
|
|
927
|
+
: {
|
|
928
|
+
get: (id) => mirroring.getMirroringStats(id),
|
|
929
|
+
setEnabled: (enabled) => mirroring.setMirroringStatsEnabled(enabled),
|
|
930
|
+
isEnabled: () => mirroring.isMirroringStatsEnabled(),
|
|
931
|
+
observe: (observer) => mirroring.observeMirroringStats(observer),
|
|
932
|
+
},
|
|
933
|
+
}, {
|
|
934
|
+
requests: defaults,
|
|
935
|
+
start: (webContentsId, sinkId) => {
|
|
936
|
+
if (presentation === undefined)
|
|
937
|
+
return Promise.reject(new manager_api_ts_1.MediaRouteError("unable_to_cast", "presentation mode is off"));
|
|
938
|
+
return presentation.startDefaultPresentation(webContentsId, sinkId);
|
|
939
|
+
},
|
|
940
|
+
});
|
|
941
|
+
// Cast sinks coming and going decide which DIAL sinks are shown; the DIAL sinks are looked up again.
|
|
942
|
+
castSinks = () => service.devices();
|
|
943
|
+
const castChanged = () => dial?.castDevicesChanged();
|
|
944
|
+
if (dial !== undefined)
|
|
945
|
+
for (const e of ["deviceUp", "deviceDown", "deviceChanged"])
|
|
946
|
+
castDevices.on(e, castChanged);
|
|
385
947
|
let disposed = false;
|
|
386
948
|
return {
|
|
387
949
|
...api,
|
|
388
|
-
|
|
389
|
-
|
|
950
|
+
...(wired !== undefined ? { wiredDisplay: wired.api } : {}),
|
|
951
|
+
async start() {
|
|
952
|
+
networkMonitor?.start();
|
|
953
|
+
await discovery.start();
|
|
954
|
+
dial?.start({ online: networkMonitor === undefined || networkMonitor.networkId() !== network_monitor_ts_1.NETWORK_ID_DISCONNECTED });
|
|
955
|
+
},
|
|
956
|
+
devices: () => service.devices(),
|
|
957
|
+
discoverSinksNow: () => service.discoverSinksNow(),
|
|
958
|
+
settled: (options) => service.settled(options),
|
|
959
|
+
addSinkByAddress: (device) => service.addSinkByAddress(device),
|
|
960
|
+
configureAccessCode: (settings) => service.configureAccessCode(settings),
|
|
961
|
+
rememberedSinks: () => service.rememberedSinks(),
|
|
390
962
|
async dispose() {
|
|
391
963
|
if (disposed)
|
|
392
964
|
return;
|
|
393
965
|
disposed = true;
|
|
394
966
|
api.dispose();
|
|
967
|
+
defaults.dispose();
|
|
968
|
+
mirroring?.dispose();
|
|
969
|
+
disposeMirroring?.();
|
|
395
970
|
options.ipcMain.removeHandler(`${channel}:call`);
|
|
396
971
|
presentation?.dispose();
|
|
972
|
+
if (dial !== undefined)
|
|
973
|
+
for (const e of ["deviceUp", "deviceDown", "deviceChanged"])
|
|
974
|
+
castDevices.off(e, castChanged);
|
|
975
|
+
unobserveDialNetwork();
|
|
976
|
+
dial?.stop();
|
|
977
|
+
networkMonitor?.stop();
|
|
978
|
+
wired?.dispose();
|
|
397
979
|
discovery.stop();
|
|
398
980
|
await service.dispose();
|
|
399
981
|
senders.clear();
|