

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 建立訊號頻道
<a name="ingestion-create-channel"></a>

Kinesis Video Streams with WebRTC 訊號頻道有助於交換在 WebRTC 用戶端之間建立和維護peer-to-peer連線所需的訊號訊息。它處理工作階段描述協定 (SDP) 提供和回應工作階段參數的交涉，以及交換互動式連線建立 (ICE) 候選項目以取得網路資訊。

若要建立訊號頻道，請呼叫 [CreateSignalingChannel](https://docs.aws.amazon.com//kinesisvideostreams/latest/dg/API_CreateSignalingChannel.html) API。此頁面將示範如何使用 AWS 管理主控台 AWS CLI和其中一個 AWS SDKs 叫用該 API。

**重要**  
請記下頻道 ARN，您稍後會需要它。

------
#### [ AWS 管理主控台 ]

請執行下列操作：

1. 在 https：//[https://console.aws.amazon.com/kinesisvideo/home/\$1/signalingChannels](https://console.aws.amazon.com//kinesisvideo/home/#/signalingChannels) 開啟 **Kinesis Video Streams Signaling Channels** 主控台。

1. 選擇 **Create signaling channel (建立訊號頻道)**。

1. 在**建立新的訊號頻道**頁面上，輸入訊號頻道的名稱。

   將預設**Time-to-live(Ttl)** 值保留為 60 秒。

   選擇 **Create signaling channel (建立訊號頻道)**。

1. 建立訊號頻道後，請檢閱頻道詳細資訊頁面上的詳細資訊。

------
#### [ AWS CLI ]

確認您已安裝 AWS CLI 並設定 。如需詳細資訊，請參閱[「AWS Command Line Interface 使用者指南」](https://docs.aws.amazon.com//cli/latest/userguide/)。

如需安裝說明，請參閱[AWS Command Line Interface 《 使用者指南》](https://docs.aws.amazon.com//cli/latest/userguide/getting-started-install.html#getting-started-install-instructions)。安裝後，使用登入資料和區域[設定 AWS CLI](https://docs.aws.amazon.com//cli/latest/userguide/getting-started-quickstart.html#getting-started-quickstart-new)。

或者，開啟已安裝並設定 AWS CLI 的 AWS CloudShell 終端機。如需詳細資訊，請參閱 [AWS CloudShell 使用者指南](https://docs.aws.amazon.com//cloudshell/latest/userguide/welcome.html#how-to-get-started)。

使用 執行下列 [Create-Signaling-Channel](https://docs.aws.amazon.com//cli/latest/reference/kinesisvideo/create-signaling-channel.html) 命令 AWS CLI：

```
aws kinesisvideo create-signaling-channel \
  --channel-name "YourChannelName" \
  --region "us-west-2"
```

回應如下所示：

```
{ 
    "ChannelARN": "arn:aws:kinesisvideo:us-west-2:123456789012:channel/YourChannelName/1234567890123"
}
```

------
#### [ AWS SDK ]

此程式碼片段說明如何使用適用於 JavaScript 的 AWS SDK v2 建立 Kinesis Video Streams with WebRTC 訊號頻道。語法將與其他 AWS SDKs不同，但一般流程將相同。在 [GitHub](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/blob/master/examples/createSignalingChannel.js) 上檢視完整的程式碼範例。

建立 Kinesis Video Streams 用戶端。這是用來呼叫 `CreateSignalingChannel` API 的用戶端。

```
const clientConfig = {
    accessKeyId: 'YourAccessKey',
    secretAccessKey: 'YourSecretKey',
    region: 'us-west-2'
};
const kinesisVideoClient = new AWS.KinesisVideo(clientConfig);
```

使用 用戶端呼叫 `CreateSignalingChannel` API。

```
const createSignalingChannelResponse = await kinesisVideoClient
    .createSignalingChannel({
        ChannelName: 'YourChannelName',
    })
    .promise();
```

列印回應。

```
console.log(createSignalingChannelResponse.ChannelARN);
```

具有此程式碼範例的即時網頁可在 [GitHub](https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-js/examples/index.html) 上使用。輸入您的區域、 AWS 憑證和訊號頻道的名稱。

選取**建立頻道**。

------