electron-cast 0.3.1 → 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 +340 -0
- package/CONTRIBUTING.md +305 -0
- package/README.md +215 -60
- package/SECURITY.md +324 -0
- package/dist/cjs/client/auth/build-time.d.ts +7 -0
- package/dist/cjs/client/auth/build-time.js +11 -0
- package/dist/cjs/client/auth/build-time.js.map +1 -0
- package/dist/cjs/client/auth/cast-auth.d.ts +46 -0
- package/dist/cjs/client/auth/cast-auth.js +145 -0
- package/dist/cjs/client/auth/cast-auth.js.map +1 -0
- package/dist/cjs/client/auth/cast-cert-validator.d.ts +34 -0
- package/dist/cjs/client/auth/cast-cert-validator.js +89 -0
- package/dist/cjs/client/auth/cast-cert-validator.js.map +1 -0
- package/dist/cjs/client/auth/crl.d.ts +45 -0
- package/dist/cjs/client/auth/crl.js +227 -0
- package/dist/cjs/client/auth/crl.js.map +1 -0
- package/dist/cjs/client/auth/der.d.ts +62 -0
- package/dist/cjs/client/auth/der.js +208 -0
- package/dist/cjs/client/auth/der.js.map +1 -0
- package/dist/cjs/client/auth/names.d.ts +52 -0
- package/dist/cjs/client/auth/names.js +447 -0
- package/dist/cjs/client/auth/names.js.map +1 -0
- package/dist/cjs/client/auth/path-validator.d.ts +29 -0
- package/dist/cjs/client/auth/path-validator.js +421 -0
- package/dist/cjs/client/auth/path-validator.js.map +1 -0
- package/dist/cjs/client/auth/trust-data.d.ts +24 -0
- package/dist/cjs/client/auth/trust-data.js +97 -0
- package/dist/cjs/client/auth/trust-data.js.map +1 -0
- package/dist/cjs/client/auth/x509.d.ts +109 -0
- package/dist/cjs/client/auth/x509.js +442 -0
- package/dist/cjs/client/auth/x509.js.map +1 -0
- package/dist/cjs/client/cast-client.d.ts +111 -0
- package/dist/cjs/client/cast-client.js +505 -0
- package/dist/cjs/client/cast-client.js.map +1 -0
- package/dist/cjs/client/errors.d.ts +28 -0
- package/dist/cjs/client/errors.js +50 -0
- package/dist/cjs/client/errors.js.map +1 -0
- package/dist/cjs/client/index.d.ts +6 -0
- package/dist/cjs/client/index.js +21 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/client/namespaces.d.ts +9 -0
- package/dist/cjs/client/namespaces.js +13 -0
- package/dist/cjs/client/namespaces.js.map +1 -0
- package/dist/cjs/client/types.d.ts +27 -0
- package/dist/cjs/client/types.js +3 -0
- package/dist/cjs/client/types.js.map +1 -0
- 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 +105 -0
- package/dist/cjs/discovery/cast-discovery.js +323 -0
- package/dist/cjs/discovery/cast-discovery.js.map +1 -0
- package/dist/cjs/discovery/device-cache.d.ts +54 -0
- package/dist/cjs/discovery/device-cache.js +240 -0
- package/dist/cjs/discovery/device-cache.js.map +1 -0
- package/dist/cjs/discovery/dns-packet.d.ts +70 -0
- package/dist/cjs/discovery/dns-packet.js +251 -0
- package/dist/cjs/discovery/dns-packet.js.map +1 -0
- package/dist/cjs/discovery/index.d.ts +5 -0
- package/dist/cjs/discovery/index.js +22 -0
- package/dist/cjs/discovery/index.js.map +1 -0
- 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 +19 -0
- package/dist/cjs/discovery/udp-socket.js +166 -0
- package/dist/cjs/discovery/udp-socket.js.map +1 -0
- 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 +173 -0
- package/dist/cjs/electron/main.js +990 -0
- package/dist/cjs/electron/main.js.map +1 -0
- package/dist/cjs/electron/manager-api.d.ts +314 -0
- package/dist/cjs/electron/manager-api.js +402 -0
- package/dist/cjs/electron/manager-api.js.map +1 -0
- 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.d.ts +39 -0
- package/dist/cjs/electron/preload.js +96 -0
- package/dist/cjs/electron/preload.js.map +1 -0
- package/dist/cjs/electron/presentation-envelope.d.ts +60 -0
- package/dist/cjs/electron/presentation-envelope.js +318 -0
- package/dist/cjs/electron/presentation-envelope.js.map +1 -0
- package/dist/cjs/electron/presentation-handler.d.ts +135 -0
- package/dist/cjs/electron/presentation-handler.js +643 -0
- package/dist/cjs/electron/presentation-handler.js.map +1 -0
- 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 +348 -0
- package/dist/cjs/electron/session-service.js +1273 -0
- package/dist/cjs/electron/session-service.js.map +1 -0
- 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 +9 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/index.js.map +1 -0
- 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/package.json +1 -0
- package/dist/cjs/polyfill/bridge-types.d.ts +97 -0
- package/dist/cjs/polyfill/bridge-types.js +3 -0
- package/dist/cjs/polyfill/bridge-types.js.map +1 -0
- package/dist/cjs/polyfill/install.d.ts +12 -0
- package/dist/cjs/polyfill/install.js +1569 -0
- package/dist/cjs/polyfill/install.js.map +1 -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.d.ts +13 -0
- package/dist/cjs/polyfill/presentation-standin.js +421 -0
- package/dist/cjs/polyfill/presentation-standin.js.map +1 -0
- package/dist/cjs/protocol/cast-message.d.ts +20 -0
- package/dist/cjs/protocol/cast-message.js +171 -0
- package/dist/cjs/protocol/cast-message.js.map +1 -0
- package/dist/cjs/protocol/device-auth.d.ts +61 -0
- package/dist/cjs/protocol/device-auth.js +113 -0
- package/dist/cjs/protocol/device-auth.js.map +1 -0
- package/dist/cjs/protocol/errors.d.ts +4 -0
- package/dist/cjs/protocol/errors.js +12 -0
- package/dist/cjs/protocol/errors.js.map +1 -0
- package/dist/cjs/protocol/framing.d.ts +18 -0
- package/dist/cjs/protocol/framing.js +100 -0
- package/dist/cjs/protocol/framing.js.map +1 -0
- package/dist/cjs/protocol/index.d.ts +4 -0
- package/dist/cjs/protocol/index.js +21 -0
- package/dist/cjs/protocol/index.js.map +1 -0
- package/dist/cjs/protocol/proto-wire.d.ts +11 -0
- package/dist/cjs/protocol/proto-wire.js +64 -0
- package/dist/cjs/protocol/proto-wire.js.map +1 -0
- 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.d.ts +7 -0
- package/dist/client/auth/build-time.js +8 -0
- package/dist/client/auth/build-time.js.map +1 -0
- package/dist/client/auth/cast-auth.d.ts +46 -0
- package/dist/client/auth/cast-auth.js +141 -0
- package/dist/client/auth/cast-auth.js.map +1 -0
- package/dist/client/auth/cast-cert-validator.d.ts +34 -0
- package/dist/client/auth/cast-cert-validator.js +86 -0
- package/dist/client/auth/cast-cert-validator.js.map +1 -0
- package/dist/client/auth/crl.d.ts +45 -0
- package/dist/client/auth/crl.js +221 -0
- package/dist/client/auth/crl.js.map +1 -0
- package/dist/client/auth/der.d.ts +62 -0
- package/dist/client/auth/der.js +196 -0
- package/dist/client/auth/der.js.map +1 -0
- package/dist/client/auth/names.d.ts +52 -0
- package/dist/client/auth/names.js +438 -0
- package/dist/client/auth/names.js.map +1 -0
- package/dist/client/auth/path-validator.d.ts +29 -0
- package/dist/client/auth/path-validator.js +417 -0
- package/dist/client/auth/path-validator.js.map +1 -0
- package/dist/client/auth/trust-data.d.ts +24 -0
- package/dist/client/auth/trust-data.js +94 -0
- package/dist/client/auth/trust-data.js.map +1 -0
- package/dist/client/auth/x509.d.ts +109 -0
- package/dist/client/auth/x509.js +430 -0
- package/dist/client/auth/x509.js.map +1 -0
- package/dist/client/cast-client.d.ts +20 -1
- package/dist/client/cast-client.js +74 -3
- package/dist/client/cast-client.js.map +1 -1
- package/dist/client/errors.d.ts +11 -0
- package/dist/client/errors.js +13 -0
- package/dist/client/errors.js.map +1 -1
- package/dist/client/index.d.ts +2 -0
- 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 +23 -2
- package/dist/discovery/cast-discovery.js +94 -14
- package/dist/discovery/cast-discovery.js.map +1 -1
- package/dist/discovery/device-cache.d.ts +15 -1
- package/dist/discovery/device-cache.js +31 -7
- 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 +8 -1
- package/dist/discovery/udp-socket.js +59 -5
- 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 +122 -13
- package/dist/electron/main.js +776 -63
- package/dist/electron/main.js.map +1 -1
- package/dist/electron/manager-api.d.ts +314 -0
- package/dist/electron/manager-api.js +390 -0
- package/dist/electron/manager-api.js.map +1 -0
- 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.d.ts +5 -0
- package/dist/electron/preload.js +9 -1
- package/dist/electron/preload.js.map +1 -1
- package/dist/electron/presentation-envelope.js +7 -1
- package/dist/electron/presentation-envelope.js.map +1 -1
- package/dist/electron/presentation-handler.d.ts +39 -4
- package/dist/electron/presentation-handler.js +208 -57
- 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 +225 -10
- package/dist/electron/session-service.js +735 -151
- 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 +160 -17
- package/dist/polyfill/presentation-standin.js.map +1 -1
- package/dist/protocol/device-auth.d.ts +61 -0
- package/dist/protocol/device-auth.js +106 -0
- package/dist/protocol/device-auth.js.map +1 -0
- package/dist/protocol/framing.d.ts +1 -1
- package/dist/protocol/framing.js +1 -1
- package/dist/protocol/framing.js.map +1 -1
- package/dist/protocol/index.d.ts +1 -0
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/proto-wire.d.ts +11 -0
- package/dist/protocol/proto-wire.js +60 -0
- package/dist/protocol/proto-wire.js.map +1 -0
- 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 +67 -16
- package/src/cli.ts +57 -0
- package/src/client/auth/build-time.ts +7 -0
- package/src/client/auth/cast-auth.ts +186 -0
- package/src/client/auth/cast-cert-validator.ts +133 -0
- package/src/client/auth/crl.ts +228 -0
- package/src/client/auth/der.ts +193 -0
- package/src/client/auth/names.ts +411 -0
- package/src/client/auth/path-validator.ts +449 -0
- package/src/client/auth/trust-data.ts +95 -0
- package/src/client/auth/x509.ts +488 -0
- package/src/client/cast-client.ts +85 -3
- package/src/client/errors.ts +29 -0
- package/src/client/index.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 +106 -19
- package/src/discovery/device-cache.ts +43 -8
- package/src/discovery/index.ts +1 -0
- package/src/discovery/ip-policy.ts +97 -0
- package/src/discovery/udp-socket.ts +66 -4
- 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 +866 -72
- package/src/electron/manager-api.ts +664 -0
- package/src/electron/media-controller.ts +313 -0
- package/src/electron/network-monitor.ts +140 -0
- package/src/electron/preload.ts +16 -2
- package/src/electron/presentation-envelope.ts +7 -1
- package/src/electron/presentation-handler.ts +211 -58
- package/src/electron/presentation-source.ts +155 -0
- package/src/electron/session-service.ts +808 -149
- 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 +150 -17
- package/src/protocol/device-auth.ts +126 -0
- package/src/protocol/framing.ts +1 -1
- package/src/protocol/index.ts +1 -0
- package/src/protocol/proto-wire.ts +55 -0
|
@@ -0,0 +1,990 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAccessCodeSink = exports.AccessCodeCastDisabledError = exports.wiredDisplaySinks = exports.availableDisplays = exports.isWiredDisplaySource = exports.createReceiverWindows = exports.MediaRouteError = void 0;
|
|
4
|
+
exports.createCastManager = createCastManager;
|
|
5
|
+
const session_service_ts_1 = require("./session-service.js");
|
|
6
|
+
const index_ts_1 = require("../discovery/index.js");
|
|
7
|
+
const index_ts_2 = require("../client/index.js");
|
|
8
|
+
const presentation_handler_ts_1 = require("./presentation-handler.js");
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
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");
|
|
20
|
+
/**
|
|
21
|
+
* The methods a page may call over IPC: the bridge's own. The service also handles methods that only main calls
|
|
22
|
+
* (joinRunningSession, from the presentation handler), which a page must not reach directly.
|
|
23
|
+
*/
|
|
24
|
+
const PAGE_METHODS = new Set([
|
|
25
|
+
"initialize", "requestSession", "joinSession", "sendMessage", "stopSession",
|
|
26
|
+
"leaveSession", "setReceiverVolume", "setReceiverMuted",
|
|
27
|
+
]);
|
|
28
|
+
var manager_api_ts_2 = require("./manager-api.js");
|
|
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; } });
|
|
38
|
+
/** Availability watches kept per frame; the page never releases one, so the oldest are dropped. */
|
|
39
|
+
const MAX_WATCHES_PER_PAGE = 32;
|
|
40
|
+
/** Sender ids of subframes start here, far above any webContents id (a main frame's sender id is its webContents id). */
|
|
41
|
+
const SUBFRAME_ID_BASE = 2 ** 30;
|
|
42
|
+
/** How often removed iframes (which Electron does not announce) are noticed and their sessions released. */
|
|
43
|
+
const FRAME_SWEEP_MS = 5000;
|
|
44
|
+
/** Largest page-to-receiver message accepted (Cast messages are capped at 64 KiB on the wire). */
|
|
45
|
+
const MAX_MESSAGE_CHARS = 1 << 20;
|
|
46
|
+
/** The sending frame's origin; null when there is no frame. An unparseable URL gives "" so allowOrigin decides. */
|
|
47
|
+
function originOf(frame) {
|
|
48
|
+
if (frame === null)
|
|
49
|
+
return null;
|
|
50
|
+
if (typeof frame.origin === "string" && frame.origin !== "")
|
|
51
|
+
return frame.origin;
|
|
52
|
+
try {
|
|
53
|
+
return new URL(frame.url).origin;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Wires the session service to Electron IPC: one invoke handler per app on
|
|
61
|
+
* `<channel>:call`, events sent back on `<channel>:event`. Each webContents is
|
|
62
|
+
* a sender that leaves its sessions when it is destroyed or navigates. Unless
|
|
63
|
+
* `presentation: false` it also serves `<channel>:presentation` (see {@link CastManagerOptions.presentation}).
|
|
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
|
+
}
|
|
141
|
+
function createCastManager(options) {
|
|
142
|
+
const channel = options.channel ?? "electron-cast";
|
|
143
|
+
if (options.presentation !== false && (typeof options.ipcMain.on !== "function" || typeof options.ipcMain.removeListener !== "function")) {
|
|
144
|
+
throw new TypeError("presentation mode needs ipcMain.on and ipcMain.removeListener");
|
|
145
|
+
}
|
|
146
|
+
const discovery = options.discovery ?? new index_ts_1.CastDiscovery();
|
|
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
|
+
};
|
|
185
|
+
const senders = new Map();
|
|
186
|
+
const subframeIds = new Map(); // frameTreeNodeId -> sender id
|
|
187
|
+
const watched = new Set(); // webContents ids
|
|
188
|
+
let nextSubframeId = SUBFRAME_ID_BASE;
|
|
189
|
+
let sweepTimer;
|
|
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();
|
|
195
|
+
const findFrame = (wc, frameTreeNodeId) => {
|
|
196
|
+
try {
|
|
197
|
+
return wc.mainFrame?.framesInSubtree.find((f) => f.frameTreeNodeId === frameTreeNodeId);
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return undefined; // the webContents is gone
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const isMainFrame = (frame) => frame.parent === undefined || frame.parent === null;
|
|
204
|
+
/**
|
|
205
|
+
* The sender id of an IPC event's frame, without registering it; undefined when it is not a known sender. An event
|
|
206
|
+
* with no `senderFrame` property at all is the main frame's; a null one is a frame that is already gone.
|
|
207
|
+
*/
|
|
208
|
+
const senderIdOf = (wc, frame) => {
|
|
209
|
+
if (frame === undefined)
|
|
210
|
+
return wc.id;
|
|
211
|
+
if (frame === null)
|
|
212
|
+
return undefined;
|
|
213
|
+
if (isMainFrame(frame))
|
|
214
|
+
return wc.id;
|
|
215
|
+
return typeof frame.frameTreeNodeId === "number" ? subframeIds.get(frame.frameTreeNodeId) : undefined;
|
|
216
|
+
};
|
|
217
|
+
/** The sender id of an IPC event's frame, registering a subframe (and watching its webContents) on first use. */
|
|
218
|
+
const registerSender = (wc, frame) => {
|
|
219
|
+
if (isMainFrame(frame)) {
|
|
220
|
+
watch(wc);
|
|
221
|
+
if (!senders.has(wc.id))
|
|
222
|
+
senders.set(wc.id, { wc, frameTreeNodeId: null });
|
|
223
|
+
return wc.id;
|
|
224
|
+
}
|
|
225
|
+
const node = frame.frameTreeNodeId;
|
|
226
|
+
if (typeof node !== "number")
|
|
227
|
+
return null;
|
|
228
|
+
watch(wc);
|
|
229
|
+
let id = subframeIds.get(node);
|
|
230
|
+
if (id === undefined) {
|
|
231
|
+
id = nextSubframeId++;
|
|
232
|
+
subframeIds.set(node, id);
|
|
233
|
+
senders.set(id, { wc, frameTreeNodeId: node });
|
|
234
|
+
sweepTimer ??= setInterval(sweepFrames, FRAME_SWEEP_MS);
|
|
235
|
+
sweepTimer.unref?.();
|
|
236
|
+
}
|
|
237
|
+
return id;
|
|
238
|
+
};
|
|
239
|
+
/** Forget a subframe sender for good: its connections, watches and sessions end. */
|
|
240
|
+
const dropSubframe = (id) => {
|
|
241
|
+
const entry = senders.get(id);
|
|
242
|
+
if (entry === undefined || entry.frameTreeNodeId === null)
|
|
243
|
+
return;
|
|
244
|
+
presentation?.senderGone(id);
|
|
245
|
+
senders.delete(id);
|
|
246
|
+
subframeIds.delete(entry.frameTreeNodeId);
|
|
247
|
+
service.senderGone(id);
|
|
248
|
+
if (subframeIds.size === 0 && sweepTimer !== undefined) {
|
|
249
|
+
clearInterval(sweepTimer);
|
|
250
|
+
sweepTimer = undefined;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
/** Drop subframe senders whose frame was removed (Electron announces neither an iframe's removal nor its page's). */
|
|
254
|
+
function sweepFrames() {
|
|
255
|
+
for (const [id, entry] of [...senders]) {
|
|
256
|
+
if (entry.frameTreeNodeId === null)
|
|
257
|
+
continue;
|
|
258
|
+
if (entry.wc.isDestroyed() || findFrame(entry.wc, entry.frameTreeNodeId) === undefined)
|
|
259
|
+
dropSubframe(id);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/** Send to the one frame that owns the sender; a frame that is gone ends the sender. */
|
|
263
|
+
const deliver = (senderId, ch, payload) => {
|
|
264
|
+
const entry = senders.get(senderId);
|
|
265
|
+
if (entry === undefined || entry.wc.isDestroyed())
|
|
266
|
+
return;
|
|
267
|
+
try {
|
|
268
|
+
if (entry.frameTreeNodeId === null) {
|
|
269
|
+
entry.wc.send(ch, payload);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const frame = findFrame(entry.wc, entry.frameTreeNodeId);
|
|
273
|
+
if (frame?.send === undefined) {
|
|
274
|
+
queueMicrotask(() => dropSubframe(senderId)); // not inside the service's own emit
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
frame.send(ch, payload);
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
// the webContents or frame was destroyed between the check and the send
|
|
281
|
+
}
|
|
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;
|
|
290
|
+
const service = new session_service_ts_1.CastSessionService({
|
|
291
|
+
devices: discovery,
|
|
292
|
+
createClient,
|
|
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
|
+
},
|
|
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),
|
|
319
|
+
emit(senderId, event) {
|
|
320
|
+
try {
|
|
321
|
+
handler?.onServiceEvent(senderId, event);
|
|
322
|
+
}
|
|
323
|
+
catch (err) {
|
|
324
|
+
console.error("electron-cast: presentation handler failed on a service event", err);
|
|
325
|
+
}
|
|
326
|
+
deliver(senderId, `${channel}:event`, event);
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
/** Watch a webContents once: its destruction and its navigations end or park its senders. */
|
|
330
|
+
function watch(wc) {
|
|
331
|
+
if (watched.has(wc.id))
|
|
332
|
+
return;
|
|
333
|
+
watched.add(wc.id);
|
|
334
|
+
const subframes = () => [...senders].filter(([, e]) => e.wc === wc && e.frameTreeNodeId !== null).map(([id]) => id);
|
|
335
|
+
wc.once("destroyed", () => {
|
|
336
|
+
watched.delete(wc.id);
|
|
337
|
+
for (const id of subframes())
|
|
338
|
+
dropSubframe(id);
|
|
339
|
+
presentation?.senderGone(wc.id);
|
|
340
|
+
defaults.forget(wc.id);
|
|
341
|
+
senders.delete(wc.id);
|
|
342
|
+
service.senderGone(wc.id);
|
|
343
|
+
});
|
|
344
|
+
// A navigation ends the page's connections, but its sessions stay open (parked) so the next page can rejoin them
|
|
345
|
+
wc.on("did-navigate", () => {
|
|
346
|
+
presentation?.senderGone(wc.id);
|
|
347
|
+
service.senderNavigated(wc.id);
|
|
348
|
+
for (const id of subframes())
|
|
349
|
+
dropSubframe(id); // the page's iframes went with it
|
|
350
|
+
});
|
|
351
|
+
// An iframe that navigates on its own is treated the same way (the main frame is handled above).
|
|
352
|
+
wc.on("did-frame-navigate", (_event, _url, _code, _text, mainFrame, processId, routingId) => {
|
|
353
|
+
if (mainFrame === true)
|
|
354
|
+
return;
|
|
355
|
+
const frame = wc.mainFrame?.framesInSubtree.find((f) => f.processId === processId && f.routingId === routingId);
|
|
356
|
+
const id = typeof frame?.frameTreeNodeId === "number" ? subframeIds.get(frame.frameTreeNodeId) : undefined;
|
|
357
|
+
if (id !== undefined) {
|
|
358
|
+
presentation?.senderGone(id);
|
|
359
|
+
service.senderNavigated(id);
|
|
360
|
+
}
|
|
361
|
+
sweepFrames();
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
options.ipcMain.handle(`${channel}:call`, (event, method, params) => {
|
|
365
|
+
const origin = originOf(event.senderFrame);
|
|
366
|
+
if (origin === null || event.senderFrame === null) {
|
|
367
|
+
return Promise.resolve({ ok: false, code: "extension_missing", description: "No sender frame" });
|
|
368
|
+
}
|
|
369
|
+
// mode "chromecast" is main-frame only; iframes are served in presentation mode, as in Chrome
|
|
370
|
+
if (!isMainFrame(event.senderFrame)) {
|
|
371
|
+
return Promise.resolve({ ok: false, code: "extension_missing", description: "chrome.cast is not available in iframes; use presentation mode" });
|
|
372
|
+
}
|
|
373
|
+
if (typeof method !== "string" || !PAGE_METHODS.has(method)) {
|
|
374
|
+
return Promise.resolve({ ok: false, code: "invalid_parameter", description: `unknown method: ${String(method)}` });
|
|
375
|
+
}
|
|
376
|
+
const id = registerSender(event.sender, event.senderFrame);
|
|
377
|
+
return service.handle({ id, origin }, method, params);
|
|
378
|
+
});
|
|
379
|
+
const wired = options.wiredDisplay !== undefined && options.presentation !== false ? (0, index_ts_3.createWiredDisplay)(options.wiredDisplay) : undefined;
|
|
380
|
+
/** Presentation mode: IPC for the page's stand-in Presentation API, answered by a CastPresentationHandler. */
|
|
381
|
+
const setUpPresentation = () => {
|
|
382
|
+
const ipc = options.ipcMain;
|
|
383
|
+
const on = ipc.on.bind(ipc);
|
|
384
|
+
const off = ipc.removeListener.bind(ipc);
|
|
385
|
+
const h = new presentation_handler_ts_1.CastPresentationHandler({ service, token: hashToken, ...(dial !== undefined ? { dial } : {}), dialRoutesChanged: notifyRoutes });
|
|
386
|
+
handler = h;
|
|
387
|
+
const connections = new Map();
|
|
388
|
+
const watches = new Map();
|
|
389
|
+
const sendTo = (sid, payload) => {
|
|
390
|
+
deliver(sid, `${channel}:presentation:event`, payload);
|
|
391
|
+
};
|
|
392
|
+
const invalid = (description) => ({ ok: false, code: "InvalidAccessError", description });
|
|
393
|
+
const isId = (v) => typeof v === "string" && v !== "" && v.length <= 256;
|
|
394
|
+
const isUrls = (v) => Array.isArray(v) && v.length > 0 && v.length <= 16 && v.every((u) => typeof u === "string");
|
|
395
|
+
/** Finish a start/reconnect: register the connection and route its traffic to the page. */
|
|
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) => {
|
|
399
|
+
if (connections.has(connectionId))
|
|
400
|
+
return invalid("connectionId in use");
|
|
401
|
+
const slot = { conn: null, sid };
|
|
402
|
+
connections.set(connectionId, slot); // reserved while the picker or join is pending
|
|
403
|
+
let conn;
|
|
404
|
+
try {
|
|
405
|
+
conn = await opening();
|
|
406
|
+
}
|
|
407
|
+
catch (err) {
|
|
408
|
+
if (connections.get(connectionId) === slot)
|
|
409
|
+
connections.delete(connectionId);
|
|
410
|
+
const e = err;
|
|
411
|
+
const name = typeof e?.name === "string" && e.name !== "" && e.name !== "Error" ? e.name : "OperationError";
|
|
412
|
+
return { ok: false, code: name, description: typeof e?.message === "string" ? e.message : String(err) };
|
|
413
|
+
}
|
|
414
|
+
if (!senders.has(sid) || connections.get(connectionId) !== slot) {
|
|
415
|
+
conn.close();
|
|
416
|
+
return { ok: false, code: "AbortError", description: "The page went away" };
|
|
417
|
+
}
|
|
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
|
+
}
|
|
424
|
+
conn.onclose = (state) => {
|
|
425
|
+
if (connections.get(connectionId) === slot)
|
|
426
|
+
connections.delete(connectionId);
|
|
427
|
+
sendTo(sid, { type: "statechange", connectionId, state });
|
|
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
|
+
}
|
|
437
|
+
// The stand-in registered this connectionId before calling, so it buffers anything sent before the reply.
|
|
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
|
+
}
|
|
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);
|
|
490
|
+
ipc.handle(`${channel}:presentation`, async (event, method, params) => {
|
|
491
|
+
const origin = originOf(event.senderFrame);
|
|
492
|
+
if (origin === null || event.senderFrame === null)
|
|
493
|
+
return { ok: false, code: "NotAllowedError", description: "No sender frame" };
|
|
494
|
+
const sid = registerSender(event.sender, event.senderFrame);
|
|
495
|
+
if (sid === null)
|
|
496
|
+
return { ok: false, code: "NotAllowedError", description: "Unidentifiable sender frame" };
|
|
497
|
+
const p = (typeof params === "object" && params !== null ? params : {});
|
|
498
|
+
try {
|
|
499
|
+
switch (method) {
|
|
500
|
+
case "getAvailability": {
|
|
501
|
+
if (!isId(p.watchId) || !isUrls(p.urls))
|
|
502
|
+
return invalid("getAvailability expects { watchId, urls }");
|
|
503
|
+
const watchId = p.watchId;
|
|
504
|
+
const old = watches.get(watchId);
|
|
505
|
+
if (old !== undefined && old.sid !== sid)
|
|
506
|
+
return invalid("watchId in use");
|
|
507
|
+
old?.ac.abort();
|
|
508
|
+
watches.delete(watchId);
|
|
509
|
+
const mine = [...watches].filter(([, w]) => w.sid === sid);
|
|
510
|
+
for (const [id, w] of mine.slice(0, Math.max(0, mine.length - (MAX_WATCHES_PER_PAGE - 1)))) {
|
|
511
|
+
w.ac.abort();
|
|
512
|
+
watches.delete(id);
|
|
513
|
+
}
|
|
514
|
+
const ac = new AbortController();
|
|
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
|
+
}
|
|
551
|
+
const available = await h.getAvailability({
|
|
552
|
+
urls: p.urls,
|
|
553
|
+
origin,
|
|
554
|
+
senderId: sid,
|
|
555
|
+
signal: ac.signal,
|
|
556
|
+
onchange: (value) => sendTo(sid, { type: "availability", watchId, value }),
|
|
557
|
+
});
|
|
558
|
+
return { ok: true, value: { available } };
|
|
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
|
+
}
|
|
570
|
+
case "stopWatching": {
|
|
571
|
+
const w = isId(p.watchId) ? watches.get(p.watchId) : undefined;
|
|
572
|
+
if (w !== undefined && w.sid === sid) {
|
|
573
|
+
w.ac.abort();
|
|
574
|
+
watches.delete(p.watchId);
|
|
575
|
+
}
|
|
576
|
+
return { ok: true, value: undefined };
|
|
577
|
+
}
|
|
578
|
+
case "start":
|
|
579
|
+
if (!isId(p.connectionId) || !isUrls(p.urls))
|
|
580
|
+
return invalid("start expects { connectionId, urls }");
|
|
581
|
+
// PresentationServiceImpl::StartPresentation: PRESENTATION_REQUEST_CANCELLED, which the page sees as AbortError
|
|
582
|
+
if (p.hasGesture !== true) {
|
|
583
|
+
return { ok: false, code: "AbortError", description: "PresentationRequest::start() requires user gesture." };
|
|
584
|
+
}
|
|
585
|
+
{
|
|
586
|
+
const urls = p.urls;
|
|
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;
|
|
598
|
+
}
|
|
599
|
+
case "reconnect":
|
|
600
|
+
if (!isId(p.connectionId) || !isUrls(p.urls) || !isId(p.presentationId)) {
|
|
601
|
+
return invalid("reconnect expects { connectionId, urls, presentationId }");
|
|
602
|
+
}
|
|
603
|
+
{
|
|
604
|
+
const { urls, presentationId } = p;
|
|
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 }));
|
|
611
|
+
}
|
|
612
|
+
case "close":
|
|
613
|
+
case "terminate": {
|
|
614
|
+
const c = isId(p.connectionId) ? connections.get(p.connectionId) : undefined;
|
|
615
|
+
if (c !== undefined && c.sid === sid && c.conn !== null) {
|
|
616
|
+
if (method === "close")
|
|
617
|
+
c.conn.close();
|
|
618
|
+
else
|
|
619
|
+
c.conn.terminate();
|
|
620
|
+
}
|
|
621
|
+
return { ok: true, value: undefined };
|
|
622
|
+
}
|
|
623
|
+
default:
|
|
624
|
+
return invalid(`unknown method: ${String(method)}`);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
catch (err) {
|
|
628
|
+
return { ok: false, code: "OperationError", description: err instanceof Error ? err.message : String(err) };
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
const onSend = (event, connectionId, data) => {
|
|
632
|
+
if (typeof connectionId !== "string")
|
|
633
|
+
return;
|
|
634
|
+
const c = connections.get(connectionId);
|
|
635
|
+
if (c === undefined || c.sid !== senderIdOf(event.sender, event.senderFrame) || c.conn === null)
|
|
636
|
+
return;
|
|
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)
|
|
646
|
+
return;
|
|
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);
|
|
651
|
+
};
|
|
652
|
+
on(`${channel}:presentation:send`, onSend);
|
|
653
|
+
return {
|
|
654
|
+
/** Close the page's connections and watches before the service drops it. */
|
|
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);
|
|
659
|
+
h.senderGone(sid);
|
|
660
|
+
wired?.controllers.senderGone(sid);
|
|
661
|
+
for (const [id, c] of connections)
|
|
662
|
+
if (c.sid === sid)
|
|
663
|
+
connections.delete(id);
|
|
664
|
+
for (const [id, w] of watches) {
|
|
665
|
+
if (w.sid !== sid)
|
|
666
|
+
continue;
|
|
667
|
+
w.ac.abort();
|
|
668
|
+
watches.delete(id);
|
|
669
|
+
}
|
|
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
|
+
},
|
|
761
|
+
dispose() {
|
|
762
|
+
ipc.removeHandler(`${channel}:presentation`);
|
|
763
|
+
off(`${channel}:presentation:send`, onSend);
|
|
764
|
+
for (const w of watches.values())
|
|
765
|
+
w.ac.abort();
|
|
766
|
+
watches.clear();
|
|
767
|
+
connections.clear();
|
|
768
|
+
},
|
|
769
|
+
};
|
|
770
|
+
};
|
|
771
|
+
const presentation = options.presentation !== false ? setUpPresentation() : undefined;
|
|
772
|
+
// The service knows frames by sender id (an iframe has a synthetic one); the API speaks of windows, so a route's
|
|
773
|
+
// pages are reported as `webContents.id`s, once each however many of its frames hold the route.
|
|
774
|
+
const windowIds = (ids) => [...new Set(ids.map((id) => senders.get(id)?.wc.id ?? id))];
|
|
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
|
+
};
|
|
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);
|
|
947
|
+
let disposed = false;
|
|
948
|
+
return {
|
|
949
|
+
...api,
|
|
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(),
|
|
962
|
+
async dispose() {
|
|
963
|
+
if (disposed)
|
|
964
|
+
return;
|
|
965
|
+
disposed = true;
|
|
966
|
+
api.dispose();
|
|
967
|
+
defaults.dispose();
|
|
968
|
+
mirroring?.dispose();
|
|
969
|
+
disposeMirroring?.();
|
|
970
|
+
options.ipcMain.removeHandler(`${channel}:call`);
|
|
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();
|
|
979
|
+
discovery.stop();
|
|
980
|
+
await service.dispose();
|
|
981
|
+
senders.clear();
|
|
982
|
+
subframeIds.clear();
|
|
983
|
+
watched.clear();
|
|
984
|
+
if (sweepTimer !== undefined)
|
|
985
|
+
clearInterval(sweepTimer);
|
|
986
|
+
sweepTimer = undefined;
|
|
987
|
+
},
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
//# sourceMappingURL=main.js.map
|