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,466 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine's `MirroringBackend` over a port to the capture agent. Frame ids are assigned here, as
|
|
3
|
+
* `media::cast::VideoEncoder` / `AudioEncoder` assign them in Chromium: a key frame references itself, a delta frame
|
|
4
|
+
* the frame before it; the RTP timestamp of audio is the running sample count.
|
|
5
|
+
*/
|
|
6
|
+
import { performance } from "node:perf_hooks";
|
|
7
|
+
import type {
|
|
8
|
+
AudioCaptureSink, AudioEncoderCallbacks, AudioEncoderPort, MirroringBackend, VideoCaptureSink, VideoEncoderCallbacks,
|
|
9
|
+
} from "../backend.ts";
|
|
10
|
+
import type { FrameSenderConfig, ResolutionChangePolicy, VideoCaptureParams } from "../mirror-settings.ts";
|
|
11
|
+
import { CaptureSizeOracle, suggestConstraints } from "../sender/capture-size-oracle.ts";
|
|
12
|
+
import { EncoderUtilizationAverage, calculateEncoderUtilization, computeLossiness } from "../sender/video-encoder-metrics.ts";
|
|
13
|
+
import type { RawVideoFrame, VideoEncoderPort } from "../sender/video-sender.ts";
|
|
14
|
+
import type { AgentPort, AgentToEngine, CaptureSource } from "./agent-protocol.ts";
|
|
15
|
+
|
|
16
|
+
const toLocalMs = (epochMs: number): number => epochMs - performance.timeOrigin;
|
|
17
|
+
|
|
18
|
+
/** Debug aid, not in Chrome: mean and maximum of each pipeline stage, written to the log every five seconds. */
|
|
19
|
+
export class StageStats {
|
|
20
|
+
private readonly stages = new Map<string, { n: number; sum: number; max: number }>();
|
|
21
|
+
private since = Number.NEGATIVE_INFINITY;
|
|
22
|
+
private readonly now: () => number;
|
|
23
|
+
private readonly log: () => ((message: string) => void) | undefined;
|
|
24
|
+
|
|
25
|
+
constructor(now: () => number, log: () => ((message: string) => void) | undefined) {
|
|
26
|
+
this.now = now;
|
|
27
|
+
this.log = log;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
add(stage: string, ms: number): void {
|
|
31
|
+
const t = this.now();
|
|
32
|
+
if (this.since === Number.NEGATIVE_INFINITY) this.since = t;
|
|
33
|
+
const s = this.stages.get(stage) ?? { n: 0, sum: 0, max: 0 };
|
|
34
|
+
s.n++;
|
|
35
|
+
s.sum += ms;
|
|
36
|
+
s.max = Math.max(s.max, ms);
|
|
37
|
+
this.stages.set(stage, s);
|
|
38
|
+
if (t - this.since < 5000) return;
|
|
39
|
+
const r = (n: number) => Math.round(n * 10) / 10;
|
|
40
|
+
this.log()?.(`latency stages (mean / max ms): ${[...this.stages].map(([k, v]) => `${k} ${r(v.sum / v.n)} / ${r(v.max)}`).join("; ")}`);
|
|
41
|
+
this.stages.clear();
|
|
42
|
+
this.since = t;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** media/cast/encoding/audio_encoder.cc `kUnderrunSkipThreshold`. */
|
|
47
|
+
export const UNDERRUN_SKIP_THRESHOLD = 3;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* `FrameSinkVideoCapturerImpl::GetPipelineUtilization`: frames in flight over `kDesignLimitMaxFrames` (10) times
|
|
51
|
+
* `kTargetPipelineUtilization` (0.6).
|
|
52
|
+
*/
|
|
53
|
+
const PIPELINE_CAPACITY = 10 * 0.6;
|
|
54
|
+
/** Frames this close together count as animating content, standing in for `AnimatedContentSampler`'s detection. */
|
|
55
|
+
const ANIMATION_MAX_GAP_MS = 200;
|
|
56
|
+
|
|
57
|
+
/** What `ImplBase::EncodeAudio` decided for one buffer: the frame's timestamps and the samples skipped before it. */
|
|
58
|
+
interface AudioMeta {
|
|
59
|
+
frameId: number;
|
|
60
|
+
rtp: number;
|
|
61
|
+
referenceTimeMs: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class PortBackend implements MirroringBackend {
|
|
65
|
+
private readonly port: AgentPort;
|
|
66
|
+
private source: CaptureSource;
|
|
67
|
+
private videoSink: VideoCaptureSink | undefined;
|
|
68
|
+
private audioSink: AudioCaptureSink | undefined;
|
|
69
|
+
private videoCallbacks: VideoEncoderCallbacks | undefined;
|
|
70
|
+
private audioCallbacks: AudioEncoderCallbacks | undefined;
|
|
71
|
+
private lastVideoParams: string | undefined;
|
|
72
|
+
private pendingVideo = new Map<number, { ref: number; captureBegin: number | undefined; captureEnd: number | undefined }>();
|
|
73
|
+
private nextVideoFrameId = 0;
|
|
74
|
+
private lastVideoFrameId = -1;
|
|
75
|
+
private nextAudioFrameId = 0;
|
|
76
|
+
private audioRtp = 0;
|
|
77
|
+
private audioCaptureTimeMs: number | undefined;
|
|
78
|
+
private samplesDroppedFromBuffer = 0;
|
|
79
|
+
private audioMeta = new Map<number, AudioMeta>();
|
|
80
|
+
private currentAudioSeq = 0;
|
|
81
|
+
private frameInterval = 1000 / 30;
|
|
82
|
+
private targetBitrate = 0;
|
|
83
|
+
private isHardwareEncoder = false;
|
|
84
|
+
private readonly utilizationAverage = new EncoderUtilizationAverage();
|
|
85
|
+
private oracle: CaptureSizeOracle | undefined;
|
|
86
|
+
private oracleFrames = new Map<number, number>();
|
|
87
|
+
private feedbackFrame: number | undefined;
|
|
88
|
+
private lastContentFrameMs: number | undefined;
|
|
89
|
+
private sentCaptureSize: string | undefined;
|
|
90
|
+
private audioConfig: { sampleRate: number; channels: number } | undefined;
|
|
91
|
+
private audioSenderConfig: FrameSenderConfig | undefined;
|
|
92
|
+
private stopped = false;
|
|
93
|
+
log: ((message: string) => void) | undefined;
|
|
94
|
+
private readonly stages = new StageStats(() => performance.now(), () => this.log);
|
|
95
|
+
|
|
96
|
+
constructor(port: AgentPort, source: CaptureSource) {
|
|
97
|
+
this.port = port;
|
|
98
|
+
this.source = source;
|
|
99
|
+
port.onMessage((m) => this.onAgentMessage(m));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private onAgentMessage(m: AgentToEngine): void {
|
|
103
|
+
if (this.stopped || typeof m !== "object" || m === null) return;
|
|
104
|
+
switch (m.t) {
|
|
105
|
+
case "ready":
|
|
106
|
+
break;
|
|
107
|
+
case "error":
|
|
108
|
+
if (m.where === "video") this.videoSink?.onCaptureError(m.message);
|
|
109
|
+
else if (m.where === "audio") this.audioSink?.onCaptureError(m.message);
|
|
110
|
+
else this.videoCallbacks?.onStatus("codec_runtime_error", m.message);
|
|
111
|
+
break;
|
|
112
|
+
case "frame":
|
|
113
|
+
this.observeCapturedFrame(m.rtp, toLocalMs(m.refMs), m.width, m.height, m.refresh === true);
|
|
114
|
+
this.stages.add("video capture to engine", performance.now() - toLocalMs(m.refMs));
|
|
115
|
+
this.videoSink?.insertVideoFrame({
|
|
116
|
+
rtpTimestamp: m.rtp,
|
|
117
|
+
referenceTimeMs: toLocalMs(m.refMs),
|
|
118
|
+
visibleRectEmpty: false,
|
|
119
|
+
...(typeof m.captureBeginMs === "number" ? { captureBeginTimeMs: toLocalMs(m.captureBeginMs) } : {}),
|
|
120
|
+
...(typeof m.captureEndMs === "number" ? { captureEndTimeMs: toLocalMs(m.captureEndMs) } : {}),
|
|
121
|
+
});
|
|
122
|
+
break;
|
|
123
|
+
case "video-chunk": {
|
|
124
|
+
const pending = this.pendingVideo.get(m.rtp);
|
|
125
|
+
// The frame still counts in the backlog while its own output is processed (`recent_metadata_` is popped last).
|
|
126
|
+
const backlog = this.pendingVideo.size;
|
|
127
|
+
this.pendingVideo.delete(m.rtp);
|
|
128
|
+
if (pending === undefined) return;
|
|
129
|
+
const ref = pending.ref;
|
|
130
|
+
this.stages.add("video encode (agent)", m.encodeMs);
|
|
131
|
+
this.stages.add("video capture to encoded", performance.now() - ref);
|
|
132
|
+
this.stages.add(m.key ? "video key frame bytes" : "video delta frame bytes", m.data.byteLength);
|
|
133
|
+
const frameId = this.nextVideoFrameId++;
|
|
134
|
+
const referenced = m.key ? frameId : this.lastVideoFrameId;
|
|
135
|
+
this.lastVideoFrameId = frameId;
|
|
136
|
+
const data = Buffer.from(m.data);
|
|
137
|
+
// OnFrameEncodeDone: WebCodecs reports no quantizer, so the frame's estimated complexity stands in for it and
|
|
138
|
+
// only frames that were estimated have a lossiness.
|
|
139
|
+
const lossiness =
|
|
140
|
+
m.complexity !== undefined && this.targetBitrate > 0
|
|
141
|
+
? computeLossiness(data.length, m.durationMs ?? this.frameInterval, this.targetBitrate, m.complexity)
|
|
142
|
+
: undefined;
|
|
143
|
+
this.feedbackFrame = this.oracleFrames.get(m.rtp);
|
|
144
|
+
this.videoCallbacks?.onEncoded(ref, {
|
|
145
|
+
isKeyFrame: m.key,
|
|
146
|
+
frameId,
|
|
147
|
+
referencedFrameId: referenced,
|
|
148
|
+
rtpTimestamp: m.rtp,
|
|
149
|
+
referenceTimeMs: ref,
|
|
150
|
+
newPlayoutDelayMs: 0,
|
|
151
|
+
data,
|
|
152
|
+
...(pending.captureBegin !== undefined ? { captureBeginTimeMs: pending.captureBegin } : {}),
|
|
153
|
+
...(pending.captureEnd !== undefined ? { captureEndTimeMs: pending.captureEnd } : {}),
|
|
154
|
+
// ComputeAndRecordUtilization: how much of the frame interval the encoder needed, smoothed.
|
|
155
|
+
encoderUtilization: this.utilizationAverage.record(
|
|
156
|
+
calculateEncoderUtilization(this.isHardwareEncoder, backlog, m.encodeMs, this.frameInterval),
|
|
157
|
+
),
|
|
158
|
+
lossiness,
|
|
159
|
+
});
|
|
160
|
+
this.feedbackFrame = undefined;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case "video-drop": {
|
|
164
|
+
// The agent could not produce a chunk. Chrome's encoder reports that as a frame with no data
|
|
165
|
+
// (VideoSender::OnFrameDroppedByEncoder), which also frees the frame's slot in `framesInEncoder`.
|
|
166
|
+
const ref = this.pendingVideo.get(m.rtp)?.ref;
|
|
167
|
+
if (ref === undefined) return;
|
|
168
|
+
this.pendingVideo.delete(m.rtp);
|
|
169
|
+
this.feedbackFrame = this.oracleFrames.get(m.rtp);
|
|
170
|
+
this.videoCallbacks?.onEncoded(ref, {
|
|
171
|
+
isKeyFrame: false,
|
|
172
|
+
frameId: this.nextVideoFrameId,
|
|
173
|
+
referencedFrameId: this.lastVideoFrameId,
|
|
174
|
+
rtpTimestamp: m.rtp,
|
|
175
|
+
referenceTimeMs: ref,
|
|
176
|
+
newPlayoutDelayMs: 0,
|
|
177
|
+
data: new Uint8Array(0),
|
|
178
|
+
encoderUtilization: -1,
|
|
179
|
+
});
|
|
180
|
+
this.feedbackFrame = undefined;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
case "audio-drop": {
|
|
184
|
+
// A buffer that never became a frame: its samples are reported as skipped with the next frame, which is how
|
|
185
|
+
// AudioSender::OnEncodedAudioFrame learns they left the encoder.
|
|
186
|
+
const meta = this.audioMeta.get(m.seq);
|
|
187
|
+
if (meta === undefined) return;
|
|
188
|
+
this.audioMeta.delete(m.seq);
|
|
189
|
+
this.samplesDroppedFromBuffer += this.samplesPerAudioFrame();
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case "audio-buffer": {
|
|
193
|
+
this.currentAudioSeq = m.seq;
|
|
194
|
+
this.stages.add("audio capture to engine", performance.now() - toLocalMs(m.recMs));
|
|
195
|
+
const accepted = this.audioSink?.insertAudio(m.frames, toLocalMs(m.recMs)) ?? false;
|
|
196
|
+
if (!accepted) this.port.postMessage({ t: "drop-audio", seq: m.seq });
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case "audio-chunk": {
|
|
200
|
+
const meta = this.audioMeta.get(m.seq);
|
|
201
|
+
if (meta === undefined) return;
|
|
202
|
+
this.audioMeta.delete(m.seq);
|
|
203
|
+
const skipped = this.samplesDroppedFromBuffer;
|
|
204
|
+
this.samplesDroppedFromBuffer = 0;
|
|
205
|
+
this.audioCallbacks?.onEncoded(
|
|
206
|
+
{
|
|
207
|
+
isKeyFrame: true,
|
|
208
|
+
frameId: meta.frameId,
|
|
209
|
+
referencedFrameId: meta.frameId,
|
|
210
|
+
rtpTimestamp: meta.rtp,
|
|
211
|
+
referenceTimeMs: meta.referenceTimeMs,
|
|
212
|
+
newPlayoutDelayMs: 0,
|
|
213
|
+
data: Buffer.from(m.data),
|
|
214
|
+
encoderUtilization: -1,
|
|
215
|
+
// Chrome's audio source also uses the capture time for both.
|
|
216
|
+
captureBeginTimeMs: meta.referenceTimeMs,
|
|
217
|
+
captureEndTimeMs: meta.referenceTimeMs,
|
|
218
|
+
},
|
|
219
|
+
skipped,
|
|
220
|
+
);
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case "log":
|
|
224
|
+
if (typeof m.message === "string") this.log?.(m.message);
|
|
225
|
+
break;
|
|
226
|
+
case "encoder-status":
|
|
227
|
+
if (m.kind === "video") this.videoCallbacks?.onStatus(m.status, m.message);
|
|
228
|
+
else this.audioCallbacks?.onStatus(m.status);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
createVideoEncoder(config: FrameSenderConfig, callbacks: VideoEncoderCallbacks): VideoEncoderPort {
|
|
234
|
+
this.videoCallbacks = callbacks;
|
|
235
|
+
this.frameInterval = 1000 / config.maxFrameRate;
|
|
236
|
+
// A new encoder numbers its frames from 0 and owns no frames of the one before (a renegotiation after an encoder
|
|
237
|
+
// failure replaces it while the capture goes on); answers to the old one's frames are ignored from here on.
|
|
238
|
+
this.pendingVideo.clear();
|
|
239
|
+
this.nextVideoFrameId = 0;
|
|
240
|
+
this.lastVideoFrameId = -1;
|
|
241
|
+
this.targetBitrate = config.startBitrate;
|
|
242
|
+
// CalculateEncoderUtilization treats hardware and software encoders differently; the session host says which one
|
|
243
|
+
// this is (a WebCodecs hardware encoder was found for the codec).
|
|
244
|
+
this.isHardwareEncoder = config.useHardwareEncoder;
|
|
245
|
+
this.port.postMessage({ t: "set-codec", codec: config.videoCodec ?? "vp8", codecString: config.codecParameter, hardware: config.useHardwareEncoder });
|
|
246
|
+
this.port.postMessage({ t: "set-bitrate", bps: config.startBitrate });
|
|
247
|
+
// The agent reports unsupported or failed codecs; "initialized" is the default until it says otherwise.
|
|
248
|
+
queueMicrotask(() => callbacks.onStatus("initialized"));
|
|
249
|
+
return {
|
|
250
|
+
generateKeyFrame: () => this.port.postMessage({ t: "key-frame" }),
|
|
251
|
+
setBitRate: (bps) => {
|
|
252
|
+
this.targetBitrate = bps;
|
|
253
|
+
this.port.postMessage({ t: "set-bitrate", bps });
|
|
254
|
+
},
|
|
255
|
+
setMaxFrameRate: (rate) => {
|
|
256
|
+
this.frameInterval = 1000 / rate;
|
|
257
|
+
},
|
|
258
|
+
encodeVideoFrame: (frame: RawVideoFrame, referenceTimeMs: number) => {
|
|
259
|
+
this.pendingVideo.set(frame.rtpTimestamp, { ref: referenceTimeMs, captureBegin: frame.captureBeginTimeMs, captureEnd: frame.captureEndTimeMs });
|
|
260
|
+
// Frames the agent never hears about again are closed by its own bounded queue; forget stale references too.
|
|
261
|
+
if (this.pendingVideo.size > 64) this.pendingVideo.delete(this.pendingVideo.keys().next().value!);
|
|
262
|
+
this.port.postMessage({ t: "encode", rtp: frame.rtpTimestamp });
|
|
263
|
+
return true;
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
createAudioEncoder(config: FrameSenderConfig, callbacks: AudioEncoderCallbacks): AudioEncoderPort {
|
|
269
|
+
this.audioCallbacks = callbacks;
|
|
270
|
+
this.audioSenderConfig = config;
|
|
271
|
+
this.nextAudioFrameId = 0;
|
|
272
|
+
this.audioRtp = 0;
|
|
273
|
+
this.audioCaptureTimeMs = undefined;
|
|
274
|
+
this.samplesDroppedFromBuffer = 0;
|
|
275
|
+
this.audioMeta.clear();
|
|
276
|
+
this.port.postMessage({ t: "set-audio", bps: config.maxBitrate });
|
|
277
|
+
queueMicrotask(() => callbacks.onStatus("initialized"));
|
|
278
|
+
return {
|
|
279
|
+
samplesPerFrame: config.rtpTimebase / 100,
|
|
280
|
+
bitrate: config.maxBitrate,
|
|
281
|
+
encode: (_frames, recordedTimeMs) => this.encodeAudio(recordedTimeMs),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private samplesPerAudioFrame(): number {
|
|
286
|
+
return this.audioSenderConfig !== undefined ? this.audioSenderConfig.rtpTimebase / 100 : 480;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The timeline of `ImplBase::EncodeAudio` (media/cast/encoding/audio_encoder.cc). The agent hands over whole 10 ms
|
|
291
|
+
* buffers, so the encoder's partial-buffer fill is always empty here. A recorded time more than
|
|
292
|
+
* `kUnderrunSkipThreshold` frames ahead of the audio processed so far is an underrun: the RTP timestamp skips
|
|
293
|
+
* ahead by the frames missed. An overrun (time behind) is not resolved. The frame id advances for every buffer, as
|
|
294
|
+
* `++frame_id_` does even when the encoder produced nothing.
|
|
295
|
+
*/
|
|
296
|
+
private encodeAudio(recordedTimeMs: number): void {
|
|
297
|
+
const samplesPerFrame = this.samplesPerAudioFrame();
|
|
298
|
+
const frameDurationMs = (samplesPerFrame * 1000) / (this.audioSenderConfig?.rtpTimebase ?? 48000);
|
|
299
|
+
if (this.audioCaptureTimeMs !== undefined) {
|
|
300
|
+
const missed = Math.trunc((recordedTimeMs - this.audioCaptureTimeMs) / frameDurationMs);
|
|
301
|
+
if (missed > UNDERRUN_SKIP_THRESHOLD) {
|
|
302
|
+
// samples_dropped_from_buffer_ gains only the partial buffer's fill, which is empty here.
|
|
303
|
+
this.audioRtp += missed * samplesPerFrame;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// frame_capture_time_ = recorded_time - buffer_fill_duration (always empty here).
|
|
307
|
+
const referenceTimeMs = recordedTimeMs;
|
|
308
|
+
const meta: AudioMeta = { frameId: this.nextAudioFrameId++, rtp: this.audioRtp, referenceTimeMs };
|
|
309
|
+
this.audioMeta.set(this.currentAudioSeq, meta);
|
|
310
|
+
this.audioRtp += samplesPerFrame;
|
|
311
|
+
this.audioCaptureTimeMs = referenceTimeMs + frameDurationMs;
|
|
312
|
+
this.port.postMessage({ t: "encode-audio", seq: this.currentAudioSeq });
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
startAudioCapture(params: { sampleRate: number; channels: number; framesPerBuffer: number }, sink: AudioCaptureSink): void {
|
|
316
|
+
this.audioSink = sink;
|
|
317
|
+
this.audioConfig = { sampleRate: params.sampleRate, channels: params.channels };
|
|
318
|
+
this.maybeStart();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
stopAudioCapture(): void {
|
|
322
|
+
this.audioSink = undefined;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
startVideoCapture(params: VideoCaptureParams, sink: VideoCaptureSink): void {
|
|
326
|
+
this.videoSink = sink;
|
|
327
|
+
this.lastVideoParams = JSON.stringify(params);
|
|
328
|
+
this.videoParams = { width: params.width, height: params.height, frameRate: params.frameRate, resolutionChangePolicy: params.resolutionChangePolicy };
|
|
329
|
+
this.resetOracle();
|
|
330
|
+
this.maybeStart();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* A capture device of its own, with its own oracle: at the start, and when a switch moves the capture to another tab
|
|
335
|
+
* (`VideoCaptureClient::SwitchVideoCaptureHost` binds the new tab's host and starts a new device on it). Only the
|
|
336
|
+
* capturer of a tab (viz's FrameSinkVideoCapturerImpl) acts on resource utilization. A desktop capture
|
|
337
|
+
* (DesktopCaptureDevice) has the same CaptureResolutionChooser but never narrows it: it always captures at the
|
|
338
|
+
* largest size the constraints allow.
|
|
339
|
+
*/
|
|
340
|
+
private resetOracle(): void {
|
|
341
|
+
const params = this.videoParams;
|
|
342
|
+
this.oracle =
|
|
343
|
+
params !== undefined && this.source.kind === "tab"
|
|
344
|
+
? new CaptureSizeOracle({
|
|
345
|
+
...suggestConstraints({ width: params.width, height: params.height }, params.resolutionChangePolicy),
|
|
346
|
+
minCapturePeriodMs: 1000 / params.frameRate,
|
|
347
|
+
})
|
|
348
|
+
: undefined;
|
|
349
|
+
this.oracleFrames.clear();
|
|
350
|
+
this.lastContentFrameMs = undefined;
|
|
351
|
+
this.sentCaptureSize = undefined;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private videoParams: { width: number; height: number; frameRate: number; resolutionChangePolicy: ResolutionChangePolicy } | undefined;
|
|
355
|
+
private started = false;
|
|
356
|
+
|
|
357
|
+
/** Audio and video capture start together, as one `getUserMedia` or `getDisplayMedia` call can serve both. */
|
|
358
|
+
private maybeStart(): void {
|
|
359
|
+
if (this.started) return;
|
|
360
|
+
queueMicrotask(() => {
|
|
361
|
+
if (this.started || this.stopped) return;
|
|
362
|
+
this.started = true;
|
|
363
|
+
this.port.postMessage({ t: "start", source: this.source, video: this.videoParams, audio: this.audioConfig });
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
pauseVideoCapture(): void {
|
|
368
|
+
this.port.postMessage({ t: "pause" });
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
resumeVideoCapture(params: VideoCaptureParams, sink: VideoCaptureSink): boolean {
|
|
372
|
+
if (JSON.stringify(params) !== this.lastVideoParams || !this.started) return false;
|
|
373
|
+
this.videoSink = sink;
|
|
374
|
+
this.port.postMessage({ t: "resume" });
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** The capture source the next start or switch uses: what `CastMirroringServiceHost::source_media_id_` is in Chrome. */
|
|
379
|
+
setSource(source: CaptureSource): void {
|
|
380
|
+
this.source = source;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private switchPending: { video: boolean; audio: boolean } | undefined;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* One `switch` for both streams, since one `getUserMedia` call serves both tracks. Before capture has started there is
|
|
387
|
+
* nothing to move: the start message carries the new source already.
|
|
388
|
+
*/
|
|
389
|
+
private requestSwitch(kind: "video" | "audio"): void {
|
|
390
|
+
if (!this.started || this.stopped) return;
|
|
391
|
+
if (this.switchPending === undefined) {
|
|
392
|
+
const pending = { video: false, audio: false };
|
|
393
|
+
this.switchPending = pending;
|
|
394
|
+
queueMicrotask(() => {
|
|
395
|
+
this.switchPending = undefined;
|
|
396
|
+
if (!this.stopped) this.port.postMessage({ t: "switch", source: this.source, video: pending.video, audio: pending.audio });
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
this.switchPending[kind] = true;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
switchVideoCaptureHost(): void {
|
|
403
|
+
if (!this.started || this.stopped) return;
|
|
404
|
+
this.resetOracle();
|
|
405
|
+
this.requestSwitch("video");
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
restartAudioCapture(): void {
|
|
409
|
+
this.requestSwitch("audio");
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
suspendVideoDevice(): void {
|
|
413
|
+
this.port.postMessage({ t: "freeze" });
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
resumeVideoDevice(): void {
|
|
417
|
+
this.port.postMessage({ t: "unfreeze" });
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
requestRefreshFrame(): void {
|
|
421
|
+
this.port.postMessage({ t: "refresh" });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* `VideoCaptureClient::ProcessFeedback`. Chrome keeps the feedback for the next buffer it releases and the capture
|
|
426
|
+
* device's oracle takes it from there (`FrameSinkVideoCapturerImpl`, `VideoCaptureOracle::RecordConsumerFeedback`);
|
|
427
|
+
* here it goes to the oracle at once, for the frame whose output produced it.
|
|
428
|
+
*/
|
|
429
|
+
processFeedback(resourceUtilization: number): void {
|
|
430
|
+
if (this.oracle === undefined || this.feedbackFrame === undefined) return;
|
|
431
|
+
this.oracle.recordConsumerFeedback(this.feedbackFrame, resourceUtilization);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The oracle sees each captured frame as `FrameSinkVideoCapturerImpl::MaybeCaptureFrame` shows it one: the source
|
|
436
|
+
* size, the event, then the capture with the pipeline's utilization. The size it proposes goes to the agent when it
|
|
437
|
+
* changes.
|
|
438
|
+
*/
|
|
439
|
+
private observeCapturedFrame(rtp: number, refMs: number, width: number, height: number, refresh: boolean): void {
|
|
440
|
+
const oracle = this.oracle;
|
|
441
|
+
if (oracle === undefined) return;
|
|
442
|
+
const animating = !refresh && this.lastContentFrameMs !== undefined && refMs - this.lastContentFrameMs <= ANIMATION_MAX_GAP_MS;
|
|
443
|
+
if (!refresh) this.lastContentFrameMs = refMs;
|
|
444
|
+
oracle.setSourceSize({ width, height });
|
|
445
|
+
oracle.observeEvent(refMs, animating);
|
|
446
|
+
this.oracleFrames.set(rtp, oracle.nextFrameNumber);
|
|
447
|
+
if (this.oracleFrames.size > 64) this.oracleFrames.delete(this.oracleFrames.keys().next().value!);
|
|
448
|
+
oracle.recordCapture(this.pendingVideo.size / PIPELINE_CAPACITY);
|
|
449
|
+
|
|
450
|
+
// The encoder wants even dimensions (I420 chroma); the capture constraints round their maximum to even for the same reason.
|
|
451
|
+
const { width: w, height: h } = oracle.captureSize;
|
|
452
|
+
const size = { width: w - (w % 2), height: h - (h % 2) };
|
|
453
|
+
const key = `${size.width}x${size.height}`;
|
|
454
|
+
if (key !== this.sentCaptureSize) {
|
|
455
|
+
this.sentCaptureSize = key;
|
|
456
|
+
this.port.postMessage({ t: "capture-size", ...size });
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
stopAll(): void {
|
|
461
|
+
if (this.stopped) return;
|
|
462
|
+
this.port.postMessage({ t: "stop" });
|
|
463
|
+
this.stopped = true;
|
|
464
|
+
this.port.close();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which video codecs the session offers, ported from Chromium `media/cast/encoding/encoding_support.cc`
|
|
3
|
+
* (`IsSoftwareEnabled`, `IsHardwareEnabled`) with the feature defaults of `media/base/media_switches.cc`.
|
|
4
|
+
*
|
|
5
|
+
* Chromium asks the GPU process for the hardware encoder profiles; here the capture side probes WebCodecs
|
|
6
|
+
* (`VideoEncoder.isConfigSupported`, with `hardwareAcceleration` set to `prefer-hardware` or `prefer-software`) and
|
|
7
|
+
* passes the result as `EncodingProbe`. A codec is offered only if both the probe and Chromium's default feature
|
|
8
|
+
* state allow it.
|
|
9
|
+
*/
|
|
10
|
+
import type { VideoCodec } from "./protocol/constants.ts";
|
|
11
|
+
|
|
12
|
+
/** What the capture side found WebCodecs able to encode at the session's resolution and frame rate. */
|
|
13
|
+
export interface EncodingProbe {
|
|
14
|
+
hardware: ReadonlySet<VideoCodec>;
|
|
15
|
+
software: ReadonlySet<VideoCodec>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The part of Chrome's `base::CommandLine` this module reads; Electron's `app.commandLine` has exactly these two. */
|
|
19
|
+
export interface CommandLineLike {
|
|
20
|
+
hasSwitch(name: string): boolean;
|
|
21
|
+
getSwitchValue(name: string): string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* What Chrome's command line and feature defaults say about the codecs, as `encoding_support.cc` reads them.
|
|
26
|
+
* `hardwareFeatures` and `softwareFeatures` are the codecs whose `media::kCastStreaming*` feature is enabled
|
|
27
|
+
* (`GetHardwareCodecParameters` and `IsSoftwareEnabled`); the force sets are the
|
|
28
|
+
* `--cast-streaming-force-{enable,disable}-hardware-<codec>` switches.
|
|
29
|
+
*/
|
|
30
|
+
export interface EncodingPolicy {
|
|
31
|
+
hardwareFeatures: ReadonlySet<VideoCodec>;
|
|
32
|
+
softwareFeatures: ReadonlySet<VideoCodec>;
|
|
33
|
+
forceEnable: ReadonlySet<VideoCodec>;
|
|
34
|
+
forceDisable: ReadonlySet<VideoCodec>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ALL_CODECS: readonly VideoCodec[] = ["h264", "hevc", "vp8", "vp9", "av1"];
|
|
38
|
+
|
|
39
|
+
interface Feature {
|
|
40
|
+
name: string | undefined;
|
|
41
|
+
enabledByDefault: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* media_switches.cc feature names and defaults. Hardware: H.264 is tied to `kCastStreamingMac/WinHardwareH264` (enabled
|
|
46
|
+
* by default; no feature at all elsewhere, which counts as enabled), HEVC to `kCastStreamingHardwareHevc` (disabled),
|
|
47
|
+
* VP8 to `kCastStreamingVp8` and VP9 to `kCastStreamingVp9` (enabled), AV1 to `kCastStreamingAv1` (disabled).
|
|
48
|
+
*/
|
|
49
|
+
function hardwareFeature(codec: VideoCodec, platform: string): Feature {
|
|
50
|
+
switch (codec) {
|
|
51
|
+
case "h264": return { name: platform === "win32" ? "CastStreamingWinHardwareH264" : platform === "darwin" ? "CastStreamingMacHardwareH264" : undefined, enabledByDefault: true };
|
|
52
|
+
case "hevc": return { name: "CastStreamingHardwareHevc", enabledByDefault: false };
|
|
53
|
+
case "vp8": return { name: "CastStreamingVp8", enabledByDefault: true };
|
|
54
|
+
case "vp9": return { name: "CastStreamingVp9", enabledByDefault: true };
|
|
55
|
+
case "av1": return { name: "CastStreamingAv1", enabledByDefault: false };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** `IsSoftwareEnabled`: VP8 and VP9 by their features, AV1 by `kCastStreamingAv1`, H.264 and HEVC never. */
|
|
59
|
+
const SOFTWARE_FEATURES: Partial<Record<VideoCodec, Feature>> = {
|
|
60
|
+
vp8: { name: "CastStreamingVp8", enabledByDefault: true },
|
|
61
|
+
vp9: { name: "CastStreamingVp9", enabledByDefault: true },
|
|
62
|
+
av1: { name: "CastStreamingAv1", enabledByDefault: false },
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** `--enable-features=A,B:params` / `--disable-features=...`: the feature names. */
|
|
66
|
+
function featureNames(commandLine: CommandLineLike, name: string): Set<string> {
|
|
67
|
+
const names = new Set<string>();
|
|
68
|
+
if (!commandLine.hasSwitch(name)) return names;
|
|
69
|
+
for (const item of commandLine.getSwitchValue(name).split(",")) {
|
|
70
|
+
const feature = item.trim().split(/[:<]/)[0]!.replace(/^[*!]/, "");
|
|
71
|
+
if (feature !== "") names.add(feature);
|
|
72
|
+
}
|
|
73
|
+
return names;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Chrome's own switches and features, read from the app's command line (`app.commandLine`, which also sees
|
|
78
|
+
* `appendSwitch`). A feature named in both `--enable-features` and `--disable-features` is disabled, as in
|
|
79
|
+
* `base::FeatureList`.
|
|
80
|
+
*/
|
|
81
|
+
export function encodingPolicyFromCommandLine(commandLine: CommandLineLike | undefined, platform: string = process.platform): EncodingPolicy {
|
|
82
|
+
const enabled = commandLine === undefined ? new Set<string>() : featureNames(commandLine, "enable-features");
|
|
83
|
+
const disabled = commandLine === undefined ? new Set<string>() : featureNames(commandLine, "disable-features");
|
|
84
|
+
const on = (f: Feature): boolean => (f.name !== undefined && disabled.has(f.name) ? false : (f.name !== undefined && enabled.has(f.name)) || f.enabledByDefault);
|
|
85
|
+
const hardwareFeatures = new Set<VideoCodec>(ALL_CODECS.filter((c) => on(hardwareFeature(c, platform))));
|
|
86
|
+
const softwareFeatures = new Set<VideoCodec>(ALL_CODECS.filter((c) => { const f = SOFTWARE_FEATURES[c]; return f !== undefined && on(f); }));
|
|
87
|
+
const forced = (kind: "enable" | "disable"): Set<VideoCodec> =>
|
|
88
|
+
new Set(ALL_CODECS.filter((c) => commandLine?.hasSwitch(`cast-streaming-force-${kind}-hardware-${c}`) === true));
|
|
89
|
+
return { hardwareFeatures, softwareFeatures, forceEnable: forced("enable"), forceDisable: forced("disable") };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The policy of a command line that says nothing. */
|
|
93
|
+
export const DEFAULT_ENCODING_POLICY: EncodingPolicy = encodingPolicyFromCommandLine(undefined);
|
|
94
|
+
|
|
95
|
+
/** The part of `IsHardwareEnabled` that does not depend on the encoder: the switches, then the feature state. */
|
|
96
|
+
export function isHardwareCodecAllowed(codec: VideoCodec, policy: EncodingPolicy): boolean {
|
|
97
|
+
if (policy.forceDisable.has(codec)) return false;
|
|
98
|
+
return policy.hardwareFeatures.has(codec) || policy.forceEnable.has(codec);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Codecs worth asking the encoder about in hardware. */
|
|
102
|
+
export function hardwareCodecsToProbe(policy: EncodingPolicy): VideoCodec[] {
|
|
103
|
+
return ALL_CODECS.filter((c) => isHardwareCodecAllowed(c, policy));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Codecs worth asking the encoder about in software. */
|
|
107
|
+
export function softwareCodecsToProbe(policy: EncodingPolicy): VideoCodec[] {
|
|
108
|
+
return ALL_CODECS.filter((c) => policy.softwareFeatures.has(c));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface EncodingSupport {
|
|
112
|
+
isHardwareEnabled(codec: VideoCodec): boolean;
|
|
113
|
+
isSoftwareEnabled(codec: VideoCodec): boolean;
|
|
114
|
+
isHardwareDenyListed(codec: VideoCodec): boolean;
|
|
115
|
+
/** `DenyListHardwareCodec`: stop offering the codec in hardware, for the rest of the app's run. Chrome CHECKs it is not already listed. */
|
|
116
|
+
denyListHardwareCodec(codec: VideoCodec): void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface EncodingSupportOptions {
|
|
120
|
+
/**
|
|
121
|
+
* Chromium's process-wide `GetHardwareCodecDenyList()`: a codec whose hardware encoder failed stays out of every
|
|
122
|
+
* later session's offer. The engine runs in its own process per session, so the owner of the list (the main
|
|
123
|
+
* process) passes it in and `onDenyListed` reports an addition back.
|
|
124
|
+
*/
|
|
125
|
+
denyListed?: Set<VideoCodec>;
|
|
126
|
+
onDenyListed?: (codec: VideoCodec) => void;
|
|
127
|
+
policy?: EncodingPolicy;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function createEncodingSupport(probe: EncodingProbe, options: EncodingSupportOptions = {}): EncodingSupport {
|
|
131
|
+
const denyListed = options.denyListed ?? new Set<VideoCodec>();
|
|
132
|
+
const policy = options.policy ?? DEFAULT_ENCODING_POLICY;
|
|
133
|
+
return {
|
|
134
|
+
isHardwareEnabled: (codec) => !denyListed.has(codec) && isHardwareCodecAllowed(codec, policy) && probe.hardware.has(codec),
|
|
135
|
+
isSoftwareEnabled: (codec) => policy.softwareFeatures.has(codec) && probe.software.has(codec),
|
|
136
|
+
isHardwareDenyListed: (codec) => denyListed.has(codec),
|
|
137
|
+
denyListHardwareCodec(codec) {
|
|
138
|
+
if (denyListed.has(codec)) throw new Error(`hardware ${codec} is already deny-listed`);
|
|
139
|
+
denyListed.add(codec);
|
|
140
|
+
options.onDenyListed?.(codec);
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** openscreen_session_host.cc `kSupportedVideoCodecs`, in order of priority. */
|
|
146
|
+
export const SUPPORTED_VIDEO_CODECS: readonly VideoCodec[] = ["hevc", "av1", "vp9", "h264", "vp8"];
|