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 |
{ |
{ |
310 |
/* constructor */ |
/* constructor */ |
311 |
|
|
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 |
|
|
352 |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
353 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
354 |
DPRINTF("dll load failed"); |
DPRINTF("dll load failed"); |
355 |
MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST); |
MessageBox(0, XVID_DLL_NAME TEXT(" not found"), TEXT("Error"), MB_TOPMOST); |
356 |
return E_FAIL; |
return E_FAIL; |
357 |
} |
} |
358 |
|
|
360 |
if (xvid_global_func == NULL) { |
if (xvid_global_func == NULL) { |
361 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
362 |
m_hdll = NULL; |
m_hdll = NULL; |
363 |
MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_global() not found"), TEXT("Error"), MB_TOPMOST); |
364 |
return E_FAIL; |
return E_FAIL; |
365 |
} |
} |
366 |
|
|
369 |
xvid_global_func = NULL; |
xvid_global_func = NULL; |
370 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
371 |
m_hdll = NULL; |
m_hdll = NULL; |
372 |
MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_decore() not found"), TEXT("Error"), MB_TOPMOST); |
373 |
return E_FAIL; |
return E_FAIL; |
374 |
} |
} |
375 |
|
|
379 |
xvid_decore_func = NULL; |
xvid_decore_func = NULL; |
380 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
381 |
m_hdll = NULL; |
m_hdll = NULL; |
382 |
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST); |
383 |
return E_FAIL; |
return E_FAIL; |
384 |
} |
} |
385 |
|
|
389 |
xvid_decore_func = NULL; |
xvid_decore_func = NULL; |
390 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
391 |
m_hdll = NULL; |
m_hdll = NULL; |
392 |
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST); |
393 |
return E_FAIL; |
return E_FAIL; |
394 |
} |
} |
395 |
|
|
492 |
{ |
{ |
493 |
DPRINTF("Destructor"); |
DPRINTF("Destructor"); |
494 |
|
|
|
#ifdef XVID_USE_TRAYICON |
|
495 |
if (Tray_Icon) { /* Destroy tray icon */ |
if (Tray_Icon) { /* Destroy tray icon */ |
496 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
497 |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
503 |
Shell_NotifyIcon(NIM_DELETE, &nid); |
Shell_NotifyIcon(NIM_DELETE, &nid); |
504 |
Tray_Icon = 0; |
Tray_Icon = 0; |
505 |
} |
} |
|
#endif |
|
506 |
|
|
507 |
/* Close xvidcore library */ |
/* Close xvidcore library */ |
508 |
CloseLib(); |
CloseLib(); |
929 |
{ |
{ |
930 |
DPRINTF("CompleteConnect"); |
DPRINTF("CompleteConnect"); |
931 |
|
|
932 |
#ifdef XVID_USE_TRAYICON |
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0)) |
|
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)) |
|
933 |
{ |
{ |
934 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
935 |
|
|
941 |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
942 |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
943 |
wc.lpszMenuName = NULL; |
wc.lpszMenuName = NULL; |
944 |
wc.lpszClassName = "XVID_MSG_WINDOW"; |
wc.lpszClassName = TEXT("XVID_MSG_WINDOW"); |
945 |
wc.hIcon = NULL; |
wc.hIcon = NULL; |
946 |
wc.hIconSm = NULL; |
wc.hIconSm = NULL; |
947 |
wc.hCursor = NULL; |
wc.hCursor = NULL; |
948 |
RegisterClassEx(&wc); |
RegisterClassEx(&wc); |
949 |
|
|
950 |
MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT, |
MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT, |
951 |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
952 |
|
|
953 |
/* display the tray icon */ |
/* display the tray icon */ |
959 |
nid.uID = 1456; |
nid.uID = 1456; |
960 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
961 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
962 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
lstrcpy(nid.szTip, TEXT("Xvid Video Decoder")); |
963 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
964 |
|
|
965 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
967 |
DestroyIcon(nid.hIcon); |
DestroyIcon(nid.hIcon); |
968 |
Tray_Icon = 1; |
Tray_Icon = 1; |
969 |
} |
} |
|
#endif |
|
970 |
|
|
971 |
return S_OK; |
return S_OK; |
972 |
} |
} |
1639 |
hr = OnSetOutputType(pType); |
hr = OnSetOutputType(pType); |
1640 |
} |
} |
1641 |
} |
} |
1642 |
#ifdef XVID_USE_TRAYICON |
|
1643 |
if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */ |
if (SUCCEEDED(hr) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0)) /* Create message passing window */ |
1644 |
{ |
{ |
1645 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
1646 |
|
|
1652 |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
wc.hInstance = (HINSTANCE) g_xvid_hInst; |
1653 |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH); |
1654 |
wc.lpszMenuName = NULL; |
wc.lpszMenuName = NULL; |
1655 |
wc.lpszClassName = "XVID_MSG_WINDOW"; |
wc.lpszClassName = TEXT("XVID_MSG_WINDOW"); |
1656 |
wc.hIcon = NULL; |
wc.hIcon = NULL; |
1657 |
wc.hIconSm = NULL; |
wc.hIconSm = NULL; |
1658 |
wc.hCursor = NULL; |
wc.hCursor = NULL; |
1659 |
RegisterClassEx(&wc); |
RegisterClassEx(&wc); |
1660 |
|
|
1661 |
MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT, |
MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT, |
1662 |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL); |
1663 |
|
|
1664 |
/* display the tray icon */ |
/* display the tray icon */ |
1670 |
nid.uID = 1456; |
nid.uID = 1456; |
1671 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
1672 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
1673 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
lstrcpy(nid.szTip, TEXT("Xvid Video Decoder")); |
1674 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
1675 |
|
|
1676 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
1678 |
DestroyIcon(nid.hIcon); |
DestroyIcon(nid.hIcon); |
1679 |
Tray_Icon = 1; |
Tray_Icon = 1; |
1680 |
} |
} |
|
#endif |
|
1681 |
|
|
1682 |
LeaveCriticalSection(&m_mft_lock); |
LeaveCriticalSection(&m_mft_lock); |
1683 |
return hr; |
return hr; |
1898 |
EnterCriticalSection(&m_mft_lock); |
EnterCriticalSection(&m_mft_lock); |
1899 |
|
|
1900 |
HRESULT hr = S_OK; |
HRESULT hr = S_OK; |
1901 |
IMFMediaBuffer *pBuffer; |
IMFMediaBuffer *pBuffer = NULL; |
1902 |
|
|
1903 |
if (SUCCEEDED(hr)) { |
if (SUCCEEDED(hr)) { |
1904 |
hr = pSample->ConvertToContiguousBuffer(&pBuffer); |
hr = pSample->ConvertToContiguousBuffer(&pBuffer); |
2152 |
} |
} |
2153 |
|
|
2154 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
2155 |
HRESULT hr = OpenLib(); |
HRESULT hr2 = OpenLib(); |
2156 |
|
|
2157 |
if (FAILED(hr) || (m_hdll == NULL)) // Paranoid checks. |
if (FAILED(hr2) || (m_hdll == NULL)) // Paranoid checks. |
2158 |
hr = MF_E_INVALIDTYPE; |
hr = MF_E_INVALIDTYPE; |
2159 |
} |
} |
2160 |
|
|