electron-cast 0.4.0 → 0.5.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +280 -0
- package/CONTRIBUTING.md +305 -0
- package/README.md +211 -165
- package/SECURITY.md +324 -0
- package/dist/cjs/client/auth/build-time.js +1 -1
- package/dist/cjs/client/auth/cast-auth.d.ts +2 -0
- package/dist/cjs/client/auth/cast-auth.js.map +1 -1
- package/dist/cjs/dial/dial-registry.d.ts +104 -0
- package/dist/cjs/dial/dial-registry.js +301 -0
- package/dist/cjs/dial/dial-registry.js.map +1 -0
- package/dist/cjs/dial/dial-sink-service.d.ts +108 -0
- package/dist/cjs/dial/dial-sink-service.js +314 -0
- package/dist/cjs/dial/dial-sink-service.js.map +1 -0
- package/dist/cjs/dial/http.d.ts +40 -0
- package/dist/cjs/dial/http.js +172 -0
- package/dist/cjs/dial/http.js.map +1 -0
- package/dist/cjs/dial/index.d.ts +63 -0
- package/dist/cjs/dial/index.js +134 -0
- package/dist/cjs/dial/index.js.map +1 -0
- package/dist/cjs/dial/origins.d.ts +4 -0
- package/dist/cjs/dial/origins.js +36 -0
- package/dist/cjs/dial/origins.js.map +1 -0
- package/dist/cjs/dial/parse.d.ts +101 -0
- package/dist/cjs/dial/parse.js +296 -0
- package/dist/cjs/dial/parse.js.map +1 -0
- package/dist/cjs/dial/route-provider.d.ts +96 -0
- package/dist/cjs/dial/route-provider.js +376 -0
- package/dist/cjs/dial/route-provider.js.map +1 -0
- package/dist/cjs/dial/ssdp-socket.d.ts +34 -0
- package/dist/cjs/dial/ssdp-socket.js +72 -0
- package/dist/cjs/dial/ssdp-socket.js.map +1 -0
- package/dist/cjs/dial/xml.d.ts +13 -0
- package/dist/cjs/dial/xml.js +208 -0
- package/dist/cjs/dial/xml.js.map +1 -0
- package/dist/cjs/discovery/cast-discovery.d.ts +2 -0
- package/dist/cjs/discovery/cast-discovery.js.map +1 -1
- package/dist/cjs/discovery/device-cache.d.ts +9 -0
- package/dist/cjs/discovery/device-cache.js.map +1 -1
- package/dist/cjs/discovery/index.d.ts +1 -0
- package/dist/cjs/discovery/index.js +1 -0
- package/dist/cjs/discovery/index.js.map +1 -1
- package/dist/cjs/discovery/ip-policy.d.ts +20 -0
- package/dist/cjs/discovery/ip-policy.js +109 -0
- package/dist/cjs/discovery/ip-policy.js.map +1 -0
- package/dist/cjs/discovery/udp-socket.d.ts +3 -0
- package/dist/cjs/discovery/udp-socket.js +3 -0
- package/dist/cjs/discovery/udp-socket.js.map +1 -1
- package/dist/cjs/electron/access-code.d.ts +221 -0
- package/dist/cjs/electron/access-code.js +586 -0
- package/dist/cjs/electron/access-code.js.map +1 -0
- package/dist/cjs/electron/app-discovery.d.ts +82 -0
- package/dist/cjs/electron/app-discovery.js +219 -0
- package/dist/cjs/electron/app-discovery.js.map +1 -0
- package/dist/cjs/electron/default-presentation.d.ts +38 -0
- package/dist/cjs/electron/default-presentation.js +88 -0
- package/dist/cjs/electron/default-presentation.js.map +1 -0
- package/dist/cjs/electron/main.d.ts +98 -11
- package/dist/cjs/electron/main.js +602 -20
- package/dist/cjs/electron/main.js.map +1 -1
- package/dist/cjs/electron/manager-api.d.ts +200 -18
- package/dist/cjs/electron/manager-api.js +199 -4
- package/dist/cjs/electron/manager-api.js.map +1 -1
- package/dist/cjs/electron/media-controller.d.ts +79 -0
- package/dist/cjs/electron/media-controller.js +251 -0
- package/dist/cjs/electron/media-controller.js.map +1 -0
- package/dist/cjs/electron/network-monitor.d.ts +61 -0
- package/dist/cjs/electron/network-monitor.js +124 -0
- package/dist/cjs/electron/network-monitor.js.map +1 -0
- package/dist/cjs/electron/preload.js.map +1 -1
- package/dist/cjs/electron/presentation-handler.d.ts +39 -4
- package/dist/cjs/electron/presentation-handler.js +191 -47
- package/dist/cjs/electron/presentation-handler.js.map +1 -1
- package/dist/cjs/electron/presentation-source.d.ts +76 -0
- package/dist/cjs/electron/presentation-source.js +132 -0
- package/dist/cjs/electron/presentation-source.js.map +1 -0
- package/dist/cjs/electron/session-service.d.ts +198 -24
- package/dist/cjs/electron/session-service.js +630 -248
- package/dist/cjs/electron/session-service.js.map +1 -1
- package/dist/cjs/electron/session-tracker.d.ts +82 -0
- package/dist/cjs/electron/session-tracker.js +225 -0
- package/dist/cjs/electron/session-tracker.js.map +1 -0
- package/dist/cjs/electron/sink-service.d.ts +246 -0
- package/dist/cjs/electron/sink-service.js +606 -0
- package/dist/cjs/electron/sink-service.js.map +1 -0
- package/dist/cjs/electron/wired-display/controller.d.ts +76 -0
- package/dist/cjs/electron/wired-display/controller.js +198 -0
- package/dist/cjs/electron/wired-display/controller.js.map +1 -0
- package/dist/cjs/electron/wired-display/displays.d.ts +44 -0
- package/dist/cjs/electron/wired-display/displays.js +98 -0
- package/dist/cjs/electron/wired-display/displays.js.map +1 -0
- package/dist/cjs/electron/wired-display/electron-windows.d.ts +111 -0
- package/dist/cjs/electron/wired-display/electron-windows.js +306 -0
- package/dist/cjs/electron/wired-display/electron-windows.js.map +1 -0
- package/dist/cjs/electron/wired-display/index.d.ts +90 -0
- package/dist/cjs/electron/wired-display/index.js +115 -0
- package/dist/cjs/electron/wired-display/index.js.map +1 -0
- package/dist/cjs/electron/wired-display/local-presentation.d.ts +98 -0
- package/dist/cjs/electron/wired-display/local-presentation.js +234 -0
- package/dist/cjs/electron/wired-display/local-presentation.js.map +1 -0
- package/dist/cjs/electron/wired-display/provider.d.ts +112 -0
- package/dist/cjs/electron/wired-display/provider.js +202 -0
- package/dist/cjs/electron/wired-display/provider.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mirroring/backend.d.ts +76 -0
- package/dist/cjs/mirroring/backend.js +21 -0
- package/dist/cjs/mirroring/backend.js.map +1 -0
- package/dist/cjs/mirroring/electron/agent-protocol.d.ts +158 -0
- package/dist/cjs/mirroring/electron/agent-protocol.js +11 -0
- package/dist/cjs/mirroring/electron/agent-protocol.js.map +1 -0
- package/dist/cjs/mirroring/electron/agent-source.d.ts +20 -0
- package/dist/cjs/mirroring/electron/agent-source.js +621 -0
- package/dist/cjs/mirroring/electron/agent-source.js.map +1 -0
- package/dist/cjs/mirroring/electron/engine-process.d.ts +87 -0
- package/dist/cjs/mirroring/electron/engine-process.js +81 -0
- package/dist/cjs/mirroring/electron/engine-process.js.map +1 -0
- package/dist/cjs/mirroring/electron/host.d.ts +89 -0
- package/dist/cjs/mirroring/electron/host.js +321 -0
- package/dist/cjs/mirroring/electron/host.js.map +1 -0
- package/dist/cjs/mirroring/electron/port-backend.d.ts +107 -0
- package/dist/cjs/mirroring/electron/port-backend.js +446 -0
- package/dist/cjs/mirroring/electron/port-backend.js.map +1 -0
- package/dist/cjs/mirroring/encoding-support.d.ts +66 -0
- package/dist/cjs/mirroring/encoding-support.js +89 -0
- package/dist/cjs/mirroring/encoding-support.js.map +1 -0
- package/dist/cjs/mirroring/engine.d.ts +16 -0
- package/dist/cjs/mirroring/engine.js +78 -0
- package/dist/cjs/mirroring/engine.js.map +1 -0
- package/dist/cjs/mirroring/mirror-settings.d.ts +101 -0
- package/dist/cjs/mirroring/mirror-settings.js +140 -0
- package/dist/cjs/mirroring/mirror-settings.js.map +1 -0
- package/dist/cjs/mirroring/mirroring-activity.d.ts +207 -0
- package/dist/cjs/mirroring/mirroring-activity.js +367 -0
- package/dist/cjs/mirroring/mirroring-activity.js.map +1 -0
- package/dist/cjs/mirroring/mirroring-manager.d.ts +134 -0
- package/dist/cjs/mirroring/mirroring-manager.js +286 -0
- package/dist/cjs/mirroring/mirroring-manager.js.map +1 -0
- package/dist/cjs/mirroring/protocol/answer.d.ts +87 -0
- package/dist/cjs/mirroring/protocol/answer.js +233 -0
- package/dist/cjs/mirroring/protocol/answer.js.map +1 -0
- package/dist/cjs/mirroring/protocol/constants.d.ts +64 -0
- package/dist/cjs/mirroring/protocol/constants.js +70 -0
- package/dist/cjs/mirroring/protocol/constants.js.map +1 -0
- package/dist/cjs/mirroring/protocol/errors.d.ts +25 -0
- package/dist/cjs/mirroring/protocol/errors.js +34 -0
- package/dist/cjs/mirroring/protocol/errors.js.map +1 -0
- package/dist/cjs/mirroring/protocol/frame-id.d.ts +9 -0
- package/dist/cjs/mirroring/protocol/frame-id.js +24 -0
- package/dist/cjs/mirroring/protocol/frame-id.js.map +1 -0
- package/dist/cjs/mirroring/protocol/messenger.d.ts +42 -0
- package/dist/cjs/mirroring/protocol/messenger.js +122 -0
- package/dist/cjs/mirroring/protocol/messenger.js.map +1 -0
- package/dist/cjs/mirroring/protocol/offer.d.ts +109 -0
- package/dist/cjs/mirroring/protocol/offer.js +192 -0
- package/dist/cjs/mirroring/protocol/offer.js.map +1 -0
- package/dist/cjs/mirroring/protocol/recommendations.d.ts +28 -0
- package/dist/cjs/mirroring/protocol/recommendations.js +103 -0
- package/dist/cjs/mirroring/protocol/recommendations.js.map +1 -0
- package/dist/cjs/mirroring/routing.d.ts +60 -0
- package/dist/cjs/mirroring/routing.js +147 -0
- package/dist/cjs/mirroring/routing.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/ntp.d.ts +27 -0
- package/dist/cjs/mirroring/rtcp/ntp.js +62 -0
- package/dist/cjs/mirroring/rtcp/ntp.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/parser.d.ts +50 -0
- package/dist/cjs/mirroring/rtcp/parser.js +270 -0
- package/dist/cjs/mirroring/rtcp/parser.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/sender-report.d.ts +32 -0
- package/dist/cjs/mirroring/rtcp/sender-report.js +56 -0
- package/dist/cjs/mirroring/rtcp/sender-report.js.map +1 -0
- package/dist/cjs/mirroring/rtcp/wire.d.ts +54 -0
- package/dist/cjs/mirroring/rtcp/wire.js +73 -0
- package/dist/cjs/mirroring/rtcp/wire.js.map +1 -0
- package/dist/cjs/mirroring/rtp/frame-crypto.d.ts +11 -0
- package/dist/cjs/mirroring/rtp/frame-crypto.js +39 -0
- package/dist/cjs/mirroring/rtp/frame-crypto.js.map +1 -0
- package/dist/cjs/mirroring/rtp/frame.d.ts +23 -0
- package/dist/cjs/mirroring/rtp/frame.js +3 -0
- package/dist/cjs/mirroring/rtp/frame.js.map +1 -0
- package/dist/cjs/mirroring/rtp/packetizer.d.ts +27 -0
- package/dist/cjs/mirroring/rtp/packetizer.js +92 -0
- package/dist/cjs/mirroring/rtp/packetizer.js.map +1 -0
- package/dist/cjs/mirroring/sender/audio-sender.d.ts +23 -0
- package/dist/cjs/mirroring/sender/audio-sender.js +52 -0
- package/dist/cjs/mirroring/sender/audio-sender.js.map +1 -0
- package/dist/cjs/mirroring/sender/bandwidth-estimator.d.ts +26 -0
- package/dist/cjs/mirroring/sender/bandwidth-estimator.js +107 -0
- package/dist/cjs/mirroring/sender/bandwidth-estimator.js.map +1 -0
- package/dist/cjs/mirroring/sender/capture-size-oracle.d.ts +121 -0
- package/dist/cjs/mirroring/sender/capture-size-oracle.js +440 -0
- package/dist/cjs/mirroring/sender/capture-size-oracle.js.map +1 -0
- package/dist/cjs/mirroring/sender/frame-sender.d.ts +103 -0
- package/dist/cjs/mirroring/sender/frame-sender.js +217 -0
- package/dist/cjs/mirroring/sender/frame-sender.js.map +1 -0
- package/dist/cjs/mirroring/sender/packet-router.d.ts +74 -0
- package/dist/cjs/mirroring/sender/packet-router.js +196 -0
- package/dist/cjs/mirroring/sender/packet-router.js.map +1 -0
- package/dist/cjs/mirroring/sender/sender-session.d.ts +85 -0
- package/dist/cjs/mirroring/sender/sender-session.js +240 -0
- package/dist/cjs/mirroring/sender/sender-session.js.map +1 -0
- package/dist/cjs/mirroring/sender/sender.d.ts +120 -0
- package/dist/cjs/mirroring/sender/sender.js +457 -0
- package/dist/cjs/mirroring/sender/sender.js.map +1 -0
- package/dist/cjs/mirroring/sender/video-encoder-metrics.d.ts +29 -0
- package/dist/cjs/mirroring/sender/video-encoder-metrics.js +64 -0
- package/dist/cjs/mirroring/sender/video-encoder-metrics.js.map +1 -0
- package/dist/cjs/mirroring/sender/video-sender.d.ts +95 -0
- package/dist/cjs/mirroring/sender/video-sender.js +183 -0
- package/dist/cjs/mirroring/sender/video-sender.js.map +1 -0
- package/dist/cjs/mirroring/session-host.d.ts +185 -0
- package/dist/cjs/mirroring/session-host.js +630 -0
- package/dist/cjs/mirroring/session-host.js.map +1 -0
- package/dist/cjs/mirroring/stats/clock-offset-estimator.d.ts +11 -0
- package/dist/cjs/mirroring/stats/clock-offset-estimator.js +123 -0
- package/dist/cjs/mirroring/stats/clock-offset-estimator.js.map +1 -0
- package/dist/cjs/mirroring/stats/openscreen-stats-client.d.ts +12 -0
- package/dist/cjs/mirroring/stats/openscreen-stats-client.js +21 -0
- package/dist/cjs/mirroring/stats/openscreen-stats-client.js.map +1 -0
- package/dist/cjs/mirroring/stats/sorted-map.d.ts +23 -0
- package/dist/cjs/mirroring/stats/sorted-map.js +70 -0
- package/dist/cjs/mirroring/stats/sorted-map.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-analyzer.d.ts +50 -0
- package/dist/cjs/mirroring/stats/statistics-analyzer.js +339 -0
- package/dist/cjs/mirroring/stats/statistics-analyzer.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-collector.d.ts +29 -0
- package/dist/cjs/mirroring/stats/statistics-collector.js +53 -0
- package/dist/cjs/mirroring/stats/statistics-collector.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-common.d.ts +61 -0
- package/dist/cjs/mirroring/stats/statistics-common.js +45 -0
- package/dist/cjs/mirroring/stats/statistics-common.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics-dispatcher.d.ts +28 -0
- package/dist/cjs/mirroring/stats/statistics-dispatcher.js +104 -0
- package/dist/cjs/mirroring/stats/statistics-dispatcher.js.map +1 -0
- package/dist/cjs/mirroring/stats/statistics.d.ts +84 -0
- package/dist/cjs/mirroring/stats/statistics.js +147 -0
- package/dist/cjs/mirroring/stats/statistics.js.map +1 -0
- package/dist/cjs/mirroring/transport/udp-environment.d.ts +40 -0
- package/dist/cjs/mirroring/transport/udp-environment.js +97 -0
- package/dist/cjs/mirroring/transport/udp-environment.js.map +1 -0
- package/dist/cjs/polyfill/bridge-types.d.ts +11 -0
- package/dist/cjs/polyfill/presentation-receiver.d.ts +12 -0
- package/dist/cjs/polyfill/presentation-receiver.js +369 -0
- package/dist/cjs/polyfill/presentation-receiver.js.map +1 -0
- package/dist/cjs/polyfill/presentation-standin.js +157 -15
- package/dist/cjs/polyfill/presentation-standin.js.map +1 -1
- package/dist/cjs/protocol/framing.d.ts +1 -1
- package/dist/cjs/protocol/framing.js +1 -1
- package/dist/cjs/protocol/framing.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +56 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/auth/build-time.js +1 -1
- package/dist/client/auth/cast-auth.d.ts +2 -0
- package/dist/client/auth/cast-auth.js.map +1 -1
- package/dist/dial/dial-registry.d.ts +104 -0
- package/dist/dial/dial-registry.js +297 -0
- package/dist/dial/dial-registry.js.map +1 -0
- package/dist/dial/dial-sink-service.d.ts +108 -0
- package/dist/dial/dial-sink-service.js +310 -0
- package/dist/dial/dial-sink-service.js.map +1 -0
- package/dist/dial/http.d.ts +40 -0
- package/dist/dial/http.js +165 -0
- package/dist/dial/http.js.map +1 -0
- package/dist/dial/index.d.ts +63 -0
- package/dist/dial/index.js +115 -0
- package/dist/dial/index.js.map +1 -0
- package/dist/dial/origins.d.ts +4 -0
- package/dist/dial/origins.js +32 -0
- package/dist/dial/origins.js.map +1 -0
- package/dist/dial/parse.d.ts +101 -0
- package/dist/dial/parse.js +281 -0
- package/dist/dial/parse.js.map +1 -0
- package/dist/dial/route-provider.d.ts +96 -0
- package/dist/dial/route-provider.js +369 -0
- package/dist/dial/route-provider.js.map +1 -0
- package/dist/dial/ssdp-socket.d.ts +34 -0
- package/dist/dial/ssdp-socket.js +65 -0
- package/dist/dial/ssdp-socket.js.map +1 -0
- package/dist/dial/xml.d.ts +13 -0
- package/dist/dial/xml.js +204 -0
- package/dist/dial/xml.js.map +1 -0
- package/dist/dial-test/cli-main.d.ts +17 -0
- package/dist/dial-test/cli-main.js +130 -0
- package/dist/dial-test/cli-main.js.map +1 -0
- package/dist/dial-test/report.d.ts +55 -0
- package/dist/dial-test/report.js +77 -0
- package/dist/dial-test/report.js.map +1 -0
- package/dist/dial-test/runner.d.ts +42 -0
- package/dist/dial-test/runner.js +566 -0
- package/dist/dial-test/runner.js.map +1 -0
- package/dist/dial-test/scrub.d.ts +14 -0
- package/dist/dial-test/scrub.js +73 -0
- package/dist/dial-test/scrub.js.map +1 -0
- package/dist/discovery/cast-discovery.d.ts +2 -0
- package/dist/discovery/cast-discovery.js.map +1 -1
- package/dist/discovery/device-cache.d.ts +9 -0
- package/dist/discovery/device-cache.js.map +1 -1
- package/dist/discovery/index.d.ts +1 -0
- package/dist/discovery/index.js +1 -0
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/ip-policy.d.ts +20 -0
- package/dist/discovery/ip-policy.js +103 -0
- package/dist/discovery/ip-policy.js.map +1 -0
- package/dist/discovery/udp-socket.d.ts +3 -0
- package/dist/discovery/udp-socket.js +3 -0
- package/dist/discovery/udp-socket.js.map +1 -1
- package/dist/electron/access-code.d.ts +221 -0
- package/dist/electron/access-code.js +577 -0
- package/dist/electron/access-code.js.map +1 -0
- package/dist/electron/app-discovery.d.ts +82 -0
- package/dist/electron/app-discovery.js +215 -0
- package/dist/electron/app-discovery.js.map +1 -0
- package/dist/electron/default-presentation.d.ts +38 -0
- package/dist/electron/default-presentation.js +83 -0
- package/dist/electron/default-presentation.js.map +1 -0
- package/dist/electron/main.d.ts +98 -11
- package/dist/electron/main.js +597 -21
- package/dist/electron/main.js.map +1 -1
- package/dist/electron/manager-api.d.ts +200 -18
- package/dist/electron/manager-api.js +196 -4
- package/dist/electron/manager-api.js.map +1 -1
- package/dist/electron/media-controller.d.ts +79 -0
- package/dist/electron/media-controller.js +248 -0
- package/dist/electron/media-controller.js.map +1 -0
- package/dist/electron/network-monitor.d.ts +61 -0
- package/dist/electron/network-monitor.js +117 -0
- package/dist/electron/network-monitor.js.map +1 -0
- package/dist/electron/preload.js.map +1 -1
- package/dist/electron/presentation-handler.d.ts +39 -4
- package/dist/electron/presentation-handler.js +192 -48
- package/dist/electron/presentation-handler.js.map +1 -1
- package/dist/electron/presentation-source.d.ts +76 -0
- package/dist/electron/presentation-source.js +125 -0
- package/dist/electron/presentation-source.js.map +1 -0
- package/dist/electron/session-service.d.ts +198 -24
- package/dist/electron/session-service.js +629 -248
- package/dist/electron/session-service.js.map +1 -1
- package/dist/electron/session-tracker.d.ts +82 -0
- package/dist/electron/session-tracker.js +219 -0
- package/dist/electron/session-tracker.js.map +1 -0
- package/dist/electron/sink-service.d.ts +246 -0
- package/dist/electron/sink-service.js +602 -0
- package/dist/electron/sink-service.js.map +1 -0
- package/dist/electron/wired-display/controller.d.ts +76 -0
- package/dist/electron/wired-display/controller.js +194 -0
- package/dist/electron/wired-display/controller.js.map +1 -0
- package/dist/electron/wired-display/displays.d.ts +44 -0
- package/dist/electron/wired-display/displays.js +91 -0
- package/dist/electron/wired-display/displays.js.map +1 -0
- package/dist/electron/wired-display/electron-windows.d.ts +111 -0
- package/dist/electron/wired-display/electron-windows.js +301 -0
- package/dist/electron/wired-display/electron-windows.js.map +1 -0
- package/dist/electron/wired-display/index.d.ts +90 -0
- package/dist/electron/wired-display/index.js +99 -0
- package/dist/electron/wired-display/index.js.map +1 -0
- package/dist/electron/wired-display/local-presentation.d.ts +98 -0
- package/dist/electron/wired-display/local-presentation.js +228 -0
- package/dist/electron/wired-display/local-presentation.js.map +1 -0
- package/dist/electron/wired-display/provider.d.ts +112 -0
- package/dist/electron/wired-display/provider.js +197 -0
- package/dist/electron/wired-display/provider.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mirroring/backend.d.ts +76 -0
- package/dist/mirroring/backend.js +18 -0
- package/dist/mirroring/backend.js.map +1 -0
- package/dist/mirroring/electron/agent-protocol.d.ts +158 -0
- package/dist/mirroring/electron/agent-protocol.js +10 -0
- package/dist/mirroring/electron/agent-protocol.js.map +1 -0
- package/dist/mirroring/electron/agent-source.d.ts +20 -0
- package/dist/mirroring/electron/agent-source.js +618 -0
- package/dist/mirroring/electron/agent-source.js.map +1 -0
- package/dist/mirroring/electron/engine-process.d.ts +87 -0
- package/dist/mirroring/electron/engine-process.js +78 -0
- package/dist/mirroring/electron/engine-process.js.map +1 -0
- package/dist/mirroring/electron/host.d.ts +89 -0
- package/dist/mirroring/electron/host.js +318 -0
- package/dist/mirroring/electron/host.js.map +1 -0
- package/dist/mirroring/electron/port-backend.d.ts +107 -0
- package/dist/mirroring/electron/port-backend.js +441 -0
- package/dist/mirroring/electron/port-backend.js.map +1 -0
- package/dist/mirroring/encoding-support.d.ts +66 -0
- package/dist/mirroring/encoding-support.js +81 -0
- package/dist/mirroring/encoding-support.js.map +1 -0
- package/dist/mirroring/engine.d.ts +16 -0
- package/dist/mirroring/engine.js +75 -0
- package/dist/mirroring/engine.js.map +1 -0
- package/dist/mirroring/mirror-settings.d.ts +101 -0
- package/dist/mirroring/mirror-settings.js +134 -0
- package/dist/mirroring/mirror-settings.js.map +1 -0
- package/dist/mirroring/mirroring-activity.d.ts +207 -0
- package/dist/mirroring/mirroring-activity.js +362 -0
- package/dist/mirroring/mirroring-activity.js.map +1 -0
- package/dist/mirroring/mirroring-manager.d.ts +134 -0
- package/dist/mirroring/mirroring-manager.js +281 -0
- package/dist/mirroring/mirroring-manager.js.map +1 -0
- package/dist/mirroring/protocol/answer.d.ts +87 -0
- package/dist/mirroring/protocol/answer.js +226 -0
- package/dist/mirroring/protocol/answer.js.map +1 -0
- package/dist/mirroring/protocol/constants.d.ts +64 -0
- package/dist/mirroring/protocol/constants.js +66 -0
- package/dist/mirroring/protocol/constants.js.map +1 -0
- package/dist/mirroring/protocol/errors.d.ts +25 -0
- package/dist/mirroring/protocol/errors.js +29 -0
- package/dist/mirroring/protocol/errors.js.map +1 -0
- package/dist/mirroring/protocol/frame-id.d.ts +9 -0
- package/dist/mirroring/protocol/frame-id.js +20 -0
- package/dist/mirroring/protocol/frame-id.js.map +1 -0
- package/dist/mirroring/protocol/messenger.d.ts +42 -0
- package/dist/mirroring/protocol/messenger.js +118 -0
- package/dist/mirroring/protocol/messenger.js.map +1 -0
- package/dist/mirroring/protocol/offer.d.ts +109 -0
- package/dist/mirroring/protocol/offer.js +176 -0
- package/dist/mirroring/protocol/offer.js.map +1 -0
- package/dist/mirroring/protocol/recommendations.d.ts +28 -0
- package/dist/mirroring/protocol/recommendations.js +99 -0
- package/dist/mirroring/protocol/recommendations.js.map +1 -0
- package/dist/mirroring/routing.d.ts +60 -0
- package/dist/mirroring/routing.js +130 -0
- package/dist/mirroring/routing.js.map +1 -0
- package/dist/mirroring/rtcp/ntp.d.ts +27 -0
- package/dist/mirroring/rtcp/ntp.js +57 -0
- package/dist/mirroring/rtcp/ntp.js.map +1 -0
- package/dist/mirroring/rtcp/parser.d.ts +50 -0
- package/dist/mirroring/rtcp/parser.js +265 -0
- package/dist/mirroring/rtcp/parser.js.map +1 -0
- package/dist/mirroring/rtcp/sender-report.d.ts +32 -0
- package/dist/mirroring/rtcp/sender-report.js +51 -0
- package/dist/mirroring/rtcp/sender-report.js.map +1 -0
- package/dist/mirroring/rtcp/wire.d.ts +54 -0
- package/dist/mirroring/rtcp/wire.js +68 -0
- package/dist/mirroring/rtcp/wire.js.map +1 -0
- package/dist/mirroring/rtp/frame-crypto.d.ts +11 -0
- package/dist/mirroring/rtp/frame-crypto.js +35 -0
- package/dist/mirroring/rtp/frame-crypto.js.map +1 -0
- package/dist/mirroring/rtp/frame.d.ts +23 -0
- package/dist/mirroring/rtp/frame.js +2 -0
- package/dist/mirroring/rtp/frame.js.map +1 -0
- package/dist/mirroring/rtp/packetizer.d.ts +27 -0
- package/dist/mirroring/rtp/packetizer.js +88 -0
- package/dist/mirroring/rtp/packetizer.js.map +1 -0
- package/dist/mirroring/sender/audio-sender.d.ts +23 -0
- package/dist/mirroring/sender/audio-sender.js +54 -0
- package/dist/mirroring/sender/audio-sender.js.map +1 -0
- package/dist/mirroring/sender/bandwidth-estimator.d.ts +26 -0
- package/dist/mirroring/sender/bandwidth-estimator.js +103 -0
- package/dist/mirroring/sender/bandwidth-estimator.js.map +1 -0
- package/dist/mirroring/sender/capture-size-oracle.d.ts +121 -0
- package/dist/mirroring/sender/capture-size-oracle.js +433 -0
- package/dist/mirroring/sender/capture-size-oracle.js.map +1 -0
- package/dist/mirroring/sender/frame-sender.d.ts +103 -0
- package/dist/mirroring/sender/frame-sender.js +212 -0
- package/dist/mirroring/sender/frame-sender.js.map +1 -0
- package/dist/mirroring/sender/packet-router.d.ts +74 -0
- package/dist/mirroring/sender/packet-router.js +191 -0
- package/dist/mirroring/sender/packet-router.js.map +1 -0
- package/dist/mirroring/sender/sender-session.d.ts +85 -0
- package/dist/mirroring/sender/sender-session.js +235 -0
- package/dist/mirroring/sender/sender-session.js.map +1 -0
- package/dist/mirroring/sender/sender.d.ts +120 -0
- package/dist/mirroring/sender/sender.js +452 -0
- package/dist/mirroring/sender/sender.js.map +1 -0
- package/dist/mirroring/sender/video-encoder-metrics.d.ts +29 -0
- package/dist/mirroring/sender/video-encoder-metrics.js +58 -0
- package/dist/mirroring/sender/video-encoder-metrics.js.map +1 -0
- package/dist/mirroring/sender/video-sender.d.ts +95 -0
- package/dist/mirroring/sender/video-sender.js +190 -0
- package/dist/mirroring/sender/video-sender.js.map +1 -0
- package/dist/mirroring/session-host.d.ts +185 -0
- package/dist/mirroring/session-host.js +625 -0
- package/dist/mirroring/session-host.js.map +1 -0
- package/dist/mirroring/stats/clock-offset-estimator.d.ts +11 -0
- package/dist/mirroring/stats/clock-offset-estimator.js +120 -0
- package/dist/mirroring/stats/clock-offset-estimator.js.map +1 -0
- package/dist/mirroring/stats/openscreen-stats-client.d.ts +12 -0
- package/dist/mirroring/stats/openscreen-stats-client.js +17 -0
- package/dist/mirroring/stats/openscreen-stats-client.js.map +1 -0
- package/dist/mirroring/stats/sorted-map.d.ts +23 -0
- package/dist/mirroring/stats/sorted-map.js +66 -0
- package/dist/mirroring/stats/sorted-map.js.map +1 -0
- package/dist/mirroring/stats/statistics-analyzer.d.ts +50 -0
- package/dist/mirroring/stats/statistics-analyzer.js +335 -0
- package/dist/mirroring/stats/statistics-analyzer.js.map +1 -0
- package/dist/mirroring/stats/statistics-collector.d.ts +29 -0
- package/dist/mirroring/stats/statistics-collector.js +49 -0
- package/dist/mirroring/stats/statistics-collector.js.map +1 -0
- package/dist/mirroring/stats/statistics-common.d.ts +61 -0
- package/dist/mirroring/stats/statistics-common.js +39 -0
- package/dist/mirroring/stats/statistics-common.js.map +1 -0
- package/dist/mirroring/stats/statistics-dispatcher.d.ts +28 -0
- package/dist/mirroring/stats/statistics-dispatcher.js +100 -0
- package/dist/mirroring/stats/statistics-dispatcher.js.map +1 -0
- package/dist/mirroring/stats/statistics.d.ts +84 -0
- package/dist/mirroring/stats/statistics.js +141 -0
- package/dist/mirroring/stats/statistics.js.map +1 -0
- package/dist/mirroring/transport/udp-environment.d.ts +40 -0
- package/dist/mirroring/transport/udp-environment.js +93 -0
- package/dist/mirroring/transport/udp-environment.js.map +1 -0
- package/dist/polyfill/bridge-types.d.ts +11 -0
- package/dist/polyfill/presentation-receiver.d.ts +12 -0
- package/dist/polyfill/presentation-receiver.js +366 -0
- package/dist/polyfill/presentation-receiver.js.map +1 -0
- package/dist/polyfill/presentation-standin.js +157 -15
- package/dist/polyfill/presentation-standin.js.map +1 -1
- package/dist/protocol/framing.d.ts +1 -1
- package/dist/protocol/framing.js +1 -1
- package/dist/protocol/framing.js.map +1 -1
- package/docs/API.md +724 -0
- package/docs/ARCHITECTURE.md +242 -0
- package/docs/CHROMIUM-MAP.md +176 -0
- package/docs/DESIGN.md +1189 -0
- package/docs/FAQ.md +123 -0
- package/docs/GETTING-STARTED.md +248 -0
- package/docs/MAIN-API.md +524 -0
- package/docs/TROUBLESHOOTING.md +283 -0
- package/docs/guides/audio-and-groups.md +75 -0
- package/docs/guides/custom-receivers.md +109 -0
- package/docs/guides/device-authentication.md +145 -0
- package/docs/guides/device-picker.md +176 -0
- package/docs/guides/index.md +17 -0
- package/docs/guides/low-level-client.md +103 -0
- package/docs/guides/restart-rejoin.md +172 -0
- package/docs/guides/testing.md +162 -0
- package/docs/guides/windows-and-iframes.md +116 -0
- package/docs/readme/badges/dependencies.svg +1 -0
- package/docs/readme/badges/electron.svg +1 -0
- package/docs/readme/badges/license.svg +1 -0
- package/docs/readme/badges/node.svg +1 -0
- package/docs/readme/board.jpg +0 -0
- package/docs/readme/hero-dark.jpg +0 -0
- package/docs/readme/hero-light.jpg +0 -0
- package/docs/readme/nosignal.jpg +0 -0
- package/docs/readme/parity.jpg +0 -0
- package/docs/readme/trace.svg +22 -0
- package/package.json +21 -5
- package/src/cli.ts +57 -0
- package/src/client/auth/cast-auth.ts +2 -0
- package/src/dial/dial-registry.ts +316 -0
- package/src/dial/dial-sink-service.ts +343 -0
- package/src/dial/http.ts +200 -0
- package/src/dial/index.ts +135 -0
- package/src/dial/origins.ts +31 -0
- package/src/dial/parse.ts +319 -0
- package/src/dial/route-provider.ts +429 -0
- package/src/dial/ssdp-socket.ts +79 -0
- package/src/dial/xml.ts +180 -0
- package/src/dial-test/cli-main.ts +146 -0
- package/src/dial-test/report.ts +109 -0
- package/src/dial-test/runner.ts +615 -0
- package/src/dial-test/scrub.ts +74 -0
- package/src/discovery/cast-discovery.ts +2 -0
- package/src/discovery/device-cache.ts +5 -0
- package/src/discovery/index.ts +1 -0
- package/src/discovery/ip-policy.ts +97 -0
- package/src/discovery/udp-socket.ts +3 -0
- package/src/electron/access-code.ts +681 -0
- package/src/electron/app-discovery.ts +244 -0
- package/src/electron/default-presentation.ts +104 -0
- package/src/electron/main.ts +664 -29
- package/src/electron/manager-api.ts +367 -15
- package/src/electron/media-controller.ts +313 -0
- package/src/electron/network-monitor.ts +140 -0
- package/src/electron/preload.ts +1 -1
- package/src/electron/presentation-handler.ts +195 -48
- package/src/electron/presentation-source.ts +155 -0
- package/src/electron/session-service.ts +693 -238
- package/src/electron/session-tracker.ts +248 -0
- package/src/electron/sink-service.ts +726 -0
- package/src/electron/wired-display/controller.ts +212 -0
- package/src/electron/wired-display/displays.ts +107 -0
- package/src/electron/wired-display/electron-windows.ts +386 -0
- package/src/electron/wired-display/index.ts +181 -0
- package/src/electron/wired-display/local-presentation.ts +286 -0
- package/src/electron/wired-display/provider.ts +276 -0
- package/src/index.ts +1 -0
- package/src/mirroring/backend.ts +103 -0
- package/src/mirroring/electron/agent-protocol.ts +84 -0
- package/src/mirroring/electron/agent-source.ts +619 -0
- package/src/mirroring/electron/engine-process.ts +131 -0
- package/src/mirroring/electron/host.ts +361 -0
- package/src/mirroring/electron/port-backend.ts +466 -0
- package/src/mirroring/encoding-support.ts +146 -0
- package/src/mirroring/engine.ts +91 -0
- package/src/mirroring/mirror-settings.ts +174 -0
- package/src/mirroring/mirroring-activity.ts +466 -0
- package/src/mirroring/mirroring-manager.ts +342 -0
- package/src/mirroring/protocol/answer.ts +285 -0
- package/src/mirroring/protocol/constants.ts +75 -0
- package/src/mirroring/protocol/errors.ts +36 -0
- package/src/mirroring/protocol/frame-id.ts +20 -0
- package/src/mirroring/protocol/messenger.ts +128 -0
- package/src/mirroring/protocol/offer.ts +275 -0
- package/src/mirroring/protocol/recommendations.ts +135 -0
- package/src/mirroring/routing.ts +160 -0
- package/src/mirroring/rtcp/ntp.ts +61 -0
- package/src/mirroring/rtcp/parser.ts +292 -0
- package/src/mirroring/rtcp/sender-report.ts +88 -0
- package/src/mirroring/rtcp/wire.ts +76 -0
- package/src/mirroring/rtp/frame-crypto.ts +38 -0
- package/src/mirroring/rtp/frame.ts +25 -0
- package/src/mirroring/rtp/packetizer.ts +95 -0
- package/src/mirroring/sender/audio-sender.ts +59 -0
- package/src/mirroring/sender/bandwidth-estimator.ts +111 -0
- package/src/mirroring/sender/capture-size-oracle.ts +476 -0
- package/src/mirroring/sender/frame-sender.ts +293 -0
- package/src/mirroring/sender/packet-router.ts +228 -0
- package/src/mirroring/sender/sender-session.ts +306 -0
- package/src/mirroring/sender/sender.ts +497 -0
- package/src/mirroring/sender/video-encoder-metrics.ts +64 -0
- package/src/mirroring/sender/video-sender.ts +243 -0
- package/src/mirroring/session-host.ts +725 -0
- package/src/mirroring/stats/clock-offset-estimator.ts +139 -0
- package/src/mirroring/stats/openscreen-stats-client.ts +19 -0
- package/src/mirroring/stats/sorted-map.ts +68 -0
- package/src/mirroring/stats/statistics-analyzer.ts +388 -0
- package/src/mirroring/stats/statistics-collector.ts +69 -0
- package/src/mirroring/stats/statistics-common.ts +112 -0
- package/src/mirroring/stats/statistics-dispatcher.ts +133 -0
- package/src/mirroring/stats/statistics.ts +170 -0
- package/src/mirroring/transport/udp-environment.ts +100 -0
- package/src/polyfill/bridge-types.ts +11 -0
- package/src/polyfill/presentation-receiver.ts +350 -0
- package/src/polyfill/presentation-standin.ts +147 -15
- package/src/protocol/framing.ts +1 -1
package/docs/MAIN-API.md
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
# Main-process API
|
|
2
|
+
|
|
3
|
+
`createCastManager` returns a `CastManager`: `start()`, `devices()`, `discoverSinksNow()`, `settled()`, `dispose()`, `addSinkByAddress()` (see [Adding a device by address](#adding-a-device-by-address)) and the API below, which lets the
|
|
4
|
+
app observe and control casting from the main process. It follows Chrome's Media Router, so the same concepts and
|
|
5
|
+
method names apply: devices are **sinks**, running sessions are **routes**, and you watch both with **observers**.
|
|
6
|
+
|
|
7
|
+
This API does not touch the preload's `mode: "chromecast"`; it works for both modes, because both end in the same
|
|
8
|
+
session service.
|
|
9
|
+
|
|
10
|
+
Media control, casting from the app's own UI, wired displays, adding a device by address and tab and desktop mirroring
|
|
11
|
+
are new in 0.5. Until 0.5.0 is released they are in the `next` prerelease: `npm i electron-cast@next`.
|
|
12
|
+
|
|
13
|
+
## Mapping to Chrome
|
|
14
|
+
|
|
15
|
+
Checked against Chromium `main` (November 2026). Paths are relative to the Chromium source root.
|
|
16
|
+
|
|
17
|
+
| electron-cast | Chrome | Chromium source |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `registerMediaSinksObserver(observer, query?)` | `MediaSinksObserver` (constructed with a `MediaSource` and an origin, or for all sinks; `Init()` registers it) and its `OnSinksUpdated(sinks, origins)`. `MediaRouter::RegisterMediaSinksObserver` is private to the observer class | `components/media_router/browser/media_router.h`, `components/media_router/browser/media_sinks_observer.h` |
|
|
20
|
+
| `MediaSink` | `media_router::MediaSink`: `id`, `name`, `icon_type`, `provider_id` (no description) | `components/media_router/common/media_sink.h` |
|
|
21
|
+
| `MediaSink.iconType` | `GetCastSinkIconType`: `video_out` gives `CAST`, else a multizone group gives `CAST_AUDIO_GROUP`, else `CAST_AUDIO` | `chrome/browser/media/router/discovery/mdns/media_sink_util.cc` |
|
|
22
|
+
| `registerMediaRoutesObserver(observer)` | `MediaRoutesObserver` (constructed with the router) and `OnRoutesUpdated(routes)`; `MediaRouter::RegisterMediaRoutesObserver` is private to it | `components/media_router/browser/media_routes_observer.h` |
|
|
23
|
+
| `MediaRoute` (`mediaSource`, `sinkId`, `description`) | `media_router::MediaRoute` (`media_source`, `media_sink_id`, `description`; the id is `media_route_id`) | `components/media_router/common/media_route.h`, `media_route.cc` |
|
|
24
|
+
| `MediaRoute.description` | `CastSession::GetRouteDescription`: the status text, else the display name | `chrome/browser/media/router/providers/cast/cast_internal_message_util.cc` |
|
|
25
|
+
| `terminateRoute(id)` | `MediaRouter::TerminateRoute`, called by the Cast dialog's stop (`MediaRouterUI::StopCasting`) and by the global media controls' `CastMediaNotificationItem::StopCasting`; `CastActivityManager::TerminateSession` stops the receiver app | `media_router.h`, `chrome/browser/ui/media_router/media_router_ui.cc`, `chrome/browser/ui/global_media_controls/cast_media_notification_item.cc`, `chrome/browser/media/router/providers/cast/cast_activity_manager.cc` |
|
|
26
|
+
| `detachRoute(id)` | `MediaRouter::DetachRoute` exists, but the Cast provider does not implement it (`CastMediaRouteProvider::DetachRoute` is `NOTIMPLEMENTED`): a page lets go through its Presentation connection closing (`CastSessionClientImpl::DidClose`). No counterpart for "every page lets go" | `media_router.h`, `chrome/browser/media/router/providers/cast/cast_media_route_provider.cc`, `cast_session_client_impl.cc` |
|
|
27
|
+
| `getRouteController(id).setVolume / setMute` | `MediaRouter::GetMediaController` binds a `mojom::MediaController` (`SetVolume`, `SetMute`); on a Cast route `CastMediaController` sends a receiver `SET_VOLUME` request. Used by the global media controls (`CastMediaNotificationItem::SetVolume / SetMute`, controller bound in `cast_media_notification_producer.cc`), not by the Cast dialog. There is no class named `MediaRouteController` in current Chromium | `components/media_router/common/mojom/media_controller.mojom`, `chrome/browser/media/router/providers/cast/cast_media_controller.cc`, `app_activity.cc`, `chrome/browser/ui/global_media_controls/` |
|
|
28
|
+
| `hasDefaultPresentationRequest(webContentsId)`, `getDefaultPresentationRequest(webContentsId)`, `addPresentationObserver(webContentsId, observer)` | `WebContentsPresentationManager` (`HasDefaultPresentationRequest`, `GetDefaultPresentationRequest`, `AddObserver`; implemented by `ControllerPresentationServiceDelegateImpl`, one per `WebContents`), `content::PresentationObserver::OnDefaultPresentationChanged`, `content::PresentationRequest` (`render_frame_host_id`, `presentation_urls`, `frame_origin`) | `components/media_router/browser/presentation/web_contents_presentation_manager.h`, `controller_presentation_service_delegate_impl.cc`, `content/public/browser/presentation_request.h` |
|
|
29
|
+
| `startCasting(sinkId, { webContentsId, castMode: "presentation" })` | `MediaRouterUI::StartCasting(sink_id, MediaCastMode::PRESENTATION)`, then `MediaRouteStarter::CreateRouteParameters` (the source for the sink comes from the default request's URLs; none gives an "unable to cast" issue), `StartRoute` (`MediaRouter::CreateRoute`, with `WebContentsPresentationManager::OnPresentationResponse` as the response callback) and `OnPresentationResponse`, which adds the presentation and runs the default-presentation callback; `RouteRequestResultCode` is the error set | `chrome/browser/ui/media_router/media_router_ui.cc`, `media_route_starter.cc`, `components/media_router/common/mojom/route_request_result_code.mojom` |
|
|
30
|
+
| `getMediaController(id, observer?)` | `MediaRouter::GetMediaController`: binds a `mojom::MediaController` (`Play`, `Pause`, `SetMute`, `SetVolume`, `Seek`, `NextTrack`, `PreviousTrack`) and a `mojom::MediaStatusObserver` (`OnMediaStatusUpdated(MediaStatus)`). `CastMediaController` builds the status from the receiver volume (`SetSession`) and MEDIA_STATUS messages (`SetMediaStatus`, `UpdateMediaStatus`), which `CastSessionTracker::HandleMediaStatusMessage` first completes from the media it saved | `components/media_router/common/mojom/media_controller.mojom`, `media_status.mojom`, `chrome/browser/media/router/providers/cast/cast_media_controller.cc`, `app_activity.cc`, `cast_session_tracker.cc` |
|
|
31
|
+
| `selectDevice`'s third argument | `QueryResultManager` (owns the sinks observers the dialog's `MediaRouteStarter` / `MediaRouterUI` uses while open) | `chrome/browser/ui/media_router/query_result_manager.cc` |
|
|
32
|
+
| `addSinkByAddress`, `configureAccessCode`, network changes (the `networkMonitor` option) | `AccessCodeCastSinkService` after the discovery server has answered (`OnAccessCodeValidated`, `OnEnabledPrefChange`, `OnNetworksChanged`) | `chrome/browser/media/router/discovery/access_code/access_code_cast_sink_service.cc`; see [DESIGN.md](DESIGN.md#access-code-casting-access-codets) |
|
|
33
|
+
| Sinks listed only once a channel is open and authenticated, with retry and removal; the session tracker; non-local routes | `CastMediaSinkServiceImpl`, `MediaSinkServiceBase`, `CastSessionTracker`, `CastActivityManager::AddNonLocalActivity` | see [DESIGN.md](DESIGN.md#sinks-and-sessions-sink-servicets-session-trackerts) for each rule and its source |
|
|
34
|
+
| the Cast provider behind routes | `CastMediaRouteProvider`, `CastActivityManager`, `AppActivity` | `chrome/browser/media/router/providers/cast/` |
|
|
35
|
+
|
|
36
|
+
Where electron-cast differs from Chrome:
|
|
37
|
+
|
|
38
|
+
- Observers get the full list straight away on registration, then after each change, as Chrome's observers do once
|
|
39
|
+
the router has a list. A sinks observer is only called when its (filtered) list actually changed.
|
|
40
|
+
- Chrome's sinks observer is scoped by a `MediaSource` and origin; here `query.capabilities` filters instead. Chrome's
|
|
41
|
+
`MediaSink` has no description; `description` here is the device model (Chrome keeps it in
|
|
42
|
+
`CastSinkExtraData::model_name`, not on the sink).
|
|
43
|
+
- Registration returns the unregister function; Chrome unregisters when the observer object is destroyed.
|
|
44
|
+
- `terminateRoute`, `setVolume` and `setMute` return promises and reject with `MediaRouteError` (`code`:
|
|
45
|
+
`route_not_found` or a bridge code such as `session_error`); `setVolume` rejects with `RangeError` for a level outside
|
|
46
|
+
0 to 1 and `setMute` with `TypeError` for a non-boolean. `detachRoute` and `getRouteController` are synchronous and
|
|
47
|
+
throw `MediaRouteError` `route_not_found` for an unknown route. Chrome's are fire-and-forget.
|
|
48
|
+
- A route's id is the Cast session id. Chrome's `media_route_id` is `urn:x-org.chromium:media:route:<presentation id>/<sink id>/<source id>`
|
|
49
|
+
(`MediaRoute::GetMediaRouteId`).
|
|
50
|
+
- `MediaRoute` also carries `appId`, `displayName`, `sinkName`, `isLocal`, `origin`, `volume`, `members` (`webContents.id`s, once each however
|
|
51
|
+
many of a window's frames hold the route), `parkedSenders` and `parked`, because in an Electron app main wants to
|
|
52
|
+
know which windows hold a route. A route is `parked` when its pages navigated away (a reload, say) and none is
|
|
53
|
+
attached; it stays on the device so the next page can rejoin (see CHANGELOG 0.3.1).
|
|
54
|
+
- `detachRoute` has no Chrome counterpart (see the table). It is electron-cast's own.
|
|
55
|
+
- Volume matches Chrome: both send the receiver's `SET_VOLUME` (`level` or `muted`), the volume of the device, not of
|
|
56
|
+
a media session; the route's `volume` shows what the device last reported. Chrome additionally ignores the call
|
|
57
|
+
when the route has no session yet (every route here has one). The rest of Chrome's controller is
|
|
58
|
+
[`getMediaController`](#media-control).
|
|
59
|
+
|
|
60
|
+
## Sinks
|
|
61
|
+
|
|
62
|
+
<!-- no-check -->
|
|
63
|
+
```ts
|
|
64
|
+
import { createCastManager, type MediaSink } from "electron-cast/main";
|
|
65
|
+
|
|
66
|
+
const manager = createCastManager({ ipcMain, selectDevice });
|
|
67
|
+
await manager.start();
|
|
68
|
+
|
|
69
|
+
const stop = manager.registerMediaSinksObserver({
|
|
70
|
+
onSinksUpdated(sinks: MediaSink[]) {
|
|
71
|
+
// called now with the current devices, then whenever one appears, changes or goes
|
|
72
|
+
tray.setDevices(sinks.map((s) => s.name));
|
|
73
|
+
},
|
|
74
|
+
}, { capabilities: ["video_out"] }); // optional, same names as requestSession's
|
|
75
|
+
// stop() unregisters
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A `MediaSink` is `{ id, providerId: "cast" | "dial", name, description (the model), iconType: "cast" | "cast_audio" | "cast_audio_group" | "generic", device }`
|
|
79
|
+
where `device` is the discovered `CastDevice`. A DIAL sink (`providerId: "dial"`, id `dial:<uuid>`, icon `generic`, as
|
|
80
|
+
`DialMediaSinkServiceImpl` creates it) has `device.dial` set. A device that both mDNS and SSDP found is reported once,
|
|
81
|
+
as the Cast sink (`CastMediaSinkServiceImpl::TryConnectDialDiscoveredSink`). DIAL sinks have no capabilities, so a
|
|
82
|
+
`capabilities` query never lists them; `manager.devices()` stays the Cast devices.
|
|
83
|
+
|
|
84
|
+
A device is a sink only once electron-cast has opened a channel to it and it has passed device authentication, as in
|
|
85
|
+
Chrome. Channels open after discovery with a random delay of up to 5 s, so right after `start()` the list is empty for
|
|
86
|
+
a moment; a failed attempt is retried (15 s, 3 attempts), and a device that never opens is never listed. The list is
|
|
87
|
+
reported once it has been quiet for 3 s. A device that mDNS stops reporting stays listed while its channel is up; it
|
|
88
|
+
goes when the channel fails and cannot be reopened (a ping every 5 s notices within 10 s). `manager.devices()` and
|
|
89
|
+
`selectDevice`'s list are these sinks. `manager.discoverSinksNow()` skips the delay, and `createCastManager({ sinks })`
|
|
90
|
+
tunes the numbers (see [API.md](API.md#castmanageroptions)); `sinks.allowAllIps` lets it reach public and loopback
|
|
91
|
+
addresses, which Chrome refuses by default.
|
|
92
|
+
|
|
93
|
+
## Routes
|
|
94
|
+
|
|
95
|
+
<!-- no-check -->
|
|
96
|
+
```ts
|
|
97
|
+
manager.registerMediaRoutesObserver({
|
|
98
|
+
onRoutesUpdated(routes) {
|
|
99
|
+
// now, then when a route starts, ends, or its status, volume or pages change
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
manager.getRoutes(); // the current list: local, parked and non-local routes
|
|
104
|
+
await manager.terminateRoute(routeId); // stop the app on the device
|
|
105
|
+
manager.detachRoute(routeId); // let go, leave the app running
|
|
106
|
+
const controller = manager.getRouteController(routeId);
|
|
107
|
+
await controller.setVolume(0.4); // 0 to 1
|
|
108
|
+
await controller.setMute(true);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
A device that runs a session no page of this app holds (started by another sender, or by this app before it restarted)
|
|
112
|
+
has a route too, as in Chrome (`AddNonLocalActivity`): `isLocal` is `false`, `members` and `origin` are empty, and
|
|
113
|
+
`sinkName` names the device. It follows the device's receiver status, goes when the app stops, and can be
|
|
114
|
+
terminated and have its volume set (while its channel is down, because the device is being reopened, terminating fails with `session_error` "StopSession response is not OK. Failed to terminate route." and the route stays, as in Chrome); `detachRoute` on it does nothing. A route a page held, once every page has let go
|
|
115
|
+
of it without stopping the app, becomes a non-local route. `isLocal` is `true` for the routes of this app's pages.
|
|
116
|
+
|
|
117
|
+
A DIAL route (`providerId: "dial"`) is the route of a `cast-dial:` presentation. Its `id` is Chrome's
|
|
118
|
+
`urn:x-org.chromium:media:route:<presentation id>/<sink id>/<source>`, `mediaSource` the `cast-dial:` source, `appId` is `""`
|
|
119
|
+
and `description` and `displayName` the app name, and `isLocal` is `true`. It has no volume and no media control:
|
|
120
|
+
`getRouteController(id).setVolume()` rejects and `getMediaController(id)` throws `MediaRouteError` `route_not_found`, as
|
|
121
|
+
Chrome's DIAL provider does not implement `BindMediaController`. `terminateRoute` sends the `DELETE` that stops the app
|
|
122
|
+
(and tells the page's connection it ended); `detachRoute` ends the page's connections and leaves the app running, which
|
|
123
|
+
is also what a page closing its connection does (`DialMediaRouteProvider::DetachRoute` is not implemented in Chrome, so
|
|
124
|
+
nothing stops the app).
|
|
125
|
+
|
|
126
|
+
Control goes through the same `CastSessionService` code the page's calls use, so the page sees what it would see if
|
|
127
|
+
the change came from the device:
|
|
128
|
+
|
|
129
|
+
- `terminateRoute`: every page on the route gets `sessionEnded` (`stopped`); the Presentation connection of
|
|
130
|
+
presentation mode closes.
|
|
131
|
+
- `detachRoute`: every page gets `sessionEnded` (`disconnected`); the device keeps running the app.
|
|
132
|
+
- `setVolume` / `setMute`: the device reports its new volume, and the pages get `sessionUpdated`.
|
|
133
|
+
|
|
134
|
+
`dispose()` stops the observers (they are not called again) and closes the device connections; it does not stop the
|
|
135
|
+
apps running on the devices.
|
|
136
|
+
|
|
137
|
+
## Media control
|
|
138
|
+
|
|
139
|
+
<!-- no-check -->
|
|
140
|
+
```ts
|
|
141
|
+
const controller = manager.getMediaController(routeId, {
|
|
142
|
+
onMediaStatusUpdated(status) {
|
|
143
|
+
// title, secondaryTitle, playState (a MediaPlayState: "playing" | "paused" | "buffering"), currentTime,
|
|
144
|
+
// duration (seconds), volume, isMuted, canPlayPause, canSeek, canMute, canSetVolume, canSkipToNextTrack,
|
|
145
|
+
// canSkipToPreviousTrack, images (MediaImage[]: { url, size: { width, height } | null })
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
await controller.play();
|
|
149
|
+
await controller.pause();
|
|
150
|
+
await controller.seek(90); // seconds
|
|
151
|
+
await controller.nextTrack(); // QUEUE_UPDATE with jump 1, as Chrome does
|
|
152
|
+
await controller.setVolume(0.4); // the receiver's volume, as getRouteController
|
|
153
|
+
controller.close(); // stop the reports
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
It is what Chrome offers for a Cast route (`CastMediaController`), sent over the device's open channel, so it is
|
|
157
|
+
available on every route electron-cast has, non-local ones included: Chrome binds a controller to any activity
|
|
158
|
+
(`CastActivityManager::BindMediaController`), and a session started elsewhere is an `AppActivity` too
|
|
159
|
+
(`AddNonLocalActivity`); for one, a virtual connection to its transport is opened first, as Chrome's message handler
|
|
160
|
+
does. (All routes here are app routes; Chrome's mirroring routes have a controller of their own, and there is no
|
|
161
|
+
mirroring here.) The status comes from the session tracker on that channel: the volume of every receiver status
|
|
162
|
+
(`SetSession`) and every MEDIA_STATUS the device sends, whoever started the media, merged with the fields saved from
|
|
163
|
+
earlier ones (`CastSessionTracker::HandleMediaStatusMessage`). Messages go out as Chrome writes them (`CreateMediaRequest`): `PLAY`, `PAUSE`,
|
|
164
|
+
`SEEK` with `currentTime`, `QUEUE_UPDATE` with `jump` 1 or -1, each with the `mediaSessionId` last seen in a
|
|
165
|
+
MEDIA_STATUS (-1 before any, which the receiver refuses, as for Chrome) and the `sessionId`. Binding asks the receiver
|
|
166
|
+
for its media status (`GET_STATUS`).
|
|
167
|
+
|
|
168
|
+
Observers are called as Chrome calls them: on every receiver status that has a volume and every MEDIA_STATUS, repeated
|
|
169
|
+
or not, and on binding (any controller's binding tells every observer of the route, as `SetSession` does).
|
|
170
|
+
|
|
171
|
+
Where it differs from Chrome:
|
|
172
|
+
|
|
173
|
+
- Commands return promises, resolved when the message is written, not when the receiver has acted. They reject with
|
|
174
|
+
`MediaRouteError` `route_not_found` once the route is gone. `seek` rejects with `RangeError` for a time that is not a
|
|
175
|
+
number of seconds from 0 up. `getMediaController` throws `MediaRouteError` for an unknown route.
|
|
176
|
+
- Times are seconds, not `TimeDelta`. `MediaStatus.images` keeps only `https` URLs, as Chrome does.
|
|
177
|
+
- electron-cast has one Cast sender id per device connection where Chrome gives the controller its own, so the
|
|
178
|
+
receiver's replies to a command also reach the route's pages. Request ids start at 2^30 so they cannot be mistaken
|
|
179
|
+
for the page SDK's.
|
|
180
|
+
- Chrome's controller is a mojo pipe that closes with its route; here, after the route ends the commands reject and the
|
|
181
|
+
observer is not called again.
|
|
182
|
+
|
|
183
|
+
## A live device picker
|
|
184
|
+
|
|
185
|
+
`selectDevice(devices, request, picker)` gets the devices at request time and, as a third argument, a handle that
|
|
186
|
+
works like Chrome's dialog watching sinks while it is open. mDNS often needs a few seconds, so devices can appear
|
|
187
|
+
after the picker opens:
|
|
188
|
+
|
|
189
|
+
<!-- no-check -->
|
|
190
|
+
```ts
|
|
191
|
+
selectDevice: (devices, request, picker) =>
|
|
192
|
+
new Promise((resolve) => {
|
|
193
|
+
const win = openPickerWindow(devices, resolve);
|
|
194
|
+
// only the devices that can serve this request, the same way `devices` was filtered
|
|
195
|
+
picker.registerMediaSinksObserver({ onSinksUpdated: (sinks) => win.setDevices(sinks.map((s) => s.device)) });
|
|
196
|
+
picker.signal.addEventListener("abort", () => win.close()); // answered, cancelled, page gone or disposed
|
|
197
|
+
}),
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The observer is called at once with the current list, and is dropped when `picker.signal` aborts. Existing pickers
|
|
201
|
+
with two parameters keep working; they just ignore the third. If no device matches when the page asks, the request
|
|
202
|
+
still fails with `receiver_unavailable` before the picker opens.
|
|
203
|
+
|
|
204
|
+
## Casting from the app's own UI
|
|
205
|
+
|
|
206
|
+
In Chrome a page that wants to be castable from the browser's Cast dialog sets
|
|
207
|
+
`navigator.presentation.defaultRequest = new PresentationRequest(urls)`, and Google's Cast SDK listens for
|
|
208
|
+
`connectionavailable` on it. The dialog (opened from the toolbar or menu, not from the page) lists that request as its presentation
|
|
209
|
+
source, and when the user picks a device Chrome starts the presentation and fires `connectionavailable` on the default
|
|
210
|
+
request with the new connection; the SDK adopts the session. The app's own cast UI does the same here:
|
|
211
|
+
|
|
212
|
+
<!-- no-check -->
|
|
213
|
+
```ts
|
|
214
|
+
const id = win.webContents.id;
|
|
215
|
+
|
|
216
|
+
// is the page castable from my UI? (has it set defaultRequest?)
|
|
217
|
+
manager.hasDefaultPresentationRequest(id);
|
|
218
|
+
manager.getDefaultPresentationRequest(id); // { webContentsId, presentationUrls, frameOrigin } or null
|
|
219
|
+
const off = manager.addPresentationObserver(id, {
|
|
220
|
+
onDefaultPresentationChanged(request) { menu.setCastEnabled(request !== null); },
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// the devices that can run it, kept current (the dialog's sinks observers for its presentation source)
|
|
224
|
+
manager.registerMediaSinksObserver(
|
|
225
|
+
{ onSinksUpdated: (sinks) => menu.setDevices(sinks) },
|
|
226
|
+
{
|
|
227
|
+
presentationUrls: manager.getDefaultPresentationRequest(id)?.presentationUrls ?? [],
|
|
228
|
+
origin: manager.getDefaultPresentationRequest(id)?.frameOrigin,
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
// the user picked a device in my menu
|
|
233
|
+
try {
|
|
234
|
+
const route = await manager.startCasting(sink.id, { webContentsId: id }); // the page's connectionavailable fires
|
|
235
|
+
} catch (err) {
|
|
236
|
+
if (err instanceof MediaRouteError) showCastError(err.code, err.message);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
What happens, with Chrome's counterparts:
|
|
241
|
+
|
|
242
|
+
1. **The page sets `defaultRequest`.** Blink's `Presentation::setDefaultRequest` sends the request's URLs (none for
|
|
243
|
+
`null`) to the browser on every set, and the stand-in does the same. `PresentationServiceImpl::SetDefaultPresentationUrls`
|
|
244
|
+
ignores a frame that is not the outermost document and a list equal to the current one, then hands the request to
|
|
245
|
+
`ControllerPresentationServiceDelegateImpl::SetDefaultPresentationUrls`, which keeps one default request per
|
|
246
|
+
`WebContents` and tells its observers. electron-cast keeps one per window, from its main frame only (an iframe's
|
|
247
|
+
`defaultRequest` is not reported to the app, as in Chrome), keyed by `webContents.id`.
|
|
248
|
+
2. **It is cleared** when the page sets `null` (or a request with no URLs), navigates to another document
|
|
249
|
+
(`PresentationServiceImpl::DidFinishNavigation` → `Reset` → `ClearDefaultPresentationRequest`; a same-document
|
|
250
|
+
navigation keeps it) or goes away. Observers then get `null`.
|
|
251
|
+
3. **`startCasting(sinkId, { webContentsId })`** is `MediaRouterUI::StartCasting(sink_id, PRESENTATION)`.
|
|
252
|
+
`MediaRouteStarter::CreateRouteParameters` needs a presentation source for the sink: the first of the request's URLs
|
|
253
|
+
the sink can run (`QueryResultManager::GetSourceForCastModeAndSink`): a Cast app URL for a Cast sink, a `cast-dial:`
|
|
254
|
+
URL for a DIAL sink (`MediaRouteStarter::OnDefaultPresentationChanged` makes a source of every URL, and the DIAL
|
|
255
|
+
provider serves the `cast-dial:` ones). With no default request, an unknown sink, or no
|
|
256
|
+
URL the sink suits (a Cast URL that is not one, or capabilities the sink lacks), Chrome shows an "unable to cast"
|
|
257
|
+
issue and starts nothing; here the promise rejects with `unable_to_cast`. Otherwise `MediaRouter::CreateRoute` runs,
|
|
258
|
+
here a launch on the sink with no picker. The session is a route like any other: routes observers see it, and it is
|
|
259
|
+
owned by the window's main frame.
|
|
260
|
+
4. **`WebContentsPresentationManager::OnPresentationResponse`** adds the presentation, and only when the default
|
|
261
|
+
request is still the one that was started (`ArePresentationRequestsEqual`) does it run the default-presentation
|
|
262
|
+
callback: `PresentationServiceImpl::OnDefaultPresentationStarted` →
|
|
263
|
+
`PresentationController::OnDefaultPresentationStarted` → `ControllerPresentationConnection::Create`, which
|
|
264
|
+
enqueues `connectionavailable` on the page's current `defaultRequest` (and does nothing if it is null). The stand-in
|
|
265
|
+
does the same: the event fires after the current task with a `connected` connection whose first messages are
|
|
266
|
+
`receiver_action` and `new_session`, which Google's SDK turns into its session. If the page replaced the request during the
|
|
267
|
+
launch, the session stays up as a route but the page is not handed a connection (Chrome likewise records the
|
|
268
|
+
presentation and tells nobody).
|
|
269
|
+
|
|
270
|
+
There is **no user gesture** on this path. The gesture check (`HasTransientUserActivation`) is in
|
|
271
|
+
`PresentationServiceImpl::StartPresentation`, which serves the page's own `PresentationRequest.start()`; the dialog's
|
|
272
|
+
route creation does not call it, because the browser UI is the user's action. The app is trusted the same way: only
|
|
273
|
+
code in the main process can call `startCasting`, never a page.
|
|
274
|
+
|
|
275
|
+
Errors are `MediaRouteError`s whose `code` is Chrome's `RouteRequestResultCode` in lower case, from the cause the
|
|
276
|
+
launch reports: `timed_out` (`TIMED_OUT`, the app did not launch in time), `sink_not_found` (`SINK_NOT_FOUND`, the device
|
|
277
|
+
cannot be reached), `invalid_origin` (`INVALID_ORIGIN`, `allowOrigin` refuses the page), `cancelled` (`CANCELLED`, the page
|
|
278
|
+
navigated or went away during the launch), `redundant_request` (`REDUNDANT_REQUEST`, the window already has a start in
|
|
279
|
+
progress, for the page's own or the app's) and `unknown_error` (`UNKNOWN_ERROR`). `unable_to_cast` is the dialog's own
|
|
280
|
+
check, above. `TypeError` and `RangeError` are thrown, as elsewhere here, for arguments of the wrong type or a cast mode
|
|
281
|
+
other than `"presentation"`, the only one electron-cast has (no tab or desktop mirroring).
|
|
282
|
+
|
|
283
|
+
Differences from Chrome:
|
|
284
|
+
|
|
285
|
+
- `getDefaultPresentationRequest` returns `null` without a request, where Chrome calls it an error. Observers are not
|
|
286
|
+
called on registration, like Chrome's, so read the current request first. They are called with `null` when the window is
|
|
287
|
+
destroyed, which Chrome does not announce.
|
|
288
|
+
- A `PresentationRequest` has `webContentsId` where Chrome has `render_frame_host_id`: only the outermost frame can own
|
|
289
|
+
one, so the window identifies it.
|
|
290
|
+
- The sinks for a presentation source are asked for with `MediaSinksQuery.presentationUrls`; Chrome builds a
|
|
291
|
+
`MediaSource` per URL. A sink matches when the URL is a Cast URL (`https://google.com/cast#__castAppId__=...` or
|
|
292
|
+
`cast:<appId>`), the sink has the capabilities its app id names **and the device answered `GET_APP_AVAILABILITY`
|
|
293
|
+
with the app available**, as Chrome's `CastAppAvailabilityTracker::GetAvailableSinks` requires
|
|
294
|
+
(`CastAppDiscoveryServiceImpl::StartObservingMediaSinks` asks every sink when a source is first observed). So a
|
|
295
|
+
sinks observer with `presentationUrls` first reports the sinks that were already asked, and the others when the
|
|
296
|
+
device has answered; `startCasting` asks (once per device and app) before launching, so it works without an observer. The
|
|
297
|
+
answers follow `CastAppDiscoveryServiceImpl::ShouldRefreshAppAvailability` (`cast_app_discovery_service.cc`): an
|
|
298
|
+
available app is kept until the device goes away and comes back, an unavailable one is asked again after
|
|
299
|
+
`kRefreshThreshold` (1 minute), and a device that cannot be reached or does not answer is unknown (always asked again
|
|
300
|
+
by `startCasting`; a sinks observer retries it at most once a minute, not at every change). `discoverSinksNow()`
|
|
301
|
+
asks again too, by the same rules (`CastAppDiscoveryServiceImpl::Refresh`). The question goes over the channel the
|
|
302
|
+
device already has open; nothing else is connected. The page's own `getAvailability()` and `start()` use the same
|
|
303
|
+
answers (see [API.md](API.md#app-availability)).
|
|
304
|
+
- A DIAL sink matches a `cast-dial:` URL whose app its DIAL server said it has, for the query's `origin` when the app is
|
|
305
|
+
one Chrome offers to some origins only (`DialMediaRouteProvider::GetOrigins`); pass the request's `frameOrigin`. While
|
|
306
|
+
the observer is registered the DIAL sinks are asked about those apps, as the DIAL provider's `StartObservingMediaSinks`
|
|
307
|
+
does. `startCasting` on a DIAL sink asks too and waits up to 5 s for the answer, then starts the DIAL route; the page
|
|
308
|
+
gets `connectionavailable` with an `mr_` presentation id, and the SDK's DIAL launch round trip runs on it as for its own
|
|
309
|
+
`start()`. A DIAL route has no earlier-route rule: `CastActivityManager`'s is Cast's, and the DIAL provider stops the
|
|
310
|
+
route already on the sink itself.
|
|
311
|
+
- Launching: `CastMediaRouteProvider::CreateRoute` ignores the `timeout` it is given (the dialog's
|
|
312
|
+
`GetRouteRequestTimeout(PRESENTATION)`, 20 s, `media_router_ui_helper.cc`). `CastActivityManager::DoLaunchSession`
|
|
313
|
+
gives the receiver the source's own `launch_timeout()`: `__castLaunchTimeout__` from the URL when it is a positive
|
|
314
|
+
number of milliseconds, else `kDefaultLaunchTimeout`, 60 s (`cast_media_source.cc` / `.h`). `startCasting` does the same,
|
|
315
|
+
as the page's own `start()` does.
|
|
316
|
+
- A sink that already has a route: `CastActivityManager::LaunchSession` launches anyway (a pending removal is noted for
|
|
317
|
+
the old activity, which goes when the receiver's status update says its session is gone). It does not reuse the route, so
|
|
318
|
+
neither does `startCasting` (the page's own picker path here still returns an existing session on the chosen sink).
|
|
319
|
+
`DoLaunchSession` also stops the route this frame launched before (`routes_by_frame_`); `startCasting` stops the
|
|
320
|
+
route its window's main frame last launched, by `startCasting` or by the page's `start()`, if it is still running.
|
|
321
|
+
- A default request replaced during the launch: `OnPresentationResponse` records the presentation and the route stays
|
|
322
|
+
(`DoLaunchSession` already added it); only the connection is not handed over. The route stays here too, listed by
|
|
323
|
+
routes observers, until the window launches another, the app terminates it or the receiver ends it. The connection of a
|
|
324
|
+
declined start is not wired to the page (nothing it sends reaches the page that has the window now). If the request
|
|
325
|
+
changed, or the page navigated, while the device was still being asked about the app, the start is `cancelled` before
|
|
326
|
+
anything is launched.
|
|
327
|
+
|
|
328
|
+
## Wired displays
|
|
329
|
+
|
|
330
|
+
With the `wiredDisplay` option, other screens are presentation sinks, as Chrome's `WiredDisplayMediaRouteProvider`
|
|
331
|
+
makes them: a page's `PresentationRequest` for an https URL (not the legacy Cast URL) or http on localhost can start on
|
|
332
|
+
a display, which opens that page fullscreen in a locked-down receiver window; the presented page gets
|
|
333
|
+
`navigator.presentation.receiver`. The package never imports Electron, so the app passes `screen`, `BrowserWindow` and
|
|
334
|
+
a receiver window factory. Rules and their Chromium counterparts: [DESIGN.md](DESIGN.md#wired-displays).
|
|
335
|
+
|
|
336
|
+
<!-- no-check -->
|
|
337
|
+
```ts
|
|
338
|
+
import { app, BrowserWindow, ipcMain, screen, session } from "electron";
|
|
339
|
+
import { join } from "node:path";
|
|
340
|
+
import { createCastManager, createReceiverWindows } from "electron-cast/main";
|
|
341
|
+
|
|
342
|
+
const receivers = createReceiverWindows({
|
|
343
|
+
BrowserWindow, session, ipcMain,
|
|
344
|
+
preloadDir: join(app.getPath("userData"), "electron-cast-receiver"), // the generated receiver preload goes here
|
|
345
|
+
});
|
|
346
|
+
const manager = createCastManager({
|
|
347
|
+
ipcMain,
|
|
348
|
+
selectDevice, // may now answer { display: id } when request.displays is set (below)
|
|
349
|
+
wiredDisplay: {
|
|
350
|
+
screen,
|
|
351
|
+
BrowserWindow, // finds the page's own display, which the picker leaves out
|
|
352
|
+
createReceiverWindow: receivers.factory,
|
|
353
|
+
async selectDisplay(sinks, request) { // the picker for a request only a display can show
|
|
354
|
+
return (await myDisplayPicker(sinks, request.observeSinks))?.id ?? null;
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
manager.wiredDisplay?.registerMediaRoutesObserver({ onRoutesUpdated: (routes) => menu.setPresentations(routes) });
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
- **The pickers.** A request whose URLs only a display serves calls `selectDisplay(sinks, request)` (a
|
|
362
|
+
`WiredDisplayRequest`; `observeSinks` follows the list while the picker is open), which resolves a sink id or `null`.
|
|
363
|
+
A request that also has a Cast (or `cast-dial:`) URL is one picker, as Chrome's dialog lists both kinds of sink: when
|
|
364
|
+
displays and devices both exist, `selectDevice` gets `request.displays` and may answer a `DisplayChoice`
|
|
365
|
+
(`{ display: id }`), or a device as usual.
|
|
366
|
+
- **Sinks and routes** (`manager.wiredDisplay`, a `WiredDisplayApi`): `getSinks`, `registerMediaSinksObserver`,
|
|
367
|
+
`getRoutes`, `registerMediaRoutesObserver` and `terminateRoute`, which closes the receiver window. A
|
|
368
|
+
`WiredDisplaySink` is `wired_display_<id>`, "Display N", with its `display`; a `WiredDisplayRoute` has the
|
|
369
|
+
presentation URL, `Presenting (<host>)` and `isLocalPresentation: true`. They are kept apart from the Cast and DIAL
|
|
370
|
+
sinks of `registerMediaSinksObserver`.
|
|
371
|
+
- **Messages** are `PresentationMessage`s, a string or bytes, up to 64 MiB either way.
|
|
372
|
+
|
|
373
|
+
| Export | What it is |
|
|
374
|
+
|---|---|
|
|
375
|
+
| `createReceiverWindows(options)` | The Electron part: a `ReceiverWindows` whose `factory` opens receiver windows, and `dispose()`. `ReceiverWindowsOptions`: `BrowserWindow`, `session`, `ipcMain`, `preloadDir`, and optional `channel` and `platform`. Once per `ipcMain` and channel. |
|
|
376
|
+
| `isWiredDisplaySource(url)` | Whether a display can show the URL (`IsValidStandardPresentationSource`). |
|
|
377
|
+
| `availableDisplays(all, primary)`, `wiredDisplaySinks(all, primary)` | The displays that are sinks, in Chrome's order (primary first, then top-left; none for a single or mirrored setup), and their sinks. |
|
|
378
|
+
| `WiredDisplayOptions`, `WiredDisplayRequest`, `WiredDisplayApi`, `WiredDisplaySink`, `WiredDisplayRoute`, `DisplayChoice` | The types above. |
|
|
379
|
+
| `ScreenLike`, `DisplayLike`, `WindowLike` | The parts of Electron's `screen`, `Display` and `BrowserWindow` that are used. |
|
|
380
|
+
|
|
381
|
+
## Adding a device by address
|
|
382
|
+
|
|
383
|
+
Chrome's Access Code Cast lets a user type the code a device shows to cast to it from another network. electron-cast does
|
|
384
|
+
not turn codes into addresses (that is a Google service that needs Chrome's own sign-in; see
|
|
385
|
+
[DESIGN.md](DESIGN.md#access-code-casting-access-codets)), but it does what Chrome does once the address is known: the app
|
|
386
|
+
supplies it.
|
|
387
|
+
|
|
388
|
+
<!-- no-check -->
|
|
389
|
+
```ts
|
|
390
|
+
const manager = createCastManager({
|
|
391
|
+
ipcMain, selectDevice,
|
|
392
|
+
accessCode: { enabled: true, deviceDuration: 3600 }, // Chrome's AccessCodeCastEnabled and AccessCodeCastDeviceDuration
|
|
393
|
+
});
|
|
394
|
+
const result = await manager.addSinkByAddress({
|
|
395
|
+
id: "a1b2c3d4e5f60718293a4b5c6d7e8f90", // the device's unique id
|
|
396
|
+
name: "Seminar Room 4",
|
|
397
|
+
capabilities: { videoOut: true, audioOut: true },
|
|
398
|
+
ipV4Address: "10.20.30.40", // or ipV6Address, which is preferred
|
|
399
|
+
port: 8009, // optional, 8009 by default
|
|
400
|
+
});
|
|
401
|
+
// { code: "ok", sinkId } | { code: "response_malformed" | "sink_creation_error" | "channel_open_error", message, ... }
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
The device is then in `devices()` and the sinks observers, offered to the picker and to pages' availability checks like any
|
|
405
|
+
discovered device. It is removed `deviceDuration` seconds after it was added (plus 20 s), or when the cast to it ends after
|
|
406
|
+
that. A public or loopback address is refused as for any device, unless `sinks.allowAllIps` is set. When the machine's
|
|
407
|
+
network changes the manager removes such devices and adds the remembered ones back, as Chrome does (it watches the
|
|
408
|
+
network itself; see the `networkMonitor` option). `configureAccessCode({ enabled, deviceDuration })` changes the settings while running,
|
|
409
|
+
`rememberedSinks()` lists what is remembered, and `accessCode.store` (`load`, `save`) keeps it between runs.
|
|
410
|
+
|
|
411
|
+
**Validate the address.** In Chrome it comes from Google's server; here it comes from your app. electron-cast only applies
|
|
412
|
+
Chrome's rules, which allow every private address and every port, so an address a user typed and you passed on unchecked
|
|
413
|
+
lets that user make the app open TLS connections to any host and port on your network and read from the result whether
|
|
414
|
+
something answered. Accept only addresses you expect (a known subnet, port 8009 unless you know otherwise) before
|
|
415
|
+
calling `addSinkByAddress`. The sink's id is the device id, in lower case without dashes, in angle brackets (`<uuid>`, Chrome's `cast:<uuid>`), so a
|
|
416
|
+
device that mDNS also finds is a second sink until the same-address rule removes one, as in Chrome.
|
|
417
|
+
|
|
418
|
+
| Export | What it is |
|
|
419
|
+
|---|---|
|
|
420
|
+
| `AccessCodeOptions` | The `accessCode` option: `enabled`, `deviceDuration` (seconds), `store`, and optional `log` and `now` (tests). |
|
|
421
|
+
| `AccessCodeDevice`, `AccessCodeCapabilities` | What `addSinkByAddress` takes: `id`, `name`, `capabilities` (`videoOut`, `videoIn`, `audioOut`, `audioIn`, `devMode`), `ipV6Address` or `ipV4Address`, and `port`. |
|
|
422
|
+
| `AddSinkResult`, `SinkCreationFailure` | How adding ended: `ok` with the `sinkId`, or `response_malformed`, `sink_creation_error` (with its `reason`) or `channel_open_error`. |
|
|
423
|
+
| `AccessCodeRememberedSink`, `AccessCodeStore` | A remembered device, and where they are kept between runs (`load`, `save`). |
|
|
424
|
+
| `AccessCodeCastDisabledError` | What `addSinkByAddress` rejects with unless access code casting is enabled. |
|
|
425
|
+
| `createAccessCodeSink(device)` | Chrome's checks on a device, without opening anything: the sink it would be, or why it cannot be one. |
|
|
426
|
+
|
|
427
|
+
## Tab and desktop mirroring
|
|
428
|
+
|
|
429
|
+
`startCasting` also starts Chrome's other two cast modes, tab and desktop mirroring ("Cast tab" and "Cast screen"):
|
|
430
|
+
the app chooses what to send. They are off unless you pass `mirroring` to `createCastManager`:
|
|
431
|
+
|
|
432
|
+
<!-- no-check -->
|
|
433
|
+
```ts
|
|
434
|
+
import { app, BrowserWindow, MessageChannelMain, utilityProcess, webContents } from "electron";
|
|
435
|
+
|
|
436
|
+
const manager = createCastManager({
|
|
437
|
+
ipcMain,
|
|
438
|
+
selectDevice,
|
|
439
|
+
mirroring: { electron: { BrowserWindow, utilityProcess, MessageChannelMain, webContents, app } },
|
|
440
|
+
});
|
|
441
|
+
await manager.start();
|
|
442
|
+
|
|
443
|
+
// Only the devices that can receive this kind of mirroring (audio-only speakers cannot take "desktop_mirror" without audio).
|
|
444
|
+
manager.registerMediaSinksObserver({ onSinksUpdated: showDevices }, { castMode: "tab_mirror" });
|
|
445
|
+
|
|
446
|
+
const route = await manager.startCasting(sink.id, { castMode: "tab_mirror", webContentsId: win.webContents.id });
|
|
447
|
+
// route.description is "Casting tab"; route.id is Chrome's urn:x-org.chromium:media:route:... form.
|
|
448
|
+
// The mirrored page is muted locally while the route runs, as in Chrome, and unmuted when it ends (an app that wants
|
|
449
|
+
// local audio can call webContents.setAudioMuted(false) itself). Desktop audio follows Chrome per platform: local
|
|
450
|
+
// playback keeps going on Windows and is muted elsewhere; there is no setting for it.
|
|
451
|
+
await manager.terminateRoute(route.id); // stops the receiver app, as Chrome does
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
`startCasting(sinkId, options)` is one method for the three modes, as `MediaRouterUI::StartCasting` takes the cast mode;
|
|
455
|
+
`options` is a `StartCastingOptions`, one shape per mode (`MediaCastMode`; the mirroring ones are `MirroringCastMode`). Note that `webContentsId` means two things:
|
|
456
|
+
|
|
457
|
+
- `castMode: "presentation"` (or none) with `webContentsId`: the window whose **default presentation request** is cast
|
|
458
|
+
(above).
|
|
459
|
+
- `castMode: "tab_mirror"` with `webContentsId`: the **page to mirror** (video and its audio).
|
|
460
|
+
- `castMode: "desktop_mirror"` with `desktopSourceId` (an id from `desktopCapturer.getSources`) and optionally
|
|
461
|
+
`withAudio` (system loopback audio, where the OS provides it).
|
|
462
|
+
- `targetPlayoutDelayMs` overrides the receiver playout delay (Chrome's default is 200 ms, `kDefaultPlayoutDelay`).
|
|
463
|
+
|
|
464
|
+
A mirroring start rejects with a `MediaRouteError` (`code`: `sink_not_found`, `unable_to_cast`, `unknown_error`,
|
|
465
|
+
`cancelled`); `unable_to_cast` too when the `mirroring` option was not given. A mode that is none of the three is a
|
|
466
|
+
`RangeError`. The sinks query for a mode is `MediaSinksQuery.castMode` (with `withAudio` for desktop mirroring): the Cast
|
|
467
|
+
sinks that can run one of its streaming apps; DIAL sinks never match. The mirroring session runs on the device's one
|
|
468
|
+
kept-open channel, as Chrome's runs on its `CastSocket`, and its route is a local route, not a non-local one. A new
|
|
469
|
+
route on a device ends the one already running there, as in Chrome. Mirroring routes show up in
|
|
470
|
+
`registerMediaRoutesObserver` and end on `terminateRoute`, when the receiver's app closes, or on a stream error.
|
|
471
|
+
|
|
472
|
+
While a tab route runs, the source can change and the video can be frozen, as in Chrome:
|
|
473
|
+
|
|
474
|
+
<!-- no-check -->
|
|
475
|
+
```ts
|
|
476
|
+
// "Share this tab instead": same route, same Cast session, no renegotiation; the new page is muted locally and the
|
|
477
|
+
// old one is unmuted (if the library muted it). A page has one route: a mirroring route already on it ends.
|
|
478
|
+
manager.switchMirroringSourceTab(route.id, otherWin.webContents.id);
|
|
479
|
+
|
|
480
|
+
// Pause the picture on its last frame (the audio goes on). It takes effect after 500 ms; unfreezing is immediate.
|
|
481
|
+
manager.registerMediaRoutesObserver({ onRoutesUpdated: (routes) => routes.forEach((r) => console.log(r.id, r.freezeInfo)) });
|
|
482
|
+
manager.freezeRoute(route.id); // ignored unless freezeInfo.canFreeze is true
|
|
483
|
+
manager.unfreezeRoute(route.id);
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
`route.id` and `route.mediaSource` keep their values across a switch (Chrome's route does not change either); the page the
|
|
487
|
+
route is bound to is in `route.members`. Switching is for `tab_mirror` routes only (`unable_to_cast` for a desktop route,
|
|
488
|
+
a route still launching, or a page that cannot be captured). `freezeInfo` is `{ canFreeze, isFrozen }` on mirroring
|
|
489
|
+
routes. A frozen route unfreezes when its tab is switched.
|
|
490
|
+
|
|
491
|
+
Mirroring statistics are a debugging aid, as in Chrome's `chrome://media-router-internals` "Mirroring stats" (not a web
|
|
492
|
+
API; nothing is uploaded, and Chrome's UMA is not ported):
|
|
493
|
+
|
|
494
|
+
```js
|
|
495
|
+
manager.setMirroringStatsEnabled(true); // off by default; read when a session starts, so call it before startCasting
|
|
496
|
+
const route = await manager.startCasting(sink.id, { castMode: "tab_mirror", webContentsId });
|
|
497
|
+
const off = manager.registerMirroringStatsObserver((routeId, stats) => {}); // every 500 ms, as Chrome's observers
|
|
498
|
+
manager.getMirroringStats(route.id); // { audio: {...}, video: {...} }; {} until the first fetch, while off, or for an unknown route
|
|
499
|
+
manager.isMirroringStatsEnabled();
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
The dictionary has Chrome's names and units. Per stream: `ENQUEUE_FPS`, `AVG_CAPTURE_LATENCY_MS`, `AVG_ENCODE_TIME_MS`,
|
|
503
|
+
`AVG_QUEUEING_LATENCY_MS`, `AVG_NETWORK_LATENCY_MS`, `AVG_PACKET_LATENCY_MS`, `AVG_FRAME_LATENCY_MS`,
|
|
504
|
+
`AVG_E2E_LATENCY_MS`, `ENCODE_KBPS`, `TRANSMISSION_KBPS`, `MS_SINCE_LAST_RECEIVER_RESPONSE`, `NUM_FRAMES_CAPTURED`,
|
|
505
|
+
`NUM_FRAMES_DROPPED_BY_ENCODER`, `NUM_FRAMES_LATE`, `NUM_PACKETS_SENT`, `NUM_PACKETS_RECEIVED`, `FIRST_EVENT_TIME_MS`,
|
|
506
|
+
`LAST_EVENT_TIME_MS`, `UNKNOWN_OPEN_SCREEN_STAT` (retransmitted packets), the histograms (`CAPTURE_LATENCY_MS_HISTO`,
|
|
507
|
+
`ENCODE_TIME_MS_HISTO`, `QUEUEING_LATENCY_MS_HISTO`, `NETWORK_LATENCY_MS_HISTO`, `PACKET_LATENCY_MS_HISTO`,
|
|
508
|
+
`E2E_LATENCY_MS_HISTO`, `LATE_FRAME_MS_HISTO`, each a list like `[{ "0-19": 12 }, { ">=800": 1 }]`), and from the session
|
|
509
|
+
host `TARGET_BITRATE`, `ENCODER_UTILIZATION`, `LOSSINESS`, `FRAMES_INSERTED`, `FRAMES_DROPPED`. A value that is not
|
|
510
|
+
finite is the string `"null"`. As in Chrome the structure is for logs, not a contract. `getMirroringStats` takes a route
|
|
511
|
+
id because several routes can run (Chrome's debugger keeps one global copy). It never throws: like Chrome's `MediaRouterDebuggerImpl::GetMirroringStats`, which has no error path, it returns `{}` while statistics are off, before the first fetch and for a route id it does not know, and a route that has ended keeps its last statistics (Chrome's copy outlives the session) until another route pushes newer ones.
|
|
512
|
+
|
|
513
|
+
`mirroring` options (`ElectronMirroringOptions`): `electron` (the Electron objects to use, an `ElectronMirroringApi`:
|
|
514
|
+
`BrowserWindow`, `utilityProcess`, `MessageChannelMain`, `webContents`, and `app` so that Chrome's
|
|
515
|
+
switches are seen), `engineModulePath` (only if a bundler moved the library's files) and `log`. Opus audio is always offered. Video is
|
|
516
|
+
chosen as Chrome chooses it: H.264, VP8 and VP9 in hardware when the machine has an encoder for them
|
|
517
|
+
(`VideoEncoder.isConfigSupported` with `prefer-hardware`), VP8 and VP9 in software when it has none; Chrome's own
|
|
518
|
+
switches on `app.commandLine` change that (`--cast-streaming-force-{enable,disable}-hardware-<codec>`,
|
|
519
|
+
`--enable-features` / `--disable-features` with `CastStreamingVp8`, `CastStreamingVp9`, `CastStreamingAv1`,
|
|
520
|
+
`CastStreamingHardwareHevc`, and `--disable-cast-letterboxing`), including ones the app appends itself. A hardware
|
|
521
|
+
encoder that fails during a session is dropped for the rest of the app's run and the session offers again without it.
|
|
522
|
+
Capture happens in a hidden window and encoding in WebCodecs; the network sender runs in a utility process, one per
|
|
523
|
+
route. See [DESIGN.md](DESIGN.md#mirroring-srcmirroring) for the layout and [examples/live-mirroring](../examples/live-mirroring/)
|
|
524
|
+
to try it on a real device.
|