[1/2] qedit: Implement IMediaDet_put_Filename.

Dan Hipschman dsh at linux.ucla.edu
Mon Apr 7 19:10:14 CDT 2008


I've also got a patch that implements IMediaDet_get_OutputStreams with
more tests which are based on this and the next patch, but that one needs
a little cleanup before I'll send it.

---
 dlls/qedit/mediadet.c       |   50 +++++++++++++++++++++++++++++++++++++++++-
 dlls/qedit/tests/mediadet.c |    2 +-
 2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/dlls/qedit/mediadet.c b/dlls/qedit/mediadet.c
index eb9f81d..728800e 100644
--- a/dlls/qedit/mediadet.c
+++ b/dlls/qedit/mediadet.c
@@ -25,8 +25,25 @@ WINE_DEFAULT_DEBUG_CHANNEL(qedit);
 typedef struct MediaDetImpl {
     const IMediaDetVtbl *MediaDet_Vtbl;
     LONG refCount;
+    IGraphBuilder *graph;
+    IBaseFilter *source;
 } MediaDetImpl;
 
+#define RELEASE(iface)                              \
+    do                                              \
+        if (iface)                                  \
+        {                                           \
+            IUnknown_Release((IUnknown *) iface);   \
+            iface = NULL;                           \
+        }                                           \
+    while (0)
+
+static void MD_cleanup(MediaDetImpl *This)
+{
+    RELEASE(This->source);
+    RELEASE(This->graph);
+}
+
 static ULONG WINAPI MediaDet_AddRef(IMediaDet* iface)
 {
     MediaDetImpl *This = (MediaDetImpl *)iface;
@@ -43,6 +60,7 @@ static ULONG WINAPI MediaDet_Release(IMediaDet* iface)
 
     if (refCount == 0)
     {
+        MD_cleanup(This);
         CoTaskMemFree(This);
         return 0;
     }
@@ -132,9 +150,35 @@ static HRESULT WINAPI MediaDet_get_Filename(IMediaDet* iface, BSTR *pVal)
 
 static HRESULT WINAPI MediaDet_put_Filename(IMediaDet* iface, BSTR newVal)
 {
+    static const WCHAR reader[] = {'R','e','a','d','e','r',0};
     MediaDetImpl *This = (MediaDetImpl *)iface;
-    FIXME("(%p)->(%p): not implemented!\n", This, newVal);
-    return E_NOTIMPL;
+    IGraphBuilder *gb;
+    IBaseFilter *bf;
+    HRESULT hr;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(newVal));
+
+    if (This->graph)
+    {
+        WARN("MSDN says not to call this method twice\n");
+        MD_cleanup(This);
+    }
+
+    hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
+                          &IID_IGraphBuilder, (void **) &gb);
+    if (FAILED(hr))
+        return hr;
+
+    hr = IGraphBuilder_AddSourceFilter(gb, newVal, reader, &bf);
+    if (FAILED(hr))
+    {
+        IGraphBuilder_Release(gb);
+        return hr;
+    }
+
+    This->graph = gb;
+    This->source = bf;
+    return S_OK;
 }
 
 static HRESULT WINAPI MediaDet_GetBitmapBits(IMediaDet* iface,
@@ -228,6 +272,8 @@ HRESULT MediaDet_create(IUnknown * pUnkOuter, LPVOID * ppv) {
 
     obj->refCount = 1;
     obj->MediaDet_Vtbl = &IMediaDet_VTable;
+    obj->graph = NULL;
+    obj->source = NULL;
     *ppv = obj;
 
     return S_OK;
diff --git a/dlls/qedit/tests/mediadet.c b/dlls/qedit/tests/mediadet.c
index 0870fd0..a12fcdc 100644
--- a/dlls/qedit/tests/mediadet.c
+++ b/dlls/qedit/tests/mediadet.c
@@ -95,7 +95,7 @@ static void test_mediadet(void)
 
     filename = SysAllocString(test_avi_filename);
     hr = IMediaDet_put_Filename(pM, filename);
-    todo_wine ok(hr == S_OK, "IMediaDet_put_Filename -> %x\n", hr);
+    ok(hr == S_OK, "IMediaDet_put_Filename -> %x\n", hr);
     SysFreeString(filename);
 
     hr = IMediaDet_get_OutputStreams(pM, &nstrms);



More information about the wine-patches mailing list