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

# XGameStreamingGetStreamPhysicalDimensions

> XGameStreamingGetStreamPhysicalDimensions

# XGameStreamingGetStreamPhysicalDimensions

获取在流式处理客户端上呈现的视频流的物理尺寸。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
HRESULT XGameStreamingGetStreamPhysicalDimensions(
         XGameStreamingClientId client,
         uint32_t* horizontalMm,
         uint32_t* verticalMm
)
```

<a id="parametersSection" />

### 参数

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

要查询物理尺寸的客户端。

*horizontalMm*   \_Out\_\
类型：uint32\_t\*

视频流水平轴的大小（以毫米为单位）。

*verticalMm*   \_Out\_\
类型：uint32\_t\*

视频流垂直轴的大小（以毫米为单位）。

<a id="retvalSection" />

### 返回值

类型：HRESULT

如果成功，则返回 **S\_OK**；否则返回错误代码。

**潜在错误**

| 错误代码                                     | 错误值        | 错误原因                                                                                                                                       |
| ---------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| E\_GAMESTREAMING\_NOT\_INITIALIZED       | 0x89245400 | XGameStreaming 运行时尚未初始化。在调用其他 API 之前，请先调用 [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize)。 |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | 指定的客户端未连接。                                                                                                                                 |
| E\_GAMESTREAMING\_NO\_DATA               | 0x89245402 | 请求的数据不可用。数据可能稍后可用。                                                                                                                         |

有关错误代码列表，请参阅[错误代码](/reference/errorcodes)。

<a id="remarksSection" />

## 备注

你可以使用此方法来确定流是否将发送到较小的设备（例如智能手机）。

这使你可以根据设备大小提供更适合玩家、更适合设备的体验（例如，使用更大的字体大小）。

如果希望游戏响应流物理尺寸的变化，则应通过 [XGameStreamingRegisterClientPropertiesChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterclientpropertieschanged) 注册回调。

<a id="exampleSection" />

## 示例

以下代码示例演示如何使用 `XGameStreamingGetStreamPhysicalDimensions` 函数查找流式处理客户端的最小尺寸。

```cpp theme={null}
void GetSmallestStreamingClient(uint32_t& widthMm, uint32_t& heightMm)
    {
        // If we don't know what the smallest client is, then search through them to find it
        if (m_smallestClient == XGameStreamingNullClientId)
        {
            for (const auto client : m_streamingClients)
            {
                if (client.clientId != XGameStreamingNullClientId)
                {
                    uint32_t clientWidthMm = 0;
                    uint32_t clientHeightMm = 0;
                    if (SUCCEEDED(XGameStreamingGetStreamPhysicalDimensions(client.clientId, &clientWidthMm, &clientHeightMm)))
                    {
                        if (clientWidthMm < m_smallestClientWidthMm)
                        {
                            m_smallestClientWidthMm = clientWidthMm;
                            m_smallestClientHeightMm = clientHeightMm;
                        }
                    }
                }
            }
        }

        widthMm = m_smallestClientWidthMm;
        heightMm = m_smallestClientHeightMm;
    }
```

<a id="requirementsSection" />

## 要求

**标头：** xgamestreaming.h

**库：** xgameruntimelib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

<a id="seealsoSection" />

## 另请参阅

[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)\
[XGameStreamingRegisterClientPropertiesChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterclientpropertieschanged)\
[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members#ClientProperties)


## Related topics

- [XGameStreamingClientProperty](/zh-CN/reference/system/xgamestreaming/enums/xgamestreamingclientproperty.md)
- [针对 XBOX 游戏串流优化您的游戏](/zh-CN/build/core-features/common/game-streaming/game-streaming-optimizing-your-game.md)
- [XAG 101：文本显示](/zh-CN/build/game-principles/accessibility/xag-deep-dives/xag-101-text-display.md)
- [XGameStreaming](/zh-CN/reference/system/xgamestreaming/xgamestreaming_members.md)
- [XGameStreamingGetStreamAddedLatency](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetstreamaddedlatency.md)
