Commit b33f0583 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

strmbase: Introduce a helper to more thoroughly trace media type.

parent a9b87a82
...@@ -18,16 +18,108 @@ ...@@ -18,16 +18,108 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <stdarg.h>
#define COBJMACROS #include "strmbase_private.h"
#include "dshow.h"
#include "wine/strmbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(strmbase); 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) HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *dest, const AM_MEDIA_TYPE *src)
{ {
*dest = *src; *dest = *src;
...@@ -176,6 +268,12 @@ static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes *iface, ...@@ -176,6 +268,12 @@ static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes *iface,
*ret_count = 0; *ret_count = 0;
return E_OUTOFMEMORY; 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) if ((count != 1) || ret_count)
......
...@@ -135,19 +135,8 @@ out: ...@@ -135,19 +135,8 @@ out:
return hr; 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) 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)) && 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))); ((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 ...@@ -257,6 +246,7 @@ HRESULT WINAPI BasePinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt
if (This->peer) if (This->peer)
{ {
CopyMediaType(pmt, &This->mtCurrent); CopyMediaType(pmt, &This->mtCurrent);
strmbase_dump_media_type(pmt);
hr = S_OK; hr = S_OK;
} }
else else
...@@ -313,6 +303,7 @@ HRESULT WINAPI BasePinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt) ...@@ -313,6 +303,7 @@ HRESULT WINAPI BasePinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt)
struct strmbase_pin *This = impl_from_IPin(iface); struct strmbase_pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", iface, pmt); 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); 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 ...@@ -369,7 +360,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const
struct strmbase_source *This = impl_source_from_IPin(iface); struct strmbase_source *This = impl_source_from_IPin(iface);
TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt); TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt);
dump_AM_MEDIA_TYPE(pmt); strmbase_dump_media_type(pmt);
if (!pReceivePin) if (!pReceivePin)
return E_POINTER; return E_POINTER;
...@@ -400,7 +391,6 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const ...@@ -400,7 +391,6 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const
while (S_OK == IEnumMediaTypes_Next(pEnumCandidates, 1, &pmtCandidate, NULL)) while (S_OK == IEnumMediaTypes_Next(pEnumCandidates, 1, &pmtCandidate, NULL))
{ {
assert(pmtCandidate); assert(pmtCandidate);
dump_AM_MEDIA_TYPE(pmtCandidate);
if (!IsEqualGUID(&FORMAT_None, &pmtCandidate->formattype) if (!IsEqualGUID(&FORMAT_None, &pmtCandidate->formattype)
&& !IsEqualGUID(&GUID_NULL, &pmtCandidate->formattype)) && !IsEqualGUID(&GUID_NULL, &pmtCandidate->formattype))
assert(pmtCandidate->pbFormat); assert(pmtCandidate->pbFormat);
...@@ -427,7 +417,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const ...@@ -427,7 +417,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const
while (S_OK == IEnumMediaTypes_Next(pEnumCandidates, 1, &pmtCandidate, &fetched)) while (S_OK == IEnumMediaTypes_Next(pEnumCandidates, 1, &pmtCandidate, &fetched))
{ {
assert(pmtCandidate); assert(pmtCandidate);
dump_AM_MEDIA_TYPE(pmtCandidate); strmbase_dump_media_type(pmtCandidate);
if ((!pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE)) if ((!pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE))
&& This->pFuncsTable->pfnAttemptConnection(This, pReceivePin, pmtCandidate) == S_OK) && This->pFuncsTable->pfnAttemptConnection(This, pReceivePin, pmtCandidate) == S_OK)
{ {
...@@ -653,7 +643,6 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *This, ...@@ -653,7 +643,6 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *This,
IMemAllocator * pMemAlloc = NULL; IMemAllocator * pMemAlloc = NULL;
TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt); 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) if ((hr = This->pFuncsTable->base.pin_query_accept(&This->pin, pmt)) != S_OK)
return hr; return hr;
...@@ -744,7 +733,7 @@ HRESULT WINAPI BaseInputPinImpl_ReceiveConnection(IPin * iface, IPin * pReceiveP ...@@ -744,7 +733,7 @@ HRESULT WINAPI BaseInputPinImpl_ReceiveConnection(IPin * iface, IPin * pReceiveP
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt); TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt);
dump_AM_MEDIA_TYPE(pmt); strmbase_dump_media_type(pmt);
EnterCriticalSection(&This->pin.filter->csFilter); EnterCriticalSection(&This->pin.filter->csFilter);
{ {
......
...@@ -51,6 +51,7 @@ static HRESULT WINAPI BaseRenderer_InputPin_ReceiveConnection(IPin *iface, IPin ...@@ -51,6 +51,7 @@ static HRESULT WINAPI BaseRenderer_InputPin_ReceiveConnection(IPin *iface, IPin
HRESULT hr; HRESULT hr;
TRACE("iface %p, peer %p, mt %p.\n", iface, peer, mt); TRACE("iface %p, peer %p, mt %p.\n", iface, peer, mt);
strmbase_dump_media_type(mt);
EnterCriticalSection(&filter->filter.csFilter); EnterCriticalSection(&filter->filter.csFilter);
hr = BaseInputPinImpl_ReceiveConnection(iface, peer, mt); hr = BaseInputPinImpl_ReceiveConnection(iface, peer, mt);
...@@ -322,6 +323,9 @@ HRESULT WINAPI BaseRendererImpl_Receive(BaseRenderer *This, IMediaSample * pSamp ...@@ -322,6 +323,9 @@ HRESULT WINAPI BaseRendererImpl_Receive(BaseRenderer *This, IMediaSample * pSamp
if (IMediaSample_GetMediaType(pSample, &pmt) == S_OK) if (IMediaSample_GetMediaType(pSample, &pmt) == S_OK)
{ {
TRACE("Format change.\n");
strmbase_dump_media_type(pmt);
if (FAILED(This->pFuncsTable->pfnCheckMediaType(This, pmt))) if (FAILED(This->pFuncsTable->pfnCheckMediaType(This, pmt)))
{ {
return VFW_E_TYPE_NOT_ACCEPTED; return VFW_E_TYPE_NOT_ACCEPTED;
......
...@@ -387,6 +387,7 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I ...@@ -387,6 +387,7 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt); TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt);
strmbase_dump_media_type(pmt);
if (pTransform->pFuncsTable->pfnSetMediaType) if (pTransform->pFuncsTable->pfnSetMediaType)
hr = pTransform->pFuncsTable->pfnSetMediaType(pTransform, PINDIR_INPUT, pmt); hr = pTransform->pFuncsTable->pfnSetMediaType(pTransform, PINDIR_INPUT, pmt);
......
...@@ -26,6 +26,8 @@ void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType); ...@@ -26,6 +26,8 @@ void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType);
AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc); AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc);
void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType); void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType);
void strmbase_dump_media_type(const AM_MEDIA_TYPE *mt);
/* Pin functions */ /* Pin functions */
struct strmbase_pin struct strmbase_pin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment