00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include <atlsync.h>
00028 #include <Tlhelp32.h>
00029 #include "MainFrm.h"
00030 #include "..\..\DSUtil\DSUtil.h"
00031
00033
00034 void CorrectComboListWidth(CComboBox& box, CFont* pWndFont)
00035 {
00036 int cnt = box.GetCount();
00037 if(cnt <= 0) return;
00038
00039 CDC* pDC = box.GetDC();
00040 pDC->SelectObject(pWndFont);
00041
00042 int maxw = box.GetDroppedWidth();
00043
00044 for(int i = 0; i < cnt; i++)
00045 {
00046 CString str;
00047 box.GetLBText(i, str);
00048 int w = pDC->GetTextExtent(str).cx + 22;
00049 if(maxw < w) maxw = w;
00050 }
00051
00052 box.ReleaseDC(pDC);
00053
00054 box.SetDroppedWidth(maxw);
00055 }
00056
00057 HICON LoadIcon(CString fn, bool fSmall)
00058 {
00059 if(fn.IsEmpty()) return(NULL);
00060
00061 CString ext = fn.Left(fn.Find(_T("://"))+1).TrimRight(':');
00062 if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
00063 ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
00064
00065 CSize size(fSmall?16:32,fSmall?16:32);
00066
00067 if(!ext.CompareNoCase(_T(".ifo")))
00068 {
00069 if(HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DVD), IMAGE_ICON, size.cx, size.cy, 0))
00070 return(hIcon);
00071 }
00072
00073 if(!ext.CompareNoCase(_T(".cda")))
00074 {
00075 if(HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIOCD), IMAGE_ICON, size.cx, size.cy, 0))
00076 return(hIcon);
00077 }
00078
00079 do
00080 {
00081 CRegKey key;
00082
00083 TCHAR buff[256];
00084 ULONG len;
00085
00086 if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ))
00087 {
00088 if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext, KEY_READ))
00089 break;
00090
00091 len = sizeof(buff);
00092 memset(buff, 0, len);
00093 if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (ext = buff).Trim().IsEmpty())
00094 break;
00095
00096 if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ))
00097 break;
00098 }
00099
00100 CString icon;
00101
00102 len = sizeof(buff);
00103 memset(buff, 0, len);
00104 if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (icon = buff).Trim().IsEmpty())
00105 break;
00106
00107 int i = icon.ReverseFind(',');
00108 if(i < 0) break;
00109
00110 int id = 0;
00111 if(_stscanf(icon.Mid(i+1), _T("%d"), &id) != 1)
00112 break;
00113
00114 icon = icon.Left(i);
00115
00116 HICON hIcon = NULL;
00117 UINT cnt = fSmall
00118 ? ExtractIconEx(icon, id, NULL, &hIcon, 1)
00119 : ExtractIconEx(icon, id, &hIcon, NULL, 1);
00120 if(hIcon) return hIcon;
00121 }
00122 while(0);
00123
00124 return((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_UNKNOWN), IMAGE_ICON, size.cx, size.cy, 0));
00125 }
00126
00127 bool LoadType(CString fn, CString& type)
00128 {
00129 CRegKey key;
00130
00131 TCHAR buff[256];
00132 ULONG len;
00133
00134 if(fn.IsEmpty()) return(NULL);
00135
00136 CString ext = fn.Left(fn.Find(_T("://"))+1).TrimRight(':');
00137 if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
00138 ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
00139
00140 if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext))
00141 return(false);
00142
00143 CString tmp = ext;
00144
00145 while(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, tmp))
00146 {
00147 len = sizeof(buff);
00148 memset(buff, 0, len);
00149 if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (tmp = buff).Trim().IsEmpty())
00150 return(false);
00151 }
00152
00153 type = tmp;
00154
00155 return(true);
00156 }
00157
00158 bool LoadResource(UINT resid, CStringA& str, LPCTSTR restype)
00159 {
00160 str.Empty();
00161 HRSRC hrsrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(resid), restype);
00162 if(!hrsrc) return(false);
00163 HGLOBAL hGlobal = LoadResource(AfxGetResourceHandle(), hrsrc);
00164 if(!hGlobal) return(false);
00165 DWORD size = SizeofResource(AfxGetResourceHandle(), hrsrc);
00166 if(!size) return(false);
00167 memcpy(str.GetBufferSetLength(size), LockResource(hGlobal), size);
00168 return(true);
00169 }
00170
00172
00173
00174 class CAboutDlg : public CDialog
00175 {
00176 public:
00177 CAboutDlg();
00178
00179
00180
00181 enum { IDD = IDD_ABOUTBOX };
00182
00183
00184
00185
00186 protected:
00187 virtual void DoDataExchange(CDataExchange* pDX);
00188
00189
00190
00191 protected:
00192
00193
00194
00195 DECLARE_MESSAGE_MAP()
00196 public:
00197 CString m_appname;
00198 virtual BOOL OnInitDialog()
00199 {
00200 #ifdef UNICODE
00201 UpdateData();
00202 m_appname += _T(" (unicode build)");
00203 UpdateData(FALSE);
00204 #endif
00205 return TRUE;
00206 }
00207 };
00208
00209 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD), m_appname(_T(""))
00210 {
00211
00212
00213 }
00214
00215 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00216 {
00217 CDialog::DoDataExchange(pDX);
00218
00219
00220 DDX_Text(pDX, IDC_STATIC1, m_appname);
00221 }
00222
00223 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00224
00225
00226
00227 END_MESSAGE_MAP()
00228
00230
00231
00232 BEGIN_MESSAGE_MAP(CMPlayerCApp, CWinApp)
00233
00234 ON_COMMAND(ID_HELP_ABOUT, OnAppAbout)
00235 ON_COMMAND(ID_FILE_EXIT, OnFileExit)
00236
00237 ON_COMMAND(ID_HELP_SHOWCOMMANDLINESWITCHES, OnHelpShowcommandlineswitches)
00238 END_MESSAGE_MAP()
00239
00241
00242
00243 CMPlayerCApp::CMPlayerCApp()
00244
00245 {
00246 }
00247
00248 void CMPlayerCApp::ShowCmdlnSwitches()
00249 {
00250 CString s;
00251
00252 if(m_s.nCLSwitches&CLSW_UNRECOGNIZEDSWITCH)
00253 {
00254 CList<CString> sl;
00255 for(int i = 0; i < __argc; i++) sl.AddTail(__targv[i]);
00256 s += "Unrecognized switch(es) found in command line string: \n\n" + Implode(sl, ' ') + "\n\n";
00257 }
00258
00259 s +=
00260 _T("Usage: mplayerc.exe \"pathname\" [switches]\n\n")
00261 _T("\"pathname\"\tThe main file or directory to be loaded. (wildcards allowed)\n")
00262 _T("/dub \"dubname\"\tLoad an additional audio file.\n")
00263 _T("/sub \"subname\"\tLoad an additional subtitle file.\n")
00264 _T("/filter \"filtername\"\tLoad DirectShow filters from a dynamic link library. (wildcards allowed)\n")
00265 _T("/dvd\t\tRun in dvd mode, \"pathname\" means the dvd folder (optional).\n")
00266 _T("/cd\t\tLoad all the tracks of an audio cd or (s)vcd, \"pathname\" means the drive path (optional).\n")
00267 _T("/open\t\tOpen the file, don't automatically start playing.\n")
00268 _T("/play\t\tStart playing the file as soon the player is launched.\n")
00269 _T("/close\t\tClose the player after playback (only works when used with /play).\n")
00270 _T("/shutdown\tShutdown the operating system after playback\n")
00271 _T("/fullscreen\tStart in full-screen mode.\n")
00272 _T("/minimized\tStart in minimized mode.\n")
00273 _T("/new\t\tUse a new instance of the player.\n")
00274 _T("/add\t\tAdd \"pathname\" to playlist, can be combined with /open and /play.\n")
00275 _T("/regvid\t\tRegister video formats\n")
00276 _T("/regaud\t\tRegister audio formats\n")
00277 _T("/unregvid\t\tUnregister video formats\n")
00278 _T("/unregaud\tUnregister audio formats\n")
00279 _T("/start ms\t\tStart playing at \"ms\" (= milliseconds)\n")
00280 _T("/fixedsize w,h\tSet fixed window size.\n")
00281 _T("/help /h /?\tShow help about command line switches. (this message box)\n");
00282
00283 AfxMessageBox(s);
00284 }
00285
00287
00288
00289 CMPlayerCApp theApp;
00290
00291 HWND g_hWnd = NULL;
00292
00293 bool CMPlayerCApp::StoreSettingsToIni()
00294 {
00295 CString ini = GetIniPath();
00296
00297
00298
00299
00300
00301
00302 if(m_pszRegistryKey) free((void*)m_pszRegistryKey);
00303 m_pszRegistryKey = NULL;
00304 if(m_pszProfileName) free((void*)m_pszProfileName);
00305 m_pszProfileName = _tcsdup(ini);
00306
00307 return(true);
00308 }
00309
00310 bool CMPlayerCApp::StoreSettingsToRegistry()
00311 {
00312 _tremove(GetIniPath());
00313
00314 if(m_pszRegistryKey) free((void*)m_pszRegistryKey);
00315 m_pszRegistryKey = NULL;
00316
00317 SetRegistryKey(_T("Gabest"));
00318
00319 return(true);
00320 }
00321
00322 CString CMPlayerCApp::GetIniPath()
00323 {
00324 CString path;
00325 GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
00326 path.ReleaseBuffer();
00327 path = path.Left(path.ReverseFind('.')+1) + _T("ini");
00328 return(path);
00329 }
00330
00331 bool CMPlayerCApp::IsIniValid()
00332 {
00333 CFileStatus fs;
00334 return CFileGetStatus(GetIniPath(), fs) && fs.m_size > 0;
00335 }
00336
00337 bool CMPlayerCApp::GetAppDataPath(CString& path)
00338 {
00339 path.Empty();
00340
00341 CRegKey key;
00342 if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ))
00343 {
00344 ULONG len = MAX_PATH;
00345 if(ERROR_SUCCESS == key.QueryStringValue(_T("AppData"), path.GetBuffer(MAX_PATH), &len))
00346 path.ReleaseBufferSetLength(len);
00347 }
00348
00349 if(path.IsEmpty())
00350 return(false);
00351
00352 CPath p;
00353 p.Combine(path, _T("Media Player Classic"));
00354 path = (LPCTSTR)p;
00355
00356 return(true);
00357 }
00358
00359 void CMPlayerCApp::PreProcessCommandLine()
00360 {
00361 m_cmdln.RemoveAll();
00362 for(int i = 1; i < __argc; i++)
00363 {
00364 CString str = CString(__targv[i]).Trim(_T(" \""));
00365
00366 if(str[0] != '/' && str[0] != '-' && str.Find(_T(":")) < 0)
00367 {
00368 LPTSTR p = NULL;
00369 CString str2;
00370 str2.ReleaseBuffer(GetFullPathName(str, MAX_PATH, str2.GetBuffer(MAX_PATH), &p));
00371 CFileStatus fs;
00372 if(!str2.IsEmpty() && CFileGetStatus(str2, fs)) str = str2;
00373 }
00374
00375 m_cmdln.AddTail(str);
00376 }
00377 }
00378
00379 void CMPlayerCApp::SendCommandLine(HWND hWnd)
00380 {
00381 if(m_cmdln.IsEmpty())
00382 return;
00383
00384 int bufflen = sizeof(DWORD);
00385
00386 POSITION pos = m_cmdln.GetHeadPosition();
00387 while(pos) bufflen += (m_cmdln.GetNext(pos).GetLength()+1)*sizeof(TCHAR);
00388
00389 CAutoVectorPtr<BYTE> buff;
00390 if(!buff.Allocate(bufflen))
00391 return;
00392
00393 BYTE* p = buff;
00394
00395 *(DWORD*)p = m_cmdln.GetCount();
00396 p += sizeof(DWORD);
00397
00398 pos = m_cmdln.GetHeadPosition();
00399 while(pos)
00400 {
00401 CString s = m_cmdln.GetNext(pos);
00402 int len = (s.GetLength()+1)*sizeof(TCHAR);
00403 memcpy(p, s, len);
00404 p += len;
00405 }
00406
00407 COPYDATASTRUCT cds;
00408 cds.dwData = 0x6ABE51;
00409 cds.cbData = bufflen;
00410 cds.lpData = (void*)(BYTE*)buff;
00411 SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
00412 }
00413
00415
00416
00417 #include "..\..\..\include\detours\detours.h"
00418
00419 DETOUR_TRAMPOLINE(BOOL WINAPI Real_IsDebuggerPresent(), IsDebuggerPresent);
00420 BOOL WINAPI Mine_IsDebuggerPresent()
00421 {
00422 TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
00423 return FALSE;
00424 }
00425
00426 DETOUR_TRAMPOLINE(LONG WINAPI Real_ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam), ChangeDisplaySettingsExA);
00427 DETOUR_TRAMPOLINE(LONG WINAPI Real_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam), ChangeDisplaySettingsExW);
00428 LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
00429 {
00430 if(dwFlags&CDS_VIDEOPARAMETERS)
00431 {
00432 VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
00433
00434 if(vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
00435 && (vp->dwFlags&VP_FLAGS_COPYPROTECT))
00436 {
00437 if(vp->dwCommand == VP_COMMAND_GET)
00438 {
00439 if((vp->dwTVStandard&VP_TV_STANDARD_WIN_VGA)
00440 && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA)
00441 {
00442 TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
00443 vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
00444 }
00445 }
00446 else if(vp->dwCommand == VP_COMMAND_SET)
00447 {
00448 TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
00449 return 0;
00450 }
00451 }
00452 }
00453
00454 return ret;
00455 }
00456 LONG WINAPI Mine_ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
00457 {
00458 return Mine_ChangeDisplaySettingsEx(
00459 Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
00460 dwFlags,
00461 lParam);
00462 }
00463 LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
00464 {
00465 return Mine_ChangeDisplaySettingsEx(
00466 Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
00467 dwFlags,
00468 lParam);
00469 }
00470
00471 DETOUR_TRAMPOLINE(HANDLE WINAPI Real_CreateFileA(LPCSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7), CreateFileA);
00472 DETOUR_TRAMPOLINE(HANDLE WINAPI Real_CreateFileW(LPCWSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7), CreateFileW);
00473 HANDLE WINAPI Mine_CreateFileA(LPCSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7)
00474 {
00475 CStringA fn(p1);
00476 fn.MakeLower();
00477 int i = fn.Find(".part");
00478 if(i > 0 && i == fn.GetLength() - 5)
00479 p3 |= FILE_SHARE_WRITE;
00480
00481 return Real_CreateFileA(p1, p2, p3, p4, p5, p6, p7);
00482 }
00483 HANDLE WINAPI Mine_CreateFileW(LPCWSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7)
00484 {
00485 CStringW fn(p1);
00486 fn.MakeLower();
00487 int i = fn.Find(L".part");
00488 if(i > 0 && i == fn.GetLength() - 5)
00489 p3 |= FILE_SHARE_WRITE;
00490
00491 return Real_CreateFileW(p1, p2, p3, p4, p5, p6, p7);
00492 }
00493
00494 DETOUR_TRAMPOLINE(MMRESULT WINAPI Real_mixerSetControlDetails(HMIXEROBJ hmxobj, LPMIXERCONTROLDETAILS pmxcd, DWORD fdwDetails), mixerSetControlDetails);
00495 MMRESULT WINAPI Mine_mixerSetControlDetails(HMIXEROBJ hmxobj, LPMIXERCONTROLDETAILS pmxcd, DWORD fdwDetails)
00496 {
00497 if(fdwDetails == (MIXER_OBJECTF_HMIXER|MIXER_SETCONTROLDETAILSF_VALUE))
00498 return MMSYSERR_NOERROR;
00499 return Real_mixerSetControlDetails(hmxobj, pmxcd, fdwDetails);
00500 }
00501
00502 BOOL CMPlayerCApp::InitInstance()
00503 {
00504 DetourFunctionWithTrampoline((PBYTE)Real_IsDebuggerPresent, (PBYTE)Mine_IsDebuggerPresent);
00505 DetourFunctionWithTrampoline((PBYTE)Real_ChangeDisplaySettingsExA, (PBYTE)Mine_ChangeDisplaySettingsExA);
00506 DetourFunctionWithTrampoline((PBYTE)Real_ChangeDisplaySettingsExW, (PBYTE)Mine_ChangeDisplaySettingsExW);
00507 DetourFunctionWithTrampoline((PBYTE)Real_CreateFileA, (PBYTE)Mine_CreateFileA);
00508 DetourFunctionWithTrampoline((PBYTE)Real_CreateFileW, (PBYTE)Mine_CreateFileW);
00509 DetourFunctionWithTrampoline((PBYTE)Real_mixerSetControlDetails, (PBYTE)Mine_mixerSetControlDetails);
00510 CFilterMapper2::Init();
00511
00512 HRESULT hr;
00513 if(FAILED(hr = OleInitialize(0)))
00514 {
00515 AfxMessageBox(_T("OleInitialize failed!"));
00516 return FALSE;
00517 }
00518
00519 WNDCLASS wndcls;
00520 memset(&wndcls, 0, sizeof(WNDCLASS));
00521 wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
00522 wndcls.lpfnWndProc = ::DefWindowProc;
00523 wndcls.hInstance = AfxGetInstanceHandle();
00524 wndcls.hIcon = LoadIcon(IDR_MAINFRAME);
00525 wndcls.hCursor = LoadCursor(IDC_ARROW);
00526 wndcls.hbrBackground = 0;
00527 wndcls.lpszMenuName = NULL;
00528 wndcls.lpszClassName = MPC_WND_CLASS_NAME;
00529
00530 if(!AfxRegisterClass(&wndcls))
00531 {
00532 AfxMessageBox(_T("MainFrm class registration failed!"));
00533 return FALSE;
00534 }
00535
00536 if(!AfxSocketInit(NULL))
00537 {
00538 AfxMessageBox(_T("AfxSocketInit failed!"));
00539 return FALSE;
00540 }
00541
00542 PreProcessCommandLine();
00543
00544 if(IsIniValid()) StoreSettingsToIni();
00545 else StoreSettingsToRegistry();
00546
00547 CString AppDataPath;
00548 if(GetAppDataPath(AppDataPath))
00549 CreateDirectory(AppDataPath, NULL);
00550
00551 m_s.ParseCommandLine(m_cmdln);
00552
00553 if(m_s.nCLSwitches&(CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH))
00554 {
00555 ShowCmdlnSwitches();
00556 return FALSE;
00557 }
00558
00559 if((m_s.nCLSwitches&CLSW_CLOSE) && m_s.slFiles.IsEmpty())
00560 {
00561 return FALSE;
00562 }
00563
00564 m_s.UpdateData(false);
00565
00566 if((m_s.nCLSwitches&CLSW_REGEXTVID) || (m_s.nCLSwitches&CLSW_UNREGEXTVID)
00567 || (m_s.nCLSwitches&CLSW_REGEXTAUD) || (m_s.nCLSwitches&CLSW_UNREGEXTAUD))
00568 {
00569 CMediaFormats& mf = m_s.Formats;
00570
00571 for(int i = 0; i < mf.GetCount(); i++)
00572 {
00573
00574 if(!mf[i].GetLabel().CompareNoCase(_T("Image file"))) continue;
00575
00576 bool fAudioOnly = mf[i].IsAudioOnly();
00577
00578 int j = 0;
00579 CString str = mf[i].GetExtsWithPeriod();
00580 for(CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j))
00581 {
00582 if((m_s.nCLSwitches&CLSW_REGEXTVID) && !fAudioOnly
00583 || (m_s.nCLSwitches&CLSW_REGEXTAUD) && fAudioOnly)
00584 CPPageFormats::RegisterExt(ext, true);
00585
00586 if((m_s.nCLSwitches&CLSW_UNREGEXTVID) && !fAudioOnly
00587 || (m_s.nCLSwitches&CLSW_UNREGEXTAUD) && fAudioOnly)
00588 CPPageFormats::RegisterExt(ext, false);
00589 }
00590 }
00591
00592 return FALSE;
00593 }
00594
00595 m_mutexOneInstance.Create(NULL, TRUE, MPC_WND_CLASS_NAME);
00596
00597 if(GetLastError() == ERROR_ALREADY_EXISTS
00598 && (!(m_s.fAllowMultipleInst || (m_s.nCLSwitches&CLSW_NEW) || m_cmdln.IsEmpty())
00599 || (m_s.nCLSwitches&CLSW_ADD)))
00600 {
00601 if(HWND hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL))
00602 {
00603 SetForegroundWindow(hWnd);
00604
00605 if(!(m_s.nCLSwitches&CLSW_MINIMIZED) && IsIconic(hWnd))
00606 ShowWindow(hWnd, SW_RESTORE);
00607
00608 SendCommandLine(hWnd);
00609
00610 return FALSE;
00611 }
00612 }
00613
00614 if(!__super::InitInstance())
00615 {
00616 AfxMessageBox(_T("InitInstance failed!"));
00617 return FALSE;
00618 }
00619
00620 CRegKey key;
00621 if(ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, _T("Software\\Gabest\\Media Player Classic")))
00622 {
00623 CString path;
00624 GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
00625 path.ReleaseBuffer();
00626 key.SetStringValue(_T("ExePath"), path);
00627 }
00628
00629 AfxEnableControlContainer();
00630
00631 CMainFrame* pFrame = new CMainFrame;
00632 m_pMainWnd = pFrame;
00633 pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE, NULL, NULL);
00634 pFrame->SetDefaultWindowRect();
00635 pFrame->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
00636 pFrame->DragAcceptFiles();
00637 pFrame->ShowWindow((m_s.nCLSwitches&CLSW_MINIMIZED)?SW_SHOWMINIMIZED:SW_SHOW);
00638 pFrame->UpdateWindow();
00639 pFrame->m_hAccelTable = m_s.hAccel;
00640
00641 m_s.WinLircClient.SetHWND(m_pMainWnd->m_hWnd);
00642 if(m_s.fWinLirc) m_s.WinLircClient.Connect(m_s.WinLircAddr);
00643 m_s.UIceClient.SetHWND(m_pMainWnd->m_hWnd);
00644 if(m_s.fUIce) m_s.UIceClient.Connect(m_s.UIceAddr);
00645
00646 SendCommandLine(m_pMainWnd->m_hWnd);
00647
00648 pFrame->SetFocus();
00649
00650 return TRUE;
00651 }
00652
00653 int CMPlayerCApp::ExitInstance()
00654 {
00655 m_s.UpdateData(true);
00656
00657 OleUninitialize();
00658
00659 return CWinApp::ExitInstance();
00660 }
00661
00663
00664
00665
00666 void CMPlayerCApp::OnAppAbout()
00667 {
00668 CAboutDlg aboutDlg;
00669 aboutDlg.DoModal();
00670 }
00671
00672 void CMPlayerCApp::OnFileExit()
00673 {
00674 OnAppExit();
00675 }
00676
00677
00678
00679 CRemoteCtrlClient::CRemoteCtrlClient()
00680 : m_pWnd(NULL)
00681 , m_nStatus(DISCONNECTED)
00682 {
00683 }
00684
00685 void CRemoteCtrlClient::SetHWND(HWND hWnd)
00686 {
00687 CAutoLock cAutoLock(&m_csLock);
00688
00689 m_pWnd = CWnd::FromHandle(hWnd);
00690 }
00691
00692 void CRemoteCtrlClient::Connect(CString addr)
00693 {
00694 CAutoLock cAutoLock(&m_csLock);
00695
00696 if(m_nStatus == CONNECTING && m_addr == addr)
00697 {
00698 TRACE(_T("CRemoteCtrlClient (Connect): already connecting to %s\n"), addr);
00699 return;
00700 }
00701
00702 if(m_nStatus == CONNECTED && m_addr == addr)
00703 {
00704 TRACE(_T("CRemoteCtrlClient (Connect): already connected to %s\n"), addr);
00705 return;
00706 }
00707
00708 m_nStatus = CONNECTING;
00709
00710 TRACE(_T("CRemoteCtrlClient (Connect): connecting to %s\n"), addr);
00711
00712 Close();
00713
00714 Create();
00715
00716 CString ip = addr.Left(addr.Find(':')+1).TrimRight(':');
00717 int port = _tcstol(addr.Mid(addr.Find(':')+1), NULL, 10);
00718
00719 __super::Connect(ip, port);
00720
00721 m_addr = addr;
00722 }
00723
00724 void CRemoteCtrlClient::OnConnect(int nErrorCode)
00725 {
00726 CAutoLock cAutoLock(&m_csLock);
00727
00728 m_nStatus = (nErrorCode == 0 ? CONNECTED : DISCONNECTED);
00729
00730 TRACE(_T("CRemoteCtrlClient (OnConnect): %d\n"), nErrorCode);
00731 }
00732
00733 void CRemoteCtrlClient::OnClose(int nErrorCode)
00734 {
00735 CAutoLock cAutoLock(&m_csLock);
00736
00737 if(m_hSocket != INVALID_SOCKET && m_nStatus == CONNECTED)
00738 {
00739 TRACE(_T("CRemoteCtrlClient (OnClose): connection lost\n"));
00740 }
00741
00742 m_nStatus = DISCONNECTED;
00743
00744 TRACE(_T("CRemoteCtrlClient (OnClose): %d\n"), nErrorCode);
00745 }
00746
00747 void CRemoteCtrlClient::OnReceive(int nErrorCode)
00748 {
00749 if(nErrorCode != 0 || !m_pWnd) return;
00750
00751 CStringA str;
00752 int ret = Receive(str.GetBuffer(256), 255, 0);
00753 if(ret <= 0) return;
00754 str.ReleaseBuffer(ret);
00755
00756 TRACE(_T("CRemoteCtrlClient (OnReceive): %s\n"), CString(str));
00757
00758 OnCommand(str);
00759
00760 __super::OnReceive(nErrorCode);
00761 }
00762
00763 void CRemoteCtrlClient::ExecuteCommand(CStringA cmd, int repcnt)
00764 {
00765 cmd.Trim();
00766 if(cmd.IsEmpty()) return;
00767 cmd.Replace(' ', '_');
00768
00769 AppSettings& s = AfxGetAppSettings();
00770
00771 POSITION pos = s.wmcmds.GetHeadPosition();
00772 while(pos)
00773 {
00774 wmcmd wc = s.wmcmds.GetNext(pos);
00775 CStringA name = CString(wc.name);
00776 name.Replace(' ', '_');
00777 if((repcnt == 0 && wc.rmrepcnt == 0 || wc.rmrepcnt > 0 && (repcnt%wc.rmrepcnt) == 0)
00778 && (!name.CompareNoCase(cmd) || !wc.rmcmd.CompareNoCase(cmd) || wc.cmd == (WORD)strtol(cmd, NULL, 10)))
00779 {
00780 CAutoLock cAutoLock(&m_csLock);
00781 TRACE(_T("CRemoteCtrlClient (calling command): %s\n"), wc.name);
00782 m_pWnd->SendMessage(WM_COMMAND, wc.cmd);
00783 break;
00784 }
00785 }
00786 }
00787
00788
00789
00790 CWinLircClient::CWinLircClient()
00791 {
00792 }
00793
00794 void CWinLircClient::OnCommand(CStringA str)
00795 {
00796 TRACE(_T("CWinLircClient (OnCommand): %s\n"), CString(str));
00797
00798 int i = 0, j = 0, repcnt = 0;
00799 for(CStringA token = str.Tokenize(" ", i);
00800 !token.IsEmpty();
00801 token = str.Tokenize(" ", i), j++)
00802 {
00803 if(j == 1)
00804 repcnt = strtol(token, NULL, 16);
00805 else if(j == 2)
00806 ExecuteCommand(token, repcnt);
00807 }
00808 }
00809
00810
00811
00812 CUIceClient::CUIceClient()
00813 {
00814 }
00815
00816 void CUIceClient::OnCommand(CStringA str)
00817 {
00818 TRACE(_T("CUIceClient (OnCommand): %s\n"), CString(str));
00819
00820 CStringA cmd;
00821 int i = 0, j = 0;
00822 for(CStringA token = str.Tokenize("|", i);
00823 !token.IsEmpty();
00824 token = str.Tokenize("|", i), j++)
00825 {
00826 if(j == 0)
00827 cmd = token;
00828 else if(j == 1)
00829 ExecuteCommand(cmd, strtol(token, NULL, 16));
00830 }
00831 }
00832
00833
00834
00835 CMPlayerCApp::Settings::Settings()
00836 : fInitialized(false)
00837 , MRU(0, _T("Recent File List"), _T("File%d"), 20)
00838 , MRUDub(0, _T("Recent Dub List"), _T("Dub%d"), 20)
00839 , hAccel(NULL)
00840 {
00841 #define ADDCMD(cmd) wmcmds.AddTail(wmcmd##cmd)
00842 ADDCMD((ID_FILE_OPENMEDIA, 'O', FVIRTKEY|FCONTROL|FNOINVERT, _T("Open File")));
00843 ADDCMD((ID_FILE_OPENDVD, 'D', FVIRTKEY|FCONTROL|FNOINVERT, _T("Open DVD")));
00844 ADDCMD((ID_FILE_OPENDEVICE, 'V', FVIRTKEY|FCONTROL|FNOINVERT, _T("Open Device")));
00845 ADDCMD((ID_FILE_SAVEAS, 0, FVIRTKEY|FNOINVERT, _T("Save As")));
00846 ADDCMD((ID_FILE_SAVE_IMAGE, 0, FVIRTKEY|FNOINVERT, _T("Save Image")));
00847 ADDCMD((ID_FILE_SAVE_IMAGE_AUTO, VK_F5, FVIRTKEY|FNOINVERT, _T("Save Image (auto)")));
00848 ADDCMD((ID_FILE_LOADSUBTITLE, 'L', FVIRTKEY|FCONTROL|FNOINVERT, _T("Load Subtitle")));
00849 ADDCMD((ID_FILE_SAVESUBTITLES, 'S', FVIRTKEY|FCONTROL|FNOINVERT, _T("Save Subtitle")));
00850 ADDCMD((ID_FILE_CLOSEPLAYLIST, 'C', FVIRTKEY|FCONTROL|FNOINVERT, _T("Close")));
00851 ADDCMD((ID_FILE_PROPERTIES, VK_F10, FVIRTKEY|FSHIFT|FNOINVERT, _T("Properties")));
00852 ADDCMD((ID_FILE_EXIT, 'X', FVIRTKEY|FALT|FNOINVERT, _T("Exit")));
00853 ADDCMD((ID_PLAY_PLAYPAUSE, VK_SPACE, FVIRTKEY|FNOINVERT, _T("Play/Pause"), APPCOMMAND_MEDIA_PLAY_PAUSE, wmcmd::LDOWN));
00854 ADDCMD((ID_PLAY_PLAY, 0, FVIRTKEY|FNOINVERT, _T("Play")));
00855 ADDCMD((ID_PLAY_PAUSE, 0, FVIRTKEY|FNOINVERT, _T("Pause")));
00856 ADDCMD((ID_PLAY_STOP, VK_OEM_PERIOD, FVIRTKEY|FNOINVERT, _T("Stop"), APPCOMMAND_MEDIA_STOP));
00857 ADDCMD((ID_PLAY_FRAMESTEP, VK_RIGHT, FVIRTKEY|FNOINVERT, _T("Framestep")));
00858 ADDCMD((ID_PLAY_FRAMESTEPCANCEL, VK_LEFT, FVIRTKEY|FNOINVERT, _T("Framestep back")));
00859 ADDCMD((ID_PLAY_GOTO, 'G', FVIRTKEY|FCONTROL|FNOINVERT, _T("Go To")));
00860 ADDCMD((ID_PLAY_INCRATE, VK_UP, FVIRTKEY|FCONTROL|FNOINVERT, _T("Increase Rate")));
00861 ADDCMD((ID_PLAY_DECRATE, VK_DOWN, FVIRTKEY|FCONTROL|FNOINVERT, _T("Decrease Rate")));
00862 ADDCMD((ID_PLAY_RESETRATE, 'R', FVIRTKEY|FCONTROL|FNOINVERT, _T("Reset Rate")));
00863 ADDCMD((ID_PLAY_INCAUDDELAY, VK_ADD, FVIRTKEY|FNOINVERT, _T("Audio Delay +10ms")));
00864 ADDCMD((ID_PLAY_DECAUDDELAY, VK_SUBTRACT, FVIRTKEY|FNOINVERT, _T("Audio Delay -10ms")));
00865 ADDCMD((ID_PLAY_SEEKFORWARDSMALL, 0, FVIRTKEY|FNOINVERT, _T("Jump Forward (small)")));
00866 ADDCMD((ID_PLAY_SEEKBACKWARDSMALL, 0, FVIRTKEY|FNOINVERT, _T("Jump Backward (small)")));
00867 ADDCMD((ID_PLAY_SEEKFORWARDMED, VK_RIGHT, FVIRTKEY|FCONTROL|FNOINVERT, _T("Jump Forward (medium)")));
00868 ADDCMD((ID_PLAY_SEEKBACKWARDMED, VK_LEFT, FVIRTKEY|FCONTROL|FNOINVERT, _T("Jump Backward (medium)")));
00869 ADDCMD((ID_PLAY_SEEKFORWARDLARGE, 0, FVIRTKEY|FNOINVERT, _T("Jump Forward (large)")));
00870 ADDCMD((ID_PLAY_SEEKBACKWARDLARGE, 0, FVIRTKEY|FNOINVERT, _T("Jump Backward (large)")));
00871 ADDCMD((ID_PLAY_SEEKKEYFORWARD, VK_RIGHT, FVIRTKEY|FSHIFT|FNOINVERT, _T("Jump Forward (keyframe)")));
00872 ADDCMD((ID_PLAY_SEEKKEYBACKWARD, VK_LEFT, FVIRTKEY|FSHIFT|FNOINVERT, _T("Jump Backward (keyframe)")));
00873 ADDCMD((ID_NAVIGATE_SKIPFORWARD, VK_NEXT, FVIRTKEY|FNOINVERT, _T("Next"), APPCOMMAND_MEDIA_NEXTTRACK, wmcmd::X2DOWN));
00874 ADDCMD((ID_NAVIGATE_SKIPBACK, VK_PRIOR, FVIRTKEY|FNOINVERT, _T("Previous"), APPCOMMAND_MEDIA_PREVIOUSTRACK, wmcmd::X1DOWN));
00875 ADDCMD((ID_NAVIGATE_SKIPFORWARDPLITEM, VK_NEXT, FVIRTKEY|FCONTROL|FNOINVERT, _T("Next Playlist Item")));
00876 ADDCMD((ID_NAVIGATE_SKIPBACKPLITEM, VK_PRIOR, FVIRTKEY|FCONTROL|FNOINVERT, _T("Previous Playlist Item")));
00877 ADDCMD((ID_VIEW_CAPTIONMENU, '0', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Caption&Menu")));
00878 ADDCMD((ID_VIEW_SEEKER, '1', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Seeker")));
00879 ADDCMD((ID_VIEW_CONTROLS, '2', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Controls")));
00880 ADDCMD((ID_VIEW_INFORMATION, '3', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Information")));
00881 ADDCMD((ID_VIEW_STATISTICS, '4', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Statistics")));
00882 ADDCMD((ID_VIEW_STATUS, '5', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Status")));
00883 ADDCMD((ID_VIEW_SUBRESYNC, '6', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Subresync Bar")));
00884 ADDCMD((ID_VIEW_PLAYLIST, '7', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Playlist Bar")));
00885 ADDCMD((ID_VIEW_CAPTURE, '8', FVIRTKEY|FCONTROL|FNOINVERT, _T("Toggle Capture Bar")));
00886 ADDCMD((ID_VIEW_PRESETS_MINIMAL, '0', FVIRTKEY|FSHIFT|FCONTROL|FNOINVERT, _T("View Minimal")));
00887 ADDCMD((ID_VIEW_PRESETS_COMPACT, '1', FVIRTKEY|FSHIFT|FCONTROL|FNOINVERT, _T("View Compact")));
00888 ADDCMD((ID_VIEW_PRESETS_NORMAL, '2', FVIRTKEY|FSHIFT|FCONTROL|FNOINVERT, _T("View Normal")));
00889 ADDCMD((ID_VIEW_FULLSCREEN, VK_RETURN, FVIRTKEY|FALT|FNOINVERT, _T("Fullscreen"), 0, wmcmd::LDBLCLK));
00890 ADDCMD((ID_VIEW_FULLSCREEN_SECONDARY, VK_RETURN, FVIRTKEY|FCONTROL|FNOINVERT, _T("Fullscreen (w/o res.change)")));
00891 ADDCMD((ID_VIEW_ZOOM_50, '1', FVIRTKEY|FALT|FNOINVERT, _T("Zoom 50%")));
00892 ADDCMD((ID_VIEW_ZOOM_100, '2', FVIRTKEY|FALT|FNOINVERT, _T("Zoom 100%")));
00893 ADDCMD((ID_VIEW_ZOOM_200, '3', FVIRTKEY|FALT|FNOINVERT, _T("Zoom 200%")));
00894 ADDCMD((ID_VIEW_VF_HALF, 0, FVIRTKEY|FNOINVERT, _T("VidFrm Half")));
00895 ADDCMD((ID_VIEW_VF_NORMAL, 0, FVIRTKEY|FNOINVERT, _T("VidFrm Normal")));
00896 ADDCMD((ID_VIEW_VF_DOUBLE, 0, FVIRTKEY|FNOINVERT, _T("VidFrm Double")));
00897 ADDCMD((ID_VIEW_VF_STRETCH, 0, FVIRTKEY|FNOINVERT, _T("VidFrm Stretch")));
00898 ADDCMD((ID_VIEW_VF_FROMINSIDE, 0, FVIRTKEY|FNOINVERT, _T("VidFrm Inside")));
00899 ADDCMD((ID_VIEW_VF_FROMOUTSIDE, 0, FVIRTKEY|FNOINVERT, _T("VidFrm Outside")));
00900 ADDCMD((ID_ONTOP_ALWAYS, 'T', FVIRTKEY|FCONTROL|FNOINVERT, _T("Always On Top")));
00901 ADDCMD((ID_VIEW_RESET, VK_NUMPAD5, FVIRTKEY|FNOINVERT, _T("PnS Reset")));
00902 ADDCMD((ID_VIEW_INCSIZE, VK_NUMPAD9, FVIRTKEY|FNOINVERT, _T("PnS Inc Size")));
00903 ADDCMD((ID_VIEW_INCWIDTH, VK_NUMPAD6, FVIRTKEY|FNOINVERT, _T("PnS Inc Width")));
00904 ADDCMD((ID_VIEW_INCHEIGHT, VK_NUMPAD8, FVIRTKEY|FNOINVERT, _T("PnS Inc Height")));
00905 ADDCMD((ID_VIEW_DECSIZE, VK_NUMPAD1, FVIRTKEY|FNOINVERT, _T("PnS Dec Size")));
00906 ADDCMD((ID_VIEW_DECWIDTH, VK_NUMPAD4, FVIRTKEY|FNOINVERT, _T("PnS Dec Width")));
00907 ADDCMD((ID_VIEW_DECHEIGHT, VK_NUMPAD2, FVIRTKEY|FNOINVERT, _T("PnS Dec Height")));
00908 ADDCMD((ID_PANSCAN_CENTER, VK_NUMPAD5, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Center")));
00909 ADDCMD((ID_PANSCAN_MOVELEFT, VK_NUMPAD4, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Left")));
00910 ADDCMD((ID_PANSCAN_MOVERIGHT, VK_NUMPAD6, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Right")));
00911 ADDCMD((ID_PANSCAN_MOVEUP, VK_NUMPAD8, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Up")));
00912 ADDCMD((ID_PANSCAN_MOVEDOWN, VK_NUMPAD2, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Down")));
00913 ADDCMD((ID_PANSCAN_MOVEUPLEFT, VK_NUMPAD7, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Up/Left")));
00914 ADDCMD((ID_PANSCAN_MOVEUPRIGHT, VK_NUMPAD9, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Up/Right")));
00915 ADDCMD((ID_PANSCAN_MOVEDOWNLEFT, VK_NUMPAD1, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Down/Left")));
00916 ADDCMD((ID_PANSCAN_MOVEDOWNRIGHT, VK_NUMPAD3, FVIRTKEY|FCONTROL|FNOINVERT, _T("PnS Down/Right")));
00917 ADDCMD((ID_PANSCAN_ROTATEXP, VK_NUMPAD8, FVIRTKEY|FALT|FNOINVERT, _T("PnS Rotate X+")));
00918 ADDCMD((ID_PANSCAN_ROTATEXM, VK_NUMPAD2, FVIRTKEY|FALT|FNOINVERT, _T("PnS Rotate X-")));
00919 ADDCMD((ID_PANSCAN_ROTATEYP, VK_NUMPAD4, FVIRTKEY|FALT|FNOINVERT, _T("PnS Rotate Y+")));
00920 ADDCMD((ID_PANSCAN_ROTATEYM, VK_NUMPAD6, FVIRTKEY|FALT|FNOINVERT, _T("PnS Rotate Y-")));
00921 ADDCMD((ID_PANSCAN_ROTATEZP, VK_NUMPAD1, FVIRTKEY|FALT|FNOINVERT, _T("PnS Rotate Z+")));
00922 ADDCMD((ID_PANSCAN_ROTATEZM, VK_NUMPAD3, FVIRTKEY|FALT|FNOINVERT, _T("PnS Rotate Z-")));
00923 ADDCMD((ID_VOLUME_UP, VK_UP, FVIRTKEY|FNOINVERT, _T("Volume Up"), APPCOMMAND_VOLUME_UP, wmcmd::WUP));
00924 ADDCMD((ID_VOLUME_DOWN, VK_DOWN, FVIRTKEY|FNOINVERT, _T("Volume Down"), APPCOMMAND_VOLUME_DOWN, wmcmd::WDOWN));
00925 ADDCMD((ID_VOLUME_MUTE, 'M', FVIRTKEY|FCONTROL|FNOINVERT, _T("Volume Mute"), APPCOMMAND_VOLUME_MUTE));
00926 ADDCMD((ID_NAVIGATE_TITLEMENU, 0, FVIRTKEY|FNOINVERT, _T("DVD Title Menu")));
00927 ADDCMD((ID_NAVIGATE_ROOTMENU, 0, FVIRTKEY|FNOINVERT, _T("DVD Root Menu")));
00928 ADDCMD((ID_NAVIGATE_SUBPICTUREMENU, 0, FVIRTKEY|FNOINVERT, _T("DVD Subtitle Menu")));
00929 ADDCMD((ID_NAVIGATE_AUDIOMENU, 0, FVIRTKEY|FNOINVERT, _T("DVD Audio Menu")));
00930 ADDCMD((ID_NAVIGATE_ANGLEMENU, 0, FVIRTKEY|FNOINVERT, _T("DVD Angle Menu")));
00931 ADDCMD((ID_NAVIGATE_CHAPTERMENU, 0, FVIRTKEY|FNOINVERT, _T("DVD Chapter Menu")));
00932 ADDCMD((ID_NAVIGATE_MENU_LEFT, 0, FVIRTKEY|FNOINVERT, _T("DVD Menu Left")));
00933 ADDCMD((ID_NAVIGATE_MENU_RIGHT, 0, FVIRTKEY|FNOINVERT, _T("DVD Menu Right")));
00934 ADDCMD((ID_NAVIGATE_MENU_UP, 0, FVIRTKEY|FNOINVERT, _T("DVD Menu Up")));
00935 ADDCMD((ID_NAVIGATE_MENU_DOWN, 0, FVIRTKEY|FNOINVERT, _T("DVD Menu Down")));
00936 ADDCMD((ID_NAVIGATE_MENU_ACTIVATE, 0, FVIRTKEY|FNOINVERT, _T("DVD Menu Activate")));
00937 ADDCMD((ID_NAVIGATE_MENU_BACK, 0, FVIRTKEY|FNOINVERT, _T("DVD Menu Back")));
00938 ADDCMD((ID_NAVIGATE_MENU_LEAVE, 0, FVIRTKEY|FNOINVERT, _T("DVD Menu Leave")));
00939 ADDCMD((ID_BOSS, 'B', FVIRTKEY|FNOINVERT, _T("Boss key")));
00940 ADDCMD((ID_MENU_PLAYER_SHORT, 0, FVIRTKEY|FNOINVERT, _T("Player Menu (short)"), 0, wmcmd::RUP));
00941 ADDCMD((ID_MENU_PLAYER_LONG, 0, FVIRTKEY|FNOINVERT, _T("Player Menu (long)")));
00942 ADDCMD((ID_MENU_FILTERS, 0, FVIRTKEY|FNOINVERT, _T("Filters Menu")));
00943 ADDCMD((ID_VIEW_OPTIONS, 'O', FVIRTKEY|FNOINVERT, _T("Options")));
00944 ADDCMD((ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY|FNOINVERT, _T("Next Audio")));
00945 ADDCMD((ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY|FSHIFT|FNOINVERT, _T("Prev Audio")));
00946 ADDCMD((ID_STREAM_SUB_NEXT, 'S', FVIRTKEY|FNOINVERT, _T("Next Subtitle")));
00947 ADDCMD((ID_STREAM_SUB_PREV, 'S', FVIRTKEY|FSHIFT|FNOINVERT, _T("Prev Subtitle")));
00948 ADDCMD((ID_STREAM_SUB_ONOFF, 'W', FVIRTKEY|FNOINVERT, _T("On/Off Subtitle")));
00949 ADDCMD((ID_SUBTITLES_SUBITEM_START+2, 0, FVIRTKEY|FNOINVERT, _T("Reload Subtitles")));
00950 ADDCMD((ID_OGM_AUDIO_NEXT, 0, FVIRTKEY|FNOINVERT, _T("Next Audio (OGM)")));
00951 ADDCMD((ID_OGM_AUDIO_PREV, 0, FVIRTKEY|FNOINVERT, _T("Prev Audio (OGM)")));
00952 ADDCMD((ID_OGM_SUB_NEXT, 0, FVIRTKEY|FNOINVERT, _T("Next Subtitle (OGM)")));
00953 ADDCMD((ID_OGM_SUB_PREV, 0, FVIRTKEY|FNOINVERT, _T("Prev Subtitle (OGM)")));
00954 ADDCMD((ID_DVD_ANGLE_NEXT, 0, FVIRTKEY|FNOINVERT, _T("Next Angle (DVD)")));
00955 ADDCMD((ID_DVD_ANGLE_PREV, 0, FVIRTKEY|FNOINVERT, _T("Prev Angle (DVD)")));
00956 ADDCMD((ID_DVD_AUDIO_NEXT, 0, FVIRTKEY|FNOINVERT, _T("Next Audio (DVD)")));
00957 ADDCMD((ID_DVD_AUDIO_PREV, 0, FVIRTKEY|FNOINVERT, _T("Prev Audio (DVD)")));
00958 ADDCMD((ID_DVD_SUB_NEXT, 0, FVIRTKEY|FNOINVERT, _T("Next Subtitle (DVD)")));
00959 ADDCMD((ID_DVD_SUB_PREV, 0, FVIRTKEY|FNOINVERT, _T("Prev Subtitle (DVD)")));
00960 ADDCMD((ID_DVD_SUB_ONOFF, 0, FVIRTKEY|FNOINVERT, _T("On/Off Subtitle (DVD)")));
00961 #undef ADDCMD
00962 }
00963
00964 CMPlayerCApp::Settings::~Settings()
00965 {
00966 if(hAccel)
00967 DestroyAcceleratorTable(hAccel);
00968 }
00969
00970 void CMPlayerCApp::Settings::UpdateData(bool fSave)
00971 {
00972 CWinApp* pApp = AfxGetApp();
00973 ASSERT(pApp);
00974
00975 UINT len;
00976 BYTE* ptr = NULL;
00977
00978 if(fSave)
00979 {
00980 if(!fInitialized) return;
00981
00982 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_HIDECAPTIONMENU), fHideCaptionMenu);
00983 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_CONTROLSTATE), nCS);
00984 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DEFAULTVIDEOFRAME), iDefaultVideoSize);
00985 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_KEEPASPECTRATIO), fKeepAspectRatio);
00986 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_COMPMONDESKARDIFF), fCompMonDeskARDiff);
00987 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VOLUME), nVolume);
00988 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_BALANCE), nBalance);
00989 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MUTE), fMute);
00990 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOOPNUM), nLoops);
00991 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOOP), fLoopForever);
00992 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REWIND), fRewind);
00993 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ZOOM), iZoomLevel);
00994 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MULTIINST), fAllowMultipleInst);
00995 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_TITLEBARTEXTSTYLE), iTitleBarTextStyle);
00996 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ONTOP), iOnTop);
00997 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_TRAYICON), fTrayIcon);
00998 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOZOOM), fRememberZoomLevel);
00999 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FULLSCREENCTRLS), fShowBarsWhenFullScreen);
01000 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FULLSCREENCTRLSTIMEOUT), nShowBarsWhenFullScreenTimeOut);
01001 pApp->WriteProfileBinary(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FULLSCREENRES), (BYTE*)&dmFullscreenRes, sizeof(dmFullscreenRes));
01002 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_EXITFULLSCREENATTHEEND), fExitFullScreenAtTheEnd);
01003 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REMEMBERWINDOWPOS), fRememberWindowPos);
01004 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REMEMBERWINDOWSIZE), fRememberWindowSize);
01005 pApp->WriteProfileBinary(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LASTWINDOWRECT), (BYTE*)&rcLastWindowPos, sizeof(rcLastWindowPos));
01006 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LASTWINDOWTYPE), lastWindowType);
01007 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ASPECTRATIO_X), AspectRatio.cx);
01008 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ASPECTRATIO_Y), AspectRatio.cy);
01009 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_KEEPHISTORY), fKeepHistory);
01010 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DSVIDEORENDERERTYPE), iDSVideoRendererType);
01011 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_RMVIDEORENDERERTYPE), iRMVideoRendererType);
01012 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_QTVIDEORENDERERTYPE), iQTVideoRendererType);
01013 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_APSURACEFUSAGE), iAPSurfaceUsage);
01014 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMRSYNCFIX), fVMRSyncFix);
01015 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DX9_RESIZER), iDX9Resizer);
01016 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIORENDERERTYPE), CString(AudioRendererDisplayName));
01017 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADAUDIO), fAutoloadAudio);
01018 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADSUBTITLES), fAutoloadSubtitles);
01019 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEWORKERTHREADFOROPENING), fEnableWorkerThreadForOpening);
01020 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REPORTFAILEDPINS), fReportFailedPins);
01021 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DVDPATH), sDVDPath);
01022 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_USEDVDPATH), fUseDVDPath);
01023 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MENULANG), idMenuLang);
01024 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIOLANG), idAudioLang);
01025 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SUBTITLESLANG), idSubtitlesLang);
01026 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOSPEAKERCONF), fAutoSpeakerConf);
01027 CString style;
01028 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPLOGFONT), style <<= subdefstyle);
01029 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPOVERRIDEPLACEMENT), fOverridePlacement);
01030 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPHORPOS), nHorPos);
01031 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPVERPOS), nVerPos);
01032 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPCSIZE), nSPCSize);
01033 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPCMAXRES), nSPCMaxRes);
01034 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_POW2TEX), fSPCPow2Tex);
01035 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOSWITCHER), fEnableAudioSwitcher);
01036 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOTIMESHIFT), fAudioTimeShift);
01037 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIOTIMESHIFT), tAudioTimeShift);
01038 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DOWNSAMPLETO441), fDownSampleTo441);
01039 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_CUSTOMCHANNELMAPPING), fCustomChannelMapping);
01040 pApp->WriteProfileBinary(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPEAKERTOCHANNELMAPPING), (BYTE*)pSpeakerToChannelMap, sizeof(pSpeakerToChannelMap));
01041
01042 {
01043 for(int i = 0; ; i++)
01044 {
01045 CString key;
01046 key.Format(_T("%s\\%04d"), ResStr(IDS_R_FILTERS), i);
01047 int j = pApp->GetProfileInt(key, _T("Enabled"), -1);
01048 pApp->WriteProfileString(key, NULL, NULL);
01049 if(j < 0) break;
01050 }
01051 pApp->WriteProfileString(ResStr(IDS_R_FILTERS), NULL, NULL);
01052
01053 POSITION pos = filters.GetHeadPosition();
01054 for(int i = 0; pos; i++)
01055 {
01056 Filter* f = filters.GetNext(pos);
01057
01058 if(f->fTemporary)
01059 continue;
01060
01061 CString key;
01062 key.Format(_T("%s\\%04d"), ResStr(IDS_R_FILTERS), i);
01063
01064 pApp->WriteProfileInt(key, _T("SourceType"), (int)f->type);
01065 pApp->WriteProfileInt(key, _T("Enabled"), (int)!f->fDisabled);
01066 if(f->type == Filter::REGISTERED)
01067 {
01068 pApp->WriteProfileString(key, _T("DisplayName"), CString(f->dispname));
01069 pApp->WriteProfileString(key, _T("Name"), f->name);
01070 }
01071 else if(f->type == Filter::EXTERNAL)
01072 {
01073 pApp->WriteProfileString(key, _T("Path"), f->path);
01074 pApp->WriteProfileString(key, _T("Name"), f->name);
01075 pApp->WriteProfileString(key, _T("CLSID"), CStringFromGUID(f->clsid));
01076 }
01077 POSITION pos2 = f->backup.GetHeadPosition();
01078 for(int i = 0; pos2; i++)
01079 {
01080 CString val;
01081 val.Format(_T("org%04d"), i);
01082 pApp->WriteProfileString(key, val, CStringFromGUID(f->backup.GetNext(pos2)));
01083 }
01084 pos2 = f->guids.GetHeadPosition();
01085 for(int i = 0; pos2; i++)
01086 {
01087 CString val;
01088 val.Format(_T("mod%04d"), i);
01089 pApp->WriteProfileString(key, val, CStringFromGUID(f->guids.GetNext(pos2)));
01090 }
01091 pApp->WriteProfileInt(key, _T("LoadType"), f->iLoadType);
01092 pApp->WriteProfileInt(key, _T("Merit"), f->dwMerit);
01093 }
01094 }
01095
01096 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_INTREALMEDIA), fIntRealMedia);
01097
01098
01099 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REALMEDIAFPS), *((DWORD*)&RealMediaQuickTimeFPS));
01100
01101 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS) + _T("\\") + ResStr(IDS_RS_PNSPRESETS), NULL, NULL);
01102 for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++)
01103 {
01104 CString str;
01105 str.Format(_T("Preset%d"), i);
01106 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS) + _T("\\") + ResStr(IDS_RS_PNSPRESETS), str, m_pnspresets[i]);
01107 }
01108
01109 pApp->WriteProfileString(ResStr(IDS_R_COMMANDS), NULL, NULL);
01110 POSITION pos = wmcmds.GetHeadPosition();
01111 for(int i = 0; pos; )
01112 {
01113 wmcmd& wc = wmcmds.GetNext(pos);
01114 if(wc.IsModified())
01115 {
01116 CString str;
01117 str.Format(_T("CommandMod%d"), i);
01118 CString str2;
01119 str2.Format(_T("%d %x %x %s %d %d %d"),
01120 wc.cmd, wc.fVirt, wc.key,
01121 _T("\"") + CString(wc.rmcmd) + _T("\""), wc.rmrepcnt,
01122 wc.mouse, wc.appcmd);
01123 pApp->WriteProfileString(ResStr(IDS_R_COMMANDS), str, str2);
01124 i++;
01125 }
01126 }
01127
01128 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WINLIRC), fWinLirc);
01129 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WINLIRCADDR), WinLircAddr);
01130 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_UICE), fUIce);
01131 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_UICEADDR), UIceAddr);
01132
01133 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DISABLEXPTOOLBARS), fDisabeXPToolbars);
01134 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_USEWMASFREADER), fUseWMASFReader);
01135 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_JUMPDISTS), nJumpDistS);
01136 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_JUMPDISTM), nJumpDistM);
01137 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_JUMPDISTL), nJumpDistL);
01138 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FREEWINDOWRESIZING), fFreeWindowResizing);
01139 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_NOTIFYMSN), fNotifyMSN);
01140
01141 Formats.UpdateData(true);
01142
01143 pApp->WriteProfileInt(ResStr(IDS_R_INTERNAL_FILTERS), ResStr(IDS_RS_SRCFILTERS), SrcFilters|~(SRC_LAST-1));
01144 pApp->WriteProfileInt(ResStr(IDS_R_INTERNAL_FILTERS), ResStr(IDS_RS_TRAFILTERS), TraFilters|~(TRA_LAST-1));
01145
01146 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOGOFILE), logofn);
01147 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOGOID), logoid);
01148 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOGOEXT), logoext);
01149
01150 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGDI), mpegdi);
01151 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGBRIGHT), (int)(mpegbright+255));
01152 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGCONT), (int)(mpegcont*100));
01153 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGHUE), (int)(mpeghue+180));
01154 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGSAT), (int)(mpegsat*100));
01155 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGFORCEDSUBS), mpegforcedsubs);
01156 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGPLANARYUV), mpegplanaryuv);
01157
01158 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPASF), mpasf);
01159 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPANORMALIZE), mpanormalize);
01160 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AC3SC), ac3sc);
01161 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AC3DRC), ac3drc);
01162 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DTSSC), dtssc);
01163 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DTSDRC), dtsdrc);
01164 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AACSC), aacsc);
01165 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPABOOST), (int)mpaboost);
01166
01167 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_HIDECDROMSSUBMENU), fHideCDROMsSubMenu);
01168
01169 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_PRIORITY), priority);
01170 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LAUNCHFULLSCREEN), launchfullscreen);
01171
01172 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEWEBSERVER), fEnableWebServer);
01173 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERPORT), nWebServerPort);
01174 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERPRINTDEBUGINFO), fWebServerPrintDebugInfo);
01175 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERUSECOMPRESSION), fWebServerUseCompression);
01176 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERLOCALHOSTONLY), fWebServerLocalhostOnly);
01177 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBROOT), WebRoot);
01178 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBDEFINDEX), WebDefIndex);
01179 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERCGI), WebServerCGI);
01180
01181 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SNAPSHOTPATH), SnapShotPath);
01182 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SNAPSHOTEXT), SnapShotExt);
01183
01184 pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ISDB), ISDb);
01185
01186 if(pApp->m_pszRegistryKey)
01187 {
01188
01189 pApp->WriteProfileInt(_T(""), _T(""), pApp->GetProfileInt(_T(""), _T(""), 0)?0:1);
01190 }
01191 }
01192 else
01193 {
01194 if(fInitialized) return;
01195
01196 if(pApp->m_pszRegistryKey)
01197 {
01198 CRegKey appkey, settingskey;
01199 appkey.Attach(pApp->GetAppRegistryKey());
01200 settingskey.Attach(pApp->GetSectionKey(ResStr(IDS_R_INTERNAL_FILTERS)));
01201 if(appkey && settingskey)
01202 {
01203 ULONGLONG ftapp = 0, ftsettings = 0;
01204 RegQueryInfoKey(appkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, (FILETIME*)&ftapp);
01205 RegQueryInfoKey(settingskey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, (FILETIME*)&ftsettings);
01206 if(ftapp < ftsettings)
01207 {
01208 pApp->WriteProfileInt(ResStr(IDS_R_INTERNAL_FILTERS), ResStr(IDS_RS_SRCFILTERS), ~0);
01209 pApp->WriteProfileInt(ResStr(IDS_R_INTERNAL_FILTERS), ResStr(IDS_RS_TRAFILTERS), ~0^TRA_MPEG1);
01210 }
01211 }
01212 }
01213
01214 OSVERSIONINFO vi;
01215 vi.dwOSVersionInfoSize = sizeof(vi);
01216 GetVersionEx(&vi);
01217 fXpOrBetter = (vi.dwMajorVersion >= 5 && vi.dwMinorVersion >= 1 || vi.dwMajorVersion >= 6);
01218
01219 iDXVer = 0;
01220 CRegKey dxver;
01221 if(ERROR_SUCCESS == dxver.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), KEY_READ))
01222 {
01223 CString str;
01224 ULONG len = 64;
01225 if(ERROR_SUCCESS == dxver.QueryStringValue(_T("Version"), str.GetBuffer(len), &len))
01226 {
01227 str.ReleaseBuffer(len);
01228 int ver[4];
01229 _stscanf(str, _T("%d.%d.%d.%d"), ver+0, ver+1, ver+2, ver+3);
01230 iDXVer = ver[1];
01231 }
01232 }
01233
01234 fHideCaptionMenu = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_HIDECAPTIONMENU), 0);
01235 nCS = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_CONTROLSTATE), CS_SEEKBAR|CS_TOOLBAR|CS_INFOBAR|CS_STATUSBAR);
01236 iDefaultVideoSize = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DEFAULTVIDEOFRAME), DVS_FROMINSIDE);
01237 fKeepAspectRatio = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_KEEPASPECTRATIO), TRUE);
01238 fCompMonDeskARDiff = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_COMPMONDESKARDIFF), FALSE);
01239 nVolume = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VOLUME), 100);
01240 nBalance = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_BALANCE), 0);
01241 fMute = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MUTE), 0);
01242 nLoops = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOOPNUM), 1);
01243 fLoopForever = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOOP), 1);
01244 fRewind = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REWIND), TRUE);
01245 iZoomLevel = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ZOOM), 1);
01246 iDSVideoRendererType = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DSVIDEORENDERERTYPE), VIDRNDT_DS_DEFAULT);
01247 iRMVideoRendererType = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_RMVIDEORENDERERTYPE), VIDRNDT_RM_DEFAULT);
01248 iQTVideoRendererType = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_QTVIDEORENDERERTYPE), VIDRNDT_QT_DEFAULT);
01249 iAPSurfaceUsage = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_APSURACEFUSAGE), VIDRNDT_AP_TEXTURE2D);
01250 fVMRSyncFix = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMRSYNCFIX), TRUE);
01251 iDX9Resizer = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DX9_RESIZER), 1);
01252 AudioRendererDisplayName = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIORENDERERTYPE), _T(""));
01253 fAutoloadAudio = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADAUDIO), TRUE);
01254 fAutoloadSubtitles = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADSUBTITLES), TRUE);
01255 fEnableWorkerThreadForOpening = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEWORKERTHREADFOROPENING), TRUE);
01256 fReportFailedPins = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REPORTFAILEDPINS), TRUE);
01257 fAllowMultipleInst = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MULTIINST), 0);
01258 iTitleBarTextStyle = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_TITLEBARTEXTSTYLE), 1);
01259 iOnTop = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ONTOP), 0);
01260 fTrayIcon = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_TRAYICON), 0);
01261 fRememberZoomLevel = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOZOOM), 1);
01262 fShowBarsWhenFullScreen = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FULLSCREENCTRLS), 1);
01263 nShowBarsWhenFullScreenTimeOut = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FULLSCREENCTRLSTIMEOUT), 0);
01264 if(pApp->GetProfileBinary(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FULLSCREENRES), &ptr, &len))
01265 {
01266 memcpy(&dmFullscreenRes, ptr, sizeof(dmFullscreenRes));
01267 delete [] ptr;
01268 }
01269 else
01270 {
01271 dmFullscreenRes.fValid = false;
01272 }
01273 fExitFullScreenAtTheEnd = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_EXITFULLSCREENATTHEEND), 0);
01274 fRememberWindowPos = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REMEMBERWINDOWPOS), 0);
01275 fRememberWindowSize = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REMEMBERWINDOWSIZE), 0);
01276 AspectRatio.cx = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ASPECTRATIO_X), 0);
01277 AspectRatio.cy = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ASPECTRATIO_Y), 0);
01278 fKeepHistory = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_KEEPHISTORY), 1);
01279 if(pApp->GetProfileBinary(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LASTWINDOWRECT), &ptr, &len))
01280 {
01281 memcpy(&rcLastWindowPos, ptr, sizeof(rcLastWindowPos));
01282 delete [] ptr;
01283 }
01284 else
01285 {
01286 fRememberWindowPos = false;
01287 }
01288 lastWindowType = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LASTWINDOWTYPE), SIZE_RESTORED);
01289 sDVDPath = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DVDPATH), _T(""));
01290 fUseDVDPath = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_USEDVDPATH), 0);
01291 idMenuLang = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MENULANG), ::GetUserDefaultLCID());
01292 idAudioLang = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIOLANG), ::GetUserDefaultLCID());
01293 idSubtitlesLang = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SUBTITLESLANG), ::GetUserDefaultLCID());
01294 fAutoSpeakerConf = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOSPEAKERCONF), 1);
01295
01296 subdefstyle <<= pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPLOGFONT), _T(""));
01297 fOverridePlacement = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPOVERRIDEPLACEMENT), 0);
01298 nHorPos = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPHORPOS), 50);
01299 nVerPos = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPVERPOS), 90);
01300 nSPCSize = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPCSIZE), 3);
01301 nSPCMaxRes = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPCMAXRES), 2);
01302 fSPCPow2Tex = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_POW2TEX), TRUE);
01303 fEnableAudioSwitcher = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOSWITCHER), TRUE);
01304 fAudioTimeShift = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOTIMESHIFT), 0);
01305 tAudioTimeShift = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIOTIMESHIFT), 0);
01306 fDownSampleTo441 = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DOWNSAMPLETO441), 0);
01307 fCustomChannelMapping = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_CUSTOMCHANNELMAPPING), 0);
01308 if(pApp->GetProfileBinary(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPEAKERTOCHANNELMAPPING), &ptr, &len))
01309 {
01310 memcpy(pSpeakerToChannelMap, ptr, sizeof(pSpeakerToChannelMap));
01311 delete [] ptr;
01312 }
01313 else
01314 {
01315 memset(pSpeakerToChannelMap, 0, sizeof(pSpeakerToChannelMap));
01316 for(int j = 0; j < 18; j++)
01317 for(int i = 0; i <= j; i++)
01318 pSpeakerToChannelMap[j][i] = 1<<i;
01319
01320 pSpeakerToChannelMap[0][0] = 1<<0;
01321 pSpeakerToChannelMap[0][1] = 1<<0;
01322
01323 pSpeakerToChannelMap[3][0] = 1<<0;
01324 pSpeakerToChannelMap[3][1] = 1<<1;
01325 pSpeakerToChannelMap[3][2] = 0;
01326 pSpeakerToChannelMap[3][3] = 0;
01327 pSpeakerToChannelMap[3][4] = 1<<2;
01328 pSpeakerToChannelMap[3][5] = 1<<3;
01329
01330 pSpeakerToChannelMap[4][0] = 1<<0;
01331 pSpeakerToChannelMap[4][1] = 1<<1;
01332 pSpeakerToChannelMap[4][2] = 1<<2;
01333 pSpeakerToChannelMap[4][3] = 0;
01334 pSpeakerToChannelMap[4][4] = 1<<3;
01335 pSpeakerToChannelMap[4][5] = 1<<4;
01336 }
01337
01338 {
01339 for(int i = 0; ; i++)
01340 {
01341 CString key;
01342 key.Format(_T("%s\\%04d"), ResStr(IDS_R_FILTERS), i);
01343
01344 CAutoPtr<Filter> f(new Filter);
01345
01346 f->fDisabled = !pApp->GetProfileInt(key, _T("Enabled"), 0);
01347
01348 UINT j = pApp->GetProfileInt(key, _T("SourceType"), -1);
01349 if(j == 0)
01350 {
01351 f->type = Filter::REGISTERED;
01352 f->dispname = CStringW(pApp->GetProfileString(key, _T("DisplayName"), _T("")));
01353 f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
01354 }
01355 else if(j == 1)
01356 {
01357 f->type = Filter::EXTERNAL;
01358 f->path = pApp->GetProfileString(key, _T("Path"), _T(""));
01359 f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
01360 f->clsid = GUIDFromCString(pApp->GetProfileString(key, _T("CLSID"), _T("")));
01361 }
01362 else
01363 {
01364 pApp->WriteProfileString(key, NULL, 0);
01365 break;
01366 }
01367
01368 f->backup.RemoveAll();
01369 for(int i = 0; ; i++)
01370 {
01371 CString val;
01372 val.Format(_T("org%04d"), i);
01373 CString guid = pApp->GetProfileString(key, val, _T(""));
01374 if(guid.IsEmpty()) break;
01375 f->backup.AddTail(GUIDFromCString(guid));
01376 }
01377
01378 f->guids.RemoveAll();
01379 for(int i = 0; ; i++)
01380 {
01381 CString val;
01382 val.Format(_T("mod%04d"), i);
01383 CString guid = pApp->GetProfileString(key, val, _T(""));
01384 if(guid.IsEmpty()) break;
01385 f->guids.AddTail(GUIDFromCString(guid));
01386 }
01387
01388 f->iLoadType = (int)pApp->GetProfileInt(key, _T("LoadType"), -1);
01389 if(f->iLoadType < 0) break;
01390
01391 f->dwMerit = pApp->GetProfileInt(key, _T("Merit"), MERIT_DO_NOT_USE+1);
01392
01393 filters.AddTail(f);
01394 }
01395 }
01396
01397 fIntRealMedia = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_INTREALMEDIA), 0);
01398
01399
01400 RealMediaQuickTimeFPS = 25.0;
01401 *((DWORD*)&RealMediaQuickTimeFPS) = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_REALMEDIAFPS), *((DWORD*)&RealMediaQuickTimeFPS));
01402
01403 m_pnspresets.RemoveAll();
01404 for(int i = 0; i < (ID_PANNSCAN_PRESETS_END - ID_PANNSCAN_PRESETS_START); i++)
01405 {
01406 CString str;
01407 str.Format(_T("Preset%d"), i);
01408 str = pApp->GetProfileString(ResStr(IDS_R_SETTINGS) + _T("\\") + ResStr(IDS_RS_PNSPRESETS), str, _T(""));
01409 if(str.IsEmpty()) break;
01410 m_pnspresets.Add(str);
01411 }
01412 if(m_pnspresets.IsEmpty())
01413 {
01414 double _4p3 = 4.0/3.0;
01415 double _16p9 = 16.0/9.0;
01416 double _185p1 = 1.85/1.0;
01417 double _235p1 = 2.35/1.0;
01418
01419 CString str;
01420 str.Format(_T("Scale to 16:9 TV,%.3f,%.3f,%.3f,%.3f"), 0.5, 0.5, _4p3/_4p3, _16p9/_4p3);
01421 m_pnspresets.Add(str);
01422 str.Format(_T("Zoom To Widescreen,%.3f,%.3f,%.3f,%.3f"), 0.5, 0.5, _16p9/_4p3, _16p9/_4p3);
01423 m_pnspresets.Add(str);
01424 str.Format(_T("Zoom To Ultra-Widescreen,%.3f,%.3f,%.3f,%.3f"), 0.5, 0.5, _235p1/_4p3, _235p1/_4p3);
01425 m_pnspresets.Add(str);
01426 }
01427
01428 for(int i = 0; i < wmcmds.GetCount(); i++)
01429 {
01430 CString str;
01431 str.Format(_T("CommandMod%d"), i);
01432 str = pApp->GetProfileString(ResStr(IDS_R_COMMANDS), str, _T(""));
01433 if(str.IsEmpty()) break;
01434 int cmd, fVirt, key, repcnt, mouse, appcmd;
01435 TCHAR buff[128];
01436 int n;
01437 if(5 > (n = _stscanf(str, _T("%d %x %x %s %d %d %d"), &cmd, &fVirt, &key, buff, &repcnt, &mouse, &appcmd)))
01438 break;
01439 if(POSITION pos = wmcmds.Find(cmd))
01440 {
01441 wmcmd& wc = wmcmds.GetAt(pos);
01442 wc.cmd = cmd;
01443 wc.fVirt = fVirt;
01444 wc.key = key;
01445 if(n >= 6) wc.mouse = (UINT)mouse;
01446 if(n >= 7) wc.appcmd = (UINT)appcmd;
01447 wc.rmcmd = CStringA(buff).Trim('\"');
01448 wc.rmrepcnt = repcnt;
01449 }
01450 }
01451
01452 CArray<ACCEL> pAccel;
01453 pAccel.SetSize(wmcmds.GetCount());
01454 POSITION pos = wmcmds.GetHeadPosition();
01455 for(int i = 0; pos; i++) pAccel[i] = wmcmds.GetNext(pos);
01456 hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
01457
01458 WinLircAddr = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WINLIRCADDR), _T("127.0.0.1:8765"));
01459 fWinLirc = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WINLIRC), 0);
01460 UIceAddr = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_UICEADDR), _T("127.0.0.1:1234"));
01461 fUIce = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_UICE), 0);
01462
01463 fDisabeXPToolbars = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DISABLEXPTOOLBARS), 0);
01464 fUseWMASFReader = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_USEWMASFREADER), TRUE);
01465 nJumpDistS = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_JUMPDISTS), 1000);
01466 nJumpDistM = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_JUMPDISTM), 5000);
01467 nJumpDistL = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_JUMPDISTL), 20000);
01468 fFreeWindowResizing = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_FREEWINDOWRESIZING), TRUE);
01469 fNotifyMSN = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_NOTIFYMSN), TRUE);
01470
01471 Formats.UpdateData(false);
01472
01473 SrcFilters = pApp->GetProfileInt(ResStr(IDS_R_INTERNAL_FILTERS), ResStr(IDS_RS_SRCFILTERS), ~0);
01474 TraFilters = pApp->GetProfileInt(ResStr(IDS_R_INTERNAL_FILTERS), ResStr(IDS_RS_TRAFILTERS), ~0^TRA_MPEG1);
01475
01476 logofn = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOGOFILE), _T(""));
01477 logoid = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOGOID), IDB_LOGO7);
01478 logoext = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LOGOEXT), 0);
01479
01480 mpegdi = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGDI), 0);
01481 mpegbright = (double)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGBRIGHT), 255) - 255;
01482 mpegcont = (double)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGCONT), 100) / 100;
01483 mpeghue = (double)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGHUE), 180) - 180;
01484 mpegsat = (double)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGSAT), 100) / 100;
01485 mpegforcedsubs = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGFORCEDSUBS), 1);
01486 mpegplanaryuv = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPEGPLANARYUV), 1);
01487
01488 mpasf = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPASF), 0);
01489 mpanormalize = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPANORMALIZE), FALSE);
01490 ac3sc = (int)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AC3SC), 2);
01491 ac3drc = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AC3DRC), FALSE);
01492 dtssc = (int)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DTSSC), 2);
01493 dtsdrc = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DTSDRC), FALSE);
01494 aacsc = (int)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AACSC), 1);
01495 mpaboost = (float)pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_MPABOOST), 1);
01496
01497 fHideCDROMsSubMenu = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_HIDECDROMSSUBMENU), 0);
01498
01499 priority = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_PRIORITY), NORMAL_PRIORITY_CLASS);
01500 ::SetPriorityClass(::GetCurrentProcess(), priority);
01501 launchfullscreen = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_LAUNCHFULLSCREEN), FALSE);
01502
01503 fEnableWebServer = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEWEBSERVER), FALSE);
01504 nWebServerPort = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERPORT), 13579);
01505 fWebServerPrintDebugInfo = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERPRINTDEBUGINFO), FALSE);
01506 fWebServerUseCompression = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERUSECOMPRESSION), TRUE);
01507 fWebServerLocalhostOnly = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERLOCALHOSTONLY), TRUE);
01508 WebRoot = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBROOT), _T("*./webroot"));
01509 WebDefIndex = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBDEFINDEX), _T("index.html;index.php"));
01510 WebServerCGI = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_WEBSERVERCGI), _T(""));
01511
01512 CString MyPictures;
01513
01514 CRegKey key;
01515
01516
01517
01518 if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ))
01519 {
01520 ULONG len = MAX_PATH;
01521 if(ERROR_SUCCESS == key.QueryStringValue(_T("My Pictures"), MyPictures.GetBuffer(MAX_PATH), &len)) MyPictures.ReleaseBufferSetLength(len);
01522 else MyPictures.Empty();
01523 }
01524 SnapShotPath = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SNAPSHOTPATH), MyPictures);
01525 SnapShotExt = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SNAPSHOTEXT), _T(".bmp"));
01526
01527 ISDb = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ISDB), _T("isdb.go.dyndns.org"));
01528
01529 pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("LastUsedPage"), 0);
01530
01531 if(!pApp->GetProfileInt(_T("Shaders"), _T("Initialized"), 0))
01532 {
01533 pApp->WriteProfileString(_T("Shaders"), NULL, NULL);
01534
01535 CString hdr =
01536 _T("|ps_2_0|")
01537 _T("sampler s0 : register(s0);\\n")
01538 _T("float4 p0 : register(c0);\\n")
01539 _T("float4 p1 : register(c1);\\n")
01540 _T("\\n")
01541 _T("#define width (p0[0])\\n")
01542 _T("#define height (p0[1])\\n")
01543 _T("#define counter (p0[2])\\n")
01544 _T("#define clock (p0[3])\\n")
01545 _T("#define one_over_width (p1[0])\\n")
01546 _T("#define one_over_height (p1[1])\\n")
01547 _T("\\n")
01548 _T("#define PI acos(-1)\\n")
01549 _T("\\n")
01550 _T("float4 main(float2 tex : TEXCOORD0) : COLOR\\n")
01551 _T("{\\n");
01552
01553 CString ftr =
01554 _T("\\t\\n")
01555 _T("\\treturn c0;\\n}")
01556 _T("\\n");
01557
01558 pApp->WriteProfileString(_T("Shaders"), _T("0"), _T("contour") + hdr +
01559 _T("\\tfloat dx = 4/width;\\n")
01560 _T("\\tfloat dy = 4/height;\\n")
01561 _T("\\t\\n")
01562 _T("\\tfloat4 c2 = tex2D(s0, tex + float2(0,-dy));\\n")
01563 _T("\\tfloat4 c4 = tex2D(s0, tex + float2(-dx,0));\\n")
01564 _T("\\tfloat4 c5 = tex2D(s0, tex + float2(0,0));\\n")
01565 _T("\\tfloat4 c6 = tex2D(s0, tex + float2(dx,0));\\n")
01566 _T("\\tfloat4 c8 = tex2D(s0, tex + float2(0,dy));\\n")
01567 _T("\\t\\n")
01568 _T("\\tfloat4 c0 = (-c2-c4+c5*4-c6-c8);\\n")
01569 _T("\\tif(length(c0) < 1.0) c0 = float4(0,0,0,0);\\n")
01570 _T("\\telse c0 = float4(1,1,1,0);\\n") + ftr);
01571
01572 pApp->WriteProfileString(_T("Shaders"), _T("1"), _T("deinterlace (blend)") + hdr +
01573 _T("\\tfloat4 c0 = tex2D(s0, tex);\\n")
01574 _T("\\t\\n")
01575 _T("\\tfloat2 h = float2(0, 1/height);\\n")
01576 _T("\\tfloat4 c1 = tex2D(s0, tex-h);\\n")
01577 _T("\\tfloat4 c2 = tex2D(s0, tex+h);\\n")
01578 _T("\\tc0 = (c0*2+c1+c2)/4;\\n") + ftr);
01579
01580 pApp->WriteProfileString(_T("Shaders"), _T("2"), _T("emboss") + hdr +
01581 _T("\\tfloat dx = 1/width;\\n")
01582 _T("\\tfloat dy = 1/height;\\n")
01583 _T("\\t\\n")
01584 _T("\\tfloat4 c1 = tex2D(s0, tex + float2(-dx,-dy));\\n")
01585 _T("\\tfloat4 c2 = tex2D(s0, tex + float2(0,-dy));\\n")
01586 _T("\\tfloat4 c4 = tex2D(s0, tex + float2(-dx,0));\\n")
01587 _T("\\tfloat4 c6 = tex2D(s0, tex + float2(dx,0));\\n")
01588 _T("\\tfloat4 c8 = tex2D(s0, tex + float2(0,dy));\\n")
01589 _T("\\tfloat4 c9 = tex2D(s0, tex + float2(dx,dy));\\n")
01590 _T("\\t\\n")
01591 _T("\\tfloat4 c0 = (-c1-c2-c4+c6+c8+c9);\\n")
01592 _T("\\tc0 = (c0.r+c0.g+c0.b)/3 + 0.5;\\n") + ftr);
01593
01594 pApp->WriteProfileString(_T("Shaders"), _T("3"), _T("grayscale") + hdr +
01595 _T("\\tfloat c0 = dot(tex2D(s0, tex), float4(0.299, 0.587, 0.114, 0));\\n") + ftr);
01596
01597 pApp->WriteProfileString(_T("Shaders"), _T("4"), _T("invert") + hdr +
01598 _T("\\tfloat4 c0 = float4(1, 1, 1, 1) - tex2D(s0, tex);\\n") + ftr);
01599
01600 pApp->WriteProfileString(_T("Shaders"), _T("5"), _T("letterbox") + hdr +
01601 _T("\\tfloat4 c0 = 0;\\n")
01602 _T("\\t\\n")
01603 _T("\\tfloat2 ar = float2(16, 9);\\n")
01604 _T("\\tfloat h = (1 - width/height * ar.y/ar.x) / 2;\\n")
01605 _T("\\t\\n")
01606 _T("\\tif(tex.y >= h && tex.y <= 1-h)\\n")
01607 _T("\\t\\tc0 = tex2D(s0, tex);\\n") + ftr);
01608
01609 pApp->WriteProfileString(_T("Shaders"), _T("6"), _T("sphere") + hdr +
01610 _T("\\t
01611 _T("\\t// - no reflection or refraction, yet (my ati 9800 has a 64 + 32 instruction limit...)\\n")
01612 _T("\\t\\n")
01613 _T("\\tfloat3 pl = float3(3,-3,-4);
01614 _T("\\tfloat4 cl = 0.4;
01615 _T("\\t\\n")
01616 _T("\\tfloat3 pc = float3(0,0,-1);
01617 _T("\\tfloat3 ps = float3(0,0,0.5);
01618 _T("\\tfloat r = 0.65;
01619 _T("\\t\\n")
01620 _T("\\tfloat3 pd = normalize(float3(tex.x-0.5, tex.y-0.5, 0) - pc);\\n")
01621 _T("\\t\\n")
01622 _T("\\tfloat A = 1;\\n")
01623 _T("\\tfloat B = 2*dot(pd, pc - ps);\\n")
01624 _T("\\tfloat C = dot(pc - ps, pc - ps) - r*r;\\n")
01625 _T("\\tfloat D = B*B - 4*A*C;\\n")
01626 _T("\\t\\n")
01627 _T("\\tfloat4 c0 = 0;\\n")
01628 _T("\\t\\n")
01629 _T("\\tif(D >= 0)\\n")
01630 _T("\\t{\\n")
01631 _T("\\t\\t
01632 _T("\\t\\t// float t1 = (-B + sqrt(D)) / (2*A);\\n")
01633 _T("\\t\\t
01634 _T("\\t\\t
01635 _T("\\t\\t\\n")
01636 _T("\\t\\tfloat t = (-B - sqrt(D)) / (2*A);\\n")
01637 _T("\\t\\t\\n")
01638 _T("\\t\\t
01639 _T("\\t\\tfloat3 p = pc + pd*t;\\n")
01640 _T("\\t\\tfloat3 n = normalize(p - ps);\\n")
01641 _T("\\t\\tfloat3 l = normalize(pl - p);\\n")
01642 _T("\\t\\t\\n")
01643 _T("\\t\\t
01644 _T("\\t\\ttex = acos(-n)/PI; \\n")
01645 _T("\\t\\t\\n")
01646 _T("\\t\\t
01647 _T("\\t\\ttex.x = frac(tex.x + frac(clock/10));\\n")
01648 _T("\\t\\t\\n")
01649 _T("\\t\\t
01650 _T("\\t\\tc0 = tex2D(s0, tex) * dot(n, l) + cl * pow(max(dot(l, reflect(pd, n)), 0), 50);\\n")
01651 _T("\\t}\\n") + ftr);
01652
01653 pApp->WriteProfileString(_T("Shaders"), _T("7"), _T("spotlight") + hdr +
01654 _T("\\tfloat4 c0 = tex2D(s0, tex);\\n")
01655 _T("\\tfloat3 lightsrc = float3(sin(clock*PI/1.5)/2+0.5,cos(clock*PI)/2+0.5,1);\\n")
01656 _T("\\tfloat3 light = normalize(lightsrc - float3(tex.x,tex.y,0));\\n")
01657 _T("\\tc0 *= pow(dot(light, float3(0,0,1)), 50);\\n") + ftr);
01658
01659 pApp->WriteProfileString(_T("Shaders"), _T("8"), _T("wave") + hdr +
01660 _T("\\t
01661 _T("\\t\\n")
01662 _T("\\tfloat4 c0 = 0;\\n")
01663 _T("\\t\\n")
01664 _T("\\ttex.x += sin(tex.x+clock/0.3)/20;\\n")
01665 _T("\\ttex.y += sin(tex.x+clock/0.3)/20;\\n")
01666 _T("\\t\\n")
01667 _T("\\tif(tex.x >= 0 && tex.x <= 1 && tex.y >= 0 && tex.y <= 1)\\n")
01668 _T("\\t{\\n")
01669 _T("\\t\\tc0 = tex2D(s0, tex);\\n")
01670 _T("\\t}\\n") + ftr);
01671
01672 pApp->WriteProfileInt(_T("Shaders"), _T("Initialized"), 1);
01673 }
01674
01675 fInitialized = true;
01676 }
01677 }
01678
01679 void CMPlayerCApp::Settings::ParseCommandLine(CList<CString>& cmdln)
01680 {
01681 nCLSwitches = 0;
01682 slFiles.RemoveAll();
01683 slDubs.RemoveAll();
01684 slSubs.RemoveAll();
01685 slFilters.RemoveAll();
01686 rtStart = 0;
01687 fixedWindowSize.SetSize(0, 0);
01688
01689 if(launchfullscreen) nCLSwitches |= CLSW_FULLSCREEN;
01690
01691 POSITION pos = cmdln.GetHeadPosition();
01692 while(pos)
01693 {
01694 CString param = cmdln.GetNext(pos);
01695 if(param.IsEmpty()) continue;
01696
01697 if((param[0] == '-' || param[0] == '/') && param.GetLength() > 1)
01698 {
01699 CString sw = param.Mid(1).MakeLower();
01700 if(sw == _T("open")) nCLSwitches |= CLSW_OPEN;
01701 else if(sw == _T("play")) nCLSwitches |= CLSW_PLAY;
01702 else if(sw == _T("fullscreen")) nCLSwitches |= CLSW_FULLSCREEN;
01703 else if(sw == _T("minimized")) nCLSwitches |= CLSW_MINIMIZED;
01704 else if(sw == _T("new")) nCLSwitches |= CLSW_NEW;
01705 else if(sw == _T("help") || sw == _T("h") || sw == _T("?")) nCLSwitches |= CLSW_HELP;
01706 else if(sw == _T("dub") && pos) slDubs.AddTail(cmdln.GetNext(pos));
01707 else if(sw == _T("sub") && pos) slSubs.AddTail(cmdln.GetNext(pos));
01708 else if(sw == _T("filter") && pos) slFilters.AddTail(cmdln.GetNext(pos));
01709 else if(sw == _T("dvd")) nCLSwitches |= CLSW_DVD;
01710 else if(sw == _T("cd")) nCLSwitches |= CLSW_CD;
01711 else if(sw == _T("add")) nCLSwitches |= CLSW_ADD;
01712 else if(sw == _T("regvid")) nCLSwitches |= CLSW_REGEXTVID;
01713 else if(sw == _T("regaud")) nCLSwitches |= CLSW_REGEXTAUD;
01714 else if(sw == _T("unregvid")) nCLSwitches |= CLSW_UNREGEXTVID;
01715 else if(sw == _T("unregaud")) nCLSwitches |= CLSW_UNREGEXTAUD;
01716 else if(sw == _T("start") && pos) {rtStart = 10000i64*_tcstol(cmdln.GetNext(pos), NULL, 10); nCLSwitches |= CLSW_STARTVALID;}
01717 else if(sw == _T("startpos") && pos) {/* TODO: mm:ss. */;}
01718 else if(sw == _T("nofocus")) nCLSwitches |= CLSW_NOFOCUS;
01719 else if(sw == _T("close")) nCLSwitches |= CLSW_CLOSE;
01720 else if(sw == _T("standby")) nCLSwitches |= CLSW_STANDBY;
01721 else if(sw == _T("hibernate")) nCLSwitches |= CLSW_HIBERNATE;
01722 else if(sw == _T("shutdown")) nCLSwitches |= CLSW_SHUTDOWN;
01723 else if(sw == _T("logoff")) nCLSwitches |= CLSW_LOGOFF;
01724 else if(sw == _T("fixedsize") && pos)
01725 {
01726 CList<CString> sl;
01727 Explode(cmdln.GetNext(pos), sl, ',', 2);
01728 if(sl.GetCount() == 2)
01729 {
01730 fixedWindowSize.SetSize(_ttol(sl.GetHead()), _ttol(sl.GetTail()));
01731 if(fixedWindowSize.cx > 0 && fixedWindowSize.cy > 0)
01732 nCLSwitches |= CLSW_FIXEDSIZE;
01733 }
01734 }
01735 else nCLSwitches |= CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH;
01736 }
01737 else
01738 {
01739 slFiles.AddTail(param);
01740 }
01741 }
01742 }
01743
01744 void CMPlayerCApp::Settings::GetFav(favtype ft, CList<CString>& sl)
01745 {
01746 sl.RemoveAll();
01747
01748 CString root;
01749
01750 switch(ft)
01751 {
01752 case FAV_FILE: root = ResStr(IDS_R_FAVFILES); break;
01753 case FAV_DVD: root = ResStr(IDS_R_FAVDVDS); break;
01754 case FAV_DEVICE: root = ResStr(IDS_R_FAVDEVICES); break;
01755 default: return;
01756 }
01757
01758 for(int i = 0; ; i++)
01759 {
01760 CString s;
01761 s.Format(_T("Name%d"), i);
01762 s = AfxGetApp()->GetProfileString(root, s, NULL);
01763 if(s.IsEmpty()) break;
01764 sl.AddTail(s);
01765 }
01766 }
01767
01768 void CMPlayerCApp::Settings::SetFav(favtype ft, CList<CString>& sl)
01769 {
01770 CString root;
01771
01772 switch(ft)
01773 {
01774 case FAV_FILE: root = ResStr(IDS_R_FAVFILES); break;
01775 case FAV_DVD: root = ResStr(IDS_R_FAVDVDS); break;
01776 case FAV_DEVICE: root = ResStr(IDS_R_FAVDEVICES); break;
01777 default: return;
01778 }
01779
01780 AfxGetApp()->WriteProfileString(root, NULL, NULL);
01781
01782 int i = 0;
01783 POSITION pos = sl.GetHeadPosition();
01784 while(pos)
01785 {
01786 CString s;
01787 s.Format(_T("Name%d"), i++);
01788 AfxGetApp()->WriteProfileString(root, s, sl.GetNext(pos));
01789 }
01790 }
01791
01792 void CMPlayerCApp::Settings::AddFav(favtype ft, CString s)
01793 {
01794 CList<CString> sl;
01795 GetFav(ft, sl);
01796 if(sl.Find(s)) return;
01797 sl.AddTail(s);
01798 SetFav(ft, sl);
01799 }
01800
01801 // CMPlayerCApp::Settings::CRecentFileAndURLList
01802
01803 CMPlayerCApp::Settings::CRecentFileAndURLList::CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
01804 LPCTSTR lpszEntryFormat, int nSize,
01805 int nMaxDispLen)
01806 : CRecentFileList(nStart, lpszSection, lpszEntryFormat, nSize, nMaxDispLen)
01807 {
01808 }
01809
01810 //#include <afximpl.h>
01811 extern BOOL AFXAPI AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn);
01812 extern BOOL AFXAPI AfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2);
01813
01814 void CMPlayerCApp::Settings::CRecentFileAndURLList::Add(LPCTSTR lpszPathName)
01815 {
01816 ASSERT(m_arrNames != NULL);
01817 ASSERT(lpszPathName != NULL);
01818 ASSERT(AfxIsValidString(lpszPathName));
01819
01820 if(CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0)
01821 return;
01822
01823 bool fURL = (CString(lpszPathName).Find(_T(":
01824
01825
01826 TCHAR szTemp[1024];
01827 if(fURL) _tcscpy_s(szTemp, countof(szTemp), lpszPathName);
01828 else AfxFullPath(szTemp, lpszPathName);
01829
01830
01831 int iMRU;
01832 for (iMRU = 0; iMRU < m_nSize-1; iMRU++)
01833 {
01834 if((fURL && !_tcscmp(m_arrNames[iMRU], szTemp))
01835 || AfxComparePath(m_arrNames[iMRU], szTemp))
01836 break;
01837 }
01838
01839 for (; iMRU > 0; iMRU--)
01840 {
01841 ASSERT(iMRU > 0);
01842 ASSERT(iMRU < m_nSize);
01843 m_arrNames[iMRU] = m_arrNames[iMRU-1];
01844 }
01845
01846 m_arrNames[0] = szTemp;
01847 }
01848
01849
01850 void CMPlayerCApp::OnHelpShowcommandlineswitches()
01851 {
01852 ShowCmdlnSwitches();
01853 }
01854
01855
01856
01857 void GetCurDispMode(dispmode& dm)
01858 {
01859 if(HDC hDC = ::GetDC(0))
01860 {
01861 dm.fValid = true;
01862 dm.size = CSize(GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES));
01863 dm.bpp = GetDeviceCaps(hDC, BITSPIXEL);
01864 dm.freq = GetDeviceCaps(hDC, VREFRESH);
01865 ::ReleaseDC(0, hDC);
01866 }
01867 }
01868
01869 bool GetDispMode(int i, dispmode& dm)
01870 {
01871 DEVMODE devmode;
01872 devmode.dmSize = sizeof(DEVMODE);
01873 if(!EnumDisplaySettings(0, i, &devmode))
01874 return(false);
01875
01876 dm.fValid = true;
01877 dm.size = CSize(devmode.dmPelsWidth, devmode.dmPelsHeight);
01878 dm.bpp = devmode.dmBitsPerPel;
01879 dm.freq = devmode.dmDisplayFrequency;
01880
01881 return(true);
01882 }
01883
01884 void SetDispMode(dispmode& dm)
01885 {
01886 if(!dm.fValid) return;
01887
01888 DEVMODE dmScreenSettings;
01889 memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
01890 dmScreenSettings.dmSize = sizeof(dmScreenSettings);
01891 dmScreenSettings.dmPelsWidth = dm.size.cx;
01892 dmScreenSettings.dmPelsHeight = dm.size.cy;
01893 dmScreenSettings.dmBitsPerPel = dm.bpp;
01894 dmScreenSettings.dmDisplayFrequency = dm.freq;
01895 dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
01896 ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
01897 }
01898
01899 #include <afxsock.h>
01900 #include <atlsync.h>
01901 #include <atlutil.h>
01902 #include <atlrx.h>
01903
01904 typedef CAtlRegExp<CAtlRECharTraits> CAtlRegExpT;
01905 typedef CAtlREMatchContext<CAtlRECharTraits> CAtlREMatchContextT;
01906
01907 bool FindRedir(CUrl& src, CString ct, CString& body, CList<CString>& urls, CAutoPtrList<CAtlRegExpT>& res)
01908 {
01909 POSITION pos = res.GetHeadPosition();
01910 while(pos)
01911 {
01912 CAtlRegExpT* re = res.GetNext(pos);
01913
01914 CAtlREMatchContextT mc;
01915 const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
01916 const CAtlREMatchContextT::RECHAR* e = NULL;
01917 for(; s && re->Match(s, &mc, &e); s = e)
01918 {
01919 const CAtlREMatchContextT::RECHAR* szStart = 0;
01920 const CAtlREMatchContextT::RECHAR* szEnd = 0;
01921 mc.GetMatch(0, &szStart, &szEnd);
01922
01923 CString url;
01924 url.Format(_T("%.*s"), szEnd - szStart, szStart);
01925 url.Trim();
01926
01927 if(url.CompareNoCase(_T("asf path")) == 0) continue;
01928
01929 CUrl dst;
01930 dst.CrackUrl(CString(url));
01931 if(_tcsicmp(src.GetSchemeName(), dst.GetSchemeName())
01932 || _tcsicmp(src.GetHostName(), dst.GetHostName())
01933 || _tcsicmp(src.GetUrlPath(), dst.GetUrlPath()))
01934 {
01935 urls.AddTail(url);
01936 }
01937 else
01938 {
01939
01940 urls.RemoveAll();
01941 break;
01942 }
01943 }
01944 }
01945
01946 return urls.GetCount() > 0;
01947 }
01948
01949 bool FindRedir(CString& fn, CString ct, CList<CString>& fns, CAutoPtrList<CAtlRegExpT>& res)
01950 {
01951 CString body;
01952
01953 CTextFile f;
01954 if(f.Open(fn)) for(CString tmp; f.ReadString(tmp); body += tmp + '\n');
01955
01956 CString dir = fn.Left(max(fn.ReverseFind('/'), fn.ReverseFind('\\'))+1);
01957
01958 POSITION pos = res.GetHeadPosition();
01959 while(pos)
01960 {
01961 CAtlRegExpT* re = res.GetNext(pos);
01962
01963 CAtlREMatchContextT mc;
01964 const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
01965 const CAtlREMatchContextT::RECHAR* e = NULL;
01966 for(; s && re->Match(s, &mc, &e); s = e)
01967 {
01968 const CAtlREMatchContextT::RECHAR* szStart = 0;
01969 const CAtlREMatchContextT::RECHAR* szEnd = 0;
01970 mc.GetMatch(0, &szStart, &szEnd);
01971
01972 CString fn2;
01973 fn2.Format(_T("%.*s"), szEnd - szStart, szStart);
01974 fn2.Trim();
01975
01976 if(!fn2.CompareNoCase(_T("asf path"))) continue;
01977 if(fn2.Find(_T("EXTM3U")) == 0 || fn2.Find(_T("#EXTINF")) == 0) continue;
01978
01979 if(fn2.Find(_T(":")) < 0 && fn2.Find(_T("\\\\")) != 0 && fn2.Find(_T("//")) != 0)
01980 {
01981 CPath p;
01982 p.Combine(dir, fn2);
01983 fn2 = (LPCTSTR)p;
01984 }
01985
01986 if(!fn2.CompareNoCase(fn))
01987 continue;
01988
01989 fns.AddTail(fn2);
01990 }
01991 }
01992
01993 return fns.GetCount() > 0;
01994 }
01995
01996 CString GetContentType(CString fn, CList<CString>* redir)
01997 {
01998 CUrl url;
01999 CString ct, body;
02000
02001 if(fn.Find(_T("://")) >= 0)
02002 {
02003 url.CrackUrl(fn);
02004
02005 if(_tcsicmp(url.GetSchemeName(), _T("pnm")) == 0)
02006 return "audio/x-pn-realaudio";
02007
02008 if(_tcsicmp(url.GetSchemeName(), _T("mms")) == 0)
02009 return "video/x-ms-asf";
02010
02011 if(_tcsicmp(url.GetSchemeName(), _T("http")) != 0)
02012 return "";
02013
02014 DWORD ProxyEnable = 0;
02015 CString ProxyServer;
02016 DWORD ProxyPort = 0;
02017
02018 ULONG len = 256+1;
02019 CRegKey key;
02020 if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), KEY_READ)
02021 && ERROR_SUCCESS == key.QueryDWORDValue(_T("ProxyEnable"), ProxyEnable) && ProxyEnable
02022 && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len))
02023 {
02024 ProxyServer.ReleaseBufferSetLength(len);
02025
02026 CList<CString> sl;
02027 ProxyServer = Explode(ProxyServer, sl, ';');
02028 if(sl.GetCount() > 1)
02029 {
02030 POSITION pos = sl.GetHeadPosition();
02031 while(pos)
02032 {
02033 CList<CString> sl2;
02034 if(!Explode(sl.GetNext(pos), sl2, '=', 2).CompareNoCase(_T("http"))
02035 && sl2.GetCount() == 2)
02036 {
02037 ProxyServer = sl2.GetTail();
02038 break;
02039 }
02040 }
02041 }
02042
02043 ProxyServer = Explode(ProxyServer, sl, ':');
02044 if(sl.GetCount() > 1) ProxyPort = _tcstol(sl.GetTail(), NULL, 10);
02045 }
02046
02047 CSocket s;
02048 s.Create();
02049 if(s.Connect(
02050 ProxyEnable ? ProxyServer : url.GetHostName(),
02051 ProxyEnable ? ProxyPort : url.GetPortNumber()))
02052 {
02053 CStringA host = CStringA(url.GetHostName());
02054 CStringA path = CStringA(url.GetUrlPath()) + CStringA(url.GetExtraInfo());
02055
02056 if(ProxyEnable) path = "http://" + host + path;
02057
02058 CStringA hdr;
02059 hdr.Format(
02060 "GET %s HTTP/1.0\r\n"
02061 "User-Agent: Media Player Classic\r\n"
02062 "Host: %s\r\n"
02063 "Accept: */*\r\n"
02064 "\r\n", path, host);
02065
02066
02067
02068 if(s.Send((LPCSTR)hdr, hdr.GetLength()) < hdr.GetLength()) return "";
02069
02070 hdr.Empty();
02071 while(1)
02072 {
02073 CStringA str;
02074 str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256));
02075 if(str.IsEmpty()) break;
02076 hdr += str;
02077 int hdrend = hdr.Find("\r\n\r\n");
02078 if(hdrend >= 0) {body = hdr.Mid(hdrend+4); hdr = hdr.Left(hdrend); break;}
02079 }
02080
02081
02082
02083 CList<CStringA> sl;
02084 Explode(hdr, sl, '\n');
02085 POSITION pos = sl.GetHeadPosition();
02086 while(pos)
02087 {
02088 CStringA& hdrline = sl.GetNext(pos);
02089 CList<CStringA> sl2;
02090 Explode(hdrline, sl2, ':', 2);
02091 CStringA field = sl2.RemoveHead().MakeLower();
02092 if(field == "location" && !sl2.IsEmpty())
02093 return GetContentType(CString(sl2.GetHead()), redir);
02094 if(field == "content-type" && !sl2.IsEmpty())
02095 ct = sl2.GetHead();
02096 }
02097
02098 while(body.GetLength() < 256)
02099 {
02100 CStringA str;
02101 str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256));
02102 if(str.IsEmpty()) break;
02103 body += str;
02104 }
02105
02106 if(body.GetLength() >= 8)
02107 {
02108 CStringA str = TToA(body);
02109 if(!strncmp((LPCSTR)str, ".ra", 3))
02110 return "audio/x-pn-realaudio";
02111 if(!strncmp((LPCSTR)str, ".RMF", 4))
02112 return "audio/x-pn-realaudio";
02113 if(*(DWORD*)(LPCSTR)str == 0x75b22630)
02114 return "video/x-ms-wmv";
02115 if(!strncmp((LPCSTR)str+4, "moov", 4))
02116 return "video/quicktime";
02117 }
02118
02119 if(redir && (ct == _T("video/x-ms-asf")
02120 || ct == _T("audio/x-scpls")
02121 || ct == _T("audio/x-mpegurl")))
02122 {
02123 while(body.GetLength() < 4*1024)
02124 {
02125 CStringA str;
02126 str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256));
02127 if(str.IsEmpty()) break;
02128 body += str;
02129 }
02130 }
02131 }
02132 }
02133 else if(!fn.IsEmpty())
02134 {
02135 CPath p(fn);
02136 CString ext = p.GetExtension().MakeLower();
02137 if(ext == _T(".asx")) ct = _T("video/x-ms-asf");
02138 else if(ext == _T(".pls")) ct = _T("audio/x-scpls");
02139 else if(ext == _T(".m3u")) ct = _T("audio/x-mpegurl");
02140 else if(ext == _T(".qtl")) ct = _T("application/x-quicktimeplayer");
02141
02142 if(FILE* f = _tfopen(fn, _T("rb")))
02143 {
02144 CStringA str;
02145 str.ReleaseBufferSetLength(fread(str.GetBuffer(10240), 1, 10240, f));
02146 body = AToT(str);
02147 fclose(f);
02148 }
02149 }
02150
02151 if(body.GetLength() >= 4)
02152 {
02153 CStringA str = TToA(body);
02154 if(!strncmp((LPCSTR)str, ".ra", 3))
02155 return "audio/x-pn-realaudio";
02156 if(!strncmp((LPCSTR)str, "FWS", 3))
02157 return "application/x-shockwave-flash";
02158 if(strstr((LPCSTR)str, "MPCPLAYLIST"))
02159 return "application/x-mpc-playlist";
02160
02161 }
02162
02163 if(redir && !ct.IsEmpty())
02164 {
02165 CAutoPtrList<CAtlRegExpT> res;
02166 CAutoPtr<CAtlRegExpT> re;
02167
02168 if(ct == _T("video/x-ms-asf"))
02169 {
02170
02171 re.Attach(new CAtlRegExpT());
02172 if(re && REPARSE_ERROR_OK == re->Parse(_T("{[a-zA-Z]+://[^\n\">]*}"), FALSE))
02173 res.AddTail(re);
02174
02175 re.Attach(new CAtlRegExpT());
02176 if(re && REPARSE_ERROR_OK == re->Parse(_T("Ref\\z\\b*=\\b*[\"]*{([a-zA-Z]+://[^\n\"]+}"), FALSE))
02177 res.AddTail(re);
02178 }
02179 else if(ct == _T("audio/x-scpls"))
02180 {
02181
02182 re.Attach(new CAtlRegExp<>());
02183 if(re && REPARSE_ERROR_OK == re->Parse(_T("file\\z\\b*=\\b*[\"]*{[^\n\"]+}"), FALSE))
02184 res.AddTail(re);
02185 }
02186 else if(ct == _T("audio/x-mpegurl"))
02187 {
02188
02189
02190 re.Attach(new CAtlRegExp<>());
02191 if(re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE))
02192 res.AddTail(re);
02193 }
02194 else if(ct == _T("audio/x-pn-realaudio"))
02195 {
02196
02197 re.Attach(new CAtlRegExp<>());
02198 if(re && REPARSE_ERROR_OK == re->Parse(_T("{rtsp://[^\n]+}"), FALSE))
02199 res.AddTail(re);
02200 }
02201
02202 if(!body.IsEmpty())
02203 {
02204 if(fn.Find(_T("://")) >= 0) FindRedir(url, ct, body, *redir, res);
02205 else FindRedir(fn, ct, *redir, res);
02206 }
02207 }
02208
02209 return ct;
02210 }