- Add amstream from Wine
authorDmitry Chapyshev <dmitry@reactos.org>
Sat, 11 Apr 2009 07:24:37 +0000 (07:24 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Sat, 11 Apr 2009 07:24:37 +0000 (07:24 +0000)
svn path=/trunk/; revision=40452

14 files changed:
reactos/baseaddress.rbuild
reactos/boot/bootdata/packages/reactos.dff
reactos/dll/directx/amstream/amstream.c [new file with mode: 0644]
reactos/dll/directx/amstream/amstream.rbuild [new file with mode: 0644]
reactos/dll/directx/amstream/amstream.spec [new file with mode: 0644]
reactos/dll/directx/amstream/amstream_i.c [new file with mode: 0644]
reactos/dll/directx/amstream/amstream_private.h [new file with mode: 0644]
reactos/dll/directx/amstream/main.c [new file with mode: 0644]
reactos/dll/directx/amstream/mediastream.c [new file with mode: 0644]
reactos/dll/directx/amstream/mediastreamfilter.c [new file with mode: 0644]
reactos/dll/directx/amstream/regsvr.c [new file with mode: 0644]
reactos/dll/directx/amstream/version.rc [new file with mode: 0644]
reactos/dll/directx/directx.rbuild
reactos/media/doc/README.WINE

index dce15eb..0c3f246 100644 (file)
   <property name="BASEADDRESS_CARDS" value="0x701a0000" />
   <property name="BASEADDRESS_WININET" value="0x70200000" />
   <property name="BASEADDRESS_WINHTTP" value="0x70c60000" />
+  <property name="BASEADDRESS_AMSTREAM" value="0x71030000" />
   <property name="BASEADDRESS_ACLUI" value="0x71550000" />
   <property name="BASEADDRESS_DHCPCSVC" value="0x71650000" />
   <property name="BASEADDRESS_SHDOCVW" value="0x71700000" />
index bb6404f..03bc4af 100644 (file)
@@ -140,6 +140,7 @@ dll\cpl\sysdm\sysdm.cpl                             1
 dll\cpl\timedate\timedate.cpl                       1
 ;dll\cpl\usrmgr\usrmgr.cpl                          1
 
+dll\directx\amstream\amstream.dll                   1
 dll\directx\dinput\dinput.dll                       1
 dll\directx\dinput8\dinput8.dll                     1
 dll\directx\dplay\dplay.dll                         1
diff --git a/reactos/dll/directx/amstream/amstream.c b/reactos/dll/directx/amstream/amstream.c
new file mode 100644 (file)
index 0000000..9e4d45a
--- /dev/null
@@ -0,0 +1,400 @@
+/*
+ * Implementation of IAMMultiMediaStream Interface
+ *
+ * Copyright 2004 Christian Costa
+ * Copyright 2006 Ivan Leo Puoti
+ *
+ * This file contains the (internal) driver registration functions,
+ * driver enumeration APIs and DirectDraw creation functions.
+ *
+ * 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 "wine/debug.h"
+
+#define COBJMACROS
+
+#include "winbase.h"
+#include "wingdi.h"
+
+#include "amstream_private.h"
+#include "amstream.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(amstream);
+
+typedef struct {
+    IAMMultiMediaStream lpVtbl;
+    LONG ref;
+    IGraphBuilder* pFilterGraph;
+    IPin* ipin;
+    IGraphBuilder* GraphBuilder;
+    ULONG nbStreams;
+    IMediaStream** pStreams;
+    STREAM_TYPE StreamType;
+} IAMMultiMediaStreamImpl;
+
+static const struct IAMMultiMediaStreamVtbl AM_Vtbl;
+
+HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj)
+{
+    IAMMultiMediaStreamImpl* object; 
+
+    TRACE("(%p,%p)\n", pUnkOuter, ppObj);
+
+    if( pUnkOuter )
+        return CLASS_E_NOAGGREGATION;
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAMMultiMediaStreamImpl));
+    if (!object)
+    {
+        ERR("Out of memory\n");
+        return E_OUTOFMEMORY;
+    }
+
+    object->lpVtbl.lpVtbl = &AM_Vtbl;
+    object->ref = 1;
+
+    *ppObj = object;
+
+    return S_OK;
+}
+
+/*** IUnknown methods ***/
+static HRESULT WINAPI IAMMultiMediaStreamImpl_QueryInterface(IAMMultiMediaStream* iface, REFIID riid, void** ppvObject)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
+
+    if (IsEqualGUID(riid, &IID_IUnknown) ||
+        IsEqualGUID(riid, &IID_IAMMultiMediaStream))
+    {
+        IClassFactory_AddRef(iface);
+        *ppvObject = This;
+        return S_OK;
+    }
+
+    ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IAMMultiMediaStreamImpl_AddRef(IAMMultiMediaStream* iface)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    TRACE("(%p/%p)\n", iface, This);
+
+    return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI IAMMultiMediaStreamImpl_Release(IAMMultiMediaStream* iface)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p/%p)\n", iface, This);
+
+    if (!ref)
+        HeapFree(GetProcessHeap(), 0, This);
+
+    return ref;
+}
+
+/*** IMultiMediaStream methods ***/
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetInformation(IAMMultiMediaStream* iface, DWORD* pdwFlags, STREAM_TYPE* pStreamType)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, pdwFlags, pStreamType);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream* iface, REFMSPID idPurpose, IMediaStream** ppMediaStream)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+    MSPID PurposeId;
+    unsigned int i;
+
+    TRACE("(%p/%p)->(%p,%p)\n", This, iface, idPurpose, ppMediaStream);
+
+    for (i = 0; i < This->nbStreams; i++)
+    {
+        IMediaStream_GetInformation(This->pStreams[i], &PurposeId, NULL);
+        if (IsEqualIID(&PurposeId, idPurpose))
+        {
+            *ppMediaStream = This->pStreams[i];
+            IMediaStream_AddRef(*ppMediaStream);
+            return S_OK;
+        }
+    }
+
+    return MS_E_NOSTREAM;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_EnumMediaStreams(IAMMultiMediaStream* iface, LONG Index, IMediaStream** ppMediaStream)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%d,%p) stub!\n", This, iface, Index, ppMediaStream);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetState(IAMMultiMediaStream* iface, STREAM_STATE* pCurrentState)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentState);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_SetState(IAMMultiMediaStream* iface, STREAM_STATE NewState)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->() stub!\n", This, iface);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetTime(IAMMultiMediaStream* iface, STREAM_TIME* pCurrentTime)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentTime);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetDuration(IAMMultiMediaStream* iface, STREAM_TIME* pDuration)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p) stub!\n", This, iface, pDuration);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_Seek(IAMMultiMediaStream* iface, STREAM_TIME SeekTime)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->() stub!\n", This, iface);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetEndOfStream(IAMMultiMediaStream* iface, HANDLE* phEOS)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p) stub!\n", This, iface, phEOS);
+
+    return E_NOTIMPL;
+}
+
+/*** IAMMultiMediaStream methods ***/
+static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* iface, STREAM_TYPE StreamType, DWORD dwFlags, IGraphBuilder* pFilterGraph)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+    HRESULT hr = S_OK;
+
+    FIXME("(%p/%p)->(%x,%x,%p) partial stub!\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph);
+
+    if (pFilterGraph)
+    {
+        This->pFilterGraph = pFilterGraph;
+        IGraphBuilder_AddRef(This->pFilterGraph);
+    }
+    else
+    {
+        hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&This->pFilterGraph);
+    }
+
+    if (SUCCEEDED(hr))
+    {
+        This->StreamType = StreamType;
+    }
+
+    return hr;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream* iface, IGraphBuilder** ppGraphBuilder)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppGraphBuilder);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream* iface, IMediaStreamFilter** ppFilter)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppFilter); 
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream* iface, IUnknown* pStreamObject, const MSPID* PurposeId,
+                                          DWORD dwFlags, IMediaStream** ppNewStream)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+    HRESULT hr;
+    IMediaStream* pStream;
+    IMediaStream** pNewStreams;
+
+    FIXME("(%p/%p)->(%p,%p,%x,%p) partial stub!\n", This, iface, pStreamObject, PurposeId, dwFlags, ppNewStream);
+
+    if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo))
+        hr = DirectDrawMediaStream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
+    else
+        hr = MediaStream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
+
+    if (SUCCEEDED(hr))
+    {
+        pNewStreams = CoTaskMemAlloc((This->nbStreams+1)*sizeof(IMediaStream*));
+        if (!pNewStreams)
+        {
+            IMediaStream_Release(pStream);
+            return E_OUTOFMEMORY;
+        }
+        if (This->nbStreams)
+            CopyMemory(pNewStreams, This->pStreams, This->nbStreams*sizeof(IMediaStream*));
+        CoTaskMemFree(This->pStreams);
+        This->pStreams = pNewStreams;
+        This->pStreams[This->nbStreams] = pStream;
+        This->nbStreams++;
+
+        if (ppNewStream)
+            *ppNewStream = pStream;
+    }
+
+    return hr;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* iface, LPCWSTR pszFileName, DWORD dwFlags)
+{
+    HRESULT ret;
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+    IFileSourceFilter *SourceFilter;
+    IBaseFilter *BaseFilter;
+    IEnumPins *EnumPins;
+    IPin *ipin;
+    PIN_DIRECTION pin_direction;
+
+    TRACE("(%p/%p)->(%s,%x)\n", This, iface, debugstr_w(pszFileName), dwFlags);
+
+    ret = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSourceFilter, (void**)&SourceFilter);
+    if(ret != S_OK)
+        return ret;
+
+    ret = IFileSourceFilter_Load(SourceFilter, pszFileName, NULL);
+    if(ret != S_OK)
+    {
+        IFileSourceFilter_Release(SourceFilter);
+        return ret;
+    }
+
+    ret = IFileSourceFilter_QueryInterface(SourceFilter, &IID_IBaseFilter, (void**)&BaseFilter);
+    if(ret != S_OK)
+    {
+        IFileSourceFilter_Release(SourceFilter);
+        return ret;
+    }
+
+    ret = IBaseFilter_EnumPins(BaseFilter, &EnumPins);
+    if(ret != S_OK)
+    {
+        goto end;
+    }
+
+    ret = IEnumPins_Next(EnumPins, 1, &ipin, NULL);
+    if(ret == S_OK)
+    {
+        ret = IPin_QueryDirection(ipin, &pin_direction);
+        IEnumPins_Release(EnumPins);
+        if(ret == S_OK && pin_direction == PINDIR_OUTPUT)
+            This->ipin = ipin;
+        else
+            goto end;
+    }
+    else
+    {
+        IEnumPins_Release(EnumPins);
+        goto end;
+    }
+
+    ret = IFilterGraph_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)&This->GraphBuilder);
+    if(ret != S_OK)
+    {
+        goto end;
+    }
+
+    ret = IGraphBuilder_AddSourceFilter(This->GraphBuilder, pszFileName, pszFileName, &BaseFilter);
+
+end:
+    IBaseFilter_Release(BaseFilter);
+    IFileSourceFilter_Release(SourceFilter);
+    return ret;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenMoniker(IAMMultiMediaStream* iface, IBindCtx* pCtx, IMoniker* pMoniker, DWORD dwFlags)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p,%p,%x) stub!\n", This, iface, pCtx, pMoniker, dwFlags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAMMultiMediaStreamImpl_Render(IAMMultiMediaStream* iface, DWORD dwFlags)
+{
+    IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%x) partial stub!\n", This, iface, dwFlags);
+
+    if(dwFlags != AMMSF_NOCLOCK)
+        return E_INVALIDARG;
+
+    return IGraphBuilder_Render(This->GraphBuilder, This->ipin);
+}
+
+static const IAMMultiMediaStreamVtbl AM_Vtbl =
+{
+    IAMMultiMediaStreamImpl_QueryInterface,
+    IAMMultiMediaStreamImpl_AddRef,
+    IAMMultiMediaStreamImpl_Release,
+    IAMMultiMediaStreamImpl_GetInformation,
+    IAMMultiMediaStreamImpl_GetMediaStream,
+    IAMMultiMediaStreamImpl_EnumMediaStreams,
+    IAMMultiMediaStreamImpl_GetState,
+    IAMMultiMediaStreamImpl_SetState,
+    IAMMultiMediaStreamImpl_GetTime,
+    IAMMultiMediaStreamImpl_GetDuration,
+    IAMMultiMediaStreamImpl_Seek,
+    IAMMultiMediaStreamImpl_GetEndOfStream,
+    IAMMultiMediaStreamImpl_Initialize,
+    IAMMultiMediaStreamImpl_GetFilterGraph,
+    IAMMultiMediaStreamImpl_GetFilter,
+    IAMMultiMediaStreamImpl_AddMediaStream,
+    IAMMultiMediaStreamImpl_OpenFile,
+    IAMMultiMediaStreamImpl_OpenMoniker,
+    IAMMultiMediaStreamImpl_Render
+};
diff --git a/reactos/dll/directx/amstream/amstream.rbuild b/reactos/dll/directx/amstream/amstream.rbuild
new file mode 100644 (file)
index 0000000..3411607
--- /dev/null
@@ -0,0 +1,22 @@
+<module name="amstream" type="win32dll" baseaddress="${BASEADDRESS_AMSTREAM}" installbase="system32" installname="amstream.dll" allowwarnings="true">
+       <autoregister infsection="OleControlDlls" type="DllRegisterServer" />
+       <importlibrary definition="amstream.spec" />
+       <include base="amstream">.</include>
+       <include base="ReactOS">include/reactos/wine</include>
+       <define name="_WIN32_WINNT">0x600</define>
+       <define name="__WINESRC__" />
+       <file>amstream.c</file>
+       <file>main.c</file>
+       <file>mediastream.c</file>
+       <file>mediastreamfilter.c</file>
+       <file>regsvr.c</file>
+       <file>amstream_i.c</file>
+       <file>version.rc</file>
+       <library>wine</library>
+       <library>strmiids</library>
+       <library>uuid</library>
+       <library>ole32</library>
+       <library>advapi32</library>
+       <library>kernel32</library>
+       <library>ntdll</library>
+</module>
diff --git a/reactos/dll/directx/amstream/amstream.spec b/reactos/dll/directx/amstream/amstream.spec
new file mode 100644 (file)
index 0000000..b16365d
--- /dev/null
@@ -0,0 +1,4 @@
+@ stdcall -private DllCanUnloadNow()
+@ stdcall -private DllGetClassObject(ptr ptr ptr)
+@ stdcall -private DllRegisterServer()
+@ stdcall -private DllUnregisterServer()
diff --git a/reactos/dll/directx/amstream/amstream_i.c b/reactos/dll/directx/amstream/amstream_i.c
new file mode 100644 (file)
index 0000000..d978bca
--- /dev/null
@@ -0,0 +1,14 @@
+#include <rpc.h>
+#include <rpcndr.h>
+
+#include <initguid.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+DEFINE_GUID(CLSID_MediaStreamFilter, 0x49c47ce0, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/reactos/dll/directx/amstream/amstream_private.h b/reactos/dll/directx/amstream/amstream_private.h
new file mode 100644 (file)
index 0000000..b10b632
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *      MultiMedia Streams private interfaces (AMSTREAM.DLL)
+ *
+ * Copyright 2004 Christian Costa
+ *
+ * This file contains the (internal) driver registration functions,
+ * driver enumeration APIs and DirectDraw creation functions.
+ *
+ * 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
+ */
+
+#ifndef __AMSTREAM_PRIVATE_INCLUDED__
+#define __AMSTREAM_PRIVATE_INCLUDED__
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wtypes.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "dshow.h"
+#include "mmstream.h"
+
+HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj);
+HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj);
+HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream);
+HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream);
+
+#endif /* __AMSTREAM_PRIVATE_INCLUDED__ */
diff --git a/reactos/dll/directx/amstream/main.c b/reactos/dll/directx/amstream/main.c
new file mode 100644 (file)
index 0000000..8af5619
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ *     MultiMedia Streams Base Functions (AMSTREAM.DLL)
+ *
+ * Copyright 2004 Christian Costa
+ *
+ * This file contains the (internal) driver registration functions,
+ * driver enumeration APIs and DirectDraw creation functions.
+ *
+ * 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 <stdarg.h>
+#include <string.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winerror.h"
+
+#include "ole2.h"
+
+#include "amstream_private.h"
+#include "amstream.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(amstream);
+
+static DWORD dll_ref = 0;
+
+/* For the moment, do nothing here. */
+BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
+{
+    switch(fdwReason) {
+        case DLL_PROCESS_ATTACH:
+            DisableThreadLibraryCalls(hInstDLL);
+           break;
+       case DLL_PROCESS_DETACH:
+           break;
+    }
+    return TRUE;
+}
+
+/******************************************************************************
+ * Multimedia Streams ClassFactory
+ */
+typedef struct {
+    IClassFactory ITF_IClassFactory;
+
+    LONG ref;
+    HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
+} IClassFactoryImpl;
+
+struct object_creation_info
+{
+    const CLSID *clsid;
+    HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
+};
+
+static const struct object_creation_info object_creation[] =
+{
+    { &CLSID_AMMultiMediaStream, AM_create },
+    { &CLSID_AMDirectDrawStream, AM_create },
+    { &CLSID_MediaStreamFilter, MediaStreamFilter_create }
+};
+
+static HRESULT WINAPI
+AMCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+    IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+
+    if (IsEqualGUID(riid, &IID_IUnknown)
+       || IsEqualGUID(riid, &IID_IClassFactory))
+    {
+       IClassFactory_AddRef(iface);
+       *ppobj = This;
+       return S_OK;
+    }
+
+    WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI AMCF_AddRef(LPCLASSFACTORY iface)
+{
+    IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+    return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI AMCF_Release(LPCLASSFACTORY iface)
+{
+    IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    if (ref == 0)
+       HeapFree(GetProcessHeap(), 0, This);
+
+    return ref;
+}
+
+
+static HRESULT WINAPI AMCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
+                                         REFIID riid, LPVOID *ppobj)
+{
+    IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+    HRESULT hres;
+    LPUNKNOWN punk;
+    
+    TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
+
+    *ppobj = NULL;
+    hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
+    if (SUCCEEDED(hres)) {
+        hres = IUnknown_QueryInterface(punk, riid, ppobj);
+        IUnknown_Release(punk);
+    }
+    return hres;
+}
+
+static HRESULT WINAPI AMCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+    IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+    FIXME("(%p)->(%d),stub!\n",This,dolock);
+    return S_OK;
+}
+
+static const IClassFactoryVtbl DSCF_Vtbl =
+{
+    AMCF_QueryInterface,
+    AMCF_AddRef,
+    AMCF_Release,
+    AMCF_CreateInstance,
+    AMCF_LockServer
+};
+
+/*******************************************************************************
+ * DllGetClassObject [AMSTREAM.@]
+ * Retrieves class object from a DLL object
+ *
+ * NOTES
+ *    Docs say returns STDAPI
+ *
+ * PARAMS
+ *    rclsid [I] CLSID for the class object
+ *    riid   [I] Reference to identifier of interface for class object
+ *    ppv    [O] Address of variable to receive interface pointer for riid
+ *
+ * RETURNS
+ *    Success: S_OK
+ *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
+ *             E_UNEXPECTED
+ */
+HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    unsigned int i;
+    IClassFactoryImpl *factory;
+    
+    TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    
+    if ( !IsEqualGUID( &IID_IClassFactory, riid )
+        && ! IsEqualGUID( &IID_IUnknown, riid) )
+       return E_NOINTERFACE;
+
+    for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
+    {
+       if (IsEqualGUID(object_creation[i].clsid, rclsid))
+           break;
+    }
+
+    if (i == sizeof(object_creation)/sizeof(object_creation[0]))
+    {
+       FIXME("%s: no class found.\n", debugstr_guid(rclsid));
+       return CLASS_E_CLASSNOTAVAILABLE;
+    }
+
+    factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
+    if (factory == NULL) return E_OUTOFMEMORY;
+
+    factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
+    factory->ref = 1;
+
+    factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
+
+    *ppv = &(factory->ITF_IClassFactory);
+    return S_OK;
+}
+
+/***********************************************************************
+ *              DllCanUnloadNow (AMSTREAM.@)
+ */
+HRESULT WINAPI DllCanUnloadNow(void)
+{
+    return dll_ref != 0 ? S_FALSE : S_OK;
+}
diff --git a/reactos/dll/directx/amstream/mediastream.c b/reactos/dll/directx/amstream/mediastream.c
new file mode 100644 (file)
index 0000000..bf197aa
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * Implementation of IMediaStream Interface
+ *
+ * Copyright 2005, 2008 Christian Costa
+ *
+ * This file contains the (internal) driver registration functions,
+ * driver enumeration APIs and DirectDraw creation functions.
+ *
+ * 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 "wine/debug.h"
+
+#define COBJMACROS
+
+#include "winbase.h"
+#include "wingdi.h"
+
+#include "amstream_private.h"
+#include "ddstream.h"
+#include "amstream.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(amstream);
+
+typedef struct {
+    IMediaStream lpVtbl;
+    LONG ref;
+    IMultiMediaStream* Parent;
+    MSPID PurposeId;
+    STREAM_TYPE StreamType;
+} IMediaStreamImpl;
+
+typedef struct {
+    IDirectDrawMediaStream lpVtbl;
+    LONG ref;
+    IMultiMediaStream* Parent;
+    MSPID PurposeId;
+    STREAM_TYPE StreamType;
+} IDirectDrawMediaStreamImpl;
+
+static const struct IMediaStreamVtbl MediaStream_Vtbl;
+static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl;
+
+HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream)
+{
+    IMediaStreamImpl* object; 
+
+    TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl));
+    if (!object)
+    {
+        ERR("Out of memory\n");
+        return E_OUTOFMEMORY;
+    }
+
+    object->lpVtbl.lpVtbl = &MediaStream_Vtbl;
+    object->ref = 1;
+
+    object->Parent = Parent;
+    object->PurposeId = *pPurposeId;
+    object->StreamType = StreamType;
+
+    *ppMediaStream = (IMediaStream*)object;
+
+    return S_OK;
+}
+
+/*** IUnknown methods ***/
+static HRESULT WINAPI IMediaStreamImpl_QueryInterface(IMediaStream* iface, REFIID riid, void** ppvObject)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
+
+    if (IsEqualGUID(riid, &IID_IUnknown) ||
+        IsEqualGUID(riid, &IID_IMediaStream))
+    {
+      IClassFactory_AddRef(iface);
+      *ppvObject = This;
+      return S_OK;
+    }
+
+    ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IMediaStreamImpl_AddRef(IMediaStream* iface)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    TRACE("(%p/%p)\n", iface, This);
+
+    return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI IMediaStreamImpl_Release(IMediaStream* iface)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p/%p)\n", iface, This);
+
+    if (!ref)
+      HeapFree(GetProcessHeap(), 0, This);
+
+    return ref;
+}
+
+/*** IMediaStream methods ***/
+static HRESULT WINAPI IMediaStreamImpl_GetMultiMediaStream(IMediaStream* iface, IMultiMediaStream** ppMultiMediaStream)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppMultiMediaStream);
+
+    return S_FALSE;
+}
+
+
+static HRESULT WINAPI IMediaStreamImpl_GetInformation(IMediaStream* iface, MSPID* pPurposeId, STREAM_TYPE* pType)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    TRACE("(%p/%p)->(%p,%p)\n", This, iface, pPurposeId, pType);
+
+    if (pPurposeId)
+        *pPurposeId = This->PurposeId;
+    if (pType)
+        *pType = This->StreamType;
+
+    return S_OK;
+}
+
+static HRESULT WINAPI IMediaStreamImpl_SetSameFormat(IMediaStream* iface, IMediaStream* pStreamThatHasDesiredFormat, DWORD dwFlags)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
+
+    return S_FALSE;
+}
+
+static HRESULT WINAPI IMediaStreamImpl_AllocateSample(IMediaStream* iface, DWORD dwFlags, IStreamSample** ppSample)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
+
+    return S_FALSE;
+}
+
+static HRESULT WINAPI IMediaStreamImpl_CreateSharedSample(IMediaStream* iface, IStreamSample* pExistingSample, DWORD dwFlags, IStreamSample** ppSample)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
+
+    return S_FALSE;
+}
+
+static HRESULT WINAPI IMediaStreamImpl_SendEndOfStream(IMediaStream* iface, DWORD dwFlags)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
+
+    return S_FALSE;
+}
+
+static const struct IMediaStreamVtbl MediaStream_Vtbl =
+{
+    IMediaStreamImpl_QueryInterface,
+    IMediaStreamImpl_AddRef,
+    IMediaStreamImpl_Release,
+    IMediaStreamImpl_GetMultiMediaStream,
+    IMediaStreamImpl_GetInformation,
+    IMediaStreamImpl_SetSameFormat,
+    IMediaStreamImpl_AllocateSample,
+    IMediaStreamImpl_CreateSharedSample,
+    IMediaStreamImpl_SendEndOfStream
+};
+
+HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream)
+{
+    IDirectDrawMediaStreamImpl* object;
+
+    TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl));
+    if (!object)
+    {
+        ERR("Out of memory\n");
+        return E_OUTOFMEMORY;
+    }
+
+    object->lpVtbl.lpVtbl = &DirectDrawMediaStream_Vtbl;
+    object->ref = 1;
+
+    object->Parent = Parent;
+    object->PurposeId = *pPurposeId;
+    object->StreamType = StreamType;
+
+    *ppMediaStream = (IMediaStream*)object;
+
+    return S_OK;
+}
+
+static HRESULT WINAPI IDirectDrawMediaStreamImpl_QueryInterface(IDirectDrawMediaStream* iface, REFIID riid, void** ppvObject)
+{
+    IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
+
+    TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
+
+    if (IsEqualGUID(riid, &IID_IUnknown) ||
+        IsEqualGUID(riid, &IID_IMediaStream) ||
+        IsEqualGUID(riid, &IID_IDirectDrawMediaStream))
+    {
+      IClassFactory_AddRef(iface);
+      *ppvObject = This;
+      return S_OK;
+    }
+
+    ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
+    return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetFormat(IDirectDrawMediaStream* iface, DDSURFACEDESC *pDDSDCurrent,
+                                                           IDirectDrawPalette **ppDirectDrawPalette, DDSURFACEDESC *pDDSDDesired, DWORD *pdwFlags)
+{
+    FIXME("(%p)->(%p,%p,%p,%p) stub!\n", iface, pDDSDCurrent, ppDirectDrawPalette, pDDSDDesired, pdwFlags);
+
+    return E_NOTIMPL;
+
+}
+
+static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetFormat(IDirectDrawMediaStream* iface, const DDSURFACEDESC *pDDSurfaceDesc,
+                                                          IDirectDrawPalette *pDirectDrawPalette)
+{
+    FIXME("(%p)->(%p,%p) stub!\n", iface, pDDSurfaceDesc, pDirectDrawPalette);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetDirectDraw(IDirectDrawMediaStream* iface, IDirectDraw **ppDirectDraw)
+{
+    FIXME("(%p)->(%p) stub!\n", iface, ppDirectDraw);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetDirectDraw(IDirectDrawMediaStream* iface, IDirectDraw *pDirectDraw)
+{
+    FIXME("(%p)->(%p) stub!\n", iface, pDirectDraw);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IDirectDrawMediaStreamImpl_CreateSample(IDirectDrawMediaStream* iface, IDirectDrawSurface *pSurface, const RECT *pRect,
+                                                             DWORD dwFlags, IDirectDrawStreamSample **ppSample)
+{
+    FIXME("(%p)->(%p,%p,%x,%p) stub!\n", iface, pSurface, pRect, dwFlags, ppSample);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetTimePerFrame(IDirectDrawMediaStream* iface, STREAM_TIME *pFrameTime)
+{
+    FIXME("(%p)->(%p) stub!\n", iface, pFrameTime);
+
+    return E_NOTIMPL;
+}
+
+/* Note: Hack so we can reuse the old functions without compiler warnings */
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)     (typeof(DirectDrawMediaStream_Vtbl.fun))
+#else
+# define XCAST(fun)     (void*)
+#endif
+
+static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl =
+{
+    IDirectDrawMediaStreamImpl_QueryInterface,
+    XCAST(AddRef)IMediaStreamImpl_AddRef,
+    XCAST(Release)IMediaStreamImpl_Release,
+    XCAST(GetMultiMediaStream)IMediaStreamImpl_GetMultiMediaStream,
+    XCAST(GetInformation)IMediaStreamImpl_GetInformation,
+    XCAST(SetSameFormat)IMediaStreamImpl_SetSameFormat,
+    XCAST(AllocateSample)IMediaStreamImpl_AllocateSample,
+    XCAST(CreateSharedSample)IMediaStreamImpl_CreateSharedSample,
+    XCAST(SendEndOfStream)IMediaStreamImpl_SendEndOfStream,
+    IDirectDrawMediaStreamImpl_GetFormat,
+    IDirectDrawMediaStreamImpl_SetFormat,
+    IDirectDrawMediaStreamImpl_GetDirectDraw,
+    IDirectDrawMediaStreamImpl_SetDirectDraw,
+    IDirectDrawMediaStreamImpl_CreateSample,
+    IDirectDrawMediaStreamImpl_GetTimePerFrame
+};
+#undef XCAST
diff --git a/reactos/dll/directx/amstream/mediastreamfilter.c b/reactos/dll/directx/amstream/mediastreamfilter.c
new file mode 100644 (file)
index 0000000..af335fd
--- /dev/null
@@ -0,0 +1,313 @@
+/*
+ * Implementation of MediaStream Filter
+ *
+ * Copyright 2008 Christian Costa
+ *
+ * This file contains the (internal) driver registration functions,
+ * driver enumeration APIs and DirectDraw creation functions.
+ *
+ * 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 "wine/debug.h"
+
+#define COBJMACROS
+
+#include "winbase.h"
+#include "wingdi.h"
+
+#include "amstream_private.h"
+#include "amstream.h"
+
+#include "ddstream.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(amstream);
+
+typedef struct {
+    IMediaStreamFilter lpVtbl;
+    LONG ref;
+    CRITICAL_SECTION csFilter;
+    FILTER_STATE state;
+    REFERENCE_TIME rtStreamStart;
+    IReferenceClock * pClock;
+    FILTER_INFO filterInfo;
+} IMediaStreamFilterImpl;
+
+static const struct IMediaStreamFilterVtbl MediaStreamFilter_Vtbl;
+
+HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj)
+{
+    IMediaStreamFilterImpl* object;
+
+    TRACE("(%p,%p)\n", pUnkOuter, ppObj);
+
+    if( pUnkOuter )
+        return CLASS_E_NOAGGREGATION;
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamFilterImpl));
+    if (!object)
+    {
+        ERR("Out of memory\n");
+        return E_OUTOFMEMORY;
+    }
+
+    object->lpVtbl.lpVtbl = &MediaStreamFilter_Vtbl;
+    object->ref = 1;
+
+    *ppObj = object;
+
+    return S_OK;
+}
+
+/*** IUnknown methods ***/
+
+static HRESULT WINAPI MediaStreamFilterImpl_QueryInterface(IMediaStreamFilter * iface, REFIID riid, LPVOID * ppv)
+{
+    IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
+
+    TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
+
+    *ppv = NULL;
+
+    if (IsEqualIID(riid, &IID_IUnknown))
+        *ppv = This;
+    else if (IsEqualIID(riid, &IID_IPersist))
+        *ppv = This;
+    else if (IsEqualIID(riid, &IID_IMediaFilter))
+        *ppv = This;
+    else if (IsEqualIID(riid, &IID_IBaseFilter))
+        *ppv = This;
+    else if (IsEqualIID(riid, &IID_IMediaStreamFilter))
+        *ppv = This;
+
+    if (*ppv)
+    {
+        IUnknown_AddRef((IUnknown *)(*ppv));
+        return S_OK;
+    }
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI MediaStreamFilterImpl_AddRef(IMediaStreamFilter * iface)
+{
+    IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p)->() AddRef from %d\n", iface, refCount - 1);
+
+    return refCount;
+}
+
+static ULONG WINAPI MediaStreamFilterImpl_Release(IMediaStreamFilter * iface)
+{
+    IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
+
+    if (!refCount)
+    {
+        This->lpVtbl.lpVtbl = NULL;
+        HeapFree(GetProcessHeap(), 0, This);
+    }
+
+    return refCount;
+}
+
+/*** IPersist methods ***/
+
+static HRESULT WINAPI MediaStreamFilterImpl_GetClassID(IMediaStreamFilter * iface, CLSID * pClsid)
+{
+    TRACE("(%p)->(%p)\n", iface, pClsid);
+
+    *pClsid = CLSID_MediaStreamFilter;
+
+    return S_OK;
+}
+
+/*** IMediaFilter methods ***/
+
+static HRESULT WINAPI MediaStreamFilterImpl_Stop(IMediaStreamFilter * iface)
+{
+    FIXME("(%p)->(): Stub!\n", iface);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_Pause(IMediaStreamFilter * iface)
+{
+    FIXME("(%p)->(): Stub!\n", iface);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_Run(IMediaStreamFilter * iface, REFERENCE_TIME tStart)
+{
+    FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(tStart));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_GetState(IMediaStreamFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
+{
+    FIXME("(%p)->(%d,%p): Stub!\n", iface, dwMilliSecsTimeout, pState);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_SetSyncSource(IMediaStreamFilter * iface, IReferenceClock *pClock)
+{
+    TRACE("(%p)->(%p): Stub!\n", iface, pClock);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_GetSyncSource(IMediaStreamFilter * iface, IReferenceClock **ppClock)
+{
+    FIXME("(%p)->(%p): Stub!\n", iface, ppClock);
+
+    return E_NOTIMPL;
+}
+
+/*** IBaseFilter methods ***/
+
+static HRESULT WINAPI MediaStreamFilterImpl_EnumPins(IMediaStreamFilter * iface, IEnumPins **ppEnum)
+{
+    FIXME("(%p)->(%p): Stub!\n", iface, ppEnum);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_FindPin(IMediaStreamFilter * iface, LPCWSTR Id, IPin **ppPin)
+{
+    FIXME("(%p)->(%s,%p): Stub!\n", iface, debugstr_w(Id), ppPin);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_QueryFilterInfo(IMediaStreamFilter * iface, FILTER_INFO *pInfo)
+{
+    FIXME("(%p)->(%p): Stub!\n", iface, pInfo);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_JoinFilterGraph(IMediaStreamFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
+{
+    FIXME("(%p)->(%p, %s): Stub!\n", iface, pGraph, debugstr_w(pName));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_QueryVendorInfo(IMediaStreamFilter * iface, LPWSTR *pVendorInfo)
+{
+    FIXME("(%p)->(%p): Stub!\n", iface, pVendorInfo);
+
+    return E_NOTIMPL;
+}
+
+/*** IMediaStreamFilter methods ***/
+
+static HRESULT WINAPI MediaStreamFilterImpl_AddMediaStream(IMediaStreamFilter* iface, IAMMediaStream *pAMMediaStream)
+{
+    FIXME("(%p)->(%p): Stub!\n", iface, pAMMediaStream);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_GetMediaStream(IMediaStreamFilter* iface, REFMSPID idPurpose, IMediaStream **ppMediaStream)
+{
+    FIXME("(%p)->(%s,%p): Stub!\n", iface, debugstr_guid(idPurpose), ppMediaStream);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_EnumMediaStreams(IMediaStreamFilter* iface, LONG Index, IMediaStream **ppMediaStream)
+{
+    FIXME("(%p)->(%d,%p): Stub!\n", iface, Index, ppMediaStream);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_SupportSeeking(IMediaStreamFilter* iface, BOOL bRenderer)
+{
+    FIXME("(%p)->(%d): Stub!\n", iface, bRenderer);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_ReferenceTimeToStreamTime(IMediaStreamFilter* iface, REFERENCE_TIME *pTime)
+{
+    FIXME("(%p)->(%p): Stub!\n", iface, pTime);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_GetCurrentStreamTime(IMediaStreamFilter* iface, REFERENCE_TIME *pCurrentStreamTime)
+{
+    FIXME("(%p)->(%p): Stub!\n", iface, pCurrentStreamTime);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_WaitUntil(IMediaStreamFilter* iface, REFERENCE_TIME WaitStreamTime)
+{
+    FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(WaitStreamTime));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_Flush(IMediaStreamFilter* iface, BOOL bCancelEOS)
+{
+    FIXME("(%p)->(%d): Stub!\n", iface, bCancelEOS);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI MediaStreamFilterImpl_EndOfStream(IMediaStreamFilter* iface)
+{
+    FIXME("(%p)->(): Stub!\n",  iface);
+
+    return E_NOTIMPL;
+}
+
+static const IMediaStreamFilterVtbl MediaStreamFilter_Vtbl =
+{
+    MediaStreamFilterImpl_QueryInterface,
+    MediaStreamFilterImpl_AddRef,
+    MediaStreamFilterImpl_Release,
+    MediaStreamFilterImpl_GetClassID,
+    MediaStreamFilterImpl_Stop,
+    MediaStreamFilterImpl_Pause,
+    MediaStreamFilterImpl_Run,
+    MediaStreamFilterImpl_GetState,
+    MediaStreamFilterImpl_SetSyncSource,
+    MediaStreamFilterImpl_GetSyncSource,
+    MediaStreamFilterImpl_EnumPins,
+    MediaStreamFilterImpl_FindPin,
+    MediaStreamFilterImpl_QueryFilterInfo,
+    MediaStreamFilterImpl_JoinFilterGraph,
+    MediaStreamFilterImpl_QueryVendorInfo,
+    MediaStreamFilterImpl_AddMediaStream,
+    MediaStreamFilterImpl_GetMediaStream,
+    MediaStreamFilterImpl_EnumMediaStreams,
+    MediaStreamFilterImpl_SupportSeeking,
+    MediaStreamFilterImpl_ReferenceTimeToStreamTime,
+    MediaStreamFilterImpl_GetCurrentStreamTime,
+    MediaStreamFilterImpl_WaitUntil,
+    MediaStreamFilterImpl_Flush,
+    MediaStreamFilterImpl_EndOfStream
+};
diff --git a/reactos/dll/directx/amstream/regsvr.c b/reactos/dll/directx/amstream/regsvr.c
new file mode 100644 (file)
index 0000000..028c68d
--- /dev/null
@@ -0,0 +1,498 @@
+/*
+ *     self-registerable dll functions for amstream.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * 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 <stdarg.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "ole2.h"
+
+#include "amstream.h"
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(amstream);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *             interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;            /* NULL for end of list */
+    LPCSTR name;               /* can be NULL to omit */
+    IID const *base_iid;       /* can be NULL to omit */
+    int num_methods;           /* can be <0 to omit */
+    CLSID const *ps_clsid;     /* can be NULL to omit */
+    CLSID const *ps_clsid32;   /* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;                /* NULL for end of list */
+    LPCSTR name;               /* can be NULL to omit */
+    LPCSTR ips;                        /* can be NULL to omit */
+    LPCSTR ips32;              /* can be NULL to omit */
+    LPCSTR ips32_tmodel;       /* can be NULL to omit */
+    LPCSTR progid;             /* can be NULL to omit */
+    LPCSTR viprogid;           /* can be NULL to omit */
+    LPCSTR progid_extra;       /* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *             static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *             static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+                                  WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+                                  char const *value);
+static LONG register_progid(WCHAR const *clsid,
+                           char const *progid, char const *curver_progid,
+                           char const *name, char const *extra);
+
+/***********************************************************************
+ *             register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+                         KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+       WCHAR buf[39];
+       HKEY iid_key;
+
+       StringFromGUID2(list->iid, buf, 39);
+       res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+                             KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+       if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+       if (list->name) {
+           res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+                                (CONST BYTE*)(list->name),
+                                strlen(list->name) + 1);
+           if (res != ERROR_SUCCESS) goto error_close_iid_key;
+       }
+
+       if (list->base_iid) {
+           res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+           if (res != ERROR_SUCCESS) goto error_close_iid_key;
+       }
+
+       if (0 <= list->num_methods) {
+           static WCHAR const fmt[3] = { '%', 'd', 0 };
+           HKEY key;
+
+           res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+                                 KEY_READ | KEY_WRITE, NULL, &key, NULL);
+           if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+           sprintfW(buf, fmt, list->num_methods);
+           res = RegSetValueExW(key, NULL, 0, REG_SZ,
+                                (CONST BYTE*)buf,
+                                (lstrlenW(buf) + 1) * sizeof(WCHAR));
+           RegCloseKey(key);
+
+           if (res != ERROR_SUCCESS) goto error_close_iid_key;
+       }
+
+       if (list->ps_clsid) {
+           res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+           if (res != ERROR_SUCCESS) goto error_close_iid_key;
+       }
+
+       if (list->ps_clsid32) {
+           res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+           if (res != ERROR_SUCCESS) goto error_close_iid_key;
+       }
+
+    error_close_iid_key:
+       RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *             unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+                       KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+       WCHAR buf[39];
+
+       StringFromGUID2(list->iid, buf, 39);
+       res = RegDeleteTreeW(interface_key, buf);
+       if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *             register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+                         KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+       WCHAR buf[39];
+       HKEY clsid_key;
+
+       StringFromGUID2(list->clsid, buf, 39);
+       res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+                             KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+       if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+       if (list->name) {
+           res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+                                (CONST BYTE*)(list->name),
+                                strlen(list->name) + 1);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+       }
+
+       if (list->ips) {
+           res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+       }
+
+       if (list->ips32) {
+           HKEY ips32_key;
+
+           res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+                                 KEY_READ | KEY_WRITE, NULL,
+                                 &ips32_key, NULL);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+           res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+                                (CONST BYTE*)list->ips32,
+                                lstrlenA(list->ips32) + 1);
+           if (res == ERROR_SUCCESS && list->ips32_tmodel)
+               res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+                                    (CONST BYTE*)list->ips32_tmodel,
+                                    strlen(list->ips32_tmodel) + 1);
+           RegCloseKey(ips32_key);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+       }
+
+       if (list->progid) {
+           res = register_key_defvalueA(clsid_key, progid_keyname,
+                                        list->progid);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+           res = register_progid(buf, list->progid, NULL,
+                                 list->name, list->progid_extra);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+       }
+
+       if (list->viprogid) {
+           res = register_key_defvalueA(clsid_key, viprogid_keyname,
+                                        list->viprogid);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+           res = register_progid(buf, list->viprogid, list->progid,
+                                 list->name, list->progid_extra);
+           if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+       }
+
+    error_close_clsid_key:
+       RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *             unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+                       KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+       WCHAR buf[39];
+
+       StringFromGUID2(list->clsid, buf, 39);
+       res = RegDeleteTreeW(coclass_key, buf);
+       if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
+       if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+       if (list->progid) {
+           res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
+           if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
+           if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+       }
+
+       if (list->viprogid) {
+           res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->viprogid);
+           if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
+           if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+       }
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *             regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *             regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+                         KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+                        (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *             regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+                         KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+                        lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *             regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+                         NULL, 0, KEY_READ | KEY_WRITE, NULL,
+                         &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+       res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+                            (CONST BYTE*)name, strlen(name) + 1);
+       if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+       res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+       if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+       res = register_key_defvalueA(progid_key, curver_keyname,
+                                    curver_progid);
+       if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+       HKEY extra_key;
+
+       res = RegCreateKeyExA(progid_key, extra, 0,
+                             NULL, 0, KEY_READ | KEY_WRITE, NULL,
+                             &extra_key, NULL);
+       if (res == ERROR_SUCCESS)
+           RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *             coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_AMMultiMediaStream,
+       "ActiveMovie MultiMedia Stream",
+       NULL,
+       "amstream.dll",
+       "Both"
+    },
+
+    {   &CLSID_AMDirectDrawStream,
+       "ActiveMovie MultiMedia Stream",
+       NULL,
+       "amstream.dll",
+       "Both"
+    },
+
+    { NULL }                   /* list terminator */
+};
+
+/***********************************************************************
+ *             interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }                   /* list terminator */
+};
+
+/***********************************************************************
+ *             DllRegisterServer (AMSTREAM.@)
+ */
+HRESULT WINAPI DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+       hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *             DllUnregisterServer (AMSTREAM.@)
+ */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+       hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/reactos/dll/directx/amstream/version.rc b/reactos/dll/directx/amstream/version.rc
new file mode 100644 (file)
index 0000000..d81bda3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2004 Christian Costa
+ *
+ * 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
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine AMStream dll"
+#define WINE_FILENAME_STR "amstream.dll"
+#define WINE_FILEVERSION 6,5,1,900
+#define WINE_FILEVERSION_STR "6.5.1.900"
+#define WINE_PRODUCTVERSION 6,5,1,900
+#define WINE_PRODUCTVERSION_STR "6.5"
+
+#include "wine/wine_common_ver.rc"
index a72e51b..b181341 100644 (file)
@@ -1,6 +1,9 @@
 <?xml version="1.0"?>
 <!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
+       <directory name="amstream">
+               <xi:include href="amstream/amstream.rbuild" />
+       </directory>
        <directory name="d3d8thk">
                <xi:include href="d3d8thk/d3d8thk.rbuild" />
        </directory>
index 5f941be..d9ac606 100644 (file)
@@ -30,11 +30,15 @@ reactos/tools/wrc                 # Synced to Wine-20081105 (~Wine-1.1.7)
 
 The following libraries are shared with Wine.
 
+reactos/dll/directx/amstream      # Autosync
 reactos/dll/directx/dinput        # Synced to Wine-1_1_4
 reactos/dll/directx/dinput8       # Synced to Wine-1_1_4
 reactos/dll/directx/dplay         # Synced to Wine-0_9_5
 reactos/dll/directx/dplayx        # Synced to Wine-0_9_5
 reactos/dll/directx/dxdiagn       # Synced to Wine-0_9_5
+reactos/dll/directx/msdmo         # Autosync
+reactos/dll/directx/qedit         # Autosync
+reactos/dll/directx/quartz        # Autosync
 reactos/dll/win32/advpack         # Autosync
 reactos/dll/win32/atl             # Autosync
 reactos/dll/win32/avifil32        # Autosync