本文整理汇总了C++中microsoft::wrl::ComPtr::SetGUID方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::SetGUID方法的具体用法?C++ ComPtr::SetGUID怎么用?C++ ComPtr::SetGUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::SetGUID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initialize
void MediaStreamer::Initialize(__in const WCHAR* url)
{
Microsoft::WRL::ComPtr<IMFMediaType> outputMediaType;
Microsoft::WRL::ComPtr<IMFMediaType> mediaType;
ThrowIfFailed(
MFStartup(MF_VERSION)
);
WCHAR filePath[MAX_PATH] = {0};
if ((wcslen(url) > 1 && url[1] == ':'))
{
// path start with "x:", is absolute path
wcscat_s(filePath, url);
}
else if (wcslen(url) > 0
&& (L'/' == url[0] || L'\\' == url[0]))
{
// path start with '/' or '\', is absolute path without driver name
wcscat_s(filePath, m_installedLocationPath->Data());
// remove '/' or '\\'
wcscat_s(filePath, (const WCHAR*)url[1]);
}else
{
wcscat_s(filePath, m_installedLocationPath->Data());
wcscat_s(filePath, url);
}
ThrowIfFailed(
MFCreateSourceReaderFromURL(filePath, nullptr, &m_reader)
);
// Set the decoded output format as PCM
// XAudio2 on Windows can process PCM and ADPCM-encoded buffers.
// When using MF, this sample always decodes into PCM.
ThrowIfFailed(
MFCreateMediaType(&mediaType)
);
ThrowIfFailed(
mediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio)
);
ThrowIfFailed(
mediaType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM)
);
ThrowIfFailed(
m_reader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, mediaType.Get())
);
// Get the complete WAVEFORMAT from the Media Type
ThrowIfFailed(
m_reader->GetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, &outputMediaType)
);
uint32 formatSize = 0;
WAVEFORMATEX* waveFormat;
ThrowIfFailed(
MFCreateWaveFormatExFromMFMediaType(outputMediaType.Get(), &waveFormat, &formatSize)
);
CopyMemory(&m_waveFormat, waveFormat, sizeof(m_waveFormat));
CoTaskMemFree(waveFormat);
// Get the total length of the stream in bytes
PROPVARIANT var;
ThrowIfFailed(
m_reader->GetPresentationAttribute(MF_SOURCE_READER_MEDIASOURCE, MF_PD_DURATION, &var)
);
LONGLONG duration = var.uhVal.QuadPart;
double durationInSeconds = (duration / static_cast<double>(10000000)); // duration is in 100ns units, convert to seconds
m_maxStreamLengthInBytes = static_cast<unsigned int>(durationInSeconds * m_waveFormat.nAvgBytesPerSec);
// Round up the buffer size to the nearest four bytes
m_maxStreamLengthInBytes = (m_maxStreamLengthInBytes + 3) / 4 * 4;
}
示例2: MFCreateSourceReaderFromURL
// Create the source reader on the url (file) with the low latency attributes
//
DX::ThrowIfFailed(
MFCreateSourceReaderFromURL(url->Data(), lowLatencyAttribute.Get(), &m_reader)
);
// Set the decoded output format as PCM
// XAudio2 on Windows can process PCM and ADPCM-encoded buffers.
// When using MF, this sample always decodes into PCM.
DX::ThrowIfFailed(
MFCreateMediaType(&mediaType)
);
DX::ThrowIfFailed(
mediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio)
);
DX::ThrowIfFailed(
mediaType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM)
);
DX::ThrowIfFailed(
m_reader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, mediaType.Get())
);
// Get the complete WAVEFORMAT from the Media Type
DX::ThrowIfFailed(
m_reader->GetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, &outputMediaType)
);
示例3: Initialize
void MediaStreamer::Initialize(_In_ const WCHAR* url)
{
Microsoft::WRL::ComPtr<IMFMediaType> outputMediaType;
Microsoft::WRL::ComPtr<IMFMediaType> mediaType;
DX::ThrowIfFailed(
MFStartup(MF_VERSION)
);
DX::ThrowIfFailed(
MFCreateSourceReaderFromURL(url, nullptr, &m_reader)
);
// Set the decoded output format as PCM.
// XAudio2 on Windows can process PCM and ADPCM-encoded buffers.
// When this sample uses Media Foundation, it always decodes into PCM.
DX::ThrowIfFailed(
MFCreateMediaType(&mediaType)
);
DX::ThrowIfFailed(
mediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio)
);
DX::ThrowIfFailed(
mediaType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM)
);
DX::ThrowIfFailed(
m_reader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, mediaType.Get())
);
// Get the complete WAVEFORMAT from the Media Type.
DX::ThrowIfFailed(
m_reader->GetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, &outputMediaType)
);
uint32 formatSize = 0;
WAVEFORMATEX* waveFormat;
DX::ThrowIfFailed(
MFCreateWaveFormatExFromMFMediaType(outputMediaType.Get(), &waveFormat, &formatSize)
);
CopyMemory(&m_waveFormat, waveFormat, sizeof(m_waveFormat));
CoTaskMemFree(waveFormat);
// Get the total length of the stream, in bytes.
PROPVARIANT var;
DX::ThrowIfFailed(
m_reader->GetPresentationAttribute(MF_SOURCE_READER_MEDIASOURCE, MF_PD_DURATION, &var)
);
// duration is in 100ns units; convert to seconds, and round up
// to the nearest whole byte.
ULONGLONG duration = var.uhVal.QuadPart;
m_maxStreamLengthInBytes =
static_cast<unsigned int>(
((duration * static_cast<ULONGLONG>(m_waveFormat.nAvgBytesPerSec)) + 10000000) /
10000000
);
}