2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 #error include 'stdafx.h' before including this file for PCH
28 #include "resource.h" // main symbols
31 #include "..\..\subtitles\STS.h"
32 #include "MediaFormats.h"
33 #include "fakefiltermapper2.h"
36 #define MPC_WND_CLASS_NAME L"MediaPlayerClassicW"
38 #define MPC_WND_CLASS_NAME "MediaPlayerClassicA"
43 WM_GRAPHNOTIFY
= WM_APP
+1,
44 WM_REARRANGERENDERLESS
,
48 #define WM_MYMOUSELAST WM_XBUTTONDBLCLK
52 extern void CorrectComboListWidth(CComboBox
& box
, CFont
* pWndFont
);
53 extern HICON
LoadIcon(CString fn
, bool fSmall
);
54 extern bool LoadType(CString fn
, CString
& type
);
55 extern bool LoadResource(UINT resid
, CStringA
& str
, LPCTSTR restype
);
56 extern CString
GetContentType(CString fn
, CAtlList
<CString
>* redir
= NULL
);
58 /////////////////////////////////////////////////////////////////////////////
60 // See mplayerc.cpp for the implementation of this class
63 // flags for AppSettings::nCS
68 CS_TOOLBAR
=CS_SEEKBAR
<<1,
69 CS_INFOBAR
=CS_TOOLBAR
<<1,
70 CS_STATSBAR
=CS_INFOBAR
<<1,
71 CS_STATUSBAR
=CS_STATSBAR
<<1,
79 CLSW_PLAY
=CLSW_OPEN
<<1,
80 CLSW_CLOSE
=CLSW_PLAY
<<1,
81 CLSW_STANDBY
=CLSW_CLOSE
<<1,
82 CLSW_HIBERNATE
=CLSW_STANDBY
<<1,
83 CLSW_SHUTDOWN
=CLSW_HIBERNATE
<<1,
84 CLSW_LOGOFF
=CLSW_SHUTDOWN
<<1,
85 CLSW_AFTERPLAYBACK_MASK
=CLSW_CLOSE
|CLSW_STANDBY
|CLSW_SHUTDOWN
|CLSW_HIBERNATE
|CLSW_LOGOFF
,
86 CLSW_FULLSCREEN
=CLSW_LOGOFF
<<1,
87 CLSW_NEW
=CLSW_FULLSCREEN
<<1,
88 CLSW_HELP
=CLSW_NEW
<<1,
89 CLSW_DVD
=CLSW_HELP
<<1,
92 CLSW_MINIMIZED
=CLSW_ADD
<<1,
93 CLSW_REGEXTVID
=CLSW_MINIMIZED
<<1,
94 CLSW_REGEXTAUD
=CLSW_REGEXTVID
<<1,
95 CLSW_UNREGEXT
=CLSW_REGEXTAUD
<<1,
96 CLSW_STARTVALID
=CLSW_UNREGEXT
<<2,
97 CLSW_NOFOCUS
=CLSW_STARTVALID
<<1,
98 CLSW_FIXEDSIZE
=CLSW_NOFOCUS
<<1,
99 CLSW_MONITOR
=CLSW_FIXEDSIZE
<<1,
100 CLSW_UNRECOGNIZEDSWITCH
=CLSW_MONITOR
<<1
106 VIDRNDT_DS_OLDRENDERER
,
107 VIDRNDT_DS_OVERLAYMIXER
,
108 VIDRNDT_DS_VMR7WINDOWED
,
109 VIDRNDT_DS_VMR9WINDOWED
,
110 VIDRNDT_DS_VMR7RENDERLESS
,
111 VIDRNDT_DS_VMR9RENDERLESS
,
113 VIDRNDT_DS_NULL_COMP
,
114 VIDRNDT_DS_NULL_UNCOMP
,
134 VIDRNDT_AP_TEXTURE2D
,
135 VIDRNDT_AP_TEXTURE3D
,
138 #define AUDRNDT_NULL_COMP _T("Null Audio Renderer (Any)")
139 #define AUDRNDT_NULL_UNCOMP _T("Null Audio Renderer (Uncompressed)")
144 SRC_CDXA
=SRC_CDDA
<<1,
148 SRC_DTSAC3
=SRC_D2V
<<1,
149 SRC_MATROSKA
=SRC_DTSAC3
<<1,
150 SRC_SHOUTCAST
=SRC_MATROSKA
<<1,
151 SRC_REALMEDIA
=SRC_SHOUTCAST
<<1,
152 SRC_AVI
=SRC_REALMEDIA
<<1,
153 SRC_RADGT
=SRC_AVI
<<1,
154 SRC_ROQ
=SRC_RADGT
<<1,
158 SRC_DIRAC
=SRC_MPEG
<<1,
159 SRC_MPA
=SRC_DIRAC
<<1,
170 TRA_MPEG2
=TRA_MPEG1
<<1,
178 TRA_PS2AUD
=TRA_AAC
<<1,
179 TRA_DIRAC
=TRA_PS2AUD
<<1,
180 TRA_VORBIS
=TRA_DIRAC
<<1,
181 TRA_LAST
=TRA_VORBIS
<<1,
201 #pragma pack(push, 1)
209 class wmcmd
: public ACCEL
217 enum {NONE
,LDOWN
,LUP
,LDBLCLK
,MDOWN
,MUP
,MDBLCLK
,RDOWN
,RUP
,RDBLCLK
,X1DOWN
,X1UP
,X1DBLCLK
,X2DOWN
,X2UP
,X2DBLCLK
,WUP
,WDOWN
,LAST
};
221 wmcmd(WORD cmd
= 0) {this->cmd
= cmd
;}
222 wmcmd(WORD cmd
, WORD key
, BYTE fVirt
, LPCTSTR name
, UINT appcmd
= 0, UINT mouse
= NONE
, LPCSTR rmcmd
= "", int rmrepcnt
= 5)
227 this->appcmd
= appcmdorg
= appcmd
;
229 this->mouse
= mouseorg
= mouse
;
231 this->rmrepcnt
= rmrepcnt
;
234 bool operator == (const wmcmd
& wc
) const
236 return(cmd
> 0 && cmd
== wc
.cmd
);
238 void Restore() {*(ACCEL
*)this = backup
; appcmd
= appcmdorg
; mouse
= mouseorg
; rmcmd
.Empty(); rmrepcnt
= 5;}
239 bool IsModified() {return(memcmp((const ACCEL
*)this, &backup
, sizeof(ACCEL
)) || appcmd
!= appcmdorg
|| mouse
!= mouseorg
|| !rmcmd
.IsEmpty() || rmrepcnt
!= 5);}
245 class CRemoteCtrlClient
: public CAsyncSocket
250 enum {DISCONNECTED
, CONNECTED
, CONNECTING
} m_nStatus
;
253 virtual void OnConnect(int nErrorCode
);
254 virtual void OnClose(int nErrorCode
);
255 virtual void OnReceive(int nErrorCode
);
257 virtual void OnCommand(CStringA str
) = 0;
259 void ExecuteCommand(CStringA cmd
, int repcnt
);
263 void SetHWND(HWND hWnd
);
264 void Connect(CString addr
);
265 int GetStatus() {return(m_nStatus
);}
268 class CWinLircClient
: public CRemoteCtrlClient
271 virtual void OnCommand(CStringA str
);
277 class CUIceClient
: public CRemoteCtrlClient
280 virtual void OnCommand(CStringA str
);
286 extern void GetCurDispMode(dispmode
& dm
);
287 extern bool GetDispMode(int i
, dispmode
& dm
);
288 extern void SetDispMode(dispmode
& dm
);
290 class CMPlayerCApp
: public CWinApp
292 ATL::CMutex m_mutexOneInstance
;
294 CAtlList
<CString
> m_cmdln
;
295 void PreProcessCommandLine();
296 void SendCommandLine(HWND hWnd
);
301 void ShowCmdlnSwitches();
303 bool StoreSettingsToIni();
304 bool StoreSettingsToRegistry();
305 CString
GetIniPath();
308 bool GetAppDataPath(CString
& path
);
310 static bool IsVistaOrAbove();
311 static bool IsVSFilterInstalled();
314 // ClassWizard generated virtual function overrides
315 //{{AFX_VIRTUAL(CMPlayerCApp)
317 virtual BOOL
InitInstance();
318 virtual int ExitInstance();
325 friend class CMPlayerCApp
;
329 class CRecentFileAndURLList
: public CRecentFileList
332 CRecentFileAndURLList(UINT nStart
, LPCTSTR lpszSection
,
333 LPCTSTR lpszEntryFormat
, int nSize
,
334 int nMaxDispLen
= AFX_ABBREV_FILENAME_LEN
);
336 virtual void Add(LPCTSTR lpszPathName
); // we have to override CRecentFileList::Add because the original version can't handle URLs
342 CAtlList
<CString
> slFiles
, slDubs
, slSubs
, slFilters
;
344 CSize fixedWindowSize
;
345 bool HasFixedWindowSize() {return fixedWindowSize
.cx
> 0 || fixedWindowSize
.cy
> 0;}
346 // int iFixedWidth, iFixedHeight;
349 void ParseCommandLine(CAtlList
<CString
>& cmdln
);
355 bool fHideCaptionMenu
;
356 int iDefaultVideoSize
;
357 bool fKeepAspectRatio
;
358 bool fCompMonDeskARDiff
;
360 CRecentFileAndURLList MRU
;
361 CRecentFileAndURLList MRUDub
;
363 CAutoPtrList
<FilterOverride
> filters
;
365 int iDSVideoRendererType
;
366 int iRMVideoRendererType
;
367 int iQTVideoRendererType
;
381 // int iVideoRendererType;
382 CStringW AudioRendererDisplayName
;
384 bool fAutoloadSubtitles
;
386 bool fEnableWorkerThreadForOpening
;
387 bool fReportFailedPins
;
389 bool fAllowMultipleInst
;
390 int iTitleBarTextStyle
;
391 bool fTitleBarTextTitle
;
394 bool fRememberZoomLevel
;
395 bool fShowBarsWhenFullScreen
;
396 int nShowBarsWhenFullScreenTimeOut
;
397 dispmode dmFullscreenRes
;
398 bool fExitFullScreenAtTheEnd
;
399 bool fRememberWindowPos
;
400 bool fRememberWindowSize
;
401 bool fSnapToDesktopEdges
;
402 CRect rcLastWindowPos
;
409 LCID idMenuLang
, idAudioLang
, idSubtitlesLang
;
410 bool fAutoSpeakerConf
;
412 STSStyle subdefstyle
;
413 bool fOverridePlacement
;
414 int nHorPos
, nVerPos
;
417 int nSubDelayInterval
;
419 bool fEnableSubtitles
;
421 bool fDisabeXPToolbars
;
422 bool fUseWMASFReader
;
426 bool fFreeWindowResizing
;
430 bool fEnableAudioSwitcher
;
431 bool fDownSampleTo441
;
432 bool fAudioTimeShift
;
434 bool fCustomChannelMapping
;
435 DWORD pSpeakerToChannelMap
[18][18];
436 bool fAudioNormalize
;
437 bool fAudioNormalizeRecover
;
441 // bool fRealMediaRenderless;
442 int iQuickTimeRenderer
;
443 float RealMediaQuickTimeFPS
;
445 CStringArray m_pnspresets
;
452 CWinLircClient WinLircClient
;
455 CUIceClient UIceClient
;
457 CMediaFormats Formats
;
459 UINT SrcFilters
, TraFilters
;
465 bool fHideCDROMsSubMenu
;
468 bool launchfullscreen
;
470 BOOL fEnableWebServer
;
472 bool fWebServerPrintDebugInfo
;
473 bool fWebServerUseCompression
;
474 bool fWebServerLocalhostOnly
;
475 CString WebRoot
, WebDefIndex
;
476 CString WebServerCGI
;
478 CString SnapShotPath
, SnapShotExt
;
479 int ThumbRows
, ThumbCols
, ThumbWidth
;
483 struct Shader
{CString label
, target
, srcdata
;};
484 CAtlList
<Shader
> m_shaders
;
485 CString m_shadercombine
;
487 CString strShaderList
;
492 void UpdateData(bool fSave
);
494 void GetFav(favtype ft
, CAtlList
<CString
>& sl
);
495 void SetFav(favtype ft
, CAtlList
<CString
>& sl
);
496 void AddFav(favtype ft
, CString s
);
500 DECLARE_MESSAGE_MAP()
501 afx_msg
void OnAppAbout();
502 afx_msg
void OnFileExit();
503 afx_msg
void OnHelpShowcommandlineswitches();
506 #define AfxGetMyApp() ((CMPlayerCApp*)AfxGetApp())
507 #define AfxGetAppSettings() ((CMPlayerCApp*)AfxGetApp())->m_s
508 #define AppSettings CMPlayerCApp::Settings