Commit a75d76c1 authored by Gildas Bazin's avatar Gildas Bazin

* modules/access/dshow/*: fixes and optimizations. Also changed all the...

* modules/access/dshow/*: fixes and optimizations. Also changed all the parameters into config options.
parent d20e5f41
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* filter.c : DirectShow access module for vlc * filter.c : DirectShow access module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: filter.cpp,v 1.5 2003/08/31 22:06:17 gbazin Exp $ * $Id: filter.cpp,v 1.6 2003/10/18 20:09:23 gbazin Exp $
* *
* Author: Gildas Bazin <gbazin@netcourrier.com> * Author: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
#define DEBUG_DSHOW 1 #define DEBUG_DSHOW 1
struct access_sys_t
{
vlc_mutex_t lock;
vlc_cond_t wait;
};
/***************************************************************************** /*****************************************************************************
* DirectShow GUIDs. * DirectShow GUIDs.
* Easier to define them hear as mingw doesn't provide them all. * Easier to define them hear as mingw doesn't provide them all.
...@@ -59,6 +65,8 @@ const GUID IID_IMemInputPin = {0x56a8689d, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20 ...@@ -59,6 +65,8 @@ const GUID IID_IMemInputPin = {0x56a8689d, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20
const GUID IID_IEnumPins = {0x56a86892, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}}; const GUID IID_IEnumPins = {0x56a86892, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID IID_IEnumMediaTypes = {0x89c31040, 0x846b, 0x11ce, {0x97,0xd3, 0x00,0xaa,0x00,0x55,0x59,0x5a}}; const GUID IID_IEnumMediaTypes = {0x89c31040, 0x846b, 0x11ce, {0x97,0xd3, 0x00,0xaa,0x00,0x55,0x59,0x5a}};
const GUID IID_IAMBufferNegotiation = {0x56ed71a0, 0xaf5f, 0x11d0, {0xb3, 0xf0, 0x00, 0xaa, 0x00, 0x37, 0x61, 0xc5}};
/* /*
* MEDIATYPEs and MEDIASUBTYPEs * MEDIATYPEs and MEDIASUBTYPEs
*/ */
...@@ -92,6 +100,7 @@ const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0 ...@@ -92,6 +100,7 @@ const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0
const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}; const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
const GUID MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
...@@ -196,7 +205,7 @@ STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv) ...@@ -196,7 +205,7 @@ STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv)
STDMETHODIMP_(ULONG) CapturePin::AddRef() STDMETHODIMP_(ULONG) CapturePin::AddRef()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CapturePin::AddRef" ); msg_Dbg( p_input, "CapturePin::AddRef (ref: %i)", i_ref );
#endif #endif
return i_ref++; return i_ref++;
...@@ -204,13 +213,12 @@ STDMETHODIMP_(ULONG) CapturePin::AddRef() ...@@ -204,13 +213,12 @@ STDMETHODIMP_(ULONG) CapturePin::AddRef()
STDMETHODIMP_(ULONG) CapturePin::Release() STDMETHODIMP_(ULONG) CapturePin::Release()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CapturePin::Release" ); msg_Dbg( p_input, "CapturePin::Release (ref: %i)", i_ref );
#endif #endif
i_ref--; if( !InterlockedDecrement(&i_ref) ) delete this;
if( !i_ref ) delete this;
return i_ref; return 0;
}; };
/* IPin methods */ /* IPin methods */
...@@ -397,6 +405,7 @@ STDMETHODIMP CapturePin::GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps ...@@ -397,6 +405,7 @@ STDMETHODIMP CapturePin::GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CapturePin::GetAllocatorRequirements" ); msg_Dbg( p_input, "CapturePin::GetAllocatorRequirements" );
#endif #endif
return E_NOTIMPL; return E_NOTIMPL;
} }
STDMETHODIMP CapturePin::Receive( IMediaSample *pSample ) STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
...@@ -408,6 +417,9 @@ STDMETHODIMP CapturePin::Receive( IMediaSample *pSample ) ...@@ -408,6 +417,9 @@ STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
pSample->AddRef(); pSample->AddRef();
mtime_t i_timestamp = mdate() * 10; mtime_t i_timestamp = mdate() * 10;
VLCMediaSample vlc_sample = {pSample, i_timestamp}; VLCMediaSample vlc_sample = {pSample, i_timestamp};
access_sys_t *p_sys = p_input->p_access_data;
vlc_mutex_lock( &p_sys->lock );
samples_queue.push_front( vlc_sample ); samples_queue.push_front( vlc_sample );
/* Make sure we don't cache too many samples */ /* Make sure we don't cache too many samples */
...@@ -419,6 +431,9 @@ STDMETHODIMP CapturePin::Receive( IMediaSample *pSample ) ...@@ -419,6 +431,9 @@ STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
vlc_sample.p_sample->Release(); vlc_sample.p_sample->Release();
} }
vlc_cond_signal( &p_sys->wait );
vlc_mutex_unlock( &p_sys->lock );
return S_OK; return S_OK;
} }
STDMETHODIMP CapturePin::ReceiveMultiple( IMediaSample **pSamples, STDMETHODIMP CapturePin::ReceiveMultiple( IMediaSample **pSamples,
...@@ -504,7 +519,7 @@ STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv ) ...@@ -504,7 +519,7 @@ STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv )
STDMETHODIMP_(ULONG) CaptureFilter::AddRef() STDMETHODIMP_(ULONG) CaptureFilter::AddRef()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CaptureFilter::AddRef" ); msg_Dbg( p_input, "CaptureFilter::AddRef (ref: %i)", i_ref );
#endif #endif
return i_ref++; return i_ref++;
...@@ -512,13 +527,12 @@ STDMETHODIMP_(ULONG) CaptureFilter::AddRef() ...@@ -512,13 +527,12 @@ STDMETHODIMP_(ULONG) CaptureFilter::AddRef()
STDMETHODIMP_(ULONG) CaptureFilter::Release() STDMETHODIMP_(ULONG) CaptureFilter::Release()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CaptureFilter::Release" ); msg_Dbg( p_input, "CaptureFilter::Release (ref: %i)", i_ref );
#endif #endif
i_ref--; if( !InterlockedDecrement(&i_ref) ) delete this;
if( !i_ref ) delete this;
return i_ref; return 0;
}; };
/* IPersist method */ /* IPersist method */
...@@ -683,7 +697,7 @@ STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv ) ...@@ -683,7 +697,7 @@ STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv )
STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef() STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CaptureEnumPins::AddRef" ); msg_Dbg( p_input, "CaptureEnumPins::AddRef (ref: %i)", i_ref );
#endif #endif
return i_ref++; return i_ref++;
...@@ -691,13 +705,12 @@ STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef() ...@@ -691,13 +705,12 @@ STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef()
STDMETHODIMP_(ULONG) CaptureEnumPins::Release() STDMETHODIMP_(ULONG) CaptureEnumPins::Release()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CaptureEnumPins::Release" ); msg_Dbg( p_input, "CaptureEnumPins::Release (ref: %i)", i_ref );
#endif #endif
i_ref--; if( !InterlockedDecrement(&i_ref) ) delete this;
if( !i_ref ) delete this;
return i_ref; return 0;
}; };
/* IEnumPins */ /* IEnumPins */
...@@ -807,7 +820,7 @@ STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv ) ...@@ -807,7 +820,7 @@ STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv )
STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef() STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef" ); msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef (ref: %i)", i_ref );
#endif #endif
return i_ref++; return i_ref++;
...@@ -815,13 +828,12 @@ STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef() ...@@ -815,13 +828,12 @@ STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef()
STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release() STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release()
{ {
#ifdef DEBUG_DSHOW #ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CaptureEnumMediaTypes::Release" ); msg_Dbg( p_input, "CaptureEnumMediaTypes::Release (ref: %i)", i_ref );
#endif #endif
i_ref--; if( !InterlockedDecrement(&i_ref) ) delete this;
if( !i_ref ) delete this;
return i_ref; return 0;
}; };
/* IEnumMediaTypes */ /* IEnumMediaTypes */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* filter.h : DirectShow access module for vlc * filter.h : DirectShow access module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: filter.h,v 1.2 2003/08/31 22:06:17 gbazin Exp $ * $Id: filter.h,v 1.3 2003/10/18 20:09:23 gbazin Exp $
* *
* Author: Gildas Bazin <gbazin@netcourrier.com> * Author: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -72,7 +72,7 @@ class CapturePin: public IPin, public IMemInputPin ...@@ -72,7 +72,7 @@ class CapturePin: public IPin, public IMemInputPin
deque<VLCMediaSample> samples_queue; deque<VLCMediaSample> samples_queue;
int i_ref; long i_ref;
public: public:
CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter, CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
...@@ -128,7 +128,7 @@ class CaptureFilter : public IBaseFilter ...@@ -128,7 +128,7 @@ class CaptureFilter : public IBaseFilter
IFilterGraph *p_graph; IFilterGraph *p_graph;
AM_MEDIA_TYPE media_type; AM_MEDIA_TYPE media_type;
int i_ref; long i_ref;
public: public:
CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt ); CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt );
...@@ -170,7 +170,7 @@ class CaptureEnumPins : public IEnumPins ...@@ -170,7 +170,7 @@ class CaptureEnumPins : public IEnumPins
CaptureFilter *p_filter; CaptureFilter *p_filter;
int i_position; int i_position;
int i_ref; long i_ref;
public: public:
CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter, CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter,
...@@ -198,7 +198,7 @@ class CaptureEnumMediaTypes : public IEnumMediaTypes ...@@ -198,7 +198,7 @@ class CaptureEnumMediaTypes : public IEnumMediaTypes
CapturePin *p_pin; CapturePin *p_pin;
int i_position; int i_position;
int i_ref; long i_ref;
public: public:
CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_pin, CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_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