[PATCH v3 01/13] qedit: Implement MediaDet_get_StreamType.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri Apr 17 11:09:01 CDT 2020


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

v3: So since there were quite a few changes to the patch series, I haven't
applied all of them yet, since I wasn't sure; but at least we should be
able to get the first few patches out of the way now.

I did add a test to show the downstream source is still used with
put_Filter. In fact, I even test the filter first to show it has only one
pin with MEDIATYPE_Stream, but the detector reports 2 pins (because of
the splitter).

But here's the things I did not do. Perhaps they may not be needed
now. However, if you think they are still needed to be changed, please let
me know again and I'll change them.

I didn't use strmbase on the tests.
I didn't split the tests into a separate function. This is needed for
proper testing.
I kept the QueryFilterInfo for the custom filter since I was uncomfortable
otherwise.

Maybe they make more sense now that the tests are split.

Unless I missed something, all the other things should have been changed
as suggested.

I also dropped IMediaPosition so it matches Windows more. It can always be
added as a separate patch later, if needed.

 dlls/qedit/mediadet.c       | 18 ++++++++++++++++--
 dlls/qedit/tests/mediadet.c | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/dlls/qedit/mediadet.c b/dlls/qedit/mediadet.c
index ecfafc4..94bc1be 100644
--- a/dlls/qedit/mediadet.c
+++ b/dlls/qedit/mediadet.c
@@ -28,6 +28,7 @@
 #include "ole2.h"
 
 #include "qedit_private.h"
+#include "wine/strmbase.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(qedit);
@@ -283,8 +284,21 @@ static HRESULT WINAPI MediaDet_put_CurrentStream(IMediaDet* iface, LONG newVal)
 static HRESULT WINAPI MediaDet_get_StreamType(IMediaDet* iface, GUID *pVal)
 {
     MediaDetImpl *This = impl_from_IMediaDet(iface);
-    FIXME("(%p)->(%s): not implemented!\n", This, debugstr_guid(pVal));
-    return E_NOTIMPL;
+    AM_MEDIA_TYPE mt;
+    HRESULT hr;
+
+    TRACE("(%p)->(%p)\n", This, pVal);
+
+    if (!pVal)
+        return E_POINTER;
+
+    hr = IMediaDet_get_StreamMediaType(&This->IMediaDet_iface, &mt);
+    if (FAILED(hr))
+        return hr;
+    FreeMediaType(&mt);
+
+    *pVal = mt.majortype;
+    return hr;
 }
 
 static HRESULT WINAPI MediaDet_get_StreamTypeB(IMediaDet* iface, BSTR *pVal)
diff --git a/dlls/qedit/tests/mediadet.c b/dlls/qedit/tests/mediadet.c
index 65f5af7..c92c187 100644
--- a/dlls/qedit/tests/mediadet.c
+++ b/dlls/qedit/tests/mediadet.c
@@ -192,6 +192,7 @@ static void test_mediadet(void)
     BSTR filename = NULL;
     LONG nstrms = 0;
     LONG strm;
+    GUID guid;
     AM_MEDIA_TYPE mt;
     double fps;
     int flags;
@@ -242,6 +243,12 @@ static void test_mediadet(void)
     hr = IMediaDet_get_StreamMediaType(pM, NULL);
     ok(hr == E_POINTER, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
 
+    hr = IMediaDet_get_StreamType(pM, &guid);
+    ok(hr == E_INVALIDARG, "IMediaDet_get_StreamType failed: %08x\n", hr);
+
+    hr = IMediaDet_get_StreamType(pM, NULL);
+    ok(hr == E_POINTER, "IMediaDet_get_StreamType failed: %08x\n", hr);
+
     filename = SysAllocString(test_avi_filename);
     hr = IMediaDet_put_Filename(pM, filename);
     ok(hr == S_OK, "IMediaDet_put_Filename failed: %08x\n", hr);
@@ -258,6 +265,10 @@ static void test_mediadet(void)
     ok(hr == S_OK, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
     CoTaskMemFree(mt.pbFormat);
 
+    hr = IMediaDet_get_StreamType(pM, &guid);
+    ok(hr == S_OK, "IMediaDet_get_StreamType failed: %08x\n", hr);
+    ok(IsEqualGUID(&guid, &MEDIATYPE_Video), "Wrong GUID %s\n", wine_dbgstr_guid(&guid));
+
     /* Even before get_OutputStreams.  */
     hr = IMediaDet_put_CurrentStream(pM, 1);
     ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
@@ -311,6 +322,10 @@ static void test_mediadet(void)
                  "IMediaDet_get_StreamMediaType\n");
     CoTaskMemFree(mt.pbFormat);
 
+    hr = IMediaDet_get_StreamType(pM, &guid);
+    ok(hr == S_OK, "IMediaDet_get_StreamType failed: %08x\n", hr);
+    ok(IsEqualGUID(&guid, &MEDIATYPE_Video), "Wrong GUID %s\n", wine_dbgstr_guid(&guid));
+
     hr = IMediaDet_get_FrameRate(pM, NULL);
     ok(hr == E_POINTER, "IMediaDet_get_FrameRate failed: %08x\n", hr);
 
@@ -370,6 +385,10 @@ static void test_mediadet(void)
 
         if (IsEqualGUID(&mt.majortype, &MEDIATYPE_Audio))
         {
+            hr = IMediaDet_get_StreamType(pM, &guid);
+            ok(hr == S_OK, "IMediaDet_get_StreamType failed: %08x\n", hr);
+            ok(IsEqualGUID(&guid, &MEDIATYPE_Audio), "Wrong GUID %s\n", wine_dbgstr_guid(&guid));
+
             hr = IMediaDet_get_FrameRate(pM, &fps);
             ok(hr == VFW_E_INVALIDMEDIATYPE, "IMediaDet_get_FrameRate failed: %08x\n", hr);
         }
-- 
2.21.0




More information about the wine-devel mailing list