C++ project of Part I. Frankly speaking this is my first c++ project, I may have made terrible mistakes in it, but best part is, its working. So anyone have any suggestion to improve it please comment.
then I moved the video to next position and finally generated a bitmap from dxgiSurface
In this I have following issues which I think someone could suggest something:
1) Is this the right and only way of extracting frames ?
2) How can i pass bitmap to c# project directly instead of storing them on file?
3) When the events are raised, they are raised from different thread, so c# project need to use dispatcher.invoke to execute anything, what is the solution for this ?
I modified this Media Playback sample, It plays video using a timer, so I removed swapchaining and created a ID3D11Texture2D and transferred video frame using TransferVideoFrame in Ontimer function.
ComPtr<ID3D11Texture2D> spTextureDst;
MEDIA::ThrowIfFailed(
m_d3dDevice->CreateTexture2D(
&CD3D11_TEXTURE2D_DESC(
DXGI_FORMAT_B8G8R8A8_UNORM,
m_rcTarget.right, // Width
m_rcTarget.bottom, // Height
1, // MipLevels
1, // ArraySize
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET
),
nullptr,
&spTextureDst
)
);
if (FAILED(
m_spMediaEngine->TransferVideoFrame(spTextureDst.Get(), nullptr, &m_rcTarget, &m_bkgColor)
))
{
return;
}
then I moved the video to next position and finally generated a bitmap from dxgiSurface
ComPtr<IDXGISurface2> surface;
MEDIA::ThrowIfFailed(
spTextureDst.Get()->QueryInterface(
__uuidof(IDXGISurface2), &surface)
);
D2D1_BITMAP_PROPERTIES1 bitmapProperties =
D2D1::BitmapProperties1(
D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW,
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED),
96,
96
);
m_d2dContext->CreateBitmapFromDxgiSurface(surface.Get(), &bitmapProperties, &bitmap);
In this I have following issues which I think someone could suggest something:
1) Is this the right and only way of extracting frames ?
2) How can i pass bitmap to c# project directly instead of storing them on file?
3) When the events are raised, they are raised from different thread, so c# project need to use dispatcher.invoke to execute anything, what is the solution for this ?