XGameStreamingSetResolution

스트림의 해상도를 설정합니다.

구문

HRESULT XGameStreamingSetResolution(
        uint32_t width,
        uint32_t height
)

매개 변수

width _In_
형식: uint32_t

스트림 해상도를 설정할 너비입니다.

height _In_
형식: uint32_t

스트림 해상도를 설정할 높이입니다.

반환 값

형식: HRESULT

성공한 경우 S_OK를 반환하고, 그렇지 않으면 오류 코드를 반환합니다.

잠재적인 오류

오류 코드 오류 값 오류 발생 원인
E_GAMESTREAMING_NOT_INITIALIZED 0x89245400 XGameStreaming 런타임이 아직 초기화되지 않았습니다. 다른 API를 호출하기 전에 XGameStreamingInitialize를 호출합니다.
E_INVALIDARG 0x80070057 너비 및/또는 높이 매개 변수 또는 하드웨어가 요구 사항을 충족하지 않습니다.

오류 코드 목록은 오류 코드를 참조하세요.

비고

비표준 해상도의 이 API는 Xbox 게임 스트리밍 서버, Xbox Series X 개발 키트 및 Xbox Series S 테스트 키트에서만 작동합니다. 720p 및 1080p와 같은 표준 해상도는 하드웨어에 관계없이 적합합니다. 리테일 Xbox는 Remote Play를 통해서만 스트리밍할 수 있고 여전히 TV로 비디오를 출력할 수 있으므로 비표준 해상도를 사용하면 이미지가 왜곡될 수 있기 때문입니다.

너비와 높이는 최소 640x360이어야 하며 최대값은 XGameStreamingGetDisplayDetails에서 검색할 수 있는 XGameStreamingDisplayDetailsmaxWidthmaxHeight 필드에서 찾을 수 있습니다.

width * height에서 계산된 최대 픽셀은 인코더의 최대값보다 작거나 같아야 합니다. 최대값은 XGameStreamingGetDisplayDetails API를 사용하여 찾을 수 있습니다. 이 값은 향후 증가할 수 있습니다.

widthheight은(는) 8로 나눌 수 있어야 합니다.

API는 원하는 만큼 자주 호출할 수 있지만 스트림 해상도는 200ms마다 한 번만 변경할 수 있습니다. 해당 200ms 창 내에서 발생하는 모든 호출의 마지막 해결 방법은 해당 창이 경과한 후에 적용됩니다.

이 API는 연결된 모든 클라이언트에 대한 스트림의 해상도를 설정합니다. 즉, 여러 클라이언트가 연결된 경우 게임에 가장 적합한 옵션을 결정하기 위해 특별히 고려해야 합니다. 표준 16:9 해상도를 사용하거나 모든 클라이언트에 가장 적합한 해상도를 찾으려는 것을 의미할 수 있습니다.

참고 항목

스트림 해상도를 변경하면 ID3D12CommandQueue::PresentX에서 보기 사각형 크기 조정이 수정됩니다. D3D12XBOX_PRESENT_PLANE_PARAMETERS.pDestPlacementBase 스케일 인수 0.0-1.0은 XGameStreamingSetResolution에 전달된 높이와 너비를 나타냅니다. 그렇지 않으면 참조할 표준 1920x1080 또는 3840x2160 해상도가 아닙니다.


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

요구 사항

헤더: xgamestreaming.h
라이브러리: xgameruntime.lib
지원되는 플랫폼: Windows, Xbox One 패밀리 콘솔 및 Xbox Series 콘솔

참고 항목

XGameStreaming
XGameStreamingDisplayDetails
XGameStreamingGetDisplayDetails
사용자 지정 해상도 개요