[PATCH 2/2] quartz: implement IBaseFilter_FindPin

Anton Khirnov wyskas at gmail.com
Sat Aug 21 09:34:11 CDT 2010


---
 dlls/quartz/Makefile.in                |    1 +
 dlls/quartz/avisplit.c                 |    2 +-
 dlls/quartz/basefilter.c               |   62 ++++++++++++++++++++++++++++++++
 dlls/quartz/dsoundrender.c             |   15 +-------
 dlls/quartz/filesource.c               |    8 +----
 dlls/quartz/mpegsplit.c                |    2 +-
 dlls/quartz/nullrenderer.c             |   21 +----------
 dlls/quartz/parser.c                   |    9 -----
 dlls/quartz/parser.h                   |    1 -
 dlls/quartz/quartz_private.h           |    1 +
 dlls/quartz/tests/quartz_test_common.c |   14 +++++++
 dlls/quartz/transform.c                |   11 +-----
 dlls/quartz/videorenderer.c            |   13 +------
 dlls/quartz/waveparser.c               |    2 +-
 14 files changed, 86 insertions(+), 76 deletions(-)
 create mode 100644 dlls/quartz/basefilter.c

diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in
index 6f86b94..9c4874b 100644
--- a/dlls/quartz/Makefile.in
+++ b/dlls/quartz/Makefile.in
@@ -11,6 +11,7 @@ C_SRCS = \
 	acmwrapper.c \
 	avidec.c \
 	avisplit.c \
+	basefilter.c \
 	control.c \
 	dsoundrender.c \
 	enumfilters.c \
diff --git a/dlls/quartz/avisplit.c b/dlls/quartz/avisplit.c
index 5b0c7e0..775a2e9 100644
--- a/dlls/quartz/avisplit.c
+++ b/dlls/quartz/avisplit.c
@@ -1399,7 +1399,7 @@ static const IBaseFilterVtbl AVISplitterImpl_Vtbl =
     Parser_SetSyncSource,
     Parser_GetSyncSource,
     Parser_EnumPins,
-    Parser_FindPin,
+    IBaseFilter_FindPinImpl,
     Parser_QueryFilterInfo,
     Parser_JoinFilterGraph,
     Parser_QueryVendorInfo
diff --git a/dlls/quartz/basefilter.c b/dlls/quartz/basefilter.c
new file mode 100644
index 0000000..fa3e008
--- /dev/null
+++ b/dlls/quartz/basefilter.c
@@ -0,0 +1,62 @@
+/*
+ * IBaseFilter methods
+ *
+ * Copyright 2010 Anton Khirnov
+ *
+ * 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 "quartz_private.h"
+
+#include "winreg.h"
+#include "shlwapi.h"
+
+HRESULT WINAPI IBaseFilter_FindPinImpl(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
+{
+    IEnumPins *enumpins;
+    HRESULT hr;
+
+    if (!ppPin || !Id)
+        return E_POINTER;
+
+    hr = IBaseFilter_EnumPins(iface, &enumpins);
+    if (FAILED(hr))
+        return VFW_E_NOT_FOUND;
+
+    while (hr == S_OK) {
+        IPin      *pin;
+        LPWSTR pinname;
+
+        hr = IEnumPins_Next(enumpins, 1, &pin, NULL);
+        if (FAILED(hr))
+            break;
+
+        hr = IPin_QueryId(pin, &pinname);
+        if (SUCCEEDED(hr)) {
+            if (!strcmpW(pinname, Id)) {
+                *ppPin = pin;
+                IPin_AddRef(*ppPin);
+                CoTaskMemFree(pinname);
+                break;
+            }
+            CoTaskMemFree(pinname);
+        }
+    }
+
+    IEnumPins_Release(enumpins);
+    if (SUCCEEDED(hr))
+        return S_OK;
+    return VFW_E_NOT_FOUND;
+}
diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c
index 8631cd5..a00a61f 100644
--- a/dlls/quartz/dsoundrender.c
+++ b/dlls/quartz/dsoundrender.c
@@ -755,19 +755,6 @@ static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppE
     return IEnumPinsImpl_Construct(ppEnum, DSoundRender_GetPin, iface);
 }
 
-static HRESULT WINAPI DSoundRender_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
-{
-    DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
-
-    TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
-    
-    FIXME("DSoundRender::FindPin(...)\n");
-
-    /* FIXME: critical section */
-
-    return E_NOTIMPL;
-}
-
 static HRESULT WINAPI DSoundRender_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
 {
     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
@@ -822,7 +809,7 @@ static const IBaseFilterVtbl DSoundRender_Vtbl =
     DSoundRender_SetSyncSource,
     DSoundRender_GetSyncSource,
     DSoundRender_EnumPins,
-    DSoundRender_FindPin,
+    IBaseFilter_FindPinImpl,
     DSoundRender_QueryFilterInfo,
     DSoundRender_JoinFilterGraph,
     DSoundRender_QueryVendorInfo
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c
index 110415d..5db9135 100644
--- a/dlls/quartz/filesource.c
+++ b/dlls/quartz/filesource.c
@@ -546,12 +546,6 @@ static HRESULT WINAPI AsyncReader_EnumPins(IBaseFilter * iface, IEnumPins **ppEn
     return IEnumPinsImpl_Construct(ppEnum, AsyncReader_GetPin, iface);
 }
 
-static HRESULT WINAPI AsyncReader_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
-{
-    FIXME("(%s, %p)\n", debugstr_w(Id), ppPin);
-
-    return E_NOTIMPL;
-}
 
 static HRESULT WINAPI AsyncReader_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
 {
@@ -603,7 +597,7 @@ static const IBaseFilterVtbl AsyncReader_Vtbl =
     AsyncReader_SetSyncSource,
     AsyncReader_GetSyncSource,
     AsyncReader_EnumPins,
-    AsyncReader_FindPin,
+    IBaseFilter_FindPinImpl,
     AsyncReader_QueryFilterInfo,
     AsyncReader_JoinFilterGraph,
     AsyncReader_QueryVendorInfo
diff --git a/dlls/quartz/mpegsplit.c b/dlls/quartz/mpegsplit.c
index 7eb2d2c..4613dd3 100644
--- a/dlls/quartz/mpegsplit.c
+++ b/dlls/quartz/mpegsplit.c
@@ -764,7 +764,7 @@ static const IBaseFilterVtbl MPEGSplitter_Vtbl =
     Parser_SetSyncSource,
     Parser_GetSyncSource,
     Parser_EnumPins,
-    Parser_FindPin,
+    IBaseFilter_FindPinImpl,
     Parser_QueryFilterInfo,
     Parser_JoinFilterGraph,
     Parser_QueryVendorInfo
diff --git a/dlls/quartz/nullrenderer.c b/dlls/quartz/nullrenderer.c
index d2aedfa..9468b2f 100644
--- a/dlls/quartz/nullrenderer.c
+++ b/dlls/quartz/nullrenderer.c
@@ -467,25 +467,6 @@ static HRESULT WINAPI NullRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppE
     return IEnumPinsImpl_Construct(ppEnum, NullRenderer_GetPin, iface);
 }
 
-static HRESULT WINAPI NullRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
-{
-    NullRendererImpl *This = (NullRendererImpl *)iface;
-
-    TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
-
-    if (!Id || !ppPin)
-        return E_POINTER;
-
-    if (!lstrcmpiW(Id,wcsInputPinName) || !lstrcmpiW(Id,wcsAltInputPinName))
-    {
-        *ppPin = (IPin *)This->pInputPin;
-        IPin_AddRef(*ppPin);
-        return S_OK;
-    }
-    *ppPin = NULL;
-    return VFW_E_NOT_FOUND;
-}
-
 static HRESULT WINAPI NullRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
 {
     NullRendererImpl *This = (NullRendererImpl *)iface;
@@ -540,7 +521,7 @@ static const IBaseFilterVtbl NullRenderer_Vtbl =
     NullRenderer_SetSyncSource,
     NullRenderer_GetSyncSource,
     NullRenderer_EnumPins,
-    NullRenderer_FindPin,
+    IBaseFilter_FindPinImpl,
     NullRenderer_QueryFilterInfo,
     NullRenderer_JoinFilterGraph,
     NullRenderer_QueryVendorInfo
diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c
index da5e9d3..3fcbd33 100644
--- a/dlls/quartz/parser.c
+++ b/dlls/quartz/parser.c
@@ -426,15 +426,6 @@ HRESULT WINAPI Parser_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
     return IEnumPinsImpl_Construct(ppEnum, Parser_GetPin, iface);
 }
 
-HRESULT WINAPI Parser_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
-{
-    FIXME("(%p)->(%s,%p)\n", iface, debugstr_w(Id), ppPin);
-
-    /* FIXME: critical section */
-
-    return E_NOTIMPL;
-}
-
 HRESULT WINAPI Parser_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
 {
     ParserImpl *This = (ParserImpl *)iface;
diff --git a/dlls/quartz/parser.h b/dlls/quartz/parser.h
index b542388..fc50753 100644
--- a/dlls/quartz/parser.h
+++ b/dlls/quartz/parser.h
@@ -74,7 +74,6 @@ extern HRESULT WINAPI Parser_GetState(IBaseFilter * iface, DWORD dwMilliSecsTime
 extern HRESULT WINAPI Parser_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock);
 extern HRESULT WINAPI Parser_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock);
 extern HRESULT WINAPI Parser_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum);
-extern HRESULT WINAPI Parser_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin);
 extern HRESULT WINAPI Parser_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo);
 extern HRESULT WINAPI Parser_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName);
 extern HRESULT WINAPI Parser_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo);
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h
index 3e0dfe1..b9da875 100644
--- a/dlls/quartz/quartz_private.h
+++ b/dlls/quartz/quartz_private.h
@@ -96,4 +96,5 @@ typedef struct StdMediaSample2
     LONGLONG tMediaEnd;
 } StdMediaSample2;
 
+HRESULT WINAPI IBaseFilter_FindPinImpl(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin);
 #endif /* __QUARTZ_PRIVATE_INCLUDED__ */
diff --git a/dlls/quartz/tests/quartz_test_common.c b/dlls/quartz/tests/quartz_test_common.c
index e6e2b25..f448137 100644
--- a/dlls/quartz/tests/quartz_test_common.c
+++ b/dlls/quartz/tests/quartz_test_common.c
@@ -76,7 +76,18 @@ void test_basefilter(IUnknown *basefilter)
         "pins[0] = %p\n", pins[0]);
     if (pins[0] != (void *)0xdead && pins[0] != NULL)
     {
+        LPWSTR Id;
+        IPin *pin;
+
         test_pin(pins[0]);
+
+        hr = IPin_QueryId(pins[0], &Id);
+        ok(hr == S_OK, "Could not retrieve pin Id, hr = %08x and not S_OK\n", hr);
+        hr = IBaseFilter_FindPin(base, Id, &pin);
+        ok(hr == S_OK, "Could not find pin, hr = %08x and not S_OK\n", hr);
+        IPin_Release(pin);
+        CoTaskMemFree(Id);
+
         IPin_Release(pins[0]);
     }
 
@@ -85,6 +96,9 @@ void test_basefilter(IUnknown *basefilter)
     ref = IEnumPins_Release(pin_enum);
     ok(ref == 0, "ref is %u and not 0!\n", ref);
 
+    hr = IBaseFilter_FindPin(base, NULL, NULL);
+    ok(hr == E_POINTER, "IBaseFilter_FindPin returned %08x instead of E_POINTER", hr);
+
     IBaseFilter_Release(base);
 }
 
diff --git a/dlls/quartz/transform.c b/dlls/quartz/transform.c
index adb753d..4555f8b 100644
--- a/dlls/quartz/transform.c
+++ b/dlls/quartz/transform.c
@@ -462,15 +462,6 @@ static HRESULT WINAPI TransformFilter_EnumPins(IBaseFilter * iface, IEnumPins **
     return IEnumPinsImpl_Construct(ppEnum, TransformFilter_GetPin, iface);
 }
 
-static HRESULT WINAPI TransformFilter_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
-{
-    TransformFilterImpl *This = (TransformFilterImpl *)iface;
-
-    TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
-
-    return E_NOTIMPL;
-}
-
 static HRESULT WINAPI TransformFilter_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
 {
     TransformFilterImpl *This = (TransformFilterImpl *)iface;
@@ -526,7 +517,7 @@ static const IBaseFilterVtbl TransformFilter_Vtbl =
     TransformFilter_SetSyncSource,
     TransformFilter_GetSyncSource,
     TransformFilter_EnumPins,
-    TransformFilter_FindPin,
+    IBaseFilter_FindPinImpl,
     TransformFilter_QueryFilterInfo,
     TransformFilter_JoinFilterGraph,
     TransformFilter_QueryVendorInfo
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c
index 0af8cc6..da932bd 100644
--- a/dlls/quartz/videorenderer.c
+++ b/dlls/quartz/videorenderer.c
@@ -960,17 +960,6 @@ static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **pp
     return IEnumPinsImpl_Construct(ppEnum, VideoRenderer_GetPin, iface);
 }
 
-static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
-{
-    VideoRendererImpl *This = (VideoRendererImpl *)iface;
-
-    FIXME("(%p/%p)->(%p,%p): stub !!!\n", This, iface, debugstr_w(Id), ppPin);
-
-    /* FIXME: critical section */
-
-    return E_NOTIMPL;
-}
-
 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
 {
     VideoRendererImpl *This = (VideoRendererImpl *)iface;
@@ -1025,7 +1014,7 @@ static const IBaseFilterVtbl VideoRenderer_Vtbl =
     VideoRenderer_SetSyncSource,
     VideoRenderer_GetSyncSource,
     VideoRenderer_EnumPins,
-    VideoRenderer_FindPin,
+    IBaseFilter_FindPinImpl,
     VideoRenderer_QueryFilterInfo,
     VideoRenderer_JoinFilterGraph,
     VideoRenderer_QueryVendorInfo
diff --git a/dlls/quartz/waveparser.c b/dlls/quartz/waveparser.c
index cbdfceb..7b212de 100644
--- a/dlls/quartz/waveparser.c
+++ b/dlls/quartz/waveparser.c
@@ -405,7 +405,7 @@ static const IBaseFilterVtbl WAVEParser_Vtbl =
     Parser_SetSyncSource,
     Parser_GetSyncSource,
     Parser_EnumPins,
-    Parser_FindPin,
+    IBaseFilter_FindPinImpl,
     Parser_QueryFilterInfo,
     Parser_JoinFilterGraph,
     Parser_QueryVendorInfo
-- 
1.7.1




More information about the wine-patches mailing list