@deltachat/calls-webapp

中文文档
0.12.1-beta-debug发布于 2026/02/18ES Module近 30 天下载 2366

P2P videocalls via WebRTC for integration into Delta Chat clients.

原始使用文档
文档目录9 节
  1. How it works
  2. Integrating
  3. Contributing
  4. Installing Dependencies
  5. Checking code format
  6. Testing the app in the browser
  7. Building
  8. Releasing
  9. Credits

Call

P2P videocalls via WebRTC for integration into Delta Chat clients.

How it works

Below is a sequence diagram of how Delta Chat works together with this app. If you see a block of text instead of a diagram, go here.

sequenceDiagram
    participant Alice as Alice's Delta Chat
    participant ATURN as Alice's TURN / STUN servers
    participant BTURN as Bob's TURN / STUN servers<br> (could be the same as Alice's)
    participant Bob as Bob's Delta Chat

    Note over Alice: Alice presses<br>"Start Call with Bob"
    Alice ->> ATURN: What's my public address?
    Alice ->> ATURN: Please relay my packets
    ATURN -->> Alice: Your address is<br>42.42.42.42:12345<br>(srflx candidate gathered)
    ATURN -->> Alice: I will relay your packets<br>(TURN (relay) candidate<br>gathered)
    Note over Alice: Wait for relay candidate<br>or for timeout
    Alice ->> Bob: (email) I want to start a call. My address is 42.42.42.42:12345,<br>or you can reach me at my TURN server.<br>(WebRTC offer)

    Note over Bob: Bob presses "Accept Call"
    Bob ->> BTURN: What's my public address?
    Bob ->> BTURN: Please relay my packets
    ATURN ->> Alice: BTW your other address is<br>42.42.42.43:54321
    BTURN -->> Bob: Your address is<br>43.43.43.43:55555<br>(srflx candidate gathered)
    BTURN -->> Bob: I will relay your packets<br>(TURN (relay) candidate<br>gathered)
    Note over Bob: Wait for relay candidate<br>or for timeout
    Bob ->> Alice: (email) Sure, let's have a call. My address is 43.43.43.43:55555,<br>or you can reach me at my TURN server.<br>(WebRTC answer)

    loop
        Alice <<-->> Bob: P2P video stream (if possible)
        Alice <<->> ATURN: relayed video stream<br>(if P2P not possible)
        ATURN <<->> BTURN: relayed video stream<br>(if P2P not possible)
        BTURN <<->> Bob: relayed video stream<br>(if P2P not possible)
    end

    BTURN ->> Bob: BTW your other address is<br>43.43.43.43:55556

    loop An additional WebRTC data channel can be established (via relay or P2P)<br>to promote more ICE candidates after the initial connection is established
        Alice ->> Bob: My other address is 42.42.42.43:54321
        Bob ->> Alice: My other address is 43.43.43.43:55556
    end

Integrating

To integrate into your Delta Chat client you need to provide a window.calls object with the following API:

  • startCall: (offerPayload: string) => void (implementation must call dc_place_outgoing_call chatmail core API)
  • acceptCall: (answerPayload: string) => void (implementation must call dc_accept_incoming_call chatmail core API)
  • endCall: () => void (implementation must call dc_end_call chatmail core API)
  • getIceServers: () => string | Promise<string> (returns a JSON string with array of ice server configurations as expected by https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setConfiguration)
  • getAvatar: () => string (returning the chat's avatar image URL; can be a regular URL or a data-URL, ex. "data:image/png;base64,...")

Commands are given to the app via URL hash:

  • #startCall: tells the app to generate an offer payload and call startCall(), this is how the app should be open when the user is starting an outgoing call.
  • #offerIncomingCall=PAYLOAD: tells the app to show the "Incoming call. Answer?" screen. Then, if the user clicks "Answer", generate a WebRTC answer to the offer provided in PAYLOAD, and call window.calls.acceptCall(webrtcAnswer). If the user declined the call, the app will invoke window.calls.endCall.
  • #acceptCall=PAYLOAD: same as #offerIncomingCall, but doesn't show the "Incoming call. Answer?" screen and instead automatically and immediately accepts the call.
  • #onAnswer=PAYLOAD: notifies the app that the outgoing call was accepted and provides the answer payload

IMPORTANT: PAYLOAD must be base64 encoded (NOTE: you might still need to URL-encode the base64 string to be a valid URL hash) before passing it to the app in the URL hash.

In order to start the app in audio-only mode initially, provide noOutgoingVideoInitially in the query (search) string of the initial URL, e.g. /index.html?noOutgoingVideoInitially#startCall.

In order to completely disable incoming and outgoing video, provide disableVideoCompletely in the query string of the URL. See https://github.com/deltachat/calls-webapp/issues/31.

Contributing

Installing Dependencies

After cloning this repo, install dependencies:

pnpm i

Checking code format

pnpm check

Testing the app in the browser

To test your work in your browser while developing:

pnpm start

Open the simulated instances in 2 separate tabs (the "share" button on the instance in the simulator). Then add #startCall to the end of the URL of one instance.

On macOS on Safari, you may not be able to give access to the camera to two tabs simultaneously; in this case, try Firefox.

Building

To build the app for releasing:

pnpm build

To package the app with developer tools inside to debug in Delta Chat, set the NODE_ENV environment variable to "debug":

NODE_ENV=debug pnpm build

The resulting optimized .html file is saved in dist/ folder.

Releasing

To automatically build and create a new GitHub release with the .html file:

git tag -a v1.0.1
git push origin v1.0.1

Credits

Inspired by Serverless WebRTC but built from scratch and much simpler: no data channel, file transfer and only browsers are supported.

See blog posts explaining the idea here:

版本与发布记录

@deltachat/calls-webapp 共发布 4 个版本,首次发布于 2025/10/13;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.12.1-beta-debuglatest2026/02/188 个月前
0.12.0-beta-debug2026/02/059 个月前
0.11.0-beta-debug2025/11/121 年前
0.10.0-beta-debug2025/10/131.1 年前

关于 @deltachat/calls-webapp 的常见问题

@deltachat/calls-webapp 是什么?

P2P videocalls via WebRTC for integration into Delta Chat clients.

如何安装 @deltachat/calls-webapp?

在项目目录运行 npm install @deltachat/calls-webapp,或使用 pnpm add / yarn add / bun add。

@deltachat/calls-webapp 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/deltachat__calls-webapp 是否存在。

@deltachat/calls-webapp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@deltachat/calls-webapp 可以商用吗?

@deltachat/calls-webapp 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@deltachat/calls-webapp 的下载量有多少?

根据 npm 官方下载统计,@deltachat/calls-webapp 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,366 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@deltachat/calls-webapp 还在维护吗?

最新版本 0.12.1-beta-debug 发布于 2026/02/18(8 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 2 个;首次发布于 2025/10/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。