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,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mirroring engine as an Electron `utilityProcess` entry: one process per mirroring route, so pacing, RTCP and
|
|
3
|
+
* encryption never wait for the main process (and a stuck page cannot stall a stream). Its parent is the main
|
|
4
|
+
* process, which relays Cast messages; the capture agent in the hidden window is reached over a port it was handed.
|
|
5
|
+
*
|
|
6
|
+
* main --{start, ports:[agent]}--> engine --{send, observer}--> main
|
|
7
|
+
* main --{message}--> engine
|
|
8
|
+
*/
|
|
9
|
+
import { createEncodingSupport } from "../encoding-support.ts";
|
|
10
|
+
import { createMirroringServiceFactory } from "../engine.ts";
|
|
11
|
+
import type { MirroringService } from "../mirroring-activity.ts";
|
|
12
|
+
import type { SessionParameters } from "../session-host.ts";
|
|
13
|
+
import type { MirroringStats } from "../stats/statistics.ts";
|
|
14
|
+
import type { VideoCodec } from "../protocol/constants.ts";
|
|
15
|
+
import type { AgentPort, AgentToEngine, CaptureSource, EngineToAgent } from "./agent-protocol.ts";
|
|
16
|
+
import { PortBackend } from "./port-backend.ts";
|
|
17
|
+
|
|
18
|
+
/** Main to engine. */
|
|
19
|
+
export type ToEngine =
|
|
20
|
+
| {
|
|
21
|
+
type: "start";
|
|
22
|
+
params: SessionParameters;
|
|
23
|
+
source: CaptureSource;
|
|
24
|
+
/** What `VideoEncoder.isConfigSupported` found: `prefer-hardware` and `prefer-software` respectively. */
|
|
25
|
+
hardwareCodecs: VideoCodec[];
|
|
26
|
+
softwareCodecs: VideoCodec[];
|
|
27
|
+
/** Codecs whose hardware encoder failed earlier in the app's run (`GetHardwareCodecDenyList`). */
|
|
28
|
+
hardwareDenyList: VideoCodec[];
|
|
29
|
+
/** Chrome's codec switches and features as the app's command line sets them. */
|
|
30
|
+
encodingPolicy: { hardwareFeatures: VideoCodec[]; softwareFeatures: VideoCodec[]; forceEnable: VideoCodec[]; forceDisable: VideoCodec[] };
|
|
31
|
+
env?: Record<string, string | undefined>;
|
|
32
|
+
}
|
|
33
|
+
| { type: "message"; namespace: string; json: string }
|
|
34
|
+
/** `SwitchMirroringSourceTab`: `source` is the new tab's capture id. */
|
|
35
|
+
| { type: "switch-source"; webContentsId: number; source: CaptureSource }
|
|
36
|
+
/** `CastMirroringServiceHost::Pause` / `Resume`. */
|
|
37
|
+
| { type: "pause" }
|
|
38
|
+
| { type: "resume" }
|
|
39
|
+
| { type: "get-stats"; id: number }
|
|
40
|
+
| { type: "stop" };
|
|
41
|
+
|
|
42
|
+
/** Engine to main. */
|
|
43
|
+
export type FromEngine =
|
|
44
|
+
| { type: "send"; namespace: string; json: string }
|
|
45
|
+
| { type: "did-start" }
|
|
46
|
+
| { type: "did-stop" }
|
|
47
|
+
| { type: "error"; error: string; message: string }
|
|
48
|
+
| { type: "log"; message: string }
|
|
49
|
+
| { type: "stats"; id: number; stats: MirroringStats | undefined }
|
|
50
|
+
/** A hardware encoder failed and the codec is no longer offered in hardware: the main process keeps the list. */
|
|
51
|
+
| { type: "deny-hardware-codec"; codec: VideoCodec };
|
|
52
|
+
|
|
53
|
+
/** The slice of `process.parentPort` and of a `MessagePortMain` this file uses. */
|
|
54
|
+
export interface ParentPortLike {
|
|
55
|
+
postMessage(message: FromEngine): void;
|
|
56
|
+
on(event: "message", listener: (event: { data: ToEngine; ports: MessagePortLike[] }) => void): unknown;
|
|
57
|
+
}
|
|
58
|
+
export interface MessagePortLike {
|
|
59
|
+
postMessage(message: unknown, transfer?: unknown[]): void;
|
|
60
|
+
on(event: "message", listener: (event: { data: unknown }) => void): unknown;
|
|
61
|
+
start(): void;
|
|
62
|
+
close(): void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function agentPortFrom(port: MessagePortLike): AgentPort {
|
|
66
|
+
return {
|
|
67
|
+
postMessage: (message: EngineToAgent) => port.postMessage(message),
|
|
68
|
+
onMessage: (listener) => {
|
|
69
|
+
port.on("message", (e) => listener(e.data as AgentToEngine));
|
|
70
|
+
port.start();
|
|
71
|
+
},
|
|
72
|
+
close: () => port.close(),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function runEngineProcess(parentPort: ParentPortLike, exit: () => void = () => process.exit(0)): void {
|
|
77
|
+
let service: MirroringService | undefined;
|
|
78
|
+
let backend: PortBackend | undefined;
|
|
79
|
+
parentPort.on("message", ({ data, ports }) => {
|
|
80
|
+
if (data.type === "start") {
|
|
81
|
+
const agent = ports[0];
|
|
82
|
+
if (agent === undefined || service !== undefined) return;
|
|
83
|
+
const source = data.source;
|
|
84
|
+
const factory = createMirroringServiceFactory({
|
|
85
|
+
createBackend: () => (backend = new PortBackend(agentPortFrom(agent), source)),
|
|
86
|
+
encodingSupport: createEncodingSupport(
|
|
87
|
+
{ hardware: new Set(data.hardwareCodecs), software: new Set(data.softwareCodecs) },
|
|
88
|
+
{
|
|
89
|
+
denyListed: new Set(data.hardwareDenyList),
|
|
90
|
+
onDenyListed: (codec) => parentPort.postMessage({ type: "deny-hardware-codec", codec }),
|
|
91
|
+
policy: {
|
|
92
|
+
hardwareFeatures: new Set(data.encodingPolicy.hardwareFeatures), softwareFeatures: new Set(data.encodingPolicy.softwareFeatures),
|
|
93
|
+
forceEnable: new Set(data.encodingPolicy.forceEnable), forceDisable: new Set(data.encodingPolicy.forceDisable),
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
),
|
|
97
|
+
env: data.env,
|
|
98
|
+
});
|
|
99
|
+
service = factory(
|
|
100
|
+
data.params,
|
|
101
|
+
{
|
|
102
|
+
didStart: () => parentPort.postMessage({ type: "did-start" }),
|
|
103
|
+
didStop: () => parentPort.postMessage({ type: "did-stop" }),
|
|
104
|
+
onError: (error, message) => parentPort.postMessage({ type: "error", error, message }),
|
|
105
|
+
logInfo: (message) => parentPort.postMessage({ type: "log", message }),
|
|
106
|
+
},
|
|
107
|
+
{ send: (namespace, json) => parentPort.postMessage({ type: "send", namespace, json }) },
|
|
108
|
+
);
|
|
109
|
+
} else if (data.type === "message") {
|
|
110
|
+
service?.onMessage(data.namespace, data.json);
|
|
111
|
+
} else if (data.type === "switch-source") {
|
|
112
|
+
backend?.setSource(data.source);
|
|
113
|
+
service?.switchMirroringSourceTab?.(data.webContentsId);
|
|
114
|
+
} else if (data.type === "pause") {
|
|
115
|
+
service?.pause?.(() => {});
|
|
116
|
+
} else if (data.type === "resume") {
|
|
117
|
+
service?.resume?.(() => {});
|
|
118
|
+
} else if (data.type === "get-stats") {
|
|
119
|
+
const id = data.id;
|
|
120
|
+
void (service?.getMirroringStats?.() ?? Promise.resolve(undefined)).then((stats) => parentPort.postMessage({ type: "stats", id, stats }));
|
|
121
|
+
} else if (data.type === "stop") {
|
|
122
|
+
service?.stop();
|
|
123
|
+
service = undefined;
|
|
124
|
+
exit();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Started by `utilityProcess.fork`; imported by tests, where there is no parent port.
|
|
130
|
+
const parentPort = (process as unknown as { parentPort?: ParentPortLike }).parentPort;
|
|
131
|
+
if (parentPort !== undefined) runEngineProcess(parentPort);
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs mirroring sessions in Electron: per session a hidden capture window (the agent), a utility process (the
|
|
3
|
+
* engine) and a `MessagePort` between them, so frames and encoded chunks never pass through the main process. The
|
|
4
|
+
* Electron objects are handed in, as everywhere in this package.
|
|
5
|
+
*
|
|
6
|
+
* The role this plays in Chrome is `CastMirroringServiceHost` (`chrome/browser/media/cast_mirroring_service_host.cc`),
|
|
7
|
+
* which prepares the capture source (a tab through `WebContentsMediaCaptureId`, the desktop through a stream id) and
|
|
8
|
+
* starts the Mirroring Service, here the engine process.
|
|
9
|
+
*/
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import type { VideoCodec } from "../protocol/constants.ts";
|
|
16
|
+
import type { MirroringStats } from "../stats/statistics.ts";
|
|
17
|
+
import type { MirroringServiceFactory, MirroringService } from "../mirroring-activity.ts";
|
|
18
|
+
import { encodingPolicyFromCommandLine, hardwareCodecsToProbe, softwareCodecsToProbe, type CommandLineLike } from "../encoding-support.ts";
|
|
19
|
+
import { getCodecParameterString } from "../mirror-settings.ts";
|
|
20
|
+
import { desktopStreamId, isDesktopSourceWithAudio } from "../routing.ts";
|
|
21
|
+
import type { CaptureSource } from "./agent-protocol.ts";
|
|
22
|
+
import { AGENT_PRELOAD_SOURCE, AGENT_SOURCE } from "./agent-source.ts";
|
|
23
|
+
import type { FromEngine, ToEngine } from "./engine-process.ts";
|
|
24
|
+
|
|
25
|
+
/** A `MessagePortMain`. */
|
|
26
|
+
export interface PortMainLike { postMessage(message: unknown, transfer?: unknown[]): void; start(): void; close(): void }
|
|
27
|
+
export interface WebContentsMirrorLike {
|
|
28
|
+
readonly id: number;
|
|
29
|
+
isDestroyed(): boolean;
|
|
30
|
+
isAudioMuted?(): boolean;
|
|
31
|
+
setAudioMuted?(muted: boolean): void;
|
|
32
|
+
/** `webContents.getMediaSourceId(requestWebContents)`: a tab capture id that `requestWebContents` can use once. */
|
|
33
|
+
getMediaSourceId(requestWebContents: unknown): string;
|
|
34
|
+
executeJavaScript(code: string, userGesture?: boolean): Promise<unknown>;
|
|
35
|
+
postMessage(channel: string, message: unknown, transfer?: PortMainLike[]): void;
|
|
36
|
+
setWindowOpenHandler(handler: () => { action: "deny" }): void;
|
|
37
|
+
on(event: "will-navigate", listener: (event: { preventDefault(): void }) => void): unknown;
|
|
38
|
+
once(event: "destroyed", listener: () => void): unknown;
|
|
39
|
+
readonly session: {
|
|
40
|
+
setPermissionRequestHandler(handler: ((wc: unknown, permission: string, callback: (granted: boolean) => void) => void) | null): void;
|
|
41
|
+
setPermissionCheckHandler(handler: ((wc: unknown, permission: string) => boolean) | null): void;
|
|
42
|
+
setDisplayMediaRequestHandler(handler: ((request: unknown, callback: (streams: { video?: unknown; audio?: "loopback" | "loopbackWithMute" }) => void) => void) | null): void;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface BrowserWindowLike {
|
|
46
|
+
readonly webContents: WebContentsMirrorLike;
|
|
47
|
+
loadFile(path: string): Promise<void>;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
isDestroyed(): boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface UtilityProcessLike {
|
|
52
|
+
postMessage(message: ToEngine, transfer?: PortMainLike[]): void;
|
|
53
|
+
on(event: "message", listener: (message: FromEngine) => void): unknown;
|
|
54
|
+
on(event: "exit", listener: (code: number) => void): unknown;
|
|
55
|
+
on(event: "spawn", listener: () => void): unknown;
|
|
56
|
+
kill(): boolean;
|
|
57
|
+
readonly stdout?: { on(event: "data", listener: (chunk: Buffer) => void): unknown } | null;
|
|
58
|
+
readonly stderr?: { on(event: "data", listener: (chunk: Buffer) => void): unknown } | null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The Electron pieces mirroring needs. */
|
|
62
|
+
export interface ElectronMirroringApi {
|
|
63
|
+
BrowserWindow: new (options: Record<string, unknown>) => BrowserWindowLike;
|
|
64
|
+
utilityProcess: { fork(modulePath: string, args?: string[], options?: Record<string, unknown>): UtilityProcessLike };
|
|
65
|
+
MessageChannelMain: new () => { port1: PortMainLike; port2: PortMainLike };
|
|
66
|
+
webContents: { fromId(id: number): WebContentsMirrorLike | undefined };
|
|
67
|
+
/**
|
|
68
|
+
* `app`: its `commandLine` is where Chrome's `--cast-streaming-force-{enable,disable}-hardware-<codec>`,
|
|
69
|
+
* `--enable-features` / `--disable-features` (`CastStreamingVp8`, `Vp9`, `Av1`, `HardwareHevc`, `Win/MacHardwareH264`)
|
|
70
|
+
* and `--disable-cast-letterboxing` are read, including switches the app appended itself. Without it only
|
|
71
|
+
* Chrome's defaults apply.
|
|
72
|
+
*/
|
|
73
|
+
app?: { commandLine: CommandLineLike };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ElectronMirroringOptions {
|
|
77
|
+
electron: ElectronMirroringApi;
|
|
78
|
+
/** Absolute path of the engine entry (`engine-process.js` next to this file in the built package). */
|
|
79
|
+
engineModulePath?: string;
|
|
80
|
+
/** Environment for the session host (`CHROME_MIRRORING_PLAYOUT_DELAY`); default none. */
|
|
81
|
+
env?: Record<string, string | undefined>;
|
|
82
|
+
log?(level: "info" | "error", message: string): void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Locates the engine entry beside this module, for both the ESM and the CommonJS build. */
|
|
86
|
+
function defaultEngineModulePath(): string {
|
|
87
|
+
const line = (new Error().stack ?? "").split("\n").find((l) => /[\\/]host\.(?:js|cjs|mjs|ts):\d+:\d+/.test(l));
|
|
88
|
+
const match = line === undefined ? null : /(file:\/\/[^\s)]+?|[A-Za-z]:[\\/][^\s)]+?|\/[^\s)]+?)host\.(js|cjs|mjs|ts):\d+:\d+/.exec(line);
|
|
89
|
+
if (match === null) throw new Error("cannot locate the mirroring engine; pass engineModulePath");
|
|
90
|
+
const base = match[1]!.startsWith("file://") ? fileURLToPath(match[1]!) : match[1]!;
|
|
91
|
+
return `${base}engine-process.${match[2] === "ts" ? "ts" : "js"}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const PORT_CHANNEL = "electron-cast-mirroring:port";
|
|
95
|
+
const PAGE = "<!doctype html><meta charset=\"utf-8\"><title>electron-cast capture</title>";
|
|
96
|
+
|
|
97
|
+
/** Where the encoder is asked about software codecs (`GetCodecParameterString` for 720p at 30 fps). */
|
|
98
|
+
const SOFTWARE_PROBE_SIZE = { width: 1280, height: 720 };
|
|
99
|
+
|
|
100
|
+
/** The `codec_parameter` the offer carries, which is also what the encoder is asked about. */
|
|
101
|
+
function probeString(codec: VideoCodec, width: number, height: number, macBaseline: boolean): string {
|
|
102
|
+
const s = getCodecParameterString(codec, width, height, 30, macBaseline ? "baseline" : "main");
|
|
103
|
+
return s === "" ? codec : s;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** `platform` is for tests only: Chrome's choice of desktop loopback device depends on it and is not an app setting. */
|
|
107
|
+
export function createElectronMirroringServiceFactory(options: ElectronMirroringOptions, platform: string = process.platform): { factory: MirroringServiceFactory; dispose(): void } {
|
|
108
|
+
const e = options.electron;
|
|
109
|
+
const log = options.log ?? (() => {});
|
|
110
|
+
const live = new Set<() => void>();
|
|
111
|
+
// `GetHardwareCodecDenyList()` is process-wide in Chrome: a hardware encoder that failed in one session is not
|
|
112
|
+
// offered in the next either, for as long as the app runs.
|
|
113
|
+
const hardwareDenyList = new Set<VideoCodec>();
|
|
114
|
+
|
|
115
|
+
const factory: MirroringServiceFactory = (params, observer, channel, source): MirroringService => {
|
|
116
|
+
const dir = mkdtempSync(join(tmpdir(), "electron-cast-agent-"));
|
|
117
|
+
let win: BrowserWindowLike | undefined;
|
|
118
|
+
let child: UtilityProcessLike | undefined;
|
|
119
|
+
let ended = false;
|
|
120
|
+
const queue: ToEngine[] = [];
|
|
121
|
+
let ready = false;
|
|
122
|
+
let nextStatsId = 0;
|
|
123
|
+
const pendingStats = new Map<number, (stats: MirroringStats | undefined) => void>();
|
|
124
|
+
|
|
125
|
+
let unmuteTab: (() => void) | undefined;
|
|
126
|
+
// The page being mirrored (`CastMirroringServiceHost::web_contents()`), the agent's own page, and whether the
|
|
127
|
+
// start message has been given its capture id yet.
|
|
128
|
+
let tabTarget: WebContentsMirrorLike | undefined;
|
|
129
|
+
let agentContents: WebContentsMirrorLike | undefined;
|
|
130
|
+
let minted = false;
|
|
131
|
+
// CastMirroringServiceHost::CreateAudioStream binds a Muter for the tab's audio group (crbug.com/40708932): the
|
|
132
|
+
// tab is silent locally for the whole session and unmuted when the host goes away. Another feature may have
|
|
133
|
+
// muted the tab first, so only a mute made here is undone.
|
|
134
|
+
const muteTab = (target: WebContentsMirrorLike): void => {
|
|
135
|
+
if (target.setAudioMuted !== undefined && target.isAudioMuted?.() === false) {
|
|
136
|
+
target.setAudioMuted(true);
|
|
137
|
+
unmuteTab = () => {
|
|
138
|
+
if (!target.isDestroyed()) target.setAudioMuted?.(false);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
// CastMirroringServiceHost observes the mirrored WebContents (`Observe(GetContents(...))`, again for the new tab on a
|
|
143
|
+
// switch) and its WebContentsDestroyed() calls StopMirroringSession(): the Mirroring Service is released, whose
|
|
144
|
+
// session host stops and reports DidStop(), and the route ends. A desktop source observes nothing. A stale listener
|
|
145
|
+
// (the tab was switched away from) is ignored, as Chrome stops observing the old contents.
|
|
146
|
+
const observeTab = (target: WebContentsMirrorLike): void => {
|
|
147
|
+
target.once("destroyed", () => {
|
|
148
|
+
if (ended || tabTarget !== target) return;
|
|
149
|
+
observer.didStop?.();
|
|
150
|
+
teardown();
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const teardown = (): void => {
|
|
154
|
+
if (ended) return;
|
|
155
|
+
ended = true;
|
|
156
|
+
for (const resolve of pendingStats.values()) resolve(undefined);
|
|
157
|
+
pendingStats.clear();
|
|
158
|
+
unmuteTab?.();
|
|
159
|
+
live.delete(teardown);
|
|
160
|
+
try {
|
|
161
|
+
child?.postMessage({ type: "stop" });
|
|
162
|
+
} catch {
|
|
163
|
+
// already gone
|
|
164
|
+
}
|
|
165
|
+
const c = child;
|
|
166
|
+
if (c !== undefined) setTimeout(() => c.kill(), 1000).unref();
|
|
167
|
+
if (win !== undefined && !win.isDestroyed()) win.destroy();
|
|
168
|
+
rmSync(dir, { recursive: true, force: true });
|
|
169
|
+
};
|
|
170
|
+
live.add(teardown);
|
|
171
|
+
|
|
172
|
+
const post = (message: ToEngine): void => {
|
|
173
|
+
if (ready && child !== undefined) child.postMessage(message);
|
|
174
|
+
else queue.push(message);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
void (async () => {
|
|
178
|
+
try {
|
|
179
|
+
writeFileSync(join(dir, "preload.cjs"), AGENT_PRELOAD_SOURCE, { mode: 0o600 });
|
|
180
|
+
writeFileSync(join(dir, "agent.html"), PAGE, { mode: 0o600 });
|
|
181
|
+
win = new e.BrowserWindow({
|
|
182
|
+
show: false,
|
|
183
|
+
width: 320,
|
|
184
|
+
height: 240,
|
|
185
|
+
webPreferences: {
|
|
186
|
+
preload: join(dir, "preload.cjs"),
|
|
187
|
+
sandbox: true,
|
|
188
|
+
contextIsolation: true,
|
|
189
|
+
nodeIntegration: false,
|
|
190
|
+
webSecurity: true,
|
|
191
|
+
// A private, in-memory partition: nothing of the app's own session is shared with the capture window.
|
|
192
|
+
partition: `electron-cast-mirroring-${randomUUID()}`,
|
|
193
|
+
backgroundThrottling: false,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
const wc = win.webContents;
|
|
197
|
+
agentContents = wc;
|
|
198
|
+
wc.setWindowOpenHandler(() => ({ action: "deny" }));
|
|
199
|
+
wc.on("will-navigate", (ev) => ev.preventDefault());
|
|
200
|
+
wc.session.setPermissionRequestHandler((_wc, permission, callback) => callback(permission === "media" || permission === "display-capture"));
|
|
201
|
+
wc.session.setPermissionCheckHandler((_wc, permission) => permission === "media" || permission === "display-capture");
|
|
202
|
+
|
|
203
|
+
let capture: CaptureSource;
|
|
204
|
+
let mintTabSource: (() => CaptureSource) | undefined;
|
|
205
|
+
if (source.type === "tab") {
|
|
206
|
+
const tabId = Number(source.id.slice(source.id.lastIndexOf(":") + 1));
|
|
207
|
+
const target = e.webContents.fromId(tabId);
|
|
208
|
+
if (target === undefined || target.isDestroyed()) throw new Error(`no page with webContents id ${tabId}`);
|
|
209
|
+
tabTarget = target;
|
|
210
|
+
observeTab(target);
|
|
211
|
+
// The id is bound to the requesting frame, so it can only be minted once the agent page has loaded. A switch
|
|
212
|
+
// that came in before then has replaced `tabTarget`, so the start carries the newest tab.
|
|
213
|
+
mintTabSource = () => ({ kind: "tab", mediaSourceId: tabTarget!.getMediaSourceId(wc) });
|
|
214
|
+
muteTab(target);
|
|
215
|
+
capture = { kind: "tab", mediaSourceId: "" };
|
|
216
|
+
} else {
|
|
217
|
+
const id = desktopStreamId(source.id) ?? "";
|
|
218
|
+
// CastMirroringServiceHost parses the media id it is given (DesktopMediaID::Parse) and captures it; it does not
|
|
219
|
+
// list the sources again. Listing them here failed on Linux (X11 under Xvfb), where the screen the app had
|
|
220
|
+
// just been given was not in a second list; an id that names nothing fails the capture instead. Electron's
|
|
221
|
+
// handler also wants a name, which only labels the track.
|
|
222
|
+
const chosen = { id, name: id };
|
|
223
|
+
const withAudio = isDesktopSourceWithAudio(source.id);
|
|
224
|
+
// CastMirroringServiceHost::GetDesktopAudioLoopbackDeviceId: Windows keeps local playback
|
|
225
|
+
// (kLoopbackInputDeviceId, kCastDesktopMirroringKeepLocalAudio is on by default there, as muting the endpoint
|
|
226
|
+
// silences the loopback on some drivers); every other platform mutes it (kLoopbackWithMuteDeviceId).
|
|
227
|
+
const audioMode = platform === "win32" ? "loopback" : "loopbackWithMute";
|
|
228
|
+
wc.session.setDisplayMediaRequestHandler((_request, callback) => callback(withAudio ? { video: chosen, audio: audioMode } : { video: chosen }));
|
|
229
|
+
capture = { kind: "desktop", sourceId: id, audio: audioMode };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
await win.loadFile(join(dir, "agent.html"));
|
|
233
|
+
if (mintTabSource !== undefined) {
|
|
234
|
+
capture = mintTabSource();
|
|
235
|
+
minted = true;
|
|
236
|
+
}
|
|
237
|
+
// Feature-detect what WebCodecs can encode here. Chrome asks the GPU process for the hardware encoder profiles
|
|
238
|
+
// (`encoding_support::IsHardwareEnabled`); `prefer-hardware` is the same question: Chromium's VideoEncoder then
|
|
239
|
+
// accepts the configuration only if a hardware encoder takes it (blink video_encoder.cc: `GetRequiredEncoderType`
|
|
240
|
+
// is `kHardware`, and `CreateMediaVideoEncoder` returns the accelerated encoder's status without a software
|
|
241
|
+
// fallback). Hardware is asked about at the session's maximum resolution, as Chrome does; software, VP8 first and
|
|
242
|
+
// anything else only when asked for, as before.
|
|
243
|
+
const macBaseline = platform === "darwin";
|
|
244
|
+
const probes: { codec: VideoCodec; hardware: boolean; string: string; width: number; height: number }[] = [];
|
|
245
|
+
// Read at every session, as Chrome reads its command line and features whenever it negotiates.
|
|
246
|
+
const policy = encodingPolicyFromCommandLine(e.app?.commandLine, platform);
|
|
247
|
+
for (const codec of hardwareCodecsToProbe(policy)) {
|
|
248
|
+
probes.push({ codec, hardware: true, string: probeString(codec, 1920, 1080, macBaseline), width: 1920, height: 1080 });
|
|
249
|
+
}
|
|
250
|
+
for (const codec of softwareCodecsToProbe(policy)) {
|
|
251
|
+
probes.push({ codec, hardware: false, string: probeString(codec, SOFTWARE_PROBE_SIZE.width, SOFTWARE_PROBE_SIZE.height, macBaseline), ...SOFTWARE_PROBE_SIZE });
|
|
252
|
+
}
|
|
253
|
+
const found = (await wc.executeJavaScript(
|
|
254
|
+
`(async () => { const out = []; for (const p of ${JSON.stringify(probes)}) {` +
|
|
255
|
+
` try { const config = { codec: p.string, width: p.width, height: p.height, bitrate: 2000000, framerate: 30, latencyMode: "realtime", hardwareAcceleration: p.hardware ? "prefer-hardware" : "prefer-software" };` +
|
|
256
|
+
` if (p.codec === "h264") config.avc = { format: "annexb" }; if (p.codec === "hevc") config.hevc = { format: "annexb" };` +
|
|
257
|
+
` const r = await VideoEncoder.isConfigSupported(config);` +
|
|
258
|
+
` if (r.supported) out.push({ codec: p.codec, hardware: p.hardware }); } catch {} } return out; })()`,
|
|
259
|
+
)) as { codec: VideoCodec; hardware: boolean }[];
|
|
260
|
+
const hardwareCodecs = found.filter((f) => f.hardware).map((f) => f.codec);
|
|
261
|
+
const softwareCodecs = found.filter((f) => !f.hardware).map((f) => f.codec);
|
|
262
|
+
if (!softwareCodecs.includes("vp8")) throw new Error("this Electron's WebCodecs cannot encode VP8");
|
|
263
|
+
log("info", `encoders: hardware [${hardwareCodecs.join(", ")}], software [${softwareCodecs.join(", ")}]${hardwareDenyList.size > 0 ? `, deny-listed hardware [${[...hardwareDenyList].join(", ")}]` : ""}`);
|
|
264
|
+
await wc.executeJavaScript(AGENT_SOURCE);
|
|
265
|
+
|
|
266
|
+
const channelMain = new e.MessageChannelMain();
|
|
267
|
+
wc.postMessage(PORT_CHANNEL, null, [channelMain.port1]);
|
|
268
|
+
const enginePath = options.engineModulePath ?? defaultEngineModulePath();
|
|
269
|
+
const proc = e.utilityProcess.fork(enginePath, [], { serviceName: "electron-cast mirroring", stdio: "pipe" });
|
|
270
|
+
child = proc;
|
|
271
|
+
// The engine's own output (an exception, say) goes to the log, not to the app's console.
|
|
272
|
+
proc.stdout?.on("data", (c) => log("info", `engine: ${c.toString().trimEnd()}`));
|
|
273
|
+
proc.stderr?.on("data", (c) => log("error", `engine: ${c.toString().trimEnd()}`));
|
|
274
|
+
proc.on("message", (m) => {
|
|
275
|
+
switch (m.type) {
|
|
276
|
+
case "send": channel.send(m.namespace, m.json); break;
|
|
277
|
+
case "did-start": observer.didStart?.(); break;
|
|
278
|
+
// MirroringActivity::OnError and ::DidStop both end in StopMirroring, which stops this service; ending it
|
|
279
|
+
// here too keeps the window and the process from outliving a session whose owner did not.
|
|
280
|
+
case "did-stop": observer.didStop?.(); teardown(); break;
|
|
281
|
+
case "error": observer.onError?.(m.error as never, m.message); teardown(); break;
|
|
282
|
+
case "log": observer.logInfo?.(m.message); break;
|
|
283
|
+
case "stats": pendingStats.get(m.id)?.(m.stats); pendingStats.delete(m.id); break;
|
|
284
|
+
case "deny-hardware-codec": hardwareDenyList.add(m.codec); break;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
proc.on("exit", (code) => {
|
|
288
|
+
if (!ended) {
|
|
289
|
+
observer.onError?.("CAST_TRANSPORT_ERROR", `the mirroring engine exited (${code})`);
|
|
290
|
+
teardown();
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
proc.postMessage(
|
|
294
|
+
{
|
|
295
|
+
type: "start", params, source: capture, hardwareCodecs, softwareCodecs, hardwareDenyList: [...hardwareDenyList],
|
|
296
|
+
encodingPolicy: {
|
|
297
|
+
hardwareFeatures: [...policy.hardwareFeatures], softwareFeatures: [...policy.softwareFeatures],
|
|
298
|
+
forceEnable: [...policy.forceEnable], forceDisable: [...policy.forceDisable],
|
|
299
|
+
},
|
|
300
|
+
env: options.env,
|
|
301
|
+
},
|
|
302
|
+
[channelMain.port2],
|
|
303
|
+
);
|
|
304
|
+
ready = true;
|
|
305
|
+
for (const m of queue.splice(0)) proc.postMessage(m);
|
|
306
|
+
} catch (err) {
|
|
307
|
+
log("error", `mirroring could not start: ${err instanceof Error ? err.message : String(err)}`);
|
|
308
|
+
observer.onError?.("VIDEO_CAPTURE_ERROR", err instanceof Error ? err.message : String(err));
|
|
309
|
+
teardown();
|
|
310
|
+
}
|
|
311
|
+
})();
|
|
312
|
+
|
|
313
|
+
return {
|
|
314
|
+
onMessage: (namespace, json) => post({ type: "message", namespace, json }),
|
|
315
|
+
// CastMirroringServiceHost::SwitchMirroringSourceTab: the host starts observing the new tab, drops the old tab's
|
|
316
|
+
// Muter (the audio stream, created again, binds one for the new tab), and tells the Mirroring Service, which
|
|
317
|
+
// moves its video capture client and audio input device to the new source without renegotiating.
|
|
318
|
+
switchMirroringSourceTab: (webContentsId) => {
|
|
319
|
+
if (ended) throw new Error("the mirroring session has ended");
|
|
320
|
+
if (source.type !== "tab" || tabTarget === undefined) throw new Error("only a tab can be switched");
|
|
321
|
+
const next = e.webContents.fromId(webContentsId);
|
|
322
|
+
if (next === undefined || next.isDestroyed()) throw new Error(`no page with webContents id ${webContentsId}`);
|
|
323
|
+
// Minted first, so a page that cannot be captured leaves the session as it was.
|
|
324
|
+
const capture: CaptureSource | undefined = minted ? { kind: "tab", mediaSourceId: next.getMediaSourceId(agentContents) } : undefined;
|
|
325
|
+
unmuteTab?.();
|
|
326
|
+
unmuteTab = undefined;
|
|
327
|
+
muteTab(next);
|
|
328
|
+
tabTarget = next;
|
|
329
|
+
observeTab(next);
|
|
330
|
+
if (capture !== undefined) post({ type: "switch-source", webContentsId, source: capture });
|
|
331
|
+
},
|
|
332
|
+
// CastMirroringServiceHost::Pause / Resume: straight to the video capture host, so audio goes on.
|
|
333
|
+
pause: (onPaused) => {
|
|
334
|
+
if (ended) return;
|
|
335
|
+
post({ type: "pause" });
|
|
336
|
+
onPaused();
|
|
337
|
+
},
|
|
338
|
+
resume: (onResumed) => {
|
|
339
|
+
if (ended) return;
|
|
340
|
+
post({ type: "resume" });
|
|
341
|
+
onResumed();
|
|
342
|
+
},
|
|
343
|
+
getMirroringStats: () => {
|
|
344
|
+
if (ended) return Promise.resolve(undefined);
|
|
345
|
+
const id = nextStatsId++;
|
|
346
|
+
return new Promise<MirroringStats | undefined>((resolve) => {
|
|
347
|
+
pendingStats.set(id, resolve);
|
|
348
|
+
post({ type: "get-stats", id });
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
stop: teardown,
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
factory,
|
|
357
|
+
dispose() {
|
|
358
|
+
for (const t of [...live]) t();
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
}
|