diff options
22 files changed, 1849 insertions, 1773 deletions
diff --git a/src/libw32dll/DirectShow/DS_AudioDecoder.c b/src/libw32dll/DirectShow/DS_AudioDecoder.c index 41944dd09..6f2cedbf3 100644 --- a/src/libw32dll/DirectShow/DS_AudioDecoder.c +++ b/src/libw32dll/DirectShow/DS_AudioDecoder.c @@ -5,7 +5,26 @@ *********************************************************/ +#ifndef NOAVIFILE_HEADERS +#include "audiodecoder.h" +#include "except.h" +#else +#include "libwin32.h" +#endif + +#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" + #include <string.h> #include <stdio.h> #include <stdlib.h> @@ -26,25 +45,32 @@ const GUID MEDIASUBTYPE_PCM = { typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**); -DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMATEX* wf) +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 LDT_paranoia + 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(sz); - memcpy(this->m_sVhdr2, this->m_sVhdr, 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 = 2*pWF->nChannels; + pWF->nBlockAlign = pWF->nChannels * (pWF->wBitsPerSample + 7) / 8; pWF->cbSize = 0; + pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec; memcpy(&this->in_fmt,wf,sizeof(WAVEFORMATEX)); @@ -63,25 +89,34 @@ DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMA 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.subtype.f1=pWF->wFormatTag; this->m_sDestType.formattype=FORMAT_WaveFormatEx; this->m_sDestType.bFixedSizeSamples=1; this->m_sDestType.bTemporalCompression=0; - this->m_sDestType.lSampleSize=2*wf->nChannels; + 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=pWF->cbSize; + this->m_sDestType.cbFormat=18; //pWF->cbSize; this->m_sDestType.pbFormat=this->m_sVhdr2; +#if 0 +print_wave_header(this->m_sVhdr); +print_wave_header(this->m_sVhdr2); +#endif + /*try*/ { ALLOCATOR_PROPERTIES props, props1; - this->m_pDS_Filter = DS_Filter_Create((const char*)info->dll, &info->guid, &this->m_sOurType, &this->m_sDestType); + this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType); if( !this->m_pDS_Filter ) { free(this); return NULL; } - DS_Filter_Start(this->m_pDS_Filter); + this->m_pDS_Filter->Start(this->m_pDS_Filter); props.cBuffers=1; props.cbBuffer=this->m_sOurType.lSampleSize; @@ -110,37 +145,41 @@ void DS_AudioDecoder_Destroy(DS_AudioDecoder *this) free(this); } -int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, uint_t in_size, - void* out_data, uint_t out_size, - uint_t* size_read, uint_t* size_written) +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) { - uint_t written = 0; - uint_t read = 0; + unsigned int written = 0; + unsigned int read = 0; if (!in_data || !out_data) return -1; +#ifdef LDT_paranoia + Setup_FS_Segment(); +#endif + in_size -= in_size%this->in_fmt.nBlockAlign; while (in_size>0) { - uint_t frame_size = 0; + unsigned int frame_size = 0; char* frame_pointer; IMediaSample* sample=0; char* ptr; int result; // this->m_pOurOutput->SetFramePointer(out_data+written); - COutputPin_SetFramePointer(this->m_pDS_Filter->m_pOurOutput,&frame_pointer); - COutputPin_SetFrameSizePointer(this->m_pDS_Filter->m_pOurOutput,(long*)&frame_size); + this->m_pDS_Filter->m_pOurOutput->SetFramePointer(this->m_pDS_Filter->m_pOurOutput,&frame_pointer); + this->m_pDS_Filter->m_pOurOutput->SetFrameSizePointer(this->m_pDS_Filter->m_pOurOutput,(long*)&frame_size); 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->SetActualDataLength(sample, 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); @@ -155,6 +194,7 @@ int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, uint_t i sample->vt->Release((IUnknown*)sample); read+=this->in_fmt.nBlockAlign; written+=frame_size; + break; } if (size_read) *size_read = read; diff --git a/src/libw32dll/DirectShow/DS_AudioDecoder.h b/src/libw32dll/DirectShow/DS_AudioDecoder.h index b0d01c4c8..9628f65d2 100644 --- a/src/libw32dll/DirectShow/DS_AudioDecoder.h +++ b/src/libw32dll/DirectShow/DS_AudioDecoder.h @@ -1,36 +1,17 @@ #ifndef AVIFILE_DS_AUDIODECODER_H #define AVIFILE_DS_AUDIODECODER_H -#ifndef NOAVIFILE_HEADERS -#include "audiodecoder.h" -#include "except.h" -#else -#include "../libwin32.h" -#endif -#include "DS_Filter.h" +typedef struct _DS_AudioDecoder DS_AudioDecoder; -typedef struct _DS_AudioDecoder -{ - WAVEFORMATEX in_fmt; - AM_MEDIA_TYPE m_sOurType, m_sDestType; - DS_Filter* m_pDS_Filter; - char* m_sVhdr; - char* m_sVhdr2; -}DS_AudioDecoder; - -#ifndef uint_t -#define uint_t int -#endif - -DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMATEX* wf); +//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, uint_t in_size, - void* out_data, uint_t out_size, - uint_t* size_read, uint_t* size_written); +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 // AVIFILE_DS_AUDIODECODER_H diff --git a/src/libw32dll/DirectShow/DS_Filter.c b/src/libw32dll/DirectShow/DS_Filter.c index 072e7d319..2ecf1d889 100644 --- a/src/libw32dll/DirectShow/DS_Filter.c +++ b/src/libw32dll/DirectShow/DS_Filter.c @@ -1,128 +1,160 @@ #include "DS_Filter.h" -#include "../wine/driver.h" - -#ifndef NOAVIFILE_HEADERS -#include "except.h" -#else -#include "../libwin32.h" -#endif - +#include "driver.h" +#include "com.h" #include <stdio.h> #include <string.h> -#include <stdlib.h> - -#define __MODULE__ "DirectShow generic filter" typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**); -//extern "C" int STDCALL LoadLibraryA(const char*); //extern "C" STDCALL void* GetProcAddress(int, const char*); // STDCALL has to be first NetBSD -//extern "C" int STDCALL FreeLibrary(int); -void DS_Filter_Destroy(DS_Filter * this) -{ - DS_Filter_Stop(this); - - if (this->m_iState == 0) +static void DS_Filter_Start(DS_Filter* This) +{ + HRESULT hr; + + if (This->m_pAll) return; - this->m_iState = 0; - - 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); - - COutputPin_Destroy(this->m_pOurOutput); - CBaseFilter2_Destroy(this->m_pParentFilter); - CBaseFilter_Destroy(this->m_pSrcFilter); + + //Debug printf("DS_Filter_Start(%p)\n", This); + hr = This->m_pFilter->vt->Run(This->m_pFilter, 0); + if (hr != 0) + { + Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr); + } + hr = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll); + + if (hr || !This->m_pAll) + { + Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr); + This->m_pImp->vt->Release((IUnknown*)This->m_pImp); + return; + } + This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0); +} + +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(this->m_iHandle); - + if (This->m_iHandle) + FreeLibrary(This->m_iHandle); + + free(This); + CodecRelease(); } -DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, - AM_MEDIA_TYPE* in_fmt, - AM_MEDIA_TYPE* out_fmt) +DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, + AM_MEDIA_TYPE* in_fmt, + AM_MEDIA_TYPE* out_fmt) { - DS_Filter *this; - this = malloc(sizeof(DS_Filter)); - - this->m_iHandle = 0; - this->m_pFilter = 0; - this->m_pInputPin = 0; - this->m_pOutputPin = 0; - this->m_pSrcFilter = 0; - this->m_pParentFilter = 0; - this->m_pOurInput = 0; - this->m_pOurOutput = 0; - this->m_pAll = 0; - this->m_pImp = 0; - this->m_iState = 0; + int init = 0; + char eb[250]; + const char* em = NULL; + DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter)); + if (!This) + return NULL; + CodecAlloc(); - - /*try*/ + + 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; HRESULT result; - struct IClassFactory* factory = 0; - struct IUnknown* object = 0; + GETCLASS func; + struct IClassFactory* factory = NULL; + struct IUnknown* object = NULL; IEnumPins* enum_pins = 0; IPin* array[256]; ULONG fetched; - unsigned int i; - - this->m_iHandle = LoadLibraryA(dllname); - if (!this->m_iHandle) { - printf("Could not open DirectShow DLL: %.200s\n", dllname); - return NULL; + unsigned int i; + + This->m_iHandle = LoadLibraryA(dllname); + if (!This->m_iHandle) + { + em = "could not open DirectShow DLL"; + break; } - - func = (GETCLASS)GetProcAddress(this->m_iHandle, "DllGetClassObject"); - if (!func) { - printf("Illegal or corrupt DirectShow DLL: %.200s\n", dllname); - return NULL; + func = (GETCLASS)GetProcAddress(This->m_iHandle, "DllGetClassObject"); + if (!func) + { + em = "illegal or corrupt DirectShow DLL"; + break; } - result = func(id, &IID_IClassFactory, (void**)&factory); - if (result || !factory) { - printf("No such class object\n"); - return NULL; - } - + 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) { - printf("Class factory failure\n"); - return NULL; - } - - result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&this->m_pFilter); + 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) { - printf("Object does not have IBaseFilter interface\n"); - return NULL; - } - + if (result || !This->m_pFilter) + { + em = "object does not have IBaseFilter interface"; + break; + } // enumerate pins - result = this->m_pFilter->vt->EnumPins(this->m_pFilter, &enum_pins); - if (result || !enum_pins) { - printf("Could not enumerate pins\n"); - return NULL; + 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); Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result); @@ -131,123 +163,80 @@ DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, { int direction = -1; array[i]->vt->QueryDirection(array[i], (PIN_DIRECTION*)&direction); - if (!this->m_pInputPin && direction == 0) + if (!This->m_pInputPin && direction == 0) { - this->m_pInputPin = array[i]; - this->m_pInputPin->vt->AddRef((IUnknown*)this->m_pInputPin); + This->m_pInputPin = array[i]; + This->m_pInputPin->vt->AddRef((IUnknown*)This->m_pInputPin); } - if (!this->m_pOutputPin && direction == 1) + if (!This->m_pOutputPin && direction == 1) { - this->m_pOutputPin = array[i]; - this->m_pOutputPin->vt->AddRef((IUnknown*)this->m_pOutputPin); + 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) { - printf("Input pin not found\n"); - return NULL; - } - - if (!this->m_pOutputPin) { - printf("Output pin not found\n"); - return NULL; + if (!This->m_pInputPin) + { + em = "could not find input pin"; + break; } - - result = this->m_pInputPin->vt->QueryInterface((IUnknown*)this->m_pInputPin, - &IID_IMemInputPin, - (void**)&this->m_pImp); - if (result) { - printf("Error getting IMemInputPin interface\n"); - return NULL; - } - - this->m_pOurType = in_fmt; - this->m_pDestType = out_fmt; - result = this->m_pInputPin->vt->QueryAccept(this->m_pInputPin, this->m_pOurType); - if (result) { - printf("Source format is not accepted\n"); - return NULL; + if (!This->m_pOutputPin) + { + em = "could not find output pin"; + break; } - - this->m_pParentFilter = CBaseFilter2_Create(); - this->m_pSrcFilter = CBaseFilter_Create(this->m_pOurType, this->m_pParentFilter); - this->m_pOurInput = CBaseFilter_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) { - printf("Error connecting to input pin\n"); - return NULL; + 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_pOurOutput = COutputPin_Create(this->m_pDestType); - //extern void trapbug(); - //trapbug(); - result = this->m_pOutputPin->vt->ReceiveConnection(this->m_pOutputPin, - (IPin*)this->m_pOurOutput, - this->m_pDestType); + This->m_pOurType = in_fmt; + This->m_pDestType = out_fmt; + result = This->m_pInputPin->vt->QueryAccept(This->m_pInputPin, This->m_pOurType); if (result) { - printf("Error connecting to output pin (result = %x)\n",(int)result); - return NULL; + 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; } - printf("Using DirectShow codec: %s\n", dllname); - this->m_iState = 1; - } - /* - catch (printfError& e) - { - //e.PrintAll(); - destroy(); - throw; - } - */ - return this; -} -void DS_Filter_Start(DS_Filter *this) -{ - HRESULT hr; - if (this->m_iState != 1) - return; + This->m_pOurOutput = COutputPinCreate(This->m_pDestType); - Debug printf("DS_Filter::Start() %p\n", this->m_pFilter); + 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; + } - this->m_pFilter->vt->Pause(this->m_pFilter); - - hr=this->m_pFilter->vt->Run(this->m_pFilter, 0); - if (hr != 0) - { - Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr); - } - hr = this->m_pImp->vt->GetAllocator(this->m_pImp, &this->m_pAll); - if (hr) - { - Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr); - this->m_pImp->vt->Release((IUnknown*)this->m_pImp); - return; + printf("Using DirectShow codec: %s\n", dllname); + init++; + break; } - this->m_pImp->vt->NotifyAllocator(this->m_pImp, this->m_pAll, 0); - this->m_iState = 2; -} -void DS_Filter_Stop(DS_Filter *this) -{ - if (this->m_iState == 2) + if (!init) { - this->m_iState = 1; - Debug printf("DS_Filter::Stop() %p\n", this->m_pFilter); - if (this->m_pFilter) - { - //printf("vt: %p\n", this->m_pFilter->vt); - //printf("vtstop %p\n", this->m_pFilter->vt->Stop); - this->m_pFilter->vt->Stop(this->m_pFilter); // causes weird crash ??? FIXME - } - else - printf("WARNING: DS_Filter::Stop() m_pFilter is NULL!\n"); - this->m_pAll->vt->Release((IUnknown*)this->m_pAll); - this->m_pAll = 0; + DS_Filter_Destroy(This); + printf("Warning: DS_Filter() %s. (DLL=%.200s)\n", em, dllname); + This = 0; } + return This; } diff --git a/src/libw32dll/DirectShow/DS_Filter.h b/src/libw32dll/DirectShow/DS_Filter.h index 3b069cffe..909217602 100644 --- a/src/libw32dll/DirectShow/DS_Filter.h +++ b/src/libw32dll/DirectShow/DS_Filter.h @@ -4,12 +4,16 @@ #include "inputpin.h" #include "outputpin.h" +#if defined(__cplusplus) +extern "C" { +#endif + /** User will allocate and fill format structures, call Create(), and then set up m_pAll. **/ -typedef struct _DS_Filter DS_Filter; +typedef struct _DS_Filter DS_Filter; struct _DS_Filter { int m_iHandle; @@ -22,21 +26,20 @@ struct _DS_Filter IPin* m_pOurInput; COutputPin* m_pOurOutput; - AM_MEDIA_TYPE *m_pOurType; - AM_MEDIA_TYPE *m_pDestType; + AM_MEDIA_TYPE *m_pOurType, *m_pDestType; IMemAllocator* m_pAll; IMemInputPin* m_pImp; - int m_iState; -}; - -void DS_Filter_Destroy(DS_Filter * this); -DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, - AM_MEDIA_TYPE* in_fmt, - AM_MEDIA_TYPE* out_fmt); + void ( *Start )(DS_Filter*); + void ( *Stop )(DS_Filter*); +}; -void DS_Filter_Start(DS_Filter *this); +DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, + AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt); +void DS_Filter_Destroy(DS_Filter* This); -void DS_Filter_Stop(DS_Filter *this); +#if defined(__cplusplus) +} +#endif #endif /* DS_FILTER_H */ diff --git a/src/libw32dll/DirectShow/DS_VideoDecoder.c b/src/libw32dll/DirectShow/DS_VideoDecoder.c index 85f5817a8..faa080fef 100644 --- a/src/libw32dll/DirectShow/DS_VideoDecoder.c +++ b/src/libw32dll/DirectShow/DS_VideoDecoder.c @@ -8,7 +8,31 @@ #include "guids.h" #include "interfaces.h" +#ifndef NOAVIFILE_HEADERS +#include "videodecoder.h" +#else +#include "libwin32.h" +#endif +#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 +}; + #include "DS_VideoDecoder.h" + #include "../wine/winerror.h" #ifndef NOAVIFILE_HEADERS @@ -57,7 +81,7 @@ static ct check[] = { }; -DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * format, int flip, int maxauto) +DS_VideoDecoder * DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto) { DS_VideoDecoder *this; HRESULT result; @@ -70,6 +94,10 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f this->m_iLastQuality = -1; this->m_iMaxAuto = maxauto; +#ifdef LDT_paranoia + Setup_LDT_Keeper(); +#endif + //memset(&m_obh, 0, sizeof(m_obh)); //m_obh.biSize = sizeof(m_obh); /*try*/ @@ -140,22 +168,24 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f * ((this->iv.m_obh.biBitCount + 7) / 8); - this->m_pDS_Filter = DS_Filter_Create((const char*)info->dll, &info->guid, &this->m_sOurType, &this->m_sDestType); - if( !this->m_pDS_Filter ) { - /* FIXME: memory leak */ - return NULL; - } + this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType); + if (!this->m_pDS_Filter) + { + printf("Failed to create DirectShow filter\n"); + return 0; + } + if (!flip) { - this->m_sVhdr2->bmiHeader.biHeight *= -1; 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 frames\n"); - this->m_sVhdr2->bmiHeader.biHeight *= -1; + 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; } } @@ -170,7 +200,7 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f case fccMP42: case fccWMV2: //YV12 seems to be broken for DivX :-) codec - case fccIV50: +// case fccIV50: //produces incorrect picture //m_Caps = (CAPS) (m_Caps & ~CAP_YV12); //m_Caps = CAP_UYVY;//CAP_YUY2; // | CAP_I420; @@ -200,11 +230,11 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; this->m_iMinBuffers = this->iv.VBUFSIZE; - this->m_bIsDivX = (strcmp((const char*)info->dll, "divxcvki.ax") == 0 - || strcmp((const char*)info->dll, "divx_c32.ax") == 0 - || strcmp((const char*)info->dll, "wmvds32.ax") == 0 - || strcmp((const char*)info->dll, "wmv8ds32.ax") == 0); - this->m_bIsDivX4 = (strcmp((const char*)info->dll, "divxdec.ax") == 0); + 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) @@ -234,7 +264,7 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this) ALLOCATOR_PROPERTIES props, props1; Debug printf("DS_VideoDecoder_StartInternal\n"); //cout << "DSSTART" << endl; - DS_Filter_Start(this->m_pDS_Filter); + this->m_pDS_Filter->Start(this->m_pDS_Filter); props.cBuffers = 1; props.cbBuffer = this->m_sDestType.lSampleSize; @@ -244,22 +274,22 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this) this->m_pDS_Filter->m_pAll->vt->SetProperties(this->m_pDS_Filter->m_pAll, &props, &props1); this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll); - //this->iv.m_State = START; + this->iv.m_State = START; } void DS_VideoDecoder_StopInternal(DS_VideoDecoder *this) { - DS_Filter_Stop(this->m_pDS_Filter); + 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, CImage* pImage) +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->ptr); + 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); @@ -272,18 +302,13 @@ int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int s //cout << "DECODE " << (void*) pImage << " d: " << (void*) pImage->Data() << endl; if (pImage) { - if (!(pImage->ptr)) - { - Debug printf("no m_outFrame??\n"); - } - else - COutputPin_SetPointer2(this->m_pDS_Filter->m_pOurOutput,(char*)pImage->ptr); + this->m_pDS_Filter->m_pOurOutput->SetPointer2(this->m_pDS_Filter->m_pOurOutput,pImage); } + sample->vt->SetActualDataLength(sample, size); sample->vt->GetPointer(sample, (BYTE **)&ptr); memcpy(ptr, src, size); - sample->vt->SetActualDataLength(sample, size); sample->vt->SetSyncPoint(sample, is_keyframe); sample->vt->SetPreroll(sample, pImage ? 0 : 1); // sample->vt->SetMediaType(sample, &m_sOurType); @@ -294,7 +319,9 @@ int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int s // crashes inside ...->Receive() fixed now? // // nope - but this is surely helpfull - I'll try some more experiments - //Setup_FS_Segment(); +#ifdef LDT_paranoia + Setup_FS_Segment(); +#endif #if 0 if (!this->m_pDS_Filter || !this->m_pDS_Filter->m_pImp || !this->m_pDS_Filter->m_pImp->vt @@ -381,7 +408,7 @@ int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int s * 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, fourcc_t csp) +int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, unsigned int csp) { HRESULT result; int should_test=1; @@ -394,7 +421,7 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp) */ // BitmapInfo temp = m_obh; - if (bits != 0) + if (!csp) // RGB { int ok = true; @@ -442,10 +469,8 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp) } } //.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8)); - } - - if (csp != 0) - { + } else + { // YUV int ok = true; switch (csp) { @@ -470,19 +495,6 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp) } if (ok) { - int bits=0; - switch(csp){ - case fccYUV: - bits=24;break; - case fccYUY2: - case fccUYVY: - case fccYVYU: - bits=16;break; - case fccYV12: - case fccIYUV: - case fccI420: - bits=12;break; - } 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); @@ -565,7 +577,7 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp) 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); - COutputPin_SetNewFormat(this->m_pDS_Filter->m_pOurOutput,&this->m_sDestType); + 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); @@ -600,7 +612,7 @@ int DS_VideoDecoder_SetDirection(DS_VideoDecoder *this, int d) return 0; } -HRESULT DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value) +int DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value) { /* if (m_bIsDivX4) @@ -709,15 +721,14 @@ HRESULT DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* v return 0; } -HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value) +int DS_VideoDecoder_SetValue(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)) + 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)) { - Debug printf("No such interface\n"); + printf("No such interface\n"); return -1; } if (strcmp(name, "Postprocessing") == 0) @@ -729,14 +740,15 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va else if (strcmp(name, "Saturation") == 0) pIDivx->vt->put_Saturation(pIDivx, value); else if (strcmp(name, "MaxAuto") == 0) - m_iMaxAuto = value; + this->m_iMaxAuto = value; pIDivx->vt->Release((IUnknown*)pIDivx); //printf("Set %s %d\n", name, value); return 0; } - else if (m_bIsDivX) - { - if (m_State != START) + + if (this->m_bIsDivX) { + IHidden* hidden; + if (this->iv.m_State != START) return VFW_E_NOT_RUNNING; //cout << "set value " << name << " " << value << endl; @@ -751,10 +763,11 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va // get4=set3 73 // get5=set4 19 // get6=set5 23 - IHidden* hidden = (IHidden*)((int)m_pDS_Filter->m_pFilter + 0xb8); + hidden = (IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8); + printf("DS_SetValue for DIVX, name=%s value=%d\n",name,value); if (strcmp(name, "Quality") == 0) { - m_iLastQuality = value; + this->m_iLastQuality = value; return hidden->vt->SetSmth(hidden, value, 0); } if (strcmp(name, "Brightness") == 0) @@ -767,11 +780,12 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va return hidden->vt->SetSmth5(hidden, value, 0); if (strcmp(name, "MaxAuto") == 0) { - m_iMaxAuto = value; - return 0; + this->m_iMaxAuto = value; } + return 0; } - else if (strcmp((const char*)record.dll, "ir50_32.dll") == 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)) @@ -811,9 +825,71 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va return result; } -*/ +#endif + printf("DS_SetValue for ????, name=%s value=%d\n",name,value); return 0; } /* -vim: tabstop=8 +vim: vi* sux. +hahaha */ + +#if 0 +int DS_SetAttr_DivX(char* attribute, int value){ + int result, status, newkey, count; + if(strcmp(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( + (strcmp(attribute, "Saturation")==0) || + (strcmp(attribute, "Hue")==0) || + (strcmp(attribute, "Contrast")==0) || + (strcmp(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; +} +#endif + + + diff --git a/src/libw32dll/DirectShow/DS_VideoDecoder.h b/src/libw32dll/DirectShow/DS_VideoDecoder.h index ba97162da..82e76f66a 100644 --- a/src/libw32dll/DirectShow/DS_VideoDecoder.h +++ b/src/libw32dll/DirectShow/DS_VideoDecoder.h @@ -1,34 +1,11 @@ #ifndef AVIFILE_DS_VIDEODECODER_H #define AVIFILE_DS_VIDEODECODER_H -#ifndef NOAVIFILE_HEADERS -#include "videodecoder.h" -#else -#include "../libwin32.h" -#endif -#include "DS_Filter.h" - -typedef 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 -}DS_VideoDecoder; - - +typedef struct _DS_VideoDecoder DS_VideoDecoder; int DS_VideoDecoder_GetCapabilities(DS_VideoDecoder *this); -DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * format, int flip, int maxauto); +DS_VideoDecoder * DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto); void DS_VideoDecoder_Destroy(DS_VideoDecoder *this); @@ -36,20 +13,16 @@ 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, CImage* pImage); +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, fourcc_t csp); - - +int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, unsigned int csp); int DS_VideoDecoder_SetDirection(DS_VideoDecoder *this, int d); - -HRESULT DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value); - -HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value); +int DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value); +int DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value); #endif /* AVIFILE_DS_VIDEODECODER_H */ diff --git a/src/libw32dll/DirectShow/Makefile.am b/src/libw32dll/DirectShow/Makefile.am index 6041d0c0b..a9636a6b0 100644 --- a/src/libw32dll/DirectShow/Makefile.am +++ b/src/libw32dll/DirectShow/Makefile.am @@ -1,11 +1,13 @@ CFLAGS = @GLOBAL_CFLAGS@ @X_CFLAGS@ -fno-omit-frame-pointer \ -Wmissing-prototypes -Wimplicit-function-declaration \ - -DWIN32_PATH=\"@w32_path@\" -DNOAVIFILE_HEADERS + -DWIN32_PATH=\"@w32_path@\" -DNOAVIFILE_HEADERS \ + -I.. -I../wine DEBUG_CFLAGS = @DEBUG_CFLAGS@ @X_CFLAGS@ -fno-omit-frame-pointer \ -Wmissing-prototypes -Wimplicit-function-declaration \ - -DWIN32_PATH=\\\"@w32_path@\\\" -DNOAVIFILE_HEADERS + -DWIN32_PATH=\\\"@w32_path@\\\" -DNOAVIFILE_HEADERS \ + -I.. -I../wine if HAVE_W32DLL ds_filter_lib = libds_filter.la diff --git a/src/libw32dll/DirectShow/allocator.c b/src/libw32dll/DirectShow/allocator.c index f9f6826ea..bc129dc42 100644 --- a/src/libw32dll/DirectShow/allocator.c +++ b/src/libw32dll/DirectShow/allocator.c @@ -1,163 +1,141 @@ #include "allocator.h" -#include "cmediasample.h" -#include "../wine/com.h" -#include "../wine/winerror.h" +#include "com.h" +#include "wine/winerror.h" #include <stdio.h> -#include <stdlib.h> -//#undef Debug -//#define Debug +static int AllocatorKeeper = 0; -/* -class AllocatorKeeper +static inline int avm_list_size(avm_list_t* head) { -public: - AllocatorKeeper() + avm_list_t* it = head; + int i = 0; + if (it) { - RegisterComClass(&CLSID_MemoryAllocator, MemAllocator::CreateAllocator); - } - ~AllocatorKeeper() - { - UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator::CreateAllocator); - } -}; -static AllocatorKeeper keeper; -*/ -static int Allocator_Used; - -void CMediaSample_vector_copy(CMediaSample_vector *this, CMediaSample** in, int sz, int alloc) -{ - int i; - this->m_Type = malloc(alloc*sizeof(CMediaSample *)); - this->m_uiSize = sz; - this->m_uiAlloc = alloc; - for (i = 0; i < sz; i++) - this->m_Type[i] = in[i]; -} - -CMediaSample** CMediaSample_vector_begin(CMediaSample_vector *this) -{ return this->m_Type; } - -CMediaSample** CMediaSample_vector_end(CMediaSample_vector *this) -{ return this->m_Type + this->m_uiSize; } - -void CMediaSample_vector_pop_back(CMediaSample_vector *this) -{ - this->m_uiSize--; - if ((this->m_uiAlloc >= 8) && (this->m_uiSize < this->m_uiAlloc / 4)) + for (;;) { - CMediaSample** t = this->m_Type; - CMediaSample_vector_copy(this, this->m_Type, this->m_uiSize, this->m_uiAlloc / 2); - free(t); + i++; + it = it->next; + if (it == head) + break; } + } + return i; } -void CMediaSample_vector_erase(CMediaSample_vector *this, CMediaSample** pos) +static inline int avm_list_print(avm_list_t* head) { - if (this->m_uiSize > 0) + avm_list_t* it = head; + int i = 0; + printf("Head: %p\n", head); + if (it) + { + for (;;) { - while (pos < CMediaSample_vector_end(this) - 1) - { - pos[0] = pos[1]; - pos++; - } - CMediaSample_vector_pop_back(this); + 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; } - -void CMediaSample_vector_push_back(CMediaSample_vector *this, CMediaSample *m) + +static inline avm_list_t* avm_list_add_head(avm_list_t* head, void* member) { - if (this->m_uiSize + 1 >= this->m_uiAlloc) - { - CMediaSample** t = this->m_Type; - CMediaSample_vector_copy(this, this->m_Type, this->m_uiSize, this->m_uiAlloc * 2); - free(t); - } - this->m_Type[this->m_uiSize++] = m; -} + avm_list_t* n = (avm_list_t*) 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; -int CMediaSample_vector_size(CMediaSample_vector *this) -{ return this->m_uiSize; } + return n; +} -void CMediaSample_vector_clear(CMediaSample_vector *this) +static inline avm_list_t* avm_list_add_tail(avm_list_t* head, void* member) { - if (this->m_uiAlloc > 4) + 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) { - free( this->m_Type ); - this->m_uiAlloc = 4; - this->m_Type = malloc(this->m_uiAlloc*sizeof(CMediaSample *)); + n = head->next; + head->prev->next = head->next; + head->next->prev = head->prev; } - this->m_uiSize = 0; + free(head); + } + return n; } -CMediaSample_vector * CMediaSample_vector_create() +static inline avm_list_t* avm_list_find(avm_list_t* head, void* member) { - CMediaSample_vector *this; - this = malloc( sizeof( CMediaSample_vector ) ); - this->m_uiAlloc = 4; - this->m_Type = malloc(sizeof(CMediaSample *) * this->m_uiAlloc); - this->m_uiSize = 0; - return this; + avm_list_t* it = head; + if (it) + { + for (;;) + { + if (it->member == member) + return it; + it = it->next; + if (it == head) + break; + } + } + return NULL; } - -IMPLEMENT_IUNKNOWN(MemAllocator) - -long MemAllocator_CreateAllocator(GUID* clsid, GUID* iid, void** ppv) +static long MemAllocator_CreateAllocator(GUID* clsid, GUID* iid, void** ppv) { - MemAllocator* p; + IMemAllocator* p; int result; - - if (!ppv) return -1; + if (!ppv) + return -1; *ppv = 0; if (memcmp(clsid, &CLSID_MemoryAllocator, sizeof(GUID))) return -1; - p = MemAllocator_Create(); - result=p->vt->QueryInterface((IUnknown*)p, iid, ppv); + p = (IMemAllocator*) MemAllocatorCreate(); + result = p->vt->QueryInterface((IUnknown*)p, iid, ppv); p->vt->Release((IUnknown*)p); - return result; -} -void MemAllocator_SetPointer(MemAllocator*this, char* pointer) -{ this->new_pointer=pointer; } - -void MemAllocator_ResetPointer(MemAllocator*this) -{ - if (this->modified_sample) - { - this->modified_sample->ResetPointer(this->modified_sample); - this->modified_sample=0; - } -} - - -void AllocatorKeeper_Create() { -RegisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); -} - -void AllocatorKeeper_Destroy() { -UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); + return result; } - static HRESULT STDCALL MemAllocator_SetProperties(IMemAllocator * This, /* [in] */ ALLOCATOR_PROPERTIES *pRequest, /* [out] */ ALLOCATOR_PROPERTIES *pActual) { MemAllocator* me = (MemAllocator*)This; - - Debug printf("MemAllocator_SetProperties() called\n"); + 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 (CMediaSample_vector_size(me->used_list) || CMediaSample_vector_size(me->free_list)) + if (me->used_list != 0 || me->free_list != 0) return E_FAIL; - me->props = *pRequest; + *pActual = *pRequest; + //if (pActual->cbBuffer == 2) + // pActual->cbBuffer = 576; + + me->props = *pActual; + return 0; } @@ -170,40 +148,55 @@ static HRESULT STDCALL MemAllocator_GetProperties(IMemAllocator * This, if (((MemAllocator*)This)->props.cbBuffer<0) return E_FAIL; *pProps=((MemAllocator*)This)->props; + return 0; } static HRESULT STDCALL MemAllocator_Commit(IMemAllocator * This) { - int i; MemAllocator* me = (MemAllocator*)This; - + int i; Debug printf("MemAllocator_Commit(%p) called\n", This); if (((MemAllocator*)This)->props.cbBuffer < 0) return E_FAIL; - if (CMediaSample_vector_size(me->used_list) || CMediaSample_vector_size(me->free_list)) + if (me->used_list || me->free_list) return E_INVALIDARG; - for(i = 0; i<me->props.cBuffers; i++) - CMediaSample_vector_push_back(me->free_list,CMediaSample_Create(This, me->props.cbBuffer)); + 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: %d %d size: %d\n", me, me->free_list.size(), me->props.cBuffers, me->props.cbBuffer); + //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; - CMediaSample **it; Debug printf("MemAllocator_Decommit(%p) called\n", This); - //printf("Deleted mem %p: %d %d\n", me, me->free_list.size(), me->used_list.size()); - for(it=CMediaSample_vector_begin(me->free_list); it!=CMediaSample_vector_end(me->free_list); it++) - CMediaSample_Destroy(*it); - for(it=CMediaSample_vector_begin(me->used_list); it!=CMediaSample_vector_end(me->used_list); it++) - CMediaSample_Destroy(*it); - - CMediaSample_vector_clear(me->free_list); - CMediaSample_vector_clear(me->used_list); + 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; } @@ -214,94 +207,130 @@ static HRESULT STDCALL MemAllocator_GetBuffer(IMemAllocator * This, /* [in] */ DWORD dwFlags) { MemAllocator* me = (MemAllocator*)This; - CMediaSample **it; - - it = CMediaSample_vector_begin(me->free_list); - - Debug printf("MemAllocator_GetBuffer(%p) called\n", This); - if (CMediaSample_vector_size(me->free_list) == 0) + 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 } - CMediaSample_vector_push_back(me->used_list,*it); - *ppBuffer = (IMediaSample *)*it; - (*ppBuffer)->vt->AddRef((IUnknown*)*ppBuffer); + + 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) + if (me->modified_sample) me->modified_sample->ResetPointer(me->modified_sample); - (*it)->SetPointer(*it,me->new_pointer); - me->modified_sample = *it; + sample->SetPointer(sample, me->new_pointer); + me->modified_sample = sample; me->new_pointer = 0; } - CMediaSample_vector_erase(me->free_list,it); return 0; } -static HRESULT STDCALL MemAllocator_ReleaseBuffer(IMemAllocator * This, - /* [in] */ IMediaSample *pBuffer) +static HRESULT STDCALL MemAllocator_ReleaseBuffer(IMemAllocator* This, + /* [in] */ IMediaSample* pBuffer) { + avm_list_t* l; MemAllocator* me = (MemAllocator*)This; - CMediaSample **it; - - Debug printf("MemAllocator_ReleaseBuffer(%p) called\n", This); - - for (it = CMediaSample_vector_begin(me->used_list); it != CMediaSample_vector_end(me->used_list); it++) - if ( *it == (CMediaSample*)pBuffer) + 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) { - CMediaSample_vector_erase(me->used_list,it); - CMediaSample_vector_push_back(me->free_list,(CMediaSample*)pBuffer); - return 0; + me->modified_sample->ResetPointer(me->modified_sample); + me->modified_sample = 0; } - Debug printf("Releasing unknown buffer\n"); + 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; } -MemAllocator * MemAllocator_Create() + +static void MemAllocator_SetPointer(MemAllocator* This, char* pointer) +{ + This->new_pointer = pointer; +} + +static void MemAllocator_ResetPointer(MemAllocator* This) { - MemAllocator *this; - - this = malloc(sizeof(MemAllocator)); - - Debug printf("MemAllocator::MemAllocator() called\n"); - this->vt = malloc(sizeof(IMemAllocator_vt)); - - 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->refcount = 1; - this->props.cBuffers = 1; - this->props.cbBuffer = 65536; /* :/ */ - this->props.cbAlign = this->props.cbPrefix = 0; - - this->new_pointer=0; - this->modified_sample=0; - - this->interfaces[0]=IID_IUnknown; - this->interfaces[1]=IID_IMemAllocator; - - this->used_list = CMediaSample_vector_create(); - this->free_list = CMediaSample_vector_create(); - - if( Allocator_Used++ == 0) - RegisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); - - return this; + if (This->modified_sample) + { + This->modified_sample->ResetPointer(This->modified_sample); + This->modified_sample = 0; + } } -void MemAllocator_Destroy(MemAllocator *this) +void MemAllocator_Destroy(MemAllocator* This) { - if( --Allocator_Used == 0) - UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); - - Debug printf("MemAllocator::~MemAllocator() called\n"); - free( this->vt ); + Debug printf("MemAllocator_Destroy(%p) called (%d, %d)\n", This, This->refcount, AllocatorKeeper); + if (--AllocatorKeeper == 0) + UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); + free(This->vt); + free(This); +} + +IMPLEMENT_IUNKNOWN(MemAllocator) + +MemAllocator* MemAllocatorCreate() +{ + MemAllocator* This = (MemAllocator*) 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 = This->props.cbPrefix = 0; + + This->vt = (IMemAllocator_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; + + if (AllocatorKeeper++ == 0) + RegisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator); + + return This; } diff --git a/src/libw32dll/DirectShow/allocator.h b/src/libw32dll/DirectShow/allocator.h index 1d37dd920..855637063 100644 --- a/src/libw32dll/DirectShow/allocator.h +++ b/src/libw32dll/DirectShow/allocator.h @@ -1,51 +1,32 @@ #ifndef DS_ALLOCATOR_H #define DS_ALLOCATOR_H -/* -#ifndef NOAVIFILE_HEADERS -#include "default.h" -#else -#include "../wine/libwin32.h" -#endif -*/ - #include "interfaces.h" #include "cmediasample.h" -#include "iunk.h" -typedef struct _CMediaSample_vector -{ - CMediaSample** m_Type; - int m_uiSize; - int m_uiAlloc; -} CMediaSample_vector; +typedef struct avm_list_t +{ + struct avm_list_t* next; + struct avm_list_t* prev; + void* member; +} avm_list_t; -typedef struct _MemAllocator +typedef struct _MemAllocator MemAllocator; +struct _MemAllocator { - IMemAllocator_vt *vt; - + IMemAllocator_vt* vt; + DECLARE_IUNKNOWN(); ALLOCATOR_PROPERTIES props; - - CMediaSample_vector * used_list; - CMediaSample_vector * free_list; - + avm_list_t* used_list; + avm_list_t* free_list; char* new_pointer; CMediaSample* modified_sample; GUID interfaces[2]; - DECLARE_IUNKNOWN(MemAllocator); - - /* - MemAllocator(); - ~MemAllocator(); - static long CreateAllocator(GUID* clsid, GUID* iid, void** ppv); - */ -} MemAllocator; -MemAllocator * MemAllocator_Create(); -void MemAllocator_Destroy(MemAllocator *this); + void ( *SetPointer )(MemAllocator* This, char* pointer); + void ( *ResetPointer )(MemAllocator* This); +}; -long MemAllocator_CreateAllocator(GUID* clsid, GUID* iid, void** ppv); -void MemAllocator_SetPointer(MemAllocator*this, char* pointer); -void MemAllocator_ResetPointer(MemAllocator*this); +MemAllocator* MemAllocatorCreate(); #endif /* DS_ALLOCATOR_H */ diff --git a/src/libw32dll/DirectShow/cmediasample.c b/src/libw32dll/DirectShow/cmediasample.c index 1f2f2d0ca..eba60dd4a 100644 --- a/src/libw32dll/DirectShow/cmediasample.c +++ b/src/libw32dll/DirectShow/cmediasample.c @@ -1,26 +1,25 @@ #include "cmediasample.h" -#include "../wine/winerror.h" +#include "wine/winerror.h" #include <stdio.h> #include <string.h> -#include <stdlib.h> -static long STDCALL CMediaSample_QueryInterface(IUnknown * This, +static long STDCALL CMediaSample_QueryInterface(IUnknown* This, /* [in] */ IID* iid, /* [iid_is][out] */ void **ppv) { - Debug printf("CMediaSample_QueryInterface() called\n"); + Debug printf("CMediaSample_QueryInterface(%p) called\n", This); if (!ppv) return E_INVALIDARG; - if (!memcmp(iid, &IID_IUnknown, 16)) + if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0) { - *ppv=(void*)This; - ((IMediaSample *)This)->vt->AddRef(This); + *ppv = (void*)This; + ((IMediaSample*) This)->vt->AddRef(This); return 0; } - if (!memcmp(iid, &IID_IMediaSample, 16)) + if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0) { - *ppv=(void*)This; - ((IMediaSample *)This)->vt->AddRef(This); + *ppv = (void*)This; + ((IMediaSample*) This)->vt->AddRef(This); return 0; } return E_NOINTERFACE; @@ -28,44 +27,57 @@ static long STDCALL CMediaSample_QueryInterface(IUnknown * This, static long STDCALL CMediaSample_AddRef(IUnknown* This) { - Debug printf("CMediaSample_AddRef() called\n"); + Debug printf("CMediaSample_AddRef(%p) called\n", This); ((CMediaSample*)This)->refcount++; return 0; } +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 (This->media_type.pbFormat) + CoTaskMemFree(This->media_type.pbFormat); + free(This); +} + static long STDCALL CMediaSample_Release(IUnknown* This) { - CMediaSample* parent=(CMediaSample*)This; - Debug printf("%p: CMediaSample_Release() called, new refcount %d\n", + CMediaSample* parent = (CMediaSample*)This; + Debug printf("CMediaSample_Release(%p) called (new ref:%d)\n", This, ((CMediaSample*)This)->refcount-1); - if (--((CMediaSample*)This)->refcount==0) + + if (--((CMediaSample*) This)->refcount == 0) + { parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all), (IMediaSample*)This); + } return 0; } -static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample * This, - /* [out] */ BYTE **ppBuffer) +static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This, + /* [out] */ BYTE** ppBuffer) { - Debug printf("%p: CMediaSample_GetPointer() called\n", This); + 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; + *ppBuffer = (BYTE*) ((CMediaSample*) This)->block; return 0; } static long STDCALL CMediaSample_GetSize(IMediaSample * This) { - Debug printf("%p: CMediaSample_GetSize() called -> %d\n", - This, ((CMediaSample*)This)->size); - return ((CMediaSample*)This)->size; + Debug printf("CMediaSample_GetSize(%p) called -> %d\n", This, ((CMediaSample*) This)->size); + return ((CMediaSample*) This)->size; } static HRESULT STDCALL CMediaSample_GetTime(IMediaSample * This, /* [out] */ REFERENCE_TIME *pTimeStart, /* [out] */ REFERENCE_TIME *pTimeEnd) { - Debug printf("%p: CMediaSample_GetTime() called\n", This); + Debug printf("CMediaSample_GetTime(%p) called (UNIMPLIMENTED)\n", This); return E_NOTIMPL; } @@ -73,13 +85,13 @@ static HRESULT STDCALL CMediaSample_SetTime(IMediaSample * This, /* [in] */ REFERENCE_TIME *pTimeStart, /* [in] */ REFERENCE_TIME *pTimeEnd) { - Debug printf("%p: CMediaSample_SetTime() called\n", This); + Debug printf("CMediaSample_SetTime(%p) called (UNIMPLIMENTED)\n", This); return E_NOTIMPL; } static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This) { - Debug printf("%p: CMediaSample_IsSyncPoint() called\n", This); + Debug printf("CMediaSample_IsSyncPoint(%p) called\n", This); if (((CMediaSample*)This)->isSyncPoint) return 0; return 1; @@ -88,14 +100,14 @@ static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This) static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This, long bIsSyncPoint) { - Debug printf("%p: CMediaSample_SetSyncPoint() called\n", This); - ((CMediaSample*)This)->isSyncPoint=bIsSyncPoint; + Debug printf("CMediaSample_SetSyncPoint(%p) called\n", This); + ((CMediaSample*)This)->isSyncPoint = bIsSyncPoint; return 0; } static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This) { - Debug printf("%p: CMediaSample_IsPreroll() called\n", This); + Debug printf("CMediaSample_IsPreroll(%p) called\n", This); if (((CMediaSample*)This)->isPreroll) return 0;//S_OK @@ -106,35 +118,41 @@ static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This) static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This, long bIsPreroll) { - Debug printf("%p: CMediaSample_SetPreroll() called\n", This); + Debug printf("CMediaSample_SetPreroll(%p) called\n", This); ((CMediaSample*)This)->isPreroll=bIsPreroll; return 0; } -static long STDCALL CMediaSample_GetActualDataLength(IMediaSample * This) +static long STDCALL CMediaSample_GetActualDataLength(IMediaSample* This) { - Debug printf("%p: CMediaSample_GetActualDataLength() called -> %d\n", This, ((CMediaSample*)This)->actual_size); + Debug printf("CMediaSample_GetActualDataLength(%p) called -> %d\n", This, ((CMediaSample*)This)->actual_size); return ((CMediaSample*)This)->actual_size; } -static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample * This, +static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample* This, long __MIDL_0010) { - Debug printf("%p: CMediaSample_SetActualDataLength(%ld) called\n", This, __MIDL_0010); - if (__MIDL_0010 > ((CMediaSample*)This)->size) + CMediaSample* cms = (CMediaSample*)This; + Debug printf("CMediaSample_SetActualDataLength(%p, %ld) called\n", This, __MIDL_0010); + if (__MIDL_0010 > cms->size) { - printf("%p: ERROR: CMediaSample buffer overflow\n", This); + 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, __MIDL_0010); + if (c == cms->block) + cms->block = cms->own_block; + cms->size = __MIDL_0010; } - ((CMediaSample*)This)->actual_size=__MIDL_0010; + cms->actual_size = __MIDL_0010; return 0; } -static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample * This, - AM_MEDIA_TYPE **ppMediaType) +static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample* This, + AM_MEDIA_TYPE** ppMediaType) { - AM_MEDIA_TYPE *t=&((CMediaSample*)This)->media_type; - - Debug printf("%p: CMediaSample_GetMediaType() called\n", This); + AM_MEDIA_TYPE* t; + Debug printf("CMediaSample_GetMediaType(%p) called\n", This); if(!ppMediaType) return E_INVALIDARG; if(!((CMediaSample*)This)->type_valid) @@ -142,122 +160,156 @@ static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample * This, *ppMediaType=0; return 1; } -// if(t.pbFormat)CoTaskMemFree(t.pbFormat); - (*ppMediaType)=(AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); - memcpy(*ppMediaType, t, sizeof(AM_MEDIA_TYPE)); - (*ppMediaType)->pbFormat=(char*)CoTaskMemAlloc(t->cbFormat); + + t = &((CMediaSample*)This)->media_type; + // if(t.pbFormat)CoTaskMemFree(t.pbFormat); + (*ppMediaType) = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + **ppMediaType = *t; + (*ppMediaType)->pbFormat = (char*)CoTaskMemAlloc(t->cbFormat); memcpy((*ppMediaType)->pbFormat, t->pbFormat, t->cbFormat); -// *ppMediaType=0; //media type was not changed + // *ppMediaType=0; //media type was not changed return 0; } static HRESULT STDCALL CMediaSample_SetMediaType(IMediaSample * This, AM_MEDIA_TYPE *pMediaType) { - AM_MEDIA_TYPE *t = &((CMediaSample*)This)->media_type; - - Debug printf("%p: CMediaSample_SetMediaType() called\n", This); + AM_MEDIA_TYPE* t; + Debug printf("CMediaSample_SetMediaType(%p) called\n", This); if (!pMediaType) return E_INVALIDARG; + t = &((CMediaSample*)This)->media_type; if (t->pbFormat) CoTaskMemFree(t->pbFormat); t = pMediaType; - t->pbFormat = (char*)CoTaskMemAlloc(t->cbFormat); - memcpy(t->pbFormat, pMediaType->pbFormat, t->cbFormat); - ((CMediaSample*)This)->type_valid=1; + if (t->cbFormat) + { + t->pbFormat = (char*)CoTaskMemAlloc(t->cbFormat); + memcpy(t->pbFormat, pMediaType->pbFormat, t->cbFormat); + } + else + t->pbFormat = 0; + ((CMediaSample*) This)->type_valid=1; return 0; } static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This) { - Debug printf("%p: CMediaSample_IsDiscontinuity() called\n", This); - return 1; + Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This); + return ((CMediaSample*) This)->isDiscontinuity; } static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This, long bDiscontinuity) { - Debug printf("%p: CMediaSample_SetDiscontinuity() called\n", This); - return E_NOTIMPL; + Debug printf("CMediaSample_SetDiscontinuity(%p) called (%ld)\n", This, bDiscontinuity); + ((CMediaSample*) This)->isDiscontinuity = bDiscontinuity; + return 0; } static HRESULT STDCALL CMediaSample_GetMediaTime(IMediaSample * This, /* [out] */ LONGLONG *pTimeStart, /* [out] */ LONGLONG *pTimeEnd) { - Debug printf("%p: CMediaSample_GetMediaTime() called\n", This); - return E_NOTIMPL; + Debug printf("CMediaSample_GetMediaTime(%p) called\n", This); + if (pTimeStart) + *pTimeStart = ((CMediaSample*) This)->time_start; + if (pTimeEnd) + *pTimeEnd = ((CMediaSample*) This)->time_end; + return 0; } static HRESULT STDCALL CMediaSample_SetMediaTime(IMediaSample * This, /* [in] */ LONGLONG *pTimeStart, /* [in] */ LONGLONG *pTimeEnd) { - Debug printf("%p: CMediaSample_SetMediaTime() called\n", This); - return E_NOTIMPL; + Debug printf("CMediaSample_SetMediaTime(%p) called\n", This); + if (pTimeStart) + ((CMediaSample*) This)->time_start = *pTimeStart; + if (pTimeEnd) + ((CMediaSample*) This)->time_end = *pTimeEnd; + return 0; } -void CMediaSample_SetPointer(CMediaSample *this, char* pointer) -{ this->block = pointer; } +// extension for direct memory write or decompressed data +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; +} -void CMediaSample_ResetPointer(CMediaSample *this) -{ this->block = this->own_block; } - -CMediaSample * CMediaSample_Create(IMemAllocator* allocator, long _size) +static void CMediaSample_ResetPointer(CMediaSample* This) { - CMediaSample *this; - - this = malloc( sizeof( CMediaSample ) ); - this->vt = malloc( sizeof( IMediaSample_vt ) ); - - 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; - this->actual_size = 0; - this->media_type.pbFormat = 0; - this->isPreroll = 0; - this->type_valid = 0; - this->own_block = malloc(this->size); - this->block = this->own_block; - - this->SetPointer = CMediaSample_SetPointer; - this->ResetPointer = CMediaSample_ResetPointer; - - Debug printf("%p: Creating media sample with size %ld, buffer %p\n", - this, _size, this->block); - return this; + Debug printf("CMediaSample_ResetPointer(%p) called\n", This); + This->block = This->own_block; } -void CMediaSample_Destroy(CMediaSample *this) +CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size) { - Debug printf("%p: CMediaSample::~CMediaSample() called\n", this); - if (!this->vt) - printf("Second delete of CMediaSample()!!\n"); - free( this->vt ); - free( this->own_block ); - if (this->media_type.pbFormat) - CoTaskMemFree(this->media_type.pbFormat); - free( this ); + CMediaSample* This = (CMediaSample*) 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 = (IMediaSample_vt*) malloc(sizeof(IMediaSample_vt)); + This->own_block = (char*) malloc(_size); + This->media_type.pbFormat = 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/src/libw32dll/DirectShow/cmediasample.h b/src/libw32dll/DirectShow/cmediasample.h index 061566cc1..3d6e1218c 100644 --- a/src/libw32dll/DirectShow/cmediasample.h +++ b/src/libw32dll/DirectShow/cmediasample.h @@ -4,31 +4,29 @@ #include "interfaces.h" #include "guids.h" -typedef struct _CMediaSample +typedef struct _CMediaSample CMediaSample; +struct _CMediaSample { - IMediaSample_vt *vt; - + IMediaSample_vt* vt; + DECLARE_IUNKNOWN(); IMemAllocator* all; int size; int actual_size; char* block; char* own_block; - int refcount; int isPreroll; int isSyncPoint; + int isDiscontinuity; + LONGLONG time_start; + LONGLONG time_end; AM_MEDIA_TYPE media_type; int type_valid; - - /* - CMediaSample(IMemAllocator* allocator, long _size); - ~CMediaSample(); - */ - - void (*SetPointer)(struct _CMediaSample *this, char* pointer); - void (*ResetPointer)(struct _CMediaSample *this); -} CMediaSample; + void ( *SetPointer) (CMediaSample* This, char* pointer); + void ( *ResetPointer) (CMediaSample* This); // FIXME replace with Set & 0 +}; -CMediaSample * CMediaSample_Create(IMemAllocator* allocator, long _size); -void CMediaSample_Destroy(CMediaSample *this); +CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size); +// called from allocator +void CMediaSample_Destroy(CMediaSample* This); #endif /* DS_CMEDIASAMPLE_H */ diff --git a/src/libw32dll/DirectShow/guids.c b/src/libw32dll/DirectShow/guids.c index 3a8096373..393b5f90c 100644 --- a/src/libw32dll/DirectShow/guids.c +++ b/src/libw32dll/DirectShow/guids.c @@ -1,5 +1,5 @@ #include "guids.h" -int DSHOW_DEBUG=0; +int DSHOW_DEBUG = 0; GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0, { 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}}; diff --git a/src/libw32dll/DirectShow/guids.h b/src/libw32dll/DirectShow/guids.h index 165119a82..1c6355b38 100644 --- a/src/libw32dll/DirectShow/guids.h +++ b/src/libw32dll/DirectShow/guids.h @@ -1,42 +1,41 @@ #ifndef GUIDS_H #define GUIDS_H -#include "../wine/com.h" -#include "../wine/winbase.h" -#include "../wine/vfw.h" +#include "com.h" +#include "wine/module.h" +#include "wine/windef.h" +#include "wine/vfw.h" extern int DSHOW_DEBUG; #define Debug if(DSHOW_DEBUG) -typedef void IUnknown; - -typedef struct _MediaType +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 + 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; typedef enum { - PINDIR_INPUT = 0, - PINDIR_OUTPUT = PINDIR_INPUT + 1 + PINDIR_INPUT = 0, + PINDIR_OUTPUT } PIN_DIRECTION; typedef long long REFERENCE_TIME; -typedef struct _RECT32 +typedef struct __attribute__((__packed__)) RECT32 { int left, top, right, bottom; -}RECT32; +} RECT32; -typedef struct tagVIDEOINFOHEADER { +typedef struct __attribute__((__packed__)) tagVIDEOINFOHEADER { RECT32 rcSource; // The bit we really want to use RECT32 rcTarget; // Where the video should go @@ -44,7 +43,7 @@ typedef struct tagVIDEOINFOHEADER { unsigned long dwBitErrorRate; // Bit error rate for this stream REFERENCE_TIME AvgTimePerFrame; // Average time per frame (100ns units) BITMAPINFOHEADER bmiHeader; - int spare[4]; + //int reserved[3]; } VIDEOINFOHEADER; typedef struct _AllocatorProperties @@ -56,14 +55,14 @@ typedef struct _AllocatorProperties } ALLOCATOR_PROPERTIES; typedef struct _IBaseFilter IBaseFilter; - typedef struct _PinInfo { - IBaseFilter *pFilter; + IBaseFilter* pFilter; PIN_DIRECTION dir; unsigned short achName[128]; } PIN_INFO; + extern GUID IID_IBaseFilter; extern GUID IID_IEnumPins; extern GUID IID_IEnumMediaTypes; diff --git a/src/libw32dll/DirectShow/inputpin.c b/src/libw32dll/DirectShow/inputpin.c index 76908f831..89264ec08 100644 --- a/src/libw32dll/DirectShow/inputpin.c +++ b/src/libw32dll/DirectShow/inputpin.c @@ -1,40 +1,37 @@ #include "inputpin.h" -#include "../wine/winerror.h" +#include "wine/winerror.h" #include <string.h> #include <stdio.h> #include <stdlib.h> -IMPLEMENT_IUNKNOWN(CInputPin) - -IMPLEMENT_IUNKNOWN(CRemotePin) - -IMPLEMENT_IUNKNOWN(CRemotePin2) - -IMPLEMENT_IUNKNOWN(CBaseFilter) +static int unimplemented(const char* s, void* p) +{ + Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p); + return E_NOTIMPL; +} -IMPLEMENT_IUNKNOWN(CBaseFilter2) +/*********** + * EnumPins + ***********/ -typedef struct _CEnumPins +typedef struct { - struct _IEnumPins_vt *vt; + IEnumPins_vt* vt; + DECLARE_IUNKNOWN(); IPin* pin1; IPin* pin2; int counter; GUID interfaces[2]; - DECLARE_IUNKNOWN(CEnumPins) - } CEnumPins; -long STDCALL CEnumPins_Next(IEnumPins * This, - /* [in] */ unsigned long cMediaTypes, - /* [size_is][out] */ IPin **ppMediaTypes, - /* [out] */ unsigned long *pcFetched) +static long STDCALL CEnumPins_Next(IEnumPins* This, + /* [in] */ unsigned long cMediaTypes, + /* [size_is][out] */ IPin** ppMediaTypes, + /* [out] */ unsigned long* pcFetched) { - int *lcounter=&((CEnumPins*)This)->counter; - IPin* lpin1=((CEnumPins*)This)->pin1; - IPin* lpin2=((CEnumPins*)This)->pin2; - - Debug printf("CEnumPins::Next() called\n"); + CEnumPins* pin = (CEnumPins*)This; + + Debug printf("CEnumPins_Next(%p) called\n", This); if (!ppMediaTypes) return E_INVALIDARG; if (!pcFetched && (cMediaTypes!=1)) @@ -42,7 +39,11 @@ long STDCALL CEnumPins_Next(IEnumPins * This, if (cMediaTypes<=0) return 0; - if (((*lcounter == 2) && lpin2) || ((*lcounter == 1) && !lpin2)) + //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; @@ -51,111 +52,126 @@ long STDCALL CEnumPins_Next(IEnumPins * This, if (pcFetched) *pcFetched=1; - if (*lcounter==0) + if (pin->counter==0) { - *ppMediaTypes = lpin1; - lpin1->vt->AddRef((IUnknown*)lpin1); + *ppMediaTypes = pin->pin1; + pin->pin1->vt->AddRef((IUnknown*)pin->pin1); } else { - *ppMediaTypes = lpin2; - lpin2->vt->AddRef((IUnknown*)lpin2); + *ppMediaTypes = pin->pin2; + pin->pin2->vt->AddRef((IUnknown*)pin->pin2); } - (*lcounter)++; + pin->counter++; if (cMediaTypes == 1) return 0; return 1; } -long STDCALL CEnumPins_Skip(IEnumPins * This, - /* [in] */ unsigned long cMediaTypes) +static long STDCALL CEnumPins_Skip(IEnumPins* This, + /* [in] */ unsigned long cMediaTypes) { - Debug printf("CEnumPins::Skip() called\n"); + Debug unimplemented("CEnumPins_Skip", This); return E_NOTIMPL; } -long STDCALL CEnumPins_Reset(IEnumPins * This) +static long STDCALL CEnumPins_Reset(IEnumPins* This) { - Debug printf("CEnumPins::Reset() called\n"); - ((CEnumPins*)This)->counter=0; + Debug printf("CEnumPins_Reset(%p) called\n", This); + ((CEnumPins*)This)->counter = 0; return 0; } -long STDCALL CEnumPins_Clone(IEnumPins * This, - /* [out] */ IEnumPins **ppEnum) +static long STDCALL CEnumPins_Clone(IEnumPins* This, + /* [out] */ IEnumPins** ppEnum) { - Debug printf("CEnumPins::Clone() called\n"); + Debug unimplemented("CEnumPins_Clone", This); return E_NOTIMPL; } -void CEnumPins_Destroy(CEnumPins *this) +static void CEnumPins_Destroy(CEnumPins* This) { - free(this); + free(This->vt); + free(This); } IMPLEMENT_IUNKNOWN(CEnumPins) -CEnumPins * CEnumPins_Create(IPin* p, IPin* pp) +static CEnumPins* CEnumPinsCreate(IPin* p, IPin* pp) { - CEnumPins *this; - this = malloc(sizeof(CEnumPins)); - - this->vt=malloc(sizeof(IEnumPins_vt)); - - this->pin1 = p; - this->pin2 = pp; - this->counter = 0; - this->refcount = 1; - - 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; + CEnumPins* This = (CEnumPins*) malloc(sizeof(CEnumPins)); + + if (!This) + return NULL; + + This->refcount = 1; + This->pin1 = p; + This->pin2 = pp; + This->counter = 0; + + This->vt = (IEnumPins_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; } -long STDCALL CInputPin_Connect ( - IPin * This, - /* [in] */ IPin *pReceivePin, - /* [in] */ AM_MEDIA_TYPE *pmt) + +/*********** + * InputPin + ***********/ + +static long STDCALL CInputPin_Connect(IPin* This, + /* [in] */ IPin* pReceivePin, + /* [in] */ AM_MEDIA_TYPE* pmt) { - Debug printf("CInputPin::Connect() called\n"); + Debug unimplemented("CInputPin_Connect", This); return E_NOTIMPL; } -long STDCALL CInputPin_ReceiveConnection(IPin * This, - /* [in] */ IPin *pConnector, - /* [in] */ const AM_MEDIA_TYPE *pmt) +static long STDCALL CInputPin_ReceiveConnection(IPin* This, + /* [in] */ IPin* pConnector, + /* [in] */ const AM_MEDIA_TYPE *pmt) { - Debug printf("CInputPin::ReceiveConnection() called\n"); + Debug unimplemented("CInputPin_ReceiveConnection", This); return E_NOTIMPL; } -long STDCALL CInputPin_Disconnect(IPin * This) +static long STDCALL CInputPin_Disconnect(IPin* This) { - Debug printf("CInputPin::Disconnect() called\n"); + Debug unimplemented("CInputPin_Disconnect", This); return E_NOTIMPL; } -long STDCALL CInputPin_ConnectedTo(IPin * This, /* [out] */ IPin **pPin) +static long STDCALL CInputPin_ConnectedTo(IPin* This, + /* [out] */ IPin** pPin) { - Debug printf("CInputPin::ConnectedTo() called\n"); + Debug unimplemented("CInputPin_ConnectedTo", This); return E_NOTIMPL; } -long STDCALL CInputPin_ConnectionMediaType(IPin * This, - /* [out] */ AM_MEDIA_TYPE *pmt) +static long STDCALL CInputPin_ConnectionMediaType(IPin* This, + /* [out] */ AM_MEDIA_TYPE *pmt) { - Debug printf("CInputPin::ConnectionMediaType() called\n"); - if(!pmt)return E_INVALIDARG; + Debug printf("CInputPin_ConnectionMediaType(%p) called\n", This); + if (!pmt) + return E_INVALIDARG; *pmt=((CInputPin*)This)->type; - if(pmt->cbFormat>0) + if (pmt->cbFormat > 0) { pmt->pbFormat=(char *)CoTaskMemAlloc(pmt->cbFormat); memcpy(pmt->pbFormat, ((CInputPin*)This)->type.pbFormat, pmt->cbFormat); @@ -163,438 +179,480 @@ long STDCALL CInputPin_ConnectionMediaType(IPin * This, return 0; } -long STDCALL CInputPin_QueryPinInfo(IPin * This, /* [out] */ PIN_INFO *pInfo) +static long STDCALL CInputPin_QueryPinInfo(IPin* This, + /* [out] */ PIN_INFO *pInfo) { CBaseFilter* lparent=((CInputPin*)This)->parent; - Debug printf("CInputPin::QueryPinInfo() called\n"); - pInfo->dir=PINDIR_OUTPUT; - pInfo->pFilter = (IBaseFilter *)lparent; + 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; + pInfo->achName[0] = 0; return 0; } -long STDCALL CInputPin_QueryDirection(IPin * This, - /* [out] */ PIN_DIRECTION *pPinDir) +static long STDCALL CInputPin_QueryDirection(IPin* This, + /* [out] */ PIN_DIRECTION *pPinDir) { - *pPinDir=PINDIR_OUTPUT; - Debug printf("CInputPin::QueryDirection() called\n"); + *pPinDir = PINDIR_OUTPUT; + Debug printf("CInputPin_QueryDirection(%p) called\n", This); return 0; } -long STDCALL CInputPin_QueryId(IPin * This, /* [out] */ unsigned short* *Id) +static long STDCALL CInputPin_QueryId(IPin* This, + /* [out] */ unsigned short* *Id) { - Debug printf("CInputPin::QueryId() called\n"); + Debug unimplemented("CInputPin_QueryId", This); return E_NOTIMPL; } -long STDCALL CInputPin_QueryAccept(IPin * This, - /* [in] */ const AM_MEDIA_TYPE *pmt) +static long STDCALL CInputPin_QueryAccept(IPin* This, + /* [in] */ const AM_MEDIA_TYPE* pmt) { - Debug printf("CInputPin::QueryAccept() called\n"); + Debug unimplemented("CInputPin_QueryAccept", This); return E_NOTIMPL; } - -long STDCALL CInputPin_EnumMediaTypes ( - IPin * This, - /* [out] */ IEnumMediaTypes **ppEnum) +static long STDCALL CInputPin_EnumMediaTypes(IPin* This, + /* [out] */ IEnumMediaTypes** ppEnum) { - Debug printf("CInputPin::EnumMediaTypes() called\n"); + Debug unimplemented("CInputPin_EnumMediaTypes", This); return E_NOTIMPL; } - -long STDCALL CInputPin_QueryInternalConnections(IPin * This, - /* [out] */ IPin **apPin, - /* [out][in] */ unsigned long *nPin) +static long STDCALL CInputPin_QueryInternalConnections(IPin* This, + /* [out] */ IPin** apPin, + /* [out][in] */ unsigned long *nPin) { - Debug printf("CInputPin::QueryInternalConnections() called\n"); + Debug unimplemented("CInputPin_QueryInternalConnections", This); return E_NOTIMPL; } -long STDCALL CInputPin_EndOfStream (IPin * This) +static long STDCALL CInputPin_EndOfStream(IPin * This) { - Debug printf("CInputPin::EndOfStream() called\n"); + Debug unimplemented("CInputPin_EndOfStream", This); return E_NOTIMPL; } -long STDCALL CInputPin_BeginFlush(IPin * This) +static long STDCALL CInputPin_BeginFlush(IPin * This) { - Debug printf("CInputPin::BeginFlush() called\n"); + Debug unimplemented("CInputPin_BeginFlush", This); return E_NOTIMPL; } -long STDCALL CInputPin_EndFlush(IPin * This) +static long STDCALL CInputPin_EndFlush(IPin* This) { - Debug printf("CInputPin::EndFlush() called\n"); + Debug unimplemented("CInputPin_EndFlush", This); return E_NOTIMPL; } -long STDCALL CInputPin_NewSegment(IPin * This, - /* [in] */ REFERENCE_TIME tStart, - /* [in] */ REFERENCE_TIME tStop, - /* [in] */ double dRate) +static long STDCALL CInputPin_NewSegment(IPin* This, + /* [in] */ REFERENCE_TIME tStart, + /* [in] */ REFERENCE_TIME tStop, + /* [in] */ double dRate) { - Debug printf("CInputPin::NewSegment() called\n"); + Debug unimplemented("CInputPin_NewSegment", This); return E_NOTIMPL; } -CInputPin * CInputPin_Create(CBaseFilter* p, const AM_MEDIA_TYPE *vh) +static void CInputPin_Destroy(CInputPin* This) { - CInputPin *this; - this = malloc(sizeof(CInputPin)); - - Debug printf("CInputPin_Create %p\n", this ); - - memcpy(&this->type,vh,sizeof(AM_MEDIA_TYPE)); - this->refcount = 1; - this->parent = p; - this->vt=malloc(sizeof(IPin_vt)); - 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; + free(This->vt); + free(This); } -void CInputPin_Destroy(CInputPin * this) +IMPLEMENT_IUNKNOWN(CInputPin) + +CInputPin* CInputPinCreate(CBaseFilter* p, const AM_MEDIA_TYPE* amt) { - free(this->vt); - free(this); + CInputPin* This = (CInputPin*) malloc(sizeof(CInputPin)); + + if (!This) + return NULL; + + This->refcount = 1; + This->parent = p; + This->type = *amt; + + This->vt= (IPin_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; } -long STDCALL CBaseFilter_GetClassID(IBaseFilter * This, - /* [out] */ CLSID *pClassID) + +/************* + * BaseFilter + *************/ + +static long STDCALL CBaseFilter_GetClassID(IBaseFilter * This, + /* [out] */ CLSID *pClassID) { - Debug printf("CBaseFilter::GetClassID() called\n"); + Debug unimplemented("CBaseFilter_GetClassID", This); return E_NOTIMPL; } -long STDCALL CBaseFilter_Stop(IBaseFilter * This) +static long STDCALL CBaseFilter_Stop(IBaseFilter* This) { - Debug printf("CBaseFilter::Stop() called\n"); + Debug unimplemented("CBaseFilter_Stop", This); return E_NOTIMPL; } -long STDCALL CBaseFilter_Pause(IBaseFilter * This) +static long STDCALL CBaseFilter_Pause(IBaseFilter* This) { - Debug printf("CBaseFilter::Pause() called\n"); + Debug unimplemented("CBaseFilter_Pause", This); return E_NOTIMPL; } -long STDCALL CBaseFilter_Run(IBaseFilter * This, - REFERENCE_TIME tStart) +static long STDCALL CBaseFilter_Run(IBaseFilter* This, REFERENCE_TIME tStart) { - Debug printf("CBaseFilter::Run() called\n"); + Debug unimplemented("CBaseFilter_Run", This); return E_NOTIMPL; } -long STDCALL CBaseFilter_GetState(IBaseFilter * This, - /* [in] */ unsigned long dwMilliSecsTimeout, - // /* [out] */ FILTER_STATE *State) - void* State) +static long STDCALL CBaseFilter_GetState(IBaseFilter* This, + /* [in] */ unsigned long dwMilliSecsTimeout, + // /* [out] */ FILTER_STATE *State) + void* State) { - Debug printf("CBaseFilter::GetState() called\n"); + Debug unimplemented("CBaseFilter_GetState", This); return E_NOTIMPL; } -long STDCALL CBaseFilter_SetSyncSource(IBaseFilter * This, - /* [in] */ IReferenceClock *pClock) +static long STDCALL CBaseFilter_SetSyncSource(IBaseFilter* This, + /* [in] */ IReferenceClock *pClock) { - Debug printf("CBaseFilter::SetSyncSource() called\n"); + Debug unimplemented("CBaseFilter_SetSyncSource", This); return E_NOTIMPL; } -long STDCALL CBaseFilter_GetSyncSource ( - IBaseFilter * This, - /* [out] */ IReferenceClock **pClock) +static long STDCALL CBaseFilter_GetSyncSource(IBaseFilter* This, + /* [out] */ IReferenceClock **pClock) { - Debug printf("CBaseFilter::GetSyncSource() called\n"); + Debug unimplemented("CBaseFilter_GetSyncSource", This); return E_NOTIMPL; } -long STDCALL CBaseFilter_EnumPins ( - IBaseFilter * This, - /* [out] */ IEnumPins **ppEnum) +static long STDCALL CBaseFilter_EnumPins(IBaseFilter* This, + /* [out] */ IEnumPins **ppEnum) { - Debug printf("CBaseFilter::EnumPins() called\n"); - *ppEnum=(IEnumPins *)CEnumPins_Create(((CBaseFilter*)This)->pin, ((CBaseFilter*)This)->unused_pin); + Debug printf("CBaseFilter_EnumPins(%p) called\n", This); + *ppEnum = (IEnumPins*) CEnumPinsCreate(((CBaseFilter*)This)->pin, ((CBaseFilter*)This)->unused_pin); return 0; } - -long STDCALL CBaseFilter_FindPin ( - IBaseFilter * This, - /* [string][in] */ const unsigned short* Id, - /* [out] */ IPin **ppPin) +static long STDCALL CBaseFilter_FindPin(IBaseFilter* This, + /* [string][in] */ const unsigned short* Id, + /* [out] */ IPin **ppPin) { - Debug printf("CBaseFilter::FindPin() called\n"); + Debug unimplemented("CBaseFilter_FindPin\n", This); return E_NOTIMPL; } - -long STDCALL CBaseFilter_QueryFilterInfo ( - IBaseFilter * This, -// /* [out] */ FILTER_INFO *pInfo) - void* pInfo) +static long STDCALL CBaseFilter_QueryFilterInfo(IBaseFilter* This, + // /* [out] */ FILTER_INFO *pInfo) + void* pInfo) { - Debug printf("CBaseFilter::QueryFilterInfo() called\n"); + Debug unimplemented("CBaseFilter_QueryFilterInfo", This); return E_NOTIMPL; } +static long STDCALL CBaseFilter_JoinFilterGraph(IBaseFilter* This, + /* [in] */ IFilterGraph* pGraph, + /* [string][in] */ const unsigned short* pName) +{ + Debug unimplemented("CBaseFilter_JoinFilterGraph", This); + return E_NOTIMPL; +} -long STDCALL CBaseFilter_JoinFilterGraph ( - IBaseFilter * This, - /* [in] */ IFilterGraph *pGraph, - /* [string][in] */ const unsigned short* pName) +static long STDCALL CBaseFilter_QueryVendorInfo(IBaseFilter* This, + /* [string][out] */ unsigned short** pVendorInfo) { - Debug printf("CBaseFilter::JoinFilterGraph() called\n"); + Debug unimplemented("CBaseFilter_QueryVendorInfo", This); return E_NOTIMPL; } +static IPin* CBaseFilter_GetPin(CBaseFilter* This) +{ + return This->pin; +} -long STDCALL CBaseFilter_QueryVendorInfo ( - IBaseFilter * This, - /* [string][out] */ unsigned short* *pVendorInfo) +static IPin* CBaseFilter_GetUnusedPin(CBaseFilter* This) { - Debug printf("CBaseFilter::QueryVendorInfo() called\n"); - return E_NOTIMPL; + return This->unused_pin; } -CBaseFilter * CBaseFilter_Create(const AM_MEDIA_TYPE *type, CBaseFilter2* parent) +static void CBaseFilter_Destroy(CBaseFilter* This) { - CBaseFilter *this; - - this = malloc(sizeof(CBaseFilter)); - this->refcount = 1; - this->pin=(IPin *)CInputPin_Create(this, type); - this->unused_pin=(IPin *)CRemotePin_Create(this, CBaseFilter2_GetPin(parent)); - this->vt=malloc(sizeof(IBaseFilter_vt)); - 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; - return this; + if (This->vt) + 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) -void CBaseFilter_Destroy(CBaseFilter *this) +CBaseFilter* CBaseFilterCreate(const AM_MEDIA_TYPE* type, CBaseFilter2* parent) { - free(this->vt); - this->pin->vt->Release((IUnknown*)this->pin); - this->unused_pin->vt->Release((IUnknown*)this->unused_pin); - free(this); + CBaseFilter* This = (CBaseFilter*) 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 = (IBaseFilter_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; } - -IPin* CBaseFilter_GetPin(CBaseFilter *this) -{return this->pin;} -IPin* CBaseFilter_GetUnusedPin(CBaseFilter *this) -{return this->unused_pin;} +/************** + * BaseFilter2 + **************/ -long STDCALL CBaseFilter2_GetClassID ( - IBaseFilter * This, - /* [out] */ CLSID *pClassID) +static long STDCALL CBaseFilter2_GetClassID(IBaseFilter* This, + /* [out] */ CLSID* pClassID) { - Debug printf("CBaseFilter2::GetClassID() called\n"); + Debug unimplemented("CBaseFilter2_GetClassID", This); return E_NOTIMPL; } -long STDCALL CBaseFilter2_Stop ( - IBaseFilter * This) +static long STDCALL CBaseFilter2_Stop(IBaseFilter* This) { - Debug printf("CBaseFilter2::Stop() called\n"); + Debug unimplemented("CBaseFilter2_Stop", This); return E_NOTIMPL; } - -long STDCALL CBaseFilter2_Pause (IBaseFilter * This) +static long STDCALL CBaseFilter2_Pause(IBaseFilter* This) { - Debug printf("CBaseFilter2::Pause() called\n"); + Debug unimplemented("CBaseFilter2_Pause", This); return E_NOTIMPL; } -long STDCALL CBaseFilter2_Run (IBaseFilter * This, REFERENCE_TIME tStart) +static long STDCALL CBaseFilter2_Run(IBaseFilter* This, REFERENCE_TIME tStart) { - Debug printf("CBaseFilter2::Run() called\n"); + Debug unimplemented("CBaseFilter2_Run", This); return E_NOTIMPL; } -long STDCALL CBaseFilter2_GetState ( - IBaseFilter * This, - /* [in] */ unsigned long dwMilliSecsTimeout, -// /* [out] */ FILTER_STATE *State) - void* State) +static long STDCALL CBaseFilter2_GetState(IBaseFilter* This, + /* [in] */ unsigned long dwMilliSecsTimeout, + // /* [out] */ FILTER_STATE *State) + void* State) { - Debug printf("CBaseFilter2::GetState() called\n"); + Debug unimplemented("CBaseFilter2_GetState", This); return E_NOTIMPL; } - -long STDCALL CBaseFilter2_SetSyncSource ( - IBaseFilter * This, - /* [in] */ IReferenceClock *pClock) +static long STDCALL CBaseFilter2_SetSyncSource(IBaseFilter* This, + /* [in] */ IReferenceClock* pClock) { - Debug printf("CBaseFilter2::SetSyncSource() called\n"); + Debug unimplemented("CBaseFilter2_SetSyncSource", This); return E_NOTIMPL; } - -long STDCALL CBaseFilter2_GetSyncSource ( - IBaseFilter * This, - /* [out] */ IReferenceClock **pClock) +static long STDCALL CBaseFilter2_GetSyncSource(IBaseFilter* This, + /* [out] */ IReferenceClock** pClock) { - Debug printf("CBaseFilter2::GetSyncSource() called\n"); + Debug unimplemented("CBaseFilter2_GetSyncSource", This); return E_NOTIMPL; } - -long STDCALL CBaseFilter2_EnumPins ( - IBaseFilter * This, - /* [out] */ IEnumPins **ppEnum) +static long STDCALL CBaseFilter2_EnumPins(IBaseFilter* This, + /* [out] */ IEnumPins** ppEnum) { - Debug printf("CBaseFilter2::EnumPins() called\n"); - *ppEnum=(IEnumPins *)CEnumPins_Create(((CBaseFilter2*)This)->pin,0); + Debug printf("CBaseFilter2_EnumPins(%p) called\n", This); + *ppEnum = (IEnumPins*) CEnumPinsCreate(((CBaseFilter2*)This)->pin, 0); return 0; } - -long STDCALL CBaseFilter2_FindPin ( - IBaseFilter * This, - /* [string][in] */ const unsigned short* Id, - /* [out] */ IPin **ppPin) +static long STDCALL CBaseFilter2_FindPin(IBaseFilter* This, + /* [string][in] */ const unsigned short* Id, + /* [out] */ IPin** ppPin) { - Debug printf("CBaseFilter2::FindPin() called\n"); + Debug unimplemented("CBaseFilter2_FindPin", This); return E_NOTIMPL; } - -long STDCALL CBaseFilter2_QueryFilterInfo ( - IBaseFilter * This, -// /* [out] */ FILTER_INFO *pInfo) - void* pInfo) +static long STDCALL CBaseFilter2_QueryFilterInfo(IBaseFilter* This, + // /* [out] */ FILTER_INFO *pInfo) + void* pInfo) { - Debug printf("CBaseFilter2::QueryFilterInfo() called\n"); + Debug unimplemented("CBaseFilter2_QueryFilterInfo", This); return E_NOTIMPL; } - -long STDCALL CBaseFilter2_JoinFilterGraph(IBaseFilter * This, - /* [in] */ IFilterGraph *pGraph, - /* [string][in] */ - const unsigned short* pName) +static long STDCALL CBaseFilter2_JoinFilterGraph(IBaseFilter* This, + /* [in] */ IFilterGraph* pGraph, + /* [string][in] */ + const unsigned short* pName) { - Debug printf("CBaseFilter2::JoinFilterGraph() called\n"); + Debug unimplemented("CBaseFilter2_JoinFilterGraph", This); return E_NOTIMPL; } -long STDCALL CBaseFilter2_QueryVendorInfo(IBaseFilter * This, - /* [string][out] */ - unsigned short* *pVendorInfo) +static long STDCALL CBaseFilter2_QueryVendorInfo(IBaseFilter* This, + /* [string][out] */ + unsigned short** pVendorInfo) { - Debug printf("CBaseFilter2::QueryVendorInfo() called\n"); + Debug unimplemented("CBaseFilter2_QueryVendorInfo", This); return E_NOTIMPL; } -GUID CBaseFilter2_interf1={0x76c61a30, 0xebe1, 0x11cf, {0x89, 0xf9, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}}; -GUID CBaseFilter2_interf2={0xaae7e4e2, 0x6388, 0x11d1, {0x8d, 0x93, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}}; -GUID CBaseFilter2_interf3={0x02ef04dd, 0x7580, 0x11d1, {0xbe, 0xce, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x37}}; +static IPin* CBaseFilter2_GetPin(CBaseFilter2* This) +{ + return This->pin; +} -CBaseFilter2 * CBaseFilter2_Create() +static void CBaseFilter2_Destroy(CBaseFilter2* This) { - CBaseFilter2 *this; - - this = malloc(sizeof(CBaseFilter2)); - this->refcount = 1; - this->pin=(IPin *)CRemotePin2_Create(this); - this->vt=malloc(sizeof(IBaseFilter_vt)); - 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->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; + Debug printf("CBaseFilter2_Destroy(%p) called\n", This); + if (This->pin) + This->pin->vt->Release((IUnknown*) This->pin); + if (This->vt) + free(This->vt); + free(This); } +IMPLEMENT_IUNKNOWN(CBaseFilter2) + +static GUID CBaseFilter2_interf1 = +{0x76c61a30, 0xebe1, 0x11cf, {0x89, 0xf9, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}}; +static GUID CBaseFilter2_interf2 = +{0xaae7e4e2, 0x6388, 0x11d1, {0x8d, 0x93, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}}; +static GUID CBaseFilter2_interf3 = +{0x02ef04dd, 0x7580, 0x11d1, {0xbe, 0xce, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x37}}; - -void CBaseFilter2_Destroy(CBaseFilter2 *this) +CBaseFilter2* CBaseFilter2Create() { -free(this->vt); -this->pin->vt->Release((IUnknown*)this->pin); -free(this); + CBaseFilter2* This = (CBaseFilter2*) malloc(sizeof(CBaseFilter2)); + + if (!This) + return NULL; + + This->refcount = 1; + This->pin = (IPin*) CRemotePin2Create(This); + + This->vt = (IBaseFilter_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; } -IPin* CBaseFilter2_GetPin(CBaseFilter2 *this) -{return this->pin;} -static long STDCALL CRemotePin_ConnectedTo(IPin * This, /* [out] */ IPin **pPin) +/************* + * CRemotePin + *************/ + + +static long STDCALL CRemotePin_ConnectedTo(IPin* This, /* [out] */ IPin** pPin) { - Debug printf("CRemotePin::ConnectedTo called\n"); + Debug printf("CRemotePin_ConnectedTo(%p) called\n", This); if (!pPin) return E_INVALIDARG; - *pPin=((CRemotePin*)This)->remote_pin; + *pPin = ((CRemotePin*)This)->remote_pin; (*pPin)->vt->AddRef((IUnknown*)(*pPin)); return 0; } -static long STDCALL CRemotePin_QueryDirection(IPin * This, - /* [out] */ PIN_DIRECTION *pPinDir) +static long STDCALL CRemotePin_QueryDirection(IPin* This, + /* [out] */ PIN_DIRECTION* pPinDir) { - Debug printf("CRemotePin::QueryDirection called\n"); + Debug printf("CRemotePin_QueryDirection(%p) called\n", This); if (!pPinDir) return E_INVALIDARG; *pPinDir=PINDIR_INPUT; @@ -603,27 +661,76 @@ static long STDCALL CRemotePin_QueryDirection(IPin * This, static long STDCALL CRemotePin_ConnectionMediaType(IPin* This, /* [out] */ AM_MEDIA_TYPE* pmt) { - Debug printf("CRemotePin::ConnectionMediaType() called\n"); + Debug unimplemented("CRemotePin_ConnectionMediaType", This); return E_NOTIMPL; } static long STDCALL CRemotePin_QueryPinInfo(IPin* This, /* [out] */ PIN_INFO* pInfo) { CBaseFilter* lparent = ((CRemotePin*)This)->parent; - Debug printf("CRemotePin::QueryPinInfo() called\n"); - pInfo->dir=PINDIR_INPUT; - pInfo->pFilter = (IBaseFilter *)lparent; + 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; } +static void CRemotePin_Destroy(CRemotePin* This) +{ + Debug printf("CRemotePin_Destroy(%p) called\n", This); + free(This->vt); + free(This); +} -static long STDCALL CRemotePin2_QueryPinInfo(IPin * This, - /* [out] */ PIN_INFO *pInfo) +IMPLEMENT_IUNKNOWN(CRemotePin) + +CRemotePin* CRemotePinCreate(CBaseFilter* pt, IPin* rpin) +{ + CRemotePin* This = (CRemotePin*) 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 = (IPin_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 + *************/ + + +static long STDCALL CRemotePin2_QueryPinInfo(IPin* This, + /* [out] */ PIN_INFO* pInfo) { CBaseFilter2* lparent=((CRemotePin2*)This)->parent; - Debug printf("CRemotePin2::QueryPinInfo called\n"); + Debug printf("CRemotePin2_QueryPinInfo(%p) called\n", This); pInfo->pFilter=(IBaseFilter*)lparent; lparent->vt->AddRef((IUnknown*)lparent); pInfo->dir=PINDIR_OUTPUT; @@ -631,52 +738,43 @@ static long STDCALL CRemotePin2_QueryPinInfo(IPin * This, return 0; } -CRemotePin * CRemotePin_Create(CBaseFilter* pt, IPin* rpin) +// FIXME - not being released! +static void CRemotePin2_Destroy(CRemotePin2* This) { - CRemotePin *this; - - this = malloc(sizeof(CRemotePin)); - this->parent = pt; - this->remote_pin = rpin; - this->refcount = 1; - this->vt = malloc(sizeof(IPin_vt)); - 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; + Debug printf("CRemotePin2_Destroy(%p) called\n", This); + free(This->vt); + free(This); } -void CRemotePin_Destroy(CRemotePin * this) -{ - free(this->vt); - free(this); -} +IMPLEMENT_IUNKNOWN(CRemotePin2) -CRemotePin2 * CRemotePin2_Create(CBaseFilter2* p) +CRemotePin2* CRemotePin2Create(CBaseFilter2* p) { - CRemotePin2 *this; - this = malloc(sizeof(CRemotePin2)); - this->parent = p, - this->refcount = 1; - this->vt = malloc(sizeof(IPin_vt)); - 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; -} + CRemotePin2* This = (CRemotePin2*) malloc(sizeof(CRemotePin2)); -void CRemotePin2_Destroy(CRemotePin2 * this) -{ - free(this->vt); - free(this); + if (!This) + return NULL; + + Debug printf("CRemotePin2Create() called -> %p\n", This); + + This->parent = p; + This->refcount = 1; + + This->vt = (IPin_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/src/libw32dll/DirectShow/inputpin.h b/src/libw32dll/DirectShow/inputpin.h index ba1e2817e..1ad9a2d60 100644 --- a/src/libw32dll/DirectShow/inputpin.h +++ b/src/libw32dll/DirectShow/inputpin.h @@ -3,209 +3,69 @@ #include "interfaces.h" -//class CBaseFilter2; +typedef struct _CBaseFilter2 CBaseFilter2; +struct _CBaseFilter2 +{ + IBaseFilter_vt* vt; + DECLARE_IUNKNOWN(); + IPin* pin; + GUID interfaces[5]; + + IPin* ( *GetPin )(CBaseFilter2* This); +}; -typedef struct _CBaseFilter +CBaseFilter2* CBaseFilter2Create(); + + +typedef struct _CBaseFilter CBaseFilter; +struct _CBaseFilter { - struct _IBaseFilter_vt *vt; - + IBaseFilter_vt* vt; + DECLARE_IUNKNOWN(); // has to match CBaseFilter2 - INHERITANCE!! IPin* pin; IPin* unused_pin; GUID interfaces[2]; - DECLARE_IUNKNOWN(CBaseFilter) -} CBaseFilter; -typedef struct _CInputPin + IPin* ( *GetPin )(CBaseFilter* This); + IPin* ( *GetUnusedPin )(CBaseFilter* This); +}; + +CBaseFilter* CBaseFilterCreate(const AM_MEDIA_TYPE* vhdr, CBaseFilter2* parent); + + +typedef struct _CInputPin CInputPin; +struct _CInputPin { - IPin_vt *vt; - - AM_MEDIA_TYPE type; + IPin_vt* vt; + DECLARE_IUNKNOWN(); CBaseFilter* parent; + AM_MEDIA_TYPE type; GUID interfaces[1]; - DECLARE_IUNKNOWN(CInputPin) - -} CInputPin; +}; -typedef struct _CBaseFilter2 -{ - struct _IBaseFilter_vt *vt; - - IPin* pin; - GUID interfaces[5]; - DECLARE_IUNKNOWN(CBaseFilter2) - -}CBaseFilter2; +CInputPin* CInputPinCreate(CBaseFilter* parent, const AM_MEDIA_TYPE* vhdr); -typedef struct _CRemotePin +typedef struct CRemotePin { - IPin_vt *vt; + IPin_vt* vt; + DECLARE_IUNKNOWN(); CBaseFilter* parent; - IPin* remote_pin; GUID interfaces[1]; - DECLARE_IUNKNOWN(CRemotePin) -}CRemotePin; + IPin* remote_pin; +} CRemotePin; + +CRemotePin* CRemotePinCreate(CBaseFilter* pt, IPin* rpin); + -typedef struct _CRemotePin2 +typedef struct CRemotePin2 { - IPin_vt *vt; + IPin_vt* vt; + DECLARE_IUNKNOWN(); CBaseFilter2* parent; GUID interfaces[1]; - DECLARE_IUNKNOWN(CRemotePin2) -}CRemotePin2; - - -long STDCALL CInputPin_Connect ( - IPin * This, - /* [in] */ IPin *pReceivePin, - /* [in] */ AM_MEDIA_TYPE *pmt); - -long STDCALL CInputPin_ReceiveConnection(IPin * This, - /* [in] */ IPin *pConnector, - /* [in] */ const AM_MEDIA_TYPE *pmt); - -long STDCALL CInputPin_Disconnect(IPin * This); -long STDCALL CInputPin_ConnectedTo(IPin * This, /* [out] */ IPin **pPin); - -long STDCALL CInputPin_ConnectionMediaType(IPin * This, - /* [out] */ AM_MEDIA_TYPE *pmt); - -long STDCALL CInputPin_QueryPinInfo(IPin * This, /* [out] */ PIN_INFO *pInfo); -long STDCALL CInputPin_QueryDirection(IPin * This, - /* [out] */ PIN_DIRECTION *pPinDir); -long STDCALL CInputPin_QueryId(IPin * This, /* [out] */ unsigned short* *Id); - -long STDCALL CInputPin_QueryAccept(IPin * This, - /* [in] */ const AM_MEDIA_TYPE *pmt); - - -long STDCALL CInputPin_EnumMediaTypes ( - IPin * This, - /* [out] */ IEnumMediaTypes **ppEnum); - -long STDCALL CInputPin_QueryInternalConnections(IPin * This, - /* [out] */ IPin **apPin, - /* [out][in] */ unsigned long *nPin); - -long STDCALL CInputPin_EndOfStream (IPin * This); -long STDCALL CInputPin_BeginFlush(IPin * This); - -long STDCALL CInputPin_EndFlush(IPin * This); - -long STDCALL CInputPin_NewSegment(IPin * This, - /* [in] */ REFERENCE_TIME tStart, - /* [in] */ REFERENCE_TIME tStop, - /* [in] */ double dRate); - -CInputPin * CInputPin_Create(CBaseFilter* p, const AM_MEDIA_TYPE *vh); -void CInputPin_Destroy(CInputPin * this); - -long STDCALL CBaseFilter_GetClassID(IBaseFilter * This, - /* [out] */ CLSID *pClassID); -long STDCALL CBaseFilter_Stop(IBaseFilter * This); - -long STDCALL CBaseFilter_Pause(IBaseFilter * This); - -long STDCALL CBaseFilter_Run(IBaseFilter * This, - REFERENCE_TIME tStart); - -long STDCALL CBaseFilter_GetState(IBaseFilter * This, - /* [in] */ unsigned long dwMilliSecsTimeout, - // /* [out] */ FILTER_STATE *State) - void* State); - -long STDCALL CBaseFilter_SetSyncSource(IBaseFilter * This, - /* [in] */ IReferenceClock *pClock); - -long STDCALL CBaseFilter_GetSyncSource ( - IBaseFilter * This, - /* [out] */ IReferenceClock **pClock); - - -long STDCALL CBaseFilter_EnumPins ( - IBaseFilter * This, - /* [out] */ IEnumPins **ppEnum); - -long STDCALL CBaseFilter_FindPin ( - IBaseFilter * This, - /* [string][in] */ const unsigned short* Id, - /* [out] */ IPin **ppPin); - - -long STDCALL CBaseFilter_QueryFilterInfo ( - IBaseFilter * This, -// /* [out] */ FILTER_INFO *pInfo) - void* pInfo); - -long STDCALL CBaseFilter_JoinFilterGraph ( - IBaseFilter * This, - /* [in] */ IFilterGraph *pGraph, - /* [string][in] */ const unsigned short* pName); - - -long STDCALL CBaseFilter_QueryVendorInfo ( - IBaseFilter * This, - /* [string][out] */ unsigned short* *pVendorInfo); - -CBaseFilter * CBaseFilter_Create(const AM_MEDIA_TYPE *type, CBaseFilter2* parent); - - -void CBaseFilter_Destroy(CBaseFilter *this); -IPin* CBaseFilter_GetPin(CBaseFilter *this); -IPin* CBaseFilter_GetUnusedPin(CBaseFilter *this); -long STDCALL CBaseFilter2_GetClassID ( - IBaseFilter * This, - /* [out] */ CLSID *pClassID); - -long STDCALL CBaseFilter2_Stop ( - IBaseFilter * This); -long STDCALL CBaseFilter2_Pause (IBaseFilter * This); - -long STDCALL CBaseFilter2_Run (IBaseFilter * This, REFERENCE_TIME tStart); - -long STDCALL CBaseFilter2_GetState ( - IBaseFilter * This, - /* [in] */ unsigned long dwMilliSecsTimeout, -// /* [out] */ FILTER_STATE *State) - void* State); - -long STDCALL CBaseFilter2_SetSyncSource ( - IBaseFilter * This, - /* [in] */ IReferenceClock *pClock); -long STDCALL CBaseFilter2_GetSyncSource ( - IBaseFilter * This, - /* [out] */ IReferenceClock **pClock); - -long STDCALL CBaseFilter2_EnumPins ( - IBaseFilter * This, - /* [out] */ IEnumPins **ppEnum); -long STDCALL CBaseFilter2_FindPin ( - IBaseFilter * This, - /* [string][in] */ const unsigned short* Id, - /* [out] */ IPin **ppPin); - -long STDCALL CBaseFilter2_QueryFilterInfo ( - IBaseFilter * This, -// /* [out] */ FILTER_INFO *pInfo) - void* pInfo); - -long STDCALL CBaseFilter2_JoinFilterGraph(IBaseFilter * This, - /* [in] */ IFilterGraph *pGraph, - /* [string][in] */ - const unsigned short* pName); - -long STDCALL CBaseFilter2_QueryVendorInfo(IBaseFilter * This, - /* [string][out] */ - unsigned short* *pVendorInfo); -CBaseFilter2 * CBaseFilter2_Create(); -void CBaseFilter2_Destroy(CBaseFilter2 *this); - -IPin* CBaseFilter2_GetPin(CBaseFilter2 *this); - -CRemotePin * CRemotePin_Create(CBaseFilter* pt, IPin* rpin); -void CRemotePin_Destroy(CRemotePin * this); -CRemotePin2 * CRemotePin2_Create(CBaseFilter2* p); -void CRemotePin2_Destroy(CRemotePin2 * this); +} CRemotePin2; +CRemotePin2* CRemotePin2Create(CBaseFilter2* parent); #endif /* DS_INPUTPIN_H */ diff --git a/src/libw32dll/DirectShow/interfaces.h b/src/libw32dll/DirectShow/interfaces.h index 88ef7e4e9..23b02a509 100644 --- a/src/libw32dll/DirectShow/interfaces.h +++ b/src/libw32dll/DirectShow/interfaces.h @@ -9,122 +9,41 @@ Created using freely-available DirectX 8.0 SDK */ -#include "../wine/com.h" -#include "guids.h" #include "iunk.h" +#include "com.h" -#ifndef STDCALL -#define STDCALL __attribute__((__stdcall__)) -#endif - -/*typedef GUID& REFIID;*/ +//typedef GUID& REFIID; typedef GUID CLSID; typedef GUID IID; /* Sh*t. MSVC++ and g++ use different methods of storing vtables. */ - -/*typedef struct _IBaseFilter IBaseFilter;*/ typedef struct _IReferenceClock IReferenceClock; -typedef struct _IEnumPins IEnumPins; -typedef struct _IEnumMediaTypes IEnumMediaTypes; -typedef struct _IPin IPin; typedef struct _IFilterGraph IFilterGraph; -typedef struct _IMemInputPin IMemInputPin; -typedef struct _IMemAllocator IMemAllocator; -typedef struct _IMediaSample IMediaSample; -typedef struct _IHidden IHidden; -typedef struct _IHidden2 IHidden2; -typedef struct _IDivxFilterInterface IDivxFilterInterface; - -typedef struct _IBaseFilter_vt IBaseFilter_vt; -typedef struct _IReferenceClock_vt IReferenceClock_vt; -typedef struct _IEnumPins_vt IEnumPins_vt; -typedef struct _IEnumMediaTypes_vt IEnumMediaTypes_vt; -typedef struct _IPin_vt IPin_vt; -typedef struct _IFilterGraph_vt IFilterGraph_vt; -typedef struct _IMemInputPin_vt IMemInputPin_vt; -typedef struct _IMemAllocator_vt IMemAllocator_vt; -typedef struct _IMediaSample_vt IMediaSample_vt; -typedef struct _IHidden_vt IHidden_vt; -typedef struct _IHidden2_vt IHidden2_vt; -typedef struct _IDivxFilterInterface_vt IDivxFilterInterface_vt; - enum PIN_DIRECTION; -/* -class IClassFactory2 -{ -public: - virtual long STDCALL QueryInterface(GUID* iid, void** ppv) =0; - virtual long STDCALL AddRef(void) =0; - virtual long STDCALL Release(void) =0; - virtual long STDCALL CreateInstance(IUnknown* pUnkOuter, GUID* riid, void** ppvObject) =0; -}; -*/ - -struct _IBaseFilter_vt +typedef struct _IEnumMediaTypes IEnumMediaTypes; +typedef struct IEnumMediaTypes_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); -}; -struct _IBaseFilter -{ - struct _IBaseFilter_vt *vt; -}; - - -struct _IEnumPins_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *Next )(IEnumPins * This, - /* [in] */ unsigned long cPins, - /* [size_is][out] */ IPin **ppPins, - /* [out] */ unsigned long *pcFetched); - HRESULT STDCALL ( *Skip )(IEnumPins * This, - /* [in] */ unsigned long cPins); - HRESULT STDCALL ( *Reset )(IEnumPins * This); - HRESULT STDCALL ( *Clone )(IEnumPins * This, - /* [out] */ IEnumPins **ppEnum); -}; + 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; }; -struct _IEnumPins -{ - struct _IEnumPins_vt *vt; -}; -struct _IPin_vt +typedef struct _IPin IPin; +typedef struct IPin_vt { INHERIT_IUNKNOWN(); @@ -156,39 +75,166 @@ struct _IPin_vt /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate); -}; +} IPin_vt; +struct _IPin { IPin_vt *vt; }; + -struct _IPin +typedef struct _IEnumPins IEnumPins; +typedef struct IEnumPins_vt { - IPin_vt *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; }; -struct _IEnumMediaTypes_vt +typedef struct _IMediaSample IMediaSample; +typedef struct IMediaSample_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); -}; -struct _IEnumMediaTypes + 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 { - IEnumMediaTypes_vt *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; }; -struct _IMemInputPin_vt + +typedef struct _IMemInputPin IMemInputPin; +typedef struct IMemInputPin_vt { INHERIT_IUNKNOWN(); - + HRESULT STDCALL ( *GetAllocator )(IMemInputPin * This, /* [out] */ IMemAllocator **ppAllocator); HRESULT STDCALL ( *NotifyAllocator )(IMemInputPin * This, @@ -203,108 +249,35 @@ struct _IMemInputPin_vt /* [in] */ long nSamples, /* [out] */ long *nSamplesProcessed); HRESULT STDCALL ( *ReceiveCanBlock )(IMemInputPin * This); -}; - -struct _IMemInputPin -{ - IMemInputPin_vt *vt; -}; - - -struct _IMemAllocator_vt -{ - INHERIT_IUNKNOWN(); - - HRESULT STDCALL ( *SetProperties )(IMemAllocator * This, - /* [in] */ ALLOCATOR_PROPERTIES *pRequest, - /* [out] */ ALLOCATOR_PROPERTIES *pActual); - HRESULT STDCALL ( *GetProperties )(IMemAllocator * This, - /* [out] */ ALLOCATOR_PROPERTIES *pProps); - HRESULT STDCALL ( *Commit )(IMemAllocator * This); - HRESULT STDCALL ( *Decommit )(IMemAllocator * This); - HRESULT STDCALL ( *GetBuffer )(IMemAllocator * This, - /* [out] */ IMediaSample **ppBuffer, - /* [in] */ REFERENCE_TIME *pStartTime, - /* [in] */ REFERENCE_TIME *pEndTime, - /* [in] */ unsigned long dwFlags); - HRESULT STDCALL ( *ReleaseBuffer )(IMemAllocator * This, - /* [in] */ IMediaSample *pBuffer); -}; - -struct _IMemAllocator -{ - IMemAllocator_vt *vt; -}; +} IMemInputPin_vt; +struct _IMemInputPin { IMemInputPin_vt* vt; }; -struct _IMediaSample_vt +typedef struct _IHidden IHidden; +typedef struct IHidden_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); - HRESULT STDCALL ( *IsSyncPoint )(IMediaSample * This); - HRESULT STDCALL ( *SetSyncPoint )(IMediaSample * This, - long bIsSyncPoint); - 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); - HRESULT STDCALL ( *GetMediaType )(IMediaSample * This, - AM_MEDIA_TYPE **ppMediaType); - HRESULT STDCALL ( *SetMediaType )(IMediaSample * This, - AM_MEDIA_TYPE *pMediaType); - HRESULT STDCALL ( *IsDiscontinuity )(IMediaSample * This); - HRESULT STDCALL ( *SetDiscontinuity )(IMediaSample * This, - long bDiscontinuity); - HRESULT STDCALL ( *GetMediaTime )(IMediaSample * This, - /* [out] */ long long *pTimeStart, - /* [out] */ long long *pTimeEnd); - HRESULT STDCALL ( *SetMediaTime )(IMediaSample * This, - /* [in] */ long long *pTimeStart, - /* [in] */ long long *pTimeEnd); -}; + 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; }; -struct _IMediaSample -{ - struct _IMediaSample_vt *vt; -}; -struct _IHidden_vt +typedef struct _IHidden2 IHidden2; +typedef struct IHidden2_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); -}; - -struct _IHidden -{ - struct _IHidden_vt *vt; -}; -struct _IHidden2_vt -{ - INHERIT_IUNKNOWN(); - HRESULT STDCALL ( *unk1 )(void); HRESULT STDCALL ( *unk2 )(void); HRESULT STDCALL ( *unk3 )(void); @@ -313,22 +286,19 @@ struct _IHidden2_vt HRESULT STDCALL ( *DecodeSet )(IHidden2* This, int* region); HRESULT STDCALL ( *unk7 )(void); HRESULT STDCALL ( *unk8 )(void); -}; +} IHidden2_vt; +struct _IHidden2 { struct IHidden2_vt* vt; }; -struct _IHidden2 -{ - struct _IHidden2_vt *vt; -}; -struct _IDivxFilterInterface -{ - struct _IDivxFilterInterface_vt* vt; -}; +// fixme +typedef struct IDivxFilterInterface { + struct IDivxFilterInterface_vt* vt; +} IDivxFilterInterface; -struct _IDivxFilterInterface_vt +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); @@ -340,7 +310,8 @@ struct _IDivxFilterInterface_vt 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* This2, int y); - HRESULT STDCALL ( *get_AspectRatio )(IDivxFilterInterface* This, int* x, IDivxFilterInterface* This2, int* y); + HRESULT STDCALL ( *put_AspectRatio )(IDivxFilterInterface* This, int x, IDivxFilterInterface* Thisit, int y); + HRESULT STDCALL ( *get_AspectRatio )(IDivxFilterInterface* This, int* x, IDivxFilterInterface* Thisit, int* y); }; + #endif /* DS_INTERFACES_H */ diff --git a/src/libw32dll/DirectShow/iunk.h b/src/libw32dll/DirectShow/iunk.h index cf139b924..6dbf00ffa 100644 --- a/src/libw32dll/DirectShow/iunk.h +++ b/src/libw32dll/DirectShow/iunk.h @@ -2,55 +2,49 @@ #define DS_IUNK_H #include "guids.h" - -#define DECLARE_IUNKNOWN(CLASSNAME) \ - int refcount; +#include <stdlib.h> #define INHERIT_IUNKNOWN() \ - long STDCALL (*QueryInterface)(IUnknown * This, GUID* riid, void **ppvObject); \ - long STDCALL (*AddRef) (IUnknown * This); \ - long STDCALL (*Release) (IUnknown * This); - + long STDCALL ( *QueryInterface )(IUnknown * This, GUID* riid, void **ppvObject); \ + long STDCALL ( *AddRef )(IUnknown * This); \ + long STDCALL ( *Release )(IUnknown * This); + +#define DECLARE_IUNKNOWN() \ + int refcount; + #define IMPLEMENT_IUNKNOWN(CLASSNAME) \ -long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, GUID* riid, void **ppvObject); \ -long STDCALL CLASSNAME ## _AddRef ( \ - IUnknown * This); \ -long STDCALL CLASSNAME ## _Release ( \ - IUnknown * This); \ -long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, GUID* riid, void **ppvObject) \ +static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \ + GUID* riid, void **ppvObject) \ { \ CLASSNAME * me = (CLASSNAME *)This; \ - GUID* r; unsigned int i = 0; \ - Debug printf(#CLASSNAME "_QueryInterface() called\n");\ + GUID* r; unsigned int i = 0; \ + Debug printf(#CLASSNAME "_QueryInterface(%p) called\n", This);\ if (!ppvObject) return 0x80004003; \ for(r=me->interfaces; i<sizeof(me->interfaces)/sizeof(me->interfaces[0]); r++, i++) \ - if(!memcmp(r, riid, 16)) \ + if(!memcmp(r, riid, sizeof(*r))) \ { \ me->vt->AddRef((IUnknown*)This); \ *ppvObject=This; \ return 0; \ } \ - Debug printf("Failed\n"); \ + Debug printf("Query failed!\n"); \ return E_NOINTERFACE; \ } \ \ -long STDCALL CLASSNAME ## _AddRef ( \ - IUnknown * This) \ +static long STDCALL CLASSNAME ## _AddRef(IUnknown * This) \ { \ CLASSNAME * me=( CLASSNAME *)This; \ - Debug printf(#CLASSNAME "_AddRef() called\n"); \ + Debug printf(#CLASSNAME "_AddRef(%p) called (ref:%d)\n", This, me->refcount); \ return ++(me->refcount); \ } \ \ -long STDCALL CLASSNAME ## _Release ( \ - IUnknown * This) \ +static long STDCALL CLASSNAME ## _Release(IUnknown * This) \ { \ CLASSNAME* me=( CLASSNAME *)This; \ - Debug printf(#CLASSNAME "_Release() called\n"); \ - if(--(me->refcount) ==0) \ + Debug printf(#CLASSNAME "_Release(%p) called (new ref:%d)\n", This, me->refcount - 1); \ + if(--(me->refcount) == 0) \ CLASSNAME ## _Destroy(me); \ return 0; \ } - #endif /* DS_IUNK_H */ diff --git a/src/libw32dll/DirectShow/outputpin.c b/src/libw32dll/DirectShow/outputpin.c index 32c8d153e..4546d0294 100644 --- a/src/libw32dll/DirectShow/outputpin.c +++ b/src/libw32dll/DirectShow/outputpin.c @@ -1,31 +1,37 @@ + +#include "wine/winerror.h" +#include "wine/windef.h" #include "outputpin.h" -#include "allocator.h" -#include "iunk.h" -#include "../wine/winerror.h" #include <stdio.h> #include <string.h> -#include <stdlib.h> /* An object beyond interface IEnumMediaTypes. Returned by COutputPin through call IPin::EnumMediaTypes(). */ -typedef struct _CEnumMediaTypes +static int unimplemented(const char* s, void* p) { - IEnumMediaTypes_vt *vt; + Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p); + return E_NOTIMPL; +} + +typedef struct CEnumMediaTypes +{ + IEnumMediaTypes_vt* vt; + DECLARE_IUNKNOWN(); AM_MEDIA_TYPE type; GUID interfaces[2]; - DECLARE_IUNKNOWN(CEnumMediaTypes) -}CEnumMediaTypes; +} CEnumMediaTypes; + 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() called\n"); + AM_MEDIA_TYPE* type = &((CEnumMediaTypes*)This)->type; + Debug printf("CEnumMediaTypes::Next(%p) called\n", This); if (!ppMediaTypes) return E_INVALIDARG; if (!pcFetched && (cMediaTypes!=1)) @@ -36,11 +42,12 @@ static HRESULT STDCALL CEnumMediaTypes_Next(IEnumMediaTypes * This, if (pcFetched) *pcFetched=1; ppMediaTypes[0] = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); - memcpy(*ppMediaTypes, type, sizeof(AM_MEDIA_TYPE)); + // copy structures - C can handle this... + **ppMediaTypes = *type; if (ppMediaTypes[0]->pbFormat) { ppMediaTypes[0]->pbFormat=(char *)CoTaskMemAlloc(ppMediaTypes[0]->cbFormat); - memcpy(ppMediaTypes[0]->pbFormat, type->pbFormat, sizeof(ppMediaTypes[0]->cbFormat)); + memcpy(ppMediaTypes[0]->pbFormat, type->pbFormat, ppMediaTypes[0]->cbFormat); } if (cMediaTypes == 1) return 0; @@ -51,100 +58,73 @@ static HRESULT STDCALL CEnumMediaTypes_Next(IEnumMediaTypes * This, static HRESULT STDCALL CEnumMediaTypes_Skip(IEnumMediaTypes * This, /* [in] */ ULONG cMediaTypes) { - Debug printf("CEnumMediaTypes::Skip() called\n"); + Debug unimplemented("CEnumMediaTypes::Skip", This); return E_NOTIMPL; } static HRESULT STDCALL CEnumMediaTypes_Reset(IEnumMediaTypes * This) { - Debug printf("CEnumMediaTypes::Reset() called\n"); + Debug printf("CEnumMediaTypes::Reset(%p) called\n", This); return 0; } static HRESULT STDCALL CEnumMediaTypes_Clone(IEnumMediaTypes * This, /* [out] */ IEnumMediaTypes **ppEnum) { - Debug printf("CEnumMediaTypes::Clone() called\n"); + Debug printf("CEnumMediaTypes::Clone(%p) called\n", This); return E_NOTIMPL; } -void CEnumMediaTypes_Destroy(CEnumMediaTypes * this) +void CEnumMediaTypes_Destroy(CEnumMediaTypes* This) { - free(this->vt); - free(this); + free(This->vt); + free(This); } // IPin->IUnknown methods IMPLEMENT_IUNKNOWN(CEnumMediaTypes) -CEnumMediaTypes * CEnumMediaTypes_Create(const AM_MEDIA_TYPE *amtype) +CEnumMediaTypes* CEnumMediaTypesCreate(const AM_MEDIA_TYPE* amt) { - CEnumMediaTypes *this; - this = malloc(sizeof(CEnumMediaTypes)); - - this->refcount = 1; - memcpy(&this->type,amtype,sizeof(AM_MEDIA_TYPE)); + CEnumMediaTypes *This = (CEnumMediaTypes*) malloc(sizeof(CEnumMediaTypes)) ; - this->vt = malloc(sizeof(IEnumMediaTypes_vt)); - 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; -} + if (!This) + return NULL; + This->vt = (IEnumMediaTypes_vt*) malloc(sizeof(IEnumMediaTypes_vt)); + if (!This->vt) + { + free(This); + return NULL; + } -static HRESULT STDCALL COutputPin_AddRef(IUnknown* This) -{ - Debug printf("COutputPin_AddRef(%p) called (%d)\n", - This, ((COutputPin*)This)->refcount); - ((COutputPin*)This)->refcount++; - return 0; -} + This->refcount = 1; + This->type = *amt; -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); + 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; - return 0; -} + This->interfaces[0] = IID_IUnknown; + This->interfaces[1] = IID_IEnumMediaTypes; -static HRESULT STDCALL COutputPin_M_AddRef(IUnknown* This) -{ - COutputMemPin* p = (COutputMemPin*) This; - Debug printf("COutputPin_MAddRef(%p) called (%p, %d)\n", - p, p->parent, p->parent->refcount); - p->parent->refcount++; - return 0; + return This; } -static HRESULT STDCALL COutputPin_M_Release(IUnknown* This) -{ - COutputMemPin* p = (COutputMemPin*) This; - Debug printf("COutputPin_MRelease(%p) called (%p, %d)\n", - p, p->parent, p->parent->refcount); - if (--p->parent->refcount <= 0) - COutputPin_Destroy(p->parent); - return 0; -} -/* Implementation of output pin object. */ -// Constructor +/************* + * COutputPin + *************/ static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, GUID* iid, void** ppv) { COutputPin* p = (COutputPin*) This; - + Debug printf("COutputPin_QueryInterface(%p) called\n", This); if (!ppv) return E_INVALIDARG; @@ -162,7 +142,7 @@ static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, GUID* iid, void return 0; } - Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \ + 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], @@ -184,7 +164,7 @@ static HRESULT STDCALL COutputPin_Connect(IPin * This, { pmt->pbFormat=CoTaskMemAlloc(pmt->cbFormat); memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat); - } + } */ //return E_NOTIMPL; return 0;// XXXXXXXXXXXXX CHECKME XXXXXXXXXXXXXXX @@ -195,21 +175,21 @@ static HRESULT STDCALL COutputPin_ReceiveConnection(IPin * This, /* [in] */ IPin *pConnector, /* [in] */ const AM_MEDIA_TYPE *pmt) { - Debug printf("COutputPin_ReceiveConnection() called\n"); - ((COutputPin*)This)->remote=pConnector; + Debug printf("COutputPin_ReceiveConnection(%p) called\n", This); + ((COutputPin*)This)->remote = pConnector; return 0; } static HRESULT STDCALL COutputPin_Disconnect(IPin * This) { - Debug printf("COutputPin_Disconnect() called\n"); + Debug printf("COutputPin_Disconnect(%p) called\n", This); return 1; } static HRESULT STDCALL COutputPin_ConnectedTo(IPin * This, /* [out] */ IPin **pPin) { - Debug printf("COutputPin_ConnectedTo() called\n"); + Debug printf("COutputPin_ConnectedTo(%p) called\n", This); if (!pPin) return E_INVALIDARG; *pPin = ((COutputPin*)This)->remote; @@ -234,14 +214,14 @@ static HRESULT STDCALL COutputPin_ConnectionMediaType(IPin * This, static HRESULT STDCALL COutputPin_QueryPinInfo(IPin * This, /* [out] */ PIN_INFO *pInfo) { - Debug printf("COutputPin_QueryPinInfo() called\n"); + Debug unimplemented("COutputPin_QueryPinInfo", This); return E_NOTIMPL; } static HRESULT STDCALL COutputPin_QueryDirection(IPin * This, /* [out] */ PIN_DIRECTION *pPinDir) { - Debug printf("COutputPin_QueryDirection() called\n"); + Debug printf("COutputPin_QueryDirection(%p) called\n", This); if (!pPinDir) return E_INVALIDARG; *pPinDir = PINDIR_INPUT; @@ -251,14 +231,14 @@ static HRESULT STDCALL COutputPin_QueryDirection(IPin * This, static HRESULT STDCALL COutputPin_QueryId(IPin * This, /* [out] */ LPWSTR *Id) { - Debug printf("COutputPin_QueryId() called\n"); + Debug unimplemented("COutputPin_QueryId", This); return E_NOTIMPL; } static HRESULT STDCALL COutputPin_QueryAccept(IPin * This, /* [in] */ const AM_MEDIA_TYPE *pmt) { - Debug printf("COutputPin_QueryAccept() called\n"); + Debug unimplemented("COutputPin_QueryAccept", This); return E_NOTIMPL; } @@ -268,7 +248,7 @@ static HRESULT STDCALL COutputPin_EnumMediaTypes(IPin * This, Debug printf("COutputPin_EnumMediaTypes() called\n"); if (!ppEnum) return E_INVALIDARG; - *ppEnum=(IEnumMediaTypes *)CEnumMediaTypes_Create(&((COutputPin*)This)->type); + *ppEnum = (IEnumMediaTypes*) CEnumMediaTypesCreate(&((COutputPin*)This)->type); return 0; } @@ -276,25 +256,25 @@ static HRESULT STDCALL COutputPin_QueryInternalConnections(IPin * This, /* [out] */ IPin **apPin, /* [out][in] */ ULONG *nPin) { - Debug printf("COutputPin_QueryInternalConnections() called\n"); + Debug unimplemented("COutputPin_QueryInternalConnections", This); return E_NOTIMPL; } static HRESULT STDCALL COutputPin_EndOfStream(IPin * This) { - Debug printf("COutputPin_EndOfStream() called\n"); + Debug unimplemented("COutputPin_EndOfStream", This); return E_NOTIMPL; } static HRESULT STDCALL COutputPin_BeginFlush(IPin * This) { - Debug printf("COutputPin_BeginFlush() called\n"); + Debug unimplemented("COutputPin_BeginFlush", This); return E_NOTIMPL; } static HRESULT STDCALL COutputPin_EndFlush(IPin * This) { - Debug printf("COutputPin_EndFlush() called\n"); + Debug unimplemented("COutputPin_EndFlush", This); return E_NOTIMPL; } @@ -315,13 +295,14 @@ static HRESULT STDCALL COutputPin_NewSegment(IPin * This, static HRESULT STDCALL COutputPin_M_QueryInterface(IUnknown* This, GUID* iid, void** ppv) { COutputPin* p = (COutputPin*)This; - Debug printf("COutputPin_M_QueryInterface() called\n"); + + Debug printf("COutputPin_M_QueryInterface(%p) called\n", This); if (!ppv) return E_INVALIDARG; if(!memcmp(iid, &IID_IUnknown, 16)) { - *ppv=p; + *ppv = p; p->vt->AddRef(This); return 0; } @@ -334,7 +315,7 @@ static HRESULT STDCALL COutputPin_M_QueryInterface(IUnknown* This, GUID* iid, vo }*/ if(!memcmp(iid, &IID_IMemInputPin, 16)) { - *ppv=p->mempin; + *ppv = p->mempin; p->mempin->vt->AddRef(This); return 0; } @@ -350,16 +331,16 @@ static HRESULT STDCALL COutputPin_M_QueryInterface(IUnknown* This, GUID* iid, vo // IMemInputPin methods -static HRESULT STDCALL COutputPin_GetAllocator(IMemInputPin * This, - /* [out] */ IMemAllocator **ppAllocator) +static HRESULT STDCALL COutputPin_GetAllocator(IMemInputPin* This, + /* [out] */ IMemAllocator** ppAllocator) { Debug printf("COutputPin_GetAllocator(%p, %p) called\n", This->vt, ppAllocator); - *ppAllocator=(IMemAllocator *)MemAllocator_Create(); + *ppAllocator = (IMemAllocator*) MemAllocatorCreate(); return 0; } - -static HRESULT STDCALL COutputPin_NotifyAllocator(IMemInputPin * This, - /* [in] */ IMemAllocator *pAllocator, + +static HRESULT STDCALL COutputPin_NotifyAllocator(IMemInputPin* This, + /* [in] */ IMemAllocator* pAllocator, /* [in] */ int bReadOnly) { Debug printf("COutputPin_NotifyAllocator(%p, %p) called\n", This, pAllocator); @@ -367,27 +348,26 @@ static HRESULT STDCALL COutputPin_NotifyAllocator(IMemInputPin * This, return 0; } -static HRESULT STDCALL COutputPin_GetAllocatorRequirements(IMemInputPin * This, - /* [out] */ ALLOCATOR_PROPERTIES *pProps) +static HRESULT STDCALL COutputPin_GetAllocatorRequirements(IMemInputPin* This, + /* [out] */ ALLOCATOR_PROPERTIES* pProps) { - Debug printf("COutputPin_GetAllocatorRequirements() called\n"); + Debug unimplemented("COutputPin_GetAllocatorRequirements", This); return E_NOTIMPL; } -static HRESULT STDCALL COutputPin_Receive(IMemInputPin * This, - /* [in] */ IMediaSample *pSample) +static HRESULT STDCALL COutputPin_Receive(IMemInputPin* This, + /* [in] */ IMediaSample* pSample) { + COutputMemPin* mp = (COutputMemPin*)This; char* pointer; - COutputMemPin* mp= (COutputMemPin*)This; - int len = pSample->vt->GetActualDataLength(pSample); - + int len; + Debug printf("COutputPin_Receive(%p) called\n", This); if (!pSample) return E_INVALIDARG; - - if (pSample->vt->GetPointer(pSample, (BYTE **)&pointer)) + if (pSample->vt->GetPointer(pSample, (BYTE**) &pointer)) return -1; - + len = pSample->vt->GetActualDataLength(pSample); if (len == 0) len = pSample->vt->GetSize(pSample);//for iv50 //if(me.frame_pointer)memcpy(me.frame_pointer, pointer, len); @@ -404,8 +384,9 @@ static HRESULT STDCALL COutputPin_Receive(IMemInputPin * This, fwrite(&((VIDEOINFOHEADER*)me.type.pbFormat)->bmiHeader, sizeof(BITMAPINFOHEADER), 1, file); fwrite(pointer, len, 1, file); fclose(file); -*/ +*/ // pSample->vt->Release((IUnknown*)pSample); + return 0; } @@ -414,82 +395,146 @@ static HRESULT STDCALL COutputPin_ReceiveMultiple(IMemInputPin * This, /* [in] */ long nSamples, /* [out] */ long *nSamplesProcessed) { - Debug printf("COutputPin_ReceiveMultiple() called (UNIMPLEMENTED)\n"); + Debug unimplemented("COutputPin_ReceiveMultiple", This); return E_NOTIMPL; } static HRESULT STDCALL COutputPin_ReceiveCanBlock(IMemInputPin * This) { - Debug printf("COutputPin_ReceiveCanBlock() called (UNIMPLEMENTED)\n"); + Debug unimplemented("COutputPin_ReceiveCanBlock", This); return E_NOTIMPL; } -COutputPin * COutputPin_Create(const AM_MEDIA_TYPE * vh) -{ - COutputPin *this; - this = malloc(sizeof(COutputPin)); - this->refcount = 1; - memcpy(&this->type,vh,sizeof(AM_MEDIA_TYPE)); - this->remote=0; - this->vt = malloc(sizeof(IPin_vt)); - 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 = malloc(sizeof(COutputMemPin)); - this->mempin->vt = malloc(sizeof(IMemInputPin_vt)); - this->mempin->vt->QueryInterface = COutputPin_M_QueryInterface; - this->mempin->vt->AddRef = COutputPin_M_AddRef; - this->mempin->vt->Release = COutputPin_M_Release; - this->mempin->vt->GetAllocator = COutputPin_GetAllocator; - this->mempin->vt->NotifyAllocator = COutputPin_NotifyAllocator; - this->mempin->vt->GetAllocatorRequirements = COutputPin_GetAllocatorRequirements; - this->mempin->vt->Receive = COutputPin_Receive; - this->mempin->vt->ReceiveMultiple = COutputPin_ReceiveMultiple; - this->mempin->vt->ReceiveCanBlock = COutputPin_ReceiveCanBlock; - - this->mempin->frame_size_pointer = 0; - this->mempin->frame_pointer = 0; - this->mempin->pAllocator = 0; - this->mempin->parent = this; - - return this; -} - -void COutputPin_Destroy(COutputPin *this) -{ - free(this->vt); - free(this->mempin->vt); - free(this->mempin); - free(this); -} - -void COutputPin_SetFramePointer(COutputPin *this,char** z) -{ this->mempin->frame_pointer = z; } - -void COutputPin_SetPointer2(COutputPin *this,char* p) -{ - if (this->mempin->pAllocator) - MemAllocator_SetPointer(this->mempin->pAllocator,p); -} - -void COutputPin_SetFrameSizePointer(COutputPin *this,long* z) -{ this->mempin->frame_size_pointer = z; } - -void COutputPin_SetNewFormat(COutputPin *this, AM_MEDIA_TYPE * a) -{ memcpy(&this->type,a,sizeof(AM_MEDIA_TYPE)); } +static void COutputPin_SetFramePointer(COutputPin* This, char** z) +{ + This->mempin->frame_pointer = z; +} + +static void COutputPin_SetPointer2(COutputPin* This, char* p) +{ + if (This->mempin->pAllocator) + // fixme + This->mempin->pAllocator->SetPointer(This->mempin->pAllocator, p); +} + +static void COutputPin_SetFrameSizePointer(COutputPin* This, long* z) +{ + This->mempin->frame_size_pointer = z; +} + +static void COutputPin_SetNewFormat(COutputPin* This, const AM_MEDIA_TYPE* amt) +{ + This->type = *amt; +} + +static void COutputPin_Destroy(COutputPin* This) +{ + if (This->mempin->vt) + free(This->mempin->vt); + if (This->mempin) + free(This->mempin); + if (This->vt) + free(This->vt); + free(This); +} + +static HRESULT STDCALL COutputPin_AddRef(IUnknown* This) +{ + Debug printf("COutputPin_AddRef(%p) called (%d)\n", This, ((COutputPin*)This)->refcount); + ((COutputPin*)This)->refcount++; + return 0; +} + +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; +} + +static HRESULT STDCALL COutputPin_M_AddRef(IUnknown* This) +{ + COutputMemPin* p = (COutputMemPin*) This; + Debug printf("COutputPin_MAddRef(%p) called (%p, %d)\n", p, p->parent, p->parent->refcount); + p->parent->refcount++; + return 0; +} + +static HRESULT STDCALL COutputPin_M_Release(IUnknown* This) +{ + COutputMemPin* p = (COutputMemPin*) This; + Debug printf("COutputPin_MRelease(%p) called (%p, %d)\n", + p, p->parent, p->parent->refcount); + if (--p->parent->refcount <= 0) + COutputPin_Destroy(p->parent); + return 0; +} + +COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* amt) +{ + COutputPin* This = (COutputPin*) malloc(sizeof(COutputPin)); + IMemInputPin_vt* ivt; + + if (!This) + return NULL; + + This->vt = (IPin_vt*) malloc(sizeof(IPin_vt)); + This->mempin = (COutputMemPin*) malloc(sizeof(COutputMemPin)); + ivt = (IMemInputPin_vt*) malloc(sizeof(IMemInputPin_vt)); + + if (!This->vt || !This->mempin || !ivt) + { + COutputPin_Destroy(This); + return NULL; + } + + This->mempin->vt = ivt; + + This->refcount = 1; + This->remote = 0; + 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 = COutputPin_M_QueryInterface; + This->mempin->vt->AddRef = COutputPin_M_AddRef; + This->mempin->vt->Release = COutputPin_M_Release; + This->mempin->vt->GetAllocator = COutputPin_GetAllocator; + This->mempin->vt->NotifyAllocator = COutputPin_NotifyAllocator; + This->mempin->vt->GetAllocatorRequirements = COutputPin_GetAllocatorRequirements; + This->mempin->vt->Receive = COutputPin_Receive; + This->mempin->vt->ReceiveMultiple = COutputPin_ReceiveMultiple; + This->mempin->vt->ReceiveCanBlock = COutputPin_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->SetPointer2 = COutputPin_SetPointer2; + This->SetFramePointer = COutputPin_SetFramePointer; + This->SetFrameSizePointer = COutputPin_SetFrameSizePointer; + This->SetNewFormat = COutputPin_SetNewFormat; + + return This; +} diff --git a/src/libw32dll/DirectShow/outputpin.h b/src/libw32dll/DirectShow/outputpin.h index 8f4fe1f63..016b36787 100644 --- a/src/libw32dll/DirectShow/outputpin.h +++ b/src/libw32dll/DirectShow/outputpin.h @@ -5,37 +5,32 @@ #include "allocator.h" -typedef struct _COutputPin COutputPin; +typedef struct _COutputPin COutputPin; -typedef struct _COutputMemPin -{ - IMemInputPin_vt *vt; +typedef struct _COutputMemPin COutputMemPin; +struct _COutputMemPin +{ + IMemInputPin_vt* vt; + DECLARE_IUNKNOWN(); char** frame_pointer; long* frame_size_pointer; MemAllocator* pAllocator; COutputPin* parent; -}COutputMemPin; +}; struct _COutputPin { - IPin_vt *vt; + IPin_vt* vt; + DECLARE_IUNKNOWN(); COutputMemPin* mempin; - int refcount; AM_MEDIA_TYPE type; IPin* remote; + void ( *SetFramePointer )(COutputPin*, char** z); + void ( *SetPointer2 )(COutputPin*, char* p); + void ( *SetFrameSizePointer )(COutputPin*, long* z); + void ( *SetNewFormat )(COutputPin*, const AM_MEDIA_TYPE* a); }; - -COutputPin * COutputPin_Create(const AM_MEDIA_TYPE * vh); - -void COutputPin_Destroy(COutputPin *this); - -void COutputPin_SetFramePointer(COutputPin *this,char** z); - -void COutputPin_SetPointer2(COutputPin *this,char* p); - -void COutputPin_SetFrameSizePointer(COutputPin *this,long* z); - -void COutputPin_SetNewFormat(COutputPin *this, AM_MEDIA_TYPE * a); +COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* vhdr); #endif /* DS_OUTPUTPIN_H */ diff --git a/src/libw32dll/Makefile.am b/src/libw32dll/Makefile.am index 008a114f5..78512268f 100644 --- a/src/libw32dll/Makefile.am +++ b/src/libw32dll/Makefile.am @@ -1,4 +1,4 @@ -CFLAGS = @GLOBAL_CFLAGS@ +CFLAGS = @GLOBAL_CFLAGS@ -Iwine SUBDIRS = wine DirectShow @@ -28,7 +28,7 @@ debug: @list='$(SUBDIRS)'; for subdir in $$list; do \ (cd $$subdir && $(MAKE) $@) || exit;\ done; - @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)" + @$(MAKE) CFLAGS="$(DEBUG_CFLAGS) -Iwine" install-debug: debug @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c index fedba9391..8facc1c54 100644 --- a/src/libw32dll/w32codec.c +++ b/src/libw32dll/w32codec.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: w32codec.c,v 1.53 2002/01/05 21:54:17 miguelfreitas Exp $ + * $Id: w32codec.c,v 1.54 2002/01/06 18:56:19 miguelfreitas Exp $ * * routines for using w32 codecs * DirectShow support by Miguel Freitas (Nov/2001) @@ -468,7 +468,6 @@ static void w32v_init_codec (w32v_decoder_t *this, int buf_type) { static void w32v_init_ds_codec (w32v_decoder_t *this, int buf_type) { uint32_t vo_cap; int outfmt; - CodecInfo ci; printf ("w32codec: init Direct Show video codec...\n"); @@ -477,9 +476,8 @@ static void w32v_init_ds_codec (w32v_decoder_t *this, int buf_type) { this->ldt_fs = Setup_LDT_Keeper(); - ci.dll=win32_codec_name; - memcpy(&ci.guid,this->guid,sizeof(ci.guid)); - this->ds_dec = DS_VideoDecoder_Create(&ci, &this->bih, this->flipped, 0); + this->ds_dec = DS_VideoDecoder_Open(win32_codec_name, this->guid, + &this->bih, this->flipped, 0); if(!this->ds_dec){ printf ("w32codec: DS_VideoDecoder failed! unknown codec %08lx / wrong parameters?\n", @@ -606,10 +604,8 @@ static void w32v_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { &this->bih, this->buf, &this->o_bih, this->img_buffer); else { - CImage image; - image.ptr=this->img_buffer; ret = DS_VideoDecoder_DecodeInternal(this->ds_dec, this->buf, - this->size, 0, &image); + this->size, 0, this->img_buffer); } if (this->outfmt==IMGFMT_YUY2) { @@ -871,16 +867,9 @@ static int w32a_init_audio (w32a_decoder_t *this, acmStreamSize(this->srcstream, out_size, (LPDWORD) &this->rec_audio_src_size, ACM_STREAMSIZEF_DESTINATION); } else { - CodecInfo ci; - - ci.dll=win32_codec_name; - memcpy(&ci.guid,this->guid,sizeof(GUID)); - /*__asm__ __volatile__( - "int $0x3\n" : : - );*/ - - if( (this->ds_dec=DS_AudioDecoder_Create(&ci, in_fmt)) == NULL ) { + if( (this->ds_dec=DS_AudioDecoder_Open(win32_codec_name, + this->guid, in_fmt)) == NULL ) { printf("w32codec: Error initializing DirectShow Audio\n"); this->srcstream = 0; return 0; diff --git a/src/libw32dll/wine/com.h b/src/libw32dll/wine/com.h index 10d8bbf08..4082b1350 100644 --- a/src/libw32dll/wine/com.h +++ b/src/libw32dll/wine/com.h @@ -46,10 +46,11 @@ struct IUnknown_vt long STDCALL (*AddRef)(struct IUnknown* _this) ; long STDCALL (*Release)(struct IUnknown* _this) ; } ; -struct IUnknown + +typedef struct IUnknown { struct IUnknown_vt* vt; -}; +} IUnknown; struct IClassFactory_vt { |