{"id":25546790,"url":"https://github.com/benoitlahoz/electron-window-rtc","last_synced_at":"2026-03-07T10:31:49.832Z","repository":{"id":278428161,"uuid":"934338592","full_name":"benoitlahoz/electron-window-rtc","owner":"benoitlahoz","description":"Connect Electron windows through WebRTC.","archived":false,"fork":false,"pushed_at":"2025-02-24T08:56:16.000Z","size":1522,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T20:47:48.504Z","etag":null,"topics":["browser-window","communication","electron","ipc","webrtc","window"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benoitlahoz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-17T16:59:56.000Z","updated_at":"2025-02-24T08:56:19.000Z","dependencies_parsed_at":"2025-05-29T10:33:01.395Z","dependency_job_id":null,"html_url":"https://github.com/benoitlahoz/electron-window-rtc","commit_stats":null,"previous_names":["benoitlahoz/electron-window-rtc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/benoitlahoz/electron-window-rtc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitlahoz%2Felectron-window-rtc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitlahoz%2Felectron-window-rtc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitlahoz%2Felectron-window-rtc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitlahoz%2Felectron-window-rtc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoitlahoz","download_url":"https://codeload.github.com/benoitlahoz/electron-window-rtc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitlahoz%2Felectron-window-rtc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-window","communication","electron","ipc","webrtc","window"],"created_at":"2025-02-20T09:17:46.388Z","updated_at":"2026-03-07T10:31:49.787Z","avatar_url":"https://github.com/benoitlahoz.png","language":"TypeScript","funding_links":["https://www.paypal.com/donate/?hosted_button_id=C2ABZ3KBUXF92"],"categories":[],"sub_categories":[],"readme":"# electron-window-rtc\n\n\u003ca href='https://en.wikipedia.org/wiki/Marseille'\u003e\n    \u003cimg src=\"assets/badges/made_with_♥_in-Marseille-cc0040.svg\"\u003e\n\u003c/a\u003e\n\nInspired by [electron-peer-connection](https://github.com/han-gyeol/electron-peer-connection), `electron-window-rtc` is a zero-dependency package that allows sharing medias between [Electron](https://www.electronjs.org/) windows through [WebRTC](https://webrtc.org/) with (almost) zero-latency, depending on application configuration.\n\nIt works by creating a **main process** events hub that acts as a signaling server for the windows through Electron's IPC. Once windows are registered, each **renderer process** creates a `WindowRTCPeerConnection` to another window and begins to send/receive media streams.\n\nThis package was primarily released to handle video/canvas manipulation before sending it to a [window rendered offscreen](https://www.electronjs.org/docs/latest/tutorial/offscreen-rendering) passed to the [Syphon framework](https://github.com/Syphon/Syphon-Framework) with same author's [node-syphon](https://github.com/benoitlahoz/node-syphon) package.\n\n### Donate\n\nIf you find this package useful, contribute to my Open-Source work by donating here! Thank you!\n\n[![paypal](https://img.shields.io/badge/contribute-Paypal-2ea44f)](https://www.paypal.com/donate/?hosted_button_id=C2ABZ3KBUXF92)\n\n## Install\n\n```sh\nnpm i -s electron-window-rtc\n```\n\n```sh\nyarn add electron-window-rtc\n```\n\n## Usage\n\nSee [Electron+Vue example](https://github.com/benoitlahoz/electron-window-rtc/tree/main/example) for a complete integration example.\n\n### Main process\n\n```typescript\n// WindowRTCMain is a singleton.\nimport { WindowRTCMain } from 'electron-window-rtc';\n\nconst senderWindow: BrowserWindow = createWindow(); // Left to application.\nconst receiverWindow: BrowserWindow = createWindow();\n\n// Note that windows can both send and receive by creating two connection (see below in 'renderer process' section).\n\nWindowRTCMain.register('sender', senderWindow);\nWindowRTCMain.register('receiver', receiverWindow);\n```\n\n### Renderer process\n\n#### Sender\n\n```typescript\nimport {\n  WindowRTCPeerConnection,\n  defineIpc,\n} from 'electron-window-rtc/renderer';\n\n// Important: define early how to access to IPC object, according to application 'preload' script.\n// The IPC object must at least expose `on`, `removeListener`, `send` and `invoke` methods (see IPCObject below).\ndefineIpc(window.electron.ipcRenderer);\n\ndocument.addEventListener('DOMContentLoaded', (event) =\u003e {\n  const windowConnection = new WindowRTCPeerConnection('receiver');\n\n  // Canvas for example...\n  const canvas: HTMLCanvasElement = document.getElementById('canvas');\n\n  // Add track from canvas: this will create an 'offer' for 'receiver' window.\n  // Note the '240' fps framerate: leaving it empty creates latency in the receiver.\n  windowConnection.addStream(canvas.captureStream(240));\n});\n```\n\n#### Receiver\n\n```typescript\nimport {\n  WindowRTCPeerConnection,\n  defineIpc,\n} from 'electron-window-rtc/renderer';\n\n// Important: define early how to access to IPC object, according to application 'preload' script.\n// The IPC object must at least expose `on`, `removeListener`, `send` and `invoke` methods (see IPCObject below).\ndefineIpc(window.electron.ipcRenderer);\n\ndocument.addEventListener('DOMContentLoaded', (event) =\u003e {\n  const windowConnection = new WindowRTCPeerConnection('sender');\n\n  // Listen to 'track' added by 'sender' window.\n  windowConnection.on('track', (event: EventManagerDTO) =\u003e {\n    const video: HTMLVideoElement = document.getElementById('video');\n\n    const trackEvent: RTCTrackEvent = event.payload;\n    const streams = trackEvent.streams;\n    for (const stream of streams) {\n      // For the sake of this example, keep only one stream, we could also get `streams[0]`.\n      video.srcObject = null;\n      video.srcObject = stream;\n    }\n  });\n});\n```\n\n## API\n\n### Main process\n\nWindowRTCMain.register(name: string, window: BrowserWindow): void\nWindowRTCMain.unregister(name: string): void\nWindowRTCMain.dispose(): void\n\n### Renderer process\n\npublic static async with(peer: string): Promise\u003cWindowRTCPeerConnection\u003e\n\npublic dispose(): void\n\npublic async addStream(stream: MediaStream): Promise\u003cvoid\u003e\n\npublic async requestOffer(): Promise\u003cvoid\u003e\n\npublic on(\nchannel: EventManagerChannel,\nlistener: (data: EventManagerDTO) =\u003e void\n): void\n\npublic off(\nchannel: EventManagerChannel,\nlistener?: (data: EventManagerDTO) =\u003e void\n): void\n\n### Events\n\n`WindowRTCEvent` (see below) sent by `WindowRTCPeerConnection` with different payloads according to the event emitted.\n\n| Channel                    | Payload Type                                              | Emitted                                                     |\n| -------------------------- | --------------------------------------------------------- | ----------------------------------------------------------- |\n| `*`                        | `any`                                                     | For each event.                                             |\n| `icecandidate`             | `RTCIceCandidate`                                         | On `icecandidate` RTCPeerConnection event.                  |\n| `iceconnectionstatechange` | `Event`                                                   | On `iceconnectionstatechange` RTCPeerConnection event.      |\n| `icecandidateerror`        | `RTCPeerConnectionIceErrorEvent`                          | On `icecandidateerror` RTCPeerConnection event.             |\n| `icegatheringstatechange`  | `Event`                                                   | On `icegatheringstatechange` RTCPeerConnection event.       |\n| `negotiationneeded`        | `Event`                                                   | On `negotiationneeded` RTCPeerConnection event.             |\n| `signalingstatechange`     | `Event`                                                   | On `signalingstatechange` RTCPeerConnection event.          |\n| `track`                    | `RTCTrackEvent`                                           | On `track` RTCPeerConnection event.                         |\n| `leave`                    | `undefined` \\| `Error`                                    | When `local` window leaves.                                 |\n| `peer-left`                | `undefined` \\| `Error`                                    | When `remote` window leaves.                                |\n| `request-offer`            | `undefined`                                               | When a window requests an offer from its peer window.       |\n| `sent-offer`               | `RTCSessionDescriptionInit`                               | When a window has sent an offer.                            |\n| `received-offer`           | `{ offer: SdpObject, answer: RTCSessionDescriptionInit }` | When a window has received an offer and **sent an answer**. |\n| `received-answer`          | `SdpObject`                                               | When a window has received an answer.                       |\n| `received-candidate`       | `RTCIceCandidate`                                         | When a window has received an ICE candidate.                |\n| `error`                    | `Error`                                                   | When an error occurred in IPC communication.                |\n\n### Types\n\n#### IpcObject\n\nDescribes the IPC object used by `electron-window-rtc`\n\n```typescript\ninterface IpcObject {\n  on: (\n    channel: string,\n    callback: (event: IpcRendererEvent, ...args: any[]) =\u003e void\n  ) =\u003e void;\n  removeListener: (\n    channel: string,\n    callback: (event: IpcRendererEvent, ...args: any[]) =\u003e void\n  ) =\u003e void;\n  send: (channel: string, ...args: any[]) =\u003e void;\n  invoke: (channel: string, ...args: any[]) =\u003e Promise\u003cany\u003e;\n}\n```\n\n#### WindowRTCEvent\n\nDescribes the generic event data sent and received by `WindowRTCPeerConnection`.\n\n**WARNING:** interface name and property keys may change. The reason is that, for internal events, `sender` and `receiver` do not correspond to the actual event. For example, in case of `iceconnectionstatechange` event, the `sender` is actually the local peer receiving the event (self) and receiver is the remote one (`peer`) that is actually not receiving anything.\n\n```typescript\ninterface WindowRTCEvent {\n  sender: string;\n  receiver: string;\n  payload: any;\n}\n\n// Example.\nwindowConnection.on('track', (event: WindowRTCEvent) =\u003e {\n  const sender: string = event.sender;\n  const receiver: string = event.receiver;\n  const trackEvent: RTCTrackEvent = event.payload;\n});\n```\n\n## Using `canvas`\n\nWhen using `canvas` to get an image to send to other windows, application should set the `frameRequestRate` parameter of `canvas.captureStream` to a high framerate to avoid latency at the receiver side.\n\n### Setting `frameRequestRate`\n\n![alt good_performance](https://github.com/benoitlahoz/electron-window-rtc/blob/main/assets/electron-demo-240fps.jpg)\n\n**Fig. 1:** _`const stream = canvas.captureStream(240);` in `Sender` window doesn't induce latency. Look at the result of `performance.now()` sent by the `Sender`._\n\n### Withour setting `frameRequestRate`\n\n![alt bad_performance](https://github.com/benoitlahoz/electron-window-rtc/blob/main/assets/electron-demo.jpg)\n\n**Fig. 2:** _Without setting `frameRequestRate`: a latency of ~30ms is induced._\n\n## Known Issues\n\n- In the Electron example provided, reloading `Sender` window takes a lot of time for `Receiver` window to reconnect, whereas the `requestOffer` method allows reconnecting quickly on `Receiver` window's reload.\n- Closing and opening again windows has not been tested: it may involve some logic in the `main process` to be integrated in `WindowRTCMain`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitlahoz%2Felectron-window-rtc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitlahoz%2Felectron-window-rtc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitlahoz%2Felectron-window-rtc/lists"}