electron-cast 0.4.0 → 0.5.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (626) hide show
  1. package/CHANGELOG.md +280 -0
  2. package/CONTRIBUTING.md +305 -0
  3. package/README.md +211 -165
  4. package/SECURITY.md +324 -0
  5. package/dist/cjs/client/auth/build-time.js +1 -1
  6. package/dist/cjs/client/auth/cast-auth.d.ts +2 -0
  7. package/dist/cjs/client/auth/cast-auth.js.map +1 -1
  8. package/dist/cjs/dial/dial-registry.d.ts +104 -0
  9. package/dist/cjs/dial/dial-registry.js +301 -0
  10. package/dist/cjs/dial/dial-registry.js.map +1 -0
  11. package/dist/cjs/dial/dial-sink-service.d.ts +108 -0
  12. package/dist/cjs/dial/dial-sink-service.js +314 -0
  13. package/dist/cjs/dial/dial-sink-service.js.map +1 -0
  14. package/dist/cjs/dial/http.d.ts +40 -0
  15. package/dist/cjs/dial/http.js +172 -0
  16. package/dist/cjs/dial/http.js.map +1 -0
  17. package/dist/cjs/dial/index.d.ts +63 -0
  18. package/dist/cjs/dial/index.js +134 -0
  19. package/dist/cjs/dial/index.js.map +1 -0
  20. package/dist/cjs/dial/origins.d.ts +4 -0
  21. package/dist/cjs/dial/origins.js +36 -0
  22. package/dist/cjs/dial/origins.js.map +1 -0
  23. package/dist/cjs/dial/parse.d.ts +101 -0
  24. package/dist/cjs/dial/parse.js +296 -0
  25. package/dist/cjs/dial/parse.js.map +1 -0
  26. package/dist/cjs/dial/route-provider.d.ts +96 -0
  27. package/dist/cjs/dial/route-provider.js +376 -0
  28. package/dist/cjs/dial/route-provider.js.map +1 -0
  29. package/dist/cjs/dial/ssdp-socket.d.ts +34 -0
  30. package/dist/cjs/dial/ssdp-socket.js +72 -0
  31. package/dist/cjs/dial/ssdp-socket.js.map +1 -0
  32. package/dist/cjs/dial/xml.d.ts +13 -0
  33. package/dist/cjs/dial/xml.js +208 -0
  34. package/dist/cjs/dial/xml.js.map +1 -0
  35. package/dist/cjs/discovery/cast-discovery.d.ts +2 -0
  36. package/dist/cjs/discovery/cast-discovery.js.map +1 -1
  37. package/dist/cjs/discovery/device-cache.d.ts +9 -0
  38. package/dist/cjs/discovery/device-cache.js.map +1 -1
  39. package/dist/cjs/discovery/index.d.ts +1 -0
  40. package/dist/cjs/discovery/index.js +1 -0
  41. package/dist/cjs/discovery/index.js.map +1 -1
  42. package/dist/cjs/discovery/ip-policy.d.ts +20 -0
  43. package/dist/cjs/discovery/ip-policy.js +109 -0
  44. package/dist/cjs/discovery/ip-policy.js.map +1 -0
  45. package/dist/cjs/discovery/udp-socket.d.ts +3 -0
  46. package/dist/cjs/discovery/udp-socket.js +3 -0
  47. package/dist/cjs/discovery/udp-socket.js.map +1 -1
  48. package/dist/cjs/electron/access-code.d.ts +221 -0
  49. package/dist/cjs/electron/access-code.js +586 -0
  50. package/dist/cjs/electron/access-code.js.map +1 -0
  51. package/dist/cjs/electron/app-discovery.d.ts +82 -0
  52. package/dist/cjs/electron/app-discovery.js +219 -0
  53. package/dist/cjs/electron/app-discovery.js.map +1 -0
  54. package/dist/cjs/electron/default-presentation.d.ts +38 -0
  55. package/dist/cjs/electron/default-presentation.js +88 -0
  56. package/dist/cjs/electron/default-presentation.js.map +1 -0
  57. package/dist/cjs/electron/main.d.ts +98 -11
  58. package/dist/cjs/electron/main.js +602 -20
  59. package/dist/cjs/electron/main.js.map +1 -1
  60. package/dist/cjs/electron/manager-api.d.ts +200 -18
  61. package/dist/cjs/electron/manager-api.js +199 -4
  62. package/dist/cjs/electron/manager-api.js.map +1 -1
  63. package/dist/cjs/electron/media-controller.d.ts +79 -0
  64. package/dist/cjs/electron/media-controller.js +251 -0
  65. package/dist/cjs/electron/media-controller.js.map +1 -0
  66. package/dist/cjs/electron/network-monitor.d.ts +61 -0
  67. package/dist/cjs/electron/network-monitor.js +124 -0
  68. package/dist/cjs/electron/network-monitor.js.map +1 -0
  69. package/dist/cjs/electron/preload.js.map +1 -1
  70. package/dist/cjs/electron/presentation-handler.d.ts +39 -4
  71. package/dist/cjs/electron/presentation-handler.js +191 -47
  72. package/dist/cjs/electron/presentation-handler.js.map +1 -1
  73. package/dist/cjs/electron/presentation-source.d.ts +76 -0
  74. package/dist/cjs/electron/presentation-source.js +132 -0
  75. package/dist/cjs/electron/presentation-source.js.map +1 -0
  76. package/dist/cjs/electron/session-service.d.ts +198 -24
  77. package/dist/cjs/electron/session-service.js +630 -248
  78. package/dist/cjs/electron/session-service.js.map +1 -1
  79. package/dist/cjs/electron/session-tracker.d.ts +82 -0
  80. package/dist/cjs/electron/session-tracker.js +225 -0
  81. package/dist/cjs/electron/session-tracker.js.map +1 -0
  82. package/dist/cjs/electron/sink-service.d.ts +246 -0
  83. package/dist/cjs/electron/sink-service.js +606 -0
  84. package/dist/cjs/electron/sink-service.js.map +1 -0
  85. package/dist/cjs/electron/wired-display/controller.d.ts +76 -0
  86. package/dist/cjs/electron/wired-display/controller.js +198 -0
  87. package/dist/cjs/electron/wired-display/controller.js.map +1 -0
  88. package/dist/cjs/electron/wired-display/displays.d.ts +44 -0
  89. package/dist/cjs/electron/wired-display/displays.js +98 -0
  90. package/dist/cjs/electron/wired-display/displays.js.map +1 -0
  91. package/dist/cjs/electron/wired-display/electron-windows.d.ts +111 -0
  92. package/dist/cjs/electron/wired-display/electron-windows.js +306 -0
  93. package/dist/cjs/electron/wired-display/electron-windows.js.map +1 -0
  94. package/dist/cjs/electron/wired-display/index.d.ts +90 -0
  95. package/dist/cjs/electron/wired-display/index.js +115 -0
  96. package/dist/cjs/electron/wired-display/index.js.map +1 -0
  97. package/dist/cjs/electron/wired-display/local-presentation.d.ts +98 -0
  98. package/dist/cjs/electron/wired-display/local-presentation.js +234 -0
  99. package/dist/cjs/electron/wired-display/local-presentation.js.map +1 -0
  100. package/dist/cjs/electron/wired-display/provider.d.ts +112 -0
  101. package/dist/cjs/electron/wired-display/provider.js +202 -0
  102. package/dist/cjs/electron/wired-display/provider.js.map +1 -0
  103. package/dist/cjs/index.d.ts +1 -0
  104. package/dist/cjs/index.js +1 -0
  105. package/dist/cjs/index.js.map +1 -1
  106. package/dist/cjs/mirroring/backend.d.ts +76 -0
  107. package/dist/cjs/mirroring/backend.js +21 -0
  108. package/dist/cjs/mirroring/backend.js.map +1 -0
  109. package/dist/cjs/mirroring/electron/agent-protocol.d.ts +158 -0
  110. package/dist/cjs/mirroring/electron/agent-protocol.js +11 -0
  111. package/dist/cjs/mirroring/electron/agent-protocol.js.map +1 -0
  112. package/dist/cjs/mirroring/electron/agent-source.d.ts +20 -0
  113. package/dist/cjs/mirroring/electron/agent-source.js +621 -0
  114. package/dist/cjs/mirroring/electron/agent-source.js.map +1 -0
  115. package/dist/cjs/mirroring/electron/engine-process.d.ts +87 -0
  116. package/dist/cjs/mirroring/electron/engine-process.js +81 -0
  117. package/dist/cjs/mirroring/electron/engine-process.js.map +1 -0
  118. package/dist/cjs/mirroring/electron/host.d.ts +89 -0
  119. package/dist/cjs/mirroring/electron/host.js +321 -0
  120. package/dist/cjs/mirroring/electron/host.js.map +1 -0
  121. package/dist/cjs/mirroring/electron/port-backend.d.ts +107 -0
  122. package/dist/cjs/mirroring/electron/port-backend.js +446 -0
  123. package/dist/cjs/mirroring/electron/port-backend.js.map +1 -0
  124. package/dist/cjs/mirroring/encoding-support.d.ts +66 -0
  125. package/dist/cjs/mirroring/encoding-support.js +89 -0
  126. package/dist/cjs/mirroring/encoding-support.js.map +1 -0
  127. package/dist/cjs/mirroring/engine.d.ts +16 -0
  128. package/dist/cjs/mirroring/engine.js +78 -0
  129. package/dist/cjs/mirroring/engine.js.map +1 -0
  130. package/dist/cjs/mirroring/mirror-settings.d.ts +101 -0
  131. package/dist/cjs/mirroring/mirror-settings.js +140 -0
  132. package/dist/cjs/mirroring/mirror-settings.js.map +1 -0
  133. package/dist/cjs/mirroring/mirroring-activity.d.ts +207 -0
  134. package/dist/cjs/mirroring/mirroring-activity.js +367 -0
  135. package/dist/cjs/mirroring/mirroring-activity.js.map +1 -0
  136. package/dist/cjs/mirroring/mirroring-manager.d.ts +134 -0
  137. package/dist/cjs/mirroring/mirroring-manager.js +286 -0
  138. package/dist/cjs/mirroring/mirroring-manager.js.map +1 -0
  139. package/dist/cjs/mirroring/protocol/answer.d.ts +87 -0
  140. package/dist/cjs/mirroring/protocol/answer.js +233 -0
  141. package/dist/cjs/mirroring/protocol/answer.js.map +1 -0
  142. package/dist/cjs/mirroring/protocol/constants.d.ts +64 -0
  143. package/dist/cjs/mirroring/protocol/constants.js +70 -0
  144. package/dist/cjs/mirroring/protocol/constants.js.map +1 -0
  145. package/dist/cjs/mirroring/protocol/errors.d.ts +25 -0
  146. package/dist/cjs/mirroring/protocol/errors.js +34 -0
  147. package/dist/cjs/mirroring/protocol/errors.js.map +1 -0
  148. package/dist/cjs/mirroring/protocol/frame-id.d.ts +9 -0
  149. package/dist/cjs/mirroring/protocol/frame-id.js +24 -0
  150. package/dist/cjs/mirroring/protocol/frame-id.js.map +1 -0
  151. package/dist/cjs/mirroring/protocol/messenger.d.ts +42 -0
  152. package/dist/cjs/mirroring/protocol/messenger.js +122 -0
  153. package/dist/cjs/mirroring/protocol/messenger.js.map +1 -0
  154. package/dist/cjs/mirroring/protocol/offer.d.ts +109 -0
  155. package/dist/cjs/mirroring/protocol/offer.js +192 -0
  156. package/dist/cjs/mirroring/protocol/offer.js.map +1 -0
  157. package/dist/cjs/mirroring/protocol/recommendations.d.ts +28 -0
  158. package/dist/cjs/mirroring/protocol/recommendations.js +103 -0
  159. package/dist/cjs/mirroring/protocol/recommendations.js.map +1 -0
  160. package/dist/cjs/mirroring/routing.d.ts +60 -0
  161. package/dist/cjs/mirroring/routing.js +147 -0
  162. package/dist/cjs/mirroring/routing.js.map +1 -0
  163. package/dist/cjs/mirroring/rtcp/ntp.d.ts +27 -0
  164. package/dist/cjs/mirroring/rtcp/ntp.js +62 -0
  165. package/dist/cjs/mirroring/rtcp/ntp.js.map +1 -0
  166. package/dist/cjs/mirroring/rtcp/parser.d.ts +50 -0
  167. package/dist/cjs/mirroring/rtcp/parser.js +270 -0
  168. package/dist/cjs/mirroring/rtcp/parser.js.map +1 -0
  169. package/dist/cjs/mirroring/rtcp/sender-report.d.ts +32 -0
  170. package/dist/cjs/mirroring/rtcp/sender-report.js +56 -0
  171. package/dist/cjs/mirroring/rtcp/sender-report.js.map +1 -0
  172. package/dist/cjs/mirroring/rtcp/wire.d.ts +54 -0
  173. package/dist/cjs/mirroring/rtcp/wire.js +73 -0
  174. package/dist/cjs/mirroring/rtcp/wire.js.map +1 -0
  175. package/dist/cjs/mirroring/rtp/frame-crypto.d.ts +11 -0
  176. package/dist/cjs/mirroring/rtp/frame-crypto.js +39 -0
  177. package/dist/cjs/mirroring/rtp/frame-crypto.js.map +1 -0
  178. package/dist/cjs/mirroring/rtp/frame.d.ts +23 -0
  179. package/dist/cjs/mirroring/rtp/frame.js +3 -0
  180. package/dist/cjs/mirroring/rtp/frame.js.map +1 -0
  181. package/dist/cjs/mirroring/rtp/packetizer.d.ts +27 -0
  182. package/dist/cjs/mirroring/rtp/packetizer.js +92 -0
  183. package/dist/cjs/mirroring/rtp/packetizer.js.map +1 -0
  184. package/dist/cjs/mirroring/sender/audio-sender.d.ts +23 -0
  185. package/dist/cjs/mirroring/sender/audio-sender.js +52 -0
  186. package/dist/cjs/mirroring/sender/audio-sender.js.map +1 -0
  187. package/dist/cjs/mirroring/sender/bandwidth-estimator.d.ts +26 -0
  188. package/dist/cjs/mirroring/sender/bandwidth-estimator.js +107 -0
  189. package/dist/cjs/mirroring/sender/bandwidth-estimator.js.map +1 -0
  190. package/dist/cjs/mirroring/sender/capture-size-oracle.d.ts +121 -0
  191. package/dist/cjs/mirroring/sender/capture-size-oracle.js +440 -0
  192. package/dist/cjs/mirroring/sender/capture-size-oracle.js.map +1 -0
  193. package/dist/cjs/mirroring/sender/frame-sender.d.ts +103 -0
  194. package/dist/cjs/mirroring/sender/frame-sender.js +217 -0
  195. package/dist/cjs/mirroring/sender/frame-sender.js.map +1 -0
  196. package/dist/cjs/mirroring/sender/packet-router.d.ts +74 -0
  197. package/dist/cjs/mirroring/sender/packet-router.js +196 -0
  198. package/dist/cjs/mirroring/sender/packet-router.js.map +1 -0
  199. package/dist/cjs/mirroring/sender/sender-session.d.ts +85 -0
  200. package/dist/cjs/mirroring/sender/sender-session.js +240 -0
  201. package/dist/cjs/mirroring/sender/sender-session.js.map +1 -0
  202. package/dist/cjs/mirroring/sender/sender.d.ts +120 -0
  203. package/dist/cjs/mirroring/sender/sender.js +457 -0
  204. package/dist/cjs/mirroring/sender/sender.js.map +1 -0
  205. package/dist/cjs/mirroring/sender/video-encoder-metrics.d.ts +29 -0
  206. package/dist/cjs/mirroring/sender/video-encoder-metrics.js +64 -0
  207. package/dist/cjs/mirroring/sender/video-encoder-metrics.js.map +1 -0
  208. package/dist/cjs/mirroring/sender/video-sender.d.ts +95 -0
  209. package/dist/cjs/mirroring/sender/video-sender.js +183 -0
  210. package/dist/cjs/mirroring/sender/video-sender.js.map +1 -0
  211. package/dist/cjs/mirroring/session-host.d.ts +185 -0
  212. package/dist/cjs/mirroring/session-host.js +630 -0
  213. package/dist/cjs/mirroring/session-host.js.map +1 -0
  214. package/dist/cjs/mirroring/stats/clock-offset-estimator.d.ts +11 -0
  215. package/dist/cjs/mirroring/stats/clock-offset-estimator.js +123 -0
  216. package/dist/cjs/mirroring/stats/clock-offset-estimator.js.map +1 -0
  217. package/dist/cjs/mirroring/stats/openscreen-stats-client.d.ts +12 -0
  218. package/dist/cjs/mirroring/stats/openscreen-stats-client.js +21 -0
  219. package/dist/cjs/mirroring/stats/openscreen-stats-client.js.map +1 -0
  220. package/dist/cjs/mirroring/stats/sorted-map.d.ts +23 -0
  221. package/dist/cjs/mirroring/stats/sorted-map.js +70 -0
  222. package/dist/cjs/mirroring/stats/sorted-map.js.map +1 -0
  223. package/dist/cjs/mirroring/stats/statistics-analyzer.d.ts +50 -0
  224. package/dist/cjs/mirroring/stats/statistics-analyzer.js +339 -0
  225. package/dist/cjs/mirroring/stats/statistics-analyzer.js.map +1 -0
  226. package/dist/cjs/mirroring/stats/statistics-collector.d.ts +29 -0
  227. package/dist/cjs/mirroring/stats/statistics-collector.js +53 -0
  228. package/dist/cjs/mirroring/stats/statistics-collector.js.map +1 -0
  229. package/dist/cjs/mirroring/stats/statistics-common.d.ts +61 -0
  230. package/dist/cjs/mirroring/stats/statistics-common.js +45 -0
  231. package/dist/cjs/mirroring/stats/statistics-common.js.map +1 -0
  232. package/dist/cjs/mirroring/stats/statistics-dispatcher.d.ts +28 -0
  233. package/dist/cjs/mirroring/stats/statistics-dispatcher.js +104 -0
  234. package/dist/cjs/mirroring/stats/statistics-dispatcher.js.map +1 -0
  235. package/dist/cjs/mirroring/stats/statistics.d.ts +84 -0
  236. package/dist/cjs/mirroring/stats/statistics.js +147 -0
  237. package/dist/cjs/mirroring/stats/statistics.js.map +1 -0
  238. package/dist/cjs/mirroring/transport/udp-environment.d.ts +40 -0
  239. package/dist/cjs/mirroring/transport/udp-environment.js +97 -0
  240. package/dist/cjs/mirroring/transport/udp-environment.js.map +1 -0
  241. package/dist/cjs/polyfill/bridge-types.d.ts +11 -0
  242. package/dist/cjs/polyfill/presentation-receiver.d.ts +12 -0
  243. package/dist/cjs/polyfill/presentation-receiver.js +369 -0
  244. package/dist/cjs/polyfill/presentation-receiver.js.map +1 -0
  245. package/dist/cjs/polyfill/presentation-standin.js +157 -15
  246. package/dist/cjs/polyfill/presentation-standin.js.map +1 -1
  247. package/dist/cjs/protocol/framing.d.ts +1 -1
  248. package/dist/cjs/protocol/framing.js +1 -1
  249. package/dist/cjs/protocol/framing.js.map +1 -1
  250. package/dist/cli.d.ts +2 -0
  251. package/dist/cli.js +56 -0
  252. package/dist/cli.js.map +1 -0
  253. package/dist/client/auth/build-time.js +1 -1
  254. package/dist/client/auth/cast-auth.d.ts +2 -0
  255. package/dist/client/auth/cast-auth.js.map +1 -1
  256. package/dist/dial/dial-registry.d.ts +104 -0
  257. package/dist/dial/dial-registry.js +297 -0
  258. package/dist/dial/dial-registry.js.map +1 -0
  259. package/dist/dial/dial-sink-service.d.ts +108 -0
  260. package/dist/dial/dial-sink-service.js +310 -0
  261. package/dist/dial/dial-sink-service.js.map +1 -0
  262. package/dist/dial/http.d.ts +40 -0
  263. package/dist/dial/http.js +165 -0
  264. package/dist/dial/http.js.map +1 -0
  265. package/dist/dial/index.d.ts +63 -0
  266. package/dist/dial/index.js +115 -0
  267. package/dist/dial/index.js.map +1 -0
  268. package/dist/dial/origins.d.ts +4 -0
  269. package/dist/dial/origins.js +32 -0
  270. package/dist/dial/origins.js.map +1 -0
  271. package/dist/dial/parse.d.ts +101 -0
  272. package/dist/dial/parse.js +281 -0
  273. package/dist/dial/parse.js.map +1 -0
  274. package/dist/dial/route-provider.d.ts +96 -0
  275. package/dist/dial/route-provider.js +369 -0
  276. package/dist/dial/route-provider.js.map +1 -0
  277. package/dist/dial/ssdp-socket.d.ts +34 -0
  278. package/dist/dial/ssdp-socket.js +65 -0
  279. package/dist/dial/ssdp-socket.js.map +1 -0
  280. package/dist/dial/xml.d.ts +13 -0
  281. package/dist/dial/xml.js +204 -0
  282. package/dist/dial/xml.js.map +1 -0
  283. package/dist/dial-test/cli-main.d.ts +17 -0
  284. package/dist/dial-test/cli-main.js +130 -0
  285. package/dist/dial-test/cli-main.js.map +1 -0
  286. package/dist/dial-test/report.d.ts +55 -0
  287. package/dist/dial-test/report.js +77 -0
  288. package/dist/dial-test/report.js.map +1 -0
  289. package/dist/dial-test/runner.d.ts +42 -0
  290. package/dist/dial-test/runner.js +566 -0
  291. package/dist/dial-test/runner.js.map +1 -0
  292. package/dist/dial-test/scrub.d.ts +14 -0
  293. package/dist/dial-test/scrub.js +73 -0
  294. package/dist/dial-test/scrub.js.map +1 -0
  295. package/dist/discovery/cast-discovery.d.ts +2 -0
  296. package/dist/discovery/cast-discovery.js.map +1 -1
  297. package/dist/discovery/device-cache.d.ts +9 -0
  298. package/dist/discovery/device-cache.js.map +1 -1
  299. package/dist/discovery/index.d.ts +1 -0
  300. package/dist/discovery/index.js +1 -0
  301. package/dist/discovery/index.js.map +1 -1
  302. package/dist/discovery/ip-policy.d.ts +20 -0
  303. package/dist/discovery/ip-policy.js +103 -0
  304. package/dist/discovery/ip-policy.js.map +1 -0
  305. package/dist/discovery/udp-socket.d.ts +3 -0
  306. package/dist/discovery/udp-socket.js +3 -0
  307. package/dist/discovery/udp-socket.js.map +1 -1
  308. package/dist/electron/access-code.d.ts +221 -0
  309. package/dist/electron/access-code.js +577 -0
  310. package/dist/electron/access-code.js.map +1 -0
  311. package/dist/electron/app-discovery.d.ts +82 -0
  312. package/dist/electron/app-discovery.js +215 -0
  313. package/dist/electron/app-discovery.js.map +1 -0
  314. package/dist/electron/default-presentation.d.ts +38 -0
  315. package/dist/electron/default-presentation.js +83 -0
  316. package/dist/electron/default-presentation.js.map +1 -0
  317. package/dist/electron/main.d.ts +98 -11
  318. package/dist/electron/main.js +597 -21
  319. package/dist/electron/main.js.map +1 -1
  320. package/dist/electron/manager-api.d.ts +200 -18
  321. package/dist/electron/manager-api.js +196 -4
  322. package/dist/electron/manager-api.js.map +1 -1
  323. package/dist/electron/media-controller.d.ts +79 -0
  324. package/dist/electron/media-controller.js +248 -0
  325. package/dist/electron/media-controller.js.map +1 -0
  326. package/dist/electron/network-monitor.d.ts +61 -0
  327. package/dist/electron/network-monitor.js +117 -0
  328. package/dist/electron/network-monitor.js.map +1 -0
  329. package/dist/electron/preload.js.map +1 -1
  330. package/dist/electron/presentation-handler.d.ts +39 -4
  331. package/dist/electron/presentation-handler.js +192 -48
  332. package/dist/electron/presentation-handler.js.map +1 -1
  333. package/dist/electron/presentation-source.d.ts +76 -0
  334. package/dist/electron/presentation-source.js +125 -0
  335. package/dist/electron/presentation-source.js.map +1 -0
  336. package/dist/electron/session-service.d.ts +198 -24
  337. package/dist/electron/session-service.js +629 -248
  338. package/dist/electron/session-service.js.map +1 -1
  339. package/dist/electron/session-tracker.d.ts +82 -0
  340. package/dist/electron/session-tracker.js +219 -0
  341. package/dist/electron/session-tracker.js.map +1 -0
  342. package/dist/electron/sink-service.d.ts +246 -0
  343. package/dist/electron/sink-service.js +602 -0
  344. package/dist/electron/sink-service.js.map +1 -0
  345. package/dist/electron/wired-display/controller.d.ts +76 -0
  346. package/dist/electron/wired-display/controller.js +194 -0
  347. package/dist/electron/wired-display/controller.js.map +1 -0
  348. package/dist/electron/wired-display/displays.d.ts +44 -0
  349. package/dist/electron/wired-display/displays.js +91 -0
  350. package/dist/electron/wired-display/displays.js.map +1 -0
  351. package/dist/electron/wired-display/electron-windows.d.ts +111 -0
  352. package/dist/electron/wired-display/electron-windows.js +301 -0
  353. package/dist/electron/wired-display/electron-windows.js.map +1 -0
  354. package/dist/electron/wired-display/index.d.ts +90 -0
  355. package/dist/electron/wired-display/index.js +99 -0
  356. package/dist/electron/wired-display/index.js.map +1 -0
  357. package/dist/electron/wired-display/local-presentation.d.ts +98 -0
  358. package/dist/electron/wired-display/local-presentation.js +228 -0
  359. package/dist/electron/wired-display/local-presentation.js.map +1 -0
  360. package/dist/electron/wired-display/provider.d.ts +112 -0
  361. package/dist/electron/wired-display/provider.js +197 -0
  362. package/dist/electron/wired-display/provider.js.map +1 -0
  363. package/dist/index.d.ts +1 -0
  364. package/dist/index.js +1 -0
  365. package/dist/index.js.map +1 -1
  366. package/dist/mirroring/backend.d.ts +76 -0
  367. package/dist/mirroring/backend.js +18 -0
  368. package/dist/mirroring/backend.js.map +1 -0
  369. package/dist/mirroring/electron/agent-protocol.d.ts +158 -0
  370. package/dist/mirroring/electron/agent-protocol.js +10 -0
  371. package/dist/mirroring/electron/agent-protocol.js.map +1 -0
  372. package/dist/mirroring/electron/agent-source.d.ts +20 -0
  373. package/dist/mirroring/electron/agent-source.js +618 -0
  374. package/dist/mirroring/electron/agent-source.js.map +1 -0
  375. package/dist/mirroring/electron/engine-process.d.ts +87 -0
  376. package/dist/mirroring/electron/engine-process.js +78 -0
  377. package/dist/mirroring/electron/engine-process.js.map +1 -0
  378. package/dist/mirroring/electron/host.d.ts +89 -0
  379. package/dist/mirroring/electron/host.js +318 -0
  380. package/dist/mirroring/electron/host.js.map +1 -0
  381. package/dist/mirroring/electron/port-backend.d.ts +107 -0
  382. package/dist/mirroring/electron/port-backend.js +441 -0
  383. package/dist/mirroring/electron/port-backend.js.map +1 -0
  384. package/dist/mirroring/encoding-support.d.ts +66 -0
  385. package/dist/mirroring/encoding-support.js +81 -0
  386. package/dist/mirroring/encoding-support.js.map +1 -0
  387. package/dist/mirroring/engine.d.ts +16 -0
  388. package/dist/mirroring/engine.js +75 -0
  389. package/dist/mirroring/engine.js.map +1 -0
  390. package/dist/mirroring/mirror-settings.d.ts +101 -0
  391. package/dist/mirroring/mirror-settings.js +134 -0
  392. package/dist/mirroring/mirror-settings.js.map +1 -0
  393. package/dist/mirroring/mirroring-activity.d.ts +207 -0
  394. package/dist/mirroring/mirroring-activity.js +362 -0
  395. package/dist/mirroring/mirroring-activity.js.map +1 -0
  396. package/dist/mirroring/mirroring-manager.d.ts +134 -0
  397. package/dist/mirroring/mirroring-manager.js +281 -0
  398. package/dist/mirroring/mirroring-manager.js.map +1 -0
  399. package/dist/mirroring/protocol/answer.d.ts +87 -0
  400. package/dist/mirroring/protocol/answer.js +226 -0
  401. package/dist/mirroring/protocol/answer.js.map +1 -0
  402. package/dist/mirroring/protocol/constants.d.ts +64 -0
  403. package/dist/mirroring/protocol/constants.js +66 -0
  404. package/dist/mirroring/protocol/constants.js.map +1 -0
  405. package/dist/mirroring/protocol/errors.d.ts +25 -0
  406. package/dist/mirroring/protocol/errors.js +29 -0
  407. package/dist/mirroring/protocol/errors.js.map +1 -0
  408. package/dist/mirroring/protocol/frame-id.d.ts +9 -0
  409. package/dist/mirroring/protocol/frame-id.js +20 -0
  410. package/dist/mirroring/protocol/frame-id.js.map +1 -0
  411. package/dist/mirroring/protocol/messenger.d.ts +42 -0
  412. package/dist/mirroring/protocol/messenger.js +118 -0
  413. package/dist/mirroring/protocol/messenger.js.map +1 -0
  414. package/dist/mirroring/protocol/offer.d.ts +109 -0
  415. package/dist/mirroring/protocol/offer.js +176 -0
  416. package/dist/mirroring/protocol/offer.js.map +1 -0
  417. package/dist/mirroring/protocol/recommendations.d.ts +28 -0
  418. package/dist/mirroring/protocol/recommendations.js +99 -0
  419. package/dist/mirroring/protocol/recommendations.js.map +1 -0
  420. package/dist/mirroring/routing.d.ts +60 -0
  421. package/dist/mirroring/routing.js +130 -0
  422. package/dist/mirroring/routing.js.map +1 -0
  423. package/dist/mirroring/rtcp/ntp.d.ts +27 -0
  424. package/dist/mirroring/rtcp/ntp.js +57 -0
  425. package/dist/mirroring/rtcp/ntp.js.map +1 -0
  426. package/dist/mirroring/rtcp/parser.d.ts +50 -0
  427. package/dist/mirroring/rtcp/parser.js +265 -0
  428. package/dist/mirroring/rtcp/parser.js.map +1 -0
  429. package/dist/mirroring/rtcp/sender-report.d.ts +32 -0
  430. package/dist/mirroring/rtcp/sender-report.js +51 -0
  431. package/dist/mirroring/rtcp/sender-report.js.map +1 -0
  432. package/dist/mirroring/rtcp/wire.d.ts +54 -0
  433. package/dist/mirroring/rtcp/wire.js +68 -0
  434. package/dist/mirroring/rtcp/wire.js.map +1 -0
  435. package/dist/mirroring/rtp/frame-crypto.d.ts +11 -0
  436. package/dist/mirroring/rtp/frame-crypto.js +35 -0
  437. package/dist/mirroring/rtp/frame-crypto.js.map +1 -0
  438. package/dist/mirroring/rtp/frame.d.ts +23 -0
  439. package/dist/mirroring/rtp/frame.js +2 -0
  440. package/dist/mirroring/rtp/frame.js.map +1 -0
  441. package/dist/mirroring/rtp/packetizer.d.ts +27 -0
  442. package/dist/mirroring/rtp/packetizer.js +88 -0
  443. package/dist/mirroring/rtp/packetizer.js.map +1 -0
  444. package/dist/mirroring/sender/audio-sender.d.ts +23 -0
  445. package/dist/mirroring/sender/audio-sender.js +54 -0
  446. package/dist/mirroring/sender/audio-sender.js.map +1 -0
  447. package/dist/mirroring/sender/bandwidth-estimator.d.ts +26 -0
  448. package/dist/mirroring/sender/bandwidth-estimator.js +103 -0
  449. package/dist/mirroring/sender/bandwidth-estimator.js.map +1 -0
  450. package/dist/mirroring/sender/capture-size-oracle.d.ts +121 -0
  451. package/dist/mirroring/sender/capture-size-oracle.js +433 -0
  452. package/dist/mirroring/sender/capture-size-oracle.js.map +1 -0
  453. package/dist/mirroring/sender/frame-sender.d.ts +103 -0
  454. package/dist/mirroring/sender/frame-sender.js +212 -0
  455. package/dist/mirroring/sender/frame-sender.js.map +1 -0
  456. package/dist/mirroring/sender/packet-router.d.ts +74 -0
  457. package/dist/mirroring/sender/packet-router.js +191 -0
  458. package/dist/mirroring/sender/packet-router.js.map +1 -0
  459. package/dist/mirroring/sender/sender-session.d.ts +85 -0
  460. package/dist/mirroring/sender/sender-session.js +235 -0
  461. package/dist/mirroring/sender/sender-session.js.map +1 -0
  462. package/dist/mirroring/sender/sender.d.ts +120 -0
  463. package/dist/mirroring/sender/sender.js +452 -0
  464. package/dist/mirroring/sender/sender.js.map +1 -0
  465. package/dist/mirroring/sender/video-encoder-metrics.d.ts +29 -0
  466. package/dist/mirroring/sender/video-encoder-metrics.js +58 -0
  467. package/dist/mirroring/sender/video-encoder-metrics.js.map +1 -0
  468. package/dist/mirroring/sender/video-sender.d.ts +95 -0
  469. package/dist/mirroring/sender/video-sender.js +190 -0
  470. package/dist/mirroring/sender/video-sender.js.map +1 -0
  471. package/dist/mirroring/session-host.d.ts +185 -0
  472. package/dist/mirroring/session-host.js +625 -0
  473. package/dist/mirroring/session-host.js.map +1 -0
  474. package/dist/mirroring/stats/clock-offset-estimator.d.ts +11 -0
  475. package/dist/mirroring/stats/clock-offset-estimator.js +120 -0
  476. package/dist/mirroring/stats/clock-offset-estimator.js.map +1 -0
  477. package/dist/mirroring/stats/openscreen-stats-client.d.ts +12 -0
  478. package/dist/mirroring/stats/openscreen-stats-client.js +17 -0
  479. package/dist/mirroring/stats/openscreen-stats-client.js.map +1 -0
  480. package/dist/mirroring/stats/sorted-map.d.ts +23 -0
  481. package/dist/mirroring/stats/sorted-map.js +66 -0
  482. package/dist/mirroring/stats/sorted-map.js.map +1 -0
  483. package/dist/mirroring/stats/statistics-analyzer.d.ts +50 -0
  484. package/dist/mirroring/stats/statistics-analyzer.js +335 -0
  485. package/dist/mirroring/stats/statistics-analyzer.js.map +1 -0
  486. package/dist/mirroring/stats/statistics-collector.d.ts +29 -0
  487. package/dist/mirroring/stats/statistics-collector.js +49 -0
  488. package/dist/mirroring/stats/statistics-collector.js.map +1 -0
  489. package/dist/mirroring/stats/statistics-common.d.ts +61 -0
  490. package/dist/mirroring/stats/statistics-common.js +39 -0
  491. package/dist/mirroring/stats/statistics-common.js.map +1 -0
  492. package/dist/mirroring/stats/statistics-dispatcher.d.ts +28 -0
  493. package/dist/mirroring/stats/statistics-dispatcher.js +100 -0
  494. package/dist/mirroring/stats/statistics-dispatcher.js.map +1 -0
  495. package/dist/mirroring/stats/statistics.d.ts +84 -0
  496. package/dist/mirroring/stats/statistics.js +141 -0
  497. package/dist/mirroring/stats/statistics.js.map +1 -0
  498. package/dist/mirroring/transport/udp-environment.d.ts +40 -0
  499. package/dist/mirroring/transport/udp-environment.js +93 -0
  500. package/dist/mirroring/transport/udp-environment.js.map +1 -0
  501. package/dist/polyfill/bridge-types.d.ts +11 -0
  502. package/dist/polyfill/presentation-receiver.d.ts +12 -0
  503. package/dist/polyfill/presentation-receiver.js +366 -0
  504. package/dist/polyfill/presentation-receiver.js.map +1 -0
  505. package/dist/polyfill/presentation-standin.js +157 -15
  506. package/dist/polyfill/presentation-standin.js.map +1 -1
  507. package/dist/protocol/framing.d.ts +1 -1
  508. package/dist/protocol/framing.js +1 -1
  509. package/dist/protocol/framing.js.map +1 -1
  510. package/docs/API.md +724 -0
  511. package/docs/ARCHITECTURE.md +242 -0
  512. package/docs/CHROMIUM-MAP.md +176 -0
  513. package/docs/DESIGN.md +1189 -0
  514. package/docs/FAQ.md +123 -0
  515. package/docs/GETTING-STARTED.md +248 -0
  516. package/docs/MAIN-API.md +524 -0
  517. package/docs/TROUBLESHOOTING.md +283 -0
  518. package/docs/guides/audio-and-groups.md +75 -0
  519. package/docs/guides/custom-receivers.md +109 -0
  520. package/docs/guides/device-authentication.md +145 -0
  521. package/docs/guides/device-picker.md +176 -0
  522. package/docs/guides/index.md +17 -0
  523. package/docs/guides/low-level-client.md +103 -0
  524. package/docs/guides/restart-rejoin.md +172 -0
  525. package/docs/guides/testing.md +162 -0
  526. package/docs/guides/windows-and-iframes.md +116 -0
  527. package/docs/readme/badges/dependencies.svg +1 -0
  528. package/docs/readme/badges/electron.svg +1 -0
  529. package/docs/readme/badges/license.svg +1 -0
  530. package/docs/readme/badges/node.svg +1 -0
  531. package/docs/readme/board.jpg +0 -0
  532. package/docs/readme/hero-dark.jpg +0 -0
  533. package/docs/readme/hero-light.jpg +0 -0
  534. package/docs/readme/nosignal.jpg +0 -0
  535. package/docs/readme/parity.jpg +0 -0
  536. package/docs/readme/trace.svg +22 -0
  537. package/package.json +21 -5
  538. package/src/cli.ts +57 -0
  539. package/src/client/auth/cast-auth.ts +2 -0
  540. package/src/dial/dial-registry.ts +316 -0
  541. package/src/dial/dial-sink-service.ts +343 -0
  542. package/src/dial/http.ts +200 -0
  543. package/src/dial/index.ts +135 -0
  544. package/src/dial/origins.ts +31 -0
  545. package/src/dial/parse.ts +319 -0
  546. package/src/dial/route-provider.ts +429 -0
  547. package/src/dial/ssdp-socket.ts +79 -0
  548. package/src/dial/xml.ts +180 -0
  549. package/src/dial-test/cli-main.ts +146 -0
  550. package/src/dial-test/report.ts +109 -0
  551. package/src/dial-test/runner.ts +615 -0
  552. package/src/dial-test/scrub.ts +74 -0
  553. package/src/discovery/cast-discovery.ts +2 -0
  554. package/src/discovery/device-cache.ts +5 -0
  555. package/src/discovery/index.ts +1 -0
  556. package/src/discovery/ip-policy.ts +97 -0
  557. package/src/discovery/udp-socket.ts +3 -0
  558. package/src/electron/access-code.ts +681 -0
  559. package/src/electron/app-discovery.ts +244 -0
  560. package/src/electron/default-presentation.ts +104 -0
  561. package/src/electron/main.ts +664 -29
  562. package/src/electron/manager-api.ts +367 -15
  563. package/src/electron/media-controller.ts +313 -0
  564. package/src/electron/network-monitor.ts +140 -0
  565. package/src/electron/preload.ts +1 -1
  566. package/src/electron/presentation-handler.ts +195 -48
  567. package/src/electron/presentation-source.ts +155 -0
  568. package/src/electron/session-service.ts +693 -238
  569. package/src/electron/session-tracker.ts +248 -0
  570. package/src/electron/sink-service.ts +726 -0
  571. package/src/electron/wired-display/controller.ts +212 -0
  572. package/src/electron/wired-display/displays.ts +107 -0
  573. package/src/electron/wired-display/electron-windows.ts +386 -0
  574. package/src/electron/wired-display/index.ts +181 -0
  575. package/src/electron/wired-display/local-presentation.ts +286 -0
  576. package/src/electron/wired-display/provider.ts +276 -0
  577. package/src/index.ts +1 -0
  578. package/src/mirroring/backend.ts +103 -0
  579. package/src/mirroring/electron/agent-protocol.ts +84 -0
  580. package/src/mirroring/electron/agent-source.ts +619 -0
  581. package/src/mirroring/electron/engine-process.ts +131 -0
  582. package/src/mirroring/electron/host.ts +361 -0
  583. package/src/mirroring/electron/port-backend.ts +466 -0
  584. package/src/mirroring/encoding-support.ts +146 -0
  585. package/src/mirroring/engine.ts +91 -0
  586. package/src/mirroring/mirror-settings.ts +174 -0
  587. package/src/mirroring/mirroring-activity.ts +466 -0
  588. package/src/mirroring/mirroring-manager.ts +342 -0
  589. package/src/mirroring/protocol/answer.ts +285 -0
  590. package/src/mirroring/protocol/constants.ts +75 -0
  591. package/src/mirroring/protocol/errors.ts +36 -0
  592. package/src/mirroring/protocol/frame-id.ts +20 -0
  593. package/src/mirroring/protocol/messenger.ts +128 -0
  594. package/src/mirroring/protocol/offer.ts +275 -0
  595. package/src/mirroring/protocol/recommendations.ts +135 -0
  596. package/src/mirroring/routing.ts +160 -0
  597. package/src/mirroring/rtcp/ntp.ts +61 -0
  598. package/src/mirroring/rtcp/parser.ts +292 -0
  599. package/src/mirroring/rtcp/sender-report.ts +88 -0
  600. package/src/mirroring/rtcp/wire.ts +76 -0
  601. package/src/mirroring/rtp/frame-crypto.ts +38 -0
  602. package/src/mirroring/rtp/frame.ts +25 -0
  603. package/src/mirroring/rtp/packetizer.ts +95 -0
  604. package/src/mirroring/sender/audio-sender.ts +59 -0
  605. package/src/mirroring/sender/bandwidth-estimator.ts +111 -0
  606. package/src/mirroring/sender/capture-size-oracle.ts +476 -0
  607. package/src/mirroring/sender/frame-sender.ts +293 -0
  608. package/src/mirroring/sender/packet-router.ts +228 -0
  609. package/src/mirroring/sender/sender-session.ts +306 -0
  610. package/src/mirroring/sender/sender.ts +497 -0
  611. package/src/mirroring/sender/video-encoder-metrics.ts +64 -0
  612. package/src/mirroring/sender/video-sender.ts +243 -0
  613. package/src/mirroring/session-host.ts +725 -0
  614. package/src/mirroring/stats/clock-offset-estimator.ts +139 -0
  615. package/src/mirroring/stats/openscreen-stats-client.ts +19 -0
  616. package/src/mirroring/stats/sorted-map.ts +68 -0
  617. package/src/mirroring/stats/statistics-analyzer.ts +388 -0
  618. package/src/mirroring/stats/statistics-collector.ts +69 -0
  619. package/src/mirroring/stats/statistics-common.ts +112 -0
  620. package/src/mirroring/stats/statistics-dispatcher.ts +133 -0
  621. package/src/mirroring/stats/statistics.ts +170 -0
  622. package/src/mirroring/transport/udp-environment.ts +100 -0
  623. package/src/polyfill/bridge-types.ts +11 -0
  624. package/src/polyfill/presentation-receiver.ts +350 -0
  625. package/src/polyfill/presentation-standin.ts +147 -15
  626. package/src/protocol/framing.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,285 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0-next.1 (prerelease)
4
+
5
+ A prerelease of 0.5.0 on the npm `next` tag: install it with `npm i electron-cast@next` (`npm i electron-cast`
6
+ still installs 0.4.0).
7
+
8
+ This release brings electron-cast's main process in line with Chrome's Media Router: devices are tracked over kept-open
9
+ channels, the sessions on them are followed whoever started them, the app can cast and control media from its own
10
+ UI, DIAL devices are found and cast to next to Cast devices, a page can present on another screen (a wired
11
+ display) with the Presentation Receiver API on the other end, and the app can mirror a tab or the desktop. Each rule names the Chromium code it follows ([docs/CHROMIUM-MAP.md](docs/CHROMIUM-MAP.md)). `mode: "chromecast"`
12
+ is frozen and behaves as before for pages; it shares the device list.
13
+
14
+ ### Highlights
15
+
16
+ - **Tab and desktop mirroring, tested on a Chromecast Ultra and a Nest Hub Max.** `createCastManager({ mirroring })` enables
17
+ `startCasting(sinkId, { castMode: "tab_mirror", webContentsId })` and
18
+ `startCasting(sinkId, { castMode: "desktop_mirror", desktopSourceId, withAudio })` in the main process, Chrome's `TAB_MIRROR` and `DESKTOP_MIRROR` cast modes, with `castMode` and `withAudio` filters on
19
+ `registerMediaSinksObserver`. `startCasting` is one method for the three modes (`StartCastingOptions`, a union on
20
+ `castMode`; `MediaCastMode` gains the two mirroring modes). It is a TypeScript port of Chrome's Cast Streaming sender
21
+ (openscreen's sender session, Chromium's frame sender policy and Mirroring Service host, and the MirroringActivity
22
+ routing): OFFER/ANSWER, VP8, VP9, H.264 in hardware and Opus, AES encryption, RTCP, NACK retransmission and bitrate adaptation.
23
+ The video encoder is set up as Chrome's `MediaVideoEncoderWrapper` sets it up (a constant bitrate, the screen content
24
+ hint), and frame drops are logged by reason.
25
+ Capture and WebCodecs encoding run in a hidden window; the sender runs in a utility process per route; the session
26
+ runs on the device's one kept-open channel. A mirrored tab is muted locally while it is cast (Chrome's muter);
27
+ desktop audio follows Chrome per platform (local playback keeps going on Windows, `kCastDesktopMirroringKeepLocalAudio`,
28
+ and is muted elsewhere). No new dependencies. Tested on Windows to a Chromecast Ultra (1080p, tab and desktop) and a
29
+ Nest Hub Max (720p): at 720p frames reach the device in about 30 ms with none late; on the Ultra, video lag at 1080p
30
+ is under investigation. Tab mirroring sends Opus and VP8 in software, with the audio in sync and only on the TV;
31
+ desktop mirroring sends the picture and system audio and keeps local audio on Windows. Not tested on Linux or macOS. Desktop mirroring on macOS is untested on a real Mac; CI covers it with video only on Electron 40+. Not ported: remoting (Electron has no hook
32
+ for it, see [DESIGN.md](docs/DESIGN.md#media-remoting-capabilities-only-the-renderer-side-is-not-reachable)). Like Chrome, a mirroring session sends `GET_CAPABILITIES`
33
+ once after the first negotiation and keeps the receiver's remoting capabilities. Tested on a Nest Hub Max: it answers
34
+ error 10106 "Remoting is not supported" and mirroring goes on.
35
+ - **Wired displays, as Chrome's `WiredDisplayMediaRouteProvider` has them, tested on a second monitor** (Windows, a
36
+ 1080x1920 portrait display). New `wiredDisplay` option on `createCastManager` (presentation mode): other screens are presentation sinks (`wired_display_<id>`, "Display N"). A
37
+ `PresentationRequest` whose URL is https (not the legacy Cast URL) or http on localhost can start on a display: the
38
+ page opens fullscreen in a receiver window that has its own in-memory session (cleared and reused, not one per
39
+ presentation), no menu or developer tools, no permissions except fullscreen, and ends the presentation if it
40
+ navigates away. The receiver is sandboxed as Chrome's is (`kPresentationReceiverSandboxFlags`: no modals, popups or
41
+ top-level navigation) by a `Content-Security-Policy: sandbox` header on every receiver document, so an iframe's
42
+ `alert()` is refused too. A display connection starts `connecting` and becomes `connected` when the receiver page is
43
+ ready, as Blink's does.
44
+ - The receiver page gets `navigator.presentation.receiver` (`connectionList`, `connectionavailable`, `send`, `close`,
45
+ `terminate`), and the controller can `reconnect(id)`. Closing the window, removing the display or `terminate()`
46
+ ends the presentation for every controller; a controller that goes away only leaves it.
47
+ - The display a page is on is left out of the picker by default, found with the new `BrowserWindow` option and
48
+ `screen.getDisplayMatching`, and `request.observeSinks` follows the window as it moves (`displayOf` overrides it).
49
+ - A request that lists both a Cast (or `cast-dial:`) URL and a page URL is one picker, as Chrome's dialog lists both
50
+ kinds of sink: `selectDevice` gets `request.displays` and may answer `{ display }` (new type `DisplayChoice`), and the
51
+ request starts on the sink it returns. Its `getAvailability()` is true when either kind has a sink.
52
+ - New exports: `createReceiverWindows` (the Electron `BrowserWindow` part, taking `BrowserWindow`, `session`,
53
+ `ipcMain` and a folder for the generated receiver preload; calling it twice on one `ipcMain` and channel throws),
54
+ the display rules (`isWiredDisplaySource`, `availableDisplays`, `wiredDisplaySinks`), and `manager.wiredDisplay`
55
+ (sinks and routes observers, `terminateRoute`). `mode: "chromecast"` is unchanged.
56
+ - **DIAL, as Chrome's Media Router does it (presentation mode).** DIAL discovery and device descriptions are tested on
57
+ real Chromecasts (1st gen, Ultra); launching an app over DIAL needs a DIAL-only TV and is untested. electron-cast now
58
+ discovers DIAL devices by SSDP and
59
+ serves the `cast-dial:` sources that Google's SDK adds to a request when the page passes a `dialRequest`
60
+ (`chrome.cast.DialRequest`, as YouTube's web app does for non-Cast TVs). Each rule follows a Chromium function,
61
+ cited in [docs/DESIGN.md](docs/DESIGN.md#dial-srcdial): an M-SEARCH on every IPv4 interface (four searches a second
62
+ apart, every 120 s), the UPnP device description and the `Application-URL` header (both only for private addresses
63
+ that equal the sender's), app info for the app a page asks about, and a sink per device. A page sees availability
64
+ per app (only to the origins Chrome allows for that app) through the same observation as its Cast URL, the picker
65
+ offers DIAL sinks that have the app next to the Cast devices that have theirs, and starting one runs the SDK's
66
+ `custom_dial_launch` round trip, an HTTP launch with the SDK's launch parameter, and a stop by `DELETE` of the run
67
+ URL. A device that is also a Cast sink (its UDN is the Cast id, and its channel is open) is shown as a Cast device
68
+ only, as in Chrome. On by default, as in Chrome; `dial: false` on `createCastManager` turns it off (SSDP and the
69
+ HTTP requests to devices stop entirely). A custom `discovery` turns it off unless `dial` is given.
70
+ - A DIAL sink that is a Cast sink too is removed, as Chrome removes it, and only DIAL discovery adds it back (not
71
+ the Cast sink going away).
72
+ - Differences from Chrome: requests have timeouts (Chrome sets none). A DIAL route has no volume or media control,
73
+ as in Chrome (`BindMediaController` is not implemented there).
74
+ - **A DIAL device is tried as a Cast device**, as Chrome's `CastMediaSinkServiceImpl` does
75
+ (`OnSinkAddedOrUpdated`, `TryConnectDialDiscoveredSink`, `CreateCastSinkFromDialSink`): when a DIAL sink is new or
76
+ changed, and on `discoverSinksNow()`, a Cast channel is opened to its address on port 8009. If it opens and the device
77
+ authenticates, the device is a Cast sink (id the sink's UUID, its friendly name and model, audio and video, or audio
78
+ only for an audio-only certificate) and the DIAL sink is removed, as above. It is skipped when a Cast sink has that id or that
79
+ address. Every failed attempt is counted per device; at ten (`kMaxDialSinkFailureCount`) the device is taken for a
80
+ non-Cast device and not tried again, until it is opened from mDNS or the network changes.
81
+ - DIAL discovery errors (no interface, a socket that fails to bind or send) are logged through `dial.log` and never
82
+ thrown; `start()` works with no network. Nothing is asked of a device for an app the page's origin may not see,
83
+ the monitored apps are bounded, stopping aborts requests in flight (a route terminated mid-launch cancels its
84
+ POST), and a `start()` without an earlier availability watch waits (up to 5 s) for the devices' app answers.
85
+ - API: `MediaSink` and `MediaRoute` gain `providerId` (`"cast"` or `"dial"`), `SinkIconType` gains `"generic"`, and
86
+ `CastDevice` gains an optional `dial` field that marks a DIAL sink. The sinks observer without a query also
87
+ reports DIAL sinks (they have no capabilities, so a `capabilities` query never does, and a `presentationUrls` query
88
+ matches them for its `cast-dial:` URLs); `manager.devices()` still lists Cast devices only. `selectDevice` can be handed a DIAL
89
+ device when the request carries a `cast-dial:` URL: return it like any other and the manager does the rest (do not
90
+ connect to it yourself). `getMediaController` on a DIAL route throws `route_not_found`. The SDK canary no longer
91
+ lists the DIAL messages and `cast-dial:` as unhandled.
92
+ - New options and methods for the device list: `sinks` (`openDelayMaxMs`, `reportDelayMs`, `retry`, `allowAllIps`,
93
+ `dynamicTimeoutDeltaMs`) on `createCastManager` and `CastSessionService`, each a Chrome setting (there is no cap or
94
+ off switch, because Chrome has none); `CastManager.discoverSinksNow()` and `CastManager.settled()` (with
95
+ `{ retries: true }`); the type `ChannelParams`.
96
+ - `isPubliclyRoutable`, `isLoopback`, `isCastAddressAllowed` and `parseIpBytes` are exported from the discovery layer
97
+ (ports of `net::IPAddress`). `APP_AVAILABILITY_REFRESH_MS` is exported.
98
+ - **Access code casting: devices can be added by address, as Chrome's access code casting adds the device a code
99
+ resolves to.** `manager.addSinkByAddress({ id, name, capabilities, ipV4Address, port })` opens a channel to a device the app knows the
100
+ address of, lists it like a discovered one (the picker, availability for pages, the sinks observers) and remembers it,
101
+ with Chrome's checks, quick open parameters (2 s connect, 3 attempts 1 s apart) and expiry: it stays for
102
+ `accessCode.deviceDuration` seconds (default 0) plus 20 s, a device a page is casting to stays until the cast ends, and a
103
+ network change removes it and brings the remembered ones back. It is off
104
+ unless `createCastManager({ accessCode: { enabled: true } })`, as Chrome's `AccessCodeCastEnabled` policy is. Turning a
105
+ typed code into an address is a private Google service that needs Chrome's sign-in, so it is not part of electron-cast;
106
+ [DESIGN.md](docs/DESIGN.md#access-code-casting-access-codets) says why. The address comes from the app, not from
107
+ Google's server as in Chrome, so validate what users type: Chrome's rules allow any private address and port. New: `addSinkByAddress`, `configureAccessCode`,
108
+ `rememberedSinks`, `createAccessCodeSink`, the `accessCode` option (with `store` to keep devices
109
+ between runs), and `pingIntervalMs` in `createClient`'s second argument.
110
+ - **`electron-cast dial-test`, a one-command test for DIAL TVs** (`npx electron-cast@next dial-test`; Node 20 or later, no
111
+ Electron), run on a real network: it found three Chromecasts over DIAL and flagged them as Cast devices. It runs the
112
+ library's own DIAL discovery, device description, app info, launch and stop against a real device, asks before it opens YouTube on it, and writes a Markdown report with names, serial numbers, UUIDs, MAC addresses,
113
+ IP addresses and URL hosts removed, plus a prefilled GitHub issue link. The package gains a `bin` entry
114
+ (`electron-cast` -> `dist/cli.js`). See the README's "Test a DIAL TV".
115
+
116
+ Not yet tried on real devices: casting from the app's own UI (`startCasting` from its menu) and the sessions that other
117
+ senders started. Both are covered by unit tests with fakes.
118
+
119
+ ### Added
120
+
121
+ - **A session tracker follows what every device runs**, from the receiver status and media status on the device's
122
+ channel, whoever started it (Chrome's `CastSessionTracker`). Sessions started elsewhere, or by this app before it
123
+ restarted, are reported through the routes observers and `getRoutes()` as non-local routes, as Chrome does;
124
+ `MediaRoute` gains `isLocal` and `sinkName`, and `origin` is empty on a non-local route. A non-local route can be
125
+ terminated and have its volume set.
126
+ - **Media control from the main process.** `manager.getMediaController(routeId, observer?)` is Chrome's
127
+ `MediaController` and `MediaStatusObserver` for a route: `play`, `pause`, `seek`, `nextTrack`, `previousTrack`,
128
+ `setVolume`, `setMute`, and the media status (title, play state, position, duration, volume, what the media can do,
129
+ images). It works on non-local routes too. Its status comes from the session tracker, as `CastMediaController`'s does:
130
+ every receiver status and every `MEDIA_STATUS` reaches every observer, changed or not, with media updates merged
131
+ into what was known and the `supportedMediaCommands` mask turned into a list. Binding sends the session's state
132
+ first and then `MEDIA_GET_STATUS`. New types `MediaController`, `MediaStatus`, `MediaStatusObserver`, `MediaImage`
133
+ and `MediaPlayState`. See docs/MAIN-API.md.
134
+ - **Casting from the app's own UI, on the page's default request.** In Chrome a page sets
135
+ `navigator.presentation.defaultRequest = new PresentationRequest(urls)`; the Cast dialog, opened from the browser's
136
+ menu or toolbar, offers it as a source, and when the user picks a device Chrome starts the presentation and fires
137
+ `connectionavailable` on the default request, which Google's Cast SDK adopts. electron-cast now does the same:
138
+ - The page-side stand-in reports `navigator.presentation.defaultRequest` (set, replaced, cleared) to the main
139
+ process, and only the window's main frame counts. A navigation or a destroyed window clears it.
140
+ - New `CastManager` methods, named after Chrome's `WebContentsPresentationManager` and `MediaRouterUI`:
141
+ `hasDefaultPresentationRequest(webContentsId)`, `getDefaultPresentationRequest(webContentsId)`,
142
+ `addPresentationObserver(webContentsId, observer)` and `startCasting(sinkId, { webContentsId })`, which starts the
143
+ default request on a sink with no picker and no user gesture. The page gets `connectionavailable` with a working
144
+ connection and the route appears in routes observers. It rejects with `MediaRouteError` carrying Chrome's
145
+ `RouteRequestResultCode` (`timed_out`, `sink_not_found`, `invalid_origin`, `cancelled`, `redundant_request`,
146
+ `unknown_error`) or `unable_to_cast`. `startCasting` launches anew on a sink that already has a route, stops the
147
+ route its window launched before, and uses the URL's `__castLaunchTimeout__` or 60 s, all as Chrome's
148
+ `CastActivityManager` does. New types `PresentationRequest`, `PresentationObserver` and `MediaCastMode`.
149
+ - `MediaSinksQuery` gains `presentationUrls`, the sinks that can run a presentation URL: as in Chrome, the device
150
+ must say the app is available (`GET_APP_AVAILABILITY`) and have its capabilities. A DIAL sink matches a
151
+ `cast-dial:` URL whose app it has, for the query's new `origin`, and `startCasting` starts a DIAL route on it, as
152
+ Chrome's dialog offers DIAL sinks for a default request's `cast-dial:` URLs.
153
+ - **Switch the mirrored tab, freeze the picture.** `switchMirroringSourceTab(routeId, webContentsId)` moves a
154
+ `tab_mirror` route to another page without ending or renegotiating the session (Chrome's "share this tab instead":
155
+ capture and the audio stream restart on the new page, encoders and timelines carry on, local muting moves to the new
156
+ page, and a second route on the same page ends). `freezeRoute` / `unfreezeRoute` pause and resume the video on its last
157
+ frame as Chrome's freeze does (audio goes on, 500 ms delay), and mirroring routes report `freezeInfo` (`canFreeze`,
158
+ `isFrozen`). Tested on a Nest Hub Max: a switch keeps the same route with no new OFFER and runs at about 30 fps after (the
159
+ picture was not checked on screen); freezing the picture works and keeps the session, but the Hub stopped acknowledging frames for about 9 s during a 15 s freeze and for 8 s after unfreezing (the sender matches Chrome; a Chrome control run is pending).
160
+ - **One route per page, and a closed tab ends its mirroring.** As in Chrome, a page that becomes a mirroring source
161
+ (a launch or a switch) loses the Cast SDK / Presentation API sessions it launched, and a page that launches one
162
+ loses its mirroring routes (`CastActivityManager::routes_by_frame_`). Closing the page being mirrored ends a tab route
163
+ (`CastMirroringServiceHost::WebContentsDestroyed`); a desktop route is unaffected. Tested on a Nest Hub Max: closing the
164
+ mirrored tab ends the route at once, and the receiver app is gone within 3 s.
165
+ - **Mirroring statistics.** A debugging aid with Chrome's names and units, like `chrome://media-router-internals`
166
+ "Mirroring stats": `setMirroringStatsEnabled(true)` before `startCasting`, then `getMirroringStats(routeId)` and
167
+ `registerMirroringStatsObserver` (every 500 ms) give `{ audio, video }` with `ENQUEUE_FPS`, the latency averages and
168
+ histograms, bitrates, packet counts and the sender's own counters. A port of openscreen's statistics collector,
169
+ clock offset estimator and analyzer, with the receiver's RTCP event log parsed. Off by default; nothing is uploaded
170
+ (Chrome's UMA is not ported). `examples/live-mirroring` takes `--stats`. `getMirroringStats` never throws, as
171
+ Chrome's `MediaRouterDebuggerImpl::GetMirroringStats` has no error path: `{}` while off and for an unknown route, and an
172
+ ended route keeps its last statistics until another route pushes. Tested on a Nest Hub Max: Chrome's names, internally
173
+ consistent; `AVG_E2E_LATENCY_MS` is 0 on the Hub, which sends no playout events.
174
+ - **Mirroring uses a hardware encoder when there is one, as Chrome does.** The capture page asks WebCodecs
175
+ (`prefer-hardware`) which of H.264, VP8 and VP9 a hardware encoder takes, and offers those hardware-first (H.264 as
176
+ Annex B); VP8 in software is offered only when no hardware codec is, or when the receiver takes none of the hardware
177
+ ones. A hardware encoder that fails mid-session no longer stops mirroring: the codec is dropped for the rest of the
178
+ app's run and the session negotiates again. Chrome's `--cast-streaming-force-{enable,disable}-hardware-<codec>` and
179
+ `--disable-cast-letterboxing` switches, and the `CastStreamingVp8` / `Vp9` / `Av1` / `HardwareHevc` / `Win|MacHardwareH264`
180
+ features of `--enable-features` / `--disable-features`, are honoured, read from `app.commandLine` (so switches the app
181
+ appends count) when the `electron` object passed as `mirroring.electron` includes `app`. Tested on a Nest Hub Max: the
182
+ Hub chose H.264 in hardware, about 30 fps at 2.7 Mbps, with about 4.4 ms per encode.
183
+ - **VP9 is offered by default, as in Chrome.** In hardware when an encoder takes it, in software under the same
184
+ hardware-first rule as VP8; there is no option for it.
185
+ - **Mirroring letterboxes like Chrome.** The capture now asks for the `fixed_aspect_ratio` policy when the receiver
186
+ cannot scale (always for a Nest Hub): frames keep a 16:9 shape whatever the page or screen looks like, and a tab is
187
+ no longer upscaled to 1920x1080. The new offer after an encoder failure and the letterboxing are tested
188
+ against the fake receiver and in the smoke test; not yet on a real device (H.264 in hardware is, above).
189
+ - **Mirroring adapts to encoder load as Chrome does.** Each encoded frame now carries Chrome's encoder utilization
190
+ (smoothed, clamped) and lossiness, estimated from the frame's pixels because WebCodecs reports no quantizer (a port of
191
+ `FrameComplexityEstimator`). `VideoSender` feeds the larger of the two back, and for a tab the capture size follows it
192
+ like Chrome's `VideoCaptureOracle`: it steps down when the encoder or the link is overloaded and back up when there is
193
+ room, within the limits of the resolution change policy. Screens are captured at the full size, as in Chrome.
194
+ Switching the tab starts the size over, as a new capture device does in Chrome. The `LOSSINESS` statistic now reads
195
+ each frame's value; it is -100, as in Chrome, until a frame has reported one. Not yet tried on a real device.
196
+ - **Mirrored frames carry their capture time, and the capture rate is limited as Chrome limits it.** A frame's
197
+ reference time is its capture time from the frame metadata when the source gives one (else the capture timestamp
198
+ moved onto the wall clock by the smallest delay seen), so uneven delivery no longer skews the receiver's playout.
199
+ Each frame carries its capture begin and end times to the sender, which logs them as `FRAME_CAPTURE_BEGIN` and
200
+ `FRAME_CAPTURE_END`, so the capture, encode and end-to-end latency statistics start at capture. The capture is thinned
201
+ to the session's frame rate by a port of Chrome's `SmoothEventSampler` (a token bucket of 1.5 frame periods, judged
202
+ on capture timestamps), so a burst after a stall is kept whole. The sender logs its pipeline stages, the router's
203
+ bursts and the frame sizes, and `smoke/perf.mjs` mirrors a 1080p page to the fake receiver to measure them. Checked
204
+ on a Nest Hub Max: a steady 30 fps, 1.1% of the video frames dropped, no audio dropped.
205
+ - **The manager follows network changes by itself, as Chrome's `DiscoveryNetworkMonitor` tells its media router.** It
206
+ computes Chrome's network id from the connected interfaces and, when it changes, does what Chrome's two observers do:
207
+ DIAL devices given up on as non-Cast are tried again, the sinks of the network being left are remembered and reopened
208
+ on coming back to it (`CastMediaSinkServiceImpl::OnNetworksChanged`), and devices added by address with no route are
209
+ removed and the remembered ones added back 4.45 s later (`AccessCodeCastSinkService::OnNetworksChanged`). DIAL
210
+ discovery forgets its devices and searches again at once instead of waiting up to 120 s, and does not search while
211
+ there is no network (`DialRegistry::OnConnectionChanged`). Node has no
212
+ network-change event, so it reads `os.networkInterfaces()` every 5 s while started; Node has no Wi-Fi SSID either, so
213
+ an interface is identified by its MAC and IPv4 network. A custom `discovery` turns it off unless the new
214
+ `networkMonitor` option is given, and `networkMonitor: false` turns it off; a `NetworkMonitor` of your own drives it in
215
+ tests. There is no method for the app to call.
216
+ - Presentation mode: `PresentationConnection.send()` takes ArrayBuffer, ArrayBufferView and Blob as well as strings,
217
+ and `binaryType` (`arraybuffer` or `blob`) picks what `message` events carry, as in Chrome. Binary goes to wired
218
+ displays, in both directions. To a Cast device it is dropped without an error, as Chrome's
219
+ `CastSessionClientImpl::OnMessage` ignores messages that are not text. One 64 MiB cap holds for text and bytes in both
220
+ directions; a larger `send()` throws `RangeError`, and a detached ArrayBuffer is a `TypeError`. Before,
221
+ `send()` threw a `TypeError` for anything but a string.
222
+
223
+ ### Changed
224
+
225
+ - **Devices are tracked as Chrome's Media Router tracks them.** electron-cast opens a channel to every device mDNS
226
+ finds (after Chrome's random delay of up to 5 s), runs device authentication on it, and lists the device only once
227
+ that has passed. A failed attempt is retried with Chrome's backoff (15 s, 3 attempts); a device that fails
228
+ authentication is never listed, where before it appeared in the picker and failed on use. The channel then stays
229
+ open, with a ping every 5 s, and is reopened after a failure (sleep and resume included); a device is dropped only
230
+ when it cannot be reopened, not when mDNS stops reporting it. The list is reported once it has been quiet for 3 s.
231
+ `manager.devices()`, the picker's list and the sinks observers show these devices, so **right after `start()` the
232
+ list is empty and fills in over a few seconds**.
233
+ - **`createClient` is called once per device, and its signature is now `(device, params)`.** A device's channel is
234
+ shared by its sessions and kept open, so clients live as long as the device is a sink, not as long as a session,
235
+ and must be fine to keep connected. `createClient` is called again after a failure, with
236
+ `params = { connectTimeoutMs, livenessTimeoutMs }` for that attempt; pass them on to `CastClient`
237
+ (`connectTimeoutMs`, `heartbeatTimeoutMs`). A channel replaced because the device's address changed stays open while
238
+ a session uses it (as Chrome leaves the old socket); an address list that mDNS merely reorders changes nothing. A
239
+ device whose host is not an IP address is skipped with a warning.
240
+ - **App availability for pages, as in Chrome.** In the default mode a page's `getAvailability()` and the devices its
241
+ `start()` offers come from the devices' own answer to `GET_APP_AVAILABILITY` for the request's app, asked over the
242
+ channels already open (Chrome's `CastAppDiscoveryServiceImpl`): a device that does not have the app is not offered,
243
+ availability turns true as soon as a device says it has the app, and `change` events follow each answer. An
244
+ "available" answer stands, an "unavailable" one for a minute, no answer never. `discoverSinksNow()` asks again by
245
+ the same rules. `mode: "chromecast"` still goes by capabilities.
246
+ - **Public and loopback device addresses are refused, as in Chrome.** Chrome opens no Cast channel to a publicly
247
+ routable or loopback address unless `MediaRouterCastAllowAllIPs` is set (`CastMediaSinkServiceImpl::OpenChannel`).
248
+ The sink service checks the address each time it opens a channel, so such a device is not listed, offered or
249
+ connected to; `sinks: { allowAllIps: true }` turns it off. Private, link-local, unique-local and `100.64.0.0/10`
250
+ addresses are unaffected.
251
+ - `joinRunningSession` is answered from the session tracker instead of connecting to every device and asking, with the
252
+ same results and errors; the device must be listed (its channel open) by then. A session whose pages all let go now
253
+ stays a (non-local) route while the device runs it, where it used to disappear from the list.
254
+ - `navigator.presentation.defaultRequest` is now a nullable attribute as in Blink: it takes a `PresentationRequest`
255
+ or `null` and throws `TypeError` for anything else. `connectionavailable` fires after the current task, as Blink
256
+ enqueues it.
257
+ - Up to 1024 media requests from a page may wait for the receiver's answer, as in Chrome
258
+ (`kMaxPendingMediaRequests`); a full table drops its older half before taking the new one (it was 100).
259
+
260
+ ### Fixed
261
+
262
+ - **Mirroring and remote-playback sources are never launched as ordinary apps.** A presentation URL naming a Cast
263
+ Streaming app (`0F5096E8`, `85CDB22F`), alone or beside other apps in one legacy URL, and a `remote-playback:` URL
264
+ are unavailable (`getAvailability()` is `false`) and `start()` rejects with `NotFoundError` ("No screens found.").
265
+ Of several URLs the first ordinary Cast app one is served. The stand-in's `PresentationRequest` drops URLs of unknown
266
+ protocol like Blink and throws `NotSupportedError` when none is left.
267
+ - A device that fails device authentication no longer shows in the picker (see Changed).
268
+
269
+ ### Documentation
270
+
271
+ - A rewritten README with a Chrome parity table (including what is out of scope, such as Chrome's Global Media
272
+ Controls panel, and what is partly done: access-code
273
+ casting, without the code lookup), a getting-started page, guides (device picker, restart rejoin, windows and iframes, custom
274
+ receivers, audio-only devices and groups, device authentication, the low-level client, testing), troubleshooting
275
+ and a FAQ, architecture diagrams and a glossary, a map of the Chromium code each module follows, and CONTRIBUTING.
276
+ - Tested-on facts: casting, rejoin after a force-kill, and stop verified end to end in an Electron 45 app on Linux
277
+ (Ubuntu under WSL2, dev and packaged builds) as well as Windows; IPv6 discovery and the Cast channel with TLS and device
278
+ authentication over unique-local and link-local addresses verified on real devices.
279
+ - `npm run check` now also checks the docs: every public export is mentioned, the TypeScript examples typecheck
280
+ against the sources, and relative links and anchors resolve; `npm run docs:check:chromium` (network) rechecks the
281
+ Chromium citations. Comment fixes only in `src/`.
282
+
3
283
  ## 0.4.0
4
284
 
5
285
  - **Devices are now verified, as in Chrome.** `CastClient.connect()` runs the Cast device authentication challenge
@@ -0,0 +1,305 @@
1
+ # Contributing to electron-cast
2
+
3
+ Thanks for helping. electron-cast brings Chrome's Cast support to Electron, and the most useful things you can bring are
4
+ a bug fix, a doc fix, or a report from a device and a desktop we have not tried.
5
+
6
+ Start here:
7
+
8
+ - [Report a Cast device you tested](#test-on-real-devices): the most wanted contribution.
9
+ - [Fix a bug or a doc](#how-to-contribute): open a pull request directly.
10
+ - [Add a feature or change the API](#how-to-contribute): open an issue first.
11
+ - [Report a security problem](#security-issues): privately, never in an issue.
12
+
13
+ ## How to contribute
14
+
15
+ | You want to | Do this |
16
+ |---|---|
17
+ | Fix a bug, or fix or improve the docs | Open a pull request. No issue needed. |
18
+ | Add a feature, or change the public API | Open an issue first. We agree on the Chromium behaviour it matches before you write code. |
19
+ | Report a bug | Open an issue with the bug form. |
20
+ | Say what works on your device or OS | Open an issue with the device report form. |
21
+ | Report a vulnerability | Use a [private advisory](#security-issues). |
22
+
23
+ There is no CLA and no sign-off line. By contributing you agree your work is licensed under the [MIT license](LICENSE), the
24
+ same as the project (inbound = outbound).
25
+
26
+ ### AI-assisted contributions
27
+
28
+ Welcome. Use whatever tools help you. You do not need to say you used them.
29
+
30
+ You own what you submit. That means you understand every line, you ran it, and you can explain it in review. Check every
31
+ Chromium citation yourself, by opening the file: a tool can invent a source, a function name or a test result. Keep the pull
32
+ request small enough for a person to review.
33
+
34
+ ## The rules
35
+
36
+ ### Behave as Chrome, and cite Chromium
37
+
38
+ This is a hard rule. electron-cast does what Chrome does. When the library has a choice to make (what to check, which error
39
+ to return, what to do after a navigation), the answer is what Chrome does.
40
+
41
+ - **Every behaviour change cites the Chromium (or Open Screen) source it matches.** Give the file and the function, and link
42
+ it on chromium.googlesource.com. Put the citation in the comment next to the code.
43
+ - Cite the file and the symbol, never a line number. Lines move.
44
+ - Read the source on `main` before you write the citation. Do not cite from memory or from a search snippet.
45
+ - Deviations are accepted only when Electron forces them. Each one is written down in [docs/DESIGN.md](docs/DESIGN.md) with
46
+ the reason, and noted in the code and the changelog. A silent difference is a bug.
47
+ - App-specific features belong in the app, not in the library. `src/` never knows which app uses it.
48
+ - **`mode: "chromecast"` is frozen.** The legacy `chrome.cast` polyfill (`src/polyfill/install.ts`) gets fixes for crashes
49
+ and security problems and nothing else. No new features. New work goes on the Presentation API path.
50
+ - **No runtime dependencies.** `dependencies` in `package.json` stays empty. Dev dependencies are fine when a tool needs
51
+ one.
52
+
53
+ ### Finding the Chromium source
54
+
55
+ Search and browse at [source.chromium.org](https://source.chromium.org/chromium/chromium/src), and link to
56
+ `https://chromium.googlesource.com/chromium/src/+/refs/heads/main/<path>`. Open Screen lives in
57
+ `https://chromium.googlesource.com/openscreen`. Where to look:
58
+
59
+ | Area | Path in Chromium |
60
+ |---|---|
61
+ | Media Router: sinks, routes, Cast sessions, Cast channels | `chrome/browser/media/router/` (the Cast provider is `providers/cast/`) |
62
+ | Media Router: shared parts, Presentation API plumbing | `components/media_router/` |
63
+ | Tab and desktop mirroring | `components/mirroring/` |
64
+ | The page-side Presentation API | `third_party/blink/renderer/modules/presentation/` |
65
+ | Cast protocol, discovery, authentication (Open Screen) | `cast/` in openscreen |
66
+
67
+ Add or update a row in [docs/CHROMIUM-MAP.md](docs/CHROMIUM-MAP.md): the electron-cast file, the Chromium file, the symbols,
68
+ what is mirrored, and how electron-cast differs. Then run the citation check, which needs the network:
69
+
70
+ ```sh
71
+ npm run docs:check:chromium
72
+ ```
73
+
74
+ It fetches each Chromium file linked from the map, looks for each cited symbol in it, and checks that every
75
+ Chromium-style path written in backticks in `docs/` exists. Chromium moves code around: a failure usually means the
76
+ citation needs updating, not that the library is wrong.
77
+
78
+ ### Security-sensitive code
79
+
80
+ The page is untrusted and the main process is trusted. Everything that arrives over IPC is validated in the main process.
81
+ The origin and frame come from `event.senderFrame`, never from the message. A page never names a host or port. Read
82
+ [SECURITY.md](SECURITY.md) before you change `src/electron/` or the client's authentication, and do not weaken a check to
83
+ make a test pass.
84
+
85
+ ### Comments
86
+
87
+ Comments explain why, and cite Chromium where the behaviour is Chrome's. They do not narrate the change that added them.
88
+
89
+ ## Set up
90
+
91
+ You need Node 20 or later (the `engines` field in `package.json`). CI uses Node 24. Running TypeScript files directly, as
92
+ `node examples/discover.ts` does, needs a Node that strips types: 22.18 or later.
93
+
94
+ ```sh
95
+ git clone https://github.com/adammpkins/electron-cast.git
96
+ cd electron-cast
97
+ npm ci
98
+ ```
99
+
100
+ Electron is an optional peer dependency and `npm ci` does not install it. Only the smoke test and the live harnesses need
101
+ it, and they install it for you or tell you how.
102
+
103
+ | Command | What it does |
104
+ |---|---|
105
+ | `npm run check` | Typecheck, lint (oxlint), unit tests and the docs check. No network. This is the CI gate. |
106
+ | `npm run build` | Builds `dist/` (ES modules) and `dist/cjs/` (CommonJS). |
107
+ | `npm test` | The unit tests alone, on Node's own test runner. |
108
+ | `npm run typecheck`, `npm run lint` | Each step of `npm run check` on its own. |
109
+ | `npm run docs:check` | The docs checks alone. No network. |
110
+ | `npm run docs:check:chromium` | Checks the Chromium citations. Needs the network. |
111
+ | `npm run smoke` | Builds, then loads the built package in a real Electron with a fake network. |
112
+ | `npm run canary` | Checks Google's Cast sender SDK still speaks what we translate. Needs the network. |
113
+
114
+ Run one test file:
115
+
116
+ ```sh
117
+ node --test --test-force-exit --test-timeout=20000 test/client/cast-client.test.ts
118
+ ```
119
+
120
+ ## Repository layout
121
+
122
+ | Path | What is there |
123
+ |---|---|
124
+ | `src/discovery/` | mDNS discovery of Cast devices, and the address policy |
125
+ | `src/dial/` | DIAL discovery and launch |
126
+ | `src/protocol/`, `src/client/` | The Cast v2 wire format, device authentication, and the channel client |
127
+ | `src/electron/` | The main-process manager, sessions, routes, media control, the network monitor, access code casting, and the preload |
128
+ | `src/mirroring/` | Tab and desktop mirroring: the Cast Streaming sender (`sender/`, `rtp/`, `rtcp/`, `transport/`), the session host, codec choice, statistics (`stats/`), and the Electron capture and utility process (`electron/`) |
129
+ | `src/polyfill/` | The page side: the stand-in Presentation API and the frozen `chrome.cast` polyfill |
130
+ | `src/cli.ts`, `src/dial-test/` | The `electron-cast` command (the package's `bin`, built to `dist/cli.js`) and its `dial-test` |
131
+ | `src/index.ts` | The package's main entry |
132
+ | `test/` | Unit tests, with fakes for everything outside the process |
133
+ | `smoke/` | The Electron smoke test, mirroring included |
134
+ | `tools/` | Docs checks, the SDK canary and the trace recorder |
135
+ | `examples/` | A small app (`electron-app/`), a discovery script (`discover.ts`), and the live mirroring harness that casts to a real device (`live-mirroring/`) |
136
+ | `docs/` | The documentation: API, design, the Chromium map, guides |
137
+ | `site/` | The documentation website (VitePress) |
138
+
139
+ ## Test your change
140
+
141
+ CI runs two gates. Both must pass:
142
+
143
+ 1. **`npm run check`** on Linux, Windows and macOS.
144
+ 2. **The Electron smoke test** on Electron 35, 40 and the latest, on the same three systems.
145
+
146
+ New behaviour needs a test that fails without it. Use the fakes the tests already have: a fake receiver (a TLS server on
147
+ 127.0.0.1, `test/client/fake-receiver.ts`), a fake discovery socket, fake clients and a fake `ipcMain`. **No test uses a
148
+ real device or the real network.**
149
+
150
+ ### The smoke test
151
+
152
+ It loads the built package by name inside a real Electron with a sandboxed preload, and drives it from a page. Electron is
153
+ installed into its own folder:
154
+
155
+ ```sh
156
+ npm i --prefix smoke/.out/electron --no-package-lock electron@45
157
+ npm run smoke
158
+ ```
159
+
160
+ On Linux it needs a display (`xvfb-run`) and Electron's sandbox helper allowed. `.github/workflows/ci.yml` shows the steps.
161
+
162
+ ### The SDK canary
163
+
164
+ Google can change its Cast sender SDK per Chrome major without an electron-cast release, and the stand-in depends on what the
165
+ SDK sends. `npm run canary` (`tools/sdk-canary.mjs`) fetches the SDK for Chrome stable, beta and dev, and for the Chromium in
166
+ Electron 45, and compares it with `tools/sdk-canary-baseline.json`. The downloaded JavaScript is only searched as text, never
167
+ run. A weekly workflow opens an issue when it fails. Exit codes: 0 compatible, 1 incompatible, 2 could not run. Update the
168
+ baseline deliberately, with `--update-baseline`, after reading what changed.
169
+
170
+ ### The docs checks
171
+
172
+ `npm run docs:check` fails when a public export is missing from the API reference, a TypeScript block in the Markdown does
173
+ not typecheck, or a relative link or `#anchor` does not resolve. Mark a fragment or a signature with `no-check` after the
174
+ language (` ```ts no-check `) or put `<!-- no-check -->` on the line before the block.
175
+
176
+ ## Test on real devices
177
+
178
+ The unit tests cannot tell us how real hardware behaves. We want reports, especially from:
179
+
180
+ - **macOS** (not tested yet).
181
+ - **Real Linux desktops**: GNOME and KDE, on X11 and on Wayland.
182
+ - **DIAL smart TVs.**
183
+ - **Two network adapters** (Wi-Fi and Ethernet, a VPN, a virtual switch).
184
+ - **Cast groups.**
185
+ - **Older Chromecasts.**
186
+
187
+ What has been tested, and what has not, is in the [README](README.md#platforms-and-what-was-tested). A report that fills a
188
+ gap is a real contribution, even if everything works.
189
+
190
+ ### Send a device report
191
+
192
+ Open an issue with the **Device report** form (`.github/ISSUE_TEMPLATE/device-report.yml`). If you prefer to write it
193
+ yourself, this is what it needs:
194
+
195
+ ```md
196
+ **OS and version:**
197
+ **Electron version:**
198
+ **electron-cast version:**
199
+ **Device model and Cast firmware:**
200
+ **Network:** IPv4 / IPv6 / both, how many adapters, Wi-Fi or wired
201
+ **What I tried:**
202
+ **What worked:**
203
+ **What failed:**
204
+ **Logs (scrubbed):**
205
+ ```
206
+
207
+ ### Run the live harnesses
208
+
209
+ These cast to a real device. The mirroring harness lives in `examples/live-mirroring/`. Build the library first, then:
210
+
211
+ ```sh
212
+ npm run build
213
+ cd examples/live-mirroring
214
+ npm install
215
+ npm start # lists devices that can receive tab mirroring, then quits
216
+ npm run tab -- "<device name>" # mirror the demo window
217
+ npm run desktop -- "<device name>" # mirror the primary screen
218
+ ```
219
+
220
+ DIAL TVs are probed with `electron-cast dial-test` (`src/dial-test/`, built to `dist/cli.js`; [how a volunteer runs
221
+ it](README.md#test-a-dial-tv)). It uses the library's own SSDP discovery, description fetch, app info, launch and stop, so what
222
+ it reports is what the library does. Everything it does is read-only except opening and closing YouTube, which it does only
223
+ after asking. It scrubs its report once, at the end, in `src/dial-test/scrub.ts`; anything new that goes into the report is
224
+ scrubbed there, and the tests in `test/dial-test/` fail if a name, serial number, UDN, MAC, address or app-info value from
225
+ the fake device appears in it. Do not run it against devices that are not yours.
226
+
227
+ The trace recorder (`tools/capture-trace.mjs`) runs one session against a device: it connects, launches the Default Media
228
+ Receiver, loads a public video, pauses, plays and stops, and always stops the app it launched. It scrubs names, ids and
229
+ addresses before it writes a file, and refuses to write if something still looks like an IP, MAC or id.
230
+
231
+ ```sh
232
+ node tools/capture-trace.mjs --dry-run --out trace.json # a fake receiver, no network
233
+ node tools/capture-trace.mjs --host <device ip> --out trace.json # a real device
234
+ ```
235
+
236
+ Each harness has a README or header comment with its options. The rules for all of them:
237
+
238
+ - **Use your own devices only.** Never cast to a device that is not yours to disturb.
239
+ - The live harnesses ask before they start casting. Read what the dialog says.
240
+ - The harnesses and the trace recorder play and stop media on the device you pick.
241
+
242
+ ### Scrub before you post
243
+
244
+ Paste only scrubbed output. **Never post** device names, device ids, IP addresses, MAC addresses, Wi-Fi network names or
245
+ certificates. Not in an issue, a pull request, a test fixture or a commit. Replace them (`Living Room TV`, `192.0.2.10`)
246
+ and read the output again before you post it. The model and firmware are fine.
247
+
248
+ ## Documentation
249
+
250
+ Docs are part of the change. A pull request that changes behaviour updates, as they apply:
251
+
252
+ - the [README](README.md) parity table, when Chrome parity changes;
253
+ - [docs/CHROMIUM-MAP.md](docs/CHROMIUM-MAP.md), for every new citation;
254
+ - [docs/DESIGN.md](docs/DESIGN.md), for behaviour and for every deviation from Chrome;
255
+ - the [API reference](docs/API.md) or [main-process API](docs/MAIN-API.md), for a public change;
256
+ - [CHANGELOG.md](CHANGELOG.md), under `## Unreleased`, for anything a user can see.
257
+
258
+ Each file in `docs/` starts with one `# Title` and a one-sentence summary, and pages link to each other with relative
259
+ links.
260
+
261
+ The website lives in `site/` and is built from `docs/`. To preview it:
262
+
263
+ ```sh
264
+ cd site
265
+ npm ci
266
+ npm run dev
267
+ ```
268
+
269
+ It is published at <https://adammpkins.github.io/electron-cast/>.
270
+
271
+ ## Commits and pull requests
272
+
273
+ Commit messages are plain and in the imperative: "Bound pending media requests at Chrome's 1024". The first line says what
274
+ changed. The body, when there is one, says why. Run `git log` and match what you see.
275
+
276
+ Before you open a pull request:
277
+
278
+ - [ ] One change, with a clear description of what and why.
279
+ - [ ] Every behaviour change cites its Chromium source, and `npm run docs:check:chromium` passes.
280
+ - [ ] Any deviation from Chrome is in `docs/DESIGN.md` with the reason.
281
+ - [ ] New behaviour has tests that use the existing fakes.
282
+ - [ ] `npm run check` and `npm run build` pass. The smoke test passes if you touched `src/electron/` or `src/polyfill/`.
283
+ - [ ] Docs and `CHANGELOG.md` are updated.
284
+ - [ ] No runtime dependencies added, and nothing app-specific in `src/`.
285
+ - [ ] No device names, ids, addresses, MACs, Wi-Fi names or certificates anywhere.
286
+
287
+ ## Security issues
288
+
289
+ Do not open a public issue for a security problem. Use GitHub's private vulnerability reporting: open the **Security** tab
290
+ of [the repository](https://github.com/adammpkins/electron-cast) and choose **Report a vulnerability**. [SECURITY.md](SECURITY.md)
291
+ says what to include and what the library trusts.
292
+
293
+ ## Releases
294
+
295
+ Maintainers only. A release is published by `.github/workflows/publish.yml` from a tag, with npm trusted publishing and a
296
+ provenance attestation.
297
+
298
+ 1. On `main`, with a clean tree: `npm ci`, `npm run check`, `npm run build` and `npm run smoke`. Run `npm run canary` and
299
+ read the result.
300
+ 2. Move the `## Unreleased` entries of the changelog under a new `## <version>` heading.
301
+ 3. Set `version` in `package.json` and the lockfile (`npm install --package-lock-only`).
302
+ 4. Commit, then tag and push: `git tag v<version> && git push origin main v<version>`. The workflow refuses a tag that does
303
+ not match `package.json`, skips a version already on npm, runs `npm run check`, and publishes.
304
+ 5. Confirm the version on npm, and that `electron-cast`, `electron-cast/main` and `electron-cast/preload` import from a fresh
305
+ install.