# define QACONTAINERFLAGS QACONTAINERFLAGS_SOMETHINGELSE
#endif
+#include "common.h"
#include "filter.h"
#define DEBUG_DSHOW 1
-struct access_sys_t
-{
- vlc_mutex_t lock;
- vlc_cond_t wait;
-};
-
-
#define FILTER_NAME L"VideoLAN Capture Filter"
#define PIN_NAME L"Capture"
const GUID CLSID_SystemDeviceEnum = {0x62be5d10, 0x60eb, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
const GUID CLSID_VideoInputDeviceCategory = {0x860BB310,0x5D01,0x11d0,{0xBD,0x3B,0x00,0xA0,0xC9,0x11,0xCE,0x86}};
const GUID CLSID_AudioInputDeviceCategory = {0x33d9a762, 0x90c8, 0x11d0, {0xbd, 0x43, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
-const GUID IID_IPropertyBag = {0x55272A00, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}};
+//const GUID IID_IPropertyBag = {0x55272A00, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}};
+extern const GUID IID_IPropertyBag;
const GUID IID_ICreateDevEnum = {0x29840822, 0x5b84, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
const GUID IID_IFilterGraph = {0x56a8689f, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
const GUID IID_IMediaControl = {0x56a868b1, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
const GUID CLSID_FilterGraph = {0xe436ebb3, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
-const GUID IID_IPersist = {0x0000010c, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
+//const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
+extern const GUID IID_IUnknown;
+//const GUID IID_IPersist = {0x0000010c, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
+extern const GUID IID_IPersist;
const GUID IID_IMediaFilter = {0x56a86899, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID IID_IBaseFilter = {0x56a86895, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID IID_IMemInputPin = {0x56a8689d, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
+extern const GUID IID_IMemInputPin;
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_IAMBufferNegotiation = {0x56ed71a0, 0xaf5f, 0x11d0, {0xb3, 0xf0, 0x00, 0xaa, 0x00, 0x37, 0x61, 0xc5}};
-const GUID IID_ISpecifyPropertyPages = {0xb196b28b, 0xbab4, 0x101a, {0xb6, 0x9c, 0x00, 0xaa, 0x00, 0x34, 0x1d, 0x07}};
+//const GUID IID_ISpecifyPropertyPages = {0xb196b28b, 0xbab4, 0x101a, {0xb6, 0x9c, 0x00, 0xaa, 0x00, 0x34, 0x1d, 0x07}};
+extern const GUID IID_ISpecifyPropertyPages;
const GUID IID_IQualityControl = {0x56a868a5, 0x0ad4, 0x11ce, {0xb, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
const GUID PIN_CATEGORY_CAPTURE= {0xfb6c4281, 0x0353, 0x11d1, {0x90, 0x5f, 0x0, 0x0, 0xc0, 0xcc, 0x16, 0xba}};
const GUID LOOK_UPSTREAM_ONLY= {0xac798be0, 0x98e3, 0x11d1, {0xb3, 0xf1, 0x0, 0xaa, 0x0, 0x37, 0x61, 0xc}};
-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}};
+extern const GUID GUID_NULL;
void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt )
{
const AM_MEDIA_TYPE *pmtSource )
{
*pmtTarget = *pmtSource;
- if( pmtSource->cbFormat != 0 )
+
+ if( !pmtSource || !pmtTarget ) return S_FALSE;
+
+ if( pmtSource->cbFormat && pmtSource->pbFormat )
{
pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc( pmtSource->cbFormat );
if( pmtTarget->pbFormat == NULL )
return S_OK;
}
-int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type)
+int GetFourCCFromMediaType( const AM_MEDIA_TYPE &media_type )
{
int i_fourcc = 0;
if( media_type.majortype == MEDIATYPE_Video )
{
/* currently only support this type of video info format */
- if( media_type.formattype == FORMAT_VideoInfo )
- {
- /* Packed RGB formats */
- if( media_type.subtype == MEDIASUBTYPE_RGB1 )
- i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '1' );
- else if( media_type.subtype == MEDIASUBTYPE_RGB4 )
- i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '4' );
- else if( media_type.subtype == MEDIASUBTYPE_RGB8 )
- i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '8' );
- else if( media_type.subtype == MEDIASUBTYPE_RGB555 )
- i_fourcc = VLC_FOURCC( 'R', 'V', '1', '5' );
- else if( media_type.subtype == MEDIASUBTYPE_RGB565 )
- i_fourcc = VLC_FOURCC( 'R', 'V', '1', '6' );
- else if( media_type.subtype == MEDIASUBTYPE_RGB24 )
- i_fourcc = VLC_FOURCC( 'R', 'V', '2', '4' );
- else if( media_type.subtype == MEDIASUBTYPE_RGB32 )
- i_fourcc = VLC_FOURCC( 'R', 'V', '3', '2' );
- else if( media_type.subtype == MEDIASUBTYPE_ARGB32 )
- i_fourcc = VLC_FOURCC( 'R', 'G', 'B', 'A' );
-
- /* Planar YUV formats */
- else if( media_type.subtype == MEDIASUBTYPE_I420 )
- i_fourcc = VLC_FOURCC( 'I', '4', '2', '0' );
- else if( media_type.subtype == MEDIASUBTYPE_Y41P )
- i_fourcc = VLC_FOURCC( 'I', '4', '1', '1' );
- else if( media_type.subtype == MEDIASUBTYPE_YV12 )
- i_fourcc = VLC_FOURCC( 'Y', 'V', '1', '2' );
- else if( media_type.subtype == MEDIASUBTYPE_IYUV )
- i_fourcc = VLC_FOURCC( 'Y', 'V', '1', '2' );
- else if( media_type.subtype == MEDIASUBTYPE_YVU9 )
- i_fourcc = VLC_FOURCC( 'Y', 'V', 'U', '9' );
-
- /* Packed YUV formats */
- else if( media_type.subtype == MEDIASUBTYPE_YVYU )
- i_fourcc = VLC_FOURCC( 'Y', 'V', 'Y', 'U' );
- else if( media_type.subtype == MEDIASUBTYPE_YUYV )
- i_fourcc = VLC_FOURCC( 'Y', 'U', 'Y', '2' );
- else if( media_type.subtype == MEDIASUBTYPE_Y411 )
- i_fourcc = VLC_FOURCC( 'I', '4', '1', 'N' );
- else if( media_type.subtype == MEDIASUBTYPE_Y211 )
- i_fourcc = VLC_FOURCC( 'Y', '2', '1', '1' );
- else if( media_type.subtype == MEDIASUBTYPE_YUY2 )
- i_fourcc = VLC_FOURCC( 'Y', 'U', 'Y', '2' );
- else if( media_type.subtype == MEDIASUBTYPE_UYVY )
- i_fourcc = VLC_FOURCC( 'U', 'Y', 'V', 'Y' );
-
- /* MPEG2 video elementary stream */
- else if( media_type.subtype == MEDIASUBTYPE_MPEG2_VIDEO )
- i_fourcc = VLC_FOURCC( 'm', 'p', '2', 'v' );
-
- /* DV formats */
- else if( media_type.subtype == MEDIASUBTYPE_dvsl )
- i_fourcc = VLC_FOURCC( 'd', 'v', 's', 'l' );
- else if( media_type.subtype == MEDIASUBTYPE_dvsd )
- i_fourcc = VLC_FOURCC( 'd', 'v', 's', 'd' );
- else if( media_type.subtype == MEDIASUBTYPE_dvhd )
- i_fourcc = VLC_FOURCC( 'd', 'v', 'h', 'd' );
- }
+ if( 1 /* media_type.formattype == FORMAT_VideoInfo */ )
+ {
+ /* Packed RGB formats */
+ if( media_type.subtype == MEDIASUBTYPE_RGB1 )
+ i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '1' );
+ else if( media_type.subtype == MEDIASUBTYPE_RGB4 )
+ i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '4' );
+ else if( media_type.subtype == MEDIASUBTYPE_RGB8 )
+ i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '8' );
+ else if( media_type.subtype == MEDIASUBTYPE_RGB555 )
+ i_fourcc = VLC_FOURCC( 'R', 'V', '1', '5' );
+ else if( media_type.subtype == MEDIASUBTYPE_RGB565 )
+ i_fourcc = VLC_FOURCC( 'R', 'V', '1', '6' );
+ else if( media_type.subtype == MEDIASUBTYPE_RGB24 )
+ i_fourcc = VLC_FOURCC( 'R', 'V', '2', '4' );
+ else if( media_type.subtype == MEDIASUBTYPE_RGB32 )
+ i_fourcc = VLC_FOURCC( 'R', 'V', '3', '2' );
+ else if( media_type.subtype == MEDIASUBTYPE_ARGB32 )
+ i_fourcc = VLC_FOURCC( 'R', 'G', 'B', 'A' );
+
+ /* Planar YUV formats */
+ else if( media_type.subtype == MEDIASUBTYPE_I420 )
+ i_fourcc = VLC_FOURCC( 'I', '4', '2', '0' );
+ else if( media_type.subtype == MEDIASUBTYPE_Y41P )
+ i_fourcc = VLC_FOURCC( 'I', '4', '1', '1' );
+ else if( media_type.subtype == MEDIASUBTYPE_YV12 )
+ i_fourcc = VLC_FOURCC( 'Y', 'V', '1', '2' );
+ else if( media_type.subtype == MEDIASUBTYPE_IYUV )
+ i_fourcc = VLC_FOURCC( 'Y', 'V', '1', '2' );
+ else if( media_type.subtype == MEDIASUBTYPE_YVU9 )
+ i_fourcc = VLC_FOURCC( 'Y', 'V', 'U', '9' );
+
+ /* Packed YUV formats */
+ else if( media_type.subtype == MEDIASUBTYPE_YVYU )
+ i_fourcc = VLC_FOURCC( 'Y', 'V', 'Y', 'U' );
+ else if( media_type.subtype == MEDIASUBTYPE_YUYV )
+ i_fourcc = VLC_FOURCC( 'Y', 'U', 'Y', '2' );
+ else if( media_type.subtype == MEDIASUBTYPE_Y411 )
+ i_fourcc = VLC_FOURCC( 'I', '4', '1', 'N' );
+ else if( media_type.subtype == MEDIASUBTYPE_Y211 )
+ i_fourcc = VLC_FOURCC( 'Y', '2', '1', '1' );
+ else if( media_type.subtype == MEDIASUBTYPE_YUY2 )
+ i_fourcc = VLC_FOURCC( 'Y', 'U', 'Y', '2' );
+ else if( media_type.subtype == MEDIASUBTYPE_UYVY )
+ i_fourcc = VLC_FOURCC( 'U', 'Y', 'V', 'Y' );
+
+ /* MPEG2 video elementary stream */
+ else if( media_type.subtype == MEDIASUBTYPE_MPEG2_VIDEO )
+ i_fourcc = VLC_FOURCC( 'm', 'p', '2', 'v' );
+
+ /* DV formats */
+ else if( media_type.subtype == MEDIASUBTYPE_dvsl )
+ i_fourcc = VLC_FOURCC( 'd', 'v', 's', 'l' );
+ else if( media_type.subtype == MEDIASUBTYPE_dvsd )
+ i_fourcc = VLC_FOURCC( 'd', 'v', 's', 'd' );
+ else if( media_type.subtype == MEDIASUBTYPE_dvhd )
+ i_fourcc = VLC_FOURCC( 'd', 'v', 'h', 'd' );
+ }
}
else if( media_type.majortype == MEDIATYPE_Audio )
{
}
}
else if( media_type.majortype == MEDIATYPE_Stream )
- {
+ {
if( media_type.subtype == MEDIASUBTYPE_MPEG2_PROGRAM )
- i_fourcc = VLC_FOURCC( 'm', 'p', '2', 'p' );
+ i_fourcc = VLC_FOURCC( 'm', 'p', '2', 'p' );
else if( media_type.subtype == MEDIASUBTYPE_MPEG2_TRANSPORT )
- i_fourcc = VLC_FOURCC( 'm', 'p', '2', 't' );
+ i_fourcc = VLC_FOURCC( 'm', 'p', '2', 't' );
}
+
return i_fourcc;
}
* Implementation of our dummy directshow filter pin class
****************************************************************************/
-CapturePin::CapturePin( access_t * _p_input, CaptureFilter *_p_filter,
+CapturePin::CapturePin( vlc_object_t *_p_input, access_sys_t *_p_sys,
+ 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 )
+ : p_input( _p_input ), p_sys( _p_sys ), p_filter( _p_filter ),
+ p_connected_pin( NULL ), media_types(mt), media_type_count(mt_count),
+ i_ref( 1 )
{
cx_media_type.majortype = mt[0].majortype;
cx_media_type.subtype = GUID_NULL;
cx_media_type.pbFormat = NULL;
+ cx_media_type.cbFormat = 0;
cx_media_type.pUnk = NULL;
}
msg_Dbg( p_input, "CapturePin::CustomGetSample" );
#endif
- access_sys_t *p_sys = p_input->p_sys;
vlc_mutex_lock( &p_sys->lock );
if( samples_queue.size() )
{
/* IUnknown methods */
STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv)
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CapturePin::QueryInterface" );
#endif
}
else
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CapturePin::QueryInterface() failed for: "
"%04X-%02X-%02X-%02X%02X%02X%02X%02X%02X%02X%02X",
(int)riid.Data1, (int)riid.Data2, (int)riid.Data3,
STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
const AM_MEDIA_TYPE *pmt )
{
- if( State_Running != p_filter->state )
+ if( State_Running == p_filter->state )
{
- if( ! p_connected_pin )
- {
- if( ! pmt )
- return S_OK;
+ msg_Dbg( p_input, "CapturePin::Connect [not stopped]" );
+ return VFW_E_NOT_STOPPED;
+ }
+
+ if( p_connected_pin )
+ {
+ msg_Dbg( p_input, "CapturePin::Connect [already connected]" );
+ return VFW_E_ALREADY_CONNECTED;
+ }
+
+ if( !pmt ) return S_OK;
- if( (GUID_NULL != pmt->majortype) && (media_types[0].majortype != pmt->majortype) )
- msg_Dbg( p_input, "CapturePin::Connect [media major type mismatch]" );
- return S_FALSE;
-
- if( (GUID_NULL != pmt->subtype) && (! GetFourCCFromMediaType(*pmt)) )
- msg_Dbg( p_input, "CapturePin::Connect [media subtype type not supported]" );
- return S_FALSE;
-
- if( pmt->pbFormat )
- {
- if( pmt->majortype == MEDIATYPE_Video )
- {
- if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) )
- {
- msg_Dbg( p_input, "CapturePin::Connect [video height == 0]" );
- return S_FALSE;
- }
- if( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0) )
- {
- msg_Dbg( p_input, "CapturePin::Connect [video width == 0]" );
- return S_FALSE;
- }
- }
- }
- msg_Dbg( p_input, "CapturePin::Connect [OK]" );
- return S_OK;
+ if( GUID_NULL != pmt->majortype &&
+ media_types[0].majortype != pmt->majortype )
+ {
+ msg_Dbg( p_input, "CapturePin::Connect [media major type mismatch]" );
+ return S_FALSE;
+ }
+
+ if( GUID_NULL != pmt->subtype && !GetFourCCFromMediaType(*pmt) )
+ {
+ msg_Dbg( p_input, "CapturePin::Connect [media subtype type "
+ "not supported]" );
+ return S_FALSE;
+ }
+
+ if( pmt->pbFormat && pmt->majortype == MEDIATYPE_Video )
+ {
+ if( !((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight ||
+ !((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth )
+ {
+ msg_Dbg( p_input, "CapturePin::Connect "
+ "[video width/height == 0 ]" );
+ return S_FALSE;
}
- msg_Dbg( p_input, "CapturePin::Connect [already connected]" );
- return VFW_E_ALREADY_CONNECTED;
}
- msg_Dbg( p_input, "CapturePin::Connect [not stopped]" );
- return VFW_E_NOT_STOPPED;
+
+ msg_Dbg( p_input, "CapturePin::Connect [OK]" );
+ return S_OK;
}
STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
const AM_MEDIA_TYPE *pmt )
{
if( State_Stopped != p_filter->state )
{
- msg_Dbg( p_input, "CapturePin::ReceiveConnection [not stopped]" );
+ msg_Dbg( p_input, "CapturePin::ReceiveConnection [not stopped]" );
return VFW_E_NOT_STOPPED;
}
if( !pConnector || !pmt )
{
- msg_Dbg( p_input, "CapturePin::ReceiveConnection [null pointer]" );
+ msg_Dbg( p_input, "CapturePin::ReceiveConnection [null pointer]" );
return E_POINTER;
}
if( p_connected_pin )
{
- msg_Dbg( p_input, "CapturePin::ReceiveConnection [already connected]" );
+ msg_Dbg( p_input, "CapturePin::ReceiveConnection [already connected]");
return VFW_E_ALREADY_CONNECTED;
}
if( S_OK != QueryAccept(pmt) )
{
- msg_Dbg( p_input, "CapturePin::ReceiveConnection [media type not accepted]" );
+ msg_Dbg( p_input, "CapturePin::ReceiveConnection "
+ "[media type not accepted]" );
return VFW_E_TYPE_NOT_ACCEPTED;
}
{
if( ! p_connected_pin )
{
- msg_Dbg( p_input, "CapturePin::Disconnect [not connected]" );
- return S_FALSE;
+ msg_Dbg( p_input, "CapturePin::Disconnect [not connected]" );
+ return S_FALSE;
}
msg_Dbg( p_input, "CapturePin::Disconnect [OK]" );
-#if 0 // FIXME: This does seem to create crashes sometimes
- VLCMediaSample vlc_sample;
- access_sys_t *p_sys = p_input->p_sys;
-
- vlc_mutex_lock( &p_sys->lock );
- while( samples_queue.size() )
- {
- vlc_sample = samples_queue.back();
- samples_queue.pop_back();
- vlc_sample.p_sample->Release();
- }
- vlc_mutex_unlock( &p_sys->lock );
-#endif
+ /* samples_queue was already flushed in EndFlush() */
p_connected_pin->Release();
p_connected_pin = NULL;
- FreeMediaType( cx_media_type );
+ //FreeMediaType( cx_media_type );
+ //cx_media_type.subtype = GUID_NULL;
return S_OK;
}
{
if( !p_connected_pin )
{
- msg_Dbg( p_input, "CapturePin::ConnectedTo [not connected]" );
- return VFW_E_NOT_CONNECTED;
+ msg_Dbg( p_input, "CapturePin::ConnectedTo [not connected]" );
+ return VFW_E_NOT_CONNECTED;
}
p_connected_pin->AddRef();
{
if( !p_connected_pin )
{
- msg_Dbg( p_input, "CapturePin::ConnectionMediaType [not connected]" );
- return VFW_E_NOT_CONNECTED;
+ msg_Dbg( p_input, "CapturePin::ConnectionMediaType [not connected]" );
+ return VFW_E_NOT_CONNECTED;
}
return CopyMediaType( pmt, &cx_media_type );
}
STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt )
{
- if( State_Stopped == p_filter->state )
+ if( State_Stopped != p_filter->state )
+ {
+ msg_Dbg( p_input, "CapturePin::QueryAccept [not stopped]" );
+ return S_FALSE;
+ }
+
+ if( media_types[0].majortype != pmt->majortype )
+ {
+ msg_Dbg( p_input, "CapturePin::QueryAccept [media type mismatch]" );
+ return S_FALSE;
+ }
+
+ int i_fourcc = GetFourCCFromMediaType(*pmt);
+ if( !i_fourcc )
+ {
+ msg_Dbg( p_input, "CapturePin::QueryAccept "
+ "[media type not supported]" );
+ return S_FALSE;
+ }
+
+ if( pmt->majortype == MEDIATYPE_Video )
{
- if( media_types[0].majortype == pmt->majortype )
+ if( pmt->pbFormat &&
+ ( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) ||
+ (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0) ) )
{
- int i_chroma = GetFourCCFromMediaType(*pmt);
- if( 0 != i_chroma )
- {
- if( pmt->majortype == MEDIATYPE_Video )
- {
- if( pmt->pbFormat &&
- ((((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) ||
- (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0)) )
- {
- msg_Dbg( p_input, "CapturePin::QueryAccept [video size wxh == 0]" );
- 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 )
- {
- FreeMediaType( cx_media_type );
- CopyMediaType( &cx_media_type, pmt );
- }
- return S_OK;
- }
- else {
- msg_Dbg( p_input, "CapturePin::QueryAccept [media type not supported]" );
- }
+ msg_Dbg( p_input, "CapturePin::QueryAccept [video size wxh == 0]");
+ return S_FALSE;
}
- else {
- msg_Dbg( p_input, "CapturePin::QueryAccept [media type mismatch]" );
- }
+
+ 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_fourcc );
+ }
+ else if( pmt->majortype == MEDIATYPE_Audio )
+ {
+ 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_fourcc );
+ }
+ else
+ {
+ msg_Dbg( p_input, "CapturePin::QueryAccept [OK] (stream format=%4.4s)",
+ (char *)&i_fourcc );
}
- else {
- msg_Dbg( p_input, "CapturePin::QueryAccept [not stopped]" );
+
+ if( p_connected_pin )
+ {
+ FreeMediaType( cx_media_type );
+ CopyMediaType( &cx_media_type, pmt );
}
- return S_FALSE;
+
+ return S_OK;
}
STDMETHODIMP CapturePin::EnumMediaTypes( IEnumMediaTypes **ppEnum )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CapturePin::EnumMediaTypes" );
#endif
}
STDMETHODIMP CapturePin::QueryInternalConnections( IPin* *apPin, ULONG *nPin )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CapturePin::QueryInternalConnections" );
#endif
return E_NOTIMPL;
#ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CapturePin::EndFlush" );
#endif
+
+ VLCMediaSample vlc_sample;
+
+ vlc_mutex_lock( &p_sys->lock );
+ while( samples_queue.size() )
+ {
+ vlc_sample = samples_queue.back();
+ samples_queue.pop_back();
+ vlc_sample.p_sample->Release();
+ }
+ vlc_mutex_unlock( &p_sys->lock );
+
return S_OK;
}
STDMETHODIMP CapturePin::NewSegment( REFERENCE_TIME tStart,
mtime_t i_timestamp = mdate() * 10;
VLCMediaSample vlc_sample = {pSample, i_timestamp};
- access_sys_t *p_sys = p_input->p_sys;
vlc_mutex_lock( &p_sys->lock );
samples_queue.push_front( vlc_sample );
/****************************************************************************
* Implementation of our dummy directshow filter class
****************************************************************************/
-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 )
+CaptureFilter::CaptureFilter( vlc_object_t *_p_input, access_sys_t *p_sys,
+ AM_MEDIA_TYPE *mt, size_t mt_count )
+ : p_input( _p_input ),
+ p_pin( new CapturePin( _p_input, p_sys, this, mt, mt_count ) ),
+ state( State_Stopped ), i_ref( 1 )
{
}
/* IUnknown methods */
STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureFilter::QueryInterface" );
#endif
}
else
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureFilter::QueryInterface() failed for: "
"%04X-%02X-%02X-%02X%02X%02X%02X%02X%02X%02X%02X",
(int)riid.Data1, (int)riid.Data2, (int)riid.Data3,
msg_Dbg( p_input, "CaptureFilter::Stop" );
#endif
+ p_pin->EndFlush();
+
state = State_Stopped;
return S_OK;
};
* Implementation of our dummy directshow enumpins class
****************************************************************************/
-CaptureEnumPins::CaptureEnumPins( access_t * _p_input,
+CaptureEnumPins::CaptureEnumPins( vlc_object_t *_p_input,
CaptureFilter *_p_filter,
CaptureEnumPins *pEnumPins )
: p_input( _p_input ), p_filter( _p_filter ), i_ref( 1 )
CaptureEnumPins::~CaptureEnumPins()
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumPins::~CaptureEnumPins" );
#endif
p_filter->Release();
/* IUnknown methods */
STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumPins::QueryInterface" );
#endif
STDMETHODIMP CaptureEnumPins::Next( ULONG cPins, IPin ** ppPins,
ULONG * pcFetched )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumPins::Next" );
#endif
};
STDMETHODIMP CaptureEnumPins::Skip( ULONG cPins )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumPins::Skip" );
#endif
};
STDMETHODIMP CaptureEnumPins::Reset()
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumPins::Reset" );
#endif
};
STDMETHODIMP CaptureEnumPins::Clone( IEnumPins **ppEnum )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumPins::Clone" );
#endif
/****************************************************************************
* Implementation of our dummy directshow enummediatypes class
****************************************************************************/
-CaptureEnumMediaTypes::CaptureEnumMediaTypes( access_t * _p_input,
+CaptureEnumMediaTypes::CaptureEnumMediaTypes( vlc_object_t *_p_input,
CapturePin *_p_pin, CaptureEnumMediaTypes *pEnumMediaTypes )
: p_input( _p_input ), p_pin( _p_pin ), i_ref( 1 )
{
/* Are we creating a new enumerator */
if( pEnumMediaTypes == NULL )
{
+ CopyMediaType(&cx_media_type, &p_pin->cx_media_type);
i_position = 0;
}
else
{
+ CopyMediaType(&cx_media_type, &pEnumMediaTypes->cx_media_type);
i_position = pEnumMediaTypes->i_position;
}
}
CaptureEnumMediaTypes::~CaptureEnumMediaTypes()
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumMediaTypes::~CaptureEnumMediaTypes" );
#endif
+ FreeMediaType(cx_media_type);
p_pin->Release();
}
/* IUnknown methods */
STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumMediaTypes::QueryInterface" );
#endif
AM_MEDIA_TYPE ** ppMediaTypes,
ULONG * pcFetched )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumMediaTypes::Next " );
#endif
- ULONG count;
+ ULONG copied = 0;
+ ULONG offset = 0;
+ ULONG max = p_pin->media_type_count;
if( ! ppMediaTypes )
return E_POINTER;
if( (! pcFetched) && (cMediaTypes > 1) )
return E_POINTER;
- count = 0;
+ /*
+ ** use connection media type as first entry in iterator if it exists
+ */
+ copied = 0;
+ if( cx_media_type.subtype != GUID_NULL )
+ {
+ ++max;
+ if( i_position == 0 )
+ {
+ ppMediaTypes[copied] =
+ (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ if( CopyMediaType(ppMediaTypes[copied], &cx_media_type) != S_OK )
+ return E_OUTOFMEMORY;
+ ++i_position;
+ ++copied;
+ }
+ }
- while( (count < cMediaTypes) && (i_position < p_pin->media_type_count) )
+ while( (copied < cMediaTypes) && (i_position < max) )
{
- ppMediaTypes[count] = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- if( CopyMediaType(ppMediaTypes[count], &p_pin->media_types[i_position]) != S_OK )
+ ppMediaTypes[copied] =
+ (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ if( CopyMediaType( ppMediaTypes[copied],
+ &p_pin->media_types[i_position-offset]) != S_OK )
return E_OUTOFMEMORY;
- count++;
- i_position++;
+ ++copied;
+ ++i_position;
}
- if( pcFetched )
- {
- *pcFetched = count;
- }
+ if( pcFetched ) *pcFetched = copied;
- return (count == cMediaTypes) ? S_OK : S_FALSE;
+ return (copied == cMediaTypes) ? S_OK : S_FALSE;
};
STDMETHODIMP CaptureEnumMediaTypes::Skip( ULONG cMediaTypes )
{
-#ifdef DEBUG_DSHOW
+ ULONG max = p_pin->media_type_count;
+ if( cx_media_type.subtype != GUID_NULL )
+ {
+ max = 1;
+ }
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumMediaTypes::Skip" );
#endif
i_position += cMediaTypes;
- return (i_position < p_pin->media_type_count) ? S_OK : S_FALSE;
+ return (i_position < max) ? S_OK : S_FALSE;
};
STDMETHODIMP CaptureEnumMediaTypes::Reset()
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumMediaTypes::Reset" );
#endif
+ FreeMediaType(cx_media_type);
+ CopyMediaType(&cx_media_type, &p_pin->cx_media_type);
i_position = 0;
return S_OK;
};
STDMETHODIMP CaptureEnumMediaTypes::Clone( IEnumMediaTypes **ppEnum )
{
-#ifdef DEBUG_DSHOW
+#ifdef DEBUG_DSHOW_L1
msg_Dbg( p_input, "CaptureEnumMediaTypes::Clone" );
#endif