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

# XGameStreamingGetDisplayDetails

> XGameStreamingGetDisplayDetails

# XGameStreamingGetDisplayDetails

この API は、指定されたクライアントのディスプレイの詳細を返します。これを使用して、レンダリングするカスタム アスペクト比や、DirectCapture を有効にするために使用する解像度など、根拠のある判断を行うことができます。

## Syntax

```cpp theme={null}
HRESULT XGameStreamingGetDisplayDetails(
        XGameStreamingClientId client,
        uint32_t maxSupportedPixels,
        float widestSupportedAspectRatio,
        float tallestSupportedAspectRatio,
        XGameStreamingDisplayDetails* displayDetails
)
```

### Parameters

*client*   \_In\_\
型: XGameStreamingClientId

照会するストリーミング クライアント。

*maxSupportedPixels*   \_In\_\
型: uint32\_t

ゲームがサポートする最大ピクセル数。

*widestSupportedAspectRatio*   \_In\_\
型: float

ゲームがサポートする最も横長のアスペクト比。これは、サポートされる最も横長の解像度を使用して width / height から計算されます。

*tallestSupportedAspectRatio*   \_In\_\
型: float

ゲームがサポートする最も縦長のアスペクト比。これは、サポートされる最も縦長の解像度を使用して width / height から計算されます。

*displayDetails*   \_Out\_\
型: [XGameStreamingDisplayDetails\*](/reference/system/xgamestreaming/structs/xgamestreamingdisplaydetails)

ストリーミング クライアントのディスプレイの詳細。

### Return value

型: HRESULT

成功した場合は **S\_OK** を返します。それ以外の場合はエラー コードを返します。

#### 想定されるエラー

| エラー コード                                  | エラー値       | エラーの理由                                                                                                                                                                  |
| ---------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_GAMESTREAMING\_NOT\_INITIALIZED       | 0x89245400 | XGameStreaming ランタイムが初期化されていません。他の API を呼び出す前に XGameStreamingInitialize を呼び出してください。                                                                                     |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | 指定されたクライアントが接続されていません。                                                                                                                                                  |
| E\_GAMESTREAMING\_NO\_DATA               | 0x89245402 | 要求されたデータは利用できません。データは後で利用可能になる場合があります。                                                                                                                                  |
| E\_INVALIDARG                            | 0x80070057 | 1 つ以上のパラメーターが無効でした。`maxSupportedPixels` は 0 より大きい必要があります。`widestSupportedAspectRatio` は 16/9 以上で、無限大であってはなりません。`tallestSupportedAspectRatio` は 16/9 以下で、0 より大きい必要があります。 |

エラー コードの一覧については、[Error Codes](/reference/errorcodes) を参照してください。

## Remarks

`displayDetails` 内のデータは、ゲームのレンダリング解像度や、重要な情報や UI を操作可能かつ隠されない位置に配置するための情報など、ゲームの各種側面を制御するために使用できます。

`displayDetails` 構造体内の `preferredWidth` および `preferredHeight` は、ストリーミング クライアント上の実際のディスプレイ、ストリーミング システムに基づく制限、およびゲームから提供されるパラメーター (`maxSupportedPixels`、`widestSupportedAspectRatio`、`tallestSupportedAspectRatio`) に基づいて決定されます。

このデータはゲームの起動時には利用できない可能性があり、また必ずしもクライアント接続イベントの時点で利用可能とは限らないため、ゲームはイベントまたはポーリングを使用する必要があります。

## Example

```C++ theme={null}

#define DEFAULT_GAME_WIDTH 1920
#define DEFAULT_GAME_HEIGHT 1080

#define GAME_WIDEST_SUPPORTED_ASPECT_RATIO 21.5f / 9.0f
#define GAME_TALLEST_SUPPORTED_ASPECT_RATIO 16.0f / 10.0f

static uint32_t s_currentStreamWidth = DEFAULT_GAME_WIDTH;
static uint32_t s_currentStreamHeight = DEFAULT_GAME_HEIGHT;

// Option 1: Event driven. Note: be aware of potential threading issues when using the task queue.
void GameStreamingClientManager::OnConnectionStateChanged(XGameStreamingClientId client, XGameStreamingConnectionState connected)
{
    // Other connection work like registering or unregistering for the client properties change events.
    ...

    UpdateResolutionIfNeeded();
}

void GameStreamingClientManager::OnClientPropertiesChanged(
    XGameStreamingClientId client,
    uint32_t updatedPropertiesCount,
    XGameStreamingClientProperty* updatedProperties)
{
    for (uint32_t i = 0; i < updatedPropertiesCount; ++i)
    {
        switch (updatedProperties[i])
        {
        case XGameStreamingClientProperty::DisplayDetails:
        {
            UpdateResolutionIfNeeded();
            break;
        }

        default:
            // A characteristic we are not tracking - do nothing
            break;
        }
    }
}

// Option 2: Polling.

void Game::Update(DX::StepTimer const& timer)
{
    ...

    gameStreamingClientManager->UpdateResolutionIfNeeded();

    ...
}

void GameStreamingClientManager::UpdateResolutionIfNeeded()
{
    bool changeResolution = false;
    bool useDefaultResolution = true;

    // Only use custom resolution when there is only one streaming client connected.
    if (XGameStreamingGetClientCount() == 1)
    {
        XGameStreamingClientId client;
        uint32_t clientsUsed = 0;
        HRESULT hr = XGameStreamingGetClients(1, &client, &clientsUsed);
        if (SUCCEEDED(hr) && clientsUsed == 1)
        {
            XGameStreamingDisplayDetails displayDetails = {};
            hr = XGameStreamingGetDisplayDetails(client, DEFAULT_GAME_WIDTH * DEFAULT_GAME_HEIGHT, GAME_WIDEST_SUPPORTED_ASPECT_RATIO, GAME_TALLEST_SUPPORTED_ASPECT_RATIO, &displayDetails);

            if (SUCCEEDED(hr))
            {
                useDefaultResolution = false;

                // Assuming the game supports all resolutions, use the stream resolution to the preferred dimensions as provided.
                if (s_currentStreamWidth != displayDetails.preferredWidth || s_currentStreamHeight != displayDetails.preferredHeight)
                {
                    changeResolution = true;
                    s_currentStreamWidth = displayDetails.preferredWidth;
                    s_currentStreamHeight = displayDetails.preferredHeight;
                }
            }
            else
            {
                LogFormat(L"XGameStreamingGetDisplayDetails failed %x", hr);
            }
        }
        else
        {
            LogFormat(L"XGameStreamingGetClients failed hr=%x clientsUsed=%d", hr, clientsUsed);
        }
    }

    if (useDefaultResolution)
    {
        if (s_currentStreamWidth != DEFAULT_GAME_WIDTH || s_currentStreamHeight != DEFAULT_GAME_HEIGHT)
        {
            changeResolution = true;
            s_currentStreamWidth = DEFAULT_GAME_WIDTH;
            s_currentStreamHeight = DEFAULT_GAME_HEIGHT;
        }
    }

    if (changeResolution)
    {
        // Update the stream to the new resolution.
        HRESULT hr = XGameStreamingSetResolution(s_currentStreamWidth, s_currentStreamHeight);
        if (SUCCEEDED(hr))
        {
            // Update the game to render at the new resolution.
        }
        else
        {
            LogFormat(L"XGameStreamingSetResolution failed %x", hr);
        }
    }
}

```

## Requirements

**ヘッダー:** xgamestreaming.h\
**ライブラリ:** xgameruntime.lib\
**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体および XBOX Series 本体

## See also

[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)

[XGameStreamingDisplayDetails](/reference/system/xgamestreaming/structs/xgamestreamingdisplaydetails)

[XGameStreamingRegisterClientPropertiesChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterclientpropertieschanged)

[XGameStreamingSetResolution](/reference/system/xgamestreaming/functions/xgamestreamingsetresolution)

[Custom Resolution Overview](/build/core-features/common/game-streaming/game-streaming-custom-resolution-overview)


## Related topics

- [XGameStreamingDisplayDetails](/ja-jp/reference/system/xgamestreaming/structs/xgamestreamingdisplaydetails.md)
- [XGameStreamingVideoFlags](/ja-jp/reference/system/xgamestreaming/enums/xgamestreamingvideoflags.md)
- [XGameStreamingSetResolution](/ja-jp/reference/system/xgamestreaming/functions/xgamestreamingsetresolution.md)
- [XGameStreamingClientProperty](/ja-jp/reference/system/xgamestreaming/enums/xgamestreamingclientproperty.md)
- [ゲーム ストリーミングにおけるカスタム解像度のベスト プラクティス](/ja-jp/build/core-features/common/game-streaming/game-streaming-custom-resolution-best-practices.md)
