Thread: Trouble adding source filter for WMV

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195

    Trouble adding source filter for WMV

    here is the code

    Code:
        HRESULT hr;
        pthis->HasPTZ = FALSE;
        pthis->PanLocation  = 0;
        pthis->TiltLocation = 0;
        //----------------------------//
        //  Create the Source Filter  //
        //----------------------------//
        hr = CoCreateInstance(  CLSID_WMAsfReader  ,
                                NULL , 
                                CLSCTX_INPROC_SERVER ,
                                IID_IGraphBuilder ,
                                (void**)&pthis->pCapFilter);
        if(FAILED(hr)){
            pthis->FailPoint = 1;
            return hr;
            }
        hr = pthis->pCapFilter->QueryInterface(IID_IFileSourceFilter , (void**)&pthis->pFileSource);
        if(FAILED(hr)){
            MessageBox(NULL , "Failed to QueryInterface(IID_IFileSourceFilter)" , "DirectShow Error" , MB_OK);
            return hr;
            }
     
        hr = pthis->pFileSource->Load("C:/iei/test.wmv" , &pthis->MediaType);
        if(FAILED(hr)){
            MessageBox(NULL , "Failed to Load File" , "DirectShow Error" , MB_OK);
            return hr;
            }
        pthis->pDecoder = pthis->pCapFilter;
        return hr;
    Its not returning an error but the filter graph later fails to render the stream. The remaining code works with other source filters, so that code is not the problem. Amazingly enough, just using IGraphBuilder::AddSourceFilter() doesnt work either.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Did you try debugging with GraphEdit?
    You can use the following code to "add to rot":

    Code:
    	HRESULT AddToRot(IUnknown* pGraph, DWORD /*dwName*/, DWORD* pdwRegister)
    	{
    		IMoniker* pMoniker = NULL;
    		IRunningObjectTable* pROT = NULL;
    
    		if (FAILED( GetRunningObjectTable(0, &pROT) )) return E_FAIL;
    
    		const size_t STRING_LENGTH = 256;
    		WCHAR wsz[STRING_LENGTH];
    		StringCchPrintfW(wsz, STRING_LENGTH, L"FilterGraph %08x pid %08x", (DWORD*)pGraph, GetCurrentProcessId());
    
    		HRESULT hr = CreateItemMoniker(L"!", wsz, &pMoniker);
    		if (SUCCEEDED(hr)) 
    		{
    			hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, pGraph, pMoniker, pdwRegister);
    			pMoniker->Release();
    		}
    		pROT->Release();
    
    		return hr;
    	}
    
    	void RemoveFromRot(DWORD dwRegister)
    	{
    		IRunningObjectTable *pROT;
    		if (SUCCEEDED( GetRunningObjectTable(0, &pROT) )) 
    		{
    			pROT->Revoke(dwRegister);
    			pROT->Release();
    		}
    	}
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    See, thats one thing, Graphedit renders the file properly, running it through ffdshow, which means that RenderStream() should properly connect the source filter to the sample grabber through ffdshow, but it doesnt.

    Oh, im using ICaptureGraphBuilder2, not IGraphBuilder as I stated earlier.

    Code:
        hr = this->pBuilder->RenderStream(  NULL , 
                                            NULL , 
                                            this->pDecoder ,
                                            this->pGrabberF ,
                                            this->pNullRenderer);
    Last edited by abachler; 07-03-2008 at 09:18 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  2. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  3. Replies: 4
    Last Post: 03-02-2003, 09:12 AM