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

Esta API retorna os detalhes de exibição do cliente especificado. Isso pode ser usado para tomar decisões informadas, como em quais proporções personalizadas renderizar ou qual resolução usar para habilitar o DirectCapture.

## Sintaxe

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

### Parâmetros

*client*   \_In\_\
Tipo: XGameStreamingClientId

O cliente de streaming que está sendo consultado.

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

O número máximo de pixels com suporte no jogo.

*widestSupportedAspectRatio*   \_In\_\
Tipo: float

A proporção mais larga com suporte no jogo. Ela é calculada a partir de largura / altura usando a resolução mais larga com suporte.

*tallestSupportedAspectRatio*   \_In\_\
Tipo: float

A proporção mais alta com suporte no jogo. Ela é calculada a partir de largura / altura usando a resolução mais alta com suporte.

*displayDetails*   \_Out\_\
Tipo: [XGameStreamingDisplayDetails\*](/pt-BR/reference/system/xgamestreaming/structs/xgamestreamingdisplaydetails)

Os detalhes de exibição do cliente de streaming.

### Valor retornado

Tipo: HRESULT

Retornará **S\_OK** se for bem-sucedido; caso contrário, retornará um código de erro.

#### Erros potenciais

| Código de erro | Valor do erro | Motivo do erro |
| - | - | - |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | O runtime do XGameStreaming não foi inicializado. Chame XGameStreamingInitialize antes de chamar outras APIs. |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | O cliente especificado não está conectado. |
| E\_GAMESTREAMING\_NO\_DATA | 0x89245402 | Os dados solicitados não estão disponíveis. Os dados podem ficar disponíveis mais tarde. |
| E\_INVALIDARG | 0x80070057 | Um ou mais parâmetros eram inválidos. `maxSupportedPixels` deve ser maior que 0. `widestSupportedAspectRatio` deve ser igual ou maior que 16/9 e não deve ser infinito. `tallestSupportedAspectRatio` deve ser igual ou menor que 16/9 e deve ser maior que 0. |

Para obter uma lista de códigos de erro, consulte [Códigos de erro](/pt-BR/reference/errorcodes).

## Comentários

Os dados em `displayDetails` podem ser usados para orientar aspectos do jogo, como a resolução na qual renderizar o jogo, e para informar onde posicionar informações ou interface do usuário críticas, garantindo que sejam interativas e não fiquem obstruídas.

Os campos `preferredWidth` e `preferredHeight` no struct `displayDetails` se baseiam na tela real do cliente de streaming, nas limitações do sistema de streaming e nos parâmetros fornecidos pelo jogo (`maxSupportedPixels`, `widestSupportedAspectRatio`, `tallestSupportedAspectRatio`).

Lembre-se de que os dados podem não estar disponíveis na inicialização do jogo e não necessariamente estarão disponíveis no momento do evento de conexão do cliente; portanto, os jogos devem usar eventos ou sondagem.

## Exemplo

```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);
        }
    }
}

```

## Requisitos

**Cabeçalho:** xgamestreaming.h\
**Biblioteca:** xgameruntime.lib\
**Plataformas com suporte:** Windows, consoles da família XBOX One e consoles XBOX Series

## Confira também

[XGameStreaming](/pt-BR/reference/system/xgamestreaming/xgamestreaming_members)

[XGameStreamingDisplayDetails](/pt-BR/reference/system/xgamestreaming/structs/xgamestreamingdisplaydetails)

[XGameStreamingRegisterClientPropertiesChanged](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingregisterclientpropertieschanged)

[XGameStreamingSetResolution](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingsetresolution)

[Visão geral da resolução personalizada](/pt-BR/build/core-features/common/game-streaming/game-streaming-custom-resolution-overview)


## Related topics

- [XGameStreamingGetDisplayDetails](/reference/system/xgamestreaming/functions/xgamestreaminggetdisplaydetails.md)
- [XGameStreamingDisplayDetails](/reference/system/xgamestreaming/structs/xgamestreamingdisplaydetails.md)
