Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
v0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
disoul committed May 15, 2020
1 parent 64e2245 commit 4868918
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 31 deletions.
26 changes: 13 additions & 13 deletions Docs/cn/basic_call.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sidebar_label: 实现基本通话
> 由于浏览器的安全策略对除 127.0.0.1 以外的 HTTP 地址作了限制,Agora Web SDK NG 仅支持 HTTPS 协议或者 http://localhost(http://127.0.0.1)。请勿使用 HTTP 协议在 http://localhost(http://127.0.0.1) 之外访问你的项目。
## 常用对象
在使用 Agora Web SDK NG 时,你会经常用到以下两种对象
在使用 Agora Web SDK NG 时,你会经常用到以下三种对象

- [AgoraRTCClient](/api/en/interfaces/iagorartcclient.html) 对象,代表一个本地客户端。`AgoraRTCClient` 类的方法提供了音视频通话的主要功能,例如加入频道、发布音视频轨道等。
- [LocalTrack](/api/en/interfaces/ilocalaudiotrack.html) 对象 和 [RemoteTrack](/api/en/interfaces/iremotetrack.html) 对象,代表本地和远端的音视频轨道对象。音视频轨道对象用于播放等音视频相关的控制。
Expand All @@ -20,13 +20,13 @@ sidebar_label: 实现基本通话
一次简单的音视频通话的步骤一般如下:
1. 根据项目的 `APP ID` 创建一个本地客户端 `AgoraRTCClient` 对象。
2. 通过 `AgoraRTCClient.join` 加入到一个指定的频道中。
3. 通过采集自己的摄像头/麦克风,分别创建一个 `CameraVideoTrack` 对象(本地视频轨道对象)和一个 `MicrophoneAudioTrack` 对象(本地音频轨道对象)。
4. 通过 `AgoraRTCClient.publish` 将刚刚创建的本地音视频轨道对象发布到频道中
3. 通过麦克风采集的音频创建一个 `MicrophoneAudioTrack` 对象(本地音频轨道对象);通过摄像头采集的视频创建一个 `CameraVideoTrack` 对象(本地视频轨道对象)。
4. 通过 `AgoraRTCClient.publish` 将创建的本地音视频轨道对象发布到频道中

当有其他用户加入频道并且也发布音视频轨道时:
1. SDK 会触发 `client.on("user-published")` 事件,在这个事件回调函数的参数中你可以拿到远端用户对象 `AgoraRTCRemoteUser`,表示这个用户刚刚发布了音视频轨道。
2. 通过 `subscribe` 订阅我们刚刚获取到的 `AgoraRTCRemoteUser`
3. 订阅完成后,访问 `AgoraRTCRemoteUser.audioTrack` / `AgoraRTCRemoteUser.videoTrack` 即可获取到 `RemoteAudioTrack`(远端音频轨道对象) / `RemoteVideoTrack`(远端视频轨道对象)。
2. 通过 `AgoraRTCClient.subscribe` 订阅我们刚刚获取到的 `AgoraRTCRemoteUser`
3. 订阅完成后,访问 `AgoraRTCRemoteUser.audioTrack` `AgoraRTCRemoteUser.videoTrack` 即可获取到 `RemoteAudioTrack`(远端音频轨道对象) `RemoteVideoTrack`(远端视频轨道对象)。

为方便起见,我们为下面要用到的示例代码预定义了两个变量和一个函数,接下来的示例代码都包裹在这个函数中。此步骤不是必须的,你可以根据你的项目有其他的实现。

Expand Down Expand Up @@ -57,7 +57,7 @@ async function startBasicCall() {
startBasicCall();
```

### 创建本地客户端
### 1.创建本地客户端

```js
rtc.client = AgoraRTC.createClient({ mode: "rtc", codec: "h264" });
Expand All @@ -67,7 +67,7 @@ rtc.client = AgoraRTC.createClient({ mode: "rtc", codec: "h264" });
- `mode` 用于设置[频道场景](https://docs.agora.io/cn/Agora%20Platform/terms?platform=All%20Platforms%23live-broadcast-core-concepts#%E9%A2%91%E9%81%93%E6%A8%A1%E5%BC%8F)。一对一或多人通话中,建议设为 `"rtc"`,使用通信场景;互动直播中,建议设为 `"live"`,使用直播场景。Agora Web SDK NG 会根据使用场景的不同实行不同的优化策略
- `codec` 用于设置浏览器使用的编解码格式。如果你需要使用 Safari 12.1 及之前版本,将该参数设为 `"h264"`;其他情况我们推荐使用 `"vp8"`

### 加入目标频道
### 2.加入目标频道

```js
const uid = await rtc.client.join(options.appId, options.channel, options.token, null);
Expand All @@ -78,17 +78,17 @@ const uid = await rtc.client.join(options.appId, options.channel, options.token,
`join` 方法中需要注意以下参数:
- `appid`: 上文中提到的项目 App ID,如果不清楚,请参考[前提条件](setup.md#前提条件)
- `channel`: 频道名,长度在 64 字节以内的字符串。
> - 在我们的示例项目中,`channel` 的值为 `demo_channel_name`
> - 如果你启用了 App 证书,请注意这里传入的 channel 值和生成 Token 的 channel 值需要保持一致。
- `token`: 该参数为可选。如果你的 Agora 项目开启了 App 证书,你需要在该参数中传入一个 Token,详见 [使用 Token](https://docs.agora.io/cn/Agora%20Platform/token?platform=All%20Platforms#%E4%BD%BF%E7%94%A8-token)
- 在测试环境,我们推荐使用控制台生成临时 Token,详见 [获取临时 Token](https://docs.agora.io/cn/Agora%20Platform/token?platform=All%20Platforms%23get-a-temporary-token#%E8%8E%B7%E5%8F%96%E4%B8%B4%E6%97%B6-token)
- 在生产环境,我们推荐你在自己的服务端生成 Token,详见 [生成 Token](https://docs.agora.io/cn/Interactive%20Broadcast/token_server)
> 在我们的示例项目中,为了叙述方便,没有开启 App 证书,所以不需要校验 Token,`token` 的值为 `null`
- `uid`:用户 ID,频道内每个用户的 UID 必须是唯一的。你可以通过这个参数指定用户的 UID,一般来说这里都填 `null`,表示让 Agora 自动分配一个 UID 并在 `join` 的结果中返回。

> - 在我们的示例项目中,`channel` 的值为 `demo_channel_name`
> - 在我们的示例项目中,为了叙述方便,没有开启 App 证书,所以不需要校验 Token,`token` 的值为 `null`。如果你启用了 App 证书,请注意上面传入的 `channel` 值和生成 Token 的 `channel` 值需要保持一致。
更多的 API 介绍和注意事项请参考 [AgoraRTCClient.join](/api/cn/interfaces/iagorartcclient.html#join) 接口中的参数描述。

### 创建并发布本地音视频轨道
### 3.创建并发布本地音视频轨道

```js
// 通过采集麦克风创建本地音频轨道对象
Expand All @@ -111,7 +111,7 @@ console.log("publish success!");
- [createMicrophoneAudioTrack](/api/cn/interfaces/iagorartc.html#createmicrophoneaudiotrack)
- [createCameraVideoTrack](/api/cn/interfaces/iagorartc.html#createcameravideotrack)

### 订阅远端用户
### 4.订阅远端用户
当远端用户发布音视频轨道时,会触发 `client.on("user-published")` 事件,我们需要通过 `client.on` 监听该事件并在回调中订阅新加入的远端用户。

> 我们建议在创建客户端对象之后立即监听事件,以避免有些事件因为没有监听而错过没有收到。放在这里介绍是因为叙述顺序。
Expand Down Expand Up @@ -175,7 +175,7 @@ rtc.client.on("user-unpublished", user => {
});
```

### 离开频道
### 5.离开频道
一般来说,离开频道有以下几个步骤:
1. 销毁创建的本地音视频轨道,解除网页对摄像头和麦克风的访问。
2. 手动销毁之前动态创建的 DIV 节点。
Expand Down
6 changes: 3 additions & 3 deletions Docs/cn/cdn_streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ sidebar_label: 推流到 CDN

## 前提条件
请确保已开通 CDN 旁路推流功能,步骤如下:
1. 登录[控制台](https://console.agora.io),点击左侧导航栏 ![img](https://web-cdn.agora.io/docs-files/1551250582235) 按钮进入**产品用量**页面。
1. 登录[控制台](https://console.agora.io),点击左侧导航栏 ![img](assets/usage.jpeg) 按钮进入**产品用量**页面。
2. 在页面左上角展开下拉列表选择需要开通 CDN 旁路推流的项目,然后点击旁路推流下的**分钟数**
![](https://web-cdn.agora.io/docs-files/1569297956098)
![](assets/enable_cdn_streaming.png)
3. 点击**开启旁路推流服务**
4. 点击**应用** 即可开通旁路推流服务,并得到 500 个最大并发频道数。
4. 点击**应用**即可开通旁路推流服务,并得到 500 个最大并发频道数。

> 并发频道数 N,指用户可以同时使用 N 路流进行推流转码。
Expand Down
4 changes: 2 additions & 2 deletions Docs/cn/screensharing.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ AgoraRTC.getElectronScreenSources().then(sources => {
```
`sources` 是一个 `source` 对象的列表,`source` 里包含了分享源的信息和 `sourceId``source` 的属性如下:

![](assets/source.png)
![](assets/sources.png)

- `id`: 即 `sourceId`
- `name`:屏幕源的名字
- `thumbnail`:屏幕源的快照

2. 根据 `source` 的属性,(用 html 和 css)绘制选择界面,让用户选择要共享的屏幕源。`source` 的属性与屏幕共享的选择界面对应关系如下:

![](assets/electron2.png)
![](assets/electron2.jpeg)

3. 获取用户选择的 `sourceId`
4. 调用 [createScreenVideoTrack](/api/cn/interfaces/iagorartc.html#createscreenvideotrack) 时将 `sourceId` 填入 `electronScreenSourceId`,就能创建相应的屏幕共享流了。
Expand Down
9 changes: 5 additions & 4 deletions Docs/cn/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ sidebar_label: 集成 SDK
本文指导你如何准备开发环境并将 Agora Web SDK NG 集成到你的项目中。

## 前提条件
在使用 Agora Web SDK NG 之前,你需要:
- [注册](https://sso.agora.io/cn/signup?_ga=2.63500074.482805615.1577072824-849535803.1560925029) 一个有效的 Agora 账号。
在使用 Agora Web SDK NG 之前,你需要
- [注册](https://sso.agora.io/cn/signup?_ga=2.63500074.482805615.1577072824-849535803.1560925029)一个有效的 Agora 账号。
-[控制台](https://console.agora.io/)创建一个项目,鉴权机制选择 **APP ID**
- 摄像头和麦克风设备。
- 如果你的网络环境部署了防火墙,请根据[应用企业防火墙限制](https://docs.agora.io/cn/Agora%20Platform/firewall?platform=All%20Platforms)打开相关端口。
Expand All @@ -33,6 +33,7 @@ const client = AgoraRTC.createClient({ mode: "live", codec: "vp8" });
```

如果你使用 Typescript, 还可以引入 SDK 中的类型对象:

```typescript
import AgoraRTC, { IAgoraRTCClient } from "agora-rtc-sdk-ng"

Expand All @@ -43,7 +44,7 @@ const client: IAgoraRTCClient = AgoraRTC.createClient({ mode: "live", codec: "vp
该方法无需下载安装包。在项目 html 文件中,添加如下代码:

```html
<script src="https://download.agora.io/sdk/web/AgoraRTC_N-0.1.7.js"></script>
<script src="https://download.agora.io/sdk/web/AgoraRTC_N-0.1.8.js"></script>
```

### 方法 3. 手动下载 SDK
Expand All @@ -54,7 +55,7 @@ const client: IAgoraRTCClient = AgoraRTC.createClient({ mode: "live", codec: "vp
3. 在项目文件中,将如下代码添加到 html 中:

```html
<script src="./AgoraRTC_N-0.1.7.js"></script>
<script src="./AgoraRTC_N-0.1.8.js"></script>
```

> - 在方法 2 和方法 3 中,SDK 都会在全局导出一个 `AgoraRTC` 对象,直接访问这个对象即可操作 SDK。
Expand Down
Binary file added Docs/en/assets/enable_cdn_streaming-en.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/en/assets/enable_cdn_streaming.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/en/assets/usage.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Docs/en/cdn_streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ When multiple hosts are in a channel in CDN live streaming, [transcoding](https:
## Prerequisites
Ensure that you enable the RTMP Converter service before using this function.

1. Log in to [Console](https://console.agora.io), and click ![img](https://web-cdn.agora.io/docs-files/1551250582235) in the left navigation menu to go to the **Products & Usage** page.
1. Log in to [Console](https://console.agora.io), and click ![img](assets/usage.jpeg) in the left navigation menu to go to the **Products & Usage** page.
2. Select a project from the drop-down list in the upper-left corner, and click **Duration** under RTMP Converter.
![](assets/enable_cdn_streaming-en.png)
3. Click **Enable RTMP Converter**.
4. Click **Apply** to enable the RTMP Converter service and get 500 max concurrent channels.

Expand Down
4 changes: 2 additions & 2 deletions Docs/en/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const client: IAgoraRTCClient = AgoraRTC.createClient({ mode: "live", codec: "vp
Add the following code to the line before `<style>` in your project.

```html
<script src="https://download.agora.io/sdk/web/AgoraRTC_N-0.1.7.js"></script>
<script src="https://download.agora.io/sdk/web/AgoraRTC_N-0.1.8.js"></script>
```

### Method 3: Through the Agora website
Expand All @@ -55,7 +55,7 @@ Add the following code to the line before `<style>` in your project.

3. Add the following code to the line before `<style>` in your project.
```html
<script src="./AgoraRTC_N-0.1.7.js"></script>
<script src="./AgoraRTC_N-0.1.8.js"></script>
```

> - In method 2 and 3, the SDK fully exports an `AgoraRTC` object. You can visit the `AgoraRTC` object to operate the Agora Web SDK NG.
Expand Down
6 changes: 0 additions & 6 deletions Release/AgoraRTC_N-0.1.7.js

This file was deleted.

6 changes: 6 additions & 0 deletions Release/AgoraRTC_N-0.1.8.js

Large diffs are not rendered by default.

0 comments on commit 4868918

Please sign in to comment.