> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XGameStreamingGetStreamAddedLatency

> XGameStreamingGetStreamAddedLatency

# XGameStreamingGetStreamAddedLatency

取得串流相關延遲的近期平均值。

## 語法

```cpp theme={null}
HRESULT XGameStreamingGetStreamAddedLatency(  
         XGameStreamingClientId client,  
         uint32_t* averageInputLatencyUs,  
         uint32_t* averageOutputLatencyUs,  
         uint32_t* standardDeviationUs  
)  
```

### 參數

*client*   \_In\_\
類型：XGameStreamingClientId

要查詢其延遲的串流用戶端裝置。

*averageInputLatencyUs*   \_Out\_\
類型：uint32\_t\*

在最近一段時間內，XBOX 遊戲接收輸入的平均延遲 (以微秒為單位)。

*averageOutputLatencyUs*   \_Out\_\
類型：uint32\_t\*

在最近一段時間內，遊戲畫面在用戶端裝置上轉譯的平均延遲 (以微秒為單位)。

*standardDeviationUs*   \_Out\_\
類型：uint32\_t\*

在最近一段時間內，延遲中所測得之抖動標準差的觀察平均值 (以微秒為單位)。

### 傳回值

類型：HRESULT

如果成功，則傳回 **S\_OK**；否則傳回錯誤碼。

#### 可能的錯誤

| 錯誤碼 | 錯誤值 | 錯誤原因 |
| - | - | - |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | XGameStreaming 執行階段尚未初始化。請先呼叫 [XGameStreamingInitialize](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminginitialize)，再呼叫其他 API。 |
| E\_GAMESTREAMING\_NO\_DATA | 0x89245402 | 要求的資料無法使用。資料稍後可能會可供使用。 |

如需錯誤碼清單，請參閱[錯誤碼](/zh-TW/reference/errorcodes)。

## 備註

<Note>在時間敏感的執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱[時間敏感的執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

<Note>如下所述，輸入和輸出延遲值測量的是不同的值，且可能從不同的來源計算而得。這些值預期不會相近，應分別看待。</Note>

`XGameStreamingGetStreamAddedLatency` 提供因遊戲串流而測得之延遲的相關資料。遊戲可利用此資料，進一步了解玩家在串流體驗中的感受。

請務必注意，這**不會**提供玩家可能察覺到的完整端對端延遲 (例如，它**不會**直接對應從按下連接至串流用戶端裝置之控制器上的按鈕，到轉譯出反映該輸入之新畫面為止的時間)。例如，下列元件**不**包含在這些測量中：

* 遊戲引擎轉譯時間
* 從傳遞至用戶端裝置進行轉譯，到玩家看到影像為止的時間
* 從用戶端裝置上控制器的 Bluetooth® 傳輸和解碼時間

相反地，輸入延遲包括：

* 遊戲串流應用程式處理從控制器接收之輸入所需的時間。
* 從遊戲串流應用程式透過網路傳輸至執行遊戲之伺服器的時間。

輸出延遲包括：

* 遊戲所轉譯之每個畫面的編碼時間。
* 透過網路將此畫面傳輸至玩家正在互動之應用程式的時間。
* 應用程式準備將畫面呈現給玩家時的解碼時間。

`XGameStreamingGetStreamAddedLatency` 是每隔幾秒更新一次的平均測量值。如需更精確的測量，可以使用 [XGameStreamingGetAssociatedFrame](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe) API。如需詳細資訊，請參閱[遊戲串流延遲補償深入探討](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive)。

## 需求

**標頭：** xgamestreaming.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [遊戲串流延遲補償深入探討](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive)
* [時間敏感的執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另請參閱

[XGameStreaming](/zh-TW/reference/system/xgamestreaming/xgamestreaming_members)\
[遊戲串流延遲補償概觀](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-overview)


## Related topics

- [XGameStreamingGetStreamAddedLatency](/reference/system/xgamestreaming/functions/xgamestreaminggetstreamaddedlatency.md)
- [Game streaming latency compensation deep dive](/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive.md)
- [XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members.md)
- [XGameStreamingGetAssociatedFrame](/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe.md)
- [Análisis en profundidad de la compensación de latencia en game streaming](/es/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive.md)
