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,1273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CastSessionService = exports.APP_AVAILABILITY_REFRESH_MS = void 0;
|
|
4
|
+
exports.capabilityNames = capabilityNames;
|
|
5
|
+
const index_ts_1 = require("../client/index.js");
|
|
6
|
+
const manager_api_ts_1 = require("./manager-api.js");
|
|
7
|
+
const sink_service_ts_1 = require("./sink-service.js");
|
|
8
|
+
const session_tracker_ts_1 = require("./session-tracker.js");
|
|
9
|
+
const app_discovery_ts_1 = require("./app-discovery.js");
|
|
10
|
+
const node_events_1 = require("node:events");
|
|
11
|
+
const access_code_ts_1 = require("./access-code.js");
|
|
12
|
+
/** Capability bit names in bit order: 1 video_out, 2 video_in, 4 audio_out, 8 audio_in, 32 multizone_group. */
|
|
13
|
+
function capabilityNames(bits) {
|
|
14
|
+
const names = [];
|
|
15
|
+
if (bits & 1)
|
|
16
|
+
names.push("video_out");
|
|
17
|
+
if (bits & 2)
|
|
18
|
+
names.push("video_in");
|
|
19
|
+
if (bits & 4)
|
|
20
|
+
names.push("audio_out");
|
|
21
|
+
if (bits & 8)
|
|
22
|
+
names.push("audio_in");
|
|
23
|
+
if (bits & 32)
|
|
24
|
+
names.push("multizone_group");
|
|
25
|
+
return names;
|
|
26
|
+
}
|
|
27
|
+
var app_discovery_ts_2 = require("./app-discovery.js");
|
|
28
|
+
Object.defineProperty(exports, "APP_AVAILABILITY_REFRESH_MS", { enumerable: true, get: function () { return app_discovery_ts_2.APP_AVAILABILITY_REFRESH_MS; } });
|
|
29
|
+
/** How long a request that finds no DIAL sink yet waits for the devices' app info (the dialog of Chrome waits for as long as it is open). */
|
|
30
|
+
const DIAL_PROBE_WAIT_MS = 5000;
|
|
31
|
+
/** Resolves when `done()` is true after a device change, or after `ms`. */
|
|
32
|
+
function waitForDevices(source, ms, done) {
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
if (done())
|
|
35
|
+
return resolve();
|
|
36
|
+
const finish = () => {
|
|
37
|
+
clearTimeout(timer);
|
|
38
|
+
source.off("deviceChanged", onChange);
|
|
39
|
+
resolve();
|
|
40
|
+
};
|
|
41
|
+
const onChange = () => {
|
|
42
|
+
if (done())
|
|
43
|
+
finish();
|
|
44
|
+
};
|
|
45
|
+
const timer = setTimeout(finish, ms);
|
|
46
|
+
source.on("deviceChanged", onChange);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const CAPABILITY_BITS = {
|
|
50
|
+
video_out: 1,
|
|
51
|
+
video_in: 2,
|
|
52
|
+
audio_out: 4,
|
|
53
|
+
audio_in: 8,
|
|
54
|
+
multizone_group: 32,
|
|
55
|
+
};
|
|
56
|
+
const DEFAULT_TIMEOUT_MS = 60000;
|
|
57
|
+
/** The caller id of a stop that comes from the main process, not from a page. */
|
|
58
|
+
const MAIN_CALLER = -1;
|
|
59
|
+
/** A request that must be reported as a specific chrome.cast error code. */
|
|
60
|
+
class MappedError extends Error {
|
|
61
|
+
code;
|
|
62
|
+
constructor(code, message) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.code = code;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** The request bound expired while the client was still working; clean up silently. */
|
|
68
|
+
class Discarded extends Error {
|
|
69
|
+
}
|
|
70
|
+
function describe(err) {
|
|
71
|
+
return err instanceof Error ? err.message : String(err);
|
|
72
|
+
}
|
|
73
|
+
function bad(code, description) {
|
|
74
|
+
return description === undefined ? { ok: false, code } : { ok: false, code, description };
|
|
75
|
+
}
|
|
76
|
+
function good(value) {
|
|
77
|
+
return { ok: true, value };
|
|
78
|
+
}
|
|
79
|
+
function isRecord(v) {
|
|
80
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
81
|
+
}
|
|
82
|
+
function isStringArray(v) {
|
|
83
|
+
return Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
84
|
+
}
|
|
85
|
+
function parseInitialize(params) {
|
|
86
|
+
if (!isRecord(params))
|
|
87
|
+
return null;
|
|
88
|
+
const { appId, capabilities, autoJoinPolicy } = params;
|
|
89
|
+
if (typeof appId !== "string" || !isStringArray(capabilities) || typeof autoJoinPolicy !== "string")
|
|
90
|
+
return null;
|
|
91
|
+
return { appId, capabilities, autoJoinPolicy };
|
|
92
|
+
}
|
|
93
|
+
function parseRequestSession(params) {
|
|
94
|
+
if (!isRecord(params))
|
|
95
|
+
return null;
|
|
96
|
+
const { appId, capabilities, timeoutMs } = params;
|
|
97
|
+
if (typeof appId !== "string" || !isStringArray(capabilities))
|
|
98
|
+
return null;
|
|
99
|
+
const timeout = timeoutMs === undefined ? DEFAULT_TIMEOUT_MS : timeoutMs;
|
|
100
|
+
if (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout <= 0)
|
|
101
|
+
return null;
|
|
102
|
+
return { appId, capabilities, timeoutMs: timeout, appAvailability: params.appAvailability === true };
|
|
103
|
+
}
|
|
104
|
+
/** `requestSession`'s parameters as a picker request with no DIAL app. */
|
|
105
|
+
function parseRequestSessionParams(params) {
|
|
106
|
+
const p = parseRequestSession(params);
|
|
107
|
+
return p === null ? null : { ...p, dialApp: null };
|
|
108
|
+
}
|
|
109
|
+
/** `requestSink` parameters: like `requestSession`'s, with the Cast app id optional and a DIAL app name. */
|
|
110
|
+
function parseRequestSink(params) {
|
|
111
|
+
if (!isRecord(params))
|
|
112
|
+
return null;
|
|
113
|
+
const { appId, dialApp, capabilities, timeoutMs } = params;
|
|
114
|
+
if (appId !== null && typeof appId !== "string")
|
|
115
|
+
return null;
|
|
116
|
+
if (dialApp !== null && typeof dialApp !== "string")
|
|
117
|
+
return null;
|
|
118
|
+
if (appId === null && dialApp === null)
|
|
119
|
+
return null;
|
|
120
|
+
if (!isStringArray(capabilities))
|
|
121
|
+
return null;
|
|
122
|
+
const timeout = timeoutMs === undefined ? DEFAULT_TIMEOUT_MS : timeoutMs;
|
|
123
|
+
if (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout <= 0)
|
|
124
|
+
return null;
|
|
125
|
+
return { appId, dialApp, capabilities, timeoutMs: timeout, appAvailability: params.appAvailability === true };
|
|
126
|
+
}
|
|
127
|
+
function parseSessionId(params) {
|
|
128
|
+
if (!isRecord(params) || typeof params.sessionId !== "string")
|
|
129
|
+
return null;
|
|
130
|
+
return { sessionId: params.sessionId };
|
|
131
|
+
}
|
|
132
|
+
function parseSendMessage(params) {
|
|
133
|
+
if (!isRecord(params))
|
|
134
|
+
return null;
|
|
135
|
+
const { sessionId, namespace, message } = params;
|
|
136
|
+
if (typeof sessionId !== "string" || typeof namespace !== "string" || typeof message !== "string")
|
|
137
|
+
return null;
|
|
138
|
+
return { sessionId, namespace, message };
|
|
139
|
+
}
|
|
140
|
+
function parseSetVolume(params) {
|
|
141
|
+
if (!isRecord(params))
|
|
142
|
+
return null;
|
|
143
|
+
const { sessionId, level } = params;
|
|
144
|
+
if (typeof sessionId !== "string" || typeof level !== "number" || !Number.isFinite(level) || level < 0 || level > 1) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return { sessionId, level };
|
|
148
|
+
}
|
|
149
|
+
function parseSetMuted(params) {
|
|
150
|
+
if (!isRecord(params))
|
|
151
|
+
return null;
|
|
152
|
+
const { sessionId, muted } = params;
|
|
153
|
+
if (typeof sessionId !== "string" || typeof muted !== "boolean")
|
|
154
|
+
return null;
|
|
155
|
+
return { sessionId, muted };
|
|
156
|
+
}
|
|
157
|
+
/** True when every requested capability bit is set on the device (unknown names are ignored). */
|
|
158
|
+
function deviceMatches(device, capabilities) {
|
|
159
|
+
for (const cap of capabilities) {
|
|
160
|
+
const bit = CAPABILITY_BITS[cap];
|
|
161
|
+
if (bit !== undefined && (device.capabilities & bit) === 0)
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
function sameValue(a, b) {
|
|
167
|
+
if (Object.is(a, b))
|
|
168
|
+
return true;
|
|
169
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
170
|
+
return false;
|
|
171
|
+
if (Array.isArray(a) !== Array.isArray(b))
|
|
172
|
+
return false;
|
|
173
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
174
|
+
if (a.length !== b.length)
|
|
175
|
+
return false;
|
|
176
|
+
for (let i = 0; i < a.length; i++) {
|
|
177
|
+
if (!sameValue(a[i], b[i]))
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
const ao = a;
|
|
183
|
+
const bo = b;
|
|
184
|
+
const ak = Object.keys(ao);
|
|
185
|
+
const bk = Object.keys(bo);
|
|
186
|
+
if (ak.length !== bk.length)
|
|
187
|
+
return false;
|
|
188
|
+
for (const k of ak) {
|
|
189
|
+
if (!Object.prototype.hasOwnProperty.call(bo, k))
|
|
190
|
+
return false;
|
|
191
|
+
if (!sameValue(ao[k], bo[k]))
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Main-process cast session manager: tracks initialized senders, one client per
|
|
198
|
+
* device and the sessions pages hold; pushes BridgeEvents back via options.emit.
|
|
199
|
+
*/
|
|
200
|
+
class CastSessionService {
|
|
201
|
+
options;
|
|
202
|
+
senders = new Map();
|
|
203
|
+
sessions = new manager_api_ts_1.ObservedMap((kind, rec) => this.notifySession(kind, rec));
|
|
204
|
+
sessionListeners = new Set();
|
|
205
|
+
sinks;
|
|
206
|
+
/** The devices with an open channel; the only devices the service offers or casts to. */
|
|
207
|
+
sinkService;
|
|
208
|
+
tracker = new session_tracker_ts_1.CastSessionTracker();
|
|
209
|
+
accessCode;
|
|
210
|
+
lastRoutesKey = "";
|
|
211
|
+
/** Devices a page's launch is in flight on, with how many: the session it starts is the page's, not a non-local one. */
|
|
212
|
+
launching = new Map();
|
|
213
|
+
pendingRequests = new Map();
|
|
214
|
+
deviceListener = () => this.onDevicesChanged();
|
|
215
|
+
/** Which sinks have which apps, asked over their open channels (Chrome: CastAppDiscoveryServiceImpl). */
|
|
216
|
+
appDiscovery;
|
|
217
|
+
/** The availability observations that follow the DIAL sinks (see `watchDialSinks`). */
|
|
218
|
+
dialWatchers = new Set();
|
|
219
|
+
onDialSinks = () => {
|
|
220
|
+
for (const watcher of [...this.dialWatchers])
|
|
221
|
+
watcher();
|
|
222
|
+
};
|
|
223
|
+
disposed = false;
|
|
224
|
+
unobserveNetwork;
|
|
225
|
+
constructor(options) {
|
|
226
|
+
this.options = options;
|
|
227
|
+
this.sinkService = new sink_service_ts_1.CastSinkService({
|
|
228
|
+
...options.sinks,
|
|
229
|
+
source: options.devices,
|
|
230
|
+
...(options.dial !== undefined ? { dial: options.dial.source } : {}),
|
|
231
|
+
createClient: options.createClient,
|
|
232
|
+
isClientInUse: (client) => [...this.sessions.values()].some((rec) => rec.client === client),
|
|
233
|
+
});
|
|
234
|
+
this.sinks = (0, manager_api_ts_1.createSinksObservers)(this.sinkService);
|
|
235
|
+
this.appDiscovery = new app_discovery_ts_1.CastAppDiscovery(this.sinkService);
|
|
236
|
+
this.sinkService.on("deviceUp", this.deviceListener);
|
|
237
|
+
this.sinkService.on("deviceDown", this.deviceListener);
|
|
238
|
+
this.sinkService.on("deviceChanged", this.deviceListener);
|
|
239
|
+
this.sinkService.on("channelOpened", ({ device, client }) => {
|
|
240
|
+
// The tracker goes first so that, when a status ends a session, it no longer lists it by the time this one reports.
|
|
241
|
+
this.tracker.attach(device.id, client);
|
|
242
|
+
this.bindClient(client, device);
|
|
243
|
+
});
|
|
244
|
+
// MediaSinkServiceBase::AddOrUpdateSink tells CastAppDiscoveryServiceImpl at once, not after the 3 s report
|
|
245
|
+
this.sinkService.on("channelOpened", ({ device }) => this.appDiscovery.onSinkAddedOrUpdated(device));
|
|
246
|
+
this.sinkService.on("sinkRemoved", (device) => {
|
|
247
|
+
this.tracker.removeSink(device.id);
|
|
248
|
+
this.appDiscovery.onSinkRemoved(device);
|
|
249
|
+
});
|
|
250
|
+
this.tracker.on("sessionAddedOrUpdated", () => this.onTrackerChanged());
|
|
251
|
+
this.tracker.on("sessionRemoved", () => this.onTrackerChanged());
|
|
252
|
+
this.accessCode = new access_code_ts_1.AccessCodeSinks(this.sinkService, {
|
|
253
|
+
current: () => this.mediaRoutes().map((r) => ({ id: r.id, sinkId: r.sinkId, isLocal: r.isLocal })),
|
|
254
|
+
observe: (listener) => this.observeSessions(listener),
|
|
255
|
+
}, options.accessCode);
|
|
256
|
+
// The two observers of Chrome's DiscoveryNetworkMonitor; the sink service asks for the current id first (`Start`).
|
|
257
|
+
const monitor = options.networkMonitor;
|
|
258
|
+
if (monitor !== undefined)
|
|
259
|
+
this.sinkService.onNetworksChanged(monitor.networkId());
|
|
260
|
+
this.unobserveNetwork = monitor?.observe((networkId) => {
|
|
261
|
+
this.sinkService.onNetworksChanged(networkId);
|
|
262
|
+
this.accessCode.onNetworksChanged(networkId);
|
|
263
|
+
}) ?? (() => { });
|
|
264
|
+
}
|
|
265
|
+
/** The devices that can be cast to: those with an open, authenticated channel (as Chrome lists sinks). */
|
|
266
|
+
devices() {
|
|
267
|
+
return this.sinkService.devices();
|
|
268
|
+
}
|
|
269
|
+
/** The devices as a {@link DeviceSource}: what `devices()` lists, with the events of that list changing. */
|
|
270
|
+
deviceSource() {
|
|
271
|
+
return this.sinkService;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Open channels to the discovered devices that have none now, without Chrome's random delay, and ask the sinks again
|
|
275
|
+
* about the apps being observed, by the refresh rules (`CastMediaRouteProvider::DiscoverSinksNow` ->
|
|
276
|
+
* `CastAppDiscoveryServiceImpl::Refresh`).
|
|
277
|
+
*/
|
|
278
|
+
discoverSinksNow() {
|
|
279
|
+
this.sinkService.discoverSinksNow();
|
|
280
|
+
this.appDiscovery.refresh();
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The client of the device's open channel, which every activity on the device shares (Chrome: one `CastSocket` per
|
|
284
|
+
* sink, used by `CastMessageHandler` for every session); undefined when the device is not a sink now.
|
|
285
|
+
*/
|
|
286
|
+
channelClient(deviceId) {
|
|
287
|
+
return this.sinkService.clientOf(deviceId);
|
|
288
|
+
}
|
|
289
|
+
/** Resolves when no channel is being opened and none is scheduled to be; for tests. */
|
|
290
|
+
settled(options) {
|
|
291
|
+
// no extra wait when nothing is being read: callers of settled() depend on how soon it resolves
|
|
292
|
+
const reading = this.accessCode.ready();
|
|
293
|
+
return reading === undefined ? this.sinkService.settled(options) : reading.then(() => this.sinkService.settled(options));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Add a device whose address the app knows, as Chrome adds the one an access code resolved to: a channel is opened and
|
|
297
|
+
* the device is listed like any other, remembered for `accessCode.deviceDuration`, then removed. Rejects with
|
|
298
|
+
* `AccessCodeCastDisabledError` unless access code casting is enabled.
|
|
299
|
+
*/
|
|
300
|
+
addSinkByAddress(device) {
|
|
301
|
+
return this.accessCode.addSinkByAddress(device);
|
|
302
|
+
}
|
|
303
|
+
/** Change `enabled` and `deviceDuration` while running, as Chrome applies its policies. */
|
|
304
|
+
configureAccessCode(settings) {
|
|
305
|
+
return this.accessCode.configure(settings);
|
|
306
|
+
}
|
|
307
|
+
/** The devices added by address that are remembered now. */
|
|
308
|
+
rememberedSinks() {
|
|
309
|
+
return this.accessCode.remembered();
|
|
310
|
+
}
|
|
311
|
+
/** Handle one bridge call; never throws or rejects. */
|
|
312
|
+
async handle(sender, method, params) {
|
|
313
|
+
try {
|
|
314
|
+
const allow = this.options.allowOrigin;
|
|
315
|
+
if (allow !== undefined && !allow(sender.origin)) {
|
|
316
|
+
return bad("extension_missing", "Casting is not allowed for this origin");
|
|
317
|
+
}
|
|
318
|
+
switch (method) {
|
|
319
|
+
case "initialize":
|
|
320
|
+
return this.handleInitialize(sender, params);
|
|
321
|
+
case "requestSession":
|
|
322
|
+
return await this.handleRequestSession(sender, params);
|
|
323
|
+
case "requestSessionOnDevice":
|
|
324
|
+
// main only: the app's own UI chose the device (see the manager's startCasting)
|
|
325
|
+
return await this.handleRequestSession(sender, params, { presetDeviceId: isRecord(params) && typeof params.deviceId === "string" ? params.deviceId : "" });
|
|
326
|
+
case "joinSession":
|
|
327
|
+
return this.handleJoinSession(sender, params, true);
|
|
328
|
+
case "requestSink":
|
|
329
|
+
// main only: the presentation handler's request with a `cast-dial:` source
|
|
330
|
+
return await this.handleRequestSession(sender, params, {
|
|
331
|
+
sink: true,
|
|
332
|
+
...(isRecord(params) && typeof params.deviceId === "string" ? { presetDeviceId: params.deviceId } : {}),
|
|
333
|
+
});
|
|
334
|
+
case "joinRunningSession":
|
|
335
|
+
return await this.handleJoinRunningSession(sender, params);
|
|
336
|
+
case "sendMessage":
|
|
337
|
+
return this.handleSendMessage(sender, params);
|
|
338
|
+
case "stopSession":
|
|
339
|
+
return await this.handleStopSession(sender, params);
|
|
340
|
+
case "leaveSession":
|
|
341
|
+
return this.handleLeaveSession(sender, params);
|
|
342
|
+
case "setReceiverVolume":
|
|
343
|
+
return await this.handleSetVolume(sender, params);
|
|
344
|
+
case "setReceiverMuted":
|
|
345
|
+
return await this.handleSetMuted(sender, params);
|
|
346
|
+
default:
|
|
347
|
+
return bad("invalid_parameter", `unknown method: ${method}`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
catch (err) {
|
|
351
|
+
return bad("session_error", describe(err));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/** Detach a sender that went away: cancel its pending request, leave its sessions, drop its bookkeeping. */
|
|
355
|
+
senderGone(senderId) {
|
|
356
|
+
this.forgetSender(senderId);
|
|
357
|
+
for (const rec of [...this.sessions.values()]) {
|
|
358
|
+
if (!rec.members.has(senderId) && !rec.parked.has(senderId))
|
|
359
|
+
continue;
|
|
360
|
+
this.leave(rec, senderId);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The sender's page navigated (a reload or a new page): cancel its pending request and drop its bookkeeping, but
|
|
365
|
+
* keep its sessions open on the device, parked, so the next page can rejoin them (auto-join or joinSession) as it
|
|
366
|
+
* would in Chrome. A parked session ends as usual if the receiver app stops or the device drops; senderGone ends
|
|
367
|
+
* the sender's share of it for good.
|
|
368
|
+
*/
|
|
369
|
+
senderNavigated(senderId) {
|
|
370
|
+
this.forgetSender(senderId);
|
|
371
|
+
for (const rec of this.sessions.values()) {
|
|
372
|
+
if (!rec.members.delete(senderId))
|
|
373
|
+
continue;
|
|
374
|
+
rec.parked.add(senderId);
|
|
375
|
+
this.notifySession("updated", rec);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
forgetSender(senderId) {
|
|
379
|
+
const pending = this.pendingRequests.get(senderId);
|
|
380
|
+
if (pending !== undefined) {
|
|
381
|
+
pending.cancelled.value = true;
|
|
382
|
+
pending.picker?.close();
|
|
383
|
+
}
|
|
384
|
+
this.pendingRequests.delete(senderId);
|
|
385
|
+
this.senders.delete(senderId);
|
|
386
|
+
}
|
|
387
|
+
/** Unsubscribe, close every client and clear all state. */
|
|
388
|
+
async dispose() {
|
|
389
|
+
if (this.disposed)
|
|
390
|
+
return;
|
|
391
|
+
this.disposed = true;
|
|
392
|
+
this.unobserveNetwork();
|
|
393
|
+
this.sinks.dispose();
|
|
394
|
+
this.accessCode.dispose();
|
|
395
|
+
for (const pending of this.pendingRequests.values())
|
|
396
|
+
pending.picker?.close();
|
|
397
|
+
this.sessions.clear();
|
|
398
|
+
this.tracker.dispose();
|
|
399
|
+
this.appDiscovery.dispose();
|
|
400
|
+
this.sinkService.dispose();
|
|
401
|
+
this.senders.clear();
|
|
402
|
+
this.pendingRequests.clear();
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* What the device said about the app (`GET_APP_AVAILABILITY`), or undefined when it has to be asked: never asked, no
|
|
406
|
+
* answer last time, or "unavailable" longer than `APP_AVAILABILITY_REFRESH_MS` ago. This is
|
|
407
|
+
* CastAppDiscoveryServiceImpl::ShouldRefreshAppAvailability: kAvailable is kept, kUnavailable is asked again after
|
|
408
|
+
* kRefreshThreshold, kUnknown always.
|
|
409
|
+
*/
|
|
410
|
+
cachedAppAvailability(device, appId) {
|
|
411
|
+
return this.appDiscovery.cached(device.id, appId);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Ask the device whether it has the app (`GET_APP_AVAILABILITY`) unless a still-valid answer is cached. An error or
|
|
415
|
+
* no answer is not cached (Chrome's kUnknown): this resolves false, and the next call asks again. Callers that ask on
|
|
416
|
+
* every change (sinks observers) must pace themselves; see createSinksObservers.
|
|
417
|
+
*/
|
|
418
|
+
async checkAppAvailability(device, appId) {
|
|
419
|
+
// Asked over the device's kept-open channel (Chrome: the sink's CastSocket); no channel now is kUnknown. An answer
|
|
420
|
+
// about a channel that was replaced while it was asked is dropped, so it is unknown too.
|
|
421
|
+
await this.appDiscovery.request(device.id, appId);
|
|
422
|
+
return this.appDiscovery.availability(device.id, appId).result === "available";
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* A page's `PresentationRequest` availability (`getAvailability()`), as Chrome serves it: a
|
|
426
|
+
* `PresentationMediaSinksObserver` on the source, fed by `CastAppDiscoveryServiceImpl::StartObservingMediaSinks`, so
|
|
427
|
+
* a sink counts once it has said over its open channel that it has the app (`GET_APP_AVAILABILITY`). With `dialApp`
|
|
428
|
+
* (a `cast-dial:` source of the same request) the DIAL sinks that have that app for the page's origin count too, as
|
|
429
|
+
* Blink ORs the sources of a request; the DIAL sink service is asked to find out while the observation lasts.
|
|
430
|
+
* `available` is the first answer: at once from the answers that stand, else once the Cast sinks asked have answered
|
|
431
|
+
* (a sink that says yes answers it at once). `onchange` is called after that only when the answer changes, as
|
|
432
|
+
* `PresentationMediaSinksObserver::OnSinksReceived` skips a repeated one. `close()` stops the observation
|
|
433
|
+
* (`StopObservingMediaSinks`). A disallowed origin is never available.
|
|
434
|
+
*/
|
|
435
|
+
observeAppAvailability(sender, source, onchange) {
|
|
436
|
+
const allow = this.options.allowOrigin;
|
|
437
|
+
if (this.disposed || (allow !== undefined && !allow(sender.origin)))
|
|
438
|
+
return { available: Promise.resolve(false), close: () => { } };
|
|
439
|
+
const dialApp = source.dialApp;
|
|
440
|
+
const dial = dialApp !== undefined ? this.options.dial : undefined;
|
|
441
|
+
const castSource = { appIds: source.appIds, capabilities: source.capabilities };
|
|
442
|
+
const hasCast = castSource.appIds.length > 0;
|
|
443
|
+
const anyAvailable = () => (hasCast && this.appDiscovery.availableSinks(castSource).length > 0)
|
|
444
|
+
|| (dial !== undefined && dialApp !== undefined && dial.available(dialApp, sender.origin).length > 0);
|
|
445
|
+
let last;
|
|
446
|
+
let closed = false;
|
|
447
|
+
let first;
|
|
448
|
+
const available = new Promise((resolve) => (first = resolve));
|
|
449
|
+
const report = (value) => {
|
|
450
|
+
if (closed || value === last)
|
|
451
|
+
return;
|
|
452
|
+
const answered = last !== undefined;
|
|
453
|
+
last = value;
|
|
454
|
+
if (answered)
|
|
455
|
+
onchange(value);
|
|
456
|
+
else
|
|
457
|
+
first(value);
|
|
458
|
+
};
|
|
459
|
+
const stopCast = hasCast ? this.appDiscovery.startObserving(castSource, () => report(anyAvailable())) : () => { };
|
|
460
|
+
let stopDial = () => { };
|
|
461
|
+
if (dial !== undefined && dialApp !== undefined) {
|
|
462
|
+
const release = dial.monitor(dialApp, sender.origin) ?? (() => undefined);
|
|
463
|
+
// before the first answer only a yes is final; after it every change counts
|
|
464
|
+
const onDial = () => {
|
|
465
|
+
const value = anyAvailable();
|
|
466
|
+
if (last !== undefined || value)
|
|
467
|
+
report(value);
|
|
468
|
+
};
|
|
469
|
+
const off = this.watchDialSinks(dial.source, onDial);
|
|
470
|
+
stopDial = () => {
|
|
471
|
+
off();
|
|
472
|
+
release();
|
|
473
|
+
};
|
|
474
|
+
if (anyAvailable())
|
|
475
|
+
report(true);
|
|
476
|
+
}
|
|
477
|
+
if (last === undefined) {
|
|
478
|
+
const ready = hasCast ? this.appDiscovery.settled(castSource) : Promise.resolve();
|
|
479
|
+
void ready.then(() => {
|
|
480
|
+
if (last === undefined)
|
|
481
|
+
report(anyAvailable());
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
return {
|
|
485
|
+
available,
|
|
486
|
+
close: () => {
|
|
487
|
+
if (closed)
|
|
488
|
+
return;
|
|
489
|
+
closed = true;
|
|
490
|
+
stopCast();
|
|
491
|
+
stopDial();
|
|
492
|
+
if (last === undefined)
|
|
493
|
+
first(false);
|
|
494
|
+
},
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* One listener on the DIAL sinks for every availability observation: a page may hold many, and a listener each would
|
|
499
|
+
* trip EventEmitter's limit of ten.
|
|
500
|
+
*/
|
|
501
|
+
watchDialSinks(source, callback) {
|
|
502
|
+
if (this.dialWatchers.size === 0)
|
|
503
|
+
source.on("deviceChanged", this.onDialSinks);
|
|
504
|
+
this.dialWatchers.add(callback);
|
|
505
|
+
return () => {
|
|
506
|
+
if (!this.dialWatchers.delete(callback))
|
|
507
|
+
return;
|
|
508
|
+
if (this.dialWatchers.size === 0)
|
|
509
|
+
source.off("deviceChanged", this.onDialSinks);
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* The sinks a request for an app is offered, as Chrome's dialog and `StartPresentation` offer the sinks of the
|
|
514
|
+
* source: those that have the app. Observes the source until `close()`, so the picker sees the list change; the
|
|
515
|
+
* first list is waited for when no answer stands yet.
|
|
516
|
+
*/
|
|
517
|
+
async appSinks(source) {
|
|
518
|
+
const events = new node_events_1.EventEmitter();
|
|
519
|
+
const devices = () => this.appDiscovery.availableSinks(source);
|
|
520
|
+
const stop = this.appDiscovery.startObserving(source, () => events.emit("deviceChanged"));
|
|
521
|
+
const sinks = {
|
|
522
|
+
devices,
|
|
523
|
+
on: (e, l) => events.on(e, l),
|
|
524
|
+
off: (e, l) => events.off(e, l),
|
|
525
|
+
};
|
|
526
|
+
const observers = (0, manager_api_ts_1.createSinksObservers)(sinks);
|
|
527
|
+
if (devices().length === 0)
|
|
528
|
+
await this.appDiscovery.settled(source);
|
|
529
|
+
return {
|
|
530
|
+
devices,
|
|
531
|
+
source: sinks,
|
|
532
|
+
observers,
|
|
533
|
+
close: () => {
|
|
534
|
+
observers.dispose();
|
|
535
|
+
stop();
|
|
536
|
+
},
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
handleInitialize(sender, params) {
|
|
540
|
+
const p = parseInitialize(params);
|
|
541
|
+
if (p === null)
|
|
542
|
+
return bad("invalid_parameter");
|
|
543
|
+
const available = this.sinkService.devices().some((d) => deviceMatches(d, p.capabilities));
|
|
544
|
+
this.senders.set(sender.id, { appId: p.appId, capabilities: p.capabilities, lastAvailable: available });
|
|
545
|
+
const joined = [];
|
|
546
|
+
for (const rec of this.sessions.values()) {
|
|
547
|
+
if (rec.appId !== p.appId || rec.origin !== sender.origin)
|
|
548
|
+
continue;
|
|
549
|
+
// tab_and_origin_scoped: this sender (the same tab) is a member, or was one before its page navigated
|
|
550
|
+
const sameTab = rec.members.has(sender.id) || rec.parked.has(sender.id);
|
|
551
|
+
if (p.autoJoinPolicy === "origin_scoped" || (p.autoJoinPolicy === "tab_and_origin_scoped" && sameTab)) {
|
|
552
|
+
rec.parked.delete(sender.id);
|
|
553
|
+
rec.members.add(sender.id);
|
|
554
|
+
this.notifySession("updated", rec);
|
|
555
|
+
joined.push(this.snapshotOf(rec));
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return good({ available, sessions: joined });
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* `requestSession`; with `presetDeviceId` (`requestSessionOnDevice`) the picker is skipped: that device is the choice
|
|
562
|
+
* (and must still be eligible). With `sink` (`requestSink`) the request may name a DIAL app as well as, or instead
|
|
563
|
+
* of, a Cast app, and the picker is offered the DIAL sinks that have it too; a DIAL choice is returned as
|
|
564
|
+
* `{ dialSink }` and nothing is launched here (the presentation handler creates the DIAL route).
|
|
565
|
+
*/
|
|
566
|
+
async handleRequestSession(sender, params, opts = {}) {
|
|
567
|
+
const presetDeviceId = opts.presetDeviceId;
|
|
568
|
+
const p = opts.sink === true ? parseRequestSink(params) : parseRequestSessionParams(params);
|
|
569
|
+
if (p === null)
|
|
570
|
+
return bad("invalid_parameter");
|
|
571
|
+
const appId = p.appId;
|
|
572
|
+
const dialApp = p.dialApp;
|
|
573
|
+
const capabilities = p.capabilities;
|
|
574
|
+
const dial = dialApp !== null ? this.options.dial : undefined;
|
|
575
|
+
const dialAvailable = () => (dial !== undefined && dialApp !== null ? dial.available(dialApp, sender.origin) : []);
|
|
576
|
+
if (this.pendingRequests.has(sender.id))
|
|
577
|
+
return bad("invalid_parameter");
|
|
578
|
+
const discard = { value: false };
|
|
579
|
+
const cancelled = { value: false };
|
|
580
|
+
const pending = { discard, cancelled };
|
|
581
|
+
this.pendingRequests.set(sender.id, pending);
|
|
582
|
+
// Chrome's dialog starts observing the sinks of the source when it opens (StartObservingMediaSinks), and the
|
|
583
|
+
// observer then waits for the answers; so the DIAL monitor starts before the first look, and a request with no sink
|
|
584
|
+
// yet waits a while for the devices' app info instead of failing on a page that never watched availability.
|
|
585
|
+
const stopMonitoring = dial !== undefined && dialApp !== null ? dial.monitor(dialApp, sender.origin) ?? undefined : undefined;
|
|
586
|
+
let appSinks;
|
|
587
|
+
let combined;
|
|
588
|
+
try {
|
|
589
|
+
// A page's presentation request is offered the sinks that have the app; chrome.cast's requestSession is unchanged
|
|
590
|
+
if (p.appAvailability && appId !== null)
|
|
591
|
+
appSinks = await this.appSinks({ appIds: [appId], capabilities });
|
|
592
|
+
if (cancelled.value || this.disposed)
|
|
593
|
+
return bad("cancel");
|
|
594
|
+
const castEligible = () => appId === null ? [] : (appSinks?.devices() ?? this.sinkService.devices()).filter((d) => deviceMatches(d, capabilities));
|
|
595
|
+
let eligible = [...castEligible(), ...dialAvailable()];
|
|
596
|
+
if (eligible.length === 0 && dial !== undefined && stopMonitoring !== undefined) {
|
|
597
|
+
await waitForDevices(dial.source, Math.min(p.timeoutMs, DIAL_PROBE_WAIT_MS), () => cancelled.value || discard.value || dialAvailable().length > 0);
|
|
598
|
+
if (cancelled.value || this.disposed)
|
|
599
|
+
return bad("cancel");
|
|
600
|
+
eligible = [...castEligible(), ...dialAvailable()];
|
|
601
|
+
}
|
|
602
|
+
if (eligible.length === 0) {
|
|
603
|
+
// Say why the devices found are not offered, when they failed to open (Chrome shows no sink and logs the error)
|
|
604
|
+
const why = this.sinkService.openErrors();
|
|
605
|
+
return bad("receiver_unavailable", why.length > 0 ? `no device could be reached: ${why.join("; ")}` : undefined);
|
|
606
|
+
}
|
|
607
|
+
const request = {
|
|
608
|
+
appId: appId ?? "",
|
|
609
|
+
capabilities,
|
|
610
|
+
origin: sender.origin,
|
|
611
|
+
senderId: sender.id,
|
|
612
|
+
};
|
|
613
|
+
const current = appId === null ? undefined : this.currentSessionFor(sender.id, appId);
|
|
614
|
+
if (current !== undefined) {
|
|
615
|
+
request.session = { sessionId: current.app.sessionId, deviceId: current.device.id };
|
|
616
|
+
}
|
|
617
|
+
let choice;
|
|
618
|
+
if (presetDeviceId !== undefined) {
|
|
619
|
+
choice = eligible.find((d) => d.id === presetDeviceId) ?? null;
|
|
620
|
+
if (choice === null)
|
|
621
|
+
return bad("receiver_unavailable");
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
// The picker gets live device updates until it answers; closing aborts its signal. With a DIAL app it watches
|
|
625
|
+
// the DIAL sinks too.
|
|
626
|
+
const castObservers = appSinks?.observers ?? this.sinks;
|
|
627
|
+
if (dial !== undefined)
|
|
628
|
+
combined = (0, manager_api_ts_1.createSinksObservers)((0, manager_api_ts_1.combineSources)(appSinks?.source ?? this.sinkService, dial.source));
|
|
629
|
+
const pick = (0, manager_api_ts_1.createPickerContext)(combined ?? castObservers, (d) => d.dial !== undefined ? dialAvailable().some((x) => x.id === d.id) : appId !== null && deviceMatches(d, capabilities));
|
|
630
|
+
pending.picker = pick;
|
|
631
|
+
try {
|
|
632
|
+
choice = await this.options.selectDevice(eligible, request, pick.context);
|
|
633
|
+
}
|
|
634
|
+
catch (err) {
|
|
635
|
+
return bad("session_error", describe(err));
|
|
636
|
+
}
|
|
637
|
+
finally {
|
|
638
|
+
pick.close();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (choice === null)
|
|
642
|
+
return bad("cancel");
|
|
643
|
+
if (choice !== "stop" && choice.dial !== undefined) {
|
|
644
|
+
// Only a device offered for this request can be chosen.
|
|
645
|
+
if (!eligible.some((d) => d.id === choice.id))
|
|
646
|
+
return bad("receiver_unavailable");
|
|
647
|
+
return good({ dialSink: choice });
|
|
648
|
+
}
|
|
649
|
+
if (appId === null)
|
|
650
|
+
return bad("invalid_parameter");
|
|
651
|
+
if (choice === "stop") {
|
|
652
|
+
const rec = request.session !== undefined ? this.sessions.get(request.session.sessionId) : undefined;
|
|
653
|
+
if (rec === undefined)
|
|
654
|
+
return bad("cancel");
|
|
655
|
+
// Like Chrome, tell the caller's receiver action listeners about the stop before the session ends.
|
|
656
|
+
this.emitTo(sender.id, { type: "receiverAction", sessionId: rec.app.sessionId, action: "stop" });
|
|
657
|
+
const stopped = await this.stopSessionRecord(rec, sender.id, true);
|
|
658
|
+
return stopped.ok ? bad("cancel") : stopped;
|
|
659
|
+
}
|
|
660
|
+
// Chrome's CastActivityManager::LaunchSession launches anew even on a sink that has a route (the receiver's status
|
|
661
|
+
// update then removes the old one), so only the page's own picker reuses the sender's session
|
|
662
|
+
if (presetDeviceId === undefined && request.session !== undefined && choice.id === request.session.deviceId) {
|
|
663
|
+
const rec = this.sessions.get(request.session.sessionId);
|
|
664
|
+
if (rec !== undefined)
|
|
665
|
+
return good(this.snapshotOf(rec));
|
|
666
|
+
}
|
|
667
|
+
// The bound starts after the picker resolves; picker time does not count.
|
|
668
|
+
let timer;
|
|
669
|
+
const bound = new Promise((_, reject) => {
|
|
670
|
+
timer = setTimeout(() => {
|
|
671
|
+
discard.value = true;
|
|
672
|
+
reject(new Discarded());
|
|
673
|
+
}, p.timeoutMs);
|
|
674
|
+
});
|
|
675
|
+
try {
|
|
676
|
+
const snapshot = await Promise.race([this.openSession(choice, appId, sender, discard, cancelled), bound]);
|
|
677
|
+
return good(snapshot);
|
|
678
|
+
}
|
|
679
|
+
catch (err) {
|
|
680
|
+
if (err instanceof Discarded)
|
|
681
|
+
return bad("timeout", "timed out");
|
|
682
|
+
if (err instanceof MappedError)
|
|
683
|
+
return bad(err.code, err.message);
|
|
684
|
+
throw err;
|
|
685
|
+
}
|
|
686
|
+
finally {
|
|
687
|
+
if (timer !== undefined)
|
|
688
|
+
clearTimeout(timer);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
finally {
|
|
692
|
+
combined?.dispose();
|
|
693
|
+
appSinks?.close();
|
|
694
|
+
stopMonitoring?.();
|
|
695
|
+
this.pendingRequests.delete(sender.id);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* `checkOrigin` is joinSession's own rule (mode "chromecast", which is frozen and has no
|
|
700
|
+
* Chromium counterpart). Joining by id, as Chrome's Presentation API path does, has none: AppActivity::CanJoinSession checks only
|
|
701
|
+
* the app and that the client is not connected yet.
|
|
702
|
+
*/
|
|
703
|
+
handleJoinSession(sender, params, checkOrigin) {
|
|
704
|
+
const p = parseSessionId(params);
|
|
705
|
+
if (p === null)
|
|
706
|
+
return bad("invalid_parameter");
|
|
707
|
+
const rec = this.sessions.get(p.sessionId);
|
|
708
|
+
if (rec === undefined || (checkOrigin && rec.origin !== sender.origin))
|
|
709
|
+
return bad("session_error");
|
|
710
|
+
rec.parked.delete(sender.id);
|
|
711
|
+
rec.members.add(sender.id);
|
|
712
|
+
this.notifySession("updated", rec);
|
|
713
|
+
return good(this.snapshotOf(rec));
|
|
714
|
+
}
|
|
715
|
+
handleSendMessage(sender, params) {
|
|
716
|
+
const p = parseSendMessage(params);
|
|
717
|
+
if (p === null)
|
|
718
|
+
return bad("invalid_parameter");
|
|
719
|
+
const rec = this.sessions.get(p.sessionId);
|
|
720
|
+
if (rec === undefined || !rec.members.has(sender.id))
|
|
721
|
+
return bad("session_error");
|
|
722
|
+
try {
|
|
723
|
+
rec.client.send(p.namespace, rec.app.transportId, p.message);
|
|
724
|
+
}
|
|
725
|
+
catch (err) {
|
|
726
|
+
return bad("channel_error", describe(err));
|
|
727
|
+
}
|
|
728
|
+
return good(undefined);
|
|
729
|
+
}
|
|
730
|
+
async handleStopSession(sender, params) {
|
|
731
|
+
const p = parseSessionId(params);
|
|
732
|
+
if (p === null)
|
|
733
|
+
return bad("invalid_parameter");
|
|
734
|
+
const rec = this.sessions.get(p.sessionId);
|
|
735
|
+
if (rec === undefined || !rec.members.has(sender.id))
|
|
736
|
+
return bad("session_error");
|
|
737
|
+
return this.stopSessionRecord(rec, sender.id, false);
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Stop a session on the device and tear it down. `stoppingBy` keeps an echoed
|
|
741
|
+
* receiverStatus from notifying the caller; the other members learn from that echo
|
|
742
|
+
* or from the sessionEnded emitted here. When `tellCaller` is set (a picker "stop"),
|
|
743
|
+
* the caller gets sessionEnded too, because it did not call stop itself.
|
|
744
|
+
*/
|
|
745
|
+
async stopSessionRecord(rec, caller, tellCaller) {
|
|
746
|
+
rec.stoppingBy = caller;
|
|
747
|
+
try {
|
|
748
|
+
this.tracker.applyStatus(rec.device.id, rec.client, await rec.client.stop(rec.app.sessionId));
|
|
749
|
+
}
|
|
750
|
+
catch (err) {
|
|
751
|
+
rec.stoppingBy = undefined;
|
|
752
|
+
return bad("session_error", describe(err));
|
|
753
|
+
}
|
|
754
|
+
// An echoed receiverStatus may have already ended the session (and notified the others).
|
|
755
|
+
const current = this.sessions.get(rec.app.sessionId);
|
|
756
|
+
if (current !== undefined) {
|
|
757
|
+
this.sessions.delete(rec.app.sessionId);
|
|
758
|
+
for (const member of current.members) {
|
|
759
|
+
if (!tellCaller && member === caller)
|
|
760
|
+
continue;
|
|
761
|
+
this.emitTo(member, { type: "sessionEnded", sessionId: rec.app.sessionId, status: "stopped" });
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
else if (tellCaller) {
|
|
765
|
+
this.emitTo(caller, { type: "sessionEnded", sessionId: rec.app.sessionId, status: "stopped" });
|
|
766
|
+
}
|
|
767
|
+
return good(undefined);
|
|
768
|
+
}
|
|
769
|
+
/** The sender's current session for the app, if it has one (the first one found). */
|
|
770
|
+
currentSessionFor(senderId, appId) {
|
|
771
|
+
for (const rec of this.sessions.values()) {
|
|
772
|
+
if (rec.appId === appId && rec.members.has(senderId))
|
|
773
|
+
return rec;
|
|
774
|
+
}
|
|
775
|
+
return undefined;
|
|
776
|
+
}
|
|
777
|
+
handleLeaveSession(sender, params) {
|
|
778
|
+
const p = parseSessionId(params);
|
|
779
|
+
if (p === null)
|
|
780
|
+
return bad("invalid_parameter");
|
|
781
|
+
const rec = this.sessions.get(p.sessionId);
|
|
782
|
+
if (rec === undefined || !rec.members.has(sender.id))
|
|
783
|
+
return bad("session_error");
|
|
784
|
+
this.leave(rec, sender.id);
|
|
785
|
+
return good(undefined);
|
|
786
|
+
}
|
|
787
|
+
async handleSetVolume(sender, params) {
|
|
788
|
+
const p = parseSetVolume(params);
|
|
789
|
+
if (p === null)
|
|
790
|
+
return bad("invalid_parameter");
|
|
791
|
+
const rec = this.sessions.get(p.sessionId);
|
|
792
|
+
if (rec === undefined || !rec.members.has(sender.id))
|
|
793
|
+
return bad("session_error");
|
|
794
|
+
try {
|
|
795
|
+
this.tracker.applyStatus(rec.device.id, rec.client, await rec.client.setVolume({ level: p.level }));
|
|
796
|
+
}
|
|
797
|
+
catch (err) {
|
|
798
|
+
return bad("session_error", describe(err));
|
|
799
|
+
}
|
|
800
|
+
return good(undefined);
|
|
801
|
+
}
|
|
802
|
+
async handleSetMuted(sender, params) {
|
|
803
|
+
const p = parseSetMuted(params);
|
|
804
|
+
if (p === null)
|
|
805
|
+
return bad("invalid_parameter");
|
|
806
|
+
const rec = this.sessions.get(p.sessionId);
|
|
807
|
+
if (rec === undefined || !rec.members.has(sender.id))
|
|
808
|
+
return bad("session_error");
|
|
809
|
+
try {
|
|
810
|
+
this.tracker.applyStatus(rec.device.id, rec.client, await rec.client.setVolume({ muted: p.muted }));
|
|
811
|
+
}
|
|
812
|
+
catch (err) {
|
|
813
|
+
return bad("session_error", describe(err));
|
|
814
|
+
}
|
|
815
|
+
return good(undefined);
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Join a session by its id, as Chrome's Media Router does for `reconnect("cast-session_<id>")`. A session this
|
|
819
|
+
* service already holds is joined without an origin check, like one found on a device. Otherwise the id is looked up
|
|
820
|
+
* in the session tracker, which knows what every device with an open channel runs: Chrome's CastActivityManager adds
|
|
821
|
+
* a non-local activity for each session its CastSessionTracker learns (AddNonLocalActivity) and
|
|
822
|
+
* FindActivityForSessionJoin finds it by id alone; auto-join skips it and no origin is checked. `appId`, when given,
|
|
823
|
+
* must be the session's app (AppActivity::CanJoinSession). Joining makes the route local, as in Chrome.
|
|
824
|
+
*/
|
|
825
|
+
async handleJoinRunningSession(sender, params) {
|
|
826
|
+
const p = parseSessionId(params);
|
|
827
|
+
if (p === null)
|
|
828
|
+
return bad("invalid_parameter");
|
|
829
|
+
const appId = isRecord(params) && typeof params.appId === "string" ? params.appId : undefined;
|
|
830
|
+
const known = this.sessions.get(p.sessionId);
|
|
831
|
+
if (known !== undefined) {
|
|
832
|
+
if (appId !== undefined && known.appId !== appId)
|
|
833
|
+
return bad("session_error");
|
|
834
|
+
return this.handleJoinSession(sender, params, false);
|
|
835
|
+
}
|
|
836
|
+
const tracked = this.tracker.sessionById(p.sessionId);
|
|
837
|
+
if (tracked === undefined || this.disposed || (appId !== undefined && tracked.appId !== appId))
|
|
838
|
+
return bad("session_error");
|
|
839
|
+
const client = this.sinkService.clientOf(tracked.sinkId);
|
|
840
|
+
const device = this.sinkService.sinkOf(tracked.sinkId);
|
|
841
|
+
if (client === undefined || device === undefined)
|
|
842
|
+
return bad("session_error");
|
|
843
|
+
client.connectTransport(tracked.app.transportId);
|
|
844
|
+
const rec = {
|
|
845
|
+
device,
|
|
846
|
+
client,
|
|
847
|
+
app: tracked.app,
|
|
848
|
+
origin: sender.origin,
|
|
849
|
+
appId: tracked.appId,
|
|
850
|
+
members: new Set([sender.id]),
|
|
851
|
+
parked: new Set(),
|
|
852
|
+
lastVolume: tracked.volume,
|
|
853
|
+
lastSnapshot: null,
|
|
854
|
+
};
|
|
855
|
+
rec.lastSnapshot = this.snapshotOf(rec);
|
|
856
|
+
this.sessions.set(tracked.sessionId, rec);
|
|
857
|
+
return good(rec.lastSnapshot);
|
|
858
|
+
}
|
|
859
|
+
/** Launch the app on the device's open channel and register the session. */
|
|
860
|
+
async openSession(device, appId, sender, discard, cancelled) {
|
|
861
|
+
// A DIAL sink has no Cast port: it is launched by the presentation handler's DIAL route, never as a Cast session.
|
|
862
|
+
if (device.dial !== undefined)
|
|
863
|
+
throw new MappedError("session_error", "A DIAL device cannot host a Cast session");
|
|
864
|
+
// Casting needs a channel that is open now; a device that is not a sink (or whose channel dropped) is unavailable.
|
|
865
|
+
const client = this.sinkService.clientOf(device.id);
|
|
866
|
+
if (client === undefined)
|
|
867
|
+
throw new MappedError("receiver_unavailable", "no open channel to the device");
|
|
868
|
+
if (discard.value)
|
|
869
|
+
throw new Discarded();
|
|
870
|
+
if (cancelled.value)
|
|
871
|
+
throw new MappedError("cancel", "cancelled");
|
|
872
|
+
this.launching.set(device.id, (this.launching.get(device.id) ?? 0) + 1);
|
|
873
|
+
try {
|
|
874
|
+
return await this.launchOn(device, client, appId, sender, discard, cancelled);
|
|
875
|
+
}
|
|
876
|
+
finally {
|
|
877
|
+
const left = (this.launching.get(device.id) ?? 1) - 1;
|
|
878
|
+
if (left > 0)
|
|
879
|
+
this.launching.set(device.id, left);
|
|
880
|
+
else
|
|
881
|
+
this.launching.delete(device.id);
|
|
882
|
+
// A launch that ended without a session leaves the device's own session listed again
|
|
883
|
+
if (left === 0)
|
|
884
|
+
this.onTrackerChanged();
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
async launchOn(device, client, appId, sender, discard, cancelled) {
|
|
888
|
+
let app;
|
|
889
|
+
try {
|
|
890
|
+
app = await client.launch(appId);
|
|
891
|
+
}
|
|
892
|
+
catch (err) {
|
|
893
|
+
if (err instanceof index_ts_1.CastTimeoutError)
|
|
894
|
+
throw new MappedError("timeout", err.message);
|
|
895
|
+
throw new MappedError("session_error", describe(err));
|
|
896
|
+
}
|
|
897
|
+
if (discard.value) {
|
|
898
|
+
client.closeTransport(app.transportId);
|
|
899
|
+
throw new Discarded();
|
|
900
|
+
}
|
|
901
|
+
if (cancelled.value) {
|
|
902
|
+
client.closeTransport(app.transportId);
|
|
903
|
+
throw new MappedError("cancel", "cancelled");
|
|
904
|
+
}
|
|
905
|
+
client.connectTransport(app.transportId);
|
|
906
|
+
let status;
|
|
907
|
+
try {
|
|
908
|
+
status = await client.getStatus();
|
|
909
|
+
this.tracker.applyStatus(device.id, client, status);
|
|
910
|
+
}
|
|
911
|
+
catch (err) {
|
|
912
|
+
client.closeTransport(app.transportId);
|
|
913
|
+
throw new MappedError("session_error", describe(err));
|
|
914
|
+
}
|
|
915
|
+
if (discard.value) {
|
|
916
|
+
client.closeTransport(app.transportId);
|
|
917
|
+
throw new Discarded();
|
|
918
|
+
}
|
|
919
|
+
if (cancelled.value) {
|
|
920
|
+
client.closeTransport(app.transportId);
|
|
921
|
+
throw new MappedError("cancel", "cancelled");
|
|
922
|
+
}
|
|
923
|
+
const rec = {
|
|
924
|
+
device,
|
|
925
|
+
client,
|
|
926
|
+
app,
|
|
927
|
+
origin: sender.origin,
|
|
928
|
+
appId,
|
|
929
|
+
launchedBy: sender.id,
|
|
930
|
+
members: new Set([sender.id]),
|
|
931
|
+
parked: new Set(),
|
|
932
|
+
lastVolume: status.volume,
|
|
933
|
+
lastSnapshot: null,
|
|
934
|
+
};
|
|
935
|
+
const snapshot = this.snapshotOf(rec);
|
|
936
|
+
rec.lastSnapshot = snapshot;
|
|
937
|
+
this.sessions.set(app.sessionId, rec);
|
|
938
|
+
try {
|
|
939
|
+
this.options.onSessionLaunched?.(sender.id);
|
|
940
|
+
}
|
|
941
|
+
catch (err) {
|
|
942
|
+
console.error("electron-cast: onSessionLaunched failed", err);
|
|
943
|
+
}
|
|
944
|
+
return snapshot;
|
|
945
|
+
}
|
|
946
|
+
/** Remove a sender from a session; when it was the last one, tear the session down. */
|
|
947
|
+
leave(rec, senderId) {
|
|
948
|
+
rec.members.delete(senderId);
|
|
949
|
+
rec.parked.delete(senderId);
|
|
950
|
+
if (rec.members.size === 0 && rec.parked.size === 0) {
|
|
951
|
+
rec.client.closeTransport(rec.app.transportId);
|
|
952
|
+
this.sessions.delete(rec.app.sessionId);
|
|
953
|
+
}
|
|
954
|
+
else {
|
|
955
|
+
this.notifySession("updated", rec);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
/** Subscribe to a freshly opened channel's events. */
|
|
959
|
+
bindClient(client, _device) {
|
|
960
|
+
client.on("message", (msg) => this.onClientMessage(client, msg));
|
|
961
|
+
client.on("receiverStatus", (status) => this.onClientStatus(client, status));
|
|
962
|
+
client.on("transportClosed", (transportId) => this.onTransportClosed(client, transportId));
|
|
963
|
+
client.on("close", () => this.onClientClose(client));
|
|
964
|
+
}
|
|
965
|
+
onClientMessage(client, msg) {
|
|
966
|
+
if (typeof msg.data !== "string")
|
|
967
|
+
return;
|
|
968
|
+
for (const rec of this.sessions.values()) {
|
|
969
|
+
if (rec.client !== client || rec.app.transportId !== msg.sourceId)
|
|
970
|
+
continue;
|
|
971
|
+
for (const member of rec.members) {
|
|
972
|
+
this.emitTo(member, {
|
|
973
|
+
type: "message",
|
|
974
|
+
sessionId: rec.app.sessionId,
|
|
975
|
+
namespace: msg.namespace,
|
|
976
|
+
message: msg.data,
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
onClientStatus(client, status) {
|
|
982
|
+
for (const rec of [...this.sessions.values()]) {
|
|
983
|
+
if (rec.client !== client)
|
|
984
|
+
continue;
|
|
985
|
+
const app = status.applications.find((a) => a.sessionId === rec.app.sessionId);
|
|
986
|
+
if (app === undefined) {
|
|
987
|
+
this.sessions.delete(rec.app.sessionId);
|
|
988
|
+
for (const member of rec.members) {
|
|
989
|
+
if (rec.stoppingBy !== undefined && member === rec.stoppingBy)
|
|
990
|
+
continue;
|
|
991
|
+
this.emitTo(member, { type: "sessionEnded", sessionId: rec.app.sessionId, status: "stopped" });
|
|
992
|
+
}
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
rec.app = app;
|
|
996
|
+
rec.lastVolume = status.volume;
|
|
997
|
+
const snapshot = this.snapshotOf(rec);
|
|
998
|
+
if (!sameValue(snapshot, rec.lastSnapshot)) {
|
|
999
|
+
rec.lastSnapshot = snapshot;
|
|
1000
|
+
this.notifySession("updated", rec);
|
|
1001
|
+
for (const member of rec.members) {
|
|
1002
|
+
this.emitTo(member, { type: "sessionUpdated", session: snapshot });
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
onTransportClosed(client, transportId) {
|
|
1008
|
+
for (const rec of [...this.sessions.values()]) {
|
|
1009
|
+
if (rec.client !== client || rec.app.transportId !== transportId)
|
|
1010
|
+
continue;
|
|
1011
|
+
this.sessions.delete(rec.app.sessionId);
|
|
1012
|
+
for (const member of rec.members) {
|
|
1013
|
+
this.emitTo(member, { type: "sessionEnded", sessionId: rec.app.sessionId, status: "disconnected" });
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
onClientClose(client) {
|
|
1018
|
+
for (const rec of [...this.sessions.values()]) {
|
|
1019
|
+
if (rec.client !== client)
|
|
1020
|
+
continue;
|
|
1021
|
+
this.sessions.delete(rec.app.sessionId);
|
|
1022
|
+
for (const member of rec.members) {
|
|
1023
|
+
this.emitTo(member, { type: "sessionEnded", sessionId: rec.app.sessionId, status: "disconnected" });
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
/** Re-check availability for every initialized sender; emit only on change. */
|
|
1028
|
+
onDevicesChanged() {
|
|
1029
|
+
if (this.disposed)
|
|
1030
|
+
return;
|
|
1031
|
+
const devices = this.sinkService.devices();
|
|
1032
|
+
for (const [id, rec] of this.senders) {
|
|
1033
|
+
const available = devices.some((d) => deviceMatches(d, rec.capabilities));
|
|
1034
|
+
if (available !== rec.lastAvailable) {
|
|
1035
|
+
rec.lastAvailable = available;
|
|
1036
|
+
this.emitTo(id, { type: "receiverAvailability", available });
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
// Main-process API (see manager-api.ts). Control goes through the paths the pages use, so pages see the same events.
|
|
1041
|
+
/** The sessions `senderId` launched and that still run (`routes_by_frame_` lookup by frame). */
|
|
1042
|
+
sessionsLaunchedBy(senderId) {
|
|
1043
|
+
return [...this.sessions.values()].filter((rec) => rec.launchedBy === senderId).map((rec) => rec.app.sessionId);
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Every live session, parked ones included, then the sessions the devices run that this service does not hold
|
|
1047
|
+
* (started elsewhere, or let go of here), as Chrome's non-local routes.
|
|
1048
|
+
*/
|
|
1049
|
+
mediaRoutes() {
|
|
1050
|
+
const local = [...this.sessions.values()].map((rec) => this.routeOf(rec));
|
|
1051
|
+
return [...local, ...this.nonLocalSessions().map((s) => this.nonLocalRouteOf(s))];
|
|
1052
|
+
}
|
|
1053
|
+
/** The tracked sessions no page of this service holds (Chrome: activities with `is_local` false). */
|
|
1054
|
+
nonLocalSessions() {
|
|
1055
|
+
return this.tracker.sessions().filter((s) => !this.sessions.has(s.sessionId) && !this.launching.has(s.sinkId)
|
|
1056
|
+
&& this.options.ownsSession?.(s.sessionId, s.sinkId) !== true);
|
|
1057
|
+
}
|
|
1058
|
+
/** Be told when a session starts, changes (status, volume, pages) or ends; returns the unsubscribe function. */
|
|
1059
|
+
observeSessions(listener) {
|
|
1060
|
+
this.sessionListeners.add(listener);
|
|
1061
|
+
return () => void this.sessionListeners.delete(listener);
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Stop a session on the device for every page, as if a member had called stopSession. A session this service does not
|
|
1065
|
+
* hold is stopped on its device as it is (Chrome's TerminateSession works on non-local activities too).
|
|
1066
|
+
*/
|
|
1067
|
+
async terminateSession(sessionId) {
|
|
1068
|
+
const rec = this.sessions.get(sessionId);
|
|
1069
|
+
// No page is the caller, so every member is told sessionEnded.
|
|
1070
|
+
if (rec !== undefined)
|
|
1071
|
+
return this.stopSessionRecord(rec, MAIN_CALLER, false);
|
|
1072
|
+
const tracked = this.nonLocalSessions().find((s) => s.sessionId === sessionId);
|
|
1073
|
+
if (tracked === undefined)
|
|
1074
|
+
return bad("session_error", "unknown session");
|
|
1075
|
+
// With no open channel the stop cannot be sent: Chrome's `CastMessageHandler::StopSession` finds no socket and
|
|
1076
|
+
// reports a failure, which `HandleStopSessionResponse` turns into this message while the route stays.
|
|
1077
|
+
const client = this.sinkService.clientOf(tracked.sinkId);
|
|
1078
|
+
if (client === undefined)
|
|
1079
|
+
return bad("session_error", "StopSession response is not OK. Failed to terminate route.");
|
|
1080
|
+
try {
|
|
1081
|
+
this.tracker.applyStatus(tracked.sinkId, client, await client.stop(sessionId));
|
|
1082
|
+
}
|
|
1083
|
+
catch (err) {
|
|
1084
|
+
return bad("session_error", describe(err));
|
|
1085
|
+
}
|
|
1086
|
+
return good(undefined);
|
|
1087
|
+
}
|
|
1088
|
+
async setSessionVolume(sessionId, volume) {
|
|
1089
|
+
const rec = this.sessions.get(sessionId);
|
|
1090
|
+
const tracked = rec === undefined ? this.nonLocalSessions().find((s) => s.sessionId === sessionId) : undefined;
|
|
1091
|
+
const client = rec?.client ?? (tracked === undefined ? undefined : this.sinkService.clientOf(tracked.sinkId));
|
|
1092
|
+
const sinkId = rec?.device.id ?? tracked?.sinkId;
|
|
1093
|
+
if (client === undefined || sinkId === undefined)
|
|
1094
|
+
return bad("session_error", "unknown session");
|
|
1095
|
+
try {
|
|
1096
|
+
this.tracker.applyStatus(sinkId, client, await client.setVolume(volume));
|
|
1097
|
+
}
|
|
1098
|
+
catch (err) {
|
|
1099
|
+
return bad("session_error", describe(err));
|
|
1100
|
+
}
|
|
1101
|
+
return good(undefined);
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Every receiver status that describes a session, changed or not, with its volume (the tracker's
|
|
1105
|
+
* `OnSessionAddedOrUpdated`); for the media controller. Returns the unsubscribe function.
|
|
1106
|
+
*/
|
|
1107
|
+
observeSessionStatus(listener) {
|
|
1108
|
+
const on = (s) => listener(s.sessionId, s.volume);
|
|
1109
|
+
this.tracker.on("sessionStatus", on);
|
|
1110
|
+
return () => void this.tracker.off("sessionStatus", on);
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Every MEDIA_STATUS on a device's channel, credited to the session the device runs and merged with the media saved
|
|
1114
|
+
* before (`CastSessionTracker::HandleMediaStatusMessage`); for the media controller. Returns the unsubscribe function.
|
|
1115
|
+
*/
|
|
1116
|
+
observeMediaStatus(listener) {
|
|
1117
|
+
const on = (s, message) => listener(s.sessionId, message);
|
|
1118
|
+
this.tracker.on("mediaStatus", on);
|
|
1119
|
+
return () => void this.tracker.off("mediaStatus", on);
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Send a message to a session's receiver app from main, with no page involved, over the device's channel. A session
|
|
1123
|
+
* this service does not hold is reached too, as Chrome's `CastMessageHandler::SendMediaRequest` reaches a non-local
|
|
1124
|
+
* activity's session: a virtual connection to its transport is opened first (`SendCastMessageToSocket` -> `DoEnsureConnection`).
|
|
1125
|
+
*/
|
|
1126
|
+
sendSessionMessage(sessionId, namespace, message) {
|
|
1127
|
+
const rec = this.sessions.get(sessionId);
|
|
1128
|
+
let client = rec?.client;
|
|
1129
|
+
let transportId = rec?.app.transportId;
|
|
1130
|
+
if (rec === undefined) {
|
|
1131
|
+
const tracked = this.nonLocalSessions().find((s) => s.sessionId === sessionId);
|
|
1132
|
+
if (tracked === undefined)
|
|
1133
|
+
return bad("session_error", "unknown session");
|
|
1134
|
+
client = this.sinkService.clientOf(tracked.sinkId);
|
|
1135
|
+
transportId = tracked.transportId;
|
|
1136
|
+
if (client === undefined)
|
|
1137
|
+
return bad("channel_error", "no open channel to the device");
|
|
1138
|
+
}
|
|
1139
|
+
if (client === undefined || transportId === undefined)
|
|
1140
|
+
return bad("session_error", "unknown session");
|
|
1141
|
+
try {
|
|
1142
|
+
if (rec === undefined)
|
|
1143
|
+
client.connectTransport(transportId);
|
|
1144
|
+
client.send(namespace, transportId, message);
|
|
1145
|
+
}
|
|
1146
|
+
catch (err) {
|
|
1147
|
+
return bad("channel_error", describe(err));
|
|
1148
|
+
}
|
|
1149
|
+
return good(undefined);
|
|
1150
|
+
}
|
|
1151
|
+
/** The volume the receiver last reported for a session, local or not (Chrome: `receiver.volume` of the CastSession). */
|
|
1152
|
+
sessionVolume(sessionId) {
|
|
1153
|
+
return this.sessions.get(sessionId)?.lastVolume ?? this.tracker.sessionById(sessionId)?.volume;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Detach every page from the session and close its transport; the receiver app keeps running (and is then listed as a
|
|
1157
|
+
* non-local route). A route no page holds has nothing to detach.
|
|
1158
|
+
*/
|
|
1159
|
+
detachSession(sessionId) {
|
|
1160
|
+
const rec = this.sessions.get(sessionId);
|
|
1161
|
+
if (rec === undefined) {
|
|
1162
|
+
return this.nonLocalSessions().some((s) => s.sessionId === sessionId) ? good(undefined) : bad("session_error", "unknown session");
|
|
1163
|
+
}
|
|
1164
|
+
for (const member of rec.members) {
|
|
1165
|
+
this.emitTo(member, { type: "sessionEnded", sessionId, status: "disconnected" });
|
|
1166
|
+
}
|
|
1167
|
+
rec.members.clear();
|
|
1168
|
+
rec.parked.clear();
|
|
1169
|
+
rec.client.closeTransport(rec.app.transportId);
|
|
1170
|
+
this.sessions.delete(sessionId);
|
|
1171
|
+
return good(undefined);
|
|
1172
|
+
}
|
|
1173
|
+
/** Tell the route observers something changed (the arguments only fit the ObservedMap callback). */
|
|
1174
|
+
notifySession(_kind, _rec) {
|
|
1175
|
+
if (this.disposed)
|
|
1176
|
+
return;
|
|
1177
|
+
if (_kind === "ended")
|
|
1178
|
+
this.sinkService.releaseUnused();
|
|
1179
|
+
this.lastRoutesKey = JSON.stringify(this.mediaRoutes());
|
|
1180
|
+
this.fireSessionListeners();
|
|
1181
|
+
}
|
|
1182
|
+
/** The tracker learned something; route observers hear of it only if the routes they see differ now. */
|
|
1183
|
+
onTrackerChanged() {
|
|
1184
|
+
if (this.disposed)
|
|
1185
|
+
return;
|
|
1186
|
+
const key = JSON.stringify(this.mediaRoutes());
|
|
1187
|
+
if (key === this.lastRoutesKey)
|
|
1188
|
+
return;
|
|
1189
|
+
this.lastRoutesKey = key;
|
|
1190
|
+
this.fireSessionListeners();
|
|
1191
|
+
}
|
|
1192
|
+
fireSessionListeners() {
|
|
1193
|
+
for (const listener of [...this.sessionListeners]) {
|
|
1194
|
+
try {
|
|
1195
|
+
listener();
|
|
1196
|
+
}
|
|
1197
|
+
catch (err) {
|
|
1198
|
+
console.error("electron-cast: a session listener failed", err);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
routeOf(rec) {
|
|
1203
|
+
return {
|
|
1204
|
+
id: rec.app.sessionId,
|
|
1205
|
+
providerId: "cast",
|
|
1206
|
+
mediaSource: `cast:${rec.appId}`,
|
|
1207
|
+
sinkId: rec.device.id,
|
|
1208
|
+
sinkName: rec.device.name,
|
|
1209
|
+
description: rec.app.statusText || rec.app.displayName,
|
|
1210
|
+
isLocal: true,
|
|
1211
|
+
appId: rec.appId,
|
|
1212
|
+
displayName: rec.app.displayName,
|
|
1213
|
+
origin: rec.origin,
|
|
1214
|
+
volume: { level: rec.lastVolume.level ?? null, muted: rec.lastVolume.muted ?? null },
|
|
1215
|
+
members: [...rec.members],
|
|
1216
|
+
parkedSenders: [...rec.parked],
|
|
1217
|
+
parked: rec.members.size === 0,
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
/** Chrome's `AddNonLocalActivity`: the route has no page, and its description is the session's (`GetRouteDescription`). */
|
|
1221
|
+
nonLocalRouteOf(session) {
|
|
1222
|
+
return {
|
|
1223
|
+
id: session.sessionId,
|
|
1224
|
+
providerId: "cast",
|
|
1225
|
+
mediaSource: `cast:${session.appId}`,
|
|
1226
|
+
sinkId: session.sinkId,
|
|
1227
|
+
sinkName: this.sinkService.sinkOf(session.sinkId)?.name ?? "",
|
|
1228
|
+
description: session.statusText || session.displayName,
|
|
1229
|
+
isLocal: false,
|
|
1230
|
+
appId: session.appId,
|
|
1231
|
+
displayName: session.displayName,
|
|
1232
|
+
origin: "",
|
|
1233
|
+
volume: { level: session.volume.level ?? null, muted: session.volume.muted ?? null },
|
|
1234
|
+
members: [],
|
|
1235
|
+
parkedSenders: [],
|
|
1236
|
+
parked: false,
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
snapshotOf(rec) {
|
|
1240
|
+
const app = rec.app;
|
|
1241
|
+
const volume = {
|
|
1242
|
+
level: rec.lastVolume.level ?? null,
|
|
1243
|
+
muted: rec.lastVolume.muted ?? null,
|
|
1244
|
+
};
|
|
1245
|
+
if (rec.lastVolume.controlType !== undefined)
|
|
1246
|
+
volume.controlType = rec.lastVolume.controlType;
|
|
1247
|
+
if (rec.lastVolume.stepInterval !== undefined)
|
|
1248
|
+
volume.stepInterval = rec.lastVolume.stepInterval;
|
|
1249
|
+
return {
|
|
1250
|
+
sessionId: app.sessionId,
|
|
1251
|
+
appId: app.appId,
|
|
1252
|
+
displayName: app.displayName,
|
|
1253
|
+
appImages: app.iconUrl ? [{ url: app.iconUrl }] : [],
|
|
1254
|
+
statusText: app.statusText ?? null,
|
|
1255
|
+
namespaces: app.namespaces,
|
|
1256
|
+
transportId: app.transportId,
|
|
1257
|
+
receiver: {
|
|
1258
|
+
label: rec.device.id,
|
|
1259
|
+
friendlyName: rec.device.name,
|
|
1260
|
+
capabilities: capabilityNames(rec.device.capabilities),
|
|
1261
|
+
volume,
|
|
1262
|
+
isActiveInput: null,
|
|
1263
|
+
},
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
emitTo(senderId, event) {
|
|
1267
|
+
if (this.disposed)
|
|
1268
|
+
return;
|
|
1269
|
+
this.options.emit(senderId, event);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
exports.CastSessionService = CastSessionService;
|
|
1273
|
+
//# sourceMappingURL=session-service.js.map
|