> ## 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

Gets the recent average of the streaming related latency.

## Syntax

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

### Parameters

*client*   \_In\_\
Type: XGameStreamingClientId

The streaming client device that latency is being queried for.

*averageInputLatencyUs*   \_Out\_\
Type: uint32\_t\*

The average latency, in microseconds, over a recent period of time for input to be received by the XBOX game.

*averageOutputLatencyUs*   \_Out\_\
Type: uint32\_t\*

The average latency, in microseconds, over a recent period of time for a game frame to be rendered on the client device.

*standardDeviationUs*   \_Out\_\
Type: uint32\_t\*

Observed average of the measured standard deviation of jitter, in microseconds, over a recent period of time in the latency.

### Return value

Type: HRESULT

Returns **S\_OK** if successful; otherwise, returns an error code.

#### Potential Errors

| Error Code                         | Error Value | Reason for Error                                                                                                                                                                     |
| ---------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400  | The XGameStreaming runtime has not been initialized. Call [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize) before calling other APIs. |
| E\_GAMESTREAMING\_NO\_DATA         | 0x89245402  | The requested data is not available. The data may be available later.                                                                                                                |

For a list of error codes, see [Error Codes](/reference/errorcodes).

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

<Note>As explained below, the input and output latency values measure different values and may be calculated from different sources. These values are not expected to be similar and should be treated independently.</Note>

`XGameStreamingGetStreamAddedLatency` provides data about the measured latency due to the streaming of the game.  This can be utilized by games to better understand the experience that the player is having with the streamed experience.

It is important to note that this does **not** provide the full end to end latency that a player may notice (e.g., it does **not** map directly to a button press on a controller attached to the streaming client device until a new frame is rendered that takes that into account.)  For example, the following components are **not** included in these measurements:

* Game engine render time
* Time from when passed to render on the client device to when the player sees the image
* Bluetooth® transport and decode time from the controller on the client device

Instead, the input latency includes:

* The time it takes for the game streaming application to process inputs received from a controller.
* Transmission time from the game streaming application over the network to the server which is running the game.

Output latency includes:

* Encoding time for each frame that is rendered by the title.
* Time to transmit this frame across the network to the application the player is interacting with.
* Decoding time in the application, as it prepares to present the frame to the player.

`XGameStreamingGetStreamAddedLatency` is an average measurement which is updated every few seconds.  For more precise measurements, the [XGameStreamingGetAssociatedFrame](/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe) API may be used. See [Game streaming latency compensation deep dive](/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive) for more information.

## Requirements

**Header:** xgamestreaming.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Game streaming latency compensation deep dive](/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive)
* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)\
[Game Streaming Latency Compensation Overview](/build/core-features/common/game-streaming/game-streaming-latency-compensation-overview)


## Related topics

- [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)
- [XGameStreamingGetLastFrameDisplayed](/reference/system/xgamestreaming/functions/xgamestreaminggetlastframedisplayed.md)
- [Game streaming latency measurement](/build/core-features/common/game-streaming/game-streaming-latency-measurement.md)
