

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

# 設定目的地
<a name="configure-ingestion"></a>

建立 Kinesis Video Streams 資源後，您需要告知訊號頻道要將其儲存到哪個串流。

如果您想要刪除訊號頻道或串流，您必須先將它們取消連結。請參閱 [取消連結訊號頻道和串流](#ingest-unlink)。

## 連結訊號頻道和串流
<a name="ingestion-link"></a>

使用 [UpdateMediaStorageConfiguration](https://docs.aws.amazon.com//kinesisvideostreams/latest/dg/API_UpdateMediaStorageConfiguration.html) API，並為您要連結的 Kinesis Video Streams 資源輸入 ARNs。

**重要**  
一旦`StorageStatus`啟用，就不會再發生對peer-to-peer（主要檢視者） 連線。對等直接連線至儲存工作階段。您必須呼叫 `JoinStorageSession` API 來觸發 SDP 優惠傳送，並在對等和儲存工作階段之間建立連線。

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

**注意**  
Kinesis Video Streams 目前不支援此操作 AWS 管理主控台。

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

遵循 AWS CLI 索引標籤中的指示。

------
#### [ 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)。

在 中執行 `Update-Media-Storage-Configuration`命令 AWS CLI：

```
aws kinesisvideo update-media-storage-configuration \
  --channel-arn arn:aws:kinesisvideo:us-west-2:123456789012:channel/YourChannelName/1234567890123 \
  --media-storage-configuration \
    StreamARN="arn:aws:kinesisvideo:us-west-2:123456789012:stream/YourStreamName/1234567890123",Status="ENABLED" \
  --region "us-west-2"
```

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

此程式碼片段說明如何使用適用於 JavaScript 的 AWS SDK v2 設定訊號頻道，將媒體擷取至指定的 Kinesis 影片串流。語法將與其他 AWS SDKs不同，但一般流程將相同。在 [GitHub](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/blob/master/examples/updateMediaStorageConfiguration.js) 上檢視完整的程式碼範例。

建立 Kinesis Video Streams 用戶端。這是用來呼叫 [UpdateMediaStorageConfiguration](https://docs.aws.amazon.com//kinesisvideostreams/latest/dg/API_UpdateMediaStorageConfiguration.html) API 的用戶端。

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

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

```
await kinesisVideoClient
    .updateMediaStorageConfiguration({
        ChannelARN: 'YourChannelARN',
        MediaStorageConfiguration: {
            Status: 'ENABLED',
            StreamARN: 'YourStreamARN',
        },
    })
    .promise();
```

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

展開 **WebRTC 擷取和儲存**節點，輸入串流的名稱，然後選擇**更新媒體儲存組態**。頻道會設定為將媒體擷取至指定的串流。

------

## 取消連結訊號頻道和串流
<a name="ingest-unlink"></a>

**重要**  
在訊號頻道或串流彼此取消連結之前，您無法將其刪除。

如果您不希望訊號頻道的媒體擷取到串流，請使用 [UpdateMediaStorageConfiguration](https://docs.aws.amazon.com//kinesisvideostreams/latest/dg/API_UpdateMediaStorageConfiguration.html) API 來取消連結 Kinesis Video Streams 資源。通道取消連結後，可以繼續直接peer-to-peer連線。

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

**注意**  
Kinesis Video Streams 目前不支援此操作 AWS 管理主控台。

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

遵循 AWS CLI 索引標籤中的指示。

------
#### [ 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)。

在 中執行 `Update-Media-Storage-Configuration`命令 AWS CLI：

```
aws kinesisvideo update-media-storage-configuration \
  --channel-arn arn:aws:kinesisvideo:us-west-2:123456789012:channel/YourChannelName/1234567890123 \
  --media-storage-configuration \
    StreamARN="null",Status="DISABLED" \
  --region "us-west-2"
```

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

此程式碼片段說明如何使用適用於 JavaScript 的 AWS SDK v2 設定訊號頻道，將媒體擷取至指定的 Kinesis 影片串流。語法將與其他 AWS SDKs不同，但一般流程將相同。在 [GitHub](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/blob/master/examples/updateMediaStorageConfiguration.js) 上檢視完整的程式碼範例。

建立 Kinesis Video Streams 用戶端。這是用來呼叫 [UpdateMediaStorageConfiguration](https://docs.aws.amazon.com//kinesisvideostreams/latest/dg/API_UpdateMediaStorageConfiguration.html) API 的用戶端。

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

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

```
await kinesisVideoClient
    .updateMediaStorageConfiguration({
        ChannelARN: 'YourChannelARN',
        MediaStorageConfiguration: {
            Status: 'DISABLED',
            StreamARN: 'null',
        },
    })
    .promise();
```

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

展開 **WebRTC 擷取和儲存**節點，確認**串流名稱**欄位為空白，然後選擇**更新媒體儲存組態**。頻道將不再設定為將媒體擷取至指定的串流。

------