Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/strmbase/mediatype.c | 110 +++++++++++++++++++++++++++++++++++--- dlls/strmbase/pin.c | 21 ++------ dlls/strmbase/renderer.c | 4 ++ dlls/strmbase/transform.c | 1 + include/wine/strmbase.h | 2 + 5 files changed, 116 insertions(+), 22 deletions(-)
diff --git a/dlls/strmbase/mediatype.c b/dlls/strmbase/mediatype.c index 931e00a5cba..7ab8b6e7083 100644 --- a/dlls/strmbase/mediatype.c +++ b/dlls/strmbase/mediatype.c @@ -18,16 +18,108 @@ * 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>
-#define COBJMACROS -#include "dshow.h" - -#include "wine/strmbase.h" -#include "wine/debug.h" +#include "strmbase_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
+static const struct +{ + const GUID *guid; + const char *name; +} +strmbase_guids[] = +{ +#define X(g) {&(g), #g} + X(GUID_NULL), + +#undef OUR_GUID_ENTRY +#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) X(name), +#include "uuids.h" + +#undef X +}; + +static const char *strmbase_debugstr_guid(const GUID *guid) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(strmbase_guids); ++i) + { + if (IsEqualGUID(strmbase_guids[i].guid, guid)) + return wine_dbg_sprintf("%s", strmbase_guids[i].name); + } + + return debugstr_guid(guid); +} + +static const char *debugstr_fourcc(DWORD fourcc) +{ + char str[4] = {fourcc, fourcc >> 8, fourcc >> 16, fourcc >> 24}; + if (isprint(str[0]) && isprint(str[1]) && isprint(str[2]) && isprint(str[3])) + return wine_dbgstr_an(str, 4); + return wine_dbg_sprintf("%#x", fourcc); +} + +void strmbase_dump_media_type(const AM_MEDIA_TYPE *mt) +{ + if (!TRACE_ON(strmbase) || !mt) return; + + TRACE("Dumping media type %p: major type %s, subtype %s", + mt, strmbase_debugstr_guid(&mt->majortype), strmbase_debugstr_guid(&mt->subtype)); + if (mt->bFixedSizeSamples) TRACE(", fixed size samples"); + if (mt->bTemporalCompression) TRACE(", temporal compression"); + if (mt->lSampleSize) TRACE(", sample size %d", mt->lSampleSize); + if (mt->pUnk) TRACE(", pUnk %p", mt->pUnk); + TRACE(", format type %s.\n", strmbase_debugstr_guid(&mt->formattype)); + + if (!mt->pbFormat) return; + + TRACE("Dumping format %p: ", mt->pbFormat); + + if (IsEqualGUID(&mt->formattype, &FORMAT_WaveFormatEx) && mt->cbFormat >= sizeof(WAVEFORMATEX)) + { + WAVEFORMATEX *wfx = (WAVEFORMATEX *)mt->pbFormat; + + TRACE("tag %#x, %u channels, sample rate %u, %u bytes/sec, alignment %u, %u bits/sample.\n", + wfx->wFormatTag, wfx->nChannels, wfx->nSamplesPerSec, + wfx->nAvgBytesPerSec, wfx->nBlockAlign, wfx->wBitsPerSample); + + if (wfx->cbSize) + { + const unsigned char *extra = (const unsigned char *)(wfx + 1); + unsigned int i; + + TRACE(" Extra bytes:"); + for (i = 0; i < wfx->cbSize; ++i) + { + if (!(i % 16)) TRACE("\n "); + TRACE(" %02x", extra[i]); + } + TRACE("\n"); + } + } + else if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) && mt->cbFormat >= sizeof(VIDEOINFOHEADER)) + { + VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)mt->pbFormat; + + TRACE("source %s, target %s, bitrate %u, error rate %u, %s sec/frame, ", + wine_dbgstr_rect(&vih->rcSource), wine_dbgstr_rect(&vih->rcTarget), + vih->dwBitRate, vih->dwBitErrorRate, debugstr_time(vih->AvgTimePerFrame)); + TRACE("size %dx%d, %u planes, %u bpp, compression %s, image size %u", + vih->bmiHeader.biWidth, vih->bmiHeader.biHeight, vih->bmiHeader.biPlanes, + vih->bmiHeader.biBitCount, debugstr_fourcc(vih->bmiHeader.biCompression), + vih->bmiHeader.biSizeImage); + if (vih->bmiHeader.biXPelsPerMeter || vih->bmiHeader.biYPelsPerMeter) + TRACE(", resolution %dx%d", vih->bmiHeader.biXPelsPerMeter, vih->bmiHeader.biYPelsPerMeter); + if (vih->bmiHeader.biClrUsed) TRACE(", %d colours", vih->bmiHeader.biClrUsed); + if (vih->bmiHeader.biClrImportant) TRACE(", %d important colours", vih->bmiHeader.biClrImportant); + TRACE(".\n"); + } + else + TRACE("not implemented for this format type.\n"); +} + HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *dest, const AM_MEDIA_TYPE *src) { *dest = *src; @@ -176,6 +268,12 @@ static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes *iface, *ret_count = 0; return E_OUTOFMEMORY; } + + if (TRACE_ON(strmbase)) + { + TRACE("Returning media type %u:\n", enummt->uIndex + i); + strmbase_dump_media_type(mts[i]); + } }
if ((count != 1) || ret_count) diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c index 42b150be673..2d981684184 100644 --- a/dlls/strmbase/pin.c +++ b/dlls/strmbase/pin.c @@ -135,19 +135,8 @@ out: return hr; }
-static void dump_AM_MEDIA_TYPE(const AM_MEDIA_TYPE * pmt) -{ - if (!pmt) - return; - TRACE("\t%s\n\t%s\n\t...\n\t%s\n", debugstr_guid(&pmt->majortype), debugstr_guid(&pmt->subtype), debugstr_guid(&pmt->formattype)); -} - static BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, BOOL bWildcards) { - TRACE("pmt1: "); - dump_AM_MEDIA_TYPE(pmt1); - TRACE("pmt2: "); - dump_AM_MEDIA_TYPE(pmt2); return (((bWildcards && (IsEqualGUID(&pmt1->majortype, &GUID_NULL) || IsEqualGUID(&pmt2->majortype, &GUID_NULL))) || IsEqualGUID(&pmt1->majortype, &pmt2->majortype)) && ((bWildcards && (IsEqualGUID(&pmt1->subtype, &GUID_NULL) || IsEqualGUID(&pmt2->subtype, &GUID_NULL))) || IsEqualGUID(&pmt1->subtype, &pmt2->subtype))); } @@ -257,6 +246,7 @@ HRESULT WINAPI BasePinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt if (This->peer) { CopyMediaType(pmt, &This->mtCurrent); + strmbase_dump_media_type(pmt); hr = S_OK; } else @@ -313,6 +303,7 @@ HRESULT WINAPI BasePinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt) struct strmbase_pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", iface, pmt); + strmbase_dump_media_type(pmt);
return (This->pFuncsTable->pin_query_accept(This, pmt) == S_OK ? S_OK : S_FALSE); } @@ -369,7 +360,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const struct strmbase_source *This = impl_source_from_IPin(iface);
TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt); - dump_AM_MEDIA_TYPE(pmt); + strmbase_dump_media_type(pmt);
if (!pReceivePin) return E_POINTER; @@ -400,7 +391,6 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const while (S_OK == IEnumMediaTypes_Next(pEnumCandidates, 1, &pmtCandidate, NULL)) { assert(pmtCandidate); - dump_AM_MEDIA_TYPE(pmtCandidate); if (!IsEqualGUID(&FORMAT_None, &pmtCandidate->formattype) && !IsEqualGUID(&GUID_NULL, &pmtCandidate->formattype)) assert(pmtCandidate->pbFormat); @@ -427,7 +417,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const while (S_OK == IEnumMediaTypes_Next(pEnumCandidates, 1, &pmtCandidate, &fetched)) { assert(pmtCandidate); - dump_AM_MEDIA_TYPE(pmtCandidate); + strmbase_dump_media_type(pmtCandidate); if ((!pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE)) && This->pFuncsTable->pfnAttemptConnection(This, pReceivePin, pmtCandidate) == S_OK) { @@ -653,7 +643,6 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *This, IMemAllocator * pMemAlloc = NULL;
TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt); - dump_AM_MEDIA_TYPE(pmt);
if ((hr = This->pFuncsTable->base.pin_query_accept(&This->pin, pmt)) != S_OK) return hr; @@ -744,7 +733,7 @@ HRESULT WINAPI BaseInputPinImpl_ReceiveConnection(IPin * iface, IPin * pReceiveP HRESULT hr = S_OK;
TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt); - dump_AM_MEDIA_TYPE(pmt); + strmbase_dump_media_type(pmt);
EnterCriticalSection(&This->pin.filter->csFilter); { diff --git a/dlls/strmbase/renderer.c b/dlls/strmbase/renderer.c index 270a6f260f1..3a5fa19ace6 100644 --- a/dlls/strmbase/renderer.c +++ b/dlls/strmbase/renderer.c @@ -51,6 +51,7 @@ static HRESULT WINAPI BaseRenderer_InputPin_ReceiveConnection(IPin *iface, IPin HRESULT hr;
TRACE("iface %p, peer %p, mt %p.\n", iface, peer, mt); + strmbase_dump_media_type(mt);
EnterCriticalSection(&filter->filter.csFilter); hr = BaseInputPinImpl_ReceiveConnection(iface, peer, mt); @@ -322,6 +323,9 @@ HRESULT WINAPI BaseRendererImpl_Receive(BaseRenderer *This, IMediaSample * pSamp
if (IMediaSample_GetMediaType(pSample, &pmt) == S_OK) { + TRACE("Format change.\n"); + strmbase_dump_media_type(pmt); + if (FAILED(This->pFuncsTable->pfnCheckMediaType(This, pmt))) { return VFW_E_TYPE_NOT_ACCEPTED; diff --git a/dlls/strmbase/transform.c b/dlls/strmbase/transform.c index bd70b8a90c6..3fd9d8bd6f3 100644 --- a/dlls/strmbase/transform.c +++ b/dlls/strmbase/transform.c @@ -387,6 +387,7 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I HRESULT hr = S_OK;
TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt); + strmbase_dump_media_type(pmt);
if (pTransform->pFuncsTable->pfnSetMediaType) hr = pTransform->pFuncsTable->pfnSetMediaType(pTransform, PINDIR_INPUT, pmt); diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index 99d680a365b..de5c875105a 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -26,6 +26,8 @@ void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType); AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc); void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType);
+void strmbase_dump_media_type(const AM_MEDIA_TYPE *mt); + /* Pin functions */
struct strmbase_pin