Mercurial > mplayer.hg
annotate loader/driver.c @ 185:b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
| author | arpi_esp |
|---|---|
| date | Wed, 21 Mar 2001 21:09:36 +0000 |
| parents | 28091b3caff9 |
| children | a2c9731b2e01 |
| rev | line source |
|---|---|
| 1 | 1 #include <config.h> |
| 2 #include <stdio.h> | |
| 3 | |
| 4 #ifdef HAVE_MALLOC_H | |
| 5 #include <malloc.h> | |
| 6 #else | |
| 7 #include <stdlib.h> | |
| 8 #endif | |
| 9 | |
| 10 #include <wine/driver.h> | |
| 11 #include <wine/pe_image.h> | |
| 12 #include <wine/winreg.h> | |
| 13 #include <wine/vfw.h> | |
| 14 #include <registry.h> | |
| 15 | |
|
185
b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
arpi_esp
parents:
128
diff
changeset
|
16 //#include "com.h" |
|
b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
arpi_esp
parents:
128
diff
changeset
|
17 //typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**); |
| 1 | 18 |
| 19 | |
| 20 #ifdef __FreeBSD__ | |
| 21 #include <sys/time.h> | |
| 22 #endif | |
| 23 | |
| 24 | |
| 25 #define STORE_ALL \ | |
| 26 __asm__ ( \ | |
| 27 "push %%ebx\n\t" \ | |
| 28 "push %%ecx\n\t" \ | |
| 29 "push %%edx\n\t" \ | |
| 30 "push %%esi\n\t" \ | |
| 31 "push %%edi\n\t"::) | |
| 32 | |
| 33 #define REST_ALL \ | |
| 34 __asm__ ( \ | |
| 35 "pop %%edi\n\t" \ | |
| 36 "pop %%esi\n\t" \ | |
| 37 "pop %%edx\n\t" \ | |
| 38 "pop %%ecx\n\t" \ | |
| 39 "pop %%ebx\n\t"::) | |
| 40 | |
| 41 | |
| 42 | |
| 43 typedef struct { | |
| 44 UINT uDriverSignature; | |
| 45 HINSTANCE hDriverModule; | |
| 46 DRIVERPROC DriverProc; | |
| 47 DWORD dwDriverID; | |
| 48 } DRVR; | |
| 49 | |
| 50 typedef DRVR *PDRVR; | |
| 51 typedef DRVR *NPDRVR; | |
| 52 typedef DRVR *LPDRVR; | |
| 53 | |
| 54 static DWORD dwDrvID = 0; | |
| 55 | |
| 56 | |
| 57 LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message, | |
| 58 LPARAM lParam1, LPARAM lParam2 ) | |
| 59 { | |
| 60 DRVR* module=(DRVR*)hDriver; | |
| 61 int result; | |
| 62 #ifdef DETAILED_OUT | |
| 63 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2); | |
| 64 #endif | |
| 65 if(module==0)return -1; | |
| 66 if(module->hDriverModule==0)return -1; | |
| 67 if(module->DriverProc==0)return -1; | |
| 68 STORE_ALL; | |
| 69 result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2); | |
| 70 REST_ALL; | |
| 71 #ifdef DETAILED_OUT | |
| 72 printf("\t\tResult: %X\n", result); | |
| 73 #endif | |
| 74 return result; | |
| 75 } | |
| 76 | |
| 77 static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult) | |
| 78 { | |
| 79 NPDRVR npDriver; | |
| 80 /* allocate and lock handle */ | |
| 81 if (lpDriver) | |
| 82 { | |
| 83 if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) ) | |
| 84 { | |
| 85 if ((npDriver = (NPDRVR) *lpDriver)) | |
| 86 { | |
| 87 *lpDrvResult = MMSYSERR_NOERROR; | |
| 88 return (npDriver); | |
| 89 } | |
| 90 free((NPDRVR)*lpDriver); | |
| 91 } | |
| 92 return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0); | |
| 93 } | |
| 94 return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0); | |
| 95 } | |
| 96 | |
| 97 | |
| 98 static void DrvFree(HDRVR hDriver) | |
| 99 { | |
| 100 int i; | |
| 101 if(hDriver) | |
| 102 if(((DRVR*)hDriver)->hDriverModule) | |
| 103 if(((DRVR*)hDriver)->DriverProc) | |
| 104 (((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0); | |
| 105 if(hDriver) { | |
| 106 if(((DRVR*)hDriver)->hDriverModule) | |
| 107 if(((DRVR*)hDriver)->DriverProc) | |
| 108 (((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0); | |
| 109 FreeLibrary(((DRVR*)hDriver)->hDriverModule); | |
| 110 free((NPDRVR)hDriver); | |
| 111 return; | |
| 112 } | |
| 113 } | |
| 114 | |
| 115 void DrvClose(HDRVR hdrvr) | |
| 116 { | |
| 117 DrvFree(hdrvr); | |
| 118 } | |
| 119 | |
| 120 | |
| 128 | 121 extern char* def_path; //=WIN32_PATH; // path to codecs |
| 1 | 122 char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!! |
| 123 | |
| 124 HDRVR | |
| 125 DrvOpen(LPARAM lParam2) | |
| 126 { | |
| 127 ICOPEN *icopen=(ICOPEN *) lParam2; | |
| 128 UINT uDrvResult; | |
| 129 HDRVR hDriver; | |
| 130 NPDRVR npDriver; | |
| 131 char unknown[0x24]; | |
| 132 // char* codec_name=icopen->fccHandler; | |
| 133 | |
| 134 if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult))) | |
| 135 return ((HDRVR) 0); | |
| 136 | |
| 137 if (!(npDriver->hDriverModule = expLoadLibraryA(win32_codec_name))) { | |
| 138 printf("Can't open library %s\n", win32_codec_name); | |
| 139 DrvFree(hDriver); | |
| 140 return ((HDRVR) 0); | |
| 141 } | |
| 142 | |
| 143 #if 0 | |
| 144 { | |
| 145 unsigned char *p=((char*)npDriver->hDriverModule); | |
| 146 double *dp; | |
| 147 int i; | |
| 148 p+=0x14c0; | |
| 149 for(i=0;i<16;i++)printf(" %02X",p[i]); printf("\n"); | |
| 150 dp=(double*)p; | |
| 151 printf("divx bitrate = %f\n",(float)(*dp)); | |
| 152 // *(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate; | |
| 153 } | |
| 154 #endif | |
| 155 | |
| 156 if (!(npDriver->DriverProc = (DRIVERPROC) | |
| 157 GetProcAddress(npDriver->hDriverModule, "DriverProc"))) { | |
|
185
b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
arpi_esp
parents:
128
diff
changeset
|
158 #if 1 |
| 1 | 159 printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name); |
| 160 #else | |
| 161 // Try DirectShow... | |
| 162 GETCLASS func=(GETCLASS)GetProcAddress(npDriver->hDriverModule,"DllGetClassObject"); | |
| 163 if(!func) | |
| 164 printf("Library %s is not a valid VfW/ACM/DShow codec\n", win32_codec_name); | |
| 165 else { | |
| 166 HRESULT result; | |
| 167 struct IClassFactory* factory=0; | |
| 168 struct IUnknown* object=0; | |
| 169 GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1, | |
| 170 {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}}; | |
| 171 GUID* id=&CLSID_Voxware; | |
| 172 | |
| 173 result=func(id, &IID_IClassFactory, (void**)&factory); | |
| 174 if(result || (!factory)) printf("No such class object\n"); | |
| 175 | |
| 176 printf("Calling factory->vt->CreateInstance()\n"); | |
| 177 printf("addr = %X\n",(unsigned int)factory->vt->CreateInstance); | |
| 178 result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object); | |
| 179 printf("Calling factory->vt->Release()\n"); | |
| 180 factory->vt->Release((struct IUnknown*)factory); | |
| 181 if(result || (!object)) printf("Class factory failure\n"); | |
| 182 | |
| 183 printf("DirectShow codecs not yet supported...\n"); | |
| 184 } | |
| 185 #endif | |
| 186 | |
| 187 FreeLibrary(npDriver->hDriverModule); | |
| 188 DrvFree(hDriver); | |
| 189 return ((HDRVR) 0); | |
| 190 | |
| 191 } | |
| 192 | |
| 193 //TRACE("DriverProc == %X\n", npDriver->DriverProc); | |
| 194 npDriver->dwDriverID = ++dwDrvID; | |
| 195 | |
| 196 STORE_ALL; | |
| 197 (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0); | |
| 198 REST_ALL; | |
| 199 //TRACE("DRV_LOAD Ok!\n"); | |
| 200 STORE_ALL; | |
| 201 (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0); | |
| 202 REST_ALL; | |
| 203 //TRACE("DRV_ENABLE Ok!\n"); | |
| 204 | |
| 205 // open driver | |
| 206 STORE_ALL; | |
| 207 npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN, | |
| 208 (LPARAM) (LPSTR) unknown, lParam2); | |
| 209 REST_ALL; | |
| 210 | |
| 211 //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID); | |
| 212 | |
| 213 if (uDrvResult) | |
| 214 { | |
| 215 DrvFree(hDriver); | |
| 216 hDriver = (HDRVR) 0; | |
| 217 } | |
| 218 | |
| 219 printf("Successfully loaded codec %s\n",win32_codec_name); | |
| 220 | |
| 221 return (hDriver); | |
| 222 } | |
| 223 |
