strmbase: Begin implementations of AMovieDllRegisterServer2 and AMovieSetupRegisterFilter2.

This commit is contained in:
Aric Stewart 2010-10-19 13:23:38 -05:00 committed by Alexandre Julliard
parent 514a5c091f
commit 6a00d78b39
6 changed files with 139 additions and 74 deletions

View File

@ -34,6 +34,8 @@
#include "objbase.h"
#include "uuids.h"
#include "strmif.h"
#include "wine/strmbase.h"
#include "dllsetup.h"
#include "wine/unicode.h"
@ -101,7 +103,7 @@ err_out:
/*
* RegisterAllClasses()
*/
static HRESULT SetupRegisterAllClasses(const CFactoryTemplate * pList, int num,
static HRESULT SetupRegisterAllClasses(const FactoryTemplate * pList, int num,
LPCWSTR szFileName, BOOL bRegister)
{
HRESULT hr = NOERROR;
@ -140,51 +142,17 @@ static HRESULT SetupRegisterAllClasses(const CFactoryTemplate * pList, int num,
* CFactoryTemplate
*
****************************************************************************/
HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num,
HRESULT SetupRegisterServers(const FactoryTemplate * pList, int num,
BOOL bRegister)
{
static const WCHAR szFileName[] = {'q','c','a','p','.','d','l','l',0};
HRESULT hr = NOERROR;
IFilterMapper2 *pIFM2 = NULL;
/* first register all server classes, just to make sure */
if (bRegister)
hr = SetupRegisterAllClasses(pList, num, szFileName, TRUE );
/* next, register/unregister all filters */
if (SUCCEEDED(hr))
{
hr = CoInitialize(NULL);
TRACE("Getting IFilterMapper2\r\n");
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
&IID_IFilterMapper2, (void **)&pIFM2);
if (SUCCEEDED(hr))
{
int i;
/* scan through array of CFactoryTemplates registering all filters */
for (i = 0; i < num; i++, pList++)
{
if (pList->m_pAMovieSetup_Filter.dwVersion)
{
hr = IFilterMapper2_RegisterFilter(pIFM2, pList->m_ClsID, pList->m_Name, NULL, &CLSID_LegacyAmFilterCategory, NULL, &pList->m_pAMovieSetup_Filter);
}
/* check final error for this pass and break loop if we failed */
if (FAILED(hr))
break;
}
/* release interface */
IFilterMapper2_Release(pIFM2);
}
/* and clear up */
CoFreeUnusedLibraries();
CoUninitialize();
}
hr = AMovieDllRegisterServer2(bRegister);
/* if unregistering, unregister all OLE servers */
if (SUCCEEDED(hr) && !bRegister)
@ -202,7 +170,7 @@ HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num,
* one defined.
*
****************************************************************************/
void SetupInitializeServers(const CFactoryTemplate * pList, int num,
void SetupInitializeServers(const FactoryTemplate * pList, int num,
BOOL bLoading)
{
int i;

View File

@ -22,30 +22,6 @@
#define _QCAP_DLLSETUP_H_DEFINED
#define COBJMACROS
#include "strmif.h"
/* Filter Setup data structures not defined in axextend.idl
They are not part of the standard SDK headers but come from the combase.h header
file in the DirectX Samples/Multimedia/BaseClasses */
typedef REGPINTYPES AMOVIESETUP_MEDIATYPE,
* PAMOVIESETUP_MEDIATYPE,
* LPAMOVIESETUP_MEDIATYPE;
typedef REGFILTERPINS AMOVIESETUP_PIN,
* PAMOVIESETUP_PIN,
* LPAMOVIESETUP_PIN;
/* This needs to go into Combase.h */
typedef IUnknown *(CALLBACK *LPFNNewCOMObject)(LPUNKNOWN pUnkOuter, HRESULT *phr);
typedef void (CALLBACK *LPFNInitRoutine)(BOOL bLoading, const CLSID *rclsid);
typedef struct tagCFactoryTemplate {
const WCHAR *m_Name;
const CLSID *m_ClsID;
LPFNNewCOMObject m_lpfnNew;
LPFNInitRoutine m_lpfnInit;
const REGFILTER2 m_pAMovieSetup_Filter;
} CFactoryTemplate;
/****************************************************************************
* SetupRegisterServers
@ -57,7 +33,7 @@ typedef struct tagCFactoryTemplate {
* CFactoryTemplate
*
****************************************************************************/
extern HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num, BOOL bRegister);
extern HRESULT SetupRegisterServers(const FactoryTemplate * pList, int num, BOOL bRegister);
/****************************************************************************
* SetupInitializeServers
@ -69,7 +45,7 @@ extern HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num, BOO
* one defined.
*
****************************************************************************/
extern void SetupInitializeServers(const CFactoryTemplate * pList, int num,
extern void SetupInitializeServers(const FactoryTemplate * pList, int num,
BOOL bLoading);
#endif /* _QCAP_DLLSETUP_H_DEFINED */

View File

@ -36,8 +36,8 @@
#include "uuids.h"
#include "strmif.h"
#include "dllsetup.h"
#include "qcap_main.h"
#include "dllsetup.h"
#include "wine/unicode.h"
#include "wine/debug.h"
@ -77,7 +77,7 @@ static const WCHAR wAudioInMixerProp[] =
{'A','u','d','i','o','I','n','p','u','t','M','i','x','e','r',' ','P','r','o',
'p','e','r','t','y',' ','P','a','g','e',0};
static CFactoryTemplate const g_cTemplates[] = {
FactoryTemplate const g_Templates[] = {
/*
{
wAudioCaptureFilter,
@ -147,7 +147,7 @@ static CFactoryTemplate const g_cTemplates[] = {
}*/
};
static int g_numTemplates = sizeof(g_cTemplates) / sizeof(g_cTemplates[0]);
int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
/***********************************************************************
* Dll EntryPoint (QCAP.@)
@ -158,10 +158,10 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
SetupInitializeServers(g_cTemplates, g_numTemplates, TRUE);
SetupInitializeServers(g_Templates, g_cTemplates, TRUE);
break;
case DLL_PROCESS_DETACH:
SetupInitializeServers(g_cTemplates, g_numTemplates, FALSE);
SetupInitializeServers(g_Templates, g_cTemplates, FALSE);
break;
}
return TRUE;
@ -174,7 +174,7 @@ HRESULT WINAPI DllRegisterServer(void)
{
TRACE("()\n");
return SetupRegisterServers(g_cTemplates, g_numTemplates, TRUE);
return SetupRegisterServers(g_Templates, g_cTemplates, TRUE);
}
/***********************************************************************
@ -184,7 +184,7 @@ HRESULT WINAPI DllUnregisterServer(void)
{
TRACE("\n");
return SetupRegisterServers(g_cTemplates, g_numTemplates, FALSE);
return SetupRegisterServers(g_Templates, g_cTemplates, FALSE);
}
/***********************************************************************
@ -307,7 +307,7 @@ static const IClassFactoryVtbl DSCF_Vtbl =
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
const CFactoryTemplate *pList = g_cTemplates;
const FactoryTemplate *pList = g_Templates;
IClassFactoryImpl *factory;
int i;
@ -322,13 +322,13 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
!IsEqualGUID(&IID_IUnknown, riid))
return E_NOINTERFACE;
for (i = 0; i < g_numTemplates; i++, pList++)
for (i = 0; i < g_cTemplates; i++, pList++)
{
if (IsEqualGUID(pList->m_ClsID, rclsid))
break;
}
if (i == g_numTemplates)
if (i == g_cTemplates)
{
FIXME("%s: no class found.\n", debugstr_guid(rclsid));
return CLASS_E_CLASSNOTAVAILABLE;

View File

@ -1,6 +1,7 @@
MODULE = strmbase
C_SRCS = \
dllfunc.c \
enumpins.c \
filter.c \
mediatype.c \

93
dlls/strmbase/dllfunc.c Normal file
View File

@ -0,0 +1,93 @@
/*
* Strmbase DLL functions
*
* Copyright (C) 2005 Rolf Kalbermatter
* Copyright (C) 2010 Aric Stewart, CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include <assert.h>
#define COBJMACROS
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winerror.h"
#include "winreg.h"
#include "objbase.h"
#include "uuids.h"
#include "strmif.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/strmbase.h"
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
extern const int g_cTemplates;
extern const FactoryTemplate g_Templates[];
HRESULT WINAPI AMovieSetupRegisterFilter2( const AMOVIESETUP_FILTER const * pFilter, IFilterMapper2 *pIFM2, BOOL bRegister)
{
if (!pFilter)
return S_OK;
if (bRegister)
{
{
REGFILTER2 rf2;
rf2.dwVersion = 1;
rf2.dwMerit = pFilter->merit;
rf2.u.s.cPins = pFilter->pins;
rf2.u.s.rgPins = pFilter->pPin;
return IFilterMapper2_RegisterFilter(pIFM2, pFilter->clsid, pFilter->name, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rf2);
}
}
else
return IFilterMapper2_UnregisterFilter(pIFM2, &CLSID_LegacyAmFilterCategory, NULL, pFilter->clsid);
}
HRESULT WINAPI AMovieDllRegisterServer2(BOOL bRegister)
{
HRESULT hr;
int i;
IFilterMapper2 *pIFM2 = NULL;
hr = CoInitialize(NULL);
TRACE("Getting IFilterMapper2\r\n");
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
&IID_IFilterMapper2, (void **)&pIFM2);
for (i = 0; SUCCEEDED(hr) && i < g_cTemplates; i++)
hr = AMovieSetupRegisterFilter2(g_Templates[i].m_pAMovieSetup_Filter, pIFM2, bRegister);
/* release interface */
if (pIFM2)
IFilterMapper2_Release(pIFM2);
/* and clear up */
CoFreeUnusedLibraries();
CoUninitialize();
return hr;
}

View File

@ -285,3 +285,30 @@ HRESULT WINAPI SourceSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG *
HRESULT WINAPI SourceSeekingImpl_SetRate(IMediaSeeking * iface, double dRate);
HRESULT WINAPI SourceSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate);
HRESULT WINAPI SourceSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll);
/* Filter Registration */
typedef REGPINTYPES AMOVIESETUP_MEDIATYPE;
typedef REGFILTERPINS AMOVIESETUP_PIN;
typedef struct AMOVIESETUP_FILTER {
const CLSID *clsid;
const WCHAR *name;
DWORD merit;
UINT pins;
const AMOVIESETUP_PIN *pPin;
} AMOVIESETUP_FILTER, *LPAMOVIESETUP_FILTER;
typedef IUnknown *(CALLBACK *LPFNNewCOMObject)(LPUNKNOWN pUnkOuter, HRESULT *phr);
typedef void (CALLBACK *LPFNInitRoutine)(BOOL bLoading, const CLSID *rclsid);
typedef struct tagFactoryTemplate {
const WCHAR *m_Name;
const CLSID *m_ClsID;
LPFNNewCOMObject m_lpfnNew;
LPFNInitRoutine m_lpfnInit;
const AMOVIESETUP_FILTER *m_pAMovieSetup_Filter;
} FactoryTemplate;
HRESULT WINAPI AMovieDllRegisterServer2(BOOL bRegister);
HRESULT WINAPI AMovieSetupRegisterFilter2( const AMOVIESETUP_FILTER const * pFilter, IFilterMapper2 *pIFM2, BOOL bRegister);