diff options
author | wm4 <wm4@nowhere> | 2012-08-12 15:30:21 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-16 17:16:33 +0200 |
commit | aebfbbf2bdda8e18beef90c16da97bd335f7d3b0 (patch) | |
tree | a7362bf3ef6f2d80a47b2e539a2ea4efe5e2e079 /loader/dshow | |
parent | c6b03ffef6250096373c4a81a489dae9fbff9087 (diff) |
Remove win32/qt/xanim/real binary codecs loading
Remove the win32 loader - the win32 emulation layer, as well as the
code for using DirectShow/DMO/VFW codecs. Remove loading of xanim,
QuickTime, and RealMedia codecs.
The win32 emulation layer is based on a very old version of wine.
Apparently, wine code was copied and hacked until it was somehow able
to load a limited collection of binary codecs. It poked around in the
code segment of some known binary codecs to disable unsupported win32
API calls to make them work. Example from module.c:
for (i=0;i<5;i++) RVA(0x19e842)[i]=0x90; // make_new_region ?
for (i=0;i<28;i++) RVA(0x19e86d)[i]=0x90; // call__call_CreateCompatibleDC ?
for (i=0;i<5;i++) RVA(0x19e898)[i]=0x90; // jmp_to_call_loadbitmap ?
for (i=0;i<9;i++) RVA(0x19e8ac)[i]=0x90; // call__calls_OLE_shit ?
for (i=0;i<106;i++) RVA(0x261b10)[i]=0x90; // disable threads
Just to show how utterly insane this code is. You wouldn't want even
your worst enemy to have to maintain this. In fact, it seems nobody
made major changes to this code ever since it was committed.
Most formats can be decoded by libavcodecs these days, and the loader
couldn't be used on 64 bit platforms anyway. The same is (probably)
true for the other binary codecs.
General note about how support for win32 codecs could be added back:
It's not possible to replace the win32 loader code by using wine as
library, because modern wine can not be linked with native Linux
programs for certain reasons. It would be possible to to move DirectShow
video decoding into a separate process linked with wine, like the
CoreAVC-for-Linux patches do. There is also the mplayer-ww fork, which
uses the dshownative library to use DirectShow codecs on Windows.
Diffstat (limited to 'loader/dshow')
-rw-r--r-- | loader/dshow/DS_AudioDecoder.c | 192 | ||||
-rw-r--r-- | loader/dshow/DS_AudioDecoder.h | 20 | ||||
-rw-r--r-- | loader/dshow/DS_Filter.c | 318 | ||||
-rw-r--r-- | loader/dshow/DS_Filter.h | 42 | ||||
-rw-r--r-- | loader/dshow/DS_VideoDecoder.c | 916 | ||||
-rw-r--r-- | loader/dshow/DS_VideoDecoder.h | 32 | ||||
-rw-r--r-- | loader/dshow/allocator.c | 363 | ||||
-rw-r--r-- | loader/dshow/allocator.h | 27 | ||||
-rw-r--r-- | loader/dshow/cmediasample.c | 576 | ||||
-rw-r--r-- | loader/dshow/cmediasample.h | 32 | ||||
-rw-r--r-- | loader/dshow/graph.c | 165 | ||||
-rw-r--r-- | loader/dshow/graph.h | 57 | ||||
-rw-r--r-- | loader/dshow/guids.c | 83 | ||||
-rw-r--r-- | loader/dshow/guids.h | 89 | ||||
-rw-r--r-- | loader/dshow/inputpin.c | 1492 | ||||
-rw-r--r-- | loader/dshow/inputpin.h | 70 | ||||
-rw-r--r-- | loader/dshow/interfaces.h | 360 | ||||
-rw-r--r-- | loader/dshow/iunk.h | 54 | ||||
-rw-r--r-- | loader/dshow/libwin32.h | 256 | ||||
-rw-r--r-- | loader/dshow/mediatype.c | 161 | ||||
-rw-r--r-- | loader/dshow/mediatype.h | 96 | ||||
-rw-r--r-- | loader/dshow/outputpin.c | 957 | ||||
-rw-r--r-- | loader/dshow/outputpin.h | 32 |
23 files changed, 0 insertions, 6390 deletions
diff --git a/loader/dshow/DS_AudioDecoder.c b/loader/dshow/DS_AudioDecoder.c deleted file mode 100644 index cfa2fcb5a2..0000000000 --- a/loader/dshow/DS_AudioDecoder.c +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************** - - DirectShow audio decoder - Copyright 2001 Eugene Kuznetsov (divx@euro.ru) - -*********************************************************/ -#include "config.h" - -#include "libwin32.h" - -#include "DS_Filter.h" - -struct DS_AudioDecoder -{ - WAVEFORMATEX in_fmt; - AM_MEDIA_TYPE m_sOurType, m_sDestType; - DS_Filter* m_pDS_Filter; - char* m_sVhdr; - char* m_sVhdr2; -}; - -#include "DS_AudioDecoder.h" -#ifdef WIN32_LOADER -#include "loader/ldt_keeper.h" -#endif - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> - -typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**); - -static SampleProcUserData sampleProcData; - - -DS_AudioDecoder * DS_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* wf) -//DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMATEX* wf) -{ - DS_AudioDecoder *this; - int sz; - WAVEFORMATEX* pWF; - -#ifdef WIN32_LOADER - Setup_LDT_Keeper(); - Setup_FS_Segment(); -#endif - - this = malloc(sizeof(DS_AudioDecoder)); - - sz = 18 + wf->cbSize; - this->m_sVhdr = malloc(sz); - memcpy(this->m_sVhdr, wf, sz); - this->m_sVhdr2 = malloc(18); - memcpy(this->m_sVhdr2, this->m_sVhdr, 18); - - pWF = (WAVEFORMATEX*)this->m_sVhdr2; - pWF->wFormatTag = 1; - pWF->wBitsPerSample = 16; - pWF->nBlockAlign = pWF->nChannels * (pWF->wBitsPerSample + 7) / 8; - pWF->cbSize = 0; - pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec; - - memcpy(&this->in_fmt,wf,sizeof(WAVEFORMATEX)); - - memset(&this->m_sOurType, 0, sizeof(this->m_sOurType)); - this->m_sOurType.majortype=MEDIATYPE_Audio; - this->m_sOurType.subtype=MEDIASUBTYPE_PCM; - this->m_sOurType.subtype.f1=wf->wFormatTag; - this->m_sOurType.formattype=FORMAT_WaveFormatEx; - this->m_sOurType.lSampleSize=wf->nBlockAlign; - this->m_sOurType.bFixedSizeSamples=1; - this->m_sOurType.bTemporalCompression=0; - this->m_sOurType.pUnk=0; - this->m_sOurType.cbFormat=sz; - this->m_sOurType.pbFormat=this->m_sVhdr; - - memset(&this->m_sDestType, 0, sizeof(this->m_sDestType)); - this->m_sDestType.majortype=MEDIATYPE_Audio; - this->m_sDestType.subtype=MEDIASUBTYPE_PCM; -// this->m_sDestType.subtype.f1=pWF->wFormatTag; - this->m_sDestType.formattype=FORMAT_WaveFormatEx; - this->m_sDestType.bFixedSizeSamples=1; - this->m_sDestType.bTemporalCompression=0; - this->m_sDestType.lSampleSize=pWF->nBlockAlign; - if (wf->wFormatTag == 0x130) - // ACEL hack to prevent memory corruption - // obviosly we are missing something here - this->m_sDestType.lSampleSize *= 288; - this->m_sDestType.pUnk=0; - this->m_sDestType.cbFormat=18; //pWF->cbSize; - this->m_sDestType.pbFormat=this->m_sVhdr2; - -//print_wave_header(this->m_sVhdr, MSGL_V); -//print_wave_header(this->m_sVhdr2, MSGL_V); - - /*try*/ - { - this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType,&sampleProcData); - if( !this->m_pDS_Filter ) { - free(this); - return NULL; - } - - //Commit should be done before binary codec start - this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll); - - this->m_pDS_Filter->Start(this->m_pDS_Filter); - - } - /* - catch (FatalError& e) - { - e.PrintAll(); - delete[] m_sVhdr; - delete[] m_sVhdr2; - delete m_pDS_Filter; - throw; - } - */ - return this; -} - -void DS_AudioDecoder_Destroy(DS_AudioDecoder *this) -{ - free(this->m_sVhdr); - free(this->m_sVhdr2); - DS_Filter_Destroy(this->m_pDS_Filter); - free(this); -} - -int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, unsigned int in_size, - void* out_data, unsigned int out_size, - unsigned int* size_read, unsigned int* size_written) -{ - unsigned int written = 0; - unsigned int read = 0; - - if (!in_data || !out_data) - return -1; - -#ifdef WIN32_LOADER - Setup_FS_Segment(); -#endif - - in_size -= in_size%this->in_fmt.nBlockAlign; - while (in_size>0) - { - IMediaSample* sample=0; - char* ptr; - int result; - this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0); - if (!sample) - { - Debug printf("DS_AudioDecoder::Convert() Error: null sample\n"); - break; - } - sample->vt->SetActualDataLength(sample, this->in_fmt.nBlockAlign); - sample->vt->GetPointer(sample, (BYTE **)&ptr); - memcpy(ptr, (const uint8_t*)in_data + read, this->in_fmt.nBlockAlign); - sample->vt->SetSyncPoint(sample, 1); - sample->vt->SetPreroll(sample, 0); - result = this->m_pDS_Filter->m_pImp->vt->Receive(this->m_pDS_Filter->m_pImp, sample); - if (result) - Debug printf("DS_AudioDecoder::Convert() Error: putting data into input pin %x\n", result); - if ((written + sampleProcData.frame_size) > out_size) - { - sample->vt->Release((IUnknown*)sample); - break; - } - memcpy((uint8_t*)out_data + written, sampleProcData.frame_pointer, sampleProcData.frame_size); - sample->vt->Release((IUnknown*)sample); - read+=this->in_fmt.nBlockAlign; - written+=sampleProcData.frame_size; - break; - } - if (size_read) - *size_read = read; - if (size_written) - *size_written = written; - return 0; -} - -int DS_AudioDecoder_GetSrcSize(DS_AudioDecoder *this, int dest_size) -{ - double efficiency =(double) this->in_fmt.nAvgBytesPerSec - / (this->in_fmt.nSamplesPerSec*this->in_fmt.nBlockAlign); - int frames = (int)(dest_size*efficiency); - - if (frames < 1) - frames = 1; - return frames * this->in_fmt.nBlockAlign; -} diff --git a/loader/dshow/DS_AudioDecoder.h b/loader/dshow/DS_AudioDecoder.h deleted file mode 100644 index 157993cda3..0000000000 --- a/loader/dshow/DS_AudioDecoder.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef MPLAYER_DS_AUDIODECODER_H -#define MPLAYER_DS_AUDIODECODER_H - -#include "loader/com.h" -#include "loader/wine/mmreg.h" - -typedef struct DS_AudioDecoder DS_AudioDecoder; - -//DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMATEX* wf); -DS_AudioDecoder * DS_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* wf); - -void DS_AudioDecoder_Destroy(DS_AudioDecoder *this); - -int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, unsigned int in_size, - void* out_data, unsigned int out_size, - unsigned int* size_read, unsigned int* size_written); - -int DS_AudioDecoder_GetSrcSize(DS_AudioDecoder *this, int dest_size); - -#endif /* MPLAYER_DS_AUDIODECODER_H */ diff --git a/loader/dshow/DS_Filter.c b/loader/dshow/DS_Filter.c deleted file mode 100644 index 88f881523a..0000000000 --- a/loader/dshow/DS_Filter.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Modified for use with MPlayer, detailed changelog at - * http://svn.mplayerhq.hu/mplayer/trunk/ - */ - -#include "config.h" -#include "DS_Filter.h" -#include "graph.h" -#include "loader/drv.h" -#include "loader/com.h" -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include "loader/win32.h" // printf macro - -typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**); - -#ifndef WIN32_LOADER -const GUID IID_IUnknown = -{ - 0x00000000, 0x0000, 0x0000, - {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} -}; -const GUID IID_IClassFactory = -{ - 0x00000001, 0x0000, 0x0000, - {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} -}; - -HRESULT STDCALL CoInitialize(LPVOID pvReserved); -void STDCALL CoUninitialize(void); -#endif - -static void DS_Filter_Start(DS_Filter* This) -{ - HRESULT hr; - - //Debug printf("DS_Filter_Start(%p)\n", This); - hr = This->m_pFilter->vt->Run(This->m_pFilter, (REFERENCE_TIME)0); - if (hr != 0) - { - Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr); - } -} - -static void DS_Filter_Stop(DS_Filter* This) -{ - if (This->m_pAll) - { - //Debug printf("DS_Filter_Stop(%p)\n", This); - This->m_pFilter->vt->Stop(This->m_pFilter); // causes weird crash ??? FIXME - This->m_pAll->vt->Release((IUnknown*)This->m_pAll); - This->m_pAll = 0; - } -} - -void DS_Filter_Destroy(DS_Filter* This) -{ - This->Stop(This); - - if (This->m_pOurInput) - This->m_pOurInput->vt->Release((IUnknown*)This->m_pOurInput); - if (This->m_pInputPin) - This->m_pInputPin->vt->Disconnect(This->m_pInputPin); - if (This->m_pOutputPin) - This->m_pOutputPin->vt->Disconnect(This->m_pOutputPin); - if (This->m_pFilter) - This->m_pFilter->vt->Release((IUnknown*)This->m_pFilter); - if (This->m_pOutputPin) - This->m_pOutputPin->vt->Release((IUnknown*)This->m_pOutputPin); - if (This->m_pInputPin) - This->m_pInputPin->vt->Release((IUnknown*)This->m_pInputPin); - if (This->m_pImp) - This->m_pImp->vt->Release((IUnknown*)This->m_pImp); - - if (This->m_pOurOutput) - This->m_pOurOutput->vt->Release((IUnknown*)This->m_pOurOutput); - if (This->m_pParentFilter) - This->m_pParentFilter->vt->Release((IUnknown*)This->m_pParentFilter); - if (This->m_pSrcFilter) - This->m_pSrcFilter->vt->Release((IUnknown*)This->m_pSrcFilter); - - // FIXME - we are still leaving few things allocated! - if (This->m_iHandle) - FreeLibrary((unsigned)This->m_iHandle); - - free(This); - -#ifdef WIN32_LOADER - CodecRelease(); -#else - CoUninitialize(); -#endif -} - -static HRESULT STDCALL DS_Filter_CopySample(void* pUserData,IMediaSample* pSample){ - BYTE* pointer; - int len; - SampleProcUserData* pData=pUserData; - Debug printf("CopySample called(%p,%p)\n",pSample,pUserData); - if (pSample->vt->GetPointer(pSample, &pointer)) - return 1; - len = pSample->vt->GetActualDataLength(pSample); - if (len == 0) - len = pSample->vt->GetSize(pSample);//for iv50 - - pData->frame_pointer = pointer; - pData->frame_size = len; -/* - FILE* file=fopen("./uncompr.bmp", "wb"); - char head[14]={0x42, 0x4D, 0x36, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00}; - *(int*)(&head[2])=len+0x36; - fwrite(head, 14, 1, file); - fwrite(&((VIDEOINFOHEADER*)me.type.pbFormat)->bmiHeader, sizeof(BITMAPINFOHEADER), 1, file); - fwrite(pointer, len, 1, file); - fclose(file); -*/ - return 0; -} - -DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, - AM_MEDIA_TYPE* in_fmt, - AM_MEDIA_TYPE* out_fmt,SampleProcUserData* pUserData) -{ - int init = 0; -// char eb[250]; - const char* em = NULL; - MemAllocator* tempAll; - FilterGraph* graph; - ALLOCATOR_PROPERTIES props,props1; - DS_Filter* This = malloc(sizeof(DS_Filter)); - if (!This) - return NULL; - -#ifdef WIN32_LOADER - CodecAlloc(); -#else - CoInitialize(0L); -#endif - - /* - tempAll is not used anywhere. - MemAllocatorCreate() is called to ensure that RegisterComObject for IMemoryAllocator - will be called before possible call - to CoCreateInstance(...,&IID_IMemoryAllocator,...) from binary codec. - */ - tempAll=MemAllocatorCreate(); - This->m_pFilter = NULL; - This->m_pInputPin = NULL; - This->m_pOutputPin = NULL; - This->m_pSrcFilter = NULL; - This->m_pParentFilter = NULL; - This->m_pOurInput = NULL; - This->m_pOurOutput = NULL; - This->m_pAll = NULL; - This->m_pImp = NULL; - - This->Start = DS_Filter_Start; - This->Stop = DS_Filter_Stop; - - for (;;) - { - GETCLASS func; - struct IClassFactory* factory = NULL; - struct IUnknown* object = NULL; - IEnumPins* enum_pins = 0; - IPin* array[256]; - ULONG fetched; - HRESULT result; - unsigned int i; - static const uint16_t filter_name[] = { 'F', 'i', 'l', 't', 'e', 'r', 0 }; - - This->m_iHandle = LoadLibraryA(dllname); - if (!This->m_iHandle) - { - em = "could not open DirectShow DLL"; - break; - } - func = (GETCLASS)GetProcAddress((unsigned)This->m_iHandle, "DllGetClassObject"); - if (!func) - { - em = "illegal or corrupt DirectShow DLL"; - break; - } - result = func(id, &IID_IClassFactory, (void*)&factory); - if (result || !factory) - { - em = "no such class object"; - break; - } - result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void*)&object); - factory->vt->Release((IUnknown*)factory); - if (result || !object) - { - em = "class factory failure"; - break; - } - result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void*)&This->m_pFilter); - object->vt->Release((IUnknown*)object); - if (result || !This->m_pFilter) - { - em = "object does not provide IBaseFilter interface"; - break; - } - - graph = FilterGraphCreate(); - result = This->m_pFilter->vt->JoinFilterGraph(This->m_pFilter, (IFilterGraph*)graph, filter_name); - - // enumerate pins - result = This->m_pFilter->vt->EnumPins(This->m_pFilter, &enum_pins); - if (result || !enum_pins) - { - em = "could not enumerate pins"; - break; - } - - enum_pins->vt->Reset(enum_pins); - result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched); - enum_pins->vt->Release((IUnknown*)enum_pins); - Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result); - - for (i = 0; i < fetched; i++) - { - PIN_DIRECTION direction = -1; - array[i]->vt->QueryDirection(array[i], &direction); - if (!This->m_pInputPin && direction == PINDIR_INPUT) - { - This->m_pInputPin = array[i]; - This->m_pInputPin->vt->AddRef((IUnknown*)This->m_pInputPin); - } - if (!This->m_pOutputPin && direction == PINDIR_OUTPUT) - { - This->m_pOutputPin = array[i]; - This->m_pOutputPin->vt->AddRef((IUnknown*)This->m_pOutputPin); - } - array[i]->vt->Release((IUnknown*)(array[i])); - } - if (!This->m_pInputPin) - { - em = "could not find input pin"; - break; - } - if (!This->m_pOutputPin) - { - em = "could not find output pin"; - break; - } - result = This->m_pInputPin->vt->QueryInterface((IUnknown*)This->m_pInputPin, - &IID_IMemInputPin, - (void*)&This->m_pImp); - if (result) - { - em = "could not get IMemInputPin interface"; - break; - } - - This->m_pOurType = in_fmt; - This->m_pDestType = out_fmt; - result = This->m_pInputPin->vt->QueryAccept(This->m_pInputPin, This->m_pOurType); - if (result) - { - em = "source format is not accepted"; - break; - } - This->m_pParentFilter = CBaseFilter2Create(); - This->m_pSrcFilter = CBaseFilterCreate(This->m_pOurType, This->m_pParentFilter); - This->m_pOurInput = This->m_pSrcFilter->GetPin(This->m_pSrcFilter); - This->m_pOurInput->vt->AddRef((IUnknown*)This->m_pOurInput); - - result = This->m_pInputPin->vt->ReceiveConnection(This->m_pInputPin, - This->m_pOurInput, - This->m_pOurType); - if (result) - { - em = "could not connect to input pin"; - break; - } - result = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll); - if (result || !This->m_pAll) - { - em="error getting IMemAllocator interface"; - break; - } - - //Seting allocator property according to our media type - props.cBuffers=1; - props.cbBuffer=This->m_pOurType->lSampleSize; - props.cbAlign=1; - props.cbPrefix=0; - This->m_pAll->vt->SetProperties(This->m_pAll, &props, &props1); - - //Notify remote pin about choosed allocator - This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0); - - This->m_pOurOutput = COutputPinCreate(This->m_pDestType,DS_Filter_CopySample,pUserData); - - result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin, - (IPin*) This->m_pOurOutput, - This->m_pDestType); - if (result) - { - em = "could not connect to output pin"; - break; - } - - init++; - break; - } - tempAll->vt->Release((IUnknown*)tempAll); - - if (!init) - { - DS_Filter_Destroy(This); - printf("Warning: DS_Filter() %s. (DLL=%.200s)\n", em, dllname); - This = 0; - } - return This; -} diff --git a/loader/dshow/DS_Filter.h b/loader/dshow/DS_Filter.h deleted file mode 100644 index 945321a153..0000000000 --- a/loader/dshow/DS_Filter.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef MPLAYER_DS_FILTER_H -#define MPLAYER_DS_FILTER_H - -#include "inputpin.h" -#include "outputpin.h" - -typedef struct { - char* frame_pointer; - long frame_size; -} SampleProcUserData; - -/** - User will allocate and fill format structures, call Create(), - and then set up m_pAll. - **/ - -typedef struct DS_Filter DS_Filter; -struct DS_Filter -{ - int m_iHandle; - IBaseFilter* m_pFilter; - IPin* m_pInputPin; - IPin* m_pOutputPin; - - CBaseFilter* m_pSrcFilter; - CBaseFilter2* m_pParentFilter; - IPin* m_pOurInput; - COutputPin* m_pOurOutput; - - AM_MEDIA_TYPE *m_pOurType, *m_pDestType; - IMemAllocator* m_pAll; - IMemInputPin* m_pImp; - - void ( *Start )(DS_Filter*); - void ( *Stop )(DS_Filter*); -}; - -DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, - AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt,SampleProcUserData* pUserData); -void DS_Filter_Destroy(DS_Filter* This); - -#endif /* MPLAYER_DS_FILTER_H */ diff --git a/loader/dshow/DS_VideoDecoder.c b/loader/dshow/DS_VideoDecoder.c deleted file mode 100644 index c8cc988b61..0000000000 --- a/loader/dshow/DS_VideoDecoder.c +++ /dev/null @@ -1,916 +0,0 @@ -/******************************************************** - - DirectShow Video decoder implementation - Copyright 2000 Eugene Kuznetsov (divx@euro.ru) - -*********************************************************/ -#include "config.h" -#include "guids.h" -#include "interfaces.h" -#include "loader/registry.h" -#include "libwin32.h" -#include "DS_Filter.h" - -struct DS_VideoDecoder -{ - IVideoDecoder iv; - - DS_Filter* m_pDS_Filter; - AM_MEDIA_TYPE m_sOurType, m_sDestType; - VIDEOINFOHEADER* m_sVhdr; - VIDEOINFOHEADER* m_sVhdr2; - int m_Caps;//CAPS m_Caps; // capabilities of DirectShow decoder - int m_iLastQuality; // remember last quality as integer - int m_iMinBuffers; - int m_iMaxAuto; - int m_bIsDivX; // for speed - int m_bIsDivX4; // for speed -}; -static SampleProcUserData sampleProcData; - -#include "DS_VideoDecoder.h" - -#include "loader/wine/winerror.h" -#ifdef WIN32_LOADER -#include "loader/ldt_keeper.h" -#endif - -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/types.h> -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#endif -#include <stdio.h> -#include <stdlib.h> // labs - -// strcmp((const char*)info.dll,...) is used instead of (... == ...) -// so Arpi could use char* pointer in his simplified DS_VideoDecoder class - -#define false 0 -#define true 1 - -int DS_VideoDecoder_GetCapabilities(DS_VideoDecoder *this) -{return this->m_Caps;} - -typedef struct ct ct; - -struct ct { - unsigned int bits; - fourcc_t fcc; - const GUID *subtype; - int cap; - }; - -static ct check[] = { - {16, fccYUY2, &MEDIASUBTYPE_YUY2, CAP_YUY2}, - {12, fccIYUV, &MEDIASUBTYPE_IYUV, CAP_IYUV}, - {16, fccUYVY, &MEDIASUBTYPE_UYVY, CAP_UYVY}, - {12, fccYV12, &MEDIASUBTYPE_YV12, CAP_YV12}, - //{16, fccYV12, &MEDIASUBTYPE_YV12, CAP_YV12}, - {16, fccYVYU, &MEDIASUBTYPE_YVYU, CAP_YVYU}, - {12, fccI420, &MEDIASUBTYPE_I420, CAP_I420}, - {9, fccYVU9, &MEDIASUBTYPE_YVU9, CAP_YVU9}, - {0, 0, 0, 0}, - }; - - -DS_VideoDecoder * DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto) -{ - DS_VideoDecoder *this; - HRESULT result; - ct* c; - - this = malloc(sizeof(DS_VideoDecoder)); - memset( this, 0, sizeof(DS_VideoDecoder)); - - this->m_sVhdr2 = 0; - this->m_iLastQuality = -1; - this->m_iMaxAuto = maxauto; - -#ifdef WIN32_LOADER - Setup_LDT_Keeper(); -#endif - - //memset(&m_obh, 0, sizeof(m_obh)); - //m_obh.biSize = sizeof(m_obh); - /*try*/ - { - unsigned int bihs; - - bihs = (format->biSize < (int) sizeof(BITMAPINFOHEADER)) ? - sizeof(BITMAPINFOHEADER) : format->biSize; - - this->iv.m_bh = malloc(bihs); - memcpy(this->iv.m_bh, format, bihs); - this->iv.m_bh->biSize = bihs; - - this->iv.m_State = STOP; - //this->iv.m_pFrame = 0; - this->iv.m_Mode = DIRECT; - this->iv.m_iDecpos = 0; - this->iv.m_iPlaypos = -1; - this->iv.m_fQuality = 0.0f; - this->iv.m_bCapable16b = true; - - bihs += sizeof(VIDEOINFOHEADER) - sizeof(BITMAPINFOHEADER); - this->m_sVhdr = malloc(bihs); - memset(this->m_sVhdr, 0, bihs); - memcpy(&this->m_sVhdr->bmiHeader, this->iv.m_bh, this->iv.m_bh->biSize); - this->m_sVhdr->rcSource.left = this->m_sVhdr->rcSource.top = 0; - this->m_sVhdr->rcSource.right = this->m_sVhdr->bmiHeader.biWidth; - this->m_sVhdr->rcSource.bottom = this->m_sVhdr->bmiHeader.biHeight; - //this->m_sVhdr->rcSource.right = 0; - //this->m_sVhdr->rcSource.bottom = 0; - this->m_sVhdr->rcTarget = this->m_sVhdr->rcSource; - - this->m_sOurType.majortype = MEDIATYPE_Video; - this->m_sOurType.subtype = MEDIATYPE_Video; - this->m_sOurType.subtype.f1 = this->m_sVhdr->bmiHeader.biCompression; - this->m_sOurType.formattype = FORMAT_VideoInfo; - this->m_sOurType.bFixedSizeSamples = false; - this->m_sOurType.bTemporalCompression = true; - this->m_sOurType.pUnk = 0; - this->m_sOurType.cbFormat = bihs; - this->m_sOurType.pbFormat = (char*)this->m_sVhdr; - - this->m_sVhdr2 = malloc(sizeof(VIDEOINFOHEADER)+12); - memcpy(this->m_sVhdr2, this->m_sVhdr, sizeof(VIDEOINFOHEADER)); - memset((char*)this->m_sVhdr2 + sizeof(VIDEOINFOHEADER), 0, 12); - this->m_sVhdr2->bmiHeader.biCompression = 0; - this->m_sVhdr2->bmiHeader.biBitCount = 24; - - memset(&this->m_sDestType, 0, sizeof(this->m_sDestType)); - this->m_sDestType.majortype = MEDIATYPE_Video; - this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; - this->m_sDestType.formattype = FORMAT_VideoInfo; - this->m_sDestType.bFixedSizeSamples = true; - this->m_sDestType.bTemporalCompression = false; - this->m_sDestType.lSampleSize = labs(this->m_sVhdr2->bmiHeader.biWidth*this->m_sVhdr2->bmiHeader.biHeight - * ((this->m_sVhdr2->bmiHeader.biBitCount + 7) / 8)); - this->m_sVhdr2->bmiHeader.biSizeImage = this->m_sDestType.lSampleSize; - this->m_sDestType.pUnk = 0; - this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); - this->m_sDestType.pbFormat = (char*)this->m_sVhdr2; - - memset(&this->iv.m_obh, 0, sizeof(this->iv.m_obh)); - memcpy(&this->iv.m_obh, this->iv.m_bh, sizeof(this->iv.m_obh) < (unsigned) this->iv.m_bh->biSize - ? sizeof(this->iv.m_obh) : (unsigned) this->iv.m_bh->biSize); - this->iv.m_obh.biBitCount=24; - this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); - this->iv.m_obh.biCompression = 0; //BI_RGB - //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); - this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) - * ((this->iv.m_obh.biBitCount + 7) / 8); - - - this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType,&sampleProcData); - - if (!this->m_pDS_Filter) - { - printf("Failed to create DirectShow filter\n"); - return 0; - } - - if (!flip) - { - this->iv.m_obh.biHeight *= -1; - this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; - result = this->m_pDS_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDS_Filter->m_pOutputPin, &this->m_sDestType); - if (result) - { - printf("Decoder does not support upside-down RGB frames\n"); - this->iv.m_obh.biHeight *= -1; - this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; - } - } - - memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh) ); - - switch (this->iv.m_bh->biCompression) - { -#if 0 - case fccDIV3: - case fccDIV4: - case fccDIV5: - case fccDIV6: - case fccMP42: - case fccWMV2: - //YV12 seems to be broken for DivX :-) codec -// case fccIV50: - //produces incorrect picture - //m_Caps = (CAPS) (m_Caps & ~CAP_YV12); - //m_Caps = CAP_UYVY;//CAP_YUY2; // | CAP_I420; - //m_Caps = CAP_I420; - this->m_Caps = (CAP_YUY2 | CAP_UYVY); - break; -#endif - default: - - this->m_Caps = CAP_NONE; - - printf("Decoder supports the following YUV formats: "); - for (c = check; c->bits; c++) - { - this->m_sVhdr2->bmiHeader.biBitCount = c->bits; - this->m_sVhdr2->bmiHeader.biCompression = c->fcc; - this->m_sDestType.subtype = *c->subtype; - result = this->m_pDS_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDS_Filter->m_pOutputPin, &this->m_sDestType); - if (!result) - { - this->m_Caps = (this->m_Caps | c->cap); - printf("%.4s ", (char *)&c->fcc); - } - } - printf("\n"); - } - - if (this->m_Caps != CAP_NONE) - printf("Decoder is capable of YUV output (flags 0x%x)\n", (int)this->m_Caps); - - this->m_sVhdr2->bmiHeader.biBitCount = 24; - this->m_sVhdr2->bmiHeader.biCompression = 0; - this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; - - this->m_iMinBuffers = this->iv.VBUFSIZE; - this->m_bIsDivX = (strcmp(dllname, "divxcvki.ax") == 0 - || strcmp(dllname, "divx_c32.ax") == 0 - || strcmp(dllname, "wmvds32.ax") == 0 - || strcmp(dllname, "wmv8ds32.ax") == 0); - this->m_bIsDivX4 = (strcmp(dllname, "divxdec.ax") == 0); - if (this->m_bIsDivX) - this->iv.VBUFSIZE += 7; - else if (this->m_bIsDivX4) - this->iv.VBUFSIZE += 9; - } - /*catch (FatalError& error) - { - delete[] m_sVhdr; - delete[] m_sVhdr2; - delete m_pDS_Filter; - throw; - }*/ - return this; -} - -void DS_VideoDecoder_Destroy(DS_VideoDecoder *this) -{ - DS_VideoDecoder_StopInternal(this); - this->iv.m_State = STOP; - free(this->m_sVhdr); - free(this->m_sVhdr2); - DS_Filter_Destroy(this->m_pDS_Filter); -} - -void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this) -{ - Debug printf("DS_VideoDecoder_StartInternal\n"); - //cout << "DSSTART" << endl; - this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll); - this->m_pDS_Filter->Start(this->m_pDS_Filter); - - this->iv.m_State = START; -} - -void DS_VideoDecoder_StopInternal(DS_VideoDecoder *this) -{ - this->m_pDS_Filter->Stop(this->m_pDS_Filter); - //??? why was this here ??? m_pOurOutput->SetFramePointer(0); -} - -int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, char* pImage) -{ - IMediaSample* sample = 0; - char* ptr; - int result; - - Debug printf("DS_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,pImage); - - this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0); - - if (!sample) - { - Debug printf("ERROR: null sample\n"); - return -1; - } - - //cout << "DECODE " << (void*) pImage << " d: " << (void*) pImage->Data() << endl; - - - sample->vt->SetActualDataLength(sample, size); - sample->vt->GetPointer(sample, (BYTE **)&ptr); - memcpy(ptr, src, size); - sample->vt->SetSyncPoint(sample, is_keyframe); - sample->vt->SetPreroll(sample, pImage ? 0 : 1); - // sample->vt->SetMediaType(sample, &m_sOurType); - - // FIXME: - crashing with YV12 at this place decoder will crash - // while doing this call - // %FS register was not setup for calling into win32 dll. Are all - // crashes inside ...->Receive() fixed now? - // - // nope - but this is surely helpfull - I'll try some more experiments -#ifdef WIN32_LOADER - Setup_FS_Segment(); -#endif -#if 0 - if (!this->m_pDS_Filter || !this->m_pDS_Filter->m_pImp - || !this->m_pDS_Filter->m_pImp->vt - || !this->m_pDS_Filter->m_pImp->vt->Receive) - printf("DecodeInternal ERROR???\n"); -#endif - result = this->m_pDS_Filter->m_pImp->vt->Receive(this->m_pDS_Filter->m_pImp, sample); - if (result) - { - Debug printf("DS_VideoDecoder::DecodeInternal() error putting data into input pin %x\n", result); - } - if (pImage) - { - memcpy(pImage, sampleProcData.frame_pointer, sampleProcData.frame_size); - } - sample->vt->Release((IUnknown*)sample); - -#if 0 - if (this->m_bIsDivX) - { - int q; - IHidden* hidden=(IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8); - // always check for actual value - // this seems to be the only way to know the actual value - hidden->vt->GetSmth2(hidden, &this->m_iLastQuality); - if (this->m_iLastQuality > 9) - this->m_iLastQuality -= 10; - - if (this->m_iLastQuality < 0) - this->m_iLastQuality = 0; - else if (this->m_iLastQuality > this->m_iMaxAuto) - this->m_iLastQuality = this->m_iMaxAuto; - - //cout << " Qual: " << this->m_iLastQuality << endl; - this->iv.m_fQuality = this->m_iLastQuality / 4.0; - } - else if (this->m_bIsDivX4) - { - - // maybe access methods directly to safe some cpu cycles... - DS_VideoDecoder_GetValue(this, "Postprocessing", this->m_iLastQuality); - if (this->m_iLastQuality < 0) - this->m_iLastQuality = 0; - else if (this->m_iLastQuality > this->m_iMaxAuto) - this->m_iLastQuality = this->m_iMaxAuto; - - //cout << " Qual: " << m_iLastQuality << endl; - this->iv.m_fQuality = this->m_iLastQuality / 6.0; - } - - if (this->iv.m_Mode == -1 ) // ???BUFFERED_QUALITY_AUTO) - { - // adjust Quality - depends on how many cached frames we have - int buffered = this->iv.m_iDecpos - this->iv.m_iPlaypos; - - if (this->m_bIsDivX || this->m_bIsDivX4) - { - int to = buffered - this->m_iMinBuffers; - if (to < 0) - to = 0; - if (to != this->m_iLastQuality) - { - if (to > this->m_iMaxAuto) - to = this->m_iMaxAuto; - if (this->m_iLastQuality != to) - { - if (this->m_bIsDivX) - { - IHidden* hidden=(IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8); - hidden->vt->SetSmth(hidden, to, 0); - } - else - DS_VideoDecoder_SetValue(this, "Postprocessing", to); -#ifndef QUIET - //printf("Switching quality %d -> %d b:%d\n",m_iLastQuality, to, buffered); -#endif - } - } - } - } -#endif - - return 0; -} - -/* - * bits == 0 - leave unchanged - */ -//int SetDestFmt(DS_VideoDecoder * this, int bits = 24, fourcc_t csp = 0); -int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, unsigned int csp) -{ - HRESULT result; - ALLOCATOR_PROPERTIES props,props1; - int should_test=1; - int stopped = 0; - - Debug printf("DS_VideoDecoder_SetDestFmt (%p, %d, %d)\n",this,bits,(int)csp); - - /* if (!CImage::Supported(csp, bits)) - return -1; -*/ - // BitmapInfo temp = m_obh; - - if (!csp) // RGB - { - int ok = true; - - switch (bits) - { - case 15: - this->m_sDestType.subtype = MEDIASUBTYPE_RGB555; - break; - case 16: - this->m_sDestType.subtype = MEDIASUBTYPE_RGB565; - break; - case 24: - this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; - break; - case 32: - this->m_sDestType.subtype = MEDIASUBTYPE_RGB32; - break; - default: - ok = false; - break; - } - - if (ok) { - if (bits == 15) - this->iv.m_obh.biBitCount=16; - else - this->iv.m_obh.biBitCount=bits; - if( bits == 15 || bits == 16 ) { - this->iv.m_obh.biSize=sizeof(BITMAPINFOHEADER)+12; - this->iv.m_obh.biCompression=3;//BI_BITFIELDS - this->iv.m_obh.biSizeImage=abs((int)(2*this->iv.m_obh.biWidth*this->iv.m_obh.biHeight)); - } - - if( bits == 16 ) { - this->iv.m_obh.colors[0]=0xF800; - this->iv.m_obh.colors[1]=0x07E0; - this->iv.m_obh.colors[2]=0x001F; - } else if ( bits == 15 ) { - this->iv.m_obh.colors[0]=0x7C00; - this->iv.m_obh.colors[1]=0x03E0; - this->iv.m_obh.colors[2]=0x001F; - } else { - this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); - this->iv.m_obh.biCompression = 0; //BI_RGB - //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); - this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) - * ((this->iv.m_obh.biBitCount + 7) / 8); - } - } - //.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8)); - } else - { // YUV - int ok = true; - switch (csp) - { - case fccYUY2: - this->m_sDestType.subtype = MEDIASUBTYPE_YUY2; - break; - case fccYV12: - this->m_sDestType.subtype = MEDIASUBTYPE_YV12; - break; - case fccIYUV: - this->m_sDestType.subtype = MEDIASUBTYPE_IYUV; - break; - case fccI420: - this->m_sDestType.subtype = MEDIASUBTYPE_I420; - break; - case fccUYVY: - this->m_sDestType.subtype = MEDIASUBTYPE_UYVY; - break; - case fccYVYU: - this->m_sDestType.subtype = MEDIASUBTYPE_YVYU; - break; - case fccYVU9: - this->m_sDestType.subtype = MEDIASUBTYPE_YVU9; - default: - ok = false; - break; - } - - if (ok) { - if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0) - this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0 - this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); - this->iv.m_obh.biCompression=csp; - this->iv.m_obh.biBitCount=bits; - this->iv.m_obh.biSizeImage=labs(this->iv.m_obh.biBitCount* - this->iv.m_obh.biWidth*this->iv.m_obh.biHeight)>>3; - } - } - this->m_sDestType.lSampleSize = this->iv.m_obh.biSizeImage; - memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_obh, sizeof(this->iv.m_obh)); - this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - if (this->m_sVhdr2->bmiHeader.biCompression == 3) - this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; - else - this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); - - - switch(csp) - { - case fccYUY2: - if(!(this->m_Caps & CAP_YUY2)) - should_test=false; - break; - case fccYV12: - if(!(this->m_Caps & CAP_YV12)) - should_test=false; - break; - case fccIYUV: - if(!(this->m_Caps & CAP_IYUV)) - should_test=false; - break; - case fccI420: - if(!(this->m_Caps & CAP_I420)) - should_test=false; - break; - case fccUYVY: - if(!(this->m_Caps & CAP_UYVY)) - should_test=false; - break; - case fccYVYU: - if(!(this->m_Caps & CAP_YVYU)) - should_test=false; - break; - case fccYVU9: - if(!(this->m_Caps & CAP_YVU9)) - should_test=false; - break; - } - if(should_test) - result = this->m_pDS_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDS_Filter->m_pOutputPin, &this->m_sDestType); - else - result = -1; - - if (result != 0) - { - if (csp) - printf("Warning: unsupported color space\n"); - else - printf("Warning: unsupported bit depth\n"); - - this->m_sDestType.lSampleSize = this->iv.m_decoder.biSizeImage; - memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_decoder, sizeof(this->iv.m_decoder)); - this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - if (this->m_sVhdr2->bmiHeader.biCompression == 3) - this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; - else - this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); - - return -1; - } - - memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh)); - -// m_obh=temp; -// if(csp) -// m_obh.biBitCount=BitmapInfo::BitCount(csp); - this->iv.m_bh->biBitCount = bits; - - //DS_VideoDecoder_Restart(this); - - if (this->iv.m_State == START) - { - DS_VideoDecoder_StopInternal(this); - this->iv.m_State = STOP; - stopped = true; - } - - this->m_pDS_Filter->m_pInputPin->vt->Disconnect(this->m_pDS_Filter->m_pInputPin); - this->m_pDS_Filter->m_pOutputPin->vt->Disconnect(this->m_pDS_Filter->m_pOutputPin); - this->m_pDS_Filter->m_pOurOutput->SetNewFormat(this->m_pDS_Filter->m_pOurOutput,&this->m_sDestType); - result = this->m_pDS_Filter->m_pInputPin->vt->ReceiveConnection(this->m_pDS_Filter->m_pInputPin, - this->m_pDS_Filter->m_pOurInput, - &this->m_sOurType); - if (result) - { - printf("Error reconnecting input pin 0x%x\n", (int)result); - return -1; - } - - if(this->m_pDS_Filter->m_pAll) - this->m_pDS_Filter->m_pAll->vt->Release((IUnknown*)this->m_pDS_Filter->m_pAll); - this->m_pDS_Filter->m_pAll=(IMemAllocator*)MemAllocatorCreate(); - if (!this->m_pDS_Filter->m_pAll) - { - printf("Call to MemAllocatorCreate failed\n"); - return -1; - } - //Seting allocator property according to our media type - props.cBuffers=1; - props.cbBuffer=this->m_sDestType.lSampleSize; - props.cbAlign=1; - props.cbPrefix=0; - this->m_pDS_Filter->m_pAll->vt->SetProperties(this->m_pDS_Filter->m_pAll, &props, &props1); - //Notify remote pin about choosed allocator - this->m_pDS_Filter->m_pImp->vt->NotifyAllocator(this->m_pDS_Filter->m_pImp, this->m_pDS_Filter->m_pAll, 0); - - result = this->m_pDS_Filter->m_pOutputPin->vt->ReceiveConnection(this->m_pDS_Filter->m_pOutputPin, - (IPin *)this->m_pDS_Filter->m_pOurOutput, - &this->m_sDestType); - if (result) - { - printf("Error reconnecting output pin 0x%x\n", (int)result); - return -1; - } - - if (stopped) - { - DS_VideoDecoder_StartInternal(this); - this->iv.m_State = START; - } - - return 0; -} - - -int DS_VideoDecoder_SetDirection(DS_VideoDecoder *this, int d) -{ - this->iv.m_obh.biHeight = (d) ? this->iv.m_bh->biHeight : -this->iv.m_bh->biHeight; - this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; - return 0; -} - -int DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value) -{ -/* - if (m_bIsDivX4) - { - IDivxFilterInterface* pIDivx; - if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_IDivxFilterInterface, (void**)&pIDivx)) - { - Debug printf("No such interface\n"); - return -1; - } - if (strcmp(name, "Postprocessing") == 0) - { - pIDivx->vt->get_PPLevel(pIDivx, &value); - value /= 10; - } - else if (strcmp(name, "Brightness") == 0) - pIDivx->vt->get_Brightness(pIDivx, &value); - else if (strcmp(name, "Contrast") == 0) - pIDivx->vt->get_Contrast(pIDivx, &value); - else if (strcmp(name, "Saturation") == 0) - pIDivx->vt->get_Saturation(pIDivx, &value); - else if (strcmp(name, "MaxAuto") == 0) - value = m_iMaxAuto; - pIDivx->vt->Release((IUnknown*)pIDivx); - return 0; - } - else if (m_bIsDivX) - { - if (m_State != START) - return VFW_E_NOT_RUNNING; -// brightness 87 -// contrast 74 -// hue 23 -// saturation 20 -// post process mode 0 -// get1 0x01 -// get2 10 -// get3=set2 86 -// get4=set3 73 -// get5=set4 19 -// get6=set5 23 - IHidden* hidden=(IHidden*)((int)m_pDS_Filter->m_pFilter+0xb8); - if (strcmp(name, "Quality") == 0) - { - // NOT SURE - int r = hidden->vt->GetSmth2(hidden, &value); - if (value >= 10) - value -= 10; - return 0; - } - if (strcmp(name, "Brightness") == 0) - return hidden->vt->GetSmth3(hidden, &value); - if (strcmp(name, "Contrast") == 0) - return hidden->vt->GetSmth4(hidden, &value); - if (strcmp(name, "Hue") == 0) - return hidden->vt->GetSmth6(hidden, &value); - if (strcmp(name, "Saturation") == 0) - return hidden->vt->GetSmth5(hidden, &value); - if (strcmp(name, "MaxAuto") == 0) - { - value = m_iMaxAuto; - return 0; - } - } - else if (strcmp((const char*)record.dll, "ir50_32.dll") == 0) - { - IHidden2* hidden = 0; - if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_Iv50Hidden, (void**)&hidden)) - { - Debug printf("No such interface\n"); - return -1; - } - // FIXME - int recordpar[30]; - recordpar[0]=0x7c; - recordpar[1]=fccIV50; - recordpar[2]=0x10005; - recordpar[3]=2; - recordpar[4]=1; - recordpar[5]=0x80000000; - - if (strcmp(name, "Brightness") == 0) - recordpar[5]|=0x20; - else if (strcmp(name, "Saturation") == 0) - recordpar[5]|=0x40; - else if (strcmp(name, "Contrast") == 0) - recordpar[5]|=0x80; - if (!recordpar[5]) - { - hidden->vt->Release((IUnknown*)hidden); - return -1; - } - if (hidden->vt->DecodeSet(hidden, recordpar)) - return -1; - - if (strcmp(name, "Brightness") == 0) - value = recordpar[18]; - else if (strcmp(name, "Saturation") == 0) - value = recordpar[19]; - else if (strcmp(name, "Contrast") == 0) - value = recordpar[20]; - - hidden->vt->Release((IUnknown*)hidden); - } -*/ - return 0; -} - -int DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value) -{ - if (this->m_bIsDivX4) { - IDivxFilterInterface* pIDivx=NULL; -// printf("DS_SetValue for DIVX4, name=%s value=%d\n",name,value); - if (this->m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)this->m_pDS_Filter->m_pFilter, &IID_IDivxFilterInterface, (void**)&pIDivx)) - { - printf("No such interface\n"); - return -1; - } - if (strcasecmp(name, "Postprocessing") == 0) - pIDivx->vt->put_PPLevel(pIDivx, value * 10); - else if (strcasecmp(name, "Brightness") == 0) - pIDivx->vt->put_Brightness(pIDivx, value); - else if (strcasecmp(name, "Contrast") == 0) - pIDivx->vt->put_Contrast(pIDivx, value); - else if (strcasecmp(name, "Saturation") == 0) - pIDivx->vt->put_Saturation(pIDivx, value); - else if (strcasecmp(name, "MaxAuto") == 0) - this->m_iMaxAuto = value; - pIDivx->vt->Release((IUnknown*)pIDivx); - //printf("Set %s %d\n", name, value); - return 0; - } - - if (this->m_bIsDivX) { - IHidden* hidden; - if (this->iv.m_State != START) - return VFW_E_NOT_RUNNING; - - //cout << "set value " << name << " " << value << endl; -// brightness 87 -// contrast 74 -// hue 23 -// saturation 20 -// post process mode 0 -// get1 0x01 -// get2 10 -// get3=set2 86 -// get4=set3 73 -// get5=set4 19 - // get6=set5 23 - hidden = (IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8); - //printf("DS_SetValue for DIVX, name=%s value=%d\n",name,value); - if (strcasecmp(name, "Quality") == 0) - { - this->m_iLastQuality = value; - return hidden->vt->SetSmth(hidden, value, 0); - } - if (strcasecmp(name, "Brightness") == 0) - return hidden->vt->SetSmth2(hidden, value, 0); - if (strcasecmp(name, "Contrast") == 0) - return hidden->vt->SetSmth3(hidden, value, 0); - if (strcasecmp(name, "Saturation") == 0) - return hidden->vt->SetSmth4(hidden, value, 0); - if (strcasecmp(name, "Hue") == 0) - return hidden->vt->SetSmth5(hidden, value, 0); - if (strcasecmp(name, "MaxAuto") == 0) - { - this->m_iMaxAuto = value; - } - return 0; - } -#if 0 - if (strcmp((const char*)record.dll, "ir50_32.dll") == 0) - { - IHidden2* hidden = 0; - if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_Iv50Hidden, (void**)&hidden)) - { - Debug printf("No such interface\n"); - return -1; - } - int recordpar[30]; - recordpar[0]=0x7c; - recordpar[1]=fccIV50; - recordpar[2]=0x10005; - recordpar[3]=2; - recordpar[4]=1; - recordpar[5]=0x80000000; - if (strcmp(name, "Brightness") == 0) - { - recordpar[5]|=0x20; - recordpar[18]=value; - } - else if (strcmp(name, "Saturation") == 0) - { - recordpar[5]|=0x40; - recordpar[19]=value; - } - else if (strcmp(name, "Contrast") == 0) - { - recordpar[5]|=0x80; - recordpar[20]=value; - } - if(!recordpar[5]) - { - hidden->vt->Release((IUnknown*)hidden); - return -1; - } - HRESULT result = hidden->vt->DecodeSet(hidden, recordpar); - hidden->vt->Release((IUnknown*)hidden); - - return result; - } -#endif -// printf("DS_SetValue for ????, name=%s value=%d\n",name,value); - return 0; -} - -int DS_SetAttr_DivX(char* attribute, int value){ - int result, status, newkey; - if(strcasecmp(attribute, "Quality")==0){ - char* keyname="SOFTWARE\\Microsoft\\Scrunch"; - result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status); - if(result!=0) - { - printf("VideoDecoder::SetExtAttr: registry failure\n"); - return -1; - } - result=RegSetValueExA(newkey, "Current Post Process Mode", 0, REG_DWORD, &value, 4); - if(result!=0) - { - printf("VideoDecoder::SetExtAttr: error writing value\n"); - return -1; - } - value=-1; - result=RegSetValueExA(newkey, "Force Post Process Mode", 0, REG_DWORD, &value, 4); - if(result!=0) - { - printf("VideoDecoder::SetExtAttr: error writing value\n"); - return -1; - } - RegCloseKey(newkey); - return 0; - } - - if( - (strcasecmp(attribute, "Saturation")==0) || - (strcasecmp(attribute, "Hue")==0) || - (strcasecmp(attribute, "Contrast")==0) || - (strcasecmp(attribute, "Brightness")==0) - ) - { - char* keyname="SOFTWARE\\Microsoft\\Scrunch\\Video"; - result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status); - if(result!=0) - { - printf("VideoDecoder::SetExtAttr: registry failure\n"); - return -1; - } - result=RegSetValueExA(newkey, attribute, 0, REG_DWORD, &value, 4); - if(result!=0) - { - printf("VideoDecoder::SetExtAttr: error writing value\n"); - return -1; - } - RegCloseKey(newkey); - return 0; - } - - printf("Unknown attribute!\n"); - return -200; -} diff --git a/loader/dshow/DS_VideoDecoder.h b/loader/dshow/DS_VideoDecoder.h deleted file mode 100644 index f1a0898868..0000000000 --- a/loader/dshow/DS_VideoDecoder.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MPLAYER_DS_VIDEODECODER_H -#define MPLAYER_DS_VIDEODECODER_H - -#include "loader/com.h" -#include "loader/wine/vfw.h" - -typedef struct DS_VideoDecoder DS_VideoDecoder; - -int DS_VideoDecoder_GetCapabilities(DS_VideoDecoder *this); - -DS_VideoDecoder * DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto); - -void DS_VideoDecoder_Destroy(DS_VideoDecoder *this); - -void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this); - -void DS_VideoDecoder_StopInternal(DS_VideoDecoder *this); - -int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, char* pImage); - -/* - * bits == 0 - leave unchanged - */ -//int SetDestFmt(DS_VideoDecoder * this, int bits = 24, fourcc_t csp = 0); -int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, unsigned int csp); -int DS_VideoDecoder_SetDirection(DS_VideoDecoder *this, int d); -int DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value); -int DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value); -int DS_SetAttr_DivX(char* attribute, int value); - - -#endif /* MPLAYER_DS_VIDEODECODER_H */ diff --git a/loader/dshow/allocator.c b/loader/dshow/allocator.c deleted file mode 100644 index 744debf968..0000000000 --- a/loader/dshow/allocator.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Modified for use with MPlayer, detailed changelog at - * http://svn.mplayerhq.hu/mplayer/trunk/ - */ - -#include "config.h" -#include "allocator.h" -#include "loader/com.h" -#include "loader/wine/winerror.h" -#include <stdio.h> -#include <stdlib.h> - -static int AllocatorKeeper = 0; - -struct avm_list_t -{ - struct avm_list_t* next; - struct avm_list_t* prev; - void* member; -}; - -static inline int avm_list_size(avm_list_t* head) -{ - avm_list_t* it = head; - int i = 0; - if (it) - { - for (;;) - { - i++; - it = it->next; - if (it == head) - break; - } - } - return i; -} - -static inline int avm_list_print(avm_list_t* head) -{ - avm_list_t* it = head; - int i = 0; - printf("Head: %p\n", head); - if (it) - { - for (;;) - { - i++; - printf("%d: member: %p next: %p prev: %p\n", - i, it->member, it->next, it->prev); - it = it->next; - if (it == head) - break; - } - } - return i; -} - -static inline avm_list_t* avm_list_add_head(avm_list_t* head, void* member) -{ - avm_list_t* n = malloc(sizeof(avm_list_t)); - n->member = member; - - if (!head) - { - head = n; - head->prev = head; - } - - n->prev = head->prev; - head->prev = n; - n->next = head; - - return n; -} - -static inline avm_list_t* avm_list_add_tail(avm_list_t* head, void* member) -{ - avm_list_t* n = avm_list_add_head(head, member); - return (!head) ? n : head; -} - -static inline avm_list_t* avm_list_del_head(avm_list_t* head) -{ - avm_list_t* n = 0; - - if (head) - { - if (head->next != head) - { - n = head->next; - head->prev->next = head->next; - head->next->prev = head->prev; - } - free(head); - } - return n; -} - -static inline avm_list_t* avm_list_find(avm_list_t* head, void* member) -{ - avm_list_t* it = head; - if (it) - { - for (;;) - { - if (it->member == member) - return it; - it = it->next; - if (it == head) - break; - } - } - return NULL; -} - -#ifdef WIN32_LOADER -static long MemAllocator_CreateAllocator(GUID* clsid, const GUID* iid, void** ppv) -{ - IUnknown* p; - int result; - if (!ppv) - return -1; - *ppv = 0; - if (memcmp(clsid, &CLSID_MemoryAllocator, sizeof(GUID))) - return -1; - - p = (IUnknown*) MemAllocatorCreate(); - result = p->vt->QueryInterface(p, iid, ppv); - p->vt->Release(p); - - return result; -} -#endif - -static HRESULT STDCALL MemAllocator_SetProperties(IMemAllocator * This, - /* [in] */ ALLOCATOR_PROPERTIES *pRequest, - /* [out] */ ALLOCATOR_PROPERTIES *pActual) -{ - MemAllocator* me = (MemAllocator*)This; - Debug printf("MemAllocator_SetProperties(%p) called\n", This); - if (!pRequest || !pActual) - return E_INVALIDARG; - if (pRequest->cBuffers<=0 || pRequest->cbBuffer<=0) - return E_FAIL; - if (me->used_list != 0 || me->free_list != 0) - return E_FAIL; - - *pActual = *pRequest; - /* - DirectShow DOCS ("Negotiating Allocators" chapter) says that allocator might not - honor the requested properties. Thus, since WMSP audio codecs requests bufer with two - bytes length for unknown reason, we should correct requested value. Otherwise above - codec don't want to load. - */ - if (pActual->cbBuffer == 2) - pActual->cbBuffer = 10240; //Enough for WMSP codec - - me->props = *pActual; - - return 0; -} - -static HRESULT STDCALL MemAllocator_GetProperties(IMemAllocator * This, - /* [out] */ ALLOCATOR_PROPERTIES *pProps) -{ - Debug printf("MemAllocator_GetProperties(%p) called\n", This); - if (!pProps) - return E_INVALIDARG; - if (((MemAllocator*)This)->props.cbBuffer<0) - return E_FAIL; - *pProps=((MemAllocator*)This)->props; - - return 0; -} - -static HRESULT STDCALL MemAllocator_Commit(IMemAllocator * This) -{ - MemAllocator* me = (MemAllocator*)This; - int i; - Debug printf("MemAllocator_Commit(%p) called\n", This); - if (((MemAllocator*)This)->props.cbBuffer < 0) - return E_FAIL; - if (me->used_list || me->free_list) - return E_INVALIDARG; - for (i = 0; i < me->props.cBuffers; i++) - { - CMediaSample* sample = CMediaSampleCreate((IMemAllocator*)me, - me->props.cbBuffer); - if (!sample) - return E_OUTOFMEMORY; - //printf("FREEEEEEEEEEEE ADDED %p\n", sample); - me->free_list = avm_list_add_tail(me->free_list, sample); - //avm_list_print(me->free_list); - } - - //printf("Added mem %p: lsz: %d %d size: %d\n", me, avm_list_size(me->free_list), me->props.cBuffers, me->props.cbBuffer); - return 0; -} - -static HRESULT STDCALL MemAllocator_Decommit(IMemAllocator * This) -{ - MemAllocator* me=(MemAllocator*)This; - Debug printf("MemAllocator_Decommit(%p) called\n", This); - //printf("Deleted mem %p: %d %d\n", me, me->free_list.size(), me->used_list.size()); - while (me->used_list) - { - me->free_list = avm_list_add_tail(me->free_list, - (CMediaSample*) me->used_list->member); - me->used_list = avm_list_del_head(me->used_list); - } - - while (me->free_list) - { - CMediaSample* sample = (CMediaSample*) me->free_list->member; - //printf("****************** Decommiting FREE %p\n", sample); - //sample->vt->Release((IUnknown*)sample); - CMediaSample_Destroy((CMediaSample*)sample); - me->free_list = avm_list_del_head(me->free_list); - } - - return 0; -} - -static HRESULT STDCALL MemAllocator_GetBuffer(IMemAllocator * This, - /* [out] */ IMediaSample **ppBuffer, - /* [in] */ REFERENCE_TIME *pStartTime, - /* [in] */ REFERENCE_TIME *pEndTime, - /* [in] */ DWORD dwFlags) -{ - MemAllocator* me = (MemAllocator*)This; - CMediaSample* sample; - Debug printf("MemAllocator_ReleaseBuffer(%p) called %d %d\n", This, - avm_list_size(me->used_list), avm_list_size(me->free_list)); - - if (!me->free_list) - { - Debug printf("No samples available\n"); - return E_FAIL;//should block here if no samples are available - } - - sample = (CMediaSample*) me->free_list->member; - me->free_list = avm_list_del_head(me->free_list); - me->used_list = avm_list_add_tail(me->used_list, sample); - - *ppBuffer = (IMediaSample*) sample; - sample->vt->AddRef((IUnknown*) sample); - if (me->new_pointer) - { - if (me->modified_sample) - me->modified_sample->ResetPointer(me->modified_sample); - sample->SetPointer(sample, me->new_pointer); - me->modified_sample = sample; - me->new_pointer = 0; - } - return 0; -} - -static HRESULT STDCALL MemAllocator_ReleaseBuffer(IMemAllocator* This, - /* [in] */ IMediaSample* pBuffer) -{ - avm_list_t* l; - MemAllocator* me = (MemAllocator*)This; - Debug printf("MemAllocator_ReleaseBuffer(%p) called %d %d\n", This, - avm_list_size(me->used_list), avm_list_size(me->free_list)); - - l = avm_list_find(me->used_list, pBuffer); - if (l) - { - CMediaSample* sample = (CMediaSample*) l->member; - if (me->modified_sample == sample) - { - me->modified_sample->ResetPointer(me->modified_sample); - me->modified_sample = 0; - } - me->used_list = avm_list_del_head(me->used_list); - me->free_list = avm_list_add_head(me->free_list, sample); - //printf("****************** RELEASED OK %p %p\n", me->used_list, me->free_list); - return 0; - } - Debug printf("MemAllocator_ReleaseBuffer(%p) releasing unknown buffer!!!! %p\n", This, pBuffer); - return E_FAIL; -} - - -static void MemAllocator_SetPointer(MemAllocator* This, char* pointer) -{ - This->new_pointer = pointer; -} - -static void MemAllocator_ResetPointer(MemAllocator* This) -{ - if (This->modified_sample) - { - This->modified_sample->ResetPointer(This->modified_sample); - This->modified_sample = 0; - } -} - -static void MemAllocator_Destroy(MemAllocator* This) -{ - Debug printf("MemAllocator_Destroy(%p) called (%d, %d)\n", This, This->refcount, AllocatorKeeper); -#ifdef WIN32_LOADER - if (--AllocatorKeeper == 0) - UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); -#endif - free(This->vt); - free(This); -} - -IMPLEMENT_IUNKNOWN(MemAllocator) - -MemAllocator* MemAllocatorCreate() -{ - MemAllocator* This = malloc(sizeof(MemAllocator)); - - if (!This) - return NULL; - - Debug printf("MemAllocatorCreate() called -> %p\n", This); - - This->refcount = 1; - This->props.cBuffers = 1; - This->props.cbBuffer = 65536; /* :/ */ - This->props.cbAlign = 1; - This->props.cbPrefix = 0; - - This->vt = malloc(sizeof(IMemAllocator_vt)); - - if (!This->vt) - { - free(This); - return NULL; - } - - This->vt->QueryInterface = MemAllocator_QueryInterface; - This->vt->AddRef = MemAllocator_AddRef; - This->vt->Release = MemAllocator_Release; - This->vt->SetProperties = MemAllocator_SetProperties; - This->vt->GetProperties = MemAllocator_GetProperties; - This->vt->Commit = MemAllocator_Commit; - This->vt->Decommit = MemAllocator_Decommit; - This->vt->GetBuffer = MemAllocator_GetBuffer; - This->vt->ReleaseBuffer = MemAllocator_ReleaseBuffer; - - This->SetPointer = MemAllocator_SetPointer; - This->ResetPointer = MemAllocator_ResetPointer; - - This->modified_sample = 0; - This->new_pointer = 0; - This->used_list = 0; - This->free_list = 0; - - This->interfaces[0]=IID_IUnknown; - This->interfaces[1]=IID_IMemAllocator; - -#ifdef WIN32_LOADER - if (AllocatorKeeper++ == 0) - RegisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); -#endif - - return This; -} diff --git a/loader/dshow/allocator.h b/loader/dshow/allocator.h deleted file mode 100644 index 71597b3634..0000000000 --- a/loader/dshow/allocator.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MPLAYER_ALLOCATOR_H -#define MPLAYER_ALLOCATOR_H - -#include "interfaces.h" -#include "cmediasample.h" - -typedef struct avm_list_t avm_list_t; -typedef struct MemAllocator MemAllocator; - -struct MemAllocator -{ - IMemAllocator_vt* vt; - DECLARE_IUNKNOWN(); - ALLOCATOR_PROPERTIES props; - avm_list_t* used_list; - avm_list_t* free_list; - char* new_pointer; - CMediaSample* modified_sample; - GUID interfaces[2]; - - void ( *SetPointer )(MemAllocator* This, char* pointer); - void ( *ResetPointer )(MemAllocator* This); -}; - -MemAllocator* MemAllocatorCreate(void); - -#endif /* MPLAYER_ALLOCATOR_H */ diff --git a/loader/dshow/cmediasample.c b/loader/dshow/cmediasample.c deleted file mode 100644 index 3b7e45bb15..0000000000 --- a/loader/dshow/cmediasample.c +++ /dev/null @@ -1,576 +0,0 @@ -/* - * Modified for use with MPlayer, detailed changelog at - * http://svn.mplayerhq.hu/mplayer/trunk/ - */ - -#include "cmediasample.h" -#include "mediatype.h" -#include "loader/wine/winerror.h" -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -/* - * currently hack to make some extra room for DS Acel codec which - * seems to overwrite allocated memory - FIXME better later - * check the buffer allocation - */ -static const int SAFETY_ACEL = 1024; - -/** - * \brief IPin::QueryInternalConnections (retries pin's internal connections) - * - * \param[in] This pointer to IPin interface - * \param[out] apPin Array that receives pins, internally connected to this - * \param[in,out] nPint Size of an array - * - * \return S_OK - success - * \return S_FALSE - pin rejects media type - * \return E_NOTIMPL - not implemented - * - */ -static long STDCALL CMediaSample_QueryInterface(IUnknown* This, - /* [in] */ const GUID* iid, - /* [iid_is][out] */ void **ppv) -{ - Debug printf("CMediaSample_QueryInterface(%p) called\n", This); - if (!ppv) - return E_INVALIDARG; - if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0) - { - *ppv = (void*)This; - ((IMediaSample*) This)->vt->AddRef(This); - return 0; - } - if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0) - { - *ppv = (void*)This; - ((IMediaSample*) This)->vt->AddRef(This); - return 0; - } - return E_NOINTERFACE; -} - -/** - * \brief IUnknown::AddRef (increases reference counter for interface) - * - * \param[in] This pointer to IUnknown class - * - * \return new value of reference counter - * - * \remarks - * Return value should be used only for debug purposes - * - */ -static long STDCALL CMediaSample_AddRef(IUnknown* This) -{ - Debug printf("CMediaSample_AddRef(%p) called\n", This); - ((CMediaSample*)This)->refcount++; - return 0; -} - -/** - * \brief CMediaSample destructor - * - * \param[in] This pointer to CMediaSample object - * - */ -void CMediaSample_Destroy(CMediaSample* This) -{ - - Debug printf("CMediaSample_Destroy(%p) called (ref:%d)\n", This, This->refcount); - free(This->vt); - free(This->own_block); - if(((CMediaSample*)This)->type_valid) - FreeMediaType(&(This->media_type)); - free(This); -} - -/** - * \brief IUnknown::Release (desreases reference counter for interface) - * - * \param[in] This pointer to IUnknown class - * - * \return new value of reference counter - * - * \remarks - * When reference counter reaches zero calls destructor - * Return value should be used only for debug purposes - * - */ -static long STDCALL CMediaSample_Release(IUnknown* This) -{ - CMediaSample* parent = (CMediaSample*)This; - Debug printf("CMediaSample_Release(%p) called (new ref:%d)\n", - This, ((CMediaSample*)This)->refcount-1); - - if (--((CMediaSample*) This)->refcount == 0) - { - parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all), - (IMediaSample*)This); - } - return 0; -} - -/** - * \brief IMediaSample::GetPointer (retrieves a read/write pointer to the media sample's buffer) - * - * \param[in] This pointer to CMediaSample object - * \param[out] address of variable that receives pointer to sample's buffer - * - * \return S_OK success - * \return apropriate error otherwise - * - * \note The calles should not free or reallocate buffer - * - */ -static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This, - /* [out] */ BYTE** ppBuffer) -{ - Debug printf("CMediaSample_GetPointer(%p) called -> %p, size: %d %d\n", This, ((CMediaSample*) This)->block, ((CMediaSample*)This)->actual_size, ((CMediaSample*)This)->size); - if (!ppBuffer) - return E_INVALIDARG; - *ppBuffer = (BYTE*) ((CMediaSample*) This)->block; - return 0; -} - -/** - * \brief IMediaSample::GetSize (retrieves a size of buffer in bytes) - * - * \param[in] This pointer to CMediaSample object - * - * \return size of buffer in bytes - * - */ -static long STDCALL CMediaSample_GetSize(IMediaSample * This) -{ - Debug printf("CMediaSample_GetSize(%p) called -> %d\n", This, ((CMediaSample*) This)->size); - return ((CMediaSample*) This)->size; -} - -/** - * \brief IMediaSample::GetTime (retrieves a stream time at wich sample sould start and finish) - * - * \param[in] This pointer to CMediaSample object - * \param[out] pTimeStart pointer to variable that receives start time - * \param[out] pTimeEnd pointer to variable that receives end time - * - * \return S_OK success - * \return VFW_E_NO_STOP_TIME The sample has valid start time, but no stop time - * \return VFW_E_SAMPLE_TIME_NOT_SET The sample is not time-stamped - * - * \remarks - * Both values are relative to stream time - * - */ -static HRESULT STDCALL CMediaSample_GetTime(IMediaSample * This, - /* [out] */ REFERENCE_TIME *pTimeStart, - /* [out] */ REFERENCE_TIME *pTimeEnd) -{ - Debug printf("CMediaSample_GetTime(%p) called (UNIMPLEMENTED)\n", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaSample::SetTime (sets a stream time at wich sample sould start and finish) - * - * \param[in] This pointer to CMediaSample object - * \param[out] pTimeStart pointer to variable that contains start time - * \param[out] pTimeEnd pointer to variable that contains end time - * - * \return S_OK success - * \return apropriate error otherwise - * - * \remarks - * Both values are relative to stream time - * To invalidate the stream times set pTimeStart and pTimeEnd to NULL. this will cause - * IMEdiaSample::GetTime to return VFW_E_SAMPLE_TIME_NOT_SET - * - */ -static HRESULT STDCALL CMediaSample_SetTime(IMediaSample * This, - /* [in] */ REFERENCE_TIME *pTimeStart, - /* [in] */ REFERENCE_TIME *pTimeEnd) -{ - Debug printf("CMediaSample_SetTime(%p) called (UNIMPLEMENTED)\n", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaSample::IsSyncPoint (determines if start of this sample is sync point) - * - * \param[in] This pointer to CMediaSample object - * - * \return S_OK start of this sample is sync point - * \return S_FALSE start of this sample is not sync point - * - * \remarks - * If bTemporalCompression of AM_MEDIA_TYPE is FALSE, all samples are sync points. - * - */ -static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This) -{ - Debug printf("CMediaSample_IsSyncPoint(%p) called\n", This); - if (((CMediaSample*)This)->isSyncPoint) - return 0; - return 1; -} - -/** - * \brief IMediaSample::SetSyncPoint (specifies if start of this sample is sync point) - * - * \param[in] This pointer to CMediaSample object - * \param[in] bIsSyncPoint specifies whether this is sync point or not - * - * \return S_OK success - * \return apropriate error code otherwise - * - */ -static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This, - long bIsSyncPoint) -{ - Debug printf("CMediaSample_SetSyncPoint(%p) called\n", This); - ((CMediaSample*)This)->isSyncPoint = bIsSyncPoint; - return 0; -} - -/** - * \brief IMediaSample::IsPreroll (determines if this sample is preroll sample) - * - * \param[in] This pointer to CMediaSample object - * - * \return S_OK if this sample is preroll sample - * \return S_FALSE if this sample is not preroll sample - * - * \remarks - * Preroll samples are processed but not displayed. They are lokated in media stream - * before displayable samples. - * - */ -static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This) -{ - Debug printf("CMediaSample_IsPreroll(%p) called\n", This); - - if (((CMediaSample*)This)->isPreroll) - return 0;//S_OK - - return 1;//S_FALSE -} - -/** - * \brief IMediaSample::SetPreroll (specifies if this sample is preroll sample) - * - * \param[in] This pointer to CMediaSample object - * \param[in] bIsPreroll specifies whether this sample is preroll sample or not - * - * \return S_OK success - * \return apropriate error code otherwise - * - * \remarks - * Preroll samples are processed but not displayed. They are lokated in media stream - * before displayable samples. - * - */ -static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This, - long bIsPreroll) -{ - Debug printf("CMediaSample_SetPreroll(%p) called\n", This); - ((CMediaSample*)This)->isPreroll=bIsPreroll; - return 0; -} - -/** - * \brief IMediaSample::GetActualDataLength (retrieves the length of valid data in the buffer) - * - * \param[in] This pointer to CMediaSample object - * - * \return length of valid data in buffer in bytes - * - */ -static long STDCALL CMediaSample_GetActualDataLength(IMediaSample* This) -{ - Debug printf("CMediaSample_GetActualDataLength(%p) called -> %d\n", This, ((CMediaSample*)This)->actual_size); - return ((CMediaSample*)This)->actual_size; -} - -/** - * \brief IMediaSample::SetActualDataLength (specifies the length of valid data in the buffer) - * - * \param[in] This pointer to CMediaSample object - * \param[in] __MIDL_0010 length of data in sample in bytes - * - * \return S_OK success - * \return VFW_E_BUFFER_OVERFLOW length specified by parameter is larger than buffer size - * - */ -static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample* This, - long __MIDL_0010) -{ - CMediaSample* cms = (CMediaSample*)This; - Debug printf("CMediaSample_SetActualDataLength(%p, %ld) called\n", This, __MIDL_0010); - - if (__MIDL_0010 > cms->size) - { - char* c = cms->own_block; - Debug printf("CMediaSample - buffer overflow %ld %d %p %p\n", - __MIDL_0010, ((CMediaSample*)This)->size, cms->own_block, cms->block); - cms->own_block = realloc(cms->own_block, (size_t) __MIDL_0010 + SAFETY_ACEL); - if (c == cms->block) - cms->block = cms->own_block; - cms->size = __MIDL_0010; - } - cms->actual_size = __MIDL_0010; - return 0; -} - -/** - * \brief IMediaSample::GetMediaType (retrieves media type, if it changed from previous sample) - * - * \param[in] This pointer to CMediaSample object - * \param[out] ppMediaType address of variable that receives pointer to AM_MEDIA_TYPE. - * - * \return S_OK success - * \return S_FALSE Media type was not changed from previous sample - * \return E_OUTOFMEMORY Insufficient memory - * - * \remarks - * If media type is not changed from previous sample, ppMediaType is null - * If method returns S_OK caller should free memory allocated for structure - * including pbFormat block - */ -static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample* This, - AM_MEDIA_TYPE** ppMediaType) -{ - AM_MEDIA_TYPE* t; - Debug printf("CMediaSample_GetMediaType(%p) called\n", This); - if(!ppMediaType) - return E_INVALIDARG; - if(!((CMediaSample*)This)->type_valid) - { - *ppMediaType=0; - return 1; - } - - t = &((CMediaSample*)This)->media_type; - // free(t.pbFormat); - *ppMediaType=CreateMediaType(t); - // *ppMediaType=0; //media type was not changed - return 0; -} - -/** - * \brief IMediaType::SetMediaType (specifies media type for sample) - * - * \param[in] This pointer to CMediaSample object - * \param[in] pMediaType pointer to AM_MEDIA_TYPE specifies new media type - * - * \return S_OK success - * \return E_OUTOFMEMORY insufficient memory - * - */ -static HRESULT STDCALL CMediaSample_SetMediaType(IMediaSample * This, - AM_MEDIA_TYPE *pMediaType) -{ - AM_MEDIA_TYPE* t; - Debug printf("CMediaSample_SetMediaType(%p) called\n", This); - if (!pMediaType) - return E_INVALIDARG; - t = &((CMediaSample*)This)->media_type; - if(((CMediaSample*)This)->type_valid) - FreeMediaType(t); - CopyMediaType(t,pMediaType); - ((CMediaSample*) This)->type_valid=1; - - return 0; -} - -/** - * \brief IMediaSample::IsDiscontinuity (determines if this sample represents data break - * in stream) - * - * \param[in] This pointer to CMediaSample object - * - * \return S_OK if this sample is break in data stream - * \return S_FALSE otherwise - * - * \remarks - * Discontinuity occures when filter seeks to different place in the stream or when drops - * samples. - * - */ -static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This) -{ - Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This); - return ((CMediaSample*) This)->isDiscontinuity; -} - -/** - * \brief IMediaSample::IsDiscontinuity (specifies whether this sample represents data break - * in stream) - * - * \param[in] This pointer to CMediaSample object - * \param[in] bDiscontinuity if TRUE this sample represents discontinuity with previous sample - * - * \return S_OK success - * \return apropriate error code otherwise - * - */ -static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This, - long bDiscontinuity) -{ - Debug printf("CMediaSample_SetDiscontinuity(%p) called (%ld)\n", This, bDiscontinuity); - ((CMediaSample*) This)->isDiscontinuity = bDiscontinuity; - return 0; -} - -/** - * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) - * - * \param[in] This pointer to CMediaSample object - * \param[out] pTimeStart pointer to variable that receives start time - * \param[out] pTimeEnd pointer to variable that receives end time - * - * \return S_OK success - * \return VFW_E_MEDIA_TIME_NOT_SET The sample is not time-stamped - * - */ -static HRESULT STDCALL CMediaSample_GetMediaTime(IMediaSample * This, - /* [out] */ LONGLONG *pTimeStart, - /* [out] */ LONGLONG *pTimeEnd) -{ - Debug printf("CMediaSample_GetMediaTime(%p) called\n", This); - if (pTimeStart) - *pTimeStart = ((CMediaSample*) This)->time_start; - if (pTimeEnd) - *pTimeEnd = ((CMediaSample*) This)->time_end; - return 0; -} - -/** - * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) - * - * \param[in] This pointer to CMediaSample object - * \param[out] pTimeStart pointer to variable that specifies start time - * \param[out] pTimeEnd pointer to variable that specifies end time - * - * \return S_OK success - * \return apropriate error code otherwise - * - * \remarks - * To invalidate the media times set pTimeStart and pTimeEnd to NULL. this will cause - * IMEdiaSample::GetTime to return VFW_E_MEDIA_TIME_NOT_SET - */ -static HRESULT STDCALL CMediaSample_SetMediaTime(IMediaSample * This, - /* [in] */ LONGLONG *pTimeStart, - /* [in] */ LONGLONG *pTimeEnd) -{ - Debug printf("CMediaSample_SetMediaTime(%p) called\n", This); - if (pTimeStart) - ((CMediaSample*) This)->time_start = *pTimeStart; - if (pTimeEnd) - ((CMediaSample*) This)->time_end = *pTimeEnd; - return 0; -} - -/** - * \brief CMediaSample::SetPointer (extension for direct memory write of decompressed data) - * - * \param[in] This pointer to CMediaSample object - * \param[in] pointer pointer to an external buffer to store data to - * - */ -static void CMediaSample_SetPointer(CMediaSample* This, char* pointer) -{ - Debug printf("CMediaSample_SetPointer(%p) called -> %p\n", This, pointer); - if (pointer) - This->block = pointer; - else - This->block = This->own_block; -} - -/** - * \brief CMediaSample::SetPointer (resets pointer to external buffer with internal one) - * - * \param[in] This pointer to CMediaSample object - * - */ -static void CMediaSample_ResetPointer(CMediaSample* This) -{ - Debug printf("CMediaSample_ResetPointer(%p) called\n", This); - This->block = This->own_block; -} - -/** - * \brief CMediaSample constructor - * - * \param[in] allocator IMemallocator interface of allocator to use - * \param[in] size size of internal buffer - * - * \return pointer to CMediaSample object of NULL if error occured - * - */ -CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int size) -{ - CMediaSample* This = malloc(sizeof(CMediaSample)); - if (!This) - return NULL; - - // some hack here! - // it looks like Acelp decoder is actually accessing - // the allocated memory before it sets the new size for it ??? - // -- maybe it's being initialized with wrong parameters - // anyway this is fixes the problem somehow with some reserves - // - // using different trick for now - in DS_Audio modify sample size - //if (size < 0x1000) - // size = (size + 0xfff) & ~0xfff; - - This->vt = malloc(sizeof(IMediaSample_vt)); - This->own_block = malloc((size_t)size + SAFETY_ACEL); - This->media_type.pbFormat = 0; - This->media_type.pUnk = 0; - - if (!This->vt || !This->own_block) - { - CMediaSample_Destroy(This); - return NULL; - } - - This->vt->QueryInterface = CMediaSample_QueryInterface; - This->vt->AddRef = CMediaSample_AddRef; - This->vt->Release = CMediaSample_Release; - This->vt->GetPointer = CMediaSample_GetPointer; - This->vt->GetSize = CMediaSample_GetSize; - This->vt->GetTime = CMediaSample_GetTime; - This->vt->SetTime = CMediaSample_SetTime; - This->vt->IsSyncPoint = CMediaSample_IsSyncPoint; - This->vt->SetSyncPoint = CMediaSample_SetSyncPoint; - This->vt->IsPreroll = CMediaSample_IsPreroll; - This->vt->SetPreroll = CMediaSample_SetPreroll; - This->vt->GetActualDataLength = CMediaSample_GetActualDataLength; - This->vt->SetActualDataLength = CMediaSample_SetActualDataLength; - This->vt->GetMediaType = CMediaSample_GetMediaType; - This->vt->SetMediaType = CMediaSample_SetMediaType; - This->vt->IsDiscontinuity = CMediaSample_IsDiscontinuity; - This->vt->SetDiscontinuity = CMediaSample_SetDiscontinuity; - This->vt->GetMediaTime = CMediaSample_GetMediaTime; - This->vt->SetMediaTime = CMediaSample_SetMediaTime; - - This->all = allocator; - This->size = size; - This->refcount = 0; // increased by MemAllocator - This->actual_size = 0; - This->isPreroll = 0; - This->isDiscontinuity = 1; - This->time_start = 0; - This->time_end = 0; - This->type_valid = 0; - This->block = This->own_block; - - This->SetPointer = CMediaSample_SetPointer; - This->ResetPointer = CMediaSample_ResetPointer; - - Debug printf("CMediaSample_Create(%p) called - sample size %d, buffer %p\n", - This, This->size, This->block); - - return This; -} diff --git a/loader/dshow/cmediasample.h b/loader/dshow/cmediasample.h deleted file mode 100644 index a874dc2289..0000000000 --- a/loader/dshow/cmediasample.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MPLAYER_CMEDIASAMPLE_H -#define MPLAYER_CMEDIASAMPLE_H - -#include "interfaces.h" -#include "guids.h" - -typedef struct CMediaSample CMediaSample; -struct CMediaSample -{ - IMediaSample_vt* vt; - DECLARE_IUNKNOWN(); - IMemAllocator* all; - int size; - int actual_size; - char* block; - char* own_block; - int isPreroll; - int isSyncPoint; - int isDiscontinuity; - LONGLONG time_start; - LONGLONG time_end; - AM_MEDIA_TYPE media_type; - int type_valid; - void ( *SetPointer) (CMediaSample* This, char* pointer); - void ( *ResetPointer) (CMediaSample* This); // FIXME replace with Set & 0 -}; - -CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int size); -// called from allocator -void CMediaSample_Destroy(CMediaSample* This); - -#endif /* MPLAYER_CMEDIASAMPLE_H */ diff --git a/loader/dshow/graph.c b/loader/dshow/graph.c deleted file mode 100644 index 14517a627f..0000000000 --- a/loader/dshow/graph.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Implemention of FilterGraph. Based on allocator.c. - * Copyright 2010 Steinar H. Gunderson - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Modified for use with MPlayer, detailed changelog at - * http://svn.mplayerhq.hu/mplayer/trunk/ - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "config.h" -#include "loader/com.h" -#include "loader/dshow/graph.h" -#include "loader/wine/winerror.h" - -// How many FilterGraph objects exist. -// Used for knowing when to register and unregister the class in COM. -static int GraphKeeper = 0; - -#ifdef WIN32_LOADER -static long FilterGraph_CreateGraph(GUID* clsid, const GUID* iid, void** ppv) -{ - IUnknown* p; - int result; - if (!ppv) - return -1; - *ppv = 0; - if (memcmp(clsid, &CLSID_FilterGraph, sizeof(*clsid))) - return -1; - - p = (IUnknown*) FilterGraphCreate(); - result = p->vt->QueryInterface(p, iid, ppv); - p->vt->Release(p); - - return result; -} -#endif - -static void FilterGraph_Destroy(FilterGraph* This) -{ - Debug printf("FilterGraph_Destroy(%p) called (%d, %d)\n", This, This->refcount, GraphKeeper); -#ifdef WIN32_LOADER - if (--GraphKeeper == 0) - UnregisterComClass(&CLSID_FilterGraph, FilterGraph_CreateGraph); -#endif - free(This->vt); - free(This); -} - -static HRESULT STDCALL FilterGraph_AddFilter(IFilterGraph* This, - IBaseFilter* pFilter, - unsigned short* pName) -{ - Debug printf("FilterGraph_AddFilter(%p) called\n", This); - return E_NOTIMPL; -} - -static HRESULT STDCALL FilterGraph_RemoveFilter(IFilterGraph* This, IBaseFilter* pFilter) -{ - Debug printf("FilterGraph_RemoveFilter(%p) called\n", This); - return E_NOTIMPL; -} - -static HRESULT STDCALL FilterGraph_EnumFilters(IFilterGraph* This, IEnumFilters** ppEnum) -{ - Debug printf("FilterGraph_EnumFilters(%p) called\n", This); - return E_NOTIMPL; -} - -static HRESULT STDCALL FilterGraph_FindFilterByName(IFilterGraph* This, - unsigned short* pName, - IBaseFilter** ppFilter) -{ - Debug printf("FilterGraph_FindFilterByName(%p) called\n", This); - return E_NOTIMPL; -} - -static HRESULT STDCALL FilterGraph_ConnectDirect(IFilterGraph* This, - IPin* ppinOut, - IPin* ppinIn, - const AM_MEDIA_TYPE* pmt) -{ - Debug printf("FilterGraph_ConnectDirect(%p) called\n", This); - return E_NOTIMPL; -} - -static HRESULT STDCALL FilterGraph_Reconnect(IFilterGraph* This, IPin* ppin) -{ - Debug printf("FilterGraph_Reconnect(%p) called\n", This); - return E_NOTIMPL; -} - -static HRESULT STDCALL FilterGraph_Disconnect(IFilterGraph* This, IPin* ppin) -{ - Debug printf("FilterGraph_Disconnect(%p) called\n", This); - return E_NOTIMPL; -} - -static HRESULT STDCALL FilterGraph_SetDefaultSyncSource(IFilterGraph* This) -{ - Debug printf("FilterGraph_SetDefaultSyncSource(%p) called\n", This); - return E_NOTIMPL; -} - -IMPLEMENT_IUNKNOWN(FilterGraph) - -FilterGraph* FilterGraphCreate() -{ - FilterGraph* This = calloc(1, sizeof(*This)); - - if (!This) - return NULL; - - Debug printf("FilterGraphCreate() called -> %p\n", This); - - This->refcount = 1; - - This->vt = calloc(1, sizeof(*This->vt)); - - if (!This->vt) { - free(This); - return NULL; - } - - This->vt->QueryInterface = FilterGraph_QueryInterface; - This->vt->AddRef = FilterGraph_AddRef; - This->vt->Release = FilterGraph_Release; - - This->vt->AddFilter = FilterGraph_AddFilter; - This->vt->RemoveFilter = FilterGraph_RemoveFilter; - This->vt->EnumFilters = FilterGraph_EnumFilters; - This->vt->FindFilterByName = FilterGraph_FindFilterByName; - This->vt->ConnectDirect = FilterGraph_ConnectDirect; - This->vt->Reconnect = FilterGraph_Reconnect; - This->vt->Disconnect = FilterGraph_Disconnect; - This->vt->SetDefaultSyncSource = FilterGraph_SetDefaultSyncSource; - - This->interfaces[0] = IID_IUnknown; - This->interfaces[1] = IID_IFilterGraph; - -#ifdef WIN32_LOADER - if (GraphKeeper++ == 0) - RegisterComClass(&CLSID_FilterGraph, FilterGraph_CreateGraph); -#endif - - return This; -} - diff --git a/loader/dshow/graph.h b/loader/dshow/graph.h deleted file mode 100644 index 7667f5a39e..0000000000 --- a/loader/dshow/graph.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef MPLAYER_GRAPH_H -#define MPLAYER_GRAPH_H - -/* - * Copyright 2010 Steinar H. Gunderson - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "interfaces.h" -#include "cmediasample.h" - -typedef struct FilterGraph FilterGraph; - -struct FilterGraph { - IFilterGraph_vt* vt; - DECLARE_IUNKNOWN(); - GUID interfaces[2]; - - HRESULT STDCALL (*AddFilter)(FilterGraph* This, - /* [in] */ IBaseFilter* pFilter, - /* [string][in] */ unsigned short* pName); - HRESULT STDCALL (*RemoveFilter)(FilterGraph* This, - /* [in] */ IBaseFilter* pFilter); - HRESULT STDCALL (*EnumFilters)(FilterGraph* This, - /* [out] */ IEnumFilters** ppEnum); - HRESULT STDCALL (*FindFilterByName)(FilterGraph* This, - /* [string][in] */ unsigned short* pName, - /* [out] */ IBaseFilter** ppFilter); - HRESULT STDCALL (*ConnectDirect)(FilterGraph* This, - /* [in] */ IPin* ppinOut, - /* [in] */ IPin* ppinIn, - /* [in] */ const AM_MEDIA_TYPE* pmt); - HRESULT STDCALL (*Reconnect)(FilterGraph* This, - /* [in] */ IPin* ppin); - HRESULT STDCALL (*Disconnect)(FilterGraph* This, - /* [in] */ IPin* ppin); - HRESULT STDCALL (*SetDefaultSyncSource)(FilterGraph* This); -}; - -FilterGraph* FilterGraphCreate(void); - -#endif /* MPLAYER_GRAPH_H */ diff --git a/loader/dshow/guids.c b/loader/dshow/guids.c deleted file mode 100644 index 5d793bb14d..0000000000 --- a/loader/dshow/guids.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "guids.h" - -const GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0, - { 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}}; -const GUID IID_IDivxFilterInterface={0xd132ee97, 0x3e38, 0x4030, - {0x8b, 0x17, 0x59, 0x16, 0x3b, 0x30, 0xa1, 0xf5}}; - -const GUID CLSID_IV50_Decoder={0x30355649, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID IID_IBaseFilter={0x56a86895, 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_IFilterGraph={0x56a8689f, 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_IMemInputPin={0x56a8689d, 0x0ad4, 0x11ce, - {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID IID_IMemAllocator={0x56a8689c, 0x0ad4, 0x11ce, - {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID IID_IMediaSample={0x56a8689a, 0x0ad4, 0x11ce, - {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; - -const GUID MEDIATYPE_Video={0x73646976, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID GUID_NULL={0x0, 0x0, 0x0, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}; -const GUID FORMAT_VideoInfo={0x05589f80, 0xc356, 0x11ce, - {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}; -const GUID MEDIASUBTYPE_RGB1={0xe436eb78, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID MEDIASUBTYPE_RGB4={0xe436eb79, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID MEDIASUBTYPE_RGB8={0xe436eb7a, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID MEDIASUBTYPE_RGB565={0xe436eb7b, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID MEDIASUBTYPE_RGB555={0xe436eb7c, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID MEDIASUBTYPE_RGB24={0xe436eb7d, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID MEDIASUBTYPE_RGB32={0xe436eb7e, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID MEDIASUBTYPE_YUYV={0x56595559, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_IYUV={0x56555949, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_YVU9={0x39555659, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_Y411={0x31313459, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_Y41P={0x50313459, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_YUY2={0x32595559, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_YVYU={0x55595659, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_UYVY={0x59565955, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_Y211={0x31313259, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_YV12={0x32315659, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_I420={0x30323449, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID MEDIASUBTYPE_IF09={0x39304649, 0x0000, 0x0010, - {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; -const GUID CLSID_FilterGraph={0xe436ebb3, 0x524f, 0x11ce, - {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; -const GUID CLSID_MemoryAllocator={0x1e651cc0, 0xb199, 0x11d0, - {0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45}}; -const GUID IID_DivxHidden={0x598eba01, 0xb49a, 0x11d2, - {0xa1, 0xc1, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}}; -const GUID IID_Iv50Hidden={0x665a4442, 0xd905, 0x11d0, - {0xa3, 0x0e, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}; - -const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11CE, - {0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59, 0x5A}}; -const GUID MEDIATYPE_Audio = {0x73647561, 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}}; diff --git a/loader/dshow/guids.h b/loader/dshow/guids.h deleted file mode 100644 index 76a4970d27..0000000000 --- a/loader/dshow/guids.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef MPLAYER_GUIDS_H -#define MPLAYER_GUIDS_H - -/* -this will be defined if <ole2.h> already included before this file -under MinGW -*/ - -#ifndef GUID_DEFINED -#include "loader/com.h" -#endif - -#ifndef VFWAPI -#include "loader/wine/module.h" -#include "loader/wine/windef.h" -#include "loader/wine/vfw.h" -#endif - -#include "mediatype.h" - -//#define Debug if(1) -#define Debug if(0) - - -typedef long long REFERENCE_TIME; - -typedef struct __attribute__((__packed__)) RECT32 -{ - int left, top, right, bottom; -} RECT32; - -typedef struct __attribute__((__packed__)) tagVIDEOINFOHEADER -{ - RECT32 rcSource; // The bit we really want to use - RECT32 rcTarget; // Where the video should go - unsigned long dwBitRate; // Approximate bit data rate - unsigned long dwBitErrorRate; // Bit error rate for this stream - REFERENCE_TIME AvgTimePerFrame; // Average time per frame (100ns units) - BITMAPINFOHEADER bmiHeader; - //int reserved[3]; -} VIDEOINFOHEADER; - -typedef GUID CLSID; -typedef GUID IID; - -extern const GUID IID_IBaseFilter; -extern const GUID IID_IEnumPins; -extern const GUID IID_IEnumMediaTypes; -extern const GUID IID_IFilterGraph; -extern const GUID IID_IMemInputPin; -extern const GUID IID_IMemAllocator; -extern const GUID IID_IMediaSample; -extern const GUID IID_DivxHidden; -extern const GUID IID_Iv50Hidden; -extern const GUID CLSID_DivxDecompressorCF; -extern const GUID IID_IDivxFilterInterface; -extern const GUID CLSID_IV50_Decoder; -extern const GUID CLSID_FilterGraph; -extern const GUID CLSID_MemoryAllocator; -extern const GUID MEDIATYPE_Video; -// avoid a clash with MinGW-W64 libuuid -#define GUID_NULL MP_GUID_NULL -extern const GUID GUID_NULL; -extern const GUID FORMAT_VideoInfo; -extern const GUID MEDIASUBTYPE_RGB1; -extern const GUID MEDIASUBTYPE_RGB4; -extern const GUID MEDIASUBTYPE_RGB8; -extern const GUID MEDIASUBTYPE_RGB565; -extern const GUID MEDIASUBTYPE_RGB555; -extern const GUID MEDIASUBTYPE_RGB24; -extern const GUID MEDIASUBTYPE_RGB32; -extern const GUID MEDIASUBTYPE_YUYV; -extern const GUID MEDIASUBTYPE_IYUV; -extern const GUID MEDIASUBTYPE_YVU9; -extern const GUID MEDIASUBTYPE_Y411; -extern const GUID MEDIASUBTYPE_Y41P; -extern const GUID MEDIASUBTYPE_YUY2; -extern const GUID MEDIASUBTYPE_YVYU; -extern const GUID MEDIASUBTYPE_UYVY; -extern const GUID MEDIASUBTYPE_Y211; -extern const GUID MEDIASUBTYPE_YV12; -extern const GUID MEDIASUBTYPE_I420; -extern const GUID MEDIASUBTYPE_IF09; - -extern const GUID FORMAT_WaveFormatEx; -extern const GUID MEDIATYPE_Audio; -extern const GUID MEDIASUBTYPE_PCM; - -#endif /* MPLAYER_GUIDS_H */ diff --git a/loader/dshow/inputpin.c b/loader/dshow/inputpin.c deleted file mode 100644 index f3ca4ba6c0..0000000000 --- a/loader/dshow/inputpin.c +++ /dev/null @@ -1,1492 +0,0 @@ -/* - * Modified for use with MPlayer, detailed changelog at - * http://svn.mplayerhq.hu/mplayer/trunk/ - */ - -#include "inputpin.h" -#include "mediatype.h" -#include "loader/wine/winerror.h" -#include <string.h> -#include <stdio.h> -#include <stdlib.h> - -static inline int unimplemented(const char* s, void* p) -{ - Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p); - return E_NOTIMPL; -} - -/*********** - * EnumPins - ***********/ - -typedef struct -{ - IEnumPins_vt* vt; - DECLARE_IUNKNOWN(); - IPin* pin1; - IPin* pin2; - int counter; - GUID interfaces[2]; -} CEnumPins; - -/** - * \brief IEnumPins:Next (retrives a specified number of pins ) - * - * \param[in] This pointer to CEnumPins object - * \param[in] cMediaTypes number of pins to retrive - * \param[out] ppMediaTypes array of IPin interface pointers of size cMediaTypes - * \param[out] pcFetched address of variables that receives number of returned pins - * - * \return S_OK - success - * \return S_FALSE - did not return as meny pins as requested - * \return E_INVALIDARG Invalid argument - * \return E_POINTER Null pointer - * \return VFW_E_ENUM_OUT_OF_SYNC - filter's state has changed and is now inconsistent with enumerator - * - */ -static long STDCALL CEnumPins_Next(IEnumPins* This, - /* [in] */ unsigned long cMediaTypes, - /* [size_is][out] */ IPin** ppMediaTypes, - /* [out] */ unsigned long* pcFetched) -{ - CEnumPins* pin = (CEnumPins*)This; - - Debug printf("CEnumPins_Next(%p) called\n", This); - if (!ppMediaTypes) - return E_INVALIDARG; - if (!pcFetched && (cMediaTypes!=1)) - return E_INVALIDARG; - if (cMediaTypes<=0) - return 0; - - //lcounter = ((CEnumPins*)This)->counter; - //lpin1 = ((CEnumPins*)This)->pin1; - //lpin2 = ((CEnumPins*)This)->pin2; - if (((pin->counter == 2) && pin->pin2) - || ((pin->counter == 1) && !pin->pin2)) - { - if (pcFetched) - *pcFetched=0; - return 1; - } - - if (pcFetched) - *pcFetched=1; - if (pin->counter==0) - { - *ppMediaTypes = pin->pin1; - pin->pin1->vt->AddRef((IUnknown*)pin->pin1); - } - else - { - *ppMediaTypes = pin->pin2; - pin->pin2->vt->AddRef((IUnknown*)pin->pin2); - } - pin->counter++; - if (cMediaTypes == 1) - return 0; - return 1; -} - -/** - * \brief IEnumPins::Skip (skips over a specified number of pins) - * - * \param[in] This pointer to CEnumPinss object - * \param[in] cMediaTypes number of pins to skip - * - * \return S_OK - success - * \return S_FALSE - skipped past the end of the sequence - * \return VFW_E_ENUM_OUT_OF_SYNC - filter's state has changed and is now inconsistent with enumerator - * - */ -static long STDCALL CEnumPins_Skip(IEnumPins* This, - /* [in] */ unsigned long cMediaTypes) -{ - Debug unimplemented("CEnumPins_Skip", This); - return E_NOTIMPL; -} - -/** - * \brief IEnumPins::Reset (resets enumeration sequence to beginning) - * - * \param[in] This pointer to CEnumPins object - * - * \return S_OK - success - * - */ -static long STDCALL CEnumPins_Reset(IEnumPins* This) -{ - Debug printf("CEnumPins_Reset(%p) called\n", This); - ((CEnumPins*)This)->counter = 0; - return 0; -} - -/** - * \brief IEnumPins::Clone (makes a copy of enumerator, returned object - * starts at the same position as original) - * - * \param[in] This pointer to CEnumPins object - * \param[out] ppEnum address of variable that receives pointer to IEnumPins interface - * - * \return S_OK - success - * \return E_OUTOFMEMRY - Insufficient memory - * \return E_POINTER - Null pointer - * \return VFW_E_ENUM_OUT_OF_SYNC - filter's state has changed and is now inconsistent with enumerator - * - */ -static long STDCALL CEnumPins_Clone(IEnumPins* This, - /* [out] */ IEnumPins** ppEnum) -{ - Debug unimplemented("CEnumPins_Clone", This); - return E_NOTIMPL; -} - -/** - * \brief CEnumPins destructor - * - * \param[in] This pointer to CEnumPins object - * - */ -static void CEnumPins_Destroy(CEnumPins* This) -{ - free(This->vt); - free(This); -} - -IMPLEMENT_IUNKNOWN(CEnumPins) - -/** - * \brief CEnumPins constructor - * - * \param[in] p first pin for enumerator - * \param[in] pp second pin for enumerator - * - * \return pointer to CEnumPins object or NULL if error occured - * - */ -static CEnumPins* CEnumPinsCreate(IPin* p, IPin* pp) -{ - CEnumPins* This = malloc(sizeof(CEnumPins)); - - if (!This) - return NULL; - - This->refcount = 1; - This->pin1 = p; - This->pin2 = pp; - This->counter = 0; - - This->vt = malloc(sizeof(IEnumPins_vt)); - if (!This->vt) - { - free(This); - return NULL; - } - This->vt->QueryInterface = CEnumPins_QueryInterface; - This->vt->AddRef = CEnumPins_AddRef; - This->vt->Release = CEnumPins_Release; - This->vt->Next = CEnumPins_Next; - This->vt->Skip = CEnumPins_Skip; - This->vt->Reset = CEnumPins_Reset; - This->vt->Clone = CEnumPins_Clone; - - This->interfaces[0] = IID_IUnknown; - This->interfaces[1] = IID_IEnumPins; - - return This; -} - - - -/*********** - * InputPin - * - * WARNING: - * This is implementation of OUTPUT pin in DirectShow's terms - * - ***********/ - -/** - * \brief IPin::Connect (connects pin to another pin) - * - * \param[in] This pointer to IPin interface - * \param[in] pReceivePin pointer to IPin interface of remote pin - * \param[in] pmt suggested media type for link. Can be NULL (any media type) - * - * \return S_OK - success. - * \return VFW_E_ALREADY_CONNECTED - pin already connected - * \return VFW_E_NOT_STOPPED - filter is active - * \return VFW_E_TYPE_NOT_ACCEPT - type is not acceptable - * \return Apropriate error code otherwise. - * - */ -static long STDCALL CInputPin_Connect(IPin* This, - /* [in] */ IPin* pReceivePin, - /* [in] */ AM_MEDIA_TYPE* pmt) -{ - Debug unimplemented("CInputPin_Connect", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::ReceiveConnection (accepts a connection from another pin) - * - * \param[in] This pointer to IPin interface - * \param[in] pConnector connecting pin's IPin interface - * \param[in] pmt suggested media type for connection - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_ALREADY_CONNECTED - pin already connected - * \return VFW_E_NOT_STOPPED - filter is active - * \return VFW_E_TYPE_NOT_ACCEPT - type is not acceptable - * - * \note - * When returning S_OK method should also do the following: - * - store media type and return the same type in IPin::ConnectionMediaType - * - store pConnector and return it in IPin::ConnectedTo - * - */ -static long STDCALL CInputPin_ReceiveConnection(IPin* This, - /* [in] */ IPin* pConnector, - /* [in] */ const AM_MEDIA_TYPE *pmt) -{ - Debug unimplemented("CInputPin_ReceiveConnection", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::Disconnect (accepts a connection from another pin) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return S_FALSE - pin was not connected - * \return VFW_E_NOT_STOPPED - filter is active - * - * \note - * To break connection you have to also call Disconnect on other pin - */ -static long STDCALL CInputPin_Disconnect(IPin* This) -{ - Debug unimplemented("CInputPin_Disconnect", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::ConnectedTo (retrieves pointer to the connected pin, if such exist) - * - * \param[in] This pointer to IPin interface - * \param[out] pPin pointer to remote pin's IPin interface - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_NOT_CONNECTED - pin is not connected - * - * \note - * Caller must call Release on received IPin, when done - */ -static long STDCALL CInputPin_ConnectedTo(IPin* This, - /* [out] */ IPin** pPin) -{ - Debug unimplemented("CInputPin_ConnectedTo", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::ConnectionMediaType (retrieves media type for connection, if such exist) - * - * \param[in] This pointer to IPin interface - * \param[out] pmt pointer to AM_MEDIA_TYPE, that receives connection media type - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_NOT_CONNECTED - pin is not connected - * - */ -static long STDCALL CInputPin_ConnectionMediaType(IPin* This, - /* [out] */ AM_MEDIA_TYPE *pmt) -{ - Debug printf("CInputPin_ConnectionMediaType(%p) called\n", This); - if (!pmt) - return E_INVALIDARG; - CopyMediaType(pmt,&(((CInputPin*)This)->type)); - return 0; -} - -/** - * \brief IPin::QueryPinInfo (retrieves information about the pin) - * - * \param[in] This pointer to IPin interface - * \param[out] pInfo pointer to PIN_INFO structure, that receives pin info - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * - * \note - * If pInfo->pFilter is not NULL, then caller must call Release on pInfo->pFilter when done - * - */ -static long STDCALL CInputPin_QueryPinInfo(IPin* This, - /* [out] */ PIN_INFO *pInfo) -{ - CBaseFilter* lparent=((CInputPin*)This)->parent; - Debug printf("CInputPin_QueryPinInfo(%p) called\n", This); - pInfo->dir = PINDIR_OUTPUT; - pInfo->pFilter = (IBaseFilter*) lparent; - lparent->vt->AddRef((IUnknown*)lparent); - pInfo->achName[0] = 0; - return 0; -} - -/** - * \brief IPin::QueryDirection (retrieves pin direction) - * - * \param[in] This pointer to IPin interface - * \param[out] pPinDir pointer to variable, that receives pin direction (PINDIR_INPUT,PINDIR_OUTPUT) - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * - */ -static long STDCALL CInputPin_QueryDirection(IPin* This, - /* [out] */ PIN_DIRECTION *pPinDir) -{ - *pPinDir = PINDIR_OUTPUT; - Debug printf("CInputPin_QueryDirection(%p) called\n", This); - return 0; -} - -/** - * \brief IPin::QueryId (retrieves pin identificator) - * - * \param[in] This pointer to IPin interface - * \param[out] Id adress of variable, that receives string with pin's Id. - * - * \return S_OK - success - * \return E_OUTOFMEMORY - Insufficient memory - * \return E_POINTER - Null pointer - * - * \note - * Pin's Id is not the same as pin's name - * - */ -static long STDCALL CInputPin_QueryId(IPin* This, - /* [out] */ unsigned short* *Id) -{ - Debug unimplemented("CInputPin_QueryId", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::QueryAccept (determines can media type be accepted or not) - * - * \param[in] This pointer to IPin interface - * \param[in] pmt Media type to check - * - * \return S_OK - success - * \return S_FALSE - pin rejects media type - * - */ -static long STDCALL CInputPin_QueryAccept(IPin* This, - /* [in] */ const AM_MEDIA_TYPE* pmt) -{ - Debug unimplemented("CInputPin_QueryAccept", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::EnumMediaTypes (enumerates the pin's preferred media types) - * - * \param[in] This pointer to IPin interface - * \param[out] ppEnum adress of variable that receives pointer to IEnumMEdiaTypes interface - * - * \return S_OK - success - * \return E_OUTOFMEMORY - Insufficient memory - * \return E_POINTER - Null pointer - * - * \note - * Caller must call Release on received interface when done - * - */ -static long STDCALL CInputPin_EnumMediaTypes(IPin* This, - /* [out] */ IEnumMediaTypes** ppEnum) -{ - Debug unimplemented("CInputPin_EnumMediaTypes", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::QueryInternalConnections (retries pin's internal connections) - * - * \param[in] This pointer to IPin interface - * \param[out] apPin Array that receives pins, internally connected to this - * \param[in,out] nPint Size of an array - * - * \return S_OK - success - * \return S_FALSE - pin rejects media type - * \return E_NOTIMPL - not implemented - * - */ -static long STDCALL CInputPin_QueryInternalConnections(IPin* This, - /* [out] */ IPin** apPin, - /* [out][in] */ unsigned long *nPin) -{ - Debug unimplemented("CInputPin_QueryInternalConnections", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::EndOfStream (notifies pin, that no data is expected, until new run command) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - * \note - * IMemoryInputPin::Receive,IMemoryInputPin::ReceiveMultiple, IMemoryInputPin::EndOfStream, - * IMemAllocator::GetBuffer runs in different (streaming) thread then other - * methods (application thread). - * IMemoryInputPin::NewSegment runs either in streaming or application thread. - * Developer must use critical sections for thread-safing work. - * - */ -static long STDCALL CInputPin_EndOfStream(IPin * This) -{ - Debug unimplemented("CInputPin_EndOfStream", This); - return E_NOTIMPL; -} - - -/** - * \brief IPin::BeginFlush (begins a flush operation) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - */ -static long STDCALL CInputPin_BeginFlush(IPin * This) -{ - Debug unimplemented("CInputPin_BeginFlush", This); - return E_NOTIMPL; -} - - -/** - * \brief IPin::EndFlush (ends a flush operation) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - */ -static long STDCALL CInputPin_EndFlush(IPin* This) -{ - Debug unimplemented("CInputPin_EndFlush", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::NewSegment (media sample received after this call grouped as segment with common - * start,stop time and rate) - * - * \param[in] This pointer to IPin interface - * \param[in] tStart start time of new segment - * \param[in] tStop end time of new segment - * \param[in] dRate rate at wich segment should be processed - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - */ -static long STDCALL CInputPin_NewSegment(IPin* This, - /* [in] */ REFERENCE_TIME tStart, - /* [in] */ REFERENCE_TIME tStop, - /* [in] */ double dRate) -{ - Debug unimplemented("CInputPin_NewSegment", This); - return E_NOTIMPL; -} - -/** - * \brief CInputPin destructor - * - * \param[in] This pointer to CInputPin class - * - */ -static void CInputPin_Destroy(CInputPin* This) -{ - free(This->vt); - FreeMediaType(&(This->type)); - free(This); -} - -IMPLEMENT_IUNKNOWN(CInputPin) - -/** - * \brief CInputPin constructor - * - * \param[in] amt media type for pin - * - * \return pointer to CInputPin if success - * \return NULL if error occured - * - */ -CInputPin* CInputPinCreate(CBaseFilter* p, const AM_MEDIA_TYPE* amt) -{ - CInputPin* This = malloc(sizeof(CInputPin)); - - if (!This) - return NULL; - - This->refcount = 1; - This->parent = p; - CopyMediaType(&(This->type),amt); - - This->vt= malloc(sizeof(IPin_vt)); - - if (!This->vt) - { - free(This); - return NULL; - } - - This->vt->QueryInterface = CInputPin_QueryInterface; - This->vt->AddRef = CInputPin_AddRef; - This->vt->Release = CInputPin_Release; - This->vt->Connect = CInputPin_Connect; - This->vt->ReceiveConnection = CInputPin_ReceiveConnection; - This->vt->Disconnect = CInputPin_Disconnect; - This->vt->ConnectedTo = CInputPin_ConnectedTo; - This->vt->ConnectionMediaType = CInputPin_ConnectionMediaType; - This->vt->QueryPinInfo = CInputPin_QueryPinInfo; - This->vt->QueryDirection = CInputPin_QueryDirection; - This->vt->QueryId = CInputPin_QueryId; - This->vt->QueryAccept = CInputPin_QueryAccept; - This->vt->EnumMediaTypes = CInputPin_EnumMediaTypes; - This->vt->QueryInternalConnections = CInputPin_QueryInternalConnections; - This->vt->EndOfStream = CInputPin_EndOfStream; - This->vt->BeginFlush = CInputPin_BeginFlush; - This->vt->EndFlush = CInputPin_EndFlush; - This->vt->NewSegment = CInputPin_NewSegment; - - This->interfaces[0]=IID_IUnknown; - - return This; -} - - -/************* - * BaseFilter - *************/ - -static long STDCALL CBaseFilter_GetClassID(IBaseFilter * This, - /* [out] */ CLSID *pClassID) -{ - Debug unimplemented("CBaseFilter_GetClassID", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::Stop (stops the filter) - * - * \param[in] This pointer to IBaseFilter interface - * - * \return S_OK success - * \return S_FALSE transition is not complete - * - * \remarks - * When filter is stopped it does onot deliver or process any samples and rejects any samples - * from upstream filter. - * Transition may be asynchronous. In this case method should return S_FALSE. - * Method always sets filter's state to State_Stopped even if error occured. - * - */ -static long STDCALL CBaseFilter_Stop(IBaseFilter* This) -{ - Debug unimplemented("CBaseFilter_Stop", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::Pause (pauses filter) - * - * \param[in] This pointer to IBaseFilter interface - * - * \return S_OK success - * \return S_FALSE transition is not complete - * - * \remarks - * When filter is paused it can receive, process and deliver samples. - * Live source filters do not deliver any samples while paused. - * Transition may be asynchronous. In this case method should return S_FALSE. - * Method always sets filter's state to State_Stopped even if error occured. - * - */ -static long STDCALL CBaseFilter_Pause(IBaseFilter* This) -{ - Debug unimplemented("CBaseFilter_Pause", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::Run (runs the filter) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] tStart Reference time corresponding to stream time 0. - * - * \return S_OK success - * \return S_FALSE transition is not complete - * - * \remarks - * When filter is running it can receive, process and deliver samples. Source filters - * generatesnew samples, and renderers renders them. - * Stream time is calculated as the current reference time minus tStart. - * Graph Manager sets tStart slightly in the future according to graph latency. - * - */ -static long STDCALL CBaseFilter_Run(IBaseFilter* This, REFERENCE_TIME tStart) -{ - Debug unimplemented("CBaseFilter_Run", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::GetState (retrieves the filter's state (running, stopped or paused)) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] dwMilliSecsTimeout Timeout interval in milliseconds. To block indifinitely pass - * INFINITE. - * \param[out] State pointer to variable that receives a member of FILTER_STATE enumeration. - * - * \return S_OK success - * \return E_POINTER Null pointer - * \return VFW_S_STATE_INTERMEDATE Intermediate state - * \return VFW_S_CANT_CUE The filter is active, but cannot deliver data. - * - */ -static long STDCALL CBaseFilter_GetState(IBaseFilter* This, - /* [in] */ unsigned long dwMilliSecsTimeout, - // /* [out] */ FILTER_STATE *State) - void* State) -{ - Debug unimplemented("CBaseFilter_GetState", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::SetSyncSource (sets the reference clock) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] pClock IReferenceClock interface of reference clock - * - * \return S_OK success - * \return apripriate error otherwise - * - */ -static long STDCALL CBaseFilter_SetSyncSource(IBaseFilter* This, - /* [in] */ IReferenceClock *pClock) -{ - Debug unimplemented("CBaseFilter_SetSyncSource", This); - return E_NOTIMPL; -} - -/** - * \brief IMediafilter::GetSyncSource (gets current reference clock) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] pClock address of variable that receives pointer to clock's - * IReferenceClock interface - * - * \return S_OK success - * \return E_POINTER Null pointer - * - */ -static long STDCALL CBaseFilter_GetSyncSource(IBaseFilter* This, - /* [out] */ IReferenceClock **pClock) -{ - Debug unimplemented("CBaseFilter_GetSyncSource", This); - return E_NOTIMPL; -} - - -/** - * \brief IBaseFilter::EnumPins (enumerates the pins of this filter) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] ppEnum address of variable that receives pointer to IEnumPins interface - * - * \return S_OK success - * \return E_OUTOFMEMORY Insufficient memory - * \return E_POINTER Null pointer - * - */ -static long STDCALL CBaseFilter_EnumPins(IBaseFilter* This, - /* [out] */ IEnumPins **ppEnum) -{ - Debug printf("CBaseFilter_EnumPins(%p) called\n", This); - *ppEnum = (IEnumPins*) CEnumPinsCreate(((CBaseFilter*)This)->pin, ((CBaseFilter*)This)->unused_pin); - return 0; -} - -/** - * \brief IBaseFilter::FindPin (retrieves the pin with specified id) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] Id constant wide string, containing pin id - * \param[out] ppPin address of variable that receives pointer to pin's IPin interface - * - * \return S_OK success - * \return E_POINTER Null pointer - * \return VFW_E_NOT_FOUND Could not find a pin with specified id - * - * \note - * Be sure to release the interface after use. - * - */ -static long STDCALL CBaseFilter_FindPin(IBaseFilter* This, - /* [string][in] */ const unsigned short* Id, - /* [out] */ IPin **ppPin) -{ - Debug unimplemented("CBaseFilter_FindPin\n", This); - return E_NOTIMPL; -} - -/** - * \brief IBaseFilter::QueryFilterInfo (retrieves information aboud the filter) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] pInfo pointer to FILTER_INFO structure - * - * \return S_OK success - * \return E_POINTER Null pointer - * - * \note - * If pGraph member of FILTER_INFO is not NULL, be sure to release IFilterGraph interface after use. - * - */ -static long STDCALL CBaseFilter_QueryFilterInfo(IBaseFilter* This, - // /* [out] */ FILTER_INFO *pInfo) - void* pInfo) -{ - Debug unimplemented("CBaseFilter_QueryFilterInfo", This); - return E_NOTIMPL; -} - -/** - * \brief IBaseFilter::JoinFilterGraph (notifies the filter that it has joined of left filter graph) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] pInfo pointer to graph's IFilterGraph interface or NULL if filter is leaving graph - * \param[in] pName pointer to wide character string that specifies a name for the filter - * - * \return S_OK success - * \return apropriate error code otherwise - * - * \remarks - * Filter should not call to graph's AddRef method. - * The IFilterGraph is guaranteed to be valid until graph manager calls this method again with - * the value NULL. - * - */ -static long STDCALL CBaseFilter_JoinFilterGraph(IBaseFilter* This, - /* [in] */ IFilterGraph* pGraph, - /* [string][in] */ const unsigned short* pName) -{ - Debug unimplemented("CBaseFilter_JoinFilterGraph", This); - return E_NOTIMPL; -} - -/** - * \brief IBaseFilter::QueryVendorInfo (retrieves a string containing vendor info) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] address of variable that receives pointer to a string containing vendor info - * - * \return S_OK success - * \return E_POINTER Null pointer - * \return E_NOTIMPL Not implemented - * - * \remarks - * Call to CoTaskMemFree to free memory allocated for string - * - */ -static long STDCALL CBaseFilter_QueryVendorInfo(IBaseFilter* This, - /* [string][out] */ unsigned short** pVendorInfo) -{ - Debug unimplemented("CBaseFilter_QueryVendorInfo", This); - return E_NOTIMPL; -} - -/** - * \brief CBaseFilter::GetPin (gets used pin) - * - * \param[in] This pointer to CBaseFilter object - * - * \return pointer to used pin's IPin interface - * - */ -static IPin* CBaseFilter_GetPin(CBaseFilter* This) -{ - return This->pin; -} - -/** - * \brief CBaseFilter::GetUnusedPin (gets used pin) - * - * \param[in] This pointer to CBaseFilter object - * - * \return pointer to unused pin's IPin interface - * - */ -static IPin* CBaseFilter_GetUnusedPin(CBaseFilter* This) -{ - return This->unused_pin; -} - -/** - * \brief CBaseFilter destructor - * - * \param[in] This pointer to CBaseFilter object - * - */ -static void CBaseFilter_Destroy(CBaseFilter* This) -{ - free(This->vt); - if (This->pin) - This->pin->vt->Release((IUnknown*)This->pin); - if (This->unused_pin) - This->unused_pin->vt->Release((IUnknown*)This->unused_pin); - free(This); -} - -IMPLEMENT_IUNKNOWN(CBaseFilter) - -/** - * \brief CBaseFilter constructor - * - * \param[in] type Pointer to media type for connection - * \param[in] parent Pointer to parent CBaseFilter2 object - * - * \return pointer to CBaseFilter object or NULL if error occured - * - */ -CBaseFilter* CBaseFilterCreate(const AM_MEDIA_TYPE* type, CBaseFilter2* parent) -{ - CBaseFilter* This = malloc(sizeof(CBaseFilter)); - if (!This) - return NULL; - - This->refcount = 1; - - This->pin = (IPin*) CInputPinCreate(This, type); - This->unused_pin = (IPin*) CRemotePinCreate(This, parent->GetPin(parent)); - - This->vt = malloc(sizeof(IBaseFilter_vt)); - if (!This->vt || !This->pin || !This->unused_pin) - { - CBaseFilter_Destroy(This); - return NULL; - } - - This->vt->QueryInterface = CBaseFilter_QueryInterface; - This->vt->AddRef = CBaseFilter_AddRef; - This->vt->Release = CBaseFilter_Release; - This->vt->GetClassID = CBaseFilter_GetClassID; - This->vt->Stop = CBaseFilter_Stop; - This->vt->Pause = CBaseFilter_Pause; - This->vt->Run = CBaseFilter_Run; - This->vt->GetState = CBaseFilter_GetState; - This->vt->SetSyncSource = CBaseFilter_SetSyncSource; - This->vt->GetSyncSource = CBaseFilter_GetSyncSource; - This->vt->EnumPins = CBaseFilter_EnumPins; - This->vt->FindPin = CBaseFilter_FindPin; - This->vt->QueryFilterInfo = CBaseFilter_QueryFilterInfo; - This->vt->JoinFilterGraph = CBaseFilter_JoinFilterGraph; - This->vt->QueryVendorInfo = CBaseFilter_QueryVendorInfo; - - This->interfaces[0] = IID_IUnknown; - This->interfaces[1] = IID_IBaseFilter; - - This->GetPin = CBaseFilter_GetPin; - This->GetUnusedPin = CBaseFilter_GetUnusedPin; - - return This; -} - - -/************** - * BaseFilter2 - **************/ - - -static long STDCALL CBaseFilter2_GetClassID(IBaseFilter* This, - /* [out] */ CLSID* pClassID) -{ - Debug unimplemented("CBaseFilter2_GetClassID", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::Stop (stops the filter) - * - * \param[in] This pointer to IBaseFilter interface - * - * \return S_OK success - * \return S_FALSE transition is not complete - * - * \remarks - * When filter is stopped it does onot deliver or process any samples and rejects any samples - * from upstream filter. - * Transition may be asynchronous. In this case method should return S_FALSE. - * Method always sets filter's state to State_Stopped even if error occured. - * - */ -static long STDCALL CBaseFilter2_Stop(IBaseFilter* This) -{ - Debug unimplemented("CBaseFilter2_Stop", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::Pause (pauses filter) - * - * \param[in] This pointer to IBaseFilter interface - * - * \return S_OK success - * \return S_FALSE transition is not complete - * - * \remarks - * When filter is paused it can receive, process and deliver samples. - * Live source filters do not deliver any samples while paused. - * Transition may be asynchronous. In this case method should return S_FALSE. - * Method always sets filter's state to State_Stopped even if error occured. - * - */ -static long STDCALL CBaseFilter2_Pause(IBaseFilter* This) -{ - Debug unimplemented("CBaseFilter2_Pause", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::Run (runs the filter) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] tStart Reference time corresponding to stream time 0. - * - * \return S_OK success - * \return S_FALSE transition is not complete - * - * \remarks - * When filter is running it can receive, process and deliver samples. Source filters - * generatesnew samples, and renderers renders them. - * Stream time is calculated as the current reference time minus tStart. - * Graph Manager sets tStart slightly in the future according to graph latency. - * - */ -static long STDCALL CBaseFilter2_Run(IBaseFilter* This, REFERENCE_TIME tStart) -{ - Debug unimplemented("CBaseFilter2_Run", This); - return E_NOTIMPL; -} - - -/** - * \brief IMediaFilter::GetState (retrieves the filter's state (running, stopped or paused)) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] dwMilliSecsTimeout Timeout interval in milliseconds. To block indifinitely pass - * INFINITE. - * \param[out] State pointer to variable that receives a member of FILTER_STATE enumeration. - * - * \return S_OK success - * \return E_POINTER Null pointer - * \return VFW_S_STATE_INTERMEDATE Intermediate state - * \return VFW_S_CANT_CUE The filter is active, but cannot deliver data. - * - */ -static long STDCALL CBaseFilter2_GetState(IBaseFilter* This, - /* [in] */ unsigned long dwMilliSecsTimeout, - // /* [out] */ FILTER_STATE *State) - void* State) -{ - Debug unimplemented("CBaseFilter2_GetState", This); - return E_NOTIMPL; -} - -/** - * \brief IMediaFilter::SetSyncSource (sets the reference clock) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] pClock IReferenceClock interface of reference clock - * - * \return S_OK success - * \return apripriate error otherwise - * - */ -static long STDCALL CBaseFilter2_SetSyncSource(IBaseFilter* This, - /* [in] */ IReferenceClock* pClock) -{ - Debug unimplemented("CBaseFilter2_SetSyncSource", This); - return E_NOTIMPL; -} - -/** - * \brief IMediafilter::GetSyncSource (gets current reference clock) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] pClock address of variable that receives pointer to clock's - * IReferenceClock interface - * - * \return S_OK success - * \return E_POINTER Null pointer - * - */ -static long STDCALL CBaseFilter2_GetSyncSource(IBaseFilter* This, - /* [out] */ IReferenceClock** pClock) -{ - Debug unimplemented("CBaseFilter2_GetSyncSource", This); - return E_NOTIMPL; -} - -/** - * \brief IBaseFilter::EnumPins (enumerates the pins of this filter) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] ppEnum address of variable that receives pointer to IEnumPins interface - * - * \return S_OK success - * \return E_OUTOFMEMORY Insufficient memory - * \return E_POINTER Null pointer - * - */ -static long STDCALL CBaseFilter2_EnumPins(IBaseFilter* This, - /* [out] */ IEnumPins** ppEnum) -{ - Debug printf("CBaseFilter2_EnumPins(%p) called\n", This); - *ppEnum = (IEnumPins*) CEnumPinsCreate(((CBaseFilter2*)This)->pin, 0); - return 0; -} - -/** - * \brief IBaseFilter::FindPin (retrieves the pin with specified id) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] Id constant wide string, containing pin id - * \param[out] ppPin address of variable that receives pointer to pin's IPin interface - * - * \return S_OK success - * \return E_POINTER Null pointer - * \return VFW_E_NOT_FOUND Could not find a pin with specified id - * - * \note - * Be sure to release the interface after use. - * - */ -static long STDCALL CBaseFilter2_FindPin(IBaseFilter* This, - /* [string][in] */ const unsigned short* Id, - /* [out] */ IPin** ppPin) -{ - Debug unimplemented("CBaseFilter2_FindPin", This); - return E_NOTIMPL; -} - -/** - * \brief IBaseFilter::QueryFilterInfo (retrieves information aboud the filter) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] pInfo pointer to FILTER_INFO structure - * - * \return S_OK success - * \return E_POINTER Null pointer - * - * \note - * If pGraph member of FILTER_INFO is not NULL, be sure to release IFilterGraph interface after use. - * - */ -static long STDCALL CBaseFilter2_QueryFilterInfo(IBaseFilter* This, - // /* [out] */ FILTER_INFO *pInfo) - void* pInfo) -{ - Debug unimplemented("CBaseFilter2_QueryFilterInfo", This); - return E_NOTIMPL; -} - -/** - * \brief IBaseFilter::JoinFilterGraph (notifies the filter that it has joined of left filter graph) - * - * \param[in] This pointer to IBaseFilter interface - * \param[in] pInfo pointer to graph's IFilterGraph interface or NULL if filter is leaving graph - * \param[in] pName pointer to wide character string that specifies a name for the filter - * - * \return S_OK success - * \return apropriate error code otherwise - * - * \remarks - * Filter should not call to graph's AddRef method. - * The IFilterGraph is guaranteed to be valid until graph manager calls this method again with - * the value NULL. - * - */ -static long STDCALL CBaseFilter2_JoinFilterGraph(IBaseFilter* This, - /* [in] */ IFilterGraph* pGraph, - /* [string][in] */ - const unsigned short* pName) -{ - Debug unimplemented("CBaseFilter2_JoinFilterGraph", This); - return E_NOTIMPL; -} - -/** - * \brief IBaseFilter::QueryVendorInfo (retrieves a string containing vendor info) - * - * \param[in] This pointer to IBaseFilter interface - * \param[out] address of variable that receives pointer to a string containing vendor info - * - * \return S_OK success - * \return E_POINTER Null pointer - * \return E_NOTIMPL Not implemented - * - * \remarks - * Call to CoTaskMemFree to free memory allocated for string - * - */ -static long STDCALL CBaseFilter2_QueryVendorInfo(IBaseFilter* This, - /* [string][out] */ - unsigned short** pVendorInfo) -{ - Debug unimplemented("CBaseFilter2_QueryVendorInfo", This); - return E_NOTIMPL; -} - -/** - * \brief CBaseFilter2::GetPin (gets used pin) - * - * \param[in] This pointer to CBaseFilter2 object - * - * \return pointer to used pin's IPin interface - * - */ -static IPin* CBaseFilter2_GetPin(CBaseFilter2* This) -{ - return This->pin; -} - -/** - * \brief CBaseFilter2 destructor - * - * \param[in] This pointer to CBaseFilter2 object - * - */ -static void CBaseFilter2_Destroy(CBaseFilter2* This) -{ - Debug printf("CBaseFilter2_Destroy(%p) called\n", This); - if (This->pin) - This->pin->vt->Release((IUnknown*) This->pin); - free(This->vt); - free(This); -} - -IMPLEMENT_IUNKNOWN(CBaseFilter2) - -static GUID CBaseFilter2_interf1 = -{0x76c61a30, 0xebe1, 0x11cf, {0x89, 0xf9, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}}; -/// IID_IAMNetShowPreroll -static GUID CBaseFilter2_interf2 = -{0xaae7e4e2, 0x6388, 0x11d1, {0x8d, 0x93, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}}; -/// IID_IAMRebuild -static GUID CBaseFilter2_interf3 = -{0x02ef04dd, 0x7580, 0x11d1, {0xbe, 0xce, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x37}}; - -/** - * \brief CBaseFilter2 constructor - * - * \return pointer to CBaseFilter2 object or NULL if error occured - * - */ -CBaseFilter2* CBaseFilter2Create() -{ - CBaseFilter2* This = malloc(sizeof(CBaseFilter2)); - - if (!This) - return NULL; - - This->refcount = 1; - This->pin = (IPin*) CRemotePin2Create(This); - - This->vt = malloc(sizeof(IBaseFilter_vt)); - - if (!This->pin || !This->vt) - { - CBaseFilter2_Destroy(This); - return NULL; - } - - memset(This->vt, 0, sizeof(IBaseFilter_vt)); - This->vt->QueryInterface = CBaseFilter2_QueryInterface; - This->vt->AddRef = CBaseFilter2_AddRef; - This->vt->Release = CBaseFilter2_Release; - This->vt->GetClassID = CBaseFilter2_GetClassID; - This->vt->Stop = CBaseFilter2_Stop; - This->vt->Pause = CBaseFilter2_Pause; - This->vt->Run = CBaseFilter2_Run; - This->vt->GetState = CBaseFilter2_GetState; - This->vt->SetSyncSource = CBaseFilter2_SetSyncSource; - This->vt->GetSyncSource = CBaseFilter2_GetSyncSource; - This->vt->EnumPins = CBaseFilter2_EnumPins; - This->vt->FindPin = CBaseFilter2_FindPin; - This->vt->QueryFilterInfo = CBaseFilter2_QueryFilterInfo; - This->vt->JoinFilterGraph = CBaseFilter2_JoinFilterGraph; - This->vt->QueryVendorInfo = CBaseFilter2_QueryVendorInfo; - - This->GetPin = CBaseFilter2_GetPin; - - This->interfaces[0] = IID_IUnknown; - This->interfaces[1] = IID_IBaseFilter; - This->interfaces[2] = CBaseFilter2_interf1; - This->interfaces[3] = CBaseFilter2_interf2; - This->interfaces[4] = CBaseFilter2_interf3; - - return This; -} - - -/************* - * CRemotePin - *************/ - - -/** - * \brief IPin::ConnectedTo (retrieves pointer to the connected pin, if such exist) - * - * \param[in] This pointer to IPin interface - * \param[out] pPin pointer to remote pin's IPin interface - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_NOT_CONNECTED - pin is not connected - * - * \note - * Caller must call Release on received IPin, when done - */ -static long STDCALL CRemotePin_ConnectedTo(IPin* This, /* [out] */ IPin** pPin) -{ - Debug printf("CRemotePin_ConnectedTo(%p) called\n", This); - if (!pPin) - return E_INVALIDARG; - *pPin = ((CRemotePin*)This)->remote_pin; - (*pPin)->vt->AddRef((IUnknown*)(*pPin)); - return 0; -} - -/** - * \brief IPin::QueryDirection (retrieves pin direction) - * - * \param[in] This pointer to IPin interface - * \param[out] pPinDir pointer to variable, that receives pin direction (PINDIR_INPUT,PINDIR_OUTPUT) - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * - */ -static long STDCALL CRemotePin_QueryDirection(IPin* This, - /* [out] */ PIN_DIRECTION* pPinDir) -{ - Debug printf("CRemotePin_QueryDirection(%p) called\n", This); - if (!pPinDir) - return E_INVALIDARG; - *pPinDir=PINDIR_INPUT; - return 0; -} - -/** - * \brief IPin::ConnectionMediaType (retrieves media type for connection, if such exist) - * - * \param[in] This pointer to IPin interface - * \param[out] pmt pointer to AM_MEDIA_TYPE, that receives connection media type - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_NOT_CONNECTED - pin is not connected - * - */ -static long STDCALL CRemotePin_ConnectionMediaType(IPin* This, /* [out] */ AM_MEDIA_TYPE* pmt) -{ - Debug unimplemented("CRemotePin_ConnectionMediaType", This); - return E_NOTIMPL; -} - -/** - * \brief IPin::QueryPinInfo (retrieves information about the pin) - * - * \param[in] This pointer to IPin interface - * \param[out] pInfo pointer to PIN_INFO structure, that receives pin info - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * - * \note - * If pInfo->pFilter is not NULL, then caller must call Release on pInfo->pFilter when done - * - */ -static long STDCALL CRemotePin_QueryPinInfo(IPin* This, /* [out] */ PIN_INFO* pInfo) -{ - CBaseFilter* lparent = ((CRemotePin*)This)->parent; - Debug printf("CRemotePin_QueryPinInfo(%p) called\n", This); - pInfo->dir= PINDIR_INPUT; - pInfo->pFilter = (IBaseFilter*) lparent; - lparent->vt->AddRef((IUnknown*)lparent); - pInfo->achName[0]=0; - return 0; -} - -/** - * \brief CRemotePin destructor - * - * \param[in] This pointer to CRemotePin object - * - */ -static void CRemotePin_Destroy(CRemotePin* This) -{ - Debug printf("CRemotePin_Destroy(%p) called\n", This); - free(This->vt); - free(This); -} - -IMPLEMENT_IUNKNOWN(CRemotePin) - -/** - * \brief CRemotePin constructor - * - * \param[in] pt parent filter - * \param[in] rpin remote pin - * - * \return pointer to CRemotePin or NULL if error occured - * - */ -CRemotePin* CRemotePinCreate(CBaseFilter* pt, IPin* rpin) -{ - CRemotePin* This = malloc(sizeof(CRemotePin)); - - if (!This) - return NULL; - - Debug printf("CRemotePinCreate() called -> %p\n", This); - - This->parent = pt; - This->remote_pin = rpin; - This->refcount = 1; - - This->vt = malloc(sizeof(IPin_vt)); - - if (!This->vt) - { - free(This); - return NULL; - } - - memset(This->vt, 0, sizeof(IPin_vt)); - This->vt->QueryInterface = CRemotePin_QueryInterface; - This->vt->AddRef = CRemotePin_AddRef; - This->vt->Release = CRemotePin_Release; - This->vt->QueryDirection = CRemotePin_QueryDirection; - This->vt->ConnectedTo = CRemotePin_ConnectedTo; - This->vt->ConnectionMediaType = CRemotePin_ConnectionMediaType; - This->vt->QueryPinInfo = CRemotePin_QueryPinInfo; - - This->interfaces[0] = IID_IUnknown; - - return This; -} - - -/************* - * CRemotePin2 - *************/ - - -/** - * \brief IPin::QueryPinInfo (retrieves information about the pin) - * - * \param[in] This pointer to IPin interface - * \param[out] pInfo pointer to PIN_INFO structure, that receives pin info - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * - * \note - * If pInfo->pFilter is not NULL, then caller must call Release on pInfo->pFilter when done - * - */ -static long STDCALL CRemotePin2_QueryPinInfo(IPin* This, - /* [out] */ PIN_INFO* pInfo) -{ - CBaseFilter2* lparent=((CRemotePin2*)This)->parent; - Debug printf("CRemotePin2_QueryPinInfo(%p) called\n", This); - pInfo->pFilter=(IBaseFilter*)lparent; - lparent->vt->AddRef((IUnknown*)lparent); - pInfo->dir=PINDIR_OUTPUT; - pInfo->achName[0]=0; - return 0; -} - -/** - * \brief CremotePin2 destructor - * - * \param This pointer to CRemotePin2 object - * - * FIXME - not being released! - */ -static void CRemotePin2_Destroy(CRemotePin2* This) -{ - Debug printf("CRemotePin2_Destroy(%p) called\n", This); - free(This->vt); - free(This); -} - -IMPLEMENT_IUNKNOWN(CRemotePin2) - -/** - * \brief CRemotePin2 contructor - * - * \param[in] p pointer to parent CBaseFilter2 object - * - * \return pointer to CRemotePin2 object or NULL if error occured - * - */ -CRemotePin2* CRemotePin2Create(CBaseFilter2* p) -{ - CRemotePin2* This = malloc(sizeof(CRemotePin2)); - - if (!This) - return NULL; - - Debug printf("CRemotePin2Create() called -> %p\n", This); - - This->parent = p; - This->refcount = 1; - - This->vt = malloc(sizeof(IPin_vt)); - - if (!This->vt) - { - free(This); - return NULL; - } - - memset(This->vt, 0, sizeof(IPin_vt)); - This->vt->QueryInterface = CRemotePin2_QueryInterface; - This->vt->AddRef = CRemotePin2_AddRef; - This->vt->Release = CRemotePin2_Release; - This->vt->QueryPinInfo = CRemotePin2_QueryPinInfo; - - This->interfaces[0] = IID_IUnknown; - - return This; -} diff --git a/loader/dshow/inputpin.h b/loader/dshow/inputpin.h deleted file mode 100644 index 02f1c8b98f..0000000000 --- a/loader/dshow/inputpin.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef MPLAYER_INPUTPIN_H -#define MPLAYER_INPUTPIN_H - -#include "interfaces.h" - -typedef struct CBaseFilter2 CBaseFilter2; -struct CBaseFilter2 -{ - IBaseFilter_vt* vt; - DECLARE_IUNKNOWN(); - IPin* pin; - GUID interfaces[5]; - - IPin* ( *GetPin )(CBaseFilter2* This); -}; - -CBaseFilter2* CBaseFilter2Create(void); - - -typedef struct CBaseFilter CBaseFilter; -struct CBaseFilter -{ - IBaseFilter_vt* vt; - DECLARE_IUNKNOWN(); // has to match CBaseFilter2 - INHERITANCE!! - IPin* pin; - IPin* unused_pin; - GUID interfaces[2]; - - IPin* ( *GetPin )(CBaseFilter* This); - IPin* ( *GetUnusedPin )(CBaseFilter* This); -}; - -CBaseFilter* CBaseFilterCreate(const AM_MEDIA_TYPE* vhdr, CBaseFilter2* parent); - - -typedef struct -{ - IPin_vt* vt; - DECLARE_IUNKNOWN(); - CBaseFilter* parent; - AM_MEDIA_TYPE type; - GUID interfaces[1]; -} CInputPin; - -CInputPin* CInputPinCreate(CBaseFilter* parent, const AM_MEDIA_TYPE* vhdr); - - -typedef struct -{ - IPin_vt* vt; - DECLARE_IUNKNOWN(); - CBaseFilter* parent; - GUID interfaces[1]; - IPin* remote_pin; -} CRemotePin; - -CRemotePin* CRemotePinCreate(CBaseFilter* pt, IPin* rpin); - - -typedef struct -{ - IPin_vt* vt; - DECLARE_IUNKNOWN(); - CBaseFilter2* parent; - GUID interfaces[1]; -} CRemotePin2; - -CRemotePin2* CRemotePin2Create(CBaseFilter2* parent); - -#endif /* MPLAYER_INPUTPIN_H */ diff --git a/loader/dshow/interfaces.h b/loader/dshow/interfaces.h deleted file mode 100644 index af9544ada5..0000000000 --- a/loader/dshow/interfaces.h +++ /dev/null @@ -1,360 +0,0 @@ -#ifndef MPLAYER_INTERFACES_H -#define MPLAYER_INTERFACES_H - -/* - * Definition of important DirectShow interfaces. - * Created using freely-available DirectX 8.0 SDK - * ( http://msdn.microsoft.com ) - */ - -#include "iunk.h" -#include "loader/com.h" - -/* Sh*t. MSVC++ and g++ use different methods of storing vtables. */ - -typedef struct IReferenceClock IReferenceClock; -typedef struct IFilterGraph IFilterGraph; - -typedef struct IBaseFilter IBaseFilter; - -typedef enum -{ - PINDIR_INPUT = 0, - PINDIR_OUTPUT -} PIN_DIRECTION; - -typedef struct PinInfo -{ - IBaseFilter* pFilter; - PIN_DIRECTION dir; - unsigned short achName[128]; -} PIN_INFO; - -typedef struct AllocatorProperties -{ - long cBuffers; - long cbBuffer; - long cbAlign; - long cbPrefix; -} ALLOCATOR_PROPERTIES; - -typedef struct IEnumMediaTypes IEnumMediaTypes; -typedef struct IEnumMediaTypes_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *Next )(IEnumMediaTypes* This, - /* [in] */ unsigned long cMediaTypes, - /* [size_is][out] */ AM_MEDIA_TYPE** ppMediaTypes, - /* [out] */ unsigned long* pcFetched); - HRESULT STDCALL ( *Skip )(IEnumMediaTypes* This, - /* [in] */ unsigned long cMediaTypes); - HRESULT STDCALL ( *Reset )(IEnumMediaTypes* This); - HRESULT STDCALL ( *Clone )(IEnumMediaTypes* This, - /* [out] */ IEnumMediaTypes** ppEnum); -} IEnumMediaTypes_vt; -struct IEnumMediaTypes { IEnumMediaTypes_vt* vt; }; - - - -typedef struct IPin IPin; -typedef struct IPin_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *Connect )(IPin * This, - /* [in] */ IPin *pReceivePin, - /* [in] */ /*const*/ AM_MEDIA_TYPE *pmt); - HRESULT STDCALL ( *ReceiveConnection )(IPin * This, - /* [in] */ IPin *pConnector, - /* [in] */ const AM_MEDIA_TYPE *pmt); - HRESULT STDCALL ( *Disconnect )(IPin * This); - HRESULT STDCALL ( *ConnectedTo )(IPin * This, /* [out] */ IPin **pPin); - HRESULT STDCALL ( *ConnectionMediaType )(IPin * This, - /* [out] */ AM_MEDIA_TYPE *pmt); - HRESULT STDCALL ( *QueryPinInfo )(IPin * This, /* [out] */ PIN_INFO *pInfo); - HRESULT STDCALL ( *QueryDirection )(IPin * This, - /* [out] */ PIN_DIRECTION *pPinDir); - HRESULT STDCALL ( *QueryId )(IPin * This, /* [out] */ unsigned short* *Id); - HRESULT STDCALL ( *QueryAccept )(IPin * This, - /* [in] */ const AM_MEDIA_TYPE *pmt); - HRESULT STDCALL ( *EnumMediaTypes )(IPin * This, - /* [out] */ IEnumMediaTypes **ppEnum); - HRESULT STDCALL ( *QueryInternalConnections )(IPin * This, - /* [out] */ IPin **apPin, - /* [out][in] */ unsigned long *nPin); - HRESULT STDCALL ( *EndOfStream )(IPin * This); - HRESULT STDCALL ( *BeginFlush )(IPin * This); - HRESULT STDCALL ( *EndFlush )(IPin * This); - HRESULT STDCALL ( *NewSegment )(IPin * This, - /* [in] */ REFERENCE_TIME tStart, - /* [in] */ REFERENCE_TIME tStop, - /* [in] */ double dRate); -} IPin_vt; -struct IPin { IPin_vt *vt; }; - - -typedef struct IEnumPins IEnumPins; -typedef struct IEnumPins_vt -{ - INHERIT_IUNKNOWN(); - - // retrieves a specified number of pins in the enumeration sequence.. - HRESULT STDCALL ( *Next )(IEnumPins* This, - /* [in] */ unsigned long cPins, - /* [size_is][out] */ IPin** ppPins, - /* [out] */ unsigned long* pcFetched); - // skips over a specified number of pins. - HRESULT STDCALL ( *Skip )(IEnumPins* This, - /* [in] */ unsigned long cPins); - // resets the enumeration sequence to the beginning. - HRESULT STDCALL ( *Reset )(IEnumPins* This); - // makes a copy of the enumerator with the same enumeration state. - HRESULT STDCALL ( *Clone )(IEnumPins* This, - /* [out] */ IEnumPins** ppEnum); -} IEnumPins_vt; -struct IEnumPins { struct IEnumPins_vt* vt; }; - - -typedef struct IMediaSample IMediaSample; -typedef struct IMediaSample_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *GetPointer )(IMediaSample* This, - /* [out] */ unsigned char** ppBuffer); - LONG STDCALL ( *GetSize )(IMediaSample* This); - HRESULT STDCALL ( *GetTime )(IMediaSample* This, - /* [out] */ REFERENCE_TIME* pTimeStart, - /* [out] */ REFERENCE_TIME* pTimeEnd); - HRESULT STDCALL ( *SetTime )(IMediaSample* This, - /* [in] */ REFERENCE_TIME* pTimeStart, - /* [in] */ REFERENCE_TIME* pTimeEnd); - - // sync-point property. If true, then the beginning of this - // sample is a sync-point. (note that if AM_MEDIA_TYPE.bTemporalCompression - // is false then all samples are sync points). A filter can start - // a stream at any sync point. S_FALSE if not sync-point, S_OK if true. - HRESULT STDCALL ( *IsSyncPoint )(IMediaSample* This); - HRESULT STDCALL ( *SetSyncPoint )(IMediaSample* This, - long bIsSyncPoint); - - // preroll property. If true, this sample is for preroll only and - // shouldn't be displayed. - HRESULT STDCALL ( *IsPreroll )(IMediaSample* This); - HRESULT STDCALL ( *SetPreroll )(IMediaSample* This, - long bIsPreroll); - - LONG STDCALL ( *GetActualDataLength )(IMediaSample* This); - HRESULT STDCALL ( *SetActualDataLength )(IMediaSample* This, - long __MIDL_0010); - - // these allow for limited format changes in band - if no format change - // has been made when you receive a sample GetMediaType will return S_FALSE - HRESULT STDCALL ( *GetMediaType )(IMediaSample* This, - AM_MEDIA_TYPE** ppMediaType); - HRESULT STDCALL ( *SetMediaType )(IMediaSample* This, - AM_MEDIA_TYPE* pMediaType); - - // returns S_OK if there is a discontinuity in the data (this frame is - // not a continuation of the previous stream of data - // - there has been a seek or some dropped samples). - HRESULT STDCALL ( *IsDiscontinuity )(IMediaSample* This); - HRESULT STDCALL ( *SetDiscontinuity )(IMediaSample* This, - long bDiscontinuity); - - // get the media times for this sample - HRESULT STDCALL ( *GetMediaTime )(IMediaSample* This, - /* [out] */ long long* pTimeStart, - /* [out] */ long long* pTimeEnd); - // Set the media times for this sample - // pTimeStart==pTimeEnd==NULL will invalidate the media time stamps in - // this sample - HRESULT STDCALL ( *SetMediaTime )(IMediaSample* This, - /* [in] */ long long* pTimeStart, - /* [in] */ long long* pTimeEnd); -} IMediaSample_vt; -struct IMediaSample { struct IMediaSample_vt* vt; }; - - - -//typedef struct IBaseFilter IBaseFilter; -typedef struct IBaseFilter_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *GetClassID )(IBaseFilter * This, - /* [out] */ CLSID *pClassID); - HRESULT STDCALL ( *Stop )(IBaseFilter * This); - HRESULT STDCALL ( *Pause )(IBaseFilter * This); - HRESULT STDCALL ( *Run )(IBaseFilter * This, - REFERENCE_TIME tStart); - HRESULT STDCALL ( *GetState )(IBaseFilter * This, - /* [in] */ unsigned long dwMilliSecsTimeout, - ///* [out] */ FILTER_STATE *State); - void* State); - HRESULT STDCALL ( *SetSyncSource )(IBaseFilter* This, - /* [in] */ IReferenceClock *pClock); - HRESULT STDCALL ( *GetSyncSource )(IBaseFilter* This, - /* [out] */ IReferenceClock **pClock); - HRESULT STDCALL ( *EnumPins )(IBaseFilter* This, - /* [out] */ IEnumPins **ppEnum); - HRESULT STDCALL ( *FindPin )(IBaseFilter* This, - /* [string][in] */ const unsigned short* Id, - /* [out] */ IPin** ppPin); - HRESULT STDCALL ( *QueryFilterInfo )(IBaseFilter* This, - // /* [out] */ FILTER_INFO *pInfo); - void* pInfo); - HRESULT STDCALL ( *JoinFilterGraph )(IBaseFilter* This, - /* [in] */ IFilterGraph* pGraph, - /* [string][in] */ const unsigned short* pName); - HRESULT STDCALL ( *QueryVendorInfo )(IBaseFilter* This, - /* [string][out] */ unsigned short** pVendorInfo); -} IBaseFilter_vt; -struct IBaseFilter { struct IBaseFilter_vt* vt; }; - - - -typedef struct IMemAllocator IMemAllocator; -typedef struct IMemAllocator_vt -{ - INHERIT_IUNKNOWN(); - - // specifies the number of buffers to allocate and the size of each buffer. - HRESULT STDCALL ( *SetProperties )(IMemAllocator* This, - /* [in] */ ALLOCATOR_PROPERTIES *pRequest, - /* [out] */ ALLOCATOR_PROPERTIES *pActual); - // retrieves the number of buffers that the allocator will create, and the buffer properties. - HRESULT STDCALL ( *GetProperties )(IMemAllocator* This, - /* [out] */ ALLOCATOR_PROPERTIES *pProps); - // allocates the buffer memory. - HRESULT STDCALL ( *Commit )(IMemAllocator* This); - // releases the memory for the buffers. - HRESULT STDCALL ( *Decommit )(IMemAllocator* This); - // retrieves a media sample that contains an empty buffer. - HRESULT STDCALL ( *GetBuffer )(IMemAllocator* This, - /* [out] */ IMediaSample** ppBuffer, - /* [in] */ REFERENCE_TIME* pStartTime, - /* [in] */ REFERENCE_TIME* pEndTime, - /* [in] */ unsigned long dwFlags); - // releases a media sample. - HRESULT STDCALL ( *ReleaseBuffer )(IMemAllocator* This, - /* [in] */ IMediaSample* pBuffer); -} IMemAllocator_vt; -struct IMemAllocator { IMemAllocator_vt* vt; }; - - - -typedef struct IMemInputPin IMemInputPin; -typedef struct IMemInputPin_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *GetAllocator )(IMemInputPin * This, - /* [out] */ IMemAllocator **ppAllocator); - HRESULT STDCALL ( *NotifyAllocator )(IMemInputPin * This, - /* [in] */ IMemAllocator *pAllocator, - /* [in] */ int bReadOnly); - HRESULT STDCALL ( *GetAllocatorRequirements )(IMemInputPin * This, - /* [out] */ ALLOCATOR_PROPERTIES *pProps); - HRESULT STDCALL ( *Receive )(IMemInputPin * This, - /* [in] */ IMediaSample *pSample); - HRESULT STDCALL ( *ReceiveMultiple )(IMemInputPin * This, - /* [size_is][in] */ IMediaSample **pSamples, - /* [in] */ long nSamples, - /* [out] */ long *nSamplesProcessed); - HRESULT STDCALL ( *ReceiveCanBlock )(IMemInputPin * This); -} IMemInputPin_vt; -struct IMemInputPin { IMemInputPin_vt* vt; }; - - -typedef struct IHidden IHidden; -typedef struct IHidden_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *GetSmth )(IHidden* This, int* pv); - HRESULT STDCALL ( *SetSmth )(IHidden* This, int v1, int v2); - HRESULT STDCALL ( *GetSmth2 )(IHidden* This, int* pv); - HRESULT STDCALL ( *SetSmth2 )(IHidden* This, int v1, int v2); - HRESULT STDCALL ( *GetSmth3 )(IHidden* This, int* pv); - HRESULT STDCALL ( *SetSmth3 )(IHidden* This, int v1, int v2); - HRESULT STDCALL ( *GetSmth4 )(IHidden* This, int* pv); - HRESULT STDCALL ( *SetSmth4 )(IHidden* This, int v1, int v2); - HRESULT STDCALL ( *GetSmth5 )(IHidden* This, int* pv); - HRESULT STDCALL ( *SetSmth5 )(IHidden* This, int v1, int v2); - HRESULT STDCALL ( *GetSmth6 )(IHidden* This, int* pv); -} IHidden_vt; -struct IHidden { struct IHidden_vt* vt; }; - - -typedef struct IHidden2 IHidden2; -typedef struct IHidden2_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *unk1 )(void); - HRESULT STDCALL ( *unk2 )(void); - HRESULT STDCALL ( *unk3 )(void); - HRESULT STDCALL ( *DecodeGet )(IHidden2* This, int* region); - HRESULT STDCALL ( *unk5 )(void); - HRESULT STDCALL ( *DecodeSet )(IHidden2* This, int* region); - HRESULT STDCALL ( *unk7 )(void); - HRESULT STDCALL ( *unk8 )(void); -} IHidden2_vt; -struct IHidden2 { struct IHidden2_vt* vt; }; - - -// fixme -typedef struct IDivxFilterInterface { - struct IDivxFilterInterface_vt* vt; -} IDivxFilterInterface; - -struct IDivxFilterInterface_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *get_PPLevel )(IDivxFilterInterface* This, int* PPLevel); // current postprocessing level - HRESULT STDCALL ( *put_PPLevel )(IDivxFilterInterface* This, int PPLevel); // new postprocessing level - HRESULT STDCALL ( *put_DefaultPPLevel )(IDivxFilterInterface* This); - HRESULT STDCALL ( *put_MaxDelayAllowed )(IDivxFilterInterface* This, int maxdelayallowed); - HRESULT STDCALL ( *put_Brightness )(IDivxFilterInterface* This, int brightness); - HRESULT STDCALL ( *put_Contrast )(IDivxFilterInterface* This, int contrast); - HRESULT STDCALL ( *put_Saturation )(IDivxFilterInterface* This, int saturation); - HRESULT STDCALL ( *get_MaxDelayAllowed )(IDivxFilterInterface* This, int* maxdelayallowed); - HRESULT STDCALL ( *get_Brightness)(IDivxFilterInterface* This, int* brightness); - HRESULT STDCALL ( *get_Contrast)(IDivxFilterInterface* This, int* contrast); - HRESULT STDCALL ( *get_Saturation )(IDivxFilterInterface* This, int* saturation); - HRESULT STDCALL ( *put_AspectRatio )(IDivxFilterInterface* This, int x, IDivxFilterInterface* Thisit, int y); - HRESULT STDCALL ( *get_AspectRatio )(IDivxFilterInterface* This, int* x, IDivxFilterInterface* Thisit, int* y); -}; - -typedef struct IEnumFilters IEnumFilters; - -typedef struct IFilterGraph_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *AddFilter )(IFilterGraph* This, - /* [in] */ IBaseFilter* pFilter, - /* [string][in] */ unsigned short* pName); - HRESULT STDCALL ( *RemoveFilter )(IFilterGraph* This, - /* [in] */ IBaseFilter* pFilter); - HRESULT STDCALL ( *EnumFilters )(IFilterGraph* This, - /* [out] */ IEnumFilters** ppEnum); - HRESULT STDCALL ( *FindFilterByName )(IFilterGraph* This, - /* [string][in] */ unsigned short* pName, - /* [out] */ IBaseFilter** ppFilter); - HRESULT STDCALL ( *ConnectDirect )(IFilterGraph* This, - /* [in] */ IPin* ppinOut, - /* [in] */ IPin* ppinIn, - /* [in] */ const AM_MEDIA_TYPE* pmt); - HRESULT STDCALL ( *Reconnect )(IFilterGraph* This, - /* [in] */ IPin* ppin); - HRESULT STDCALL ( *Disconnect )(IFilterGraph* This, - /* [in] */ IPin* ppin); - HRESULT STDCALL ( *SetDefaultSyncSource )(IFilterGraph* This); -} IFilterGraph_vt; -struct IFilterGraph { IFilterGraph_vt *vt; }; - -#endif /*MPLAYER_INTERFACES_H */ diff --git a/loader/dshow/iunk.h b/loader/dshow/iunk.h deleted file mode 100644 index 0c2aee300b..0000000000 --- a/loader/dshow/iunk.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Modified for use with MPlayer, detailed changelog at - * http://svn.mplayerhq.hu/mplayer/trunk/ - */ - -#ifndef MPLAYER_IUNK_H -#define MPLAYER_IUNK_H - -#include "guids.h" - -#define INHERIT_IUNKNOWN() \ - long STDCALL ( *QueryInterface )(IUnknown * This, const GUID* riid, void **ppvObject); \ - long STDCALL ( *AddRef )(IUnknown * This); \ - long STDCALL ( *Release )(IUnknown * This); - -#define DECLARE_IUNKNOWN() \ - int refcount; - -#define IMPLEMENT_IUNKNOWN(CLASSNAME) \ -static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \ - const GUID* riid, void **ppvObject) \ -{ \ - CLASSNAME * me = (CLASSNAME *)This; \ - GUID* r; unsigned int i = 0; \ - Debug printf(#CLASSNAME "_QueryInterface(%p) called\n", This);\ - if (!ppvObject) return E_POINTER; \ - for(r=me->interfaces; i<sizeof(me->interfaces)/sizeof(me->interfaces[0]); r++, i++) \ - if(!memcmp(r, riid, sizeof(*r))) \ - { \ - me->vt->AddRef((IUnknown*)This); \ - *ppvObject=This; \ - return 0; \ - } \ - Debug printf("Query failed! (GUID: 0x%x)\n", *(unsigned int*)riid); \ - return E_NOINTERFACE; \ -} \ - \ -static long STDCALL CLASSNAME ## _AddRef(IUnknown * This) \ -{ \ - CLASSNAME * me=( CLASSNAME *)This; \ - Debug printf(#CLASSNAME "_AddRef(%p) called (ref:%d)\n", This, me->refcount); \ - return ++(me->refcount); \ -} \ - \ -static long STDCALL CLASSNAME ## _Release(IUnknown * This) \ -{ \ - CLASSNAME* me=( CLASSNAME *)This; \ - Debug printf(#CLASSNAME "_Release(%p) called (new ref:%d)\n", This, me->refcount - 1); \ - if(--(me->refcount) == 0) \ - CLASSNAME ## _Destroy(me); \ - return 0; \ -} - -#endif /* MPLAYER_IUNK_H */ diff --git a/loader/dshow/libwin32.h b/loader/dshow/libwin32.h deleted file mode 100644 index dd25c31941..0000000000 --- a/loader/dshow/libwin32.h +++ /dev/null @@ -1,256 +0,0 @@ -#ifndef MPLAYER_LIBWIN32_H -#define MPLAYER_LIBWIN32_H - -#define VFW_E_NOT_RUNNING 0x80040226 - -#include <inttypes.h> - -//#define FATAL(a) // you don't need exception - if you want - just fill more code -#include "loader/wine/mmreg.h" -#include "loader/wine/winreg.h" -#include "loader/wine/vfw.h" -#include "loader/com.h" - -typedef uint32_t fourcc_t; - -/* -typedef struct FatalError -{ - FatalError(); - void PrintAll(void) {} -}FatalError; -*/ - -typedef struct CodecInfo -{ - char* dll; - GUID* guid; -}CodecInfo; - - -typedef struct CImage // public your_libvo_mem -{ - char* ptr; - - /*char* (*Data)(); - { - return 0; - // pointer to memory block - }*/ - /*int (*Supported)(fourcc_t csp, int bits); - { - return true; - // if you support such surface - }*/ -}CImage; - - -#if 0 -struct BitmapInfo : public BITMAPINFOHEADER -{ - void SetBits(int b) { return; /*fixme*/ } - void SetSpace(int b) { return; /*fixme*/ } -}; -#endif - -typedef struct IAudioDecoder -{ - WAVEFORMATEX in_fmt; - CodecInfo record; - /*(*IAudioDecoder)( CodecInfo * r, const WAVEFORMATEX* w); - { - memcpy(&this->record,r,sizeof(CodecInfo)); - in_fmt = *w; - }*/ -}IAudioDecoder; - -/* -struct IAudioEncoder -{ - IAudioEncoder(const CodecInfo&, WAVEFORMATEX*) {} - // you do not need this one... -}; -*/ - - enum CAPS - { - CAP_NONE = 0, - CAP_YUY2 = 1, - CAP_YV12 = 2, - CAP_IYUV = 4, - CAP_UYVY = 8, - CAP_YVYU = 16, - CAP_I420 = 32, - CAP_YVU9 = 64, - CAP_IF09 = 128, - }; - enum DecodingMode - { - DIRECT = 0, - REALTIME, - REALTIME_QUALITY_AUTO, - }; - enum DecodingState - { - STOP = 0, - START, - }; - -typedef struct BitmapInfo -{ - long biSize; - long biWidth; - long biHeight; - short biPlanes; - short biBitCount; - long biCompression; - long biSizeImage; - long biXPelsPerMeter; - long biYPelsPerMeter; - long biClrUsed; - long biClrImportant; - int colors[3]; -} BitmapInfo; - -typedef struct IVideoDecoder -{ - int VBUFSIZE; - int QMARKHI; - int QMARKLO; - int DMARKHI; - int DMARKLO; - - /* - IVideoDecoder(CodecInfo& info, const BITMAPINFOHEADER& format) : record(info) - { - // implement init part - } - virtual ~IVideoDecoder(); - void Stop() - { - } - void Start() - { - } - */ - const CodecInfo record; - int m_Mode; // should we do precaching (or even change Quality on the fly) - int m_State; - int m_iDecpos; - int m_iPlaypos; - float m_fQuality; // quality for the progress bar 0..1(best) - int m_bCapable16b; - - BITMAPINFOHEADER* m_bh; // format of input data (might be larger - e.g. huffyuv) - BitmapInfo m_decoder; // format of decoder output - BitmapInfo m_obh; // format of returned frames -}IVideoDecoder; - -/* -struct IRtConfig -{ -}; -*/ - -// might be minimalized to contain just those which are needed by DS_VideoDecoder - -#ifndef mmioFOURCC -#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ - ( (long)(unsigned char)(ch0) | ( (long)(unsigned char)(ch1) << 8 ) | \ - ( (long)(unsigned char)(ch2) << 16 ) | ( (long)(unsigned char)(ch3) << 24 ) ) -#endif /* mmioFOURCC */ - -/* OpenDivX */ -#define fccMP4S mmioFOURCC('M', 'P', '4', 'S') -#define fccmp4s mmioFOURCC('m', 'p', '4', 's') -#define fccDIVX mmioFOURCC('D', 'I', 'V', 'X') -#define fccdivx mmioFOURCC('d', 'i', 'v', 'x') -#define fccDIV1 mmioFOURCC('D', 'I', 'V', '1') -#define fccdiv1 mmioFOURCC('d', 'i', 'v', '1') - -/* DivX codecs */ -#define fccDIV2 mmioFOURCC('D', 'I', 'V', '2') -#define fccdiv2 mmioFOURCC('d', 'i', 'v', '2') -#define fccDIV3 mmioFOURCC('D', 'I', 'V', '3') -#define fccdiv3 mmioFOURCC('d', 'i', 'v', '3') -#define fccDIV4 mmioFOURCC('D', 'I', 'V', '4') -#define fccdiv4 mmioFOURCC('d', 'i', 'v', '4') -#define fccDIV5 mmioFOURCC('D', 'I', 'V', '5') -#define fccdiv5 mmioFOURCC('d', 'i', 'v', '5') -#define fccDIV6 mmioFOURCC('D', 'I', 'V', '6') -#define fccdiv6 mmioFOURCC('d', 'i', 'v', '6') -#define fccMP41 mmioFOURCC('M', 'P', '4', '1') -#define fccmp41 mmioFOURCC('m', 'p', '4', '1') -#define fccMP43 mmioFOURCC('M', 'P', '4', '3') -#define fccmp43 mmioFOURCC('m', 'p', '4', '3') -/* old ms mpeg-4 codecs */ -#define fccMP42 mmioFOURCC('M', 'P', '4', '2') -#define fccmp42 mmioFOURCC('m', 'p', '4', '2') -#define fccMPG4 mmioFOURCC('M', 'P', 'G', '4') -#define fccmpg4 mmioFOURCC('m', 'p', 'g', '4') -/* Windows media codecs */ -#define fccWMV1 mmioFOURCC('W', 'M', 'V', '1') -#define fccwmv1 mmioFOURCC('w', 'm', 'v', '1') -#define fccWMV2 mmioFOURCC('W', 'M', 'V', '2') -#define fccwmv2 mmioFOURCC('w', 'm', 'v', '2') -#define fccMWV1 mmioFOURCC('M', 'W', 'V', '1') - -/* Angel codecs */ -#define fccAP41 mmioFOURCC('A', 'P', '4', '1') -#define fccap41 mmioFOURCC('a', 'p', '4', '1') -#define fccAP42 mmioFOURCC('A', 'P', '4', '2') -#define fccap42 mmioFOURCC('a', 'p', '4', '2') - -/* other codecs */ -#define fccIV31 mmioFOURCC('I', 'V', '3', '1') -#define fcciv31 mmioFOURCC('i', 'v', '3', '1') -#define fccIV32 mmioFOURCC('I', 'V', '3', '2') -#define fcciv32 mmioFOURCC('i', 'v', '3', '2') -#define fccIV41 mmioFOURCC('I', 'V', '4', '1') -#define fcciv41 mmioFOURCC('i', 'v', '4', '1') -#define fccIV50 mmioFOURCC('I', 'V', '5', '0') -#define fcciv50 mmioFOURCC('i', 'v', '5', '0') -#define fccI263 mmioFOURCC('I', '2', '6', '3') -#define fcci263 mmioFOURCC('i', '2', '6', '3') - -#define fccMJPG mmioFOURCC('M', 'J', 'P', 'G') -#define fccmjpg mmioFOURCC('m', 'j', 'p', 'g') - -#define fccHFYU mmioFOURCC('H', 'F', 'Y', 'U') - -#define fcccvid mmioFOURCC('c', 'v', 'i', 'd') -#define fccdvsd mmioFOURCC('d', 'v', 's', 'd') - -/* Ati codecs */ -#define fccVCR2 mmioFOURCC('V', 'C', 'R', '2') -#define fccVCR1 mmioFOURCC('V', 'C', 'R', '1') -#define fccVYUY mmioFOURCC('V', 'Y', 'U', 'Y') -#define fccIYU9 mmioFOURCC('I', 'Y', 'U', '9') // it was defined as fccYVU9 - -/* Asus codecs */ -#define fccASV1 mmioFOURCC('A', 'S', 'V', '1') -#define fccASV2 mmioFOURCC('A', 'S', 'V', '2') - -/* Microsoft video */ -#define fcccram mmioFOURCC('c', 'r', 'a', 'm') -#define fccCRAM mmioFOURCC('C', 'R', 'A', 'M') -#define fccMSVC mmioFOURCC('M', 'S', 'V', 'C') - - -#define fccMSZH mmioFOURCC('M', 'S', 'Z', 'H') - -#define fccZLIB mmioFOURCC('Z', 'L', 'I', 'B') - -#define fccTM20 mmioFOURCC('T', 'M', '2', '0') - -#define fccYUV mmioFOURCC('Y', 'U', 'V', ' ') -#define fccYUY2 mmioFOURCC('Y', 'U', 'Y', '2') -#define fccYV12 mmioFOURCC('Y', 'V', '1', '2')/* Planar mode: Y + V + U (3 planes) */ -#define fccI420 mmioFOURCC('I', '4', '2', '0') -#define fccIYUV mmioFOURCC('I', 'Y', 'U', 'V')/* Planar mode: Y + U + V (3 planes) */ -#define fccUYVY mmioFOURCC('U', 'Y', 'V', 'Y')/* Packed mode: U0+Y0+V0+Y1 (1 plane) */ -#define fccYVYU mmioFOURCC('Y', 'V', 'Y', 'U')/* Packed mode: Y0+V0+Y1+U0 (1 plane) */ -#define fccYVU9 mmioFOURCC('Y', 'V', 'U', '9')/* Planar 4:1:0 */ -#define fccIF09 mmioFOURCC('I', 'F', '0', '9')/* Planar 4:1:0 + delta */ - -#endif /* MPLAYER_LIBWIN32_H */ diff --git a/loader/dshow/mediatype.c b/loader/dshow/mediatype.c deleted file mode 100644 index 873c303477..0000000000 --- a/loader/dshow/mediatype.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * AM_MEDIA_TYPE service functions implementations - * Code is based on quartz/enummedia.c file from wine project. - * Modified by Vladimir Voroshilov - * - * Original code: Copyright 2003 Robert Shearman - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ -#include "mp_msg.h" -#include "libmpcodecs/img_format.h" -#include "loader/wine/winerror.h" -#include "loader/com.h" -#include "mediatype.h" -#include "libwin32.h" - -void DisplayMediaType(const char * label,const AM_MEDIA_TYPE* pmt){ - WAVEFORMATEX* pWF; - VIDEOINFOHEADER* Vhdr; - int i; - GUID* iid; - - - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"=======================\n"); - if(label){ - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"AM_MEDIA_TYPE: %s\n",label); - }else - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"AM_MEDIA_TYPE:\n"); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"-(Ptr:%p)--------\n",pmt); - for(i=0;i<sizeof(AM_MEDIA_TYPE);i++){ - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"%02x ",(BYTE)((BYTE*)pmt)[i]); - if((i+1)%8==0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n"); - } - if((i)%8!=0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n"); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"-(Ptr:%p)--(%lu)--\n",pmt->pbFormat,pmt->cbFormat); - for(i=0;i<pmt->cbFormat;i++){ - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"%02x ",(BYTE)pmt->pbFormat[i]); - if((i+1)%8==0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n"); - } - if((i)%8!=0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n"); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"-----------------------\n"); - iid=(GUID*)&(pmt->subtype); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Subtype: %08x-%04x-%04x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x\n", - iid->f1, iid->f2, iid->f3, - (unsigned char)iid->f4[1], (unsigned char)iid->f4[0], - (unsigned char)iid->f4[2], (unsigned char)iid->f4[3], - (unsigned char)iid->f4[4], (unsigned char)iid->f4[5], - (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]); - - iid=(GUID*)&(pmt->formattype); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Format type: %08x-%04x-%04x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x\n", - iid->f1, iid->f2, iid->f3, - (unsigned char)iid->f4[1], (unsigned char)iid->f4[0], - (unsigned char)iid->f4[2], (unsigned char)iid->f4[3], - (unsigned char)iid->f4[4], (unsigned char)iid->f4[5], - (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]); - if(pmt && memcmp(&pmt->formattype,&FORMAT_WaveFormatEx,16)==0 && pmt->pbFormat){ - pWF=(WAVEFORMATEX*)pmt->pbFormat; - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nChannels %d\n",pWF->nChannels); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nSamplesPerSec %ld\n",pWF->nSamplesPerSec); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: wBitsPerSample %d\n",pWF->wBitsPerSample); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nBlockAlign %d\n",pWF->nBlockAlign); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nAvgBytesPerSec %ld\n",pWF->nAvgBytesPerSec); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: SampleSize %ld\n",pmt->lSampleSize); - } - if(pmt && memcmp(&pmt->formattype,&FORMAT_VideoInfo,16)==0 && pmt->pbFormat){ - Vhdr=(VIDEOINFOHEADER*)pmt->pbFormat; - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: dwBitRate %ld\n",Vhdr->dwBitRate); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biWidth %ld\n",Vhdr->bmiHeader.biWidth); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biHeight %ld\n",Vhdr->bmiHeader.biHeight); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biSizeImage %ld\n",Vhdr->bmiHeader.biSizeImage); - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biBitCount %d\n",Vhdr->bmiHeader.biBitCount); - if(Vhdr->bmiHeader.biCompression){ - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biComression 0x%08lx (%s)\n",Vhdr->bmiHeader.biCompression,vo_format_name(Vhdr->bmiHeader.biCompression)); - }else - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biComression 0x00000000\n"); - - } - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"=======================\n"); -} - -HRESULT CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc) -{ - Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"%s(%p) called\n", "CopyMediaType",pSrc); - - if(!pSrc || !pDest) return E_POINTER; - - if(pSrc == pDest) return E_INVALIDARG; - - if(!pSrc->pbFormat && pSrc->cbFormat) return E_POINTER; - - memcpy(pDest, pSrc, sizeof(AM_MEDIA_TYPE)); - if (!pSrc->pbFormat) return S_OK; - if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat))) - return E_OUTOFMEMORY; - memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat); - if (pDest->pUnk) - pDest->pUnk->vt->AddRef(pDest->pUnk); - return S_OK; -} - -void FreeMediaType(AM_MEDIA_TYPE * pMediaType) -{ - if (!pMediaType) return; - if (pMediaType->pbFormat) - { - CoTaskMemFree(pMediaType->pbFormat); - pMediaType->pbFormat = NULL; - } - if (pMediaType->pUnk) - { - pMediaType->pUnk->vt->Release(pMediaType->pUnk); - pMediaType->pUnk = NULL; - } -} - -AM_MEDIA_TYPE * CreateMediaType(AM_MEDIA_TYPE const * pSrc) -{ - AM_MEDIA_TYPE * pDest; - if (!pSrc) return NULL; - pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); - if (!pDest) - return NULL; - - if (FAILED(CopyMediaType(pDest, pSrc))) - { - CoTaskMemFree(pDest); - return NULL; - } - - return pDest; -} - -void DeleteMediaType(AM_MEDIA_TYPE * pMediaType) -{ - if (!pMediaType) return; - FreeMediaType(pMediaType); - CoTaskMemFree(pMediaType); -} - -#define IsEqualGUID(a,b) (memcmp(a,b,16)==0) -int CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, int bWildcards) -{ - 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)); -} diff --git a/loader/dshow/mediatype.h b/loader/dshow/mediatype.h deleted file mode 100644 index ecb696ca39..0000000000 --- a/loader/dshow/mediatype.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -------------------------------------------------------------------- - AM_MEDIA_TYPE service functions declarations -------------------------------------------------------------------- -*/ - -#ifndef MPLAYER_MEDIATYPE_H -#define MPLAYER_MEDIATYPE_H - -#include "guids.h" - -typedef struct __attribute__((__packed__)) MediaType -{ - GUID majortype; //0x0 - GUID subtype; //0x10 - int bFixedSizeSamples; //0x20 - int bTemporalCompression; //0x24 - unsigned long lSampleSize; //0x28 - GUID formattype; //0x2c - IUnknown* pUnk; //0x3c - unsigned long cbFormat; //0x40 - char* pbFormat; //0x44 -} AM_MEDIA_TYPE; - -/** - * \brief print info from AM_MEDIA_TYPE structure - * =param[in] label short lable for media type - * \param[in] pmt pointer to AM_MEDIA_TYPE - * - * routine used for debug purposes - * - */ -void DisplayMediaType(const char * label,const AM_MEDIA_TYPE* pmt); -/** - * \brief frees memory, pointed by pbFormat and pUnk members of AM_MEDIA_TYPE structure - * - * \param[in] pmt pointer to structure - * - * \note - * routine does not frees memory allocated for AM_MEDIA_TYPE, so given pointer will be - * valid after this routine call. - * - */ -void FreeMediaType(AM_MEDIA_TYPE* pmt); -/** - * \brief frees memory allocated for AM_MEDIA_TYPE structure, including pbFormat and pUnk - * members - * - * \param[in] pmt pointer to structure - * - * \note - * after call to this routine, pointer to AM_MEDIA_TYPE will not be valid anymore - * - */ -void DeleteMediaType(AM_MEDIA_TYPE* pmt); -/** - * \brief copyies info from source to destination AM_MEDIA_TYPE structures - * - * \param[in] pSrc pointer to AM_MEDIA_TYPE structure to copy data from - * \param[out] pDst pointer to AM_MEDIA_TYPE structure to copy data to - * - * \return S_OK - success - * \return E_POINTER - pSrc or pDst is NULL or (pSrc->cbFormat && !pSrc->pbFormat) - * \return E_INVALIDARG - (pSrc == pDst) - * \return E_OUTOFMEMORY - Insufficient memory - * - * \note - * - pDst must point to existing AM_MEDIA_TYPE structure (all data will be overwritten) - * - if pDst->pbFormat!=NULL this will cause memory leak (as described in Directshow SDK)! - * - */ -HRESULT CopyMediaType(AM_MEDIA_TYPE* pDst,const AM_MEDIA_TYPE* pSrc); -/** - * \brief allocates new AM_MEDIA_TYPE structure and fills it with info from given one - * - * \param[in] pSrc pointer to AM_MEDIA_TYPE structure to copy data from - * - * \return result code, returned from CopyMediaType - * - */ -AM_MEDIA_TYPE* CreateMediaType(const AM_MEDIA_TYPE* pSrc); - -/** - * \brief compares two AM_MEDIA_TYPE structures for compatibility - * - * \param[in] pmt1 first AM_MEDIA_TYPE structure for compare - * \param[in] pmt2 second AM_MEDIA_TYPE structure for compare - * \param[in] bWildcards 1 means that GUID_NULL of one structure will be compatible with any value of another structure - * - * \return 1 if structures are compatible - * \return 0 if structures are not compatible - * - */ -int CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, int bWildcards); - -#endif /* MPLAYER_MEDIA_TYPE_H */ diff --git a/loader/dshow/outputpin.c b/loader/dshow/outputpin.c deleted file mode 100644 index a1baf80116..0000000000 --- a/loader/dshow/outputpin.c +++ /dev/null @@ -1,957 +0,0 @@ -/* - * Modified for use with MPlayer, detailed changelog at - * http://svn.mplayerhq.hu/mplayer/trunk/ - */ - -#include "loader/wine/winerror.h" -#include "loader/wine/windef.h" -#include "outputpin.h" -#include "mediatype.h" -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -static inline int output_unimplemented(const char* s, void* p) -{ - Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p); - return E_NOTIMPL; -} - -/** - An object beyond interface IEnumMediaTypes. - Returned by COutputPin through call IPin::EnumMediaTypes(). -*/ -typedef struct CEnumMediaTypes -{ - IEnumMediaTypes_vt* vt; - DECLARE_IUNKNOWN(); - AM_MEDIA_TYPE type; - GUID interfaces[2]; -} CEnumMediaTypes; - -/** - IMemOutput interface implementation -*/ -struct COutputMemPin -{ - IMemInputPin_vt* vt; - DECLARE_IUNKNOWN(); - char** frame_pointer; - long* frame_size_pointer; - MemAllocator* pAllocator; - COutputPin* parent; -}; - -/** - * \brief IEnumMediaTypes:Next (retrives a specified number of media types ) - * - * \param[in] This pointer to CEnumMediaTypes object - * \param[in] cMediaTypes number of media types to retrive - * \param[out] ppMediaTypes array of AM_MEDIA_TYPE structure pointers of size cMediaTypes - * \param[out] pcFetched address of variables that receives number of returned media types - * - * \return S_OK - success - * \return S_FALSE - did not return as meny structures as requested - * \return E_INVALIDARG Invalid argument - * \return E_POINTER Null pointer - * \return VFW_E_ENUM_OUT_OF_SYNC - pin's state has changed and is now inconsistent with enumerator - * - */ -static HRESULT STDCALL CEnumMediaTypes_Next(IEnumMediaTypes * This, - /* [in] */ ULONG cMediaTypes, - /* [size_is][out] */ AM_MEDIA_TYPE **ppMediaTypes, - /* [out] */ ULONG *pcFetched) -{ - AM_MEDIA_TYPE* type = &((CEnumMediaTypes*)This)->type; - Debug printf("CEnumMediaTypes::Next(%p) called\n", This); - if (!ppMediaTypes) - return E_INVALIDARG; - if (!pcFetched && (cMediaTypes!=1)) - return E_INVALIDARG; - if (cMediaTypes <= 0) - return 0; - - if (pcFetched) - *pcFetched=1; - ppMediaTypes[0] = CreateMediaType(type); - - if (cMediaTypes == 1) - return 0; - return 1; -} - -/* I expect that these methods are unused. */ - -/** - * \brief IEnumMediaTypes::Skip (skips over a specified number of media types) - * - * \param[in] This pointer to CEnumMEdiaTypes object - * \param[in] cMediaTypes number of media types to skip - * - * \return S_OK - success - * \return S_FALSE - skipped past the end of the sequence - * \return VFW_E_ENUM_OUT_OF_SYNC - pin's state has changed and is now inconsistent with enumerator - * - */ -static HRESULT STDCALL CEnumMediaTypes_Skip(IEnumMediaTypes * This, - /* [in] */ ULONG cMediaTypes) -{ - return output_unimplemented("CEnumMediaTypes::Skip", This); -} - -/** - * \brief IEnumMediaTypes::Reset (resets enumeration sequence to beginning) - * - * \param[in] This pointer to CEnumMEdiaTypes object - * - * \return S_OK - success - * - */ -static HRESULT STDCALL CEnumMediaTypes_Reset(IEnumMediaTypes * This) -{ - Debug printf("CEnumMediaTypes::Reset(%p) called\n", This); - return 0; -} - -/** - * \brief IEnumMediaTypes::Clone (makes a copy of enumerator, returned object - * starts at the same position as original) - * - * \param[in] This pointer to CEnumMEdiaTypes object - * \param[out] ppEnum address of variable that receives pointer to IEnumMediaTypes interface - * - * \return S_OK - success - * \return E_OUTOFMEMRY - Insufficient memory - * \return E_POINTER - Null pointer - * \return VFW_E_ENUM_OUT_OF_SYNC - pin's state has changed and is now inconsistent with enumerator - * - */ -static HRESULT STDCALL CEnumMediaTypes_Clone(IEnumMediaTypes * This, - /* [out] */ IEnumMediaTypes **ppEnum) -{ - Debug printf("CEnumMediaTypes::Clone(%p) called\n", This); - return E_NOTIMPL; -} - -/** - * \brief CEnumMediaTypes destructor - * - * \param[in] This pointer to CEnumMediaTypes object - * - */ -static void CEnumMediaTypes_Destroy(CEnumMediaTypes* This) -{ - FreeMediaType(&(This->type)); - free(This->vt); - free(This); -} - -// IEnumMediaTypes->IUnknown methods -IMPLEMENT_IUNKNOWN(CEnumMediaTypes) - -/** - * \brief CEnumMediaTypes constructor - * - * \param[in] amt media type for enumerating - * - * \return pointer to CEnumMEdiaTypes object or NULL if error occured - * - */ -static CEnumMediaTypes* CEnumMediaTypesCreate(const AM_MEDIA_TYPE* amt) -{ - CEnumMediaTypes *This = malloc(sizeof(CEnumMediaTypes)) ; - - if (!This) - return NULL; - - This->vt = malloc(sizeof(IEnumMediaTypes_vt)); - if (!This->vt) - { - free(This); - return NULL; - } - - This->refcount = 1; - CopyMediaType(&(This->type),amt); - - This->vt->QueryInterface = CEnumMediaTypes_QueryInterface; - This->vt->AddRef = CEnumMediaTypes_AddRef; - This->vt->Release = CEnumMediaTypes_Release; - This->vt->Next = CEnumMediaTypes_Next; - This->vt->Skip = CEnumMediaTypes_Skip; - This->vt->Reset = CEnumMediaTypes_Reset; - This->vt->Clone = CEnumMediaTypes_Clone; - - This->interfaces[0] = IID_IUnknown; - This->interfaces[1] = IID_IEnumMediaTypes; - - return This; -} - - -/************* - * COutputPin - * - * WARNING: - * This is implementation of INPUT pin in DirectShow's terms - * - *************/ - - -/** - * - * \brief IUnknown::QueryInterface (query object for interface) - * \param[in] This pointer to IUnknown interface - * \param[in] iid GUID of requested interface - * \param[out] ppv receives pointer to interface - * - * \return S_OK - success (and *ppv contains valid pointer) - * \return E_NOINTERFACE - interface not found (and *ppv was set NULL) - * - * \note - * Make sure to call Release on received interface when you are done - * - */ -static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, const GUID* iid, void** ppv) -{ - COutputPin* p = (COutputPin*) This; - - Debug printf("COutputPin_QueryInterface(%p) called\n", This); - if (!ppv) - return E_INVALIDARG; - - if (memcmp(iid, &IID_IUnknown, 16) == 0) - { - *ppv = p; - p->vt->AddRef(This); - return 0; - } - if (memcmp(iid, &IID_IMemInputPin, 16) == 0) - { - *ppv = p->mempin; - p->mempin->vt->AddRef((IUnknown*)*ppv); - return 0; - } - - Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x\n", - iid->f1, iid->f2, iid->f3, - (unsigned char)iid->f4[1], (unsigned char)iid->f4[0], - (unsigned char)iid->f4[2], (unsigned char)iid->f4[3], - (unsigned char)iid->f4[4], (unsigned char)iid->f4[5], - (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]); - return E_NOINTERFACE; -} - -// IPin methods - -/** - * \brief IPin::Connect (connects pin to another pin) - * - * \param[in] This pointer to IPin interface - * \param[in] pReceivePin pointer to IPin interface of remote pin - * \param[in] pmt suggested media type for link. Can be NULL (any media type) - * - * \return S_OK - success. - * \return VFW_E_ALREADY_CONNECTED - pin already connected - * \return VFW_E_NOT_STOPPED - filter is active - * \return VFW_E_TYPE_NOT_ACCEPT - type is not acceptable - * \return Apropriate error code otherwise. - * - */ -static HRESULT STDCALL COutputPin_Connect(IPin * This, - /* [in] */ IPin *pReceivePin, - /* [in] */ /* const */ AM_MEDIA_TYPE *pmt) -{ - Debug printf("COutputPin_Connect(%p) called\n",This); -/* - *pmt=((COutputPin*)This)->type; - if(pmt->cbFormat>0) - { - pmt->pbFormat=malloc(pmt->cbFormat); - memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat); - } -*/ - //return E_NOTIMPL; - return 0;// XXXXXXXXXXXXX CHECKME XXXXXXXXXXXXXXX - // if I put return 0; here, it crashes -} - -/** - * \brief IPin::ReceiveConnection (accepts a connection from another pin) - * - * \param[in] This pointer to IPin interface - * \param[in] pConnector connecting pin's IPin interface - * \param[in] pmt suggested media type for connection - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_ALREADY_CONNECTED - pin already connected - * \return VFW_E_NOT_STOPPED - filter is active - * \return VFW_E_TYPE_NOT_ACCEPT - type is not acceptable - * - * \note - * When returning S_OK method should also do the following: - * - store media type and return the same type in IPin::ConnectionMediaType - * - store pConnector and return it in IPin::ConnectedTo - * - */ -static HRESULT STDCALL COutputPin_ReceiveConnection(IPin * This, - /* [in] */ IPin *pConnector, - /* [in] */ const AM_MEDIA_TYPE *pmt) -{ - Debug printf("COutputPin_ReceiveConnection(%p) called\n", This); - ((COutputPin*)This)->remote = pConnector; - return 0; -} - -/** - * \brief IPin::Disconnect (accepts a connection from another pin) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return S_FALSE - pin was not connected - * \return VFW_E_NOT_STOPPED - filter is active - * - * \note - * To break connection you have to also call Disconnect on other pin - */ -static HRESULT STDCALL COutputPin_Disconnect(IPin * This) -{ - Debug printf("COutputPin_Disconnect(%p) called\n", This); - return 1; -} - -/** - * \brief IPin::ConnectedTo (retrieves pointer to the connected pin, if such exist) - * - * \param[in] This pointer to IPin interface - * \param[out] pPin pointer to remote pin's IPin interface - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_NOT_CONNECTED - pin is not connected - * - * \note - * Caller must call Release on received IPin, when done - */ -static HRESULT STDCALL COutputPin_ConnectedTo(IPin * This, - /* [out] */ IPin **pPin) -{ - Debug printf("COutputPin_ConnectedTo(%p) called\n", This); - if (!pPin) - return E_INVALIDARG; - *pPin = ((COutputPin*)This)->remote; - return 0; -} - -/** - * \brief IPin::ConnectionMediaType (retrieves media type for connection, if such exist) - * - * \param[in] This pointer to IPin interface - * \param[out] pmt pointer to AM_MEDIA_TYPE, that receives connection media type - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * \return VFW_E_NOT_CONNECTED - pin is not connected - * - */ -static HRESULT STDCALL COutputPin_ConnectionMediaType(IPin * This, - /* [out] */ AM_MEDIA_TYPE *pmt) -{ - Debug printf("COutputPin_ConnectionMediaType(%p) called\n",This); - if (!pmt) - return E_INVALIDARG; - CopyMediaType(pmt,&(((COutputPin*)This)->type)); - return 0; -} - -/** - * \brief IPin::QueryPinInfo (retrieves information about the pin) - * - * \param[in] This pointer to IPin interface - * \param[out] pInfo pointer to PIN_INFO structure, that receives pin info - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * - * \note - * If pInfo->pFilter is not NULL, then caller must call Release on pInfo->pFilter when done - * - */ -static HRESULT STDCALL COutputPin_QueryPinInfo(IPin * This, - /* [out] */ PIN_INFO *pInfo) -{ - return output_unimplemented("COutputPin_QueryPinInfo", This); -} - -/** - * \brief IPin::QueryDirection (retrieves pin direction) - * - * \param[in] This pointer to IPin interface - * \param[out] pPinDir pointer to variable, that receives pin direction (PINDIR_INPUT,PINDIR_OUTPUT) - * - * \return S_OK - success - * \return E_POINTER - Null pointer - * - */ -static HRESULT STDCALL COutputPin_QueryDirection(IPin * This, - /* [out] */ PIN_DIRECTION *pPinDir) -{ - Debug printf("COutputPin_QueryDirection(%p) called\n", This); - if (!pPinDir) - return E_INVALIDARG; - *pPinDir = PINDIR_INPUT; - return 0; -} - -/** - * \brief IPin::QueryId (retrieves pin identificator) - * - * \param[in] This pointer to IPin interface - * \param[out] Id adress of variable, that receives string with pin's Id. - * - * \return S_OK - success - * \return E_OUTOFMEMORY - Insufficient memory - * \return E_POINTER - Null pointer - * - * \note - * Pin's Id is not the same as pin's name - * - */ -static HRESULT STDCALL COutputPin_QueryId(IPin * This, - /* [out] */ LPWSTR *Id) -{ - return output_unimplemented("COutputPin_QueryId", This); -} - -/** - * \brief IPin::QueryAccept (determines can media type be accepted or not) - * - * \param[in] This pointer to IPin interface - * \param[in] pmt Media type to check - * - * \return S_OK - success - * \return S_FALSE - pin rejects media type - * - */ -static HRESULT STDCALL COutputPin_QueryAccept(IPin * This, - /* [in] */ const AM_MEDIA_TYPE *pmt) -{ - return output_unimplemented("COutputPin_QueryAccept", This); -} - -/** - * \brief IPin::EnumMediaTypes (enumerates the pin's preferred media types) - * - * \param[in] This pointer to IPin interface - * \param[out] ppEnum adress of variable that receives pointer to IEnumMEdiaTypes interface - * - * \return S_OK - success - * \return E_OUTOFMEMORY - Insufficient memory - * \return E_POINTER - Null pointer - * - * \note - * Caller must call Release on received interface when done - * - */ -static HRESULT STDCALL COutputPin_EnumMediaTypes(IPin * This, - /* [out] */ IEnumMediaTypes **ppEnum) -{ - Debug printf("COutputPin_EnumMediaTypes(%p) called\n",This); - if (!ppEnum) - return E_INVALIDARG; - *ppEnum = (IEnumMediaTypes*) CEnumMediaTypesCreate(&((COutputPin*)This)->type); - return 0; -} - -/** - * \brief IPin::QueryInternalConnections (retries pin's internal connections) - * - * \param[in] This pointer to IPin interface - * \param[out] apPin Array that receives pins, internally connected to this - * \param[in,out] nPint Size of an array - * - * \return S_OK - success - * \return S_FALSE - pin rejects media type - * \return E_NOTIMPL - not implemented - * - */ -static HRESULT STDCALL COutputPin_QueryInternalConnections(IPin * This, - /* [out] */ IPin **apPin, - /* [out][in] */ ULONG *nPin) -{ - return output_unimplemented("COutputPin_QueryInternalConnections", This); -} - -/** - * \brief IPin::EndOfStream (notifies pin, that no data is expected, until new run command) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - * \note - * IMemoryInputPin::Receive,IMemoryInputPin::ReceiveMultiple, IMemoryInputPin::EndOfStream, - * IMemAllocator::GetBuffer runs in different (streaming) thread then other - * methods (application thread). - * IMemoryInputPin::NewSegment runs either in streaming or application thread. - * Developer must use critical sections for thread-safing work. - * - */ -static HRESULT STDCALL COutputPin_EndOfStream(IPin * This) -{ - return output_unimplemented("COutputPin_EndOfStream", This); -} - -/** - * \brief IPin::BeginFlush (begins a flush operation) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - */ -static HRESULT STDCALL COutputPin_BeginFlush(IPin * This) -{ - return output_unimplemented("COutputPin_BeginFlush", This); -} - -/** - * \brief IPin::EndFlush (ends a flush operation) - * - * \param[in] This pointer to IPin interface - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - */ -static HRESULT STDCALL COutputPin_EndFlush(IPin * This) -{ - return output_unimplemented("COutputPin_EndFlush", This); -} - -/** - * \brief IPin::NewSegment (media sample received after this call grouped as segment with common - * start,stop time and rate) - * - * \param[in] This pointer to IPin interface - * \param[in] tStart start time of new segment - * \param[in] tStop end time of new segment - * \param[in] dRate rate at wich segment should be processed - * - * \return S_OK - success - * \return E_UNEXPECTED - The pin is output pin - * - */ -static HRESULT STDCALL COutputPin_NewSegment(IPin * This, - /* [in] */ REFERENCE_TIME tStart, - /* [in] */ REFERENCE_TIME tStop, - /* [in] */ double dRate) -{ - Debug printf("COutputPin_NewSegment(%d,%d,%f) called\n", - (int)tStart, (int)tStop, dRate); - return 0; -} - - - -// IMemInputPin->IUnknown methods - -/** - * \brief IUnknown::QueryInterface (query object for interface) - * - * \param[in] This pointer to IUnknown interface - * \param[in] iid GUID of requested interface - * \param[out] ppv receives pointer to interface - * - * \return S_OK - success (and *ppv contains valid pointer) - * \return E_NOINTERFACE - interface not found (and *ppv was set NULL) - * - * \note - * Make sure to call Release on received interface when you are done - * - */ -static HRESULT STDCALL COutputMemPin_QueryInterface(IUnknown* This, const GUID* iid, void** ppv) -{ - COutputMemPin* p = (COutputMemPin*)This; - - Debug printf("COutputMemPin_QueryInterface(%p) called\n", This); - if (!ppv) - return E_INVALIDARG; - - if(!memcmp(iid, &IID_IUnknown, 16)) - { - *ppv = p; - p->vt->AddRef(This); - return 0; - } - /*if(!memcmp(iid, &IID_IPin, 16)) - { - COutputPin* ptr=(COutputPin*)(This-1); - *ppv=(void*)ptr; - AddRef((IUnknown*)ptr); - return 0; - }*/ - if(!memcmp(iid, &IID_IMemInputPin, 16)) - { - *ppv = p; - p->vt->AddRef(This); - return 0; - } - Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \ - "%02x%02x%02x%02x%02x%02x\n", - iid->f1, iid->f2, iid->f3, - (unsigned char)iid->f4[1], (unsigned char)iid->f4[0], - (unsigned char)iid->f4[2], (unsigned char)iid->f4[3], - (unsigned char)iid->f4[4], (unsigned char)iid->f4[5], - (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]); - return E_NOINTERFACE; -} - -// IMemInputPin methods - -/** - * \brief IMemInputPin::GetAllocator (retrives memory allocator, proposed by pin) - * - * \param[in] This pointer to IMemInputPin interface - * \param[out] ppAllocator address of variable that receives allocator's IMemAllocator interface - * - * \return S_OK - success - * \return VFW_E_NO_ALLOCATOR - No allocator - * - * \note - * Make sure to call Release on received interface when you are done - * - */ -static HRESULT STDCALL COutputMemPin_GetAllocator(IMemInputPin* This, - /* [out] */ IMemAllocator** ppAllocator) -{ - Debug printf("COutputMemPin_GetAllocator(%p, %p) called\n", This->vt, ppAllocator); - *ppAllocator = (IMemAllocator*) MemAllocatorCreate(); - return 0; -} - -/** - * - * \brief IMemInputPin::NotifyAllocator (specifies an allocator for the connection) - * - * \param[in] This pointer to IMemInputPin interface - * \param[in] pAllocator allocator's IMemAllocator interface - * \param[in] bReadOnly specifies whether samples from allocator are readonly - * - * \return S_OK - success - * \return Apropriate error code otherwise - * - */ -static HRESULT STDCALL COutputMemPin_NotifyAllocator(IMemInputPin* This, - /* [in] */ IMemAllocator* pAllocator, - /* [in] */ int bReadOnly) -{ - Debug printf("COutputMemPin_NotifyAllocator(%p, %p) called\n", This, pAllocator); - ((COutputMemPin*)This)->pAllocator = (MemAllocator*) pAllocator; - return 0; -} - -/** - * \brief IMemInputPin::GetAllocatorRequirements (retrieves allocator properties requested by - * input pin) - * - * \param[in] This pointer to IMemInputPin interface - * \param[out] pProps pointer to a structure that receives allocator properties - * - * \return S_OK - success - * \return E_NOTIMPL - Not implemented - * \return E_POINTER - Null pointer - * - */ -static HRESULT STDCALL COutputMemPin_GetAllocatorRequirements(IMemInputPin* This, - /* [out] */ ALLOCATOR_PROPERTIES* pProps) -{ - return output_unimplemented("COutputMemPin_GetAllocatorRequirements", This); -} - -/** - * \brief IMemInputPin::Receive (receives the next media sample int thre stream) - * - * \param[in] This pointer to IMemInputPin interface - * \param[in] pSample pointer to sample's IMediaSample interface - * - * \return S_OK - success - * \return S_FALSE - The sample was rejected - * \return E_POINTER - Null pointer - * \return VFW_E_INVALIDMEDIATYPE - invalid media type - * \return VFW_E_RUNTIME_ERROR - run-time error occured - * \return VFW_E_WRONG_STATE - pin is stopped - * - * \remarks - * Method san do on of the following: - * - reject sample - * - accept sample and process it in another thread - * - accept sample and process it before returning - * - * In second case method should increase reference count for sample (through AddRef) - * In the last case method might block indefinitely. If this might - * happen IMemInpuPin::ReceiveCAnBlock returns S_OK - * - * \note - * IMemoryInputPin::Receive,IMemoryInputPin::ReceiveMultiple, IMemoryInputPin::EndOfStream, - * IMemAllocator::GetBuffer runs in different (streaming) thread then other - * methods (application thread). - * IMemoryInputPin::NewSegment runs either in streaming or application thread. - * Developer must use critical sections for thread-safing work. - * - */ -static HRESULT STDCALL COutputMemPin_Receive(IMemInputPin* This, - /* [in] */ IMediaSample* pSample) -{ - Debug printf("COutputMemPin_Receive(%p) called\n", This); - if (!pSample) - return E_INVALIDARG; - - if(((COutputMemPin*)This)->parent->SampleProc) - return ((COutputMemPin*)This)->parent->SampleProc(((COutputMemPin*)This)->parent->pUserData,pSample); - //reject sample - return S_FALSE; -} - -/** - * \brief IMemInputPin::ReceiveMultiple (receives multiple samples in the stream) - * - * \param[in] This pointer to IMemInputPin interface - * \param[in] pSamples pointer to array with samples - * \param[in] nSamples number of samples in array - * \param[out] nSamplesProcessed number of processed samples - * - * \return S_OK - success - * \return S_FALSE - The sample was rejected - * \return E_POINTER - Null pointer - * \return VFW_E_INVALIDMEDIATYPE - invalid media type - * \return VFW_E_RUNTIME_ERROR - run-time error occured - * \return VFW_E_WRONG_STATE - pin is stopped - * - * \remarks - * This method behaves like IMemInputPin::Receive but for array of samples - * - * \note - * IMemoryInputPin::Receive,IMemoryInputPin::ReceiveMultiple, IMemoryInputPin::EndOfStream, - * IMemAllocator::GetBuffer runs in different (streaming) thread then other - * methods (application thread). - * IMemoryInputPin::NewSegment runs either in streaming or application thread. - * Developer must use critical sections for thread-safing work. - * - */ -static HRESULT STDCALL COutputMemPin_ReceiveMultiple(IMemInputPin * This, - /* [size_is][in] */ IMediaSample **pSamples, - /* [in] */ long nSamples, - /* [out] */ long *nSamplesProcessed) -{ - HRESULT hr = 0; - Debug printf("COutputMemPin_ReceiveMultiple(%p) %ld\n", This,nSamples); - for(*nSamplesProcessed=0; *nSamplesProcessed < nSamples; *nSamplesProcessed++) { - hr = This->vt->Receive(This,pSamples[*nSamplesProcessed]); - if (hr != S_OK) break; - } - return hr; -} - -/** - * \brief IMemInputPin::ReceiveCanBlock (determines whether IMemInputPin:::Receive might block) - * - * \param[in] This pointer to IMemInputPin interface - * - * \return S_OK - the pin might block - * \return S_FALSE - the pin will not block - * - */ -static HRESULT STDCALL COutputMemPin_ReceiveCanBlock(IMemInputPin * This) -{ - return output_unimplemented("COutputMemPin_ReceiveCanBlock", This); -} - -/** - * \brief COutputPin::SetNewFormat(sets new media format for the pin) - * - * \param[in] This pointer to COutputPin class - * \param[in] amt new media format - * - */ -static void COutputPin_SetNewFormat(COutputPin* This, const AM_MEDIA_TYPE* amt) -{ - CopyMediaType(&(This->type),amt); -} - -/** - * \brief COutputPin destructor - * - * \param[in] This pointer to COutputPin class - * - */ -static void COutputPin_Destroy(COutputPin* This) -{ - free(This->mempin->vt); - free(This->mempin); - free(This->vt); - FreeMediaType(&(This->type)); - free(This); -} - -/** - * \brief IUnknown::AddRef (increases reference counter for interface) - * - * \param[in] This pointer to IUnknown class - * - * \return new value of reference counter - * - * \remarks - * Return value should be used only for debug purposes - * - */ -static HRESULT STDCALL COutputPin_AddRef(IUnknown* This) -{ - Debug printf("COutputPin_AddRef(%p) called (%d)\n", This, ((COutputPin*)This)->refcount); - ((COutputPin*)This)->refcount++; - return 0; -} - -/** - * \brief IUnknown::Release (desreases reference counter for interface) - * - * \param[in] This pointer to IUnknown class - * - * \return new value of reference counter - * - * \remarks - * When reference counter reaches zero calls destructor - * Return value should be used only for debug purposes - * - */ -static HRESULT STDCALL COutputPin_Release(IUnknown* This) -{ - Debug printf("COutputPin_Release(%p) called (%d)\n", This, ((COutputPin*)This)->refcount); - if (--((COutputPin*)This)->refcount <= 0) - COutputPin_Destroy((COutputPin*)This); - - return 0; -} - -/** - * \brief IUnknown::AddRef (increases reference counter for interface) - * - * \param[in] This pointer to IUnknown class - * - * \return new value of reference counter - * - * \remarks - * Return value should be used only for debug purposes - * - */ -static HRESULT STDCALL COutputMemPin_AddRef(IUnknown* This) -{ - COutputMemPin* p = (COutputMemPin*) This; - Debug printf("COutputMemPin_AddRef(%p) called (%p, %d)\n", p, p->parent, p->parent->refcount); - p->parent->refcount++; - return 0; -} - -/** - * \brief IUnknown::Release (desreases reference counter for interface) - * - * \param[in] This pointer to IUnknown class - * - * \return new value of reference counter - * - * \remarks - * When reference counter reaches zero calls destructor - * Return value should be used only for debug purposes - * - */ -static HRESULT STDCALL COutputMemPin_Release(IUnknown* This) -{ - COutputMemPin* p = (COutputMemPin*) This; - Debug printf("COutputMemPin_Release(%p) called (%p, %d)\n", - p, p->parent, p->parent->refcount); - if (--p->parent->refcount <= 0) - COutputPin_Destroy(p->parent); - return 0; -} - -/** - * \brief COutputPin constructor - * - * \param[in] amt media type for pin - * - * \return pointer to COutputPin if success - * \return NULL if error occured - * - */ -COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* amt,SAMPLEPROC SampleProc,void* pUserData) -{ - COutputPin* This = malloc(sizeof(COutputPin)); - IMemInputPin_vt* ivt; - - if (!This) - return NULL; - - This->vt = malloc(sizeof(IPin_vt)); - This->mempin = malloc(sizeof(COutputMemPin)); - ivt = malloc(sizeof(IMemInputPin_vt)); - - if (!This->vt || !This->mempin || !ivt) - { - COutputPin_Destroy(This); - free(ivt); - return NULL; - } - - This->SampleProc=SampleProc; - This->pUserData=pUserData; - - This->mempin->vt = ivt; - - This->refcount = 1; - This->remote = 0; - CopyMediaType(&(This->type),amt); - - This->vt->QueryInterface = COutputPin_QueryInterface; - This->vt->AddRef = COutputPin_AddRef; - This->vt->Release = COutputPin_Release; - This->vt->Connect = COutputPin_Connect; - This->vt->ReceiveConnection = COutputPin_ReceiveConnection; - This->vt->Disconnect = COutputPin_Disconnect; - This->vt->ConnectedTo = COutputPin_ConnectedTo; - This->vt->ConnectionMediaType = COutputPin_ConnectionMediaType; - This->vt->QueryPinInfo = COutputPin_QueryPinInfo; - This->vt->QueryDirection = COutputPin_QueryDirection; - This->vt->QueryId = COutputPin_QueryId; - This->vt->QueryAccept = COutputPin_QueryAccept; - This->vt->EnumMediaTypes = COutputPin_EnumMediaTypes; - This->vt->QueryInternalConnections = COutputPin_QueryInternalConnections; - This->vt->EndOfStream = COutputPin_EndOfStream; - This->vt->BeginFlush = COutputPin_BeginFlush; - This->vt->EndFlush = COutputPin_EndFlush; - This->vt->NewSegment = COutputPin_NewSegment; - - This->mempin->vt->QueryInterface = COutputMemPin_QueryInterface; - This->mempin->vt->AddRef = COutputMemPin_AddRef; - This->mempin->vt->Release = COutputMemPin_Release; - This->mempin->vt->GetAllocator = COutputMemPin_GetAllocator; - This->mempin->vt->NotifyAllocator = COutputMemPin_NotifyAllocator; - This->mempin->vt->GetAllocatorRequirements = COutputMemPin_GetAllocatorRequirements; - This->mempin->vt->Receive = COutputMemPin_Receive; - This->mempin->vt->ReceiveMultiple = COutputMemPin_ReceiveMultiple; - This->mempin->vt->ReceiveCanBlock = COutputMemPin_ReceiveCanBlock; - - This->mempin->frame_size_pointer = 0; - This->mempin->frame_pointer = 0; - This->mempin->pAllocator = 0; - This->mempin->refcount = 1; - This->mempin->parent = This; - - This->SetNewFormat = COutputPin_SetNewFormat; - - return This; -} diff --git a/loader/dshow/outputpin.h b/loader/dshow/outputpin.h deleted file mode 100644 index 111ea17a56..0000000000 --- a/loader/dshow/outputpin.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MPLAYER_OUTPUTPIN_H -#define MPLAYER_OUTPUTPIN_H - -/* "output pin" - the one that connects to output of filter. */ - -#include "allocator.h" - -typedef struct COutputMemPin COutputMemPin; -typedef struct COutputPin COutputPin; - -/** - Callback routine for copying samples from pin into filter - \param pUserData pointer to user's data - \param sample IMediaSample -*/ -typedef HRESULT STDCALL (*SAMPLEPROC)(void* pUserData,IMediaSample*sample); - -struct COutputPin -{ - IPin_vt* vt; - DECLARE_IUNKNOWN(); - COutputMemPin* mempin; - AM_MEDIA_TYPE type; - IPin* remote; - SAMPLEPROC SampleProc; - void* pUserData; - void ( *SetNewFormat )(COutputPin*, const AM_MEDIA_TYPE* a); -}; - -COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* amt,SAMPLEPROC SampleProc,void* pUserData); - -#endif /* MPLAYER_OUTPUTPIN_H */ |