Click here to Skip to main content
15,891,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello:

in my impression that filters that appear in graphedit have been registered.so we can use it directly.
but this time i have a touble about it.
when i use coCreateInstace function to create a special filter in my code ,my complier
reports erro.




it reports that no registered. and i have to register it in my code:


//
C#
//{4A69B442-28BE-4991-969C-B500ADF5D8A8} MPEG4s decoder
OUR_GUID_ENTRY(CLSID_MPEG4s_decoder,
               0x4a69e442,0x28be,0x4991, 0x96, 0x9c,0xb5, 0x00, 0xad ,0xf5,0xd8,0xa8);


BOOL pass=FALSE ;
if(!IsFilterRegistered(CLSID_MPEG4s_decoder))
pass = RegisterFilter(TEXT("C:\\Windows\\System32\\MP4SDECD.DLL"));

if(pass) //break here ,the pass value =true
hr =AddFilterByClSID(pGraph,CLSID_MPEG4s_decoder,
TEXT("MPEG4s Decoder DMO"),&pMPEG4sDecoder);
if(FAILED(hr))//but here ,hr =0x80040154
return FALSE ;

HRESULT CPlayer::AddFilterByClSID(
IFilterGraph *pfG,
const GUID & clsid,
LPCWSTR wszName,
IBaseFilter ** ppf)
{
if(!pfG || !ppf )
return E_POINTER ;
(*ppf) = 0 ;
IBaseFilter * pF =0 ;
HRESULT hr = CoCreateInstance(
clsid,
NULL,
CLSCTX_INPROC,
IID_IBaseFilter,
reinterpret_cast<void>(&pF));
if(SUCCEEDED(hr))
{
hr = pfG->AddFilter(pF,wszName);
if(SUCCEEDED(hr))
*ppf=pF ;
else
pF->Release();
}
return hr ;
}
C#
BOOL CPlayer::IsFilterRegistered(CLSID  infilerId)
{
    IBaseFilter * pFilter = NULL ;
    if(SUCCEEDED(
        CoCreateInstance(infilerId,NULL,CLSCTX_INPROC_SERVER,IID_IBaseFilter,
        (void**)&pFilter) ) )
    {
        pFilter->Release();
        return TRUE ;
    }
    return FALSE ;
}
Posted

1 solution

Looking at that filter in GraphEdit shows it to be a DMO - you need to wrap DMO's up in the IDMOWraperFilter[^] before you can use them as IBaseFilters

The code in that web page is almost an exact replacement for your AddFilterByCLSID function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900