> ## 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 devuelve los detalles de pantalla del cliente especificado. Se puede usar para tomar decisiones fundamentadas, como con qué relaciones de aspecto personalizadas representar o qué resolución usar para habilitar DirectCapture.

## Sintaxis

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

### Parámetros

*client*   \_In\_\
Tipo: XGameStreamingClientId

El cliente de streaming que se está consultando.

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

El número máximo de píxeles que admite el juego.

*widestSupportedAspectRatio*   \_In\_\
Tipo: float

La relación de aspecto más ancha que admite el juego. Se calcula a partir de ancho / alto usando la resolución más ancha admitida.

*tallestSupportedAspectRatio*   \_In\_\
Tipo: float

La relación de aspecto más alta que admite el juego. Se calcula a partir de ancho / alto usando la resolución más alta admitida.

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

Los detalles de pantalla del cliente de streaming.

### Valor devuelto

Tipo: HRESULT

Devuelve **S\_OK** si se realiza correctamente; de lo contrario, devuelve un código de error.

#### Posibles errores

| Código de error                          | Valor de error | Motivo del error                                                                                                                                                                                                                                                      |
| ---------------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_GAMESTREAMING\_NOT\_INITIALIZED       | 0x89245400     | El entorno de ejecución de XGameStreaming no se ha inicializado. Llame a XGameStreamingInitialize antes de llamar a otras API.                                                                                                                                        |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401     | El cliente especificado no está conectado.                                                                                                                                                                                                                            |
| E\_GAMESTREAMING\_NO\_DATA               | 0x89245402     | Los datos solicitados no están disponibles. Es posible que los datos estén disponibles más adelante.                                                                                                                                                                  |
| E\_INVALIDARG                            | 0x80070057     | Uno o varios de los parámetros no eran válidos. `maxSupportedPixels` debe ser mayor que 0. `widestSupportedAspectRatio` debe ser igual o mayor que 16/9 y no debe ser infinito. `tallestSupportedAspectRatio` debe ser igual o menor que 16/9 y debe ser mayor que 0. |

Para obtener una lista de códigos de error, consulte [Códigos de error](/reference/errorcodes).

## Comentarios

Los datos incluidos en `displayDetails` se pueden usar para controlar aspectos del juego, como la resolución a la que se representa el juego, y para determinar dónde colocar información crítica o la interfaz de usuario a fin de garantizar que sea interactiva y no quede oculta.

Los valores `preferredWidth` y `preferredHeight` de la estructura `displayDetails` se basan en la pantalla real del cliente de streaming, en las limitaciones del sistema de streaming y en los parámetros proporcionados por el juego (`maxSupportedPixels`, `widestSupportedAspectRatio`, `tallestSupportedAspectRatio`).

Tenga en cuenta que es posible que los datos no estén disponibles al iniciar el juego y que no necesariamente estén disponibles en el momento del evento de conexión del cliente, por lo que los juegos deben usar eventos o sondeo.

## Ejemplo

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

**Encabezado:** xgamestreaming.h\
**Biblioteca:** xgameruntime.lib\
**Plataformas compatibles:** Windows, consolas de la familia XBOX One y consolas XBOX Series

## Consulte también

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

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

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

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

[Información general sobre la resolución personalizada](/build/core-features/common/game-streaming/game-streaming-custom-resolution-overview)


## Related topics

- [XGameStreamingDisplayDetails](/es/reference/system/xgamestreaming/structs/xgamestreamingdisplaydetails.md)
- [XGameStreamingVideoFlags](/es/reference/system/xgamestreaming/enums/xgamestreamingvideoflags.md)
- [XGameStreamingSetResolution](/es/reference/system/xgamestreaming/functions/xgamestreamingsetresolution.md)
- [Procedimientos recomendados para la resolución personalizada en Game Streaming](/es/build/core-features/common/game-streaming/game-streaming-custom-resolution-best-practices.md)
- [XGameStreamingClientProperty](/es/reference/system/xgamestreaming/enums/xgamestreamingclientproperty.md)
