none
Source filter - property page in Matlab

    Domanda

  • Hello.

    I'm developing my own source filter. I can display property page in programs like AMCap, GraphEdit, but I cannot in Matlab. I found out that Matlab never calls GetPages method or constructor of my property page. It doesn't even querying for property page:

    STDMETHODIMP CVCam::NonDelegatingQueryInterface(REFIID riid, void **ppv)
    {
    	append_to_file("CVCam NonDelegatingQueryInterface");
    	CheckPointer(ppv,E_POINTER);
    
        if (riid == IID_ISpecifyPropertyPages)
        {
    		append_to_file("IID_ISpecifyPropertyPages"); // this is never called
    		return GetInterface((ISpecifyPropertyPages *) this, ppv);
        }
        else
            return CSource::NonDelegatingQueryInterface(riid, ppv);
    }
    Matlab never query for "riid == IID_ISpecifyPropertyPages".

    Maybe the problem might be in dll regsvr? Here is the code:

    //////////////////////////////////////////////////////////////////////////
    //  This file contains routines to register / Unregister the 
    //  Directshow filter
    //  We do not use the inbuilt BaseClasses routines as we need to register as
    //  a capture source
    //////////////////////////////////////////////////////////////////////////
    #pragma comment(lib, "kernel32")
    #pragma comment(lib, "user32")
    #pragma comment(lib, "gdi32")
    #pragma comment(lib, "advapi32")
    #pragma comment(lib, "winmm")
    #pragma comment(lib, "ole32")
    #pragma comment(lib, "oleaut32")
    
    #ifdef _DEBUG
        #pragma comment(lib, "strmbasd")
    #else
        #pragma comment(lib, "strmbase")
    #endif
    
    
    #include <streams.h>
    #include <olectl.h>
    #include <initguid.h>
    #include <dllsetup.h>
    #include "filters.h"
    
    
    #define CreateComObject(clsid, iid, var) CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER, iid, (void **)&var);
    
    STDAPI AMovieSetupRegisterServer( CLSID   clsServer, LPCWSTR szDescription, LPCWSTR szFileName, LPCWSTR szThreadingModel = L"Both", LPCWSTR szServerType     = L"InprocServer32" );
    STDAPI AMovieSetupUnregisterServer( CLSID clsServer );
    
    
    
    // {C18E8F1C-F18D-4DDB-B559-58EF23A8C1B6}
    DEFINE_GUID(CLSID_OptoMCam, 
    0xc18e8f1c, 0xf18d, 0x4ddb, 0xb5, 0x59, 0x58, 0xef, 0x23, 0xa8, 0xc1, 0xb6);
    
    
    
    const AMOVIESETUP_MEDIATYPE AMSMediaTypesVCam = 
    { 
        &MEDIATYPE_Video, 
        &MEDIASUBTYPE_NULL 
    };
    
    const AMOVIESETUP_PIN AMSPinVCam=
    {
        L"Output",             // Pin string name
        FALSE,                 // Is it rendered
        TRUE,                  // Is it an output
        FALSE,                 // Can we have none
        FALSE,                 // Can we have many
        &CLSID_NULL,           // Connects to filter
        NULL,                  // Connects to pin
        1,                     // Number of types
        &AMSMediaTypesVCam      // Pin Media types
    };
    
    const AMOVIESETUP_FILTER AMSFilterVCam =
    {
        &CLSID_OptoMCam,  // Filter CLSID
        L"example camera",     // String name
        MERIT_DO_NOT_USE,      // Filter merit
        2,                     // Number pins
        &AMSPinVCam             // Pin details
    };
    
    CFactoryTemplate g_Templates[] = 
    {
        {
            L"example camera",
            &CLSID_OptoMCam,
            CVCam::CreateInstance,
            NULL,
            &AMSFilterVCam
        },
    	// This entry is for the property page.
        { 
            L"example camera properties",
            &CLSID_property_pages,
            CAMproperty::CreateInstance,
    		NULL, NULL
        }
    
    };
    
    int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
    
    
    
    
    STDAPI RegisterFilters( BOOL bRegister )
    {
        HRESULT hr = NOERROR;
        WCHAR achFileName[MAX_PATH];
        char achTemp[MAX_PATH];
        ASSERT(g_hInst != 0);
    
        if( 0 == GetModuleFileNameA(g_hInst, achTemp, sizeof(achTemp))) 
            return AmHresultFromWin32(GetLastError());
    
        MultiByteToWideChar(CP_ACP, 0L, achTemp, lstrlenA(achTemp) + 1, 
                           achFileName, NUMELMS(achFileName));
    
    	//property pages
    	WCHAR achFileName2[MAX_PATH];
        char achTemp2[MAX_PATH];
    
        if( 0 == GetModuleFileNameA(g_hInst, achTemp2, sizeof(achTemp2))) 
            return AmHresultFromWin32(GetLastError());
    
        MultiByteToWideChar(CP_ACP, 0L, achTemp2, lstrlenA(achTemp2) + 1, 
                           achFileName2, NUMELMS(achFileName2));
    	//END property pages
      
        hr = CoInitialize(0);
        if(bRegister)
        {
            hr = AMovieSetupRegisterServer(CLSID_OptoMCam, L"example camera", achFileName, L"Both", L"InprocServer32");
    		AMovieSetupRegisterServer(CLSID_property_pages, L"example camera properties", achFileName2, L"Both", L"InprocServer32");
        }
    
        if( SUCCEEDED(hr) )
        {
            IFilterMapper2 *fm = 0;
            hr = CreateComObject( CLSID_FilterMapper2, IID_IFilterMapper2, fm );
            if( SUCCEEDED(hr) )
            {
                if(bRegister)
                {
                    IMoniker *pMoniker = 0;
                    REGFILTER2 rf2;
                    rf2.dwVersion = 1;
                    rf2.dwMerit = MERIT_DO_NOT_USE;
                    rf2.cPins = 1; // debug
                    rf2.rgPins = &AMSPinVCam;
                    hr = fm->RegisterFilter(CLSID_OptoMCam, L"example camera", &pMoniker, &CLSID_VideoInputDeviceCategory, NULL, &rf2);
                }
                else
                {
                    hr = fm->UnregisterFilter(&CLSID_VideoInputDeviceCategory, 0, CLSID_OptoMCam);
                }
            }
    
          // release interface
          //
          if(fm)
              fm->Release();
        }
    
        if( SUCCEEDED(hr) && !bRegister )
    	{
            hr = AMovieSetupUnregisterServer( CLSID_OptoMCam );
    		AMovieSetupUnregisterServer( CLSID_property_pages );
    	}
    
        CoFreeUnusedLibraries();
        CoUninitialize();
        return hr;
    }
    
    STDAPI DllRegisterServer()
    {
        return RegisterFilters(TRUE);
    }
    
    STDAPI DllUnregisterServer()
    {
        return RegisterFilters(FALSE);
    }
    
    extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
    
    BOOL APIENTRY DllMain(HANDLE hModule, DWORD  dwReason, LPVOID lpReserved)
    {
    	return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
    }
    

    martedì 27 marzo 2012 11:14

Tutte le risposte