summaryrefslogtreecommitdiffstats
path: root/loader/dshow/DS_Filter.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-16 00:50:02 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-16 00:50:02 +0000
commitbda27f2adc68d6065d7a7df1e6558c062efe41f1 (patch)
tree4077a416a09134894f71166eef48f9f39782fc9d /loader/dshow/DS_Filter.c
parentfda7100c9d34a2c5dccddfd25e87193abe55a152 (diff)
downloadmpv-bda27f2adc68d6065d7a7df1e6558c062efe41f1.tar.bz2
mpv-bda27f2adc68d6065d7a7df1e6558c062efe41f1.tar.xz
big avifile sync - from now we have common code
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1546 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader/dshow/DS_Filter.c')
-rw-r--r--loader/dshow/DS_Filter.c160
1 files changed, 84 insertions, 76 deletions
diff --git a/loader/dshow/DS_Filter.c b/loader/dshow/DS_Filter.c
index e2eeb1301a..a057dd2cec 100644
--- a/loader/dshow/DS_Filter.c
+++ b/loader/dshow/DS_Filter.c
@@ -1,34 +1,49 @@
-#include <stdio.h>
-#include <string.h>
#include "DS_Filter.h"
-#include <except.h>
//#include "../loader/loader.h"
+#include <libwin32.h>
#include <string>
-#include <iostream>
+#include <stdio.h>
+#include <string.h>
+
#define __MODULE__ "DirectShow generic filter"
using namespace std;
-typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
-extern "C" char* def_path;
-
extern "C" int STDCALL expLoadLibraryA(const char*);
-extern "C" STDCALL void* GetProcAddress(int, const char*);
-extern "C" int STDCALL FreeLibrary(int);
-extern "C" void Setup_LDT_Keeper();
-extern "C" void setup_FS_Segment();
+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);
DS_Filter::DS_Filter()
- :m_iHandle(0), m_pFilter(0), m_pInputPin(0),
- m_pOutputPin(0), m_pSrcFilter(0), m_pParentFilter(0),
- m_pOurInput(0), m_pOurOutput(0), m_pAll(0), m_pImp(0),
- m_iState(0)
{
+ m_iHandle = 0;
+ m_pFilter = 0;
+ m_pInputPin = 0;
+ m_pOutputPin = 0;
+ m_pSrcFilter = 0;
+ m_pParentFilter = 0;
+ m_pOurInput = 0;
+ m_pOurOutput = 0;
+ m_pAll = 0;
+ m_pImp = 0;
+ m_iState = 0;
}
-void DS_Filter::clean()
+DS_Filter::~DS_Filter()
{
+ //cout << "Destruction of DS_FILTER" << endl;
+ Stop();
+ destroy();
+ //cout << "Destruction of DS_FILTER done" << endl;
+}
+
+void DS_Filter::destroy()
+{
+ if (m_iState == 0)
+ return;
m_iState = 0;
if (m_pOurInput)
@@ -53,67 +68,56 @@ void DS_Filter::clean()
// FIXME - we are still leaving few things allocated!
if (m_iHandle)
FreeLibrary(m_iHandle);
-
}
-DS_Filter::~DS_Filter()
+void DS_Filter::Create(const char* dllname, const GUID* id,
+ AM_MEDIA_TYPE* in_fmt,
+ AM_MEDIA_TYPE* out_fmt)
{
- //cout << "Destruction of DS_FILTER" << endl;
- Stop();
- if (m_iState == 1)
- clean();
- //cout << "Destruction of DS_FILTER done" << endl;
-}
-
-void DS_Filter::Create(char* dllname, const GUID* id, AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt)
-{
-
- Setup_LDT_Keeper();
-
try
{
-// string _fullname=def_path;
-// _fullname+="/";
-// _fullname+=dllname;
- m_iHandle= expLoadLibraryA(dllname);
+ m_iHandle = expLoadLibraryA(dllname);
if (!m_iHandle)
{
- char e[1024];
- snprintf(e, 1024, "Could not open DirectShow DLL: %s", dllname);
+ char e[256];
+ printf("Could not open DirectShow DLL: %.200s", dllname);
throw FATAL(e);
}
- GETCLASS func=(GETCLASS)GetProcAddress(m_iHandle, "DllGetClassObject");
+ GETCLASS func = (GETCLASS)GetProcAddress(m_iHandle, "DllGetClassObject");
if (!func)
{
- char e[1024];
- snprintf(e, 1024, "Illegal or corrupt DirectShow DLL: %s", dllname);
+ char e[256];
+ printf("Illegal or corrupt DirectShow DLL: %.200s", dllname);
throw FATAL(e);
}
HRESULT result;
- IClassFactory* factory=0;
- result=func(id, &IID_IClassFactory, (void**)&factory);
- if(result || (!factory)) throw FATAL("No such class object");;
-
- setup_FS_Segment();
+ IClassFactory* factory = 0;
+ result = func(id, &IID_IClassFactory, (void**)&factory);
+ if (result || !factory)
+ throw FATAL("No such class object");;
- IUnknown* object=0;
- result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
+ IUnknown* object = 0;
+ result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
factory->vt->Release((IUnknown*)factory);
- if(result || (!object)) throw FATAL("Class factory failure");
+ if (result || !object)
+ throw FATAL("Class factory failure");
- result=object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&m_pFilter);
+ result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&m_pFilter);
object->vt->Release((IUnknown*)object);
- if(result || (!m_pFilter)) throw FATAL("Object does not have IBaseFilter interface");
+ if (result || !m_pFilter)
+ throw FATAL("Object does not have IBaseFilter interface");
+
+ IEnumPins* enum_pins = 0;
+ // enumerate pins
+ result = m_pFilter->vt->EnumPins(m_pFilter, &enum_pins);
+ if (result || !enum_pins)
+ throw FATAL("Could not enumerate pins");
- IEnumPins* enum_pins=0;
- // enumerate pins
- result=m_pFilter->vt->EnumPins(m_pFilter, &enum_pins);
- if(result || (!enum_pins)) throw FATAL("Could not enumerate pins");
IPin* array[256];
ULONG fetched;
enum_pins->vt->Reset(enum_pins);
- result=enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched);
+ 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);
for (unsigned i = 0; i < fetched; i++)
@@ -140,38 +144,45 @@ void DS_Filter::Create(char* dllname, const GUID* id, AM_MEDIA_TYPE* in_fmt, AM
result = m_pInputPin->vt->QueryInterface((IUnknown*)m_pInputPin,
&IID_IMemInputPin,
(void**)&m_pImp);
- if(result)
+ if (result)
throw FATAL("Error getting IMemInputPin interface");
- m_pOurType=in_fmt;
- m_pDestType=out_fmt;
- result=m_pInputPin->vt->QueryAccept(m_pInputPin, m_pOurType);
+ m_pOurType = in_fmt;
+ m_pDestType = out_fmt;
+ result = m_pInputPin->vt->QueryAccept(m_pInputPin, m_pOurType);
if (result)
throw FATAL("Source format is not accepted");
- m_pParentFilter=new CBaseFilter2;
- m_pSrcFilter=new CBaseFilter(*m_pOurType, m_pParentFilter);
- m_pOurInput=m_pSrcFilter->GetPin();
+ m_pParentFilter = new CBaseFilter2;
+ m_pSrcFilter = new CBaseFilter(*m_pOurType, m_pParentFilter);
+ m_pOurInput = m_pSrcFilter->GetPin();
m_pOurInput->vt->AddRef((IUnknown*)m_pOurInput);
- result=m_pInputPin->vt->ReceiveConnection(m_pInputPin, m_pOurInput,
- m_pOurType);
+ result = m_pInputPin->vt->ReceiveConnection(m_pInputPin,
+ m_pOurInput,
+ m_pOurType);
if (result)
throw FATAL("Error connecting to input pin");
m_pOurOutput = new COutputPin(*m_pDestType);
+ //extern void trapbug();
+ //trapbug();
result = m_pOutputPin->vt->ReceiveConnection(m_pOutputPin,
m_pOurOutput,
m_pDestType);
if (result)
+ {
+ //printf("Tracking ACELP %d 0%x\n", result);
throw FATAL("Error connecting to output pin");
- cout << "Using DirectShow codec: " << dllname << endl;
+ }
+
+ printf("Using DirectShow codec: %s\n", dllname);
m_iState = 1;
}
- catch(FatalError e)
+ catch (FatalError e)
{
- e.PrintAll();
- clean();
+ //e.PrintAll();
+ destroy();
throw;
}
}
@@ -181,22 +192,19 @@ void DS_Filter::Start()
if (m_iState != 1)
return;
- m_pFilter->vt->Pause(m_pFilter);
-
HRESULT hr=m_pFilter->vt->Run(m_pFilter, 0);
if (hr != 0)
{
- Debug cerr<<"WARNING: m_Filter->Run() failed, error code "<<hex<<hr<<dec<<endl;
+ Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr);
}
- hr=m_pImp->vt->GetAllocator(m_pImp, &m_pAll);
+ hr = m_pImp->vt->GetAllocator(m_pImp, &m_pAll);
if (hr)
{
- Debug cerr<<"Error getting IMemAllocator interface "<<hex<<hr<<dec<<endl;
+ Debug printf("Error getting IMemAllocator interface %x\n", (int)hr);
m_pImp->vt->Release((IUnknown*)m_pImp);
return;
}
m_pImp->vt->NotifyAllocator(m_pImp, m_pAll, 0);
-
m_iState = 2;
}
@@ -205,8 +213,8 @@ void DS_Filter::Stop()
if (m_iState == 2)
{
m_pAll->vt->Release((IUnknown*)m_pAll);
- m_pAll=0;
- m_pFilter->vt->Stop(m_pFilter);
- m_iState=1;
+ m_pFilter->vt->Stop(m_pFilter); // causes weird crash ??? FIXME
+ m_pAll = 0;
+ m_iState = 1;
}
}