mplayerc.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #pragma once
00023 
00024 #ifndef __AFXWIN_H__
00025         #error include 'stdafx.h' before including this file for PCH
00026 #endif
00027 
00028 #include "resource.h"       // main symbols
00029 #include <afxadv.h>
00030 #include <atlsync.h>
00031 #include "..\..\subtitles\STS.h"
00032 #include "MediaFormats.h"
00033 #include "fakefiltermapper2.h"
00034 
00035 #ifdef UNICODE
00036 #define MPC_WND_CLASS_NAME L"MediaPlayerClassicW"
00037 #else
00038 #define MPC_WND_CLASS_NAME "MediaPlayerClassicA"
00039 #endif
00040 
00041 enum 
00042 {
00043         WM_GRAPHNOTIFY = WM_APP+1,
00044         WM_REARRANGERENDERLESS,
00045         WM_RESUMEFROMSTATE
00046 };
00047 
00048 #define WM_MYMOUSELAST WM_XBUTTONDBLCLK
00049 
00051 
00052 extern void CorrectComboListWidth(CComboBox& box, CFont* pWndFont);
00053 extern HICON LoadIcon(CString fn, bool fSmall);
00054 extern bool LoadType(CString fn, CString& type);
00055 extern bool LoadResource(UINT resid, CStringA& str, LPCTSTR restype);
00056 extern CString GetContentType(CString fn, CList<CString>* redir = NULL);
00057 
00059 // CMPlayerCApp:
00060 // See mplayerc.cpp for the implementation of this class
00061 //
00062 
00063 // flags for AppSettings::nCS
00064 enum 
00065 {
00066         CS_NONE=0, 
00067         CS_SEEKBAR=1, 
00068         CS_TOOLBAR=CS_SEEKBAR<<1, 
00069         CS_INFOBAR=CS_TOOLBAR<<1, 
00070         CS_STATSBAR=CS_INFOBAR<<1, 
00071         CS_STATUSBAR=CS_STATSBAR<<1, 
00072         CS_LAST=CS_STATUSBAR
00073 };
00074 
00075 enum
00076 {
00077         CLSW_NONE=0,
00078         CLSW_OPEN=1,
00079         CLSW_PLAY=CLSW_OPEN<<1,
00080         CLSW_CLOSE=CLSW_PLAY<<1,
00081         CLSW_STANDBY=CLSW_CLOSE<<1,
00082         CLSW_HIBERNATE=CLSW_STANDBY<<1,
00083         CLSW_SHUTDOWN=CLSW_HIBERNATE<<1,
00084         CLSW_LOGOFF=CLSW_SHUTDOWN<<1,
00085         CLSW_AFTERPLAYBACK_MASK=CLSW_CLOSE|CLSW_STANDBY|CLSW_SHUTDOWN|CLSW_HIBERNATE|CLSW_LOGOFF,
00086         CLSW_FULLSCREEN=CLSW_LOGOFF<<1,
00087         CLSW_NEW=CLSW_FULLSCREEN<<1,
00088         CLSW_HELP=CLSW_NEW<<1,
00089         CLSW_DVD=CLSW_HELP<<1,
00090         CLSW_CD=CLSW_DVD<<1,
00091         CLSW_ADD=CLSW_CD<<1,
00092         CLSW_MINIMIZED=CLSW_ADD<<1,
00093         CLSW_REGEXTVID=CLSW_MINIMIZED<<1,
00094         CLSW_REGEXTAUD=CLSW_REGEXTVID<<1,
00095         CLSW_UNREGEXTVID=CLSW_REGEXTAUD<<1,
00096         CLSW_UNREGEXTAUD=CLSW_UNREGEXTVID<<1,
00097         CLSW_STARTVALID=CLSW_UNREGEXTAUD<<1,
00098         CLSW_NOFOCUS=CLSW_STARTVALID<<1,
00099         CLSW_FIXEDSIZE=CLSW_NOFOCUS<<1,
00100         CLSW_UNRECOGNIZEDSWITCH=CLSW_FIXEDSIZE<<1       
00101 };
00102 
00103 enum
00104 {
00105         VIDRNDT_DS_DEFAULT,
00106         VIDRNDT_DS_OLDRENDERER,
00107         VIDRNDT_DS_OVERLAYMIXER,
00108         VIDRNDT_DS_VMR7WINDOWED,
00109         VIDRNDT_DS_VMR9WINDOWED,
00110         VIDRNDT_DS_VMR7RENDERLESS,
00111         VIDRNDT_DS_VMR9RENDERLESS,
00112         VIDRNDT_DS_NULL_COMP,
00113         VIDRNDT_DS_NULL_UNCOMP,
00114 };
00115 
00116 enum
00117 {
00118         VIDRNDT_RM_DEFAULT,
00119         VIDRNDT_RM_DX7,
00120         VIDRNDT_RM_DX9,
00121 };
00122 
00123 enum
00124 {
00125         VIDRNDT_QT_DEFAULT,
00126         VIDRNDT_QT_DX7,
00127         VIDRNDT_QT_DX9,
00128 };
00129 
00130 enum
00131 {
00132         VIDRNDT_AP_SURFACE,
00133         VIDRNDT_AP_TEXTURE2D,
00134         VIDRNDT_AP_TEXTURE3D,
00135 };
00136 
00137 #define AUDRNDT_NULL_COMP _T("Null Audio Renderer (Any)")
00138 #define AUDRNDT_NULL_UNCOMP _T("Null Audio Renderer (Uncompressed)")
00139 
00140 enum
00141 {
00142         SRC_CDDA=1, 
00143         SRC_CDXA=SRC_CDDA<<1,
00144         SRC_VTS=SRC_CDXA<<1,
00145         SRC_FLIC=SRC_VTS<<1,
00146         SRC_D2V=SRC_FLIC<<1,
00147         SRC_DTSAC3=SRC_D2V<<1,
00148         SRC_MATROSKA=SRC_DTSAC3<<1,
00149         SRC_SHOUTCAST=SRC_MATROSKA<<1,
00150         SRC_REALMEDIA=SRC_SHOUTCAST<<1,
00151         SRC_AVI=SRC_REALMEDIA<<1,
00152         SRC_RADGT=SRC_AVI<<1,
00153         SRC_ROQ=SRC_RADGT<<1,
00154         SRC_OGG=SRC_ROQ<<1,
00155         SRC_NUT=SRC_OGG<<1,
00156         SRC_MPEG=SRC_NUT<<1,
00157         SRC_DIRAC=SRC_MPEG<<1,
00158         SRC_MPA=SRC_DIRAC<<1,
00159         SRC_DSM=SRC_MPA<<1,
00160         SRC_SUBS=SRC_DSM<<1,
00161         SRC_MP4=SRC_SUBS<<1,
00162         SRC_LAST=SRC_MP4<<1
00163 };
00164 
00165 enum
00166 {
00167         TRA_MPEG1=1, 
00168         TRA_MPEG2=TRA_MPEG1<<1,
00169         TRA_RV=TRA_MPEG2<<1,
00170         TRA_RA=TRA_RV<<1,
00171         TRA_MPA=TRA_RA<<1,
00172         TRA_LPCM=TRA_MPA<<1,
00173         TRA_AC3=TRA_LPCM<<1,
00174         TRA_DTS=TRA_AC3<<1,
00175         TRA_AAC=TRA_DTS<<1,
00176         TRA_PS2AUD=TRA_AAC<<1,
00177         TRA_DIRAC=TRA_PS2AUD<<1,
00178         TRA_LAST=TRA_DIRAC<<1
00179 };
00180 
00181 enum
00182 {
00183         DVS_HALF, 
00184         DVS_NORMAL, 
00185         DVS_DOUBLE, 
00186         DVS_STRETCH, 
00187         DVS_FROMINSIDE, 
00188         DVS_FROMOUTSIDE
00189 };
00190 
00191 typedef enum 
00192 {
00193         FAV_FILE,
00194         FAV_DVD,
00195         FAV_DEVICE
00196 } favtype;
00197 
00198 #pragma pack(push, 1)
00199 typedef struct
00200 {
00201         bool fValid;
00202         CSize size; 
00203         int bpp, freq;
00204 } dispmode;
00205 
00206 class wmcmd : public ACCEL
00207 {
00208         ACCEL backup;
00209         UINT appcmdorg;
00210         UINT mouseorg;
00211 public:
00212         CString name;
00213         UINT appcmd;
00214         enum {NONE,LDOWN,LUP,LDBLCLK,MDOWN,MUP,MDBLCLK,RDOWN,RUP,RDBLCLK,X1DOWN,X1UP,X1DBLCLK,X2DOWN,X2UP,X2DBLCLK,WUP,WDOWN,LAST};
00215         UINT mouse;
00216         CStringA rmcmd;
00217         int rmrepcnt;
00218         wmcmd(WORD cmd = 0) {this->cmd = cmd;}
00219         wmcmd(WORD cmd, WORD key, BYTE fVirt, LPCTSTR name, UINT appcmd = 0, UINT mouse = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5)
00220         {
00221                 this->cmd = cmd;
00222                 this->key = key;
00223                 this->fVirt = fVirt;
00224                 this->appcmd = appcmdorg = appcmd;
00225                 this->name = name;
00226                 this->mouse = mouseorg = mouse;
00227                 this->rmcmd = rmcmd;
00228                 this->rmrepcnt = rmrepcnt;
00229                 backup = *this;
00230         }
00231         bool operator == (const wmcmd& wc) const
00232         {
00233                 return(cmd > 0 && cmd == wc.cmd);
00234         }
00235         void Restore() {*(ACCEL*)this = backup; appcmd = appcmdorg; mouse = mouseorg; rmcmd.Empty(); rmrepcnt = 5;}
00236         bool IsModified() {return(memcmp((const ACCEL*)this, &backup, sizeof(ACCEL)) || appcmd != appcmdorg || mouse != mouseorg || !rmcmd.IsEmpty() || rmrepcnt != 5);}
00237 };
00238 #pragma pack(pop)
00239 
00240 #include <afxsock.h>
00241 
00242 class CRemoteCtrlClient : public CAsyncSocket
00243 {
00244 protected:
00245         CCritSec m_csLock;
00246         CWnd* m_pWnd;
00247         enum {DISCONNECTED, CONNECTED, CONNECTING} m_nStatus;
00248         CString m_addr;
00249 
00250         virtual void OnConnect(int nErrorCode);
00251         virtual void OnClose(int nErrorCode);
00252         virtual void OnReceive(int nErrorCode);
00253 
00254         virtual void OnCommand(CStringA str) = 0;
00255 
00256         void ExecuteCommand(CStringA cmd, int repcnt);
00257 
00258 public:
00259         CRemoteCtrlClient();
00260         void SetHWND(HWND hWnd);
00261         void Connect(CString addr);
00262         int GetStatus() {return(m_nStatus);}
00263 };
00264 
00265 class CWinLircClient : public CRemoteCtrlClient
00266 {
00267 protected:
00268         virtual void OnCommand(CStringA str);
00269 
00270 public:
00271         CWinLircClient();
00272 };
00273 
00274 class CUIceClient : public CRemoteCtrlClient
00275 {
00276 protected:
00277         virtual void OnCommand(CStringA str);
00278 
00279 public:
00280         CUIceClient();
00281 };
00282 
00283 extern void GetCurDispMode(dispmode& dm);
00284 extern bool GetDispMode(int i, dispmode& dm);
00285 extern void SetDispMode(dispmode& dm);
00286 
00287 class CMPlayerCApp : public CWinApp
00288 {
00289         ATL::CMutex m_mutexOneInstance;
00290 
00291         CList<CString> m_cmdln;
00292         void PreProcessCommandLine();
00293         void SendCommandLine(HWND hWnd);
00294 
00295 public:
00296         CMPlayerCApp();
00297 
00298         void ShowCmdlnSwitches();
00299 
00300         bool StoreSettingsToIni();
00301         bool StoreSettingsToRegistry();
00302         CString GetIniPath();
00303         bool IsIniValid();
00304 
00305         bool GetAppDataPath(CString& path);
00306 
00307 // Overrides
00308         // ClassWizard generated virtual function overrides
00309         //{{AFX_VIRTUAL(CMPlayerCApp)
00310         public:
00311         virtual BOOL InitInstance();
00312         virtual int ExitInstance();
00313         //}}AFX_VIRTUAL
00314 
00315 // Implementation
00316 
00317         class Settings
00318         {
00319                 friend class CMPlayerCApp;
00320 
00321                 bool fInitialized;
00322 
00323                 class CRecentFileAndURLList : public CRecentFileList
00324                 {
00325                 public:
00326                         CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
00327                                 LPCTSTR lpszEntryFormat, int nSize,
00328                                 int nMaxDispLen = AFX_ABBREV_FILENAME_LEN);
00329 
00330                         virtual void Add(LPCTSTR lpszPathName); // we have to override CRecentFileList::Add because the original version can't handle URLs
00331                 };
00332 
00333         public:
00334                 // cmdline params
00335                 int nCLSwitches;
00336                 CList<CString> slFiles, slDubs, slSubs, slFilters;
00337                 __int64 rtStart;
00338                 CSize fixedWindowSize;
00339                 bool HasFixedWindowSize() {return fixedWindowSize.cx > 0 || fixedWindowSize.cy > 0;}
00340                 // int iFixedWidth, iFixedHeight;
00341 
00342                 void ParseCommandLine(CList<CString>& cmdln);
00343 
00344                 bool fXpOrBetter;
00345                 int iDXVer;
00346 
00347                 int nCS;
00348                 bool fHideCaptionMenu;
00349                 int iDefaultVideoSize;
00350                 bool fKeepAspectRatio;
00351                 bool fCompMonDeskARDiff;
00352 
00353                 CRecentFileAndURLList MRU;
00354                 CRecentFileAndURLList MRUDub;
00355 
00356                 CAutoPtrList<Filter> filters;
00357 
00358                 int iDSVideoRendererType;
00359                 int iRMVideoRendererType;
00360                 int iQTVideoRendererType;
00361                 int iAPSurfaceUsage;
00362                 bool fVMRSyncFix;
00363                 int iDX9Resizer;
00364 
00365                 int nVolume;
00366                 int nBalance;
00367                 bool fMute;
00368                 int nLoops;
00369                 bool fLoopForever;
00370                 bool fRewind;
00371                 int iZoomLevel;
00372                 // int iVideoRendererType; 
00373                 CStringW AudioRendererDisplayName;
00374                 bool fAutoloadAudio;
00375                 bool fAutoloadSubtitles;
00376                 bool fEnableWorkerThreadForOpening;
00377                 bool fReportFailedPins;
00378 
00379                 bool fAllowMultipleInst;
00380                 int iTitleBarTextStyle;
00381                 int iOnTop;
00382                 bool fTrayIcon;
00383                 bool fRememberZoomLevel;
00384                 bool fShowBarsWhenFullScreen;
00385                 int nShowBarsWhenFullScreenTimeOut;
00386                 dispmode dmFullscreenRes;
00387                 bool fExitFullScreenAtTheEnd;
00388                 bool fRememberWindowPos;
00389                 bool fRememberWindowSize;
00390                 CRect rcLastWindowPos;
00391                 UINT lastWindowType;
00392                 CSize AspectRatio;
00393                 bool fKeepHistory;
00394 
00395                 CString sDVDPath;
00396                 bool fUseDVDPath;
00397                 LCID idMenuLang, idAudioLang, idSubtitlesLang;
00398                 bool fAutoSpeakerConf;
00399 
00400                 STSStyle subdefstyle;
00401                 bool fOverridePlacement;
00402                 int nHorPos, nVerPos;
00403                 int nSPCSize;
00404                 int nSPCMaxRes;
00405                 bool fSPCPow2Tex;
00406 
00407                 bool fDisabeXPToolbars;
00408                 bool fUseWMASFReader;
00409                 int nJumpDistS;
00410                 int nJumpDistM;
00411                 int nJumpDistL;
00412                 bool fFreeWindowResizing;
00413                 bool fNotifyMSN;
00414 
00415                 bool fEnableAudioSwitcher;
00416                 bool fDownSampleTo441;
00417                 bool fAudioTimeShift;
00418                 int tAudioTimeShift;
00419                 bool fCustomChannelMapping;
00420                 DWORD pSpeakerToChannelMap[18][18];
00421 
00422                 bool fIntRealMedia;
00423                 // bool fRealMediaRenderless;
00424                 int iQuickTimeRenderer;
00425                 float RealMediaQuickTimeFPS;
00426 
00427                 CStringArray m_pnspresets;
00428 
00429                 CList<wmcmd> wmcmds;
00430                 HACCEL hAccel;
00431 
00432                 bool fWinLirc;
00433                 CString WinLircAddr;
00434                 CWinLircClient WinLircClient;
00435                 bool fUIce;
00436                 CString UIceAddr;
00437                 CUIceClient UIceClient;
00438 
00439                 CMediaFormats Formats;
00440 
00441                 UINT SrcFilters, TraFilters;
00442 
00443                 CString logofn;
00444                 UINT logoid;
00445                 bool logoext;
00446 
00447                 int mpegdi;
00448                 double mpegbright, mpegcont, mpeghue, mpegsat;
00449                 bool mpegforcedsubs, mpegplanaryuv;
00450                 DWORD mpegpreffmt;
00451 
00452                 int mpasf;
00453                 bool mpanormalize;
00454                 int ac3sc, dtssc, aacsc;
00455                 bool ac3drc, dtsdrc;
00456                 float mpaboost;
00457 
00458                 bool fHideCDROMsSubMenu;
00459 
00460                 DWORD priority;
00461                 bool launchfullscreen;
00462 
00463                 BOOL fEnableWebServer;
00464                 int nWebServerPort;
00465                 bool fWebServerPrintDebugInfo;
00466                 bool fWebServerUseCompression;
00467                 bool fWebServerLocalhostOnly;
00468                 CString WebRoot, WebDefIndex;
00469                 CString WebServerCGI;
00470 
00471                 CString SnapShotPath, SnapShotExt;
00472 
00473                 CString ISDb;
00474 
00475         public:
00476                 Settings();
00477                 virtual ~Settings();
00478                 void UpdateData(bool fSave);
00479 
00480                 void GetFav(favtype ft, CList<CString>& sl);
00481                 void SetFav(favtype ft, CList<CString>& sl);
00482                 void AddFav(favtype ft, CString s);
00483         } m_s;
00484 
00485 public:
00486         DECLARE_MESSAGE_MAP()
00487         afx_msg void OnAppAbout();
00488         afx_msg void OnFileExit();
00489         afx_msg void OnHelpShowcommandlineswitches();
00490 };
00491 
00492 #define AfxGetMyApp() ((CMPlayerCApp*)AfxGetApp())
00493 #define AfxGetAppSettings() ((CMPlayerCApp*)AfxGetApp())->m_s
00494 #define AppSettings CMPlayerCApp::Settings

Generated on Tue Dec 13 14:46:57 2005 for guliverkli by  doxygen 1.4.5