您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

呼叫 SDK 概述Calling SDK overview

最终用户设备可以通过呼叫 SDK 来驱动语音和视频通信体验。The Calling SDK enables end-user devices to drive voice and video communication experiences. 本页提供呼叫功能的详细说明,包括平台和浏览器支持信息。This page provides detailed descriptions of Calling features, including platform and browser support information. 若要立即开始,请查看呼叫快速入门呼叫 hero 示例To get started right away, please check out Calling quickstarts or Calling hero sample.

开始开发后,请查看已知问题页,找到我们正在处理的 bug。Once you've started development, check out the known issues page to find bugs we're working on.

呼叫 SDK 的关键功能:Key features of the Calling SDK:

  • 寻址 - Azure 通信服务提供通用标识用于对通信终结点进行寻址。Addressing - Azure Communication Services provides generic identities that are used to address communication endpoints. 客户端使用这些标识对服务进行身份验证并相互通信。Clients use these identities to authenticate to the service and communicate with each other. 在可让客户端洞察谁已连接到呼叫终结点(名单)的呼叫 API 中会使用这些标识。These identities are used in Calling APIs that provides clients visibility into who is connected to a call (the roster).
  • 加密 - 呼叫 SDK 将加密流量并防止在线篡改。Encryption - The Calling SDK encrypts traffic and prevents tampering on the wire.
  • 设备管理和媒体 - 呼叫 SDK 提供所需的工具用于绑定到音频和视频设备、对内容进行编码以通过通信数据平面高效传输,并在指定的输出设备和视图中呈现内容。Device Management and Media - The Calling SDK provides facilities for binding to audio and video devices, encodes content for efficient transmission over the communications dataplane, and renders content to output devices and views that you specify. 此外,还提供 API 用于屏幕和应用程序共享。APIs are also provided for screen and application sharing.
  • PSTN - 呼叫 SDK 可以使用你在 Azure 门户中获取的电话号码或者以编程方式,通过传统的公共交换电话系统接收和发起语音呼叫。PSTN - The Calling SDK can receive and initiate voice calls with the traditional publically switched telephony system, using phone numbers you acquire in the Azure portal or programmatically.
  • Teams 会议 - 呼叫 SDK 可以加入 Teams 会议,并与 Teams 语音和视频数据平面交互。Teams Meetings - The Calling SDK can join Teams meetings and interact with the Teams voice and video dataplane.
  • 通知 - 呼叫 SDK 提供可以在接到来电时通知客户端的 API。Notifications - The Calling SDK provides APIs allowing clients to be notified of an incoming call. 如果你的应用不是在前台运行,可以使用触发弹出式通知(“toast”)的模式来通知最终用户接到了来电。In situations where your app is not running in the foreground, patterns are available to fire pop-up notifications ("toasts") to inform end-users of an incoming call.

详细功能Detailed capabilities

下面列出了 Azure 通信服务呼叫 SDK 中当前提供的功能集。The following list presents the set of features which are currently available in the Azure Communication Services Calling SDKs.

功能组Group of features 功能Capability JSJS Java (Android)Java (Android) Objective-C (iOS)Objective-C (iOS)
核心功能Core Capabilities 在两个用户之间启动一对一呼叫Place a one-to-one call between two users ✔️✔️ ✔️✔️ ✔️✔️
为两个以上的用户(最多 350 个用户)启动组呼叫Place a group call with more than two users (up to 350 users) ✔️✔️ ✔️✔️ ✔️✔️
将两个用户的一对一呼叫升级为两个以上用户的组呼叫Promote a one-to-one call with two users into a group call with more than two users ✔️✔️ ✔️✔️ ✔️✔️
在一个组呼叫开始后加入它Join a group call after it has started ✔️✔️ ✔️✔️ ✔️✔️
邀请其他 VoIP 参与者加入正在进行的组呼叫Invite another VoIP participant to join an ongoing group call ✔️✔️ ✔️✔️ ✔️✔️
Mid 呼叫控制Mid call control 打开/关闭视频Turn your video on/off ✔️✔️ ✔️✔️ ✔️✔️
将麦克风静音/取消静音Mute/Unmute mic ✔️✔️ ✔️✔️ ✔️✔️
切换照相机Switch between cameras ✔️✔️ ✔️✔️ ✔️✔️
本地保持/取消保持Local hold/un-hold ✔️✔️ ✔️✔️ ✔️✔️
活动说话人Active speaker ✔️✔️ ✔️✔️ ✔️✔️
选择通话扬声器Choose speaker for calls ✔️✔️ ✔️✔️ ✔️✔️
选择呼叫麦克风Choose microphone for calls ✔️✔️ ✔️✔️ ✔️✔️
显示参与者的状态Show state of a participant
空闲、早期媒体、正在连接、已连接、等候接听、接听中、已断开连接Idle, Early media, Connecting, Connected, On hold, In Lobby, Disconnected
✔️✔️ ✔️✔️ ✔️✔️
显示呼叫的状态Show state of a call
早期媒体、正在传入、正在连接、正在响铃、已连接、通话保持、正在断开连接、已断开连接Early Media, Incoming, Connecting, Ringing, Connected, Hold, Disconnecting, Disconnected
✔️✔️ ✔️✔️ ✔️✔️
显示参与者是否静音Show if a participant is muted ✔️✔️ ✔️✔️ ✔️✔️
显示参与者退出通话的原因Show the reason why a participant left a call ✔️✔️ ✔️✔️ ✔️✔️
屏幕共享Screen sharing 在应用程序中共享整个屏幕Share the entire screen from within the application ✔️✔️
共享特定的应用程序(从正在运行的应用程序列表中)Share a specific application (from the list of running applications) ✔️✔️
从打开的选项卡列表中共享 web 浏览器选项卡Share a web browser tab from the list of open tabs ✔️✔️
参与者可以查看远程屏幕共享Participant can view remote screen share ✔️✔️ ✔️✔️ ✔️✔️
名单Roster 列出参与者List participants ✔️✔️ ✔️✔️ ✔️✔️
删除参与者Remove a participant ✔️✔️ ✔️✔️ ✔️✔️
PSTNPSTN 启动与 PSTN 参与者的一对一呼叫Place a one-to-one call with a PSTN participant ✔️✔️ ✔️✔️ ✔️✔️
与 PSTN 参与者进行组呼叫Place a group call with PSTN participants ✔️✔️ ✔️✔️ ✔️✔️
将 PSTN 参与者的一对一呼叫升级为组呼叫Promote a one-to-one call with a PSTN participant into a group call ✔️✔️ ✔️✔️ ✔️✔️
以 PSTN 参与者身份在组呼叫中拨出Dial-out from a group call as a PSTN participant ✔️✔️ ✔️✔️ ✔️✔️
常规General 使用音频测试服务测试麦克风、扬声器和照相机(可通过呼叫 8:echo123 使用)Test your mic, speaker, and camera with an audio testing service (available by calling 8:echo123) ✔️✔️ ✔️✔️ ✔️✔️
设备管理Device Management 请求使用音频和/或视频的权限Ask for permission to use audio and/or video ✔️✔️ ✔️✔️ ✔️✔️
获取相机列表Get camera list ✔️✔️ ✔️✔️ ✔️✔️
设置相机Set camera ✔️✔️ ✔️✔️ ✔️✔️
获取所选相机Get selected camera ✔️✔️ ✔️✔️ ✔️✔️
获取麦克风列表Get microphone list ✔️✔️
设置麦克风Set microphone ✔️✔️
获取所选麦克风Get selected microphone ✔️✔️
获取扬声器列表Get speakers list ✔️✔️
设置扬声器Set speaker ✔️✔️
获取所选扬声器Get selected speaker ✔️✔️
视频渲染Video Rendering 在多个位置(本地相机或远程流)渲染单个视频Render single video in many places (local camera or remote stream) ✔️✔️ ✔️✔️ ✔️✔️
设置/更新缩放模式Set / update scaling mode ✔️✔️ ✔️✔️ ✔️✔️
渲染远程视频流Render remote video stream ✔️✔️ ✔️✔️ ✔️✔️

呼叫 SDK 流式传输支持Calling SDK streaming support

通信服务呼叫 SDK 支持以下流式传输配置:The Communication Services Calling SDK supports the following streaming configurations:

限制Limit WebWeb Android/iOSAndroid/iOS
# 个可同时发送的传出数据流# of outgoing streams that can be sent simultaneously 1 个视频或 1 个屏幕共享1 video or 1 screen sharing 1 个视频 + 1 个屏幕共享1 video + 1 screen sharing
# 个可同时呈现的传入数据流# of incoming streams that can be rendered simultaneously 1 个视频或 1 个屏幕共享1 video or 1 screen sharing 6 个视频 + 1 个屏幕共享6 video + 1 screen sharing

呼叫 SDK 超时Calling SDK timeouts

以下超时适用于通信服务呼叫 SDK:The following timeouts apply to the Communication Services Calling SDKs:

操作Action 超时(秒)Timeout in seconds
重新连接/删除参与者Reconnect/removal participant 120120
在调用中添加或删除新的模态(启动/停止视频或屏幕共享)Add or remove new modality from a call (Start/stop video or screen sharing) 4040
呼叫转移操作超时Call Transfer operation timeout 6060
1:1 呼叫建立超时1:1 call establishment timeout 8585
组呼叫建立超时Group call establishment timeout 8585
PSTN 呼叫建立超时PSTN call establishment timeout 115115
将 1:1 呼叫升级到组呼叫超时Promote 1:1 call to a group call timeout 115115

OS 和浏览器提供的 JavaScript 呼叫 SDK 支持JavaScript Calling SDK support by OS and browser

下表显示了当前可用的一组受支持的浏览器。The following table represents the set of supported browsers which are currently available. 除非另有说明,否则我们支持浏览器最新的三个版本。We support the most recent three versions of the browser unless otherwise indicated.

平台Platform ChromeChrome Safari*Safari* Edge (Chromium)Edge (Chromium)
AndroidAndroid ✔️✔️
iOSiOS ✔️****✔️****
macOS***macOS*** ✔️✔️ ✔️**✔️**
Windows***Windows*** ✔️✔️ ✔️✔️
Ubuntu/LinuxUbuntu/Linux ✔️✔️

*支持 Safari 版本 13.1+,但 Safari 不支持一对一呼叫。*Safari versions 13.1+ are supported, 1:1 calls are not supported on Safari.

**Safari 14+/macOS 11+ 需要传出视频支持。**Safari 14+/macOS 11+ needed for outgoing video support.

***无论浏览器版本如何,仅桌面平台(Windows、macOS 和 Linux)支持传出屏幕共享,而任何移动平台(Android、iOS、iPad 和平板电脑)均不支持传出屏幕共享。***Outgoing screen sharing is supported only on desktop platforms (Windows, macOS, and Linux), regardless of the browser version, and is not supported on any mobile platform (Android, iOS, iPad, and tablets).

****Safari 上的一个 iOS 应用无法枚举/选择麦克风和扬声器设备(例如,蓝牙);这是 OS 的限制,且始终只有一个设备。****An iOS app on Safari can't enumerate/select mic and speaker devices (for example, Bluetooth); this is a limitation of the OS, and there's always only one device.

调用客户端 - 浏览器安全模型Calling client - browser security model

通过 HTTPS 的用户 WebRTCUser WebRTC over HTTPS

WebRTC API(如 getUserMedia)要求通过 HTTPS 处理调用这些 API 的应用。WebRTC APIs like getUserMedia require that the app that calls these APIs is served over HTTPS.

对于本地开发,可使用 http://localhostFor local development, you can use http://localhost.

在 iframe 中嵌入通信服务调用 SDKEmbed the Communication Services Calling SDK in an iframe

各种浏览器正在采用新的权限策略(也称为功能策略)。A new permissions policy (also called a feature policy) is being adopted by various browsers. 此策略通过控制应用程序如何通过跨源 iframe 元素访问设备的摄像头和麦克风来影响调用方案。This policy affects calling scenarios by controlling how applications can access a device's camera and microphone through a cross-origin iframe element.

如果要使用 iframe 从其他域托管应用的一部分,则必须将具有正确值的 allow 属性添加到 iframe。If you want to use an iframe to host part of the app from a different domain, you must add the allow attribute with the correct value to your iframe.

例如,此 iframe 允许摄像头和麦克风访问:For example, this iframe allows both camera and microphone access:

<iframe allow="camera *; microphone *">

后续步骤Next steps

有关详细信息,请参阅以下文章:For more information, see the following articles: