33 |
#include "status.h" |
#include "status.h" |
34 |
#include "resource.h" |
#include "resource.h" |
35 |
|
|
36 |
|
static int clean_dll_bindings(CODEC* codec); |
37 |
|
|
38 |
BOOL WINAPI DllMain( |
BOOL WINAPI DllMain( |
39 |
HANDLE hModule, |
HANDLE hModule, |
44 |
return TRUE; |
return TRUE; |
45 |
} |
} |
46 |
|
|
|
extern HINSTANCE m_hdll; |
|
|
|
|
47 |
/* __declspec(dllexport) */ LRESULT WINAPI DriverProc( |
/* __declspec(dllexport) */ LRESULT WINAPI DriverProc( |
48 |
DWORD dwDriverId, |
DWORD dwDriverId, |
49 |
HDRVR hDriver, |
HDRVR hDriver, |
60 |
|
|
61 |
case DRV_LOAD : |
case DRV_LOAD : |
62 |
case DRV_FREE : |
case DRV_FREE : |
63 |
return DRV_OK; |
return DRVCNF_OK; |
64 |
|
|
65 |
case DRV_OPEN : |
case DRV_OPEN : |
66 |
DPRINTF("DRV_OPEN"); |
DPRINTF("DRV_OPEN"); |
67 |
m_hdll = NULL; |
|
68 |
{ |
{ |
69 |
ICOPEN * icopen = (ICOPEN *)lParam2; |
ICOPEN * icopen = (ICOPEN *)lParam2; |
70 |
|
|
71 |
if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO) |
if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO) |
72 |
{ |
{ |
73 |
return DRV_CANCEL; |
return DRVCNF_CANCEL; |
74 |
} |
} |
75 |
|
|
76 |
codec = malloc(sizeof(CODEC)); |
codec = malloc(sizeof(CODEC)); |
84 |
return 0; |
return 0; |
85 |
} |
} |
86 |
|
|
87 |
|
memset(codec, 0, sizeof(CODEC)); |
88 |
|
|
89 |
codec->status.hDlg = NULL; |
codec->status.hDlg = NULL; |
90 |
codec->config.ci_valid = 0; |
codec->config.ci_valid = 0; |
113 |
/* compress_end/decompress_end don't always get called */ |
/* compress_end/decompress_end don't always get called */ |
114 |
compress_end(codec); |
compress_end(codec); |
115 |
decompress_end(codec); |
decompress_end(codec); |
116 |
|
clean_dll_bindings(codec); |
117 |
status_destroy_always(&codec->status); |
status_destroy_always(&codec->status); |
118 |
free(codec); |
free(codec); |
119 |
return DRV_OK; |
return DRVCNF_OK; |
120 |
|
|
121 |
case DRV_DISABLE : |
case DRV_DISABLE : |
122 |
case DRV_ENABLE : |
case DRV_ENABLE : |
123 |
return DRV_OK; |
return DRVCNF_OK; |
124 |
|
|
125 |
case DRV_INSTALL : |
case DRV_INSTALL : |
126 |
case DRV_REMOVE : |
case DRV_REMOVE : |
127 |
return DRV_OK; |
return DRVCNF_OK; |
128 |
|
|
129 |
case DRV_QUERYCONFIGURE : |
case DRV_QUERYCONFIGURE : |
130 |
case DRV_CONFIGURE : |
case DRV_CONFIGURE : |
131 |
return DRV_CANCEL; |
return DRVCNF_CANCEL; |
132 |
|
|
133 |
|
|
134 |
/* info */ |
/* info */ |
135 |
|
|
136 |
case ICM_GETINFO : |
case ICM_GETINFO : |
137 |
DPRINTF("ICM_GETINFO"); |
DPRINTF("ICM_GETINFO"); |
138 |
{ |
|
139 |
|
if (lParam1 && lParam2 >= sizeof(ICINFO)) { |
140 |
ICINFO *icinfo = (ICINFO *)lParam1; |
ICINFO *icinfo = (ICINFO *)lParam1; |
141 |
|
|
142 |
icinfo->fccType = ICTYPE_VIDEO; |
icinfo->fccType = ICTYPE_VIDEO; |
155 |
return lParam2; /* size of struct */ |
return lParam2; /* size of struct */ |
156 |
} |
} |
157 |
|
|
158 |
|
return 0; /* error */ |
159 |
|
|
160 |
/* state control */ |
/* state control */ |
161 |
|
|
162 |
case ICM_ABOUT : |
case ICM_ABOUT : |
296 |
return ICERR_UNSUPPORTED; |
return ICERR_UNSUPPORTED; |
297 |
|
|
298 |
default: |
default: |
299 |
|
if (uMsg < DRV_USER) |
300 |
return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); |
return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); |
301 |
|
else |
302 |
|
return ICERR_UNSUPPORTED; |
303 |
} |
} |
304 |
} |
} |
305 |
|
|
|
|
|
306 |
void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow) |
void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow) |
307 |
{ |
{ |
308 |
DWORD dwDriverId; |
DWORD dwDriverId; |
310 |
dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0); |
dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0); |
311 |
if (dwDriverId != (DWORD)NULL) |
if (dwDriverId != (DWORD)NULL) |
312 |
{ |
{ |
313 |
|
if (lstrcmpi(lpCmdLine, "about")==0) { |
314 |
|
DriverProc(dwDriverId, 0, ICM_ABOUT, (LPARAM)GetDesktopWindow(), 0); |
315 |
|
}else{ |
316 |
DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0); |
DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0); |
317 |
|
} |
318 |
DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0); |
DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0); |
319 |
} |
} |
320 |
} |
} |
321 |
|
|
322 |
|
static int clean_dll_bindings(CODEC* codec) |
323 |
|
{ |
324 |
|
if(codec->m_hdll) |
325 |
|
{ |
326 |
|
FreeLibrary(codec->m_hdll); |
327 |
|
codec->m_hdll = NULL; |
328 |
|
codec->xvid_global_func = NULL; |
329 |
|
codec->xvid_encore_func = NULL; |
330 |
|
codec->xvid_decore_func = NULL; |
331 |
|
codec->xvid_plugin_single_func = NULL; |
332 |
|
codec->xvid_plugin_2pass1_func = NULL; |
333 |
|
codec->xvid_plugin_2pass2_func = NULL; |
334 |
|
codec->xvid_plugin_lumimasking_func = NULL; |
335 |
|
codec->xvid_plugin_psnr_func = NULL; |
336 |
|
} |
337 |
|
return 0; |
338 |
|
} |