XAppCaptureStartUserRecord

Record as if the user had triggered it. If the player suspends/constrains their game while a recording is ongoing, the recording will be stopped. The recording is saved in the user partition. Capture settings are based on GameDVR settings. Once the concurrent recording limit has been hit, XAppCaptureStopUserRecord will need to be called before another recording can be started. Windows support for this API will be added in a future release.

Syntax

HRESULT XAppCaptureStartUserRecord(
    XUserHandle requestingUser,
    uint32_t localIdBufferLength,
    char* localIdBuffer
)

Parameters

requestingUser _In_
Type: XUserHandle

Handle representing the user requesting the recording.

localIdBufferLength _In_
Type: uint32_t

The length of the buffer receiving the local recording ID.

localIdBuffer _Out_
Type: char*

Buffer containing the local ID specifying the ongoing recording operation.

Return value

Type: HRESULT

Function result.

Remarks

On successful function completion, localIdOfUserRecording contains the local ID of the recording and must be stored to stop a specific recording with XAppCaptureStopUserRecord.

char localIdOfUserRecording[APPCAPTURE_MAX_LOCALID_LENGTH] = { '\0' };

XAppCaptureVideoCaptureSettings captureSettings = { 0 };
if (FAILED_LOG(XAppCaptureGetVideoCaptureSettings(&captureSettings)))
{
    return;
}

if (captureSettings.isCaptureByGamesAllowed)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = g_taskQueue;
    asyncBlock->callback = [](XAsyncBlock* ab)
    {
        auto asyncBlock = std::unique_ptr<XAsyncBlock>(ab);

        XUserHandle user = nullptr;
        auto scopeExit = wil::scope_exit([&]()
        {
            if (user != nullptr)
            {
                XUserCloseHandle(user);
            }
        });

        if (FAILED_LOG(XUserAddResult(asyncBlock.get(), &user)))
        {
            return;
        }

        if (FAILED_LOG(XAppCaptureStartUserRecord(user, ARRAYSIZE(localIdOfUserRecording), localIdOfUserRecording)))
        {
            return;
        }
        appLog.AddLog("Recording started: localId = %s\n", localIdOfUserRecording);
    };

    if (SUCCEEDED_LOG(XUserAddAsync(
        XUserAddOptions::AddDefaultUserAllowingUI,
        asyncBlock.get())))
    {
        // Once started, release the pointer
        asyncBlock.release();
    }
}

Requirements

Header: XAppCapture.h

Library: xgameruntime.lib

Supported platforms: Xbox One family consoles and Xbox Series consoles

See also

XAppCapture members