1
mirror of https://code.videolan.org/videolan/vlc synced 2024-07-29 11:58:24 +02:00

* modules/access/dshow: converted to access2/demux2. Let's hope I didn't break anything ;)

This commit is contained in:
Gildas Bazin 2004-06-09 15:24:18 +00:00
parent cd3d0c21ff
commit a7620012f5
5 changed files with 461 additions and 418 deletions

View File

@ -69,6 +69,7 @@ vlc_module_begin();
add_shortcut( "svcd" );
add_shortcut( "v4l" );
add_shortcut( "dshow" );
vlc_module_end();
/*****************************************************************************

File diff suppressed because it is too large Load Diff

View File

@ -299,7 +299,7 @@ int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type)
* Implementation of our dummy directshow filter pin class
****************************************************************************/
CapturePin::CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
CapturePin::CapturePin( access_t * _p_input, CaptureFilter *_p_filter,
AM_MEDIA_TYPE *mt, size_t mt_count )
: p_input( _p_input ), p_filter( _p_filter ), p_connected_pin( NULL ),
media_types(mt), media_type_count(mt_count), i_ref( 1 )
@ -317,7 +317,7 @@ CapturePin::~CapturePin()
#endif
for( size_t c=0; c<media_type_count; c++ )
{
FreeMediaType(media_types[c]);
FreeMediaType(media_types[c]);
}
FreeMediaType(cx_media_type);
}
@ -328,7 +328,7 @@ HRESULT CapturePin::CustomGetSample( VLCMediaSample *vlc_sample )
msg_Dbg( p_input, "CapturePin::CustomGetSample" );
#endif
access_sys_t *p_sys = p_input->p_access_data;
access_sys_t *p_sys = p_input->p_sys;
vlc_mutex_lock( &p_sys->lock );
if( samples_queue.size() )
{
@ -410,31 +410,31 @@ STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
#endif
if( State_Stopped == p_filter->state )
{
if( ! p_connected_pin )
{
if( ! pmt )
return S_OK;
if( (GUID_NULL != pmt->majortype) && (media_types[0].majortype != pmt->majortype) )
return S_FALSE;
if( ! p_connected_pin )
{
if( ! pmt )
return S_OK;
if( (GUID_NULL != pmt->majortype) && (media_types[0].majortype != pmt->majortype) )
return S_FALSE;
if( (GUID_NULL != pmt->subtype) && (! GetFourCCFromMediaType(*pmt)) )
return S_FALSE;
if( (GUID_NULL != pmt->subtype) && (! GetFourCCFromMediaType(*pmt)) )
return S_FALSE;
if( pmt->pbFormat )
{
if( pmt->majortype == MEDIATYPE_Video )
{
if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) )
return S_FALSE;
if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0) )
return S_FALSE;
if( pmt->pbFormat )
{
if( pmt->majortype == MEDIATYPE_Video )
{
if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) )
return S_FALSE;
if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0) )
return S_FALSE;
}
}
return S_OK;
}
return VFW_E_ALREADY_CONNECTED;
}
}
return S_OK;
}
return VFW_E_ALREADY_CONNECTED;
}
return VFW_E_NOT_STOPPED;
}
@ -446,16 +446,16 @@ STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
#endif
if( State_Stopped != p_filter->state )
return VFW_E_NOT_STOPPED;
return VFW_E_NOT_STOPPED;
if( ! pmt )
return E_POINTER;
return E_POINTER;
if( p_connected_pin )
return VFW_E_ALREADY_CONNECTED;
return VFW_E_ALREADY_CONNECTED;
if( S_OK != QueryAccept(pmt) )
return VFW_E_TYPE_NOT_ACCEPTED;
return VFW_E_TYPE_NOT_ACCEPTED;
p_connected_pin = pConnector;
p_connected_pin->AddRef();
@ -473,7 +473,7 @@ STDMETHODIMP CapturePin::Disconnect()
#if 0 // FIXME: This does seem to create crashes sometimes
VLCMediaSample vlc_sample;
access_sys_t *p_sys = p_input->p_access_data;
access_sys_t *p_sys = p_input->p_sys;
vlc_mutex_lock( &p_sys->lock );
while( samples_queue.size() )
@ -554,23 +554,23 @@ STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt )
#endif
if( State_Stopped == p_filter->state )
{
if( media_types[0].majortype == pmt->majortype )
{
if( GetFourCCFromMediaType(*pmt) )
{
if( pmt->majortype == MEDIATYPE_Video )
if( pmt->pbFormat &&
((((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) ||
(((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0)) )
return S_FALSE;
if( media_types[0].majortype == pmt->majortype )
{
if( GetFourCCFromMediaType(*pmt) )
{
if( pmt->majortype == MEDIATYPE_Video )
if( pmt->pbFormat &&
((((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) ||
(((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0)) )
return S_FALSE;
if( !p_connected_pin )
return S_OK;
if( !p_connected_pin )
return S_OK;
FreeMediaType( cx_media_type );
return CopyMediaType( &cx_media_type, pmt );
}
}
FreeMediaType( cx_media_type );
return CopyMediaType( &cx_media_type, pmt );
}
}
}
return S_FALSE;
}
@ -660,7 +660,7 @@ STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
mtime_t i_timestamp = mdate() * 10;
VLCMediaSample vlc_sample = {pSample, i_timestamp};
access_sys_t *p_sys = p_input->p_access_data;
access_sys_t *p_sys = p_input->p_sys;
vlc_mutex_lock( &p_sys->lock );
samples_queue.push_front( vlc_sample );
@ -705,9 +705,10 @@ STDMETHODIMP CapturePin::ReceiveCanBlock( void )
/****************************************************************************
* Implementation of our dummy directshow filter class
****************************************************************************/
CaptureFilter::CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE *mt, size_t mt_count )
: p_input( _p_input ), p_pin( new CapturePin( _p_input, this, mt, mt_count ) ),
CaptureFilter::CaptureFilter( access_t * _p_input, AM_MEDIA_TYPE *mt,
size_t mt_count )
: p_input( _p_input ),
p_pin( new CapturePin( _p_input, this, mt, mt_count ) ),
state( State_Stopped ), i_ref( 1 )
{
}
@ -909,7 +910,7 @@ CapturePin *CaptureFilter::CustomGetPin()
* Implementation of our dummy directshow enumpins class
****************************************************************************/
CaptureEnumPins::CaptureEnumPins( input_thread_t * _p_input,
CaptureEnumPins::CaptureEnumPins( access_t * _p_input,
CaptureFilter *_p_filter,
CaptureEnumPins *pEnumPins )
: p_input( _p_input ), p_filter( _p_filter ), i_ref( 1 )
@ -1038,10 +1039,8 @@ STDMETHODIMP CaptureEnumPins::Clone( IEnumPins **ppEnum )
/****************************************************************************
* Implementation of our dummy directshow enummediatypes class
****************************************************************************/
CaptureEnumMediaTypes::CaptureEnumMediaTypes( input_thread_t * _p_input,
CapturePin *_p_pin,
CaptureEnumMediaTypes *pEnumMediaTypes )
CaptureEnumMediaTypes::CaptureEnumMediaTypes( access_t * _p_input,
CapturePin *_p_pin, CaptureEnumMediaTypes *pEnumMediaTypes )
: p_input( _p_input ), p_pin( _p_pin ), i_ref( 1 )
{
/* Hold a reference count on our filter */
@ -1116,7 +1115,7 @@ STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes,
ULONG count;
if( ! ppMediaTypes )
return E_POINTER;
return E_POINTER;
if( (! pcFetched) && (cMediaTypes > 1) )
return E_POINTER;
@ -1125,17 +1124,17 @@ STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes,
while( (count < cMediaTypes) && (i_position < p_pin->media_type_count) )
{
ppMediaTypes[count] = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
if( CopyMediaType(ppMediaTypes[count], &p_pin->media_types[i_position]) != S_OK )
return E_OUTOFMEMORY;
ppMediaTypes[count] = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
if( CopyMediaType(ppMediaTypes[count], &p_pin->media_types[i_position]) != S_OK )
return E_OUTOFMEMORY;
count++;
i_position++;
count++;
i_position++;
}
if( pcFetched )
{
*pcFetched = count;
*pcFetched = count;
}
return (count == cMediaTypes) ? S_OK : S_FALSE;

View File

@ -69,7 +69,7 @@ class CapturePin: public IPin, public IMemInputPin
{
friend class CaptureEnumMediaTypes;
input_thread_t *p_input;
access_t *p_input;
CaptureFilter *p_filter;
IPin *p_connected_pin;
@ -84,7 +84,7 @@ class CapturePin: public IPin, public IMemInputPin
long i_ref;
public:
CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
CapturePin( access_t * _p_input, CaptureFilter *_p_filter,
AM_MEDIA_TYPE *mt, size_t mt_count );
virtual ~CapturePin();
@ -134,7 +134,7 @@ class CaptureFilter : public IBaseFilter
{
friend class CapturePin;
input_thread_t *p_input;
access_t *p_input;
CapturePin *p_pin;
IFilterGraph *p_graph;
//AM_MEDIA_TYPE media_type;
@ -143,7 +143,7 @@ class CaptureFilter : public IBaseFilter
long i_ref;
public:
CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE *mt, size_t mt_count );
CaptureFilter( access_t * _p_input, AM_MEDIA_TYPE *mt, size_t mt_count );
virtual ~CaptureFilter();
/* IUnknown methods */
@ -178,14 +178,14 @@ class CaptureFilter : public IBaseFilter
****************************************************************************/
class CaptureEnumPins : public IEnumPins
{
input_thread_t * p_input;
access_t * p_input;
CaptureFilter *p_filter;
int i_position;
long i_ref;
public:
CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter,
CaptureEnumPins( access_t * _p_input, CaptureFilter *_p_filter,
CaptureEnumPins *pEnumPins );
virtual ~CaptureEnumPins();
@ -206,14 +206,14 @@ public:
****************************************************************************/
class CaptureEnumMediaTypes : public IEnumMediaTypes
{
input_thread_t * p_input;
access_t * p_input;
CapturePin *p_pin;
int i_position;
long i_ref;
public:
CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_pin,
CaptureEnumMediaTypes( access_t * _p_input, CapturePin *_p_pin,
CaptureEnumMediaTypes *pEnumMediaTypes );
virtual ~CaptureEnumMediaTypes();

View File

@ -71,6 +71,7 @@ vlc_module_begin();
add_shortcut( "directory" );
add_shortcut( "wav" );
add_shortcut( "v4l" );
add_shortcut( "dshow" );
vlc_module_end();
/*****************************************************************************
@ -141,8 +142,9 @@ static int Demux2Open( vlc_object_t * p_this )
*****************************************************************************/
static int Demux2Demux( input_thread_t * p_input )
{
demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
p_sys->p_demux->b_die = p_input->b_die;
return demux2_Demux( p_sys->p_demux );
}
@ -151,7 +153,7 @@ static int Demux2Demux( input_thread_t * p_input )
*****************************************************************************/
static int Demux2Control( input_thread_t *p_input, int i_query, va_list args )
{
demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
return demux2_vaControl( p_sys->p_demux, i_query, args );
}