stax76
19th May 2004, 21:12
Hi,
can anyone explain me how to use this interface in .NET or point me to sample code?
in C++ it looks like this (taken from usenet)
IBaseFilter* g_pSource;
IBaseFilter* g_pVideoRenderer;
CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void**)&g_pSource);
CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void**)&g_pVideoRenderer);
IFileSourceFilter* FileSource=NULL;
hr = g_pSource->QueryInterface(IID_IFileSourceFilter, (void**)&FileSource);
DShowUtils::MessageBoxError(hr);
hr = FileSource->Load(L"D:\\MPG2\\MP2 von Telergional\\WöhrlJeans.mpg", NULL);
DShowUtils::MessageBoxError(hr);
if (FileSource)
FileSource->Release();
hr = m_Graph1->AddFilter(g_pSource, L"AsyncReader");
DShowUtils::MessageBoxError(hr);
hr = m_Graph1->AddFilter(g_pVideoRenderer, L"Video Renderer");
DShowUtils::MessageBoxError(hr);
IPin *pFileOut = NULL, *pVideoIn = NULL;
pFileOut = DShowUtils::GetPin(g_pSource, PINDIR_OUTPUT);
if (pFileOut != NULL) {
pVideoIn = DShowUtils::GetPin(g_pVideoRenderer, PINDIR_INPUT);
if (pVideoIn != NULL)
{
hr = DShowUtils::ConnectAndFreePins(m_Graph1, pFileOut, pVideoIn);
DShowUtils::MessageBoxError(hr);
}
this is what I've done so far with NETMaster's DShowNET lib and some fixes and helper functions (in DShowNET I had to fix IEnumPins.Next and add the definition of IFileSourceFilter)
IBaseFilter aviSrc = GetFilter(Guids.FileSourceAsync);
ShowPinCount(aviSrc); // debug info showing how many pins the filter has
(aviSrc as IFileSourceFilter).Load(
@"D:\Video\test files\Tweet\tweet.avi", null);
ShowPinCount(aviSrc); // shows 0 so I guess something is wrong
the interop is a hassle for people who lack the required knowledge, if I knew C++ better I wouldn't bother and do it in C++ but this is even a bigger problem for me.
Thank you
can anyone explain me how to use this interface in .NET or point me to sample code?
in C++ it looks like this (taken from usenet)
IBaseFilter* g_pSource;
IBaseFilter* g_pVideoRenderer;
CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void**)&g_pSource);
CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void**)&g_pVideoRenderer);
IFileSourceFilter* FileSource=NULL;
hr = g_pSource->QueryInterface(IID_IFileSourceFilter, (void**)&FileSource);
DShowUtils::MessageBoxError(hr);
hr = FileSource->Load(L"D:\\MPG2\\MP2 von Telergional\\WöhrlJeans.mpg", NULL);
DShowUtils::MessageBoxError(hr);
if (FileSource)
FileSource->Release();
hr = m_Graph1->AddFilter(g_pSource, L"AsyncReader");
DShowUtils::MessageBoxError(hr);
hr = m_Graph1->AddFilter(g_pVideoRenderer, L"Video Renderer");
DShowUtils::MessageBoxError(hr);
IPin *pFileOut = NULL, *pVideoIn = NULL;
pFileOut = DShowUtils::GetPin(g_pSource, PINDIR_OUTPUT);
if (pFileOut != NULL) {
pVideoIn = DShowUtils::GetPin(g_pVideoRenderer, PINDIR_INPUT);
if (pVideoIn != NULL)
{
hr = DShowUtils::ConnectAndFreePins(m_Graph1, pFileOut, pVideoIn);
DShowUtils::MessageBoxError(hr);
}
this is what I've done so far with NETMaster's DShowNET lib and some fixes and helper functions (in DShowNET I had to fix IEnumPins.Next and add the definition of IFileSourceFilter)
IBaseFilter aviSrc = GetFilter(Guids.FileSourceAsync);
ShowPinCount(aviSrc); // debug info showing how many pins the filter has
(aviSrc as IFileSourceFilter).Load(
@"D:\Video\test files\Tweet\tweet.avi", null);
ShowPinCount(aviSrc); // shows 0 so I guess something is wrong
the interop is a hassle for people who lack the required knowledge, if I knew C++ better I wouldn't bother and do it in C++ but this is even a bigger problem for me.
Thank you