64,649
社区成员
发帖
与我相关
我的任务
分享
HRESULT AddSourceNode(
IMFTopology *pTopology, // Topology.
IMFMediaSource *pSource, // Media source.
IMFPresentationDescriptor *pPD, // Presentation descriptor.
IMFStreamDescriptor *pSD, // Stream descriptor.
IMFTopologyNode **ppNode) // Receives the node pointer.
{
IMFTopologyNode *pNode = NULL;
// Create the node.
HRESULT hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &pNode);
if (FAILED(hr))
{
goto done;
}
// Set the attributes.
hr = pNode->SetUnknown(MF_TOPONODE_SOURCE, pSource);
if (FAILED(hr))
{
goto done;
}
hr = pNode->SetUnknown(MF_TOPONODE_PRESENTATION_DESCRIPTOR, pPD);
if (FAILED(hr))
{
goto done;
}
hr = pNode->SetUnknown(MF_TOPONODE_STREAM_DESCRIPTOR, pSD);
if (FAILED(hr))
{
goto done;
}
// Add the node to the topology.
hr = pTopology->AddNode(pNode);
if (FAILED(hr))
{
goto done;
}
// Return the pointer to the caller.
*ppNode = pNode;
(*ppNode)->AddRef();
done:
SafeRelease(&pNode);
return hr;
}
HRESULT AddSourceNode(
IMFTopology *pTopology, // Topology.
IMFMediaSource *pSource , // Media source.
IMFPresentationDescriptor *pPD , // Presentation descriptor.
IMFStreamDescriptor *pSD , // Stream descriptor.
IMFTopologyNode **ppNode ) // Receives the node pointer.
{
IMFTopologyNode *pNode = NULL;
while (1) {
// Create the node.
HRESULT hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &pNode); if (FAILED(hr)) break;
// Set the attributes.
hr = pNode->SetUnknown(MF_TOPONODE_SOURCE, pSource); if (FAILED(hr)) break;
hr = pNode->SetUnknown(MF_TOPONODE_PRESENTATION_DESCRIPTOR, pPD); if (FAILED(hr)) break;
hr = pNode->SetUnknown(MF_TOPONODE_STREAM_DESCRIPTOR, pSD); if (FAILED(hr)) break;
// Add the node to the topology.
hr = pTopology->AddNode(pNode); if (FAILED(hr)) break;
// Return the pointer to the caller.
*ppNode = pNode;
(*ppNode)->AddRef();
}
SafeRelease(&pNode);
return hr;
}
// 创建直接组合(Direct Composition)设备
if (SUCCEEDED(hr)) {
hr = LongUI::Dll::DCompositionCreateDevice(
UIManager_DXGIDevice,
LongUI_IID_PV_ARGS(m_pDcompDevice)
);
longui_debug_hr(hr, L"DCompositionCreateDevice faild");
}
// 创建直接组合(Direct Composition)目标
if (SUCCEEDED(hr)) {
hr = m_pDcompDevice->CreateTargetForHwnd(
m_hwnd, true, &m_pDcompTarget
);
longui_debug_hr(hr, L"m_pDcompDevice->CreateTargetForHwnd faild");
}
// 创建直接组合(Direct Composition)视觉
if (SUCCEEDED(hr)) {
hr = m_pDcompDevice->CreateVisual(&m_pDcompVisual);
longui_debug_hr(hr, L"m_pDcompDevice->CreateVisual faild");
}
// 设置当前交换链为视觉内容
if (SUCCEEDED(hr)) {
hr = m_pDcompVisual->SetContent(m_pSwapChain);
longui_debug_hr(hr, L"m_pDcompVisual->SetContent faild");
}
// 设置当前视觉为窗口目标
if (SUCCEEDED(hr)) {
hr = m_pDcompTarget->SetRoot(m_pDcompVisual);
longui_debug_hr(hr, L"m_pDcompTarget->SetRoot faild");
}
// 向系统提交
if (SUCCEEDED(hr)) {
hr = m_pDcompDevice->Commit();
longui_debug_hr(hr, L"m_pDcompDevice->Commit faild");
}