XAppCaptureReadLocalStream
XAppCaptureRecordTimespan の以前の呼び出しによって生成された .mp4 ファイルの内容を読み取ります。
構文
HRESULT XAppCaptureReadLocalStream(
XAppCaptureLocalStreamHandle handle,
size_t startPosition,
uint32_t bytesToRead,
uint8_t * buffer,
uint32_t * bytesWritten
)
パラメーター
handle _In_
型: XAppCaptureLocalStreamHandle
前に XAppCaptureRecordTimespan によって作成されたローカル記録ファイルへのハンドル。
startPosition _In_
型: size_t
ストリーム内の開始位置。
bytesToRead _In_
型: uint32_t
読み取るバイト数。
buffer _Out_writes_to_(bytesToRead, *bytesWritten)
型: uint8_t *
ストリーム データの書き込み先のバッファー。
bytesWritten _Out_
型: uint32_t *
関数の完了時に、指定されたバッファーに書き込まれたバイト数を格納します。
戻り値
型: HRESULT
関数の結果です。
解説
一度に存在できる記録は最大 2 つです。 ストリームが閉じると、ファイルは削除されます。 ゲームが終了すると、古いファイルを守るために録画が自動的に削除されます。
XAppCaptureLocalResult を取得する方法については、XAppCaptureRecordTimespan をご覧ください。
const int MAX_DATA = 1024;
XAppCaptureLocalResult localResult = {0};
XAppCaptureLocalStreamHandle localHandle = nullptr;
HANDLE file = INVALID_HANDLE_VALUE;
uint8_t buffer[MAX_DATA];
/* 5 seconds, for example. You should call XAppCaptureGetVideoCaptureSettings() to ensure there's sufficient duration available */
uint64_t durationInMs = 5000;
size_t totalBytesRead = 0;
size_t fileSize = 0;
XAppCaptureRecordTimespan(nullptr, durationInMs, &localResult);
localHandle = localResult.clipHandle;
fileSize = localResult.fileSizeInBytes;
/* T:\ is one example of a writeable local directory. Be aware that the T:\ drive can be invalidated on suspend or resume, and as such it's better to use PLS */
file = CreateFileA("T:\\MyFile.mp4", GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
while (totalBytesRead < fileSize)
{
uint32_t bytesRead = 0;
uint32_t bytesWritten = 0;
if (SUCCEEDED(XAppCaptureReadLocalStream(localHandle, totalBytesRead, sizeof(buffer), buffer, &bytesRead)))
{
WriteFile(file, buffer, bytesRead, &bytesWritten, NULL);
totalBytesRead += bytesRead;
}
else
{
break;
}
}
/* You must always close a local stream handle even if nothing was read in */
XAppCaptureCloseLocalStream(localHandle);
要件
ヘッダー: XAppCapture.h
ライブラリ: xgameruntime.lib
サポートされているプラットフォーム: Windows、Xbox One ファミリー本体、Xbox Series 本体