3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Xvid Decoder part of the DShow Filter - |
* - Xvid Decoder part of the DShow Filter - |
5 |
* |
* |
6 |
* Copyright(C) 2002-2010 Peter Ross <pross@xvid.org> |
* Copyright(C) 2002-2011 Peter Ross <pross@xvid.org> |
7 |
* 2003-2010 Michael Militzer <michael@xvid.org> |
* 2003-2011 Michael Militzer <michael@xvid.org> |
8 |
* |
* |
9 |
* This program is free software ; you can redistribute it and/or modify |
* This program is free software ; you can redistribute it and/or modify |
10 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
20 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: CXvidDecoder.cpp,v 1.29 2011-03-17 15:11:32 Isibaar Exp $ |
* $Id$ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
36 |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug |
37 |
*/ |
*/ |
38 |
|
|
39 |
/* |
#ifdef ENABLE_MFT |
40 |
#define XVID_USE_MFT |
#define XVID_USE_MFT |
41 |
#define XVID_USE_TRAYICON |
#endif |
|
*/ |
|
42 |
|
|
43 |
#include <windows.h> |
#include <windows.h> |
44 |
|
|
175 |
/* note: g_cTemplates must be global; used by strmbase.lib(dllentry.cpp,dllsetup.cpp) */ |
/* note: g_cTemplates must be global; used by strmbase.lib(dllentry.cpp,dllsetup.cpp) */ |
176 |
int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate); |
int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate); |
177 |
|
|
|
#ifdef XVID_USE_TRAYICON |
|
178 |
extern HINSTANCE g_xvid_hInst; |
extern HINSTANCE g_xvid_hInst; |
179 |
|
|
180 |
static int GUI_Page = 0; |
static int GUI_Page = 0; |
216 |
|
|
217 |
return TRUE; /* ok */ |
return TRUE; /* ok */ |
218 |
} |
} |
|
#endif |
|
219 |
|
|
220 |
STDAPI DllRegisterServer() |
STDAPI DllRegisterServer() |
221 |
{ |
{ |
309 |
|
|
310 |
/* constructor */ |
/* constructor */ |
311 |
|
|
|
#define XVID_DLL_NAME "xvidcore.dll" |
|
|
|
|
312 |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
313 |
CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL) |
CVideoTransformFilter(TEXT("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL) |
314 |
{ |
{ |
315 |
DPRINTF("Constructor"); |
DPRINTF("Constructor"); |
316 |
|
|
331 |
LoadRegistryInfo(); |
LoadRegistryInfo(); |
332 |
|
|
333 |
*phr = OpenLib(); |
*phr = OpenLib(); |
334 |
|
|
335 |
|
{ |
336 |
|
TCHAR lpFilename[MAX_PATH]; |
337 |
|
int sLen = GetModuleFileName(NULL, lpFilename, MAX_PATH); |
338 |
|
#ifdef _UNICODE |
339 |
|
if ((sLen >= 11) && (_wcsnicmp(&(lpFilename[sLen - 11]), TEXT("dllhost.exe"), 11) == 0)) { |
340 |
|
#else |
341 |
|
if ((sLen >= 11) && (_strnicmp(&(lpFilename[sLen - 11]), TEXT("dllhost.exe"), 11) == 0)) { |
342 |
|
#endif |
343 |
|
if (Tray_Icon == 0) Tray_Icon = -1; // create no tray icon upon thumbnail generation |
344 |
|
} |
345 |
|
else |
346 |
|
if (Tray_Icon == -1) Tray_Icon = 0; // can show tray icon |
347 |
|
} |
348 |
|
|
349 |
} |
} |
350 |
|
|
351 |
HRESULT CXvidDecoder::OpenLib() |
HRESULT CXvidDecoder::OpenLib() |
367 |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
368 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
369 |
DPRINTF("dll load failed"); |
DPRINTF("dll load failed"); |
370 |
MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST); |
MessageBox(0, XVID_DLL_NAME TEXT(" not found"), TEXT("Error"), MB_TOPMOST); |
371 |
return E_FAIL; |
return E_FAIL; |
372 |
} |
} |
373 |
|
|
375 |
if (xvid_global_func == NULL) { |
if (xvid_global_func == NULL) { |
376 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
377 |
m_hdll = NULL; |
m_hdll = NULL; |
378 |
MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_global() not found"), TEXT("Error"), MB_TOPMOST); |
379 |
return E_FAIL; |
return E_FAIL; |
380 |
} |
} |
381 |
|
|
384 |
xvid_global_func = NULL; |
xvid_global_func = NULL; |
385 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
386 |
m_hdll = NULL; |
m_hdll = NULL; |
387 |
MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_decore() not found"), TEXT("Error"), MB_TOPMOST); |
388 |
return E_FAIL; |
return E_FAIL; |
389 |
} |
} |
390 |
|
|
394 |
xvid_decore_func = NULL; |
xvid_decore_func = NULL; |
395 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
396 |
m_hdll = NULL; |
m_hdll = NULL; |
397 |
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST); |
398 |
return E_FAIL; |
return E_FAIL; |
399 |
} |
} |
400 |
|
|
404 |
xvid_decore_func = NULL; |
xvid_decore_func = NULL; |
405 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
406 |
m_hdll = NULL; |
m_hdll = NULL; |
407 |
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST); |
408 |
return E_FAIL; |
return E_FAIL; |
409 |
} |
} |
410 |
|
|
507 |
{ |
{ |
508 |
DPRINTF("Destructor"); |
DPRINTF("Destructor"); |
509 |
|
|
510 |
#ifdef XVID_USE_TRAYICON |
if (Tray_Icon > 0) { /* Destroy tray icon */ |
|
if (Tray_Icon) { /* Destroy tray icon */ |
|
511 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
512 |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
513 |
|
|
518 |
Shell_NotifyIcon(NIM_DELETE, &nid); |
Shell_NotifyIcon(NIM_DELETE, &nid); |
519 |
Tray_Icon = 0; |
Tray_Icon = 0; |
520 |
} |
} |
|
#endif |
|
521 |
|
|
522 |
/* Close xvidcore library */ |
/* Close xvidcore library */ |
523 |
CloseLib(); |
CloseLib(); |
944 |
{ |
{ |
945 |
DPRINTF("CompleteConnect"); |
DPRINTF("CompleteConnect"); |
946 |
|
|
947 |
#ifdef XVID_USE_TRAYICON |
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0)) |
|
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)) |
|
948 |
{ |
{ |
949 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
950 |
|
|
956 |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
957 |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
958 |
wc.lpszMenuName = NULL; |
wc.lpszMenuName = NULL; |
959 |
wc.lpszClassName = "XVID_MSG_WINDOW"; |
wc.lpszClassName = TEXT("XVID_MSG_WINDOW"); |
960 |
wc.hIcon = NULL; |
wc.hIcon = NULL; |
961 |
wc.hIconSm = NULL; |
wc.hIconSm = NULL; |
962 |
wc.hCursor = NULL; |
wc.hCursor = NULL; |
963 |
RegisterClassEx(&wc); |
RegisterClassEx(&wc); |
964 |
|
|
965 |
MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT, |
MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT, |
966 |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
967 |
|
|
968 |
/* display the tray icon */ |
/* display the tray icon */ |
974 |
nid.uID = 1456; |
nid.uID = 1456; |
975 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
976 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
977 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
lstrcpy(nid.szTip, TEXT("Xvid Video Decoder")); |
978 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
979 |
|
|
980 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
982 |
DestroyIcon(nid.hIcon); |
DestroyIcon(nid.hIcon); |
983 |
Tray_Icon = 1; |
Tray_Icon = 1; |
984 |
} |
} |
|
#endif |
|
985 |
|
|
986 |
return S_OK; |
return S_OK; |
987 |
} |
} |
1654 |
hr = OnSetOutputType(pType); |
hr = OnSetOutputType(pType); |
1655 |
} |
} |
1656 |
} |
} |
1657 |
#ifdef XVID_USE_TRAYICON |
|
1658 |
if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */ |
if (SUCCEEDED(hr) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0)) /* Create message passing window */ |
1659 |
{ |
{ |
1660 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
1661 |
|
|
1667 |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
1668 |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
1669 |
wc.lpszMenuName = NULL; |
wc.lpszMenuName = NULL; |
1670 |
wc.lpszClassName = "XVID_MSG_WINDOW"; |
wc.lpszClassName = TEXT("XVID_MSG_WINDOW"); |
1671 |
wc.hIcon = NULL; |
wc.hIcon = NULL; |
1672 |
wc.hIconSm = NULL; |
wc.hIconSm = NULL; |
1673 |
wc.hCursor = NULL; |
wc.hCursor = NULL; |
1674 |
RegisterClassEx(&wc); |
RegisterClassEx(&wc); |
1675 |
|
|
1676 |
MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT, |
MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT, |
1677 |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
1678 |
|
|
1679 |
/* display the tray icon */ |
/* display the tray icon */ |
1685 |
nid.uID = 1456; |
nid.uID = 1456; |
1686 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
1687 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
1688 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
lstrcpy(nid.szTip, TEXT("Xvid Video Decoder")); |
1689 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
1690 |
|
|
1691 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
1693 |
DestroyIcon(nid.hIcon); |
DestroyIcon(nid.hIcon); |
1694 |
Tray_Icon = 1; |
Tray_Icon = 1; |
1695 |
} |
} |
|
#endif |
|
1696 |
|
|
1697 |
LeaveCriticalSection(&m_mft_lock); |
LeaveCriticalSection(&m_mft_lock); |
1698 |
return hr; |
return hr; |
1913 |
EnterCriticalSection(&m_mft_lock); |
EnterCriticalSection(&m_mft_lock); |
1914 |
|
|
1915 |
HRESULT hr = S_OK; |
HRESULT hr = S_OK; |
1916 |
IMFMediaBuffer *pBuffer; |
IMFMediaBuffer *pBuffer = NULL; |
1917 |
|
|
1918 |
if (SUCCEEDED(hr)) { |
if (SUCCEEDED(hr)) { |
1919 |
hr = pSample->ConvertToContiguousBuffer(&pBuffer); |
hr = pSample->ConvertToContiguousBuffer(&pBuffer); |
2167 |
} |
} |
2168 |
|
|
2169 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
2170 |
HRESULT hr = OpenLib(); |
HRESULT hr2 = OpenLib(); |
2171 |
|
|
2172 |
if (FAILED(hr) || (m_hdll == NULL)) // Paranoid checks. |
if (FAILED(hr2) || (m_hdll == NULL)) // Paranoid checks. |
2173 |
hr = MF_E_INVALIDTYPE; |
hr = MF_E_INVALIDTYPE; |
2174 |
} |
} |
2175 |
|
|