Commit 08be895a authored by Damien Fouilleul's avatar Damien Fouilleul

- added last resort built-in mediatype for capture filter if card does not...

- added last resort built-in mediatype for capture filter if card does not returns any (i.e Osprey cards)
- miscelaneous clean ups
parent e60b15c3
...@@ -471,7 +471,7 @@ static int AccessOpen( vlc_object_t *p_this ) ...@@ -471,7 +471,7 @@ static int AccessOpen( vlc_object_t *p_this )
if( SUCCEEDED(pXbar->Route(VideoOutputIndex, VideoInputIndex)) ) if( SUCCEEDED(pXbar->Route(VideoOutputIndex, VideoInputIndex)) )
{ {
msg_Dbg( p_access, "Crossbar at depth %d, Routed video " msg_Dbg( p_access, "Crossbar at depth %d, Routed video "
"ouput %d to video input %d", i, VideoOutputIndex, "ouput %ld to video input %ld", i, VideoOutputIndex,
VideoInputIndex ); VideoInputIndex );
if( AudioOutputIndex != -1 && AudioInputIndex != -1 ) if( AudioOutputIndex != -1 && AudioInputIndex != -1 )
...@@ -480,7 +480,7 @@ static int AccessOpen( vlc_object_t *p_this ) ...@@ -480,7 +480,7 @@ static int AccessOpen( vlc_object_t *p_this )
AudioInputIndex)) ) AudioInputIndex)) )
{ {
msg_Dbg(p_access, "Crossbar at depth %d, Routed audio " msg_Dbg(p_access, "Crossbar at depth %d, Routed audio "
"ouput %d to audio input %d", i, "ouput %ld to audio input %ld", i,
AudioOutputIndex, AudioInputIndex ); AudioOutputIndex, AudioInputIndex );
} }
} }
...@@ -745,7 +745,7 @@ static HRESULT FindCrossbarRoutes( access_t *p_access, IPin *p_input_pin, ...@@ -745,7 +745,7 @@ static HRESULT FindCrossbarRoutes( access_t *p_access, IPin *p_input_pin,
p_sys->crossbar_routes[depth].AudioOutputIndex = outputPinIndexRelated; p_sys->crossbar_routes[depth].AudioOutputIndex = outputPinIndexRelated;
msg_Dbg( p_access, "Crossbar at depth %d, Found Route For " msg_Dbg( p_access, "Crossbar at depth %d, Found Route For "
"ouput %ld (type %ld) to input %d (type %ld)", depth, "ouput %ld (type %ld) to input %ld (type %ld)", depth,
outputPinIndex, outputPinPhysicalType, inputPinIndex, outputPinIndex, outputPinPhysicalType, inputPinIndex,
inputPinPhysicalType ); inputPinPhysicalType );
...@@ -865,12 +865,13 @@ static int GetFourCCPriority(int i_fourcc) ...@@ -865,12 +865,13 @@ static int GetFourCCPriority(int i_fourcc)
switch( i_fourcc ) switch( i_fourcc )
{ {
case VLC_FOURCC('I','4','2','0'): case VLC_FOURCC('I','4','2','0'):
case VLC_FOURCC('a','r','a','w'): case VLC_FOURCC('f','l','3','2'):
{ {
return 9; return 9;
} }
case VLC_FOURCC('Y','V','1','2'): case VLC_FOURCC('Y','V','1','2'):
case VLC_FOURCC('a','r','a','w'):
{ {
return 8; return 8;
} }
...@@ -883,7 +884,6 @@ static int GetFourCCPriority(int i_fourcc) ...@@ -883,7 +884,6 @@ static int GetFourCCPriority(int i_fourcc)
case VLC_FOURCC('Y','U','Y','2'): case VLC_FOURCC('Y','U','Y','2'):
case VLC_FOURCC('R','V','3','2'): case VLC_FOURCC('R','V','3','2'):
case VLC_FOURCC('R','G','B','A'): case VLC_FOURCC('R','G','B','A'):
case VLC_FOURCC('f','l','3','2'):
{ {
return 6; return 6;
} }
...@@ -940,6 +940,7 @@ static int OpenDevice( access_t *p_access, string devicename, ...@@ -940,6 +940,7 @@ static int OpenDevice( access_t *p_access, string devicename,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
AM_MEDIA_TYPE *mt;
AM_MEDIA_TYPE media_types[MAX_MEDIA_TYPES]; AM_MEDIA_TYPE media_types[MAX_MEDIA_TYPES];
size_t mt_count = EnumDeviceCaps( (vlc_object_t *)p_access, size_t mt_count = EnumDeviceCaps( (vlc_object_t *)p_access,
...@@ -947,15 +948,9 @@ static int OpenDevice( access_t *p_access, string devicename, ...@@ -947,15 +948,9 @@ static int OpenDevice( access_t *p_access, string devicename,
p_sys->i_width, p_sys->i_height, p_sys->i_width, p_sys->i_height,
0, 0, 0, media_types, MAX_MEDIA_TYPES ); 0, 0, 0, media_types, MAX_MEDIA_TYPES );
if( 0 == mt_count ) if( mt_count > 0 )
{ {
msg_Err( p_access, "can't use device: %s, unsupported media types", mt = (AM_MEDIA_TYPE *)malloc( sizeof(AM_MEDIA_TYPE)*mt_count );
devicename.c_str() );
return VLC_EGENERIC;
}
AM_MEDIA_TYPE *mt =
(AM_MEDIA_TYPE *)malloc( sizeof(AM_MEDIA_TYPE)*mt_count );
// Order and copy returned media types according to arbitrary // Order and copy returned media types according to arbitrary
// fourcc priority // fourcc priority
...@@ -963,7 +958,7 @@ static int OpenDevice( access_t *p_access, string devicename, ...@@ -963,7 +958,7 @@ static int OpenDevice( access_t *p_access, string devicename,
{ {
int slot_priority = int slot_priority =
GetFourCCPriority(GetFourCCFromMediaType(media_types[c])); GetFourCCPriority(GetFourCCFromMediaType(media_types[c]));
int slot_copy = c; size_t slot_copy = c;
for( size_t d=c+1; d<mt_count; d++ ) for( size_t d=c+1; d<mt_count; d++ )
{ {
int priority = int priority =
...@@ -984,6 +979,71 @@ static int OpenDevice( access_t *p_access, string devicename, ...@@ -984,6 +979,71 @@ static int OpenDevice( access_t *p_access, string devicename,
mt[c] = media_types[c]; mt[c] = media_types[c];
} }
} }
}
else if( ! b_audio ) {
// Use default video media type
AM_MEDIA_TYPE mtr;
VIDEOINFOHEADER vh;
mtr.majortype = MEDIATYPE_Video;
mtr.subtype = MEDIASUBTYPE_I420;
mtr.bFixedSizeSamples = TRUE;
mtr.bTemporalCompression = FALSE;
mtr.lSampleSize = 0;
mtr.pUnk = NULL;
mtr.formattype = FORMAT_VideoInfo;
mtr.cbFormat = sizeof(vh);
mtr.pbFormat = (BYTE *)&vh;
memset(&vh, 0, sizeof(vh));
vh.bmiHeader.biSize = sizeof(vh.bmiHeader);
vh.bmiHeader.biWidth = p_sys->i_width > 0 ? p_sys->i_width: 320;
vh.bmiHeader.biHeight = p_sys->i_height > 0 ? p_sys->i_height : 240;
vh.bmiHeader.biPlanes = 1;
vh.bmiHeader.biBitCount = 24;
vh.bmiHeader.biCompression = VLC_FOURCC('I','4','2','0');
vh.bmiHeader.biSizeImage = p_sys->i_width * 24 * p_sys->i_height / 8;
msg_Warn( p_access, "device %s using built-in video media type",
devicename.c_str() );
mt_count = 1;
mt = (AM_MEDIA_TYPE *)malloc( sizeof(AM_MEDIA_TYPE)*mt_count );
CopyMediaType(mt, &mtr);
}
else {
// Use default audio media type
AM_MEDIA_TYPE mtr;
WAVEFORMATEX wf;
mtr.majortype = MEDIATYPE_Audio;
mtr.subtype = MEDIASUBTYPE_PCM;
mtr.bFixedSizeSamples = TRUE;
mtr.bTemporalCompression = FALSE;
mtr.lSampleSize = 0;
mtr.pUnk = NULL;
mtr.formattype = FORMAT_WaveFormatEx;
mtr.cbFormat = sizeof(wf);
mtr.pbFormat = (BYTE *)&wf;
memset(&wf, 0, sizeof(wf));
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 2;
wf.nSamplesPerSec = 44100;
wf.wBitsPerSample = 16;
wf.nBlockAlign = wf.nSamplesPerSec * wf.wBitsPerSample / 8;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
wf.cbSize = 0;
msg_Warn( p_access, "device %s using built-in audio media type",
devicename.c_str() );
mt_count = 1;
mt = (AM_MEDIA_TYPE *)malloc( sizeof(AM_MEDIA_TYPE)*mt_count );
CopyMediaType(mt, &mtr);
}
/* Create and add our capture filter */ /* Create and add our capture filter */
CaptureFilter *p_capture_filter = CaptureFilter *p_capture_filter =
...@@ -1026,8 +1086,6 @@ static int OpenDevice( access_t *p_access, string devicename, ...@@ -1026,8 +1086,6 @@ static int OpenDevice( access_t *p_access, string devicename,
{ {
if( dshow_stream.mt.majortype == MEDIATYPE_Video ) if( dshow_stream.mt.majortype == MEDIATYPE_Video )
{ {
msg_Dbg( p_access, "MEDIATYPE_Video");
dshow_stream.header.video = dshow_stream.header.video =
*(VIDEOINFOHEADER *)dshow_stream.mt.pbFormat; *(VIDEOINFOHEADER *)dshow_stream.mt.pbFormat;
...@@ -1087,13 +1145,11 @@ static int OpenDevice( access_t *p_access, string devicename, ...@@ -1087,13 +1145,11 @@ static int OpenDevice( access_t *p_access, string devicename,
/* Greatly simplifies the reading routine */ /* Greatly simplifies the reading routine */
int i_mtu = dshow_stream.header.video.bmiHeader.biWidth * int i_mtu = dshow_stream.header.video.bmiHeader.biWidth *
i_height * 4; i_height * 4;
p_sys->i_mtu = __MAX( p_sys->i_mtu, (unsigned int)i_mtu ); p_sys->i_mtu = __MAX( p_sys->i_mtu, i_mtu );
} }
else if( dshow_stream.mt.majortype == MEDIATYPE_Audio ) else if( dshow_stream.mt.majortype == MEDIATYPE_Audio )
{ {
msg_Dbg( p_access, "MEDIATYPE_Audio");
dshow_stream.header.audio = dshow_stream.header.audio =
*(WAVEFORMATEX *)dshow_stream.mt.pbFormat; *(WAVEFORMATEX *)dshow_stream.mt.pbFormat;
...@@ -1135,7 +1191,7 @@ static int OpenDevice( access_t *p_access, string devicename, ...@@ -1135,7 +1191,7 @@ static int OpenDevice( access_t *p_access, string devicename,
dshow_stream.header.audio.wBitsPerSample / 8; dshow_stream.header.audio.wBitsPerSample / 8;
} }
p_pin->Release(); p_pin->Release();
p_sys->i_mtu = __MAX( p_sys->i_mtu, (unsigned int)i_mtu ); p_sys->i_mtu = __MAX( p_sys->i_mtu, i_mtu );
} }
else if( dshow_stream.mt.majortype == MEDIATYPE_Stream ) else if( dshow_stream.mt.majortype == MEDIATYPE_Stream )
...@@ -1200,7 +1256,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename, ...@@ -1200,7 +1256,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename,
IID_ICreateDevEnum, (void **)&p_dev_enum ); IID_ICreateDevEnum, (void **)&p_dev_enum );
if( FAILED(hr) ) if( FAILED(hr) )
{ {
msg_Err( p_this, "failed to create the device enumerator (0x%x)", hr); msg_Err( p_this, "failed to create the device enumerator (0x%lx)", hr);
return NULL; return NULL;
} }
...@@ -1215,7 +1271,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename, ...@@ -1215,7 +1271,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename,
p_dev_enum->Release(); p_dev_enum->Release();
if( FAILED(hr) ) if( FAILED(hr) )
{ {
msg_Err( p_this, "failed to create the class enumerator (0x%x)", hr ); msg_Err( p_this, "failed to create the class enumerator (0x%lx)", hr );
return NULL; return NULL;
} }
...@@ -1263,7 +1319,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename, ...@@ -1263,7 +1319,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename,
if( FAILED(hr) ) if( FAILED(hr) )
{ {
msg_Err( p_this, "couldn't bind moniker to filter " msg_Err( p_this, "couldn't bind moniker to filter "
"object (0x%x)", hr ); "object (0x%lx)", hr );
p_moniker->Release(); p_moniker->Release();
p_class_enum->Release(); p_class_enum->Release();
return NULL; return NULL;
...@@ -1293,7 +1349,11 @@ static size_t EnumDeviceCaps( vlc_object_t *p_this, IBaseFilter *p_filter, ...@@ -1293,7 +1349,11 @@ static size_t EnumDeviceCaps( vlc_object_t *p_this, IBaseFilter *p_filter,
IEnumMediaTypes *p_enummt; IEnumMediaTypes *p_enummt;
size_t mt_count = 0; size_t mt_count = 0;
if( S_OK != p_filter->EnumPins( &p_enumpins ) ) return 0; if( FAILED(p_filter->EnumPins( &p_enumpins )) )
{
msg_Dbg( p_this, "EnumDeviceCaps failed: no pin enumeration !");
return 0;
}
while( S_OK == p_enumpins->Next( 1, &p_output_pin, NULL ) ) while( S_OK == p_enumpins->Next( 1, &p_output_pin, NULL ) )
{ {
...@@ -1309,6 +1369,7 @@ static size_t EnumDeviceCaps( vlc_object_t *p_this, IBaseFilter *p_filter, ...@@ -1309,6 +1369,7 @@ static size_t EnumDeviceCaps( vlc_object_t *p_this, IBaseFilter *p_filter,
p_output_pin->Release(); p_output_pin->Release();
} }
p_enumpins->Reset(); p_enumpins->Reset();
while( !mt_count && p_enumpins->Next( 1, &p_output_pin, NULL ) == S_OK ) while( !mt_count && p_enumpins->Next( 1, &p_output_pin, NULL ) == S_OK )
...@@ -1414,8 +1475,6 @@ static size_t EnumDeviceCaps( vlc_object_t *p_this, IBaseFilter *p_filter, ...@@ -1414,8 +1475,6 @@ static size_t EnumDeviceCaps( vlc_object_t *p_this, IBaseFilter *p_filter,
} }
else if( p_mt->majortype == MEDIATYPE_Stream ) else if( p_mt->majortype == MEDIATYPE_Stream )
{ {
msg_Dbg( p_this, "EnumDeviceCaps: MEDIATYPE_Stream" );
if( ( !i_fourcc || i_fourcc == i_current_fourcc ) && if( ( !i_fourcc || i_fourcc == i_current_fourcc ) &&
(mt_count < mt_max) ) (mt_count < mt_max) )
{ {
......
...@@ -93,7 +93,9 @@ const GUID IID_IAMTVTuner = {0x211A8766, 0x03AC, 0x11d1, {0x8D, 0x13, 0x00, 0xAA ...@@ -93,7 +93,9 @@ const GUID IID_IAMTVTuner = {0x211A8766, 0x03AC, 0x11d1, {0x8D, 0x13, 0x00, 0xAA
const GUID IID_IKsPropertySet = {0x31EFAC30, 0x515C, 0x11d0, {0xA9, 0xAA, 0x00, 0xAA, 0x00, 0x61, 0xBE, 0x93}}; const GUID IID_IKsPropertySet = {0x31EFAC30, 0x515C, 0x11d0, {0xA9, 0xAA, 0x00, 0xAA, 0x00, 0x61, 0xBE, 0x93}};
/* Video Format */
const GUID FORMAT_VideoInfo = {0x05589f80, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
/* /*
* MEDIATYPEs and MEDIASUBTYPEs * MEDIATYPEs and MEDIASUBTYPEs
*/ */
...@@ -218,6 +220,9 @@ int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type) ...@@ -218,6 +220,9 @@ int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type)
int i_fourcc = 0; int i_fourcc = 0;
if( media_type.majortype == MEDIATYPE_Video ) if( media_type.majortype == MEDIATYPE_Video )
{
/* currently only support this type of video info format */
if( media_type.formattype == FORMAT_VideoInfo )
{ {
/* Packed RGB formats */ /* Packed RGB formats */
if( media_type.subtype == MEDIASUBTYPE_RGB1 ) if( media_type.subtype == MEDIASUBTYPE_RGB1 )
...@@ -275,8 +280,10 @@ int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type) ...@@ -275,8 +280,10 @@ int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type)
else if( media_type.subtype == MEDIASUBTYPE_dvhd ) else if( media_type.subtype == MEDIASUBTYPE_dvhd )
i_fourcc = VLC_FOURCC( 'd', 'v', 'h', 'd' ); i_fourcc = VLC_FOURCC( 'd', 'v', 'h', 'd' );
} }
}
else if( media_type.majortype == MEDIATYPE_Audio ) else if( media_type.majortype == MEDIATYPE_Audio )
{ {
/* currently only support this type of audio info format */
if( media_type.formattype == FORMAT_WaveFormatEx ) if( media_type.formattype == FORMAT_WaveFormatEx )
{ {
if( media_type.subtype == MEDIASUBTYPE_PCM ) if( media_type.subtype == MEDIASUBTYPE_PCM )
...@@ -405,10 +412,7 @@ STDMETHODIMP_(ULONG) CapturePin::Release() ...@@ -405,10 +412,7 @@ STDMETHODIMP_(ULONG) CapturePin::Release()
STDMETHODIMP CapturePin::Connect( IPin * pReceivePin, STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
const AM_MEDIA_TYPE *pmt ) const AM_MEDIA_TYPE *pmt )
{ {
#ifdef DEBUG_DSHOW if( State_Running != p_filter->state )
msg_Dbg( p_input, "CapturePin::Connect" );
#endif
if( State_Stopped == p_filter->state )
{ {
if( ! p_connected_pin ) if( ! p_connected_pin )
{ {
...@@ -416,9 +420,11 @@ STDMETHODIMP CapturePin::Connect( IPin * pReceivePin, ...@@ -416,9 +420,11 @@ STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
return S_OK; return S_OK;
if( (GUID_NULL != pmt->majortype) && (media_types[0].majortype != pmt->majortype) ) if( (GUID_NULL != pmt->majortype) && (media_types[0].majortype != pmt->majortype) )
msg_Dbg( p_input, "CapturePin::Connect [media major type mismatch]" );
return S_FALSE; return S_FALSE;
if( (GUID_NULL != pmt->subtype) && (! GetFourCCFromMediaType(*pmt)) ) if( (GUID_NULL != pmt->subtype) && (! GetFourCCFromMediaType(*pmt)) )
msg_Dbg( p_input, "CapturePin::Connect [media subtype type not supported]" );
return S_FALSE; return S_FALSE;
if( pmt->pbFormat ) if( pmt->pbFormat )
...@@ -426,36 +432,54 @@ STDMETHODIMP CapturePin::Connect( IPin * pReceivePin, ...@@ -426,36 +432,54 @@ STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
if( pmt->majortype == MEDIATYPE_Video ) if( pmt->majortype == MEDIATYPE_Video )
{ {
if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) ) if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) )
{
msg_Dbg( p_input, "CapturePin::Connect [video height == 0]" );
return S_FALSE; return S_FALSE;
}
if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0) ) if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0) )
{
msg_Dbg( p_input, "CapturePin::Connect [video width == 0]" );
return S_FALSE; return S_FALSE;
} }
} }
}
msg_Dbg( p_input, "CapturePin::Connect [OK]" );
return S_OK; return S_OK;
} }
msg_Dbg( p_input, "CapturePin::Connect [already connected]" );
return VFW_E_ALREADY_CONNECTED; return VFW_E_ALREADY_CONNECTED;
} }
msg_Dbg( p_input, "CapturePin::Connect [not stopped]" );
return VFW_E_NOT_STOPPED; return VFW_E_NOT_STOPPED;
} }
STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector, STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
const AM_MEDIA_TYPE *pmt ) const AM_MEDIA_TYPE *pmt )
{ {
#ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CapturePin::ReceiveConnection" );
#endif
if( State_Stopped != p_filter->state ) if( State_Stopped != p_filter->state )
{
msg_Dbg( p_input, "CapturePin::ReceiveConnection [not stopped]" );
return VFW_E_NOT_STOPPED; return VFW_E_NOT_STOPPED;
}
if( ! pmt ) if( !pConnector || !pmt )
{
msg_Dbg( p_input, "CapturePin::ReceiveConnection [null pointer]" );
return E_POINTER; return E_POINTER;
}
if( p_connected_pin ) if( p_connected_pin )
{
msg_Dbg( p_input, "CapturePin::ReceiveConnection [already connected]" );
return VFW_E_ALREADY_CONNECTED; return VFW_E_ALREADY_CONNECTED;
}
if( S_OK != QueryAccept(pmt) ) if( S_OK != QueryAccept(pmt) )
{
msg_Dbg( p_input, "CapturePin::ReceiveConnection [media type not accepted]" );
return VFW_E_TYPE_NOT_ACCEPTED; return VFW_E_TYPE_NOT_ACCEPTED;
}
msg_Dbg( p_input, "CapturePin::ReceiveConnection [OK]" );
p_connected_pin = pConnector; p_connected_pin = pConnector;
p_connected_pin->AddRef(); p_connected_pin->AddRef();
...@@ -465,11 +489,13 @@ STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector, ...@@ -465,11 +489,13 @@ STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
} }
STDMETHODIMP CapturePin::Disconnect() STDMETHODIMP CapturePin::Disconnect()
{ {
#ifdef DEBUG_DSHOW if( ! p_connected_pin )
msg_Dbg( p_input, "CapturePin::Disconnect" ); {
#endif msg_Dbg( p_input, "CapturePin::Disconnect [not connected]" );
return S_FALSE;
}
if( ! p_connected_pin ) return S_FALSE; msg_Dbg( p_input, "CapturePin::Disconnect [OK]" );
#if 0 // FIXME: This does seem to create crashes sometimes #if 0 // FIXME: This does seem to create crashes sometimes
VLCMediaSample vlc_sample; VLCMediaSample vlc_sample;
...@@ -493,24 +519,26 @@ STDMETHODIMP CapturePin::Disconnect() ...@@ -493,24 +519,26 @@ STDMETHODIMP CapturePin::Disconnect()
} }
STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin ) STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin )
{ {
#ifdef DEBUG_DSHOW if( !p_connected_pin )
msg_Dbg( p_input, "CapturePin::ConnectedTo" ); {
#endif msg_Dbg( p_input, "CapturePin::ConnectedTo [not connected]" );
return VFW_E_NOT_CONNECTED;
if( !p_connected_pin ) return VFW_E_NOT_CONNECTED; }
p_connected_pin->AddRef(); p_connected_pin->AddRef();
*pPin = p_connected_pin; *pPin = p_connected_pin;
msg_Dbg( p_input, "CapturePin::ConnectedTo [OK]" );
return S_OK; return S_OK;
} }
STDMETHODIMP CapturePin::ConnectionMediaType( AM_MEDIA_TYPE *pmt ) STDMETHODIMP CapturePin::ConnectionMediaType( AM_MEDIA_TYPE *pmt )
{ {
#ifdef DEBUG_DSHOW if( !p_connected_pin )
msg_Dbg( p_input, "CapturePin::ConnectionMediaType" ); {
#endif msg_Dbg( p_input, "CapturePin::ConnectionMediaType [not connected]" );
return VFW_E_NOT_CONNECTED;
if( !p_connected_pin ) return VFW_E_NOT_CONNECTED; }
return CopyMediaType( pmt, &cx_media_type ); return CopyMediaType( pmt, &cx_media_type );
} }
...@@ -549,28 +577,54 @@ STDMETHODIMP CapturePin::QueryId( LPWSTR * Id ) ...@@ -549,28 +577,54 @@ STDMETHODIMP CapturePin::QueryId( LPWSTR * Id )
} }
STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt ) STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt )
{ {
#ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CapturePin::QueryAccept" );
#endif
if( State_Stopped == p_filter->state ) if( State_Stopped == p_filter->state )
{ {
if( media_types[0].majortype == pmt->majortype ) if( media_types[0].majortype == pmt->majortype )
{ {
if( GetFourCCFromMediaType(*pmt) ) int i_chroma = GetFourCCFromMediaType(*pmt);
if( 0 != i_chroma )
{ {
if( pmt->majortype == MEDIATYPE_Video ) if( pmt->majortype == MEDIATYPE_Video )
{
if( pmt->pbFormat && if( pmt->pbFormat &&
((((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) || ((((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) ||
(((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0)) ) (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0)) )
{
msg_Dbg( p_input, "CapturePin::QueryAccept [video size wxh == 0]" );
return S_FALSE; return S_FALSE;
}
msg_Dbg( p_input, "CapturePin::QueryAccept [OK] (width=%ld, height=%ld, chroma=%4.4s)",
((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth,
((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight,
(char *)&i_chroma
);
}
else {
msg_Dbg( p_input, "CapturePin::QueryAccept [OK] (channels=%d, samples/sec=%lu, bits/samples=%d, format=%4.4s)",
((WAVEFORMATEX *)pmt->pbFormat)->nChannels,
((WAVEFORMATEX *)pmt->pbFormat)->nSamplesPerSec,
((WAVEFORMATEX *)pmt->pbFormat)->wBitsPerSample,
(char *)&i_chroma
);
}
if( !p_connected_pin ) if( p_connected_pin )
return S_OK; {
FreeMediaType( cx_media_type ); FreeMediaType( cx_media_type );
return CopyMediaType( &cx_media_type, pmt ); CopyMediaType( &cx_media_type, pmt );
}
return S_OK;
}
else {
msg_Dbg( p_input, "CapturePin::QueryAccept [media type not supported]" );
}
}
else {
msg_Dbg( p_input, "CapturePin::QueryAccept [media type mismatch]" );
} }
} }
else {
msg_Dbg( p_input, "CapturePin::QueryAccept [not stopped]" );
} }
return S_FALSE; return S_FALSE;
} }
...@@ -707,8 +761,7 @@ STDMETHODIMP CapturePin::ReceiveCanBlock( void ) ...@@ -707,8 +761,7 @@ STDMETHODIMP CapturePin::ReceiveCanBlock( void )
****************************************************************************/ ****************************************************************************/
CaptureFilter::CaptureFilter( access_t * _p_input, AM_MEDIA_TYPE *mt, CaptureFilter::CaptureFilter( access_t * _p_input, AM_MEDIA_TYPE *mt,
size_t mt_count ) size_t mt_count )
: p_input( _p_input ), : p_input( _p_input ), p_pin( new CapturePin( _p_input, this, mt, mt_count ) ),
p_pin( new CapturePin( _p_input, this, mt, mt_count ) ),
state( State_Stopped ), i_ref( 1 ) state( State_Stopped ), i_ref( 1 )
{ {
} }
...@@ -1110,7 +1163,7 @@ STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes, ...@@ -1110,7 +1163,7 @@ STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes,
ULONG * pcFetched ) ULONG * pcFetched )
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CaptureEnumMediaTypes::Next" ); msg_Dbg( p_input, "CaptureEnumMediaTypes::Next " );
#endif #endif
ULONG count; ULONG count;
......
...@@ -209,7 +209,7 @@ class CaptureEnumMediaTypes : public IEnumMediaTypes ...@@ -209,7 +209,7 @@ class CaptureEnumMediaTypes : public IEnumMediaTypes
access_t * p_input; access_t * p_input;
CapturePin *p_pin; CapturePin *p_pin;
int i_position; size_t i_position;
long i_ref; long i_ref;
public: public:
......
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