Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
commitefbc9d9043ff8ff92716ddd00a5f61412d535593 (patch)
tree8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/apps/mplayerc
parentdf6b139a6d9027156f614b68687e039e3a5854db (diff)
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc')
-rw-r--r--src/apps/mplayerc/AllocatorCommon.cpp420
-rw-r--r--src/apps/mplayerc/AllocatorCommon.h18
-rw-r--r--src/apps/mplayerc/AuthDlg.cpp196
-rw-r--r--src/apps/mplayerc/AuthDlg.h32
-rw-r--r--src/apps/mplayerc/BaseGraph.cpp831
-rw-r--r--src/apps/mplayerc/BaseGraph.h379
-rw-r--r--src/apps/mplayerc/CGdiPlusBitmap.h198
-rw-r--r--src/apps/mplayerc/CShockwaveFlash.h838
-rw-r--r--src/apps/mplayerc/ChildView.cpp516
-rw-r--r--src/apps/mplayerc/ChildView.h49
-rw-r--r--src/apps/mplayerc/ComPropertyPage.cpp62
-rw-r--r--src/apps/mplayerc/ComPropertyPage.h24
-rw-r--r--src/apps/mplayerc/ComPropertySheet.cpp320
-rw-r--r--src/apps/mplayerc/ComPropertySheet.h35
-rw-r--r--src/apps/mplayerc/ConvertChapDlg.cpp56
-rw-r--r--src/apps/mplayerc/ConvertChapDlg.h20
-rw-r--r--src/apps/mplayerc/ConvertDlg.cpp1964
-rw-r--r--src/apps/mplayerc/ConvertDlg.h270
-rw-r--r--src/apps/mplayerc/ConvertPropsDlg.cpp220
-rw-r--r--src/apps/mplayerc/ConvertPropsDlg.h38
-rw-r--r--src/apps/mplayerc/ConvertResDlg.cpp122
-rw-r--r--src/apps/mplayerc/ConvertResDlg.h24
-rw-r--r--src/apps/mplayerc/D3DFont.cpp574
-rw-r--r--src/apps/mplayerc/D3DFont.h64
-rw-r--r--src/apps/mplayerc/DVBChannel.cpp206
-rw-r--r--src/apps/mplayerc/DVBChannel.h228
-rw-r--r--src/apps/mplayerc/DX7AllocatorPresenter.cpp1998
-rw-r--r--src/apps/mplayerc/DX7AllocatorPresenter.h12
-rw-r--r--src/apps/mplayerc/DX9AllocatorPresenter.cpp5704
-rw-r--r--src/apps/mplayerc/DX9AllocatorPresenter.h621
-rw-r--r--src/apps/mplayerc/DXRAllocatorPresenter.cpp285
-rw-r--r--src/apps/mplayerc/DXRAllocatorPresenter.h150
-rw-r--r--src/apps/mplayerc/DeinterlacerFilter.cpp177
-rw-r--r--src/apps/mplayerc/DeinterlacerFilter.h10
-rw-r--r--src/apps/mplayerc/EVRAllocatorPresenter.cpp4016
-rw-r--r--src/apps/mplayerc/EVRAllocatorPresenter.h486
-rw-r--r--src/apps/mplayerc/EditListEditor.cpp820
-rw-r--r--src/apps/mplayerc/EditListEditor.h140
-rw-r--r--src/apps/mplayerc/FGFilter.cpp985
-rw-r--r--src/apps/mplayerc/FGFilter.h157
-rw-r--r--src/apps/mplayerc/FGManager.cpp4149
-rw-r--r--src/apps/mplayerc/FGManager.h176
-rw-r--r--src/apps/mplayerc/FGManagerBDA.cpp1049
-rw-r--r--src/apps/mplayerc/FGManagerBDA.h271
-rw-r--r--src/apps/mplayerc/FakeFilterMapper2.cpp964
-rw-r--r--src/apps/mplayerc/FakeFilterMapper2.h116
-rw-r--r--src/apps/mplayerc/FavoriteAddDlg.cpp60
-rw-r--r--src/apps/mplayerc/FavoriteAddDlg.h28
-rw-r--r--src/apps/mplayerc/FavoriteOrganizeDlg.cpp314
-rw-r--r--src/apps/mplayerc/FavoriteOrganizeDlg.h42
-rw-r--r--src/apps/mplayerc/FileDropTarget.cpp16
-rw-r--r--src/apps/mplayerc/FileDropTarget.h49
-rw-r--r--src/apps/mplayerc/FileVersionInfo.cpp350
-rw-r--r--src/apps/mplayerc/FileVersionInfo.h86
-rw-r--r--src/apps/mplayerc/FloatEdit.cpp122
-rw-r--r--src/apps/mplayerc/FloatEdit.h30
-rw-r--r--src/apps/mplayerc/FullscreenWnd.cpp118
-rw-r--r--src/apps/mplayerc/FullscreenWnd.h30
-rw-r--r--src/apps/mplayerc/GoToDlg.cpp258
-rw-r--r--src/apps/mplayerc/GoToDlg.h32
-rw-r--r--src/apps/mplayerc/IGraphBuilder2.h41
-rw-r--r--src/apps/mplayerc/IPinHook.cpp2252
-rw-r--r--src/apps/mplayerc/IPinHook.h234
-rw-r--r--src/apps/mplayerc/IQTVideoSurface.h7
-rw-r--r--src/apps/mplayerc/ISDb.cpp108
-rw-r--r--src/apps/mplayerc/ISDb.h45
-rw-r--r--src/apps/mplayerc/Ifo.cpp260
-rw-r--r--src/apps/mplayerc/Ifo.h322
-rw-r--r--src/apps/mplayerc/KeyProvider.cpp22
-rw-r--r--src/apps/mplayerc/KeyProvider.h6
-rw-r--r--src/apps/mplayerc/LcdSupport.cpp537
-rw-r--r--src/apps/mplayerc/LcdSupport.h69
-rw-r--r--src/apps/mplayerc/LineNumberEdit.cpp716
-rw-r--r--src/apps/mplayerc/LineNumberEdit.h109
-rw-r--r--src/apps/mplayerc/MacrovisionKicker.cpp66
-rw-r--r--src/apps/mplayerc/MacrovisionKicker.h24
-rw-r--r--src/apps/mplayerc/MainFrm.cpp22712
-rw-r--r--src/apps/mplayerc/MainFrm.h1357
-rw-r--r--src/apps/mplayerc/MediaFormats.cpp480
-rw-r--r--src/apps/mplayerc/MediaFormats.h108
-rw-r--r--src/apps/mplayerc/MediaTypesDlg.cpp138
-rw-r--r--src/apps/mplayerc/MediaTypesDlg.h28
-rw-r--r--src/apps/mplayerc/MiniDump.cpp222
-rw-r--r--src/apps/mplayerc/MiniDump.h19
-rw-r--r--src/apps/mplayerc/Monitors.cpp152
-rw-r--r--src/apps/mplayerc/Monitors.h94
-rw-r--r--src/apps/mplayerc/MpcApi.h286
-rw-r--r--src/apps/mplayerc/Mpeg2SectionData.cpp597
-rw-r--r--src/apps/mplayerc/Mpeg2SectionData.h42
-rw-r--r--src/apps/mplayerc/MultiMonitor.cpp182
-rw-r--r--src/apps/mplayerc/MultiMonitor.h72
-rw-r--r--src/apps/mplayerc/OpenCapDeviceDlg.cpp813
-rw-r--r--src/apps/mplayerc/OpenCapDeviceDlg.h26
-rw-r--r--src/apps/mplayerc/OpenDlg.cpp228
-rw-r--r--src/apps/mplayerc/OpenDlg.h36
-rw-r--r--src/apps/mplayerc/OpenFileDlg.cpp164
-rw-r--r--src/apps/mplayerc/OpenFileDlg.h36
-rw-r--r--src/apps/mplayerc/PPageAccelTbl.cpp2321
-rw-r--r--src/apps/mplayerc/PPageAccelTbl.h78
-rw-r--r--src/apps/mplayerc/PPageAudioSwitcher.cpp494
-rw-r--r--src/apps/mplayerc/PPageAudioSwitcher.h70
-rw-r--r--src/apps/mplayerc/PPageBase.cpp72
-rw-r--r--src/apps/mplayerc/PPageBase.h20
-rw-r--r--src/apps/mplayerc/PPageCapture.cpp847
-rw-r--r--src/apps/mplayerc/PPageCapture.h36
-rw-r--r--src/apps/mplayerc/PPageCasimir.cpp210
-rw-r--r--src/apps/mplayerc/PPageCasimir.h38
-rw-r--r--src/apps/mplayerc/PPageDVD.cpp466
-rw-r--r--src/apps/mplayerc/PPageDVD.h46
-rw-r--r--src/apps/mplayerc/PPageExternalFilters.cpp1100
-rw-r--r--src/apps/mplayerc/PPageExternalFilters.h78
-rw-r--r--src/apps/mplayerc/PPageFileInfoClip.cpp130
-rw-r--r--src/apps/mplayerc/PPageFileInfoClip.h34
-rw-r--r--src/apps/mplayerc/PPageFileInfoDetails.cpp470
-rw-r--r--src/apps/mplayerc/PPageFileInfoDetails.h40
-rw-r--r--src/apps/mplayerc/PPageFileInfoRes.cpp168
-rw-r--r--src/apps/mplayerc/PPageFileInfoRes.h32
-rw-r--r--src/apps/mplayerc/PPageFileInfoSheet.cpp124
-rw-r--r--src/apps/mplayerc/PPageFileInfoSheet.h24
-rw-r--r--src/apps/mplayerc/PPageFileMediaInfo.cpp76
-rw-r--r--src/apps/mplayerc/PPageFileMediaInfo.h26
-rw-r--r--src/apps/mplayerc/PPageFormats.cpp1664
-rw-r--r--src/apps/mplayerc/PPageFormats.h100
-rw-r--r--src/apps/mplayerc/PPageFullscreen.cpp448
-rw-r--r--src/apps/mplayerc/PPageFullscreen.h98
-rw-r--r--src/apps/mplayerc/PPageInternalFilters.cpp458
-rw-r--r--src/apps/mplayerc/PPageInternalFilters.h42
-rw-r--r--src/apps/mplayerc/PPageLogo.cpp204
-rw-r--r--src/apps/mplayerc/PPageLogo.h38
-rw-r--r--src/apps/mplayerc/PPageOutput.cpp696
-rw-r--r--src/apps/mplayerc/PPageOutput.h66
-rw-r--r--src/apps/mplayerc/PPagePlayback.cpp210
-rw-r--r--src/apps/mplayerc/PPagePlayback.h62
-rw-r--r--src/apps/mplayerc/PPagePlayer.cpp220
-rw-r--r--src/apps/mplayerc/PPagePlayer.h56
-rw-r--r--src/apps/mplayerc/PPageSheet.cpp106
-rw-r--r--src/apps/mplayerc/PPageSheet.h69
-rw-r--r--src/apps/mplayerc/PPageSubDB.cpp88
-rw-r--r--src/apps/mplayerc/PPageSubDB.h24
-rw-r--r--src/apps/mplayerc/PPageSubStyle.cpp400
-rw-r--r--src/apps/mplayerc/PPageSubStyle.h124
-rw-r--r--src/apps/mplayerc/PPageSubtitles.cpp264
-rw-r--r--src/apps/mplayerc/PPageSubtitles.h48
-rw-r--r--src/apps/mplayerc/PPageSync.cpp230
-rw-r--r--src/apps/mplayerc/PPageSync.h40
-rw-r--r--src/apps/mplayerc/PPageTweaks.cpp254
-rw-r--r--src/apps/mplayerc/PPageTweaks.h60
-rw-r--r--src/apps/mplayerc/PPageWebServer.cpp306
-rw-r--r--src/apps/mplayerc/PPageWebServer.h54
-rw-r--r--src/apps/mplayerc/PixelShaderCompiler.cpp130
-rw-r--r--src/apps/mplayerc/PixelShaderCompiler.h28
-rw-r--r--src/apps/mplayerc/PlayerCaptureBar.cpp36
-rw-r--r--src/apps/mplayerc/PlayerCaptureBar.h14
-rw-r--r--src/apps/mplayerc/PlayerCaptureDialog.cpp2563
-rw-r--r--src/apps/mplayerc/PlayerCaptureDialog.h737
-rw-r--r--src/apps/mplayerc/PlayerInfoBar.cpp232
-rw-r--r--src/apps/mplayerc/PlayerInfoBar.h36
-rw-r--r--src/apps/mplayerc/PlayerListCtrl.cpp1101
-rw-r--r--src/apps/mplayerc/PlayerListCtrl.h140
-rw-r--r--src/apps/mplayerc/PlayerNavigationBar.cpp102
-rw-r--r--src/apps/mplayerc/PlayerNavigationBar.h18
-rw-r--r--src/apps/mplayerc/PlayerNavigationDialog.cpp214
-rw-r--r--src/apps/mplayerc/PlayerNavigationDialog.h50
-rw-r--r--src/apps/mplayerc/PlayerPlaylistBar.cpp2335
-rw-r--r--src/apps/mplayerc/PlayerPlaylistBar.h138
-rw-r--r--src/apps/mplayerc/PlayerSeekBar.cpp348
-rw-r--r--src/apps/mplayerc/PlayerSeekBar.h62
-rw-r--r--src/apps/mplayerc/PlayerShaderEditorBar.cpp50
-rw-r--r--src/apps/mplayerc/PlayerShaderEditorBar.h16
-rw-r--r--src/apps/mplayerc/PlayerStatusBar.cpp448
-rw-r--r--src/apps/mplayerc/PlayerStatusBar.h54
-rw-r--r--src/apps/mplayerc/PlayerSubresyncBar.cpp2264
-rw-r--r--src/apps/mplayerc/PlayerSubresyncBar.h103
-rw-r--r--src/apps/mplayerc/PlayerToolBar.cpp390
-rw-r--r--src/apps/mplayerc/PlayerToolBar.h58
-rw-r--r--src/apps/mplayerc/Playlist.cpp346
-rw-r--r--src/apps/mplayerc/Playlist.h58
-rw-r--r--src/apps/mplayerc/PnSPresetsDlg.cpp279
-rw-r--r--src/apps/mplayerc/PnSPresetsDlg.h56
-rw-r--r--src/apps/mplayerc/QT9AllocatorPresenter.cpp150
-rw-r--r--src/apps/mplayerc/QT9AllocatorPresenter.h32
-rw-r--r--src/apps/mplayerc/QuicktimeGraph.cpp820
-rw-r--r--src/apps/mplayerc/QuicktimeGraph.h140
-rw-r--r--src/apps/mplayerc/RM9AllocatorPresenter.cpp334
-rw-r--r--src/apps/mplayerc/RM9AllocatorPresenter.h56
-rw-r--r--src/apps/mplayerc/RealMediaGraph.cpp744
-rw-r--r--src/apps/mplayerc/RealMediaGraph.h337
-rw-r--r--src/apps/mplayerc/RealMediaWindowlessSite.cpp754
-rw-r--r--src/apps/mplayerc/RealMediaWindowlessSite.h306
-rw-r--r--src/apps/mplayerc/RegFilterChooserDlg.cpp182
-rw-r--r--src/apps/mplayerc/RegFilterChooserDlg.h30
-rw-r--r--src/apps/mplayerc/SaveDlg.cpp312
-rw-r--r--src/apps/mplayerc/SaveDlg.h40
-rw-r--r--src/apps/mplayerc/SaveTextFileDialog.cpp80
-rw-r--r--src/apps/mplayerc/SaveTextFileDialog.h31
-rw-r--r--src/apps/mplayerc/SaveThumbnailsDialog.cpp68
-rw-r--r--src/apps/mplayerc/SaveThumbnailsDialog.h28
-rw-r--r--src/apps/mplayerc/SelectMediaType.cpp58
-rw-r--r--src/apps/mplayerc/SelectMediaType.h28
-rw-r--r--src/apps/mplayerc/ShaderAutoCompleteDlg.cpp256
-rw-r--r--src/apps/mplayerc/ShaderAutoCompleteDlg.h28
-rw-r--r--src/apps/mplayerc/ShaderCombineDlg.cpp168
-rw-r--r--src/apps/mplayerc/ShaderCombineDlg.h30
-rw-r--r--src/apps/mplayerc/ShaderEditorDlg.cpp684
-rw-r--r--src/apps/mplayerc/ShaderEditorDlg.h80
-rw-r--r--src/apps/mplayerc/ShockwaveGraph.cpp265
-rw-r--r--src/apps/mplayerc/ShockwaveGraph.h94
-rw-r--r--src/apps/mplayerc/StaticLink.cpp288
-rw-r--r--src/apps/mplayerc/StaticLink.h86
-rw-r--r--src/apps/mplayerc/StatusLabel.cpp84
-rw-r--r--src/apps/mplayerc/StatusLabel.h21
-rw-r--r--src/apps/mplayerc/Struct.h350
-rw-r--r--src/apps/mplayerc/SubtitleDlDlg.cpp166
-rw-r--r--src/apps/mplayerc/SubtitleDlDlg.h34
-rw-r--r--src/apps/mplayerc/SyncRenderer.cpp7494
-rw-r--r--src/apps/mplayerc/SyncRenderer.h1229
-rw-r--r--src/apps/mplayerc/TextPassThruFilter.cpp183
-rw-r--r--src/apps/mplayerc/TextPassThruFilter.h22
-rw-r--r--src/apps/mplayerc/TunerScanDlg.cpp216
-rw-r--r--src/apps/mplayerc/TunerScanDlg.h52
-rw-r--r--src/apps/mplayerc/VMR9AllocatorPresenter.cpp1453
-rw-r--r--src/apps/mplayerc/VMR9AllocatorPresenter.h90
-rw-r--r--src/apps/mplayerc/VMROSD.cpp608
-rw-r--r--src/apps/mplayerc/VMROSD.h138
-rw-r--r--src/apps/mplayerc/VolumeCtrl.cpp200
-rw-r--r--src/apps/mplayerc/VolumeCtrl.h24
-rw-r--r--src/apps/mplayerc/WebClientSocket.cpp1328
-rw-r--r--src/apps/mplayerc/WebClientSocket.h57
-rw-r--r--src/apps/mplayerc/WebServer.cpp1111
-rw-r--r--src/apps/mplayerc/WebServer.h44
-rw-r--r--src/apps/mplayerc/WebServerSocket.cpp14
-rw-r--r--src/apps/mplayerc/WebServerSocket.h8
-rw-r--r--src/apps/mplayerc/jpeg.cpp490
-rw-r--r--src/apps/mplayerc/jpeg.h56
-rw-r--r--src/apps/mplayerc/jpeg_tables.h400
-rw-r--r--src/apps/mplayerc/libpng.c88
-rw-r--r--src/apps/mplayerc/libpng.h52
-rw-r--r--src/apps/mplayerc/madVRAllocatorPresenter.cpp285
-rw-r--r--src/apps/mplayerc/madVRAllocatorPresenter.h150
-rw-r--r--src/apps/mplayerc/mpciconlib.cpp208
-rw-r--r--src/apps/mplayerc/mpciconlib.h2
-rw-r--r--src/apps/mplayerc/mplayerc.cpp5869
-rw-r--r--src/apps/mplayerc/mplayerc.h1314
-rw-r--r--src/apps/mplayerc/pngdib.c2846
-rw-r--r--src/apps/mplayerc/pngdib.h299
-rw-r--r--src/apps/mplayerc/stdafx.h2
246 files changed, 59880 insertions, 63586 deletions
diff --git a/src/apps/mplayerc/AllocatorCommon.cpp b/src/apps/mplayerc/AllocatorCommon.cpp
index dbed96574..6dd5f5ed7 100644
--- a/src/apps/mplayerc/AllocatorCommon.cpp
+++ b/src/apps/mplayerc/AllocatorCommon.cpp
@@ -31,287 +31,195 @@
bool IsVMR9InGraph(IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF)
- if(CComQIPtr<IVMRWindowlessControl9>(pBF)) return(true);
- EndEnumFilters
- return(false);
+ BeginEnumFilters(pFG, pEF, pBF)
+ if(CComQIPtr<IVMRWindowlessControl9>(pBF)) return(true);
+ EndEnumFilters
+ return(false);
}
//
HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
{
- CheckPointer(ppAP, E_POINTER);
+ CheckPointer(ppAP, E_POINTER);
- *ppAP = NULL;
+ *ppAP = NULL;
- using namespace DSObjects;
+ using namespace DSObjects;
- HRESULT hr = E_FAIL;
- CString Error;
- if(clsid == CLSID_VMR9AllocatorPresenter && !(*ppAP = DNew CVMR9AllocatorPresenter(hWnd, hr, Error))
- || clsid == CLSID_RM9AllocatorPresenter && !(*ppAP = DNew CRM9AllocatorPresenter(hWnd, hr, Error))
- || clsid == CLSID_QT9AllocatorPresenter && !(*ppAP = DNew CQT9AllocatorPresenter(hWnd, hr, Error))
- || clsid == CLSID_DXRAllocatorPresenter && !(*ppAP = DNew CDXRAllocatorPresenter(hWnd, hr, Error))
- || clsid == CLSID_madVRAllocatorPresenter && !(*ppAP = DNew CmadVRAllocatorPresenter(hWnd, hr, Error)))
- return E_OUTOFMEMORY;
+ HRESULT hr = E_FAIL;
+ CString Error;
+ if(clsid == CLSID_VMR9AllocatorPresenter && !(*ppAP = DNew CVMR9AllocatorPresenter(hWnd, hr, Error))
+ || clsid == CLSID_RM9AllocatorPresenter && !(*ppAP = DNew CRM9AllocatorPresenter(hWnd, hr, Error))
+ || clsid == CLSID_QT9AllocatorPresenter && !(*ppAP = DNew CQT9AllocatorPresenter(hWnd, hr, Error))
+ || clsid == CLSID_DXRAllocatorPresenter && !(*ppAP = DNew CDXRAllocatorPresenter(hWnd, hr, Error))
+ || clsid == CLSID_madVRAllocatorPresenter && !(*ppAP = DNew CmadVRAllocatorPresenter(hWnd, hr, Error)))
+ return E_OUTOFMEMORY;
- if(*ppAP == NULL)
- return E_FAIL;
+ if(*ppAP == NULL)
+ return E_FAIL;
- (*ppAP)->AddRef();
+ (*ppAP)->AddRef();
- if(FAILED(hr))
- {
- Error += L"\n";
- Error += GetWindowsErrorMessage(hr, NULL);
+ if(FAILED(hr))
+ {
+ Error += L"\n";
+ Error += GetWindowsErrorMessage(hr, NULL);
- MessageBox(hWnd, Error, L"Error creating DX9 allocation presenter", MB_OK | MB_ICONERROR);
- (*ppAP)->Release();
- *ppAP = NULL;
- }
- else if(!Error.IsEmpty())
- {
- MessageBox(hWnd, Error, L"Warning creating DX9 allocation presenter", MB_OK | MB_ICONWARNING);
- }
+ MessageBox(hWnd, Error, L"Error creating DX9 allocation presenter", MB_OK|MB_ICONERROR);
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ }
+ else if (!Error.IsEmpty())
+ {
+ MessageBox(hWnd, Error, L"Warning creating DX9 allocation presenter", MB_OK|MB_ICONWARNING);
+ }
- return hr;
+ return hr;
}
HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
{
- HRESULT hr = E_FAIL;
- if(clsid == CLSID_EVRAllocatorPresenter)
- {
- CString Error;
- *ppAP = DNew DSObjects::CEVRAllocatorPresenter(hWnd, hr, Error);
- (*ppAP)->AddRef();
-
- if(FAILED(hr))
- {
- Error += L"\n";
- Error += GetWindowsErrorMessage(hr, NULL);
- MessageBox(hWnd, Error, L"Error creating EVR Custom renderer", MB_OK | MB_ICONERROR);
- (*ppAP)->Release();
- *ppAP = NULL;
- }
- else if(!Error.IsEmpty())
- {
- MessageBox(hWnd, Error, L"Warning creating EVR Custom renderer", MB_OK | MB_ICONWARNING);
- }
- }
-
- return hr;
+ HRESULT hr = E_FAIL;
+ if (clsid == CLSID_EVRAllocatorPresenter)
+ {
+ CString Error;
+ *ppAP = DNew DSObjects::CEVRAllocatorPresenter(hWnd, hr, Error);
+ (*ppAP)->AddRef();
+
+ if(FAILED(hr))
+ {
+ Error += L"\n";
+ Error += GetWindowsErrorMessage(hr, NULL);
+ MessageBox(hWnd, Error, L"Error creating EVR Custom renderer", MB_OK | MB_ICONERROR);
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ }
+ else if (!Error.IsEmpty())
+ {
+ MessageBox(hWnd, Error, L"Warning creating EVR Custom renderer", MB_OK|MB_ICONWARNING);
+ }
+ }
+
+ return hr;
}
CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module)
{
- switch(_Error)
- {
- case D3DERR_WRONGTEXTUREFORMAT :
- return _T("D3DERR_WRONGTEXTUREFORMAT");
- case D3DERR_UNSUPPORTEDCOLOROPERATION :
- return _T("D3DERR_UNSUPPORTEDCOLOROPERATION");
- case D3DERR_UNSUPPORTEDCOLORARG :
- return _T("D3DERR_UNSUPPORTEDCOLORARG");
- case D3DERR_UNSUPPORTEDALPHAOPERATION :
- return _T("D3DERR_UNSUPPORTEDALPHAOPERATION");
- case D3DERR_UNSUPPORTEDALPHAARG :
- return _T("D3DERR_UNSUPPORTEDALPHAARG");
- case D3DERR_TOOMANYOPERATIONS :
- return _T("D3DERR_TOOMANYOPERATIONS");
- case D3DERR_CONFLICTINGTEXTUREFILTER :
- return _T("D3DERR_CONFLICTINGTEXTUREFILTER");
- case D3DERR_UNSUPPORTEDFACTORVALUE :
- return _T("D3DERR_UNSUPPORTEDFACTORVALUE");
- case D3DERR_CONFLICTINGRENDERSTATE :
- return _T("D3DERR_CONFLICTINGRENDERSTATE");
- case D3DERR_UNSUPPORTEDTEXTUREFILTER :
- return _T("D3DERR_UNSUPPORTEDTEXTUREFILTER");
- case D3DERR_CONFLICTINGTEXTUREPALETTE :
- return _T("D3DERR_CONFLICTINGTEXTUREPALETTE");
- case D3DERR_DRIVERINTERNALERROR :
- return _T("D3DERR_DRIVERINTERNALERROR");
- case D3DERR_NOTFOUND :
- return _T("D3DERR_NOTFOUND");
- case D3DERR_MOREDATA :
- return _T("D3DERR_MOREDATA");
- case D3DERR_DEVICELOST :
- return _T("D3DERR_DEVICELOST");
- case D3DERR_DEVICENOTRESET :
- return _T("D3DERR_DEVICENOTRESET");
- case D3DERR_NOTAVAILABLE :
- return _T("D3DERR_NOTAVAILABLE");
- case D3DERR_OUTOFVIDEOMEMORY :
- return _T("D3DERR_OUTOFVIDEOMEMORY");
- case D3DERR_INVALIDDEVICE :
- return _T("D3DERR_INVALIDDEVICE");
- case D3DERR_INVALIDCALL :
- return _T("D3DERR_INVALIDCALL");
- case D3DERR_DRIVERINVALIDCALL :
- return _T("D3DERR_DRIVERINVALIDCALL");
- case D3DERR_WASSTILLDRAWING :
- return _T("D3DERR_WASSTILLDRAWING");
- case D3DOK_NOAUTOGEN :
- return _T("D3DOK_NOAUTOGEN");
- case D3DERR_DEVICEREMOVED :
- return _T("D3DERR_DEVICEREMOVED");
- case S_NOT_RESIDENT :
- return _T("S_NOT_RESIDENT");
- case S_RESIDENT_IN_SHARED_MEMORY :
- return _T("S_RESIDENT_IN_SHARED_MEMORY");
- case S_PRESENT_MODE_CHANGED :
- return _T("S_PRESENT_MODE_CHANGED");
- case S_PRESENT_OCCLUDED :
- return _T("S_PRESENT_OCCLUDED");
- case D3DERR_DEVICEHUNG :
- return _T("D3DERR_DEVICEHUNG");
- }
-
- CString errmsg;
- LPVOID lpMsgBuf;
- if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
- _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
- {
- errmsg = (LPCTSTR)lpMsgBuf;
- LocalFree(lpMsgBuf);
- }
- CString Temp;
- Temp.Format(L"0x%08x ", _Error);
- return Temp + errmsg;
+ switch (_Error)
+ {
+ case D3DERR_WRONGTEXTUREFORMAT : return _T("D3DERR_WRONGTEXTUREFORMAT");
+ case D3DERR_UNSUPPORTEDCOLOROPERATION : return _T("D3DERR_UNSUPPORTEDCOLOROPERATION");
+ case D3DERR_UNSUPPORTEDCOLORARG : return _T("D3DERR_UNSUPPORTEDCOLORARG");
+ case D3DERR_UNSUPPORTEDALPHAOPERATION : return _T("D3DERR_UNSUPPORTEDALPHAOPERATION");
+ case D3DERR_UNSUPPORTEDALPHAARG : return _T("D3DERR_UNSUPPORTEDALPHAARG");
+ case D3DERR_TOOMANYOPERATIONS : return _T("D3DERR_TOOMANYOPERATIONS");
+ case D3DERR_CONFLICTINGTEXTUREFILTER : return _T("D3DERR_CONFLICTINGTEXTUREFILTER");
+ case D3DERR_UNSUPPORTEDFACTORVALUE : return _T("D3DERR_UNSUPPORTEDFACTORVALUE");
+ case D3DERR_CONFLICTINGRENDERSTATE : return _T("D3DERR_CONFLICTINGRENDERSTATE");
+ case D3DERR_UNSUPPORTEDTEXTUREFILTER : return _T("D3DERR_UNSUPPORTEDTEXTUREFILTER");
+ case D3DERR_CONFLICTINGTEXTUREPALETTE : return _T("D3DERR_CONFLICTINGTEXTUREPALETTE");
+ case D3DERR_DRIVERINTERNALERROR : return _T("D3DERR_DRIVERINTERNALERROR");
+ case D3DERR_NOTFOUND : return _T("D3DERR_NOTFOUND");
+ case D3DERR_MOREDATA : return _T("D3DERR_MOREDATA");
+ case D3DERR_DEVICELOST : return _T("D3DERR_DEVICELOST");
+ case D3DERR_DEVICENOTRESET : return _T("D3DERR_DEVICENOTRESET");
+ case D3DERR_NOTAVAILABLE : return _T("D3DERR_NOTAVAILABLE");
+ case D3DERR_OUTOFVIDEOMEMORY : return _T("D3DERR_OUTOFVIDEOMEMORY");
+ case D3DERR_INVALIDDEVICE : return _T("D3DERR_INVALIDDEVICE");
+ case D3DERR_INVALIDCALL : return _T("D3DERR_INVALIDCALL");
+ case D3DERR_DRIVERINVALIDCALL : return _T("D3DERR_DRIVERINVALIDCALL");
+ case D3DERR_WASSTILLDRAWING : return _T("D3DERR_WASSTILLDRAWING");
+ case D3DOK_NOAUTOGEN : return _T("D3DOK_NOAUTOGEN");
+ case D3DERR_DEVICEREMOVED : return _T("D3DERR_DEVICEREMOVED");
+ case S_NOT_RESIDENT : return _T("S_NOT_RESIDENT");
+ case S_RESIDENT_IN_SHARED_MEMORY : return _T("S_RESIDENT_IN_SHARED_MEMORY");
+ case S_PRESENT_MODE_CHANGED : return _T("S_PRESENT_MODE_CHANGED");
+ case S_PRESENT_OCCLUDED : return _T("S_PRESENT_OCCLUDED");
+ case D3DERR_DEVICEHUNG : return _T("D3DERR_DEVICEHUNG");
+ }
+
+ CString errmsg;
+ LPVOID lpMsgBuf;
+ if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
+ _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
+ {
+ errmsg = (LPCTSTR)lpMsgBuf;
+ LocalFree(lpMsgBuf);
+ }
+ CString Temp;
+ Temp.Format(L"0x%08x ", _Error);
+ return Temp + errmsg;
}
const wchar_t *GetD3DFormatStr(D3DFORMAT Format)
{
- switch(Format)
- {
- case D3DFMT_R8G8B8 :
- return L"R8G8B8";
- case D3DFMT_A8R8G8B8 :
- return L"A8R8G8B8";
- case D3DFMT_X8R8G8B8 :
- return L"X8R8G8B8";
- case D3DFMT_R5G6B5 :
- return L"R5G6B5";
- case D3DFMT_X1R5G5B5 :
- return L"X1R5G5B5";
- case D3DFMT_A1R5G5B5 :
- return L"A1R5G5B5";
- case D3DFMT_A4R4G4B4 :
- return L"A4R4G4B4";
- case D3DFMT_R3G3B2 :
- return L"R3G3B2";
- case D3DFMT_A8 :
- return L"A8";
- case D3DFMT_A8R3G3B2 :
- return L"A8R3G3B2";
- case D3DFMT_X4R4G4B4 :
- return L"X4R4G4B4";
- case D3DFMT_A2B10G10R10:
- return L"A2B10G10R10";
- case D3DFMT_A8B8G8R8 :
- return L"A8B8G8R8";
- case D3DFMT_X8B8G8R8 :
- return L"X8B8G8R8";
- case D3DFMT_G16R16 :
- return L"G16R16";
- case D3DFMT_A2R10G10B10:
- return L"A2R10G10B10";
- case D3DFMT_A16B16G16R16 :
- return L"A16B16G16R16";
- case D3DFMT_A8P8 :
- return L"A8P8";
- case D3DFMT_P8 :
- return L"P8";
- case D3DFMT_L8 :
- return L"L8";
- case D3DFMT_A8L8 :
- return L"A8L8";
- case D3DFMT_A4L4 :
- return L"A4L4";
- case D3DFMT_V8U8 :
- return L"V8U8";
- case D3DFMT_L6V5U5 :
- return L"L6V5U5";
- case D3DFMT_X8L8V8U8 :
- return L"X8L8V8U8";
- case D3DFMT_Q8W8V8U8 :
- return L"Q8W8V8U8";
- case D3DFMT_V16U16 :
- return L"V16U16";
- case D3DFMT_A2W10V10U10:
- return L"A2W10V10U10";
- case D3DFMT_UYVY :
- return L"UYVY";
- case D3DFMT_R8G8_B8G8:
- return L"R8G8_B8G8";
- case D3DFMT_YUY2 :
- return L"YUY2";
- case D3DFMT_G8R8_G8B8:
- return L"G8R8_G8B8";
- case D3DFMT_DXT1 :
- return L"DXT1";
- case D3DFMT_DXT2 :
- return L"DXT2";
- case D3DFMT_DXT3 :
- return L"DXT3";
- case D3DFMT_DXT4 :
- return L"DXT4";
- case D3DFMT_DXT5 :
- return L"DXT5";
- case D3DFMT_D16_LOCKABLE :
- return L"D16_LOCKABLE";
- case D3DFMT_D32:
- return L"D32";
- case D3DFMT_D15S1:
- return L"D15S1";
- case D3DFMT_D24S8:
- return L"D24S8";
- case D3DFMT_D24X8:
- return L"D24X8";
- case D3DFMT_D24X4S4:
- return L"D24X4S4";
- case D3DFMT_D16:
- return L"D16";
- case D3DFMT_D32F_LOCKABLE:
- return L"D32F_LOCKABLE";
- case D3DFMT_D24FS8 :
- return L"D24FS8";
- case D3DFMT_D32_LOCKABLE :
- return L"D32_LOCKABLE";
- case D3DFMT_S8_LOCKABLE:
- return L"S8_LOCKABLE";
- case D3DFMT_L16:
- return L"L16";
- case D3DFMT_VERTEXDATA :
- return L"VERTEXDATA";
- case D3DFMT_INDEX16:
- return L"INDEX16";
- case D3DFMT_INDEX32:
- return L"INDEX32";
- case D3DFMT_Q16W16V16U16 :
- return L"Q16W16V16U16";
- case D3DFMT_MULTI2_ARGB8 :
- return L"MULTI2_ARGB8";
- case D3DFMT_R16F :
- return L"R16F";
- case D3DFMT_G16R16F:
- return L"G16R16F";
- case D3DFMT_A16B16G16R16F:
- return L"A16B16G16R16F";
- case D3DFMT_R32F :
- return L"R32F";
- case D3DFMT_G32R32F:
- return L"G32R32F";
- case D3DFMT_A32B32G32R32F:
- return L"A32B32G32R32F";
- case D3DFMT_CxV8U8 :
- return L"CxV8U8";
- case D3DFMT_A1 :
- return L"A1";
- case D3DFMT_BINARYBUFFER :
- return L"BINARYBUFFER";
- }
- return L"Unknown";
+ switch (Format)
+ {
+ case D3DFMT_R8G8B8 : return L"R8G8B8";
+ case D3DFMT_A8R8G8B8 : return L"A8R8G8B8";
+ case D3DFMT_X8R8G8B8 : return L"X8R8G8B8";
+ case D3DFMT_R5G6B5 : return L"R5G6B5";
+ case D3DFMT_X1R5G5B5 : return L"X1R5G5B5";
+ case D3DFMT_A1R5G5B5 : return L"A1R5G5B5";
+ case D3DFMT_A4R4G4B4 : return L"A4R4G4B4";
+ case D3DFMT_R3G3B2 : return L"R3G3B2";
+ case D3DFMT_A8 : return L"A8";
+ case D3DFMT_A8R3G3B2 : return L"A8R3G3B2";
+ case D3DFMT_X4R4G4B4 : return L"X4R4G4B4";
+ case D3DFMT_A2B10G10R10: return L"A2B10G10R10";
+ case D3DFMT_A8B8G8R8 : return L"A8B8G8R8";
+ case D3DFMT_X8B8G8R8 : return L"X8B8G8R8";
+ case D3DFMT_G16R16 : return L"G16R16";
+ case D3DFMT_A2R10G10B10: return L"A2R10G10B10";
+ case D3DFMT_A16B16G16R16 : return L"A16B16G16R16";
+ case D3DFMT_A8P8 : return L"A8P8";
+ case D3DFMT_P8 : return L"P8";
+ case D3DFMT_L8 : return L"L8";
+ case D3DFMT_A8L8 : return L"A8L8";
+ case D3DFMT_A4L4 : return L"A4L4";
+ case D3DFMT_V8U8 : return L"V8U8";
+ case D3DFMT_L6V5U5 : return L"L6V5U5";
+ case D3DFMT_X8L8V8U8 : return L"X8L8V8U8";
+ case D3DFMT_Q8W8V8U8 : return L"Q8W8V8U8";
+ case D3DFMT_V16U16 : return L"V16U16";
+ case D3DFMT_A2W10V10U10: return L"A2W10V10U10";
+ case D3DFMT_UYVY : return L"UYVY";
+ case D3DFMT_R8G8_B8G8: return L"R8G8_B8G8";
+ case D3DFMT_YUY2 : return L"YUY2";
+ case D3DFMT_G8R8_G8B8: return L"G8R8_G8B8";
+ case D3DFMT_DXT1 : return L"DXT1";
+ case D3DFMT_DXT2 : return L"DXT2";
+ case D3DFMT_DXT3 : return L"DXT3";
+ case D3DFMT_DXT4 : return L"DXT4";
+ case D3DFMT_DXT5 : return L"DXT5";
+ case D3DFMT_D16_LOCKABLE : return L"D16_LOCKABLE";
+ case D3DFMT_D32: return L"D32";
+ case D3DFMT_D15S1: return L"D15S1";
+ case D3DFMT_D24S8: return L"D24S8";
+ case D3DFMT_D24X8: return L"D24X8";
+ case D3DFMT_D24X4S4: return L"D24X4S4";
+ case D3DFMT_D16: return L"D16";
+ case D3DFMT_D32F_LOCKABLE: return L"D32F_LOCKABLE";
+ case D3DFMT_D24FS8 : return L"D24FS8";
+ case D3DFMT_D32_LOCKABLE : return L"D32_LOCKABLE";
+ case D3DFMT_S8_LOCKABLE: return L"S8_LOCKABLE";
+ case D3DFMT_L16: return L"L16";
+ case D3DFMT_VERTEXDATA : return L"VERTEXDATA";
+ case D3DFMT_INDEX16: return L"INDEX16";
+ case D3DFMT_INDEX32: return L"INDEX32";
+ case D3DFMT_Q16W16V16U16 : return L"Q16W16V16U16";
+ case D3DFMT_MULTI2_ARGB8 : return L"MULTI2_ARGB8";
+ case D3DFMT_R16F : return L"R16F";
+ case D3DFMT_G16R16F: return L"G16R16F";
+ case D3DFMT_A16B16G16R16F: return L"A16B16G16R16F";
+ case D3DFMT_R32F : return L"R32F";
+ case D3DFMT_G32R32F: return L"G32R32F";
+ case D3DFMT_A32B32G32R32F: return L"A32B32G32R32F";
+ case D3DFMT_CxV8U8 : return L"CxV8U8";
+ case D3DFMT_A1 : return L"A1";
+ case D3DFMT_BINARYBUFFER : return L"BINARYBUFFER";
+ }
+ return L"Unknown";
}
diff --git a/src/apps/mplayerc/AllocatorCommon.h b/src/apps/mplayerc/AllocatorCommon.h
index 2f9b29624..713cc2941 100644
--- a/src/apps/mplayerc/AllocatorCommon.h
+++ b/src/apps/mplayerc/AllocatorCommon.h
@@ -32,26 +32,26 @@
// {4E4834FA-22C2-40e2-9446-F77DD05D245E}
DEFINE_GUID(CLSID_VMR9AllocatorPresenter,
- 0x4e4834fa, 0x22c2, 0x40e2, 0x94, 0x46, 0xf7, 0x7d, 0xd0, 0x5d, 0x24, 0x5e);
+ 0x4e4834fa, 0x22c2, 0x40e2, 0x94, 0x46, 0xf7, 0x7d, 0xd0, 0x5d, 0x24, 0x5e);
// {A1542F93-EB53-4e11-8D34-05C57ABA9207}
DEFINE_GUID(CLSID_RM9AllocatorPresenter,
- 0xa1542f93, 0xeb53, 0x4e11, 0x8d, 0x34, 0x5, 0xc5, 0x7a, 0xba, 0x92, 0x7);
+ 0xa1542f93, 0xeb53, 0x4e11, 0x8d, 0x34, 0x5, 0xc5, 0x7a, 0xba, 0x92, 0x7);
// {622A4032-70CE-4040-8231-0F24F2886618}
DEFINE_GUID(CLSID_QT9AllocatorPresenter,
- 0x622a4032, 0x70ce, 0x4040, 0x82, 0x31, 0xf, 0x24, 0xf2, 0x88, 0x66, 0x18);
+ 0x622a4032, 0x70ce, 0x4040, 0x82, 0x31, 0xf, 0x24, 0xf2, 0x88, 0x66, 0x18);
// {B72EBDD4-831D-440f-A656-B48F5486CD82}
-DEFINE_GUID(CLSID_DXRAllocatorPresenter,
- 0xb72ebdd4, 0x831d, 0x440f, 0xa6, 0x56, 0xb4, 0x8f, 0x54, 0x86, 0xcd, 0x82);
+DEFINE_GUID(CLSID_DXRAllocatorPresenter,
+ 0xb72ebdd4, 0x831d, 0x440f, 0xa6, 0x56, 0xb4, 0x8f, 0x54, 0x86, 0xcd, 0x82);
// {C7ED3100-9002-4595-9DCA-B30B30413429}
-DEFINE_GUID(CLSID_madVRAllocatorPresenter,
- 0xc7ed3100, 0x9002, 0x4595, 0x9d, 0xca, 0xb3, 0xb, 0x30, 0x41, 0x34, 0x29);
+DEFINE_GUID(CLSID_madVRAllocatorPresenter,
+ 0xc7ed3100, 0x9002, 0x4595, 0x9d, 0xca, 0xb3, 0xb, 0x30, 0x41, 0x34, 0x29);
-DEFINE_GUID(CLSID_EVRAllocatorPresenter,
- 0x7612b889, 0xe070, 0x4bcc, 0xb8, 0x8, 0x91, 0xcb, 0x79, 0x41, 0x74, 0xab);
+DEFINE_GUID(CLSID_EVRAllocatorPresenter,
+ 0x7612b889, 0xe070, 0x4bcc, 0xb8, 0x8, 0x91, 0xcb, 0x79, 0x41, 0x74, 0xab);
extern CCritSec g_ffdshowReceive;
extern bool queue_ffdshow_support;
diff --git a/src/apps/mplayerc/AuthDlg.cpp b/src/apps/mplayerc/AuthDlg.cpp
index e7250de71..607adc2b2 100644
--- a/src/apps/mplayerc/AuthDlg.cpp
+++ b/src/apps/mplayerc/AuthDlg.cpp
@@ -31,10 +31,10 @@
IMPLEMENT_DYNAMIC(CAuthDlg, CDialog)
CAuthDlg::CAuthDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CAuthDlg::IDD, pParent)
- , m_username(_T(""))
- , m_password(_T(""))
- , m_remember(FALSE)
+ : CDialog(CAuthDlg::IDD, pParent)
+ , m_username(_T(""))
+ , m_password(_T(""))
+ , m_remember(FALSE)
{
}
@@ -44,25 +44,25 @@ CAuthDlg::~CAuthDlg()
void CAuthDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_usernamectrl);
- DDX_Text(pDX, IDC_COMBO1, m_username);
- DDX_Text(pDX, IDC_EDIT3, m_password);
- DDX_Check(pDX, IDC_CHECK1, m_remember);
+ CDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_usernamectrl);
+ DDX_Text(pDX, IDC_COMBO1, m_username);
+ DDX_Text(pDX, IDC_EDIT3, m_password);
+ DDX_Check(pDX, IDC_CHECK1, m_remember);
}
CString CAuthDlg::DEncrypt(CString str)
{
- for(int i = 0; i < str.GetLength(); i++)
- str.SetAt(i, str[i] ^ 5);
- return str;
+ for(int i = 0; i < str.GetLength(); i++)
+ str.SetAt(i, str[i]^5);
+ return str;
}
BEGIN_MESSAGE_MAP(CAuthDlg, CDialog)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
- ON_EN_SETFOCUS(IDC_EDIT3, OnEnSetfocusEdit3)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
+ ON_EN_SETFOCUS(IDC_EDIT3, OnEnSetfocusEdit3)
END_MESSAGE_MAP()
@@ -70,102 +70,102 @@ END_MESSAGE_MAP()
BOOL CAuthDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
-
- CWinApp* pApp = AfxGetApp();
-
- if(pApp->m_pszRegistryKey)
- {
- CRegKey hSecKey(pApp->GetSectionKey(IDS_R_LOGINS));
- if(hSecKey)
- {
- int i = 0;
- TCHAR username[256], password[256];
- while(1)
- {
- DWORD unlen = countof(username);
- DWORD pwlen = sizeof(password);
- DWORD type = REG_SZ;
- if(ERROR_SUCCESS == RegEnumValue(
- hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen))
- {
- m_logins[username] = DEncrypt(password);
- m_usernamectrl.AddString(username);
- }
- else
- {
- break;
- }
- }
- }
- }
- else
- {
- CAutoVectorPtr<TCHAR> buff;
- buff.Allocate(32767 / sizeof(TCHAR));
-
- DWORD len = GetPrivateProfileSection(
- IDS_R_LOGINS, buff, 32767 / sizeof(TCHAR), pApp->m_pszProfileName);
-
- TCHAR* p = buff;
- while(*p && len > 0)
- {
- CString str = p;
- p += str.GetLength() + 1;
- len -= str.GetLength() + 1;
- CAtlList<CString> sl;
- Explode(str, sl, '=', 2);
- if(sl.GetCount() == 2)
- {
- m_logins[sl.GetHead()] = DEncrypt(sl.GetTail());
- m_usernamectrl.AddString(sl.GetHead());
- }
- }
- }
-
- m_usernamectrl.SetFocus();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ CDialog::OnInitDialog();
+
+ CWinApp* pApp = AfxGetApp();
+
+ if(pApp->m_pszRegistryKey)
+ {
+ CRegKey hSecKey(pApp->GetSectionKey(IDS_R_LOGINS));
+ if(hSecKey)
+ {
+ int i = 0;
+ TCHAR username[256], password[256];
+ while(1)
+ {
+ DWORD unlen = countof(username);
+ DWORD pwlen = sizeof(password);
+ DWORD type = REG_SZ;
+ if(ERROR_SUCCESS == RegEnumValue(
+ hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen))
+ {
+ m_logins[username] = DEncrypt(password);
+ m_usernamectrl.AddString(username);
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ CAutoVectorPtr<TCHAR> buff;
+ buff.Allocate(32767/sizeof(TCHAR));
+
+ DWORD len = GetPrivateProfileSection(
+ IDS_R_LOGINS, buff, 32767/sizeof(TCHAR), pApp->m_pszProfileName);
+
+ TCHAR* p = buff;
+ while(*p && len > 0)
+ {
+ CString str = p;
+ p += str.GetLength()+1;
+ len -= str.GetLength()+1;
+ CAtlList<CString> sl;
+ Explode(str, sl, '=', 2);
+ if(sl.GetCount() == 2)
+ {
+ m_logins[sl.GetHead()] = DEncrypt(sl.GetTail());
+ m_usernamectrl.AddString(sl.GetHead());
+ }
+ }
+ }
+
+ m_usernamectrl.SetFocus();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CAuthDlg::OnBnClickedOk()
{
- UpdateData();
+ UpdateData();
- if(!m_username.IsEmpty())
- {
- CWinApp* pApp = AfxGetApp();
- pApp->WriteProfileString(IDS_R_LOGINS, m_username, m_remember ? DEncrypt(m_password) : _T(""));
- }
+ if(!m_username.IsEmpty())
+ {
+ CWinApp* pApp = AfxGetApp();
+ pApp->WriteProfileString(IDS_R_LOGINS, m_username, m_remember ? DEncrypt(m_password) : _T(""));
+ }
- OnOK();
+ OnOK();
}
void CAuthDlg::OnCbnSelchangeCombo1()
{
- CString username;
- m_usernamectrl.GetLBText(m_usernamectrl.GetCurSel(), username);
-
- CString password;
- if(m_logins.Lookup(username, password))
- {
- m_password = password;
- m_remember = TRUE;
- UpdateData(FALSE);
- }
+ CString username;
+ m_usernamectrl.GetLBText(m_usernamectrl.GetCurSel(), username);
+
+ CString password;
+ if(m_logins.Lookup(username, password))
+ {
+ m_password = password;
+ m_remember = TRUE;
+ UpdateData(FALSE);
+ }
}
void CAuthDlg::OnEnSetfocusEdit3()
{
- UpdateData();
-
- CString password;
- if(m_logins.Lookup(m_username, password))
- {
- m_password = password;
- m_remember = TRUE;
- UpdateData(FALSE);
- }
+ UpdateData();
+
+ CString password;
+ if(m_logins.Lookup(m_username, password))
+ {
+ m_password = password;
+ m_remember = TRUE;
+ UpdateData(FALSE);
+ }
}
diff --git a/src/apps/mplayerc/AuthDlg.h b/src/apps/mplayerc/AuthDlg.h
index 74dc78290..748cbffe7 100644
--- a/src/apps/mplayerc/AuthDlg.h
+++ b/src/apps/mplayerc/AuthDlg.h
@@ -30,31 +30,31 @@
class CAuthDlg : public CDialog
{
- DECLARE_DYNAMIC(CAuthDlg)
+ DECLARE_DYNAMIC(CAuthDlg)
private:
- CString DEncrypt(CString pw);
- CMapStringToString m_logins;
+ CString DEncrypt(CString pw);
+ CMapStringToString m_logins;
public:
- CAuthDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CAuthDlg();
+ CAuthDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CAuthDlg();
// Dialog Data
- enum { IDD = IDD_AUTH_DLG };
- CComboBox m_usernamectrl;
- CString m_username;
- CString m_password;
- BOOL m_remember;
+ enum { IDD = IDD_AUTH_DLG };
+ CComboBox m_usernamectrl;
+ CString m_username;
+ CString m_password;
+ BOOL m_remember;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedOk();
- afx_msg void OnCbnSelchangeCombo1();
- afx_msg void OnEnSetfocusEdit3();
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnCbnSelchangeCombo1();
+ afx_msg void OnEnSetfocusEdit3();
};
diff --git a/src/apps/mplayerc/BaseGraph.cpp b/src/apps/mplayerc/BaseGraph.cpp
index cdcc35e7e..0446eef2c 100644
--- a/src/apps/mplayerc/BaseGraph.cpp
+++ b/src/apps/mplayerc/BaseGraph.cpp
@@ -30,39 +30,39 @@
// CPlayerWindow
//
-BOOL CPlayerWindow::PreCreateWindow(CREATESTRUCT& cs)
+BOOL CPlayerWindow::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CWnd::PreCreateWindow(cs))
- return FALSE;
+ if(!CWnd::PreCreateWindow(cs))
+ return FALSE;
- cs.style &= ~WS_BORDER;
- cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
- ::LoadCursor(NULL, IDC_HAND), NULL, NULL);
+ cs.style &= ~WS_BORDER;
+ cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
+ ::LoadCursor(NULL, IDC_HAND), NULL, NULL);
- return TRUE;
+ return TRUE;
}
BEGIN_MESSAGE_MAP(CPlayerWindow, CWnd)
- ON_WM_ERASEBKGND()
+ ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
BOOL CPlayerWindow::OnEraseBkgnd(CDC* pDC)
{
- for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
- if(!pChild->IsWindowVisible()) continue;
+ for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
+ {
+ if(!pChild->IsWindowVisible()) continue;
- CRect r;
- pChild->GetClientRect(&r);
- pChild->MapWindowPoints(this, &r);
- pDC->ExcludeClipRect(&r);
- }
+ CRect r;
+ pChild->GetClientRect(&r);
+ pChild->MapWindowPoints(this, &r);
+ pDC->ExcludeClipRect(&r);
+ }
- CRect r;
- GetClientRect(&r);
- pDC->FillSolidRect(&r, 0);
+ CRect r;
+ GetClientRect(&r);
+ pDC->FillSolidRect(&r, 0);
- return TRUE;
+ return TRUE;
}
//
@@ -70,8 +70,8 @@ BOOL CPlayerWindow::OnEraseBkgnd(CDC* pDC)
//
CBaseGraph::CBaseGraph()
- : CUnknown(NAME("CBaseGraph"), NULL)
- , m_hNotifyWnd(NULL)
+ : CUnknown(NAME("CBaseGraph"), NULL)
+ , m_hNotifyWnd(NULL)
{
}
@@ -83,677 +83,274 @@ STDMETHODIMP CBaseGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IFilterGraph)
- QI(IGraphBuilder)
- QI(IFilterGraph2)
- QI(IGraphBuilder2)
- QI(IMediaControl)
- QI(IMediaSeeking)
- QI(IMediaEventEx)
- QI(IVideoWindow)
- QI(IBasicVideo)
- QI(IBasicAudio)
- QI(IAMOpenProgress)
- QI(IGraphEngine)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFilterGraph)
+ QI(IGraphBuilder)
+ QI(IFilterGraph2)
+ QI(IGraphBuilder2)
+ QI(IMediaControl)
+ QI(IMediaSeeking)
+ QI(IMediaEventEx)
+ QI(IVideoWindow)
+ QI(IBasicVideo)
+ QI(IBasicAudio)
+ QI(IAMOpenProgress)
+ QI(IGraphEngine)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CBaseGraph::ClearMessageQueue()
{
- while(!m_msgqueue.IsEmpty())
- {
- GMSG msg = m_msgqueue.RemoveHead();
- FreeEventParams(msg.m_lEventCode, msg.m_lParam1, msg.m_lParam2);
- }
+ while(!m_msgqueue.IsEmpty())
+ {
+ GMSG msg = m_msgqueue.RemoveHead();
+ FreeEventParams(msg.m_lEventCode, msg.m_lParam1, msg.m_lParam2);
+ }
}
void CBaseGraph::NotifyEvent(long lEventCode, LONG_PTR lParam1, LONG_PTR lParam2)
{
- if(!m_hNotifyWnd) return;
+ if(!m_hNotifyWnd) return;
- GMSG msg;
- msg.m_lEventCode = lEventCode;
- msg.m_lParam1 = lParam1;
- msg.m_lParam2 = lParam2;
- m_msgqueue.AddTail(msg);
+ GMSG msg;
+ msg.m_lEventCode = lEventCode;
+ msg.m_lParam1 = lParam1;
+ msg.m_lParam2 = lParam2;
+ m_msgqueue.AddTail(msg);
- PostMessage((HWND)m_hNotifyWnd, m_lNotifyMsg, 0, m_lNotifyInstData);
+ PostMessage((HWND)m_hNotifyWnd, m_lNotifyMsg, 0, m_lNotifyInstData);
}
// IDispatch
-STDMETHODIMP CBaseGraph::GetTypeInfoCount(UINT* pctinfo)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) {return E_NOTIMPL;}
// IFilterGraph
-STDMETHODIMP CBaseGraph::AddFilter(IBaseFilter* pFilter, LPCWSTR pName)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::RemoveFilter(IBaseFilter* pFilter)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::EnumFilters(IEnumFilters** ppEnum)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::Reconnect(IPin* ppin)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::Disconnect(IPin* ppin)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetDefaultSyncSource()
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::AddFilter(IBaseFilter* pFilter, LPCWSTR pName) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::RemoveFilter(IBaseFilter* pFilter) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::EnumFilters(IEnumFilters** ppEnum) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::Reconnect(IPin* ppin) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::Disconnect(IPin* ppin) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetDefaultSyncSource() {return E_NOTIMPL;}
// IGraphBuilder
-STDMETHODIMP CBaseGraph::Connect(IPin* ppinOut, IPin* ppinIn)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::Render(IPin* ppinOut)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
-{
- *ppFilter = NULL;
- return RenderFile(lpcwstrFileName, NULL);
-}//E_NOTIMPL;}
-STDMETHODIMP CBaseGraph::SetLogFile(DWORD_PTR hFile)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::Abort()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::ShouldOperationContinue()
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::Connect(IPin* ppinOut, IPin* ppinIn) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::Render(IPin* ppinOut) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter) {*ppFilter = NULL; return RenderFile(lpcwstrFileName, NULL);}//E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetLogFile(DWORD_PTR hFile) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::Abort() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::ShouldOperationContinue() {return E_NOTIMPL;}
// IFilterGraph2
-STDMETHODIMP CBaseGraph::AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext) {return E_NOTIMPL;}
// IGraphBuilder2
-STDMETHODIMP CBaseGraph::IsPinDirection(IPin* pPin, PIN_DIRECTION dir)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::IsPinConnected(IPin* pPin)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::ConnectFilter(IBaseFilter* pBF, IPin* pPinIn)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::ConnectFilter(IPin* pPinOut, IBaseFilter* pBF)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::NukeDownstream(IUnknown* pUnk)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::FindInterface(REFIID iid, void** ppv, BOOL bRemove)
-{
- return QueryInterface(iid, ppv);
-}
-STDMETHODIMP CBaseGraph::AddToROT()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::RemoveFromROT()
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::IsPinDirection(IPin* pPin, PIN_DIRECTION dir) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::IsPinConnected(IPin* pPin) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::ConnectFilter(IBaseFilter* pBF, IPin* pPinIn) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::ConnectFilter(IPin* pPinOut, IBaseFilter* pBF) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::NukeDownstream(IUnknown* pUnk) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::FindInterface(REFIID iid, void** ppv, BOOL bRemove) {return QueryInterface(iid, ppv);}
+STDMETHODIMP CBaseGraph::AddToROT() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::RemoveFromROT() {return E_NOTIMPL;}
// IMediaControl
-STDMETHODIMP CBaseGraph::Run()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::Pause()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::Stop()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetState(LONG msTimeout, OAFilterState* pfs)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::RenderFile(BSTR strFilename)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::AddSourceFilter(BSTR strFilename, IDispatch** ppUnk)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_FilterCollection(IDispatch** ppUnk)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_RegFilterCollection(IDispatch** ppUnk)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::StopWhenReady()
-{
- return Stop();
-}
+STDMETHODIMP CBaseGraph::Run() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::Pause() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::Stop() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetState(LONG msTimeout, OAFilterState* pfs) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::RenderFile(BSTR strFilename) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::AddSourceFilter(BSTR strFilename, IDispatch** ppUnk) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_FilterCollection(IDispatch** ppUnk) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_RegFilterCollection(IDispatch** ppUnk) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::StopWhenReady() {return Stop();}
// IMediaEvent
-STDMETHODIMP CBaseGraph::GetEventHandle(OAEVENT* hEvent)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::GetEventHandle(OAEVENT* hEvent) {return E_NOTIMPL;}
STDMETHODIMP CBaseGraph::GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout)
{
- if(m_msgqueue.IsEmpty()) return E_FAIL;
+ if(m_msgqueue.IsEmpty()) return E_FAIL;
- GMSG msg = m_msgqueue.RemoveHead();
- if(lEventCode) *lEventCode = msg.m_lEventCode;
- if(lParam1) *lParam1 = msg.m_lParam1;
- if(lParam2) *lParam2 = msg.m_lParam2;
+ GMSG msg = m_msgqueue.RemoveHead();
+ if(lEventCode) *lEventCode = msg.m_lEventCode;
+ if(lParam1) *lParam1 = msg.m_lParam1;
+ if(lParam2) *lParam2 = msg.m_lParam2;
- return S_OK;
-}
-STDMETHODIMP CBaseGraph::WaitForCompletion(long msTimeout, long* pEvCode)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::CancelDefaultHandling(long lEvCode)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::RestoreDefaultHandling(long lEvCode)
-{
- return E_NOTIMPL;
+ return S_OK;
}
+STDMETHODIMP CBaseGraph::WaitForCompletion(long msTimeout, long* pEvCode) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::CancelDefaultHandling(long lEvCode) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::RestoreDefaultHandling(long lEvCode) {return E_NOTIMPL;}
STDMETHODIMP CBaseGraph::FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2)
{
- if(EC_BG_ERROR == lEvCode)
- {
- if(lParam1) CoTaskMemFree((void*)lParam1);
- }
+ if(EC_BG_ERROR == lEvCode)
+ {
+ if(lParam1) CoTaskMemFree((void*)lParam1);
+ }
- return S_OK;
+ return S_OK;
}
// IMediaEventEx
STDMETHODIMP CBaseGraph::SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData)
{
- m_hNotifyWnd = hwnd;
- m_lNotifyMsg = lMsg;
- m_lNotifyInstData = lInstanceData;
+ m_hNotifyWnd = hwnd;
+ m_lNotifyMsg = lMsg;
+ m_lNotifyInstData = lInstanceData;
- if(!IsWindow((HWND)m_hNotifyWnd))
- {
- m_hNotifyWnd = NULL;
- return E_FAIL;
- }
+ if(!IsWindow((HWND)m_hNotifyWnd))
+ {
+ m_hNotifyWnd = NULL;
+ return E_FAIL;
+ }
- return S_OK;
-}
-STDMETHODIMP CBaseGraph::SetNotifyFlags(long lNoNotifyFlags)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetNotifyFlags(long* lplNoNotifyFlags)
-{
- return E_NOTIMPL;
+ return S_OK;
}
+STDMETHODIMP CBaseGraph::SetNotifyFlags(long lNoNotifyFlags) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetNotifyFlags(long* lplNoNotifyFlags) {return E_NOTIMPL;}
// IMediaSeeking
STDMETHODIMP CBaseGraph::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanGetCurrentPos | AM_SEEKING_CanGetDuration, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities = AM_SEEKING_CanSeekAbsolute|AM_SEEKING_CanGetCurrentPos|AM_SEEKING_CanGetDuration, S_OK : E_POINTER;
}
STDMETHODIMP CBaseGraph::CheckCapabilities(DWORD* pCapabilities)
{
- CheckPointer(pCapabilities, E_POINTER);
+ CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ if(*pCapabilities == 0) return S_OK;
- DWORD caps;
- GetCapabilities(&caps);
+ DWORD caps;
+ GetCapabilities(&caps);
- DWORD caps2 = caps & *pCapabilities;
+ DWORD caps2 = caps & *pCapabilities;
- return caps2 == 0 ? E_FAIL : caps2 == *pCapabilities ? S_OK : S_FALSE;
+ return caps2 == 0 ? E_FAIL : caps2 == *pCapabilities ? S_OK : S_FALSE;
}
STDMETHODIMP CBaseGraph::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
STDMETHODIMP CBaseGraph::QueryPreferredFormat(GUID* pFormat)
{
- return GetTimeFormat(pFormat);
+ return GetTimeFormat(pFormat);
}
STDMETHODIMP CBaseGraph::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
STDMETHODIMP CBaseGraph::IsUsingTimeFormat(const GUID* pFormat)
{
- return IsFormatSupported(pFormat);
+ return IsFormatSupported(pFormat);
}
STDMETHODIMP CBaseGraph::SetTimeFormat(const GUID* pFormat)
{
- return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
-}
-STDMETHODIMP CBaseGraph::GetDuration(LONGLONG* pDuration)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetStopPosition(LONGLONG* pStop)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetCurrentPosition(LONGLONG* pCurrent)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetRate(double dRate)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetRate(double* pdRate)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetPreroll(LONGLONG* pllPreroll)
-{
- return E_NOTIMPL;
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
+STDMETHODIMP CBaseGraph::GetDuration(LONGLONG* pDuration) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetStopPosition(LONGLONG* pStop) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetCurrentPosition(LONGLONG* pCurrent) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetRate(double dRate) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetRate(double* pdRate) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetPreroll(LONGLONG* pllPreroll) {return E_NOTIMPL;}
// IVideoWindow
-STDMETHODIMP CBaseGraph::put_Caption(BSTR strCaption)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Caption(BSTR* strCaption)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_WindowStyle(long WindowStyle)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_WindowStyle(long* WindowStyle)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_WindowStyleEx(long WindowStyleEx)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_WindowStyleEx(long* WindowStyleEx)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_AutoShow(long AutoShow)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_AutoShow(long* AutoShow)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_WindowState(long WindowState)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_WindowState(long* WindowState)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_BackgroundPalette(long BackgroundPalette)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_BackgroundPalette(long* pBackgroundPalette)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_Visible(long Visible)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Visible(long* pVisible)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_Left(long Left)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Left(long* pLeft)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_Width(long Width)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Width(long* pWidth)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_Top(long Top)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Top(long* pTop)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_Height(long Height)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Height(long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_Owner(OAHWND Owner)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Owner(OAHWND* Owner)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_MessageDrain(OAHWND Drain)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_MessageDrain(OAHWND* Drain)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_BorderColor(long* Color)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_BorderColor(long Color)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_FullScreenMode(long* FullScreenMode)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_FullScreenMode(long FullScreenMode)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetWindowForeground(long Focus)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetMinIdealImageSize(long* pWidth, long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetMaxIdealImageSize(long* pWidth, long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::HideCursor(long HideCursor)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::IsCursorHidden(long* CursorHidden)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::put_Caption(BSTR strCaption) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Caption(BSTR* strCaption) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_WindowStyle(long WindowStyle) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_WindowStyle(long* WindowStyle) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_WindowStyleEx(long WindowStyleEx) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_WindowStyleEx(long* WindowStyleEx) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_AutoShow(long AutoShow) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_AutoShow(long* AutoShow) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_WindowState(long WindowState) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_WindowState(long* WindowState) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_BackgroundPalette(long BackgroundPalette) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_BackgroundPalette(long* pBackgroundPalette) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_Visible(long Visible) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Visible(long* pVisible) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_Left(long Left) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Left(long* pLeft) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_Width(long Width) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Width(long* pWidth) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_Top(long Top) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Top(long* pTop) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_Height(long Height) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Height(long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_Owner(OAHWND Owner) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Owner(OAHWND* Owner) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_MessageDrain(OAHWND Drain) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_MessageDrain(OAHWND* Drain) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_BorderColor(long* Color) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_BorderColor(long Color) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_FullScreenMode(long* FullScreenMode) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_FullScreenMode(long FullScreenMode) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetWindowForeground(long Focus) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetWindowPosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetMinIdealImageSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetMaxIdealImageSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::HideCursor(long HideCursor) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::IsCursorHidden(long* CursorHidden) {return E_NOTIMPL;}
// IBasicVideo
-STDMETHODIMP CBaseGraph::get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_BitRate(long* pBitRate)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_BitErrorRate(long* pBitErrorRate)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_VideoWidth(long* pVideoWidth)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_VideoHeight(long* pVideoHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_SourceLeft(long SourceLeft)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_SourceLeft(long* pSourceLeft)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_SourceWidth(long SourceWidth)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_SourceWidth(long* pSourceWidth)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_SourceTop(long SourceTop)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_SourceTop(long* pSourceTop)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_SourceHeight(long SourceHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_SourceHeight(long* pSourceHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_DestinationLeft(long DestinationLeft)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_DestinationLeft(long* pDestinationLeft)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_DestinationWidth(long DestinationWidth)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_DestinationWidth(long* pDestinationWidth)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_DestinationTop(long DestinationTop)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_DestinationTop(long* pDestinationTop)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_DestinationHeight(long DestinationHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_DestinationHeight(long* pDestinationHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetSourcePosition(long Left, long Top, long Width, long Height)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetDefaultSourcePosition()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::SetDefaultDestinationPosition()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetVideoSize(long* pWidth, long* pHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::GetCurrentImage(long* pBufferSize, long* pDIBImage)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::IsUsingDefaultSource()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::IsUsingDefaultDestination()
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_BitRate(long* pBitRate) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_BitErrorRate(long* pBitErrorRate) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_VideoWidth(long* pVideoWidth) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_VideoHeight(long* pVideoHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_SourceLeft(long SourceLeft) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_SourceLeft(long* pSourceLeft) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_SourceWidth(long SourceWidth) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_SourceWidth(long* pSourceWidth) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_SourceTop(long SourceTop) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_SourceTop(long* pSourceTop) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_SourceHeight(long SourceHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_SourceHeight(long* pSourceHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_DestinationLeft(long DestinationLeft) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_DestinationLeft(long* pDestinationLeft) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_DestinationWidth(long DestinationWidth) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_DestinationWidth(long* pDestinationWidth) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_DestinationTop(long DestinationTop) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_DestinationTop(long* pDestinationTop) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_DestinationHeight(long DestinationHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_DestinationHeight(long* pDestinationHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetSourcePosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetDefaultSourcePosition() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetDestinationPosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::SetDefaultDestinationPosition() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetVideoSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::GetCurrentImage(long* pBufferSize, long* pDIBImage) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::IsUsingDefaultSource() {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::IsUsingDefaultDestination() {return E_NOTIMPL;}
// IBasicAudio
-STDMETHODIMP CBaseGraph::put_Volume(long lVolume)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Volume(long* plVolume)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::put_Balance(long lBalance)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::get_Balance(long* plBalance)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::put_Volume(long lVolume) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Volume(long* plVolume) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::put_Balance(long lBalance) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::get_Balance(long* plBalance) {return E_NOTIMPL;}
// IAMOpenProgress
-STDMETHODIMP CBaseGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CBaseGraph::AbortOperation()
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CBaseGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent) {return E_NOTIMPL;}
+STDMETHODIMP CBaseGraph::AbortOperation() {return E_NOTIMPL;}
// IGraphEngine
-STDMETHODIMP_(engine_t) CBaseGraph::GetEngine()
-{
- return DirectShow;
-}
+STDMETHODIMP_(engine_t) CBaseGraph::GetEngine() {return DirectShow;}
diff --git a/src/apps/mplayerc/BaseGraph.h b/src/apps/mplayerc/BaseGraph.h
index 761942330..789907a2d 100644
--- a/src/apps/mplayerc/BaseGraph.h
+++ b/src/apps/mplayerc/BaseGraph.h
@@ -29,234 +29,229 @@
class CPlayerWindow : public CWnd
{
public:
- CPlayerWindow() {}
+ CPlayerWindow() {}
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- DECLARE_MESSAGE_MAP()
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ DECLARE_MESSAGE_MAP()
};
typedef enum {DirectShow = 0, RealMedia, QuickTime, ShockWave} engine_t;
[uuid("B110CDE5-6331-4118-8AAF-A870D6F7E2E4")]
-interface IGraphEngine :
-public IUnknown
+interface IGraphEngine : public IUnknown
{
- STDMETHOD_(engine_t, GetEngine)() = 0;
+ STDMETHOD_(engine_t, GetEngine) () = 0;
};
-enum
+enum
{
- EC_BG_AUDIO_CHANGED = EC_USER + 1,
- EC_BG_ERROR
+ EC_BG_AUDIO_CHANGED = EC_USER+1,
+ EC_BG_ERROR
};
class CBaseGraph
- : public CUnknown
- , public IGraphBuilder2
- , public IMediaControl
- , public IMediaEventEx
- , public IMediaSeeking
- , public IVideoWindow
- , public IBasicVideo
- , public IBasicAudio
- , public IAMOpenProgress
- , public IGraphEngine
+ : public CUnknown
+ , public IGraphBuilder2
+ , public IMediaControl
+ , public IMediaEventEx
+ , public IMediaSeeking
+ , public IVideoWindow
+ , public IBasicVideo
+ , public IBasicAudio
+ , public IAMOpenProgress
+ , public IGraphEngine
{
- OAHWND m_hNotifyWnd;
- long m_lNotifyMsg;
- LONG_PTR m_lNotifyInstData;
+ OAHWND m_hNotifyWnd;
+ long m_lNotifyMsg;
+ LONG_PTR m_lNotifyInstData;
- typedef struct
- {
- long m_lEventCode;
- LONG_PTR m_lParam1, m_lParam2;
- } GMSG;
- CList<GMSG> m_msgqueue;
+ typedef struct {long m_lEventCode; LONG_PTR m_lParam1, m_lParam2;} GMSG;
+ CList<GMSG> m_msgqueue;
protected:
- void ClearMessageQueue();
+ void ClearMessageQueue();
public:
- CBaseGraph();
- virtual ~CBaseGraph();
+ CBaseGraph();
+ virtual ~CBaseGraph();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- void NotifyEvent(long lEventCode, LONG_PTR lParam1 = 0, LONG_PTR lParam2 = 0);
+ void NotifyEvent(long lEventCode, LONG_PTR lParam1 = 0, LONG_PTR lParam2 = 0);
protected:
// IDispatch
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
- STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
- STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId);
- STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
+ STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
+ STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId);
+ STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
- // IFilterGraph
- STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
- STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
- STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
- STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
- STDMETHODIMP ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP Reconnect(IPin* ppin);
- STDMETHODIMP Disconnect(IPin* ppin);
- STDMETHODIMP SetDefaultSyncSource();
+ // IFilterGraph
+ STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
+ STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
+ STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
+ STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
+ STDMETHODIMP ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP Reconnect(IPin* ppin);
+ STDMETHODIMP Disconnect(IPin* ppin);
+ STDMETHODIMP SetDefaultSyncSource();
- // IGraphBuilder
- STDMETHODIMP Connect(IPin* ppinOut, IPin* ppinIn);
- STDMETHODIMP Render(IPin* ppinOut);
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP SetLogFile(DWORD_PTR hFile);
- STDMETHODIMP Abort();
- STDMETHODIMP ShouldOperationContinue();
+ // IGraphBuilder
+ STDMETHODIMP Connect(IPin* ppinOut, IPin* ppinIn);
+ STDMETHODIMP Render(IPin* ppinOut);
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP SetLogFile(DWORD_PTR hFile);
+ STDMETHODIMP Abort();
+ STDMETHODIMP ShouldOperationContinue();
- // IFilterGraph2
- STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
+ // IFilterGraph2
+ STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
- // IGraphBuilder2
- STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
- STDMETHODIMP IsPinConnected(IPin* pPin);
- STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
- STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
- STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP NukeDownstream(IUnknown* pUnk);
- STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
- STDMETHODIMP AddToROT();
- STDMETHODIMP RemoveFromROT();
+ // IGraphBuilder2
+ STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
+ STDMETHODIMP IsPinConnected(IPin* pPin);
+ STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
+ STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
+ STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP NukeDownstream(IUnknown* pUnk);
+ STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
+ STDMETHODIMP AddToROT();
+ STDMETHODIMP RemoveFromROT();
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
- STDMETHODIMP RenderFile(BSTR strFilename);
- STDMETHODIMP AddSourceFilter(BSTR strFilename, IDispatch** ppUnk);
- STDMETHODIMP get_FilterCollection(IDispatch** ppUnk);
- STDMETHODIMP get_RegFilterCollection(IDispatch** ppUnk);
- STDMETHODIMP StopWhenReady();
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+ STDMETHODIMP RenderFile(BSTR strFilename);
+ STDMETHODIMP AddSourceFilter(BSTR strFilename, IDispatch** ppUnk);
+ STDMETHODIMP get_FilterCollection(IDispatch** ppUnk);
+ STDMETHODIMP get_RegFilterCollection(IDispatch** ppUnk);
+ STDMETHODIMP StopWhenReady();
- // IMediaEvent
- STDMETHODIMP GetEventHandle(OAEVENT* hEvent);
- STDMETHODIMP GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout);
- STDMETHODIMP WaitForCompletion(long msTimeout, long* pEvCode);
- STDMETHODIMP CancelDefaultHandling(long lEvCode);
- STDMETHODIMP RestoreDefaultHandling(long lEvCode);
- STDMETHODIMP FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2);
+ // IMediaEvent
+ STDMETHODIMP GetEventHandle(OAEVENT* hEvent);
+ STDMETHODIMP GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout);
+ STDMETHODIMP WaitForCompletion(long msTimeout, long* pEvCode);
+ STDMETHODIMP CancelDefaultHandling(long lEvCode);
+ STDMETHODIMP RestoreDefaultHandling(long lEvCode);
+ STDMETHODIMP FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2);
- // IMediaEventEx
- STDMETHODIMP SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData);
- STDMETHODIMP SetNotifyFlags(long lNoNotifyFlags);
- STDMETHODIMP GetNotifyFlags(long* lplNoNotifyFlags);
+ // IMediaEventEx
+ STDMETHODIMP SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData);
+ STDMETHODIMP SetNotifyFlags(long lNoNotifyFlags);
+ STDMETHODIMP GetNotifyFlags(long* lplNoNotifyFlags);
- // IMediaSeeking
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+ // IMediaSeeking
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
- // IVideoWindow
- STDMETHODIMP put_Caption(BSTR strCaption);
- STDMETHODIMP get_Caption(BSTR* strCaption);
- STDMETHODIMP put_WindowStyle(long WindowStyle);
- STDMETHODIMP get_WindowStyle(long* WindowStyle);
- STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);
- STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx);
- STDMETHODIMP put_AutoShow(long AutoShow);
- STDMETHODIMP get_AutoShow(long* AutoShow);
- STDMETHODIMP put_WindowState(long WindowState);
- STDMETHODIMP get_WindowState(long* WindowState);
- STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);
- STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette);
- STDMETHODIMP put_Visible(long Visible);
- STDMETHODIMP get_Visible(long* pVisible);
- STDMETHODIMP put_Left(long Left);
- STDMETHODIMP get_Left(long* pLeft);
- STDMETHODIMP put_Width(long Width);
- STDMETHODIMP get_Width(long* pWidth);
- STDMETHODIMP put_Top(long Top);
- STDMETHODIMP get_Top(long* pTop);
- STDMETHODIMP put_Height(long Height);
- STDMETHODIMP get_Height(long* pHeight);
- STDMETHODIMP put_Owner(OAHWND Owner);
- STDMETHODIMP get_Owner(OAHWND* Owner);
- STDMETHODIMP put_MessageDrain(OAHWND Drain);
- STDMETHODIMP get_MessageDrain(OAHWND* Drain);
- STDMETHODIMP get_BorderColor(long* Color);
- STDMETHODIMP put_BorderColor(long Color);
- STDMETHODIMP get_FullScreenMode(long* FullScreenMode);
- STDMETHODIMP put_FullScreenMode(long FullScreenMode);
- STDMETHODIMP SetWindowForeground(long Focus);
- STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam);
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight);
- STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight);
- STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP HideCursor(long HideCursor);
- STDMETHODIMP IsCursorHidden(long* CursorHidden);
+ // IVideoWindow
+ STDMETHODIMP put_Caption(BSTR strCaption);
+ STDMETHODIMP get_Caption(BSTR* strCaption);
+ STDMETHODIMP put_WindowStyle(long WindowStyle);
+ STDMETHODIMP get_WindowStyle(long* WindowStyle);
+ STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);
+ STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx);
+ STDMETHODIMP put_AutoShow(long AutoShow);
+ STDMETHODIMP get_AutoShow(long* AutoShow);
+ STDMETHODIMP put_WindowState(long WindowState);
+ STDMETHODIMP get_WindowState(long* WindowState);
+ STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);
+ STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette);
+ STDMETHODIMP put_Visible(long Visible);
+ STDMETHODIMP get_Visible(long* pVisible);
+ STDMETHODIMP put_Left(long Left);
+ STDMETHODIMP get_Left(long* pLeft);
+ STDMETHODIMP put_Width(long Width);
+ STDMETHODIMP get_Width(long* pWidth);
+ STDMETHODIMP put_Top(long Top);
+ STDMETHODIMP get_Top(long* pTop);
+ STDMETHODIMP put_Height(long Height);
+ STDMETHODIMP get_Height(long* pHeight);
+ STDMETHODIMP put_Owner(OAHWND Owner);
+ STDMETHODIMP get_Owner(OAHWND* Owner);
+ STDMETHODIMP put_MessageDrain(OAHWND Drain);
+ STDMETHODIMP get_MessageDrain(OAHWND* Drain);
+ STDMETHODIMP get_BorderColor(long* Color);
+ STDMETHODIMP put_BorderColor(long Color);
+ STDMETHODIMP get_FullScreenMode(long* FullScreenMode);
+ STDMETHODIMP put_FullScreenMode(long FullScreenMode);
+ STDMETHODIMP SetWindowForeground(long Focus);
+ STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam);
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight);
+ STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight);
+ STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP HideCursor(long HideCursor);
+ STDMETHODIMP IsCursorHidden(long* CursorHidden);
- // IBasicVideo
- STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame);
- STDMETHODIMP get_BitRate(long* pBitRate);
- STDMETHODIMP get_BitErrorRate(long* pBitErrorRate);
- STDMETHODIMP get_VideoWidth(long* pVideoWidth);
- STDMETHODIMP get_VideoHeight(long* pVideoHeight);
- STDMETHODIMP put_SourceLeft(long SourceLeft);
- STDMETHODIMP get_SourceLeft(long* pSourceLeft);
- STDMETHODIMP put_SourceWidth(long SourceWidth);
- STDMETHODIMP get_SourceWidth(long* pSourceWidth);
- STDMETHODIMP put_SourceTop(long SourceTop);
- STDMETHODIMP get_SourceTop(long* pSourceTop);
- STDMETHODIMP put_SourceHeight(long SourceHeight);
- STDMETHODIMP get_SourceHeight(long* pSourceHeight);
- STDMETHODIMP put_DestinationLeft(long DestinationLeft);
- STDMETHODIMP get_DestinationLeft(long* pDestinationLeft);
- STDMETHODIMP put_DestinationWidth(long DestinationWidth);
- STDMETHODIMP get_DestinationWidth(long* pDestinationWidth);
- STDMETHODIMP put_DestinationTop(long DestinationTop);
- STDMETHODIMP get_DestinationTop(long* pDestinationTop);
- STDMETHODIMP put_DestinationHeight(long DestinationHeight);
- STDMETHODIMP get_DestinationHeight(long* pDestinationHeight);
- STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP SetDefaultSourcePosition();
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP SetDefaultDestinationPosition();
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
- STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette);
- STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage);
- STDMETHODIMP IsUsingDefaultSource();
- STDMETHODIMP IsUsingDefaultDestination();
+ // IBasicVideo
+ STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame);
+ STDMETHODIMP get_BitRate(long* pBitRate);
+ STDMETHODIMP get_BitErrorRate(long* pBitErrorRate);
+ STDMETHODIMP get_VideoWidth(long* pVideoWidth);
+ STDMETHODIMP get_VideoHeight(long* pVideoHeight);
+ STDMETHODIMP put_SourceLeft(long SourceLeft);
+ STDMETHODIMP get_SourceLeft(long* pSourceLeft);
+ STDMETHODIMP put_SourceWidth(long SourceWidth);
+ STDMETHODIMP get_SourceWidth(long* pSourceWidth);
+ STDMETHODIMP put_SourceTop(long SourceTop);
+ STDMETHODIMP get_SourceTop(long* pSourceTop);
+ STDMETHODIMP put_SourceHeight(long SourceHeight);
+ STDMETHODIMP get_SourceHeight(long* pSourceHeight);
+ STDMETHODIMP put_DestinationLeft(long DestinationLeft);
+ STDMETHODIMP get_DestinationLeft(long* pDestinationLeft);
+ STDMETHODIMP put_DestinationWidth(long DestinationWidth);
+ STDMETHODIMP get_DestinationWidth(long* pDestinationWidth);
+ STDMETHODIMP put_DestinationTop(long DestinationTop);
+ STDMETHODIMP get_DestinationTop(long* pDestinationTop);
+ STDMETHODIMP put_DestinationHeight(long DestinationHeight);
+ STDMETHODIMP get_DestinationHeight(long* pDestinationHeight);
+ STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP SetDefaultSourcePosition();
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP SetDefaultDestinationPosition();
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+ STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette);
+ STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage);
+ STDMETHODIMP IsUsingDefaultSource();
+ STDMETHODIMP IsUsingDefaultDestination();
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
- STDMETHODIMP put_Balance(long lBalance);
- STDMETHODIMP get_Balance(long* plBalance);
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
+ STDMETHODIMP put_Balance(long lBalance);
+ STDMETHODIMP get_Balance(long* plBalance);
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
- STDMETHODIMP AbortOperation();
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+ STDMETHODIMP AbortOperation();
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
};
diff --git a/src/apps/mplayerc/CGdiPlusBitmap.h b/src/apps/mplayerc/CGdiPlusBitmap.h
index ec561629e..dd46ac2d0 100644
--- a/src/apps/mplayerc/CGdiPlusBitmap.h
+++ b/src/apps/mplayerc/CGdiPlusBitmap.h
@@ -3,141 +3,105 @@
class CGdiPlusBitmap
{
public:
- Gdiplus::Bitmap* m_pBitmap;
+ Gdiplus::Bitmap* m_pBitmap;
public:
- CGdiPlusBitmap()
- {
- m_pBitmap = NULL;
- }
- CGdiPlusBitmap(LPCWSTR pFile)
- {
- m_pBitmap = NULL;
- Load(pFile);
- }
- virtual ~CGdiPlusBitmap()
- {
- Empty();
- }
-
- void Empty()
- {
- delete m_pBitmap;
- m_pBitmap = NULL;
- }
-
- bool Load(LPCWSTR pFile)
- {
- Empty();
- m_pBitmap = Gdiplus::Bitmap::FromFile(pFile);
- return m_pBitmap->GetLastStatus() == Gdiplus::Ok;
- }
-
- operator Gdiplus::Bitmap*() const
- {
- return m_pBitmap;
- }
+ CGdiPlusBitmap() { m_pBitmap = NULL; }
+ CGdiPlusBitmap(LPCWSTR pFile) { m_pBitmap = NULL; Load(pFile); }
+ virtual ~CGdiPlusBitmap() { Empty(); }
+
+ void Empty() { delete m_pBitmap; m_pBitmap = NULL; }
+
+ bool Load(LPCWSTR pFile)
+ {
+ Empty();
+ m_pBitmap = Gdiplus::Bitmap::FromFile(pFile);
+ return m_pBitmap->GetLastStatus() == Gdiplus::Ok;
+ }
+
+ operator Gdiplus::Bitmap*() const { return m_pBitmap; }
};
class CGdiPlusBitmapResource : public CGdiPlusBitmap
{
protected:
- HGLOBAL m_hBuffer;
+ HGLOBAL m_hBuffer;
public:
- CGdiPlusBitmapResource()
- {
- m_hBuffer = NULL;
- }
- CGdiPlusBitmapResource(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
- m_hBuffer = NULL;
- Load(pName, pType, hInst);
- }
- CGdiPlusBitmapResource(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
- m_hBuffer = NULL;
- Load(id, pType, hInst);
- }
- CGdiPlusBitmapResource(UINT id, UINT type, HMODULE hInst = NULL)
- {
- m_hBuffer = NULL;
- Load(id, type, hInst);
- }
- virtual ~CGdiPlusBitmapResource()
- {
- Empty();
- }
-
- void Empty();
-
- bool Load(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL);
- bool Load(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
- return Load(MAKEINTRESOURCE(id), pType, hInst);
- }
- bool Load(UINT id, UINT type, HMODULE hInst = NULL)
- {
- return Load(MAKEINTRESOURCE(id), MAKEINTRESOURCE(type), hInst);
- }
+ CGdiPlusBitmapResource() { m_hBuffer = NULL; }
+ CGdiPlusBitmapResource(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
+ { m_hBuffer = NULL; Load(pName, pType, hInst); }
+ CGdiPlusBitmapResource(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
+ { m_hBuffer = NULL; Load(id, pType, hInst); }
+ CGdiPlusBitmapResource(UINT id, UINT type, HMODULE hInst = NULL)
+ { m_hBuffer = NULL; Load(id, type, hInst); }
+ virtual ~CGdiPlusBitmapResource() { Empty(); }
+
+ void Empty();
+
+ bool Load(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL);
+ bool Load(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
+ { return Load(MAKEINTRESOURCE(id), pType, hInst); }
+ bool Load(UINT id, UINT type, HMODULE hInst = NULL)
+ { return Load(MAKEINTRESOURCE(id), MAKEINTRESOURCE(type), hInst); }
};
inline
void CGdiPlusBitmapResource::Empty()
{
- CGdiPlusBitmap::Empty();
- if(m_hBuffer)
- {
- ::GlobalUnlock(m_hBuffer);
- ::GlobalFree(m_hBuffer);
- m_hBuffer = NULL;
- }
+ CGdiPlusBitmap::Empty();
+ if (m_hBuffer)
+ {
+ ::GlobalUnlock(m_hBuffer);
+ ::GlobalFree(m_hBuffer);
+ m_hBuffer = NULL;
+ }
}
inline
bool CGdiPlusBitmapResource::Load(LPCTSTR pName, LPCTSTR pType, HMODULE hInst)
{
- Empty();
-
- HRSRC hResource = ::FindResource(hInst, pName, pType);
- if(!hResource)
- return false;
-
- DWORD imageSize = ::SizeofResource(hInst, hResource);
- if(!imageSize)
- return false;
-
- const void* pResourceData = ::LockResource(::LoadResource(hInst, hResource));
- if(!pResourceData)
- return false;
-
- m_hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
- if(m_hBuffer)
- {
- void* pBuffer = ::GlobalLock(m_hBuffer);
- if(pBuffer)
- {
- CopyMemory(pBuffer, pResourceData, imageSize);
-
- IStream* pStream = NULL;
- if(::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK)
- {
- m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
- pStream->Release();
- if(m_pBitmap)
- {
- if(m_pBitmap->GetLastStatus() == Gdiplus::Ok)
- return true;
-
- delete m_pBitmap;
- m_pBitmap = NULL;
- }
- }
- ::GlobalUnlock(m_hBuffer);
- }
- ::GlobalFree(m_hBuffer);
- m_hBuffer = NULL;
- }
- return false;
+ Empty();
+
+ HRSRC hResource = ::FindResource(hInst, pName, pType);
+ if (!hResource)
+ return false;
+
+ DWORD imageSize = ::SizeofResource(hInst, hResource);
+ if (!imageSize)
+ return false;
+
+ const void* pResourceData = ::LockResource(::LoadResource(hInst, hResource));
+ if (!pResourceData)
+ return false;
+
+ m_hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
+ if (m_hBuffer)
+ {
+ void* pBuffer = ::GlobalLock(m_hBuffer);
+ if (pBuffer)
+ {
+ CopyMemory(pBuffer, pResourceData, imageSize);
+
+ IStream* pStream = NULL;
+ if (::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK)
+ {
+ m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
+ pStream->Release();
+ if (m_pBitmap)
+ {
+ if (m_pBitmap->GetLastStatus() == Gdiplus::Ok)
+ return true;
+
+ delete m_pBitmap;
+ m_pBitmap = NULL;
+ }
+ }
+ ::GlobalUnlock(m_hBuffer);
+ }
+ ::GlobalFree(m_hBuffer);
+ m_hBuffer = NULL;
+ }
+ return false;
}
diff --git a/src/apps/mplayerc/CShockwaveFlash.h b/src/apps/mplayerc/CShockwaveFlash.h
index 1fd25f969..f9dbc683c 100644
--- a/src/apps/mplayerc/CShockwaveFlash.h
+++ b/src/apps/mplayerc/CShockwaveFlash.h
@@ -29,28 +29,28 @@
class CShockwaveFlash : public CWnd
{
protected:
- DECLARE_DYNCREATE(CShockwaveFlash)
+ DECLARE_DYNCREATE(CShockwaveFlash)
public:
- CLSID const& GetClsid()
- {
- static CLSID const clsid
- = { 0xD27CDB6E, 0xAE6D, 0x11CF, { 0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
- return clsid;
- }
- virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
- const RECT& rect, CWnd* pParentWnd, UINT nID,
- CCreateContext* pContext = NULL)
- {
- return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
- }
+ CLSID const& GetClsid()
+ {
+ static CLSID const clsid
+ = { 0xD27CDB6E, 0xAE6D, 0x11CF, { 0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
+ return clsid;
+ }
+ virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
+ const RECT& rect, CWnd* pParentWnd, UINT nID,
+ CCreateContext* pContext = NULL)
+ {
+ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
+ }
- BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
- UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
- BSTR bstrLicKey = NULL)
- {
- return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
- pPersist, bStorage, bstrLicKey);
- }
+ BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
+ UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
+ BSTR bstrLicKey = NULL)
+ {
+ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
+ pPersist, bStorage, bstrLicKey);
+ }
// Attributes
public:
@@ -58,404 +58,404 @@ public:
// Operations
public:
- long get_ReadyState()
- {
- long result;
- InvokeHelper(DISPID_READYSTATE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- long get_TotalFrames()
- {
- long result;
- InvokeHelper(0x7c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- BOOL get_Playing()
- {
- BOOL result;
- InvokeHelper(0x7d, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_Playing(BOOL newValue)
- {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x7d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_Quality()
- {
- long result;
- InvokeHelper(0x69, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_Quality(long newValue)
- {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x69, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_ScaleMode()
- {
- long result;
- InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_ScaleMode(long newValue)
- {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_AlignMode()
- {
- long result;
- InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_AlignMode(long newValue)
- {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x79, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_BackgroundColor()
- {
- long result;
- InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_BackgroundColor(long newValue)
- {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x7b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_Loop()
- {
- BOOL result;
- InvokeHelper(0x6a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_Loop(BOOL newValue)
- {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x6a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Movie()
- {
- CString result;
- InvokeHelper(0x66, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Movie(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x66, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_FrameNum()
- {
- long result;
- InvokeHelper(0x6b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_FrameNum(long newValue)
- {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x6b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- void SetZoomRect(long left, long top, long right, long bottom)
- {
- static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 VTS_I4 ;
- InvokeHelper(0x6d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, left, top, right, bottom);
- }
- void Zoom(long factor)
- {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x76, DISPATCH_METHOD, VT_EMPTY, NULL, parms, factor);
- }
- void Pan(long x, long y, long mode)
- {
- static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 ;
- InvokeHelper(0x77, DISPATCH_METHOD, VT_EMPTY, NULL, parms, x, y, mode);
- }
- void Play()
- {
- InvokeHelper(0x70, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Stop()
- {
- InvokeHelper(0x71, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Back()
- {
- InvokeHelper(0x72, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Forward()
- {
- InvokeHelper(0x73, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Rewind()
- {
- InvokeHelper(0x74, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void StopPlay()
- {
- InvokeHelper(0x7e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void GotoFrame(long FrameNum)
- {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x7f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, FrameNum);
- }
- long CurrentFrame()
- {
- long result;
- InvokeHelper(0x80, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
- return result;
- }
- BOOL IsPlaying()
- {
- BOOL result;
- InvokeHelper(0x81, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- long PercentLoaded()
- {
- long result;
- InvokeHelper(0x82, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
- return result;
- }
- BOOL FrameLoaded(long FrameNum)
- {
- BOOL result;
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x83, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, FrameNum);
- return result;
- }
- long FlashVersion()
- {
- long result;
- InvokeHelper(0x84, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
- return result;
- }
- CString get_WMode()
- {
- CString result;
- InvokeHelper(0x85, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_WMode(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x85, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_SAlign()
- {
- CString result;
- InvokeHelper(0x86, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_SAlign(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x86, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_Menu()
- {
- BOOL result;
- InvokeHelper(0x87, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_Menu(BOOL newValue)
- {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x87, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Base()
- {
- CString result;
- InvokeHelper(0x88, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Base(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x88, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Scale()
- {
- CString result;
- InvokeHelper(0x89, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Scale(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x89, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_DeviceFont()
- {
- BOOL result;
- InvokeHelper(0x8a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_DeviceFont(BOOL newValue)
- {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x8a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_EmbedMovie()
- {
- BOOL result;
- InvokeHelper(0x8b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_EmbedMovie(BOOL newValue)
- {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x8b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_BGColor()
- {
- CString result;
- InvokeHelper(0x8c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_BGColor(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x8c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Quality2()
- {
- CString result;
- InvokeHelper(0x8d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Quality2(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x8d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- void LoadMovie(long layer, LPCTSTR url)
- {
- static BYTE parms[] = VTS_I4 VTS_BSTR ;
- InvokeHelper(0x8e, DISPATCH_METHOD, VT_EMPTY, NULL, parms, layer, url);
- }
- void TGotoFrame(LPCTSTR target, long FrameNum)
- {
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x8f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
- }
- void TGotoLabel(LPCTSTR target, LPCTSTR label)
- {
- static BYTE parms[] = VTS_BSTR VTS_BSTR ;
- InvokeHelper(0x90, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
- }
- long TCurrentFrame(LPCTSTR target)
- {
- long result;
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x91, DISPATCH_METHOD, VT_I4, (void*)&result, parms, target);
- return result;
- }
- CString TCurrentLabel(LPCTSTR target)
- {
- CString result;
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x92, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target);
- return result;
- }
- void TPlay(LPCTSTR target)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x93, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
- }
- void TStopPlay(LPCTSTR target)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x94, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
- }
- void SetVariable(LPCTSTR name, LPCTSTR value)
- {
- static BYTE parms[] = VTS_BSTR VTS_BSTR ;
- InvokeHelper(0x97, DISPATCH_METHOD, VT_EMPTY, NULL, parms, name, value);
- }
- CString GetVariable(LPCTSTR name)
- {
- CString result;
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x98, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, name);
- return result;
- }
- void TSetProperty(LPCTSTR target, long property, LPCTSTR value)
- {
- static BYTE parms[] = VTS_BSTR VTS_I4 VTS_BSTR ;
- InvokeHelper(0x99, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
- }
- CString TGetProperty(LPCTSTR target, long property)
- {
- CString result;
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x9a, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target, property);
- return result;
- }
- void TCallFrame(LPCTSTR target, long FrameNum)
- {
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x9b, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
- }
- void TCallLabel(LPCTSTR target, LPCTSTR label)
- {
- static BYTE parms[] = VTS_BSTR VTS_BSTR ;
- InvokeHelper(0x9c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
- }
- void TSetPropertyNum(LPCTSTR target, long property, double value)
- {
- static BYTE parms[] = VTS_BSTR VTS_I4 VTS_R8 ;
- InvokeHelper(0x9d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
- }
- double TGetPropertyNum(LPCTSTR target, long property)
- {
- double result;
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x9e, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
- return result;
- }
- double TGetPropertyAsNumber(LPCTSTR target, long property)
- {
- double result;
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0xac, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
- return result;
- }
- CString get_SWRemote()
- {
- CString result;
- InvokeHelper(0x9f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_SWRemote(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x9f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_FlashVars()
- {
- CString result;
- InvokeHelper(0xaa, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_FlashVars(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0xaa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_AllowScriptAccess()
- {
- CString result;
- InvokeHelper(0xab, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_AllowScriptAccess(LPCTSTR newValue)
- {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0xab, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
+ long get_ReadyState()
+ {
+ long result;
+ InvokeHelper(DISPID_READYSTATE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ long get_TotalFrames()
+ {
+ long result;
+ InvokeHelper(0x7c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ BOOL get_Playing()
+ {
+ BOOL result;
+ InvokeHelper(0x7d, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_Playing(BOOL newValue)
+ {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x7d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_Quality()
+ {
+ long result;
+ InvokeHelper(0x69, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_Quality(long newValue)
+ {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x69, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_ScaleMode()
+ {
+ long result;
+ InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_ScaleMode(long newValue)
+ {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_AlignMode()
+ {
+ long result;
+ InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_AlignMode(long newValue)
+ {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x79, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_BackgroundColor()
+ {
+ long result;
+ InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_BackgroundColor(long newValue)
+ {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x7b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_Loop()
+ {
+ BOOL result;
+ InvokeHelper(0x6a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_Loop(BOOL newValue)
+ {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x6a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Movie()
+ {
+ CString result;
+ InvokeHelper(0x66, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Movie(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x66, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_FrameNum()
+ {
+ long result;
+ InvokeHelper(0x6b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_FrameNum(long newValue)
+ {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x6b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ void SetZoomRect(long left, long top, long right, long bottom)
+ {
+ static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 VTS_I4 ;
+ InvokeHelper(0x6d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, left, top, right, bottom);
+ }
+ void Zoom(long factor)
+ {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x76, DISPATCH_METHOD, VT_EMPTY, NULL, parms, factor);
+ }
+ void Pan(long x, long y, long mode)
+ {
+ static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 ;
+ InvokeHelper(0x77, DISPATCH_METHOD, VT_EMPTY, NULL, parms, x, y, mode);
+ }
+ void Play()
+ {
+ InvokeHelper(0x70, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Stop()
+ {
+ InvokeHelper(0x71, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Back()
+ {
+ InvokeHelper(0x72, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Forward()
+ {
+ InvokeHelper(0x73, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Rewind()
+ {
+ InvokeHelper(0x74, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void StopPlay()
+ {
+ InvokeHelper(0x7e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void GotoFrame(long FrameNum)
+ {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x7f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, FrameNum);
+ }
+ long CurrentFrame()
+ {
+ long result;
+ InvokeHelper(0x80, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ BOOL IsPlaying()
+ {
+ BOOL result;
+ InvokeHelper(0x81, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ long PercentLoaded()
+ {
+ long result;
+ InvokeHelper(0x82, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ BOOL FrameLoaded(long FrameNum)
+ {
+ BOOL result;
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x83, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, FrameNum);
+ return result;
+ }
+ long FlashVersion()
+ {
+ long result;
+ InvokeHelper(0x84, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ CString get_WMode()
+ {
+ CString result;
+ InvokeHelper(0x85, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_WMode(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x85, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_SAlign()
+ {
+ CString result;
+ InvokeHelper(0x86, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_SAlign(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x86, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_Menu()
+ {
+ BOOL result;
+ InvokeHelper(0x87, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_Menu(BOOL newValue)
+ {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x87, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Base()
+ {
+ CString result;
+ InvokeHelper(0x88, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Base(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x88, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Scale()
+ {
+ CString result;
+ InvokeHelper(0x89, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Scale(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x89, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_DeviceFont()
+ {
+ BOOL result;
+ InvokeHelper(0x8a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_DeviceFont(BOOL newValue)
+ {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x8a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_EmbedMovie()
+ {
+ BOOL result;
+ InvokeHelper(0x8b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_EmbedMovie(BOOL newValue)
+ {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x8b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_BGColor()
+ {
+ CString result;
+ InvokeHelper(0x8c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_BGColor(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x8c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Quality2()
+ {
+ CString result;
+ InvokeHelper(0x8d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Quality2(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x8d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ void LoadMovie(long layer, LPCTSTR url)
+ {
+ static BYTE parms[] = VTS_I4 VTS_BSTR ;
+ InvokeHelper(0x8e, DISPATCH_METHOD, VT_EMPTY, NULL, parms, layer, url);
+ }
+ void TGotoFrame(LPCTSTR target, long FrameNum)
+ {
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x8f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
+ }
+ void TGotoLabel(LPCTSTR target, LPCTSTR label)
+ {
+ static BYTE parms[] = VTS_BSTR VTS_BSTR ;
+ InvokeHelper(0x90, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
+ }
+ long TCurrentFrame(LPCTSTR target)
+ {
+ long result;
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x91, DISPATCH_METHOD, VT_I4, (void*)&result, parms, target);
+ return result;
+ }
+ CString TCurrentLabel(LPCTSTR target)
+ {
+ CString result;
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x92, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target);
+ return result;
+ }
+ void TPlay(LPCTSTR target)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x93, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
+ }
+ void TStopPlay(LPCTSTR target)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x94, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
+ }
+ void SetVariable(LPCTSTR name, LPCTSTR value)
+ {
+ static BYTE parms[] = VTS_BSTR VTS_BSTR ;
+ InvokeHelper(0x97, DISPATCH_METHOD, VT_EMPTY, NULL, parms, name, value);
+ }
+ CString GetVariable(LPCTSTR name)
+ {
+ CString result;
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x98, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, name);
+ return result;
+ }
+ void TSetProperty(LPCTSTR target, long property, LPCTSTR value)
+ {
+ static BYTE parms[] = VTS_BSTR VTS_I4 VTS_BSTR ;
+ InvokeHelper(0x99, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
+ }
+ CString TGetProperty(LPCTSTR target, long property)
+ {
+ CString result;
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x9a, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target, property);
+ return result;
+ }
+ void TCallFrame(LPCTSTR target, long FrameNum)
+ {
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x9b, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
+ }
+ void TCallLabel(LPCTSTR target, LPCTSTR label)
+ {
+ static BYTE parms[] = VTS_BSTR VTS_BSTR ;
+ InvokeHelper(0x9c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
+ }
+ void TSetPropertyNum(LPCTSTR target, long property, double value)
+ {
+ static BYTE parms[] = VTS_BSTR VTS_I4 VTS_R8 ;
+ InvokeHelper(0x9d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
+ }
+ double TGetPropertyNum(LPCTSTR target, long property)
+ {
+ double result;
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x9e, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
+ return result;
+ }
+ double TGetPropertyAsNumber(LPCTSTR target, long property)
+ {
+ double result;
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0xac, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
+ return result;
+ }
+ CString get_SWRemote()
+ {
+ CString result;
+ InvokeHelper(0x9f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_SWRemote(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x9f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_FlashVars()
+ {
+ CString result;
+ InvokeHelper(0xaa, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_FlashVars(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0xaa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_AllowScriptAccess()
+ {
+ CString result;
+ InvokeHelper(0xab, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_AllowScriptAccess(LPCTSTR newValue)
+ {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0xab, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
};
diff --git a/src/apps/mplayerc/ChildView.cpp b/src/apps/mplayerc/ChildView.cpp
index 51d4f8613..e5cff9565 100644
--- a/src/apps/mplayerc/ChildView.cpp
+++ b/src/apps/mplayerc/ChildView.cpp
@@ -31,345 +31,345 @@
/////////////////////////////////////////////////////////////////////////////
// CChildView
-CChildView::CChildView() : m_vrect(0, 0, 0, 0)
+CChildView::CChildView() : m_vrect(0,0,0,0)
{
- m_lastlmdowntime = 0;
- m_lastlmdownpoint.SetPoint(0, 0);
+ m_lastlmdowntime = 0;
+ m_lastlmdownpoint.SetPoint(0, 0);
- LoadLogo();
+ LoadLogo();
}
CChildView::~CChildView()
{
}
-BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
+BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CWnd::PreCreateWindow(cs))
- return FALSE;
+ if(!CWnd::PreCreateWindow(cs))
+ return FALSE;
- cs.style &= ~WS_BORDER;
- cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
- ::LoadCursor(NULL, IDC_HAND), HBRUSH(COLOR_WINDOW + 1), NULL);
+ cs.style &= ~WS_BORDER;
+ cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
+ ::LoadCursor(NULL, IDC_HAND), HBRUSH(COLOR_WINDOW+1), NULL);
- return TRUE;
+ return TRUE;
}
BOOL CChildView::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MYMOUSELAST)
- {
- CWnd* pParent = GetParent();
- CPoint p(pMsg->lParam);
- ::MapWindowPoints(pMsg->hwnd, pParent->m_hWnd, &p, 1);
-
- bool fDblClick = false;
-
- bool fInteractiveVideo = ((CMainFrame*)AfxGetMainWnd())->IsInteractiveVideo();
- /*
- if(fInteractiveVideo)
- {
- if(pMsg->message == WM_LBUTTONDOWN)
- {
- if((pMsg->time - m_lastlmdowntime) <= GetDoubleClickTime()
- && abs(pMsg->pt.x - m_lastlmdownpoint.x) <= GetSystemMetrics(SM_CXDOUBLECLK)
- && abs(pMsg->pt.y - m_lastlmdownpoint.y) <= GetSystemMetrics(SM_CYDOUBLECLK))
- {
- fDblClick = true;
- m_lastlmdowntime = 0;
- m_lastlmdownpoint.SetPoint(0, 0);
- }
- else
- {
- m_lastlmdowntime = pMsg->time;
- m_lastlmdownpoint = pMsg->pt;
- }
- }
- else if(pMsg->message == WM_LBUTTONDBLCLK)
- {
- m_lastlmdowntime = pMsg->time;
- m_lastlmdownpoint = pMsg->pt;
- }
- }
- */
- if((pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP || pMsg->message == WM_MOUSEMOVE)
- && fInteractiveVideo)
- {
- if(pMsg->message == WM_MOUSEMOVE)
- {
- pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
- }
-
- if(fDblClick)
- {
- pParent->PostMessage(WM_LBUTTONDOWN, pMsg->wParam, MAKELPARAM(p.x, p.y));
- pParent->PostMessage(WM_LBUTTONDBLCLK, pMsg->wParam, MAKELPARAM(p.x, p.y));
- }
- }
- else
- {
- pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MYMOUSELAST)
+ {
+ CWnd* pParent = GetParent();
+ CPoint p(pMsg->lParam);
+ ::MapWindowPoints(pMsg->hwnd, pParent->m_hWnd, &p, 1);
+
+ bool fDblClick = false;
+
+ bool fInteractiveVideo = ((CMainFrame*)AfxGetMainWnd())->IsInteractiveVideo();
+/*
+ if(fInteractiveVideo)
+ {
+ if(pMsg->message == WM_LBUTTONDOWN)
+ {
+ if((pMsg->time - m_lastlmdowntime) <= GetDoubleClickTime()
+ && abs(pMsg->pt.x - m_lastlmdownpoint.x) <= GetSystemMetrics(SM_CXDOUBLECLK)
+ && abs(pMsg->pt.y - m_lastlmdownpoint.y) <= GetSystemMetrics(SM_CYDOUBLECLK))
+ {
+ fDblClick = true;
+ m_lastlmdowntime = 0;
+ m_lastlmdownpoint.SetPoint(0, 0);
+ }
+ else
+ {
+ m_lastlmdowntime = pMsg->time;
+ m_lastlmdownpoint = pMsg->pt;
+ }
+ }
+ else if(pMsg->message == WM_LBUTTONDBLCLK)
+ {
+ m_lastlmdowntime = pMsg->time;
+ m_lastlmdownpoint = pMsg->pt;
+ }
+ }
+*/
+ if((pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP || pMsg->message == WM_MOUSEMOVE)
+ && fInteractiveVideo)
+ {
+ if(pMsg->message == WM_MOUSEMOVE)
+ {
+ pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ }
+
+ if(fDblClick)
+ {
+ pParent->PostMessage(WM_LBUTTONDOWN, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ pParent->PostMessage(WM_LBUTTONDBLCLK, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ }
+ }
+ else
+ {
+ pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
return TRUE;
- }
- }
+ }
+ }
- return CWnd::PreTranslateMessage(pMsg);
+ return CWnd::PreTranslateMessage(pMsg);
}
void CChildView::SetVideoRect(CRect r)
{
- m_vrect = r;
+ m_vrect = r;
- Invalidate();
+ Invalidate();
}
void CChildView::LoadLogo()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CAutoLock cAutoLock(&m_csLogo);
+ CAutoLock cAutoLock(&m_csLogo);
- m_logo.Destroy();
+ m_logo.Destroy();
- if(s.logoext)
- {
- if(AfxGetAppSettings().fXpOrBetter)
- m_logo.Load(s.logofn);
- else if(HANDLE h = LoadImage(NULL, s.logofn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE))
- m_logo.Attach((HBITMAP)h); // win9x bug: Inside Attach GetObject() will return all zeros in DIBSECTION and silly CImage uses that to init width, height, bpp, ... so we can't use CImage::Draw later
- }
+ if(s.logoext)
+ {
+ if(AfxGetAppSettings().fXpOrBetter)
+ m_logo.Load(s.logofn);
+ else if(HANDLE h = LoadImage(NULL, s.logofn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE))
+ m_logo.Attach((HBITMAP)h); // win9x bug: Inside Attach GetObject() will return all zeros in DIBSECTION and silly CImage uses that to init width, height, bpp, ... so we can't use CImage::Draw later
+ }
- if(m_logo.IsNull())
- {
- m_logo.LoadFromResource(s.logoid);
- // m_logo.LoadFromResource(AfxGetInstanceHandle(), s.logoid);
- }
+ if(m_logo.IsNull())
+ {
+ m_logo.LoadFromResource(s.logoid);
+ // m_logo.LoadFromResource(AfxGetInstanceHandle(), s.logoid);
+ }
- if(m_hWnd) Invalidate();
+ if(m_hWnd) Invalidate();
}
CSize CChildView::GetLogoSize()
{
- CSize ret(0, 0);
- if(!m_logo.IsNull())
- ret.SetSize(m_logo.GetWidth(), m_logo.GetHeight());
- return ret;
+ CSize ret(0,0);
+ if(!m_logo.IsNull())
+ ret.SetSize(m_logo.GetWidth(), m_logo.GetHeight());
+ return ret;
}
IMPLEMENT_DYNAMIC(CChildView, CWnd)
BEGIN_MESSAGE_MAP(CChildView, CWnd)
- //{{AFX_MSG_MAP(CChildView)
- ON_WM_PAINT()
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_COMMAND_EX(ID_PLAY_PLAYPAUSE, OnPlayPlayPauseStop)
- ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlayPauseStop)
- ON_COMMAND_EX(ID_PLAY_PAUSE, OnPlayPlayPauseStop)
- ON_COMMAND_EX(ID_PLAY_STOP, OnPlayPlayPauseStop)
- ON_WM_SETCURSOR()
- //}}AFX_MSG_MAP
- // ON_WM_NCHITTEST()
- ON_WM_NCHITTEST()
- ON_WM_NCLBUTTONDOWN()
+ //{{AFX_MSG_MAP(CChildView)
+ ON_WM_PAINT()
+ ON_WM_ERASEBKGND()
+ ON_WM_SIZE()
+ ON_COMMAND_EX(ID_PLAY_PLAYPAUSE, OnPlayPlayPauseStop)
+ ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlayPauseStop)
+ ON_COMMAND_EX(ID_PLAY_PAUSE, OnPlayPlayPauseStop)
+ ON_COMMAND_EX(ID_PLAY_STOP, OnPlayPlayPauseStop)
+ ON_WM_SETCURSOR()
+ //}}AFX_MSG_MAP
+ // ON_WM_NCHITTEST()
+ ON_WM_NCHITTEST()
+ ON_WM_NCLBUTTONDOWN()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildView message handlers
-void CChildView::OnPaint()
+void CChildView::OnPaint()
{
- CPaintDC dc(this); // device context for painting
+ CPaintDC dc(this); // device context for painting
- ((CMainFrame*)GetParentFrame())->RepaintVideo();
+ ((CMainFrame*)GetParentFrame())->RepaintVideo();
- // Do not call CWnd::OnPaint() for painting messages
+ // Do not call CWnd::OnPaint() for painting messages
}
BOOL CChildView::OnEraseBkgnd(CDC* pDC)
{
- CRect r;
-
- CAutoLock cAutoLock(&m_csLogo);
-
- if(((CMainFrame*)GetParentFrame())->IsSomethingLoaded())
- {
- pDC->ExcludeClipRect(m_vrect);
- }
- else if(!m_logo.IsNull() /*&& ((CMainFrame*)GetParentFrame())->IsPlaylistEmpty()*/)
- {
- BITMAP bm;
- GetObject(m_logo, sizeof(bm), &bm);
-
- GetClientRect(r);
- int w = min(bm.bmWidth, r.Width());
- int h = min(abs(bm.bmHeight), r.Height());
+ CRect r;
+
+ CAutoLock cAutoLock(&m_csLogo);
+
+ if(((CMainFrame*)GetParentFrame())->IsSomethingLoaded())
+ {
+ pDC->ExcludeClipRect(m_vrect);
+ }
+ else if(!m_logo.IsNull() /*&& ((CMainFrame*)GetParentFrame())->IsPlaylistEmpty()*/)
+ {
+ BITMAP bm;
+ GetObject(m_logo, sizeof(bm), &bm);
+
+ GetClientRect(r);
+ int w = min(bm.bmWidth, r.Width());
+ int h = min(abs(bm.bmHeight), r.Height());
// int w = min(m_logo.GetWidth(), r.Width());
// int h = min(m_logo.GetHeight(), r.Height());
- int x = (r.Width() - w) / 2;
- int y = (r.Height() - h) / 2;
- r = CRect(CPoint(x, y), CSize(w, h));
+ int x = (r.Width() - w) / 2;
+ int y = (r.Height() - h) / 2;
+ r = CRect(CPoint(x, y), CSize(w, h));
- int oldmode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
- m_logo.StretchBlt(*pDC, r, CRect(0, 0, bm.bmWidth, abs(bm.bmHeight)));
+ int oldmode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
+ m_logo.StretchBlt(*pDC, r, CRect(0,0,bm.bmWidth,abs(bm.bmHeight)));
// m_logo.Draw(*pDC, r);
- pDC->SetStretchBltMode(oldmode);
+ pDC->SetStretchBltMode(oldmode);
- pDC->ExcludeClipRect(r);
- }
+ pDC->ExcludeClipRect(r);
+ }
- GetClientRect(r);
- pDC->FillSolidRect(r, 0);
+ GetClientRect(r);
+ pDC->FillSolidRect(r, 0);
- return TRUE;
+ return TRUE;
}
void CChildView::OnSize(UINT nType, int cx, int cy)
{
- CWnd::OnSize(nType, cx, cy);
+ CWnd::OnSize(nType, cx, cy);
- ((CMainFrame*)GetParentFrame())->MoveVideoWindow();
+ ((CMainFrame*)GetParentFrame())->MoveVideoWindow();
}
BOOL CChildView::OnPlayPlayPauseStop(UINT nID)
{
- if(nID == ID_PLAY_STOP) SetVideoRect();
- CString osd = ResStr(nID);
- int i = osd.Find(_T("\n"));
- if(i > 0) osd.Delete(i, osd.GetLength() - i);
+ if(nID == ID_PLAY_STOP) SetVideoRect();
+ CString osd = ResStr(nID);
+ int i = osd.Find(_T("\n"));
+ if(i > 0) osd.Delete(i, osd.GetLength()-i);
- CRect r1;
- ((CMainFrame*)AfxGetMainWnd())->GetClientRect(&r1);
- if((!r1.Width()) || (!r1.Height())) return FALSE;
+ CRect r1;
+ ((CMainFrame*)AfxGetMainWnd())->GetClientRect(&r1);
+ if((!r1.Width()) || (!r1.Height())) return FALSE;
- ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, osd, 1500);
- return FALSE;
+ ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, osd, 1500);
+ return FALSE;
}
BOOL CChildView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- if(((CMainFrame*)GetParentFrame())->m_fHideCursor)
- {
- SetCursor(NULL);
- return TRUE;
- }
- return CWnd::OnSetCursor(pWnd, nHitTest, message);
+ if(((CMainFrame*)GetParentFrame())->m_fHideCursor)
+ {
+ SetCursor(NULL);
+ return TRUE;
+ }
+ return CWnd::OnSetCursor(pWnd, nHitTest, message);
}
LRESULT CChildView::OnNcHitTest(CPoint point)
{
- UINT nHitTest = CWnd::OnNcHitTest(point);
-
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- bool fLeftMouseBtnUnassigned = true;
- AppSettings& s = AfxGetAppSettings();
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos && fLeftMouseBtnUnassigned)
- if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
- fLeftMouseBtnUnassigned = false;
- if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
- {
- CRect rcClient, rcFrame;
- GetWindowRect(&rcFrame);
- rcClient = rcFrame;
-
- CSize sizeBorder(GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
-
- rcClient.InflateRect(-(5 * sizeBorder.cx), -(5 * sizeBorder.cy));
- rcFrame.InflateRect(sizeBorder.cx, sizeBorder.cy);
-
- if(rcFrame.PtInRect(point))
- {
- if(point.x > rcClient.right)
- {
- if(point.y < rcClient.top)
- {
- nHitTest = HTTOPRIGHT;
- }
- else if(point.y > rcClient.bottom)
- {
- nHitTest = HTBOTTOMRIGHT;
- }
- else
- {
- nHitTest = HTRIGHT;
- }
- }
- else if(point.x < rcClient.left)
- {
- if(point.y < rcClient.top)
- {
- nHitTest = HTTOPLEFT;
- }
- else if(point.y > rcClient.bottom)
- {
- nHitTest = HTBOTTOMLEFT;
- }
- else
- {
- nHitTest = HTLEFT;
- }
- }
- else if(point.y < rcClient.top)
- {
- nHitTest = HTTOP;
- }
- else if(point.y > rcClient.bottom)
- {
- nHitTest = HTBOTTOM;
- }
- }
- }
- return nHitTest;
+ UINT nHitTest = CWnd::OnNcHitTest(point);
+
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ bool fLeftMouseBtnUnassigned = true;
+ AppSettings& s = AfxGetAppSettings();
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos && fLeftMouseBtnUnassigned)
+ if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
+ fLeftMouseBtnUnassigned = false;
+ if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
+ {
+ CRect rcClient, rcFrame;
+ GetWindowRect(&rcFrame);
+ rcClient = rcFrame;
+
+ CSize sizeBorder(GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
+
+ rcClient.InflateRect(-(5 * sizeBorder.cx), -(5 * sizeBorder.cy));
+ rcFrame.InflateRect(sizeBorder.cx, sizeBorder.cy);
+
+ if(rcFrame.PtInRect(point))
+ {
+ if(point.x > rcClient.right)
+ {
+ if(point.y < rcClient.top)
+ {
+ nHitTest = HTTOPRIGHT;
+ }
+ else if(point.y > rcClient.bottom)
+ {
+ nHitTest = HTBOTTOMRIGHT;
+ }
+ else
+ {
+ nHitTest = HTRIGHT;
+ }
+ }
+ else if(point.x < rcClient.left)
+ {
+ if(point.y < rcClient.top)
+ {
+ nHitTest = HTTOPLEFT;
+ }
+ else if(point.y > rcClient.bottom)
+ {
+ nHitTest = HTBOTTOMLEFT;
+ }
+ else
+ {
+ nHitTest = HTLEFT;
+ }
+ }
+ else if(point.y < rcClient.top)
+ {
+ nHitTest = HTTOP;
+ }
+ else if(point.y > rcClient.bottom)
+ {
+ nHitTest = HTBOTTOM;
+ }
+ }
+ }
+ return nHitTest;
}
void CChildView::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- bool fLeftMouseBtnUnassigned = true;
- AppSettings& s = AfxGetAppSettings();
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos && fLeftMouseBtnUnassigned)
- if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
- fLeftMouseBtnUnassigned = false;
- if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
- {
- BYTE bFlag = 0;
- switch(nHitTest)
- {
- case HTTOP:
- bFlag = WMSZ_TOP;
- break;
- case HTTOPLEFT:
- bFlag = WMSZ_TOPLEFT;
- break;
- case HTTOPRIGHT:
- bFlag = WMSZ_TOPRIGHT;
- break;
- case HTLEFT:
- bFlag = WMSZ_LEFT;
- break;
- case HTRIGHT:
- bFlag = WMSZ_RIGHT;
- break;
- case HTBOTTOM:
- bFlag = WMSZ_BOTTOM;
- break;
- case HTBOTTOMLEFT:
- bFlag = WMSZ_BOTTOMLEFT;
- break;
- case HTBOTTOMRIGHT:
- bFlag = WMSZ_BOTTOMRIGHT;
- break;
- }
- if(bFlag)
- {
- pFrame->PostMessage(WM_SYSCOMMAND, (SC_SIZE | bFlag), (LPARAM)POINTTOPOINTS(point));
- }
- else
- {
- CWnd::OnNcLButtonDown(nHitTest, point);
- }
- }
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ bool fLeftMouseBtnUnassigned = true;
+ AppSettings& s = AfxGetAppSettings();
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos && fLeftMouseBtnUnassigned)
+ if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
+ fLeftMouseBtnUnassigned = false;
+ if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
+ {
+ BYTE bFlag = 0;
+ switch(nHitTest)
+ {
+ case HTTOP:
+ bFlag = WMSZ_TOP;
+ break;
+ case HTTOPLEFT:
+ bFlag = WMSZ_TOPLEFT;
+ break;
+ case HTTOPRIGHT:
+ bFlag = WMSZ_TOPRIGHT;
+ break;
+ case HTLEFT:
+ bFlag = WMSZ_LEFT;
+ break;
+ case HTRIGHT:
+ bFlag = WMSZ_RIGHT;
+ break;
+ case HTBOTTOM:
+ bFlag = WMSZ_BOTTOM;
+ break;
+ case HTBOTTOMLEFT:
+ bFlag = WMSZ_BOTTOMLEFT;
+ break;
+ case HTBOTTOMRIGHT:
+ bFlag = WMSZ_BOTTOMRIGHT;
+ break;
+ }
+ if(bFlag)
+ {
+ pFrame->PostMessage(WM_SYSCOMMAND, (SC_SIZE | bFlag), (LPARAM)POINTTOPOINTS(point));
+ }
+ else
+ {
+ CWnd::OnNcLButtonDown(nHitTest, point);
+ }
+ }
}
diff --git a/src/apps/mplayerc/ChildView.h b/src/apps/mplayerc/ChildView.h
index cfb456756..3f5ee961f 100644
--- a/src/apps/mplayerc/ChildView.h
+++ b/src/apps/mplayerc/ChildView.h
@@ -27,43 +27,40 @@
class CChildView : public CWnd
{
- CRect m_vrect;
+ CRect m_vrect;
- DWORD m_lastlmdowntime;
- CPoint m_lastlmdownpoint;
+ DWORD m_lastlmdowntime;
+ CPoint m_lastlmdownpoint;
- CCritSec m_csLogo;
- CPngImage m_logo;
+ CCritSec m_csLogo;
+ CPngImage m_logo;
public:
- CChildView();
- virtual ~CChildView();
+ CChildView();
+ virtual ~CChildView();
- DECLARE_DYNAMIC(CChildView)
+ DECLARE_DYNAMIC(CChildView)
public:
- void SetVideoRect(CRect r = CRect(0, 0, 0, 0));
- CRect GetVideoRect()
- {
- return(m_vrect);
- }
+ void SetVideoRect(CRect r = CRect(0,0,0,0));
+ CRect GetVideoRect() {return(m_vrect);}
- void LoadLogo();
- CSize GetLogoSize();
+ void LoadLogo();
+ CSize GetLogoSize();
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- afx_msg void OnPaint();
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg BOOL OnPlayPlayPauseStop(UINT nID);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg void OnPaint();
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg BOOL OnPlayPlayPauseStop(UINT nID);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg LRESULT OnNcHitTest(CPoint point);
- afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+ afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
};
diff --git a/src/apps/mplayerc/ComPropertyPage.cpp b/src/apps/mplayerc/ComPropertyPage.cpp
index 865aebb33..5cbd5bd44 100644
--- a/src/apps/mplayerc/ComPropertyPage.cpp
+++ b/src/apps/mplayerc/ComPropertyPage.cpp
@@ -31,12 +31,12 @@
IMPLEMENT_DYNAMIC(CComPropertyPage, CPropertyPage)
CComPropertyPage::CComPropertyPage(IPropertyPage* pPage)
- : CPropertyPage(CComPropertyPage::IDD), m_pPage(pPage)
+ : CPropertyPage(CComPropertyPage::IDD), m_pPage(pPage)
{
- PROPPAGEINFO ppi;
- m_pPage->GetPageInfo(&ppi);
- m_pPSP->pszTitle = (m_strCaption = ppi.pszTitle);
- m_psp.dwFlags |= PSP_USETITLE;
+ PROPPAGEINFO ppi;
+ m_pPage->GetPageInfo(&ppi);
+ m_pPSP->pszTitle = (m_strCaption = ppi.pszTitle);
+ m_psp.dwFlags |= PSP_USETITLE;
}
CComPropertyPage::~CComPropertyPage()
@@ -45,55 +45,55 @@ CComPropertyPage::~CComPropertyPage()
void CComPropertyPage::DoDataExchange(CDataExchange* pDX)
{
- CPropertyPage::DoDataExchange(pDX);
+ CPropertyPage::DoDataExchange(pDX);
}
BOOL CComPropertyPage::OnInitDialog()
{
- CPropertyPage::OnInitDialog();
+ CPropertyPage::OnInitDialog();
- CRect r;
- PROPPAGEINFO ppi;
- m_pPage->GetPageInfo(&ppi);
- r = CRect(CPoint(0, 0), ppi.size);
- m_pPage->Activate(m_hWnd, r, FALSE);
- m_pPage->Show(SW_SHOW);
+ CRect r;
+ PROPPAGEINFO ppi;
+ m_pPage->GetPageInfo(&ppi);
+ r = CRect(CPoint(0,0), ppi.size);
+ m_pPage->Activate(m_hWnd, r, FALSE);
+ m_pPage->Show(SW_SHOW);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CComPropertyPage::OnDestroy()
{
- CPropertyPage::OnDestroy();
+ CPropertyPage::OnDestroy();
- m_pPage->Deactivate();
+ m_pPage->Deactivate();
}
BOOL CComPropertyPage::OnSetActive()
{
- SetModified(S_OK == m_pPage->IsPageDirty());
+ SetModified(S_OK == m_pPage->IsPageDirty());
- CWnd* pParent = GetParent();
- if(pParent->IsKindOf(RUNTIME_CLASS(CComPropertySheet)))
- {
- CComPropertySheet* pSheet = static_cast<CComPropertySheet*>(pParent);
- pSheet->OnActivated(this);
- }
+ CWnd* pParent = GetParent();
+ if(pParent->IsKindOf(RUNTIME_CLASS(CComPropertySheet)))
+ {
+ CComPropertySheet* pSheet = static_cast<CComPropertySheet*>(pParent);
+ pSheet->OnActivated(this);
+ }
- return CPropertyPage::OnSetActive();
+ return CPropertyPage::OnSetActive();
}
BOOL CComPropertyPage::OnKillActive()
{
- SetModified(FALSE);
+ SetModified(FALSE);
- return CPropertyPage::OnKillActive();
+ return CPropertyPage::OnKillActive();
}
BEGIN_MESSAGE_MAP(CComPropertyPage, CPropertyPage)
- ON_WM_DESTROY()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
@@ -101,8 +101,8 @@ END_MESSAGE_MAP()
void CComPropertyPage::OnOK()
{
- if(S_OK == m_pPage->IsPageDirty()) m_pPage->Apply();
- SetModified(FALSE);
+ if(S_OK == m_pPage->IsPageDirty()) m_pPage->Apply();
+ SetModified(FALSE);
- CPropertyPage::OnOK();
+ CPropertyPage::OnOK();
}
diff --git a/src/apps/mplayerc/ComPropertyPage.h b/src/apps/mplayerc/ComPropertyPage.h
index 3deb821b9..e8fa04d64 100644
--- a/src/apps/mplayerc/ComPropertyPage.h
+++ b/src/apps/mplayerc/ComPropertyPage.h
@@ -27,26 +27,26 @@
class CComPropertyPage : public CPropertyPage
{
- DECLARE_DYNAMIC(CComPropertyPage)
+ DECLARE_DYNAMIC(CComPropertyPage)
- CComPtr<IPropertyPage> m_pPage;
+ CComPtr<IPropertyPage> m_pPage;
public:
- CComPropertyPage(IPropertyPage* pPage);
- virtual ~CComPropertyPage();
+ CComPropertyPage(IPropertyPage* pPage);
+ virtual ~CComPropertyPage();
// Dialog Data
- enum { IDD = IDD_COMPROPERTYPAGE };
+ enum { IDD = IDD_COMPROPERTYPAGE };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnSetActive();
- virtual BOOL OnKillActive();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnSetActive();
+ virtual BOOL OnKillActive();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- virtual BOOL OnInitDialog();
- afx_msg void OnDestroy();
- virtual void OnOK();
+ virtual BOOL OnInitDialog();
+ afx_msg void OnDestroy();
+ virtual void OnOK();
};
diff --git a/src/apps/mplayerc/ComPropertySheet.cpp b/src/apps/mplayerc/ComPropertySheet.cpp
index 5f286b2fb..70b2ea4b5 100644
--- a/src/apps/mplayerc/ComPropertySheet.cpp
+++ b/src/apps/mplayerc/ComPropertySheet.cpp
@@ -32,60 +32,54 @@
class CComPropertyPageSite : public CUnknown, public IPropertyPageSite
{
- IComPropertyPageDirty* m_pPPD;
+ IComPropertyPageDirty* m_pPPD;
public:
- CComPropertyPageSite(IComPropertyPageDirty* pPPD) : CUnknown(NAME("CComPropertyPageSite"), NULL), m_pPPD(pPPD) {}
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- return
- QI(IPropertyPageSite)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- // IPropertyPageSite
- STDMETHODIMP OnStatusChange(DWORD flags)
- {
- if(m_pPPD)
- {
- if(flags & PROPPAGESTATUS_DIRTY) m_pPPD->OnSetDirty(true);
- if(flags & PROPPAGESTATUS_CLEAN) m_pPPD->OnSetDirty(false);
- }
- return S_OK;
- }
- STDMETHODIMP GetLocaleID(LCID* pLocaleID)
- {
- CheckPointer(pLocaleID, E_POINTER);
- *pLocaleID = ::GetUserDefaultLCID();
- return S_OK;
- }
- STDMETHODIMP GetPageContainer(IUnknown** ppUnk)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP TranslateAccelerator(LPMSG pMsg)
- {
- return E_NOTIMPL;
- }
+ CComPropertyPageSite(IComPropertyPageDirty* pPPD) : CUnknown(NAME("CComPropertyPageSite"), NULL), m_pPPD(pPPD) {}
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ return
+ QI(IPropertyPageSite)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ // IPropertyPageSite
+ STDMETHODIMP OnStatusChange(DWORD flags)
+ {
+ if(m_pPPD)
+ {
+ if(flags&PROPPAGESTATUS_DIRTY) m_pPPD->OnSetDirty(true);
+ if(flags&PROPPAGESTATUS_CLEAN) m_pPPD->OnSetDirty(false);
+ }
+ return S_OK;
+ }
+ STDMETHODIMP GetLocaleID(LCID* pLocaleID)
+ {
+ CheckPointer(pLocaleID, E_POINTER);
+ *pLocaleID = ::GetUserDefaultLCID();
+ return S_OK;
+ }
+ STDMETHODIMP GetPageContainer(IUnknown** ppUnk) {return E_NOTIMPL;}
+ STDMETHODIMP TranslateAccelerator(LPMSG pMsg) {return E_NOTIMPL;}
};
// CComPropertySheet
IMPLEMENT_DYNAMIC(CComPropertySheet, CPropertySheet)
CComPropertySheet::CComPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
- : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
+ : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
- m_pSite = DNew CComPropertyPageSite(this);
- m_size.SetSize(0, 0);
+ m_pSite = DNew CComPropertyPageSite(this);
+ m_size.SetSize(0, 0);
}
CComPropertySheet::CComPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
- : CPropertySheet(pszCaption, pParentWnd, iSelectPage)
+ : CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
- m_pSite = DNew CComPropertyPageSite(this);
- m_size.SetSize(0, 0);
+ m_pSite = DNew CComPropertyPageSite(this);
+ m_size.SetSize(0, 0);
}
CComPropertySheet::~CComPropertySheet()
@@ -94,144 +88,144 @@ CComPropertySheet::~CComPropertySheet()
int CComPropertySheet::AddPages(CComPtr<ISpecifyPropertyPages> pSPP)
{
- if(!pSPP) return(0);
+ if(!pSPP) return(0);
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if(FAILED(pSPP->GetPages(&caGUID)))
- return(0);
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if(FAILED(pSPP->GetPages(&caGUID)))
+ return(0);
- IUnknown* lpUnk = NULL;
- if(FAILED(pSPP.QueryInterface(&lpUnk)))
- return(0);
+ IUnknown* lpUnk = NULL;
+ if(FAILED(pSPP.QueryInterface(&lpUnk)))
+ return(0);
- m_spp.AddTail(pSPP);
+ m_spp.AddTail(pSPP);
- CComQIPtr<ISpecifyPropertyPages2> pSPP2 = pSPP;
- CComQIPtr<IPersist> pPersist = pSPP;
+ CComQIPtr<ISpecifyPropertyPages2> pSPP2 = pSPP;
+ CComQIPtr<IPersist> pPersist = pSPP;
- ULONG nPages = 0;
- for(ULONG i = 0; i < caGUID.cElems; i++)
- {
- CComPtr<IPropertyPage> pPage;
+ ULONG nPages = 0;
+ for(ULONG i = 0; i < caGUID.cElems; i++)
+ {
+ CComPtr<IPropertyPage> pPage;
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if(FAILED(hr) && !pPage && pSPP2)
- {
- hr = pSPP2->CreatePage(caGUID.pElems[i], &pPage);
- }
+ if(FAILED(hr) && !pPage && pSPP2)
+ {
+ hr = pSPP2->CreatePage(caGUID.pElems[i], &pPage);
+ }
- if(FAILED(hr) && !pPage)
- {
- hr = pPage.CoCreateInstance(caGUID.pElems[i]);
- }
+ if(FAILED(hr) && !pPage)
+ {
+ hr = pPage.CoCreateInstance(caGUID.pElems[i]);
+ }
- if(FAILED(hr) && !pPage && pPersist)
- {
- hr = LoadExternalPropertyPage(pPersist, caGUID.pElems[i], &pPage);
- }
+ if(FAILED(hr) && !pPage && pPersist)
+ {
+ hr = LoadExternalPropertyPage(pPersist, caGUID.pElems[i], &pPage);
+ }
- if(SUCCEEDED(hr))
- {
- if(AddPage(pPage, lpUnk))
- nPages++;
- }
- }
+ if(SUCCEEDED(hr))
+ {
+ if(AddPage(pPage, lpUnk))
+ nPages++;
+ }
+ }
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- lpUnk->Release();
+ if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+ lpUnk->Release();
- return(nPages);
+ return(nPages);
}
bool CComPropertySheet::AddPage(IPropertyPage* pPage, IUnknown* pUnk)
{
- if(!pPage || !pUnk) return false;
-
- HRESULT hr;
- hr = pPage->SetPageSite(m_pSite);
- hr = pPage->SetObjects(1, &pUnk);
- PROPPAGEINFO ppi;
- hr = pPage->GetPageInfo(&ppi);
- m_size.cx = max(m_size.cx, ppi.size.cx);
- m_size.cy = max(m_size.cy, ppi.size.cy);
- CAutoPtr<CComPropertyPage> p(DNew CComPropertyPage(pPage));
- __super::AddPage(p);
- m_pages.AddTail(p);
-
- return true;
+ if(!pPage || !pUnk) return false;
+
+ HRESULT hr;
+ hr = pPage->SetPageSite(m_pSite);
+ hr = pPage->SetObjects(1, &pUnk);
+ PROPPAGEINFO ppi;
+ hr = pPage->GetPageInfo(&ppi);
+ m_size.cx = max(m_size.cx, ppi.size.cx);
+ m_size.cy = max(m_size.cy, ppi.size.cy);
+ CAutoPtr<CComPropertyPage> p(DNew CComPropertyPage(pPage));
+ __super::AddPage(p);
+ m_pages.AddTail(p);
+
+ return true;
}
void CComPropertySheet::OnActivated(CPropertyPage* pPage)
{
- if(!pPage) return;
-
- CRect bounds(30000, 30000, -30000, -30000);
-
- CRect wr, cr;
- GetWindowRect(wr);
- GetClientRect(cr);
- CSize ws = wr.Size(), cs = cr.Size();
-
- CRect twr, tcr;
- CTabCtrl* pTC = (CTabCtrl*)GetDlgItem(AFX_IDC_TAB_CONTROL);
- pTC->GetWindowRect(twr);
- pTC->GetClientRect(tcr);
- CSize tws = twr.Size(), tcs = tcr.Size();
-
- if(CWnd* pChild = pPage->GetWindow(GW_CHILD))
- {
- pChild->ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0);
- pChild->ModifyStyleEx(WS_EX_DLGMODALFRAME, WS_EX_CONTROLPARENT);
-
- for(CWnd* pGrandChild = pChild->GetWindow(GW_CHILD); pGrandChild; pGrandChild = pGrandChild->GetNextWindow())
- {
- if(!(pGrandChild->GetStyle()&WS_VISIBLE)) continue;
-
- CRect r;
- pGrandChild->GetWindowRect(&r);
- pChild->ScreenToClient(r);
- bounds |= r;
- }
- }
-
- bounds |= CRect(0, 0, 0, 0);
- bounds.SetRect(0, 0, bounds.right + max(bounds.left, 4), bounds.bottom + max(bounds.top, 4));
-
- CRect r = CRect(CPoint(0, 0), bounds.Size());
- pTC->AdjustRect(TRUE, r);
- r.SetRect(twr.TopLeft(), twr.TopLeft() + r.Size());
- ScreenToClient(r);
- pTC->MoveWindow(r);
- pTC->ModifyStyle(TCS_MULTILINE, TCS_SINGLELINE);
-
- CSize diff = r.Size() - tws;
-
- if(!bounds.IsRectEmpty())
- {
- if(CWnd* pChild = pPage->GetWindow(GW_CHILD))
- pChild->MoveWindow(bounds);
- CRect r = twr;
- pTC->AdjustRect(FALSE, r);
- ScreenToClient(r);
- pPage->MoveWindow(CRect(r.TopLeft(), bounds.Size()));
- }
-
- int _afxPropSheetButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP };
- for(int i = 0; i < countof(_afxPropSheetButtons); i++)
- {
- if(CWnd* pWnd = GetDlgItem(_afxPropSheetButtons[i]))
- {
- pWnd->GetWindowRect(r);
- ScreenToClient(r);
- pWnd->MoveWindow(CRect(r.TopLeft() + diff, r.Size()));
- }
- }
-
- MoveWindow(CRect(wr.TopLeft(), ws + diff));
-
- Invalidate();
+ if(!pPage) return;
+
+ CRect bounds(30000,30000,-30000,-30000);
+
+ CRect wr, cr;
+ GetWindowRect(wr);
+ GetClientRect(cr);
+ CSize ws = wr.Size(), cs = cr.Size();
+
+ CRect twr, tcr;
+ CTabCtrl* pTC = (CTabCtrl*)GetDlgItem(AFX_IDC_TAB_CONTROL);
+ pTC->GetWindowRect(twr);
+ pTC->GetClientRect(tcr);
+ CSize tws = twr.Size(), tcs = tcr.Size();
+
+ if(CWnd* pChild = pPage->GetWindow(GW_CHILD))
+ {
+ pChild->ModifyStyle(WS_CAPTION|WS_THICKFRAME, 0);
+ pChild->ModifyStyleEx(WS_EX_DLGMODALFRAME, WS_EX_CONTROLPARENT);
+
+ for(CWnd* pGrandChild = pChild->GetWindow(GW_CHILD); pGrandChild; pGrandChild = pGrandChild->GetNextWindow())
+ {
+ if(!(pGrandChild->GetStyle()&WS_VISIBLE)) continue;
+
+ CRect r;
+ pGrandChild->GetWindowRect(&r);
+ pChild->ScreenToClient(r);
+ bounds |= r;
+ }
+ }
+
+ bounds |= CRect(0,0,0,0);
+ bounds.SetRect(0, 0, bounds.right + max(bounds.left, 4), bounds.bottom + max(bounds.top, 4));
+
+ CRect r = CRect(CPoint(0,0), bounds.Size());
+ pTC->AdjustRect(TRUE, r);
+ r.SetRect(twr.TopLeft(), twr.TopLeft() + r.Size());
+ ScreenToClient(r);
+ pTC->MoveWindow(r);
+ pTC->ModifyStyle(TCS_MULTILINE, TCS_SINGLELINE);
+
+ CSize diff = r.Size() - tws;
+
+ if(!bounds.IsRectEmpty())
+ {
+ if(CWnd* pChild = pPage->GetWindow(GW_CHILD))
+ pChild->MoveWindow(bounds);
+ CRect r = twr;
+ pTC->AdjustRect(FALSE, r);
+ ScreenToClient(r);
+ pPage->MoveWindow(CRect(r.TopLeft(), bounds.Size()));
+ }
+
+ int _afxPropSheetButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP };
+ for(int i = 0; i < countof(_afxPropSheetButtons); i++)
+ {
+ if(CWnd* pWnd = GetDlgItem(_afxPropSheetButtons[i]))
+ {
+ pWnd->GetWindowRect(r);
+ ScreenToClient(r);
+ pWnd->MoveWindow(CRect(r.TopLeft() + diff, r.Size()));
+ }
+ }
+
+ MoveWindow(CRect(wr.TopLeft(), ws + diff));
+
+ Invalidate();
}
@@ -243,10 +237,10 @@ END_MESSAGE_MAP()
BOOL CComPropertySheet::OnInitDialog()
{
- BOOL bResult = (BOOL)Default();//CPropertySheet::OnInitDialog();
+ BOOL bResult = (BOOL)Default();//CPropertySheet::OnInitDialog();
- if(!(GetStyle() & WS_CHILD))
- CenterWindow();
+ if (!(GetStyle() & WS_CHILD))
+ CenterWindow();
- return bResult;
+ return bResult;
}
diff --git a/src/apps/mplayerc/ComPropertySheet.h b/src/apps/mplayerc/ComPropertySheet.h
index ada078a44..7aa008d38 100644
--- a/src/apps/mplayerc/ComPropertySheet.h
+++ b/src/apps/mplayerc/ComPropertySheet.h
@@ -28,38 +28,35 @@
interface IComPropertyPageDirty
{
- virtual void OnSetDirty(bool fDirty) = 0;
+ virtual void OnSetDirty(bool fDirty) = 0;
};
// CComPropertySheet
class CComPropertySheet : public CPropertySheet, public IComPropertyPageDirty
{
- DECLARE_DYNAMIC(CComPropertySheet)
+ DECLARE_DYNAMIC(CComPropertySheet)
- CComPtr<IPropertyPageSite> m_pSite;
- CInterfaceList<ISpecifyPropertyPages> m_spp;
- CAutoPtrList<CComPropertyPage> m_pages;
- CSize m_size;
+ CComPtr<IPropertyPageSite> m_pSite;
+ CInterfaceList<ISpecifyPropertyPages> m_spp;
+ CAutoPtrList<CComPropertyPage> m_pages;
+ CSize m_size;
public:
- CComPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
- CComPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
- virtual ~CComPropertySheet();
+ CComPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
+ CComPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
+ virtual ~CComPropertySheet();
- int AddPages(CComPtr<ISpecifyPropertyPages> pSPP);
- bool AddPage(IPropertyPage* pPage, IUnknown* pUnk);
+ int AddPages(CComPtr<ISpecifyPropertyPages> pSPP);
+ bool AddPage(IPropertyPage* pPage, IUnknown* pUnk);
- void OnActivated(CPropertyPage* pPage);
+ void OnActivated(CPropertyPage* pPage);
- // IComPropertyPageDirty
- void OnSetDirty(bool fDirty)
- {
- if(CPropertyPage* p = GetActivePage()) p->SetModified(fDirty);
- }
+ // IComPropertyPageDirty
+ void OnSetDirty(bool fDirty) {if(CPropertyPage* p = GetActivePage()) p->SetModified(fDirty);}
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/apps/mplayerc/ConvertChapDlg.cpp b/src/apps/mplayerc/ConvertChapDlg.cpp
index cd5b42449..c462c5c9d 100644
--- a/src/apps/mplayerc/ConvertChapDlg.cpp
+++ b/src/apps/mplayerc/ConvertChapDlg.cpp
@@ -29,9 +29,9 @@
// CConvertChapDlg dialog
CConvertChapDlg::CConvertChapDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CConvertChapDlg::IDD, pParent)
- , m_time(_T(""))
- , m_name(_T(""))
+ : CResizableDialog(CConvertChapDlg::IDD, pParent)
+ , m_time(_T(""))
+ , m_name(_T(""))
{
}
@@ -41,13 +41,13 @@ CConvertChapDlg::~CConvertChapDlg()
void CConvertChapDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT1, m_time);
- DDX_Text(pDX, IDC_EDIT2, m_name);
+ __super::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT1, m_time);
+ DDX_Text(pDX, IDC_EDIT2, m_name);
}
BEGIN_MESSAGE_MAP(CConvertChapDlg, CResizableDialog)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
END_MESSAGE_MAP()
@@ -55,38 +55,38 @@ END_MESSAGE_MAP()
BOOL CConvertChapDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AddAnchor(IDC_EDIT1, TOP_LEFT);
- AddAnchor(IDC_EDIT2, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDOK, BOTTOM_CENTER);
- AddAnchor(IDCANCEL, BOTTOM_CENTER);
+ AddAnchor(IDC_EDIT1, TOP_LEFT);
+ AddAnchor(IDC_EDIT2, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDOK, BOTTOM_CENTER);
+ AddAnchor(IDCANCEL, BOTTOM_CENTER);
- CRect r;
- GetWindowRect(r);
- CSize s = r.Size();
- SetMinTrackSize(s);
- s.cx = 1000;
- SetMaxTrackSize(s);
+ CRect r;
+ GetWindowRect(r);
+ CSize s = r.Size();
+ SetMinTrackSize(s);
+ s.cx = 1000;
+ SetMaxTrackSize(s);
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CConvertChapDlg::OnOK()
{
- UpdateData();
+ UpdateData();
- __super::OnOK();
+ __super::OnOK();
}
void CConvertChapDlg::OnUpdateOK(CCmdUI* pCmdUI)
{
- CString str;
- GetDlgItem(IDC_EDIT1)->GetWindowText(str);
- int i;
- pCmdUI->Enable(3 == _stscanf(str, _T("%d:%d:%d"), &i, &i, &i)
- && GetDlgItem(IDC_EDIT2)->GetWindowTextLength() > 0);
+ CString str;
+ GetDlgItem(IDC_EDIT1)->GetWindowText(str);
+ int i;
+ pCmdUI->Enable(3 == _stscanf(str, _T("%d:%d:%d"), &i, &i, &i)
+ && GetDlgItem(IDC_EDIT2)->GetWindowTextLength() > 0);
}
diff --git a/src/apps/mplayerc/ConvertChapDlg.h b/src/apps/mplayerc/ConvertChapDlg.h
index b9f81cbcc..958a2cee7 100644
--- a/src/apps/mplayerc/ConvertChapDlg.h
+++ b/src/apps/mplayerc/ConvertChapDlg.h
@@ -28,20 +28,20 @@
class CConvertChapDlg : public CResizableDialog
{
public:
- CConvertChapDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CConvertChapDlg();
+ CConvertChapDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CConvertChapDlg();
// Dialog Data
- enum { IDD = IDD_CONVERTCHAP_DLG };
- CString m_time;
- CString m_name;
+ enum { IDD = IDD_CONVERTCHAP_DLG };
+ CString m_time;
+ CString m_name;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/ConvertDlg.cpp b/src/apps/mplayerc/ConvertDlg.cpp
index 3eeede903..1e49fabae 100644
--- a/src/apps/mplayerc/ConvertDlg.cpp
+++ b/src/apps/mplayerc/ConvertDlg.cpp
@@ -38,8 +38,8 @@
// CConvertDlg dialog
CConvertDlg::CConvertDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CConvertDlg::IDD, pParent)
- , m_fn(_T(""))
+ : CResizableDialog(CConvertDlg::IDD, pParent)
+ , m_fn(_T(""))
{
}
@@ -49,792 +49,776 @@ CConvertDlg::~CConvertDlg()
void CConvertDlg::AddFile(CString fn)
{
- CString protocol;
-
- int i = fn.Find(_T("://"));
- if(i > 0)
- {
- CString url = fn.Mid(i);
- CPath path(fn.Left(i));
- path.StripPath();
- protocol = (LPCTSTR)path;
- fn = (LPCTSTR)path + url;
- }
-
- CComPtr<IBaseFilter> pBF;
- if(FAILED(m_pGB->AddSourceFilter(CStringW(fn), CStringW(fn), &pBF)))
- return;
-
- int nConnected = 0;
- BeginEnumPins(pBF, pEP, pPin)
- if(S_OK == m_pGB->ConnectFilter(pPin, m_pMux)) nConnected++;
- EndEnumPins
- if(!nConnected)
- {
- MessageBeep(-1);
- DeleteFilter(pBF);
- return;
- }
-
- if(m_tree.GetCount() == 0)
- {
- if(CComQIPtr<IDSMPropertyBag> pPB = m_pMux)
- pPB->DelAllProperties();
-
- CString ext(_T(".dsm"));
-
- if(!protocol.IsEmpty())
- {
- m_fn = protocol + ext;
- }
- else
- {
- CPath p(fn);
- if(ext.CompareNoCase(p.GetExtension()) == 0)
- ext = _T(" (remuxed)") + ext;
- p.RemoveExtension();
- m_fn = (LPCTSTR)p + ext;
- }
-
- UpdateData(FALSE);
- }
-
- CTreeItemFile* t = DNew CTreeItemFile(fn, pBF, m_tree, NULL);
-
- AddFilter(*t, pBF);
-
- m_tree.Expand(*t, TVE_EXPAND);
- m_tree.EnsureVisible(*t);
+ CString protocol;
+
+ int i = fn.Find(_T("://"));
+ if(i > 0)
+ {
+ CString url = fn.Mid(i);
+ CPath path(fn.Left(i));
+ path.StripPath();
+ protocol = (LPCTSTR)path;
+ fn = (LPCTSTR)path + url;
+ }
+
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(m_pGB->AddSourceFilter(CStringW(fn), CStringW(fn), &pBF)))
+ return;
+
+ int nConnected = 0;
+ BeginEnumPins(pBF, pEP, pPin)
+ if(S_OK == m_pGB->ConnectFilter(pPin, m_pMux)) nConnected++;
+ EndEnumPins
+ if(!nConnected) {MessageBeep(-1); DeleteFilter(pBF); return;}
+
+ if(m_tree.GetCount() == 0)
+ {
+ if(CComQIPtr<IDSMPropertyBag> pPB = m_pMux)
+ pPB->DelAllProperties();
+
+ CString ext(_T(".dsm"));
+
+ if(!protocol.IsEmpty())
+ {
+ m_fn = protocol + ext;
+ }
+ else
+ {
+ CPath p(fn);
+ if(ext.CompareNoCase(p.GetExtension()) == 0)
+ ext = _T(" (remuxed)") + ext;
+ p.RemoveExtension();
+ m_fn = (LPCTSTR)p + ext;
+ }
+
+ UpdateData(FALSE);
+ }
+
+ CTreeItemFile* t = DNew CTreeItemFile(fn, pBF, m_tree, NULL);
+
+ AddFilter(*t, pBF);
+
+ m_tree.Expand(*t, TVE_EXPAND);
+ m_tree.EnsureVisible(*t);
}
bool CConvertDlg::ConvertFile(LPCTSTR fn, IPin* pPin)
{
- OAFilterState fs;
- if(!m_pMC || FAILED(m_pMC->GetState(0, &fs)) || fs != State_Stopped)
- return false;
-
- m_pGB->NukeDownstream(m_pMux);
-
- CComPtr<IBaseFilter> pFW;
- pFW.CoCreateInstance(CLSID_FileWriter);
- CComQIPtr<IFileSinkFilter2> pFSF = pFW;
-
- if(pPin)
- {
- CComQIPtr<IBaseMuxerRelatedPin> pRP = pPin;
- if(!pRP) return false;
-
- pPin = pRP->GetRelatedPin();
- }
- else
- {
- pPin = GetFirstPin(m_pMux, PINDIR_OUTPUT);
- }
-
- if(!pPin || !pFSF
- || FAILED(m_pGB->AddFilter(pFW, NULL))
- || FAILED(pFSF->SetFileName(CStringW(fn), NULL))
- || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))
- || FAILED(m_pGB->ConnectDirect(pPin, GetFirstPin(pFW), NULL)))
- {
- m_pGB->RemoveFilter(pFW);
- return false;
- }
-
- if(m_pMS)
- {
- LONGLONG pos = 0;
- m_pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
-
- if(CComQIPtr<IDSMPropertyBag> pPB = m_pMux)
- {
- pPB->SetProperty(L"APPL", L"Media Player Classic");
- }
-
- if(CComQIPtr<IDSMResourceBag> pRB = m_pMux)
- {
- pRB->ResRemoveAll(0);
- POSITION pos = m_pTIs.GetHeadPosition();
- while(pos)
- {
- if(CTreeItemResource* t2 = dynamic_cast<CTreeItemResource*>((CTreeItem*)m_pTIs.GetNext(pos)))
- pRB->ResAppend(
- t2->m_res.name, t2->m_res.desc, t2->m_res.mime,
- t2->m_res.data.GetData(), t2->m_res.data.GetCount(),
- NULL);
- }
- }
-
- if(CComQIPtr<IDSMChapterBag> pCB = m_pMux)
- {
- pCB->ChapRemoveAll();
- POSITION pos = m_pTIs.GetHeadPosition();
- while(pos)
- {
- if(CTreeItemChapter* t2 = dynamic_cast<CTreeItemChapter*>((CTreeItem*)m_pTIs.GetNext(pos)))
- pCB->ChapAppend(t2->m_chap.rt, t2->m_chap.name);
- }
- }
-
- if(FAILED(m_pMC->Run()))
- return false;
-
- m_tree.EnableWindow(FALSE);
-
- return true;
+ OAFilterState fs;
+ if(!m_pMC || FAILED(m_pMC->GetState(0, &fs)) || fs != State_Stopped)
+ return false;
+
+ m_pGB->NukeDownstream(m_pMux);
+
+ CComPtr<IBaseFilter> pFW;
+ pFW.CoCreateInstance(CLSID_FileWriter);
+ CComQIPtr<IFileSinkFilter2> pFSF = pFW;
+
+ if(pPin)
+ {
+ CComQIPtr<IBaseMuxerRelatedPin> pRP = pPin;
+ if(!pRP) return false;
+
+ pPin = pRP->GetRelatedPin();
+ }
+ else
+ {
+ pPin = GetFirstPin(m_pMux, PINDIR_OUTPUT);
+ }
+
+ if(!pPin || !pFSF
+ || FAILED(m_pGB->AddFilter(pFW, NULL))
+ || FAILED(pFSF->SetFileName(CStringW(fn), NULL))
+ || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))
+ || FAILED(m_pGB->ConnectDirect(pPin, GetFirstPin(pFW), NULL)))
+ {
+ m_pGB->RemoveFilter(pFW);
+ return false;
+ }
+
+ if(m_pMS)
+ {
+ LONGLONG pos = 0;
+ m_pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
+
+ if(CComQIPtr<IDSMPropertyBag> pPB = m_pMux)
+ {
+ pPB->SetProperty(L"APPL", L"Media Player Classic");
+ }
+
+ if(CComQIPtr<IDSMResourceBag> pRB = m_pMux)
+ {
+ pRB->ResRemoveAll(0);
+ POSITION pos = m_pTIs.GetHeadPosition();
+ while(pos)
+ {
+ if(CTreeItemResource* t2 = dynamic_cast<CTreeItemResource*>((CTreeItem*)m_pTIs.GetNext(pos)))
+ pRB->ResAppend(
+ t2->m_res.name, t2->m_res.desc, t2->m_res.mime,
+ t2->m_res.data.GetData(), t2->m_res.data.GetCount(),
+ NULL);
+ }
+ }
+
+ if(CComQIPtr<IDSMChapterBag> pCB = m_pMux)
+ {
+ pCB->ChapRemoveAll();
+ POSITION pos = m_pTIs.GetHeadPosition();
+ while(pos)
+ {
+ if(CTreeItemChapter* t2 = dynamic_cast<CTreeItemChapter*>((CTreeItem*)m_pTIs.GetNext(pos)))
+ pCB->ChapAppend(t2->m_chap.rt, t2->m_chap.name);
+ }
+ }
+
+ if(FAILED(m_pMC->Run()))
+ return false;
+
+ m_tree.EnableWindow(FALSE);
+
+ return true;
}
void CConvertDlg::AddFilter(HTREEITEM hTIParent, IBaseFilter* pBFParent)
{
- BeginEnumPins(pBFParent, pEP, pPin)
- {
- CComPtr<IPin> pPinTo;
- CComPtr<IBaseFilter> pBF;
- if(S_OK != m_pGB->IsPinDirection(pPin, PINDIR_OUTPUT)
- || FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
- || !(pBF = GetFilterFromPin(pPinTo)))
- continue;
-
- CTreeItem* t = NULL;
-
- if(pBF == m_pMux)
- {
- t = DNew CTreeItemPin(pPin, m_tree, hTIParent);
- }
- else
- {
- t = DNew CTreeItemFilter(pBF, m_tree, hTIParent);
- AddFilter(*t, pBF);
- }
- }
- EndEnumPins
-
- if(CComQIPtr<IDSMPropertyBag> pPB = pBFParent)
- {
- ULONG props;
- if(FAILED(pPB->CountProperties(&props)))
- props = 0;
-
- for(ULONG i = 0; i < props; i++)
- {
- PROPBAG2 PropBag;
- memset(&PropBag, 0, sizeof(PropBag));
- ULONG cPropertiesReturned = 0;
- if(FAILED(pPB->GetPropertyInfo(i, 1, &PropBag, &cPropertiesReturned)))
- continue;
-
- HRESULT hr;
- CComVariant var;
- if(SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr))
- {
- CComQIPtr<IDSMPropertyBag> pPBMux = m_pMux;
- CComBSTR value;
- if(pPBMux && FAILED(pPBMux->GetProperty(PropBag.pstrName, &value)))
- pPBMux->SetProperty(PropBag.pstrName, var.bstrVal);
- }
-
- CoTaskMemFree(PropBag.pstrName);
- }
- }
-
- CTreeItem* t2 = DNew CTreeItemResourceFolder(m_tree, hTIParent);
- if(CComQIPtr<IDSMResourceBag> pRB = pBFParent)
- {
- for(DWORD i = 0, cnt = pRB->ResGetCount(); i < cnt; i++)
- {
- CComBSTR name, mime, desc;
- BYTE* pData = NULL;
- DWORD len = 0;
- if(FAILED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL)))
- continue;
-
- if(len > 0)
- {
- m_pTIs.AddTail(DNew CTreeItemResource(CDSMResource(name, desc, mime, pData, len), m_tree, *t2));
- }
-
- CoTaskMemFree(pData);
- }
- }
- m_tree.Expand(*t2, TVE_EXPAND);
-
- CTreeItem* t3 = DNew CTreeItemChapterFolder(m_tree, hTIParent);
- if(CComQIPtr<IDSMChapterBag> pCB = pBFParent)
- {
- for(DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++)
- {
- REFERENCE_TIME rt;
- CComBSTR name;
- if(FAILED(pCB->ChapGet(i, &rt, &name)))
- continue;
-
- m_pTIs.AddTail(DNew CTreeItemChapter(CDSMChapter(rt, name), m_tree, *t3));
- }
- }
- m_tree.Expand(*t3, TVE_EXPAND);
-
- m_tree.Expand(hTIParent, TVE_EXPAND);
+ BeginEnumPins(pBFParent, pEP, pPin)
+ {
+ CComPtr<IPin> pPinTo;
+ CComPtr<IBaseFilter> pBF;
+ if(S_OK != m_pGB->IsPinDirection(pPin, PINDIR_OUTPUT)
+ || FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
+ || !(pBF = GetFilterFromPin(pPinTo)))
+ continue;
+
+ CTreeItem* t = NULL;
+
+ if(pBF == m_pMux)
+ {
+ t = DNew CTreeItemPin(pPin, m_tree, hTIParent);
+ }
+ else
+ {
+ t = DNew CTreeItemFilter(pBF, m_tree, hTIParent);
+ AddFilter(*t, pBF);
+ }
+ }
+ EndEnumPins
+
+ if(CComQIPtr<IDSMPropertyBag> pPB = pBFParent)
+ {
+ ULONG props;
+ if(FAILED(pPB->CountProperties(&props)))
+ props = 0;
+
+ for(ULONG i = 0; i < props; i++)
+ {
+ PROPBAG2 PropBag;
+ memset(&PropBag, 0, sizeof(PropBag));
+ ULONG cPropertiesReturned = 0;
+ if(FAILED(pPB->GetPropertyInfo(i, 1, &PropBag, &cPropertiesReturned)))
+ continue;
+
+ HRESULT hr;
+ CComVariant var;
+ if(SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr))
+ {
+ CComQIPtr<IDSMPropertyBag> pPBMux = m_pMux;
+ CComBSTR value;
+ if(pPBMux && FAILED(pPBMux->GetProperty(PropBag.pstrName, &value)))
+ pPBMux->SetProperty(PropBag.pstrName, var.bstrVal);
+ }
+
+ CoTaskMemFree(PropBag.pstrName);
+ }
+ }
+
+ CTreeItem* t2 = DNew CTreeItemResourceFolder(m_tree, hTIParent);
+ if(CComQIPtr<IDSMResourceBag> pRB = pBFParent)
+ {
+ for(DWORD i = 0, cnt = pRB->ResGetCount(); i < cnt; i++)
+ {
+ CComBSTR name, mime, desc;
+ BYTE* pData = NULL;
+ DWORD len = 0;
+ if(FAILED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL)))
+ continue;
+
+ if(len > 0)
+ {
+ m_pTIs.AddTail(DNew CTreeItemResource(CDSMResource(name, desc, mime, pData, len), m_tree, *t2));
+ }
+
+ CoTaskMemFree(pData);
+ }
+ }
+ m_tree.Expand(*t2, TVE_EXPAND);
+
+ CTreeItem* t3 = DNew CTreeItemChapterFolder(m_tree, hTIParent);
+ if(CComQIPtr<IDSMChapterBag> pCB = pBFParent)
+ {
+ for(DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++)
+ {
+ REFERENCE_TIME rt;
+ CComBSTR name;
+ if(FAILED(pCB->ChapGet(i, &rt, &name)))
+ continue;
+
+ m_pTIs.AddTail(DNew CTreeItemChapter(CDSMChapter(rt, name), m_tree, *t3));
+ }
+ }
+ m_tree.Expand(*t3, TVE_EXPAND);
+
+ m_tree.Expand(hTIParent, TVE_EXPAND);
}
void CConvertDlg::DeleteFilter(IBaseFilter* pBF)
{
- BeginEnumPins(pBF, pEP, pPin)
- {
- CComPtr<IPin> pPinTo;
- CComPtr<IBaseFilter> pBF;
- if(S_OK != m_pGB->IsPinDirection(pPin, PINDIR_OUTPUT)
- || FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
- || !(pBF = GetFilterFromPin(pPinTo)))
- continue;
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ CComPtr<IPin> pPinTo;
+ CComPtr<IBaseFilter> pBF;
+ if(S_OK != m_pGB->IsPinDirection(pPin, PINDIR_OUTPUT)
+ || FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
+ || !(pBF = GetFilterFromPin(pPinTo)))
+ continue;
- if(pBF != m_pMux) DeleteFilter(pBF);
- }
- EndEnumPins
+ if(pBF != m_pMux) DeleteFilter(pBF);
+ }
+ EndEnumPins
- m_pGB->RemoveFilter(pBF);
+ m_pGB->RemoveFilter(pBF);
}
void CConvertDlg::DeleteItem(HTREEITEM hTI)
{
- if(!hTI) return;
+ if(!hTI) return;
- DeleteChildren(hTI);
+ DeleteChildren(hTI);
- CTreeItem* t = (CTreeItem*)m_tree.GetItemData(hTI);
- if(POSITION pos = m_pTIs.Find(t)) m_pTIs.RemoveAt(pos);
- delete t;
- m_tree.DeleteItem(hTI);
+ CTreeItem* t = (CTreeItem*)m_tree.GetItemData(hTI);
+ if(POSITION pos = m_pTIs.Find(t)) m_pTIs.RemoveAt(pos);
+ delete t;
+ m_tree.DeleteItem(hTI);
}
void CConvertDlg::DeleteChildren(HTREEITEM hTI)
{
- if(!hTI) return;
+ if(!hTI) return;
- if(m_tree.ItemHasChildren(hTI))
- {
- HTREEITEM hChildItem = m_tree.GetChildItem(hTI);
+ if(m_tree.ItemHasChildren(hTI))
+ {
+ HTREEITEM hChildItem = m_tree.GetChildItem(hTI);
- while(hChildItem != NULL)
- {
- HTREEITEM hNextItem = m_tree.GetNextItem(hChildItem, TVGN_NEXT);
- DeleteItem(hChildItem);
- hChildItem = hNextItem;
- }
- }
+ while(hChildItem != NULL)
+ {
+ HTREEITEM hNextItem = m_tree.GetNextItem(hChildItem, TVGN_NEXT);
+ DeleteItem(hChildItem);
+ hChildItem = hNextItem;
+ }
+ }
}
HTREEITEM CConvertDlg::HitTest(CPoint& sp, CPoint& cp)
{
- sp = CPoint((LPARAM)GetMessagePos());
- cp = sp;
- m_tree.ScreenToClient(&cp);
- UINT flags = 0;
- HTREEITEM hTI = m_tree.HitTest(cp, &flags);
- return hTI && (flags & TVHT_ONITEM) ? hTI : NULL;
+ sp = CPoint((LPARAM)GetMessagePos());
+ cp = sp;
+ m_tree.ScreenToClient(&cp);
+ UINT flags = 0;
+ HTREEITEM hTI = m_tree.HitTest(cp, &flags);
+ return hTI && (flags&TVHT_ONITEM) ? hTI : NULL;
}
void CConvertDlg::ShowPopup(CPoint p)
{
- CMenu m;
- m.CreatePopupMenu();
-
- int i = 1;
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_ADDFILE));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_PROPERTIES));
-
- switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this))
- {
- case 1:
- {
- CFileDialog fd(TRUE, NULL, m_fn,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_NOVALIDATE,
- ResStr(IDS_CONVERTDLG_0), this, 0);
- if(fd.DoModal() == IDOK) AddFile(fd.GetPathName());
- }
- break;
- case 2:
- EditProperties(CComQIPtr<IDSMPropertyBag>(m_pMux));
- break;
- }
+ CMenu m;
+ m.CreatePopupMenu();
+
+ int i = 1;
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_ADDFILE));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_PROPERTIES));
+
+ switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this))
+ {
+ case 1:
+ {
+ CFileDialog fd(TRUE, NULL, m_fn,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_NOVALIDATE,
+ ResStr(IDS_CONVERTDLG_0), this, 0);
+ if(fd.DoModal() == IDOK) AddFile(fd.GetPathName());
+ }
+ break;
+ case 2:
+ EditProperties(CComQIPtr<IDSMPropertyBag>(m_pMux));
+ break;
+ }
}
void CConvertDlg::ShowFilePopup(HTREEITEM hTI, CPoint p)
{
- CTreeItemFile* t = dynamic_cast<CTreeItemFile*>((CTreeItem*)m_tree.GetItemData(hTI));
- ASSERT(t);
+ CTreeItemFile* t = dynamic_cast<CTreeItemFile*>((CTreeItem*)m_tree.GetItemData(hTI));
+ ASSERT(t);
- CMenu m;
- m.CreatePopupMenu();
+ CMenu m;
+ m.CreatePopupMenu();
- int i = 1;
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVE));
+ int i = 1;
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVE));
- switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this))
- {
- case 1:
- DeleteFilter(t->m_pBF);
- DeleteItem(hTI);
- break;
- }
+ switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this))
+ {
+ case 1:
+ DeleteFilter(t->m_pBF);
+ DeleteItem(hTI);
+ break;
+ }
}
void CConvertDlg::ShowPinPopup(HTREEITEM hTI, CPoint p)
{
- CTreeItemPin* t = dynamic_cast<CTreeItemPin*>((CTreeItem*)m_tree.GetItemData(hTI));
- ASSERT(t);
-
- if(!t->m_pPin) return;
-
- CComPtr<IPin> pPinTo;
- t->m_pPin->ConnectedTo(&pPinTo);
-
- CMediaType mt;
- if(pPinTo) t->m_pPin->ConnectionMediaType(&mt);
-
- CAtlArray<CMediaType> mts;
- BeginEnumMediaTypes(t->m_pPin, pEMT, pmt)
- mts.Add(*pmt);
- EndEnumMediaTypes(pmt)
-
- CMenu m;
- m.CreatePopupMenu();
-
- int i = 1, mtbase = 1000, mti = mtbase;
-
- m.AppendMenu(MF_STRING, i++, !pPinTo ? ResStr(IDS_CONVERT_ENABLESTREAM) : ResStr(IDS_CONVERT_DISABLESTREAM));
- m.AppendMenu(MF_STRING | (!pPinTo ? MF_GRAYED : 0), i++, ResStr(IDS_CONVERT_DEMUXSTREAM));
-
- if(mts.GetCount() > 1)
- {
- m.AppendMenu(MF_SEPARATOR);
- for(int i = 0; i < mts.GetCount(); i++)
- m.AppendMenu(MF_STRING | (mts[i] == mt ? MF_CHECKED : 0), mti++, CMediaTypeEx(mts[i]).ToString());
- }
-
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | (!pPinTo ? MF_GRAYED : 0), i++, ResStr(IDS_CONVERT_PINPROPERTIES));
-
- switch(i = (int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this))
- {
- case 1:
- if(pPinTo)
- {
- m_pGB->Disconnect(pPinTo);
- m_pGB->Disconnect(t->m_pPin);
- }
- else if(pPinTo = GetFirstDisconnectedPin(m_pMux, PINDIR_INPUT)) m_pGB->ConnectDirect(t->m_pPin, pPinTo, NULL);
- t->Update();
- break;
- case 2:
- {
- UpdateData();
-
- CString ext = _T("raw");
-
- if(mt.subtype == MEDIASUBTYPE_AAC) ext = _T("aac");
- else if(mt.subtype == MEDIASUBTYPE_MP3) ext = _T("mp3");
- else if(mt.subtype == FOURCCMap(WAVE_FORMAT_MPEG)) ext = _T("m1a");
- else if(mt.subtype == MEDIASUBTYPE_MPEG2_AUDIO) ext = _T("m2a");
- else if(mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 || mt.subtype == MEDIASUBTYPE_DOLBY_AC3) ext = _T("ac3");
- else if(mt.subtype == MEDIASUBTYPE_WAVE_DTS || mt.subtype == MEDIASUBTYPE_DTS) ext = _T("dts");
- else if((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) ext = _T("h264");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_XVID || mt.subtype == MEDIASUBTYPE_xvid || mt.subtype == MEDIASUBTYPE_XVIX || mt.subtype == MEDIASUBTYPE_xvix)) ext = _T("xvid");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_DIVX || mt.subtype == MEDIASUBTYPE_divx || mt.subtype == MEDIASUBTYPE_DX50 || mt.subtype == MEDIASUBTYPE_dx50)) ext = _T("divx");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP4V || mt.subtype == MEDIASUBTYPE_mp4v || mt.subtype == MEDIASUBTYPE_M4S2 || mt.subtype == MEDIASUBTYPE_m4s2 || mt.subtype == MEDIASUBTYPE_MP4S || mt.subtype == MEDIASUBTYPE_mp4s)) ext = _T("mp4v");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_WMV1 || mt.subtype == MEDIASUBTYPE_wmv1)) ext = _T("WMV1");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_WMV2 || mt.subtype == MEDIASUBTYPE_wmv2)) ext = _T("WMV2");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_WMV3 || mt.subtype == MEDIASUBTYPE_wmv3)) ext = _T("WMV3");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_DIV3 || mt.subtype == MEDIASUBTYPE_div3 || mt.subtype == MEDIASUBTYPE_DIV4 || mt.subtype == MEDIASUBTYPE_div4 || mt.subtype == MEDIASUBTYPE_DIV5 || mt.subtype == MEDIASUBTYPE_div5)) ext = _T("div3");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP43 || mt.subtype == MEDIASUBTYPE_mp43 || mt.subtype == MEDIASUBTYPE_MPG3 || mt.subtype == MEDIASUBTYPE_mpg3)) ext = _T("mp43");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP42 || mt.subtype == MEDIASUBTYPE_mp42 || mt.subtype == MEDIASUBTYPE_DIV2 || mt.subtype == MEDIASUBTYPE_div2)) ext = _T("mp42");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP41 || mt.subtype == MEDIASUBTYPE_mp41 || mt.subtype == MEDIASUBTYPE_DIV1 || mt.subtype == MEDIASUBTYPE_div1)) ext = _T("mp41");
- else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_VP50) ext = _T("vp5");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_VP60 || mt.subtype == MEDIASUBTYPE_VP61 || mt.subtype == MEDIASUBTYPE_VP62 || mt.subtype == MEDIASUBTYPE_VP6A || mt.subtype == MEDIASUBTYPE_VP6F)) ext = _T("vp6");
- else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_FLV1) ext = _T("flv");
- else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_FLV4) ext = _T("flv");
- else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_SVQ3) ext = _T("svq3");
- else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_SVQ1) ext = _T("svq1");
- else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_H263 || mt.subtype == MEDIASUBTYPE_h263)) ext = _T("h263");
- else if(mt.subtype == FOURCCMap('GEPJ') || mt.subtype == FOURCCMap('gepj')) ext = _T("jpg");
- else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_MPEG2_VIDEO) ext = _T("m2v");
- else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_MPEG1Payload) ext = _T("m1v");
- else if(mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text) ext = _T("srt");
- else if(mt.subtype == MEDIASUBTYPE_SSA) ext = _T("ssa");
- else if(mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) ext = _T("ass");
- else if(mt.subtype == MEDIASUBTYPE_SSF) ext = _T("ssf");
- else if(mt.subtype == MEDIASUBTYPE_VOBSUB) ext = _T("sub");
- else if(mt.subtype == MEDIASUBTYPE_PCM || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE) || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT)) ext = _T("wav");
- // TODO: else if...
-
- CPath path(m_fn);
- path.RenameExtension('.' + ext);
-
- CFileDialog fd(FALSE, NULL, (LPCTSTR)path,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
- ResStr(IDS_CONVERTDLG_0), this, 0);
- if(fd.DoModal() == IDOK)
- {
- if(!ConvertFile(fd.GetPathName(), pPinTo))
- {
- AfxMessageBox(ResStr(IDS_CONVERTDLG_2));
- }
- }
- }
- break;
- case 3:
- EditProperties(CComQIPtr<IDSMPropertyBag>(pPinTo));
- break;
- default:
- i -= mtbase;
- if(i >= 0 && i < mts.GetCount())
- {
- if(pPinTo)
- {
- m_pGB->Disconnect(pPinTo);
- m_pGB->Disconnect(t->m_pPin);
- }
- else
- {
- pPinTo = GetFirstDisconnectedPin(m_pMux, PINDIR_INPUT);
- }
- HRESULT hr = m_pGB->ConnectDirect(t->m_pPin, pPinTo, &mts[i]);
- if(FAILED(hr))
- {
- AfxMessageBox(ResStr(IDS_CONVERTDLG_3));
- if(mt.majortype != GUID_NULL)
- hr = m_pGB->ConnectDirect(t->m_pPin, pPinTo, &mt);
- }
- t->Update();
- }
- break;
- }
+ CTreeItemPin* t = dynamic_cast<CTreeItemPin*>((CTreeItem*)m_tree.GetItemData(hTI));
+ ASSERT(t);
+
+ if(!t->m_pPin) return;
+
+ CComPtr<IPin> pPinTo;
+ t->m_pPin->ConnectedTo(&pPinTo);
+
+ CMediaType mt;
+ if(pPinTo) t->m_pPin->ConnectionMediaType(&mt);
+
+ CAtlArray<CMediaType> mts;
+ BeginEnumMediaTypes(t->m_pPin, pEMT, pmt)
+ mts.Add(*pmt);
+ EndEnumMediaTypes(pmt)
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ int i = 1, mtbase = 1000, mti = mtbase;
+
+ m.AppendMenu(MF_STRING, i++, !pPinTo ? ResStr(IDS_CONVERT_ENABLESTREAM) : ResStr(IDS_CONVERT_DISABLESTREAM));
+ m.AppendMenu(MF_STRING | (!pPinTo ? MF_GRAYED : 0), i++, ResStr(IDS_CONVERT_DEMUXSTREAM));
+
+ if(mts.GetCount() > 1)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ for(int i = 0; i < mts.GetCount(); i++)
+ m.AppendMenu(MF_STRING | (mts[i] == mt ? MF_CHECKED : 0), mti++, CMediaTypeEx(mts[i]).ToString());
+ }
+
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | (!pPinTo ? MF_GRAYED : 0), i++, ResStr(IDS_CONVERT_PINPROPERTIES));
+
+ switch(i = (int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this))
+ {
+ case 1:
+ if(pPinTo) {m_pGB->Disconnect(pPinTo); m_pGB->Disconnect(t->m_pPin);}
+ else if(pPinTo = GetFirstDisconnectedPin(m_pMux, PINDIR_INPUT)) m_pGB->ConnectDirect(t->m_pPin, pPinTo, NULL);
+ t->Update();
+ break;
+ case 2:
+ {
+ UpdateData();
+
+ CString ext = _T("raw");
+
+ if(mt.subtype == MEDIASUBTYPE_AAC) ext = _T("aac");
+ else if(mt.subtype == MEDIASUBTYPE_MP3) ext = _T("mp3");
+ else if(mt.subtype == FOURCCMap(WAVE_FORMAT_MPEG)) ext = _T("m1a");
+ else if(mt.subtype == MEDIASUBTYPE_MPEG2_AUDIO) ext = _T("m2a");
+ else if(mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 || mt.subtype == MEDIASUBTYPE_DOLBY_AC3) ext = _T("ac3");
+ else if(mt.subtype == MEDIASUBTYPE_WAVE_DTS || mt.subtype == MEDIASUBTYPE_DTS) ext = _T("dts");
+ else if((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) ext = _T("h264");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_XVID || mt.subtype == MEDIASUBTYPE_xvid || mt.subtype == MEDIASUBTYPE_XVIX || mt.subtype == MEDIASUBTYPE_xvix)) ext = _T("xvid");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_DIVX || mt.subtype == MEDIASUBTYPE_divx || mt.subtype == MEDIASUBTYPE_DX50 || mt.subtype == MEDIASUBTYPE_dx50)) ext = _T("divx");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP4V || mt.subtype == MEDIASUBTYPE_mp4v || mt.subtype == MEDIASUBTYPE_M4S2 || mt.subtype == MEDIASUBTYPE_m4s2 || mt.subtype == MEDIASUBTYPE_MP4S || mt.subtype == MEDIASUBTYPE_mp4s)) ext = _T("mp4v");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_WMV1 || mt.subtype == MEDIASUBTYPE_wmv1)) ext = _T("WMV1");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_WMV2 || mt.subtype == MEDIASUBTYPE_wmv2)) ext = _T("WMV2");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_WMV3 || mt.subtype == MEDIASUBTYPE_wmv3)) ext = _T("WMV3");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_DIV3 || mt.subtype == MEDIASUBTYPE_div3 || mt.subtype == MEDIASUBTYPE_DIV4 || mt.subtype == MEDIASUBTYPE_div4 || mt.subtype == MEDIASUBTYPE_DIV5 || mt.subtype == MEDIASUBTYPE_div5)) ext = _T("div3");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP43 || mt.subtype == MEDIASUBTYPE_mp43 || mt.subtype == MEDIASUBTYPE_MPG3 || mt.subtype == MEDIASUBTYPE_mpg3)) ext = _T("mp43");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP42 || mt.subtype == MEDIASUBTYPE_mp42 || mt.subtype == MEDIASUBTYPE_DIV2 || mt.subtype == MEDIASUBTYPE_div2)) ext = _T("mp42");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_MP41 || mt.subtype == MEDIASUBTYPE_mp41 || mt.subtype == MEDIASUBTYPE_DIV1 || mt.subtype == MEDIASUBTYPE_div1)) ext = _T("mp41");
+ else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_VP50) ext = _T("vp5");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_VP60 || mt.subtype == MEDIASUBTYPE_VP61 || mt.subtype == MEDIASUBTYPE_VP62 || mt.subtype == MEDIASUBTYPE_VP6A || mt.subtype == MEDIASUBTYPE_VP6F)) ext = _T("vp6");
+ else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_FLV1) ext = _T("flv");
+ else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_FLV4) ext = _T("flv");
+ else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_SVQ3) ext = _T("svq3");
+ else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_SVQ1) ext = _T("svq1");
+ else if(mt.majortype == MEDIATYPE_Video && (mt.subtype == MEDIASUBTYPE_H263 || mt.subtype == MEDIASUBTYPE_h263)) ext = _T("h263");
+ else if(mt.subtype == FOURCCMap('GEPJ') || mt.subtype == FOURCCMap('gepj')) ext = _T("jpg");
+ else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_MPEG2_VIDEO) ext = _T("m2v");
+ else if(mt.majortype == MEDIATYPE_Video && mt.subtype == MEDIASUBTYPE_MPEG1Payload) ext = _T("m1v");
+ else if(mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text) ext = _T("srt");
+ else if(mt.subtype == MEDIASUBTYPE_SSA) ext = _T("ssa");
+ else if(mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) ext = _T("ass");
+ else if(mt.subtype == MEDIASUBTYPE_SSF) ext = _T("ssf");
+ else if(mt.subtype == MEDIASUBTYPE_VOBSUB) ext = _T("sub");
+ else if(mt.subtype == MEDIASUBTYPE_PCM || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE) || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT)) ext = _T("wav");
+ // TODO: else if...
+
+ CPath path(m_fn);
+ path.RenameExtension('.' + ext);
+
+ CFileDialog fd(FALSE, NULL, (LPCTSTR)path,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ ResStr(IDS_CONVERTDLG_0), this, 0);
+ if(fd.DoModal() == IDOK)
+ {
+ if(!ConvertFile(fd.GetPathName(), pPinTo))
+ {
+ AfxMessageBox(ResStr(IDS_CONVERTDLG_2));
+ }
+ }
+ }
+ break;
+ case 3:
+ EditProperties(CComQIPtr<IDSMPropertyBag>(pPinTo));
+ break;
+ default:
+ i -= mtbase;
+ if(i >= 0 && i < mts.GetCount())
+ {
+ if(pPinTo) {m_pGB->Disconnect(pPinTo); m_pGB->Disconnect(t->m_pPin);}
+ else {pPinTo = GetFirstDisconnectedPin(m_pMux, PINDIR_INPUT);}
+ HRESULT hr = m_pGB->ConnectDirect(t->m_pPin, pPinTo, &mts[i]);
+ if(FAILED(hr))
+ {
+ AfxMessageBox(ResStr(IDS_CONVERTDLG_3));
+ if(mt.majortype != GUID_NULL)
+ hr = m_pGB->ConnectDirect(t->m_pPin, pPinTo, &mt);
+ }
+ t->Update();
+ }
+ break;
+ }
}
void CConvertDlg::ShowResourceFolderPopup(HTREEITEM hTI, CPoint p)
{
- CTreeItemResourceFolder* t = dynamic_cast<CTreeItemResourceFolder*>((CTreeItem*)m_tree.GetItemData(hTI));
- ASSERT(t);
-
- CMenu m;
- m.CreatePopupMenu();
-
- int i = 1;
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_ADDRESOURCE));
- if(m_tree.ItemHasChildren(*t))
- {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVEALL));
- }
-
- switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this))
- {
- case 1:
- {
- CFileDialog fd(TRUE, NULL, NULL,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
- ResStr(IDS_CONVERTDLG_4), this, 0);
- if(fd.DoModal() == IDOK)
- {
- CString fn = fd.GetPathName();
- if(FILE* f = _tfopen(fn, _T("rb")))
- {
- CDSMResource res;
-
- CPath path(fn);
- path.StripPath();
- res.name = (LPCTSTR)path;
-
- CRegKey key;
- TCHAR mime[256];
- ULONG len = countof(mime);
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, path.GetExtension().MakeLower(), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(_T("Content Type"), mime, &len))
- res.mime = mime;
-
- CTreeItemResource* t = DNew CTreeItemResource(res, m_tree, hTI);
- m_pTIs.AddTail(t);
-
- if(EditResource(t))
- {
- fseek(f, 0, 2);
- long size = ftell(f);
- fseek(f, 0, 0);
- t->m_res.data.SetCount(size);
- for(BYTE* ptr = t->m_res.data.GetData(), * end = ptr + size;
- size > 0 && end - ptr >= size && fread(ptr, min(size, 1024), 1, f) > 0;
- ptr += 1024, size -= 1024);
- fclose(f);
- }
- else
- {
- DeleteItem(*t);
- }
- }
- else
- {
- AfxMessageBox(ResStr(IDS_CONVERTDLG_5));
- }
- }
- }
- break;
- case 2:
- DeleteChildren(hTI);
- break;
- }
+ CTreeItemResourceFolder* t = dynamic_cast<CTreeItemResourceFolder*>((CTreeItem*)m_tree.GetItemData(hTI));
+ ASSERT(t);
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ int i = 1;
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_ADDRESOURCE));
+ if(m_tree.ItemHasChildren(*t))
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVEALL));
+ }
+
+ switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this))
+ {
+ case 1:
+ {
+ CFileDialog fd(TRUE, NULL, NULL,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ ResStr(IDS_CONVERTDLG_4), this, 0);
+ if(fd.DoModal() == IDOK)
+ {
+ CString fn = fd.GetPathName();
+ if(FILE* f = _tfopen(fn, _T("rb")))
+ {
+ CDSMResource res;
+
+ CPath path(fn);
+ path.StripPath();
+ res.name = (LPCTSTR)path;
+
+ CRegKey key;
+ TCHAR mime[256];
+ ULONG len = countof(mime);
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, path.GetExtension().MakeLower(), KEY_READ)
+ && ERROR_SUCCESS == key.QueryStringValue(_T("Content Type"), mime, &len))
+ res.mime = mime;
+
+ CTreeItemResource* t = DNew CTreeItemResource(res, m_tree, hTI);
+ m_pTIs.AddTail(t);
+
+ if(EditResource(t))
+ {
+ fseek(f, 0, 2);
+ long size = ftell(f);
+ fseek(f, 0, 0);
+ t->m_res.data.SetCount(size);
+ for(BYTE* ptr = t->m_res.data.GetData(),* end = ptr + size;
+ size > 0 && end - ptr >= size && fread(ptr, min(size, 1024), 1, f) > 0;
+ ptr += 1024, size -= 1024);
+ fclose(f);
+ }
+ else
+ {
+ DeleteItem(*t);
+ }
+ }
+ else
+ {
+ AfxMessageBox(ResStr(IDS_CONVERTDLG_5));
+ }
+ }
+ }
+ break;
+ case 2:
+ DeleteChildren(hTI);
+ break;
+ }
}
void CConvertDlg::ShowResourcePopup(HTREEITEM hTI, CPoint p)
{
- CTreeItemResource* t = dynamic_cast<CTreeItemResource*>((CTreeItem*)m_tree.GetItemData(hTI));
- ASSERT(t);
-
- CMenu m;
- m.CreatePopupMenu();
-
- int i = 1;
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVE));
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_SAVEAS));
- if(AfxGetAppSettings().fEnableWebServer) m.AppendMenu(MF_STRING, 1000, ResStr(IDS_CONVERT_LAUNCHINBROWSER));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_RESOURCEPROPERTIES));
-
- switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this))
- {
- case 1:
- DeleteItem(*t);
- break;
- case 2:
- {
- CFileDialog fd(FALSE, NULL, CString(t->m_res.name),
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- ResStr(IDS_CONVERTDLG_4), this, 0);
- if(fd.DoModal() == IDOK)
- {
- if(FILE* f = _tfopen(fd.GetPathName(), _T("wb")))
- {
- fwrite(t->m_res.data.GetData(), 1, t->m_res.data.GetCount(), f);
- fclose(f);
- }
- }
- }
- break;
- case 3:
- EditResource(t);
- break;
- case 1000:
- {
- CString url;
- url.Format(_T("http://localhost:%d/convres.html?id=%x"), AfxGetAppSettings().nWebServerPort, (DWORD)&t->m_res);
- ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
- }
- break;
- }
+ CTreeItemResource* t = dynamic_cast<CTreeItemResource*>((CTreeItem*)m_tree.GetItemData(hTI));
+ ASSERT(t);
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ int i = 1;
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVE));
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_SAVEAS));
+ if(AfxGetAppSettings().fEnableWebServer) m.AppendMenu(MF_STRING, 1000, ResStr(IDS_CONVERT_LAUNCHINBROWSER));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_RESOURCEPROPERTIES));
+
+ switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this))
+ {
+ case 1:
+ DeleteItem(*t);
+ break;
+ case 2:
+ {
+ CFileDialog fd(FALSE, NULL, CString(t->m_res.name),
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
+ ResStr(IDS_CONVERTDLG_4), this, 0);
+ if(fd.DoModal() == IDOK)
+ {
+ if(FILE* f = _tfopen(fd.GetPathName(), _T("wb")))
+ {
+ fwrite(t->m_res.data.GetData(), 1, t->m_res.data.GetCount(), f);
+ fclose(f);
+ }
+ }
+ }
+ break;
+ case 3:
+ EditResource(t);
+ break;
+ case 1000:
+ {
+ CString url;
+ url.Format(_T("http://localhost:%d/convres.html?id=%x"), AfxGetAppSettings().nWebServerPort, (DWORD)&t->m_res);
+ ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
+ }
+ break;
+ }
}
bool CConvertDlg::EditProperties(IDSMPropertyBag* pPB)
{
- CConvertPropsDlg dlg(!!CComQIPtr<IPin>(pPB), this);
+ CConvertPropsDlg dlg(!!CComQIPtr<IPin>(pPB), this);
- ULONG props;
- if(FAILED(pPB->CountProperties(&props)))
- props = 0;
+ ULONG props;
+ if(FAILED(pPB->CountProperties(&props)))
+ props = 0;
- for(ULONG i = 0; i < props; i++)
- {
- PROPBAG2 PropBag;
- memset(&PropBag, 0, sizeof(PropBag));
- ULONG cPropertiesReturned = 0;
- if(FAILED(pPB->GetPropertyInfo(i, 1, &PropBag, &cPropertiesReturned)))
- continue;
+ for(ULONG i = 0; i < props; i++)
+ {
+ PROPBAG2 PropBag;
+ memset(&PropBag, 0, sizeof(PropBag));
+ ULONG cPropertiesReturned = 0;
+ if(FAILED(pPB->GetPropertyInfo(i, 1, &PropBag, &cPropertiesReturned)))
+ continue;
- HRESULT hr;
- CComVariant var;
- if(SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr))
- dlg.m_props[CString(PropBag.pstrName)] = CString(var);
+ HRESULT hr;
+ CComVariant var;
+ if(SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr))
+ dlg.m_props[CString(PropBag.pstrName)] = CString(var);
- CoTaskMemFree(PropBag.pstrName);
- }
+ CoTaskMemFree(PropBag.pstrName);
+ }
- if(IDOK != dlg.DoModal())
- return false;
+ if(IDOK != dlg.DoModal())
+ return false;
- pPB->DelAllProperties();
+ pPB->DelAllProperties();
- POSITION pos = dlg.m_props.GetStartPosition();
- while(pos)
- {
- CString key, value;
- dlg.m_props.GetNextAssoc(pos, key, value);
- pPB->SetProperty(CStringW(key), CStringW(value));
- }
+ POSITION pos = dlg.m_props.GetStartPosition();
+ while(pos)
+ {
+ CString key, value;
+ dlg.m_props.GetNextAssoc(pos, key, value);
+ pPB->SetProperty(CStringW(key), CStringW(value));
+ }
- return true;
+ return true;
}
bool CConvertDlg::EditResource(CTreeItemResource* t)
{
- CConvertResDlg dlg(this);
+ CConvertResDlg dlg(this);
- dlg.m_name = t->m_res.name;
- dlg.m_mime = t->m_res.mime;
- dlg.m_desc = t->m_res.desc;
+ dlg.m_name = t->m_res.name;
+ dlg.m_mime = t->m_res.mime;
+ dlg.m_desc = t->m_res.desc;
- if(IDOK != dlg.DoModal())
- return false;
+ if(IDOK != dlg.DoModal())
+ return false;
- t->m_res.name = dlg.m_name;
- t->m_res.mime = dlg.m_mime;
- t->m_res.desc = dlg.m_desc;
+ t->m_res.name = dlg.m_name;
+ t->m_res.mime = dlg.m_mime;
+ t->m_res.desc = dlg.m_desc;
- t->Update();
+ t->Update();
- return true;
+ return true;
}
void CConvertDlg::ShowChapterFolderPopup(HTREEITEM hTI, CPoint p)
{
- CTreeItemChapterFolder* t = dynamic_cast<CTreeItemChapterFolder*>((CTreeItem*)m_tree.GetItemData(hTI));
- ASSERT(t);
-
- CMenu m;
- m.CreatePopupMenu();
-
- int i = 1;
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_ADDCHAPTER));
- if(m_tree.ItemHasChildren(*t))
- {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVEALL));
- }
-
- switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this))
- {
- case 1:
- {
- CDSMChapter chap;
- CTreeItemChapter* t = DNew CTreeItemChapter(CDSMChapter(0, L""), m_tree, hTI);
- m_pTIs.AddTail(t);
- if(!EditChapter(t))
- DeleteItem(*t);
- }
- break;
- case 2:
- DeleteChildren(hTI);
- break;
- }
+ CTreeItemChapterFolder* t = dynamic_cast<CTreeItemChapterFolder*>((CTreeItem*)m_tree.GetItemData(hTI));
+ ASSERT(t);
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ int i = 1;
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_ADDCHAPTER));
+ if(m_tree.ItemHasChildren(*t))
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVEALL));
+ }
+
+ switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this))
+ {
+ case 1:
+ {
+ CDSMChapter chap;
+ CTreeItemChapter* t = DNew CTreeItemChapter(CDSMChapter(0, L""), m_tree, hTI);
+ m_pTIs.AddTail(t);
+ if(!EditChapter(t))
+ DeleteItem(*t);
+ }
+ break;
+ case 2:
+ DeleteChildren(hTI);
+ break;
+ }
}
void CConvertDlg::ShowChapterPopup(HTREEITEM hTI, CPoint p)
{
- CTreeItemChapter* t = dynamic_cast<CTreeItemChapter*>((CTreeItem*)m_tree.GetItemData(hTI));
- ASSERT(t);
+ CTreeItemChapter* t = dynamic_cast<CTreeItemChapter*>((CTreeItem*)m_tree.GetItemData(hTI));
+ ASSERT(t);
- CMenu m;
- m.CreatePopupMenu();
+ CMenu m;
+ m.CreatePopupMenu();
- int i = 1;
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVE));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_CHAPTERPROPERTIES));
+ int i = 1;
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_REMOVE));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING, i++, ResStr(IDS_CONVERT_CHAPTERPROPERTIES));
- switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this))
- {
- case 1:
- DeleteItem(hTI);
- break;
- case 2:
- EditChapter(t);
- break;
- }
+ switch((int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this))
+ {
+ case 1:
+ DeleteItem(hTI);
+ break;
+ case 2:
+ EditChapter(t);
+ break;
+ }
}
bool CConvertDlg::EditChapter(CTreeItemChapter* t)
{
- CConvertChapDlg dlg(this);
+ CConvertChapDlg dlg(this);
- int h = (int)(t->m_chap.rt / 10000000 / 60 / 60);
- int m = (int)(t->m_chap.rt / 10000000 / 60 % 60);
- int s = (int)(t->m_chap.rt / 10000000 % 60);
- int ms = (int)(t->m_chap.rt / 10000 % 1000);
+ int h = (int)(t->m_chap.rt/10000000/60/60);
+ int m = (int)(t->m_chap.rt/10000000/60%60);
+ int s = (int)(t->m_chap.rt/10000000%60);
+ int ms = (int)(t->m_chap.rt/10000%1000);
- dlg.m_name = t->m_chap.name;
- dlg.m_time.Format(_T("%02d:%02d:%02d.%03d"), h, m, s, ms);
+ dlg.m_name = t->m_chap.name;
+ dlg.m_time.Format(_T("%02d:%02d:%02d.%03d"), h, m, s, ms);
- if(IDOK != dlg.DoModal())
- return false;
+ if(IDOK != dlg.DoModal())
+ return false;
- TCHAR c;
- if(_stscanf(dlg.m_time, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms) != 7)
- return false;
+ TCHAR c;
+ if(_stscanf(dlg.m_time, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms) != 7)
+ return false;
- t->m_chap.name = dlg.m_name;
- t->m_chap.rt = ((((__int64)h * 60 + m) * 60 + s) * 1000 + ms) * 10000;
+ t->m_chap.name = dlg.m_name;
+ t->m_chap.rt = ((((__int64)h*60+m)*60+s)*1000+ms)*10000;
- t->Update();
+ t->Update();
- return true;
+ return true;
}
void CConvertDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_TREE1, m_tree);
- DDX_Text(pDX, IDC_EDIT1, m_fn);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_TREE1, m_tree);
+ DDX_Text(pDX, IDC_EDIT1, m_fn);
}
BOOL CConvertDlg::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
- return TRUE;
+ if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
+ return TRUE;
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
BOOL CConvertDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
- SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
+ SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
+ SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
- AddAnchor(IDC_TREE1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_EDIT1, BOTTOM_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, BOTTOM_RIGHT);
- AddAnchor(IDC_HLINE, BOTTOM_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON2, BOTTOM_CENTER);
- AddAnchor(IDC_BUTTON3, BOTTOM_CENTER);
- AddAnchor(IDC_BUTTON4, BOTTOM_CENTER);
+ AddAnchor(IDC_TREE1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_EDIT1, BOTTOM_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, BOTTOM_RIGHT);
+ AddAnchor(IDC_HLINE, BOTTOM_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON2, BOTTOM_CENTER);
+ AddAnchor(IDC_BUTTON3, BOTTOM_CENTER);
+ AddAnchor(IDC_BUTTON4, BOTTOM_CENTER);
- CSize s(400, 200);
- SetMinTrackSize(s);
+ CSize s(400, 200);
+ SetMinTrackSize(s);
- m_streamtypesbm.LoadBitmap(IDB_STREAMTYPES);
- m_streamtypes.Create(16, 18, ILC_MASK | ILC_COLOR32, 0, 4);
- m_streamtypes.Add(&m_streamtypesbm, 0xffffff);
- m_tree.SetImageList(&m_streamtypes, TVSIL_NORMAL);
+ m_streamtypesbm.LoadBitmap(IDB_STREAMTYPES);
+ m_streamtypes.Create(16, 18, ILC_MASK|ILC_COLOR32, 0, 4);
+ m_streamtypes.Add(&m_streamtypesbm, 0xffffff);
+ m_tree.SetImageList(&m_streamtypes, TVSIL_NORMAL);
- GetWindowText(m_title);
- m_nIDEventStatus = SetTimer(1, 1000, NULL);
+ GetWindowText(m_title);
+ m_nIDEventStatus = SetTimer(1, 1000, NULL);
- HRESULT hr;
- m_pMux = DNew CDSMMuxerFilter(NULL, &hr, false, false);
+ HRESULT hr;
+ m_pMux = DNew CDSMMuxerFilter(NULL, &hr, false, false);
- m_pGB = DNew CFGManagerMuxer(_T("CFGManagerMuxer"), NULL);
- m_pGB->AddToROT();
+ m_pGB = DNew CFGManagerMuxer(_T("CFGManagerMuxer"), NULL);
+ m_pGB->AddToROT();
- if(FAILED(m_pGB->AddFilter(m_pMux, L"Mux"))
- || !(m_pMC = m_pGB) || !(m_pME = m_pGB) || !(m_pMS = m_pMux)
- || FAILED(m_pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
- {
- MessageBeep(-1);
- SendMessage(WM_CLOSE);
- return TRUE;
- }
+ if(FAILED(m_pGB->AddFilter(m_pMux, L"Mux"))
+ || !(m_pMC = m_pGB) || !(m_pME = m_pGB) || !(m_pMS = m_pMux)
+ || FAILED(m_pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
+ {
+ MessageBeep(-1);
+ SendMessage(WM_CLOSE);
+ return TRUE;
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CConvertDlg::OnOK()
@@ -842,21 +826,21 @@ void CConvertDlg::OnOK()
}
BEGIN_MESSAGE_MAP(CConvertDlg, CResizableDialog)
- ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
- ON_WM_DROPFILES()
- ON_WM_CLOSE()
- ON_NOTIFY(NM_CLICK, IDC_TREE1, OnNMClickTree1)
- ON_NOTIFY(NM_RCLICK, IDC_TREE1, OnNMRclickTree1)
- ON_NOTIFY(NM_DBLCLK, IDC_TREE1, OnNMDblclkTree1)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateButton3)
- ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateButton4)
+ ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
+ ON_WM_DROPFILES()
+ ON_WM_CLOSE()
+ ON_NOTIFY(NM_CLICK, IDC_TREE1, OnNMClickTree1)
+ ON_NOTIFY(NM_RCLICK, IDC_TREE1, OnNMRclickTree1)
+ ON_NOTIFY(NM_DBLCLK, IDC_TREE1, OnNMDblclkTree1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
+ ON_WM_TIMER()
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
+ ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateButton3)
+ ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateButton4)
END_MESSAGE_MAP()
// CConvertDlg message handlers
@@ -865,251 +849,251 @@ LRESULT CConvertDlg::OnGraphNotify(WPARAM wParam, LPARAM lParam)
{
HRESULT hr = S_OK;
- LONG evCode, evParam1, evParam2;
+ LONG evCode, evParam1, evParam2;
while(m_pME && SUCCEEDED(m_pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0)))
{
- hr = m_pME->FreeEventParams(evCode, evParam1, evParam2);
+ hr = m_pME->FreeEventParams(evCode, evParam1, evParam2);
- bool fStop = false;
+ bool fStop = false;
if(EC_COMPLETE == evCode)
{
- fStop = true;
- }
- else if(EC_ERRORABORT == evCode)
- {
- fStop = true;
-
- CString errmsg;
- LPVOID lpMsgBuf;
- if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
- {
- errmsg = (LPCTSTR)lpMsgBuf;
- LocalFree(lpMsgBuf);
- }
-
- CString str;
- str.Format(ResStr(IDS_CONVERTDLG_7), evParam1);
- if(!errmsg.IsEmpty()) str += _T(" (") + errmsg + _T(")");
- AfxMessageBox(str, MB_OK);
- }
-
- if(fStop && m_pMC)
- {
- m_pMC->Stop();
- m_tree.EnableWindow(TRUE);
- }
- }
-
- return hr;
+ fStop = true;
+ }
+ else if(EC_ERRORABORT == evCode)
+ {
+ fStop = true;
+
+ CString errmsg;
+ LPVOID lpMsgBuf;
+ if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
+ {
+ errmsg = (LPCTSTR)lpMsgBuf;
+ LocalFree(lpMsgBuf);
+ }
+
+ CString str;
+ str.Format(ResStr(IDS_CONVERTDLG_7), evParam1);
+ if(!errmsg.IsEmpty()) str += _T(" (") + errmsg + _T(")");
+ AfxMessageBox(str, MB_OK);
+ }
+
+ if(fStop && m_pMC)
+ {
+ m_pMC->Stop();
+ m_tree.EnableWindow(TRUE);
+ }
+ }
+
+ return hr;
}
void CConvertDlg::OnDropFiles(HDROP hDropInfo)
{
- for(int i = 0, j = DragQueryFile(hDropInfo, 0xffffffff, 0, 0); i < j; i++)
- {
- CString fn;
- fn.ReleaseBufferSetLength(DragQueryFile(hDropInfo, i, fn.GetBuffer(MAX_PATH), MAX_PATH));
+ for(int i = 0, j = DragQueryFile(hDropInfo, 0xffffffff, 0, 0); i < j; i++)
+ {
+ CString fn;
+ fn.ReleaseBufferSetLength(DragQueryFile(hDropInfo, i, fn.GetBuffer(MAX_PATH), MAX_PATH));
- AddFile(fn);
- }
+ AddFile(fn);
+ }
- __super::OnDropFiles(hDropInfo);
+ __super::OnDropFiles(hDropInfo);
}
void CConvertDlg::OnClose()
{
- HTREEITEM hTI = m_tree.GetRootItem();
- while(hTI)
- {
- HTREEITEM hTINext = m_tree.GetNextSiblingItem(hTI);
- DeleteItem(hTI);
- hTI = hTINext;
- }
+ HTREEITEM hTI = m_tree.GetRootItem();
+ while(hTI)
+ {
+ HTREEITEM hTINext = m_tree.GetNextSiblingItem(hTI);
+ DeleteItem(hTI);
+ hTI = hTINext;
+ }
- m_pGB->RemoveFromROT();
- m_pGB = NULL;
+ m_pGB->RemoveFromROT();
+ m_pGB = NULL;
- __super::OnClose();
+ __super::OnClose();
}
void CConvertDlg::OnNMClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
- CPoint sp, cp;
- HTREEITEM hTI = HitTest(sp, cp);
- if(!hTI) return;
- m_tree.SelectItem(hTI);
+ CPoint sp, cp;
+ HTREEITEM hTI = HitTest(sp, cp);
+ if(!hTI) return;
+ m_tree.SelectItem(hTI);
- *pResult = 0;
+ *pResult = 0;
}
void CConvertDlg::OnNMRclickTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
- CPoint sp, cp;
- HTREEITEM hTI = HitTest(sp, cp);
+ CPoint sp, cp;
+ HTREEITEM hTI = HitTest(sp, cp);
- if(hTI)
- {
- m_tree.SelectItem(hTI);
-
- CTreeItem* t = (CTreeItem*)m_tree.GetItemData(hTI);
-
- if(dynamic_cast<CTreeItemPin*>(t))
- ShowPinPopup(hTI, sp);
- else if(dynamic_cast<CTreeItemFile*>(t))
- ShowFilePopup(hTI, sp);
- else if(dynamic_cast<CTreeItemResourceFolder*>(t))
- ShowResourceFolderPopup(hTI, sp);
- else if(dynamic_cast<CTreeItemResource*>(t))
- ShowResourcePopup(hTI, sp);
- else if(dynamic_cast<CTreeItemChapterFolder*>(t))
- ShowChapterFolderPopup(hTI, sp);
- else if(dynamic_cast<CTreeItemChapter*>(t))
- ShowChapterPopup(hTI, sp);
- }
- else
- {
- ShowPopup(sp);
- }
+ if(hTI)
+ {
+ m_tree.SelectItem(hTI);
- *pResult = 0;
+ CTreeItem* t = (CTreeItem*)m_tree.GetItemData(hTI);
+
+ if(dynamic_cast<CTreeItemPin*>(t))
+ ShowPinPopup(hTI, sp);
+ else if(dynamic_cast<CTreeItemFile*>(t))
+ ShowFilePopup(hTI, sp);
+ else if(dynamic_cast<CTreeItemResourceFolder*>(t))
+ ShowResourceFolderPopup(hTI, sp);
+ else if(dynamic_cast<CTreeItemResource*>(t))
+ ShowResourcePopup(hTI, sp);
+ else if(dynamic_cast<CTreeItemChapterFolder*>(t))
+ ShowChapterFolderPopup(hTI, sp);
+ else if(dynamic_cast<CTreeItemChapter*>(t))
+ ShowChapterPopup(hTI, sp);
+ }
+ else
+ {
+ ShowPopup(sp);
+ }
+
+ *pResult = 0;
}
void CConvertDlg::OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
- CPoint sp, cp;
- HTREEITEM hTI = HitTest(sp, cp);
-
- if(hTI)
- {
- CTreeItem* t = (CTreeItem*)m_tree.GetItemData(hTI);
-
- if(CTreeItemPin* t2 = dynamic_cast<CTreeItemPin*>(t))
- {
- CComPtr<IPin> pPinTo;
- t2->m_pPin->ConnectedTo(&pPinTo);
-
- if(CComQIPtr<IDSMPropertyBag> pPB = pPinTo)
- EditProperties(pPB);
- }
- else if(CTreeItemResource* t2 = dynamic_cast<CTreeItemResource*>(t))
- {
- EditResource(t2);
- }
- else if(CTreeItemChapter* t2 = dynamic_cast<CTreeItemChapter*>(t))
- {
- EditChapter(t2);
- }
- }
-
- *pResult = 0;
+ CPoint sp, cp;
+ HTREEITEM hTI = HitTest(sp, cp);
+
+ if(hTI)
+ {
+ CTreeItem* t = (CTreeItem*)m_tree.GetItemData(hTI);
+
+ if(CTreeItemPin* t2 = dynamic_cast<CTreeItemPin*>(t))
+ {
+ CComPtr<IPin> pPinTo;
+ t2->m_pPin->ConnectedTo(&pPinTo);
+
+ if(CComQIPtr<IDSMPropertyBag> pPB = pPinTo)
+ EditProperties(pPB);
+ }
+ else if(CTreeItemResource* t2 = dynamic_cast<CTreeItemResource*>(t))
+ {
+ EditResource(t2);
+ }
+ else if(CTreeItemChapter* t2 = dynamic_cast<CTreeItemChapter*>(t))
+ {
+ EditChapter(t2);
+ }
+ }
+
+ *pResult = 0;
}
void CConvertDlg::OnBnClickedButton1()
{
- UpdateData();
+ UpdateData();
- CFileDialog fd(FALSE, _T(".dsm"), m_fn,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- ResStr(IDS_CONVERTDLG_8), this, 0);
+ CFileDialog fd(FALSE, _T(".dsm"), m_fn,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
+ ResStr(IDS_CONVERTDLG_8), this, 0);
- if(fd.DoModal() == IDOK)
- {
- m_fn = fd.GetPathName();
- UpdateData(FALSE);
- }
+ if(fd.DoModal() == IDOK)
+ {
+ m_fn = fd.GetPathName();
+ UpdateData(FALSE);
+ }
}
void CConvertDlg::OnUpdateButton1(CCmdUI* pCmdUI)
{
- OAFilterState fs;
- pCmdUI->Enable(m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs == State_Stopped);
+ OAFilterState fs;
+ pCmdUI->Enable(m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs == State_Stopped);
}
void CConvertDlg::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == m_nIDEventStatus && m_pMS && m_pMC)
- {
- OAFilterState fs;
- if(SUCCEEDED(m_pMC->GetState(0, &fs)) && fs != State_Stopped)
- {
- GUID tf;
- m_pMS->GetTimeFormat(&tf);
-
- REFERENCE_TIME rtCur, rtDur;
- HRESULT hr = m_pMS->GetDuration(&rtDur);
- m_pMS->GetCurrentPosition(&rtCur);
-
- CString str;
- if(hr == S_OK && rtDur != 0) str.Format(_T("%.2f%%"), 1.0 *(rtCur * 100) / rtDur);
- else if(hr == S_OK && rtDur == 0) str = _T("Live");
- else if(tf == TIME_FORMAT_BYTE) str.Format(_T("%.2fKB"), 1.0 * rtCur / 1024);
- else if(tf == TIME_FORMAT_MEDIA_TIME) str.Format(_T("%02d:%02d:%02d"), int(rtCur / 3600000000) % 60, int(rtCur / 60000000) % 60, int(rtCur / 1000000) % 60);
- else str = ResStr(IDS_AG_PLEASE_WAIT);
-
- SetWindowText(ResStr(IDS_AG_CONVERTING) + str);
- }
- else
- {
- SetWindowText(m_title);
- }
- }
-
- __super::OnTimer(nIDEvent);
+ if(nIDEvent == m_nIDEventStatus && m_pMS && m_pMC)
+ {
+ OAFilterState fs;
+ if(SUCCEEDED(m_pMC->GetState(0, &fs)) && fs != State_Stopped)
+ {
+ GUID tf;
+ m_pMS->GetTimeFormat(&tf);
+
+ REFERENCE_TIME rtCur, rtDur;
+ HRESULT hr = m_pMS->GetDuration(&rtDur);
+ m_pMS->GetCurrentPosition(&rtCur);
+
+ CString str;
+ if(hr == S_OK && rtDur != 0) str.Format(_T("%.2f%%"), 1.0 * (rtCur * 100) / rtDur);
+ else if(hr == S_OK && rtDur == 0) str = _T("Live");
+ else if(tf == TIME_FORMAT_BYTE) str.Format(_T("%.2fKB"), 1.0 * rtCur / 1024);
+ else if(tf == TIME_FORMAT_MEDIA_TIME) str.Format(_T("%02d:%02d:%02d"), int(rtCur/3600000000)%60, int(rtCur/60000000)%60, int(rtCur/1000000)%60);
+ else str = ResStr(IDS_AG_PLEASE_WAIT);
+
+ SetWindowText(ResStr(IDS_AG_CONVERTING) + str);
+ }
+ else
+ {
+ SetWindowText(m_title);
+ }
+ }
+
+ __super::OnTimer(nIDEvent);
}
void CConvertDlg::OnBnClickedButton2()
{
- OAFilterState fs;
- if(FAILED(m_pMC->GetState(0, &fs)))
- return;
+ OAFilterState fs;
+ if(FAILED(m_pMC->GetState(0, &fs)))
+ return;
- if(fs != State_Stopped)
- {
- m_pMC->Run();
- return;
- }
+ if(fs != State_Stopped)
+ {
+ m_pMC->Run();
+ return;
+ }
- UpdateData();
+ UpdateData();
- if(!ConvertFile(m_fn))
- {
- AfxMessageBox(ResStr(IDS_CONVERTDLG_2));
- }
+ if(!ConvertFile(m_fn))
+ {
+ AfxMessageBox(ResStr(IDS_CONVERTDLG_2));
+ }
}
void CConvertDlg::OnUpdateButton2(CCmdUI* pCmdUI)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(m_pMux, nIn, nOut, nInC, nOutC);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(m_pMux, nIn, nOut, nInC, nOutC);
- OAFilterState fs;
- pCmdUI->Enable(nInC > 0 && GetDlgItem(IDC_EDIT1)->GetWindowTextLength() > 0
- && m_pMS && m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs != State_Running);
+ OAFilterState fs;
+ pCmdUI->Enable(nInC > 0 && GetDlgItem(IDC_EDIT1)->GetWindowTextLength() > 0
+ && m_pMS && m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs != State_Running);
}
void CConvertDlg::OnBnClickedButton3()
{
- if(m_pMC) m_pMC->Pause();
+ if(m_pMC) m_pMC->Pause();
}
void CConvertDlg::OnUpdateButton3(CCmdUI* pCmdUI)
{
- OAFilterState fs;
- pCmdUI->Enable(m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs == State_Running);
+ OAFilterState fs;
+ pCmdUI->Enable(m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs == State_Running);
}
void CConvertDlg::OnBnClickedButton4()
{
- if(m_pMC) m_pMC->Stop();
- m_tree.EnableWindow(TRUE);
+ if(m_pMC) m_pMC->Stop();
+ m_tree.EnableWindow(TRUE);
}
void CConvertDlg::OnUpdateButton4(CCmdUI* pCmdUI)
{
- OAFilterState fs;
- pCmdUI->Enable(m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs != State_Stopped);
+ OAFilterState fs;
+ pCmdUI->Enable(m_pMC && SUCCEEDED(m_pMC->GetState(0, &fs)) && fs != State_Stopped);
}
//
@@ -1122,78 +1106,78 @@ CFilterTreeCtrl::CFilterTreeCtrl()
void CFilterTreeCtrl::PreSubclassWindow()
{
- EnableToolTips(TRUE);
+ EnableToolTips(TRUE);
- __super::PreSubclassWindow();
+ __super::PreSubclassWindow();
}
INT_PTR CFilterTreeCtrl::OnToolHitTest(CPoint p, TOOLINFO* pTI) const
{
- UINT nFlags;
- HTREEITEM hTI = HitTest(p, &nFlags);
- if(nFlags & TVHT_ONITEM)
- {
- CRect r;
- GetItemRect(hTI, r, TRUE);
- pTI->hwnd = m_hWnd;
- pTI->uId = (UINT)hTI;
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- pTI->rect = r;
- return pTI->uId;
- }
-
- return -1;
+ UINT nFlags;
+ HTREEITEM hTI = HitTest(p, &nFlags);
+ if(nFlags & TVHT_ONITEM)
+ {
+ CRect r;
+ GetItemRect(hTI, r, TRUE);
+ pTI->hwnd = m_hWnd;
+ pTI->uId = (UINT)hTI;
+ pTI->lpszText = LPSTR_TEXTCALLBACK;
+ pTI->rect = r;
+ return pTI->uId;
+ }
+
+ return -1;
}
BEGIN_MESSAGE_MAP(CFilterTreeCtrl, CTreeCtrl)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
END_MESSAGE_MAP()
BOOL CFilterTreeCtrl::OnToolTipText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
- TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
+ TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
+ TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
- UINT nID = pNMHDR->idFrom;
+ UINT nID = pNMHDR->idFrom;
- if(nID == (UINT)m_hWnd
- && (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND)
- || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)))
- return FALSE;
+ if(nID == (UINT)m_hWnd
+ && (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND)
+ || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)))
+ return FALSE;
- ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
+ ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
- HTREEITEM hTI = (HTREEITEM)nID;
+ HTREEITEM hTI = (HTREEITEM)nID;
- CString str;
- static CStringA m_strTipTextA;
- static CStringW m_strTipTextW;
+ CString str;
+ static CStringA m_strTipTextA;
+ static CStringW m_strTipTextW;
- CConvertDlg::CTreeItem* t = (CConvertDlg::CTreeItem*)GetItemData(hTI);
- if(!t || !t->ToolTip(str)) return FALSE;
+ CConvertDlg::CTreeItem* t = (CConvertDlg::CTreeItem*)GetItemData(hTI);
+ if(!t || !t->ToolTip(str)) return FALSE;
- m_strTipTextA = str;
- m_strTipTextW = str;
+ m_strTipTextA = str;
+ m_strTipTextW = str;
- if(pNMHDR->code == TTN_NEEDTEXTA) pTTTA->lpszText = (LPSTR)(LPCSTR)m_strTipTextA;
- else pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
+ if(pNMHDR->code == TTN_NEEDTEXTA) pTTTA->lpszText = (LPSTR)(LPCSTR)m_strTipTextA;
+ else pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
- *pResult = 0;
+ *pResult = 0;
- return TRUE; // message was handled
+ return TRUE; // message was handled
}
//
// CConvertDlg::CTreeItem*
//
-CConvertDlg::CTreeItem::CTreeItem(CTreeCtrl& tree, HTREEITEM hTIParent)
- : m_tree(tree)
+CConvertDlg::CTreeItem::CTreeItem(CTreeCtrl& tree, HTREEITEM hTIParent)
+ : m_tree(tree)
{
- m_hTI = m_tree.InsertItem(_T(""), hTIParent);
- m_tree.SetItemData(m_hTI, (DWORD_PTR)this);
- Update();
+ m_hTI = m_tree.InsertItem(_T(""), hTIParent);
+ m_tree.SetItemData(m_hTI, (DWORD_PTR)this);
+ Update();
}
CConvertDlg::CTreeItem::~CTreeItem()
@@ -1202,139 +1186,135 @@ CConvertDlg::CTreeItem::~CTreeItem()
void CConvertDlg::CTreeItem::SetLabel(LPCTSTR label)
{
- m_tree.SetItemText(m_hTI, label);
+ m_tree.SetItemText(m_hTI, label);
}
void CConvertDlg::CTreeItem::SetImage(int nImage, int nSelectedImage)
{
- m_tree.SetItemImage(m_hTI, nImage, nSelectedImage);
+ m_tree.SetItemImage(m_hTI, nImage, nSelectedImage);
}
-//
+//
-CConvertDlg::CTreeItemFilter::CTreeItemFilter(IBaseFilter* pBF, CTreeCtrl& tree, HTREEITEM hTIParent)
- : CTreeItem(tree, hTIParent)
- , m_pBF(pBF)
+CConvertDlg::CTreeItemFilter::CTreeItemFilter(IBaseFilter* pBF, CTreeCtrl& tree, HTREEITEM hTIParent)
+ : CTreeItem(tree, hTIParent)
+ , m_pBF(pBF)
{
- Update();
+ Update();
}
void CConvertDlg::CTreeItemFilter::Update()
{
- SetLabel(CString(GetFilterName(m_pBF)));
+ SetLabel(CString(GetFilterName(m_pBF)));
}
//
CConvertDlg::CTreeItemFile::CTreeItemFile(CString fn, IBaseFilter* pBF, CTreeCtrl& tree, HTREEITEM hTIParent)
- : CTreeItemFilter(pBF, tree, hTIParent)
- , m_fn(fn)
+ : CTreeItemFilter(pBF, tree, hTIParent)
+ , m_fn(fn)
{
- Update();
+ Update();
}
void CConvertDlg::CTreeItemFile::Update()
{
- CPath path = m_fn;
- path.StripPath();
- SetLabel(path);
+ CPath path = m_fn;
+ path.StripPath();
+ SetLabel(path);
}
bool CConvertDlg::CTreeItemFile::ToolTip(CString& str)
{
- str = m_fn;
- return true;
+ str = m_fn;
+ return true;
}
//
CConvertDlg::CTreeItemPin::CTreeItemPin(IPin* pPin, CTreeCtrl& tree, HTREEITEM hTIParent)
- : CTreeItem(tree, hTIParent)
- , m_pPin(pPin)
+ : CTreeItem(tree, hTIParent)
+ , m_pPin(pPin)
{
- Update();
+ Update();
}
void CConvertDlg::CTreeItemPin::Update()
{
- if(!m_pPin)
- {
- ASSERT(0);
- return;
- }
+ if(!m_pPin) {ASSERT(0); return;}
- CString label = GetPinName(m_pPin);
- if(!IsConnected()) label = _T("[D] ") + label;
- SetLabel(label);
+ CString label = GetPinName(m_pPin);
+ if(!IsConnected()) label = _T("[D] ") + label;
+ SetLabel(label);
- CMediaType mt;
- if(S_OK == m_pPin->ConnectionMediaType(&mt))
- {
- if(mt.majortype == MEDIATYPE_Video) SetImage(1, 1);
- else if(mt.majortype == MEDIATYPE_Audio) SetImage(2, 2);
- else if(mt.majortype == MEDIATYPE_Text || mt.majortype == MEDIATYPE_Subtitle) SetImage(3, 3);
- }
+ CMediaType mt;
+ if(S_OK == m_pPin->ConnectionMediaType(&mt))
+ {
+ if(mt.majortype == MEDIATYPE_Video) SetImage(1, 1);
+ else if(mt.majortype == MEDIATYPE_Audio) SetImage(2, 2);
+ else if(mt.majortype == MEDIATYPE_Text || mt.majortype == MEDIATYPE_Subtitle) SetImage(3, 3);
+ }
}
bool CConvertDlg::CTreeItemPin::ToolTip(CString& str)
{
- CMediaTypeEx mt;
- if(FAILED(m_pPin->ConnectionMediaType(&mt))) return false;
- str = mt.ToString(m_pPin);
- return true;
+ CMediaTypeEx mt;
+ if(FAILED(m_pPin->ConnectionMediaType(&mt))) return false;
+ str = mt.ToString(m_pPin);
+ return true;
}
bool CConvertDlg::CTreeItemPin::IsConnected()
{
- CComPtr<IPin> pPinTo;
- return m_pPin && SUCCEEDED(m_pPin->ConnectedTo(&pPinTo)) && pPinTo;
+ CComPtr<IPin> pPinTo;
+ return m_pPin && SUCCEEDED(m_pPin->ConnectedTo(&pPinTo)) && pPinTo;
}
//
CConvertDlg::CTreeItemResourceFolder::CTreeItemResourceFolder(CTreeCtrl& tree, HTREEITEM hTIParent)
- : CTreeItem(tree, hTIParent)
+ : CTreeItem(tree, hTIParent)
{
- Update();
+ Update();
}
void CConvertDlg::CTreeItemResourceFolder::Update()
{
- SetLabel(ResStr(IDS_AG_RESOURCES));
+ SetLabel(ResStr(IDS_AG_RESOURCES));
}
bool CConvertDlg::CTreeItemResourceFolder::ToolTip(CString& str)
{
- if(!m_tree.ItemHasChildren(m_hTI))
- return false;
+ if(!m_tree.ItemHasChildren(m_hTI))
+ return false;
- int files = 0;
- float size = 0;
+ int files = 0;
+ float size = 0;
- HTREEITEM hChildItem = m_tree.GetChildItem(m_hTI);
+ HTREEITEM hChildItem = m_tree.GetChildItem(m_hTI);
- while(hChildItem != NULL)
- {
- HTREEITEM hNextItem = m_tree.GetNextItem(hChildItem, TVGN_NEXT);
- if(CTreeItemResource* t = dynamic_cast<CTreeItemResource*>((CTreeItem*)m_tree.GetItemData(hChildItem)))
- size += t->m_res.data.GetCount(), files++;
- hChildItem = hNextItem;
- }
+ while(hChildItem != NULL)
+ {
+ HTREEITEM hNextItem = m_tree.GetNextItem(hChildItem, TVGN_NEXT);
+ if(CTreeItemResource* t = dynamic_cast<CTreeItemResource*>((CTreeItem*)m_tree.GetItemData(hChildItem)))
+ size += t->m_res.data.GetCount(), files++;
+ hChildItem = hNextItem;
+ }
- size /= 1024;
- if(size < 1024) str.Format(ResStr(IDS_CONVERTDLG_13), files, size);
- else str.Format(ResStr(IDS_CONVERTDLG_14), files, size / 1024);
+ size /= 1024;
+ if(size < 1024) str.Format(ResStr(IDS_CONVERTDLG_13), files, size);
+ else str.Format(ResStr(IDS_CONVERTDLG_14), files, size/1024);
- return true;
+ return true;
}
//
CConvertDlg::CTreeItemResource::CTreeItemResource(const CDSMResource& res, CTreeCtrl& tree, HTREEITEM hTIParent)
- : CTreeItem(tree, hTIParent)
+ : CTreeItem(tree, hTIParent)
{
- m_res = res;
- Update();
+ m_res = res;
+ Update();
}
CConvertDlg::CTreeItemResource::~CTreeItemResource()
@@ -1343,61 +1323,61 @@ CConvertDlg::CTreeItemResource::~CTreeItemResource()
void CConvertDlg::CTreeItemResource::Update()
{
- SetLabel(CString(m_res.name));
+ SetLabel(CString(m_res.name));
- CStringW mime = m_res.mime;
- mime.Trim();
- mime.MakeLower();
- if(mime == L"application/x-truetype-font") SetImage(4, 4);
- else if(mime.Find(L"text/") == 0) SetImage(5, 5);
- else SetImage(6, 6);
+ CStringW mime = m_res.mime;
+ mime.Trim();
+ mime.MakeLower();
+ if(mime == L"application/x-truetype-font") SetImage(4, 4);
+ else if(mime.Find(L"text/") == 0) SetImage(5, 5);
+ else SetImage(6, 6);
}
bool CConvertDlg::CTreeItemResource::ToolTip(CString& str)
{
- if(!m_res.mime.IsEmpty()) str = CString(m_res.mime) + _T("\r\n\r\n");
- if(!m_res.desc.IsEmpty()) str += CString(m_res.desc);
- str.Trim();
- return true;
+ if(!m_res.mime.IsEmpty()) str = CString(m_res.mime) + _T("\r\n\r\n");
+ if(!m_res.desc.IsEmpty()) str += CString(m_res.desc);
+ str.Trim();
+ return true;
}
//
CConvertDlg::CTreeItemChapterFolder::CTreeItemChapterFolder(CTreeCtrl& tree, HTREEITEM hTIParent)
- : CTreeItem(tree, hTIParent)
+ : CTreeItem(tree, hTIParent)
{
- Update();
+ Update();
}
void CConvertDlg::CTreeItemChapterFolder::Update()
{
- SetLabel(ResStr(IDS_AG_CHAPTERS));
+ SetLabel(ResStr(IDS_AG_CHAPTERS));
}
//
CConvertDlg::CTreeItemChapter::CTreeItemChapter(const CDSMChapter& chap, CTreeCtrl& tree, HTREEITEM hTIParent)
- : CTreeItem(tree, hTIParent)
+ : CTreeItem(tree, hTIParent)
{
- m_chap = chap;
- Update();
+ m_chap = chap;
+ Update();
}
void CConvertDlg::CTreeItemChapter::Update()
{
- REFERENCE_TIME rt = m_chap.rt;
- rt /= 10000;
- int ms = (int)(rt % 1000);
- rt /= 1000;
- int s = (int)(rt % 60);
- rt /= 60;
- int m = (int)(rt % 60);
- rt /= 60;
- int h = (int)(rt);
-
- CString label;
- label.Format(_T("%02d:%02d:%02d.%03d - %s"), h, m, s, ms, CString(m_chap.name));
- SetLabel(label);
-
- SetImage(7, 7);
+ REFERENCE_TIME rt = m_chap.rt;
+ rt /= 10000;
+ int ms = (int)(rt%1000);
+ rt /= 1000;
+ int s = (int)(rt%60);
+ rt /= 60;
+ int m = (int)(rt%60);
+ rt /= 60;
+ int h = (int)(rt);
+
+ CString label;
+ label.Format(_T("%02d:%02d:%02d.%03d - %s"), h, m, s, ms, CString(m_chap.name));
+ SetLabel(label);
+
+ SetImage(7, 7);
}
diff --git a/src/apps/mplayerc/ConvertDlg.h b/src/apps/mplayerc/ConvertDlg.h
index 2d7f10f92..0be898a34 100644
--- a/src/apps/mplayerc/ConvertDlg.h
+++ b/src/apps/mplayerc/ConvertDlg.h
@@ -30,15 +30,15 @@
class CFilterTreeCtrl : public CTreeCtrl
{
public:
- CFilterTreeCtrl();
+ CFilterTreeCtrl();
protected:
- virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
- virtual void PreSubclassWindow();
+ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
+ virtual void PreSubclassWindow();
public:
- DECLARE_MESSAGE_MAP()
- afx_msg BOOL OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult);
+ DECLARE_MESSAGE_MAP()
+ afx_msg BOOL OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult);
};
// CConvertDlg dialog
@@ -46,155 +46,149 @@ public:
class CConvertDlg : public CResizableDialog
{
public:
- class CTreeItem
- {
- protected:
- CTreeCtrl& m_tree;
- HTREEITEM m_hTI;
-
- public:
- CTreeItem(CTreeCtrl& tree, HTREEITEM hTIParent);
- virtual ~CTreeItem();
- virtual void Update() {}
- virtual bool ToolTip(CString& str)
- {
- return false;
- }
- void SetLabel(LPCTSTR label);
- void SetImage(int nImage, int nSelectedImage);
- operator HTREEITEM() const
- {
- return m_hTI;
- }
- };
-
- class CTreeItemFilter : public CTreeItem
- {
- public:
- CComPtr<IBaseFilter> m_pBF;
- CTreeItemFilter(IBaseFilter* pBF, CTreeCtrl& tree, HTREEITEM hTIParent);
- void Update();
- };
-
- class CTreeItemFile : public CTreeItemFilter
- {
- public:
- CString m_fn;
- CTreeItemFile(CString fn, IBaseFilter* pBF, CTreeCtrl& tree, HTREEITEM hTIParent);
- void Update();
- bool ToolTip(CString& str);
- };
-
- class CTreeItemPin : public CTreeItem
- {
- public:
- CComPtr<IPin> m_pPin;
- CTreeItemPin(IPin* pPin, CTreeCtrl& tree, HTREEITEM hTIParent);
- void Update();
- bool ToolTip(CString& str);
- bool IsConnected();
- };
-
- class CTreeItemResourceFolder : public CTreeItem
- {
- public:
- CTreeItemResourceFolder(CTreeCtrl& tree, HTREEITEM hTIParent);
- void Update();
- bool ToolTip(CString& str);
- };
-
- class CTreeItemResource : public CTreeItem
- {
- public:
- CDSMResource m_res;
- CTreeItemResource(const CDSMResource& res, CTreeCtrl& tree, HTREEITEM hTIParent);
- ~CTreeItemResource();
- void Update();
- bool ToolTip(CString& str);
- };
-
- class CTreeItemChapterFolder : public CTreeItem
- {
- public:
- CTreeItemChapterFolder(CTreeCtrl& tree, HTREEITEM hTIParent);
- void Update();
- };
-
- class CTreeItemChapter : public CTreeItem
- {
- public:
- CDSMChapter m_chap;
- CTreeItemChapter(const CDSMChapter& chap, CTreeCtrl& tree, HTREEITEM hTIParent);
- void Update();
- };
+ class CTreeItem
+ {
+ protected:
+ CTreeCtrl& m_tree;
+ HTREEITEM m_hTI;
+
+ public:
+ CTreeItem(CTreeCtrl& tree, HTREEITEM hTIParent);
+ virtual ~CTreeItem();
+ virtual void Update() {}
+ virtual bool ToolTip(CString& str) {return false;}
+ void SetLabel(LPCTSTR label);
+ void SetImage(int nImage, int nSelectedImage);
+ operator HTREEITEM() const {return m_hTI;}
+ };
+
+ class CTreeItemFilter : public CTreeItem
+ {
+ public:
+ CComPtr<IBaseFilter> m_pBF;
+ CTreeItemFilter(IBaseFilter* pBF, CTreeCtrl& tree, HTREEITEM hTIParent);
+ void Update();
+ };
+
+ class CTreeItemFile : public CTreeItemFilter
+ {
+ public:
+ CString m_fn;
+ CTreeItemFile(CString fn, IBaseFilter* pBF, CTreeCtrl& tree, HTREEITEM hTIParent);
+ void Update();
+ bool ToolTip(CString& str);
+ };
+
+ class CTreeItemPin : public CTreeItem
+ {
+ public:
+ CComPtr<IPin> m_pPin;
+ CTreeItemPin(IPin* pPin, CTreeCtrl& tree, HTREEITEM hTIParent);
+ void Update();
+ bool ToolTip(CString& str);
+ bool IsConnected();
+ };
+
+ class CTreeItemResourceFolder : public CTreeItem
+ {
+ public:
+ CTreeItemResourceFolder(CTreeCtrl& tree, HTREEITEM hTIParent);
+ void Update();
+ bool ToolTip(CString& str);
+ };
+
+ class CTreeItemResource : public CTreeItem
+ {
+ public:
+ CDSMResource m_res;
+ CTreeItemResource(const CDSMResource& res, CTreeCtrl& tree, HTREEITEM hTIParent);
+ ~CTreeItemResource();
+ void Update();
+ bool ToolTip(CString& str);
+ };
+
+ class CTreeItemChapterFolder : public CTreeItem
+ {
+ public:
+ CTreeItemChapterFolder(CTreeCtrl& tree, HTREEITEM hTIParent);
+ void Update();
+ };
+
+ class CTreeItemChapter : public CTreeItem
+ {
+ public:
+ CDSMChapter m_chap;
+ CTreeItemChapter(const CDSMChapter& chap, CTreeCtrl& tree, HTREEITEM hTIParent);
+ void Update();
+ };
private:
- CComPtr<IGraphBuilder2> m_pGB;
- CComPtr<IBaseFilter> m_pMux;
- CComQIPtr<IMediaControl> m_pMC;
- CComQIPtr<IMediaEventEx> m_pME;
- CComQIPtr<IMediaSeeking> m_pMS;
+ CComPtr<IGraphBuilder2> m_pGB;
+ CComPtr<IBaseFilter> m_pMux;
+ CComQIPtr<IMediaControl> m_pMC;
+ CComQIPtr<IMediaEventEx> m_pME;
+ CComQIPtr<IMediaSeeking> m_pMS;
- CString m_title;
- UINT m_nIDEventStatus;
+ CString m_title;
+ UINT m_nIDEventStatus;
- CBitmap m_streamtypesbm;
- CImageList m_streamtypes;
+ CBitmap m_streamtypesbm;
+ CImageList m_streamtypes;
- CList<CTreeItem*> m_pTIs;
+ CList<CTreeItem*> m_pTIs;
- void AddFile(CString fn);
- bool ConvertFile(LPCTSTR fn, IPin* pPin = NULL);
- void AddFilter(HTREEITEM hTI, IBaseFilter* pBF);
- void DeleteFilter(IBaseFilter* pBF);
- void DeleteItem(HTREEITEM hTI);
- void DeleteChildren(HTREEITEM hTI);
+ void AddFile(CString fn);
+ bool ConvertFile(LPCTSTR fn, IPin* pPin = NULL);
+ void AddFilter(HTREEITEM hTI, IBaseFilter* pBF);
+ void DeleteFilter(IBaseFilter* pBF);
+ void DeleteItem(HTREEITEM hTI);
+ void DeleteChildren(HTREEITEM hTI);
- HTREEITEM HitTest(CPoint& sp, CPoint& cp);
+ HTREEITEM HitTest(CPoint& sp, CPoint& cp);
- void ShowPopup(CPoint p);
- void ShowFilePopup(HTREEITEM hTI, CPoint p);
- void ShowPinPopup(HTREEITEM hTI, CPoint p);
- void ShowResourceFolderPopup(HTREEITEM hTI, CPoint p);
- void ShowResourcePopup(HTREEITEM hTI, CPoint p);
- void ShowChapterFolderPopup(HTREEITEM hTI, CPoint p);
- void ShowChapterPopup(HTREEITEM hTI, CPoint p);
+ void ShowPopup(CPoint p);
+ void ShowFilePopup(HTREEITEM hTI, CPoint p);
+ void ShowPinPopup(HTREEITEM hTI, CPoint p);
+ void ShowResourceFolderPopup(HTREEITEM hTI, CPoint p);
+ void ShowResourcePopup(HTREEITEM hTI, CPoint p);
+ void ShowChapterFolderPopup(HTREEITEM hTI, CPoint p);
+ void ShowChapterPopup(HTREEITEM hTI, CPoint p);
- bool EditProperties(IDSMPropertyBag* pPB);
- bool EditResource(CTreeItemResource* t);
- bool EditChapter(CTreeItemChapter* t);
+ bool EditProperties(IDSMPropertyBag* pPB);
+ bool EditResource(CTreeItemResource* t);
+ bool EditChapter(CTreeItemChapter* t);
public:
- CConvertDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CConvertDlg();
+ CConvertDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CConvertDlg();
// Dialog Data
- enum { IDD = IDD_CONVERT_DLG };
- CFilterTreeCtrl m_tree;
- CString m_fn;
+ enum { IDD = IDD_CONVERT_DLG };
+ CFilterTreeCtrl m_tree;
+ CString m_fn;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
- afx_msg void OnDropFiles(HDROP hDropInfo);
- afx_msg void OnClose();
- afx_msg void OnNMClickTree1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnBnClickedButton2();
- afx_msg void OnBnClickedButton3();
- afx_msg void OnBnClickedButton4();
- afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
- afx_msg void OnUpdateButton3(CCmdUI* pCmdUI);
- afx_msg void OnUpdateButton4(CCmdUI* pCmdUI);
+ afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnDropFiles(HDROP hDropInfo);
+ afx_msg void OnClose();
+ afx_msg void OnNMClickTree1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnBnClickedButton3();
+ afx_msg void OnBnClickedButton4();
+ afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateButton3(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateButton4(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/ConvertPropsDlg.cpp b/src/apps/mplayerc/ConvertPropsDlg.cpp
index ba448af5e..2310bd8fa 100644
--- a/src/apps/mplayerc/ConvertPropsDlg.cpp
+++ b/src/apps/mplayerc/ConvertPropsDlg.cpp
@@ -29,8 +29,8 @@
// CConvertPropsDlg dialog
CConvertPropsDlg::CConvertPropsDlg(bool fPin, CWnd* pParent /*=NULL*/)
- : CResizableDialog(CConvertPropsDlg::IDD, pParent)
- , m_fPin(fPin)
+ : CResizableDialog(CConvertPropsDlg::IDD, pParent)
+ , m_fPin(fPin)
{
}
@@ -40,20 +40,20 @@ CConvertPropsDlg::~CConvertPropsDlg()
void CConvertPropsDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_fcc);
- DDX_Control(pDX, IDC_EDIT1, m_text);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_fcc);
+ DDX_Control(pDX, IDC_EDIT1, m_text);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BEGIN_MESSAGE_MAP(CConvertPropsDlg, CResizableDialog)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
- ON_CBN_EDITCHANGE(IDC_COMBO1, OnCbnEditchangeCombo1)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
- ON_NOTIFY(LVN_KEYDOWN, IDC_LIST1, OnLvnKeydownList1)
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
+ ON_CBN_EDITCHANGE(IDC_COMBO1, OnCbnEditchangeCombo1)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
+ ON_NOTIFY(LVN_KEYDOWN, IDC_LIST1, OnLvnKeydownList1)
END_MESSAGE_MAP()
@@ -61,145 +61,141 @@ END_MESSAGE_MAP()
BOOL CConvertPropsDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- AddAnchor(IDC_COMBO1, TOP_LEFT);
- AddAnchor(IDC_EDIT1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
- AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDOK, BOTTOM_CENTER);
- AddAnchor(IDCANCEL, BOTTOM_CENTER);
-
- if(m_fPin)
- {
- m_fcc.AddString(_T("NAME"));
- m_fcc.AddString(_T("LANG"));
- m_fcc.AddString(_T("DESC"));
- m_fcc.AddString(_T("SGRP"));
- }
- else
- {
- m_fcc.AddString(_T("TITL"));
- m_fcc.AddString(_T("AUTH"));
- m_fcc.AddString(_T("RTNG"));
- m_fcc.AddString(_T("CPYR"));
- m_fcc.AddString(_T("DESC"));
- }
-
- m_list.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 75);
- m_list.InsertColumn(1, _T("Text"), LVCFMT_LEFT, 280);
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
-
- POSITION pos = m_props.GetStartPosition();
- while(pos)
- {
- CString key, value;
- m_props.GetNextAssoc(pos, key, value);
- SetItem(key, value);
- }
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AddAnchor(IDC_COMBO1, TOP_LEFT);
+ AddAnchor(IDC_EDIT1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+ AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDOK, BOTTOM_CENTER);
+ AddAnchor(IDCANCEL, BOTTOM_CENTER);
+
+ if(m_fPin)
+ {
+ m_fcc.AddString(_T("NAME"));
+ m_fcc.AddString(_T("LANG"));
+ m_fcc.AddString(_T("DESC"));
+ m_fcc.AddString(_T("SGRP"));
+ }
+ else
+ {
+ m_fcc.AddString(_T("TITL"));
+ m_fcc.AddString(_T("AUTH"));
+ m_fcc.AddString(_T("RTNG"));
+ m_fcc.AddString(_T("CPYR"));
+ m_fcc.AddString(_T("DESC"));
+ }
+
+ m_list.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 75);
+ m_list.InsertColumn(1, _T("Text"), LVCFMT_LEFT, 280);
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
+
+ POSITION pos = m_props.GetStartPosition();
+ while(pos)
+ {
+ CString key, value;
+ m_props.GetNextAssoc(pos, key, value);
+ SetItem(key, value);
+ }
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CConvertPropsDlg::SetItem(CString key, CString value)
{
- LVFINDINFO fi;
- fi.flags = LVFI_STRING;
- fi.psz = key;
-
- int i = m_list.FindItem(&fi);
- if(i < 0) i = m_list.InsertItem(m_list.GetItemCount(), _T(""));
-
- key.Trim();
- value.Trim();
-
- if(value.IsEmpty())
- {
- m_list.DeleteItem(i);
- return;
- }
-
- if(key == _T("LANG") && value.GetLength() != 3)
- {
- m_list.DeleteItem(i);
- AfxMessageBox(_T("LANG has to be a three letter ISO 639-2 language code."), MB_OK);
- return;
- }
-
- m_list.SetItemText(i, 0, key);
- m_list.SetItemText(i, 1, value);
+ LVFINDINFO fi;
+ fi.flags = LVFI_STRING;
+ fi.psz = key;
+
+ int i = m_list.FindItem(&fi);
+ if(i < 0) i = m_list.InsertItem(m_list.GetItemCount(), _T(""));
+
+ key.Trim();
+ value.Trim();
+
+ if(value.IsEmpty())
+ {
+ m_list.DeleteItem(i);
+ return;
+ }
+
+ if(key == _T("LANG") && value.GetLength() != 3)
+ {
+ m_list.DeleteItem(i);
+ AfxMessageBox(_T("LANG has to be a three letter ISO 639-2 language code."), MB_OK);
+ return;
+ }
+
+ m_list.SetItemText(i, 0, key);
+ m_list.SetItemText(i, 1, value);
}
void CConvertPropsDlg::OnOK()
{
- m_props.RemoveAll();
+ m_props.RemoveAll();
- for(int i = 0; i < m_list.GetItemCount(); i++)
- m_props[m_list.GetItemText(i, 0)] = m_list.GetItemText(i, 1);
+ for(int i = 0; i < m_list.GetItemCount(); i++)
+ m_props[m_list.GetItemText(i, 0)] = m_list.GetItemText(i, 1);
- __super::OnOK();
+ __super::OnOK();
}
void CConvertPropsDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem >= 0)
- {
- m_fcc.SetWindowText(m_list.GetItemText(lpnmlv->iItem, 0));
- m_text.SetWindowText(m_list.GetItemText(lpnmlv->iItem, 1));
- }
+ if(lpnmlv->iItem >= 0)
+ {
+ m_fcc.SetWindowText(m_list.GetItemText(lpnmlv->iItem, 0));
+ m_text.SetWindowText(m_list.GetItemText(lpnmlv->iItem, 1));
+ }
- *pResult = 0;
+ *pResult = 0;
}
void CConvertPropsDlg::OnBnClickedButton1()
{
- CString key, value;
- m_fcc.GetWindowText(key);
- m_text.GetWindowText(value);
- if(key.GetLength() != 4)
- {
- AfxMessageBox(_T("ID must be 4 characters long!"), MB_OK);
- return;
- }
- SetItem(key, value);
+ CString key, value;
+ m_fcc.GetWindowText(key);
+ m_text.GetWindowText(value);
+ if(key.GetLength() != 4) {AfxMessageBox(_T("ID must be 4 characters long!"), MB_OK); return;}
+ SetItem(key, value);
}
void CConvertPropsDlg::OnUpdateButton1(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(GetDlgItem(IDC_EDIT1)->GetWindowTextLength() > 0);
+ pCmdUI->Enable(GetDlgItem(IDC_EDIT1)->GetWindowTextLength() > 0);
}
void CConvertPropsDlg::OnCbnEditchangeCombo1()
{
- int i = m_fcc.GetCurSel();
- if(i < 0) return;
+ int i = m_fcc.GetCurSel();
+ if(i < 0) return;
- CString key;
- m_fcc.GetLBText(i, key);
+ CString key;
+ m_fcc.GetLBText(i, key);
- LVFINDINFO fi;
- fi.flags = LVFI_STRING;
- fi.psz = key;
+ LVFINDINFO fi;
+ fi.flags = LVFI_STRING;
+ fi.psz = key;
- i = m_list.FindItem(&fi);
- if(i > 0) m_text.SetWindowText(m_list.GetItemText(i, 1));
+ i = m_list.FindItem(&fi);
+ if(i > 0) m_text.SetWindowText(m_list.GetItemText(i, 1));
}
void CConvertPropsDlg::OnCbnSelchangeCombo1()
{
- OnCbnEditchangeCombo1();
+ OnCbnEditchangeCombo1();
}
void CConvertPropsDlg::OnLvnKeydownList1(NMHDR *pNMHDR, LRESULT *pResult)
{
- LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
+ LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
- int i = m_fcc.GetCurSel();
- if(i >= 0) m_list.DeleteItem(i);
+ int i = m_fcc.GetCurSel();
+ if(i >= 0) m_list.DeleteItem(i);
- *pResult = 0;
+ *pResult = 0;
}
diff --git a/src/apps/mplayerc/ConvertPropsDlg.h b/src/apps/mplayerc/ConvertPropsDlg.h
index 98bd51f8a..5f188e3c6 100644
--- a/src/apps/mplayerc/ConvertPropsDlg.h
+++ b/src/apps/mplayerc/ConvertPropsDlg.h
@@ -33,32 +33,32 @@
class CConvertPropsDlg : public CResizableDialog
{
private:
- bool m_fPin;
- void SetItem(CString key, CString value);
+ bool m_fPin;
+ void SetItem(CString key, CString value);
public:
- CConvertPropsDlg(bool fPin, CWnd* pParent = NULL); // standard constructor
- virtual ~CConvertPropsDlg();
+ CConvertPropsDlg(bool fPin, CWnd* pParent = NULL); // standard constructor
+ virtual ~CConvertPropsDlg();
- CAtlStringMap<> m_props;
+ CAtlStringMap<> m_props;
// Dialog Data
- enum { IDD = IDD_CONVERTPROPS_DLG };
- CComboBox m_fcc;
- CEdit m_text;
- CListCtrl m_list;
+ enum { IDD = IDD_CONVERTPROPS_DLG };
+ CComboBox m_fcc;
+ CEdit m_text;
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
- afx_msg void OnCbnEditchangeCombo1();
- afx_msg void OnCbnSelchangeCombo1();
- afx_msg void OnLvnKeydownList1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
+ afx_msg void OnCbnEditchangeCombo1();
+ afx_msg void OnCbnSelchangeCombo1();
+ afx_msg void OnLvnKeydownList1(NMHDR *pNMHDR, LRESULT *pResult);
};
diff --git a/src/apps/mplayerc/ConvertResDlg.cpp b/src/apps/mplayerc/ConvertResDlg.cpp
index c3be85ce1..f82845f53 100644
--- a/src/apps/mplayerc/ConvertResDlg.cpp
+++ b/src/apps/mplayerc/ConvertResDlg.cpp
@@ -29,9 +29,9 @@
// CConvertResDlg dialog
CConvertResDlg::CConvertResDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CConvertResDlg::IDD, pParent)
- , m_name(_T(""))
- , m_desc(_T(""))
+ : CResizableDialog(CConvertResDlg::IDD, pParent)
+ , m_name(_T(""))
+ , m_desc(_T(""))
{
}
@@ -41,85 +41,85 @@ CConvertResDlg::~CConvertResDlg()
void CConvertResDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT3, m_name);
- DDX_Text(pDX, IDC_COMBO1, m_mime);
- DDX_Control(pDX, IDC_COMBO1, m_mimectrl);
- DDX_Text(pDX, IDC_EDIT2, m_desc);
+ __super::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT3, m_name);
+ DDX_Text(pDX, IDC_COMBO1, m_mime);
+ DDX_Control(pDX, IDC_COMBO1, m_mimectrl);
+ DDX_Text(pDX, IDC_EDIT2, m_desc);
}
BOOL CConvertResDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- AddAnchor(IDC_EDIT3, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_EDIT2, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDOK, BOTTOM_CENTER);
- AddAnchor(IDCANCEL, BOTTOM_CENTER);
-
- CRegKey key;
- CString str(_T("MIME\\Database\\Content Type"));
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ))
- {
- CAtlStringMap<bool> mimes;
-
- TCHAR buff[256];
- DWORD len = countof(buff);
- for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = countof(buff))
- {
- CRegKey mime;
- TCHAR ext[64];
- ULONG len = countof(ext);
- if(ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
- && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len))
- {
- CString mime = CString(buff).MakeLower();
- mimes[mime] = true;
- m_mimectrl.AddString(mime);
- }
- }
-
- static TCHAR* moremimes[] =
- {
- _T("application/octet-stream"),
- _T("application/zip"),
- _T("application/rar"),
- _T("application/x-truetype-font"),
- };
-
- for(int i = 0; i < countof(moremimes); i++)
+ __super::OnInitDialog();
+
+ AddAnchor(IDC_EDIT3, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_EDIT2, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDOK, BOTTOM_CENTER);
+ AddAnchor(IDCANCEL, BOTTOM_CENTER);
+
+ CRegKey key;
+ CString str(_T("MIME\\Database\\Content Type"));
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ))
+ {
+ CAtlStringMap<bool> mimes;
+
+ TCHAR buff[256];
+ DWORD len = countof(buff);
+ for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = countof(buff))
+ {
+ CRegKey mime;
+ TCHAR ext[64];
+ ULONG len = countof(ext);
+ if(ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
+ && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len))
+ {
+ CString mime = CString(buff).MakeLower();
+ mimes[mime] = true;
+ m_mimectrl.AddString(mime);
+ }
+ }
+
+ static TCHAR* moremimes[] =
+ {
+ _T("application/octet-stream"),
+ _T("application/zip"),
+ _T("application/rar"),
+ _T("application/x-truetype-font"),
+ };
+
+ for(int i = 0; i < countof(moremimes); i++)
if(!mimes.Lookup(moremimes[i]))
- m_mimectrl.AddString(moremimes[i]);
- }
+ m_mimectrl.AddString(moremimes[i]);
+ }
- m_desc.Replace(_T("\n"), _T("\r\n"));
+ m_desc.Replace(_T("\n"), _T("\r\n"));
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CConvertResDlg::OnOK()
{
- UpdateData();
+ UpdateData();
- m_name.Trim();
- m_mime.Trim();
- m_desc.Replace(_T("\r\n"), _T("\r"));
- m_desc.Trim();
+ m_name.Trim();
+ m_mime.Trim();
+ m_desc.Replace(_T("\r\n"), _T("\r"));
+ m_desc.Trim();
- __super::OnOK();
+ __super::OnOK();
}
BEGIN_MESSAGE_MAP(CConvertResDlg, CResizableDialog)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
END_MESSAGE_MAP()
// CConvertResDlg message handlers
void CConvertResDlg::OnUpdateOK(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(GetDlgItem(IDC_EDIT3)->GetWindowTextLength() > 0 && GetDlgItem(IDC_COMBO1)->GetWindowTextLength() > 0);
+ pCmdUI->Enable(GetDlgItem(IDC_EDIT3)->GetWindowTextLength() > 0 && GetDlgItem(IDC_COMBO1)->GetWindowTextLength() > 0);
}
diff --git a/src/apps/mplayerc/ConvertResDlg.h b/src/apps/mplayerc/ConvertResDlg.h
index a17acb7a9..994db8db6 100644
--- a/src/apps/mplayerc/ConvertResDlg.h
+++ b/src/apps/mplayerc/ConvertResDlg.h
@@ -31,22 +31,22 @@
class CConvertResDlg : public CResizableDialog
{
public:
- CConvertResDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CConvertResDlg();
+ CConvertResDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CConvertResDlg();
// Dialog Data
- enum { IDD = IDD_CONVERTRES_DLG };
- CString m_name;
- CString m_mime;
- CComboBox m_mimectrl;
- CString m_desc;
+ enum { IDD = IDD_CONVERTRES_DLG };
+ CString m_name;
+ CString m_mime;
+ CComboBox m_mimectrl;
+ CString m_desc;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/D3DFont.cpp b/src/apps/mplayerc/D3DFont.cpp
index c34218858..0cd98fc17 100644
--- a/src/apps/mplayerc/D3DFont.cpp
+++ b/src/apps/mplayerc/D3DFont.cpp
@@ -39,42 +39,24 @@
//-----------------------------------------------------------------------------
#define MAX_NUM_VERTICES 50*6
-struct FONT2DVERTEX
-{
- D3DXVECTOR4 p;
- DWORD color;
- FLOAT tu, tv;
-};
-struct FONT3DVERTEX
-{
- D3DXVECTOR3 p;
- D3DXVECTOR3 n;
- FLOAT tu, tv;
-};
+struct FONT2DVERTEX { D3DXVECTOR4 p; DWORD color; FLOAT tu, tv; };
+struct FONT3DVERTEX { D3DXVECTOR3 p; D3DXVECTOR3 n; FLOAT tu, tv; };
#define D3DFVF_FONT2DVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
#define D3DFVF_FONT3DVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
-inline FONT2DVERTEX InitFont2DVertex(const D3DXVECTOR4& p, D3DCOLOR color,
- FLOAT tu, FLOAT tv)
+inline FONT2DVERTEX InitFont2DVertex( const D3DXVECTOR4& p, D3DCOLOR color,
+ FLOAT tu, FLOAT tv )
{
- FONT2DVERTEX v;
- v.p = p;
- v.color = color;
- v.tu = tu;
- v.tv = tv;
+ FONT2DVERTEX v; v.p = p; v.color = color; v.tu = tu; v.tv = tv;
return v;
}
-inline FONT3DVERTEX InitFont3DVertex(const D3DXVECTOR3& p, const D3DXVECTOR3& n,
- FLOAT tu, FLOAT tv)
+inline FONT3DVERTEX InitFont3DVertex( const D3DXVECTOR3& p, const D3DXVECTOR3& n,
+ FLOAT tu, FLOAT tv )
{
- FONT3DVERTEX v;
- v.p = p;
- v.n = n;
- v.tu = tu;
- v.tv = tv;
+ FONT3DVERTEX v; v.p = p; v.n = n; v.tu = tu; v.tv = tv;
return v;
}
@@ -85,9 +67,9 @@ inline FONT3DVERTEX InitFont3DVertex(const D3DXVECTOR3& p, const D3DXVECTOR3& n,
// Name: CD3DFont()
// Desc: Font class constructor
//-----------------------------------------------------------------------------
-CD3DFont::CD3DFont(const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags)
+CD3DFont::CD3DFont( const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags )
{
- _tcsncpy(m_strFontName, strFontName, sizeof(m_strFontName) / sizeof(TCHAR));
+ _tcsncpy( m_strFontName, strFontName, sizeof(m_strFontName) / sizeof(TCHAR) );
m_strFontName[sizeof(m_strFontName) / sizeof(TCHAR) - 1] = _T('\0');
m_dwFontHeight = dwHeight;
m_dwFontFlags = dwFlags;
@@ -122,21 +104,21 @@ CD3DFont::~CD3DFont()
// Desc: Create a font based on the current state of related member variables
// and return the handle (or null on error)
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::CreateGDIFont(HDC hDC, HFONT* pFont)
+HRESULT CD3DFont::CreateGDIFont( HDC hDC, HFONT* pFont )
{
// Create a font. By specifying ANTIALIASED_QUALITY, we might get an
// antialiased font, but this is not guaranteed.
- INT nHeight = -MulDiv(m_dwFontHeight,
- (INT)(GetDeviceCaps(hDC, LOGPIXELSY) * m_fTextScale),
- 72);
+ INT nHeight = -MulDiv( m_dwFontHeight,
+ (INT)(GetDeviceCaps(hDC, LOGPIXELSY) * m_fTextScale),
+ 72 );
DWORD dwBold = (m_dwFontFlags & D3DFONT_BOLD) ? FW_BOLD : FW_NORMAL;
DWORD dwItalic = (m_dwFontFlags & D3DFONT_ITALIC) ? TRUE : FALSE;
- *pFont = CreateFont(nHeight, 0, 0, 0, dwBold, dwItalic,
- FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
- VARIABLE_PITCH, m_strFontName);
+ *pFont = CreateFont( nHeight, 0, 0, 0, dwBold, dwItalic,
+ FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
+ CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
+ VARIABLE_PITCH, m_strFontName );
- if(*pFont == NULL)
+ if( *pFont == NULL )
return E_FAIL;
return S_OK;
@@ -148,50 +130,50 @@ HRESULT CD3DFont::CreateGDIFont(HDC hDC, HFONT* pFont)
//-----------------------------------------------------------------------------
// Name: PaintAlphabet
// Desc: Paint the printable characters for the given GDI font onto the
-// provided device context. If the bMeasureOnly flag is set, no drawing
+// provided device context. If the bMeasureOnly flag is set, no drawing
// will occur.
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::PaintAlphabet(HDC hDC, BOOL bMeasureOnly)
+HRESULT CD3DFont::PaintAlphabet( HDC hDC, BOOL bMeasureOnly )
{
SIZE size;
TCHAR str[2] = _T("x"); // One-character, null-terminated string
-
+
// Calculate the spacing between characters based on line height
- if(0 == GetTextExtentPoint32(hDC, str, 1, &size))
+ if( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) )
return E_FAIL;
m_dwSpacing = (DWORD) ceil(size.cy * 0.3f);
// Set the starting point for the drawing
DWORD x = m_dwSpacing;
DWORD y = 0;
-
+
// For each character, draw text on the DC and advance the current position
- for(char c = 32; c < 127; c++)
+ for( char c = 32; c < 127; c++ )
{
str[0] = c;
- if(0 == GetTextExtentPoint32(hDC, str, 1, &size))
+ if( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) )
return E_FAIL;
- if((DWORD)(x + size.cx + m_dwSpacing) > m_dwTexWidth)
+ if( (DWORD)(x + size.cx + m_dwSpacing) > m_dwTexWidth )
{
x = m_dwSpacing;
y += size.cy + 1;
}
// Check to see if there's room to write the character here
- if(y + size.cy > m_dwTexHeight)
+ if( y + size.cy > m_dwTexHeight )
return D3DERR_MOREDATA;
-
- if(!bMeasureOnly)
+
+ if( !bMeasureOnly )
{
// Perform the actual drawing
- if(0 == ExtTextOut(hDC, x + 0, y + 0, ETO_OPAQUE, NULL, str, 1, NULL))
+ if( 0 == ExtTextOut( hDC, x+0, y+0, ETO_OPAQUE, NULL, str, 1, NULL ) )
return E_FAIL;
- m_fTexCoords[c-32][0] = ((FLOAT)(x + 0 - m_dwSpacing)) / m_dwTexWidth;
- m_fTexCoords[c-32][1] = ((FLOAT)(y + 0 + 0)) / m_dwTexHeight;
- m_fTexCoords[c-32][2] = ((FLOAT)(x + size.cx + m_dwSpacing)) / m_dwTexWidth;
- m_fTexCoords[c-32][3] = ((FLOAT)(y + size.cy + 0)) / m_dwTexHeight;
+ m_fTexCoords[c-32][0] = ((FLOAT)(x + 0 - m_dwSpacing))/m_dwTexWidth;
+ m_fTexCoords[c-32][1] = ((FLOAT)(y + 0 + 0 ))/m_dwTexHeight;
+ m_fTexCoords[c-32][2] = ((FLOAT)(x + size.cx + m_dwSpacing))/m_dwTexWidth;
+ m_fTexCoords[c-32][3] = ((FLOAT)(y + size.cy + 0 ))/m_dwTexHeight;
}
x += size.cx + (2 * m_dwSpacing);
@@ -209,7 +191,7 @@ HRESULT CD3DFont::PaintAlphabet(HDC hDC, BOOL bMeasureOnly)
// Desc: Initializes device-dependent objects, including the vertex buffer used
// for rendering text and the texture map which stores the font image.
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::InitDeviceObjects(LPDIRECT3DDEVICE9 pd3dDevice)
+HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
{
HRESULT hr = S_OK;
HFONT hFont = NULL;
@@ -223,116 +205,116 @@ HRESULT CD3DFont::InitDeviceObjects(LPDIRECT3DDEVICE9 pd3dDevice)
// Assume we will draw fonts into texture without scaling unless the
// required texture size is found to be larger than the device max
- m_fTextScale = 1.0f;
+ m_fTextScale = 1.0f;
- hDC = CreateCompatibleDC(NULL);
- SetMapMode(hDC, MM_TEXT);
+ hDC = CreateCompatibleDC( NULL );
+ SetMapMode( hDC, MM_TEXT );
- hr = CreateGDIFont(hDC, &hFont);
- if(FAILED(hr))
+ hr = CreateGDIFont( hDC, &hFont );
+ if( FAILED(hr) )
goto LCleanReturn;
- hFontOld = (HFONT) SelectObject(hDC, hFont);
+ hFontOld = (HFONT) SelectObject( hDC, hFont );
// Calculate the dimensions for the smallest power-of-two texture which
// can hold all the printable characters
m_dwTexWidth = m_dwTexHeight = 128;
- while(D3DERR_MOREDATA == (hr = PaintAlphabet(hDC, true)))
+ while( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) )
{
m_dwTexWidth *= 2;
m_dwTexHeight *= 2;
}
- if(FAILED(hr))
+ if( FAILED(hr) )
goto LCleanReturn;
-
+
// If requested texture is too big, use a smaller texture and smaller font,
// and scale up when rendering.
D3DCAPS9 d3dCaps;
- m_pd3dDevice->GetDeviceCaps(&d3dCaps);
+ m_pd3dDevice->GetDeviceCaps( &d3dCaps );
- if(m_dwTexWidth > d3dCaps.MaxTextureWidth)
+ if( m_dwTexWidth > d3dCaps.MaxTextureWidth )
{
m_fTextScale = (FLOAT)d3dCaps.MaxTextureWidth / (FLOAT)m_dwTexWidth;
m_dwTexWidth = m_dwTexHeight = d3dCaps.MaxTextureWidth;
-
+
bool bFirstRun = true; // Flag clear after first run
do
{
- // If we've already tried fitting the new text, the scale is still
+ // If we've already tried fitting the new text, the scale is still
// too large. Reduce and try again.
- if(!bFirstRun)
+ if( !bFirstRun)
m_fTextScale *= 0.9f;
// The font has to be scaled to fit on the maximum texture size; our
// current font is too big and needs to be recreated to scale.
- DeleteObject(SelectObject(hDC, hFontOld));
+ DeleteObject( SelectObject( hDC, hFontOld ) );
- hr = CreateGDIFont(hDC, &hFont);
- if(FAILED(hr))
+ hr = CreateGDIFont( hDC, &hFont );
+ if( FAILED(hr) )
goto LCleanReturn;
- hFontOld = (HFONT) SelectObject(hDC, hFont);
+ hFontOld = (HFONT) SelectObject( hDC, hFont );
bFirstRun = false;
- }
- while(D3DERR_MOREDATA == (hr = PaintAlphabet(hDC, true)));
+ }
+ while( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) );
}
-
+
// Create a new texture for the font
- hr = m_pd3dDevice->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1,
- 0, D3DFMT_A4R4G4B4,
- D3DPOOL_MANAGED, &m_pTexture, NULL);
- if(FAILED(hr))
+ hr = m_pd3dDevice->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1,
+ 0, D3DFMT_A4R4G4B4,
+ D3DPOOL_MANAGED, &m_pTexture, NULL );
+ if( FAILED(hr) )
goto LCleanReturn;
// Prepare to create a bitmap
DWORD* pBitmapBits;
BITMAPINFO bmi;
- ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
+ ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = (int)m_dwTexWidth;
+ bmi.bmiHeader.biWidth = (int)m_dwTexWidth;
bmi.bmiHeader.biHeight = -(int)m_dwTexHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biBitCount = 32;
// Create a bitmap for the font
- hbmBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS,
- (void**)&pBitmapBits, NULL, 0);
-
- hbmOld = SelectObject(hDC, hbmBitmap);
+ hbmBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS,
+ (void**)&pBitmapBits, NULL, 0 );
+ hbmOld = SelectObject( hDC, hbmBitmap );
+
// Set text properties
- SetTextColor(hDC, RGB(255, 255, 255));
- SetBkColor(hDC, 0x00000000);
- SetTextAlign(hDC, TA_TOP);
+ SetTextColor( hDC, RGB(255,255,255) );
+ SetBkColor( hDC, 0x00000000 );
+ SetTextAlign( hDC, TA_TOP );
// Paint the alphabet onto the selected bitmap
- hr = PaintAlphabet(hDC, false);
- if(FAILED(hr))
+ hr = PaintAlphabet( hDC, false );
+ if( FAILED(hr) )
goto LCleanReturn;
// Lock the surface and write the alpha values for the set pixels
D3DLOCKED_RECT d3dlr;
- m_pTexture->LockRect(0, &d3dlr, 0, 0);
+ m_pTexture->LockRect( 0, &d3dlr, 0, 0 );
BYTE* pDstRow;
pDstRow = (BYTE*)d3dlr.pBits;
WORD* pDst16;
BYTE bAlpha; // 4-bit measure of pixel intensity
DWORD x, y;
- for(y = 0; y < m_dwTexHeight; y++)
+ for( y=0; y < m_dwTexHeight; y++ )
{
pDst16 = (WORD*)pDstRow;
- for(x = 0; x < m_dwTexWidth; x++)
+ for( x=0; x < m_dwTexWidth; x++ )
{
bAlpha = (BYTE)((pBitmapBits[m_dwTexWidth*y + x] & 0xff) >> 4);
- if(bAlpha > 0)
+ if (bAlpha > 0)
{
- *pDst16++ = (WORD)((bAlpha << 12) | 0x0fff);
+ *pDst16++ = (WORD) ((bAlpha << 12) | 0x0fff);
}
else
{
@@ -346,14 +328,14 @@ HRESULT CD3DFont::InitDeviceObjects(LPDIRECT3DDEVICE9 pd3dDevice)
// Done updating texture, so clean up used objects
LCleanReturn:
- if(m_pTexture)
+ if( m_pTexture )
m_pTexture->UnlockRect(0);
- SelectObject(hDC, hbmOld);
- SelectObject(hDC, hFontOld);
- DeleteObject(hbmBitmap);
- DeleteObject(hFont);
- DeleteDC(hDC);
+ SelectObject( hDC, hbmOld );
+ SelectObject( hDC, hFontOld );
+ DeleteObject( hbmBitmap );
+ DeleteObject( hFont );
+ DeleteDC( hDC );
return hr;
}
@@ -370,91 +352,91 @@ HRESULT CD3DFont::RestoreDeviceObjects()
HRESULT hr;
// Create vertex buffer for the letters
- int vertexSize = max(sizeof(FONT2DVERTEX), sizeof(FONT3DVERTEX));
- if(FAILED(hr = m_pd3dDevice->CreateVertexBuffer(MAX_NUM_VERTICES * vertexSize,
- D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
- D3DPOOL_DEFAULT, &m_pVB, NULL)))
+ int vertexSize = max( sizeof(FONT2DVERTEX), sizeof(FONT3DVERTEX ) );
+ if( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( MAX_NUM_VERTICES * vertexSize,
+ D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
+ D3DPOOL_DEFAULT, &m_pVB, NULL ) ) )
{
return hr;
}
bool bSupportsAlphaBlend = true;
LPDIRECT3D9 pd3d9 = NULL;
- if(SUCCEEDED(m_pd3dDevice->GetDirect3D(&pd3d9)))
+ if( SUCCEEDED( m_pd3dDevice->GetDirect3D( &pd3d9 ) ) )
{
D3DCAPS9 Caps;
D3DDISPLAYMODE Mode;
LPDIRECT3DSURFACE9 pSurf = NULL;
D3DSURFACE_DESC Desc;
- m_pd3dDevice->GetDeviceCaps(&Caps);
- m_pd3dDevice->GetDisplayMode(0, &Mode);
- if(SUCCEEDED(m_pd3dDevice->GetRenderTarget(0, &pSurf)))
+ m_pd3dDevice->GetDeviceCaps( &Caps );
+ m_pd3dDevice->GetDisplayMode( 0, &Mode );
+ if( SUCCEEDED( m_pd3dDevice->GetRenderTarget( 0, &pSurf ) ) )
{
- pSurf->GetDesc(&Desc);
- if(FAILED(pd3d9->CheckDeviceFormat(Caps.AdapterOrdinal, Caps.DeviceType, Mode.Format,
- D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_SURFACE,
- Desc.Format)))
+ pSurf->GetDesc( &Desc );
+ if( FAILED( pd3d9->CheckDeviceFormat( Caps.AdapterOrdinal, Caps.DeviceType, Mode.Format,
+ D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_SURFACE,
+ Desc.Format ) ) )
{
bSupportsAlphaBlend = false;
}
- SAFE_RELEASE(pSurf);
+ SAFE_RELEASE( pSurf );
}
- SAFE_RELEASE(pd3d9);
+ SAFE_RELEASE( pd3d9 );
}
// Create the state blocks for rendering text
- for(UINT which = 0; which < 2; which++)
+ for( UINT which=0; which<2; which++ )
{
m_pd3dDevice->BeginStateBlock();
- m_pd3dDevice->SetTexture(0, m_pTexture);
+ m_pd3dDevice->SetTexture( 0, m_pTexture );
- if(D3DFONT_ZENABLE & m_dwFontFlags)
- m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
+ if ( D3DFONT_ZENABLE & m_dwFontFlags )
+ m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
else
- m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
+ m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- if(bSupportsAlphaBlend)
+ if( bSupportsAlphaBlend )
{
- m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
+ m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
+ m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
}
else
{
- m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
}
- m_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
- m_pd3dDevice->SetRenderState(D3DRS_ALPHAREF, 0x08);
- m_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
- m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
- m_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
- m_pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- m_pd3dDevice->SetRenderState(D3DRS_CLIPPING, TRUE);
- m_pd3dDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, FALSE);
- m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
- m_pd3dDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
- m_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
- m_pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
- D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN |
- D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
- m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-
- if(which == 0)
- m_pd3dDevice->EndStateBlock(&m_pStateBlockSaved);
+ m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
+ m_pd3dDevice->SetRenderState( D3DRS_ALPHAREF, 0x08 );
+ m_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
+ m_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
+ m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
+ m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
+ m_pd3dDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
+ m_pd3dDevice->SetRenderState( D3DRS_CLIPPLANEENABLE, FALSE );
+ m_pd3dDevice->SetRenderState( D3DRS_VERTEXBLEND, D3DVBF_DISABLE );
+ m_pd3dDevice->SetRenderState( D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE );
+ m_pd3dDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
+ m_pd3dDevice->SetRenderState( D3DRS_COLORWRITEENABLE,
+ D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN |
+ D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
+ m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
+ m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
+ m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE );
+
+ if( which==0 )
+ m_pd3dDevice->EndStateBlock( &m_pStateBlockSaved );
else
- m_pd3dDevice->EndStateBlock(&m_pStateBlockDrawText);
+ m_pd3dDevice->EndStateBlock( &m_pStateBlockDrawText );
}
return S_OK;
@@ -469,9 +451,9 @@ HRESULT CD3DFont::RestoreDeviceObjects()
//-----------------------------------------------------------------------------
HRESULT CD3DFont::InvalidateDeviceObjects()
{
- SAFE_RELEASE(m_pVB);
- SAFE_RELEASE(m_pStateBlockSaved);
- SAFE_RELEASE(m_pStateBlockDrawText);
+ SAFE_RELEASE( m_pVB );
+ SAFE_RELEASE( m_pStateBlockSaved );
+ SAFE_RELEASE( m_pStateBlockDrawText );
return S_OK;
}
@@ -485,7 +467,7 @@ HRESULT CD3DFont::InvalidateDeviceObjects()
//-----------------------------------------------------------------------------
HRESULT CD3DFont::DeleteDeviceObjects()
{
- SAFE_RELEASE(m_pTexture);
+ SAFE_RELEASE( m_pTexture );
m_pd3dDevice = NULL;
return S_OK;
@@ -498,35 +480,35 @@ HRESULT CD3DFont::DeleteDeviceObjects()
// Name: GetTextExtent()
// Desc: Get the dimensions of a text string
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::GetTextExtent(const TCHAR* strText, SIZE* pSize)
+HRESULT CD3DFont::GetTextExtent( const TCHAR* strText, SIZE* pSize )
{
- if(NULL == strText || NULL == pSize)
+ if( NULL==strText || NULL==pSize )
return E_FAIL;
FLOAT fRowWidth = 0.0f;
- FLOAT fRowHeight = (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight;
+ FLOAT fRowHeight = (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight;
FLOAT fWidth = 0.0f;
FLOAT fHeight = fRowHeight;
- while(*strText)
+ while( *strText )
{
TCHAR c = *strText++;
- if(c == _T('\n'))
+ if( c == _T('\n') )
{
fRowWidth = 0.0f;
fHeight += fRowHeight;
}
- if((c - 32) < 0 || (c - 32) >= 128 - 32)
+ if( (c-32) < 0 || (c-32) >= 128-32 )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT tx2 = m_fTexCoords[c-32][2];
- fRowWidth += (tx2 - tx1) * m_dwTexWidth - 2 * m_dwSpacing;
+ fRowWidth += (tx2-tx1)*m_dwTexWidth - 2*m_dwSpacing;
- if(fRowWidth > fWidth)
+ if( fRowWidth > fWidth )
fWidth = fRowWidth;
}
@@ -542,93 +524,93 @@ HRESULT CD3DFont::GetTextExtent(const TCHAR* strText, SIZE* pSize)
//-----------------------------------------------------------------------------
// Name: DrawTextScaled()
// Desc: Draws scaled 2D text. Note that x and y are in viewport coordinates
-// (ranging from -1 to +1). fXScale and fYScale are the size fraction
+// (ranging from -1 to +1). fXScale and fYScale are the size fraction
// relative to the entire viewport. For example, a fXScale of 0.25 is
// 1/8th of the screen width. This allows you to output text at a fixed
// fraction of the viewport, even if the screen or window size changes.
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::DrawTextScaled(FLOAT x, FLOAT y, FLOAT z,
- FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags)
+HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
+ FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags )
{
- if(m_pd3dDevice == NULL)
+ if( m_pd3dDevice == NULL )
return E_FAIL;
// Set up renderstate
m_pStateBlockSaved->Capture();
m_pStateBlockDrawText->Apply();
- m_pd3dDevice->SetFVF(D3DFVF_FONT2DVERTEX);
- m_pd3dDevice->SetPixelShader(NULL);
- m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(FONT2DVERTEX));
+ m_pd3dDevice->SetFVF( D3DFVF_FONT2DVERTEX );
+ m_pd3dDevice->SetPixelShader( NULL );
+ m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
// Set filter states
- if(dwFlags & D3DFONT_FILTERED)
+ if( dwFlags & D3DFONT_FILTERED )
{
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
D3DVIEWPORT9 vp;
- m_pd3dDevice->GetViewport(&vp);
- FLOAT fLineHeight = (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight;
+ m_pd3dDevice->GetViewport( &vp );
+ FLOAT fLineHeight = ( m_fTexCoords[0][3] - m_fTexCoords[0][1] ) * m_dwTexHeight;
// Center the text block in the viewport
- if(dwFlags & D3DFONT_CENTERED_X)
+ if( dwFlags & D3DFONT_CENTERED_X )
{
const TCHAR* strTextTmp = strText;
float xFinal = 0.0f;
- while(*strTextTmp)
+ while( *strTextTmp )
{
TCHAR c = *strTextTmp++;
-
- if(c == _T('\n'))
- break; // Isn't supported.
- if((c - 32) < 0 || (c - 32) >= 128 - 32)
+
+ if( c == _T('\n') )
+ break; // Isn't supported.
+ if( (c-32) < 0 || (c-32) >= 128-32 )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT tx2 = m_fTexCoords[c-32][2];
- FLOAT w = (tx2 - tx1) * m_dwTexWidth;
+ FLOAT w = (tx2-tx1)*m_dwTexWidth;
- w *= (fXScale * vp.Height) / fLineHeight;
+ w *= (fXScale*vp.Height)/fLineHeight;
- xFinal += w - (2 * m_dwSpacing) * (fXScale * vp.Height) / fLineHeight;
+ xFinal += w - (2 * m_dwSpacing) * (fXScale*vp.Height)/fLineHeight;
}
- x = -xFinal / vp.Width;
+ x = -xFinal/vp.Width;
}
- if(dwFlags & D3DFONT_CENTERED_Y)
+ if( dwFlags & D3DFONT_CENTERED_Y )
{
- y = -fLineHeight / vp.Height;
+ y = -fLineHeight/vp.Height;
}
- FLOAT sx = (x + 1.0f) * vp.Width / 2;
- FLOAT sy = (y + 1.0f) * vp.Height / 2;
+ FLOAT sx = (x+1.0f)*vp.Width/2;
+ FLOAT sy = (y+1.0f)*vp.Height/2;
FLOAT sz = z;
FLOAT rhw = 1.0f;
// Adjust for character spacing
- sx -= m_dwSpacing * (fXScale * vp.Height) / fLineHeight;
+ sx -= m_dwSpacing * (fXScale*vp.Height)/fLineHeight;
FLOAT fStartX = sx;
// Fill vertex buffer
FONT2DVERTEX* pVertices;
DWORD dwNumTriangles = 0L;
- m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while(*strText)
+ while( *strText )
{
TCHAR c = *strText++;
- if(c == _T('\n'))
+ if( c == _T('\n') )
{
sx = fStartX;
- sy += fYScale * vp.Height;
+ sy += fYScale*vp.Height;
}
- if((c - 32) < 0 || (c - 32) >= 128 - 32)
+ if( (c-32) < 0 || (c-32) >= 128-32 )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
@@ -636,39 +618,39 @@ HRESULT CD3DFont::DrawTextScaled(FLOAT x, FLOAT y, FLOAT z,
FLOAT tx2 = m_fTexCoords[c-32][2];
FLOAT ty2 = m_fTexCoords[c-32][3];
- FLOAT w = (tx2 - tx1) * m_dwTexWidth;
- FLOAT h = (ty2 - ty1) * m_dwTexHeight;
+ FLOAT w = (tx2-tx1)*m_dwTexWidth;
+ FLOAT h = (ty2-ty1)*m_dwTexHeight;
- w *= (fXScale * vp.Height) / fLineHeight;
- h *= (fYScale * vp.Height) / fLineHeight;
+ w *= (fXScale*vp.Height)/fLineHeight;
+ h *= (fYScale*vp.Height)/fLineHeight;
- if(c != _T(' '))
+ if( c != _T(' ') )
{
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + h - 0.5f, sz, rhw), dwColor, tx1, ty2);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, sz, rhw), dwColor, tx1, ty1);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, sz, rhw), dwColor, tx2, ty2);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + 0 - 0.5f, sz, rhw), dwColor, tx2, ty1);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, sz, rhw), dwColor, tx2, ty2);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, sz, rhw), dwColor, tx1, ty1);
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx1, ty2 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx2, ty2 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx2, ty1 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx2, ty2 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
dwNumTriangles += 2;
- if(dwNumTriangles * 3 > (MAX_NUM_VERTICES - 6))
+ if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) )
{
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
- m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
- m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
+ m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
dwNumTriangles = 0L;
}
}
- sx += w - (2 * m_dwSpacing) * (fXScale * vp.Height) / fLineHeight;
+ sx += w - (2 * m_dwSpacing) * (fXScale*vp.Height)/fLineHeight;
}
// Unlock and render the vertex buffer
m_pVB->Unlock();
- if(dwNumTriangles > 0)
- m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ if( dwNumTriangles > 0 )
+ m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
// Restore the modified renderstates
m_pStateBlockSaved->Apply();
@@ -683,59 +665,59 @@ HRESULT CD3DFont::DrawTextScaled(FLOAT x, FLOAT y, FLOAT z,
// Name: DrawText()
// Desc: Draws 2D text. Note that sx and sy are in pixels
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::DrawText(FLOAT sx, FLOAT sy, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags)
+HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags )
{
- if(m_pd3dDevice == NULL)
+ if( m_pd3dDevice == NULL )
return E_FAIL;
// Setup renderstate
m_pStateBlockSaved->Capture();
m_pStateBlockDrawText->Apply();
- m_pd3dDevice->SetFVF(D3DFVF_FONT2DVERTEX);
- m_pd3dDevice->SetPixelShader(NULL);
- m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(FONT2DVERTEX));
+ m_pd3dDevice->SetFVF( D3DFVF_FONT2DVERTEX );
+ m_pd3dDevice->SetPixelShader( NULL );
+ m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
// Set filter states
- if(dwFlags & D3DFONT_FILTERED)
+ if( dwFlags & D3DFONT_FILTERED )
{
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
// Center the text block in the viewport
- if(dwFlags & D3DFONT_CENTERED_X)
+ if( dwFlags & D3DFONT_CENTERED_X )
{
D3DVIEWPORT9 vp;
- m_pd3dDevice->GetViewport(&vp);
+ m_pd3dDevice->GetViewport( &vp );
const TCHAR* strTextTmp = strText;
float xFinal = 0.0f;
- while(*strTextTmp)
+ while( *strTextTmp )
{
TCHAR c = *strTextTmp++;
-
- if(c == _T('\n'))
- break; // Isn't supported.
- if((c - 32) < 0 || (c - 32) >= 128 - 32)
+
+ if( c == _T('\n') )
+ break; // Isn't supported.
+ if( (c-32) < 0 || (c-32) >= 128-32 )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT tx2 = m_fTexCoords[c-32][2];
-
- FLOAT w = (tx2 - tx1) * m_dwTexWidth / m_fTextScale;
-
+
+ FLOAT w = (tx2-tx1) * m_dwTexWidth / m_fTextScale;
+
xFinal += w - (2 * m_dwSpacing);
}
- sx = (vp.Width - xFinal) / 2.0f;
+ sx = (vp.Width-xFinal)/2.0f;
}
- if(dwFlags & D3DFONT_CENTERED_Y)
+ if( dwFlags & D3DFONT_CENTERED_Y )
{
D3DVIEWPORT9 vp;
- m_pd3dDevice->GetViewport(&vp);
- float fLineHeight = ((m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight);
- sy = (vp.Height - fLineHeight) / 2;
+ m_pd3dDevice->GetViewport( &vp );
+ float fLineHeight = ((m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight);
+ sy = (vp.Height-fLineHeight)/2;
}
// Adjust for character spacing
@@ -745,19 +727,19 @@ HRESULT CD3DFont::DrawText(FLOAT sx, FLOAT sy, DWORD dwColor,
// Fill vertex buffer
FONT2DVERTEX* pVertices = NULL;
DWORD dwNumTriangles = 0;
- m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while(*strText)
+ while( *strText )
{
TCHAR c = *strText++;
- if(c == _T('\n'))
+ if( c == _T('\n') )
{
sx = fStartX;
- sy += (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight;
+ sy += (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight;
}
- if((c - 32) < 0 || (c - 32) >= 128 - 32)
+ if( (c-32) < 0 || (c-32) >= 128-32 )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
@@ -765,26 +747,26 @@ HRESULT CD3DFont::DrawText(FLOAT sx, FLOAT sy, DWORD dwColor,
FLOAT tx2 = m_fTexCoords[c-32][2];
FLOAT ty2 = m_fTexCoords[c-32][3];
- FLOAT w = (tx2 - tx1) * m_dwTexWidth / m_fTextScale;
- FLOAT h = (ty2 - ty1) * m_dwTexHeight / m_fTextScale;
+ FLOAT w = (tx2-tx1) * m_dwTexWidth / m_fTextScale;
+ FLOAT h = (ty2-ty1) * m_dwTexHeight / m_fTextScale;
- if(c != _T(' '))
+ if( c != _T(' ') )
{
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + h - 0.5f, 0.9f, 1.0f), dwColor, tx1, ty2);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, 0.9f, 1.0f), dwColor, tx1, ty1);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, 0.9f, 1.0f), dwColor, tx2, ty2);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + 0 - 0.5f, 0.9f, 1.0f), dwColor, tx2, ty1);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, 0.9f, 1.0f), dwColor, tx2, ty2);
- *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, 0.9f, 1.0f), dwColor, tx1, ty1);
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx1, ty2 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx2, ty2 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx2, ty1 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx2, ty2 );
+ *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
dwNumTriangles += 2;
- if(dwNumTriangles * 3 > (MAX_NUM_VERTICES - 6))
+ if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) )
{
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
- m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
pVertices = NULL;
- m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
dwNumTriangles = 0L;
}
}
@@ -794,8 +776,8 @@ HRESULT CD3DFont::DrawText(FLOAT sx, FLOAT sy, DWORD dwColor,
// Unlock and render the vertex buffer
m_pVB->Unlock();
- if(dwNumTriangles > 0)
- m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ if( dwNumTriangles > 0 )
+ m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
// Restore the modified renderstates
m_pStateBlockSaved->Apply();
@@ -810,23 +792,23 @@ HRESULT CD3DFont::DrawText(FLOAT sx, FLOAT sy, DWORD dwColor,
// Name: Render3DText()
// Desc: Renders 3D text
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::Render3DText(const TCHAR* strText, DWORD dwFlags)
+HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
{
- if(m_pd3dDevice == NULL)
+ if( m_pd3dDevice == NULL )
return E_FAIL;
// Setup renderstate
m_pStateBlockSaved->Capture();
m_pStateBlockDrawText->Apply();
- m_pd3dDevice->SetFVF(D3DFVF_FONT3DVERTEX);
- m_pd3dDevice->SetPixelShader(NULL);
- m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(FONT3DVERTEX));
+ m_pd3dDevice->SetFVF( D3DFVF_FONT3DVERTEX );
+ m_pd3dDevice->SetPixelShader( NULL );
+ m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT3DVERTEX) );
// Set filter states
- if(dwFlags & D3DFONT_FILTERED)
+ if( dwFlags & D3DFONT_FILTERED )
{
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
+ m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
// Position for each text element
@@ -834,22 +816,22 @@ HRESULT CD3DFont::Render3DText(const TCHAR* strText, DWORD dwFlags)
FLOAT y = 0.0f;
// Center the text block at the origin (not the viewport)
- if(dwFlags & D3DFONT_CENTERED_X)
+ if( dwFlags & D3DFONT_CENTERED_X )
{
SIZE sz;
- GetTextExtent(strText, &sz);
- x = -(((FLOAT)sz.cx) / 10.0f) / 2.0f;
+ GetTextExtent( strText, &sz );
+ x = -(((FLOAT)sz.cx)/10.0f)/2.0f;
}
- if(dwFlags & D3DFONT_CENTERED_Y)
+ if( dwFlags & D3DFONT_CENTERED_Y )
{
SIZE sz;
- GetTextExtent(strText, &sz);
- y = -(((FLOAT)sz.cy) / 10.0f) / 2.0f;
+ GetTextExtent( strText, &sz );
+ y = -(((FLOAT)sz.cy)/10.0f)/2.0f;
}
// Turn off culling for two-sided text
- if(dwFlags & D3DFONT_TWOSIDED)
- m_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ if( dwFlags & D3DFONT_TWOSIDED )
+ m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
// Adjust for character spacing
x -= m_dwSpacing / 10.0f;
@@ -859,17 +841,17 @@ HRESULT CD3DFont::Render3DText(const TCHAR* strText, DWORD dwFlags)
// Fill vertex buffer
FONT3DVERTEX* pVertices;
DWORD dwNumTriangles = 0L;
- m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while((c = *strText++) != 0)
+ while( (c = *strText++) != 0 )
{
- if(c == '\n')
+ if( c == '\n' )
{
x = fStartX;
- y -= (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight / 10.0f;
+ y -= (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight/10.0f;
}
- if((c - 32) < 0 || (c - 32) >= 128 - 32)
+ if( (c-32) < 0 || (c-32) >= 128-32 )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
@@ -877,25 +859,25 @@ HRESULT CD3DFont::Render3DText(const TCHAR* strText, DWORD dwFlags)
FLOAT tx2 = m_fTexCoords[c-32][2];
FLOAT ty2 = m_fTexCoords[c-32][3];
- FLOAT w = (tx2 - tx1) * m_dwTexWidth / (10.0f * m_fTextScale);
- FLOAT h = (ty2 - ty1) * m_dwTexHeight / (10.0f * m_fTextScale);
+ FLOAT w = (tx2-tx1) * m_dwTexWidth / ( 10.0f * m_fTextScale );
+ FLOAT h = (ty2-ty1) * m_dwTexHeight / ( 10.0f * m_fTextScale );
- if(c != _T(' '))
+ if( c != _T(' ') )
{
- *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + 0, y + 0, 0), D3DXVECTOR3(0, 0, -1), tx1, ty2);
- *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + 0, y + h, 0), D3DXVECTOR3(0, 0, -1), tx1, ty1);
- *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + w, y + 0, 0), D3DXVECTOR3(0, 0, -1), tx2, ty2);
- *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + w, y + h, 0), D3DXVECTOR3(0, 0, -1), tx2, ty1);
- *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + w, y + 0, 0), D3DXVECTOR3(0, 0, -1), tx2, ty2);
- *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + 0, y + h, 0), D3DXVECTOR3(0, 0, -1), tx1, ty1);
+ *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+0,0), D3DXVECTOR3(0,0,-1), tx1, ty2 );
+ *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
+ *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 );
+ *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+h,0), D3DXVECTOR3(0,0,-1), tx2, ty1 );
+ *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 );
+ *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
dwNumTriangles += 2;
- if(dwNumTriangles * 3 > (MAX_NUM_VERTICES - 6))
+ if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) )
{
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
- m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
- m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
+ m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
dwNumTriangles = 0L;
}
}
@@ -905,8 +887,8 @@ HRESULT CD3DFont::Render3DText(const TCHAR* strText, DWORD dwFlags)
// Unlock and render the vertex buffer
m_pVB->Unlock();
- if(dwNumTriangles > 0)
- m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ if( dwNumTriangles > 0 )
+ m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
// Restore the modified renderstates
m_pStateBlockSaved->Apply();
diff --git a/src/apps/mplayerc/D3DFont.h b/src/apps/mplayerc/D3DFont.h
index 4190d3891..5160bd95c 100644
--- a/src/apps/mplayerc/D3DFont.h
+++ b/src/apps/mplayerc/D3DFont.h
@@ -37,45 +37,45 @@
class CD3DFont
{
- TCHAR m_strFontName[80]; // Font properties
+ TCHAR m_strFontName[80]; // Font properties
DWORD m_dwFontHeight;
- DWORD m_dwFontFlags;
+ DWORD m_dwFontFlags;
- LPDIRECT3DDEVICE9 m_pd3dDevice; // A D3DDevice used for rendering
- LPDIRECT3DTEXTURE9 m_pTexture; // The d3d texture for this font
- LPDIRECT3DVERTEXBUFFER9 m_pVB; // VertexBuffer for rendering text
- DWORD m_dwTexWidth; // Texture dimensions
- DWORD m_dwTexHeight;
- FLOAT m_fTextScale;
- FLOAT m_fTexCoords[128-32][4];
- DWORD m_dwSpacing; // Character pixel spacing per side
+ LPDIRECT3DDEVICE9 m_pd3dDevice; // A D3DDevice used for rendering
+ LPDIRECT3DTEXTURE9 m_pTexture; // The d3d texture for this font
+ LPDIRECT3DVERTEXBUFFER9 m_pVB; // VertexBuffer for rendering text
+ DWORD m_dwTexWidth; // Texture dimensions
+ DWORD m_dwTexHeight;
+ FLOAT m_fTextScale;
+ FLOAT m_fTexCoords[128-32][4];
+ DWORD m_dwSpacing; // Character pixel spacing per side
- // Stateblocks for setting and restoring render states
- LPDIRECT3DSTATEBLOCK9 m_pStateBlockSaved;
- LPDIRECT3DSTATEBLOCK9 m_pStateBlockDrawText;
+ // Stateblocks for setting and restoring render states
+ LPDIRECT3DSTATEBLOCK9 m_pStateBlockSaved;
+ LPDIRECT3DSTATEBLOCK9 m_pStateBlockDrawText;
- HRESULT CreateGDIFont(HDC hDC, HFONT* pFont);
- HRESULT PaintAlphabet(HDC hDC, BOOL bMeasureOnly = FALSE);
+ HRESULT CreateGDIFont( HDC hDC, HFONT* pFont );
+ HRESULT PaintAlphabet( HDC hDC, BOOL bMeasureOnly=FALSE );
public:
- // 2D and 3D text drawing functions
- HRESULT DrawText(FLOAT x, FLOAT y, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags = 0L);
- HRESULT DrawTextScaled(FLOAT x, FLOAT y, FLOAT z,
- FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags = 0L);
- HRESULT Render3DText(const TCHAR* strText, DWORD dwFlags = 0L);
+ // 2D and 3D text drawing functions
+ HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags=0L );
+ HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
+ FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags=0L );
+ HRESULT Render3DText( const TCHAR* strText, DWORD dwFlags=0L );
- // Function to get extent of text
- HRESULT GetTextExtent(const TCHAR* strText, SIZE* pSize);
+ // Function to get extent of text
+ HRESULT GetTextExtent( const TCHAR* strText, SIZE* pSize );
- // Initializing and destroying device-dependent objects
- HRESULT InitDeviceObjects(IDirect3DDevice9* pd3dDevice);
- HRESULT RestoreDeviceObjects();
- HRESULT InvalidateDeviceObjects();
- HRESULT DeleteDeviceObjects();
+ // Initializing and destroying device-dependent objects
+ HRESULT InitDeviceObjects( IDirect3DDevice9* pd3dDevice );
+ HRESULT RestoreDeviceObjects();
+ HRESULT InvalidateDeviceObjects();
+ HRESULT DeleteDeviceObjects();
- // Constructor / destructor
- CD3DFont(const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags = 0L);
- ~CD3DFont();
+ // Constructor / destructor
+ CD3DFont( const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
+ ~CD3DFont();
};
diff --git a/src/apps/mplayerc/DVBChannel.cpp b/src/apps/mplayerc/DVBChannel.cpp
index 3e3fd2456..df4f30635 100644
--- a/src/apps/mplayerc/DVBChannel.cpp
+++ b/src/apps/mplayerc/DVBChannel.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -28,18 +28,18 @@
CDVBChannel::CDVBChannel(void)
{
- m_ulFrequency = 0;
- m_nPrefNumber = 0;
- m_nOriginNumber = 0;
- m_ulONID = 0;
- m_ulTSID = 0;
- m_ulSID = 0;
- m_ulPMT = 0;
- m_ulPCR = 0;
- m_ulVideoPID = 0;
- m_nVideoType = DVB_MPV;
- m_nAudioCount = 0;
- m_nSubtitleCount = 0;
+ m_ulFrequency = 0;
+ m_nPrefNumber = 0;
+ m_nOriginNumber = 0;
+ m_ulONID = 0;
+ m_ulTSID = 0;
+ m_ulSID = 0;
+ m_ulPMT = 0;
+ m_ulPCR = 0;
+ m_ulVideoPID = 0;
+ m_nVideoType = DVB_MPV;
+ m_nAudioCount = 0;
+ m_nSubtitleCount = 0;
}
CDVBChannel::~CDVBChannel(void)
@@ -49,107 +49,107 @@ CDVBChannel::~CDVBChannel(void)
void CDVBChannel::FromString(CString strValue)
{
- int i = 0;
- int nVersion;
-
- nVersion = _tstol(strValue.Tokenize(_T("|"), i));
- m_strName = strValue.Tokenize(_T("|"), i);
- m_ulFrequency = _tstol(strValue.Tokenize(_T("|"), i));
- m_nPrefNumber = _tstol(strValue.Tokenize(_T("|"), i));
- m_nOriginNumber = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulONID = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulTSID = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulSID = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulPMT = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulPCR = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulVideoPID = _tstol(strValue.Tokenize(_T("|"), i));
- m_nVideoType = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_nAudioCount = _tstol(strValue.Tokenize(_T("|"), i));
- m_nSubtitleCount = _tstol(strValue.Tokenize(_T("|"), i));
-
- for(int j = 0; j < m_nAudioCount; j++)
- {
- m_Audios[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
- m_Audios[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Audios[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Audios[j].Language = strValue.Tokenize(_T("|"), i);
- }
-
- for(int j = 0; j < m_nSubtitleCount; j++)
- {
- m_Subtitles[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
- m_Subtitles[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Subtitles[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Subtitles[j].Language = strValue.Tokenize(_T("|"), i);
- }
+ int i = 0;
+ int nVersion;
+
+ nVersion = _tstol(strValue.Tokenize(_T("|"), i));
+ m_strName = strValue.Tokenize(_T("|"), i);
+ m_ulFrequency = _tstol(strValue.Tokenize(_T("|"), i));
+ m_nPrefNumber = _tstol(strValue.Tokenize(_T("|"), i));
+ m_nOriginNumber = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulONID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulTSID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulSID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulPMT = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulPCR = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulVideoPID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_nVideoType = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_nAudioCount = _tstol(strValue.Tokenize(_T("|"), i));
+ m_nSubtitleCount = _tstol(strValue.Tokenize(_T("|"), i));
+
+ for(int j=0; j<m_nAudioCount; j++)
+ {
+ m_Audios[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_Audios[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Audios[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Audios[j].Language = strValue.Tokenize(_T("|"), i);
+ }
+
+ for(int j=0; j<m_nSubtitleCount; j++)
+ {
+ m_Subtitles[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_Subtitles[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Subtitles[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Subtitles[j].Language = strValue.Tokenize(_T("|"), i);
+ }
}
CString CDVBChannel::ToString()
{
- CString strValue;
- strValue.AppendFormat(_T("%d|%s|%ld|%d|%d|%ld|%ld|%ld|%ld|%ld|%ld|%d|%ld|%ld"),
- FORMAT_VERSION,
- m_strName,
- m_ulFrequency,
- m_nPrefNumber,
- m_nOriginNumber,
- m_ulONID,
- m_ulTSID,
- m_ulSID,
- m_ulPMT,
- m_ulPCR,
- m_ulVideoPID,
- m_nVideoType,
- m_nAudioCount,
- m_nSubtitleCount);
-
- for(int i = 0; i < m_nAudioCount; i++)
- strValue.AppendFormat(_T("|%ld|%d|%d|%s"), m_Audios[i].PID, m_Audios[i].Type, m_Audios[i].PesType, m_Audios[i].Language);
-
- for(int i = 0; i < m_nSubtitleCount; i++)
- strValue.AppendFormat(_T("|%ld|%d|%d|%s"), m_Subtitles[i].PID, m_Subtitles[i].Type, m_Subtitles[i].PesType, m_Subtitles[i].Language);
-
- return strValue;
+ CString strValue;
+ strValue.AppendFormat (_T("%d|%s|%ld|%d|%d|%ld|%ld|%ld|%ld|%ld|%ld|%d|%ld|%ld"),
+ FORMAT_VERSION,
+ m_strName,
+ m_ulFrequency,
+ m_nPrefNumber,
+ m_nOriginNumber,
+ m_ulONID,
+ m_ulTSID,
+ m_ulSID,
+ m_ulPMT,
+ m_ulPCR,
+ m_ulVideoPID,
+ m_nVideoType,
+ m_nAudioCount,
+ m_nSubtitleCount);
+
+ for(int i=0; i<m_nAudioCount; i++)
+ strValue.AppendFormat (_T("|%ld|%d|%d|%s"), m_Audios[i].PID, m_Audios[i].Type, m_Audios[i].PesType, m_Audios[i].Language);
+
+ for(int i=0; i<m_nSubtitleCount; i++)
+ strValue.AppendFormat (_T("|%ld|%d|%d|%s"), m_Subtitles[i].PID, m_Subtitles[i].Type, m_Subtitles[i].PesType, m_Subtitles[i].Language);
+
+ return strValue;
}
void CDVBChannel::SetName(BYTE* Value)
{
- USES_CONVERSION;
- m_strName = A2W((LPCSTR)Value);
+ USES_CONVERSION;
+ m_strName = A2W ((LPCSTR)Value);
}
-void CDVBChannel::AddStreamInfo(ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage)
+void CDVBChannel::AddStreamInfo (ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage)
{
- switch(nType)
- {
- case DVB_MPV :
- case DVB_H264 :
- m_ulVideoPID = ulPID;
- m_nVideoType = nType;
- break;
- case DVB_MPA :
- case DVB_AC3 :
- case DVB_EAC3 :
- if(m_nAudioCount < DVB_MAX_AUDIO)
- {
- m_Audios[m_nAudioCount].PID = ulPID;
- m_Audios[m_nAudioCount].Type = nType;
- m_Audios[m_nAudioCount].PesType = nPesType;
- m_Audios[m_nAudioCount].Language = strLanguage;
- m_nAudioCount++;
- }
- break;
- case DVB_SUBTITLE :
- if(m_nSubtitleCount < DVB_MAX_SUBTITLE)
- {
- m_Subtitles[m_nSubtitleCount].PID = ulPID;
- m_Subtitles[m_nSubtitleCount].Type = nType;
- m_Subtitles[m_nSubtitleCount].PesType = nPesType;
- m_Subtitles[m_nSubtitleCount].Language = strLanguage;
- m_nSubtitleCount++;
- }
- break;
- }
+ switch (nType)
+ {
+ case DVB_MPV :
+ case DVB_H264 :
+ m_ulVideoPID = ulPID;
+ m_nVideoType = nType;
+ break;
+ case DVB_MPA :
+ case DVB_AC3 :
+ case DVB_EAC3 :
+ if (m_nAudioCount < DVB_MAX_AUDIO)
+ {
+ m_Audios[m_nAudioCount].PID = ulPID;
+ m_Audios[m_nAudioCount].Type = nType;
+ m_Audios[m_nAudioCount].PesType = nPesType;
+ m_Audios[m_nAudioCount].Language = strLanguage;
+ m_nAudioCount++;
+ }
+ break;
+ case DVB_SUBTITLE :
+ if (m_nSubtitleCount < DVB_MAX_SUBTITLE)
+ {
+ m_Subtitles[m_nSubtitleCount].PID = ulPID;
+ m_Subtitles[m_nSubtitleCount].Type = nType;
+ m_Subtitles[m_nSubtitleCount].PesType = nPesType;
+ m_Subtitles[m_nSubtitleCount].Language = strLanguage;
+ m_nSubtitleCount++;
+ }
+ break;
+ }
} \ No newline at end of file
diff --git a/src/apps/mplayerc/DVBChannel.h b/src/apps/mplayerc/DVBChannel.h
index c5a606ac5..256d3964f 100644
--- a/src/apps/mplayerc/DVBChannel.h
+++ b/src/apps/mplayerc/DVBChannel.h
@@ -1,4 +1,4 @@
-/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -28,178 +28,88 @@
typedef enum
{
- DVB_MPV = 0x00,
- DVB_H264 = 0x01,
- DVB_MPA = 0x02,
- DVB_AC3 = 0x03,
- DVB_EAC3 = 0x04,
- DVB_PSI = 0x80,
- DVB_TIF = 0x81,
- DVB_EPG = 0x82,
- DVB_PMT = 0x83,
- DVB_SUB = 0x83,
- DVB_SUBTITLE = 0xFE,
- DVB_UNKNOWN = 0xFF
+ DVB_MPV = 0x00,
+ DVB_H264 = 0x01,
+ DVB_MPA = 0x02,
+ DVB_AC3 = 0x03,
+ DVB_EAC3 = 0x04,
+ DVB_PSI = 0x80,
+ DVB_TIF = 0x81,
+ DVB_EPG = 0x82,
+ DVB_PMT = 0x83,
+ DVB_SUB = 0x83,
+ DVB_SUBTITLE= 0xFE,
+ DVB_UNKNOWN = 0xFF
} DVB_STREAM_TYPE;
-typedef struct
+typedef struct
{
- ULONG PID;
- DVB_STREAM_TYPE Type;
- PES_STREAM_TYPE PesType;
- CString Language;
+ ULONG PID;
+ DVB_STREAM_TYPE Type;
+ PES_STREAM_TYPE PesType;
+ CString Language;
- LCID GetLCID()
- {
- return ISO6392ToLcid(CStringA(Language));
- };
+ LCID GetLCID() { return ISO6392ToLcid(CStringA(Language)); };
} DVBStreamInfo;
class CDVBChannel
{
public:
- CDVBChannel(void);
- ~CDVBChannel(void);
+ CDVBChannel(void);
+ ~CDVBChannel(void);
- void FromString(CString strValue);
- CString ToString();
+ void FromString(CString strValue);
+ CString ToString();
- LPCTSTR GetName() const
- {
- return m_strName;
- };
- ULONG GetFrequency() const
- {
- return m_ulFrequency;
- };
- int GetPrefNumber() const
- {
- return m_nPrefNumber;
- };
- int GetOriginNumber() const
- {
- return m_nOriginNumber;
- };
- ULONG GetONID() const
- {
- return m_ulONID;
- };
- ULONG GetTSID() const
- {
- return m_ulTSID;
- };
- ULONG GetSID() const
- {
- return m_ulSID;
- };
- ULONG GetPMT() const
- {
- return m_ulPMT;
- };
- ULONG GetPCR() const
- {
- return m_ulPCR;
- };
- ULONG GetVideoPID() const
- {
- return m_ulVideoPID;
- };
- DVB_STREAM_TYPE GetVideoType() const
- {
- return m_nVideoType;
- }
- ULONG GetDefaultAudioPID() const
- {
- return m_Audios[0].PID; /* TODO : fa*/
- };
- DVB_STREAM_TYPE GetDefaultAudioType() const
- {
- return m_Audios[0].Type;
- }
- ULONG GetDefaultSubtitlePID() const
- {
- return m_Subtitles[0].PID; /* TODO : fa*/
- };
- int GetAudioCount() const
- {
- return m_nAudioCount;
- };
- int GetSubtitleCount() const
- {
- return m_nSubtitleCount;
- };
- DVBStreamInfo* GetAudio(int nIndex)
- {
- return &m_Audios[nIndex];
- };
- DVBStreamInfo* GetSubtitle(int nIndex)
- {
- return &m_Subtitles[nIndex];
- };
- bool HasName()
- {
- return !m_strName.IsEmpty();
- };
+ LPCTSTR GetName() const { return m_strName; };
+ ULONG GetFrequency() const { return m_ulFrequency; };
+ int GetPrefNumber() const { return m_nPrefNumber; };
+ int GetOriginNumber() const { return m_nOriginNumber; };
+ ULONG GetONID() const { return m_ulONID; };
+ ULONG GetTSID() const { return m_ulTSID; };
+ ULONG GetSID() const { return m_ulSID; };
+ ULONG GetPMT() const { return m_ulPMT; };
+ ULONG GetPCR() const { return m_ulPCR; };
+ ULONG GetVideoPID() const { return m_ulVideoPID; };
+ DVB_STREAM_TYPE GetVideoType() const { return m_nVideoType; }
+ ULONG GetDefaultAudioPID() const { return m_Audios[0].PID; /* TODO : fa*/ };
+ DVB_STREAM_TYPE GetDefaultAudioType() const { return m_Audios[0].Type; }
+ ULONG GetDefaultSubtitlePID() const { return m_Subtitles[0].PID; /* TODO : fa*/ };
+ int GetAudioCount() const { return m_nAudioCount; };
+ int GetSubtitleCount() const { return m_nSubtitleCount; };
+ DVBStreamInfo* GetAudio(int nIndex) { return &m_Audios[nIndex]; };
+ DVBStreamInfo* GetSubtitle(int nIndex) { return &m_Subtitles[nIndex]; };
+ bool HasName() { return !m_strName.IsEmpty(); };
- void SetName(BYTE* Value);
- void SetName(LPCTSTR Value)
- {
- m_strName = Value;
- };
- void SetFrequency(ULONG Value)
- {
- m_ulFrequency = Value;
- };
- void SetPrefNumber(int Value)
- {
- m_nPrefNumber = Value;
- };
- void SetOriginNumber(int Value)
- {
- m_nOriginNumber = m_nPrefNumber = Value;
- };
- void SetONID(ULONG Value)
- {
- m_ulONID = Value;
- };
- void SetTSID(ULONG Value)
- {
- m_ulTSID = Value;
- };
- void SetSID(ULONG Value)
- {
- m_ulSID = Value;
- };
- void SetPMT(ULONG Value)
- {
- m_ulPMT = Value;
- };
- void SetPCR(ULONG Value)
- {
- m_ulPCR = Value;
- };
- void SetVideoPID(ULONG Value)
- {
- m_ulVideoPID = Value;
- };
+ void SetName(BYTE* Value);
+ void SetName(LPCTSTR Value) { m_strName = Value; };
+ void SetFrequency(ULONG Value) { m_ulFrequency = Value; };
+ void SetPrefNumber(int Value) { m_nPrefNumber = Value; };
+ void SetOriginNumber(int Value) { m_nOriginNumber = m_nPrefNumber = Value; };
+ void SetONID(ULONG Value) { m_ulONID = Value; };
+ void SetTSID(ULONG Value) { m_ulTSID = Value; };
+ void SetSID(ULONG Value) { m_ulSID = Value; };
+ void SetPMT(ULONG Value) { m_ulPMT = Value; };
+ void SetPCR(ULONG Value) { m_ulPCR = Value; };
+ void SetVideoPID(ULONG Value) { m_ulVideoPID = Value; };
- void AddStreamInfo(ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage);
+ void AddStreamInfo (ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage);
private :
- CString m_strName;
- ULONG m_ulFrequency;
- int m_nPrefNumber;
- int m_nOriginNumber;
- ULONG m_ulONID;
- ULONG m_ulTSID;
- ULONG m_ulSID;
- ULONG m_ulPMT;
- ULONG m_ulPCR;
- ULONG m_ulVideoPID;
- DVB_STREAM_TYPE m_nVideoType;
- int m_nAudioCount;
- int m_nSubtitleCount;
- DVBStreamInfo m_Audios[DVB_MAX_AUDIO];
- DVBStreamInfo m_Subtitles[DVB_MAX_SUBTITLE];
+ CString m_strName;
+ ULONG m_ulFrequency;
+ int m_nPrefNumber;
+ int m_nOriginNumber;
+ ULONG m_ulONID;
+ ULONG m_ulTSID;
+ ULONG m_ulSID;
+ ULONG m_ulPMT;
+ ULONG m_ulPCR;
+ ULONG m_ulVideoPID;
+ DVB_STREAM_TYPE m_nVideoType;
+ int m_nAudioCount;
+ int m_nSubtitleCount;
+ DVBStreamInfo m_Audios[DVB_MAX_AUDIO];
+ DVBStreamInfo m_Subtitles[DVB_MAX_SUBTITLE];
};
diff --git a/src/apps/mplayerc/DX7AllocatorPresenter.cpp b/src/apps/mplayerc/DX7AllocatorPresenter.cpp
index 7d2aa3d17..3343751ea 100644
--- a/src/apps/mplayerc/DX7AllocatorPresenter.cpp
+++ b/src/apps/mplayerc/DX7AllocatorPresenter.cpp
@@ -43,143 +43,143 @@
bool IsVMR7InGraph(IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF)
- if(CComQIPtr<IVMRWindowlessControl>(pBF)) return(true);
- EndEnumFilters
- return(false);
+ BeginEnumFilters(pFG, pEF, pBF)
+ if(CComQIPtr<IVMRWindowlessControl>(pBF)) return(true);
+ EndEnumFilters
+ return(false);
}
namespace DSObjects
{
-class CDX7AllocatorPresenter
- : public ISubPicAllocatorPresenterImpl
-{
-protected:
- CSize m_ScreenSize;
-
- CComPtr<IDirectDraw7> m_pDD;
- CComQIPtr<IDirect3D7, &IID_IDirect3D7> m_pD3D;
- CComPtr<IDirect3DDevice7> m_pD3DDev;
-
- CComPtr<IDirectDrawSurface7> m_pPrimary, m_pBackBuffer;
- CComPtr<IDirectDrawSurface7> m_pVideoTexture, m_pVideoSurface;
-
- virtual HRESULT CreateDevice();
- virtual HRESULT AllocSurfaces();
- virtual void DeleteSurfaces();
-
-public:
- CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
-};
-
-class CVMR7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IVMRSurfaceAllocator
- , public IVMRImagePresenter
- , public IVMRWindowlessControl
-{
- CComPtr<IVMRSurfaceAllocatorNotify> m_pIVMRSurfAllocNotify;
- CComPtr<IVMRSurfaceAllocator> m_pSA;
-
- HRESULT CreateDevice();
- void DeleteSurfaces();
-
- bool m_fUseInternalTimer;
-
-public:
- CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
-
- // IVMRSurfaceAllocator
- STDMETHODIMP AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface);
- STDMETHODIMP FreeSurface(DWORD_PTR dwUserID);
- STDMETHODIMP PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags);
- STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify);
-
- // IVMRImagePresenter
- STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo);
-
- // IVMRWindowlessControl
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
- STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
- STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
- STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
- STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
- STDMETHODIMP DisplayModeChanged();
- STDMETHODIMP GetCurrentImage(BYTE** lpDib);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF* lpClr);
- STDMETHODIMP SetColorKey(COLORREF Clr);
- STDMETHODIMP GetColorKey(COLORREF* lpClr);
-};
-
-class CRM7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IRMAVideoSurface
-{
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceYUY2;
-
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
-
-protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
-
-public:
- CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IRMAVideoSurface
- STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
-};
-
-class CQT7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IQTVideoSurface
-{
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
-
-protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
-
-public:
- CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IQTVideoSurface
- STDMETHODIMP BeginBlt(const BITMAP& bm);
- STDMETHODIMP DoBlt(const BITMAP& bm);
-};
+ class CDX7AllocatorPresenter
+ : public ISubPicAllocatorPresenterImpl
+ {
+ protected:
+ CSize m_ScreenSize;
+
+ CComPtr<IDirectDraw7> m_pDD;
+ CComQIPtr<IDirect3D7, &IID_IDirect3D7> m_pD3D;
+ CComPtr<IDirect3DDevice7> m_pD3DDev;
+
+ CComPtr<IDirectDrawSurface7> m_pPrimary, m_pBackBuffer;
+ CComPtr<IDirectDrawSurface7> m_pVideoTexture, m_pVideoSurface;
+
+ virtual HRESULT CreateDevice();
+ virtual HRESULT AllocSurfaces();
+ virtual void DeleteSurfaces();
+
+ public:
+ CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ };
+
+ class CVMR7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IVMRSurfaceAllocator
+ , public IVMRImagePresenter
+ , public IVMRWindowlessControl
+ {
+ CComPtr<IVMRSurfaceAllocatorNotify> m_pIVMRSurfAllocNotify;
+ CComPtr<IVMRSurfaceAllocator> m_pSA;
+
+ HRESULT CreateDevice();
+ void DeleteSurfaces();
+
+ bool m_fUseInternalTimer;
+
+ public:
+ CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
+
+ // IVMRSurfaceAllocator
+ STDMETHODIMP AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface);
+ STDMETHODIMP FreeSurface(DWORD_PTR dwUserID);
+ STDMETHODIMP PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags);
+ STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify);
+
+ // IVMRImagePresenter
+ STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo);
+
+ // IVMRWindowlessControl
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
+ STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
+ STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
+ STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
+ STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
+ STDMETHODIMP DisplayModeChanged();
+ STDMETHODIMP GetCurrentImage(BYTE** lpDib);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF* lpClr);
+ STDMETHODIMP SetColorKey(COLORREF Clr);
+ STDMETHODIMP GetColorKey(COLORREF* lpClr);
+ };
+
+ class CRM7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IRMAVideoSurface
+ {
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceYUY2;
+
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
+
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
+
+ public:
+ CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IRMAVideoSurface
+ STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ };
+
+ class CQT7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IQTVideoSurface
+ {
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
+
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
+
+ public:
+ CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IQTVideoSurface
+ STDMETHODIMP BeginBlt(const BITMAP& bm);
+ STDMETHODIMP DoBlt(const BITMAP& bm);
+ };
}
using namespace DSObjects;
@@ -188,456 +188,427 @@ using namespace DSObjects;
HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
{
- CheckPointer(ppAP, E_POINTER);
+ CheckPointer(ppAP, E_POINTER);
- *ppAP = NULL;
+ *ppAP = NULL;
- HRESULT hr;
- if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = DNew CRM7AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr)))
- return E_OUTOFMEMORY;
+ HRESULT hr;
+ if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr))
+ || clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = DNew CRM7AllocatorPresenter(hWnd, hr))
+ || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr)))
+ return E_OUTOFMEMORY;
- if(*ppAP == NULL)
- return E_FAIL;
+ if(*ppAP == NULL)
+ return E_FAIL;
- (*ppAP)->AddRef();
+ (*ppAP)->AddRef();
- if(FAILED(hr))
- {
- (*ppAP)->Release();
- *ppAP = NULL;
- }
+ if(FAILED(hr))
+ {
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ }
- return hr;
+ return hr;
}
//
static HRESULT TextureBlt(CComPtr<IDirect3DDevice7> pD3DDev, CComPtr<IDirectDrawSurface7> pTexture, Vector dst[4], CRect src)
{
- if(!pTexture)
- return E_POINTER;
+ if(!pTexture)
+ return E_POINTER;
- HRESULT hr;
+ HRESULT hr;
do
- {
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if(FAILED(hr = pTexture->GetSurfaceDesc(&ddsd)))
- break;
-
- float w = (float)ddsd.dwWidth;
- float h = (float)ddsd.dwHeight;
-
- struct
- {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] =
- {
- {(float)dst[0].x, (float)dst[0].y, (float)dst[0].z, 1.0f / (float)dst[0].z, (float)src.left / w, (float)src.top / h},
- {(float)dst[1].x, (float)dst[1].y, (float)dst[1].z, 1.0f / (float)dst[1].z, (float)src.right / w, (float)src.top / h},
- {(float)dst[2].x, (float)dst[2].y, (float)dst[2].z, 1.0f / (float)dst[2].z, (float)src.left / w, (float)src.bottom / h},
- {(float)dst[3].x, (float)dst[3].y, (float)dst[3].z, 1.0f / (float)dst[3].z, (float)src.right / w, (float)src.bottom / h},
- };
-
- for(int i = 0; i < countof(pVertices); i++)
- {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
-
- hr = pD3DDev->SetTexture(0, pTexture);
-
- pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, FALSE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
-
- pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
-
- pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
-
- //
-
- if(FAILED(hr = pD3DDev->BeginScene()))
- break;
-
- hr = pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
- D3DFVF_XYZRHW | D3DFVF_TEX1,
- pVertices, 4, D3DDP_WAIT);
- pD3DDev->EndScene();
+ {
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if(FAILED(hr = pTexture->GetSurfaceDesc(&ddsd)))
+ break;
+
+ float w = (float)ddsd.dwWidth;
+ float h = (float)ddsd.dwHeight;
+
+ struct
+ {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] =
+ {
+ {(float)dst[0].x, (float)dst[0].y, (float)dst[0].z, 1.0f/(float)dst[0].z, (float)src.left / w, (float)src.top / h},
+ {(float)dst[1].x, (float)dst[1].y, (float)dst[1].z, 1.0f/(float)dst[1].z, (float)src.right / w, (float)src.top / h},
+ {(float)dst[2].x, (float)dst[2].y, (float)dst[2].z, 1.0f/(float)dst[2].z, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst[3].x, (float)dst[3].y, (float)dst[3].z, 1.0f/(float)dst[3].z, (float)src.right / w, (float)src.bottom / h},
+ };
+
+ for(int i = 0; i < countof(pVertices); i++)
+ {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+
+ hr = pD3DDev->SetTexture(0, pTexture);
+
+ pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
+
+ pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
+
+ pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
+
+ //
+
+ if(FAILED(hr = pD3DDev->BeginScene()))
+ break;
+
+ hr = pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZRHW | D3DFVF_TEX1,
+ pVertices, 4, D3DDP_WAIT);
+ pD3DDev->EndScene();
//
- pD3DDev->SetTexture(0, NULL);
+ pD3DDev->SetTexture(0, NULL);
- return S_OK;
- }
- while(0);
+ return S_OK;
+ }
+ while(0);
- return E_FAIL;
+ return E_FAIL;
}
//
// CDX7AllocatorPresenter
//
-CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : ISubPicAllocatorPresenterImpl(hWnd, hr, NULL)
- , m_ScreenSize(0, 0)
+CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr)
+ : ISubPicAllocatorPresenterImpl(hWnd, hr, NULL)
+ , m_ScreenSize(0, 0)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) return;
- if(FAILED(hr = DirectDrawCreateEx(NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL))
- || FAILED(hr = m_pDD->SetCooperativeLevel(AfxGetMainWnd()->GetSafeHwnd(), DDSCL_NORMAL)))
- return;
+ if(FAILED(hr = DirectDrawCreateEx(NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL))
+ || FAILED(hr = m_pDD->SetCooperativeLevel(AfxGetMainWnd()->GetSafeHwnd(), DDSCL_NORMAL)))
+ return;
- if(!(m_pD3D = m_pDD))
- {
- hr = E_NOINTERFACE;
- return;
- }
+ if(!(m_pD3D = m_pDD)) {hr = E_NOINTERFACE; return;}
- hr = CreateDevice();
+ hr = CreateDevice();
}
HRESULT CDX7AllocatorPresenter::CreateDevice()
{
- m_pD3DDev = NULL;
-
- m_pPrimary = NULL;
- m_pBackBuffer = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if(FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
- ddsd.ddpfPixelFormat.dwRGBBitCount <= 8)
- return DDERR_INVALIDMODE;
-
- m_ScreenSize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
-
- HRESULT hr;
-
- // m_pPrimary
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL)))
- return hr;
-
- CComPtr<IDirectDrawClipper> pcClipper;
- if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)))
- return hr;
- pcClipper->SetHWnd(0, m_hWnd);
- m_pPrimary->SetClipper(pcClipper);
-
- // m_pBackBuffer
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = /*DDSCAPS_OFFSCREENPLAIN |*/ DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE;
- ddsd.dwWidth = m_ScreenSize.cx;
- ddsd.dwHeight = m_ScreenSize.cy;
- if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL)))
- return hr;
-
- pcClipper = NULL;
- if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)))
- return hr;
- BYTE rgnDataBuffer[1024];
- HRGN hrgn = CreateRectRgn(0, 0, ddsd.dwWidth, ddsd.dwHeight);
- GetRegionData(hrgn, sizeof(rgnDataBuffer), (RGNDATA*)rgnDataBuffer);
- DeleteObject(hrgn);
- pcClipper->SetClipList((RGNDATA*)rgnDataBuffer, 0);
- m_pBackBuffer->SetClipper(pcClipper);
-
- // m_pD3DDev
-
- if(FAILED(hr = m_pD3D->CreateDevice(IID_IDirect3DHALDevice, m_pBackBuffer, &m_pD3DDev))) // this seems to fail if the desktop size is too large (width or height >2048)
- return hr;
-
- //
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
-
- CSize size;
- switch(AfxGetAppSettings().nSPCMaxRes)
- {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if(m_pAllocator)
- {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- }
- else
- {
- m_pAllocator = DNew CDX7SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
- if(!m_pAllocator || FAILED(hr))
- return E_FAIL;
- }
-
- hr = S_OK;
- m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr))
- return E_FAIL;
-
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
-
- return S_OK;
+ m_pD3DDev = NULL;
+
+ m_pPrimary = NULL;
+ m_pBackBuffer = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if(FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
+ ddsd.ddpfPixelFormat.dwRGBBitCount <= 8)
+ return DDERR_INVALIDMODE;
+
+ m_ScreenSize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
+
+ HRESULT hr;
+
+ // m_pPrimary
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+ if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL)))
+ return hr;
+
+ CComPtr<IDirectDrawClipper> pcClipper;
+ if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)))
+ return hr;
+ pcClipper->SetHWnd(0, m_hWnd);
+ m_pPrimary->SetClipper(pcClipper);
+
+ // m_pBackBuffer
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ ddsd.ddsCaps.dwCaps = /*DDSCAPS_OFFSCREENPLAIN |*/ DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE;
+ ddsd.dwWidth = m_ScreenSize.cx;
+ ddsd.dwHeight = m_ScreenSize.cy;
+ if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL)))
+ return hr;
+
+ pcClipper = NULL;
+ if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)))
+ return hr;
+ BYTE rgnDataBuffer[1024];
+ HRGN hrgn = CreateRectRgn(0, 0, ddsd.dwWidth, ddsd.dwHeight);
+ GetRegionData(hrgn, sizeof(rgnDataBuffer), (RGNDATA*)rgnDataBuffer);
+ DeleteObject(hrgn);
+ pcClipper->SetClipList((RGNDATA*)rgnDataBuffer, 0);
+ m_pBackBuffer->SetClipper(pcClipper);
+
+ // m_pD3DDev
+
+ if(FAILED(hr = m_pD3D->CreateDevice(IID_IDirect3DHALDevice, m_pBackBuffer, &m_pD3DDev))) // this seems to fail if the desktop size is too large (width or height >2048)
+ return hr;
+
+ //
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+
+ CSize size;
+ switch(AfxGetAppSettings().nSPCMaxRes)
+ {
+ case 0: default: size = m_ScreenSize; break;
+ case 1: size.SetSize(1024, 768); break;
+ case 2: size.SetSize(800, 600); break;
+ case 3: size.SetSize(640, 480); break;
+ case 4: size.SetSize(512, 384); break;
+ case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
+ }
+
+ if(m_pAllocator)
+ {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ }
+ else
+ {
+ m_pAllocator = DNew CDX7SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ if(!m_pAllocator || FAILED(hr))
+ return E_FAIL;
+ }
+
+ hr = S_OK;
+ m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if(!m_pSubPicQueue || FAILED(hr))
+ return E_FAIL;
+
+ if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+
+ return S_OK;
}
HRESULT CDX7AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_pVideoTexture = NULL;
- m_pVideoSurface = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- {
- ddsd.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
+ CAutoLock cAutoLock(this);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_pVideoTexture = NULL;
+ m_pVideoSurface = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ {
+ ddsd.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
// ddsd.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS;
// ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- }
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
- if(FAILED(hr))
- {
- // FIXME: eh, dx9 has no problem creating a 32bpp surface under a 16bpp desktop, but dx7 fails here (textures are ok)
- DDSURFACEDESC2 ddsd2;
- INITDDSTRUCT(ddsd2);
- if(!(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- && SUCCEEDED(m_pDD->GetDisplayMode(&ddsd2))
- && ddsd2.ddpfPixelFormat.dwRGBBitCount == 16)
- {
- ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x0000F800;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x000007E0;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x0000001F;
- hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
- }
-
- if(FAILED(hr))
- return hr;
- }
-
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- m_pVideoTexture = m_pVideoSurface;
-
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- hr = m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-
- return S_OK;
+ }
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
+ if(FAILED(hr))
+ {
+ // FIXME: eh, dx9 has no problem creating a 32bpp surface under a 16bpp desktop, but dx7 fails here (textures are ok)
+ DDSURFACEDESC2 ddsd2;
+ INITDDSTRUCT(ddsd2);
+ if(!(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ && SUCCEEDED(m_pDD->GetDisplayMode(&ddsd2))
+ && ddsd2.ddpfPixelFormat.dwRGBBitCount == 16)
+ {
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x0000F800;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x000007E0;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x0000001F;
+ hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
+ }
+
+ if(FAILED(hr))
+ return hr;
+ }
+
+ if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ m_pVideoTexture = m_pVideoSurface;
+
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ hr = m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ return S_OK;
}
void CDX7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pVideoTexture = NULL;
- m_pVideoSurface = NULL;
+ m_pVideoTexture = NULL;
+ m_pVideoSurface = NULL;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CDX7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
- || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
- || !m_pPrimary || !m_pBackBuffer || !m_pVideoSurface)
- return(false);
+ if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
+ || !m_pPrimary || !m_pBackBuffer || !m_pVideoSurface)
+ return(false);
- HRESULT hr;
+ HRESULT hr;
- CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
- CRect rDstVid(m_VideoRect);
+ CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
+ CRect rDstVid(m_VideoRect);
- CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
- CRect rDstPri(m_WindowRect);
- MapWindowRect(m_hWnd, HWND_DESKTOP, &rDstPri);
+ CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
+ CRect rDstPri(m_WindowRect);
+ MapWindowRect(m_hWnd, HWND_DESKTOP, &rDstPri);
- if(fAll)
- {
- // clear the backbuffer
+ if(fAll)
+ {
+ // clear the backbuffer
- CRect rl(0, 0, rDstVid.left, rSrcPri.bottom);
- CRect rr(rDstVid.right, 0, rSrcPri.right, rSrcPri.bottom);
- CRect rt(0, 0, rSrcPri.right, rDstVid.top);
- CRect rb(0, rDstVid.bottom, rSrcPri.right, rSrcPri.bottom);
+ CRect rl(0, 0, rDstVid.left, rSrcPri.bottom);
+ CRect rr(rDstVid.right, 0, rSrcPri.right, rSrcPri.bottom);
+ CRect rt(0, 0, rSrcPri.right, rDstVid.top);
+ CRect rb(0, rDstVid.bottom, rSrcPri.right, rSrcPri.bottom);
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- hr = m_pBackBuffer->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ hr = m_pBackBuffer->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
- // paint the video on the backbuffer
+ // paint the video on the backbuffer
- if(!rDstVid.IsRectEmpty())
- {
- if(m_pVideoTexture)
- {
- Vector v[4];
- Transform(rDstVid, v);
- hr = TextureBlt(m_pD3DDev, m_pVideoTexture, v, rSrcVid);
- }
- else
- {
- hr = m_pBackBuffer->Blt(rDstVid, m_pVideoSurface, rSrcVid, DDBLT_WAIT, NULL);
- }
- }
+ if(!rDstVid.IsRectEmpty())
+ {
+ if(m_pVideoTexture)
+ {
+ Vector v[4];
+ Transform(rDstVid, v);
+ hr = TextureBlt(m_pD3DDev, m_pVideoTexture, v, rSrcVid);
+ }
+ else
+ {
+ hr = m_pBackBuffer->Blt(rDstVid, m_pVideoSurface, rSrcVid, DDBLT_WAIT, NULL);
+ }
+ }
- // paint the text on the backbuffer
+ // paint the text on the backbuffer
- AlphaBltSubPic(rSrcPri.Size());
- }
+ AlphaBltSubPic(rSrcPri.Size());
+ }
- // wait vsync
+ // wait vsync
- m_pDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
+ m_pDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
- // blt to the primary surface
+ // blt to the primary surface
- hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
+ hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
- if(hr == DDERR_SURFACELOST)
- {
- HRESULT hr = DDERR_WRONGMODE; // m_pDD->TestCooperativeLevel();
+ if(hr == DDERR_SURFACELOST)
+ {
+ HRESULT hr = DDERR_WRONGMODE; // m_pDD->TestCooperativeLevel();
- if(hr == DDERR_WRONGMODE)
- {
- DeleteSurfaces();
- if(SUCCEEDED(CreateDevice()) || FAILED(hr = AllocSurfaces()))
- return(true);
- }
+ if(hr == DDERR_WRONGMODE)
+ {
+ DeleteSurfaces();
+ if(SUCCEEDED(CreateDevice()) || FAILED(hr = AllocSurfaces()))
+ return(true);
+ }
- hr = S_OK;
- }
+ hr = S_OK;
+ }
- return(true);
+ return(true);
}
STDMETHODIMP CDX7AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- CheckPointer(size, E_POINTER);
-
- HRESULT hr;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if(FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd)))
- return E_FAIL;
-
- if(ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32)
- return E_FAIL;
-
- DWORD required = sizeof(BITMAPINFOHEADER) + (ddsd.dwWidth * ddsd.dwHeight * 32 >> 3);
- if(!lpDib)
- {
- *size = required;
- return S_OK;
- }
- if(*size < required) return E_OUTOFMEMORY;
- *size = required;
-
- INITDDSTRUCT(ddsd);
- if(FAILED(hr = m_pVideoSurface->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_READONLY | DDLOCK_NOSYSLOCK, NULL)))
- {
- // TODO
- return hr;
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = ddsd.dwWidth;
- bih->biHeight = ddsd.dwHeight;
- bih->biBitCount = 32;
- bih->biPlanes = 1;
- bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
-
- BitBltFromRGBToRGB(
- bih->biWidth, bih->biHeight,
- (BYTE*)(bih + 1), bih->biWidth * bih->biBitCount >> 3, bih->biBitCount,
- (BYTE*)ddsd.lpSurface + ddsd.lPitch*(ddsd.dwHeight - 1), -(int)ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount);
-
- m_pVideoSurface->Unlock(NULL);
-
- /*
- BitBltFromRGBToRGB(
- w, h,
- (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
- (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
- m_pVideoSurfaceOff->Unlock(NULL);
- fOk = true;
- }
- */
-
- return S_OK;
+ CheckPointer(size, E_POINTER);
+
+ HRESULT hr;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if(FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd)))
+ return E_FAIL;
+
+ if(ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32)
+ return E_FAIL;
+
+ DWORD required = sizeof(BITMAPINFOHEADER) + (ddsd.dwWidth*ddsd.dwHeight*32>>3);
+ if(!lpDib) {*size = required; return S_OK;}
+ if(*size < required) return E_OUTOFMEMORY;
+ *size = required;
+
+ INITDDSTRUCT(ddsd);
+ if(FAILED(hr = m_pVideoSurface->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_READONLY|DDLOCK_NOSYSLOCK, NULL)))
+ {
+ // TODO
+ return hr;
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = ddsd.dwWidth;
+ bih->biHeight = ddsd.dwHeight;
+ bih->biBitCount = 32;
+ bih->biPlanes = 1;
+ bih->biSizeImage = bih->biWidth*bih->biHeight*bih->biBitCount>>3;
+
+ BitBltFromRGBToRGB(
+ bih->biWidth, bih->biHeight,
+ (BYTE*)(bih + 1), bih->biWidth*bih->biBitCount>>3, bih->biBitCount,
+ (BYTE*)ddsd.lpSurface + ddsd.lPitch*(ddsd.dwHeight-1), -(int)ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount);
+
+ m_pVideoSurface->Unlock(NULL);
+
+/*
+ BitBltFromRGBToRGB(
+ w, h,
+ (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
+ (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
+ m_pVideoSurfaceOff->Unlock(NULL);
+ fOk = true;
+ }
+*/
+
+ return S_OK;
}
//
@@ -646,103 +617,103 @@ STDMETHODIMP CDX7AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
#define MY_USER_ID 0x6ABE51
-CVMR7AllocatorPresenter::CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
- , m_fUseInternalTimer(false)
+CVMR7AllocatorPresenter::CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr)
+ : CDX7AllocatorPresenter(hWnd, hr)
+ , m_fUseInternalTimer(false)
{
- if(FAILED(hr))
- return;
-
- if(FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter)))
- {
- hr = E_FAIL;
- return;
- }
+ if(FAILED(hr))
+ return;
+
+ if(FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter)))
+ {
+ hr = E_FAIL;
+ return;
+ }
}
STDMETHODIMP CVMR7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IVMRSurfaceAllocator)
- QI(IVMRImagePresenter)
- QI(IVMRWindowlessControl)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IVMRSurfaceAllocator)
+ QI(IVMRImagePresenter)
+ QI(IVMRWindowlessControl)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CVMR7AllocatorPresenter::CreateDevice()
{
- HRESULT hr = __super::CreateDevice();
- if(FAILED(hr)) return hr;
+ HRESULT hr = __super::CreateDevice();
+ if(FAILED(hr)) return hr;
- if(m_pIVMRSurfAllocNotify)
- {
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor)))
- return(false);
- }
+ if(m_pIVMRSurfAllocNotify)
+ {
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor)))
+ return(false);
+ }
- return hr;
+ return hr;
}
void CVMR7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pSA->FreeSurface(MY_USER_ID);
+ m_pSA->FreeSurface(MY_USER_ID);
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// ISubPicAllocatorPresenter
STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
+ CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
+ *ppRenderer = NULL;
- HRESULT hr;
+ HRESULT hr;
- do
- {
- CComPtr<IBaseFilter> pBF;
+ do
+ {
+ CComPtr<IBaseFilter> pBF;
- if(FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer)))
- break;
+ if(FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer)))
+ break;
- CComQIPtr<IVMRFilterConfig> pConfig = pBF;
- if(!pConfig)
- break;
+ CComQIPtr<IVMRFilterConfig> pConfig = pBF;
+ if(!pConfig)
+ break;
- if(FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless)))
- break;
+ if(FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless)))
+ break;
- CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
- if(!pSAN)
- break;
+ CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
+ if(!pSAN)
+ break;
- if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
- || FAILED(hr = AdviseNotify(pSAN)))
- break;
+ if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
+ || FAILED(hr = AdviseNotify(pSAN)))
+ break;
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- *ppRenderer = (IUnknown*)pBF.Detach();
+ *ppRenderer = (IUnknown*)pBF.Detach();
- return S_OK;
- }
- while(0);
+ return S_OK;
+ }
+ while(0);
- return E_FAIL;
+ return E_FAIL;
}
STDMETHODIMP_(void) CVMR7AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
{
- __super::SetTime(rtNow);
+ __super::SetTime(rtNow);
// m_fUseInternalTimer = false;
}
@@ -750,99 +721,99 @@ STDMETHODIMP_(void) CVMR7AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface)
{
- if(!lpAllocInfo || !lpdwBuffer || !lplpSurface)
- return E_POINTER;
+ if(!lpAllocInfo || !lpdwBuffer || !lplpSurface)
+ return E_POINTER;
- if(!m_pIVMRSurfAllocNotify)
- return E_FAIL;
+ if(!m_pIVMRSurfAllocNotify)
+ return E_FAIL;
- HRESULT hr;
+ HRESULT hr;
- DeleteSurfaces();
+ DeleteSurfaces();
- // HACK: yv12 will fail to blt onto the backbuffer anyway, but if we first
- // allocate it and then let our FreeSurface callback call m_pSA->FreeSurface,
- // then that might stall for about 30 seconds because of some unknown buggy code
- // behind <ddraw surface>->Release()
+ // HACK: yv12 will fail to blt onto the backbuffer anyway, but if we first
+ // allocate it and then let our FreeSurface callback call m_pSA->FreeSurface,
+ // then that might stall for about 30 seconds because of some unknown buggy code
+ // behind <ddraw surface>->Release()
- if(lpAllocInfo->lpHdr->biBitCount < 16)
- return E_FAIL;
+ if(lpAllocInfo->lpHdr->biBitCount < 16)
+ return E_FAIL;
- hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
- if(FAILED(hr))
- return hr;
+ hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
+ if(FAILED(hr))
+ return hr;
- m_NativeVideoSize = CSize(abs(lpAllocInfo->lpHdr->biWidth), abs(lpAllocInfo->lpHdr->biHeight));
- m_AspectRatio = m_NativeVideoSize;
- int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) m_AspectRatio.SetSize(arx, ary);
+ m_NativeVideoSize = CSize(abs(lpAllocInfo->lpHdr->biWidth), abs(lpAllocInfo->lpHdr->biHeight));
+ m_AspectRatio = m_NativeVideoSize;
+ int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
+ if(arx > 0 && ary > 0) m_AspectRatio.SetSize(arx, ary);
- if(FAILED(hr = AllocSurfaces()))
- return hr;
+ if(FAILED(hr = AllocSurfaces()))
+ return hr;
- // test if the colorspace is acceptable
- if(FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL)))
- {
- DeleteSurfaces();
- return hr;
- }
+ // test if the colorspace is acceptable
+ if(FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL)))
+ {
+ DeleteSurfaces();
+ return hr;
+ }
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
- return hr;
+ return hr;
}
STDMETHODIMP CVMR7AllocatorPresenter::FreeSurface(DWORD_PTR dwUserID)
{
- DeleteSurfaces();
- return S_OK;
+ DeleteSurfaces();
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags)
{
- if(!lpSurface)
- return E_POINTER;
-
- // FIXME: sometimes the msmpeg4/divx3/wmv decoder wants to reuse our
- // surface (expects it to point to the same mem every time), and to avoid
- // problems we can't call m_pSA->PrepareSurface (flips? clears?).
- return S_OK;
- /*
- return m_pSA->PrepareSurface(dwUserID, lpSurface, dwSurfaceFlags);
- */
+ if(!lpSurface)
+ return E_POINTER;
+
+ // FIXME: sometimes the msmpeg4/divx3/wmv decoder wants to reuse our
+ // surface (expects it to point to the same mem every time), and to avoid
+ // problems we can't call m_pSA->PrepareSurface (flips? clears?).
+ return S_OK;
+/*
+ return m_pSA->PrepareSurface(dwUserID, lpSurface, dwSurfaceFlags);
+*/
}
STDMETHODIMP CVMR7AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
+ m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
- HRESULT hr;
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor)))
- return hr;
+ HRESULT hr;
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor)))
+ return hr;
- return m_pSA->AdviseNotify(lpIVMRSurfAllocNotify);
+ return m_pSA->AdviseNotify(lpIVMRSurfAllocNotify);
}
// IVMRImagePresenter
STDMETHODIMP CVMR7AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- ASSERT(m_pD3DDev);
+ ASSERT(m_pD3DDev);
- return m_pD3DDev ? S_OK : E_FAIL;
+ return m_pD3DDev ? S_OK : E_FAIL;
}
STDMETHODIMP CVMR7AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
{
- return S_OK;
+ return S_OK;
}
extern bool g_bNoDuration;
@@ -850,541 +821,504 @@ extern bool g_bExternalSubtitleTime;
STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo)
{
- if(!lpPresInfo || !lpPresInfo->lpSurf)
- return E_POINTER;
+ if(!lpPresInfo || !lpPresInfo->lpSurf)
+ return E_POINTER;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
+ m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
- {
- REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
- m_fps = 10000000.0 / rtTimePerFrame;
+ if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
+ {
+ REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
+ m_fps = 10000000.0 / rtTimePerFrame;
- if(m_pSubPicQueue)
- {
- m_pSubPicQueue->SetFPS(m_fps);
+ if(m_pSubPicQueue)
+ {
+ m_pSubPicQueue->SetFPS(m_fps);
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
- {
- __super::SetTime(g_tSegmentStart + g_tSampleStart);
- }
- }
- }
+ if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
+ {
+ __super::SetTime(g_tSegmentStart + g_tSampleStart);
+ }
+ }
+ }
- CSize VideoSize = m_NativeVideoSize;
- int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) VideoSize.cx = VideoSize.cy * arx / ary;
- if(VideoSize != GetVideoSize())
- {
- m_AspectRatio.SetSize(arx, ary);
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
+ CSize VideoSize = m_NativeVideoSize;
+ int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
+ if(arx > 0 && ary > 0) VideoSize.cx = VideoSize.cy*arx/ary;
+ if(VideoSize != GetVideoSize())
+ {
+ m_AspectRatio.SetSize(arx, ary);
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
- Paint(true);
+ Paint(true);
- return S_OK;
+ return S_OK;
}
// IVMRWindowlessControl
//
-// It is only implemented (partially) for the dvd navigator's
-// menu handling, which needs to know a few things about the
+// It is only implemented (partially) for the dvd navigator's
+// menu handling, which needs to know a few things about the
// location of our window.
STDMETHODIMP CVMR7AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- CSize vs = m_NativeVideoSize, ar = m_AspectRatio;
- // DVD Nav. bug workaround fix
- vs.cx = vs.cy * ar.cx / ar.cy;
- if(lpWidth) *lpWidth = vs.cx;
- if(lpHeight) *lpHeight = vs.cy;
- if(lpARWidth) *lpARWidth = ar.cx;
- if(lpARHeight) *lpARHeight = ar.cy;
- return S_OK;
+ CSize vs = m_NativeVideoSize, ar = m_AspectRatio;
+ // DVD Nav. bug workaround fix
+ vs.cx = vs.cy * ar.cx / ar.cy;
+ if(lpWidth) *lpWidth = vs.cx;
+ if(lpHeight) *lpHeight = vs.cy;
+ if(lpARWidth) *lpARWidth = ar.cx;
+ if(lpARHeight) *lpARHeight = ar.cy;
+ return S_OK;
}
-STDMETHODIMP CVMR7AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect)
-{
- return E_NOTIMPL; // we have our own method for this
-}
+STDMETHODIMP CVMR7AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect) {return E_NOTIMPL;} // we have our own method for this
STDMETHODIMP CVMR7AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
{
- CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
- CopyRect(lpDSTRect, &m_VideoRect);
- // DVD Nav. bug workaround fix
- GetNativeVideoSize(&lpSRCRect->right, &lpSRCRect->bottom, NULL, NULL);
- return S_OK;
+ CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
+ CopyRect(lpDSTRect, &m_VideoRect);
+ // DVD Nav. bug workaround fix
+ GetNativeVideoSize(&lpSRCRect->right, &lpSRCRect->bottom, NULL, NULL);
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
- return S_OK;
+ if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ return S_OK;
}
-STDMETHODIMP CVMR7AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::SetVideoClippingWindow(HWND hwnd)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::DisplayModeChanged()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::GetCurrentImage(BYTE** lpDib)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::SetBorderColor(COLORREF Clr)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CVMR7AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode) {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::SetVideoClippingWindow(HWND hwnd) {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc) {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::DisplayModeChanged() {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::GetCurrentImage(BYTE** lpDib) {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::SetBorderColor(COLORREF Clr) {return E_NOTIMPL;}
STDMETHODIMP CVMR7AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if(lpClr) *lpClr = 0;
- return S_OK;
+ if(lpClr) *lpClr = 0;
+ return S_OK;
}
-STDMETHODIMP CVMR7AllocatorPresenter::SetColorKey(COLORREF Clr)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::GetColorKey(COLORREF* lpClr)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CVMR7AllocatorPresenter::SetColorKey(COLORREF Clr) {return E_NOTIMPL;}
+STDMETHODIMP CVMR7AllocatorPresenter::GetColorKey(COLORREF* lpClr) {return E_NOTIMPL;}
//
static HRESULT AllocDX7Surface(IDirectDraw7* pDD, CSize size, DWORD compression, int bpp, IDirectDrawSurface7** pSurface)
{
- if(!pDD || !pSurface || size.cx <= 0 || size.cy <= 0)
- return E_POINTER;
-
- *pSurface = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
- ddsd.dwWidth = size.cx;
- ddsd.dwHeight = size.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
-
- if(compression >= 0x1000)
- {
- ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
- ddsd.ddpfPixelFormat.dwFourCC = compression;
- }
- else if((compression == 0 || compression == 3) && (bpp == 15 || bpp == 16 || bpp == 24 || bpp == 32))
- {
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = max(bpp, 16);
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = (bpp == 16) ? 0x0000 : (bpp == 15) ? 0x8000 : 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = (bpp == 16) ? 0xf800 : (bpp == 15) ? 0x7c00 : 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = (bpp == 16) ? 0x07e0 : (bpp == 15) ? 0x03e0 : 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = (bpp == 16) ? 0x001F : (bpp == 15) ? 0x001F : 0x000000FF;
- }
-
- return pDD->CreateSurface(&ddsd, pSurface, NULL);
+ if(!pDD || !pSurface || size.cx <= 0 || size.cy <= 0)
+ return E_POINTER;
+
+ *pSurface = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY;
+ ddsd.dwWidth = size.cx;
+ ddsd.dwHeight = size.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+
+ if(compression >= 0x1000)
+ {
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
+ ddsd.ddpfPixelFormat.dwFourCC = compression;
+ }
+ else if((compression == 0 || compression == 3) && (bpp == 15 || bpp == 16 || bpp == 24 || bpp == 32))
+ {
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = max(bpp, 16);
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = (bpp == 16) ? 0x0000 : (bpp == 15) ? 0x8000 : 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = (bpp == 16) ? 0xf800 : (bpp == 15) ? 0x7c00 : 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = (bpp == 16) ? 0x07e0 : (bpp == 15) ? 0x03e0 : 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = (bpp == 16) ? 0x001F : (bpp == 15) ? 0x001F : 0x000000FF;
+ }
+
+ return pDD->CreateSurface(&ddsd, pSurface, NULL);
}
//
// CRM7AllocatorPresenter
//
-CRM7AllocatorPresenter::CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
+CRM7AllocatorPresenter::CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr)
+ : CDX7AllocatorPresenter(hWnd, hr)
{
}
STDMETHODIMP CRM7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI2(IRMAVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMAVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CRM7AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
-
- DDSURFACEDESC2 ddsd;
- DDBLTFX fx;
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) return E_FAIL;
-
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
- ddsd.ddpfPixelFormat.dwYUVBitCount = 16;
- ddsd.ddpfPixelFormat.dwFourCC = '2YUY';
-
- hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
-
- if(FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL)))
- m_pVideoSurfaceYUY2 = NULL;
-
- if(m_pVideoSurfaceYUY2)
- {
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0x80108010;
- m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
- }
-
- return __super::AllocSurfaces();
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ DDBLTFX fx;
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
+ if(FAILED(hr)) return E_FAIL;
+
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
+ ddsd.ddpfPixelFormat.dwYUVBitCount = 16;
+ ddsd.ddpfPixelFormat.dwFourCC = '2YUY';
+
+ hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
+
+ if(FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL)))
+ m_pVideoSurfaceYUY2 = NULL;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0x80108010;
+ m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+ }
+
+ return __super::AllocSurfaces();
}
void CRM7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// IRMAVideoSurface
STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
- return E_FAIL;
-
- bool fRGB = false;
- bool fYUY2 = false;
-
- CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0, 0), src.Size());
- if(src.Width() > dst.Width() || src.Height() > dst.Height())
- return E_FAIL;
-
- DDSURFACEDESC2 ddsd;
-
- if(pBitmapInfo->biCompression == '024I')
- {
- DWORD pitch = pBitmapInfo->biWidth;
- DWORD size = pitch * abs(pBitmapInfo->biHeight);
-
- BYTE* y = pImageData + src.top * pitch + src.left;
- BYTE* u = pImageData + size + src.top * (pitch / 2) + src.left / 2;
- BYTE* v = pImageData + size + size / 4 + src.top * (pitch / 2) + src.left / 2;
-
- if(m_pVideoSurfaceYUY2)
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, y, u, v, pitch);
- m_pVideoSurfaceYUY2->Unlock(src2);
- fYUY2 = true;
- }
- }
- else
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, y, u, v, pitch);
- m_pVideoSurfaceOff->Unlock(src2);
- fRGB = true;
- }
- }
- }
- else if(pBitmapInfo->biCompression == '2YUY')
- {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth * 2;
-
- BYTE* yvyu = pImageData + src.top * pitch + src.left * 2;
-
- if(m_pVideoSurfaceYUY2)
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, yvyu, pitch);
- m_pVideoSurfaceYUY2->Unlock(src2);
- fYUY2 = true;
- }
- }
- else
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, yvyu, pitch);
- m_pVideoSurfaceOff->Unlock(src2);
- fRGB = true;
- }
- }
- }
- else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
- || pBitmapInfo->biCompression == 'BGRA')
- {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth * pBitmapInfo->biBitCount >> 3;
-
- BYTE* rgb = pImageData + src.top * pitch + src.left * (pBitmapInfo->biBitCount >> 3);
-
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
- {
- BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
- if(pBitmapInfo->biHeight > 0)
- {
- lpSurface += ddsd.lPitch * (src.Height() - 1);
- ddsd.lPitch = -ddsd.lPitch;
- }
- BitBltFromRGBToRGB(src.Width(), src.Height(), lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, rgb, pitch, pBitmapInfo->biBitCount);
- fRGB = true;
- m_pVideoSurfaceOff->Unlock(src2);
- }
- }
-
- if(!fRGB && !fYUY2)
- {
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-
- HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
-
- fRGB = true;
- }
- }
-
-
- HRESULT hr;
-
- if(fRGB)
- hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
- if(fYUY2)
- hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
-
- Paint(true);
-
- return PNR_OK;
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ return E_FAIL;
+
+ bool fRGB = false;
+ bool fYUY2 = false;
+
+ CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
+ if(src.Width() > dst.Width() || src.Height() > dst.Height())
+ return E_FAIL;
+
+ DDSURFACEDESC2 ddsd;
+
+ if(pBitmapInfo->biCompression == '024I')
+ {
+ DWORD pitch = pBitmapInfo->biWidth;
+ DWORD size = pitch*abs(pBitmapInfo->biHeight);
+
+ BYTE* y = pImageData + src.top*pitch + src.left;
+ BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
+ BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, y, u, v, pitch);
+ m_pVideoSurfaceYUY2->Unlock(src2);
+ fYUY2 = true;
+ }
+ }
+ else
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, y, u, v, pitch);
+ m_pVideoSurfaceOff->Unlock(src2);
+ fRGB = true;
+ }
+ }
+ }
+ else if(pBitmapInfo->biCompression == '2YUY')
+ {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth*2;
+
+ BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, yvyu, pitch);
+ m_pVideoSurfaceYUY2->Unlock(src2);
+ fYUY2 = true;
+ }
+ }
+ else
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, yvyu, pitch);
+ m_pVideoSurfaceOff->Unlock(src2);
+ fRGB = true;
+ }
+ }
+ }
+ else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
+ || pBitmapInfo->biCompression == 'BGRA')
+ {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
+
+ BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
+
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
+ if(pBitmapInfo->biHeight > 0) {lpSurface += ddsd.lPitch*(src.Height()-1); ddsd.lPitch = -ddsd.lPitch;}
+ BitBltFromRGBToRGB(src.Width(), src.Height(), lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, rgb, pitch, pBitmapInfo->biBitCount);
+ fRGB = true;
+ m_pVideoSurfaceOff->Unlock(src2);
+ }
+ }
+
+ if(!fRGB && !fYUY2)
+ {
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ HDC hDC;
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
+ {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+
+ fRGB = true;
+ }
+ }
+
+
+ HRESULT hr;
+
+ if(fRGB)
+ hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
+ if(fYUY2)
+ hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
+
+ Paint(true);
+
+ return PNR_OK;
}
STDMETHODIMP CRM7AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo)
{
- CAutoLock cAutoLock(this);
- DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if(FAILED(AllocSurfaces())) return E_FAIL;
- return PNR_NOTIMPL;
+ CAutoLock cAutoLock(this);
+ DeleteSurfaces();
+ m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
+ if(FAILED(AllocSurfaces())) return E_FAIL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::EndOptimizedBlt()
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- ulType = RMA_I420;
- return PNR_OK;
+ ulType = RMA_I420;
+ return PNR_OK;
}
//
// CQT7AllocatorPresenter
//
-CQT7AllocatorPresenter::CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
+CQT7AllocatorPresenter::CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr)
+ : CDX7AllocatorPresenter(hWnd, hr)
{
}
STDMETHODIMP CQT7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IQTVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IQTVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CQT7AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) return E_FAIL;
-
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-
- return __super::AllocSurfaces();
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
+ if(FAILED(hr)) return E_FAIL;
+
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ return __super::AllocSurfaces();
}
void CQT7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceOff = NULL;
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// IQTVideoSurface
STDMETHODIMP CQT7AllocatorPresenter::BeginBlt(const BITMAP& bm)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- DeleteSurfaces();
+ DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
+ m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
- HRESULT hr;
- if(FAILED(hr = AllocSurfaces()))
- return hr;
+ HRESULT hr;
+ if(FAILED(hr = AllocSurfaces()))
+ return hr;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
- return E_FAIL;
-
- bool fOk = false;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if(FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd)))
- return E_FAIL;
-
- int w = bm.bmWidth;
- int h = abs(bm.bmHeight);
- int bpp = bm.bmBitsPixel;
-
- if((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight)
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromRGBToRGB(
- w, h,
- (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
- (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
- m_pVideoSurfaceOff->Unlock(NULL);
- fOk = true;
- }
- }
-
- if(!fOk)
- {
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-
- HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
- }
- }
-
- m_pVideoSurface->Blt(NULL, m_pVideoSurfaceOff, NULL, DDBLT_WAIT, NULL);
-
- Paint(true);
-
- return S_OK;
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ return E_FAIL;
+
+ bool fOk = false;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if(FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd)))
+ return E_FAIL;
+
+ int w = bm.bmWidth;
+ int h = abs(bm.bmHeight);
+ int bpp = bm.bmBitsPixel;
+
+ if((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight)
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromRGBToRGB(
+ w, h,
+ (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
+ (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
+ m_pVideoSurfaceOff->Unlock(NULL);
+ fOk = true;
+ }
+ }
+
+ if(!fOk)
+ {
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ HDC hDC;
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
+ {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+ }
+ }
+
+ m_pVideoSurface->Blt(NULL, m_pVideoSurfaceOff, NULL, DDBLT_WAIT, NULL);
+
+ Paint(true);
+
+ return S_OK;
}
diff --git a/src/apps/mplayerc/DX7AllocatorPresenter.h b/src/apps/mplayerc/DX7AllocatorPresenter.h
index 504e50fe4..914a95cc2 100644
--- a/src/apps/mplayerc/DX7AllocatorPresenter.h
+++ b/src/apps/mplayerc/DX7AllocatorPresenter.h
@@ -27,16 +27,16 @@
// {495CF191-810D-44c7-92C5-E7D46AE00F44}
-DEFINE_GUID(CLSID_VMR7AllocatorPresenter,
- 0x495cf191, 0x810d, 0x44c7, 0x92, 0xc5, 0xe7, 0xd4, 0x6a, 0xe0, 0xf, 0x44);
+DEFINE_GUID(CLSID_VMR7AllocatorPresenter,
+0x495cf191, 0x810d, 0x44c7, 0x92, 0xc5, 0xe7, 0xd4, 0x6a, 0xe0, 0xf, 0x44);
// {97B3462E-1752-4dfb-A038-271060BC7A94}
-DEFINE_GUID(CLSID_RM7AllocatorPresenter,
- 0x97b3462e, 0x1752, 0x4dfb, 0xa0, 0x38, 0x27, 0x10, 0x60, 0xbc, 0x7a, 0x94);
+DEFINE_GUID(CLSID_RM7AllocatorPresenter,
+0x97b3462e, 0x1752, 0x4dfb, 0xa0, 0x38, 0x27, 0x10, 0x60, 0xbc, 0x7a, 0x94);
// {36CC5A71-441C-462a-9D10-48A19485938D}
-DEFINE_GUID(CLSID_QT7AllocatorPresenter,
- 0x36cc5a71, 0x441c, 0x462a, 0x9d, 0x10, 0x48, 0xa1, 0x94, 0x85, 0x93, 0x8d);
+DEFINE_GUID(CLSID_QT7AllocatorPresenter,
+0x36cc5a71, 0x441c, 0x462a, 0x9d, 0x10, 0x48, 0xa1, 0x94, 0x85, 0x93, 0x8d);
extern HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP);
diff --git a/src/apps/mplayerc/DX9AllocatorPresenter.cpp b/src/apps/mplayerc/DX9AllocatorPresenter.cpp
index 41fe95fc3..eb2978132 100644
--- a/src/apps/mplayerc/DX9AllocatorPresenter.cpp
+++ b/src/apps/mplayerc/DX9AllocatorPresenter.cpp
@@ -38,316 +38,288 @@ bool queue_ffdshow_support = false;
#pragma pack(push, 1)
template<int texcoords>
-struct MYD3DVERTEX
-{
- float x, y, z, rhw;
- struct
- {
- float u, v;
- } t[texcoords];
-};
+struct MYD3DVERTEX {float x, y, z, rhw; struct {float u, v;} t[texcoords];};
template<>
-struct MYD3DVERTEX<0>
+struct MYD3DVERTEX<0>
{
- float x, y, z, rhw;
- DWORD Diffuse;
+ float x, y, z, rhw;
+ DWORD Diffuse;
};
#pragma pack(pop)
template<int texcoords>
static void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
{
- double offset = 0.5;
-
- for(int i = 0; i < 4; i++)
- {
- v[i].x -= offset;
- v[i].y -= offset;
-
- for(int j = 0; j < max(texcoords - 1, 1); j++)
- {
- v[i].t[j].u -= offset * dx;
- v[i].t[j].v -= offset * dy;
- }
-
- if(texcoords > 1)
- {
- v[i].t[texcoords-1].u -= offset;
- v[i].t[texcoords-1].v -= offset;
- }
- }
+ double offset = 0.5;
+
+ for(int i = 0; i < 4; i++)
+ {
+ v[i].x -= offset;
+ v[i].y -= offset;
+
+ for(int j = 0; j < max(texcoords-1, 1); j++)
+ {
+ v[i].t[j].u -= offset*dx;
+ v[i].t[j].v -= offset*dy;
+ }
+
+ if(texcoords > 1)
+ {
+ v[i].t[texcoords-1].u -= offset;
+ v[i].t[texcoords-1].v -= offset;
+ }
+ }
}
template<int texcoords>
static HRESULT TextureBlt(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter = D3DTEXF_LINEAR)
{
- if(!pD3DDev)
- return E_POINTER;
-
- DWORD FVF = 0;
-
- switch(texcoords)
- {
- case 1:
- FVF = D3DFVF_TEX1;
- break;
- case 2:
- FVF = D3DFVF_TEX2;
- break;
- case 3:
- FVF = D3DFVF_TEX3;
- break;
- case 4:
- FVF = D3DFVF_TEX4;
- break;
- case 5:
- FVF = D3DFVF_TEX5;
- break;
- case 6:
- FVF = D3DFVF_TEX6;
- break;
- case 7:
- FVF = D3DFVF_TEX7;
- break;
- case 8:
- FVF = D3DFVF_TEX8;
- break;
- default:
- return E_FAIL;
- }
-
- HRESULT hr;
+ if(!pD3DDev)
+ return E_POINTER;
+
+ DWORD FVF = 0;
+
+ switch(texcoords)
+ {
+ case 1: FVF = D3DFVF_TEX1; break;
+ case 2: FVF = D3DFVF_TEX2; break;
+ case 3: FVF = D3DFVF_TEX3; break;
+ case 4: FVF = D3DFVF_TEX4; break;
+ case 5: FVF = D3DFVF_TEX5; break;
+ case 6: FVF = D3DFVF_TEX6; break;
+ case 7: FVF = D3DFVF_TEX7; break;
+ case 8: FVF = D3DFVF_TEX8; break;
+ default: return E_FAIL;
+ }
+
+ HRESULT hr;
do
- {
+ {
hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
-
- for(int i = 0; i < texcoords; i++)
- {
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
-
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- }
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
- //
+ for(int i = 0; i < texcoords; i++)
+ {
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
+
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ }
+
+ //
hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
- // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
+ // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
- MYD3DVERTEX<texcoords> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ MYD3DVERTEX<texcoords> tmp = v[2]; v[2] = v[3]; v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
//
- for(int i = 0; i < texcoords; i++)
- {
- pD3DDev->SetTexture(i, NULL);
- }
+ for(int i = 0; i < texcoords; i++)
+ {
+ pD3DDev->SetTexture(i, NULL);
+ }
- return S_OK;
+ return S_OK;
}
- while(0);
+ while(0);
return E_FAIL;
}
static HRESULT DrawRect(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<0> v[4])
{
- if(!pD3DDev)
- return E_POINTER;
+ if(!pD3DDev)
+ return E_POINTER;
do
- {
+ {
HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- //D3DRS_COLORVERTEX
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
-
-
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ //D3DRS_COLORVERTEX
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+
+
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
- // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
+ // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
- MYD3DVERTEX<0> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ MYD3DVERTEX<0> tmp = v[2]; v[2] = v[3]; v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- return S_OK;
+ return S_OK;
}
- while(0);
+ while(0);
return E_FAIL;
}
// CDX9AllocatorPresenter
-CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsEVR, CString &_Error)
- : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
- , m_ScreenSize(0, 0)
- , m_RefreshRate(0)
- , m_bicubicA(0)
- , m_nTearingPos(0)
- , m_nNbDXSurface(1)
- , m_nVMR9Surfaces(0)
- , m_iVMR9Surface(0)
- , m_nCurSurface(0)
- , m_rtTimePerFrame(0)
- , m_bInterlaced(0)
- , m_nUsedBuffer(0)
- , m_bNeedPendingResetDevice(0)
- , m_bPendingResetDevice(0)
- , m_OrderedPaint(0)
- , m_bCorrectedFrameTime(0)
- , m_FrameTimeCorrection(0)
- , m_LastSampleTime(0)
- , m_LastFrameDuration(0)
- , m_bAlternativeVSync(0)
- , m_bIsEVR(bIsEVR)
- , m_VSyncMode(0)
- , m_TextScale(1.0)
+CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsEVR, CString &_Error)
+ : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
+ , m_ScreenSize(0, 0)
+ , m_RefreshRate(0)
+ , m_bicubicA(0)
+ , m_nTearingPos(0)
+ , m_nNbDXSurface(1)
+ , m_nVMR9Surfaces(0)
+ , m_iVMR9Surface(0)
+ , m_nCurSurface(0)
+ , m_rtTimePerFrame(0)
+ , m_bInterlaced(0)
+ , m_nUsedBuffer(0)
+ , m_bNeedPendingResetDevice(0)
+ , m_bPendingResetDevice(0)
+ , m_OrderedPaint(0)
+ , m_bCorrectedFrameTime(0)
+ , m_FrameTimeCorrection(0)
+ , m_LastSampleTime(0)
+ , m_LastFrameDuration(0)
+ , m_bAlternativeVSync(0)
+ , m_bIsEVR(bIsEVR)
+ , m_VSyncMode(0)
+ , m_TextScale(1.0)
{
- m_MainThreadId = 0;
- m_bNeedCheckSample = true;
- m_pDirectDraw = NULL;
- m_hVSyncThread = NULL;
- m_hEvtQuit = NULL;
-
- m_bIsFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
-
- HINSTANCE hDll;
-
- if(FAILED(hr))
- {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
-
- m_pD3DXLoadSurfaceFromMemory = NULL;
- m_pD3DXCreateLine = NULL;
- m_pD3DXCreateFont = NULL;
- m_pD3DXCreateSprite = NULL;
- hDll = AfxGetMyApp()->GetD3X9Dll();
- if(hDll)
- {
- (FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
- (FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
- (FARPROC&)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
- (FARPROC&)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
- }
- else
- {
- _Error += L"No D3DX9 dll found. To enable stats, shaders and complex resizers, please make sure to install the latest DirectX End-User Runtime.\n";
- }
-
- m_pDwmIsCompositionEnabled = NULL;
- m_pDwmEnableComposition = NULL;
- m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
- if(m_hDWMAPI)
- {
- (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
- (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
- }
-
- m_hD3D9 = LoadLibrary(L"d3d9.dll");
- if(m_hD3D9)
- {
- (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
- }
- else
- m_pDirect3DCreate9Ex = NULL;
-
- m_DetectedFrameRate = 0.0;
- m_DetectedFrameTime = 0.0;
- m_DetectedFrameTimeStdDev = 0.0;
- m_DetectedLock = false;
- ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory));
- ZeroMemory(m_DetectedFrameTimeHistoryHistory, sizeof(m_DetectedFrameTimeHistoryHistory));
- m_DetectedFrameTimePos = 0;
- ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
-
- ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList));
- ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList));
- m_DetectedRefreshRatePos = 0;
- m_DetectedRefreshTimePrim = 0;
- m_DetectedScanlineTime = 0;
- m_DetectedScanlineTimePrim = 0;
- m_DetectedRefreshRate = 0;
- AppSettings& s = AfxGetAppSettings();
-
- if(s.m_RenderSettings.iVMRDisableDesktopComposition)
- {
- m_bDesktopCompositionDisabled = true;
- if(m_pDwmEnableComposition)
- m_pDwmEnableComposition(0);
- }
- else
- {
- m_bDesktopCompositionDisabled = false;
- }
-
- hr = CreateDevice(_Error);
-
- memset(m_pllJitter, 0, sizeof(m_pllJitter));
- memset(m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
- m_nNextJitter = 0;
- m_nNextSyncOffset = 0;
- m_llLastPerf = 0;
- m_fAvrFps = 0.0;
- m_fJitterStdDev = 0.0;
- m_fSyncOffsetStdDev = 0.0;
- m_fSyncOffsetAvr = 0.0;
- m_bSyncStatsAvailable = false;
+ m_MainThreadId = 0;
+ m_bNeedCheckSample = true;
+ m_pDirectDraw = NULL;
+ m_hVSyncThread = NULL;
+ m_hEvtQuit = NULL;
+
+ m_bIsFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
+
+ HINSTANCE hDll;
+
+ if(FAILED(hr))
+ {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
+
+ m_pD3DXLoadSurfaceFromMemory = NULL;
+ m_pD3DXCreateLine = NULL;
+ m_pD3DXCreateFont = NULL;
+ m_pD3DXCreateSprite = NULL;
+ hDll = AfxGetMyApp()->GetD3X9Dll();
+ if(hDll)
+ {
+ (FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
+ (FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
+ (FARPROC&)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
+ (FARPROC&)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
+ }
+ else
+ {
+ _Error += L"No D3DX9 dll found. To enable stats, shaders and complex resizers, please make sure to install the latest DirectX End-User Runtime.\n";
+ }
+
+ m_pDwmIsCompositionEnabled = NULL;
+ m_pDwmEnableComposition = NULL;
+ m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
+ if (m_hDWMAPI)
+ {
+ (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
+ (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
+ }
+
+ m_hD3D9 = LoadLibrary(L"d3d9.dll");
+ if (m_hD3D9)
+ {
+ (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+ }
+ else
+ m_pDirect3DCreate9Ex = NULL;
+
+ m_DetectedFrameRate = 0.0;
+ m_DetectedFrameTime = 0.0;
+ m_DetectedFrameTimeStdDev = 0.0;
+ m_DetectedLock = false;
+ ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory));
+ ZeroMemory(m_DetectedFrameTimeHistoryHistory, sizeof(m_DetectedFrameTimeHistoryHistory));
+ m_DetectedFrameTimePos = 0;
+ ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
+
+ ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList));
+ ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList));
+ m_DetectedRefreshRatePos = 0;
+ m_DetectedRefreshTimePrim = 0;
+ m_DetectedScanlineTime = 0;
+ m_DetectedScanlineTimePrim = 0;
+ m_DetectedRefreshRate = 0;
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(0);
+ }
+ else
+ {
+ m_bDesktopCompositionDisabled = false;
+ }
+
+ hr = CreateDevice(_Error);
+
+ memset (m_pllJitter, 0, sizeof(m_pllJitter));
+ memset (m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
+ m_nNextJitter = 0;
+ m_nNextSyncOffset = 0;
+ m_llLastPerf = 0;
+ m_fAvrFps = 0.0;
+ m_fJitterStdDev = 0.0;
+ m_fSyncOffsetStdDev = 0.0;
+ m_fSyncOffsetAvr = 0.0;
+ m_bSyncStatsAvailable = false;
}
-CDX9AllocatorPresenter::~CDX9AllocatorPresenter()
+CDX9AllocatorPresenter::~CDX9AllocatorPresenter()
{
- if(m_bDesktopCompositionDisabled)
- {
- m_bDesktopCompositionDisabled = false;
- if(m_pDwmEnableComposition)
- m_pDwmEnableComposition(1);
- }
-
- StopWorkerThreads();
- m_pFont = NULL;
- m_pLine = NULL;
+ if (m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(1);
+ }
+
+ StopWorkerThreads();
+ m_pFont = NULL;
+ m_pLine = NULL;
m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
- m_pPSC.Free();
- m_pD3D = NULL;
- m_pD3DEx = NULL;
- if(m_hDWMAPI)
- {
- FreeLibrary(m_hDWMAPI);
- m_hDWMAPI = NULL;
- }
- if(m_hD3D9)
- {
- FreeLibrary(m_hD3D9);
- m_hD3D9 = NULL;
- }
+ m_pD3DDevEx = NULL;
+ m_pPSC.Free();
+ m_pD3D = NULL;
+ m_pD3DEx = NULL;
+ if (m_hDWMAPI)
+ {
+ FreeLibrary(m_hDWMAPI);
+ m_hDWMAPI = NULL;
+ }
+ if (m_hD3D9)
+ {
+ FreeLibrary(m_hD3D9);
+ m_hD3D9 = NULL;
+ }
}
void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed);
@@ -357,235 +329,235 @@ class CRandom31
{
public:
- CRandom31()
- {
- m_Seed = 12164;
- }
-
- void f_SetSeed(int32 _Seed)
- {
- m_Seed = _Seed;
- }
- int32 f_GetSeed()
- {
- return m_Seed;
- }
- /*
- Park and Miller's psuedo-random number generator.
- */
- int32 m_Seed;
- int32 f_Get()
- {
- static const int32 A = 16807;
- static const int32 M = 2147483647; // 2^31 - 1
- static const int32 q = M / A; // M / A
- static const int32 r = M % A; // M % A
- m_Seed = A * (m_Seed % q) - r * (m_Seed / q);
- if(m_Seed < 0)
- m_Seed += M;
- return m_Seed;
- }
-
- static int32 fs_Max()
- {
- return 2147483646;
- }
-
- double f_GetFloat()
- {
- return double(f_Get()) * (1.0 / double(fs_Max()));
- }
+ CRandom31()
+ {
+ m_Seed = 12164;
+ }
+
+ void f_SetSeed(int32 _Seed)
+ {
+ m_Seed = _Seed;
+ }
+ int32 f_GetSeed()
+ {
+ return m_Seed;
+ }
+ /*
+ Park and Miller's psuedo-random number generator.
+ */
+ int32 m_Seed;
+ int32 f_Get()
+ {
+ static const int32 A = 16807;
+ static const int32 M = 2147483647; // 2^31 - 1
+ static const int32 q = M / A; // M / A
+ static const int32 r = M % A; // M % A
+ m_Seed = A * (m_Seed % q) - r * (m_Seed / q);
+ if (m_Seed < 0)
+ m_Seed += M;
+ return m_Seed;
+ }
+
+ static int32 fs_Max()
+ {
+ return 2147483646;
+ }
+
+ double f_GetFloat()
+ {
+ return double(f_Get()) * (1.0 / double(fs_Max()));
+ }
};
class CVSyncEstimation
{
private:
- class CHistoryEntry
- {
- public:
- CHistoryEntry()
- {
- m_Time = 0;
- m_ScanLine = -1;
- }
- LONGLONG m_Time;
- int m_ScanLine;
- };
-
- class CSolution
- {
- public:
- CSolution()
- {
- m_ScanLines = 1000;
- m_ScanLinesPerSecond = m_ScanLines * 100;
- }
- int m_ScanLines;
- double m_ScanLinesPerSecond;
- double m_SqrSum;
-
- void f_Mutate(double _Amount, CRandom31 &_Random, int _MinScans)
- {
- int ToDo = _Random.f_Get() % 10;
- if(ToDo == 0)
- m_ScanLines = m_ScanLines / 2;
- else if(ToDo == 1)
- m_ScanLines = m_ScanLines * 2;
-
- m_ScanLines = m_ScanLines * (1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5);
- m_ScanLines = max(m_ScanLines, _MinScans);
-
- if(ToDo == 2)
- m_ScanLinesPerSecond /= (_Random.f_Get() % 4) + 1;
- else if(ToDo == 3)
- m_ScanLinesPerSecond *= (_Random.f_Get() % 4) + 1;
-
- m_ScanLinesPerSecond *= 1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5;
- }
-
- void f_SpawnInto(CSolution &_Other, CRandom31 &_Random, int _MinScans)
- {
- _Other = *this;
- _Other.f_Mutate(_Random.f_GetFloat() * 0.1, _Random, _MinScans);
- }
-
- static int fs_Compare(const void *_pFirst, const void *_pSecond)
- {
- const CSolution *pFirst = (const CSolution *)_pFirst;
- const CSolution *pSecond = (const CSolution *)_pSecond;
- if(pFirst->m_SqrSum < pSecond->m_SqrSum)
- return -1;
- else if(pFirst->m_SqrSum > pSecond->m_SqrSum)
- return 1;
- return 0;
- }
-
-
- };
-
- enum
- {
- ENumHistory = 128
- };
-
- CHistoryEntry m_History[ENumHistory];
- int m_iHistory;
- CSolution m_OldSolutions[2];
-
- CRandom31 m_Random;
-
-
- double fp_GetSquareSum(double _ScansPerSecond, double _ScanLines)
- {
- double SquareSum = 0;
- int nHistory = min(m_nHistory, ENumHistory);
- int iHistory = m_iHistory - nHistory;
- if(iHistory < 0)
- iHistory += ENumHistory;
- for(int i = 1; i < nHistory; ++i)
- {
- int iHistory0 = iHistory + i - 1;
- int iHistory1 = iHistory + i;
- if(iHistory0 < 0)
- iHistory0 += ENumHistory;
- iHistory0 = iHistory0 % ENumHistory;
- iHistory1 = iHistory1 % ENumHistory;
- ASSERT(m_History[iHistory0].m_Time != 0);
- ASSERT(m_History[iHistory1].m_Time != 0);
-
- double DeltaTime = (m_History[iHistory1].m_Time - m_History[iHistory0].m_Time) / 10000000.0;
- double PredictedScanLine = m_History[iHistory0].m_ScanLine + DeltaTime * _ScansPerSecond;
- PredictedScanLine = fmod(PredictedScanLine, _ScanLines);
- double Delta = (m_History[iHistory1].m_ScanLine - PredictedScanLine);
- double DeltaSqr = Delta * Delta;
- SquareSum += DeltaSqr;
- }
- return SquareSum;
- }
-
- int m_nHistory;
+ class CHistoryEntry
+ {
+ public:
+ CHistoryEntry()
+ {
+ m_Time = 0;
+ m_ScanLine = -1;
+ }
+ LONGLONG m_Time;
+ int m_ScanLine;
+ };
+
+ class CSolution
+ {
+ public:
+ CSolution()
+ {
+ m_ScanLines = 1000;
+ m_ScanLinesPerSecond = m_ScanLines * 100;
+ }
+ int m_ScanLines;
+ double m_ScanLinesPerSecond;
+ double m_SqrSum;
+
+ void f_Mutate(double _Amount, CRandom31 &_Random, int _MinScans)
+ {
+ int ToDo = _Random.f_Get() % 10;
+ if (ToDo == 0)
+ m_ScanLines = m_ScanLines / 2;
+ else if (ToDo == 1)
+ m_ScanLines = m_ScanLines * 2;
+
+ m_ScanLines = m_ScanLines * (1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5);
+ m_ScanLines = max(m_ScanLines, _MinScans);
+
+ if (ToDo == 2)
+ m_ScanLinesPerSecond /= (_Random.f_Get() % 4) + 1;
+ else if (ToDo == 3)
+ m_ScanLinesPerSecond *= (_Random.f_Get() % 4) + 1;
+
+ m_ScanLinesPerSecond *= 1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5;
+ }
+
+ void f_SpawnInto(CSolution &_Other, CRandom31 &_Random, int _MinScans)
+ {
+ _Other = *this;
+ _Other.f_Mutate(_Random.f_GetFloat() * 0.1, _Random, _MinScans);
+ }
+
+ static int fs_Compare(const void *_pFirst, const void *_pSecond)
+ {
+ const CSolution *pFirst = (const CSolution *)_pFirst;
+ const CSolution *pSecond = (const CSolution *)_pSecond;
+ if (pFirst->m_SqrSum < pSecond->m_SqrSum)
+ return -1;
+ else if (pFirst->m_SqrSum > pSecond->m_SqrSum)
+ return 1;
+ return 0;
+ }
+
+
+ };
+
+ enum
+ {
+ ENumHistory = 128
+ };
+
+ CHistoryEntry m_History[ENumHistory];
+ int m_iHistory;
+ CSolution m_OldSolutions[2];
+
+ CRandom31 m_Random;
+
+
+ double fp_GetSquareSum(double _ScansPerSecond, double _ScanLines)
+ {
+ double SquareSum = 0;
+ int nHistory = min(m_nHistory, ENumHistory);
+ int iHistory = m_iHistory - nHistory;
+ if (iHistory < 0)
+ iHistory += ENumHistory;
+ for (int i = 1; i < nHistory; ++i)
+ {
+ int iHistory0 = iHistory + i - 1;
+ int iHistory1 = iHistory + i;
+ if (iHistory0 < 0)
+ iHistory0 += ENumHistory;
+ iHistory0 = iHistory0 % ENumHistory;
+ iHistory1 = iHistory1 % ENumHistory;
+ ASSERT(m_History[iHistory0].m_Time != 0);
+ ASSERT(m_History[iHistory1].m_Time != 0);
+
+ double DeltaTime = (m_History[iHistory1].m_Time - m_History[iHistory0].m_Time)/10000000.0;
+ double PredictedScanLine = m_History[iHistory0].m_ScanLine + DeltaTime * _ScansPerSecond;
+ PredictedScanLine = fmod(PredictedScanLine, _ScanLines);
+ double Delta = (m_History[iHistory1].m_ScanLine - PredictedScanLine);
+ double DeltaSqr = Delta * Delta;
+ SquareSum += DeltaSqr;
+ }
+ return SquareSum;
+ }
+
+ int m_nHistory;
public:
- CVSyncEstimation()
- {
- m_iHistory = 0;
- m_nHistory = 0;
- }
-
- void f_AddSample(int _ScanLine, LONGLONG _Time)
- {
- m_History[m_iHistory].m_ScanLine = _ScanLine;
- m_History[m_iHistory].m_Time = _Time;
- ++m_nHistory;
- m_iHistory = (m_iHistory + 1) % ENumHistory;
- }
-
- void f_GetEstimation(double &_RefreshRate, int &_ScanLines, int _ScreenSizeY, int _WindowsRefreshRate)
- {
- _RefreshRate = 0;
- _ScanLines = 0;
-
- int iHistory = m_iHistory;
- // We have a full history
- if(m_nHistory > 10)
- {
- for(int l = 0; l < 5; ++l)
- {
- const int nSol = 3 + 5 + 5 + 3;
- CSolution Solutions[nSol];
-
- Solutions[0] = m_OldSolutions[0];
- Solutions[1] = m_OldSolutions[1];
- Solutions[2].m_ScanLines = _ScreenSizeY;
- Solutions[2].m_ScanLinesPerSecond = _ScreenSizeY * _WindowsRefreshRate;
-
- int iStart = 3;
- for(int i = iStart; i < iStart + 5; ++i)
- Solutions[0].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
- iStart += 5;
- for(int i = iStart; i < iStart + 5; ++i)
- Solutions[1].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
- iStart += 5;
- for(int i = iStart; i < iStart + 3; ++i)
- Solutions[2].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
-
- int Start = 2;
- if(l == 0)
- Start = 0;
- for(int i = Start; i < nSol; ++i)
- Solutions[i].m_SqrSum = fp_GetSquareSum(Solutions[i].m_ScanLinesPerSecond, Solutions[i].m_ScanLines);
-
- qsort(Solutions, nSol, sizeof(Solutions[0]), &CSolution::fs_Compare);
- for(int i = 0; i < 2; ++i)
- m_OldSolutions[i] = Solutions[i];
- }
-
- _ScanLines = m_OldSolutions[0].m_ScanLines + 0.5;
- _RefreshRate = 1.0 / (m_OldSolutions[0].m_ScanLines / m_OldSolutions[0].m_ScanLinesPerSecond);
- }
- else
- {
- m_OldSolutions[0].m_ScanLines = _ScreenSizeY;
- m_OldSolutions[1].m_ScanLines = _ScreenSizeY;
- }
- }
+ CVSyncEstimation()
+ {
+ m_iHistory = 0;
+ m_nHistory = 0;
+ }
+
+ void f_AddSample(int _ScanLine, LONGLONG _Time)
+ {
+ m_History[m_iHistory].m_ScanLine = _ScanLine;
+ m_History[m_iHistory].m_Time = _Time;
+ ++m_nHistory;
+ m_iHistory = (m_iHistory + 1) % ENumHistory;
+ }
+
+ void f_GetEstimation(double &_RefreshRate, int &_ScanLines, int _ScreenSizeY, int _WindowsRefreshRate)
+ {
+ _RefreshRate = 0;
+ _ScanLines = 0;
+
+ int iHistory = m_iHistory;
+ // We have a full history
+ if (m_nHistory > 10)
+ {
+ for (int l = 0; l < 5; ++l)
+ {
+ const int nSol = 3+5+5+3;
+ CSolution Solutions[nSol];
+
+ Solutions[0] = m_OldSolutions[0];
+ Solutions[1] = m_OldSolutions[1];
+ Solutions[2].m_ScanLines = _ScreenSizeY;
+ Solutions[2].m_ScanLinesPerSecond = _ScreenSizeY * _WindowsRefreshRate;
+
+ int iStart = 3;
+ for (int i = iStart; i < iStart + 5; ++i)
+ Solutions[0].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
+ iStart += 5;
+ for (int i = iStart; i < iStart + 5; ++i)
+ Solutions[1].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
+ iStart += 5;
+ for (int i = iStart; i < iStart + 3; ++i)
+ Solutions[2].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
+
+ int Start = 2;
+ if (l == 0)
+ Start = 0;
+ for (int i = Start; i < nSol; ++i)
+ Solutions[i].m_SqrSum = fp_GetSquareSum(Solutions[i].m_ScanLinesPerSecond, Solutions[i].m_ScanLines);
+
+ qsort(Solutions, nSol, sizeof(Solutions[0]), &CSolution::fs_Compare);
+ for (int i = 0; i < 2; ++i)
+ m_OldSolutions[i] = Solutions[i];
+ }
+
+ _ScanLines = m_OldSolutions[0].m_ScanLines + 0.5;
+ _RefreshRate = 1.0 / (m_OldSolutions[0].m_ScanLines / m_OldSolutions[0].m_ScanLinesPerSecond);
+ }
+ else
+ {
+ m_OldSolutions[0].m_ScanLines = _ScreenSizeY;
+ m_OldSolutions[1].m_ScanLines = _ScreenSizeY;
+ }
+ }
};
#endif
void CDX9AllocatorPresenter::VSyncThread()
{
- HANDLE hAvrt;
- HANDLE hEvts[] = { m_hEvtQuit};
- bool bQuit = false;
+ HANDLE hAvrt;
+ HANDLE hEvts[] = { m_hEvtQuit};
+ bool bQuit = false;
TIMECAPS tc;
- DWORD dwResolution;
- DWORD dwUser = 0;
- DWORD dwTaskIndex = 0;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+ DWORD dwTaskIndex = 0;
- // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
-// if (pfAvSetMmThreadCharacteristicsW)
+ // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+// if (pfAvSetMmThreadCharacteristicsW)
// hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
-// if (pfAvSetMmThreadPriority)
+// if (pfAvSetMmThreadPriority)
// pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
// Sleep(2000); // Remove ugly patch : create a 2s delay on opening files with Win7!
@@ -593,1296 +565,1259 @@ void CDX9AllocatorPresenter::VSyncThread()
timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
dwUser = timeBeginPeriod(dwResolution);
- CMPlayerCApp *pApp = (CMPlayerCApp*)AfxGetApp();
- AppSettings& s = AfxGetAppSettings();
-
- while(!bQuit)
- {
-
- DWORD dwObject = WaitForMultipleObjects(countof(hEvts), hEvts, FALSE, 1);
- switch(dwObject)
- {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_TIMEOUT :
- {
- // Do our stuff
- if(m_pD3DDev && s.m_RenderSettings.iVMR9VSync)
- {
-
- int VSyncPos = GetVBlackPos();
- int WaitRange = max(m_ScreenSize.cy / 40, 5);
- int MinRange = max(min(int(0.003 * double(m_ScreenSize.cy) * double(m_RefreshRate) + 0.5), m_ScreenSize.cy / 3), 5); // 1.8 ms or max 33 % of Time
-
- VSyncPos += MinRange + WaitRange;
-
- VSyncPos = VSyncPos % m_ScreenSize.cy;
- if(VSyncPos < 0)
- VSyncPos += m_ScreenSize.cy;
-
- int ScanLine = 0;
- int bInVBlank = 0;
- int StartScanLine = ScanLine;
- int LastPos = ScanLine;
- ScanLine = (VSyncPos + 1) % m_ScreenSize.cy;
- if(ScanLine < 0)
- ScanLine += m_ScreenSize.cy;
- int FirstScanLine = ScanLine;
- int ScanLineMiddle = ScanLine + m_ScreenSize.cy / 2;
- ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy;
- if(ScanLineMiddle < 0)
- ScanLineMiddle += m_ScreenSize.cy;
-
- int ScanlineStart = ScanLine;
- bool bTakenLock;
- WaitForVBlankRange(ScanlineStart, 5, true, true, false, bTakenLock);
- LONGLONG TimeStart = pApp->GetPerfCounter();
-
- WaitForVBlankRange(ScanLineMiddle, 5, true, true, false, bTakenLock);
- LONGLONG TimeMiddle = pApp->GetPerfCounter();
-
- int ScanlineEnd = ScanLine;
- WaitForVBlankRange(ScanlineEnd, 5, true, true, false, bTakenLock);
- LONGLONG TimeEnd = pApp->GetPerfCounter();
-
- double nSeconds = double(TimeEnd - TimeStart) / 10000000.0;
- LONGLONG DiffMiddle = TimeMiddle - TimeStart;
- LONGLONG DiffEnd = TimeEnd - TimeMiddle;
- double DiffDiff;
- if(DiffEnd > DiffMiddle)
- DiffDiff = double(DiffEnd) / double(DiffMiddle);
- else
- DiffDiff = double(DiffMiddle) / double(DiffEnd);
- if(nSeconds > 0.003 && DiffDiff < 1.3)
- {
- double ScanLineSeconds;
- double nScanLines;
- if(ScanLineMiddle > ScanlineEnd)
- {
- ScanLineSeconds = double(TimeMiddle - TimeStart) / 10000000.0;
- nScanLines = ScanLineMiddle - ScanlineStart;
- }
- else
- {
- ScanLineSeconds = double(TimeEnd - TimeMiddle) / 10000000.0;
- nScanLines = ScanlineEnd - ScanLineMiddle;
- }
-
- double ScanLineTime = ScanLineSeconds / nScanLines;
-
- int iPos = m_DetectedRefreshRatePos % 100;
- m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
- if(m_DetectedScanlineTime && ScanlineStart != ScanlineEnd)
- {
- int Diff = ScanlineEnd - ScanlineStart;
- nSeconds -= double(Diff) * m_DetectedScanlineTime;
- }
- m_ldDetectedRefreshRateList[iPos] = nSeconds;
- double Average = 0;
- double AverageScanline = 0;
- int nPos = min(iPos + 1, 100);
- for(int i = 0; i < nPos; ++i)
- {
- Average += m_ldDetectedRefreshRateList[i];
- AverageScanline += m_ldDetectedScanlineRateList[i];
- }
-
- if(nPos)
- {
- Average /= double(nPos);
- AverageScanline /= double(nPos);
- }
- else
- {
- Average = 0;
- AverageScanline = 0;
- }
-
- double ThisValue = Average;
-
- if(Average > 0.0 && AverageScanline > 0.0)
- {
- CAutoLock Lock(&m_RefreshRateLock);
- ++m_DetectedRefreshRatePos;
- if(m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99)
- {
- m_DetectedRefreshTime = ThisValue;
- m_DetectedRefreshTimePrim = 0;
- }
- ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
- if(m_DetectedRefreshTime > 0.0)
- m_DetectedRefreshRate = 1.0 / m_DetectedRefreshTime;
- else
- m_DetectedRefreshRate = 0.0;
-
- if(m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99)
- {
- m_DetectedScanlineTime = AverageScanline;
- m_DetectedScanlineTimePrim = 0;
- }
- ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
- if(m_DetectedScanlineTime > 0.0)
- m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
- else
- m_DetectedScanlinesPerFrame = 0;
- }
- //TRACE("Refresh: %f\n", RefreshRate);
- }
- }
- else
- {
- m_DetectedRefreshRate = 0.0;
- m_DetectedScanlinesPerFrame = 0.0;
- }
- }
- break;
- }
- }
-
- timeEndPeriod(dwResolution);
+ CMPlayerCApp *pApp = (CMPlayerCApp*)AfxGetApp();
+ AppSettings& s = AfxGetAppSettings();
+
+ while (!bQuit)
+ {
+
+ DWORD dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject)
+ {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT :
+ {
+ // Do our stuff
+ if (m_pD3DDev && s.m_RenderSettings.iVMR9VSync)
+ {
+
+ int VSyncPos = GetVBlackPos();
+ int WaitRange = max(m_ScreenSize.cy / 40, 5);
+ int MinRange = max(min(int(0.003 * double(m_ScreenSize.cy) * double(m_RefreshRate) + 0.5), m_ScreenSize.cy/3), 5); // 1.8 ms or max 33 % of Time
+
+ VSyncPos += MinRange + WaitRange;
+
+ VSyncPos = VSyncPos % m_ScreenSize.cy;
+ if (VSyncPos < 0)
+ VSyncPos += m_ScreenSize.cy;
+
+ int ScanLine = 0;
+ int bInVBlank = 0;
+ int StartScanLine = ScanLine;
+ int LastPos = ScanLine;
+ ScanLine = (VSyncPos + 1) % m_ScreenSize.cy;
+ if (ScanLine < 0)
+ ScanLine += m_ScreenSize.cy;
+ int FirstScanLine = ScanLine;
+ int ScanLineMiddle = ScanLine + m_ScreenSize.cy/2;
+ ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy;
+ if (ScanLineMiddle < 0)
+ ScanLineMiddle += m_ScreenSize.cy;
+
+ int ScanlineStart = ScanLine;
+ bool bTakenLock;
+ WaitForVBlankRange(ScanlineStart, 5, true, true, false, bTakenLock);
+ LONGLONG TimeStart = pApp->GetPerfCounter();
+
+ WaitForVBlankRange(ScanLineMiddle, 5, true, true, false, bTakenLock);
+ LONGLONG TimeMiddle = pApp->GetPerfCounter();
+
+ int ScanlineEnd = ScanLine;
+ WaitForVBlankRange(ScanlineEnd, 5, true, true, false, bTakenLock);
+ LONGLONG TimeEnd = pApp->GetPerfCounter();
+
+ double nSeconds = double(TimeEnd - TimeStart) / 10000000.0;
+ LONGLONG DiffMiddle = TimeMiddle - TimeStart;
+ LONGLONG DiffEnd = TimeEnd - TimeMiddle;
+ double DiffDiff;
+ if (DiffEnd > DiffMiddle)
+ DiffDiff = double(DiffEnd) / double(DiffMiddle);
+ else
+ DiffDiff = double(DiffMiddle) / double(DiffEnd);
+ if (nSeconds > 0.003 && DiffDiff < 1.3)
+ {
+ double ScanLineSeconds;
+ double nScanLines;
+ if (ScanLineMiddle > ScanlineEnd)
+ {
+ ScanLineSeconds = double(TimeMiddle - TimeStart) / 10000000.0;
+ nScanLines = ScanLineMiddle - ScanlineStart;
+ }
+ else
+ {
+ ScanLineSeconds = double(TimeEnd - TimeMiddle) / 10000000.0;
+ nScanLines = ScanlineEnd - ScanLineMiddle;
+ }
+
+ double ScanLineTime = ScanLineSeconds / nScanLines;
+
+ int iPos = m_DetectedRefreshRatePos % 100;
+ m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
+ if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd)
+ {
+ int Diff = ScanlineEnd - ScanlineStart;
+ nSeconds -= double(Diff) * m_DetectedScanlineTime;
+ }
+ m_ldDetectedRefreshRateList[iPos] = nSeconds;
+ double Average = 0;
+ double AverageScanline = 0;
+ int nPos = min(iPos + 1, 100);
+ for (int i = 0; i < nPos; ++i)
+ {
+ Average += m_ldDetectedRefreshRateList[i];
+ AverageScanline += m_ldDetectedScanlineRateList[i];
+ }
+
+ if (nPos)
+ {
+ Average /= double(nPos);
+ AverageScanline /= double(nPos);
+ }
+ else
+ {
+ Average = 0;
+ AverageScanline = 0;
+ }
+
+ double ThisValue = Average;
+
+ if (Average > 0.0 && AverageScanline > 0.0)
+ {
+ CAutoLock Lock(&m_RefreshRateLock);
+ ++m_DetectedRefreshRatePos;
+ if (m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99)
+ {
+ m_DetectedRefreshTime = ThisValue;
+ m_DetectedRefreshTimePrim = 0;
+ }
+ ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
+ if (m_DetectedRefreshTime > 0.0)
+ m_DetectedRefreshRate = 1.0/m_DetectedRefreshTime;
+ else
+ m_DetectedRefreshRate = 0.0;
+
+ if (m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99)
+ {
+ m_DetectedScanlineTime = AverageScanline;
+ m_DetectedScanlineTimePrim = 0;
+ }
+ ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
+ if (m_DetectedScanlineTime > 0.0)
+ m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
+ else
+ m_DetectedScanlinesPerFrame = 0;
+ }
+ //TRACE("Refresh: %f\n", RefreshRate);
+ }
+ }
+ else
+ {
+ m_DetectedRefreshRate = 0.0;
+ m_DetectedScanlinesPerFrame = 0.0;
+ }
+ }
+ break;
+ }
+ }
+
+ timeEndPeriod (dwResolution);
// if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
DWORD WINAPI CDX9AllocatorPresenter::VSyncThreadStatic(LPVOID lpParam)
{
- CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam;
- pThis->VSyncThread();
- return 0;
+ CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam;
+ pThis->VSyncThread();
+ return 0;
}
void CDX9AllocatorPresenter::StartWorkerThreads()
{
- DWORD dwThreadId;
-
- if(m_bIsEVR)
- {
- m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
- if(m_hEvtQuit != NULL) // Don't create a thread with no stop switch
- {
- m_hVSyncThread = ::CreateThread(NULL, 0, VSyncThreadStatic, (LPVOID)this, 0, &dwThreadId);
- if(m_hVSyncThread != NULL)
- SetThreadPriority(m_hVSyncThread, THREAD_PRIORITY_HIGHEST);
- }
- }
+ DWORD dwThreadId;
+
+ if ( m_bIsEVR )
+ {
+ m_hEvtQuit = CreateEvent( NULL, TRUE, FALSE, NULL );
+ if ( m_hEvtQuit != NULL ) // Don't create a thread with no stop switch
+ {
+ m_hVSyncThread = ::CreateThread( NULL, 0, VSyncThreadStatic, (LPVOID)this, 0, &dwThreadId );
+ if ( m_hVSyncThread != NULL )
+ SetThreadPriority( m_hVSyncThread, THREAD_PRIORITY_HIGHEST );
+ }
+ }
}
void CDX9AllocatorPresenter::StopWorkerThreads()
{
- if(m_bIsEVR)
- {
- if(m_hEvtQuit != NULL)
- {
- SetEvent(m_hEvtQuit);
-
- if(m_hVSyncThread != NULL)
- {
- if(WaitForSingleObject(m_hVSyncThread, 10000) == WAIT_TIMEOUT)
- {
- ASSERT(FALSE);
- TerminateThread(m_hVSyncThread, 0xDEAD);
- }
-
- CloseHandle(m_hVSyncThread);
- m_hVSyncThread = NULL;
- }
-
- CloseHandle(m_hEvtQuit);
- m_hEvtQuit = NULL;
- }
- }
+ if ( m_bIsEVR )
+ {
+ if ( m_hEvtQuit != NULL )
+ {
+ SetEvent( m_hEvtQuit );
+
+ if ( m_hVSyncThread != NULL )
+ {
+ if ( WaitForSingleObject(m_hVSyncThread, 10000) == WAIT_TIMEOUT )
+ {
+ ASSERT(FALSE);
+ TerminateThread( m_hVSyncThread, 0xDEAD );
+ }
+
+ CloseHandle( m_hVSyncThread );
+ m_hVSyncThread = NULL;
+ }
+
+ CloseHandle( m_hEvtQuit );
+ m_hEvtQuit = NULL;
+ }
+ }
}
bool CDX9AllocatorPresenter::SettingsNeedResetDevice()
{
- AppSettings& s = AfxGetAppSettings();
- CMPlayerCApp::Settings::CRendererSettingsEVR & New = AfxGetAppSettings().m_RenderSettings;
- CMPlayerCApp::Settings::CRendererSettingsEVR & Current = m_LastRendererSettings;
-
- bool bRet = false;
-
- bRet = bRet || New.fVMR9AlterativeVSync != Current.fVMR9AlterativeVSync;
- bRet = bRet || New.iVMR9VSyncAccurate != Current.iVMR9VSyncAccurate;
-
- if(m_bIsFullscreen)
- {
- bRet = bRet || New.iVMR9FullscreenGUISupport != Current.iVMR9FullscreenGUISupport;
- }
- else
- {
- if(Current.iVMRDisableDesktopComposition)
- {
- if(!m_bDesktopCompositionDisabled)
- {
- m_bDesktopCompositionDisabled = true;
- if(m_pDwmEnableComposition)
- m_pDwmEnableComposition(0);
- }
- }
- else
- {
- if(m_bDesktopCompositionDisabled)
- {
- m_bDesktopCompositionDisabled = false;
- if(m_pDwmEnableComposition)
- m_pDwmEnableComposition(1);
- }
- }
- }
-
- if(m_bIsEVR)
- {
- bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
- }
-
- m_LastRendererSettings = s.m_RenderSettings;
-
- return bRet;
+ AppSettings& s = AfxGetAppSettings();
+ CMPlayerCApp::Settings::CRendererSettingsEVR & New = AfxGetAppSettings().m_RenderSettings;
+ CMPlayerCApp::Settings::CRendererSettingsEVR & Current = m_LastRendererSettings;
+
+ bool bRet = false;
+
+ bRet = bRet || New.fVMR9AlterativeVSync != Current.fVMR9AlterativeVSync;
+ bRet = bRet || New.iVMR9VSyncAccurate != Current.iVMR9VSyncAccurate;
+
+ if (m_bIsFullscreen)
+ {
+ bRet = bRet || New.iVMR9FullscreenGUISupport != Current.iVMR9FullscreenGUISupport;
+ }
+ else
+ {
+ if (Current.iVMRDisableDesktopComposition)
+ {
+ if (!m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(0);
+ }
+ }
+ else
+ {
+ if (m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(1);
+ }
+ }
+ }
+
+ if (m_bIsEVR)
+ {
+ bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
+ }
+
+ m_LastRendererSettings = s.m_RenderSettings;
+
+ return bRet;
}
HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
{
- StopWorkerThreads();
- AppSettings& s = AfxGetAppSettings();
- m_VBlankEndWait = 0;
- m_VBlankMin = 300000;
- m_VBlankMinCalc = 300000;
- m_VBlankMax = 0;
- m_VBlankStartWait = 0;
- m_VBlankWaitTime = 0;
- m_VBlankLockTime = 0;
- m_PresentWaitTime = 0;
- m_PresentWaitTimeMin = 3000000000;
- m_PresentWaitTimeMax = 0;
-
- m_LastRendererSettings = s.m_RenderSettings;
-
- m_VBlankEndPresent = -100000;
- m_VBlankStartMeasureTime = 0;
- m_VBlankStartMeasure = 0;
-
- m_PaintTime = 0;
- m_PaintTimeMin = 3000000000;
- m_PaintTimeMax = 0;
-
- m_RasterStatusWaitTime = 0;
- m_RasterStatusWaitTimeMin = 3000000000;
- m_RasterStatusWaitTimeMax = 0;
- m_RasterStatusWaitTimeMaxCalc = 0;
-
- m_ClockDiff = 0.0;
- m_ClockDiffPrim = 0.0;
- m_ClockDiffCalc = 0.0;
-
- m_ModeratedTimeSpeed = 1.0;
- m_ModeratedTimeSpeedDiff = 0.0;
- m_ModeratedTimeSpeedPrim = 0;
- ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
- ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
- m_ClockTimeChangeHistoryPos = 0;
-
- m_pPSC.Free();
+ StopWorkerThreads();
+ AppSettings& s = AfxGetAppSettings();
+ m_VBlankEndWait = 0;
+ m_VBlankMin = 300000;
+ m_VBlankMinCalc = 300000;
+ m_VBlankMax = 0;
+ m_VBlankStartWait = 0;
+ m_VBlankWaitTime = 0;
+ m_VBlankLockTime = 0;
+ m_PresentWaitTime = 0;
+ m_PresentWaitTimeMin = 3000000000;
+ m_PresentWaitTimeMax = 0;
+
+ m_LastRendererSettings = s.m_RenderSettings;
+
+ m_VBlankEndPresent = -100000;
+ m_VBlankStartMeasureTime = 0;
+ m_VBlankStartMeasure = 0;
+
+ m_PaintTime = 0;
+ m_PaintTimeMin = 3000000000;
+ m_PaintTimeMax = 0;
+
+ m_RasterStatusWaitTime = 0;
+ m_RasterStatusWaitTimeMin = 3000000000;
+ m_RasterStatusWaitTimeMax = 0;
+ m_RasterStatusWaitTimeMaxCalc = 0;
+
+ m_ClockDiff = 0.0;
+ m_ClockDiffPrim = 0.0;
+ m_ClockDiffCalc = 0.0;
+
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedDiff = 0.0;
+ m_ModeratedTimeSpeedPrim = 0;
+ ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
+ ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
+ m_ClockTimeChangeHistoryPos = 0;
+
+ m_pPSC.Free();
m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
- m_pDirectDraw = NULL;
-
- m_pResizerPixelShader[0] = 0;
- m_pResizerPixelShader[1] = 0;
- m_pResizerPixelShader[2] = 0;
- m_pResizerPixelShader[3] = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
- pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
-
- m_pD3DEx = NULL;
- m_pD3D = NULL;
-
- if(m_pDirect3DCreate9Ex)
- {
- m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx)
- {
- m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
- }
- }
- if(!m_pD3DEx)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
- if(!m_pD3D)
- {
- _Error += L"Failed to create D3D9\n";
- return E_UNEXPECTED;
- }
- }
- else
- m_pD3D = m_pD3DEx;
-
-
- D3DDISPLAYMODE d3ddm;
- HRESULT hr;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
- {
- _Error += L"GetAdapterDisplayMode failed\n";
- return E_UNEXPECTED;
- }
-
- /* // TODO : add nVidia PerfHUD !!!
-
- // Set default settings
- UINT AdapterToUse=D3DADAPTER_DEFAULT;
- D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
-
- #if SHIPPING_VERSION
- // When building a shipping version, disable PerfHUD (opt-out)
- #else
- // Look for 'NVIDIA PerfHUD' adapter
- // If it is present, override default settings
- for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++)
- {
- D3DADAPTER_IDENTIFIER9 Identifier;
- HRESULT Res;
-
- Res = g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
- if (strstr(Identifier.Description,"PerfHUD") != 0)
- {
- AdapterToUse=Adapter;
- DeviceType=D3DDEVTYPE_REF;
- break;
- }
- }
- #endif
-
- if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd,
- D3DCREATE_HARDWARE_VERTEXPROCESSING,
- &d3dpp, &g_pd3dDevice) ) )
- {
- return E_FAIL;
- }
- */
+ m_pD3DDevEx = NULL;
+ m_pDirectDraw = NULL;
+
+ m_pResizerPixelShader[0] = 0;
+ m_pResizerPixelShader[1] = 0;
+ m_pResizerPixelShader[2] = 0;
+ m_pResizerPixelShader[3] = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+ pos = m_pPixelShaders.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+
+ m_pD3DEx = NULL;
+ m_pD3D = NULL;
+
+ if (m_pDirect3DCreate9Ex)
+ {
+ m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
+ if(!m_pD3DEx)
+ {
+ m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
+ }
+ if(!m_pD3DEx)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if(!m_pD3D)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+ if(!m_pD3D)
+ {
+ _Error += L"Failed to create D3D9\n";
+ return E_UNEXPECTED;
+ }
+ }
+ else
+ m_pD3D = m_pD3DEx;
+
+
+ D3DDISPLAYMODE d3ddm;
+ HRESULT hr;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
+ {
+ _Error += L"GetAdapterDisplayMode failed\n";
+ return E_UNEXPECTED;
+ }
+
+ /* // TODO : add nVidia PerfHUD !!!
+
+// Set default settings
+UINT AdapterToUse=D3DADAPTER_DEFAULT;
+D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
+
+#if SHIPPING_VERSION
+// When building a shipping version, disable PerfHUD (opt-out)
+#else
+// Look for 'NVIDIA PerfHUD' adapter
+// If it is present, override default settings
+for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++)
+{
+ D3DADAPTER_IDENTIFIER9 Identifier;
+ HRESULT Res;
+
+Res = g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
+ if (strstr(Identifier.Description,"PerfHUD") != 0)
+ {
+ AdapterToUse=Adapter;
+ DeviceType=D3DDEVTYPE_REF;
+ break;
+ }
+}
+#endif
+
+if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING,
+ &d3dpp, &g_pd3dDevice) ) )
+{
+ return E_FAIL;
+}
+ */
//#define ENABLE_DDRAWSYNC
#ifdef ENABLE_DDRAWSYNC
hr = DirectDrawCreate(NULL, &m_pDirectDraw, NULL) ;
- if(hr == S_OK)
- {
- hr = m_pDirectDraw->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL) ;
- }
+ if (hr == S_OK)
+ {
+ hr = m_pDirectDraw->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL) ;
+ }
#endif
- m_RefreshRate = d3ddm.RefreshRate;
- m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
+ m_RefreshRate = d3ddm.RefreshRate;
+ m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
D3DPRESENT_PARAMETERS pp;
ZeroMemory(&pp, sizeof(pp));
- BOOL bCompositionEnabled = false;
- if(m_pDwmIsCompositionEnabled)
- m_pDwmIsCompositionEnabled(&bCompositionEnabled);
-
- m_bCompositionEnabled = bCompositionEnabled != 0;
-
- m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR;
-
- if(m_bIsFullscreen)
- {
- pp.Windowed = false;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- pp.hDeviceWindow = m_hWnd;
- if(m_bAlternativeVSync)
- {
- pp.BackBufferCount = 3;
- pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
- pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
- pp.BackBufferCount = 3;
- pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- }
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- if(s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
- pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
- if(m_bHighColorResolution)
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- else
- pp.BackBufferFormat = d3ddm.Format;
-
- m_D3DDevExError = L"No m_pD3DEx";
- if(m_pD3DEx)
- {
- D3DDISPLAYMODEEX DisplayMode;
- ZeroMemory(&DisplayMode, sizeof(DisplayMode));
- DisplayMode.Size = sizeof(DisplayMode);
- m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
-
- DisplayMode.Format = pp.BackBufferFormat;
- pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
-
- hr = m_pD3DEx->CreateDeviceEx(
- GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &DisplayMode, &m_pD3DDevEx);
-
- m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
- if(m_pD3DDevEx)
- {
- m_pD3DDev = m_pD3DDevEx;
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = DisplayMode.Format;
- }
- }
-
- if(!m_pD3DDev)
- {
- hr = m_pD3D->CreateDevice(
- GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
- if(m_pD3DDev)
- {
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = d3ddm.Format;
- }
- }
- if(m_pD3DDev && s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
- {
- m_pD3DDev->SetDialogBoxMode(true);
- //if (m_pD3DDev->SetDialogBoxMode(true) != S_OK)
- // ExitProcess(0);
-
- }
-
- TRACE("CreateDevice: %d\n", (LONG)hr);
- ASSERT(SUCCEEDED(hr));
- }
- else
- {
- pp.Windowed = TRUE;
- pp.hDeviceWindow = m_hWnd;
- pp.SwapEffect = D3DSWAPEFFECT_COPY;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferCount = 1;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- m_BackbufferType = d3ddm.Format;
- m_DisplayType = d3ddm.Format;
- if(m_bHighColorResolution)
- {
- m_BackbufferType = D3DFMT_A2R10G10B10;
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- }
- if(bCompositionEnabled || m_bAlternativeVSync)
- {
- // Desktop composition takes care of the VSYNC
- pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- }
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled)
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+
+ m_bCompositionEnabled = bCompositionEnabled != 0;
+
+ m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR;
+
+ if (m_bIsFullscreen)
+ {
+ pp.Windowed = false;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ pp.hDeviceWindow = m_hWnd;
+ if(m_bAlternativeVSync)
+ {
+ pp.BackBufferCount = 3;
+ pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ }
+ else
+ {
+ pp.BackBufferCount = 3;
+ pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
+ pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
+ if (m_bHighColorResolution)
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ else
+ pp.BackBufferFormat = d3ddm.Format;
+
+ m_D3DDevExError = L"No m_pD3DEx";
+ if (m_pD3DEx)
+ {
+ D3DDISPLAYMODEEX DisplayMode;
+ ZeroMemory(&DisplayMode, sizeof(DisplayMode));
+ DisplayMode.Size = sizeof(DisplayMode);
+ m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
+
+ DisplayMode.Format = pp.BackBufferFormat;
+ pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
+
+ hr = m_pD3DEx->CreateDeviceEx(
+ GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &DisplayMode, &m_pD3DDevEx);
+
+ m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
+ if (m_pD3DDevEx)
+ {
+ m_pD3DDev = m_pD3DDevEx;
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = DisplayMode.Format;
+ }
+ }
+
+ if (!m_pD3DDev)
+ {
+ hr = m_pD3D->CreateDevice(
+ GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
+ if (m_pD3DDev)
+ {
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = d3ddm.Format;
+ }
+ }
+ if (m_pD3DDev && s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
+ {
+ m_pD3DDev->SetDialogBoxMode(true);
+ //if (m_pD3DDev->SetDialogBoxMode(true) != S_OK)
+ // ExitProcess(0);
+
+ }
+
+ TRACE("CreateDevice: %d\n", (LONG)hr);
+ ASSERT (SUCCEEDED (hr));
+ }
+ else
+ {
+ pp.Windowed = TRUE;
+ pp.hDeviceWindow = m_hWnd;
+ pp.SwapEffect = D3DSWAPEFFECT_COPY;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ m_BackbufferType = d3ddm.Format;
+ m_DisplayType = d3ddm.Format;
+ if (m_bHighColorResolution)
+ {
+ m_BackbufferType = D3DFMT_A2R10G10B10;
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ }
+ if (bCompositionEnabled || m_bAlternativeVSync)
+ {
+ // Desktop composition takes care of the VSYNC
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ }
+ else
+ {
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
// if(m_fVMRSyncFix = AfxGetMyApp()->m_s.fVMRSyncFix)
// pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
- if(m_pD3DEx)
- {
- hr = m_pD3DEx->CreateDeviceEx(
- GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, NULL, &m_pD3DDevEx);
- if(m_pD3DDevEx)
- m_pD3DDev = m_pD3DDevEx;
- }
- else
- {
- hr = m_pD3D->CreateDevice(
- GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
- }
- }
-
- if(m_pD3DDevEx)
- {
- m_pD3DDevEx->SetGPUThreadPriority(7);
- }
-
- if(FAILED(hr))
- {
- _Error += L"CreateDevice failed\n";
-
- return hr;
- }
-
- m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
-
- //
-
- m_filter = D3DTEXF_NONE;
+ if (m_pD3DEx)
+ {
+ hr = m_pD3DEx->CreateDeviceEx(
+ GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, NULL, &m_pD3DDevEx);
+ if (m_pD3DDevEx)
+ m_pD3DDev = m_pD3DDevEx;
+ }
+ else
+ {
+ hr = m_pD3D->CreateDevice(
+ GetAdapter(m_pD3D, true), D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
+ }
+ }
+
+ if (m_pD3DDevEx)
+ {
+ m_pD3DDevEx->SetGPUThreadPriority(7);
+ }
+
+ if(FAILED(hr))
+ {
+ _Error += L"CreateDevice failed\n";
+
+ return hr;
+ }
+
+ m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
+
+ //
+
+ m_filter = D3DTEXF_NONE;
ZeroMemory(&m_caps, sizeof(m_caps));
- m_pD3DDev->GetDeviceCaps(&m_caps);
-
- if((m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFLINEAR)
- && (m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR))
- m_filter = D3DTEXF_LINEAR;
-
- //
-
- m_bicubicA = 0;
-
- //
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
-
- CSize size;
- switch(AfxGetAppSettings().nSPCMaxRes)
- {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if(m_pAllocator)
- {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- }
- else
- {
- m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- {
- _Error += L"CDX9SubPicAllocator failed\n";
-
- return E_FAIL;
- }
- }
-
- hr = S_OK;
- m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr))
- {
- _Error += L"m_pSubPicQueue failed\n";
-
- return E_FAIL;
- }
-
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
-
- m_pFont = NULL;
- if(m_pD3DXCreateFont)
- {
- int MinSize = 1600;
- int CurrentSize = min(m_ScreenSize.cx, MinSize);
- double Scale = double(CurrentSize) / double(MinSize);
- m_TextScale = Scale;
- m_pD3DXCreateFont(m_pD3DDev, // D3D device
- -24.0 * Scale, // Height
- -11.0 * Scale, // Width
- CurrentSize < 800 ? FW_NORMAL : FW_BOLD, // Weight
- 0, // MipLevels, 0 = autogen mipmaps
- FALSE, // Italic
- DEFAULT_CHARSET, // CharSet
- OUT_DEFAULT_PRECIS, // OutputPrecision
- ANTIALIASED_QUALITY, // Quality
- FIXED_PITCH | FF_DONTCARE, // PitchAndFamily
- L"Lucida Console", // pFaceName
- &m_pFont); // ppFont
- }
-
-
- m_pSprite = NULL;
-
- if(m_pD3DXCreateSprite)
- {
- m_pD3DXCreateSprite(m_pD3DDev, // D3D device
- &m_pSprite);
- }
-
- m_pLine = NULL;
- if(m_pD3DXCreateLine)
- m_pD3DXCreateLine(m_pD3DDev, &m_pLine);
-
- StartWorkerThreads();
-
- return S_OK;
-}
+ m_pD3DDev->GetDeviceCaps(&m_caps);
+
+ if((m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
+ && (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR))
+ m_filter = D3DTEXF_LINEAR;
+
+ //
+
+ m_bicubicA = 0;
+
+ //
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+
+ CSize size;
+ switch(AfxGetAppSettings().nSPCMaxRes)
+ {
+ case 0: default: size = m_ScreenSize; break;
+ case 1: size.SetSize(1024, 768); break;
+ case 2: size.SetSize(800, 600); break;
+ case 3: size.SetSize(640, 480); break;
+ case 4: size.SetSize(512, 384); break;
+ case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
+ }
+
+ if(m_pAllocator)
+ {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ }
+ else
+ {
+ m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ if(!m_pAllocator)
+ {
+ _Error += L"CDX9SubPicAllocator failed\n";
+
+ return E_FAIL;
+ }
+ }
+
+ hr = S_OK;
+ m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if(!m_pSubPicQueue || FAILED(hr))
+ {
+ _Error += L"m_pSubPicQueue failed\n";
+
+ return E_FAIL;
+ }
+
+ if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+
+ m_pFont = NULL;
+ if (m_pD3DXCreateFont)
+ {
+ int MinSize = 1600;
+ int CurrentSize = min(m_ScreenSize.cx, MinSize);
+ double Scale = double(CurrentSize) / double(MinSize);
+ m_TextScale = Scale;
+ m_pD3DXCreateFont( m_pD3DDev, // D3D device
+ -24.0*Scale, // Height
+ -11.0*Scale, // Width
+ CurrentSize < 800 ? FW_NORMAL : FW_BOLD, // Weight
+ 0, // MipLevels, 0 = autogen mipmaps
+ FALSE, // Italic
+ DEFAULT_CHARSET, // CharSet
+ OUT_DEFAULT_PRECIS, // OutputPrecision
+ ANTIALIASED_QUALITY, // Quality
+ FIXED_PITCH | FF_DONTCARE, // PitchAndFamily
+ L"Lucida Console", // pFaceName
+ &m_pFont); // ppFont
+ }
+
+
+ m_pSprite = NULL;
+
+ if (m_pD3DXCreateSprite)
+ {
+ m_pD3DXCreateSprite( m_pD3DDev, // D3D device
+ &m_pSprite);
+ }
+
+ m_pLine = NULL;
+ if (m_pD3DXCreateLine)
+ m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
+
+ StartWorkerThreads();
+
+ return S_OK;
+}
HRESULT CDX9AllocatorPresenter::AllocSurfaces(D3DFORMAT Format)
{
CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
-
- AppSettings& s = AfxGetAppSettings();
-
- for(int i = 0; i < m_nNbDXSurface + 2; i++)
- {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
-
- m_pScreenSizeTemporaryTexture[0] = NULL;
- m_pScreenSizeTemporaryTexture[1] = NULL;
-
- m_SurfaceType = Format;
-
- HRESULT hr;
-
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- {
- int nTexturesNeeded = s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nNbDXSurface + 2 : 1;
-
- for(int i = 0; i < nTexturesNeeded; i++)
- {
- if(FAILED(hr = m_pD3DDev->CreateTexture(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1,
- D3DUSAGE_RENDERTARGET, Format/*D3DFMT_X8R8G8B8 D3DFMT_A8R8G8B8*/,
- D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL)))
- return hr;
-
- if(FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i])))
- return hr;
- }
-
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D)
- {
- for(int i = 0; i < m_nNbDXSurface + 2; i++)
- {
- m_pVideoTexture[i] = NULL;
- }
- }
- }
- else
- {
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy,
- D3DFMT_X8R8G8B8/*D3DFMT_A8R8G8B8*/,
- D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL)))
- return hr;
- }
-
- hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
-
- return S_OK;
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ for(int i = 0; i < m_nNbDXSurface+2; i++)
+ {
+ m_pVideoTexture[i] = NULL;
+ m_pVideoSurface[i] = NULL;
+ }
+
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
+
+ m_SurfaceType = Format;
+
+ HRESULT hr;
+
+ if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ {
+ int nTexturesNeeded = s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nNbDXSurface+2 : 1;
+
+ for(int i = 0; i < nTexturesNeeded; i++)
+ {
+ if(FAILED(hr = m_pD3DDev->CreateTexture(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1,
+ D3DUSAGE_RENDERTARGET, Format/*D3DFMT_X8R8G8B8 D3DFMT_A8R8G8B8*/,
+ D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL)))
+ return hr;
+
+ if(FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i])))
+ return hr;
+ }
+
+ if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D)
+ {
+ for(int i = 0; i < m_nNbDXSurface+2; i++)
+ {
+ m_pVideoTexture[i] = NULL;
+ }
+ }
+ }
+ else
+ {
+ if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy,
+ D3DFMT_X8R8G8B8/*D3DFMT_A8R8G8B8*/,
+ D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL)))
+ return hr;
+ }
+
+ hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
+
+ return S_OK;
}
void CDX9AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
-
- for(int i = 0; i < m_nNbDXSurface + 2; i++)
- {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ for(int i = 0; i < m_nNbDXSurface+2; i++)
+ {
+ m_pVideoTexture[i] = NULL;
+ m_pVideoSurface[i] = NULL;
+ }
}
UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool CreateDevice)
{
- if(m_hWnd == NULL || pD3D == NULL)
- return D3DADAPTER_DEFAULT;
-
- AppSettings& s = AfxGetAppSettings();
- if(CreateDevice && (pD3D->GetAdapterCount() > 1) && (s.D3D9RenderDevice != _T("")))
- {
- TCHAR strGUID[50];
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- m_D3D9Device = _T("");
-
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
- if(pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
- {
- if((::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) && (s.D3D9RenderDevice == strGUID))
- {
- m_D3D9Device = adapterIdentifier.Description;
- return adp;
- }
- }
- }
- }
-
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor == NULL) return D3DADAPTER_DEFAULT;
-
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
- HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor)
- {
- if(CreateDevice)
- {
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if(pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
- m_D3D9Device = adapterIdentifier.Description;
- }
- return adp;
- }
- }
-
- return D3DADAPTER_DEFAULT;
+ if(m_hWnd == NULL || pD3D == NULL)
+ return D3DADAPTER_DEFAULT;
+
+ AppSettings& s = AfxGetAppSettings();
+ if(CreateDevice && (pD3D->GetAdapterCount()>1) && (s.D3D9RenderDevice != _T("")))
+ {
+ TCHAR strGUID[50];
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+ m_D3D9Device = _T("");
+
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
+ {
+ if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
+ {
+ if ((::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) && (s.D3D9RenderDevice == strGUID))
+ {
+ m_D3D9Device = adapterIdentifier.Description;
+ return adp;
+ }
+ }
+ }
+ }
+
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(hMonitor == NULL) return D3DADAPTER_DEFAULT;
+
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
+ {
+ HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
+ if(hAdpMon == hMonitor)
+ {
+ if(CreateDevice)
+ {
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+ if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
+ m_D3D9Device = adapterIdentifier.Description;
+ }
+ return adp;
+ }
+ }
+
+ return D3DADAPTER_DEFAULT;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CDX9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-static bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
-{
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pSurface->GetDesc(&d3dsd)))
- return(false);
-
- int w = d3dsd.Width, h = d3dsd.Height;
- int sw = s.Width(), sh = s.Height();
- int dw = d.Width(), dh = d.Height();
-
- if(d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
- || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0)
- {
- s.SetRectEmpty();
- d.SetRectEmpty();
- return(true);
- }
-
- if(d.right > w)
- {
- s.right -= (d.right - w) * sw / dw;
- d.right = w;
- }
- if(d.bottom > h)
- {
- s.bottom -= (d.bottom - h) * sh / dh;
- d.bottom = h;
- }
- if(d.left < 0)
- {
- s.left += (0 - d.left) * sw / dw;
- d.left = 0;
- }
- if(d.top < 0)
- {
- s.top += (0 - d.top) * sh / dh;
- d.top = 0;
- }
-
- return(true);
+static bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
+{
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if(FAILED(pSurface->GetDesc(&d3dsd)))
+ return(false);
+
+ int w = d3dsd.Width, h = d3dsd.Height;
+ int sw = s.Width(), sh = s.Height();
+ int dw = d.Width(), dh = d.Height();
+
+ if(d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
+ || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0)
+ {
+ s.SetRectEmpty();
+ d.SetRectEmpty();
+ return(true);
+ }
+
+ if(d.right > w) {s.right -= (d.right-w)*sw/dw; d.right = w;}
+ if(d.bottom > h) {s.bottom -= (d.bottom-h)*sh/dh; d.bottom = h;}
+ if(d.left < 0) {s.left += (0-d.left)*sw/dw; d.left = 0;}
+ if(d.top < 0) {s.top += (0-d.top)*sh/dh; d.top = 0;}
+
+ return(true);
}
HRESULT CDX9AllocatorPresenter::InitResizers(float bicubicA, bool bNeedScreenSizeTexture)
{
- HRESULT hr;
-
- do
- {
- if(bicubicA)
- {
- if(!m_pResizerPixelShader[0])
- break;
- if(!m_pResizerPixelShader[1])
- break;
- if(!m_pResizerPixelShader[2])
- break;
- if(!m_pResizerPixelShader[3])
- break;
- if(m_bicubicA != bicubicA)
- break;
- if(!m_pScreenSizeTemporaryTexture[0])
- break;
- if(bNeedScreenSizeTexture)
- {
- if(!m_pScreenSizeTemporaryTexture[1])
- break;
- }
- }
- else
- {
- if(!m_pResizerPixelShader[0])
- break;
- if(bNeedScreenSizeTexture)
- {
- if(!m_pScreenSizeTemporaryTexture[0])
- break;
- if(!m_pScreenSizeTemporaryTexture[1])
- break;
- }
- }
- return S_OK;
- }
- while(0);
-
- m_bicubicA = bicubicA;
- m_pScreenSizeTemporaryTexture[0] = NULL;
- m_pScreenSizeTemporaryTexture[1] = NULL;
-
- for(int i = 0; i < countof(m_pResizerPixelShader); i++)
- m_pResizerPixelShader[i] = NULL;
-
- if(m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
- return E_FAIL;
-
- LPCSTR pProfile = m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
-
- CStringA str;
- if(!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE")))
- return E_FAIL;
-
- CStringA A;
- A.Format("(%f)", bicubicA);
- str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
-
- LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
-
- ASSERT(countof(pEntries) == countof(m_pResizerPixelShader));
-
- for(int i = 0; i < countof(pEntries); i++)
- {
- CString ErrorMessage;
- CString DissAssembly;
- hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShader[i], &DissAssembly, &ErrorMessage);
- if(FAILED(hr))
- {
- TRACE("%ws", ErrorMessage.GetString());
- ASSERT(0);
- return hr;
- }
- /*
- if (i == 2 || i == 3)
- {
- const wchar_t *pStr = DissAssembly.GetString();
- TRACE("DisAsm: %s\n", pEntries[i]);
- const wchar_t *pStrStart = pStr;
- while (*pStr)
- {
- while (*pStr && *pStr != '\n')
- ++pStr;
- if (*pStr == '\n')
- ++pStr;
- if (*pStr == '\r')
- ++pStr;
- CString Test(pStrStart, pStr - pStrStart);
- TRACE("%ws", Test.GetString());
- pStrStart = pStr;
- }
- }
- */
- }
-
- if(m_bicubicA || bNeedScreenSizeTexture)
- {
- if(FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL)))
- {
- ASSERT(0);
- m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
- }
- }
- if(m_bicubicA || bNeedScreenSizeTexture)
- {
- if(FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL)))
- {
- ASSERT(0);
- m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
- }
- }
-
- return S_OK;
+ HRESULT hr;
+
+ do
+ {
+ if (bicubicA)
+ {
+ if (!m_pResizerPixelShader[0])
+ break;
+ if (!m_pResizerPixelShader[1])
+ break;
+ if (!m_pResizerPixelShader[2])
+ break;
+ if (!m_pResizerPixelShader[3])
+ break;
+ if (m_bicubicA != bicubicA)
+ break;
+ if (!m_pScreenSizeTemporaryTexture[0])
+ break;
+ if (bNeedScreenSizeTexture)
+ {
+ if (!m_pScreenSizeTemporaryTexture[1])
+ break;
+ }
+ }
+ else
+ {
+ if (!m_pResizerPixelShader[0])
+ break;
+ if (bNeedScreenSizeTexture)
+ {
+ if (!m_pScreenSizeTemporaryTexture[0])
+ break;
+ if (!m_pScreenSizeTemporaryTexture[1])
+ break;
+ }
+ }
+ return S_OK;
+ }
+ while (0);
+
+ m_bicubicA = bicubicA;
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
+
+ for(int i = 0; i < countof(m_pResizerPixelShader); i++)
+ m_pResizerPixelShader[i] = NULL;
+
+ if(m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
+ return E_FAIL;
+
+ LPCSTR pProfile = m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
+
+ CStringA str;
+ if(!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE")))
+ return E_FAIL;
+
+ CStringA A;
+ A.Format("(%f)", bicubicA);
+ str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
+
+ LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
+
+ ASSERT(countof(pEntries) == countof(m_pResizerPixelShader));
+
+ for(int i = 0; i < countof(pEntries); i++)
+ {
+ CString ErrorMessage;
+ CString DissAssembly;
+ hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShader[i], &DissAssembly, &ErrorMessage);
+ if(FAILED(hr))
+ {
+ TRACE("%ws", ErrorMessage.GetString());
+ ASSERT (0);
+ return hr;
+ }
+/*
+ if (i == 2 || i == 3)
+ {
+ const wchar_t *pStr = DissAssembly.GetString();
+ TRACE("DisAsm: %s\n", pEntries[i]);
+ const wchar_t *pStrStart = pStr;
+ while (*pStr)
+ {
+ while (*pStr && *pStr != '\n')
+ ++pStr;
+ if (*pStr == '\n')
+ ++pStr;
+ if (*pStr == '\r')
+ ++pStr;
+ CString Test(pStrStart, pStr - pStrStart);
+ TRACE("%ws", Test.GetString());
+ pStrStart = pStr;
+ }
+ }
+*/
+ }
+
+ if(m_bicubicA || bNeedScreenSizeTexture)
+ {
+ if(FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL)))
+ {
+ ASSERT(0);
+ m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
+ }
+ }
+ if(m_bicubicA || bNeedScreenSizeTexture)
+ {
+ if(FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL)))
+ {
+ ASSERT(0);
+ m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
+ }
+ }
+
+ return S_OK;
}
HRESULT CDX9AllocatorPresenter::TextureCopy(CComPtr<IDirect3DTexture9> pTexture)
{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
-
- float w = (float)desc.Width;
- float h = (float)desc.Height;
-
- MYD3DVERTEX<1> v[] =
- {
- {0, 0, 0.5f, 2.0f, 0, 0},
- {w, 0, 0.5f, 2.0f, 1, 0},
- {0, h, 0.5f, 2.0f, 0, 1},
- {w, h, 0.5f, 2.0f, 1, 1},
- };
-
- for(int i = 0; i < countof(v); i++)
- {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
- return TextureBlt(m_pD3DDev, v, D3DTEXF_LINEAR);
+ MYD3DVERTEX<1> v[] =
+ {
+ {0, 0, 0.5f, 2.0f, 0, 0},
+ {w, 0, 0.5f, 2.0f, 1, 0},
+ {0, h, 0.5f, 2.0f, 0, 1},
+ {w, h, 0.5f, 2.0f, 1, 1},
+ };
+
+ for(int i = 0; i < countof(v); i++)
+ {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+
+ return TextureBlt(m_pD3DDev, v, D3DTEXF_LINEAR);
}
HRESULT CDX9AllocatorPresenter::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect)
{
- DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
- MYD3DVERTEX<0> v[] =
- {
- {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
- };
-
- for(int i = 0; i < countof(v); i++)
- {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
-
- return ::DrawRect(m_pD3DDev, v);
+ DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
+ MYD3DVERTEX<0> v[] =
+ {
+ {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ };
+
+ for(int i = 0; i < countof(v); i++)
+ {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+
+ return ::DrawRect(m_pD3DDev, v);
}
HRESULT CDX9AllocatorPresenter::TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
- float w = (float)desc.Width;
- float h = (float)desc.Height;
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
- float dx = 1.0f / w;
- float dy = 1.0f / h;
- float dx2 = 1.0 / w;
- float dy2 = 1.0 / h;
+ float dx = 1.0f/w;
+ float dy = 1.0f/h;
+ float dx2 = 1.0/w;
+ float dy2 = 1.0/h;
- MYD3DVERTEX<1> v[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, SrcRect.left * dx2, SrcRect.top * dy2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, SrcRect.right * dx2, SrcRect.top * dy2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, SrcRect.left * dx2, SrcRect.bottom * dy2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, SrcRect.right * dx2, SrcRect.bottom * dy2},
- };
+ MYD3DVERTEX<1> v[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, SrcRect.left * dx2, SrcRect.top * dy2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, SrcRect.right * dx2, SrcRect.top * dy2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, SrcRect.left * dx2, SrcRect.bottom * dy2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, SrcRect.right * dx2, SrcRect.bottom * dy2},
+ };
- AdjustQuad(v, 0, 0);
+ AdjustQuad(v, 0, 0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(NULL);
+ hr = m_pD3DDev->SetPixelShader(NULL);
- hr = TextureBlt(m_pD3DDev, v, filter);
+ hr = TextureBlt(m_pD3DDev, v, filter);
- return hr;
+ return hr;
}
HRESULT CDX9AllocatorPresenter::TextureResizeBilinear(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
- // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
- const float dx = 1.0f / (float)desc.Width;
- const float dy = 1.0f / (float)desc.Height;
- const float tx0 = SrcRect.left;
- const float tx1 = SrcRect.right;
- const float ty0 = SrcRect.top;
- const float ty1 = SrcRect.bottom;
+ // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
+ const float dx = 1.0f/(float)desc.Width;
+ const float dy = 1.0f/(float)desc.Height;
+ const float tx0 = SrcRect.left;
+ const float tx1 = SrcRect.right;
+ const float ty0 = SrcRect.top;
+ const float ty1 = SrcRect.bottom;
- MYD3DVERTEX<1> v[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
- };
+ MYD3DVERTEX<1> v[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
+ };
- AdjustQuad(v, 1.0, 1.0);
+ AdjustQuad(v, 1.0, 1.0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- float fConstData[][4] = {{dx * 0.5f, dy * 0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ float fConstData[][4] = {{dx*0.5f, dy*0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[0]);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[0]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- //
+ //
- m_pD3DDev->SetPixelShader(NULL);
+ m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ return hr;
}
HRESULT CDX9AllocatorPresenter::TextureResizeBicubic1pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
- // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
- const float dx = 1.0f / (float)desc.Width;
- const float dy = 1.0f / (float)desc.Height;
- const float tx0 = SrcRect.left;
- const float tx1 = SrcRect.right;
- const float ty0 = SrcRect.top;
- const float ty1 = SrcRect.bottom;
+ // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
+ const float dx = 1.0f/(float)desc.Width;
+ const float dy = 1.0f/(float)desc.Height;
+ const float tx0 = SrcRect.left;
+ const float tx1 = SrcRect.right;
+ const float ty0 = SrcRect.top;
+ const float ty1 = SrcRect.bottom;
- MYD3DVERTEX<1> v[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
- };
+ MYD3DVERTEX<1> v[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
+ };
- AdjustQuad(v, 1.0, 1.0);
+ AdjustQuad(v, 1.0, 1.0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- float fConstData[][4] = {{dx * 0.5f, dy * 0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ float fConstData[][4] = {{dx*0.5f, dy*0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[1]);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[1]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
+ m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ return hr;
}
HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect)
{
- // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+ // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
- HRESULT hr;
+ HRESULT hr;
- // rotated?
- if(dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
- || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+ // rotated?
+ if(dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
+ || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
- float Tex0_Width = desc.Width;
- float Tex0_Height = desc.Height;
+ float Tex0_Width = desc.Width;
+ float Tex0_Height = desc.Height;
- double dx0 = 1.0 / desc.Width;
- double dy0 = 1.0 / desc.Height;
+ double dx0 = 1.0/desc.Width;
+ double dy0 = 1.0/desc.Height;
- CSize SrcTextSize = CSize(desc.Width, desc.Height);
- double w = (double)SrcRect.Width();
- double h = (double)SrcRect.Height();
+ CSize SrcTextSize = CSize(desc.Width, desc.Height);
+ double w = (double)SrcRect.Width();
+ double h = (double)SrcRect.Height();
- CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
+ CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
- if(!m_pScreenSizeTemporaryTexture[0] || FAILED(m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc)))
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+ if(!m_pScreenSizeTemporaryTexture[0] || FAILED(m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc)))
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
- float Tex1_Width = desc.Width;
- float Tex1_Height = desc.Height;
+ float Tex1_Width = desc.Width;
+ float Tex1_Height = desc.Height;
- double dx1 = 1.0 / desc.Width;
- double dy1 = 1.0 / desc.Height;
+ double dx1 = 1.0/desc.Width;
+ double dy1 = 1.0/desc.Height;
- double dw = (double)dst1.Width() / desc.Width;
- double dh = (double)dst1.Height() / desc.Height;
+ double dw = (double)dst1.Width() / desc.Width;
+ double dh = (double)dst1.Height() / desc.Height;
- float dx2 = 1.0f / SrcTextSize.cx;
- float dy2 = 1.0f / SrcTextSize.cy;
- float tx0 = SrcRect.left;
- float tx1 = SrcRect.right;
- float ty0 = SrcRect.top;
- float ty1 = SrcRect.bottom;
+ float dx2 = 1.0f/SrcTextSize.cx;
+ float dy2 = 1.0f/SrcTextSize.cy;
+ float tx0 = SrcRect.left;
+ float tx1 = SrcRect.right;
+ float ty0 = SrcRect.top;
+ float ty1 = SrcRect.bottom;
- float tx0_2 = 0;
- float tx1_2 = dst1.Width();
- float ty0_2 = 0;
- float ty1_2 = h;
+ float tx0_2 = 0;
+ float tx1_2 = dst1.Width();
+ float ty0_2 = 0;
+ float ty1_2 = h;
// ASSERT(dst1.Height() == desc.Height);
- if(dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
- // if(dst1.Width() != desc.Width || dst1.Height() != desc.Height)
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+ if(dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
+ // if(dst1.Width() != desc.Width || dst1.Height() != desc.Height)
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
- MYD3DVERTEX<1> vx[] =
- {
- {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
- {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
- {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
- {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
- };
+ MYD3DVERTEX<1> vx[] =
+ {
+ {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
+ {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
+ {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
+ {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
+ };
- AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug ici, génére des bandes verticales! TODO : pourquoi ??????
+ AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug ici, génére des bandes verticales! TODO : pourquoi ??????
- MYD3DVERTEX<1> vy[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0 / dst[0].z, tx0_2, ty0_2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0 / dst[1].z, tx1_2, ty0_2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0 / dst[2].z, tx0_2, ty1_2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0 / dst[3].z, tx1_2, ty1_2},
- };
+ MYD3DVERTEX<1> vy[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0/dst[0].z, tx0_2, ty0_2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0/dst[1].z, tx1_2, ty0_2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0/dst[2].z, tx0_2, ty1_2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0/dst[3].z, tx1_2, ty1_2},
+ };
- AdjustQuad(vy, 0.0, 1.0); // Casimir666 : bug ici, génére des bandes horizontales! TODO : pourquoi ??????
+ AdjustQuad(vy, 0.0, 1.0); // Casimir666 : bug ici, génére des bandes horizontales! TODO : pourquoi ??????
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[2]);
- {
- float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- }
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[2]);
+ {
+ float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ }
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- CComPtr<IDirect3DSurface9> pRTOld;
- hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
+ CComPtr<IDirect3DSurface9> pRTOld;
+ hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[0]->GetSurfaceLevel(0, &pRT);
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[0]->GetSurfaceLevel(0, &pRT);
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
- hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
+ hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[3]);
- {
- float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- }
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[3]);
+ {
+ float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ }
- hr = m_pD3DDev->SetTexture(0, m_pScreenSizeTemporaryTexture[0]);
+ hr = m_pD3DDev->SetTexture(0, m_pScreenSizeTemporaryTexture[0]);
- hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
+ hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
- hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
+ hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
+ m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ return hr;
}
HRESULT CDX9AllocatorPresenter::AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture)
{
- if(!pSrc || !pDst)
- return E_POINTER;
+ if(!pSrc || !pDst)
+ return E_POINTER;
- CRect src(*pSrc), dst(*pDst);
+ CRect src(*pSrc), dst(*pDst);
- HRESULT hr;
+ HRESULT hr;
do
- {
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
- break;
+ {
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
+ break;
float w = (float)d3dsd.Width;
float h = (float)d3dsd.Height;
- struct
- {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] =
- {
- {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
- {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
- {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
- {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
- };
- /*
- for(int i = 0; i < countof(pVertices); i++)
- {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
- */
+ struct
+ {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] =
+ {
+ {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
+ {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
+ {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
+ };
+/*
+ for(int i = 0; i < countof(pVertices); i++)
+ {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+*/
hr = m_pD3DDev->SetTexture(0, pTexture);
- DWORD abe, sb, db;
- hr = m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe);
- hr = m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb);
- hr = m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db);
+ DWORD abe, sb, db;
+ hr = m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe);
+ hr = m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb);
+ hr = m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db);
hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
@@ -1890,1450 +1825,1431 @@ HRESULT CDX9AllocatorPresenter::AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect
hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- /*//
+ /*//
- D3DCAPS9 d3dcaps9;
- hr = m_pD3DDev->GetDeviceCaps(&d3dcaps9);
- if(d3dcaps9.AlphaCmpCaps & D3DPCMPCAPS_LESS)
- {
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000FE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAFUNC, D3DPCMPCAPS_LESS);
- }
+ D3DCAPS9 d3dcaps9;
+ hr = m_pD3DDev->GetDeviceCaps(&d3dcaps9);
+ if(d3dcaps9.AlphaCmpCaps & D3DPCMPCAPS_LESS)
+ {
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000FE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAFUNC, D3DPCMPCAPS_LESS);
+ }
- *///
+ *///
hr = m_pD3DDev->SetPixelShader(NULL);
hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
- hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
+ hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
//
- m_pD3DDev->SetTexture(0, NULL);
+ m_pD3DDev->SetTexture(0, NULL);
- m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
+ m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
- return S_OK;
+ return S_OK;
}
- while(0);
+ while(0);
return E_FAIL;
}
void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter)
{
- // Calculate the jitter!
- LONGLONG llPerf = PerfCounter;
- if((m_rtTimePerFrame != 0) && (labs((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame * 3))
- {
- m_nNextJitter = (m_nNextJitter + 1) % NB_JITTER;
- m_pllJitter[m_nNextJitter] = llPerf - m_llLastPerf;
-
- m_MaxJitter = MINLONG64;
- m_MinJitter = MAXLONG64;
-
- // Calculate the real FPS
- LONGLONG llJitterSum = 0;
- LONGLONG llJitterSumAvg = 0;
- for(int i = 0; i < NB_JITTER; i++)
- {
- LONGLONG Jitter = m_pllJitter[i];
- llJitterSum += Jitter;
- llJitterSumAvg += Jitter;
- }
- double FrameTimeMean = double(llJitterSumAvg) / NB_JITTER;
- m_fJitterMean = FrameTimeMean;
- double DeviationSum = 0;
- for(int i = 0; i < NB_JITTER; i++)
- {
- LONGLONG DevInt = m_pllJitter[i] - FrameTimeMean;
- double Deviation = DevInt;
- DeviationSum += Deviation * Deviation;
- m_MaxJitter = max(m_MaxJitter, DevInt);
- m_MinJitter = min(m_MinJitter, DevInt);
- }
- double StdDev = sqrt(DeviationSum / NB_JITTER);
-
- m_fJitterStdDev = StdDev;
-
- m_fAvrFps = 10000000.0 / (double(llJitterSum) / NB_JITTER);
- }
-
- m_llLastPerf = llPerf;
+ // Calculate the jitter!
+ LONGLONG llPerf = PerfCounter;
+ if ((m_rtTimePerFrame != 0) && (labs ((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame*3) )
+ {
+ m_nNextJitter = (m_nNextJitter+1) % NB_JITTER;
+ m_pllJitter[m_nNextJitter] = llPerf - m_llLastPerf;
+
+ m_MaxJitter = MINLONG64;
+ m_MinJitter = MAXLONG64;
+
+ // Calculate the real FPS
+ LONGLONG llJitterSum = 0;
+ LONGLONG llJitterSumAvg = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG Jitter = m_pllJitter[i];
+ llJitterSum += Jitter;
+ llJitterSumAvg += Jitter;
+ }
+ double FrameTimeMean = double(llJitterSumAvg)/NB_JITTER;
+ m_fJitterMean = FrameTimeMean;
+ double DeviationSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG DevInt = m_pllJitter[i] - FrameTimeMean;
+ double Deviation = DevInt;
+ DeviationSum += Deviation*Deviation;
+ m_MaxJitter = max(m_MaxJitter, DevInt);
+ m_MinJitter = min(m_MinJitter, DevInt);
+ }
+ double StdDev = sqrt(DeviationSum/NB_JITTER);
+
+ m_fJitterStdDev = StdDev;
+
+ m_fAvrFps = 10000000.0/(double(llJitterSum)/NB_JITTER);
+ }
+
+ m_llLastPerf = llPerf;
}
bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime)
{
- LONGLONG llPerf;
- if(_bMeasureTime)
- llPerf = AfxGetMyApp()->GetPerfCounter();
-
- int ScanLine = 0;
- _ScanLine = 0;
- _bInVBlank = 0;
- if(m_pDirectDraw)
- {
- DWORD ScanLineGet = 0;
- m_pDirectDraw->GetScanLine(&ScanLineGet);
- BOOL InVBlank;
- if(m_pDirectDraw->GetVerticalBlankStatus(&InVBlank) != S_OK)
- return false;
- ScanLine = ScanLineGet;
- _bInVBlank = InVBlank;
- if(InVBlank)
- ScanLine = 0;
- }
- else
- {
- D3DRASTER_STATUS RasterStatus;
- if(m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK)
- return false;;
- ScanLine = RasterStatus.ScanLine;
- _bInVBlank = RasterStatus.InVBlank;
- }
- if(_bMeasureTime)
- {
- m_VBlankMax = max(m_VBlankMax, ScanLine);
- if(ScanLine != 0 && !_bInVBlank)
- m_VBlankMinCalc = min(m_VBlankMinCalc, ScanLine);
- m_VBlankMin = m_VBlankMax - m_ScreenSize.cy;
- }
- if(_bInVBlank)
- _ScanLine = 0;
- else if(m_VBlankMin != 300000)
- _ScanLine = ScanLine - m_VBlankMin;
- else
- _ScanLine = ScanLine;
-
- if(_bMeasureTime)
- {
- LONGLONG Time = AfxGetMyApp()->GetPerfCounter() - llPerf;
- m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time);
- }
-
- return true;
+ LONGLONG llPerf;
+ if (_bMeasureTime)
+ llPerf = AfxGetMyApp()->GetPerfCounter();
+
+ int ScanLine = 0;
+ _ScanLine = 0;
+ _bInVBlank = 0;
+ if (m_pDirectDraw)
+ {
+ DWORD ScanLineGet = 0;
+ m_pDirectDraw->GetScanLine(&ScanLineGet);
+ BOOL InVBlank;
+ if (m_pDirectDraw->GetVerticalBlankStatus (&InVBlank) != S_OK)
+ return false;
+ ScanLine = ScanLineGet;
+ _bInVBlank = InVBlank;
+ if (InVBlank)
+ ScanLine = 0;
+ }
+ else
+ {
+ D3DRASTER_STATUS RasterStatus;
+ if (m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK)
+ return false;;
+ ScanLine = RasterStatus.ScanLine;
+ _bInVBlank = RasterStatus.InVBlank;
+ }
+ if (_bMeasureTime)
+ {
+ m_VBlankMax = max(m_VBlankMax, ScanLine);
+ if (ScanLine != 0 && !_bInVBlank)
+ m_VBlankMinCalc = min(m_VBlankMinCalc, ScanLine);
+ m_VBlankMin = m_VBlankMax - m_ScreenSize.cy;
+ }
+ if (_bInVBlank)
+ _ScanLine = 0;
+ else if (m_VBlankMin != 300000)
+ _ScanLine = ScanLine - m_VBlankMin;
+ else
+ _ScanLine = ScanLine;
+
+ if (_bMeasureTime)
+ {
+ LONGLONG Time = AfxGetMyApp()->GetPerfCounter() - llPerf;
+ m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time);
+ }
+
+ return true;
}
bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSize, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock)
{
- if(_bMeasure)
- m_RasterStatusWaitTimeMaxCalc = 0;
- bool bWaited = false;
- int ScanLine = 0;
- int InVBlank = 0;
- LONGLONG llPerf;
- if(_bMeasure)
- llPerf = AfxGetMyApp()->GetPerfCounter();
- GetVBlank(ScanLine, InVBlank, _bMeasure);
- if(_bMeasure)
- m_VBlankStartWait = ScanLine;
-
- static bool bOneWait = true;
- if(bOneWait && _bMeasure)
- {
- bOneWait = false;
- // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
- int nInVBlank = 0;
- while(1)
- {
- if(!GetVBlank(ScanLine, InVBlank, _bMeasure))
- break;
-
- if(InVBlank && nInVBlank == 0)
- {
- nInVBlank = 1;
- }
- else if(!InVBlank && nInVBlank == 1)
- {
- nInVBlank = 2;
- }
- else if(InVBlank && nInVBlank == 2)
- {
- nInVBlank = 3;
- }
- else if(!InVBlank && nInVBlank == 3)
- {
- break;
- }
- }
- }
- if(_bWaitIfInside)
- {
- int ScanLineDiff = long(ScanLine) - _RasterStart;
- if(ScanLineDiff > m_ScreenSize.cy / 2)
- ScanLineDiff -= m_ScreenSize.cy;
- else if(ScanLineDiff < -m_ScreenSize.cy / 2)
- ScanLineDiff += m_ScreenSize.cy;
-
- if(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize)
- {
- bWaited = true;
- // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
- int LastLineDiff = ScanLineDiff;
- while(1)
- {
- if(!GetVBlank(ScanLine, InVBlank, _bMeasure))
- break;
- int ScanLineDiff = long(ScanLine) - _RasterStart;
- if(ScanLineDiff > m_ScreenSize.cy / 2)
- ScanLineDiff -= m_ScreenSize.cy;
- else if(ScanLineDiff < -m_ScreenSize.cy / 2)
- ScanLineDiff += m_ScreenSize.cy;
- if(!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
- break;
- LastLineDiff = ScanLineDiff;
- Sleep(1); // Just sleep
- }
- }
- }
- double RefreshRate = GetRefreshRate();
- LONG ScanLines = GetScanLines();
- int MinRange = max(min(int(0.0015 * double(ScanLines) * RefreshRate + 0.5), ScanLines / 3), 5); // 1.5 ms or max 33 % of Time
- int NoSleepStart = _RasterStart - MinRange;
- int NoSleepRange = MinRange;
- if(NoSleepStart < 0)
- NoSleepStart += m_ScreenSize.cy;
-
- int MinRange2 = max(min(int(0.0050 * double(ScanLines) * RefreshRate + 0.5), ScanLines / 3), 5); // 5 ms or max 33 % of Time
- int D3DDevLockStart = _RasterStart - MinRange2;
- int D3DDevLockRange = MinRange2;
- if(D3DDevLockStart < 0)
- D3DDevLockStart += m_ScreenSize.cy;
-
- int ScanLineDiff = ScanLine - _RasterStart;
- if(ScanLineDiff > m_ScreenSize.cy / 2)
- ScanLineDiff -= m_ScreenSize.cy;
- else if(ScanLineDiff < -m_ScreenSize.cy / 2)
- ScanLineDiff += m_ScreenSize.cy;
- int LastLineDiff = ScanLineDiff;
-
-
- int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
- if(ScanLineDiffSleep > m_ScreenSize.cy / 2)
- ScanLineDiffSleep -= m_ScreenSize.cy;
- else if(ScanLineDiffSleep < -m_ScreenSize.cy / 2)
- ScanLineDiffSleep += m_ScreenSize.cy;
- int LastLineDiffSleep = ScanLineDiffSleep;
-
-
- int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
- if(ScanLineDiffLock > m_ScreenSize.cy / 2)
- ScanLineDiffLock -= m_ScreenSize.cy;
- else if(ScanLineDiffLock < -m_ScreenSize.cy / 2)
- ScanLineDiffLock += m_ScreenSize.cy;
- int LastLineDiffLock = ScanLineDiffLock;
-
- LONGLONG llPerfLock;
-
- while(1)
- {
- if(!GetVBlank(ScanLine, InVBlank, _bMeasure))
- break;
- int ScanLineDiff = long(ScanLine) - _RasterStart;
- if(ScanLineDiff > m_ScreenSize.cy / 2)
- ScanLineDiff -= m_ScreenSize.cy;
- else if(ScanLineDiff < -m_ScreenSize.cy / 2)
- ScanLineDiff += m_ScreenSize.cy;
- if((ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
- break;
-
- LastLineDiff = ScanLineDiff;
-
- bWaited = true;
-
- int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
- if(ScanLineDiffLock > m_ScreenSize.cy / 2)
- ScanLineDiffLock -= m_ScreenSize.cy;
- else if(ScanLineDiffLock < -m_ScreenSize.cy / 2)
- ScanLineDiffLock += m_ScreenSize.cy;
-
- if(((ScanLineDiffLock >= 0 && ScanLineDiffLock <= D3DDevLockRange) || (LastLineDiffLock < 0 && ScanLineDiffLock > 0)))
- {
- if(!_bTakenLock && _bMeasure)
- {
- _bTakenLock = true;
- llPerfLock = AfxGetMyApp()->GetPerfCounter();
- LockD3DDevice();
- }
- }
- LastLineDiffLock = ScanLineDiffLock;
-
-
- int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
- if(ScanLineDiffSleep > m_ScreenSize.cy / 2)
- ScanLineDiffSleep -= m_ScreenSize.cy;
- else if(ScanLineDiffSleep < -m_ScreenSize.cy / 2)
- ScanLineDiffSleep += m_ScreenSize.cy;
-
- if(!((ScanLineDiffSleep >= 0 && ScanLineDiffSleep <= NoSleepRange) || (LastLineDiffSleep < 0 && ScanLineDiffSleep > 0)) || !_bNeedAccurate)
- {
- //TRACE("%d\n", RasterStatus.ScanLine);
- Sleep(1); // Don't sleep for the last 1.5 ms scan lines, so we get maximum precision
- }
- LastLineDiffSleep = ScanLineDiffSleep;
- }
- _RasterStart = ScanLine;
- if(_bMeasure)
- {
- m_VBlankEndWait = ScanLine;
- m_VBlankWaitTime = AfxGetMyApp()->GetPerfCounter() - llPerf;
-
- if(_bTakenLock)
- {
- m_VBlankLockTime = AfxGetMyApp()->GetPerfCounter() - llPerfLock;
- }
- else
- m_VBlankLockTime = 0;
-
- m_RasterStatusWaitTime = m_RasterStatusWaitTimeMaxCalc;
- m_RasterStatusWaitTimeMin = min(m_RasterStatusWaitTimeMin, m_RasterStatusWaitTime);
- m_RasterStatusWaitTimeMax = max(m_RasterStatusWaitTimeMax, m_RasterStatusWaitTime);
- }
-
- return bWaited;
+ if (_bMeasure)
+ m_RasterStatusWaitTimeMaxCalc = 0;
+ bool bWaited = false;
+ int ScanLine = 0;
+ int InVBlank = 0;
+ LONGLONG llPerf;
+ if (_bMeasure)
+ llPerf = AfxGetMyApp()->GetPerfCounter();
+ GetVBlank(ScanLine, InVBlank, _bMeasure);
+ if (_bMeasure)
+ m_VBlankStartWait = ScanLine;
+
+ static bool bOneWait = true;
+ if (bOneWait && _bMeasure)
+ {
+ bOneWait = false;
+ // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
+ int nInVBlank = 0;
+ while (1)
+ {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ break;
+
+ if (InVBlank && nInVBlank == 0)
+ {
+ nInVBlank = 1;
+ }
+ else if (!InVBlank && nInVBlank == 1)
+ {
+ nInVBlank = 2;
+ }
+ else if (InVBlank && nInVBlank == 2)
+ {
+ nInVBlank = 3;
+ }
+ else if (!InVBlank && nInVBlank == 3)
+ {
+ break;
+ }
+ }
+ }
+ if (_bWaitIfInside)
+ {
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+
+ if (ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize)
+ {
+ bWaited = true;
+ // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
+ int LastLineDiff = ScanLineDiff;
+ while (1)
+ {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ break;
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+ if (!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
+ break;
+ LastLineDiff = ScanLineDiff;
+ Sleep(1); // Just sleep
+ }
+ }
+ }
+ double RefreshRate = GetRefreshRate();
+ LONG ScanLines = GetScanLines();
+ int MinRange = max(min(int(0.0015 * double(ScanLines) * RefreshRate + 0.5), ScanLines/3), 5); // 1.5 ms or max 33 % of Time
+ int NoSleepStart = _RasterStart - MinRange;
+ int NoSleepRange = MinRange;
+ if (NoSleepStart < 0)
+ NoSleepStart += m_ScreenSize.cy;
+
+ int MinRange2 = max(min(int(0.0050 * double(ScanLines) * RefreshRate + 0.5), ScanLines/3), 5); // 5 ms or max 33 % of Time
+ int D3DDevLockStart = _RasterStart - MinRange2;
+ int D3DDevLockRange = MinRange2;
+ if (D3DDevLockStart < 0)
+ D3DDevLockStart += m_ScreenSize.cy;
+
+ int ScanLineDiff = ScanLine - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+ int LastLineDiff = ScanLineDiff;
+
+
+ int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
+ if (ScanLineDiffSleep > m_ScreenSize.cy / 2)
+ ScanLineDiffSleep -= m_ScreenSize.cy;
+ else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2)
+ ScanLineDiffSleep += m_ScreenSize.cy;
+ int LastLineDiffSleep = ScanLineDiffSleep;
+
+
+ int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
+ if (ScanLineDiffLock > m_ScreenSize.cy / 2)
+ ScanLineDiffLock -= m_ScreenSize.cy;
+ else if (ScanLineDiffLock < -m_ScreenSize.cy / 2)
+ ScanLineDiffLock += m_ScreenSize.cy;
+ int LastLineDiffLock = ScanLineDiffLock;
+
+ LONGLONG llPerfLock;
+
+ while (1)
+ {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ break;
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+ if ((ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
+ break;
+
+ LastLineDiff = ScanLineDiff;
+
+ bWaited = true;
+
+ int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
+ if (ScanLineDiffLock > m_ScreenSize.cy / 2)
+ ScanLineDiffLock -= m_ScreenSize.cy;
+ else if (ScanLineDiffLock < -m_ScreenSize.cy / 2)
+ ScanLineDiffLock += m_ScreenSize.cy;
+
+ if (((ScanLineDiffLock >= 0 && ScanLineDiffLock <= D3DDevLockRange) || (LastLineDiffLock < 0 && ScanLineDiffLock > 0)))
+ {
+ if (!_bTakenLock && _bMeasure)
+ {
+ _bTakenLock = true;
+ llPerfLock = AfxGetMyApp()->GetPerfCounter();
+ LockD3DDevice();
+ }
+ }
+ LastLineDiffLock = ScanLineDiffLock;
+
+
+ int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
+ if (ScanLineDiffSleep > m_ScreenSize.cy / 2)
+ ScanLineDiffSleep -= m_ScreenSize.cy;
+ else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2)
+ ScanLineDiffSleep += m_ScreenSize.cy;
+
+ if (!((ScanLineDiffSleep >= 0 && ScanLineDiffSleep <= NoSleepRange) || (LastLineDiffSleep < 0 && ScanLineDiffSleep > 0)) || !_bNeedAccurate)
+ {
+ //TRACE("%d\n", RasterStatus.ScanLine);
+ Sleep(1); // Don't sleep for the last 1.5 ms scan lines, so we get maximum precision
+ }
+ LastLineDiffSleep = ScanLineDiffSleep;
+ }
+ _RasterStart = ScanLine;
+ if (_bMeasure)
+ {
+ m_VBlankEndWait = ScanLine;
+ m_VBlankWaitTime = AfxGetMyApp()->GetPerfCounter() - llPerf;
+
+ if (_bTakenLock)
+ {
+ m_VBlankLockTime = AfxGetMyApp()->GetPerfCounter() - llPerfLock;
+ }
+ else
+ m_VBlankLockTime = 0;
+
+ m_RasterStatusWaitTime = m_RasterStatusWaitTimeMaxCalc;
+ m_RasterStatusWaitTimeMin = min(m_RasterStatusWaitTimeMin, m_RasterStatusWaitTime);
+ m_RasterStatusWaitTimeMax = max(m_RasterStatusWaitTimeMax, m_RasterStatusWaitTime);
+ }
+
+ return bWaited;
}
int CDX9AllocatorPresenter::GetVBlackPos()
{
- AppSettings& s = AfxGetAppSettings();
- BOOL bCompositionEnabled = m_bCompositionEnabled;
-
- int WaitRange = max(m_ScreenSize.cy / 40, 5);
- if(!bCompositionEnabled)
- {
- if(m_bAlternativeVSync)
- {
- return s.m_RenderSettings.iVMR9VSyncOffset;
- }
- else
- {
- int MinRange = max(min(int(0.005 * double(m_ScreenSize.cy) * GetRefreshRate() + 0.5), m_ScreenSize.cy / 3), 5); // 5 ms or max 33 % of Time
- int WaitFor = m_ScreenSize.cy - (MinRange + WaitRange);
- return WaitFor;
- }
- }
- else
- {
- int WaitFor = m_ScreenSize.cy / 2;
- return WaitFor;
- }
+ AppSettings& s = AfxGetAppSettings();
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ int WaitRange = max(m_ScreenSize.cy / 40, 5);
+ if (!bCompositionEnabled)
+ {
+ if (m_bAlternativeVSync)
+ {
+ return s.m_RenderSettings.iVMR9VSyncOffset;
+ }
+ else
+ {
+ int MinRange = max(min(int(0.005 * double(m_ScreenSize.cy) * GetRefreshRate() + 0.5), m_ScreenSize.cy/3), 5); // 5 ms or max 33 % of Time
+ int WaitFor = m_ScreenSize.cy - (MinRange + WaitRange);
+ return WaitFor;
+ }
+ }
+ else
+ {
+ int WaitFor = m_ScreenSize.cy / 2;
+ return WaitFor;
+ }
}
bool CDX9AllocatorPresenter::WaitForVBlank(bool &_Waited, bool &_bTakenLock)
{
- AppSettings& s = AfxGetAppSettings();
- if(!s.m_RenderSettings.iVMR9VSync)
- {
- _Waited = true;
- m_VBlankWaitTime = 0;
- m_VBlankLockTime = 0;
- m_VBlankEndWait = 0;
- m_VBlankStartWait = 0;
- return true;
- }
+ AppSettings& s = AfxGetAppSettings();
+ if (!s.m_RenderSettings.iVMR9VSync)
+ {
+ _Waited = true;
+ m_VBlankWaitTime = 0;
+ m_VBlankLockTime = 0;
+ m_VBlankEndWait = 0;
+ m_VBlankStartWait = 0;
+ return true;
+ }
// _Waited = true;
// return false;
- BOOL bCompositionEnabled = m_bCompositionEnabled;
- int WaitFor = GetVBlackPos();
-
- if(!bCompositionEnabled)
- {
- if(m_bAlternativeVSync)
- {
- _Waited = WaitForVBlankRange(WaitFor, 0, false, true, true, _bTakenLock);
- return false;
- }
- else
- {
- _Waited = WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
- return true;
- }
- }
- else
- {
- // Instead we wait for VBlack after the present, this seems to fix the stuttering problem. It's also possible to fix by removing the Sleep above, but that isn't an option.
- WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
-
- return false;
- }
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+ int WaitFor = GetVBlackPos();
+
+ if (!bCompositionEnabled)
+ {
+ if (m_bAlternativeVSync)
+ {
+ _Waited = WaitForVBlankRange(WaitFor, 0, false, true, true, _bTakenLock);
+ return false;
+ }
+ else
+ {
+ _Waited = WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
+ return true;
+ }
+ }
+ else
+ {
+ // Instead we wait for VBlack after the present, this seems to fix the stuttering problem. It's also possible to fix by removing the Sleep above, but that isn't an option.
+ WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
+
+ return false;
+ }
}
void CDX9AllocatorPresenter::UpdateAlphaBitmap()
{
- m_VMR9AlphaBitmapData.Free();
-
- if((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
- {
- HBITMAP hBitmap = (HBITMAP)GetCurrentObject(m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
- if(!hBitmap)
- return;
- DIBSECTION info = {0};
- if(!::GetObject(hBitmap, sizeof(DIBSECTION), &info))
- return;
-
- m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
- m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
-
- if(m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight))
- {
- memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
- }
- }
+ m_VMR9AlphaBitmapData.Free();
+
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
+ {
+ HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
+ if (!hBitmap)
+ return;
+ DIBSECTION info = {0};
+ if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info ))
+ return;
+
+ m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
+ m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
+
+ if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight))
+ {
+ memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
+ }
+ }
}
STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
{
// if (!fAll)
// return false;
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
// TRACE("Thread: %d\n", (LONG)((CRITICAL_SECTION &)m_RenderLock).OwningThread);
#if 0
- if(TryEnterCriticalSection(&(CRITICAL_SECTION &)(*((CCritSec *)this))))
- {
- LeaveCriticalSection((&(CRITICAL_SECTION &)(*((CCritSec *)this))));
- }
- else
- {
- __asm
- {
- int 3
- };
- }
+ if (TryEnterCriticalSection (&(CRITICAL_SECTION &)(*((CCritSec *)this))))
+ {
+ LeaveCriticalSection((&(CRITICAL_SECTION &)(*((CCritSec *)this))));
+ }
+ else
+ {
+ __asm {
+ int 3
+ };
+ }
#endif
- CMPlayerCApp * pApp = AfxGetMyApp();
+ CMPlayerCApp * pApp = AfxGetMyApp();
- LONGLONG StartPaint = pApp->GetPerfCounter();
- CAutoLock cRenderLock(&m_RenderLock);
+ LONGLONG StartPaint = pApp->GetPerfCounter();
+ CAutoLock cRenderLock(&m_RenderLock);
- if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
- || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
- || !m_pVideoSurface)
- {
- if(m_OrderedPaint)
- --m_OrderedPaint;
- else
- {
+ if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
+ || !m_pVideoSurface)
+ {
+ if (m_OrderedPaint)
+ --m_OrderedPaint;
+ else
+ {
// TRACE("UNORDERED PAINT!!!!!!\n");
- }
+ }
- return(false);
- }
+ return(false);
+ }
- HRESULT hr;
+ HRESULT hr;
- CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
- CRect rDstVid(m_VideoRect);
+ CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
+ CRect rDstVid(m_VideoRect);
- CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
- CRect rDstPri(m_WindowRect);
+ CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
+ CRect rDstPri(m_WindowRect);
- m_pD3DDev->BeginScene();
+ m_pD3DDev->BeginScene();
- CComPtr<IDirect3DSurface9> pBackBuffer;
- m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
+ CComPtr<IDirect3DSurface9> pBackBuffer;
+ m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
- m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
// if(fAll)
- {
- // clear the backbuffer
+ {
+ // clear the backbuffer
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- // paint the video on the backbuffer
+ // paint the video on the backbuffer
- if(!rDstVid.IsRectEmpty())
- {
- if(m_pVideoTexture[m_nCurSurface])
- {
- CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
+ if(!rDstVid.IsRectEmpty())
+ {
+ if(m_pVideoTexture[m_nCurSurface])
+ {
+ CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
- if(m_pVideoTexture[m_nNbDXSurface] && m_pVideoTexture[m_nNbDXSurface+1] && !m_pPixelShaders.IsEmpty())
- {
- static __int64 counter = 0;
- static long start = clock();
+ if(m_pVideoTexture[m_nNbDXSurface] && m_pVideoTexture[m_nNbDXSurface+1] && !m_pPixelShaders.IsEmpty())
+ {
+ static __int64 counter = 0;
+ static long start = clock();
- long stop = clock();
- long diff = stop - start;
+ long stop = clock();
+ long diff = stop - start;
- if(diff >= 10 * 60 * CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+ if(diff >= 10*60*CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
- int src = m_nCurSurface, dst = m_nNbDXSurface;
+ int src = m_nCurSurface, dst = m_nNbDXSurface;
- D3DSURFACE_DESC desc;
- m_pVideoTexture[src]->GetLevelDesc(0, &desc);
+ D3DSURFACE_DESC desc;
+ m_pVideoTexture[src]->GetLevelDesc(0, &desc);
#if 1
- float fConstData[][4] =
- {
- {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
- };
+ float fConstData[][4] =
+ {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
#else
- float fConstData[][4] =
- {
- {(float)m_NativeVideoSize.cx, (float)m_NativeVideoSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / m_NativeVideoSize.cx, 1.0f / m_NativeVideoSize.cy, 0, 0},
- };
+ float fConstData[][4] =
+ {
+ {(float)m_NativeVideoSize.cx, (float)m_NativeVideoSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / m_NativeVideoSize.cx, 1.0f / m_NativeVideoSize.cy, 0, 0},
+ };
#endif
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
-
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pD3DDev->GetRenderTarget(0, &pRT);
-
- POSITION pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
- pVideoTexture = m_pVideoTexture[dst];
-
- hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- if(!Shader.m_pPixelShader)
- Shader.Compile(m_pPSC);
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- TextureCopy(m_pVideoTexture[src]);
-
- //if(++src > 2) src = 1;
- //if(++dst > 2) dst = 1;
- src = dst;
- if(++dst >= m_nNbDXSurface + 2) dst = m_nNbDXSurface;
- }
-
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- hr = m_pD3DDev->SetPixelShader(NULL);
- }
-
- Vector dst[4];
- Transform(rDstVid, dst);
-
- DWORD iDX9Resizer = s.iDX9Resizer;
-
- float A = 0;
-
- switch(iDX9Resizer)
- {
- case 3:
- A = -0.60f;
- break;
- case 4:
- A = -0.751f;
- break; // FIXME : 0.75 crash recent D3D, or eat CPU
- case 5:
- A = -1.00f;
- break;
- }
- bool bScreenSpacePixelShaders = !m_pPixelShadersScreenSpace.IsEmpty();
-
- hr = InitResizers(A, bScreenSpacePixelShaders);
-
- if(!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1])
- bScreenSpacePixelShaders = false;
-
- if(bScreenSpacePixelShaders)
- {
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
- if(hr != S_OK)
- bScreenSpacePixelShaders = false;
- if(bScreenSpacePixelShaders)
- {
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- if(hr != S_OK)
- bScreenSpacePixelShaders = false;
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- }
- }
-
- if(rSrcVid.Size() != rDstVid.Size())
- {
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pD3DDev->GetRenderTarget(0, &pRT);
+
+ POSITION pos = m_pPixelShaders.GetHeadPosition();
+ while(pos)
+ {
+ pVideoTexture = m_pVideoTexture[dst];
+
+ hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
+ CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
+ if (!Shader.m_pPixelShader)
+ Shader.Compile(m_pPSC);
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pVideoTexture[src]);
+
+ //if(++src > 2) src = 1;
+ //if(++dst > 2) dst = 1;
+ src = dst;
+ if(++dst >= m_nNbDXSurface+2) dst = m_nNbDXSurface;
+ }
+
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ }
+
+ Vector dst[4];
+ Transform(rDstVid, dst);
+
+ DWORD iDX9Resizer = s.iDX9Resizer;
+
+ float A = 0;
+
+ switch(iDX9Resizer)
+ {
+ case 3: A = -0.60f; break;
+ case 4: A = -0.751f; break; // FIXME : 0.75 crash recent D3D, or eat CPU
+ case 5: A = -1.00f; break;
+ }
+ bool bScreenSpacePixelShaders = !m_pPixelShadersScreenSpace.IsEmpty();
+
+ hr = InitResizers(A, bScreenSpacePixelShaders);
+
+ if (!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1])
+ bScreenSpacePixelShaders = false;
+
+ if (bScreenSpacePixelShaders)
+ {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
+ if (hr != S_OK)
+ bScreenSpacePixelShaders = false;
+ if (bScreenSpacePixelShaders)
+ {
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ if (hr != S_OK)
+ bScreenSpacePixelShaders = false;
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ }
+ }
+
+ if(rSrcVid.Size() != rDstVid.Size())
+ {
// if((iDX9Resizer == 0 || iDX9Resizer == 1 || rSrcVid.Size() == rDstVid.Size() || FAILED(hr)))
- if(iDX9Resizer == 0 || iDX9Resizer == 1)
- {
- D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
- hr = TextureResize(pVideoTexture, dst, Filter, rSrcVid);
- }
- else if(iDX9Resizer == 2)
- {
- hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
- }
- else if(iDX9Resizer >= 3)
- {
- hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
- }
- }
- else hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
-
- if(bScreenSpacePixelShaders)
- {
- static __int64 counter = 555;
- static long start = clock() + 333;
-
- long stop = clock() + 333;
- long diff = stop - start;
-
- if(diff >= 10 * 60 * CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
-
- D3DSURFACE_DESC desc;
- m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc);
+ if(iDX9Resizer == 0 || iDX9Resizer == 1)
+ {
+ D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
+ hr = TextureResize(pVideoTexture, dst, Filter, rSrcVid);
+ }
+ else if(iDX9Resizer == 2)
+ {
+ hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
+ }
+ else if(iDX9Resizer >= 3)
+ {
+ hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
+ }
+ }
+ else hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
+
+ if (bScreenSpacePixelShaders)
+ {
+ static __int64 counter = 555;
+ static long start = clock() + 333;
+
+ long stop = clock() + 333;
+ long diff = stop - start;
+
+ if(diff >= 10*60*CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+
+ D3DSURFACE_DESC desc;
+ m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc);
#if 1
- float fConstData[][4] =
- {
- {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
- };
+ float fConstData[][4] =
+ {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
#else
- float fConstData[][4] =
- {
- {(float)m_ScreenSize.cx, (float)m_ScreenSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / m_ScreenSize.cx, 1.0f / m_ScreenSize.cy, 0, 0},
- };
+ float fConstData[][4] =
+ {
+ {(float)m_ScreenSize.cx, (float)m_ScreenSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / m_ScreenSize.cx, 1.0f / m_ScreenSize.cy, 0, 0},
+ };
#endif
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
-
- int src = 1, dst = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
- if(m_pPixelShadersScreenSpace.GetTailPosition() == pos)
- {
- m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- }
- else
- {
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[dst]->GetSurfaceLevel(0, &pRT);
- m_pD3DDev->SetRenderTarget(0, pRT);
- }
-
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- if(!Shader.m_pPixelShader)
- Shader.Compile(m_pPSC);
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- TextureCopy(m_pScreenSizeTemporaryTexture[src]);
-
- swap(src, dst);
- }
-
- hr = m_pD3DDev->SetPixelShader(NULL);
- }
- }
- else
- {
- if(pBackBuffer)
- {
- ClipToSurface(pBackBuffer, rSrcVid, rDstVid); // grrr
- // IMPORTANT: rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect!!!
- rSrcVid.left &= ~1;
- rSrcVid.right &= ~1;
- rSrcVid.top &= ~1;
- rSrcVid.bottom &= ~1;
- hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
-
- // Support ffdshow queueing
- // m_pD3DDev->StretchRect may fail if ffdshow is using queue output samples.
- // Here we don't want to show the black buffer.
- if(FAILED(hr))
- {
- if(m_OrderedPaint)
- --m_OrderedPaint;
- else
- {
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+
+ int src = 1, dst = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ if (m_pPixelShadersScreenSpace.GetTailPosition() == pos)
+ {
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ }
+ else
+ {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[dst]->GetSurfaceLevel(0, &pRT);
+ m_pD3DDev->SetRenderTarget(0, pRT);
+ }
+
+ CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ if (!Shader.m_pPixelShader)
+ Shader.Compile(m_pPSC);
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pScreenSizeTemporaryTexture[src]);
+
+ swap(src, dst);
+ }
+
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ }
+ }
+ else
+ {
+ if(pBackBuffer)
+ {
+ ClipToSurface(pBackBuffer, rSrcVid, rDstVid); // grrr
+ // IMPORTANT: rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect!!!
+ rSrcVid.left &= ~1; rSrcVid.right &= ~1;
+ rSrcVid.top &= ~1; rSrcVid.bottom &= ~1;
+ hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
+
+ // Support ffdshow queueing
+ // m_pD3DDev->StretchRect may fail if ffdshow is using queue output samples.
+ // Here we don't want to show the black buffer.
+ if(FAILED(hr))
+ {
+ if (m_OrderedPaint)
+ --m_OrderedPaint;
+ else
+ {
// TRACE("UNORDERED PAINT!!!!!!\n");
- }
-
- return false;
- }
- }
- }
- }
-
- // paint the text on the backbuffer
-
- AlphaBltSubPic(rSrcPri.Size());
- }
-
-
- // Casimir666 : affichage de l'OSD
- if(m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE)
- {
- CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
- CRect rcSrc(m_VMR9AlphaBitmap.rSrc);
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- if((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData)
- {
- if((m_pD3DXLoadSurfaceFromMemory != NULL) &&
- SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
- D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)))
- {
- if(SUCCEEDED(hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface)))
- {
- hr = m_pD3DXLoadSurfaceFromMemory(m_pOSDSurface,
- NULL,
- NULL,
- (BYTE *)m_VMR9AlphaBitmapData,
- D3DFMT_A8R8G8B8,
- m_VMR9AlphaBitmapWidthBytes,
- NULL,
- &m_VMR9AlphaBitmapRect,
- D3DX_FILTER_NONE,
- m_VMR9AlphaBitmap.clrSrcKey);
- }
- if(FAILED(hr))
- {
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- }
- }
- }
- m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
-
- }
-
- if(pApp->m_fDisplayStats)
- DrawStats();
-
- {
- CString Temp;
- Temp.Format(L"GPU %7.3f ms", (double(m_WaitForGPUTime) / 10000.0));
+ }
+
+ return false;
+ }
+ }
+ }
+ }
+
+ // paint the text on the backbuffer
+
+ AlphaBltSubPic(rSrcPri.Size());
+ }
+
+
+ // Casimir666 : affichage de l'OSD
+ if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE)
+ {
+ CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
+ CRect rcSrc (m_VMR9AlphaBitmap.rSrc);
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData)
+ {
+ if( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
+ SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
+ D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) )
+ {
+ if (SUCCEEDED (hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface)))
+ {
+ hr = m_pD3DXLoadSurfaceFromMemory (m_pOSDSurface,
+ NULL,
+ NULL,
+ (BYTE *)m_VMR9AlphaBitmapData,
+ D3DFMT_A8R8G8B8,
+ m_VMR9AlphaBitmapWidthBytes,
+ NULL,
+ &m_VMR9AlphaBitmapRect,
+ D3DX_FILTER_NONE,
+ m_VMR9AlphaBitmap.clrSrcKey);
+ }
+ if (FAILED (hr))
+ {
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ }
+ }
+ }
+ m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
+
+ }
+
+ if (pApp->m_fDisplayStats)
+ DrawStats();
+
+ {
+ CString Temp;
+ Temp.Format(L"GPU %7.3f ms", (double(m_WaitForGPUTime)/10000.0));
// TRACE("%ws\n", Temp.GetString());
- }
-
- if(m_pOSDTexture) AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
-
- m_pD3DDev->EndScene();
-
- BOOL bCompositionEnabled = m_bCompositionEnabled;
-
- bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
-
- LONGLONG PresentWaitTime = 0;
- /* if(fAll && m_fVMRSyncFix && bDoVSyncInPresent)
- {
- LONGLONG llPerf = pApp->GetPerfCounter();
- D3DLOCKED_RECT lr;
- if(SUCCEEDED(pBackBuffer->LockRect(&lr, NULL, 0)))
- pBackBuffer->UnlockRect();
- PresentWaitTime = pApp->GetPerfCounter() - llPerf;
- }*/
-
- CComPtr<IDirect3DQuery9> pEventQuery;
-
- m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
- if(pEventQuery)
- pEventQuery->Issue(D3DISSUE_END);
-
- if(s.m_RenderSettings.iVMRFlushGPUBeforeVSync && pEventQuery)
- {
- LONGLONG llPerf = pApp->GetPerfCounter();
- BOOL Data;
- //Sleep(5);
- LONGLONG FlushStartTime = pApp->GetPerfCounter();
- while(S_FALSE == pEventQuery->GetData(&Data, sizeof(Data), D3DGETDATA_FLUSH))
- {
- if(!s.m_RenderSettings.iVMRFlushGPUWait)
- break;
- Sleep(1);
- if(pApp->GetPerfCounter() - FlushStartTime > 500000)
- break; // timeout after 50 ms
- }
- if(s.m_RenderSettings.iVMRFlushGPUWait)
- m_WaitForGPUTime = pApp->GetPerfCounter() - llPerf;
- else
- m_WaitForGPUTime = 0;
- }
- else
- m_WaitForGPUTime = 0;
- if(fAll)
- {
- m_PaintTime = (AfxGetMyApp()->GetPerfCounter() - StartPaint);
- m_PaintTimeMin = min(m_PaintTimeMin, m_PaintTime);
- m_PaintTimeMax = max(m_PaintTimeMax, m_PaintTime);
-
- }
-
- bool bWaited = false;
- bool bTakenLock = false;
- if(fAll)
- {
- // Only sync to refresh when redrawing all
- bool bTest = WaitForVBlank(bWaited, bTakenLock);
- ASSERT(bTest == bDoVSyncInPresent);
- if(!bDoVSyncInPresent)
- {
- LONGLONG Time = pApp->GetPerfCounter();
- OnVBlankFinished(fAll, Time);
- if(!m_bIsEVR || m_OrderedPaint)
- CalculateJitter(Time);
- }
- }
-
-
- // Create a device pointer m_pd3dDevice
-
- // Create a query object
-
-
- {
- CComPtr<IDirect3DQuery9> pEventQuery;
- m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
-
- LONGLONG llPerf = pApp->GetPerfCounter();
- if(m_pD3DDevEx)
- {
- if(m_bIsFullscreen)
- hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
- else
- hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
- }
- else
- {
- if(m_bIsFullscreen)
- hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
- else
- hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
- }
- // Issue an End event
- if(pEventQuery)
- pEventQuery->Issue(D3DISSUE_END);
-
- BOOL Data;
-
- if(s.m_RenderSettings.iVMRFlushGPUAfterPresent && pEventQuery)
- {
- LONGLONG FlushStartTime = pApp->GetPerfCounter();
- while(S_FALSE == pEventQuery->GetData(&Data, sizeof(Data), D3DGETDATA_FLUSH))
- {
- if(!s.m_RenderSettings.iVMRFlushGPUWait)
- break;
- if(pApp->GetPerfCounter() - FlushStartTime > 500000)
- break; // timeout after 50 ms
- }
- }
-
- int ScanLine;
- int bInVBlank;
- GetVBlank(ScanLine, bInVBlank, false);
-
- if(fAll && (!m_bIsEVR || m_OrderedPaint))
- {
- m_VBlankEndPresent = ScanLine;
- }
-
- while(ScanLine == 0 || bInVBlank)
- {
- GetVBlank(ScanLine, bInVBlank, false);
-
- }
- m_VBlankStartMeasureTime = pApp->GetPerfCounter();
- m_VBlankStartMeasure = ScanLine;
-
- if(fAll && bDoVSyncInPresent)
- {
- m_PresentWaitTime = (pApp->GetPerfCounter() - llPerf) + PresentWaitTime;
- m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
- m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
- }
- else
- {
- m_PresentWaitTime = 0;
- m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
- m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
- }
- }
-
- if(bDoVSyncInPresent)
- {
- LONGLONG Time = pApp->GetPerfCounter();
- if(!m_bIsEVR || m_OrderedPaint)
- CalculateJitter(Time);
- OnVBlankFinished(fAll, Time);
- }
-
- if(bTakenLock)
- UnlockD3DDevice();
-
-
- /* if (!bWaited)
- {
- bWaited = true;
- WaitForVBlank(bWaited);
- TRACE("Double VBlank\n");
- ASSERT(bWaited);
- if (!bDoVSyncInPresent)
- {
- CalculateJitter();
- OnVBlankFinished(fAll);
- }
- }*/
- bool fResetDevice = m_bPendingResetDevice;
-
- if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET
- || hr == S_PRESENT_MODE_CHANGED)
- {
- fResetDevice = true;
- }
-
- if(SettingsNeedResetDevice())
- fResetDevice = true;
-
- bCompositionEnabled = false;
- if(m_pDwmIsCompositionEnabled)
- m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- if((bCompositionEnabled != 0) != m_bCompositionEnabled)
- {
- if(m_bIsFullscreen)
- {
- m_bCompositionEnabled = (bCompositionEnabled != 0);
- }
- else
- fResetDevice = true;
- }
-
- if(s.fResetDevice)
- {
- D3DDEVICE_CREATION_PARAMETERS Parameters;
- if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters)) && m_pD3D->GetAdapterMonitor(Parameters.AdapterOrdinal) != m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)))
- {
- fResetDevice = true;
- }
- }
-
- if(fResetDevice)
- {
- if(m_bNeedPendingResetDevice)
- {
- m_bPendingResetDevice = true;
- }
- else
- {
- if(m_MainThreadId && m_MainThreadId == GetCurrentThreadId())
- {
- m_bPendingResetDevice = false;
- ResetDevice();
- }
- else
- m_bPendingResetDevice = true;
- }
- }
-
- if(m_OrderedPaint)
- --m_OrderedPaint;
- else
- {
- //if (m_bIsEVR)
- // TRACE("UNORDERED PAINT!!!!!!\n");
- }
- return(true);
+ }
+
+ if (m_pOSDTexture) AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+
+ m_pD3DDev->EndScene();
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
+
+ LONGLONG PresentWaitTime = 0;
+/* if(fAll && m_fVMRSyncFix && bDoVSyncInPresent)
+ {
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ D3DLOCKED_RECT lr;
+ if(SUCCEEDED(pBackBuffer->LockRect(&lr, NULL, 0)))
+ pBackBuffer->UnlockRect();
+ PresentWaitTime = pApp->GetPerfCounter() - llPerf;
+ }*/
+
+ CComPtr<IDirect3DQuery9> pEventQuery;
+
+ m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
+ if (pEventQuery)
+ pEventQuery->Issue(D3DISSUE_END);
+
+ if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync && pEventQuery)
+ {
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ BOOL Data;
+ //Sleep(5);
+ LONGLONG FlushStartTime = pApp->GetPerfCounter();
+ while(S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH ))
+ {
+ if (!s.m_RenderSettings.iVMRFlushGPUWait)
+ break;
+ Sleep(1);
+ if (pApp->GetPerfCounter() - FlushStartTime > 500000)
+ break; // timeout after 50 ms
+ }
+ if (s.m_RenderSettings.iVMRFlushGPUWait)
+ m_WaitForGPUTime = pApp->GetPerfCounter() - llPerf;
+ else
+ m_WaitForGPUTime = 0;
+ }
+ else
+ m_WaitForGPUTime = 0;
+ if (fAll)
+ {
+ m_PaintTime = (AfxGetMyApp()->GetPerfCounter() - StartPaint);
+ m_PaintTimeMin = min(m_PaintTimeMin, m_PaintTime);
+ m_PaintTimeMax = max(m_PaintTimeMax, m_PaintTime);
+
+ }
+
+ bool bWaited = false;
+ bool bTakenLock = false;
+ if (fAll)
+ {
+ // Only sync to refresh when redrawing all
+ bool bTest = WaitForVBlank(bWaited, bTakenLock);
+ ASSERT(bTest == bDoVSyncInPresent);
+ if (!bDoVSyncInPresent)
+ {
+ LONGLONG Time = pApp->GetPerfCounter();
+ OnVBlankFinished(fAll, Time);
+ if (!m_bIsEVR || m_OrderedPaint)
+ CalculateJitter(Time);
+ }
+ }
+
+
+ // Create a device pointer m_pd3dDevice
+
+ // Create a query object
+
+
+ {
+ CComPtr<IDirect3DQuery9> pEventQuery;
+ m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
+
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ if (m_pD3DDevEx)
+ {
+ if (m_bIsFullscreen)
+ hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
+ else
+ hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
+ }
+ else
+ {
+ if (m_bIsFullscreen)
+ hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
+ else
+ hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ }
+ // Issue an End event
+ if (pEventQuery)
+ pEventQuery->Issue(D3DISSUE_END);
+
+ BOOL Data;
+
+ if (s.m_RenderSettings.iVMRFlushGPUAfterPresent && pEventQuery)
+ {
+ LONGLONG FlushStartTime = pApp->GetPerfCounter();
+ while (S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH ))
+ {
+ if (!s.m_RenderSettings.iVMRFlushGPUWait)
+ break;
+ if (pApp->GetPerfCounter() - FlushStartTime > 500000)
+ break; // timeout after 50 ms
+ }
+ }
+
+ int ScanLine;
+ int bInVBlank;
+ GetVBlank(ScanLine, bInVBlank, false);
+
+ if (fAll && (!m_bIsEVR || m_OrderedPaint))
+ {
+ m_VBlankEndPresent = ScanLine;
+ }
+
+ while (ScanLine == 0 || bInVBlank)
+ {
+ GetVBlank(ScanLine, bInVBlank, false);
+
+ }
+ m_VBlankStartMeasureTime = pApp->GetPerfCounter();
+ m_VBlankStartMeasure = ScanLine;
+
+ if (fAll && bDoVSyncInPresent)
+ {
+ m_PresentWaitTime = (pApp->GetPerfCounter() - llPerf) + PresentWaitTime;
+ m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
+ m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
+ }
+ else
+ {
+ m_PresentWaitTime = 0;
+ m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
+ m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
+ }
+ }
+
+ if (bDoVSyncInPresent)
+ {
+ LONGLONG Time = pApp->GetPerfCounter();
+ if (!m_bIsEVR || m_OrderedPaint)
+ CalculateJitter(Time);
+ OnVBlankFinished(fAll, Time);
+ }
+
+ if (bTakenLock)
+ UnlockD3DDevice();
+
+
+/* if (!bWaited)
+ {
+ bWaited = true;
+ WaitForVBlank(bWaited);
+ TRACE("Double VBlank\n");
+ ASSERT(bWaited);
+ if (!bDoVSyncInPresent)
+ {
+ CalculateJitter();
+ OnVBlankFinished(fAll);
+ }
+ }*/
+ bool fResetDevice = m_bPendingResetDevice;
+
+ if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET
+ || hr == S_PRESENT_MODE_CHANGED)
+ {
+ fResetDevice = true;
+ }
+
+ if (SettingsNeedResetDevice())
+ fResetDevice = true;
+
+ bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled)
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ if ((bCompositionEnabled != 0) != m_bCompositionEnabled)
+ {
+ if (m_bIsFullscreen)
+ {
+ m_bCompositionEnabled = (bCompositionEnabled != 0);
+ }
+ else
+ fResetDevice = true;
+ }
+
+ if(s.fResetDevice)
+ {
+ D3DDEVICE_CREATION_PARAMETERS Parameters;
+ if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters)) && m_pD3D->GetAdapterMonitor(Parameters.AdapterOrdinal) != m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)))
+ {
+ fResetDevice = true;
+ }
+ }
+
+ if(fResetDevice)
+ {
+ if (m_bNeedPendingResetDevice)
+ {
+ m_bPendingResetDevice = true;
+ }
+ else
+ {
+ if (m_MainThreadId && m_MainThreadId == GetCurrentThreadId())
+ {
+ m_bPendingResetDevice = false;
+ ResetDevice();
+ }
+ else
+ m_bPendingResetDevice = true;
+ }
+ }
+
+ if (m_OrderedPaint)
+ --m_OrderedPaint;
+ else
+ {
+ //if (m_bIsEVR)
+ // TRACE("UNORDERED PAINT!!!!!!\n");
+ }
+ return(true);
}
double CDX9AllocatorPresenter::GetFrameTime()
{
- if(m_DetectedLock)
- return m_DetectedFrameTime;
+ if (m_DetectedLock)
+ return m_DetectedFrameTime;
- return m_rtTimePerFrame / 10000000.0;
+ return m_rtTimePerFrame / 10000000.0;
}
double CDX9AllocatorPresenter::GetFrameRate()
{
- if(m_DetectedLock)
- return m_DetectedFrameRate;
+ if (m_DetectedLock)
+ return m_DetectedFrameRate;
- return 10000000.0 / m_rtTimePerFrame;
+ return 10000000.0 / m_rtTimePerFrame;
}
bool CDX9AllocatorPresenter::ResetDevice()
{
- StopWorkerThreads();
- DeleteSurfaces();
- HRESULT hr;
- CString Error;
- // TODO: Report error messages here
- if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces()))
- {
- return false;
- }
- OnResetDevice();
-
- return true;
+ StopWorkerThreads();
+ DeleteSurfaces();
+ HRESULT hr;
+ CString Error;
+ // TODO: Report error messages here
+ if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces()))
+ {
+ return false;
+ }
+ OnResetDevice();
+
+ return true;
}
void CDX9AllocatorPresenter::DrawText(const RECT &rc, const CString &strText, int _Priority)
{
- if(_Priority < 1)
- return;
- int Quality = 1;
- D3DXCOLOR Color1(1.0f, 0.2f, 0.2f, 1.0f);
- D3DXCOLOR Color0(0.0f, 0.0f, 0.0f, 1.0f);
- RECT Rect1 = rc;
- RECT Rect2 = rc;
- if(Quality == 1)
- OffsetRect(&Rect2 , 2, 2);
- else
- OffsetRect(&Rect2 , -1, -1);
- if(Quality > 0)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 1, 0);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 1, 0);
- if(Quality > 2)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 0, 1);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 0, 1);
- if(Quality > 1)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , -1, 0);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , -1, 0);
- if(Quality > 2)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 0, -1);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
+ if (_Priority < 1)
+ return;
+ int Quality = 1;
+ D3DXCOLOR Color1( 1.0f, 0.2f, 0.2f, 1.0f );
+ D3DXCOLOR Color0( 0.0f, 0.0f, 0.0f, 1.0f );
+ RECT Rect1 = rc;
+ RECT Rect2 = rc;
+ if (Quality == 1)
+ OffsetRect (&Rect2 , 2, 2);
+ else
+ OffsetRect (&Rect2 , -1, -1);
+ if (Quality > 0)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 1, 0);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 1, 0);
+ if (Quality > 2)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, 1);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, 1);
+ if (Quality > 1)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , -1, 0);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , -1, 0);
+ if (Quality > 2)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, -1);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
}
void CDX9AllocatorPresenter::DrawStats()
{
- AppSettings& s = AfxGetAppSettings();
- CMPlayerCApp * pApp = AfxGetMyApp();
- int bDetailedStats = 2;
- switch(pApp->m_fDisplayStats)
- {
- case 1:
- bDetailedStats = 2;
- break;
- case 2:
- bDetailedStats = 1;
- break;
- case 3:
- bDetailedStats = 0;
- break;
- }
-
- LONGLONG llMaxJitter = m_MaxJitter;
- LONGLONG llMinJitter = m_MinJitter;
- LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
- LONGLONG llMinSyncOffset = m_MinSyncOffset;
- if(m_pFont && m_pSprite)
- {
- m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
- RECT rc = {700, 40, 0, 0 };
- rc.left = 40;
- CString strText;
- int TextHeight = 25.0 * m_TextScale + 0.5;
+ AppSettings& s = AfxGetAppSettings();
+ CMPlayerCApp * pApp = AfxGetMyApp();
+ int bDetailedStats = 2;
+ switch (pApp->m_fDisplayStats)
+ {
+ case 1: bDetailedStats = 2; break;
+ case 2: bDetailedStats = 1; break;
+ case 3: bDetailedStats = 0; break;
+ }
+
+ LONGLONG llMaxJitter = m_MaxJitter;
+ LONGLONG llMinJitter = m_MinJitter;
+ LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
+ LONGLONG llMinSyncOffset = m_MinSyncOffset;
+ if (m_pFont && m_pSprite)
+ {
+ m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
+ RECT rc = {700, 40, 0, 0 };
+ rc.left = 40;
+ CString strText;
+ int TextHeight = 25.0*m_TextScale + 0.5;
// strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s) Clock: %7.3f ms %+1.4f %% %+1.9f %+1.9f", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_ClockDiff/10000.0, m_ModeratedTimeSpeed*100.0 - 100.0, m_ModeratedTimeSpeedDiff, m_ClockDiffCalc/10000.0);
- if(bDetailedStats > 1)
- {
- if(m_bIsEVR)
- strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed * 100.0);
- else
- strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P");
- }
+ if (bDetailedStats > 1)
+ {
+ if (m_bIsEVR)
+ strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed*100.0);
+ else
+ strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P");
+ }
// strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0);
- else
- strText.Format(L"Frame rate : %7.03f (%.03f%s)", m_fAvrFps, GetFrameRate(), m_DetectedLock ? L" L" : L"");
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(bDetailedStats > 1)
- {
- strText.Format(L"Settings : ");
-
- if(m_bIsEVR)
- strText += "EVR ";
- else
- strText += "VMR9 ";
-
- if(s.fD3DFullscreen)
- strText += "FS ";
- if(s.m_RenderSettings.iVMR9FullscreenGUISupport)
- strText += "FSGui ";
-
- if(s.m_RenderSettings.iVMRDisableDesktopComposition)
- strText += "DisDC ";
-
- if(s.m_RenderSettings.iVMRFlushGPUBeforeVSync)
- strText += "GPUFlushBV ";
- if(s.m_RenderSettings.iVMRFlushGPUAfterPresent)
- strText += "GPUFlushAP ";
-
- if(s.m_RenderSettings.iVMRFlushGPUWait)
- strText += "GPUFlushWt ";
-
- if(s.m_RenderSettings.iVMR9VSync)
- strText += "VS ";
- if(s.m_RenderSettings.fVMR9AlterativeVSync)
- strText += "AltVS ";
- if(s.m_RenderSettings.iVMR9VSyncAccurate)
- strText += "AccVS ";
- if(s.m_RenderSettings.iVMR9VSyncOffset)
- strText.AppendFormat(L"VSOfst(%d)", s.m_RenderSettings.iVMR9VSyncOffset);
-
- if(m_bIsEVR)
- {
- if(s.m_RenderSettings.iEVRHighColorResolution)
- strText += "10bit ";
- if(s.m_RenderSettings.iEVREnableFrameTimeCorrection)
- strText += "FTC ";
- if(s.m_RenderSettings.iEVROutputRange == 0)
- strText += "0-255 ";
- else if(s.m_RenderSettings.iEVROutputRange == 1)
- strText += "16-235 ";
- }
-
-
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- }
-
- if(bDetailedStats > 1)
- {
- strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s D3DExError: %s", GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType), m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.GetString());
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(m_bIsEVR)
- {
- strText.Format(L"Refresh rate : %.05f Hz SL: %4d (%3d Hz) Last Duration: %10.6f Corrected Frame Time: %s", m_DetectedRefreshRate, int(m_DetectedScanlinesPerFrame + 0.5), m_RefreshRate, double(m_LastFrameDuration) / 10000.0, m_bCorrectedFrameTime ? L"Yes" : L"No");
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
-
- if(m_bSyncStatsAvailable)
- {
- if(bDetailedStats > 1)
- strText.Format(L"Sync offset : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms, Avr = %7.3f ms, Mode = %d", (double(llMinSyncOffset) / 10000.0), (double(llMaxSyncOffset) / 10000.0), m_fSyncOffsetStdDev / 10000.0, m_fSyncOffsetAvr / 10000.0, m_VSyncMode);
- else
- strText.Format(L"Sync offset : Mode = %d", m_VSyncMode);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- if(bDetailedStats > 1)
- {
- strText.Format(L"Jitter : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms", (double(llMinJitter) / 10000.0), (double(llMaxJitter) / 10000.0), m_fJitterStdDev / 10000.0);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- if(m_pAllocator && bDetailedStats > 1)
- {
- CDX9SubPicAllocator *pAlloc = (CDX9SubPicAllocator *)m_pAllocator.p;
- int nFree = 0;
- int nAlloc = 0;
- int nSubPic = 0;
- REFERENCE_TIME QueueNow = 0;
- REFERENCE_TIME QueueStart = 0;
- REFERENCE_TIME QueueEnd = 0;
- if(m_pSubPicQueue)
- {
- m_pSubPicQueue->GetStats(nSubPic, QueueNow, QueueStart, QueueEnd);
- if(QueueStart)
- QueueStart -= QueueNow;
- if(QueueEnd)
- QueueEnd -= QueueNow;
- }
- pAlloc->GetStats(nFree, nAlloc);
- strText.Format(L"Subtitles : Free %d Allocated %d Buffered %d QueueStart %7.3f QueueEnd %7.3f", nFree, nAlloc, nSubPic, (double(QueueStart) / 10000000.0), (double(QueueEnd) / 10000000.0));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- if(bDetailedStats > 1)
- {
- if(m_VBlankEndPresent == -100000)
- strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime) / 10000.0), (double(m_VBlankLockTime) / 10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin);
- else
- strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d EndPresent %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime) / 10000.0), (double(m_VBlankLockTime) / 10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin, m_VBlankEndPresent);
- }
- else
- {
- if(m_VBlankEndPresent == -100000)
- strText.Format(L"VBlank Wait : Start %4d End %4d", m_VBlankStartWait, m_VBlankEndWait);
- else
- strText.Format(L"VBlank Wait : Start %4d End %4d EP %4d", m_VBlankStartWait, m_VBlankEndWait, m_VBlankEndPresent);
- }
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- BOOL bCompositionEnabled = m_bCompositionEnabled;
-
- bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
-
- if(bDetailedStats > 1 && bDoVSyncInPresent)
- {
- strText.Format(L"Present Wait : Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PresentWaitTime) / 10000.0), (double(m_PresentWaitTimeMin) / 10000.0), (double(m_PresentWaitTimeMax) / 10000.0));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- if(bDetailedStats > 1)
- {
- if(m_WaitForGPUTime)
- strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0), (double(m_PaintTimeMin) / 10000.0), (double(m_PaintTimeMax) / 10000.0), (double(m_WaitForGPUTime) / 10000.0));
- else
- strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0), (double(m_PaintTimeMin) / 10000.0), (double(m_PaintTimeMax) / 10000.0));
- }
- else
- {
- if(m_WaitForGPUTime)
- strText.Format(L"Paint Time : Draw %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0), (double(m_WaitForGPUTime) / 10000.0));
- else
- strText.Format(L"Paint Time : Draw %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0));
- }
- DrawText(rc, strText, 2);
- OffsetRect(&rc, 0, TextHeight);
-
- if(bDetailedStats > 1)
- {
- strText.Format(L"Raster Status: Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_RasterStatusWaitTime) / 10000.0), (double(m_RasterStatusWaitTimeMin) / 10000.0), (double(m_RasterStatusWaitTimeMax) / 10000.0));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- if(bDetailedStats > 1)
- {
- if(m_bIsEVR)
- strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nNbDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
- else
- strText.Format(L"Buffering : VMR9Surfaces %3d VMR9Surface %3d", m_nVMR9Surfaces, m_iVMR9Surface);
- }
- else
- strText.Format(L"Buffered : %3d", m_nUsedBuffer);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(bDetailedStats > 1)
- {
- strText.Format(L"Video size : %d x %d (AR = %d x %d)", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- if(m_pVideoTexture[0] || m_pVideoSurface[0])
- {
- D3DSURFACE_DESC desc;
- if(m_pVideoTexture[0])
- m_pVideoTexture[0]->GetLevelDesc(0, &desc);
- else if(m_pVideoSurface[0])
- m_pVideoSurface[0]->GetDesc(&desc);
-
- if(desc.Width != m_NativeVideoSize.cx || desc.Height != m_NativeVideoSize.cy)
- {
- strText.Format(L"Texture size : %d x %d", desc.Width, desc.Height);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
-
-
- strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(m_D3D9Device != _T(""))
- {
- strText = "Render device: " + m_D3D9Device;
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- strText.Format(L"DirectX SDK : %d", AfxGetMyApp()->GetDXSdkRelease());
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- for(int i = 0; i < 6; i++)
- {
- if(m_strStatsMsg[i][0])
- {
- DrawText(rc, m_strStatsMsg[i], 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
- }
- m_pSprite->End();
- }
-
- if(m_pLine && bDetailedStats)
- {
- D3DXVECTOR2 Points[NB_JITTER];
- int nIndex;
-
- int StartX = 0;
- int StartY = 0;
- int ScaleX = 1;
- int ScaleY = 1;
- int DrawWidth = 625 * ScaleX + 50;
- int DrawHeight = 500 * ScaleY;
- int Alpha = 80;
- StartX = m_WindowRect.Width() - (DrawWidth + 20);
- StartY = m_WindowRect.Height() - (DrawHeight + 20);
-
- DrawRect(RGB(0, 0, 0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
- // === Jitter Graduation
-// m_pLine->SetWidth(2.2); // Width
+ else
+ strText.Format(L"Frame rate : %7.03f (%.03f%s)", m_fAvrFps, GetFrameRate(), m_DetectedLock ? L" L" : L"");
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Settings : ");
+
+ if (m_bIsEVR)
+ strText += "EVR ";
+ else
+ strText += "VMR9 ";
+
+ if (s.fD3DFullscreen)
+ strText += "FS ";
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport)
+ strText += "FSGui ";
+
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ strText += "DisDC ";
+
+ if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync)
+ strText += "GPUFlushBV ";
+ if (s.m_RenderSettings.iVMRFlushGPUAfterPresent)
+ strText += "GPUFlushAP ";
+
+ if (s.m_RenderSettings.iVMRFlushGPUWait)
+ strText += "GPUFlushWt ";
+
+ if (s.m_RenderSettings.iVMR9VSync)
+ strText += "VS ";
+ if (s.m_RenderSettings.fVMR9AlterativeVSync)
+ strText += "AltVS ";
+ if (s.m_RenderSettings.iVMR9VSyncAccurate)
+ strText += "AccVS ";
+ if (s.m_RenderSettings.iVMR9VSyncOffset)
+ strText.AppendFormat(L"VSOfst(%d)", s.m_RenderSettings.iVMR9VSyncOffset);
+
+ if (m_bIsEVR)
+ {
+ if (s.m_RenderSettings.iEVRHighColorResolution)
+ strText += "10bit ";
+ if (s.m_RenderSettings.iEVREnableFrameTimeCorrection)
+ strText += "FTC ";
+ if (s.m_RenderSettings.iEVROutputRange == 0)
+ strText += "0-255 ";
+ else if (s.m_RenderSettings.iEVROutputRange == 1)
+ strText += "16-235 ";
+ }
+
+
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ }
+
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s D3DExError: %s", GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType), m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.GetString());
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ if (m_bIsEVR)
+ {
+ strText.Format(L"Refresh rate : %.05f Hz SL: %4d (%3d Hz) Last Duration: %10.6f Corrected Frame Time: %s", m_DetectedRefreshRate, int(m_DetectedScanlinesPerFrame + 0.5), m_RefreshRate, double(m_LastFrameDuration)/10000.0, m_bCorrectedFrameTime?L"Yes":L"No");
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+ }
+
+ if (m_bSyncStatsAvailable)
+ {
+ if (bDetailedStats > 1)
+ strText.Format(L"Sync offset : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms, Avr = %7.3f ms, Mode = %d", (double(llMinSyncOffset)/10000.0), (double(llMaxSyncOffset)/10000.0), m_fSyncOffsetStdDev/10000.0, m_fSyncOffsetAvr/10000.0, m_VSyncMode);
+ else
+ strText.Format(L"Sync offset : Mode = %d", m_VSyncMode);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Jitter : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms", (double(llMinJitter)/10000.0), (double(llMaxJitter)/10000.0), m_fJitterStdDev/10000.0);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (m_pAllocator && bDetailedStats > 1)
+ {
+ CDX9SubPicAllocator *pAlloc = (CDX9SubPicAllocator *)m_pAllocator.p;
+ int nFree = 0;
+ int nAlloc = 0;
+ int nSubPic = 0;
+ REFERENCE_TIME QueueNow = 0;
+ REFERENCE_TIME QueueStart = 0;
+ REFERENCE_TIME QueueEnd = 0;
+ if (m_pSubPicQueue)
+ {
+ m_pSubPicQueue->GetStats(nSubPic, QueueNow, QueueStart, QueueEnd);
+ if (QueueStart)
+ QueueStart -= QueueNow;
+ if (QueueEnd)
+ QueueEnd -= QueueNow;
+ }
+ pAlloc->GetStats(nFree, nAlloc);
+ strText.Format(L"Subtitles : Free %d Allocated %d Buffered %d QueueStart %7.3f QueueEnd %7.3f", nFree, nAlloc, nSubPic, (double(QueueStart)/10000000.0), (double(QueueEnd)/10000000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1)
+ {
+ if (m_VBlankEndPresent == -100000)
+ strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), (double(m_VBlankLockTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin);
+ else
+ strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d EndPresent %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), (double(m_VBlankLockTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin, m_VBlankEndPresent);
+ }
+ else
+ {
+ if (m_VBlankEndPresent == -100000)
+ strText.Format(L"VBlank Wait : Start %4d End %4d", m_VBlankStartWait, m_VBlankEndWait);
+ else
+ strText.Format(L"VBlank Wait : Start %4d End %4d EP %4d", m_VBlankStartWait, m_VBlankEndWait, m_VBlankEndPresent);
+ }
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
+
+ if (bDetailedStats > 1 && bDoVSyncInPresent)
+ {
+ strText.Format(L"Present Wait : Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PresentWaitTime)/10000.0), (double(m_PresentWaitTimeMin)/10000.0), (double(m_PresentWaitTimeMax)/10000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1)
+ {
+ if (m_WaitForGPUTime)
+ strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms GPU %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0), (double(m_WaitForGPUTime)/10000.0));
+ else
+ strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0));
+ }
+ else
+ {
+ if (m_WaitForGPUTime)
+ strText.Format(L"Paint Time : Draw %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0), (double(m_WaitForGPUTime)/10000.0));
+ else
+ strText.Format(L"Paint Time : Draw %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0));
+ }
+ DrawText(rc, strText, 2);
+ OffsetRect (&rc, 0, TextHeight);
+
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Raster Status: Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_RasterStatusWaitTime)/10000.0), (double(m_RasterStatusWaitTimeMin)/10000.0), (double(m_RasterStatusWaitTimeMax)/10000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1)
+ {
+ if (m_bIsEVR)
+ strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nNbDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
+ else
+ strText.Format(L"Buffering : VMR9Surfaces %3d VMR9Surface %3d", m_nVMR9Surfaces, m_iVMR9Surface);
+ }
+ else
+ strText.Format(L"Buffered : %3d", m_nUsedBuffer);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Video size : %d x %d (AR = %d x %d)", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ if (m_pVideoTexture[0] || m_pVideoSurface[0])
+ {
+ D3DSURFACE_DESC desc;
+ if (m_pVideoTexture[0])
+ m_pVideoTexture[0]->GetLevelDesc(0, &desc);
+ else if (m_pVideoSurface[0])
+ m_pVideoSurface[0]->GetDesc(&desc);
+
+ if (desc.Width != m_NativeVideoSize.cx || desc.Height != m_NativeVideoSize.cy)
+ {
+ strText.Format(L"Texture size : %d x %d", desc.Width, desc.Height);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+ }
+
+
+ strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ if(m_D3D9Device != _T(""))
+ {
+ strText = "Render device: " + m_D3D9Device;
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ strText.Format(L"DirectX SDK : %d", AfxGetMyApp()->GetDXSdkRelease());
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ for (int i=0; i<6; i++)
+ {
+ if (m_strStatsMsg[i][0])
+ {
+ DrawText(rc, m_strStatsMsg[i], 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+ }
+ }
+ m_pSprite->End();
+ }
+
+ if (m_pLine && bDetailedStats)
+ {
+ D3DXVECTOR2 Points[NB_JITTER];
+ int nIndex;
+
+ int StartX = 0;
+ int StartY = 0;
+ int ScaleX = 1;
+ int ScaleY = 1;
+ int DrawWidth = 625 * ScaleX + 50;
+ int DrawHeight = 500 * ScaleY;
+ int Alpha = 80;
+ StartX = m_WindowRect.Width() - (DrawWidth + 20);
+ StartY = m_WindowRect.Height() - (DrawHeight + 20);
+
+ DrawRect(RGB(0,0,0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
+ // === Jitter Graduation
+// m_pLine->SetWidth(2.2); // Width
// m_pLine->SetAntialias(1);
- m_pLine->SetWidth(2.5); // Width
- m_pLine->SetAntialias(1);
+ m_pLine->SetWidth(2.5); // Width
+ m_pLine->SetAntialias(1);
// m_pLine->SetGLLines(1);
- m_pLine->Begin();
-
- for(int i = 10; i < 500 * ScaleY; i += 20 * ScaleY)
- {
- Points[0].x = (FLOAT)StartX;
- Points[0].y = (FLOAT)(StartY + i);
- Points[1].x = (FLOAT)(StartX + ((i - 10) % 80 ? 50 : 625 * ScaleX));
- Points[1].y = (FLOAT)(StartY + i);
- if(i == 250) Points[1].x += 50;
- m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
- }
-
- // === Jitter curve
- if(m_rtTimePerFrame)
- {
- for(int i = 0; i < NB_JITTER; i++)
- {
- nIndex = (m_nNextJitter + 1 + i) % NB_JITTER;
- if(nIndex < 0)
- nIndex += NB_JITTER;
- double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
- Points[i].x = (FLOAT)(StartX + (i * 5 * ScaleX + 5));
- Points[i].y = (FLOAT)(StartY + ((Jitter * ScaleY) / 5000.0 + 250.0 * ScaleY));
- }
- m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(255, 100, 100));
-
- if(m_bSyncStatsAvailable)
- {
- for(int i = 0; i < NB_JITTER; i++)
- {
- nIndex = (m_nNextSyncOffset + 1 + i) % NB_JITTER;
- if(nIndex < 0)
- nIndex += NB_JITTER;
- Points[i].x = (FLOAT)(StartX + (i * 5 * ScaleX + 5));
- Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex] * ScaleY) / 5000 + 250 * ScaleY));
- }
- m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(100, 200, 100));
- }
- }
- m_pLine->End();
- }
-
- // === Text
+ m_pLine->Begin();
+
+ for (int i=10; i<500*ScaleY; i+= 20*ScaleY)
+ {
+ Points[0].x = (FLOAT)StartX;
+ Points[0].y = (FLOAT)(StartY + i);
+ Points[1].x = (FLOAT)(StartX + ((i-10)%80 ? 50 : 625 * ScaleX));
+ Points[1].y = (FLOAT)(StartY + i);
+ if (i == 250) Points[1].x += 50;
+ m_pLine->Draw (Points, 2, D3DCOLOR_XRGB(100,100,255));
+ }
+
+ // === Jitter curve
+ if (m_rtTimePerFrame)
+ {
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ nIndex = (m_nNextJitter+1+i) % NB_JITTER;
+ if (nIndex < 0)
+ nIndex += NB_JITTER;
+ double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
+ Points[i].x = (FLOAT)(StartX + (i*5*ScaleX+5));
+ Points[i].y = (FLOAT)(StartY + ((Jitter*ScaleY)/5000.0 + 250.0* ScaleY));
+ }
+ m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(255,100,100));
+
+ if (m_bSyncStatsAvailable)
+ {
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ nIndex = (m_nNextSyncOffset+1+i) % NB_JITTER;
+ if (nIndex < 0)
+ nIndex += NB_JITTER;
+ Points[i].x = (FLOAT)(StartX + (i*5*ScaleX+5));
+ Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]*ScaleY)/5000 + 250*ScaleY));
+ }
+ m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(100,200,100));
+ }
+ }
+ m_pLine->End();
+ }
+
+ // === Text
}
STDMETHODIMP CDX9AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- CheckPointer(size, E_POINTER);
-
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- memset(&desc, 0, sizeof(desc));
- m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
-
- DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if(!lpDib)
- {
- *size = required;
- return S_OK;
- }
- if(*size < required) return E_OUTOFMEMORY;
- *size = required;
-
- CComPtr<IDirect3DSurface9> pSurface = m_pVideoSurface[m_nCurSurface];
- D3DLOCKED_RECT r;
- if(FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
- {
- pSurface = NULL;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
- || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
- || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
- return hr;
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = desc.Width;
- bih->biHeight = desc.Height;
- bih->biBitCount = 32;
- bih->biPlanes = 1;
- bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
-
- BitBltFromRGBToRGB(
- bih->biWidth, bih->biHeight,
- (BYTE*)(bih + 1), bih->biWidth * bih->biBitCount >> 3, bih->biBitCount,
- (BYTE*)r.pBits + r.Pitch*(desc.Height - 1), -(int)r.Pitch, 32);
-
- pSurface->UnlockRect();
-
- return S_OK;
+ CheckPointer(size, E_POINTER);
+
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ memset(&desc, 0, sizeof(desc));
+ m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
+
+ DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
+ if(!lpDib) {*size = required; return S_OK;}
+ if(*size < required) return E_OUTOFMEMORY;
+ *size = required;
+
+ CComPtr<IDirect3DSurface9> pSurface = m_pVideoSurface[m_nCurSurface];
+ D3DLOCKED_RECT r;
+ if(FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
+ {
+ pSurface = NULL;
+ if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
+ return hr;
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = desc.Width;
+ bih->biHeight = desc.Height;
+ bih->biBitCount = 32;
+ bih->biPlanes = 1;
+ bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
+
+ BitBltFromRGBToRGB(
+ bih->biWidth, bih->biHeight,
+ (BYTE*)(bih + 1), bih->biWidth*bih->biBitCount>>3, bih->biBitCount,
+ (BYTE*)r.pBits + r.Pitch*(desc.Height-1), -(int)r.Pitch, 32);
+
+ pSurface->UnlockRect();
+
+ return S_OK;
}
STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return SetPixelShader2(pSrcData, pTarget, false);
+ return SetPixelShader2(pSrcData, pTarget, false);
}
STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
{
- CAutoLock cRenderLock(&m_RenderLock);
-
- CAtlList<CExternalPixelShader> *pPixelShaders;
- if(bScreenSpace)
- pPixelShaders = &m_pPixelShadersScreenSpace;
- else
- pPixelShaders = &m_pPixelShaders;
-
- if(!pSrcData && !pTarget)
- {
- pPixelShaders->RemoveAll();
- m_pD3DDev->SetPixelShader(NULL);
- return S_OK;
- }
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ CAtlList<CExternalPixelShader> *pPixelShaders;
+ if (bScreenSpace)
+ pPixelShaders = &m_pPixelShadersScreenSpace;
+ else
+ pPixelShaders = &m_pPixelShaders;
- if(!pSrcData || !pTarget)
- return E_INVALIDARG;
+ if(!pSrcData && !pTarget)
+ {
+ pPixelShaders->RemoveAll();
+ m_pD3DDev->SetPixelShader(NULL);
+ return S_OK;
+ }
- CExternalPixelShader Shader;
- Shader.m_SourceData = pSrcData;
- Shader.m_SourceTarget = pTarget;
+ if(!pSrcData || !pTarget)
+ return E_INVALIDARG;
- CComPtr<IDirect3DPixelShader9> pPixelShader;
+ CExternalPixelShader Shader;
+ Shader.m_SourceData = pSrcData;
+ Shader.m_SourceTarget = pTarget;
+
+ CComPtr<IDirect3DPixelShader9> pPixelShader;
- HRESULT hr = Shader.Compile(m_pPSC);
- if(FAILED(hr))
- return hr;
+ HRESULT hr = Shader.Compile(m_pPSC);
+ if(FAILED(hr))
+ return hr;
- pPixelShaders->AddTail(Shader);
+ pPixelShaders->AddTail(Shader);
- Paint(false);
+ Paint(false);
- return S_OK;
+ return S_OK;
}
diff --git a/src/apps/mplayerc/DX9AllocatorPresenter.h b/src/apps/mplayerc/DX9AllocatorPresenter.h
index 2c7b44928..d54a699d3 100644
--- a/src/apps/mplayerc/DX9AllocatorPresenter.h
+++ b/src/apps/mplayerc/DX9AllocatorPresenter.h
@@ -30,14 +30,13 @@
// This interface is used to check version of Media Player Classic.
// {A273C7F6-25D4-46b0-B2C8-4F7FADC44E37}
DEFINE_GUID(IID_IVMRffdshow9,
- 0xa273c7f6, 0x25d4, 0x46b0, 0xb2, 0xc8, 0x4f, 0x7f, 0xad, 0xc4, 0x4e, 0x37);
+0xa273c7f6, 0x25d4, 0x46b0, 0xb2, 0xc8, 0x4f, 0x7f, 0xad, 0xc4, 0x4e, 0x37);
MIDL_INTERFACE("A273C7F6-25D4-46b0-B2C8-4F7FADC44E37")
-IVMRffdshow9 :
-public IUnknown
+IVMRffdshow9 : public IUnknown
{
public:
- virtual STDMETHODIMP support_ffdshow(void) = 0;
+ virtual STDMETHODIMP support_ffdshow(void) = 0;
};
#define VMRBITMAP_UPDATE 0x80000000
@@ -51,314 +50,314 @@ extern bool g_bExternalSubtitleTime;
namespace DSObjects
{
-class CDX9AllocatorPresenter
- : public ISubPicAllocatorPresenterImpl
-{
-public:
- CCritSec m_VMR9AlphaBitmapLock;
- void UpdateAlphaBitmap();
-protected:
- CSize m_ScreenSize;
- UINT m_RefreshRate;
+ class CDX9AllocatorPresenter
+ : public ISubPicAllocatorPresenterImpl
+ {
+ public:
+ CCritSec m_VMR9AlphaBitmapLock;
+ void UpdateAlphaBitmap();
+ protected:
+ CSize m_ScreenSize;
+ UINT m_RefreshRate;
// bool m_fVMRSyncFix;
- bool m_bAlternativeVSync;
- bool m_bHighColorResolution;
- bool m_bCompositionEnabled;
- bool m_bIsEVR;
- int m_OrderedPaint;
- int m_VSyncMode;
- bool m_bDesktopCompositionDisabled;
- bool m_bIsFullscreen;
- bool m_bNeedCheckSample;
- DWORD m_MainThreadId;
-
- CMPlayerCApp::Settings::CRendererSettingsEVR m_LastRendererSettings;
-
- HRESULT(__stdcall * m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
- HRESULT(__stdcall * m_pDwmEnableComposition)(UINT uCompositionAction);
-
- HMODULE m_hDWMAPI;
-
- HRESULT(__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
- HMODULE m_hD3D9;
-
- CCritSec m_RenderLock;
- CComPtr<IDirectDraw> m_pDirectDraw;
-
- CComPtr<IDirect3D9Ex> m_pD3DEx;
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
-
- void LockD3DDevice()
- {
- if(m_pD3DDev)
- {
- _RTL_CRITICAL_SECTION *pCritSec = (_RTL_CRITICAL_SECTION *)((size_t)m_pD3DDev.p + sizeof(size_t));
-
- if(!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
- && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))))
- {
- if(pCritSec->DebugInfo->CriticalSection == pCritSec)
- EnterCriticalSection(pCritSec);
- }
- }
- }
-
- void UnlockD3DDevice()
- {
- if(m_pD3DDev)
- {
- _RTL_CRITICAL_SECTION *pCritSec = (_RTL_CRITICAL_SECTION *)((size_t)m_pD3DDev.p + sizeof(size_t));
-
- if(!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
- && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))))
- {
- if(pCritSec->DebugInfo->CriticalSection == pCritSec)
- LeaveCriticalSection(pCritSec);
- }
- }
- }
- CString m_D3DDevExError;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
- CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_PICTURE_SLOTS];
- CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_PICTURE_SLOTS];
- CComPtr<IDirect3DTexture9> m_pOSDTexture;
- CComPtr<IDirect3DSurface9> m_pOSDSurface;
- CComPtr<ID3DXLine> m_pLine;
- CComPtr<ID3DXFont> m_pFont;
- CComPtr<ID3DXSprite> m_pSprite;
- class CExternalPixelShader
- {
- public:
- CComPtr<IDirect3DPixelShader9> m_pPixelShader;
- CStringA m_SourceData;
- CStringA m_SourceTarget;
- HRESULT Compile(CPixelShaderCompiler *pCompiler)
- {
- HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if(FAILED(hr))
- return hr;
-
- return S_OK;
- }
- };
- CAtlList<CExternalPixelShader> m_pPixelShaders;
- CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
- CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
- CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
- D3DFORMAT m_SurfaceType;
- D3DFORMAT m_BackbufferType;
- D3DFORMAT m_DisplayType;
- D3DTEXTUREFILTERTYPE m_filter;
- D3DCAPS9 m_caps;
-
- CAutoPtr<CPixelShaderCompiler> m_pPSC;
-
- bool SettingsNeedResetDevice();
-
- virtual HRESULT CreateDevice(CString &_Error);
+ bool m_bAlternativeVSync;
+ bool m_bHighColorResolution;
+ bool m_bCompositionEnabled;
+ bool m_bIsEVR;
+ int m_OrderedPaint;
+ int m_VSyncMode;
+ bool m_bDesktopCompositionDisabled;
+ bool m_bIsFullscreen;
+ bool m_bNeedCheckSample;
+ DWORD m_MainThreadId;
+
+ CMPlayerCApp::Settings::CRendererSettingsEVR m_LastRendererSettings;
+
+ HRESULT (__stdcall * m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
+ HRESULT (__stdcall * m_pDwmEnableComposition)(UINT uCompositionAction);
+
+ HMODULE m_hDWMAPI;
+
+ HRESULT (__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
+ HMODULE m_hD3D9;
+
+ CCritSec m_RenderLock;
+ CComPtr<IDirectDraw> m_pDirectDraw;
+
+ CComPtr<IDirect3D9Ex> m_pD3DEx;
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
+
+ void LockD3DDevice()
+ {
+ if (m_pD3DDev)
+ {
+ _RTL_CRITICAL_SECTION *pCritSec = (_RTL_CRITICAL_SECTION *)((size_t)m_pD3DDev.p + sizeof(size_t));
+
+ if (!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
+ && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))))
+ {
+ if (pCritSec->DebugInfo->CriticalSection == pCritSec)
+ EnterCriticalSection(pCritSec);
+ }
+ }
+ }
+
+ void UnlockD3DDevice()
+ {
+ if (m_pD3DDev)
+ {
+ _RTL_CRITICAL_SECTION *pCritSec = (_RTL_CRITICAL_SECTION *)((size_t)m_pD3DDev.p + sizeof(size_t));
+
+ if (!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
+ && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))))
+ {
+ if (pCritSec->DebugInfo->CriticalSection == pCritSec)
+ LeaveCriticalSection(pCritSec);
+ }
+ }
+ }
+ CString m_D3DDevExError;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_PICTURE_SLOTS];
+ CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_PICTURE_SLOTS];
+ CComPtr<IDirect3DTexture9> m_pOSDTexture;
+ CComPtr<IDirect3DSurface9> m_pOSDSurface;
+ CComPtr<ID3DXLine> m_pLine;
+ CComPtr<ID3DXFont> m_pFont;
+ CComPtr<ID3DXSprite> m_pSprite;
+ class CExternalPixelShader
+ {
+ public:
+ CComPtr<IDirect3DPixelShader9> m_pPixelShader;
+ CStringA m_SourceData;
+ CStringA m_SourceTarget;
+ HRESULT Compile(CPixelShaderCompiler *pCompiler)
+ {
+ HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
+ if(FAILED(hr))
+ return hr;
+
+ return S_OK;
+ }
+ };
+ CAtlList<CExternalPixelShader> m_pPixelShaders;
+ CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
+ CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
+ CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
+ D3DFORMAT m_SurfaceType;
+ D3DFORMAT m_BackbufferType;
+ D3DFORMAT m_DisplayType;
+ D3DTEXTUREFILTERTYPE m_filter;
+ D3DCAPS9 m_caps;
+
+ CAutoPtr<CPixelShaderCompiler> m_pPSC;
+
+ bool SettingsNeedResetDevice();
+
+ virtual HRESULT CreateDevice(CString &_Error);
// virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A2B10G10R10);
- virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
- virtual void DeleteSurfaces();
-
- // Thread stuff
- HANDLE m_hEvtQuit; // Stop rendering thread event
- HANDLE m_hVSyncThread;
- static DWORD WINAPI VSyncThreadStatic(LPVOID lpParam);
- void VSyncThread();
- void StartWorkerThreads();
- void StopWorkerThreads();
-
- UINT GetAdapter(IDirect3D9 *pD3D, bool GetAdapter = false);
-
- float m_bicubicA;
- HRESULT InitResizers(float bicubicA, bool bNeedScreenSizeTexture);
-
- bool GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime);
- bool WaitForVBlankRange(int &_RasterStart, int _RasterEnd, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock);
- bool WaitForVBlank(bool &_Waited, bool &_bTakenLock);
- int GetVBlackPos();
- void CalculateJitter(LONGLONG PerformanceCounter);
- virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter) {}
-
- HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
- HRESULT TextureCopy(CComPtr<IDirect3DTexture9> pTexture);
- HRESULT TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect);
- HRESULT TextureResizeBilinear(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
- HRESULT TextureResizeBicubic1pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
- HRESULT TextureResizeBicubic2pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
-
- // Casimir666
- typedef HRESULT(WINAPI * D3DXLoadSurfaceFromMemoryPtr)(
- LPDIRECT3DSURFACE9 pDestSurface,
- CONST PALETTEENTRY* pDestPalette,
- CONST RECT* pDestRect,
- LPCVOID pSrcMemory,
- D3DFORMAT SrcFormat,
- UINT SrcPitch,
- CONST PALETTEENTRY* pSrcPalette,
- CONST RECT* pSrcRect,
- DWORD Filter,
- D3DCOLOR ColorKey);
-
- typedef HRESULT(WINAPI* D3DXCreateLinePtr)(LPDIRECT3DDEVICE9 pDevice, LPD3DXLINE* ppLine);
-
- typedef HRESULT(WINAPI* D3DXCreateFontPtr)(
- LPDIRECT3DDEVICE9 pDevice,
- int Height,
- UINT Width,
- UINT Weight,
- UINT MipLevels,
- bool Italic,
- DWORD CharSet,
- DWORD OutputPrecision,
- DWORD Quality,
- DWORD PitchAndFamily,
- LPCWSTR pFaceName,
- LPD3DXFONT* ppFont);
-
-
- void DrawText(const RECT &rc, const CString &strText, int _Priority);
- void DrawStats();
- HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture);
- virtual void OnResetDevice() {};
- virtual bool ResetDevice();
-
- double GetFrameTime();
- double GetFrameRate();
-
-
- int m_nTearingPos;
- VMR9AlphaBitmap m_VMR9AlphaBitmap;
- CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
- CRect m_VMR9AlphaBitmapRect;
- int m_VMR9AlphaBitmapWidthBytes;
-
- D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
- D3DXCreateLinePtr m_pD3DXCreateLine;
- D3DXCreateFontPtr m_pD3DXCreateFont;
- HRESULT(__stdcall *m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE * ppSprite);
-
-
-
- int m_nNbDXSurface; // Total number of DX Surfaces
- int m_nVMR9Surfaces; // Total number of DX Surfaces
- int m_iVMR9Surface;
- int m_nCurSurface; // Surface currently displayed
- long m_nUsedBuffer;
- bool m_bNeedPendingResetDevice;
- bool m_bPendingResetDevice;
-
- double m_fAvrFps; // Estimate the real FPS
- double m_fJitterStdDev; // Estimate the Jitter std dev
- double m_fJitterMean;
- double m_fSyncOffsetStdDev;
- double m_fSyncOffsetAvr;
- double m_DetectedRefreshRate;
-
- CCritSec m_RefreshRateLock;
- double m_DetectedRefreshTime;
- double m_DetectedRefreshTimePrim;
- double m_DetectedScanlineTime;
- double m_DetectedScanlineTimePrim;
- double m_DetectedScanlinesPerFrame;
-
- double GetRefreshRate()
- {
- if(m_DetectedRefreshRate)
- return m_DetectedRefreshRate;
- return m_RefreshRate;
- }
-
- LONG GetScanLines()
- {
- if(m_DetectedRefreshRate)
- return m_DetectedScanlinesPerFrame;
- return m_ScreenSize.cy;
- }
-
- double m_ldDetectedRefreshRateList[100];
- double m_ldDetectedScanlineRateList[100];
- int m_DetectedRefreshRatePos;
- bool m_bSyncStatsAvailable;
- LONGLONG m_pllJitter [NB_JITTER]; // Jitter buffer for stats
- LONGLONG m_pllSyncOffset [NB_JITTER]; // Jitter buffer for stats
- LONGLONG m_llLastPerf;
- LONGLONG m_JitterStdDev;
- LONGLONG m_MaxJitter;
- LONGLONG m_MinJitter;
- LONGLONG m_MaxSyncOffset;
- LONGLONG m_MinSyncOffset;
- int m_nNextJitter;
- int m_nNextSyncOffset;
- REFERENCE_TIME m_rtTimePerFrame;
- double m_DetectedFrameRate;
- double m_DetectedFrameTime;
- double m_DetectedFrameTimeStdDev;
- bool m_DetectedLock;
- LONGLONG m_DetectedFrameTimeHistory[60];
- double m_DetectedFrameTimeHistoryHistory[500];
- int m_DetectedFrameTimePos;
- int m_bInterlaced;
-
- double m_TextScale;
-
- int m_VBlankEndWait;
- int m_VBlankStartWait;
- LONGLONG m_VBlankWaitTime;
- LONGLONG m_VBlankLockTime;
- int m_VBlankMin;
- int m_VBlankMinCalc;
- int m_VBlankMax;
- int m_VBlankEndPresent;
- LONGLONG m_VBlankStartMeasureTime;
- int m_VBlankStartMeasure;
-
- LONGLONG m_PresentWaitTime;
- LONGLONG m_PresentWaitTimeMin;
- LONGLONG m_PresentWaitTimeMax;
-
- LONGLONG m_PaintTime;
- LONGLONG m_PaintTimeMin;
- LONGLONG m_PaintTimeMax;
-
- LONGLONG m_WaitForGPUTime;
-
- LONGLONG m_RasterStatusWaitTime;
- LONGLONG m_RasterStatusWaitTimeMin;
- LONGLONG m_RasterStatusWaitTimeMax;
- LONGLONG m_RasterStatusWaitTimeMaxCalc;
-
- double m_ClockDiffCalc;
- double m_ClockDiffPrim;
- double m_ClockDiff;
-
- double m_TimeChangeHistory[100];
- double m_ClockChangeHistory[100];
- int m_ClockTimeChangeHistoryPos;
- double m_ModeratedTimeSpeed;
- double m_ModeratedTimeSpeedPrim;
- double m_ModeratedTimeSpeedDiff;
-
- bool m_bCorrectedFrameTime;
- int m_FrameTimeCorrection;
- LONGLONG m_LastFrameDuration;
- LONGLONG m_LastSampleTime;
-
- CString m_strStatsMsg[10];
-
- CString m_D3D9Device;
-
-public:
- CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsEVR, CString &_Error);
- ~CDX9AllocatorPresenter();
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
-};
+ virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
+ virtual void DeleteSurfaces();
+
+ // Thread stuff
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ HANDLE m_hVSyncThread;
+ static DWORD WINAPI VSyncThreadStatic(LPVOID lpParam);
+ void VSyncThread();
+ void StartWorkerThreads();
+ void StopWorkerThreads();
+
+ UINT GetAdapter(IDirect3D9 *pD3D, bool GetAdapter = false);
+
+ float m_bicubicA;
+ HRESULT InitResizers(float bicubicA, bool bNeedScreenSizeTexture);
+
+ bool GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime);
+ bool WaitForVBlankRange(int &_RasterStart, int _RasterEnd, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock);
+ bool WaitForVBlank(bool &_Waited, bool &_bTakenLock);
+ int GetVBlackPos();
+ void CalculateJitter(LONGLONG PerformanceCounter);
+ virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter){}
+
+ HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
+ HRESULT TextureCopy(CComPtr<IDirect3DTexture9> pTexture);
+ HRESULT TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect);
+ HRESULT TextureResizeBilinear(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
+ HRESULT TextureResizeBicubic1pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
+ HRESULT TextureResizeBicubic2pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
+
+ // Casimir666
+ typedef HRESULT (WINAPI * D3DXLoadSurfaceFromMemoryPtr)(
+ LPDIRECT3DSURFACE9 pDestSurface,
+ CONST PALETTEENTRY* pDestPalette,
+ CONST RECT* pDestRect,
+ LPCVOID pSrcMemory,
+ D3DFORMAT SrcFormat,
+ UINT SrcPitch,
+ CONST PALETTEENTRY* pSrcPalette,
+ CONST RECT* pSrcRect,
+ DWORD Filter,
+ D3DCOLOR ColorKey);
+
+ typedef HRESULT (WINAPI* D3DXCreateLinePtr) (LPDIRECT3DDEVICE9 pDevice, LPD3DXLINE* ppLine);
+
+ typedef HRESULT (WINAPI* D3DXCreateFontPtr)(
+ LPDIRECT3DDEVICE9 pDevice,
+ int Height,
+ UINT Width,
+ UINT Weight,
+ UINT MipLevels,
+ bool Italic,
+ DWORD CharSet,
+ DWORD OutputPrecision,
+ DWORD Quality,
+ DWORD PitchAndFamily,
+ LPCWSTR pFaceName,
+ LPD3DXFONT* ppFont);
+
+
+ void DrawText(const RECT &rc, const CString &strText, int _Priority);
+ void DrawStats();
+ HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture);
+ virtual void OnResetDevice() {};
+ virtual bool ResetDevice();
+
+ double GetFrameTime();
+ double GetFrameRate();
+
+
+ int m_nTearingPos;
+ VMR9AlphaBitmap m_VMR9AlphaBitmap;
+ CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
+ CRect m_VMR9AlphaBitmapRect;
+ int m_VMR9AlphaBitmapWidthBytes;
+
+ D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
+ D3DXCreateLinePtr m_pD3DXCreateLine;
+ D3DXCreateFontPtr m_pD3DXCreateFont;
+ HRESULT (__stdcall *m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE * ppSprite);
+
+
+
+ int m_nNbDXSurface; // Total number of DX Surfaces
+ int m_nVMR9Surfaces; // Total number of DX Surfaces
+ int m_iVMR9Surface;
+ int m_nCurSurface; // Surface currently displayed
+ long m_nUsedBuffer;
+ bool m_bNeedPendingResetDevice;
+ bool m_bPendingResetDevice;
+
+ double m_fAvrFps; // Estimate the real FPS
+ double m_fJitterStdDev; // Estimate the Jitter std dev
+ double m_fJitterMean;
+ double m_fSyncOffsetStdDev;
+ double m_fSyncOffsetAvr;
+ double m_DetectedRefreshRate;
+
+ CCritSec m_RefreshRateLock;
+ double m_DetectedRefreshTime;
+ double m_DetectedRefreshTimePrim;
+ double m_DetectedScanlineTime;
+ double m_DetectedScanlineTimePrim;
+ double m_DetectedScanlinesPerFrame;
+
+ double GetRefreshRate()
+ {
+ if (m_DetectedRefreshRate)
+ return m_DetectedRefreshRate;
+ return m_RefreshRate;
+ }
+
+ LONG GetScanLines()
+ {
+ if (m_DetectedRefreshRate)
+ return m_DetectedScanlinesPerFrame;
+ return m_ScreenSize.cy;
+ }
+
+ double m_ldDetectedRefreshRateList[100];
+ double m_ldDetectedScanlineRateList[100];
+ int m_DetectedRefreshRatePos;
+ bool m_bSyncStatsAvailable;
+ LONGLONG m_pllJitter [NB_JITTER]; // Jitter buffer for stats
+ LONGLONG m_pllSyncOffset [NB_JITTER]; // Jitter buffer for stats
+ LONGLONG m_llLastPerf;
+ LONGLONG m_JitterStdDev;
+ LONGLONG m_MaxJitter;
+ LONGLONG m_MinJitter;
+ LONGLONG m_MaxSyncOffset;
+ LONGLONG m_MinSyncOffset;
+ int m_nNextJitter;
+ int m_nNextSyncOffset;
+ REFERENCE_TIME m_rtTimePerFrame;
+ double m_DetectedFrameRate;
+ double m_DetectedFrameTime;
+ double m_DetectedFrameTimeStdDev;
+ bool m_DetectedLock;
+ LONGLONG m_DetectedFrameTimeHistory[60];
+ double m_DetectedFrameTimeHistoryHistory[500];
+ int m_DetectedFrameTimePos;
+ int m_bInterlaced;
+
+ double m_TextScale;
+
+ int m_VBlankEndWait;
+ int m_VBlankStartWait;
+ LONGLONG m_VBlankWaitTime;
+ LONGLONG m_VBlankLockTime;
+ int m_VBlankMin;
+ int m_VBlankMinCalc;
+ int m_VBlankMax;
+ int m_VBlankEndPresent;
+ LONGLONG m_VBlankStartMeasureTime;
+ int m_VBlankStartMeasure;
+
+ LONGLONG m_PresentWaitTime;
+ LONGLONG m_PresentWaitTimeMin;
+ LONGLONG m_PresentWaitTimeMax;
+
+ LONGLONG m_PaintTime;
+ LONGLONG m_PaintTimeMin;
+ LONGLONG m_PaintTimeMax;
+
+ LONGLONG m_WaitForGPUTime;
+
+ LONGLONG m_RasterStatusWaitTime;
+ LONGLONG m_RasterStatusWaitTimeMin;
+ LONGLONG m_RasterStatusWaitTimeMax;
+ LONGLONG m_RasterStatusWaitTimeMaxCalc;
+
+ double m_ClockDiffCalc;
+ double m_ClockDiffPrim;
+ double m_ClockDiff;
+
+ double m_TimeChangeHistory[100];
+ double m_ClockChangeHistory[100];
+ int m_ClockTimeChangeHistoryPos;
+ double m_ModeratedTimeSpeed;
+ double m_ModeratedTimeSpeedPrim;
+ double m_ModeratedTimeSpeedDiff;
+
+ bool m_bCorrectedFrameTime;
+ int m_FrameTimeCorrection;
+ LONGLONG m_LastFrameDuration;
+ LONGLONG m_LastSampleTime;
+
+ CString m_strStatsMsg[10];
+
+ CString m_D3D9Device;
+
+ public:
+ CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsEVR, CString &_Error);
+ ~CDX9AllocatorPresenter();
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ };
}
diff --git a/src/apps/mplayerc/DXRAllocatorPresenter.cpp b/src/apps/mplayerc/DXRAllocatorPresenter.cpp
index 7cff44466..eca82b85b 100644
--- a/src/apps/mplayerc/DXRAllocatorPresenter.cpp
+++ b/src/apps/mplayerc/DXRAllocatorPresenter.cpp
@@ -33,129 +33,108 @@ using namespace DSObjects;
//
CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
- , m_ScreenSize(0, 0)
+ : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
+ , m_ScreenSize(0, 0)
{
- if(FAILED(hr))
- {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
+ if(FAILED(hr))
+ {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
- hr = S_OK;
+ hr = S_OK;
}
CDXRAllocatorPresenter::~CDXRAllocatorPresenter()
{
- if(m_pSRCB)
- {
- // nasty, but we have to let it know about our death somehow
- ((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
- }
-
- // the order is important here
- m_pSubPicQueue = NULL;
- m_pAllocator = NULL;
- m_pDXR = NULL;
+ if(m_pSRCB)
+ {
+ // nasty, but we have to let it know about our death somehow
+ ((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
+ }
+
+ // the order is important here
+ m_pSubPicQueue = NULL;
+ m_pAllocator = NULL;
+ m_pDXR = NULL;
}
STDMETHODIMP CDXRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- /*
- if(riid == __uuidof(IVideoWindow))
- return GetInterface((IVideoWindow*)this, ppv);
- if(riid == __uuidof(IBasicVideo))
- return GetInterface((IBasicVideo*)this, ppv);
- if(riid == __uuidof(IBasicVideo2))
- return GetInterface((IBasicVideo2*)this, ppv);
- */
- /*
- if(riid == __uuidof(IVMRWindowlessControl))
- return GetInterface((IVMRWindowlessControl*)this, ppv);
- */
-
- if(riid != IID_IUnknown && m_pDXR)
- {
- if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv)))
- return S_OK;
- }
-
- return __super::NonDelegatingQueryInterface(riid, ppv);
+/*
+ if(riid == __uuidof(IVideoWindow))
+ return GetInterface((IVideoWindow*)this, ppv);
+ if(riid == __uuidof(IBasicVideo))
+ return GetInterface((IBasicVideo*)this, ppv);
+ if(riid == __uuidof(IBasicVideo2))
+ return GetInterface((IBasicVideo2*)this, ppv);
+*/
+/*
+ if(riid == __uuidof(IVMRWindowlessControl))
+ return GetInterface((IVMRWindowlessControl*)this, ppv);
+*/
+
+ if(riid != IID_IUnknown && m_pDXR)
+ {
+ if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv)))
+ return S_OK;
+ }
+
+ return __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
{
- CheckPointer(pD3DDev, E_POINTER);
-
- CSize size;
- switch(AfxGetAppSettings().nSPCMaxRes)
- {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if(m_pAllocator)
- {
- m_pAllocator->ChangeDevice(pD3DDev);
- }
- else
- {
- m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- return E_FAIL;
- }
-
- HRESULT hr = S_OK;
-
- m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr))
- return E_FAIL;
-
- if(m_SubPicProvider) m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
-
- return S_OK;
+ CheckPointer(pD3DDev, E_POINTER);
+
+ CSize size;
+ switch(AfxGetAppSettings().nSPCMaxRes)
+ {
+ case 0: default: size = m_ScreenSize; break;
+ case 1: size.SetSize(1024, 768); break;
+ case 2: size.SetSize(800, 600); break;
+ case 3: size.SetSize(640, 480); break;
+ case 4: size.SetSize(512, 384); break;
+ case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
+ }
+
+ if(m_pAllocator)
+ {
+ m_pAllocator->ChangeDevice(pD3DDev);
+ }
+ else
+ {
+ m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ if(!m_pAllocator)
+ return E_FAIL;
+ }
+
+ HRESULT hr = S_OK;
+
+ m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if(!m_pSubPicQueue || FAILED(hr))
+ return E_FAIL;
+
+ if(m_SubPicProvider) m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+
+ return S_OK;
}
HRESULT CDXRAllocatorPresenter::Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int right, int bottom, int width, int height)
-{
- __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
- SetTime(rtStart);
- if(atpf > 0 && m_pSubPicQueue) m_pSubPicQueue->SetFPS(10000000.0 / atpf);
- AlphaBltSubPic(CSize(width, height));
- return S_OK;
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int right, int bottom, int width, int height)
+{
+ __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
+ SetTime(rtStart);
+ if(atpf > 0 && m_pSubPicQueue) m_pSubPicQueue->SetFPS(10000000.0 / atpf);
+ AlphaBltSubPic(CSize(width, height));
+ return S_OK;
}
// ISubPicAllocatorPresenter
@@ -164,80 +143,72 @@ STDMETHODIMP CDXRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
CheckPointer(ppRenderer, E_POINTER);
- if(m_pDXR) return E_UNEXPECTED;
- m_pDXR.CoCreateInstance(CLSID_DXR, GetOwner());
- if(!m_pDXR) return E_FAIL;
+ if(m_pDXR) return E_UNEXPECTED;
+ m_pDXR.CoCreateInstance(CLSID_DXR, GetOwner());
+ if(!m_pDXR) return E_FAIL;
- CComQIPtr<ISubRender> pSR = m_pDXR;
- if(!pSR)
- {
- m_pDXR = NULL;
- return E_FAIL;
- }
+ CComQIPtr<ISubRender> pSR = m_pDXR;
+ if(!pSR) {m_pDXR = NULL; return E_FAIL;}
- m_pSRCB = DNew CSubRenderCallback(this);
- if(FAILED(pSR->SetCallback(m_pSRCB)))
- {
- m_pDXR = NULL;
- return E_FAIL;
- }
+ m_pSRCB = DNew CSubRenderCallback(this);
+ if(FAILED(pSR->SetCallback(m_pSRCB))) {m_pDXR = NULL; return E_FAIL;}
- (*ppRenderer = this)->AddRef();
+ (*ppRenderer = this)->AddRef();
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- if(GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
- m_ScreenSize.SetSize(mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top);
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
+ m_ScreenSize.SetSize(mi.rcMonitor.right-mi.rcMonitor.left, mi.rcMonitor.bottom-mi.rcMonitor.top);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(void) CDXRAllocatorPresenter::SetPosition(RECT w, RECT v)
{
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
- {
- pBV->SetDefaultSourcePosition();
- pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
- }
-
- if(CComQIPtr<IVideoWindow> pVW = m_pDXR)
- {
- pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
- }
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ {
+ pBV->SetDefaultSourcePosition();
+ pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
+ }
+
+ if(CComQIPtr<IVideoWindow> pVW = m_pDXR)
+ {
+ pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
+ }
}
STDMETHODIMP_(SIZE) CDXRAllocatorPresenter::GetVideoSize(bool fCorrectAR)
{
- SIZE size = {0, 0};
-
- if(!fCorrectAR)
- {
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
- pBV->GetVideoSize(&size.cx, &size.cy);
- }
- else
- {
- if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR)
- pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
- }
-
- return size;
+ SIZE size = {0, 0};
+
+ if(!fCorrectAR)
+ {
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ pBV->GetVideoSize(&size.cx, &size.cy);
+ }
+ else
+ {
+ if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR)
+ pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
+ }
+
+ return size;
}
STDMETHODIMP_(bool) CDXRAllocatorPresenter::Paint(bool fAll)
{
- return false; // TODO
+ return false; // TODO
}
STDMETHODIMP CDXRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- HRESULT hr = E_NOTIMPL;
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
- hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
- return hr;
+ HRESULT hr = E_NOTIMPL;
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
+ return hr;
}
STDMETHODIMP CDXRAllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return E_NOTIMPL; // TODO
+ return E_NOTIMPL; // TODO
}
diff --git a/src/apps/mplayerc/DXRAllocatorPresenter.h b/src/apps/mplayerc/DXRAllocatorPresenter.h
index fef02e56c..e7291d9a0 100644
--- a/src/apps/mplayerc/DXRAllocatorPresenter.h
+++ b/src/apps/mplayerc/DXRAllocatorPresenter.h
@@ -26,79 +26,79 @@
namespace DSObjects
{
-class CDXRAllocatorPresenter
- : public ISubPicAllocatorPresenterImpl
-{
- class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
- {
- CDXRAllocatorPresenter* m_pDXRAP;
-
- public:
- CSubRenderCallback(CDXRAllocatorPresenter* pDXRAP)
- : CUnknown(_T("CSubRender"), NULL)
- , m_pDXRAP(pDXRAP)
- {
- }
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- return
- QI(ISubRenderCallback)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- void SetDXRAP(CDXRAllocatorPresenter* pDXRAP)
- {
- CAutoLock cAutoLock(this);
- m_pDXRAP = pDXRAP;
- }
-
- // ISubRenderCallback
-
- STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev)
- {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
- }
-
- STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height)
- {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
-
- // ISubRendererCallback2
-
- STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height)
- {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
- };
-
- CComPtr<IUnknown> m_pDXR;
- CComPtr<ISubRenderCallback> m_pSRCB;
- CSize m_ScreenSize;
-
-public:
- CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
- virtual ~CDXRAllocatorPresenter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
- HRESULT Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int bottom, int right, int width, int height);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
- STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
-};
+ class CDXRAllocatorPresenter
+ : public ISubPicAllocatorPresenterImpl
+ {
+ class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
+ {
+ CDXRAllocatorPresenter* m_pDXRAP;
+
+ public:
+ CSubRenderCallback(CDXRAllocatorPresenter* pDXRAP)
+ : CUnknown(_T("CSubRender"), NULL)
+ , m_pDXRAP(pDXRAP)
+ {
+ }
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ return
+ QI(ISubRenderCallback)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ void SetDXRAP(CDXRAllocatorPresenter* pDXRAP)
+ {
+ CAutoLock cAutoLock(this);
+ m_pDXRAP = pDXRAP;
+ }
+
+ // ISubRenderCallback
+
+ STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev)
+ {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
+ }
+
+ STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height)
+ {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+
+ // ISubRendererCallback2
+
+ STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height)
+ {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+ };
+
+ CComPtr<IUnknown> m_pDXR;
+ CComPtr<ISubRenderCallback> m_pSRCB;
+ CSize m_ScreenSize;
+
+ public:
+ CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
+ virtual ~CDXRAllocatorPresenter();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
+ HRESULT Render(
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int bottom, int right, int width, int height);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
+ STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ };
}
diff --git a/src/apps/mplayerc/DeinterlacerFilter.cpp b/src/apps/mplayerc/DeinterlacerFilter.cpp
index 65e217aa1..8047f2c46 100644
--- a/src/apps/mplayerc/DeinterlacerFilter.cpp
+++ b/src/apps/mplayerc/DeinterlacerFilter.cpp
@@ -28,127 +28,120 @@
CDeinterlacerFilter::CDeinterlacerFilter(LPUNKNOWN punk, HRESULT* phr)
- : CTransformFilter(NAME("CDeinterlacerFilter"), punk, __uuidof(CDeinterlacerFilter))
+ : CTransformFilter(NAME("CDeinterlacerFilter"), punk, __uuidof(CDeinterlacerFilter))
{
- if(phr) *phr = S_OK;
+ if(phr) *phr = S_OK;
}
HRESULT CDeinterlacerFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- return GetCLSID(pPin) == __uuidof(*this) ? E_FAIL : S_OK;
+ return GetCLSID(pPin) == __uuidof(*this) ? E_FAIL : S_OK;
}
HRESULT CDeinterlacerFilter::CheckInputType(const CMediaType* mtIn)
{
- BITMAPINFOHEADER bih;
- if(!ExtractBIH(mtIn, &bih) /*|| bih.biHeight <= 0*/ || bih.biHeight <= 288)
- return E_FAIL;
-
- return mtIn->subtype == MEDIASUBTYPE_YUY2 || mtIn->subtype == MEDIASUBTYPE_UYVY
- || mtIn->subtype == MEDIASUBTYPE_I420 || mtIn->subtype == MEDIASUBTYPE_YV12 || mtIn->subtype == MEDIASUBTYPE_IYUV
- ? S_OK
- : E_FAIL;
+ BITMAPINFOHEADER bih;
+ if(!ExtractBIH(mtIn, &bih) /*|| bih.biHeight <= 0*/ || bih.biHeight <= 288)
+ return E_FAIL;
+
+ return mtIn->subtype == MEDIASUBTYPE_YUY2 || mtIn->subtype == MEDIASUBTYPE_UYVY
+ || mtIn->subtype == MEDIASUBTYPE_I420 || mtIn->subtype == MEDIASUBTYPE_YV12 || mtIn->subtype == MEDIASUBTYPE_IYUV
+ ? S_OK
+ : E_FAIL;
}
HRESULT CDeinterlacerFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return mtIn->subtype == mtOut->subtype ? S_OK : E_FAIL;
+ return mtIn->subtype == mtOut->subtype ? S_OK : E_FAIL;
}
HRESULT CDeinterlacerFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
- HRESULT hr;
-
- AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
- CMediaType mt = *pmt;
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- BYTE* pDataIn = NULL;
- if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn)
- return S_FALSE;
-
- BYTE* pDataOut = NULL;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut)
- return hr;
-
- const CMediaType& mtIn = m_pInput->CurrentMediaType();
- const CMediaType& mtOut = m_pOutput->CurrentMediaType();
-
- BITMAPINFOHEADER bihIn, bihOut;
- ExtractBIH(&mtIn, &bihIn);
- ExtractBIH(&mtOut, &bihOut);
-
- bool fInputFlipped = bihIn.biHeight >= 0 && bihIn.biCompression <= 3;
- bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
- bool fFlip = fInputFlipped != fOutputFlipped;
-
- int bppIn = !(bihIn.biBitCount & 7) ? bihIn.biBitCount : 8;
- int bppOut = !(bihOut.biBitCount & 7) ? bihOut.biBitCount : 8;
- int pitchIn = bihIn.biWidth * bppIn >> 3;
- int pitchOut = bihOut.biWidth * bppOut >> 3;
- BYTE* pDataOut2 = pDataOut;
- if(fFlip)
- {
- pDataOut2 += pitchOut * (bihIn.biHeight - 1);
- pitchOut = -pitchOut;
- }
-
- if(mtIn.subtype == MEDIASUBTYPE_YUY2 || mtIn.subtype == MEDIASUBTYPE_UYVY)
- {
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
- }
- else if(mtIn.subtype == MEDIASUBTYPE_I420 || mtIn.subtype == MEDIASUBTYPE_YV12 || mtIn.subtype == MEDIASUBTYPE_IYUV)
- {
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
-
- int sizeIn = bihIn.biHeight * pitchIn, sizeOut = abs(bihOut.biHeight) * pitchOut;
- pitchIn /= 2;
- pitchOut /= 2;
- bihIn.biHeight /= 2;
- pDataIn += sizeIn;
- pDataOut += sizeOut;
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
-
- pDataIn += sizeIn / 4;
- pDataOut += sizeOut / 4;
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
- }
-
- return S_OK;
+ HRESULT hr;
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
+ {
+ CMediaType mt = *pmt;
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
+
+ BYTE* pDataIn = NULL;
+ if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn)
+ return S_FALSE;
+
+ BYTE* pDataOut = NULL;
+ if(FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut)
+ return hr;
+
+ const CMediaType& mtIn = m_pInput->CurrentMediaType();
+ const CMediaType& mtOut = m_pOutput->CurrentMediaType();
+
+ BITMAPINFOHEADER bihIn, bihOut;
+ ExtractBIH(&mtIn, &bihIn);
+ ExtractBIH(&mtOut, &bihOut);
+
+ bool fInputFlipped = bihIn.biHeight >= 0 && bihIn.biCompression <= 3;
+ bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
+ bool fFlip = fInputFlipped != fOutputFlipped;
+
+ int bppIn = !(bihIn.biBitCount&7) ? bihIn.biBitCount : 8;
+ int bppOut = !(bihOut.biBitCount&7) ? bihOut.biBitCount : 8;
+ int pitchIn = bihIn.biWidth*bppIn>>3;
+ int pitchOut = bihOut.biWidth*bppOut>>3;
+ BYTE* pDataOut2 = pDataOut;
+ if(fFlip) {pDataOut2 += pitchOut*(bihIn.biHeight-1); pitchOut = -pitchOut;}
+
+ if(mtIn.subtype == MEDIASUBTYPE_YUY2 || mtIn.subtype == MEDIASUBTYPE_UYVY)
+ {
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+ }
+ else if(mtIn.subtype == MEDIASUBTYPE_I420 || mtIn.subtype == MEDIASUBTYPE_YV12 || mtIn.subtype == MEDIASUBTYPE_IYUV)
+ {
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+
+ int sizeIn = bihIn.biHeight*pitchIn, sizeOut = abs(bihOut.biHeight)*pitchOut;
+ pitchIn /= 2; pitchOut /= 2;
+ bihIn.biHeight /= 2;
+ pDataIn += sizeIn; pDataOut += sizeOut;
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+
+ pDataIn += sizeIn/4; pDataOut += sizeOut/4;
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+ }
+
+ return S_OK;
}
HRESULT CDeinterlacerFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
- BITMAPINFOHEADER bih;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
+ BITMAPINFOHEADER bih;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = bih.biSizeImage;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = bih.biSizeImage;
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
- return hr;
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ return hr;
return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ ? E_FAIL
+ : NOERROR;
}
HRESULT CDeinterlacerFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
- *pmt = m_pInput->CurrentMediaType();
- CorrectMediaType(pmt);
- return S_OK;
+ if(iPosition < 0) return E_INVALIDARG;
+ if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
+ *pmt = m_pInput->CurrentMediaType();
+ CorrectMediaType(pmt);
+ return S_OK;
}
diff --git a/src/apps/mplayerc/DeinterlacerFilter.h b/src/apps/mplayerc/DeinterlacerFilter.h
index 06576bd38..f656f8bb6 100644
--- a/src/apps/mplayerc/DeinterlacerFilter.h
+++ b/src/apps/mplayerc/DeinterlacerFilter.h
@@ -28,12 +28,12 @@ class CDeinterlacerFilter : public CTransformFilter
{
protected:
HRESULT CDeinterlacerFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin);
- HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckInputType(const CMediaType* mtIn);
HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
public:
- CDeinterlacerFilter(LPUNKNOWN punk, HRESULT* phr);
+ CDeinterlacerFilter(LPUNKNOWN punk, HRESULT* phr);
};
diff --git a/src/apps/mplayerc/EVRAllocatorPresenter.cpp b/src/apps/mplayerc/EVRAllocatorPresenter.cpp
index 7c5cfab00..510123536 100644
--- a/src/apps/mplayerc/EVRAllocatorPresenter.cpp
+++ b/src/apps/mplayerc/EVRAllocatorPresenter.cpp
@@ -30,15 +30,15 @@
#include "MainFrm.h"
#if (0) // Set to 1 to activate EVR traces
-#define TRACE_EVR TRACE
+ #define TRACE_EVR TRACE
#else
-#define TRACE_EVR
+ #define TRACE_EVR
#endif
-typedef enum
+typedef enum
{
- MSG_MIXERIN,
- MSG_MIXEROUT
+ MSG_MIXERIN,
+ MSG_MIXEROUT
} EVR_STATS_MSG;
// Guid to tag IMFSample with DirectX surface index
@@ -52,7 +52,7 @@ MFOffset MakeOffset(float v)
{
MFOffset offset;
offset.value = short(v);
- offset.fract = WORD(65536 * (v - offset.value));
+ offset.fract = WORD(65536 * (v-offset.value));
return offset;
}
@@ -71,227 +71,227 @@ MFVideoArea MakeArea(float x, float y, DWORD width, DWORD height)
namespace DSObjects
{
-class COuterEVR
- : public CUnknown
- , public IVMRffdshow9
- , public IVMRMixerBitmap9
- , public IBaseFilter
-{
- CComPtr<IUnknown> m_pEVR;
- VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
- CEVRAllocatorPresenter *m_pAllocatorPresenter;
-
-public:
-
- // IBaseFilter
- virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->EnumPins(ppEnum);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, __out IPin **ppPin)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->FindPin(Id, ppPin);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->QueryFilterInfo(pInfo);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->JoinFilterGraph(pGraph, pName);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->QueryVendorInfo(pVendorInfo);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Stop(void)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->Stop();
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Pause(void)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->Pause();
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->Run(tStart);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
-
- virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->SetSyncSource(pClock);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetSyncSource(__deref_out_opt IReferenceClock **pClock)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->GetSyncSource(pClock);
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->GetClassID(pClassID);
- return E_NOTIMPL;
- }
-
- COuterEVR(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CEVRAllocatorPresenter *pAllocatorPresenter) : CUnknown(pName, pUnk)
- {
- hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
- m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
- m_pAllocatorPresenter = pAllocatorPresenter;
- }
-
- ~COuterEVR();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- HRESULT hr;
-
- if(riid == __uuidof(IVMRMixerBitmap9))
- {
- return GetInterface((IVMRMixerBitmap9*)this, ppv);
- }
- if(riid == __uuidof(IMediaFilter))
- {
- return GetInterface((IMediaFilter*)this, ppv);
- }
- if(riid == __uuidof(IPersist))
- {
- return GetInterface((IPersist*)this, ppv);
- }
- if(riid == __uuidof(IBaseFilter))
- {
- return GetInterface((IBaseFilter*)this, ppv);
- }
-
- hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if(m_pEVR && FAILED(hr))
- {
- if(riid == __uuidof(IVMRffdshow9)) // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
- return GetInterface((IVMRffdshow9*)this, ppv);
- }
-
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- // IVMRffdshow9
- STDMETHODIMP support_ffdshow()
- {
- queue_ffdshow_support = true;
- return S_OK;
- }
-
- // IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
-
- STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
-
- STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
-};
-}
-
-HRESULT STDMETHODCALLTYPE COuterEVR::GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State)
-{
- HRESULT ReturnValue;
- if(m_pAllocatorPresenter->GetState(dwMilliSecsTimeout, State, ReturnValue))
- return ReturnValue;
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->GetState(dwMilliSecsTimeout, State);
- return E_NOTIMPL;
+ class COuterEVR
+ : public CUnknown
+ , public IVMRffdshow9
+ , public IVMRMixerBitmap9
+ , public IBaseFilter
+ {
+ CComPtr<IUnknown> m_pEVR;
+ VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
+ CEVRAllocatorPresenter *m_pAllocatorPresenter;
+
+ public:
+
+ // IBaseFilter
+ virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->EnumPins(ppEnum);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, __out IPin **ppPin)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->FindPin(Id, ppPin);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->QueryFilterInfo(pInfo);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->JoinFilterGraph(pGraph, pName);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->QueryVendorInfo(pVendorInfo);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Stop( void)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Stop();
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Pause( void)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Pause();
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Run( REFERENCE_TIME tStart)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Run(tStart);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
+
+ virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->SetSyncSource(pClock);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetSyncSource(__deref_out_opt IReferenceClock **pClock)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetSyncSource(pClock);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetClassID(pClassID);
+ return E_NOTIMPL;
+ }
+
+ COuterEVR(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CEVRAllocatorPresenter *pAllocatorPresenter) : CUnknown(pName, pUnk)
+ {
+ hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
+ m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = pAllocatorPresenter;
+ }
+
+ ~COuterEVR();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ HRESULT hr;
+
+ if(riid == __uuidof(IVMRMixerBitmap9))
+ {
+ return GetInterface((IVMRMixerBitmap9*)this, ppv);
+ }
+ if (riid == __uuidof(IMediaFilter))
+ {
+ return GetInterface((IMediaFilter*)this, ppv);
+ }
+ if (riid == __uuidof(IPersist))
+ {
+ return GetInterface((IPersist*)this, ppv);
+ }
+ if (riid == __uuidof(IBaseFilter))
+ {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
+
+ hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ if(m_pEVR && FAILED(hr))
+ {
+ if(riid == __uuidof(IVMRffdshow9)) // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ return GetInterface((IVMRffdshow9*)this, ppv);
+ }
+
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ // IVMRffdshow9
+ STDMETHODIMP support_ffdshow()
+ {
+ queue_ffdshow_support = true;
+ return S_OK;
+ }
+
+ // IVMRMixerBitmap9
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
+
+ STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
+
+ STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
+ };
+}
+
+HRESULT STDMETHODCALLTYPE COuterEVR::GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State)
+{
+ HRESULT ReturnValue;
+ if (m_pAllocatorPresenter->GetState(dwMilliSecsTimeout, State, ReturnValue))
+ return ReturnValue;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetState(dwMilliSecsTimeout, State);
+ return E_NOTIMPL;
}
STDMETHODIMP COuterEVR::GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
}
STDMETHODIMP COuterEVR::SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
STDMETHODIMP COuterEVR::UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
COuterEVR::~COuterEVR()
@@ -299,153 +299,153 @@ COuterEVR::~COuterEVR()
}
CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, hr, true, _Error)
-{
- HMODULE hLib;
- AppSettings& s = AfxGetAppSettings();
-
- m_nResetToken = 0;
- m_hThread = INVALID_HANDLE_VALUE;
- m_hGetMixerThread = INVALID_HANDLE_VALUE;
- m_hEvtFlush = INVALID_HANDLE_VALUE;
- m_hEvtQuit = INVALID_HANDLE_VALUE;
- m_bEvtQuit = 0;
- m_bEvtFlush = 0;
- m_ModeratedTime = 0;
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
-
- m_bNeedPendingResetDevice = true;
-
- if(FAILED(hr))
- {
- _Error += L"DX9AllocatorPresenter failed\n";
-
- return;
- }
-
- // Load EVR specifics DLLs
- hLib = LoadLibrary(L"dxva2.dll");
- pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress(hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
-
- // Load EVR functions
- hLib = LoadLibrary(L"evr.dll");
- pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer) GetProcAddress(hLib, "MFCreateDXSurfaceBuffer") : NULL;
- pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface) GetProcAddress(hLib, "MFCreateVideoSampleFromSurface") : NULL;
- pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType) GetProcAddress(hLib, "MFCreateVideoMediaType") : NULL;
-
- if(!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType)
- {
- if(!pfDXVA2CreateDirect3DDeviceManager9)
- _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
- if(!pfMFCreateDXSurfaceBuffer)
- _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
- if(!pfMFCreateVideoSampleFromSurface)
- _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
- if(!pfMFCreateVideoMediaType)
- _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
- hr = E_FAIL;
- return;
- }
-
- // Load mfplat fuctions
+ : CDX9AllocatorPresenter(hWnd, hr, true, _Error)
+{
+ HMODULE hLib;
+ AppSettings& s = AfxGetAppSettings();
+
+ m_nResetToken = 0;
+ m_hThread = INVALID_HANDLE_VALUE;
+ m_hGetMixerThread= INVALID_HANDLE_VALUE;
+ m_hEvtFlush = INVALID_HANDLE_VALUE;
+ m_hEvtQuit = INVALID_HANDLE_VALUE;
+ m_bEvtQuit = 0;
+ m_bEvtFlush = 0;
+ m_ModeratedTime = 0;
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
+
+ m_bNeedPendingResetDevice = true;
+
+ if (FAILED (hr))
+ {
+ _Error += L"DX9AllocatorPresenter failed\n";
+
+ return;
+ }
+
+ // Load EVR specifics DLLs
+ hLib = LoadLibrary (L"dxva2.dll");
+ pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress (hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
+
+ // Load EVR functions
+ hLib = LoadLibrary (L"evr.dll");
+ pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer) GetProcAddress (hLib, "MFCreateDXSurfaceBuffer") : NULL;
+ pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface) GetProcAddress (hLib, "MFCreateVideoSampleFromSurface") : NULL;
+ pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType) GetProcAddress (hLib, "MFCreateVideoMediaType") : NULL;
+
+ if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType)
+ {
+ if (!pfDXVA2CreateDirect3DDeviceManager9)
+ _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
+ if (!pfMFCreateDXSurfaceBuffer)
+ _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
+ if (!pfMFCreateVideoSampleFromSurface)
+ _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
+ if (!pfMFCreateVideoMediaType)
+ _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ hr = E_FAIL;
+ return;
+ }
+
+ // Load mfplat fuctions
#if 0
- hLib = LoadLibrary(L"mfplat.dll");
- (FARPROC &)pMFCreateMediaType = GetProcAddress(hLib, "MFCreateMediaType");
- (FARPROC &)pMFInitMediaTypeFromAMMediaType = GetProcAddress(hLib, "MFInitMediaTypeFromAMMediaType");
- (FARPROC &)pMFInitAMMediaTypeFromMFMediaType = GetProcAddress(hLib, "MFInitAMMediaTypeFromMFMediaType");
-
- if(!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType)
- {
- hr = E_FAIL;
- return;
- }
+ hLib = LoadLibrary (L"mfplat.dll");
+ (FARPROC &)pMFCreateMediaType = GetProcAddress(hLib, "MFCreateMediaType");
+ (FARPROC &)pMFInitMediaTypeFromAMMediaType = GetProcAddress(hLib, "MFInitMediaTypeFromAMMediaType");
+ (FARPROC &)pMFInitAMMediaTypeFromMFMediaType = GetProcAddress(hLib, "MFInitAMMediaTypeFromMFMediaType");
+
+ if (!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType)
+ {
+ hr = E_FAIL;
+ return;
+ }
#endif
- // Load Vista specifics DLLs
- hLib = LoadLibrary(L"AVRT.dll");
- pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress(hLib, "AvSetMmThreadCharacteristicsW") : NULL;
- pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress(hLib, "AvSetMmThreadPriority") : NULL;
- pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress(hLib, "AvRevertMmThreadCharacteristics") : NULL;
-
- // Init DXVA manager
- hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
- if(SUCCEEDED(hr))
- {
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if(!SUCCEEDED(hr))
- {
- _Error += L"m_pD3DManager->ResetDevice failed\n";
- }
- }
- else
- _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
-
- CComPtr<IDirectXVideoDecoderService> pDecoderService;
- HANDLE hDevice;
- if(SUCCEEDED(m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
- SUCCEEDED(m_pD3DManager->GetVideoService(hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService)))
- {
- TRACE_EVR("EVR: DXVA2 : device handle = 0x%08x", hDevice);
- HookDirectXVideoDecoderService(pDecoderService);
-
- m_pD3DManager->CloseDeviceHandle(hDevice);
- }
-
-
- // Bufferize frame only with 3D texture!
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- m_nNbDXSurface = max(min(s.iEvrBuffers, MAX_PICTURE_SLOTS - 2), 4);
- else
- m_nNbDXSurface = 1;
-
- ResetStats();
- m_nRenderState = Shutdown;
- m_fUseInternalTimer = false;
- m_LastSetOutputRange = -1;
- m_bPendingRenegotiate = false;
- m_bPendingMediaFinished = false;
- m_bWaitingSample = false;
- m_pCurrentDisplaydSample = NULL;
- m_nStepCount = 0;
- m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
- m_BorderColor = RGB(0, 0, 0);
- m_bSignaledStarvation = false;
- m_StarvationClock = 0;
- m_pOuterEVR = NULL;
- m_LastScheduledSampleTime = -1;
- m_LastScheduledUncorrectedSampleTime = -1;
- m_MaxSampleDuration = 0;
- m_LastSampleOffset = 0;
- ZeroMemory(m_VSyncOffsetHistory, sizeof(m_VSyncOffsetHistory));
- m_VSyncOffsetHistoryPos = 0;
- m_bLastSampleOffsetValid = false;
+ // Load Vista specifics DLLs
+ hLib = LoadLibrary (L"AVRT.dll");
+ pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW") : NULL;
+ pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress (hLib, "AvSetMmThreadPriority") : NULL;
+ pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress (hLib, "AvRevertMmThreadCharacteristics") : NULL;
+
+ // Init DXVA manager
+ hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
+ if (SUCCEEDED (hr))
+ {
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (!SUCCEEDED (hr))
+ {
+ _Error += L"m_pD3DManager->ResetDevice failed\n";
+ }
+ }
+ else
+ _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
+
+ CComPtr<IDirectXVideoDecoderService> pDecoderService;
+ HANDLE hDevice;
+ if (SUCCEEDED (m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
+ SUCCEEDED (m_pD3DManager->GetVideoService (hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService)))
+ {
+ TRACE_EVR ("EVR: DXVA2 : device handle = 0x%08x", hDevice);
+ HookDirectXVideoDecoderService (pDecoderService);
+
+ m_pD3DManager->CloseDeviceHandle (hDevice);
+ }
+
+
+ // Bufferize frame only with 3D texture!
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ m_nNbDXSurface = max (min (s.iEvrBuffers, MAX_PICTURE_SLOTS-2), 4);
+ else
+ m_nNbDXSurface = 1;
+
+ ResetStats();
+ m_nRenderState = Shutdown;
+ m_fUseInternalTimer = false;
+ m_LastSetOutputRange = -1;
+ m_bPendingRenegotiate = false;
+ m_bPendingMediaFinished = false;
+ m_bWaitingSample = false;
+ m_pCurrentDisplaydSample = NULL;
+ m_nStepCount = 0;
+ m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
+ m_BorderColor = RGB (0,0,0);
+ m_bSignaledStarvation = false;
+ m_StarvationClock = 0;
+ m_pOuterEVR = NULL;
+ m_LastScheduledSampleTime = -1;
+ m_LastScheduledUncorrectedSampleTime = -1;
+ m_MaxSampleDuration = 0;
+ m_LastSampleOffset = 0;
+ ZeroMemory(m_VSyncOffsetHistory, sizeof(m_VSyncOffsetHistory));
+ m_VSyncOffsetHistoryPos = 0;
+ m_bLastSampleOffsetValid = false;
}
CEVRAllocatorPresenter::~CEVRAllocatorPresenter(void)
{
- StopWorkerThreads(); // If not already done...
- m_pMediaType = NULL;
- m_pClock = NULL;
+ StopWorkerThreads(); // If not already done...
+ m_pMediaType = NULL;
+ m_pClock = NULL;
- m_pD3DManager = NULL;
+ m_pD3DManager = NULL;
}
void CEVRAllocatorPresenter::ResetStats()
{
- m_pcFrames = 0;
- m_nDroppedUpdate = 0;
- m_pcFramesDrawn = 0;
- m_piAvg = 0;
- m_piDev = 0;
+ m_pcFrames = 0;
+ m_nDroppedUpdate = 0;
+ m_pcFramesDrawn = 0;
+ m_piAvg = 0;
+ m_piDev = 0;
}
-HRESULT CEVRAllocatorPresenter::CheckShutdown() const
+HRESULT CEVRAllocatorPresenter::CheckShutdown() const
{
- if(m_nRenderState == Shutdown)
+ if (m_nRenderState == Shutdown)
{
return MF_E_SHUTDOWN;
}
@@ -458,54 +458,54 @@ HRESULT CEVRAllocatorPresenter::CheckShutdown() const
void CEVRAllocatorPresenter::StartWorkerThreads()
{
- DWORD dwThreadId;
+ DWORD dwThreadId;
- if(m_nRenderState == Shutdown)
- {
- m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hEvtFlush = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (m_nRenderState == Shutdown)
+ {
+ m_hEvtQuit = CreateEvent (NULL, TRUE, FALSE, NULL);
+ m_hEvtFlush = CreateEvent (NULL, TRUE, FALSE, NULL);
- m_hThread = ::CreateThread(NULL, 0, PresentThread, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
- m_hGetMixerThread = ::CreateThread(NULL, 0, GetMixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hGetMixerThread, THREAD_PRIORITY_HIGHEST);
+ m_hThread = ::CreateThread(NULL, 0, PresentThread, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
+ m_hGetMixerThread = ::CreateThread(NULL, 0, GetMixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hGetMixerThread, THREAD_PRIORITY_HIGHEST);
- m_nRenderState = Stopped;
- TRACE_EVR("EVR: Worker threads started...\n");
- }
+ m_nRenderState = Stopped;
+ TRACE_EVR ("EVR: Worker threads started...\n");
+ }
}
void CEVRAllocatorPresenter::StopWorkerThreads()
{
- if(m_nRenderState != Shutdown)
- {
- SetEvent(m_hEvtFlush);
- m_bEvtFlush = true;
- SetEvent(m_hEvtQuit);
- m_bEvtQuit = true;
- if((m_hThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hThread, 10000) == WAIT_TIMEOUT))
- {
- ASSERT(FALSE);
- TerminateThread(m_hThread, 0xDEAD);
- }
- if((m_hGetMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hGetMixerThread, 10000) == WAIT_TIMEOUT))
- {
- ASSERT(FALSE);
- TerminateThread(m_hGetMixerThread, 0xDEAD);
- }
+ if (m_nRenderState != Shutdown)
+ {
+ SetEvent (m_hEvtFlush);
+ m_bEvtFlush = true;
+ SetEvent (m_hEvtQuit);
+ m_bEvtQuit = true;
+ if ((m_hThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hThread, 10000) == WAIT_TIMEOUT))
+ {
+ ASSERT (FALSE);
+ TerminateThread (m_hThread, 0xDEAD);
+ }
+ if ((m_hGetMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hGetMixerThread, 10000) == WAIT_TIMEOUT))
+ {
+ ASSERT (FALSE);
+ TerminateThread (m_hGetMixerThread, 0xDEAD);
+ }
- if(m_hThread != INVALID_HANDLE_VALUE) CloseHandle(m_hThread);
- if(m_hGetMixerThread != INVALID_HANDLE_VALUE) CloseHandle(m_hGetMixerThread);
- if(m_hEvtFlush != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtFlush);
- if(m_hEvtQuit != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtQuit);
+ if (m_hThread != INVALID_HANDLE_VALUE) CloseHandle (m_hThread);
+ if (m_hGetMixerThread != INVALID_HANDLE_VALUE) CloseHandle (m_hGetMixerThread);
+ if (m_hEvtFlush != INVALID_HANDLE_VALUE) CloseHandle (m_hEvtFlush);
+ if (m_hEvtQuit != INVALID_HANDLE_VALUE) CloseHandle (m_hEvtQuit);
- m_bEvtFlush = false;
- m_bEvtQuit = false;
+ m_bEvtFlush = false;
+ m_bEvtQuit = false;
- TRACE_EVR("EVR: Worker threads stopped...\n");
- }
- m_nRenderState = Shutdown;
+ TRACE_EVR ("EVR: Worker threads stopped...\n");
+ }
+ m_nRenderState = Shutdown;
}
@@ -513,226 +513,225 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
+ *ppRenderer = NULL;
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- do
- {
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ do
+ {
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- COuterEVR *pOuterEVR = DNew COuterEVR(NAME("COuterEVR"), pUnk, hr, &m_VMR9AlphaBitmap, this);
- m_pOuterEVR = pOuterEVR;
+ COuterEVR *pOuterEVR = DNew COuterEVR(NAME("COuterEVR"), pUnk, hr, &m_VMR9AlphaBitmap, this);
+ m_pOuterEVR = pOuterEVR;
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
- CComQIPtr<IBaseFilter> pBF = pUnk;
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
+ CComQIPtr<IBaseFilter> pBF = pUnk;
- if(FAILED(hr)) break;
+ if (FAILED (hr)) break;
- // Set EVR custom presenter
- CComPtr<IMFVideoPresenter> pVP;
- CComPtr<IMFVideoRenderer> pMFVR;
- CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
+ // Set EVR custom presenter
+ CComPtr<IMFVideoPresenter> pVP;
+ CComPtr<IMFVideoRenderer> pMFVR;
+ CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
- hr = pMFGS->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
+ hr = pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
- if(SUCCEEDED(hr)) hr = QueryInterface(__uuidof(IMFVideoPresenter), (void**)&pVP);
- if(SUCCEEDED(hr)) hr = pMFVR->InitializeRenderer(NULL, pVP);
+ if(SUCCEEDED(hr)) hr = QueryInterface (__uuidof(IMFVideoPresenter), (void**)&pVP);
+ if(SUCCEEDED(hr)) hr = pMFVR->InitializeRenderer (NULL, pVP);
#if 1
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
-
- // No NewSegment : no chocolate :o)
- m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+
+ // No NewSegment : no chocolate :o)
+ m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
#else
- m_fUseInternalTimer = false;
+ m_fUseInternalTimer = false;
#endif
- if(FAILED(hr))
- *ppRenderer = NULL;
- else
- *ppRenderer = pBF.Detach();
+ if(FAILED(hr))
+ *ppRenderer = NULL;
+ else
+ *ppRenderer = pBF.Detach();
- }
- while(0);
+ } while (0);
- return hr;
+ return hr;
}
STDMETHODIMP_(bool) CEVRAllocatorPresenter::Paint(bool fAll)
{
-
- return __super::Paint(fAll);
+
+ return __super::Paint (fAll);
}
STDMETHODIMP CEVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- HRESULT hr;
- if(riid == __uuidof(IMFClockStateSink))
- hr = GetInterface((IMFClockStateSink*)this, ppv);
- else if(riid == __uuidof(IMFVideoPresenter))
- hr = GetInterface((IMFVideoPresenter*)this, ppv);
- else if(riid == __uuidof(IMFTopologyServiceLookupClient))
- hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- else if(riid == __uuidof(IMFVideoDeviceID))
- hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- else if(riid == __uuidof(IMFGetService))
- hr = GetInterface((IMFGetService*)this, ppv);
- else if(riid == __uuidof(IMFAsyncCallback))
- hr = GetInterface((IMFAsyncCallback*)this, ppv);
- else if(riid == __uuidof(IMFVideoDisplayControl))
- hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- else if(riid == __uuidof(IEVRTrustedVideoPlugin))
- hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- else if(riid == IID_IQualProp)
- hr = GetInterface((IQualProp*)this, ppv);
- else if(riid == __uuidof(IMFRateSupport))
- hr = GetInterface((IMFRateSupport*)this, ppv);
- else if(riid == __uuidof(IDirect3DDeviceManager9))
+ HRESULT hr;
+ if(riid == __uuidof(IMFClockStateSink))
+ hr = GetInterface((IMFClockStateSink*)this, ppv);
+ else if(riid == __uuidof(IMFVideoPresenter))
+ hr = GetInterface((IMFVideoPresenter*)this, ppv);
+ else if(riid == __uuidof(IMFTopologyServiceLookupClient))
+ hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
+ else if(riid == __uuidof(IMFVideoDeviceID))
+ hr = GetInterface((IMFVideoDeviceID*)this, ppv);
+ else if(riid == __uuidof(IMFGetService))
+ hr = GetInterface((IMFGetService*)this, ppv);
+ else if(riid == __uuidof(IMFAsyncCallback))
+ hr = GetInterface((IMFAsyncCallback*)this, ppv);
+ else if(riid == __uuidof(IMFVideoDisplayControl))
+ hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
+ else if(riid == __uuidof(IEVRTrustedVideoPlugin))
+ hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
+ else if(riid == IID_IQualProp)
+ hr = GetInterface((IQualProp*)this, ppv);
+ else if(riid == __uuidof(IMFRateSupport))
+ hr = GetInterface((IMFRateSupport*)this, ppv);
+ else if(riid == __uuidof(IDirect3DDeviceManager9))
// hr = GetInterface((IDirect3DDeviceManager9*)this, ppv);
- hr = m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppv);
- else
- hr = __super::NonDelegatingQueryInterface(riid, ppv);
+ hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
+ else
+ hr = __super::NonDelegatingQueryInterface(riid, ppv);
- return hr;
+ return hr;
}
// IMFClockStateSink
STDMETHODIMP CEVRAllocatorPresenter::OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset)
{
- m_nRenderState = Started;
+ m_nRenderState = Started;
- TRACE_EVR("EVR: OnClockStart hnsSystemTime = %I64d, llClockStartOffset = %I64d\n", hnsSystemTime, llClockStartOffset);
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
+ TRACE_EVR ("EVR: OnClockStart hnsSystemTime = %I64d, llClockStartOffset = %I64d\n", hnsSystemTime, llClockStartOffset);
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockStop(MFTIME hnsSystemTime)
{
- TRACE_EVR("EVR: OnClockStop hnsSystemTime = %I64d\n", hnsSystemTime);
- m_nRenderState = Stopped;
+ TRACE_EVR ("EVR: OnClockStop hnsSystemTime = %I64d\n", hnsSystemTime);
+ m_nRenderState = Stopped;
- m_ModeratedClockLast = -1;
- m_ModeratedTimeLast = -1;
- return S_OK;
+ m_ModeratedClockLast = -1;
+ m_ModeratedTimeLast = -1;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockPause(MFTIME hnsSystemTime)
{
- TRACE_EVR("EVR: OnClockPause hnsSystemTime = %I64d\n", hnsSystemTime);
- if(!m_bSignaledStarvation)
- m_nRenderState = Paused;
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
- return S_OK;
+ TRACE_EVR ("EVR: OnClockPause hnsSystemTime = %I64d\n", hnsSystemTime);
+ if (!m_bSignaledStarvation)
+ m_nRenderState = Paused;
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockRestart(MFTIME hnsSystemTime)
{
- m_nRenderState = Started;
+ m_nRenderState = Started;
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
- TRACE_EVR("EVR: OnClockRestart hnsSystemTime = %I64d\n", hnsSystemTime);
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
+ TRACE_EVR ("EVR: OnClockRestart hnsSystemTime = %I64d\n", hnsSystemTime);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockSetRate(MFTIME hnsSystemTime, float flRate)
{
- ASSERT(FALSE);
- return E_NOTIMPL;
+ ASSERT (FALSE);
+ return E_NOTIMPL;
}
// IBaseFilter delegate
-bool CEVRAllocatorPresenter::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue)
+bool CEVRAllocatorPresenter::GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue)
{
- CAutoLock lock(&m_SampleQueueLock);
+ CAutoLock lock(&m_SampleQueueLock);
- if(m_bSignaledStarvation)
- {
- int nSamples = max(m_nNbDXSurface / 2, 1);
- if((m_ScheduledSamples.GetCount() < nSamples || m_LastSampleOffset < -m_rtTimePerFrame * 2) && !g_bNoDuration)
- {
- *State = (FILTER_STATE)Paused;
- _ReturnValue = VFW_S_STATE_INTERMEDIATE;
- return true;
- }
- m_bSignaledStarvation = false;
- }
- return false;
+ if (m_bSignaledStarvation)
+ {
+ int nSamples = max(m_nNbDXSurface / 2, 1);
+ if ((m_ScheduledSamples.GetCount() < nSamples || m_LastSampleOffset < -m_rtTimePerFrame*2) && !g_bNoDuration)
+ {
+ *State = (FILTER_STATE)Paused;
+ _ReturnValue = VFW_S_STATE_INTERMEDIATE;
+ return true;
+ }
+ m_bSignaledStarvation = false;
+ }
+ return false;
}
// IQualProp
STDMETHODIMP CEVRAllocatorPresenter::get_FramesDroppedInRenderer(int *pcFrames)
{
- *pcFrames = m_pcFrames;
- return S_OK;
+ *pcFrames = m_pcFrames;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::get_FramesDrawn(int *pcFramesDrawn)
{
- *pcFramesDrawn = m_pcFramesDrawn;
- return S_OK;
+ *pcFramesDrawn = m_pcFramesDrawn;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::get_AvgFrameRate(int *piAvgFrameRate)
{
- *piAvgFrameRate = (int)(m_fAvrFps * 100);
- return S_OK;
+ *piAvgFrameRate = (int)(m_fAvrFps * 100);
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::get_Jitter(int *iJitter)
{
- *iJitter = (int)((m_fJitterStdDev / 10000.0) + 0.5);
- return S_OK;
+ *iJitter = (int)((m_fJitterStdDev/10000.0) + 0.5);
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::get_AvgSyncOffset(int *piAvg)
{
- *piAvg = (int)((m_fSyncOffsetAvr / 10000.0) + 0.5);
- return S_OK;
+ *piAvg = (int)((m_fSyncOffsetAvr/10000.0) + 0.5);
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::get_DevSyncOffset(int *piDev)
{
- *piDev = (int)((m_fSyncOffsetStdDev / 10000.0) + 0.5);
- return S_OK;
+ *piDev = (int)((m_fSyncOffsetStdDev/10000.0) + 0.5);
+ return S_OK;
}
// IMFRateSupport
STDMETHODIMP CEVRAllocatorPresenter::GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
{
- // TODO : not finished...
- *pflRate = 0;
- return S_OK;
+ // TODO : not finished...
+ *pflRate = 0;
+ return S_OK;
}
-
+
STDMETHODIMP CEVRAllocatorPresenter::GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
{
- HRESULT hr = S_OK;
- float fMaxRate = 0.0f;
+ HRESULT hr = S_OK;
+ float fMaxRate = 0.0f;
- CAutoLock lock(this);
-
- CheckPointer(pflRate, E_POINTER);
- CheckHR(CheckShutdown());
+ CAutoLock lock(this);
- // Get the maximum forward rate.
- fMaxRate = GetMaxRate(fThin);
+ CheckPointer(pflRate, E_POINTER);
+ CheckHR(CheckShutdown());
+
+ // Get the maximum forward rate.
+ fMaxRate = GetMaxRate(fThin);
- // For reverse playback, swap the sign.
- if(eDirection == MFRATE_REVERSE)
- fMaxRate = -fMaxRate;
+ // For reverse playback, swap the sign.
+ if (eDirection == MFRATE_REVERSE)
+ fMaxRate = -fMaxRate;
- *pflRate = fMaxRate;
+ *pflRate = fMaxRate;
- return hr;
+ return hr;
}
-
+
STDMETHODIMP CEVRAllocatorPresenter::IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate)
{
// fRate can be negative for reverse playback.
@@ -744,20 +743,20 @@ STDMETHODIMP CEVRAllocatorPresenter::IsRateSupported(BOOL fThin, float flRate, f
float fMaxRate = 0.0f;
float fNearestRate = flRate; // Default.
- CheckPointer(pflNearestSupportedRate, E_POINTER);
+ CheckPointer (pflNearestSupportedRate, E_POINTER);
CheckHR(hr = CheckShutdown());
// Find the maximum forward rate.
fMaxRate = GetMaxRate(fThin);
- if(fabsf(flRate) > fMaxRate)
+ if (fabsf(flRate) > fMaxRate)
{
// The (absolute) requested rate exceeds the maximum rate.
hr = MF_E_UNSUPPORTED_RATE;
// The nearest supported rate is fMaxRate.
fNearestRate = fMaxRate;
- if(flRate < 0)
+ if (flRate < 0)
{
// For reverse playback, swap the sign.
fNearestRate = -fNearestRate;
@@ -765,7 +764,7 @@ STDMETHODIMP CEVRAllocatorPresenter::IsRateSupported(BOOL fThin, float flRate, f
}
// Return the nearest supported rate if the caller requested it.
- if(pflNearestSupportedRate != NULL)
+ if (pflNearestSupportedRate != NULL)
*pflNearestSupportedRate = fNearestRate;
return hr;
@@ -774,323 +773,312 @@ STDMETHODIMP CEVRAllocatorPresenter::IsRateSupported(BOOL fThin, float flRate, f
float CEVRAllocatorPresenter::GetMaxRate(BOOL bThin)
{
- float fMaxRate = FLT_MAX; // Default.
- UINT32 fpsNumerator = 0, fpsDenominator = 0;
- UINT MonitorRateHz = 0;
-
- if(!bThin && (m_pMediaType != NULL))
- {
- // Non-thinned: Use the frame rate and monitor refresh rate.
+ float fMaxRate = FLT_MAX; // Default.
+ UINT32 fpsNumerator = 0, fpsDenominator = 0;
+ UINT MonitorRateHz = 0;
- // Frame rate:
- MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
- &fpsNumerator, &fpsDenominator);
+ if (!bThin && (m_pMediaType != NULL))
+ {
+ // Non-thinned: Use the frame rate and monitor refresh rate.
+
+ // Frame rate:
+ MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
+ &fpsNumerator, &fpsDenominator);
- // Monitor refresh rate:
- MonitorRateHz = m_RefreshRate; // D3DDISPLAYMODE
+ // Monitor refresh rate:
+ MonitorRateHz = m_RefreshRate; // D3DDISPLAYMODE
- if(fpsDenominator && fpsNumerator && MonitorRateHz)
- {
- // Max Rate = Refresh Rate / Frame Rate
- fMaxRate = (float)MulDiv(
- MonitorRateHz, fpsDenominator, fpsNumerator);
- }
- }
- return fMaxRate;
+ if (fpsDenominator && fpsNumerator && MonitorRateHz)
+ {
+ // Max Rate = Refresh Rate / Frame Rate
+ fMaxRate = (float)MulDiv(
+ MonitorRateHz, fpsDenominator, fpsNumerator);
+ }
+ }
+ return fMaxRate;
}
void CEVRAllocatorPresenter::CompleteFrameStep(bool bCancel)
{
- if(m_nStepCount > 0)
- {
- if(bCancel || (m_nStepCount == 1))
- {
- m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
- m_nStepCount = 0;
- }
- else
- m_nStepCount--;
- }
+ if (m_nStepCount > 0)
+ {
+ if (bCancel || (m_nStepCount == 1))
+ {
+ m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
+ m_nStepCount = 0;
+ }
+ else
+ m_nStepCount--;
+ }
}
// IMFVideoPresenter
STDMETHODIMP CEVRAllocatorPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam)
{
- HRESULT hr = S_OK;
-
- switch(eMessage)
- {
- case MFVP_MESSAGE_BEGINSTREAMING : // The EVR switched from stopped to paused. The presenter should allocate resources
- ResetStats();
- TRACE_EVR("EVR: MFVP_MESSAGE_BEGINSTREAMING\n");
- break;
-
- case MFVP_MESSAGE_CANCELSTEP : // Cancels a frame step
- TRACE_EVR("EVR: MFVP_MESSAGE_CANCELSTEP\n");
- CompleteFrameStep(true);
- break;
-
- case MFVP_MESSAGE_ENDOFSTREAM : // All input streams have ended.
- TRACE_EVR("EVR: MFVP_MESSAGE_ENDOFSTREAM\n");
- m_bPendingMediaFinished = true;
- break;
-
- case MFVP_MESSAGE_ENDSTREAMING : // The EVR switched from running or paused to stopped. The presenter should free resources
- TRACE_EVR("EVR: MFVP_MESSAGE_ENDSTREAMING\n");
- break;
-
- case MFVP_MESSAGE_FLUSH : // The presenter should discard any pending samples
- SetEvent(m_hEvtFlush);
- m_bEvtFlush = true;
- TRACE_EVR("EVR: MFVP_MESSAGE_FLUSH\n");
- while(WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0);
- break;
-
- case MFVP_MESSAGE_INVALIDATEMEDIATYPE : // The mixer's output format has changed. The EVR will initiate format negotiation, as described previously
- /*
- 1) The EVR sets the media type on the reference stream.
- 2) The EVR calls IMFVideoPresenter::ProcessMessage on the presenter with the MFVP_MESSAGE_INVALIDATEMEDIATYPE message.
- 3) The presenter sets the media type on the mixer's output stream.
- 4) The EVR sets the media type on the substreams.
- */
- m_bPendingRenegotiate = true;
- while(*((volatile bool *)&m_bPendingRenegotiate))
- Sleep(1);
- break;
-
- case MFVP_MESSAGE_PROCESSINPUTNOTIFY : // One input stream on the mixer has received a new sample
+ HRESULT hr = S_OK;
+
+ switch (eMessage)
+ {
+ case MFVP_MESSAGE_BEGINSTREAMING : // The EVR switched from stopped to paused. The presenter should allocate resources
+ ResetStats();
+ TRACE_EVR ("EVR: MFVP_MESSAGE_BEGINSTREAMING\n");
+ break;
+
+ case MFVP_MESSAGE_CANCELSTEP : // Cancels a frame step
+ TRACE_EVR ("EVR: MFVP_MESSAGE_CANCELSTEP\n");
+ CompleteFrameStep (true);
+ break;
+
+ case MFVP_MESSAGE_ENDOFSTREAM : // All input streams have ended.
+ TRACE_EVR ("EVR: MFVP_MESSAGE_ENDOFSTREAM\n");
+ m_bPendingMediaFinished = true;
+ break;
+
+ case MFVP_MESSAGE_ENDSTREAMING : // The EVR switched from running or paused to stopped. The presenter should free resources
+ TRACE_EVR ("EVR: MFVP_MESSAGE_ENDSTREAMING\n");
+ break;
+
+ case MFVP_MESSAGE_FLUSH : // The presenter should discard any pending samples
+ SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
+ TRACE_EVR ("EVR: MFVP_MESSAGE_FLUSH\n");
+ while (WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0);
+ break;
+
+ case MFVP_MESSAGE_INVALIDATEMEDIATYPE : // The mixer's output format has changed. The EVR will initiate format negotiation, as described previously
+ /*
+ 1) The EVR sets the media type on the reference stream.
+ 2) The EVR calls IMFVideoPresenter::ProcessMessage on the presenter with the MFVP_MESSAGE_INVALIDATEMEDIATYPE message.
+ 3) The presenter sets the media type on the mixer's output stream.
+ 4) The EVR sets the media type on the substreams.
+ */
+ m_bPendingRenegotiate = true;
+ while (*((volatile bool *)&m_bPendingRenegotiate))
+ Sleep(1);
+ break;
+
+ case MFVP_MESSAGE_PROCESSINPUTNOTIFY : // One input stream on the mixer has received a new sample
// GetImageFromMixer();
- break;
+ break;
- case MFVP_MESSAGE_STEP : // Requests a frame step.
- TRACE_EVR("EVR: MFVP_MESSAGE_STEP\n");
- m_nStepCount = ulParam;
- hr = S_OK;
- break;
+ case MFVP_MESSAGE_STEP : // Requests a frame step.
+ TRACE_EVR ("EVR: MFVP_MESSAGE_STEP\n");
+ m_nStepCount = ulParam;
+ hr = S_OK;
+ break;
- default :
- ASSERT(FALSE);
- break;
- }
- return hr;
+ default :
+ ASSERT (FALSE);
+ break;
+ }
+ return hr;
}
HRESULT CEVRAllocatorPresenter::IsMediaTypeSupported(IMFMediaType* pMixerType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia;
- UINT nInterlaceMode;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia;
+ UINT nInterlaceMode;
- CheckHR(pMixerType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
- CheckHR(pMixerType->GetUINT32(MF_MT_INTERLACE_MODE, &nInterlaceMode));
+ CheckHR (pMixerType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
+ CheckHR (pMixerType->GetUINT32 (MF_MT_INTERLACE_MODE, &nInterlaceMode));
- /* if ( (pAMMedia->majortype != MEDIATYPE_Video) ||
- (nInterlaceMode != MFVideoInterlace_Progressive) ||
- ( (pAMMedia->subtype != MEDIASUBTYPE_RGB32) && (pAMMedia->subtype != MEDIASUBTYPE_RGB24) &&
- (pAMMedia->subtype != MEDIASUBTYPE_YUY2) && (pAMMedia->subtype != MEDIASUBTYPE_NV12) ) )
- hr = MF_E_INVALIDMEDIATYPE;*/
- if((pAMMedia->majortype != MEDIATYPE_Video))
- hr = MF_E_INVALIDMEDIATYPE;
- pMixerType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
- return hr;
+/* if ( (pAMMedia->majortype != MEDIATYPE_Video) ||
+ (nInterlaceMode != MFVideoInterlace_Progressive) ||
+ ( (pAMMedia->subtype != MEDIASUBTYPE_RGB32) && (pAMMedia->subtype != MEDIASUBTYPE_RGB24) &&
+ (pAMMedia->subtype != MEDIASUBTYPE_YUY2) && (pAMMedia->subtype != MEDIASUBTYPE_NV12) ) )
+ hr = MF_E_INVALIDMEDIATYPE;*/
+ if ( (pAMMedia->majortype != MEDIATYPE_Video))
+ hr = MF_E_INVALIDMEDIATYPE;
+ pMixerType->FreeRepresentation (FORMAT_VideoInfo2, (void*)pAMMedia);
+ return hr;
}
HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = NULL;
- LARGE_INTEGER i64Size;
- MFVIDEOFORMAT* VideoFormat;
-
- CheckHR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
-
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
- hr = pfMFCreateVideoMediaType(VideoFormat, &m_pMediaType);
-
- if(0)
- {
- // This code doesn't work, use same method as VMR9 instead
- if(VideoFormat->videoInfo.FramesPerSecond.Numerator != 0)
- {
- switch(VideoFormat->videoInfo.InterlaceMode)
- {
- case MFVideoInterlace_Progressive:
- case MFVideoInterlace_MixedInterlaceOrProgressive:
- default:
- {
- m_rtTimePerFrame = (10000000I64 * VideoFormat->videoInfo.FramesPerSecond.Denominator) / VideoFormat->videoInfo.FramesPerSecond.Numerator;
- m_bInterlaced = false;
- }
- break;
- case MFVideoInterlace_FieldSingleUpper:
- case MFVideoInterlace_FieldSingleLower:
- case MFVideoInterlace_FieldInterleavedUpperFirst:
- case MFVideoInterlace_FieldInterleavedLowerFirst:
- {
- m_rtTimePerFrame = (20000000I64 * VideoFormat->videoInfo.FramesPerSecond.Denominator) / VideoFormat->videoInfo.FramesPerSecond.Numerator;
- m_bInterlaced = true;
- }
- break;
- }
- }
- }
-
- m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
- m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
-
- if(SUCCEEDED(hr))
- {
- i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
- i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
- m_pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
-
- m_pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
-
- AppSettings& s = AfxGetAppSettings();
-
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ LARGE_INTEGER i64Size;
+ MFVIDEOFORMAT* VideoFormat;
+
+ CheckHR (pMixerType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia));
+
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+ hr = pfMFCreateVideoMediaType (VideoFormat, &m_pMediaType);
+
+ if (0)
+ {
+ // This code doesn't work, use same method as VMR9 instead
+ if (VideoFormat->videoInfo.FramesPerSecond.Numerator != 0)
+ {
+ switch (VideoFormat->videoInfo.InterlaceMode)
+ {
+ case MFVideoInterlace_Progressive:
+ case MFVideoInterlace_MixedInterlaceOrProgressive:
+ default:
+ {
+ m_rtTimePerFrame = (10000000I64*VideoFormat->videoInfo.FramesPerSecond.Denominator)/VideoFormat->videoInfo.FramesPerSecond.Numerator;
+ m_bInterlaced = false;
+ }
+ break;
+ case MFVideoInterlace_FieldSingleUpper:
+ case MFVideoInterlace_FieldSingleLower:
+ case MFVideoInterlace_FieldInterleavedUpperFirst:
+ case MFVideoInterlace_FieldInterleavedLowerFirst:
+ {
+ m_rtTimePerFrame = (20000000I64*VideoFormat->videoInfo.FramesPerSecond.Denominator)/VideoFormat->videoInfo.FramesPerSecond.Numerator;
+ m_bInterlaced = true;
+ }
+ break;
+ }
+ }
+ }
+
+ m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
+ m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
+
+ if (SUCCEEDED (hr))
+ {
+ i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
+ i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
+ m_pMediaType->SetUINT64 (MF_MT_FRAME_SIZE, i64Size.QuadPart);
+
+ m_pMediaType->SetUINT32 (MF_MT_PAN_SCAN_ENABLED, 0);
+
+ AppSettings& s = AfxGetAppSettings();
+
#if 1
- if(s.m_RenderSettings.iEVROutputRange == 1)
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- else
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ if (s.m_RenderSettings.iEVROutputRange == 1)
+ m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
+ else
+ m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
// m_pMediaType->SetUINT32 (MF_MT_TRANSFER_FUNCTION, MFVideoTransFunc_10);
-
+
#else
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
- if(s.iEVROutputRange == 1)
- m_pMediaType->SetUINT32(MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601);
- else
- m_pMediaType->SetUINT32(MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709);
+ m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ if (s.iEVROutputRange == 1)
+ m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601);
+ else
+ m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709);
#endif
-
-
- m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
-
- i64Size.HighPart = m_AspectRatio.cx;
- i64Size.LowPart = m_AspectRatio.cy;
- m_pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
-
- MFVideoArea Area = MakeArea(0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
- m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
-
- }
-
- m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
- m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
-
- bool bDoneSomething = true;
-
- if(m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) //if any of these is 0, it will stuck into a infinite loop
- {
- while(bDoneSomething)
- {
- bDoneSomething = false;
- INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
- INT i;
- for(i = 2; i < MinNum + 1; ++i)
- {
- if(m_AspectRatio.cx % i == 0 && m_AspectRatio.cy % i == 0)
- break;
- }
- if(i != MinNum + 1)
- {
- m_AspectRatio.cx = m_AspectRatio.cx / i;
- m_AspectRatio.cy = m_AspectRatio.cy / i;
- bDoneSomething = true;
- }
- }
- }
-
- pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
- m_pMediaType->QueryInterface(__uuidof(IMFMediaType), (void**) pType);
-
- return hr;
+
+
+ m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
+
+ i64Size.HighPart = m_AspectRatio.cx;
+ i64Size.LowPart = m_AspectRatio.cy;
+ m_pMediaType->SetUINT64 (MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
+
+ MFVideoArea Area = MakeArea (0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
+ m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+
+ }
+
+ m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
+ m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
+
+ bool bDoneSomething = true;
+
+ if(m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1){ //if any of these is 0, it will stuck into a infinite loop
+ while (bDoneSomething)
+ {
+ bDoneSomething = false;
+ INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
+ INT i;
+ for (i = 2; i < MinNum+1; ++i)
+ {
+ if (m_AspectRatio.cx%i == 0 && m_AspectRatio.cy%i ==0)
+ break;
+ }
+ if (i != MinNum + 1)
+ {
+ m_AspectRatio.cx = m_AspectRatio.cx / i;
+ m_AspectRatio.cy = m_AspectRatio.cy / i;
+ bDoneSomething = true;
+ }
+ }
+ }
+
+ pMixerType->FreeRepresentation (FORMAT_MFVideoFormat, (void*)pAMMedia);
+ m_pMediaType->QueryInterface (__uuidof(IMFMediaType), (void**) pType);
+
+ return hr;
}
HRESULT CEVRAllocatorPresenter::SetMediaType(IMFMediaType* pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = NULL;
- CString strTemp;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ CString strTemp;
- CheckPointer(pType, E_POINTER);
- CheckHR(pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
-
- hr = InitializeDevice(pAMMedia);
- if(SUCCEEDED(hr))
- {
- strTemp = GetMediaTypeName(pAMMedia->subtype);
- strTemp.Replace(L"MEDIASUBTYPE_", L"");
- m_strStatsMsg[MSG_MIXEROUT].Format(L"Mixer output : %s", strTemp);
- }
+ CheckPointer (pType, E_POINTER);
+ CheckHR (pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
+
+ hr = InitializeDevice (pAMMedia);
+ if (SUCCEEDED (hr))
+ {
+ strTemp = GetMediaTypeName (pAMMedia->subtype);
+ strTemp.Replace (L"MEDIASUBTYPE_", L"");
+ m_strStatsMsg[MSG_MIXEROUT].Format (L"Mixer output : %s", strTemp);
+ }
- pType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
+ pType->FreeRepresentation (FORMAT_VideoInfo2, (void*)pAMMedia);
- return hr;
+ return hr;
}
LONGLONG GetMediaTypeMerit(IMFMediaType *pMediaType)
{
- AM_MEDIA_TYPE* pAMMedia = NULL;
- MFVIDEOFORMAT* VideoFormat;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ MFVIDEOFORMAT* VideoFormat;
- HRESULT hr;
- CheckHR(pMediaType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+ HRESULT hr;
+ CheckHR (pMediaType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia));
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
- LONGLONG Merit = 0;
- switch(VideoFormat->surfaceInfo.Format)
- {
- case FCC('NV12'):
- Merit = 90000000;
- break;
- case FCC('YV12'):
- Merit = 80000000;
- break;
- case FCC('YUY2'):
- Merit = 70000000;
- break;
- case FCC('UYVY'):
- Merit = 60000000;
- break;
-
- case D3DFMT_X8R8G8B8: // Never opt for RGB
- case D3DFMT_A8R8G8B8:
- case D3DFMT_R8G8B8:
- case D3DFMT_R5G6B5:
- Merit = 0;
- break;
- default:
- Merit = 1000;
- break;
- }
+ LONGLONG Merit = 0;
+ switch (VideoFormat->surfaceInfo.Format)
+ {
+ case FCC('NV12'): Merit = 90000000; break;
+ case FCC('YV12'): Merit = 80000000; break;
+ case FCC('YUY2'): Merit = 70000000; break;
+ case FCC('UYVY'): Merit = 60000000; break;
- pMediaType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
+ case D3DFMT_X8R8G8B8: // Never opt for RGB
+ case D3DFMT_A8R8G8B8:
+ case D3DFMT_R8G8B8:
+ case D3DFMT_R5G6B5:
+ Merit = 0;
+ break;
+ default: Merit = 1000; break;
+ }
+
+ pMediaType->FreeRepresentation (FORMAT_MFVideoFormat, (void*)pAMMedia);
- return Merit;
+ return Merit;
}
LPCTSTR FindD3DFormat(const D3DFORMAT Format);
LPCTSTR GetMediaTypeFormatDesc(IMFMediaType *pMediaType)
{
- AM_MEDIA_TYPE* pAMMedia = NULL;
- MFVIDEOFORMAT* VideoFormat;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ MFVIDEOFORMAT* VideoFormat;
- HRESULT hr;
- hr = pMediaType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia);
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+ HRESULT hr;
+ hr = pMediaType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia);
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
- LPCTSTR Type = FindD3DFormat((D3DFORMAT)VideoFormat->surfaceInfo.Format);
+ LPCTSTR Type = FindD3DFormat((D3DFORMAT)VideoFormat->surfaceInfo.Format);
+
+ pMediaType->FreeRepresentation (FORMAT_MFVideoFormat, (void*)pAMMedia);
- pMediaType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
-
- return Type;
+ return Type;
}
HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
@@ -1100,95 +1088,95 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
CComPtr<IMFMediaType> pMixerType;
CComPtr<IMFMediaType> pType;
- if(!m_pMixer)
+ if (!m_pMixer)
{
return MF_E_INVALIDREQUEST;
}
- CInterfaceArray<IMFMediaType> ValidMixerTypes;
+ CInterfaceArray<IMFMediaType> ValidMixerTypes;
// Loop through all of the mixer's proposed output types.
DWORD iTypeIndex = 0;
- while((hr != MF_E_NO_MORE_TYPES))
+ while ((hr != MF_E_NO_MORE_TYPES))
{
pMixerType = NULL;
pType = NULL;
- m_pMediaType = NULL;
+ m_pMediaType = NULL;
// Step 1. Get the next media type supported by mixer.
hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
- if(FAILED(hr))
+ if (FAILED(hr))
{
break;
}
// Step 2. Check if we support this media type.
- if(SUCCEEDED(hr))
+ if (SUCCEEDED(hr))
hr = IsMediaTypeSupported(pMixerType);
- if(SUCCEEDED(hr))
- hr = CreateProposedOutputType(pMixerType, &pType);
-
+ if (SUCCEEDED(hr))
+ hr = CreateProposedOutputType(pMixerType, &pType);
+
// Step 4. Check if the mixer will accept this media type.
- if(SUCCEEDED(hr))
+ if (SUCCEEDED(hr))
hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
- if(SUCCEEDED(hr))
- {
- LONGLONG Merit = GetMediaTypeMerit(pType);
+ if (SUCCEEDED(hr))
+ {
+ LONGLONG Merit = GetMediaTypeMerit(pType);
- int nTypes = ValidMixerTypes.GetCount();
- int iInsertPos = 0;
- for(int i = 0; i < nTypes; ++i)
- {
- LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
- if(Merit > ThisMerit)
- {
- iInsertPos = i;
- break;
- }
- else
- iInsertPos = i + 1;
- }
+ int nTypes = ValidMixerTypes.GetCount();
+ int iInsertPos = 0;
+ for (int i = 0; i < nTypes; ++i)
+ {
+ LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
+ if (Merit > ThisMerit)
+ {
+ iInsertPos = i;
+ break;
+ }
+ else
+ iInsertPos = i+1;
+ }
- ValidMixerTypes.InsertAt(iInsertPos, pType);
- }
+ ValidMixerTypes.InsertAt(iInsertPos, pType);
+ }
}
- int nValidTypes = ValidMixerTypes.GetCount();
- for(int i = 0; i < nValidTypes; ++i)
- {
+ int nValidTypes = ValidMixerTypes.GetCount();
+ for (int i = 0; i < nValidTypes; ++i)
+ {
// Step 3. Adjust the mixer's type to match our requirements.
- pType = ValidMixerTypes[i];
- TRACE_EVR("EVR: Valid mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
- }
+ pType = ValidMixerTypes[i];
+ TRACE_EVR("EVR: Valid mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
+ }
- for(int i = 0; i < nValidTypes; ++i)
- {
+ for (int i = 0; i < nValidTypes; ++i)
+ {
// Step 3. Adjust the mixer's type to match our requirements.
- pType = ValidMixerTypes[i];
+ pType = ValidMixerTypes[i];
-
- TRACE_EVR("EVR: Trying mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
+
+ TRACE_EVR("EVR: Trying mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
// Step 5. Try to set the media type on ourselves.
- hr = SetMediaType(pType);
+ hr = SetMediaType(pType);
// Step 6. Set output media type on mixer.
- if(SUCCEEDED(hr))
+ if (SUCCEEDED(hr))
{
hr = m_pMixer->SetOutputType(0, pType, 0);
// If something went wrong, clear the media type.
- if(FAILED(hr))
+ if (FAILED(hr))
{
SetMediaType(NULL);
}
- else
- break;
+ else
+ break;
}
- }
+ }
pMixerType = NULL;
pType = NULL;
@@ -1198,80 +1186,80 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
bool CEVRAllocatorPresenter::GetImageFromMixer()
{
- MFT_OUTPUT_DATA_BUFFER Buffer;
- HRESULT hr = S_OK;
- DWORD dwStatus;
- REFERENCE_TIME nsSampleTime;
- LONGLONG llClockBefore = 0;
- LONGLONG llClockAfter = 0;
- LONGLONG llMixerLatency;
- UINT dwSurface;
-
- bool bDoneSomething = false;
-
- while(SUCCEEDED(hr))
- {
- CComPtr<IMFSample> pSample;
-
- if(FAILED(GetFreeSample(&pSample)))
- {
- m_bWaitingSample = true;
- break;
- }
-
- memset(&Buffer, 0, sizeof(Buffer));
- Buffer.pSample = pSample;
- pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
-
- {
- llClockBefore = AfxGetMyApp()->GetPerfCounter();
- hr = m_pMixer->ProcessOutput(0 , 1, &Buffer, &dwStatus);
- llClockAfter = AfxGetMyApp()->GetPerfCounter();
- }
-
- if(hr == MF_E_TRANSFORM_NEED_MORE_INPUT)
- {
- MoveToFreeList(pSample, false);
- break;
- }
-
- if(m_pSink)
- {
- //CAutoLock autolock(this); We shouldn't need to lock here, m_pSink is thread safe
- llMixerLatency = llClockAfter - llClockBefore;
- m_pSink->Notify(EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
- }
-
- pSample->GetSampleTime(&nsSampleTime);
- REFERENCE_TIME nsDuration;
- pSample->GetSampleDuration(&nsDuration);
-
- if(AfxGetMyApp()->m_fTearingTest)
- {
- RECT rcTearing;
-
- rcTearing.left = m_nTearingPos;
- rcTearing.top = 0;
- rcTearing.right = rcTearing.left + 4;
- rcTearing.bottom = m_NativeVideoSize.cy;
- m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
-
- rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
- rcTearing.right = rcTearing.left + 4;
- m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
- m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
- }
-
- LONGLONG TimePerFrame = m_rtTimePerFrame;
- TRACE_EVR("EVR: Get from Mixer : %d (%I64d) (%I64d)\n", dwSurface, nsSampleTime, TimePerFrame != 0 ? nsSampleTime / TimePerFrame : 0);
-
- MoveToScheduledList(pSample, false);
- bDoneSomething = true;
- if(m_rtTimePerFrame == 0)
- break;
- }
-
- return bDoneSomething;
+ MFT_OUTPUT_DATA_BUFFER Buffer;
+ HRESULT hr = S_OK;
+ DWORD dwStatus;
+ REFERENCE_TIME nsSampleTime;
+ LONGLONG llClockBefore = 0;
+ LONGLONG llClockAfter = 0;
+ LONGLONG llMixerLatency;
+ UINT dwSurface;
+
+ bool bDoneSomething = false;
+
+ while (SUCCEEDED(hr))
+ {
+ CComPtr<IMFSample> pSample;
+
+ if (FAILED (GetFreeSample (&pSample)))
+ {
+ m_bWaitingSample = true;
+ break;
+ }
+
+ memset (&Buffer, 0, sizeof(Buffer));
+ Buffer.pSample = pSample;
+ pSample->GetUINT32 (GUID_SURFACE_INDEX, &dwSurface);
+
+ {
+ llClockBefore = AfxGetMyApp()->GetPerfCounter();
+ hr = m_pMixer->ProcessOutput (0 , 1, &Buffer, &dwStatus);
+ llClockAfter = AfxGetMyApp()->GetPerfCounter();
+ }
+
+ if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT)
+ {
+ MoveToFreeList (pSample, false);
+ break;
+ }
+
+ if (m_pSink)
+ {
+ //CAutoLock autolock(this); We shouldn't need to lock here, m_pSink is thread safe
+ llMixerLatency = llClockAfter - llClockBefore;
+ m_pSink->Notify (EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
+ }
+
+ pSample->GetSampleTime (&nsSampleTime);
+ REFERENCE_TIME nsDuration;
+ pSample->GetSampleDuration (&nsDuration);
+
+ if (AfxGetMyApp()->m_fTearingTest)
+ {
+ RECT rcTearing;
+
+ rcTearing.left = m_nTearingPos;
+ rcTearing.top = 0;
+ rcTearing.right = rcTearing.left + 4;
+ rcTearing.bottom = m_NativeVideoSize.cy;
+ m_pD3DDev->ColorFill (m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+
+ rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
+ rcTearing.right = rcTearing.left + 4;
+ m_pD3DDev->ColorFill (m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+ m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
+ }
+
+ LONGLONG TimePerFrame = m_rtTimePerFrame;
+ TRACE_EVR ("EVR: Get from Mixer : %d (%I64d) (%I64d)\n", dwSurface, nsSampleTime, TimePerFrame!=0?nsSampleTime/TimePerFrame:0);
+
+ MoveToScheduledList (pSample, false);
+ bDoneSomething = true;
+ if (m_rtTimePerFrame == 0)
+ break;
+ }
+
+ return bDoneSomething;
}
@@ -1281,1444 +1269,1444 @@ STDMETHODIMP CEVRAllocatorPresenter::GetCurrentMediaType(__deref_out IMFVideoMe
HRESULT hr = S_OK;
CAutoLock lock(this); // Hold the critical section.
- CheckPointer(ppMediaType, E_POINTER);
- CheckHR(CheckShutdown());
+ CheckPointer (ppMediaType, E_POINTER);
+ CheckHR (CheckShutdown());
- if(m_pMediaType == NULL)
+ if (m_pMediaType == NULL)
CheckHR(MF_E_NOT_INITIALIZED);
- CheckHR(m_pMediaType->QueryInterface(__uuidof(IMFVideoMediaType), (void**)&ppMediaType));
+ CheckHR(m_pMediaType->QueryInterface( __uuidof(IMFVideoMediaType), (void**)&ppMediaType));
return hr;
}
-// IMFTopologyServiceLookupClient
+// IMFTopologyServiceLookupClient
STDMETHODIMP CEVRAllocatorPresenter::InitServicePointers(/* [in] */ __in IMFTopologyServiceLookup *pLookup)
{
- HRESULT hr;
- DWORD dwObjects = 1;
+ HRESULT hr;
+ DWORD dwObjects = 1;
- TRACE_EVR("EVR: CEVRAllocatorPresenter::InitServicePointers\n");
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE,
- __uuidof(IMFTransform), (void**)&m_pMixer, &dwObjects);
+ TRACE_EVR ("EVR: CEVRAllocatorPresenter::InitServicePointers\n");
+ hr = pLookup->LookupService (MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE,
+ __uuidof (IMFTransform), (void**)&m_pMixer, &dwObjects);
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
- __uuidof(IMediaEventSink), (void**)&m_pSink, &dwObjects);
+ hr = pLookup->LookupService (MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
+ __uuidof (IMediaEventSink ), (void**)&m_pSink, &dwObjects);
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
- __uuidof(IMFClock), (void**)&m_pClock, &dwObjects);
+ hr = pLookup->LookupService (MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
+ __uuidof (IMFClock ), (void**)&m_pClock, &dwObjects);
- StartWorkerThreads();
- return S_OK;
+ StartWorkerThreads();
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::ReleaseServicePointers()
{
- TRACE_EVR("EVR: CEVRAllocatorPresenter::ReleaseServicePointers\n");
- StopWorkerThreads();
- m_pMixer = NULL;
- m_pSink = NULL;
- m_pClock = NULL;
- return S_OK;
+ TRACE_EVR ("EVR: CEVRAllocatorPresenter::ReleaseServicePointers\n");
+ StopWorkerThreads();
+ m_pMixer = NULL;
+ m_pSink = NULL;
+ m_pClock = NULL;
+ return S_OK;
}
// IMFVideoDeviceID
STDMETHODIMP CEVRAllocatorPresenter::GetDeviceID(/* [out] */ __out IID *pDeviceID)
{
- CheckPointer(pDeviceID, E_POINTER);
- *pDeviceID = IID_IDirect3DDevice9;
- return S_OK;
+ CheckPointer(pDeviceID, E_POINTER);
+ *pDeviceID = IID_IDirect3DDevice9;
+ return S_OK;
}
// IMFGetService
-STDMETHODIMP CEVRAllocatorPresenter::GetService(/* [in] */ __RPC__in REFGUID guidService,
- /* [in] */ __RPC__in REFIID riid,
- /* [iid_is][out] */ __RPC__deref_out_opt LPVOID *ppvObject)
+STDMETHODIMP CEVRAllocatorPresenter::GetService (/* [in] */ __RPC__in REFGUID guidService,
+ /* [in] */ __RPC__in REFIID riid,
+ /* [iid_is][out] */ __RPC__deref_out_opt LPVOID *ppvObject)
{
- if(guidService == MR_VIDEO_RENDER_SERVICE)
- return NonDelegatingQueryInterface(riid, ppvObject);
- else if(guidService == MR_VIDEO_ACCELERATION_SERVICE)
- return m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
+ if (guidService == MR_VIDEO_RENDER_SERVICE)
+ return NonDelegatingQueryInterface (riid, ppvObject);
+ else if (guidService == MR_VIDEO_ACCELERATION_SERVICE)
+ return m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
// IMFAsyncCallback
-STDMETHODIMP CEVRAllocatorPresenter::GetParameters(/* [out] */ __RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue)
+STDMETHODIMP CEVRAllocatorPresenter::GetParameters( /* [out] */ __RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-STDMETHODIMP CEVRAllocatorPresenter::Invoke(/* [in] */ __RPC__in_opt IMFAsyncResult *pAsyncResult)
+STDMETHODIMP CEVRAllocatorPresenter::Invoke ( /* [in] */ __RPC__in_opt IMFAsyncResult *pAsyncResult)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IMFVideoDisplayControl
STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
{
- if(pszVideo)
- {
- pszVideo->cx = m_NativeVideoSize.cx;
- pszVideo->cy = m_NativeVideoSize.cy;
- }
- if(pszARVideo)
- {
- pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
- pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
- }
- return S_OK;
+ if (pszVideo)
+ {
+ pszVideo->cx = m_NativeVideoSize.cx;
+ pszVideo->cy = m_NativeVideoSize.cy;
+ }
+ if (pszARVideo)
+ {
+ pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
+ pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
+ }
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax)
{
- if(pszMin)
- {
- pszMin->cx = 1;
- pszMin->cy = 1;
- }
+ if (pszMin)
+ {
+ pszMin->cx = 1;
+ pszMin->cy = 1;
+ }
- if(pszMax)
- {
- D3DDISPLAYMODE d3ddm;
+ if (pszMax)
+ {
+ D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
- {
- pszMax->cx = d3ddm.Width;
- pszMax->cy = d3ddm.Height;
- }
- }
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
+ {
+ pszMax->cx = d3ddm.Width;
+ pszMax->cy = d3ddm.Height;
+ }
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest)
{
- // Always all source rectangle ?
- if(pnrcSource)
- {
- pnrcSource->left = 0.0;
- pnrcSource->top = 0.0;
- pnrcSource->right = 1.0;
- pnrcSource->bottom = 1.0;
- }
+ // Always all source rectangle ?
+ if (pnrcSource)
+ {
+ pnrcSource->left = 0.0;
+ pnrcSource->top = 0.0;
+ pnrcSource->right = 1.0;
+ pnrcSource->bottom = 1.0;
+ }
- if(prcDest)
- memcpy(prcDest, &m_VideoRect, sizeof(m_VideoRect)); //GetClientRect (m_hWnd, prcDest);
+ if (prcDest)
+ memcpy (prcDest, &m_VideoRect, sizeof(m_VideoRect));//GetClientRect (m_hWnd, prcDest);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetAspectRatioMode(DWORD dwAspectRatioMode)
{
- m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
- return S_OK;
+ m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetAspectRatioMode(DWORD *pdwAspectRatioMode)
{
- CheckPointer(pdwAspectRatioMode, E_POINTER);
- *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
- return S_OK;
+ CheckPointer (pdwAspectRatioMode, E_POINTER);
+ *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetVideoWindow(HWND hwndVideo)
{
- ASSERT(m_hWnd == hwndVideo); // What if not ??
+ ASSERT (m_hWnd == hwndVideo); // What if not ??
// m_hWnd = hwndVideo;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetVideoWindow(HWND *phwndVideo)
{
- CheckPointer(phwndVideo, E_POINTER);
- *phwndVideo = m_hWnd;
- return S_OK;
+ CheckPointer (phwndVideo, E_POINTER);
+ *phwndVideo = m_hWnd;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::RepaintVideo()
{
- Paint(true);
- return S_OK;
+ Paint (true);
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp)
{
- ASSERT(FALSE);
- return E_NOTIMPL;
+ ASSERT (FALSE);
+ return E_NOTIMPL;
}
STDMETHODIMP CEVRAllocatorPresenter::SetBorderColor(COLORREF Clr)
{
- m_BorderColor = Clr;
- return S_OK;
+ m_BorderColor = Clr;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetBorderColor(COLORREF *pClr)
{
- CheckPointer(pClr, E_POINTER);
- *pClr = m_BorderColor;
- return S_OK;
+ CheckPointer (pClr, E_POINTER);
+ *pClr = m_BorderColor;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetRenderingPrefs(DWORD dwRenderFlags)
{
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
- return S_OK;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetRenderingPrefs(DWORD *pdwRenderFlags)
{
- CheckPointer(pdwRenderFlags, E_POINTER);
- *pdwRenderFlags = m_dwVideoRenderPrefs;
- return S_OK;
+ CheckPointer(pdwRenderFlags, E_POINTER);
+ *pdwRenderFlags = m_dwVideoRenderPrefs;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetFullscreen(BOOL fFullscreen)
{
- ASSERT(FALSE);
- return E_NOTIMPL;
+ ASSERT (FALSE);
+ return E_NOTIMPL;
}
STDMETHODIMP CEVRAllocatorPresenter::GetFullscreen(BOOL *pfFullscreen)
{
- ASSERT(FALSE);
- return E_NOTIMPL;
+ ASSERT (FALSE);
+ return E_NOTIMPL;
}
// IEVRTrustedVideoPlugin
STDMETHODIMP CEVRAllocatorPresenter::IsInTrustedVideoMode(BOOL *pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::CanConstrict(BOOL *pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetConstriction(DWORD dwKPix)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::DisableImageExport(BOOL bDisable)
{
- return S_OK;
+ return S_OK;
}
// IDirect3DDeviceManager9
-STDMETHODIMP CEVRAllocatorPresenter::ResetDevice(IDirect3DDevice9 *pDevice, UINT resetToken)
+STDMETHODIMP CEVRAllocatorPresenter::ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken)
{
- HRESULT hr = m_pD3DManager->ResetDevice(pDevice, resetToken);
- return hr;
+ HRESULT hr = m_pD3DManager->ResetDevice (pDevice, resetToken);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::OpenDeviceHandle(HANDLE *phDevice)
{
- HRESULT hr = m_pD3DManager->OpenDeviceHandle(phDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->OpenDeviceHandle (phDevice);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::CloseDeviceHandle(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::TestDevice(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->TestDevice(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->TestDevice(hDevice);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock)
{
- HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
- return hr;
+ HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::UnlockDevice(HANDLE hDevice, BOOL fSaveState)
{
- HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
- return hr;
+ HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::GetVideoService(HANDLE hDevice, REFIID riid, void **ppService)
{
- HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
+ HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
- if(riid == __uuidof(IDirectXVideoDecoderService))
- {
- UINT nNbDecoder = 5;
- GUID* pDecoderGuid;
- IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) * ppService;
- pDXVAVideoDecoder->GetDecoderDeviceGuids(&nNbDecoder, &pDecoderGuid);
- }
- else if(riid == __uuidof(IDirectXVideoProcessorService))
- {
- IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) * ppService;
- }
+ if (riid == __uuidof(IDirectXVideoDecoderService))
+ {
+ UINT nNbDecoder = 5;
+ GUID* pDecoderGuid;
+ IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
+ pDXVAVideoDecoder->GetDecoderDeviceGuids (&nNbDecoder, &pDecoderGuid);
+ }
+ else if (riid == __uuidof(IDirectXVideoProcessorService))
+ {
+ IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- // This function should be called...
- ASSERT(FALSE);
+ // This function should be called...
+ ASSERT (FALSE);
- if(lpWidth) *lpWidth = m_NativeVideoSize.cx;
- if(lpHeight) *lpHeight = m_NativeVideoSize.cy;
- if(lpARWidth) *lpARWidth = m_AspectRatio.cx;
- if(lpARHeight) *lpARHeight = m_AspectRatio.cy;
- return S_OK;
+ if(lpWidth) *lpWidth = m_NativeVideoSize.cx;
+ if(lpHeight) *lpHeight = m_NativeVideoSize.cy;
+ if(lpARWidth) *lpARWidth = m_AspectRatio.cx;
+ if(lpARHeight) *lpARHeight = m_AspectRatio.cy;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(AM_MEDIA_TYPE* pMediaType)
{
- HRESULT hr;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_RenderLock);
+ HRESULT hr;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
- RemoveAllSamples();
- DeleteSurfaces();
+ RemoveAllSamples();
+ DeleteSurfaces();
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*) pMediaType->pbFormat;
- int w = vih2->bmiHeader.biWidth;
- int h = abs(vih2->bmiHeader.biHeight);
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*) pMediaType->pbFormat;
+ int w = vih2->bmiHeader.biWidth;
+ int h = abs(vih2->bmiHeader.biHeight);
- m_NativeVideoSize = CSize(w, h);
- if(m_bHighColorResolution)
- hr = AllocSurfaces(D3DFMT_A2R10G10B10);
- else
- hr = AllocSurfaces(D3DFMT_X8R8G8B8);
+ m_NativeVideoSize = CSize(w, h);
+ if (m_bHighColorResolution)
+ hr = AllocSurfaces(D3DFMT_A2R10G10B10);
+ else
+ hr = AllocSurfaces(D3DFMT_X8R8G8B8);
+
+ for(int i = 0; i < m_nNbDXSurface; i++)
+ {
+ CComPtr<IMFSample> pMFSample;
+ hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
- for(int i = 0; i < m_nNbDXSurface; i++)
- {
- CComPtr<IMFSample> pMFSample;
- hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ if (SUCCEEDED (hr))
+ {
+ pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail (pMFSample);
+ }
+ ASSERT (SUCCEEDED (hr));
+ }
- if(SUCCEEDED(hr))
- {
- pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail(pMFSample);
- }
- ASSERT(SUCCEEDED(hr));
- }
-
- return hr;
+ return hr;
}
DWORD WINAPI CEVRAllocatorPresenter::GetMixerThreadStatic(LPVOID lpParam)
{
- CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
- pThis->GetMixerThread();
- return 0;
+ CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
+ pThis->GetMixerThread();
+ return 0;
}
DWORD WINAPI CEVRAllocatorPresenter::PresentThread(LPVOID lpParam)
{
- CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
- pThis->RenderThread();
- return 0;
+ CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
+ pThis->RenderThread();
+ return 0;
}
void CEVRAllocatorPresenter::CheckWaitingSampleFromMixer()
{
- if(m_bWaitingSample)
- {
- m_bWaitingSample = false;
- //GetImageFromMixer(); // Do this in processing thread instead
- }
+ if (m_bWaitingSample)
+ {
+ m_bWaitingSample = false;
+ //GetImageFromMixer(); // Do this in processing thread instead
+ }
}
bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt)
{
- if(pmt->formattype == FORMAT_VideoInfo)
- return false;
- else if(pmt->formattype == FORMAT_VideoInfo2)
- return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else if(pmt->formattype == FORMAT_MPEGVideo)
- return false;
- else if(pmt->formattype == FORMAT_MPEG2Video)
- return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else
- return false;
+ if (pmt->formattype==FORMAT_VideoInfo)
+ return false;
+ else if (pmt->formattype==FORMAT_VideoInfo2)
+ return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ else if (pmt->formattype==FORMAT_MPEGVideo)
+ return false;
+ else if (pmt->formattype==FORMAT_MPEG2Video)
+ return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ else
+ return false;
}
void CEVRAllocatorPresenter::GetMixerThread()
{
- HANDLE hAvrt;
- HANDLE hEvts[] = { m_hEvtQuit};
- bool bQuit = false;
+ HANDLE hAvrt;
+ HANDLE hEvts[] = { m_hEvtQuit};
+ bool bQuit = false;
TIMECAPS tc;
- DWORD dwResolution;
- DWORD dwUser = 0;
- DWORD dwTaskIndex = 0;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+ DWORD dwTaskIndex = 0;
- // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
-// if (pfAvSetMmThreadCharacteristicsW)
+ // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+// if (pfAvSetMmThreadCharacteristicsW)
// hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
-// if (pfAvSetMmThreadPriority)
+// if (pfAvSetMmThreadPriority)
// pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
dwUser = timeBeginPeriod(dwResolution);
- while(!bQuit)
- {
- DWORD dwObject = WaitForMultipleObjects(countof(hEvts), hEvts, FALSE, 1);
- switch(dwObject)
- {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_TIMEOUT :
- {
- bool bDoneSomething = false;
- {
- CAutoLock AutoLock(&m_ImageProcessingLock);
- bDoneSomething = GetImageFromMixer();
- }
- if(m_rtTimePerFrame == 0 && bDoneSomething)
- {
- //CAutoLock lock(this);
- //CAutoLock lock2(&m_ImageProcessingLock);
- //CAutoLock cRenderLock(&m_RenderLock);
-
- // Use the code from VMR9 to get the movie fps, as this method is reliable.
- CComPtr<IPin> pPin;
- CMediaType mt;
- if(
- SUCCEEDED(m_pOuterEVR->FindPin(L"EVR Input0", &pPin)) &&
- SUCCEEDED(pPin->ConnectionMediaType(&mt)))
- {
- ExtractAvgTimePerFrame(&mt, m_rtTimePerFrame);
-
- m_bInterlaced = ExtractInterlaced(&mt);
-
- }
- // If framerate not set by Video Decoder choose 23.97...
- if(m_rtTimePerFrame == 0)
- m_rtTimePerFrame = 417166;
-
- // Update internal subtitle clock
- if(m_fUseInternalTimer && m_pSubPicQueue)
- {
- m_fps = (float)(10000000.0 / m_rtTimePerFrame);
- m_pSubPicQueue->SetFPS(m_fps);
- }
-
- }
-
- }
- break;
- }
- }
-
- timeEndPeriod(dwResolution);
+ while (!bQuit)
+ {
+ DWORD dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject)
+ {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT :
+ {
+ bool bDoneSomething = false;
+ {
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ bDoneSomething = GetImageFromMixer();
+ }
+ if (m_rtTimePerFrame == 0 && bDoneSomething)
+ {
+ //CAutoLock lock(this);
+ //CAutoLock lock2(&m_ImageProcessingLock);
+ //CAutoLock cRenderLock(&m_RenderLock);
+
+ // Use the code from VMR9 to get the movie fps, as this method is reliable.
+ CComPtr<IPin> pPin;
+ CMediaType mt;
+ if (
+ SUCCEEDED (m_pOuterEVR->FindPin(L"EVR Input0", &pPin)) &&
+ SUCCEEDED (pPin->ConnectionMediaType(&mt)) )
+ {
+ ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
+
+ m_bInterlaced = ExtractInterlaced(&mt);
+
+ }
+ // If framerate not set by Video Decoder choose 23.97...
+ if (m_rtTimePerFrame == 0)
+ m_rtTimePerFrame = 417166;
+
+ // Update internal subtitle clock
+ if(m_fUseInternalTimer && m_pSubPicQueue)
+ {
+ m_fps = (float)(10000000.0 / m_rtTimePerFrame);
+ m_pSubPicQueue->SetFPS(m_fps);
+ }
+
+ }
+
+ }
+ break;
+ }
+ }
+
+ timeEndPeriod (dwResolution);
// if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed)
{
- double xbiss = (-(ChangeSpeed) * (ValuePrim) - (Value - Target) * (ChangeSpeed * ChangeSpeed) * 0.25f);
- ValuePrim += xbiss;
- Value += ValuePrim;
+ double xbiss = (-(ChangeSpeed)*(ValuePrim) - (Value-Target)*(ChangeSpeed*ChangeSpeed)*0.25f);
+ ValuePrim += xbiss;
+ Value += ValuePrim;
}
LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
{
- LONGLONG llClockTime;
- MFTIME nsCurrentTime;
- m_pClock->GetCorrelatedTime(0, &llClockTime, &nsCurrentTime);
- DWORD Characteristics = 0;
- m_pClock->GetClockCharacteristics(&Characteristics);
- MFCLOCK_STATE State;
- m_pClock->GetState(0, &State);
-
- if(!(Characteristics & MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ))
- {
- MFCLOCK_PROPERTIES Props;
- if(m_pClock->GetProperties(&Props) == S_OK)
- llClockTime = (llClockTime * 10000000) / Props.qwClockFrequency; // Make 10 MHz
-
- }
- LONGLONG llPerf = PerformanceCounter;
+ LONGLONG llClockTime;
+ MFTIME nsCurrentTime;
+ m_pClock->GetCorrelatedTime(0, &llClockTime, &nsCurrentTime);
+ DWORD Characteristics = 0;
+ m_pClock->GetClockCharacteristics(&Characteristics);
+ MFCLOCK_STATE State;
+ m_pClock->GetState(0, &State);
+
+ if (!(Characteristics & MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ))
+ {
+ MFCLOCK_PROPERTIES Props;
+ if (m_pClock->GetProperties(&Props) == S_OK)
+ llClockTime = (llClockTime * 10000000) / Props.qwClockFrequency; // Make 10 MHz
+
+ }
+ LONGLONG llPerf = PerformanceCounter;
// return llClockTime + (llPerf - nsCurrentTime);
- double Target = llClockTime + (llPerf - nsCurrentTime) * m_ModeratedTimeSpeed;
+ double Target = llClockTime + (llPerf - nsCurrentTime) * m_ModeratedTimeSpeed;
- bool bReset = false;
- if(m_ModeratedTimeLast < 0 || State != m_LastClockState || m_ModeratedClockLast < 0)
- {
- bReset = true;
- m_ModeratedTimeLast = llPerf;
- m_ModeratedClockLast = llClockTime;
- }
+ bool bReset = false;
+ if (m_ModeratedTimeLast < 0 || State != m_LastClockState || m_ModeratedClockLast < 0)
+ {
+ bReset = true;
+ m_ModeratedTimeLast = llPerf;
+ m_ModeratedClockLast = llClockTime;
+ }
- m_LastClockState = State;
+ m_LastClockState = State;
- double TimeChange = llPerf - m_ModeratedTimeLast;
- double ClockChange = llClockTime - m_ModeratedClockLast;
+ double TimeChange = llPerf - m_ModeratedTimeLast;
+ double ClockChange = llClockTime - m_ModeratedClockLast;
- m_ModeratedTimeLast = llPerf;
- m_ModeratedClockLast = llClockTime;
+ m_ModeratedTimeLast = llPerf;
+ m_ModeratedClockLast = llClockTime;
#if 1
- if(bReset)
- {
- m_ModeratedTimeSpeed = 1.0;
- m_ModeratedTimeSpeedPrim = 0.0;
- ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
- ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
- m_ClockTimeChangeHistoryPos = 0;
- }
- if(TimeChange)
- {
- int Pos = m_ClockTimeChangeHistoryPos % 100;
- int nHistory = min(m_ClockTimeChangeHistoryPos, 100);
- ++m_ClockTimeChangeHistoryPos;
- if(nHistory > 50)
- {
- int iLastPos = (Pos - (nHistory)) % 100;
- if(iLastPos < 0)
- iLastPos += 100;
-
- double TimeChange = llPerf - m_TimeChangeHistory[iLastPos];
- double ClockChange = llClockTime - m_ClockChangeHistory[iLastPos];
-
- double ClockSpeedTarget = ClockChange / TimeChange;
- double ChangeSpeed = 0.1;
- if(ClockSpeedTarget > m_ModeratedTimeSpeed)
- {
- if(ClockSpeedTarget / m_ModeratedTimeSpeed > 0.1)
- ChangeSpeed = 0.1;
- else
- ChangeSpeed = 0.01;
- }
- else
- {
- if(m_ModeratedTimeSpeed / ClockSpeedTarget > 0.1)
- ChangeSpeed = 0.1;
- else
- ChangeSpeed = 0.01;
- }
- ModerateFloat(m_ModeratedTimeSpeed, ClockSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
+ if (bReset)
+ {
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
+ ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
+ m_ClockTimeChangeHistoryPos = 0;
+ }
+ if (TimeChange)
+ {
+ int Pos = m_ClockTimeChangeHistoryPos % 100;
+ int nHistory = min(m_ClockTimeChangeHistoryPos, 100);
+ ++m_ClockTimeChangeHistoryPos;
+ if (nHistory > 50)
+ {
+ int iLastPos = (Pos - (nHistory)) % 100;
+ if (iLastPos < 0)
+ iLastPos += 100;
+
+ double TimeChange = llPerf - m_TimeChangeHistory[iLastPos];
+ double ClockChange = llClockTime - m_ClockChangeHistory[iLastPos];
+
+ double ClockSpeedTarget = ClockChange / TimeChange;
+ double ChangeSpeed = 0.1;
+ if (ClockSpeedTarget > m_ModeratedTimeSpeed)
+ {
+ if (ClockSpeedTarget / m_ModeratedTimeSpeed > 0.1)
+ ChangeSpeed = 0.1;
+ else
+ ChangeSpeed = 0.01;
+ }
+ else
+ {
+ if (m_ModeratedTimeSpeed / ClockSpeedTarget > 0.1)
+ ChangeSpeed = 0.1;
+ else
+ ChangeSpeed = 0.01;
+ }
+ ModerateFloat(m_ModeratedTimeSpeed, ClockSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
// m_ModeratedTimeSpeed = TimeChange / ClockChange;
- }
- m_TimeChangeHistory[Pos] = llPerf;
- m_ClockChangeHistory[Pos] = llClockTime;
- }
+ }
+ m_TimeChangeHistory[Pos] = llPerf;
+ m_ClockChangeHistory[Pos] = llClockTime;
+ }
- return Target;
+ return Target;
#else
- double EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed + m_ClockDiffCalc;
- double Diff = Target - EstimateTime;
-
- // > 5 ms just set it
- if((fabs(Diff) > 50000.0 || bReset))
- {
+ double EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed + m_ClockDiffCalc;
+ double Diff = Target - EstimateTime;
+
+ // > 5 ms just set it
+ if ((fabs(Diff) > 50000.0 || bReset))
+ {
// TRACE_EVR("EVR: Reset clock at diff: %f ms\n", (m_ModeratedTime - Target) /10000.0);
- if(State == MFCLOCK_STATE_RUNNING)
- {
- if(bReset)
- {
- m_ModeratedTimeSpeed = 1.0;
- m_ModeratedTimeSpeedPrim = 0.0;
- m_ClockDiffCalc = 0;
- m_ClockDiffPrim = 0;
- m_ModeratedTime = Target;
- m_ModeratedTimer = llPerf;
- }
- else
- {
- EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed;
- Diff = Target - EstimateTime;
- m_ClockDiffCalc = Diff;
- m_ClockDiffPrim = 0;
- }
- }
- else
- {
- m_ModeratedTimeSpeed = 0.0;
- m_ModeratedTimeSpeedPrim = 0.0;
- m_ClockDiffCalc = 0;
- m_ClockDiffPrim = 0;
- m_ModeratedTime = Target;
- m_ModeratedTimer = llPerf;
- }
- }
-
- {
- LONGLONG ModerateTime = 10000;
- double ChangeSpeed = 1.00;
- /* if (m_ModeratedTimeSpeedPrim != 0.0)
- {
- if (m_ModeratedTimeSpeedPrim < 0.1)
- ChangeSpeed = 0.1;
- }*/
-
- int nModerate = 0;
- double Change = 0;
- while(m_ModeratedTimer < llPerf - ModerateTime)
- {
- m_ModeratedTimer += ModerateTime;
- m_ModeratedTime += double(ModerateTime) * m_ModeratedTimeSpeed;
-
- double TimerDiff = llPerf - m_ModeratedTimer;
-
- double Diff = (double)(m_ModeratedTime - (Target - TimerDiff));
-
- double TimeSpeedTarget;
- double AbsDiff = fabs(Diff);
- TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
+ if (State == MFCLOCK_STATE_RUNNING)
+ {
+ if (bReset)
+ {
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ m_ClockDiffCalc = 0;
+ m_ClockDiffPrim = 0;
+ m_ModeratedTime = Target;
+ m_ModeratedTimer = llPerf;
+ }
+ else
+ {
+ EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed;
+ Diff = Target - EstimateTime;
+ m_ClockDiffCalc = Diff;
+ m_ClockDiffPrim = 0;
+ }
+ }
+ else
+ {
+ m_ModeratedTimeSpeed = 0.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ m_ClockDiffCalc = 0;
+ m_ClockDiffPrim = 0;
+ m_ModeratedTime = Target;
+ m_ModeratedTimer = llPerf;
+ }
+ }
+
+ {
+ LONGLONG ModerateTime = 10000;
+ double ChangeSpeed = 1.00;
+/* if (m_ModeratedTimeSpeedPrim != 0.0)
+ {
+ if (m_ModeratedTimeSpeedPrim < 0.1)
+ ChangeSpeed = 0.1;
+ }*/
+
+ int nModerate = 0;
+ double Change = 0;
+ while (m_ModeratedTimer < llPerf - ModerateTime)
+ {
+ m_ModeratedTimer += ModerateTime;
+ m_ModeratedTime += double(ModerateTime) * m_ModeratedTimeSpeed;
+
+ double TimerDiff = llPerf - m_ModeratedTimer;
+
+ double Diff = (double)(m_ModeratedTime - (Target - TimerDiff));
+
+ double TimeSpeedTarget;
+ double AbsDiff = fabs(Diff);
+ TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
// TimeSpeedTarget = m_ModeratedTimeSpeed - (Diff / 100000000000.0);
- //if (AbsDiff > 20000.0)
+ //if (AbsDiff > 20000.0)
// TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
- /*else if (AbsDiff > 5000.0)
- TimeSpeedTarget = 1.0 - (Diff / 100000000.0);
- else
- TimeSpeedTarget = 1.0 - (Diff / 500000000.0);*/
- double StartMod = m_ModeratedTimeSpeed;
- ModerateFloat(m_ModeratedTimeSpeed, TimeSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
- m_ModeratedTimeSpeed = TimeSpeedTarget;
- ++nModerate;
- Change += m_ModeratedTimeSpeed - StartMod;
- }
- if(nModerate)
- m_ModeratedTimeSpeedDiff = Change / nModerate;
-
- double Ret = m_ModeratedTime + double(llPerf - m_ModeratedTimer) * m_ModeratedTimeSpeed;
- double Diff = Target - Ret;
- ModerateFloat(m_ClockDiffCalc, Diff, m_ClockDiffPrim, ChangeSpeed * 0.1);
-
- Ret += m_ClockDiffCalc;
- Diff = Target - Ret;
- m_ClockDiff = Diff;
- return LONGLONG(Ret + 0.5);
- }
-
- return Target;
- return LONGLONG(m_ModeratedTime + 0.5);
+ /*else if (AbsDiff > 5000.0)
+ TimeSpeedTarget = 1.0 - (Diff / 100000000.0);
+ else
+ TimeSpeedTarget = 1.0 - (Diff / 500000000.0);*/
+ double StartMod = m_ModeratedTimeSpeed;
+ ModerateFloat(m_ModeratedTimeSpeed, TimeSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
+ m_ModeratedTimeSpeed = TimeSpeedTarget;
+ ++nModerate;
+ Change += m_ModeratedTimeSpeed - StartMod;
+ }
+ if (nModerate)
+ m_ModeratedTimeSpeedDiff = Change / nModerate;
+
+ double Ret = m_ModeratedTime + double(llPerf - m_ModeratedTimer) * m_ModeratedTimeSpeed;
+ double Diff = Target - Ret;
+ ModerateFloat(m_ClockDiffCalc, Diff, m_ClockDiffPrim, ChangeSpeed*0.1);
+
+ Ret += m_ClockDiffCalc;
+ Diff = Target - Ret;
+ m_ClockDiff = Diff;
+ return LONGLONG(Ret + 0.5);
+ }
+
+ return Target;
+ return LONGLONG(m_ModeratedTime + 0.5);
#endif
}
void CEVRAllocatorPresenter::OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter)
{
- if(!m_pCurrentDisplaydSample || !m_OrderedPaint || !fAll)
- return;
-
- LONGLONG llClockTime;
- LONGLONG nsSampleTime;
- LONGLONG SampleDuration = 0;
- if(!m_bSignaledStarvation)
- {
- llClockTime = GetClockTime(PerformanceCounter);
- m_StarvationClock = llClockTime;
- }
- else
- {
- llClockTime = m_StarvationClock;
- }
- m_pCurrentDisplaydSample->GetSampleDuration(&SampleDuration);
-
- m_pCurrentDisplaydSample->GetSampleTime(&nsSampleTime);
- LONGLONG TimePerFrame = m_rtTimePerFrame;
- if(!TimePerFrame)
- return;
- if(SampleDuration > 1)
- TimePerFrame = SampleDuration;
-
- {
- m_nNextSyncOffset = (m_nNextSyncOffset + 1) % NB_JITTER;
- LONGLONG SyncOffset = nsSampleTime - llClockTime;
-
- m_pllSyncOffset[m_nNextSyncOffset] = SyncOffset;
+ if (!m_pCurrentDisplaydSample || !m_OrderedPaint || !fAll)
+ return;
+
+ LONGLONG llClockTime;
+ LONGLONG nsSampleTime;
+ LONGLONG SampleDuration = 0;
+ if (!m_bSignaledStarvation)
+ {
+ llClockTime = GetClockTime(PerformanceCounter);
+ m_StarvationClock = llClockTime;
+ }
+ else
+ {
+ llClockTime = m_StarvationClock;
+ }
+ m_pCurrentDisplaydSample->GetSampleDuration(&SampleDuration);
+
+ m_pCurrentDisplaydSample->GetSampleTime(&nsSampleTime);
+ LONGLONG TimePerFrame = m_rtTimePerFrame;
+ if (!TimePerFrame)
+ return;
+ if (SampleDuration > 1)
+ TimePerFrame = SampleDuration;
+
+ {
+ m_nNextSyncOffset = (m_nNextSyncOffset+1) % NB_JITTER;
+ LONGLONG SyncOffset = nsSampleTime - llClockTime;
+
+ m_pllSyncOffset[m_nNextSyncOffset] = SyncOffset;
// TRACE_EVR("EVR: SyncOffset(%d, %d): %8I64d %8I64d %8I64d \n", m_nCurSurface, m_VSyncMode, m_LastPredictedSync, -SyncOffset, m_LastPredictedSync - (-SyncOffset));
- m_MaxSyncOffset = MINLONG64;
- m_MinSyncOffset = MAXLONG64;
-
- LONGLONG AvrageSum = 0;
- for(int i = 0; i < NB_JITTER; i++)
- {
- LONGLONG Offset = m_pllSyncOffset[i];
- AvrageSum += Offset;
- m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
- m_MinSyncOffset = min(m_MinSyncOffset, Offset);
- }
- double MeanOffset = double(AvrageSum) / NB_JITTER;
- double DeviationSum = 0;
- for(int i = 0; i < NB_JITTER; i++)
- {
- double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
- DeviationSum += Deviation * Deviation;
- }
- double StdDev = sqrt(DeviationSum / NB_JITTER);
-
- m_fSyncOffsetAvr = MeanOffset;
- m_bSyncStatsAvailable = true;
- m_fSyncOffsetStdDev = StdDev;
-
-
- }
+ m_MaxSyncOffset = MINLONG64;
+ m_MinSyncOffset = MAXLONG64;
+
+ LONGLONG AvrageSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG Offset = m_pllSyncOffset[i];
+ AvrageSum += Offset;
+ m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
+ m_MinSyncOffset = min(m_MinSyncOffset, Offset);
+ }
+ double MeanOffset = double(AvrageSum)/NB_JITTER;
+ double DeviationSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
+ DeviationSum += Deviation*Deviation;
+ }
+ double StdDev = sqrt(DeviationSum/NB_JITTER);
+
+ m_fSyncOffsetAvr = MeanOffset;
+ m_bSyncStatsAvailable = true;
+ m_fSyncOffsetStdDev = StdDev;
+
+
+ }
}
void CEVRAllocatorPresenter::RenderThread()
{
- HANDLE hAvrt;
- DWORD dwTaskIndex = 0;
- HANDLE hEvts[] = { m_hEvtQuit, m_hEvtFlush};
- bool bQuit = false;
+ HANDLE hAvrt;
+ DWORD dwTaskIndex = 0;
+ HANDLE hEvts[] = { m_hEvtQuit, m_hEvtFlush};
+ bool bQuit = false;
TIMECAPS tc;
- DWORD dwResolution;
- MFTIME nsSampleTime;
- LONGLONG llClockTime;
- DWORD dwUser = 0;
- DWORD dwObject;
+ DWORD dwResolution;
+ MFTIME nsSampleTime;
+ LONGLONG llClockTime;
+ DWORD dwUser = 0;
+ DWORD dwObject;
-
- // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
- if(pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
- if(pfAvSetMmThreadPriority) pfAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+
+ // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+ if (pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+ if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
dwUser = timeBeginPeriod(dwResolution);
- AppSettings& s = AfxGetAppSettings();
-
- int NextSleepTime = 1;
- while(!bQuit)
- {
- LONGLONG llPerf = AfxGetMyApp()->GetPerfCounter();
- if(!s.m_RenderSettings.iVMR9VSyncAccurate && NextSleepTime == 0)
- NextSleepTime = 1;
- dwObject = WaitForMultipleObjects(countof(hEvts), hEvts, FALSE, max(NextSleepTime < 0 ? 1 : NextSleepTime, 0));
- /* dwObject = WAIT_TIMEOUT;
- if (m_bEvtFlush)
- dwObject = WAIT_OBJECT_0 + 1;
- else if (m_bEvtQuit)
- dwObject = WAIT_OBJECT_0;*/
+ AppSettings& s = AfxGetAppSettings();
+
+ int NextSleepTime = 1;
+ while (!bQuit)
+ {
+ LONGLONG llPerf = AfxGetMyApp()->GetPerfCounter();
+ if (!s.m_RenderSettings.iVMR9VSyncAccurate && NextSleepTime == 0)
+ NextSleepTime = 1;
+ dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, max(NextSleepTime < 0 ? 1 : NextSleepTime, 0));
+/* dwObject = WAIT_TIMEOUT;
+ if (m_bEvtFlush)
+ dwObject = WAIT_OBJECT_0 + 1;
+ else if (m_bEvtQuit)
+ dwObject = WAIT_OBJECT_0;*/
// if (NextSleepTime)
// TRACE_EVR("EVR: Sleep: %7.3f\n", double(AfxGetMyApp()->GetPerfCounter()-llPerf) / 10000.0);
- if(NextSleepTime > 1)
- NextSleepTime = 0;
- else if(NextSleepTime == 0)
- NextSleepTime = -1;
- switch(dwObject)
- {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_OBJECT_0 + 1 :
- // Flush pending samples!
- FlushSamples();
- m_bEvtFlush = false;
- ResetEvent(m_hEvtFlush);
- TRACE_EVR("EVR: Flush done!\n");
- break;
-
- case WAIT_TIMEOUT :
-
- if(m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate)
- {
- FlushSamples();
- RenegotiateMediaType();
- m_bPendingRenegotiate = false;
- }
- if(m_bPendingResetDevice)
- {
- m_bPendingResetDevice = false;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_RenderLock);
-
-
- RemoveAllSamples();
-
- CDX9AllocatorPresenter::ResetDevice();
-
- for(int i = 0; i < m_nNbDXSurface; i++)
- {
- CComPtr<IMFSample> pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
-
- if(SUCCEEDED(hr))
- {
- pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail(pMFSample);
- }
- ASSERT(SUCCEEDED(hr));
- }
-
- }
- // Discard timer events if playback stop
+ if (NextSleepTime > 1)
+ NextSleepTime = 0;
+ else if (NextSleepTime == 0)
+ NextSleepTime = -1;
+ switch (dwObject)
+ {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_OBJECT_0 + 1 :
+ // Flush pending samples!
+ FlushSamples();
+ m_bEvtFlush = false;
+ ResetEvent(m_hEvtFlush);
+ TRACE_EVR ("EVR: Flush done!\n");
+ break;
+
+ case WAIT_TIMEOUT :
+
+ if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate)
+ {
+ FlushSamples();
+ RenegotiateMediaType();
+ m_bPendingRenegotiate = false;
+ }
+ if (m_bPendingResetDevice)
+ {
+ m_bPendingResetDevice = false;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+
+ RemoveAllSamples();
+
+ CDX9AllocatorPresenter::ResetDevice();
+
+ for(int i = 0; i < m_nNbDXSurface; i++)
+ {
+ CComPtr<IMFSample> pMFSample;
+ HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
+
+ if (SUCCEEDED (hr))
+ {
+ pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail (pMFSample);
+ }
+ ASSERT (SUCCEEDED (hr));
+ }
+
+ }
+ // Discard timer events if playback stop
// if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
// TRACE_EVR ("EVR: RenderThread ==>> Waiting buffer\n");
-
+
// if (WaitForMultipleObjects (countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
- {
- CComPtr<IMFSample> pMFSample;
- LONGLONG llPerf = AfxGetMyApp()->GetPerfCounter();
- int nSamplesLeft = 0;
- if(SUCCEEDED(GetScheduledSample(&pMFSample, nSamplesLeft)))
- {
+ {
+ CComPtr<IMFSample> pMFSample;
+ LONGLONG llPerf = AfxGetMyApp()->GetPerfCounter();
+ int nSamplesLeft = 0;
+ if (SUCCEEDED (GetScheduledSample(&pMFSample, nSamplesLeft)))
+ {
// pMFSample->GetUINT32 (GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
- m_pCurrentDisplaydSample = pMFSample;
-
- bool bValidSampleTime = true;
- HRESULT hGetSampleTime = pMFSample->GetSampleTime(&nsSampleTime);
- if(hGetSampleTime != S_OK || nsSampleTime == 0)
- {
- bValidSampleTime = false;
- }
- // We assume that all samples have the same duration
- LONGLONG SampleDuration = 0;
- pMFSample->GetSampleDuration(&SampleDuration);
+ m_pCurrentDisplaydSample = pMFSample;
+
+ bool bValidSampleTime = true;
+ HRESULT hGetSampleTime = pMFSample->GetSampleTime (&nsSampleTime);
+ if (hGetSampleTime != S_OK || nsSampleTime == 0)
+ {
+ bValidSampleTime = false;
+ }
+ // We assume that all samples have the same duration
+ LONGLONG SampleDuration = 0;
+ pMFSample->GetSampleDuration(&SampleDuration);
// TRACE_EVR ("EVR: RenderThread ==>> Presenting surface %d (%I64d)\n", m_nCurSurface, nsSampleTime);
- bool bStepForward = false;
-
- if(m_nStepCount < 0)
- {
- // Drop frame
- TRACE_EVR("EVR: Dropped frame\n");
- m_pcFrames++;
- bStepForward = true;
- m_nStepCount = 0;
- }
- else if(m_nStepCount > 0)
- {
- pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- ++m_OrderedPaint;
- if(!g_bExternalSubtitleTime)
- __super::SetTime(g_tSegmentStart + nsSampleTime);
- Paint(true);
- m_nDroppedUpdate = 0;
- CompleteFrameStep(false);
- bStepForward = true;
- }
- else if((m_nRenderState == Started))
- {
- LONGLONG CurrentCounter = AfxGetMyApp()->GetPerfCounter();
- // Calculate wake up timer
- if(!m_bSignaledStarvation)
- {
- llClockTime = GetClockTime(CurrentCounter);
- m_StarvationClock = llClockTime;
- }
- else
- {
- llClockTime = m_StarvationClock;
- }
-
- if(!bValidSampleTime)
- {
- // Just play as fast as possible
- bStepForward = true;
- pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- ++m_OrderedPaint;
- if(!g_bExternalSubtitleTime)
- __super::SetTime(g_tSegmentStart + nsSampleTime);
- Paint(true);
- }
- else
- {
- LONGLONG TimePerFrame = GetFrameTime() * 10000000.0;
- LONGLONG DrawTime = (m_PaintTime) * 0.9 - 20000.0; // 2 ms offset
- //if (!s.iVMR9VSync)
- DrawTime = 0;
-
- LONGLONG SyncOffset = 0;
- LONGLONG VSyncTime = 0;
- LONGLONG TimeToNextVSync = -1;
- bool bVSyncCorrection = false;
- double DetectedRefreshTime;
- double DetectedScanlinesPerFrame;
- double DetectedScanlineTime;
- int DetectedRefreshRatePos;
- {
- CAutoLock Lock(&m_RefreshRateLock);
- DetectedRefreshTime = m_DetectedRefreshTime;
- DetectedRefreshRatePos = m_DetectedRefreshRatePos;
- DetectedScanlinesPerFrame = m_DetectedScanlinesPerFrame;
- DetectedScanlineTime = m_DetectedScanlineTime;
- }
-
- if(DetectedRefreshRatePos < 20 || !DetectedRefreshTime || !DetectedScanlinesPerFrame)
- {
- DetectedRefreshTime = 1.0 / m_RefreshRate;
- DetectedScanlinesPerFrame = m_ScreenSize.cy;
- DetectedScanlineTime = DetectedRefreshTime / double(m_ScreenSize.cy);
- }
-
- if(s.m_RenderSettings.iVMR9VSync)
- {
- bVSyncCorrection = true;
- double TargetVSyncPos = GetVBlackPos();
- double RefreshLines = DetectedScanlinesPerFrame;
- double ScanlinesPerSecond = 1.0 / DetectedScanlineTime;
- double CurrentVSyncPos = fmod(double(m_VBlankStartMeasure) + ScanlinesPerSecond * ((CurrentCounter - m_VBlankStartMeasureTime) / 10000000.0), RefreshLines);
- double LinesUntilVSync = 0;
- //TargetVSyncPos -= ScanlinesPerSecond * (DrawTime/10000000.0);
- //TargetVSyncPos -= 10;
- TargetVSyncPos = fmod(TargetVSyncPos, RefreshLines);
- if(TargetVSyncPos < 0)
- TargetVSyncPos += RefreshLines;
- if(TargetVSyncPos > CurrentVSyncPos)
- LinesUntilVSync = TargetVSyncPos - CurrentVSyncPos;
- else
- LinesUntilVSync = (RefreshLines - CurrentVSyncPos) + TargetVSyncPos;
- double TimeUntilVSync = LinesUntilVSync * DetectedScanlineTime;
- TimeToNextVSync = TimeUntilVSync * 10000000.0;
- VSyncTime = DetectedRefreshTime * 10000000.0;
-
- LONGLONG ClockTimeAtNextVSync = llClockTime + (TimeUntilVSync * 10000000.0) * m_ModeratedTimeSpeed;
-
- SyncOffset = (nsSampleTime - ClockTimeAtNextVSync);
+ bool bStepForward = false;
+
+ if (m_nStepCount < 0)
+ {
+ // Drop frame
+ TRACE_EVR ("EVR: Dropped frame\n");
+ m_pcFrames++;
+ bStepForward = true;
+ m_nStepCount = 0;
+ }
+ else if (m_nStepCount > 0)
+ {
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ ++m_OrderedPaint;
+ if (!g_bExternalSubtitleTime)
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ Paint(true);
+ m_nDroppedUpdate = 0;
+ CompleteFrameStep (false);
+ bStepForward = true;
+ }
+ else if ((m_nRenderState == Started))
+ {
+ LONGLONG CurrentCounter = AfxGetMyApp()->GetPerfCounter();
+ // Calculate wake up timer
+ if (!m_bSignaledStarvation)
+ {
+ llClockTime = GetClockTime(CurrentCounter);
+ m_StarvationClock = llClockTime;
+ }
+ else
+ {
+ llClockTime = m_StarvationClock;
+ }
+
+ if (!bValidSampleTime)
+ {
+ // Just play as fast as possible
+ bStepForward = true;
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ ++m_OrderedPaint;
+ if (!g_bExternalSubtitleTime)
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ Paint(true);
+ }
+ else
+ {
+ LONGLONG TimePerFrame = GetFrameTime() * 10000000.0;
+ LONGLONG DrawTime = (m_PaintTime) * 0.9 - 20000.0; // 2 ms offset
+ //if (!s.iVMR9VSync)
+ DrawTime = 0;
+
+ LONGLONG SyncOffset = 0;
+ LONGLONG VSyncTime = 0;
+ LONGLONG TimeToNextVSync = -1;
+ bool bVSyncCorrection = false;
+ double DetectedRefreshTime;
+ double DetectedScanlinesPerFrame;
+ double DetectedScanlineTime;
+ int DetectedRefreshRatePos;
+ {
+ CAutoLock Lock(&m_RefreshRateLock);
+ DetectedRefreshTime = m_DetectedRefreshTime;
+ DetectedRefreshRatePos = m_DetectedRefreshRatePos;
+ DetectedScanlinesPerFrame = m_DetectedScanlinesPerFrame;
+ DetectedScanlineTime = m_DetectedScanlineTime;
+ }
+
+ if (DetectedRefreshRatePos < 20 || !DetectedRefreshTime || !DetectedScanlinesPerFrame)
+ {
+ DetectedRefreshTime = 1.0/m_RefreshRate;
+ DetectedScanlinesPerFrame = m_ScreenSize.cy;
+ DetectedScanlineTime = DetectedRefreshTime / double(m_ScreenSize.cy);
+ }
+
+ if (s.m_RenderSettings.iVMR9VSync)
+ {
+ bVSyncCorrection = true;
+ double TargetVSyncPos = GetVBlackPos();
+ double RefreshLines = DetectedScanlinesPerFrame;
+ double ScanlinesPerSecond = 1.0/DetectedScanlineTime;
+ double CurrentVSyncPos = fmod(double(m_VBlankStartMeasure) + ScanlinesPerSecond * ((CurrentCounter - m_VBlankStartMeasureTime) / 10000000.0), RefreshLines);
+ double LinesUntilVSync = 0;
+ //TargetVSyncPos -= ScanlinesPerSecond * (DrawTime/10000000.0);
+ //TargetVSyncPos -= 10;
+ TargetVSyncPos = fmod(TargetVSyncPos, RefreshLines);
+ if (TargetVSyncPos < 0)
+ TargetVSyncPos += RefreshLines;
+ if (TargetVSyncPos > CurrentVSyncPos)
+ LinesUntilVSync = TargetVSyncPos - CurrentVSyncPos;
+ else
+ LinesUntilVSync = (RefreshLines - CurrentVSyncPos) + TargetVSyncPos;
+ double TimeUntilVSync = LinesUntilVSync * DetectedScanlineTime;
+ TimeToNextVSync = TimeUntilVSync * 10000000.0;
+ VSyncTime = DetectedRefreshTime * 10000000.0;
+
+ LONGLONG ClockTimeAtNextVSync = llClockTime + (TimeUntilVSync * 10000000.0) * m_ModeratedTimeSpeed;
+
+ SyncOffset = (nsSampleTime - ClockTimeAtNextVSync);
// if (SyncOffset < 0)
// TRACE_EVR("EVR: SyncOffset(%d): %I64d %I64d %I64d\n", m_nCurSurface, SyncOffset, TimePerFrame, VSyncTime);
- }
- else
- SyncOffset = (nsSampleTime - llClockTime);
-
- //LONGLONG SyncOffset = nsSampleTime - llClockTime;
- TRACE_EVR("EVR: SyncOffset: %I64d SampleFrame: %I64d ClockFrame: %I64d\n", SyncOffset, TimePerFrame != 0 ? nsSampleTime / TimePerFrame : 0, TimePerFrame != 0 ? llClockTime / TimePerFrame : 0);
- if(SampleDuration > 1 && !m_DetectedLock)
- TimePerFrame = SampleDuration;
-
- LONGLONG MinMargin;
- if(m_FrameTimeCorrection && 0)
- MinMargin = 15000.0;
- else
- MinMargin = 15000.0 + min(m_DetectedFrameTimeStdDev, 20000.0);
- LONGLONG TimePerFrameMargin = min(double(TimePerFrame) * 0.11, max(double(TimePerFrame) * 0.02, MinMargin));
- LONGLONG TimePerFrameMargin0 = TimePerFrameMargin / 2;
- LONGLONG TimePerFrameMargin1 = 0;
-
- if(m_DetectedLock && TimePerFrame < VSyncTime)
- VSyncTime = TimePerFrame;
-
- if(m_VSyncMode == 1)
- TimePerFrameMargin1 = -TimePerFrameMargin;
- else if(m_VSyncMode == 2)
- TimePerFrameMargin1 = TimePerFrameMargin;
-
- m_LastSampleOffset = SyncOffset;
- m_bLastSampleOffsetValid = true;
-
- LONGLONG VSyncOffset0 = 0;
- bool bDoVSyncCorrection = false;
- if((SyncOffset < -(TimePerFrame + TimePerFrameMargin0 - TimePerFrameMargin1)) && nSamplesLeft > 0) // Only drop if we have something else to display at once
- {
- // Drop frame
- TRACE_EVR("EVR: Dropped frame\n");
- m_pcFrames++;
- bStepForward = true;
- ++m_nDroppedUpdate;
- NextSleepTime = 0;
+ }
+ else
+ SyncOffset = (nsSampleTime - llClockTime);
+
+ //LONGLONG SyncOffset = nsSampleTime - llClockTime;
+ TRACE_EVR ("EVR: SyncOffset: %I64d SampleFrame: %I64d ClockFrame: %I64d\n", SyncOffset, TimePerFrame!=0 ? nsSampleTime/TimePerFrame : 0, TimePerFrame!=0 ? llClockTime /TimePerFrame : 0);
+ if (SampleDuration > 1 && !m_DetectedLock)
+ TimePerFrame = SampleDuration;
+
+ LONGLONG MinMargin;
+ if (m_FrameTimeCorrection && 0)
+ MinMargin = 15000.0;
+ else
+ MinMargin = 15000.0 + min(m_DetectedFrameTimeStdDev, 20000.0);
+ LONGLONG TimePerFrameMargin = min(double(TimePerFrame)*0.11, max(double(TimePerFrame)*0.02, MinMargin));
+ LONGLONG TimePerFrameMargin0 = TimePerFrameMargin/2;
+ LONGLONG TimePerFrameMargin1 = 0;
+
+ if (m_DetectedLock && TimePerFrame < VSyncTime)
+ VSyncTime = TimePerFrame;
+
+ if (m_VSyncMode == 1)
+ TimePerFrameMargin1 = -TimePerFrameMargin;
+ else if (m_VSyncMode == 2)
+ TimePerFrameMargin1 = TimePerFrameMargin;
+
+ m_LastSampleOffset = SyncOffset;
+ m_bLastSampleOffsetValid = true;
+
+ LONGLONG VSyncOffset0 = 0;
+ bool bDoVSyncCorrection = false;
+ if ((SyncOffset < -(TimePerFrame + TimePerFrameMargin0 - TimePerFrameMargin1)) && nSamplesLeft > 0) // Only drop if we have something else to display at once
+ {
+ // Drop frame
+ TRACE_EVR ("EVR: Dropped frame\n");
+ m_pcFrames++;
+ bStepForward = true;
+ ++m_nDroppedUpdate;
+ NextSleepTime = 0;
// VSyncOffset0 = (-SyncOffset) - VSyncTime;
- //VSyncOffset0 = (-SyncOffset) - VSyncTime + TimePerFrameMargin1;
- //m_LastPredictedSync = VSyncOffset0;
- bDoVSyncCorrection = false;
- }
- else if(SyncOffset < TimePerFrameMargin1)
- {
-
- if(bVSyncCorrection)
- {
+ //VSyncOffset0 = (-SyncOffset) - VSyncTime + TimePerFrameMargin1;
+ //m_LastPredictedSync = VSyncOffset0;
+ bDoVSyncCorrection = false;
+ }
+ else if (SyncOffset < TimePerFrameMargin1)
+ {
+
+ if (bVSyncCorrection)
+ {
// VSyncOffset0 = -SyncOffset;
- VSyncOffset0 = -SyncOffset;
- bDoVSyncCorrection = true;
- }
-
- // Paint and prepare for next frame
- TRACE_EVR("EVR: Normalframe\n");
- m_nDroppedUpdate = 0;
- bStepForward = true;
- pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- m_LastFrameDuration = nsSampleTime - m_LastSampleTime;
- m_LastSampleTime = nsSampleTime;
- m_LastPredictedSync = VSyncOffset0;
-
- ++m_OrderedPaint;
-
- if(!g_bExternalSubtitleTime)
- __super::SetTime(g_tSegmentStart + nsSampleTime);
- Paint(true);
- //m_pSink->Notify(EC_SCRUB_TIME, LODWORD(nsSampleTime), HIDWORD(nsSampleTime));
-
- NextSleepTime = 0;
- m_pcFramesDrawn++;
- }
- else
- {
- if(TimeToNextVSync >= 0 && SyncOffset > 0)
- {
- NextSleepTime = ((TimeToNextVSync) / 10000) - 2;
- }
- else
- NextSleepTime = ((SyncOffset) / 10000) - 2;
-
- if(NextSleepTime > TimePerFrame)
- NextSleepTime = 1;
-
- if(NextSleepTime < 0)
- NextSleepTime = 0;
- NextSleepTime = 1;
- //TRACE_EVR ("EVR: Delay\n");
- }
-
- if(bDoVSyncCorrection)
- {
- //LONGLONG VSyncOffset0 = (((SyncOffset) % VSyncTime) + VSyncTime) % VSyncTime;
- LONGLONG Margin = TimePerFrameMargin;
-
- LONGLONG VSyncOffsetMin = 30000000000000;
- LONGLONG VSyncOffsetMax = -30000000000000;
- for(int i = 0; i < 5; ++i)
- {
- VSyncOffsetMin = min(m_VSyncOffsetHistory[i], VSyncOffsetMin);
- VSyncOffsetMax = max(m_VSyncOffsetHistory[i], VSyncOffsetMax);
- }
-
- m_VSyncOffsetHistory[m_VSyncOffsetHistoryPos] = VSyncOffset0;
- m_VSyncOffsetHistoryPos = (m_VSyncOffsetHistoryPos + 1) % 5;
+ VSyncOffset0 = -SyncOffset;
+ bDoVSyncCorrection = true;
+ }
+
+ // Paint and prepare for next frame
+ TRACE_EVR ("EVR: Normalframe\n");
+ m_nDroppedUpdate = 0;
+ bStepForward = true;
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ m_LastFrameDuration = nsSampleTime - m_LastSampleTime;
+ m_LastSampleTime = nsSampleTime;
+ m_LastPredictedSync = VSyncOffset0;
+
+ ++m_OrderedPaint;
+
+ if (!g_bExternalSubtitleTime)
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ Paint(true);
+ //m_pSink->Notify(EC_SCRUB_TIME, LODWORD(nsSampleTime), HIDWORD(nsSampleTime));
+
+ NextSleepTime = 0;
+ m_pcFramesDrawn++;
+ }
+ else
+ {
+ if (TimeToNextVSync >= 0 && SyncOffset > 0)
+ {
+ NextSleepTime = ((TimeToNextVSync)/10000) - 2;
+ }
+ else
+ NextSleepTime = ((SyncOffset)/10000) - 2;
+
+ if (NextSleepTime > TimePerFrame)
+ NextSleepTime = 1;
+
+ if (NextSleepTime < 0)
+ NextSleepTime = 0;
+ NextSleepTime = 1;
+ //TRACE_EVR ("EVR: Delay\n");
+ }
+
+ if (bDoVSyncCorrection)
+ {
+ //LONGLONG VSyncOffset0 = (((SyncOffset) % VSyncTime) + VSyncTime) % VSyncTime;
+ LONGLONG Margin = TimePerFrameMargin;
+
+ LONGLONG VSyncOffsetMin = 30000000000000;
+ LONGLONG VSyncOffsetMax = -30000000000000;
+ for (int i = 0; i < 5; ++i)
+ {
+ VSyncOffsetMin = min(m_VSyncOffsetHistory[i], VSyncOffsetMin);
+ VSyncOffsetMax = max(m_VSyncOffsetHistory[i], VSyncOffsetMax);
+ }
+
+ m_VSyncOffsetHistory[m_VSyncOffsetHistoryPos] = VSyncOffset0;
+ m_VSyncOffsetHistoryPos = (m_VSyncOffsetHistoryPos + 1) % 5;
// LONGLONG VSyncTime2 = VSyncTime2 + (VSyncOffsetMax - VSyncOffsetMin);
- //VSyncOffsetMin; = (((VSyncOffsetMin) % VSyncTime) + VSyncTime) % VSyncTime;
- //VSyncOffsetMax = (((VSyncOffsetMax) % VSyncTime) + VSyncTime) % VSyncTime;
+ //VSyncOffsetMin; = (((VSyncOffsetMin) % VSyncTime) + VSyncTime) % VSyncTime;
+ //VSyncOffsetMax = (((VSyncOffsetMax) % VSyncTime) + VSyncTime) % VSyncTime;
// TRACE_EVR("EVR: SyncOffset(%d, %d): %8I64d %8I64d %8I64d %8I64d\n", m_nCurSurface, m_VSyncMode,VSyncOffset0, VSyncOffsetMin, VSyncOffsetMax, VSyncOffsetMax - VSyncOffsetMin);
- if(m_VSyncMode == 0)
- {
- // 23.976 in 60 Hz
- if(VSyncOffset0 < Margin && VSyncOffsetMax > (VSyncTime - Margin))
- {
- m_VSyncMode = 2;
- }
- else if(VSyncOffset0 > (VSyncTime - Margin) && VSyncOffsetMin < Margin)
- {
- m_VSyncMode = 1;
- }
- }
- else if(m_VSyncMode == 2)
- {
- if(VSyncOffsetMin > (Margin))
- {
- m_VSyncMode = 0;
- }
- }
- else if(m_VSyncMode == 1)
- {
- if(VSyncOffsetMax < (VSyncTime - Margin))
- {
- m_VSyncMode = 0;
- }
- }
- }
-
- }
- }
-
- m_pCurrentDisplaydSample = NULL;
- if(bStepForward)
- {
- MoveToFreeList(pMFSample, true);
- CheckWaitingSampleFromMixer();
- m_MaxSampleDuration = max(SampleDuration, m_MaxSampleDuration);
- }
- else
- MoveToScheduledList(pMFSample, true);
- }
- else if(m_bLastSampleOffsetValid && m_LastSampleOffset < -10000000) // Only starve if we are 1 seconds behind
- {
- if(m_nRenderState == Started && !g_bNoDuration)
- {
- m_pSink->Notify(EC_STARVATION, 0, 0);
- m_bSignaledStarvation = true;
- }
- }
- //GetImageFromMixer();
- }
+ if (m_VSyncMode == 0)
+ {
+ // 23.976 in 60 Hz
+ if (VSyncOffset0 < Margin && VSyncOffsetMax > (VSyncTime - Margin))
+ {
+ m_VSyncMode = 2;
+ }
+ else if (VSyncOffset0 > (VSyncTime - Margin) && VSyncOffsetMin < Margin)
+ {
+ m_VSyncMode = 1;
+ }
+ }
+ else if (m_VSyncMode == 2)
+ {
+ if (VSyncOffsetMin > (Margin))
+ {
+ m_VSyncMode = 0;
+ }
+ }
+ else if (m_VSyncMode == 1)
+ {
+ if (VSyncOffsetMax < (VSyncTime - Margin))
+ {
+ m_VSyncMode = 0;
+ }
+ }
+ }
+
+ }
+ }
+
+ m_pCurrentDisplaydSample = NULL;
+ if (bStepForward)
+ {
+ MoveToFreeList(pMFSample, true);
+ CheckWaitingSampleFromMixer();
+ m_MaxSampleDuration = max(SampleDuration, m_MaxSampleDuration);
+ }
+ else
+ MoveToScheduledList(pMFSample, true);
+ }
+ else if (m_bLastSampleOffsetValid && m_LastSampleOffset < -10000000) // Only starve if we are 1 seconds behind
+ {
+ if (m_nRenderState == Started && !g_bNoDuration)
+ {
+ m_pSink->Notify(EC_STARVATION, 0, 0);
+ m_bSignaledStarvation = true;
+ }
+ }
+ //GetImageFromMixer();
+ }
// else
-// {
+// {
// TRACE_EVR ("EVR: RenderThread ==>> Flush before rendering frame!\n");
// }
- break;
- }
- }
+ break;
+ }
+ }
- timeEndPeriod(dwResolution);
- if(pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics(hAvrt);
+ timeEndPeriod (dwResolution);
+ if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
void CEVRAllocatorPresenter::OnResetDevice()
{
- HRESULT hr;
+ HRESULT hr;
- // Reset DXVA Manager, and get new buffers
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ // Reset DXVA Manager, and get new buffers
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- // Not necessary, but Microsoft documentation say Presenter should send this message...
- if(m_pSink)
- m_pSink->Notify(EC_DISPLAY_CHANGED, 0, 0);
+ // Not necessary, but Microsoft documentation say Presenter should send this message...
+ if (m_pSink)
+ m_pSink->Notify (EC_DISPLAY_CHANGED, 0, 0);
}
void CEVRAllocatorPresenter::RemoveAllSamples()
{
- CAutoLock AutoLock(&m_ImageProcessingLock);
+ CAutoLock AutoLock(&m_ImageProcessingLock);
- FlushSamples();
- m_ScheduledSamples.RemoveAll();
- m_FreeSamples.RemoveAll();
- m_LastScheduledSampleTime = -1;
- m_LastScheduledUncorrectedSampleTime = -1;
- ASSERT(m_nUsedBuffer == 0);
- m_nUsedBuffer = 0;
+ FlushSamples();
+ m_ScheduledSamples.RemoveAll();
+ m_FreeSamples.RemoveAll();
+ m_LastScheduledSampleTime = -1;
+ m_LastScheduledUncorrectedSampleTime = -1;
+ ASSERT(m_nUsedBuffer == 0);
+ m_nUsedBuffer = 0;
}
HRESULT CEVRAllocatorPresenter::GetFreeSample(IMFSample** ppSample)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- if(m_FreeSamples.GetCount() > 1) // <= Cannot use first free buffer (can be currently displayed)
- {
- InterlockedIncrement(&m_nUsedBuffer);
- *ppSample = m_FreeSamples.RemoveHead().Detach();
- }
- else
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ if (m_FreeSamples.GetCount() > 1) // <= Cannot use first free buffer (can be currently displayed)
+ {
+ InterlockedIncrement (&m_nUsedBuffer);
+ *ppSample = m_FreeSamples.RemoveHead().Detach();
+ }
+ else
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- return hr;
+ return hr;
}
HRESULT CEVRAllocatorPresenter::GetScheduledSample(IMFSample** ppSample, int &_Count)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- _Count = m_ScheduledSamples.GetCount();
- if(_Count > 0)
- {
- *ppSample = m_ScheduledSamples.RemoveHead().Detach();
- --_Count;
- }
- else
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ _Count = m_ScheduledSamples.GetCount();
+ if (_Count > 0)
+ {
+ *ppSample = m_ScheduledSamples.RemoveHead().Detach();
+ --_Count;
+ }
+ else
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- return hr;
+ return hr;
}
void CEVRAllocatorPresenter::MoveToFreeList(IMFSample* pSample, bool bTail)
{
- CAutoLock lock(&m_SampleQueueLock);
- InterlockedDecrement(&m_nUsedBuffer);
- if(m_bPendingMediaFinished && m_nUsedBuffer == 0)
- {
- m_bPendingMediaFinished = false;
- m_pSink->Notify(EC_COMPLETE, 0, 0);
- }
- if(bTail)
- m_FreeSamples.AddTail(pSample);
- else
- m_FreeSamples.AddHead(pSample);
+ CAutoLock lock(&m_SampleQueueLock);
+ InterlockedDecrement (&m_nUsedBuffer);
+ if (m_bPendingMediaFinished && m_nUsedBuffer == 0)
+ {
+ m_bPendingMediaFinished = false;
+ m_pSink->Notify (EC_COMPLETE, 0, 0);
+ }
+ if (bTail)
+ m_FreeSamples.AddTail (pSample);
+ else
+ m_FreeSamples.AddHead(pSample);
}
void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
- if(_bSorted)
- {
- CAutoLock lock(&m_SampleQueueLock);
- // Insert sorted
- /* POSITION Iterator = m_ScheduledSamples.GetHeadPosition();
-
- LONGLONG NewSampleTime;
- pSample->GetSampleTime(&NewSampleTime);
-
- while (Iterator != NULL)
- {
- POSITION CurrentPos = Iterator;
- IMFSample *pIter = m_ScheduledSamples.GetNext(Iterator);
- LONGLONG SampleTime;
- pIter->GetSampleTime(&SampleTime);
- if (NewSampleTime < SampleTime)
- {
- m_ScheduledSamples.InsertBefore(CurrentPos, pSample);
- return;
- }
- }*/
-
- m_ScheduledSamples.AddHead(pSample);
- }
- else
- {
-
- CAutoLock lock(&m_SampleQueueLock);
-
- AppSettings& s = AfxGetAppSettings();
- double ForceFPS = 0.0;
+ if (_bSorted)
+ {
+ CAutoLock lock(&m_SampleQueueLock);
+ // Insert sorted
+/* POSITION Iterator = m_ScheduledSamples.GetHeadPosition();
+
+ LONGLONG NewSampleTime;
+ pSample->GetSampleTime(&NewSampleTime);
+
+ while (Iterator != NULL)
+ {
+ POSITION CurrentPos = Iterator;
+ IMFSample *pIter = m_ScheduledSamples.GetNext(Iterator);
+ LONGLONG SampleTime;
+ pIter->GetSampleTime(&SampleTime);
+ if (NewSampleTime < SampleTime)
+ {
+ m_ScheduledSamples.InsertBefore(CurrentPos, pSample);
+ return;
+ }
+ }*/
+
+ m_ScheduledSamples.AddHead(pSample);
+ }
+ else
+ {
+
+ CAutoLock lock(&m_SampleQueueLock);
+
+ AppSettings& s = AfxGetAppSettings();
+ double ForceFPS = 0.0;
// double ForceFPS = 59.94;
// double ForceFPS = 23.976;
- if(ForceFPS != 0.0)
- m_rtTimePerFrame = 10000000.0 / ForceFPS;
- LONGLONG Duration = m_rtTimePerFrame;
- LONGLONG PrevTime = m_LastScheduledUncorrectedSampleTime;
- LONGLONG Time;
- LONGLONG SetDuration;
- pSample->GetSampleDuration(&SetDuration);
- pSample->GetSampleTime(&Time);
- m_LastScheduledUncorrectedSampleTime = Time;
-
- m_bCorrectedFrameTime = false;
-
- LONGLONG Diff2 = PrevTime - m_LastScheduledSampleTimeFP * 10000000.0;
- LONGLONG Diff = Time - PrevTime;
- if(PrevTime == -1)
- Diff = 0;
- if(Diff < 0)
- Diff = -Diff;
- if(Diff2 < 0)
- Diff2 = -Diff2;
- if(Diff < m_rtTimePerFrame * 8 && m_rtTimePerFrame && Diff2 < m_rtTimePerFrame * 8) // Detect seeking
- {
- int iPos = (m_DetectedFrameTimePos++) % 60;
- LONGLONG Diff = Time - PrevTime;
- if(PrevTime == -1)
- Diff = 0;
- m_DetectedFrameTimeHistory[iPos] = Diff;
-
- if(m_DetectedFrameTimePos >= 10)
- {
- int nFrames = min(m_DetectedFrameTimePos, 60);
- LONGLONG DectedSum = 0;
- for(int i = 0; i < nFrames; ++i)
- {
- DectedSum += m_DetectedFrameTimeHistory[i];
- }
-
- double Average = double(DectedSum) / double(nFrames);
- double DeviationSum = 0.0;
- for(int i = 0; i < nFrames; ++i)
- {
- double Deviation = m_DetectedFrameTimeHistory[i] - Average;
- DeviationSum += Deviation * Deviation;
- }
-
- double StdDev = sqrt(DeviationSum / double(nFrames));
-
- m_DetectedFrameTimeStdDev = StdDev;
-
- double DetectedRate = 1.0 / (double(DectedSum) / (nFrames * 10000000.0));
-
- double AllowedError = 0.0003;
-
- static double AllowedValues[] = {60.0, 59.94, 50.0, 48.0, 47.952, 30.0, 29.97, 25.0, 24.0, 23.976};
-
- int nAllowed = sizeof(AllowedValues) / sizeof(AllowedValues[0]);
- for(int i = 0; i < nAllowed; ++i)
- {
- if(fabs(1.0 - DetectedRate / AllowedValues[i]) < AllowedError)
- {
- DetectedRate = AllowedValues[i];
- break;
- }
- }
-
- m_DetectedFrameTimeHistoryHistory[m_DetectedFrameTimePos % 500] = DetectedRate;
-
- class CAutoInt
- {
- public:
-
- int m_Int;
-
- CAutoInt()
- {
- m_Int = 0;
- }
- CAutoInt(int _Other)
- {
- m_Int = _Other;
- }
-
- operator int () const
- {
- return m_Int;
- }
-
- CAutoInt &operator ++ ()
- {
- ++m_Int;
- return *this;
- }
- };
-
-
- CMap<double, double, CAutoInt, CAutoInt> Map;
-
- for(int i = 0; i < 500; ++i)
- {
- ++Map[m_DetectedFrameTimeHistoryHistory[i]];
- }
-
- POSITION Pos = Map.GetStartPosition();
- double BestVal = 0.0;
- int BestNum = 5;
- while(Pos)
- {
- double Key;
- CAutoInt Value;
- Map.GetNextAssoc(Pos, Key, Value);
- if(Value.m_Int > BestNum && Key != 0.0)
- {
- BestNum = Value.m_Int;
- BestVal = Key;
- }
- }
-
- m_DetectedLock = false;
- for(int i = 0; i < nAllowed; ++i)
- {
- if(BestVal == AllowedValues[i])
- {
- m_DetectedLock = true;
- break;
- }
- }
- if(BestVal != 0.0)
- {
- m_DetectedFrameRate = BestVal;
- m_DetectedFrameTime = 1.0 / BestVal;
- }
- }
-
- LONGLONG PredictedNext = PrevTime + m_rtTimePerFrame;
- LONGLONG PredictedDiff = PredictedNext - Time;
- if(PredictedDiff < 0)
- PredictedDiff = -PredictedDiff;
-
- if(m_DetectedFrameTime != 0.0
- //&& PredictedDiff > 15000
- && m_DetectedLock && s.m_RenderSettings.iEVREnableFrameTimeCorrection)
- {
- double CurrentTime = Time / 10000000.0;
- double LastTime = m_LastScheduledSampleTimeFP;
- double PredictedTime = LastTime + m_DetectedFrameTime;
- if(fabs(PredictedTime - CurrentTime) > 0.0015) // 1.5 ms wrong, lets correct
- {
- CurrentTime = PredictedTime;
- Time = CurrentTime * 10000000.0;
- pSample->SetSampleTime(Time);
- pSample->SetSampleDuration(m_DetectedFrameTime * 10000000.0);
- m_bCorrectedFrameTime = true;
- m_FrameTimeCorrection = 30;
- }
- m_LastScheduledSampleTimeFP = CurrentTime;
- }
- else
- m_LastScheduledSampleTimeFP = Time / 10000000.0;
- }
- else
- {
- m_LastScheduledSampleTimeFP = Time / 10000000.0;
- if(Diff > m_rtTimePerFrame * 8)
- {
- // Seek
- m_bSignaledStarvation = false;
- m_DetectedFrameTimePos = 0;
- m_DetectedLock = false;
- }
- }
+ if (ForceFPS != 0.0)
+ m_rtTimePerFrame = 10000000.0 / ForceFPS;
+ LONGLONG Duration = m_rtTimePerFrame;
+ LONGLONG PrevTime = m_LastScheduledUncorrectedSampleTime;
+ LONGLONG Time;
+ LONGLONG SetDuration;
+ pSample->GetSampleDuration(&SetDuration);
+ pSample->GetSampleTime(&Time);
+ m_LastScheduledUncorrectedSampleTime = Time;
+
+ m_bCorrectedFrameTime = false;
+
+ LONGLONG Diff2 = PrevTime - m_LastScheduledSampleTimeFP*10000000.0;
+ LONGLONG Diff = Time - PrevTime;
+ if (PrevTime == -1)
+ Diff = 0;
+ if (Diff < 0)
+ Diff = -Diff;
+ if (Diff2 < 0)
+ Diff2 = -Diff2;
+ if (Diff < m_rtTimePerFrame*8 && m_rtTimePerFrame && Diff2 < m_rtTimePerFrame*8) // Detect seeking
+ {
+ int iPos = (m_DetectedFrameTimePos++) % 60;
+ LONGLONG Diff = Time - PrevTime;
+ if (PrevTime == -1)
+ Diff = 0;
+ m_DetectedFrameTimeHistory[iPos] = Diff;
+
+ if (m_DetectedFrameTimePos >= 10)
+ {
+ int nFrames = min(m_DetectedFrameTimePos, 60);
+ LONGLONG DectedSum = 0;
+ for (int i = 0; i < nFrames; ++i)
+ {
+ DectedSum += m_DetectedFrameTimeHistory[i];
+ }
+
+ double Average = double(DectedSum) / double(nFrames);
+ double DeviationSum = 0.0;
+ for (int i = 0; i < nFrames; ++i)
+ {
+ double Deviation = m_DetectedFrameTimeHistory[i] - Average;
+ DeviationSum += Deviation*Deviation;
+ }
+
+ double StdDev = sqrt(DeviationSum/double(nFrames));
+
+ m_DetectedFrameTimeStdDev = StdDev;
+
+ double DetectedRate = 1.0/ (double(DectedSum) / (nFrames * 10000000.0) );
+
+ double AllowedError = 0.0003;
+
+ static double AllowedValues[] = {60.0, 59.94, 50.0, 48.0, 47.952, 30.0, 29.97, 25.0, 24.0, 23.976};
+
+ int nAllowed = sizeof(AllowedValues) / sizeof(AllowedValues[0]);
+ for (int i = 0; i < nAllowed; ++i)
+ {
+ if (fabs(1.0 - DetectedRate / AllowedValues[i]) < AllowedError)
+ {
+ DetectedRate = AllowedValues[i];
+ break;
+ }
+ }
+
+ m_DetectedFrameTimeHistoryHistory[m_DetectedFrameTimePos % 500] = DetectedRate;
+
+ class CAutoInt
+ {
+ public:
+
+ int m_Int;
+
+ CAutoInt()
+ {
+ m_Int = 0;
+ }
+ CAutoInt(int _Other)
+ {
+ m_Int = _Other;
+ }
+
+ operator int () const
+ {
+ return m_Int;
+ }
+
+ CAutoInt &operator ++ ()
+ {
+ ++m_Int;
+ return *this;
+ }
+ };
+
+
+ CMap<double, double, CAutoInt, CAutoInt> Map;
+
+ for (int i = 0; i < 500; ++i)
+ {
+ ++Map[m_DetectedFrameTimeHistoryHistory[i]];
+ }
+
+ POSITION Pos = Map.GetStartPosition();
+ double BestVal = 0.0;
+ int BestNum = 5;
+ while (Pos)
+ {
+ double Key;
+ CAutoInt Value;
+ Map.GetNextAssoc(Pos, Key, Value);
+ if (Value.m_Int > BestNum && Key != 0.0)
+ {
+ BestNum = Value.m_Int;
+ BestVal = Key;
+ }
+ }
+
+ m_DetectedLock = false;
+ for (int i = 0; i < nAllowed; ++i)
+ {
+ if (BestVal == AllowedValues[i])
+ {
+ m_DetectedLock = true;
+ break;
+ }
+ }
+ if (BestVal != 0.0)
+ {
+ m_DetectedFrameRate = BestVal;
+ m_DetectedFrameTime = 1.0 / BestVal;
+ }
+ }
+
+ LONGLONG PredictedNext = PrevTime + m_rtTimePerFrame;
+ LONGLONG PredictedDiff = PredictedNext - Time;
+ if (PredictedDiff < 0)
+ PredictedDiff = -PredictedDiff;
+
+ if (m_DetectedFrameTime != 0.0
+ //&& PredictedDiff > 15000
+ && m_DetectedLock && s.m_RenderSettings.iEVREnableFrameTimeCorrection)
+ {
+ double CurrentTime = Time / 10000000.0;
+ double LastTime = m_LastScheduledSampleTimeFP;
+ double PredictedTime = LastTime + m_DetectedFrameTime;
+ if (fabs(PredictedTime - CurrentTime) > 0.0015) // 1.5 ms wrong, lets correct
+ {
+ CurrentTime = PredictedTime;
+ Time = CurrentTime * 10000000.0;
+ pSample->SetSampleTime(Time);
+ pSample->SetSampleDuration(m_DetectedFrameTime * 10000000.0);
+ m_bCorrectedFrameTime = true;
+ m_FrameTimeCorrection = 30;
+ }
+ m_LastScheduledSampleTimeFP = CurrentTime;
+ }
+ else
+ m_LastScheduledSampleTimeFP = Time / 10000000.0;
+ }
+ else
+ {
+ m_LastScheduledSampleTimeFP = Time / 10000000.0;
+ if (Diff > m_rtTimePerFrame*8)
+ {
+ // Seek
+ m_bSignaledStarvation = false;
+ m_DetectedFrameTimePos = 0;
+ m_DetectedLock = false;
+ }
+ }
// TRACE_EVR("EVR: Time: %f %f %f\n", Time / 10000000.0, SetDuration / 10000000.0, m_DetectedFrameRate);
- if(!m_bCorrectedFrameTime && m_FrameTimeCorrection)
- --m_FrameTimeCorrection;
+ if (!m_bCorrectedFrameTime && m_FrameTimeCorrection)
+ --m_FrameTimeCorrection;
#if 0
- if(Time <= m_LastScheduledUncorrectedSampleTime && m_LastScheduledSampleTime >= 0)
- PrevTime = m_LastScheduledSampleTime;
-
- m_bCorrectedFrameTime = false;
- if(PrevTime != -1 && (Time >= PrevTime - ((Duration * 20) / 9) || Time == 0) || ForceFPS != 0.0)
- {
- if(Time - PrevTime > ((Duration * 20) / 9) && Time - PrevTime < Duration * 8 || Time == 0 || ((Time - PrevTime) < (Duration / 11)) || ForceFPS != 0.0)
- {
- // Error!!!!
- Time = PrevTime + Duration;
- pSample->SetSampleTime(Time);
- pSample->SetSampleDuration(Duration);
- m_bCorrectedFrameTime = true;
- TRACE_EVR("EVR: Corrected invalid sample time\n");
- }
- }
- if(Time + Duration * 10 < m_LastScheduledSampleTime)
- {
- // Flush when repeating movie
- FlushSamplesInternal();
- }
+ if (Time <= m_LastScheduledUncorrectedSampleTime && m_LastScheduledSampleTime >= 0)
+ PrevTime = m_LastScheduledSampleTime;
+
+ m_bCorrectedFrameTime = false;
+ if (PrevTime != -1 && (Time >= PrevTime - ((Duration*20)/9) || Time == 0) || ForceFPS != 0.0)
+ {
+ if (Time - PrevTime > ((Duration*20)/9) && Time - PrevTime < Duration * 8 || Time == 0 || ((Time - PrevTime) < (Duration / 11)) || ForceFPS != 0.0)
+ {
+ // Error!!!!
+ Time = PrevTime + Duration;
+ pSample->SetSampleTime(Time);
+ pSample->SetSampleDuration(Duration);
+ m_bCorrectedFrameTime = true;
+ TRACE_EVR("EVR: Corrected invalid sample time\n");
+ }
+ }
+ if (Time+Duration*10 < m_LastScheduledSampleTime)
+ {
+ // Flush when repeating movie
+ FlushSamplesInternal();
+ }
#endif
#if 0
- static LONGLONG LastDuration = 0;
- LONGLONG SetDuration = m_rtTimePerFrame;
- pSample->GetSampleDuration(&SetDuration);
- if(SetDuration != LastDuration)
- {
- TRACE_EVR("EVR: Old duration: %I64d New duration: %I64d\n", LastDuration, SetDuration);
- }
- LastDuration = SetDuration;
+ static LONGLONG LastDuration = 0;
+ LONGLONG SetDuration = m_rtTimePerFrame;
+ pSample->GetSampleDuration(&SetDuration);
+ if (SetDuration != LastDuration)
+ {
+ TRACE_EVR("EVR: Old duration: %I64d New duration: %I64d\n", LastDuration, SetDuration);
+ }
+ LastDuration = SetDuration;
#endif
- m_LastScheduledSampleTime = Time;
+ m_LastScheduledSampleTime = Time;
- m_ScheduledSamples.AddTail(pSample);
+ m_ScheduledSamples.AddTail(pSample);
- }
+ }
}
void CEVRAllocatorPresenter::FlushSamples()
{
- CAutoLock lock(this);
- CAutoLock lock2(&m_SampleQueueLock);
-
- FlushSamplesInternal();
- m_LastScheduledSampleTime = -1;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_SampleQueueLock);
+
+ FlushSamplesInternal();
+ m_LastScheduledSampleTime = -1;
}
void CEVRAllocatorPresenter::FlushSamplesInternal()
{
- while(m_ScheduledSamples.GetCount() > 0)
- {
- CComPtr<IMFSample> pMFSample;
+ while (m_ScheduledSamples.GetCount() > 0)
+ {
+ CComPtr<IMFSample> pMFSample;
- pMFSample = m_ScheduledSamples.RemoveHead();
- MoveToFreeList(pMFSample, true);
- }
+ pMFSample = m_ScheduledSamples.RemoveHead();
+ MoveToFreeList (pMFSample, true);
+ }
- m_LastSampleOffset = 0;
- m_bLastSampleOffsetValid = false;
- m_bSignaledStarvation = false;
+ m_LastSampleOffset = 0;
+ m_bLastSampleOffsetValid = false;
+ m_bSignaledStarvation = false;
}
diff --git a/src/apps/mplayerc/EVRAllocatorPresenter.h b/src/apps/mplayerc/EVRAllocatorPresenter.h
index 670036e44..b29141e72 100644
--- a/src/apps/mplayerc/EVRAllocatorPresenter.h
+++ b/src/apps/mplayerc/EVRAllocatorPresenter.h
@@ -28,252 +28,252 @@
namespace DSObjects
{
-// dxva.dll
-typedef HRESULT(__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
-
-// mf.dll
-typedef HRESULT(__stdcall *PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
-
-// evr.dll
-typedef HRESULT(__stdcall *PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
-typedef HRESULT(__stdcall *PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
-typedef HRESULT(__stdcall *PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
-
-// AVRT.dll
-typedef HANDLE(__stdcall *PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
-typedef BOOL (__stdcall *PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
-typedef BOOL (__stdcall *PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
-
-class COuterEVR;
-
-class CEVRAllocatorPresenter :
- public CDX9AllocatorPresenter,
- public IMFGetService,
- public IMFTopologyServiceLookupClient,
- public IMFVideoDeviceID,
- public IMFVideoPresenter,
- public IDirect3DDeviceManager9,
-
- public IMFAsyncCallback,
- public IQualProp,
- public IMFRateSupport,
- public IMFVideoDisplayControl,
- public IEVRTrustedVideoPlugin
-/* public IMFVideoPositionMapper, // Non mandatory EVR Presenter Interfaces (see later...)
-*/
-{
-public:
- CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
- ~CEVRAllocatorPresenter(void);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
-
-
- // IMFClockStateSink
- STDMETHODIMP OnClockStart(/* [in] */ MFTIME hnsSystemTime, /* [in] */ LONGLONG llClockStartOffset);
- STDMETHODIMP STDMETHODCALLTYPE OnClockStop(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockPause(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockSetRate(/* [in] */ MFTIME hnsSystemTime, /* [in] */ float flRate);
-
- // IBaseFilter delegate
- bool GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue);
-
- // IQualProp (EVR statistics window)
- STDMETHODIMP get_FramesDroppedInRenderer(int *pcFrames);
- STDMETHODIMP get_FramesDrawn(int *pcFramesDrawn);
- STDMETHODIMP get_AvgFrameRate(int *piAvgFrameRate);
- STDMETHODIMP get_Jitter(int *iJitter);
- STDMETHODIMP get_AvgSyncOffset(int *piAvg);
- STDMETHODIMP get_DevSyncOffset(int *piDev);
-
-
- // IMFRateSupport
- STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate);
-
- float GetMaxRate(BOOL bThin);
-
-
- // IMFVideoPresenter
- STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
- STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType);
-
- // IMFTopologyServiceLookupClient
- STDMETHODIMP InitServicePointers(/* [in] */ __in IMFTopologyServiceLookup *pLookup);
- STDMETHODIMP ReleaseServicePointers();
-
- // IMFVideoDeviceID
- STDMETHODIMP GetDeviceID(/* [out] */ __out IID *pDeviceID);
-
- // IMFGetService
- STDMETHODIMP GetService(/* [in] */ __RPC__in REFGUID guidService,
- /* [in] */ __RPC__in REFIID riid,
- /* [iid_is][out] */ __RPC__deref_out_opt LPVOID *ppvObject);
-
- // IMFAsyncCallback
- STDMETHODIMP GetParameters(/* [out] */ __RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue);
- STDMETHODIMP Invoke(/* [in] */ __RPC__in_opt IMFAsyncResult *pAsyncResult);
-
- // IMFVideoDisplayControl
- STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo);
- STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax);
- STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest);
- STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest);
- STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
- STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode);
- STDMETHODIMP SetVideoWindow(HWND hwndVideo);
- STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
- STDMETHODIMP RepaintVideo(void);
- STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF *pClr);
- STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
- STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags);
- STDMETHODIMP SetFullscreen(BOOL fFullscreen);
- STDMETHODIMP GetFullscreen(BOOL *pfFullscreen);
-
- // IEVRTrustedVideoPlugin
- STDMETHODIMP IsInTrustedVideoMode(BOOL *pYes);
- STDMETHODIMP CanConstrict(BOOL *pYes);
- STDMETHODIMP SetConstriction(DWORD dwKPix);
- STDMETHODIMP DisableImageExport(BOOL bDisable);
-
- // IDirect3DDeviceManager9
- STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice, UINT resetToken);
- STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
- STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
- STDMETHODIMP TestDevice(HANDLE hDevice);
- STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
- STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
- STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void **ppService);
-
-protected :
- void OnResetDevice();
- virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter);
-
- double m_ModeratedTime;
- LONGLONG m_ModeratedTimeLast;
- LONGLONG m_ModeratedClockLast;
- LONGLONG m_ModeratedTimer;
- MFCLOCK_STATE m_LastClockState;
- LONGLONG GetClockTime(LONGLONG PerformanceCounter);
-
-private :
-
- typedef enum
- {
- Started = State_Running,
- Stopped = State_Stopped,
- Paused = State_Paused,
- Shutdown = State_Running + 1
- } RENDER_STATE;
-
- COuterEVR* m_pOuterEVR;
- CComPtr<IMFClock> m_pClock;
- CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
- CComPtr<IMFTransform> m_pMixer;
- CComPtr<IMediaEventSink> m_pSink;
- CComPtr<IMFVideoMediaType> m_pMediaType;
- MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
- MFVideoRenderPrefs m_dwVideoRenderPrefs;
- COLORREF m_BorderColor;
-
-
- HANDLE m_hEvtQuit; // Stop rendering thread event
- bool m_bEvtQuit;
- HANDLE m_hEvtFlush; // Discard all buffers
- bool m_bEvtFlush;
-
- bool m_fUseInternalTimer;
- int32 m_LastSetOutputRange;
- bool m_bPendingRenegotiate;
- bool m_bPendingMediaFinished;
-
- HANDLE m_hThread;
- HANDLE m_hGetMixerThread;
- RENDER_STATE m_nRenderState;
-
- CCritSec m_SampleQueueLock;
- CCritSec m_ImageProcessingLock;
-
- CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
- CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
- IMFSample * m_pCurrentDisplaydSample;
- bool m_bWaitingSample;
- bool m_bLastSampleOffsetValid;
- LONGLONG m_LastScheduledSampleTime;
- double m_LastScheduledSampleTimeFP;
- LONGLONG m_LastScheduledUncorrectedSampleTime;
- LONGLONG m_MaxSampleDuration;
- LONGLONG m_LastSampleOffset;
- LONGLONG m_VSyncOffsetHistory[5];
- LONGLONG m_LastPredictedSync;
- int m_VSyncOffsetHistoryPos;
-
- UINT m_nResetToken;
- int m_nStepCount;
-
- bool m_bSignaledStarvation;
- LONGLONG m_StarvationClock;
-
- // Stats variable for IQualProp
- UINT m_pcFrames;
- UINT m_nDroppedUpdate;
- UINT m_pcFramesDrawn; // Retrieves the number of frames drawn since streaming started
- UINT m_piAvg;
- UINT m_piDev;
-
-
- void GetMixerThread();
- static DWORD WINAPI GetMixerThreadStatic(LPVOID lpParam);
-
- bool GetImageFromMixer();
- void RenderThread();
- static DWORD WINAPI PresentThread(LPVOID lpParam);
- void ResetStats();
- void StartWorkerThreads();
- void StopWorkerThreads();
- HRESULT CheckShutdown() const;
- void CompleteFrameStep(bool bCancel);
- void CheckWaitingSampleFromMixer();
-
- void RemoveAllSamples();
- HRESULT GetFreeSample(IMFSample** ppSample);
- HRESULT GetScheduledSample(IMFSample** ppSample, int &_Count);
- void MoveToFreeList(IMFSample* pSample, bool bTail);
- void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
- void FlushSamples();
- void FlushSamplesInternal();
-
- // === Media type negociation functions
- HRESULT RenegotiateMediaType();
- HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
- HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
- HRESULT SetMediaType(IMFMediaType* pType);
-
- // === Functions pointers on Vista / .Net3 specifics library
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
- PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
- PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
+ // dxva.dll
+ typedef HRESULT (__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
+
+ // mf.dll
+ typedef HRESULT (__stdcall *PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
+
+ // evr.dll
+ typedef HRESULT (__stdcall *PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
+ typedef HRESULT (__stdcall *PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
+ typedef HRESULT (__stdcall *PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
+
+ // AVRT.dll
+ typedef HANDLE (__stdcall *PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
+ typedef BOOL (__stdcall *PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
+ typedef BOOL (__stdcall *PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
+
+ class COuterEVR;
+
+ class CEVRAllocatorPresenter :
+ public CDX9AllocatorPresenter,
+ public IMFGetService,
+ public IMFTopologyServiceLookupClient,
+ public IMFVideoDeviceID,
+ public IMFVideoPresenter,
+ public IDirect3DDeviceManager9,
+
+ public IMFAsyncCallback,
+ public IQualProp,
+ public IMFRateSupport,
+ public IMFVideoDisplayControl,
+ public IEVRTrustedVideoPlugin
+ /* public IMFVideoPositionMapper, // Non mandatory EVR Presenter Interfaces (see later...)
+ */
+ {
+ public:
+ CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
+ ~CEVRAllocatorPresenter(void);
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
+
+
+ // IMFClockStateSink
+ STDMETHODIMP OnClockStart(/* [in] */ MFTIME hnsSystemTime, /* [in] */ LONGLONG llClockStartOffset);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockStop(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockPause(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockSetRate(/* [in] */ MFTIME hnsSystemTime, /* [in] */ float flRate);
+
+ // IBaseFilter delegate
+ bool GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue);
+
+ // IQualProp (EVR statistics window)
+ STDMETHODIMP get_FramesDroppedInRenderer (int *pcFrames);
+ STDMETHODIMP get_FramesDrawn (int *pcFramesDrawn);
+ STDMETHODIMP get_AvgFrameRate (int *piAvgFrameRate);
+ STDMETHODIMP get_Jitter (int *iJitter);
+ STDMETHODIMP get_AvgSyncOffset (int *piAvg);
+ STDMETHODIMP get_DevSyncOffset (int *piDev);
+
+
+ // IMFRateSupport
+ STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
+ STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
+ STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate);
+
+ float GetMaxRate(BOOL bThin);
+
+
+ // IMFVideoPresenter
+ STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
+ STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType);
+
+ // IMFTopologyServiceLookupClient
+ STDMETHODIMP InitServicePointers(/* [in] */ __in IMFTopologyServiceLookup *pLookup);
+ STDMETHODIMP ReleaseServicePointers();
+
+ // IMFVideoDeviceID
+ STDMETHODIMP GetDeviceID(/* [out] */ __out IID *pDeviceID);
+
+ // IMFGetService
+ STDMETHODIMP GetService (/* [in] */ __RPC__in REFGUID guidService,
+ /* [in] */ __RPC__in REFIID riid,
+ /* [iid_is][out] */ __RPC__deref_out_opt LPVOID *ppvObject);
+
+ // IMFAsyncCallback
+ STDMETHODIMP GetParameters( /* [out] */ __RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue);
+ STDMETHODIMP Invoke ( /* [in] */ __RPC__in_opt IMFAsyncResult *pAsyncResult);
+
+ // IMFVideoDisplayControl
+ STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo);
+ STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax);
+ STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest);
+ STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest);
+ STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
+ STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode);
+ STDMETHODIMP SetVideoWindow(HWND hwndVideo);
+ STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
+ STDMETHODIMP RepaintVideo( void);
+ STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF *pClr);
+ STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
+ STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags);
+ STDMETHODIMP SetFullscreen(BOOL fFullscreen);
+ STDMETHODIMP GetFullscreen(BOOL *pfFullscreen);
+
+ // IEVRTrustedVideoPlugin
+ STDMETHODIMP IsInTrustedVideoMode(BOOL *pYes);
+ STDMETHODIMP CanConstrict(BOOL *pYes);
+ STDMETHODIMP SetConstriction(DWORD dwKPix);
+ STDMETHODIMP DisableImageExport(BOOL bDisable);
+
+ // IDirect3DDeviceManager9
+ STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
+ STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
+ STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
+ STDMETHODIMP TestDevice(HANDLE hDevice);
+ STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
+ STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
+ STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void **ppService);
+
+ protected :
+ void OnResetDevice();
+ virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter);
+
+ double m_ModeratedTime;
+ LONGLONG m_ModeratedTimeLast;
+ LONGLONG m_ModeratedClockLast;
+ LONGLONG m_ModeratedTimer;
+ MFCLOCK_STATE m_LastClockState;
+ LONGLONG GetClockTime(LONGLONG PerformanceCounter);
+
+ private :
+
+ typedef enum
+ {
+ Started = State_Running,
+ Stopped = State_Stopped,
+ Paused = State_Paused,
+ Shutdown = State_Running + 1
+ } RENDER_STATE;
+
+ COuterEVR* m_pOuterEVR;
+ CComPtr<IMFClock> m_pClock;
+ CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
+ CComPtr<IMFTransform> m_pMixer;
+ CComPtr<IMediaEventSink> m_pSink;
+ CComPtr<IMFVideoMediaType> m_pMediaType;
+ MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
+ MFVideoRenderPrefs m_dwVideoRenderPrefs;
+ COLORREF m_BorderColor;
+
+
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ bool m_bEvtQuit;
+ HANDLE m_hEvtFlush; // Discard all buffers
+ bool m_bEvtFlush;
+
+ bool m_fUseInternalTimer;
+ int32 m_LastSetOutputRange;
+ bool m_bPendingRenegotiate;
+ bool m_bPendingMediaFinished;
+
+ HANDLE m_hThread;
+ HANDLE m_hGetMixerThread;
+ RENDER_STATE m_nRenderState;
+
+ CCritSec m_SampleQueueLock;
+ CCritSec m_ImageProcessingLock;
+
+ CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
+ CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
+ IMFSample * m_pCurrentDisplaydSample;
+ bool m_bWaitingSample;
+ bool m_bLastSampleOffsetValid;
+ LONGLONG m_LastScheduledSampleTime;
+ double m_LastScheduledSampleTimeFP;
+ LONGLONG m_LastScheduledUncorrectedSampleTime;
+ LONGLONG m_MaxSampleDuration;
+ LONGLONG m_LastSampleOffset;
+ LONGLONG m_VSyncOffsetHistory[5];
+ LONGLONG m_LastPredictedSync;
+ int m_VSyncOffsetHistoryPos;
+
+ UINT m_nResetToken;
+ int m_nStepCount;
+
+ bool m_bSignaledStarvation;
+ LONGLONG m_StarvationClock;
+
+ // Stats variable for IQualProp
+ UINT m_pcFrames;
+ UINT m_nDroppedUpdate;
+ UINT m_pcFramesDrawn; // Retrieves the number of frames drawn since streaming started
+ UINT m_piAvg;
+ UINT m_piDev;
+
+
+ void GetMixerThread();
+ static DWORD WINAPI GetMixerThreadStatic(LPVOID lpParam);
+
+ bool GetImageFromMixer();
+ void RenderThread();
+ static DWORD WINAPI PresentThread(LPVOID lpParam);
+ void ResetStats();
+ void StartWorkerThreads();
+ void StopWorkerThreads();
+ HRESULT CheckShutdown() const;
+ void CompleteFrameStep(bool bCancel);
+ void CheckWaitingSampleFromMixer();
+
+ void RemoveAllSamples();
+ HRESULT GetFreeSample(IMFSample** ppSample);
+ HRESULT GetScheduledSample(IMFSample** ppSample, int &_Count);
+ void MoveToFreeList(IMFSample* pSample, bool bTail);
+ void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
+ void FlushSamples();
+ void FlushSamplesInternal();
+
+ // === Media type negociation functions
+ HRESULT RenegotiateMediaType();
+ HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
+ HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
+ HRESULT SetMediaType(IMFMediaType* pType);
+
+ // === Functions pointers on Vista / .Net3 specifics library
+ PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
+ PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
+ PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
+ PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
#if 0
- HRESULT(__stdcall *pMFCreateMediaType)(__deref_out IMFMediaType** ppMFType);
- HRESULT(__stdcall *pMFInitMediaTypeFromAMMediaType)(__in IMFMediaType *pMFType, __in const AM_MEDIA_TYPE *pAMType);
- HRESULT(__stdcall *pMFInitAMMediaTypeFromMFMediaType)(__in IMFMediaType *pMFType, __in GUID guidFormatBlockType, __inout AM_MEDIA_TYPE *pAMType);
+ HRESULT (__stdcall *pMFCreateMediaType)(__deref_out IMFMediaType** ppMFType);
+ HRESULT (__stdcall *pMFInitMediaTypeFromAMMediaType)(__in IMFMediaType *pMFType, __in const AM_MEDIA_TYPE *pAMType);
+ HRESULT (__stdcall *pMFInitAMMediaTypeFromMFMediaType)(__in IMFMediaType *pMFType, __in GUID guidFormatBlockType, __inout AM_MEDIA_TYPE *pAMType);
#endif
- PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
- PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
- PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
-};
+ PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
+ PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
+ PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
+ };
}
diff --git a/src/apps/mplayerc/EditListEditor.cpp b/src/apps/mplayerc/EditListEditor.cpp
index a39b3a857..3385e40d1 100644
--- a/src/apps/mplayerc/EditListEditor.cpp
+++ b/src/apps/mplayerc/EditListEditor.cpp
@@ -28,581 +28,581 @@
CClip::CClip()
{
- m_rtIn = _I64_MIN;
- m_rtOut = _I64_MIN;
+ m_rtIn = _I64_MIN;
+ m_rtOut = _I64_MIN;
}
void CClip::SetIn(LPCTSTR strVal)
{
- m_rtIn = StringToReftime(strVal);
+ m_rtIn = StringToReftime (strVal);
}
void CClip::SetOut(LPCTSTR strVal)
{
- m_rtOut = StringToReftime(strVal);
+ m_rtOut = StringToReftime (strVal);
}
-void CClip::SetIn(REFERENCE_TIME rtVal)
-{
- m_rtIn = rtVal;
- if(m_rtIn > m_rtOut) m_rtOut = _I64_MIN;
+void CClip::SetIn (REFERENCE_TIME rtVal)
+{
+ m_rtIn = rtVal;
+ if (m_rtIn > m_rtOut) m_rtOut = _I64_MIN;
};
-void CClip::SetOut(REFERENCE_TIME rtVal)
-{
- m_rtOut = rtVal;
- if(m_rtIn > m_rtOut) m_rtIn = _I64_MIN;
+void CClip::SetOut (REFERENCE_TIME rtVal)
+{
+ m_rtOut = rtVal;
+ if (m_rtIn > m_rtOut) m_rtIn = _I64_MIN;
};
CString CClip::GetIn()
{
- if(m_rtIn == _I64_MIN)
- return _T("");
- else
- return ReftimeToString(m_rtIn);
+ if (m_rtIn == _I64_MIN)
+ return _T("");
+ else
+ return ReftimeToString(m_rtIn);
}
CString CClip::GetOut()
{
- if(m_rtOut == _I64_MIN)
- return _T("");
- else
- return ReftimeToString(m_rtOut);
+ if (m_rtOut == _I64_MIN)
+ return _T("");
+ else
+ return ReftimeToString(m_rtOut);
}
IMPLEMENT_DYNAMIC(CEditListEditor, CSizingControlBarG)
CEditListEditor::CEditListEditor(void)
{
- m_CurPos = NULL;
- m_bDragging = FALSE;
- m_nDragIndex = -1;
- m_nDropIndex = -1;
- m_bFileOpen = false;
+ m_CurPos = NULL;
+ m_bDragging = FALSE;
+ m_nDragIndex = -1;
+ m_nDropIndex = -1;
+ m_bFileOpen = false;
}
CEditListEditor::~CEditListEditor(void)
{
- SaveEditListToFile();
+ SaveEditListToFile();
}
BEGIN_MESSAGE_MAP(CEditListEditor, CSizingControlBarG)
- ON_WM_SIZE()
- ON_NOTIFY(LVN_ITEMCHANGED, IDC_EDITLIST, OnLvnItemchanged)
- ON_NOTIFY(LVN_KEYDOWN, IDC_EDITLIST, OnLvnKeyDown)
- ON_WM_DRAWITEM()
- ON_NOTIFY(LVN_BEGINDRAG, IDC_EDITLIST, OnBeginDrag)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONUP()
- ON_WM_TIMER()
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_EDITLIST, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_EDITLIST, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_EDITLIST, OnEndlabeleditList)
+ ON_WM_SIZE()
+ ON_NOTIFY(LVN_ITEMCHANGED, IDC_EDITLIST, OnLvnItemchanged)
+ ON_NOTIFY(LVN_KEYDOWN, IDC_EDITLIST, OnLvnKeyDown)
+ ON_WM_DRAWITEM()
+ ON_NOTIFY(LVN_BEGINDRAG, IDC_EDITLIST, OnBeginDrag)
+ ON_WM_MOUSEMOVE()
+ ON_WM_LBUTTONUP()
+ ON_WM_TIMER()
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_EDITLIST, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_EDITLIST, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_EDITLIST, OnEndlabeleditList)
END_MESSAGE_MAP()
BOOL CEditListEditor::Create(CWnd* pParentWnd)
{
- if(!CSizingControlBarG::Create(_T("Edit list editor"), pParentWnd, 0))
- return FALSE;
+ if(!CSizingControlBarG::Create(_T("Edit list editor"), pParentWnd, 0))
+ return FALSE;
- m_list.CreateEx(
- WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP
- | LVS_OWNERDRAWFIXED
- | LVS_REPORT | LVS_SINGLESEL | LVS_AUTOARRANGE | LVS_NOSORTHEADER,
- CRect(0, 0, 100, 100), this, IDC_EDITLIST);
+ m_list.CreateEx(
+ WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
+ WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP
+ |LVS_OWNERDRAWFIXED
+ |LVS_REPORT|LVS_SINGLESEL|LVS_AUTOARRANGE|LVS_NOSORTHEADER,
+ CRect(0,0,100,100), this, IDC_EDITLIST);
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
- m_list.InsertColumn(COL_IN, _T("Nb."), LVCFMT_LEFT, 35);
- m_list.InsertColumn(COL_IN, _T("In"), LVCFMT_LEFT, 100);
- m_list.InsertColumn(COL_OUT, _T("Out"), LVCFMT_LEFT, 100);
- m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 150);
+ m_list.InsertColumn(COL_IN, _T("Nb."), LVCFMT_LEFT, 35);
+ m_list.InsertColumn(COL_IN, _T("In"), LVCFMT_LEFT, 100);
+ m_list.InsertColumn(COL_OUT, _T("Out"), LVCFMT_LEFT, 100);
+ m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 150);
m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10);
- m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
+ m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
- return TRUE;
+ return TRUE;
}
void CEditListEditor::OnSize(UINT nType, int cx, int cy)
{
- CSizingControlBarG::OnSize(nType, cx, cy);
+ CSizingControlBarG::OnSize(nType, cx, cy);
- ResizeListColumn();
+ ResizeListColumn();
}
void CEditListEditor::ResizeListColumn()
{
- if(::IsWindow(m_list.m_hWnd))
- {
- CRect r;
- GetClientRect(r);
- r.DeflateRect(2, 2);
- m_list.SetRedraw(FALSE);
- m_list.MoveWindow(r);
- m_list.GetClientRect(r);
- m_list.SetRedraw(TRUE);
- }
+ if(::IsWindow(m_list.m_hWnd))
+ {
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(2, 2);
+ m_list.SetRedraw(FALSE);
+ m_list.MoveWindow(r);
+ m_list.GetClientRect(r);
+ m_list.SetRedraw(TRUE);
+ }
}
void CEditListEditor::SaveEditListToFile()
{
- if((m_bFileOpen || m_EditList.GetCount() > 0) && !m_strFileName.IsEmpty())
- {
- CStdioFile EditListFile;
- if(EditListFile.Open(m_strFileName, CFile::modeCreate | CFile::modeWrite))
- {
- CString strLine;
-
- POSITION pos = m_EditList.GetHeadPosition();
- for(int i = 0; pos; i++, m_EditList.GetNext(pos))
- {
- CClip& CurClip = m_EditList.GetAt(pos);
-
- if(CurClip.HaveIn() && CurClip.HaveOut())
- {
- strLine.Format(_T("%s\t%s\t%s\n"), CurClip.GetIn(), CurClip.GetOut(), CurClip.GetName());
- EditListFile.WriteString(strLine);
- }
- }
-
- EditListFile.Close();
- }
- }
+ if ((m_bFileOpen || m_EditList.GetCount() >0) && !m_strFileName.IsEmpty())
+ {
+ CStdioFile EditListFile;
+ if (EditListFile.Open (m_strFileName, CFile::modeCreate|CFile::modeWrite))
+ {
+ CString strLine;
+
+ POSITION pos = m_EditList.GetHeadPosition();
+ for(int i = 0; pos; i++, m_EditList.GetNext(pos))
+ {
+ CClip& CurClip = m_EditList.GetAt(pos);
+
+ if (CurClip.HaveIn() && CurClip.HaveOut())
+ {
+ strLine.Format(_T("%s\t%s\t%s\n"), CurClip.GetIn(), CurClip.GetOut(), CurClip.GetName());
+ EditListFile.WriteString (strLine);
+ }
+ }
+
+ EditListFile.Close();
+ }
+ }
}
void CEditListEditor::CloseFile()
{
- SaveEditListToFile();
- m_EditList.RemoveAll();
- m_list.DeleteAllItems();
- m_CurPos = NULL;
- m_strFileName = "";
- m_bFileOpen = false;
+ SaveEditListToFile();
+ m_EditList.RemoveAll();
+ m_list.DeleteAllItems();
+ m_CurPos = NULL;
+ m_strFileName = "";
+ m_bFileOpen = false;
}
void CEditListEditor::OpenFile(LPCTSTR lpFileName)
{
- CString strLine;
- CStdioFile EditListFile;
-
- CloseFile();
- m_strFileName.Format(_T("%s.edl"), lpFileName);
-
- if(EditListFile.Open(m_strFileName, CFile::modeRead))
- {
- m_bFileOpen = true;
- while(EditListFile.ReadString(strLine))
- {
- int nPos = 0;
- CString strIn = strLine.Tokenize(_T(" \t"), nPos);
- CString strOut = strLine.Tokenize(_T(" \t"), nPos);
- CString strName = strLine.Tokenize(_T(" \t"), nPos);
-
- if(!strIn.IsEmpty() && !strOut.IsEmpty())
- {
- CClip NewClip;
- NewClip.SetIn(strIn);
- NewClip.SetOut(strOut);
- NewClip.SetName(strName);
-
- InsertClip(NULL, NewClip);
- }
- }
-
- EditListFile.Close();
- }
- else
- m_bFileOpen = false;
-
- if(m_NameList.GetCount() == 0)
- {
- CStdioFile NameFile;
- CString str;
- if(NameFile.Open(_T("EditListNames.txt"), CFile::modeRead))
- {
- while(NameFile.ReadString(str))
- {
- m_NameList.Add(str);
- }
- NameFile.Close();
- }
- }
+ CString strLine;
+ CStdioFile EditListFile;
+
+ CloseFile();
+ m_strFileName.Format(_T("%s.edl"), lpFileName);
+
+ if (EditListFile.Open (m_strFileName, CFile::modeRead))
+ {
+ m_bFileOpen = true;
+ while (EditListFile.ReadString(strLine))
+ {
+ int nPos = 0;
+ CString strIn = strLine.Tokenize(_T(" \t"), nPos);
+ CString strOut = strLine.Tokenize(_T(" \t"), nPos);
+ CString strName = strLine.Tokenize(_T(" \t"), nPos);
+
+ if (!strIn.IsEmpty() && !strOut.IsEmpty())
+ {
+ CClip NewClip;
+ NewClip.SetIn (strIn);
+ NewClip.SetOut (strOut);
+ NewClip.SetName(strName);
+
+ InsertClip (NULL, NewClip);
+ }
+ }
+
+ EditListFile.Close();
+ }
+ else
+ m_bFileOpen = false;
+
+ if (m_NameList.GetCount() == 0)
+ {
+ CStdioFile NameFile;
+ CString str;
+ if (NameFile.Open (_T("EditListNames.txt"), CFile::modeRead))
+ {
+ while(NameFile.ReadString(str))
+ {
+ m_NameList.Add(str);
+ }
+ NameFile.Close();
+ }
+ }
}
-void CEditListEditor::SetIn(REFERENCE_TIME rtIn)
+void CEditListEditor::SetIn (REFERENCE_TIME rtIn)
{
- if(m_CurPos != NULL)
- {
- CClip& CurClip = m_EditList.GetAt(m_CurPos);
+ if (m_CurPos != NULL)
+ {
+ CClip& CurClip = m_EditList.GetAt (m_CurPos);
- CurClip.SetIn(rtIn);
- m_list.Invalidate();
- }
+ CurClip.SetIn (rtIn);
+ m_list.Invalidate();
+ }
}
void CEditListEditor::SetOut(REFERENCE_TIME rtOut)
{
- if(m_CurPos != NULL)
- {
- CClip& CurClip = m_EditList.GetAt(m_CurPos);
+ if (m_CurPos != NULL)
+ {
+ CClip& CurClip = m_EditList.GetAt (m_CurPos);
- CurClip.SetOut(rtOut);
- m_list.Invalidate();
- }
+ CurClip.SetOut (rtOut);
+ m_list.Invalidate();
+ }
}
void CEditListEditor::NewClip(REFERENCE_TIME rtVal)
{
- CClip NewClip;
-
- if(m_CurPos != NULL)
- {
- CClip& CurClip = m_EditList.GetAt(m_CurPos);
-
- if(CurClip.HaveIn())
- {
- if(!CurClip.HaveOut())
- CurClip.SetOut(rtVal);
- }
- }
- m_CurPos = InsertClip(m_CurPos, NewClip);
- m_list.Invalidate();
+ CClip NewClip;
+
+ if (m_CurPos != NULL)
+ {
+ CClip& CurClip = m_EditList.GetAt (m_CurPos);
+
+ if (CurClip.HaveIn())
+ {
+ if (!CurClip.HaveOut())
+ CurClip.SetOut (rtVal);
+ }
+ }
+ m_CurPos = InsertClip (m_CurPos, NewClip);
+ m_list.Invalidate();
}
int CEditListEditor::FindIndex(POSITION pos)
{
- int iItem = 0;
- POSITION CurPos = m_EditList.GetHeadPosition();
- while(CurPos && CurPos != pos)
- {
- m_EditList.GetNext(CurPos);
- iItem++;
- }
- return iItem;
+ int iItem = 0;
+ POSITION CurPos = m_EditList.GetHeadPosition();
+ while (CurPos && CurPos != pos)
+ {
+ m_EditList.GetNext (CurPos);
+ iItem++;
+ }
+ return iItem;
}
POSITION CEditListEditor::InsertClip(POSITION pos, CClip& NewClip)
{
- LVITEM lv;
- POSITION NewClipPos;
-
- if(pos == NULL)
- NewClipPos = m_EditList.AddTail(NewClip);
- else
- NewClipPos = m_EditList.InsertAfter(pos, NewClip);
-
- lv.mask = LVIF_STATE | LVIF_TEXT;
- lv.iItem = FindIndex(pos);
- lv.iSubItem = 0;
- lv.pszText = _T("");
- lv.state = m_list.GetItemCount() == 0 ? LVIS_SELECTED : 0;
- m_list.InsertItem(&lv);
-
- return NewClipPos;
+ LVITEM lv;
+ POSITION NewClipPos;
+
+ if (pos == NULL)
+ NewClipPos = m_EditList.AddTail (NewClip);
+ else
+ NewClipPos = m_EditList.InsertAfter (pos, NewClip);
+
+ lv.mask = LVIF_STATE | LVIF_TEXT;
+ lv.iItem = FindIndex (pos);
+ lv.iSubItem = 0;
+ lv.pszText = _T("");
+ lv.state = m_list.GetItemCount()==0 ? LVIS_SELECTED : 0;
+ m_list.InsertItem(&lv);
+
+ return NewClipPos;
}
void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_EDITLIST) return;
-
- int nItem = lpDrawItemStruct->itemID;
- CRect rcItem = lpDrawItemStruct->rcItem;
- POSITION pos = m_EditList.FindIndex(nItem);
-
- if(pos != NULL)
- {
- bool fSelected = (pos == m_CurPos);
- CClip& CurClip = m_EditList.GetAt(pos);
- CString strTemp;
-
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
- {
- FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
- FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- }
- else
- {
- FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
- }
-
- COLORREF textcolor = RGB(0, 0, 0);
- if(!CurClip.HaveIn() || !CurClip.HaveOut()) textcolor = RGB(255, 0, 0);
-
- for(int i = 0; i < COL_MAX; i++)
- {
- m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem);
- pDC->SetTextColor(textcolor);
- switch(i)
- {
- case COL_INDEX :
- strTemp.Format(_T("%d"), nItem + 1);
- pDC->DrawText(strTemp, rcItem, DT_CENTER | DT_VCENTER);
- break;
- case COL_IN :
- pDC->DrawText(CurClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER);
- break;
- case COL_OUT :
- pDC->DrawText(CurClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER);
- break;
- case COL_NAME :
- pDC->DrawText(CurClip.GetName(), rcItem, DT_LEFT | DT_VCENTER);
- break;
- }
- }
- }
+ if(nIDCtl != IDC_EDITLIST) return;
+
+ int nItem = lpDrawItemStruct->itemID;
+ CRect rcItem = lpDrawItemStruct->rcItem;
+ POSITION pos = m_EditList.FindIndex(nItem);
+
+ if (pos != NULL)
+ {
+ bool fSelected = (pos == m_CurPos);
+ CClip& CurClip = m_EditList.GetAt(pos);
+ CString strTemp;
+
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
+ {
+ FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
+ FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
+ }
+ else
+ {
+ FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
+ }
+
+ COLORREF textcolor = RGB(0,0,0);
+ if(!CurClip.HaveIn() || !CurClip.HaveOut()) textcolor = RGB(255,0,0);
+
+ for (int i=0; i<COL_MAX; i++)
+ {
+ m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem);
+ pDC->SetTextColor(textcolor);
+ switch (i)
+ {
+ case COL_INDEX :
+ strTemp.Format (_T("%d"), nItem+1);
+ pDC->DrawText (strTemp, rcItem, DT_CENTER | DT_VCENTER);
+ break;
+ case COL_IN :
+ pDC->DrawText (CurClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER);
+ break;
+ case COL_OUT :
+ pDC->DrawText (CurClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER);
+ break;
+ case COL_NAME :
+ pDC->DrawText (CurClip.GetName(), rcItem, DT_LEFT | DT_VCENTER);
+ break;
+ }
+ }
+ }
}
void CEditListEditor::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- if(pNMLV->iItem >= 0)
- {
- m_CurPos = m_EditList.FindIndex(pNMLV->iItem);
- }
+ if(pNMLV->iItem >= 0)
+ {
+ m_CurPos = m_EditList.FindIndex (pNMLV->iItem);
+ }
}
-void CEditListEditor::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
-{
- LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
-
- *pResult = FALSE;
-
- if(pLVKeyDown->wVKey == VK_DELETE)
- {
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- POSITION ClipPos;
- int nItem = -1;
- while(pos)
- {
- nItem = m_list.GetNextSelectedItem(pos);
- ClipPos = m_EditList.FindIndex(nItem);
- if(ClipPos)
- {
- m_EditList.RemoveAt(ClipPos);
- }
- m_list.DeleteItem(nItem);
- }
- if(nItem != -1)
- m_list.SetItemState(min(nItem, m_list.GetItemCount() - 1), LVIS_SELECTED, LVIS_SELECTED);
- m_list.Invalidate();
- }
+void CEditListEditor::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
+
+ *pResult = FALSE;
+
+ if(pLVKeyDown->wVKey == VK_DELETE)
+ {
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ POSITION ClipPos;
+ int nItem = -1;
+ while(pos)
+ {
+ nItem = m_list.GetNextSelectedItem(pos);
+ ClipPos = m_EditList.FindIndex (nItem);
+ if (ClipPos)
+ {
+ m_EditList.RemoveAt (ClipPos);
+ }
+ m_list.DeleteItem (nItem);
+ }
+ if (nItem != -1)
+ m_list.SetItemState (min (nItem, m_list.GetItemCount()-1), LVIS_SELECTED, LVIS_SELECTED);
+ m_list.Invalidate();
+ }
}
void CEditListEditor::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
{
- ModifyStyle(WS_EX_ACCEPTFILES, 0);
+ ModifyStyle(WS_EX_ACCEPTFILES, 0);
- m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
+ m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
- CPoint p(0, 0);
- m_pDragImage = m_list.CreateDragImageEx(&p);
+ CPoint p(0, 0);
+ m_pDragImage = m_list.CreateDragImageEx(&p);
- CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
+ CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
- m_pDragImage->BeginDrag(0, p2 - p);
- m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
+ m_pDragImage->BeginDrag(0, p2 - p);
+ m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
- m_bDragging = TRUE;
- m_nDropIndex = -1;
+ m_bDragging = TRUE;
+ m_nDropIndex = -1;
- SetCapture();
+ SetCapture();
}
void CEditListEditor::OnMouseMove(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
- m_ptDropPoint = point;
- ClientToScreen(&m_ptDropPoint);
-
- m_pDragImage->DragMove(m_ptDropPoint);
- m_pDragImage->DragShowNolock(FALSE);
-
- WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
-
- m_pDragImage->DragShowNolock(TRUE);
-
- {
- int iOverItem = m_list.HitTest(m_ptDropPoint);
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = m_list.GetBottomIndex();
-
- if(iOverItem == iTopItem && iTopItem != 0) // top of list
- SetTimer(1, 100, NULL);
- else
- KillTimer(1);
-
- if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) // bottom of list
- SetTimer(2, 100, NULL);
- else
- KillTimer(2);
- }
- }
-
- __super::OnMouseMove(nFlags, point);
+ if(m_bDragging)
+ {
+ m_ptDropPoint = point;
+ ClientToScreen(&m_ptDropPoint);
+
+ m_pDragImage->DragMove(m_ptDropPoint);
+ m_pDragImage->DragShowNolock(FALSE);
+
+ WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
+
+ m_pDragImage->DragShowNolock(TRUE);
+
+ {
+ int iOverItem = m_list.HitTest(m_ptDropPoint);
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = m_list.GetBottomIndex();
+
+ if(iOverItem == iTopItem && iTopItem != 0) // top of list
+ SetTimer(1, 100, NULL);
+ else
+ KillTimer(1);
+
+ if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) // bottom of list
+ SetTimer(2, 100, NULL);
+ else
+ KillTimer(2);
+ }
+ }
+
+ __super::OnMouseMove(nFlags, point);
}
void CEditListEditor::OnTimer(UINT_PTR nIDEvent)
{
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
-
- if(m_bDragging)
- {
- m_pDragImage->DragShowNolock(FALSE);
-
- if(nIDEvent == 1)
- {
- m_list.EnsureVisible(iTopItem - 1, false);
- m_list.UpdateWindow();
- if(m_list.GetTopIndex() == 0) KillTimer(1);
- }
- else if(nIDEvent == 2)
- {
- m_list.EnsureVisible(iBottomItem + 1, false);
- m_list.UpdateWindow();
- if(m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) KillTimer(2);
- }
-
- m_pDragImage->DragShowNolock(TRUE);
- }
-
- __super::OnTimer(nIDEvent);
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
+
+ if(m_bDragging)
+ {
+ m_pDragImage->DragShowNolock(FALSE);
+
+ if(nIDEvent == 1)
+ {
+ m_list.EnsureVisible(iTopItem - 1, false);
+ m_list.UpdateWindow();
+ if(m_list.GetTopIndex() == 0) KillTimer(1);
+ }
+ else if(nIDEvent == 2)
+ {
+ m_list.EnsureVisible(iBottomItem + 1, false);
+ m_list.UpdateWindow();
+ if(m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) KillTimer(2);
+ }
+
+ m_pDragImage->DragShowNolock(TRUE);
+ }
+
+ __super::OnTimer(nIDEvent);
}
void CEditListEditor::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
- ::ReleaseCapture();
+ if(m_bDragging)
+ {
+ ::ReleaseCapture();
- m_bDragging = FALSE;
- m_pDragImage->DragLeave(GetDesktopWindow());
- m_pDragImage->EndDrag();
+ m_bDragging = FALSE;
+ m_pDragImage->DragLeave(GetDesktopWindow());
+ m_pDragImage->EndDrag();
- delete m_pDragImage;
- m_pDragImage = NULL;
+ delete m_pDragImage;
+ m_pDragImage = NULL;
- KillTimer(1);
- KillTimer(2);
+ KillTimer(1);
+ KillTimer(2);
- CPoint pt(point);
- ClientToScreen(&pt);
+ CPoint pt(point);
+ ClientToScreen(&pt);
- if(WindowFromPoint(pt) == &m_list)
- DropItemOnList();
- }
+ if(WindowFromPoint(pt) == &m_list)
+ DropItemOnList();
+ }
- ModifyStyle(0, WS_EX_ACCEPTFILES);
+ ModifyStyle(0, WS_EX_ACCEPTFILES);
- __super::OnLButtonUp(nFlags, point);
+ __super::OnLButtonUp(nFlags, point);
}
void CEditListEditor::DropItemOnList()
{
- m_ptDropPoint.y -= 10; //
- m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
-
- POSITION DragPos = m_EditList.FindIndex(m_nDragIndex);
- POSITION DropPos = m_EditList.FindIndex(m_nDropIndex);
- if((DragPos != NULL) && (DropPos != NULL))
- {
- CClip& DragClip = m_EditList.GetAt(DragPos);
- m_EditList.InsertAfter(DropPos, DragClip);
- m_EditList.RemoveAt(DragPos);
- m_list.Invalidate();
- }
+ m_ptDropPoint.y -= 10; //
+ m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
+
+ POSITION DragPos = m_EditList.FindIndex (m_nDragIndex);
+ POSITION DropPos = m_EditList.FindIndex (m_nDropIndex);
+ if ((DragPos!=NULL) && (DropPos!=NULL))
+ {
+ CClip& DragClip = m_EditList.GetAt(DragPos);
+ m_EditList.InsertAfter (DropPos, DragClip);
+ m_EditList.RemoveAt (DragPos);
+ m_list.Invalidate();
+ }
}
-void CEditListEditor::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CEditListEditor::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if(pItem->iItem < 0)
- return;
+ if(pItem->iItem < 0)
+ return;
- if(pItem->iSubItem == COL_NAME)
- {
- *pResult = TRUE;
- }
+ if(pItem->iSubItem == COL_NAME)
+ {
+ *pResult = TRUE;
+ }
}
void CEditListEditor::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if(pItem->iItem < 0)
- return;
+ if(pItem->iItem < 0)
+ return;
- if(m_CurPos != NULL && pItem->iSubItem == COL_NAME)
- {
- CClip& CurClip = m_EditList.GetAt(m_CurPos);
- int nSel = FindNameIndex(CurClip.GetName());
+ if (m_CurPos != NULL && pItem->iSubItem == COL_NAME)
+ {
+ CClip& CurClip = m_EditList.GetAt (m_CurPos);
+ int nSel = FindNameIndex (CurClip.GetName());
- CAtlList<CString> sl;
- for(int i = 0; i < m_NameList.GetCount(); i++)
- sl.AddTail(m_NameList.GetAt(i));
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel, true);
+ CAtlList<CString> sl;
+ for (int i=0; i<m_NameList.GetCount(); i++)
+ sl.AddTail(m_NameList.GetAt(i));
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel, true);
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
void CEditListEditor::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if(!m_list.m_fInPlaceDirty)
- return;
+ if(!m_list.m_fInPlaceDirty)
+ return;
- if(pItem->iItem < 0)
- return;
+ if(pItem->iItem < 0)
+ return;
- CString& CurName = m_NameList.GetAt(pItem->lParam);
+ CString& CurName = m_NameList.GetAt(pItem->lParam);
- if(m_CurPos != NULL && pItem->iSubItem == COL_NAME)
- {
- CClip& CurClip = m_EditList.GetAt(m_CurPos);
- CurClip.SetName(CurName);
+ if(m_CurPos != NULL && pItem->iSubItem == COL_NAME)
+ {
+ CClip& CurClip = m_EditList.GetAt (m_CurPos);
+ CurClip.SetName(CurName);
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
int CEditListEditor::FindNameIndex(LPCTSTR strName)
{
- int nResult = -1;
+ int nResult = -1;
- for(int i = 0; i < m_NameList.GetCount(); i++)
- {
- CString& CurName = m_NameList.GetAt(i);
+ for(int i = 0; i<m_NameList.GetCount(); i++)
+ {
+ CString& CurName = m_NameList.GetAt(i);
- if(CurName == strName)
- {
- nResult = i;
- break;
- }
- }
+ if (CurName == strName)
+ {
+ nResult = i;
+ break;
+ }
+ }
- return nResult;
+ return nResult;
} \ No newline at end of file
diff --git a/src/apps/mplayerc/EditListEditor.h b/src/apps/mplayerc/EditListEditor.h
index ddf68ca99..644718020 100644
--- a/src/apps/mplayerc/EditListEditor.h
+++ b/src/apps/mplayerc/EditListEditor.h
@@ -28,90 +28,78 @@
class CClip
{
private :
- REFERENCE_TIME m_rtIn;
- REFERENCE_TIME m_rtOut;
- CString m_strName;
+ REFERENCE_TIME m_rtIn;
+ REFERENCE_TIME m_rtOut;
+ CString m_strName;
public :
- CClip();
-
- bool HaveIn()
- {
- return m_rtIn != _I64_MIN;
- };
- bool HaveOut()
- {
- return m_rtOut != _I64_MIN;
- };
-
- void SetOut(LPCTSTR strVal);
- void SetIn(LPCTSTR strVal);
- void SetIn(REFERENCE_TIME rtVal);
- void SetOut(REFERENCE_TIME rtVal);
- void SetName(LPCTSTR strName)
- {
- m_strName = strName;
- };
-
- CString GetIn();
- CString GetOut();
- CString GetName() const
- {
- return m_strName;
- };
+ CClip();
+
+ bool HaveIn() { return m_rtIn != _I64_MIN; };
+ bool HaveOut() { return m_rtOut != _I64_MIN; };
+
+ void SetOut (LPCTSTR strVal);
+ void SetIn (LPCTSTR strVal);
+ void SetIn (REFERENCE_TIME rtVal);
+ void SetOut (REFERENCE_TIME rtVal);
+ void SetName(LPCTSTR strName) { m_strName = strName; };
+
+ CString GetIn();
+ CString GetOut();
+ CString GetName() const { return m_strName; };
};
class CEditListEditor : public CSizingControlBarG
{
- DECLARE_DYNAMIC(CEditListEditor)
-
- enum {COL_INDEX, COL_IN, COL_OUT, COL_NAME, COL_MAX};
-
- CPlayerListCtrl m_list;
- CImageList m_fakeImageList;
- POSITION m_CurPos;
- BOOL m_bDragging;
- int m_nDragIndex;
- int m_nDropIndex;
- CPoint m_ptDropPoint;
- CImageList* m_pDragImage;
-
- CString m_strFileName;
- bool m_bFileOpen;
- CList<CClip> m_EditList;
- CArray<CString> m_NameList;
-
- void SaveEditListToFile();
- void ResizeListColumn();
- POSITION InsertClip(POSITION pos, CClip& NewClip);
- void DropItemOnList();
- int FindIndex(POSITION pos);
- int FindNameIndex(LPCTSTR strName);
+ DECLARE_DYNAMIC(CEditListEditor)
+
+ enum {COL_INDEX, COL_IN, COL_OUT, COL_NAME, COL_MAX};
+
+ CPlayerListCtrl m_list;
+ CImageList m_fakeImageList;
+ POSITION m_CurPos;
+ BOOL m_bDragging;
+ int m_nDragIndex;
+ int m_nDropIndex;
+ CPoint m_ptDropPoint;
+ CImageList* m_pDragImage;
+
+ CString m_strFileName;
+ bool m_bFileOpen;
+ CList<CClip> m_EditList;
+ CArray<CString> m_NameList;
+
+ void SaveEditListToFile();
+ void ResizeListColumn();
+ POSITION InsertClip(POSITION pos, CClip& NewClip);
+ void DropItemOnList();
+ int FindIndex(POSITION pos);
+ int FindNameIndex(LPCTSTR strName);
protected :
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CEditListEditor(void);
- ~CEditListEditor(void);
-
- BOOL Create(CWnd* pParentWnd);
-
- void CloseFile();
- void OpenFile(LPCTSTR lpFileName);
- void SetIn(REFERENCE_TIME rtIn);
- void SetOut(REFERENCE_TIME rtOut);
- void NewClip(REFERENCE_TIME rtVal);
-
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg void OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ CEditListEditor(void);
+ ~CEditListEditor(void);
+
+ BOOL Create(CWnd* pParentWnd);
+
+ void CloseFile();
+ void OpenFile(LPCTSTR lpFileName);
+ void SetIn (REFERENCE_TIME rtIn);
+ void SetOut (REFERENCE_TIME rtOut);
+ void NewClip (REFERENCE_TIME rtVal);
+
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg void OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/apps/mplayerc/FGFilter.cpp b/src/apps/mplayerc/FGFilter.cpp
index 969e6f5de..6955e30ec 100644
--- a/src/apps/mplayerc/FGFilter.cpp
+++ b/src/apps/mplayerc/FGFilter.cpp
@@ -35,395 +35,380 @@
//
CFGFilter::CFGFilter(const CLSID& clsid, CStringW name, UINT64 merit)
- : m_clsid(clsid)
- , m_name(name)
+ : m_clsid(clsid)
+ , m_name(name)
{
- m_merit.val = merit;
+ m_merit.val = merit;
}
const CAtlList<GUID>& CFGFilter::GetTypes() const
{
- return m_types;
+ return m_types;
}
void CFGFilter::SetTypes(const CAtlList<GUID>& types)
{
- m_types.RemoveAll();
- m_types.AddTailList(&types);
+ m_types.RemoveAll();
+ m_types.AddTailList(&types);
}
void CFGFilter::AddType(const GUID& majortype, const GUID& subtype)
{
- m_types.AddTail(majortype);
- m_types.AddTail(subtype);
+ m_types.AddTail(majortype);
+ m_types.AddTail(subtype);
}
bool CFGFilter::CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch)
{
- POSITION pos = m_types.GetHeadPosition();
- while(pos)
- {
- const GUID& majortype = m_types.GetNext(pos);
- if(!pos)
- {
- ASSERT(0);
- break;
- }
- const GUID& subtype = m_types.GetNext(pos);
-
- for(int i = 0, len = types.GetCount() & ~1; i < len; i += 2)
- {
- if(fExactMatch)
- {
- if(majortype == types[i] && majortype != GUID_NULL
- && subtype == types[i+1] && subtype != GUID_NULL)
- return true;
- }
- else
- {
- if((majortype == GUID_NULL || types[i] == GUID_NULL || majortype == types[i])
- && (subtype == GUID_NULL || types[i+1] == GUID_NULL || subtype == types[i+1]))
- return true;
- }
- }
- }
-
- return false;
+ POSITION pos = m_types.GetHeadPosition();
+ while(pos)
+ {
+ const GUID& majortype = m_types.GetNext(pos);
+ if(!pos) {ASSERT(0); break;}
+ const GUID& subtype = m_types.GetNext(pos);
+
+ for(int i = 0, len = types.GetCount() & ~1; i < len; i += 2)
+ {
+ if(fExactMatch)
+ {
+ if(majortype == types[i] && majortype != GUID_NULL
+ && subtype == types[i+1] && subtype != GUID_NULL)
+ return true;
+ }
+ else
+ {
+ if((majortype == GUID_NULL || types[i] == GUID_NULL || majortype == types[i])
+ && (subtype == GUID_NULL || types[i+1] == GUID_NULL || subtype == types[i+1]))
+ return true;
+ }
+ }
+ }
+
+ return false;
}
//
// CFGFilterRegistry
//
-CFGFilterRegistry::CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit)
- : CFGFilter(GUID_NULL, L"", merit)
- , m_pMoniker(pMoniker)
+CFGFilterRegistry::CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit)
+ : CFGFilter(GUID_NULL, L"", merit)
+ , m_pMoniker(pMoniker)
{
- if(!m_pMoniker) return;
-
- LPOLESTR str = NULL;
- if(FAILED(m_pMoniker->GetDisplayName(0, 0, &str))) return;
- m_DisplayName = m_name = str;
- CoTaskMemFree(str), str = NULL;
-
- CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
- {
- CComVariant var;
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- {
- m_name = var.bstrVal;
- var.Clear();
- }
-
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL)))
- {
- CLSIDFromString(var.bstrVal, &m_clsid);
- var.Clear();
- }
-
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL)))
- {
- BSTR* pstr;
- if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr)))
- {
- ExtractFilterData((BYTE*)pstr, var.parray->cbElements*(var.parray->rgsabound[0].cElements));
- SafeArrayUnaccessData(var.parray);
- }
-
- var.Clear();
- }
- }
-
- if(merit != MERIT64_DO_USE) m_merit.val = merit;
+ if(!m_pMoniker) return;
+
+ LPOLESTR str = NULL;
+ if(FAILED(m_pMoniker->GetDisplayName(0, 0, &str))) return;
+ m_DisplayName = m_name = str;
+ CoTaskMemFree(str), str = NULL;
+
+ CComPtr<IPropertyBag> pPB;
+ if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
+ {
+ CComVariant var;
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ {
+ m_name = var.bstrVal;
+ var.Clear();
+ }
+
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL)))
+ {
+ CLSIDFromString(var.bstrVal, &m_clsid);
+ var.Clear();
+ }
+
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL)))
+ {
+ BSTR* pstr;
+ if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr)))
+ {
+ ExtractFilterData((BYTE*)pstr, var.parray->cbElements*(var.parray->rgsabound[0].cElements));
+ SafeArrayUnaccessData(var.parray);
+ }
+
+ var.Clear();
+ }
+ }
+
+ if(merit != MERIT64_DO_USE) m_merit.val = merit;
}
-CFGFilterRegistry::CFGFilterRegistry(CStringW DisplayName, UINT64 merit)
- : CFGFilter(GUID_NULL, L"", merit)
- , m_DisplayName(DisplayName)
+CFGFilterRegistry::CFGFilterRegistry(CStringW DisplayName, UINT64 merit)
+ : CFGFilter(GUID_NULL, L"", merit)
+ , m_DisplayName(DisplayName)
{
- if(m_DisplayName.IsEmpty()) return;
-
- CComPtr<IBindCtx> pBC;
- CreateBindCtx(0, &pBC);
-
- ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBC, CComBSTR(m_DisplayName), &chEaten, &m_pMoniker))
- return;
-
- CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
- {
- CComVariant var;
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- {
- m_name = var.bstrVal;
- var.Clear();
- }
-
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL)))
- {
- CLSIDFromString(var.bstrVal, &m_clsid);
- var.Clear();
- }
-
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL)))
- {
- BSTR* pstr;
- if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr)))
- {
- ExtractFilterData((BYTE*)pstr, var.parray->cbElements*(var.parray->rgsabound[0].cElements));
- SafeArrayUnaccessData(var.parray);
- }
-
- var.Clear();
- }
- }
-
- if(merit != MERIT64_DO_USE) m_merit.val = merit;
+ if(m_DisplayName.IsEmpty()) return;
+
+ CComPtr<IBindCtx> pBC;
+ CreateBindCtx(0, &pBC);
+
+ ULONG chEaten;
+ if(S_OK != MkParseDisplayName(pBC, CComBSTR(m_DisplayName), &chEaten, &m_pMoniker))
+ return;
+
+ CComPtr<IPropertyBag> pPB;
+ if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
+ {
+ CComVariant var;
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ {
+ m_name = var.bstrVal;
+ var.Clear();
+ }
+
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL)))
+ {
+ CLSIDFromString(var.bstrVal, &m_clsid);
+ var.Clear();
+ }
+
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL)))
+ {
+ BSTR* pstr;
+ if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr)))
+ {
+ ExtractFilterData((BYTE*)pstr, var.parray->cbElements*(var.parray->rgsabound[0].cElements));
+ SafeArrayUnaccessData(var.parray);
+ }
+
+ var.Clear();
+ }
+ }
+
+ if(merit != MERIT64_DO_USE) m_merit.val = merit;
}
-CFGFilterRegistry::CFGFilterRegistry(const CLSID& clsid, UINT64 merit)
- : CFGFilter(clsid, L"", merit)
+CFGFilterRegistry::CFGFilterRegistry(const CLSID& clsid, UINT64 merit)
+ : CFGFilter(clsid, L"", merit)
{
- if(m_clsid == GUID_NULL) return;
-
- CString guid = CStringFromGUID(m_clsid);
-
- CRegKey key;
-
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + guid, KEY_READ))
- {
- ULONG nChars = 0;
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, NULL, &nChars))
- {
- CString name;
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, name.GetBuffer(nChars), &nChars))
- {
- name.ReleaseBuffer(nChars);
- m_name = name;
- }
- }
-
- key.Close();
- }
-
- CRegKey catkey;
-
- if(ERROR_SUCCESS == catkey.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance"), KEY_READ))
- {
- if(ERROR_SUCCESS != key.Open(catkey, guid, KEY_READ))
- {
- // illiminable pack uses the name of the filter and not the clsid, have to enum all keys to find it...
-
- FILETIME ft;
- TCHAR buff[256];
- DWORD len = countof(buff);
- for(DWORD i = 0; ERROR_SUCCESS == catkey.EnumKey(i, buff, &len, &ft); i++, len = countof(buff))
- {
- if(ERROR_SUCCESS == key.Open(catkey, buff, KEY_READ))
- {
- TCHAR clsid[256];
- len = countof(clsid);
- if(ERROR_SUCCESS == key.QueryStringValue(_T("CLSID"), clsid, &len) && GUIDFromCString(clsid) == m_clsid)
- break;
-
- key.Close();
- }
- }
- }
-
- if(key)
- {
- ULONG nChars = 0;
- if(ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), NULL, &nChars))
- {
- CString name;
- if(ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), name.GetBuffer(nChars), &nChars))
- {
- name.ReleaseBuffer(nChars);
- m_name = name;
- }
- }
-
- ULONG nBytes = 0;
- if(ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), NULL, &nBytes))
- {
- CAutoVectorPtr<BYTE> buff;
- if(buff.Allocate(nBytes) && ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), buff, &nBytes))
- {
- ExtractFilterData(buff, nBytes);
- }
- }
-
- key.Close();
- }
- }
-
- if(merit != MERIT64_DO_USE) m_merit.val = merit;
+ if(m_clsid == GUID_NULL) return;
+
+ CString guid = CStringFromGUID(m_clsid);
+
+ CRegKey key;
+
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + guid, KEY_READ))
+ {
+ ULONG nChars = 0;
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, NULL, &nChars))
+ {
+ CString name;
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, name.GetBuffer(nChars), &nChars))
+ {
+ name.ReleaseBuffer(nChars);
+ m_name = name;
+ }
+ }
+
+ key.Close();
+ }
+
+ CRegKey catkey;
+
+ if(ERROR_SUCCESS == catkey.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance"), KEY_READ))
+ {
+ if(ERROR_SUCCESS != key.Open(catkey, guid, KEY_READ))
+ {
+ // illiminable pack uses the name of the filter and not the clsid, have to enum all keys to find it...
+
+ FILETIME ft;
+ TCHAR buff[256];
+ DWORD len = countof(buff);
+ for(DWORD i = 0; ERROR_SUCCESS == catkey.EnumKey(i, buff, &len, &ft); i++, len = countof(buff))
+ {
+ if(ERROR_SUCCESS == key.Open(catkey, buff, KEY_READ))
+ {
+ TCHAR clsid[256];
+ len = countof(clsid);
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("CLSID"), clsid, &len) && GUIDFromCString(clsid) == m_clsid)
+ break;
+
+ key.Close();
+ }
+ }
+ }
+
+ if(key)
+ {
+ ULONG nChars = 0;
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), NULL, &nChars))
+ {
+ CString name;
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), name.GetBuffer(nChars), &nChars))
+ {
+ name.ReleaseBuffer(nChars);
+ m_name = name;
+ }
+ }
+
+ ULONG nBytes = 0;
+ if(ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), NULL, &nBytes))
+ {
+ CAutoVectorPtr<BYTE> buff;
+ if(buff.Allocate(nBytes) && ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), buff, &nBytes))
+ {
+ ExtractFilterData(buff, nBytes);
+ }
+ }
+
+ key.Close();
+ }
+ }
+
+ if(merit != MERIT64_DO_USE) m_merit.val = merit;
}
HRESULT CFGFilterRegistry::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- CheckPointer(ppBF, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- if(m_pMoniker)
- {
- if(SUCCEEDED(hr = m_pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)ppBF)))
- {
- m_clsid = ::GetCLSID(*ppBF);
- }
- }
- else if(m_clsid != GUID_NULL)
- {
- CComQIPtr<IBaseFilter> pBF;
-
- if(FAILED(pBF.CoCreateInstance(m_clsid)))
- return E_FAIL;
-
- *ppBF = pBF.Detach();
-
- hr = S_OK;
- }
-
- return hr;
+ CheckPointer(ppBF, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ if(m_pMoniker)
+ {
+ if(SUCCEEDED(hr = m_pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)ppBF)))
+ {
+ m_clsid = ::GetCLSID(*ppBF);
+ }
+ }
+ else if(m_clsid != GUID_NULL)
+ {
+ CComQIPtr<IBaseFilter> pBF;
+
+ if(FAILED(pBF.CoCreateInstance(m_clsid)))
+ return E_FAIL;
+
+ *ppBF = pBF.Detach();
+
+ hr = S_OK;
+ }
+
+ return hr;
};
[uuid("97f7c4d4-547b-4a5f-8332-536430ad2e4d")]
-interface IAMFilterData :
-public IUnknown
+interface IAMFilterData : public IUnknown
{
- STDMETHOD(ParseFilterData)(BYTE* rgbFilterData, ULONG cb, BYTE** prgbRegFilter2) PURE;
- STDMETHOD(CreateFilterData)(REGFILTER2* prf2, BYTE** prgbFilterData, ULONG* pcb) PURE;
+ STDMETHOD (ParseFilterData) (BYTE* rgbFilterData, ULONG cb, BYTE** prgbRegFilter2) PURE;
+ STDMETHOD (CreateFilterData) (REGFILTER2* prf2, BYTE** prgbFilterData, ULONG* pcb) PURE;
};
void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
{
- CComPtr<IAMFilterData> pFD;
- BYTE* ptr = NULL;
-
- if(SUCCEEDED(pFD.CoCreateInstance(CLSID_FilterMapper2))
- && SUCCEEDED(pFD->ParseFilterData(p, len, (BYTE**)&ptr)))
- {
- REGFILTER2* prf = (REGFILTER2*) * (WPARAM*)ptr; // this is f*cked up
-
- m_merit.mid = prf->dwMerit;
-
- if(prf->dwVersion == 1)
- {
- for(UINT i = 0; i < prf->cPins; i++)
- {
- if(prf->rgPins[i].bOutput)
- continue;
-
- for(UINT j = 0; j < prf->rgPins[i].nMediaTypes; j++)
- {
- if(!prf->rgPins[i].lpMediaType[j].clsMajorType || !prf->rgPins[i].lpMediaType[j].clsMinorType)
- break;
-
- const REGPINTYPES& rpt = prf->rgPins[i].lpMediaType[j];
- AddType(*rpt.clsMajorType, *rpt.clsMinorType);
- }
- }
- }
- else if(prf->dwVersion == 2)
- {
- for(UINT i = 0; i < prf->cPins2; i++)
- {
- if(prf->rgPins2[i].dwFlags & REG_PINFLAG_B_OUTPUT)
- continue;
-
- for(UINT j = 0; j < prf->rgPins2[i].nMediaTypes; j++)
- {
- if(!prf->rgPins2[i].lpMediaType[j].clsMajorType || !prf->rgPins2[i].lpMediaType[j].clsMinorType)
- break;
-
- const REGPINTYPES& rpt = prf->rgPins2[i].lpMediaType[j];
- AddType(*rpt.clsMajorType, *rpt.clsMinorType);
- }
- }
- }
-
- CoTaskMemFree(prf);
- }
- else
- {
- BYTE* base = p;
-
-#define ChkLen(size) if(p - base + size > (int)len) return;
-
- ChkLen(4)
- if(*(DWORD*)p != 0x00000002) return; // only version 2 supported, no samples found for 1
- p += 4;
-
- ChkLen(4)
- m_merit.mid = *(DWORD*)p;
- p += 4;
-
- m_types.RemoveAll();
-
- ChkLen(8)
- DWORD nPins = *(DWORD*)p;
- p += 8;
- while(nPins-- > 0)
- {
- ChkLen(1)
- BYTE n = *p - 0x30;
- p++;
-
- ChkLen(2)
- WORD pi = *(WORD*)p;
- p += 2;
- ASSERT(pi == 'ip');
-
- ChkLen(1)
- BYTE x33 = *p;
- p++;
- ASSERT(x33 == 0x33);
-
- ChkLen(8)
- bool fOutput = !!(*p & REG_PINFLAG_B_OUTPUT);
- p += 8;
-
- ChkLen(12)
- DWORD nTypes = *(DWORD*)p;
- p += 12;
- while(nTypes-- > 0)
- {
- ChkLen(1)
- BYTE n = *p - 0x30;
- p++;
-
- ChkLen(2)
- WORD ty = *(WORD*)p;
- p += 2;
- ASSERT(ty == 'yt');
-
- ChkLen(5)
- BYTE x33 = *p;
- p++;
- ASSERT(x33 == 0x33);
- p += 4;
-
- ChkLen(8)
- if(*(DWORD*)p < (p - base + 8) || *(DWORD*)p >= len
- || *(DWORD*)(p + 4) < (p - base + 8) || *(DWORD*)(p + 4) >= len)
- {
- p += 8;
- continue;
- }
-
- GUID majortype, subtype;
- memcpy(&majortype, &base[*(DWORD*)p], sizeof(GUID));
- p += 4;
- if(!fOutput) AddType(majortype, subtype);
- }
- }
-
-#undef ChkLen
- }
+ CComPtr<IAMFilterData> pFD;
+ BYTE* ptr = NULL;
+
+ if(SUCCEEDED(pFD.CoCreateInstance(CLSID_FilterMapper2))
+ && SUCCEEDED(pFD->ParseFilterData(p, len, (BYTE**)&ptr)))
+ {
+ REGFILTER2* prf = (REGFILTER2*)*(WPARAM*)ptr; // this is f*cked up
+
+ m_merit.mid = prf->dwMerit;
+
+ if(prf->dwVersion == 1)
+ {
+ for(UINT i = 0; i < prf->cPins; i++)
+ {
+ if(prf->rgPins[i].bOutput)
+ continue;
+
+ for(UINT j = 0; j < prf->rgPins[i].nMediaTypes; j++)
+ {
+ if(!prf->rgPins[i].lpMediaType[j].clsMajorType || !prf->rgPins[i].lpMediaType[j].clsMinorType)
+ break;
+
+ const REGPINTYPES& rpt = prf->rgPins[i].lpMediaType[j];
+ AddType(*rpt.clsMajorType, *rpt.clsMinorType);
+ }
+ }
+ }
+ else if(prf->dwVersion == 2)
+ {
+ for(UINT i = 0; i < prf->cPins2; i++)
+ {
+ if(prf->rgPins2[i].dwFlags&REG_PINFLAG_B_OUTPUT)
+ continue;
+
+ for(UINT j = 0; j < prf->rgPins2[i].nMediaTypes; j++)
+ {
+ if(!prf->rgPins2[i].lpMediaType[j].clsMajorType || !prf->rgPins2[i].lpMediaType[j].clsMinorType)
+ break;
+
+ const REGPINTYPES& rpt = prf->rgPins2[i].lpMediaType[j];
+ AddType(*rpt.clsMajorType, *rpt.clsMinorType);
+ }
+ }
+ }
+
+ CoTaskMemFree(prf);
+ }
+ else
+ {
+ BYTE* base = p;
+
+ #define ChkLen(size) if(p - base + size > (int)len) return;
+
+ ChkLen(4)
+ if(*(DWORD*)p != 0x00000002) return; // only version 2 supported, no samples found for 1
+ p += 4;
+
+ ChkLen(4)
+ m_merit.mid = *(DWORD*)p; p += 4;
+
+ m_types.RemoveAll();
+
+ ChkLen(8)
+ DWORD nPins = *(DWORD*)p; p += 8;
+ while(nPins-- > 0)
+ {
+ ChkLen(1)
+ BYTE n = *p-0x30; p++;
+
+ ChkLen(2)
+ WORD pi = *(WORD*)p; p += 2;
+ ASSERT(pi == 'ip');
+
+ ChkLen(1)
+ BYTE x33 = *p; p++;
+ ASSERT(x33 == 0x33);
+
+ ChkLen(8)
+ bool fOutput = !!(*p&REG_PINFLAG_B_OUTPUT);
+ p += 8;
+
+ ChkLen(12)
+ DWORD nTypes = *(DWORD*)p; p += 12;
+ while(nTypes-- > 0)
+ {
+ ChkLen(1)
+ BYTE n = *p-0x30; p++;
+
+ ChkLen(2)
+ WORD ty = *(WORD*)p; p += 2;
+ ASSERT(ty == 'yt');
+
+ ChkLen(5)
+ BYTE x33 = *p; p++;
+ ASSERT(x33 == 0x33);
+ p += 4;
+
+ ChkLen(8)
+ if(*(DWORD*)p < (p-base+8) || *(DWORD*)p >= len
+ || *(DWORD*)(p+4) < (p-base+8) || *(DWORD*)(p+4) >= len)
+ {
+ p += 8;
+ continue;
+ }
+
+ GUID majortype, subtype;
+ memcpy(&majortype, &base[*(DWORD*)p], sizeof(GUID)); p += 4;
+ if(!fOutput) AddType(majortype, subtype);
+ }
+ }
+
+ #undef ChkLen
+ }
}
//
@@ -431,81 +416,81 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
//
CFGFilterFile::CFGFilterFile(const CLSID& clsid, CString path, CStringW name, UINT64 merit)
- : CFGFilter(clsid, name, merit)
- , m_path(path)
- , m_hInst(NULL)
+ : CFGFilter(clsid, name, merit)
+ , m_path(path)
+ , m_hInst(NULL)
{
}
HRESULT CFGFilterFile::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- CheckPointer(ppBF, E_POINTER);
+ CheckPointer(ppBF, E_POINTER);
- return LoadExternalFilter(m_path, m_clsid, ppBF);
+ return LoadExternalFilter(m_path, m_clsid, ppBF);
}
//
// CFGFilterVideoRenderer
//
-CFGFilterVideoRenderer::CFGFilterVideoRenderer(HWND hWnd, const CLSID& clsid, CStringW name, UINT64 merit)
- : CFGFilter(clsid, name, merit)
- , m_hWnd(hWnd)
+CFGFilterVideoRenderer::CFGFilterVideoRenderer(HWND hWnd, const CLSID& clsid, CStringW name, UINT64 merit)
+ : CFGFilter(clsid, name, merit)
+ , m_hWnd(hWnd)
{
- AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
}
HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- TRACE("--> CFGFilterVideoRenderer::Create on thread: %d\n", GetCurrentThreadId());
- CheckPointer(ppBF, E_POINTER);
-
- HRESULT hr = S_OK;
-
- CComPtr<ISubPicAllocatorPresenter> pCAP;
-
- if(m_clsid == CLSID_VMR7AllocatorPresenter
- || m_clsid == CLSID_VMR9AllocatorPresenter
- || m_clsid == CLSID_DXRAllocatorPresenter
- || m_clsid == CLSID_madVRAllocatorPresenter
- || m_clsid == CLSID_EVRAllocatorPresenter
- || m_clsid == CLSID_SyncAllocatorPresenter)
- {
- if(SUCCEEDED(CreateAP7(m_clsid, m_hWnd, &pCAP))
- || SUCCEEDED(CreateAP9(m_clsid, m_hWnd, &pCAP))
- || SUCCEEDED(CreateEVR(m_clsid, m_hWnd, &pCAP))
- || SUCCEEDED(CreateSyncRenderer(m_clsid, m_hWnd, &pCAP)))
- {
- CComPtr<IUnknown> pRenderer;
- if(SUCCEEDED(hr = pCAP->CreateRenderer(&pRenderer)))
- {
- *ppBF = CComQIPtr<IBaseFilter>(pRenderer).Detach();
- pUnks.AddTail(pCAP);
- }
- }
- }
- else
- {
- CComPtr<IBaseFilter> pBF;
- if(SUCCEEDED(pBF.CoCreateInstance(m_clsid)))
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pPin)
- {
- pUnks.AddTail(pMPC);
- break;
- }
- }
- EndEnumPins
-
- *ppBF = pBF.Detach();
- }
- }
-
- if(!*ppBF) hr = E_FAIL;
-
- return hr;
+ TRACE("--> CFGFilterVideoRenderer::Create on thread: %d\n", GetCurrentThreadId());
+ CheckPointer(ppBF, E_POINTER);
+
+ HRESULT hr = S_OK;
+
+ CComPtr<ISubPicAllocatorPresenter> pCAP;
+
+ if(m_clsid == CLSID_VMR7AllocatorPresenter
+ || m_clsid == CLSID_VMR9AllocatorPresenter
+ || m_clsid == CLSID_DXRAllocatorPresenter
+ || m_clsid == CLSID_madVRAllocatorPresenter
+ || m_clsid == CLSID_EVRAllocatorPresenter
+ || m_clsid == CLSID_SyncAllocatorPresenter)
+ {
+ if(SUCCEEDED(CreateAP7(m_clsid, m_hWnd, &pCAP))
+ || SUCCEEDED(CreateAP9(m_clsid, m_hWnd, &pCAP))
+ || SUCCEEDED(CreateEVR(m_clsid, m_hWnd, &pCAP))
+ || SUCCEEDED(CreateSyncRenderer(m_clsid, m_hWnd, &pCAP)))
+ {
+ CComPtr<IUnknown> pRenderer;
+ if(SUCCEEDED(hr = pCAP->CreateRenderer(&pRenderer)))
+ {
+ *ppBF = CComQIPtr<IBaseFilter>(pRenderer).Detach();
+ pUnks.AddTail(pCAP);
+ }
+ }
+ }
+ else
+ {
+ CComPtr<IBaseFilter> pBF;
+ if(SUCCEEDED(pBF.CoCreateInstance(m_clsid)))
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pPin)
+ {
+ pUnks.AddTail(pMPC);
+ break;
+ }
+ }
+ EndEnumPins
+
+ *ppBF = pBF.Detach();
+ }
+ }
+
+ if(!*ppBF) hr = E_FAIL;
+
+ return hr;
}
//
@@ -518,127 +503,127 @@ CFGFilterList::CFGFilterList()
CFGFilterList::~CFGFilterList()
{
- RemoveAll();
+ RemoveAll();
}
void CFGFilterList::RemoveAll()
{
- while(!m_filters.IsEmpty())
- {
- const filter_t& f = m_filters.RemoveHead();
- if(f.autodelete) delete f.pFGF;
- }
+ while(!m_filters.IsEmpty())
+ {
+ const filter_t& f = m_filters.RemoveHead();
+ if(f.autodelete) delete f.pFGF;
+ }
- m_sortedfilters.RemoveAll();
+ m_sortedfilters.RemoveAll();
}
void CFGFilterList::Insert(CFGFilter* pFGF, int group, bool exactmatch, bool autodelete)
{
- if(CFGFilterRegistry* f1r = dynamic_cast<CFGFilterRegistry*>(pFGF))
- {
- POSITION pos = m_filters.GetHeadPosition();
- while(pos)
- {
- filter_t& f2 = m_filters.GetNext(pos);
-
- if(group != f2.group) continue;
-
- if(CFGFilterRegistry* f2r = dynamic_cast<CFGFilterRegistry*>(f2.pFGF))
- {
- if(f1r->GetMoniker() && f2r->GetMoniker() && S_OK == f1r->GetMoniker()->IsEqual(f2r->GetMoniker())
- || f1r->GetCLSID() != GUID_NULL && f1r->GetCLSID() == f2r->GetCLSID())
- {
- TRACE(_T("FGM: Inserting %d %d %016I64x '%s' NOT!\n"),
- group, exactmatch, pFGF->GetMerit(),
- pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
-
- if(autodelete) delete pFGF;
- return;
- }
- }
- }
- }
-
- POSITION pos = m_filters.GetHeadPosition();
- while(pos)
- {
- if(m_filters.GetNext(pos).pFGF == pFGF)
- {
- TRACE(_T("FGM: Inserting %d %d %016I64x '%s' DUP!\n"),
- group, exactmatch, pFGF->GetMerit(),
- pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
-
- if(autodelete) delete pFGF;
- return;
- }
- }
-
- TRACE(_T("FGM: Inserting %d %d %016I64x '%s'\n"),
- group, exactmatch, pFGF->GetMerit(),
- pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
-
- filter_t f = {m_filters.GetCount(), pFGF, group, exactmatch, autodelete};
- m_filters.AddTail(f);
-
- m_sortedfilters.RemoveAll();
+ if(CFGFilterRegistry* f1r = dynamic_cast<CFGFilterRegistry*>(pFGF))
+ {
+ POSITION pos = m_filters.GetHeadPosition();
+ while(pos)
+ {
+ filter_t& f2 = m_filters.GetNext(pos);
+
+ if(group != f2.group) continue;
+
+ if(CFGFilterRegistry* f2r = dynamic_cast<CFGFilterRegistry*>(f2.pFGF))
+ {
+ if(f1r->GetMoniker() && f2r->GetMoniker() && S_OK == f1r->GetMoniker()->IsEqual(f2r->GetMoniker())
+ || f1r->GetCLSID() != GUID_NULL && f1r->GetCLSID() == f2r->GetCLSID())
+ {
+ TRACE(_T("FGM: Inserting %d %d %016I64x '%s' NOT!\n"),
+ group, exactmatch, pFGF->GetMerit(),
+ pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+
+ if(autodelete) delete pFGF;
+ return;
+ }
+ }
+ }
+ }
+
+ POSITION pos = m_filters.GetHeadPosition();
+ while(pos)
+ {
+ if(m_filters.GetNext(pos).pFGF == pFGF)
+ {
+ TRACE(_T("FGM: Inserting %d %d %016I64x '%s' DUP!\n"),
+ group, exactmatch, pFGF->GetMerit(),
+ pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+
+ if(autodelete) delete pFGF;
+ return;
+ }
+ }
+
+ TRACE(_T("FGM: Inserting %d %d %016I64x '%s'\n"),
+ group, exactmatch, pFGF->GetMerit(),
+ pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+
+ filter_t f = {m_filters.GetCount(), pFGF, group, exactmatch, autodelete};
+ m_filters.AddTail(f);
+
+ m_sortedfilters.RemoveAll();
}
POSITION CFGFilterList::GetHeadPosition()
{
- if(m_sortedfilters.IsEmpty())
- {
- CAtlArray<filter_t> sort;
- sort.SetCount(m_filters.GetCount());
- POSITION pos = m_filters.GetHeadPosition();
- for(int i = 0; pos; i++) sort[i] = m_filters.GetNext(pos);
- qsort(&sort[0], sort.GetCount(), sizeof(sort[0]), filter_cmp);
- for(size_t i = 0; i < sort.GetCount(); i++)
- if(sort[i].pFGF->GetMerit() >= MERIT64_DO_USE)
- m_sortedfilters.AddTail(sort[i].pFGF);
- }
-
- TRACE(_T("FGM: Sorting filters\n"));
-
- POSITION pos = m_sortedfilters.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_sortedfilters.GetNext(pos);
- TRACE(_T("FGM: - %016I64x '%s'\n"), pFGF->GetMerit(), pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
- }
-
- return m_sortedfilters.GetHeadPosition();
+ if(m_sortedfilters.IsEmpty())
+ {
+ CAtlArray<filter_t> sort;
+ sort.SetCount(m_filters.GetCount());
+ POSITION pos = m_filters.GetHeadPosition();
+ for(int i = 0; pos; i++) sort[i] = m_filters.GetNext(pos);
+ qsort(&sort[0], sort.GetCount(), sizeof(sort[0]), filter_cmp);
+ for(size_t i = 0; i < sort.GetCount(); i++)
+ if(sort[i].pFGF->GetMerit() >= MERIT64_DO_USE)
+ m_sortedfilters.AddTail(sort[i].pFGF);
+ }
+
+ TRACE(_T("FGM: Sorting filters\n"));
+
+ POSITION pos = m_sortedfilters.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_sortedfilters.GetNext(pos);
+ TRACE(_T("FGM: - %016I64x '%s'\n"), pFGF->GetMerit(), pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+ }
+
+ return m_sortedfilters.GetHeadPosition();
}
CFGFilter* CFGFilterList::GetNext(POSITION& pos)
{
- return m_sortedfilters.GetNext(pos);
+ return m_sortedfilters.GetNext(pos);
}
int CFGFilterList::filter_cmp(const void* a, const void* b)
{
- filter_t* fa = (filter_t*)a;
- filter_t* fb = (filter_t*)b;
+ filter_t* fa = (filter_t*)a;
+ filter_t* fb = (filter_t*)b;
- if(fa->group < fb->group) return -1;
- if(fa->group > fb->group) return +1;
+ if(fa->group < fb->group) return -1;
+ if(fa->group > fb->group) return +1;
- if(fa->pFGF->GetCLSID() == fb->pFGF->GetCLSID())
- {
- CFGFilterFile* fgfa = dynamic_cast<CFGFilterFile*>(fa->pFGF);
- CFGFilterFile* fgfb = dynamic_cast<CFGFilterFile*>(fb->pFGF);
+ if(fa->pFGF->GetCLSID() == fb->pFGF->GetCLSID())
+ {
+ CFGFilterFile* fgfa = dynamic_cast<CFGFilterFile*>(fa->pFGF);
+ CFGFilterFile* fgfb = dynamic_cast<CFGFilterFile*>(fb->pFGF);
- if(fgfa && !fgfb) return -1;
- if(!fgfa && fgfb) return +1;
- }
+ if(fgfa && !fgfb) return -1;
+ if(!fgfa && fgfb) return +1;
+ }
- if(fa->pFGF->GetMerit() > fb->pFGF->GetMerit()) return -1;
- if(fa->pFGF->GetMerit() < fb->pFGF->GetMerit()) return +1;
+ if(fa->pFGF->GetMerit() > fb->pFGF->GetMerit()) return -1;
+ if(fa->pFGF->GetMerit() < fb->pFGF->GetMerit()) return +1;
- if(fa->exactmatch && !fb->exactmatch) return -1;
- if(!fa->exactmatch && fb->exactmatch) return +1;
+ if(fa->exactmatch && !fb->exactmatch) return -1;
+ if(!fa->exactmatch && fb->exactmatch) return +1;
- if(fa->index < fb->index) return -1;
- if(fa->index > fb->index) return +1;
+ if(fa->index < fb->index) return -1;
+ if(fa->index > fb->index) return +1;
- return 0;
+ return 0;
}
diff --git a/src/apps/mplayerc/FGFilter.h b/src/apps/mplayerc/FGFilter.h
index b3f1f82a6..b58b511af 100644
--- a/src/apps/mplayerc/FGFilter.h
+++ b/src/apps/mplayerc/FGFilter.h
@@ -35,143 +35,106 @@
class CFGFilter
{
protected:
- CLSID m_clsid;
- CStringW m_name;
- struct
- {
- union
- {
- UINT64 val;
- struct
- {
- UINT64 low: 16, mid: 32, high: 16;
- };
- };
- } m_merit;
- CAtlList<GUID> m_types;
+ CLSID m_clsid;
+ CStringW m_name;
+ struct {union {UINT64 val; struct {UINT64 low:16, mid:32, high:16;};};} m_merit;
+ CAtlList<GUID> m_types;
public:
- CFGFilter(const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
- virtual ~CFGFilter() {}
-
- CLSID GetCLSID() const
- {
- return m_clsid;
- }
- CStringW GetName() const
- {
- return m_name;
- }
- UINT64 GetMerit() const
- {
- return m_merit.val;
- }
- DWORD GetMeritForDirectShow() const
- {
- return m_merit.mid;
- }
- const CAtlList<GUID>& GetTypes() const;
- void SetTypes(const CAtlList<GUID>& types);
- void AddType(const GUID& majortype, const GUID& subtype);
- bool CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch);
-
- CAtlList<CString> m_protocols, m_extensions, m_chkbytes; // TODO: subtype?
-
- virtual HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) = 0;
+ CFGFilter(const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
+ virtual ~CFGFilter() {}
+
+ CLSID GetCLSID() const {return m_clsid;}
+ CStringW GetName() const {return m_name;}
+ UINT64 GetMerit() const {return m_merit.val;}
+ DWORD GetMeritForDirectShow() const {return m_merit.mid;}
+ const CAtlList<GUID>& GetTypes() const;
+ void SetTypes(const CAtlList<GUID>& types);
+ void AddType(const GUID& majortype, const GUID& subtype);
+ bool CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch);
+
+ CAtlList<CString> m_protocols, m_extensions, m_chkbytes; // TODO: subtype?
+
+ virtual HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) = 0;
};
class CFGFilterRegistry : public CFGFilter
{
protected:
- CStringW m_DisplayName;
- CComPtr<IMoniker> m_pMoniker;
+ CStringW m_DisplayName;
+ CComPtr<IMoniker> m_pMoniker;
- void ExtractFilterData(BYTE* p, UINT len);
+ void ExtractFilterData(BYTE* p, UINT len);
public:
- CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit = MERIT64_DO_USE);
- CFGFilterRegistry(CStringW DisplayName, UINT64 merit = MERIT64_DO_USE);
- CFGFilterRegistry(const CLSID& clsid, UINT64 merit = MERIT64_DO_USE);
-
- CStringW GetDisplayName()
- {
- return m_DisplayName;
- }
- IMoniker* GetMoniker()
- {
- return m_pMoniker;
- }
-
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit = MERIT64_DO_USE);
+ CFGFilterRegistry(CStringW DisplayName, UINT64 merit = MERIT64_DO_USE);
+ CFGFilterRegistry(const CLSID& clsid, UINT64 merit = MERIT64_DO_USE);
+
+ CStringW GetDisplayName() {return m_DisplayName;}
+ IMoniker* GetMoniker() {return m_pMoniker;}
+
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
};
template<class T>
class CFGFilterInternal : public CFGFilter
{
public:
- CFGFilterInternal(CStringW name = L"", UINT64 merit = MERIT64_DO_USE) : CFGFilter(__uuidof(T), name, merit) {}
+ CFGFilterInternal(CStringW name = L"", UINT64 merit = MERIT64_DO_USE) : CFGFilter(__uuidof(T), name, merit) {}
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
- {
- CheckPointer(ppBF, E_POINTER);
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
+ {
+ CheckPointer(ppBF, E_POINTER);
- HRESULT hr = S_OK;
- CComPtr<IBaseFilter> pBF = DNew T(NULL, &hr);
- if(FAILED(hr)) return hr;
+ HRESULT hr = S_OK;
+ CComPtr<IBaseFilter> pBF = DNew T(NULL, &hr);
+ if(FAILED(hr)) return hr;
- *ppBF = pBF.Detach();
+ *ppBF = pBF.Detach();
- return hr;
- }
+ return hr;
+ }
};
class CFGFilterFile : public CFGFilter
{
protected:
- CString m_path;
- HINSTANCE m_hInst;
+ CString m_path;
+ HINSTANCE m_hInst;
public:
- CFGFilterFile(const CLSID& clsid, CString path, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
+ CFGFilterFile(const CLSID& clsid, CString path, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
};
class CFGFilterVideoRenderer : public CFGFilter
{
protected:
- HWND m_hWnd;
+ HWND m_hWnd;
public:
- CFGFilterVideoRenderer(HWND hWnd, const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
+ CFGFilterVideoRenderer(HWND hWnd, const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
};
class CFGFilterList
{
- struct filter_t
- {
- int index;
- CFGFilter* pFGF;
- int group;
- bool exactmatch, autodelete;
- };
- static int filter_cmp(const void* a, const void* b);
- CAtlList<filter_t> m_filters;
- CAtlList<CFGFilter*> m_sortedfilters;
+ struct filter_t {int index; CFGFilter* pFGF; int group; bool exactmatch, autodelete;};
+ static int filter_cmp(const void* a, const void* b);
+ CAtlList<filter_t> m_filters;
+ CAtlList<CFGFilter*> m_sortedfilters;
public:
- CFGFilterList();
- virtual ~CFGFilterList();
-
- bool IsEmpty()
- {
- return m_filters.IsEmpty();
- }
- void RemoveAll();
- void Insert(CFGFilter* pFGF, int group, bool exactmatch = false, bool autodelete = true);
-
- POSITION GetHeadPosition();
- CFGFilter* GetNext(POSITION& pos);
+ CFGFilterList();
+ virtual ~CFGFilterList();
+
+ bool IsEmpty() {return m_filters.IsEmpty();}
+ void RemoveAll();
+ void Insert(CFGFilter* pFGF, int group, bool exactmatch = false, bool autodelete = true);
+
+ POSITION GetHeadPosition();
+ CFGFilter* GetNext(POSITION& pos);
};
diff --git a/src/apps/mplayerc/FGManager.cpp b/src/apps/mplayerc/FGManager.cpp
index 70bea9cd8..14aaac726 100644
--- a/src/apps/mplayerc/FGManager.cpp
+++ b/src/apps/mplayerc/FGManager.cpp
@@ -46,1167 +46,1167 @@
//
CFGManager::CFGManager(LPCTSTR pName, LPUNKNOWN pUnk)
- : CUnknown(pName, pUnk)
- , m_dwRegister(0)
+ : CUnknown(pName, pUnk)
+ , m_dwRegister(0)
{
- m_pUnkInner.CoCreateInstance(CLSID_FilterGraph, GetOwner());
- m_pFM.CoCreateInstance(CLSID_FilterMapper2);
+ m_pUnkInner.CoCreateInstance(CLSID_FilterGraph, GetOwner());
+ m_pFM.CoCreateInstance(CLSID_FilterMapper2);
}
CFGManager::~CFGManager()
{
- CAutoLock cAutoLock(this);
- while(!m_source.IsEmpty()) delete m_source.RemoveHead();
- while(!m_transform.IsEmpty()) delete m_transform.RemoveHead();
- while(!m_override.IsEmpty()) delete m_override.RemoveHead();
- m_pUnks.RemoveAll();
- m_pUnkInner.Release();
+ CAutoLock cAutoLock(this);
+ while(!m_source.IsEmpty()) delete m_source.RemoveHead();
+ while(!m_transform.IsEmpty()) delete m_transform.RemoveHead();
+ while(!m_override.IsEmpty()) delete m_override.RemoveHead();
+ m_pUnks.RemoveAll();
+ m_pUnkInner.Release();
}
STDMETHODIMP CFGManager::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IFilterGraph)
- QI(IGraphBuilder)
- QI(IFilterGraph2)
- QI(IGraphBuilder2)
- QI(IGraphBuilderDeadEnd)
- m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFilterGraph)
+ QI(IGraphBuilder)
+ QI(IFilterGraph2)
+ QI(IGraphBuilder2)
+ QI(IGraphBuilderDeadEnd)
+ m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
//
void CFGManager::CStreamPath::Append(IBaseFilter* pBF, IPin* pPin)
{
- path_t p;
- p.clsid = GetCLSID(pBF);
- p.filter = GetFilterName(pBF);
- p.pin = GetPinName(pPin);
- AddTail(p);
+ path_t p;
+ p.clsid = GetCLSID(pBF);
+ p.filter = GetFilterName(pBF);
+ p.pin = GetPinName(pPin);
+ AddTail(p);
}
bool CFGManager::CStreamPath::Compare(const CStreamPath& path)
{
- POSITION pos1 = GetHeadPosition();
- POSITION pos2 = path.GetHeadPosition();
+ POSITION pos1 = GetHeadPosition();
+ POSITION pos2 = path.GetHeadPosition();
- while(pos1 && pos2)
- {
- const path_t& p1 = GetNext(pos1);
- const path_t& p2 = path.GetNext(pos2);
+ while(pos1 && pos2)
+ {
+ const path_t& p1 = GetNext(pos1);
+ const path_t& p2 = path.GetNext(pos2);
- if(p1.filter != p2.filter) return true;
- else if(p1.pin != p2.pin) return false;
- }
+ if(p1.filter != p2.filter) return true;
+ else if(p1.pin != p2.pin) return false;
+ }
- return true;
+ return true;
}
//
bool CFGManager::CheckBytes(HANDLE hFile, CString chkbytes)
{
- CAtlList<CString> sl;
- Explode(chkbytes, sl, ',');
-
- if(sl.GetCount() < 4)
- return false;
-
- ASSERT(!(sl.GetCount() & 3));
-
- LARGE_INTEGER size = {0, 0};
- size.LowPart = GetFileSize(hFile, (DWORD*)&size.HighPart);
-
- POSITION pos = sl.GetHeadPosition();
- while(sl.GetCount() >= 4)
- {
- CString offsetstr = sl.RemoveHead();
- CString cbstr = sl.RemoveHead();
- CString maskstr = sl.RemoveHead();
- CString valstr = sl.RemoveHead();
-
- long cb = _ttol(cbstr);
-
- if(offsetstr.IsEmpty() || cbstr.IsEmpty()
- || valstr.IsEmpty() || (valstr.GetLength() & 1)
- || cb * 2 != valstr.GetLength())
- return false;
-
- LARGE_INTEGER offset;
- offset.QuadPart = _ttoi64(offsetstr);
- if(offset.QuadPart < 0) offset.QuadPart = size.QuadPart - offset.QuadPart;
- SetFilePointer(hFile, offset.LowPart, &offset.HighPart, FILE_BEGIN);
-
- // LAME
- while(maskstr.GetLength() < valstr.GetLength())
- maskstr += 'F';
-
- CAtlArray<BYTE> mask, val;
- CStringToBin(maskstr, mask);
- CStringToBin(valstr, val);
-
- for(size_t i = 0; i < val.GetCount(); i++)
- {
- BYTE b;
- DWORD r;
- if(!ReadFile(hFile, &b, 1, &r, NULL) || (b & mask[i]) != val[i])
- return false;
- }
- }
-
- return sl.IsEmpty();
+ CAtlList<CString> sl;
+ Explode(chkbytes, sl, ',');
+
+ if(sl.GetCount() < 4)
+ return false;
+
+ ASSERT(!(sl.GetCount()&3));
+
+ LARGE_INTEGER size = {0, 0};
+ size.LowPart = GetFileSize(hFile, (DWORD*)&size.HighPart);
+
+ POSITION pos = sl.GetHeadPosition();
+ while(sl.GetCount() >= 4)
+ {
+ CString offsetstr = sl.RemoveHead();
+ CString cbstr = sl.RemoveHead();
+ CString maskstr = sl.RemoveHead();
+ CString valstr = sl.RemoveHead();
+
+ long cb = _ttol(cbstr);
+
+ if(offsetstr.IsEmpty() || cbstr.IsEmpty()
+ || valstr.IsEmpty() || (valstr.GetLength() & 1)
+ || cb*2 != valstr.GetLength())
+ return false;
+
+ LARGE_INTEGER offset;
+ offset.QuadPart = _ttoi64(offsetstr);
+ if(offset.QuadPart < 0) offset.QuadPart = size.QuadPart - offset.QuadPart;
+ SetFilePointer(hFile, offset.LowPart, &offset.HighPart, FILE_BEGIN);
+
+ // LAME
+ while(maskstr.GetLength() < valstr.GetLength())
+ maskstr += 'F';
+
+ CAtlArray<BYTE> mask, val;
+ CStringToBin(maskstr, mask);
+ CStringToBin(valstr, val);
+
+ for(size_t i = 0; i < val.GetCount(); i++)
+ {
+ BYTE b;
+ DWORD r;
+ if(!ReadFile(hFile, &b, 1, &r, NULL) || (b & mask[i]) != val[i])
+ return false;
+ }
+ }
+
+ return sl.IsEmpty();
}
HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl)
{
- // TODO: use overrides
-
- CheckPointer(lpcwstrFileName, E_POINTER);
-
- fl.RemoveAll();
-
- CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
- CStringW protocol = fn.Left(fn.Find(':') + 1).TrimRight(':').MakeLower();
- CStringW ext = CPathW(fn).GetExtension().MakeLower();
-
- HANDLE hFile = INVALID_HANDLE_VALUE;
-
- if(protocol.GetLength() <= 1 || protocol == L"file")
- {
- hFile = CreateFile(CString(fn), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
-
- if(hFile == INVALID_HANDLE_VALUE)
- {
- return VFW_E_NOT_FOUND;
- }
- }
-
- // exceptions first
-
- if(ext == _T(".dvr-ms") || ext == _T(".wtv")) // doh, this is stupid
- {
- fl.Insert(DNew CFGFilterRegistry(CLSID_StreamBufferSource, MERIT64_PREFERRED), 0);
- }
-
- TCHAR buff[256], buff2[256];
- ULONG len, len2;
-
- if(hFile == INVALID_HANDLE_VALUE)
- {
- // internal / protocol
-
- POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_source.GetNext(pos);
- if(pFGF->m_protocols.Find(CString(protocol)))
- fl.Insert(pFGF, 0, false, false);
- }
- }
- else
- {
- // internal / check bytes
-
- POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_source.GetNext(pos);
-
- POSITION pos2 = pFGF->m_chkbytes.GetHeadPosition();
- while(pos2)
- {
- if(CheckBytes(hFile, pFGF->m_chkbytes.GetNext(pos2)))
- {
- fl.Insert(pFGF, 1, false, false);
- break;
- }
- }
- }
- }
-
- if(!ext.IsEmpty())
- {
- // internal / file extension
-
- POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_source.GetNext(pos);
- if(pFGF->m_extensions.Find(CString(ext)))
- fl.Insert(pFGF, 2, false, false);
- }
- }
-
- {
- // internal / the rest
-
- POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_source.GetNext(pos);
- if(pFGF->m_protocols.IsEmpty() && pFGF->m_chkbytes.IsEmpty() && pFGF->m_extensions.IsEmpty())
- fl.Insert(pFGF, 3, false, false);
- }
- }
-
- if(hFile == INVALID_HANDLE_VALUE)
- {
- // protocol
-
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(protocol), KEY_READ))
- {
- CRegKey exts;
- if(ERROR_SUCCESS == exts.Open(key, _T("Extensions"), KEY_READ))
- {
- len = countof(buff);
- if(ERROR_SUCCESS == exts.QueryStringValue(CString(ext), buff, &len))
- fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 4);
- }
-
- len = countof(buff);
- if(ERROR_SUCCESS == key.QueryStringValue(_T("Source Filter"), buff, &len))
- fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 5);
- }
-
- fl.Insert(DNew CFGFilterRegistry(CLSID_URLReader), 6);
- }
- else
- {
- // check bytes
-
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type"), KEY_READ))
- {
- FILETIME ft;
- len = countof(buff);
- for(DWORD i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len, &ft); i++, len = countof(buff))
- {
- GUID majortype;
- if(FAILED(GUIDFromCString(buff, majortype)))
- continue;
-
- CRegKey majorkey;
- if(ERROR_SUCCESS == majorkey.Open(key, buff, KEY_READ))
- {
- len = countof(buff);
- for(DWORD j = 0; ERROR_SUCCESS == majorkey.EnumKey(j, buff, &len, &ft); j++, len = countof(buff))
- {
- GUID subtype;
- if(FAILED(GUIDFromCString(buff, subtype)))
- continue;
-
- CRegKey subkey;
- if(ERROR_SUCCESS == subkey.Open(majorkey, buff, KEY_READ))
- {
- len = countof(buff);
- if(ERROR_SUCCESS != subkey.QueryStringValue(_T("Source Filter"), buff, &len))
- continue;
-
- GUID clsid = GUIDFromCString(buff);
-
- len = countof(buff);
- len2 = sizeof(buff2);
- for(DWORD k = 0, type;
- clsid != GUID_NULL && ERROR_SUCCESS == RegEnumValue(subkey, k, buff2, &len2, 0, &type, (BYTE*)buff, &len);
- k++, len = countof(buff), len2 = sizeof(buff2))
- {
- if(CheckBytes(hFile, CString(buff)))
- {
- CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
- pFGF->AddType(majortype, subtype);
- fl.Insert(pFGF, 9);
- break;
- }
- }
- }
- }
- }
- }
- }
- }
-
- if(!ext.IsEmpty())
- {
- // file extension
-
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type\\Extensions\\") + CString(ext), KEY_READ))
- {
- ULONG len = countof(buff);
- memset(buff, 0, sizeof(buff));
- LONG ret = key.QueryStringValue(_T("Source Filter"), buff, &len); // QueryStringValue can return ERROR_INVALID_DATA on bogus strings (radlight mpc v1003, fixed in v1004)
- if(ERROR_SUCCESS == ret || ERROR_INVALID_DATA == ret && GUIDFromCString(buff) != GUID_NULL)
- {
- GUID clsid = GUIDFromCString(buff);
- GUID majortype = GUID_NULL;
- GUID subtype = GUID_NULL;
-
- len = countof(buff);
- if(ERROR_SUCCESS == key.QueryStringValue(_T("Media Type"), buff, &len))
- majortype = GUIDFromCString(buff);
-
- len = countof(buff);
- if(ERROR_SUCCESS == key.QueryStringValue(_T("Subtype"), buff, &len))
- subtype = GUIDFromCString(buff);
-
- CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
- pFGF->AddType(majortype, subtype);
- fl.Insert(pFGF, 7);
- }
- }
- }
-
- if(hFile != INVALID_HANDLE_VALUE)
- {
- CloseHandle(hFile);
- }
-
- CFGFilter* pFGF = DNew CFGFilterRegistry(CLSID_AsyncReader);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_NULL);
- fl.Insert(pFGF, 9);
-
- return S_OK;
+ // TODO: use overrides
+
+ CheckPointer(lpcwstrFileName, E_POINTER);
+
+ fl.RemoveAll();
+
+ CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
+ CStringW protocol = fn.Left(fn.Find(':')+1).TrimRight(':').MakeLower();
+ CStringW ext = CPathW(fn).GetExtension().MakeLower();
+
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+
+ if(protocol.GetLength() <= 1 || protocol == L"file")
+ {
+ hFile = CreateFile(CString(fn), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ return VFW_E_NOT_FOUND;
+ }
+ }
+
+ // exceptions first
+
+ if(ext == _T(".dvr-ms") || ext == _T(".wtv")) // doh, this is stupid
+ {
+ fl.Insert(DNew CFGFilterRegistry(CLSID_StreamBufferSource, MERIT64_PREFERRED), 0);
+ }
+
+ TCHAR buff[256], buff2[256];
+ ULONG len, len2;
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ // internal / protocol
+
+ POSITION pos = m_source.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+ if(pFGF->m_protocols.Find(CString(protocol)))
+ fl.Insert(pFGF, 0, false, false);
+ }
+ }
+ else
+ {
+ // internal / check bytes
+
+ POSITION pos = m_source.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+
+ POSITION pos2 = pFGF->m_chkbytes.GetHeadPosition();
+ while(pos2)
+ {
+ if(CheckBytes(hFile, pFGF->m_chkbytes.GetNext(pos2)))
+ {
+ fl.Insert(pFGF, 1, false, false);
+ break;
+ }
+ }
+ }
+ }
+
+ if(!ext.IsEmpty())
+ {
+ // internal / file extension
+
+ POSITION pos = m_source.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+ if(pFGF->m_extensions.Find(CString(ext)))
+ fl.Insert(pFGF, 2, false, false);
+ }
+ }
+
+ {
+ // internal / the rest
+
+ POSITION pos = m_source.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+ if(pFGF->m_protocols.IsEmpty() && pFGF->m_chkbytes.IsEmpty() && pFGF->m_extensions.IsEmpty())
+ fl.Insert(pFGF, 3, false, false);
+ }
+ }
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ // protocol
+
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(protocol), KEY_READ))
+ {
+ CRegKey exts;
+ if(ERROR_SUCCESS == exts.Open(key, _T("Extensions"), KEY_READ))
+ {
+ len = countof(buff);
+ if(ERROR_SUCCESS == exts.QueryStringValue(CString(ext), buff, &len))
+ fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 4);
+ }
+
+ len = countof(buff);
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("Source Filter"), buff, &len))
+ fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 5);
+ }
+
+ fl.Insert(DNew CFGFilterRegistry(CLSID_URLReader), 6);
+ }
+ else
+ {
+ // check bytes
+
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type"), KEY_READ))
+ {
+ FILETIME ft;
+ len = countof(buff);
+ for(DWORD i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len, &ft); i++, len = countof(buff))
+ {
+ GUID majortype;
+ if(FAILED(GUIDFromCString(buff, majortype)))
+ continue;
+
+ CRegKey majorkey;
+ if(ERROR_SUCCESS == majorkey.Open(key, buff, KEY_READ))
+ {
+ len = countof(buff);
+ for(DWORD j = 0; ERROR_SUCCESS == majorkey.EnumKey(j, buff, &len, &ft); j++, len = countof(buff))
+ {
+ GUID subtype;
+ if(FAILED(GUIDFromCString(buff, subtype)))
+ continue;
+
+ CRegKey subkey;
+ if(ERROR_SUCCESS == subkey.Open(majorkey, buff, KEY_READ))
+ {
+ len = countof(buff);
+ if(ERROR_SUCCESS != subkey.QueryStringValue(_T("Source Filter"), buff, &len))
+ continue;
+
+ GUID clsid = GUIDFromCString(buff);
+
+ len = countof(buff);
+ len2 = sizeof(buff2);
+ for(DWORD k = 0, type;
+ clsid != GUID_NULL && ERROR_SUCCESS == RegEnumValue(subkey, k, buff2, &len2, 0, &type, (BYTE*)buff, &len);
+ k++, len = countof(buff), len2 = sizeof(buff2))
+ {
+ if(CheckBytes(hFile, CString(buff)))
+ {
+ CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
+ pFGF->AddType(majortype, subtype);
+ fl.Insert(pFGF, 9);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(!ext.IsEmpty())
+ {
+ // file extension
+
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type\\Extensions\\") + CString(ext), KEY_READ))
+ {
+ ULONG len = countof(buff);
+ memset(buff, 0, sizeof(buff));
+ LONG ret = key.QueryStringValue(_T("Source Filter"), buff, &len); // QueryStringValue can return ERROR_INVALID_DATA on bogus strings (radlight mpc v1003, fixed in v1004)
+ if(ERROR_SUCCESS == ret || ERROR_INVALID_DATA == ret && GUIDFromCString(buff) != GUID_NULL)
+ {
+ GUID clsid = GUIDFromCString(buff);
+ GUID majortype = GUID_NULL;
+ GUID subtype = GUID_NULL;
+
+ len = countof(buff);
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("Media Type"), buff, &len))
+ majortype = GUIDFromCString(buff);
+
+ len = countof(buff);
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("Subtype"), buff, &len))
+ subtype = GUIDFromCString(buff);
+
+ CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
+ pFGF->AddType(majortype, subtype);
+ fl.Insert(pFGF, 7);
+ }
+ }
+ }
+
+ if(hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hFile);
+ }
+
+ CFGFilter* pFGF = DNew CFGFilterRegistry(CLSID_AsyncReader);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_NULL);
+ fl.Insert(pFGF, 9);
+
+ return S_OK;
}
HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppBF)
{
- TRACE(_T("FGM: AddSourceFilter trying '%s'\n"), CStringFromGUID(pFGF->GetCLSID()));
-
- CheckPointer(lpcwstrFileName, E_POINTER);
- CheckPointer(ppBF, E_POINTER);
-
- ASSERT(*ppBF == NULL);
-
- HRESULT hr;
-
- CComPtr<IBaseFilter> pBF;
- CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
- if(FAILED(hr = pFGF->Create(&pBF, pUnks)))
- return hr;
-
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if(!pFSF) return E_NOINTERFACE;
-
- if(FAILED(hr = AddFilter(pBF, lpcwstrFilterName)))
- return hr;
-
- const AM_MEDIA_TYPE* pmt = NULL;
-
- CMediaType mt;
- const CAtlList<GUID>& types = pFGF->GetTypes();
- if(types.GetCount() == 2 && (types.GetHead() != GUID_NULL || types.GetTail() != GUID_NULL))
- {
- mt.majortype = types.GetHead();
- mt.subtype = types.GetTail();
- pmt = &mt;
- }
-
- if(FAILED(hr = pFSF->Load(lpcwstrFileName, pmt)))
- {
- RemoveFilter(pBF);
- return hr;
- }
-
- // doh :P
- BeginEnumMediaTypes(GetFirstPin(pBF, PINDIR_OUTPUT), pEMT, pmt)
- {
- if(pmt->subtype == GUIDFromCString(_T("{640999A0-A946-11D0-A520-000000000000}"))
- || pmt->subtype == GUIDFromCString(_T("{640999A1-A946-11D0-A520-000000000000}"))
- || pmt->subtype == GUIDFromCString(_T("{D51BD5AE-7548-11CF-A520-0080C77EF58A}")))
- {
- RemoveFilter(pBF);
- pFGF = DNew CFGFilterRegistry(CLSID_NetShowSource);
- hr = AddSourceFilter(pFGF, lpcwstrFileName, lpcwstrFilterName, ppBF);
- delete pFGF;
- return hr;
- }
- }
- EndEnumMediaTypes(pmt)
-
- *ppBF = pBF.Detach();
-
- m_pUnks.AddTailList(&pUnks);
-
- return S_OK;
+ TRACE(_T("FGM: AddSourceFilter trying '%s'\n"), CStringFromGUID(pFGF->GetCLSID()));
+
+ CheckPointer(lpcwstrFileName, E_POINTER);
+ CheckPointer(ppBF, E_POINTER);
+
+ ASSERT(*ppBF == NULL);
+
+ HRESULT hr;
+
+ CComPtr<IBaseFilter> pBF;
+ CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
+ if(FAILED(hr = pFGF->Create(&pBF, pUnks)))
+ return hr;
+
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if(!pFSF) return E_NOINTERFACE;
+
+ if(FAILED(hr = AddFilter(pBF, lpcwstrFilterName)))
+ return hr;
+
+ const AM_MEDIA_TYPE* pmt = NULL;
+
+ CMediaType mt;
+ const CAtlList<GUID>& types = pFGF->GetTypes();
+ if(types.GetCount() == 2 && (types.GetHead() != GUID_NULL || types.GetTail() != GUID_NULL))
+ {
+ mt.majortype = types.GetHead();
+ mt.subtype = types.GetTail();
+ pmt = &mt;
+ }
+
+ if(FAILED(hr = pFSF->Load(lpcwstrFileName, pmt)))
+ {
+ RemoveFilter(pBF);
+ return hr;
+ }
+
+ // doh :P
+ BeginEnumMediaTypes(GetFirstPin(pBF, PINDIR_OUTPUT), pEMT, pmt)
+ {
+ if(pmt->subtype == GUIDFromCString(_T("{640999A0-A946-11D0-A520-000000000000}"))
+ || pmt->subtype == GUIDFromCString(_T("{640999A1-A946-11D0-A520-000000000000}"))
+ || pmt->subtype == GUIDFromCString(_T("{D51BD5AE-7548-11CF-A520-0080C77EF58A}")))
+ {
+ RemoveFilter(pBF);
+ pFGF = DNew CFGFilterRegistry(CLSID_NetShowSource);
+ hr = AddSourceFilter(pFGF, lpcwstrFileName, lpcwstrFilterName, ppBF);
+ delete pFGF;
+ return hr;
+ }
+ }
+ EndEnumMediaTypes(pmt)
+
+ *ppBF = pBF.Detach();
+
+ m_pUnks.AddTailList(&pUnks);
+
+ return S_OK;
}
// IFilterGraph
STDMETHODIMP CFGManager::AddFilter(IBaseFilter* pFilter, LPCWSTR pName)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if(FAILED(hr = CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddFilter(pFilter, pName)))
- return hr;
+ if(FAILED(hr = CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddFilter(pFilter, pName)))
+ return hr;
- // TODO
- hr = pFilter->JoinFilterGraph(NULL, NULL);
- hr = pFilter->JoinFilterGraph(this, pName);
+ // TODO
+ hr = pFilter->JoinFilterGraph(NULL, NULL);
+ hr = pFilter->JoinFilterGraph(this, pName);
- return hr;
+ return hr;
}
STDMETHODIMP CFGManager::RemoveFilter(IBaseFilter* pFilter)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->RemoveFilter(pFilter);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->RemoveFilter(pFilter);
}
STDMETHODIMP CFGManager::EnumFilters(IEnumFilters** ppEnum)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- // Not locking here fixes a deadlock involving ReClock
- //CAutoLock cAutoLock(this);
+ // Not locking here fixes a deadlock involving ReClock
+ //CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->EnumFilters(ppEnum);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->EnumFilters(ppEnum);
}
STDMETHODIMP CFGManager::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->FindFilterByName(pName, ppFilter);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->FindFilterByName(pName, ppFilter);
}
STDMETHODIMP CFGManager::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinIn);
- CLSID clsid = GetCLSID(pBF);
+ CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinIn);
+ CLSID clsid = GetCLSID(pBF);
- // TODO: GetUpStreamFilter goes up on the first input pin only
- for(CComPtr<IBaseFilter> pBFUS = GetFilterFromPin(pPinOut); pBFUS; pBFUS = GetUpStreamFilter(pBFUS))
- {
- if(pBFUS == pBF) return VFW_E_CIRCULAR_GRAPH;
- if(clsid != CLSID_Proxy && GetCLSID(pBFUS) == clsid) return VFW_E_CANNOT_CONNECT;
- }
+ // TODO: GetUpStreamFilter goes up on the first input pin only
+ for(CComPtr<IBaseFilter> pBFUS = GetFilterFromPin(pPinOut); pBFUS; pBFUS = GetUpStreamFilter(pBFUS))
+ {
+ if(pBFUS == pBF) return VFW_E_CIRCULAR_GRAPH;
+ if(clsid!=CLSID_Proxy && GetCLSID(pBFUS) == clsid) return VFW_E_CANNOT_CONNECT;
+ }
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ConnectDirect(pPinOut, pPinIn, pmt);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ConnectDirect(pPinOut, pPinIn, pmt);
}
STDMETHODIMP CFGManager::Reconnect(IPin* ppin)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Reconnect(ppin);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Reconnect(ppin);
}
STDMETHODIMP CFGManager::Disconnect(IPin* ppin)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Disconnect(ppin);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Disconnect(ppin);
}
STDMETHODIMP CFGManager::SetDefaultSyncSource()
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetDefaultSyncSource();
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetDefaultSyncSource();
}
// IGraphBuilder
STDMETHODIMP CFGManager::Connect(IPin* pPinOut, IPin* pPinIn)
{
- return Connect(pPinOut, pPinIn, true);
+ return Connect(pPinOut, pPinIn, true);
}
HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPinOut, E_POINTER);
+ CheckPointer(pPinOut, E_POINTER);
- HRESULT hr;
-
- if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)
- || pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT))
- return VFW_E_INVALID_DIRECTION;
+ HRESULT hr;
- if(S_OK == IsPinConnected(pPinOut)
- || pPinIn && S_OK == IsPinConnected(pPinIn))
- return VFW_E_ALREADY_CONNECTED;
+ if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)
+ || pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT))
+ return VFW_E_INVALID_DIRECTION;
- bool fDeadEnd = true;
+ if(S_OK == IsPinConnected(pPinOut)
+ || pPinIn && S_OK == IsPinConnected(pPinIn))
+ return VFW_E_ALREADY_CONNECTED;
- if(pPinIn)
- {
- // 1. Try a direct connection between the filters, with no intermediate filters
+ bool fDeadEnd = true;
- if(SUCCEEDED(hr = ConnectDirect(pPinOut, pPinIn, NULL)))
- return hr;
- }
- else
- {
- // 1. Use IStreamBuilder
-
- if(CComQIPtr<IStreamBuilder> pSB = pPinOut)
- {
- if(SUCCEEDED(hr = pSB->Render(pPinOut, this)))
- return hr;
-
- pSB->Backout(pPinOut, this);
- }
- }
-
- // 2. Try cached filters
-
- if(CComQIPtr<IGraphConfig> pGC = (IGraphBuilder2*)this)
- {
- BeginEnumCachedFilters(pGC, pEF, pBF)
- {
- if(pPinIn && GetFilterFromPin(pPinIn) == pBF)
- continue;
-
- hr = pGC->RemoveFilterFromCache(pBF);
-
- // does RemoveFilterFromCache call AddFilter like AddFilterToCache calls RemoveFilter ?
-
- if(SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL)))
- {
- if(!IsStreamEnd(pBF)) fDeadEnd = false;
-
- if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn)))
- return hr;
- }
-
- hr = pGC->AddFilterToCache(pBF);
- }
- EndEnumCachedFilters
- }
-
- // 3. Try filters in the graph
-
- {
- CInterfaceList<IBaseFilter> pBFs;
-
- BeginEnumFilters(this, pEF, pBF)
- {
- if(pPinIn && GetFilterFromPin(pPinIn) == pBF
- || GetFilterFromPin(pPinOut) == pBF)
- continue;
-
- // HACK: ffdshow - audio capture filter
- if(GetCLSID(pPinOut) == GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}"))
- && GetCLSID(pBF) == GUIDFromCString(_T("{E30629D2-27E5-11CE-875D-00608CB78066}")))
- continue;
-
- pBFs.AddTail(pBF);
- }
- EndEnumFilters
-
- POSITION pos = pBFs.GetHeadPosition();
- while(pos)
- {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- if(SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL)))
- {
- if(!IsStreamEnd(pBF)) fDeadEnd = false;
-
- if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn)))
- return hr;
- }
-
- EXECUTE_ASSERT(Disconnect(pPinOut));
- }
- }
-
- // 4. Look up filters in the registry
-
- {
- CFGFilterList fl;
-
- CAtlArray<GUID> types;
- ExtractMediaTypes(pPinOut, types);
-
- POSITION pos = m_transform.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_transform.GetNext(pos);
- if(pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false))
- fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
- }
-
- pos = m_override.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_override.GetNext(pos);
- if(pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false))
- fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
- }
-
- CComPtr<IEnumMoniker> pEM;
- if(types.GetCount() > 0
- && SUCCEEDED(m_pFM->EnumMatchingFilters(
- &pEM, 0, FALSE, MERIT_DO_NOT_USE + 1,
- TRUE, types.GetCount() / 2, types.GetData(), NULL, NULL, FALSE,
- !!pPinIn, 0, NULL, NULL, NULL)))
- {
- for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
- {
- CFGFilterRegistry* pFGF = DNew CFGFilterRegistry(pMoniker);
- fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true));
- }
- }
-
- pos = fl.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = fl.GetNext(pos);
-
- TRACE(_T("FGM: Connecting '%s'\n"), pFGF->GetName());
-
- CComPtr<IBaseFilter> pBF;
- CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
- if(FAILED(pFGF->Create(&pBF, pUnks)))
- continue;
-
- if(FAILED(hr = AddFilter(pBF, pFGF->GetName())))
- continue;
-
- hr = E_FAIL;
-
- if(FAILED(hr))
- {
- hr = ConnectFilterDirect(pPinOut, pBF, NULL);
- }
- /*
- if(FAILED(hr))
- {
- if(types.GetCount() >= 2 && types[0] == MEDIATYPE_Stream && types[1] != GUID_NULL)
- {
- CMediaType mt;
-
- mt.majortype = types[0];
- mt.subtype = types[1];
- mt.formattype = FORMAT_None;
- if(FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
-
- mt.formattype = GUID_NULL;
- if(FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
- }
- }
- */
- if(SUCCEEDED(hr))
- {
- if(!IsStreamEnd(pBF)) fDeadEnd = false;
-
- if(bContinueRender)
- hr = ConnectFilter(pBF, pPinIn);
-
- if(SUCCEEDED(hr))
- {
- m_pUnks.AddTailList(&pUnks);
-
- // maybe the application should do this...
-
- POSITION pos = pUnks.GetHeadPosition();
- while(pos)
- {
- if(CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pUnks.GetNext(pos))
- pMPC->SetAspectRatioMode(AM_ARMODE_STRETCHED);
- }
-
- if(CComQIPtr<IVMRAspectRatioControl> pARC = pBF)
- pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
-
- if(CComQIPtr<IVMRAspectRatioControl9> pARC = pBF)
- pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
-
- if(CComQIPtr<IVMRMixerControl9> pMC = pBF)
- m_pUnks.AddTail(pMC);
-
- if(CComQIPtr<IVMRMixerBitmap9> pMB = pBF)
- m_pUnks.AddTail(pMB);
-
- if(CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF)
- {
- CComPtr<IMFVideoDisplayControl> pMFVDC;
- CComPtr<IMFVideoMixerBitmap> pMFMB;
- if(SUCCEEDED(pMFGS->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, (void**)&pMFVDC)))
- m_pUnks.AddTail(pMFVDC);
-
- if(SUCCEEDED(pMFGS->GetService(MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerBitmap, (void**)&pMFMB)))
- m_pUnks.AddTail(pMFMB);
+ if(pPinIn)
+ {
+ // 1. Try a direct connection between the filters, with no intermediate filters
+
+ if(SUCCEEDED(hr = ConnectDirect(pPinOut, pPinIn, NULL)))
+ return hr;
+ }
+ else
+ {
+ // 1. Use IStreamBuilder
+
+ if(CComQIPtr<IStreamBuilder> pSB = pPinOut)
+ {
+ if(SUCCEEDED(hr = pSB->Render(pPinOut, this)))
+ return hr;
+
+ pSB->Backout(pPinOut, this);
+ }
+ }
+
+ // 2. Try cached filters
+
+ if(CComQIPtr<IGraphConfig> pGC = (IGraphBuilder2*)this)
+ {
+ BeginEnumCachedFilters(pGC, pEF, pBF)
+ {
+ if(pPinIn && GetFilterFromPin(pPinIn) == pBF)
+ continue;
+
+ hr = pGC->RemoveFilterFromCache(pBF);
+
+ // does RemoveFilterFromCache call AddFilter like AddFilterToCache calls RemoveFilter ?
+
+ if(SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL)))
+ {
+ if(!IsStreamEnd(pBF)) fDeadEnd = false;
+
+ if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn)))
+ return hr;
+ }
+
+ hr = pGC->AddFilterToCache(pBF);
+ }
+ EndEnumCachedFilters
+ }
+
+ // 3. Try filters in the graph
+
+ {
+ CInterfaceList<IBaseFilter> pBFs;
+
+ BeginEnumFilters(this, pEF, pBF)
+ {
+ if(pPinIn && GetFilterFromPin(pPinIn) == pBF
+ || GetFilterFromPin(pPinOut) == pBF)
+ continue;
+
+ // HACK: ffdshow - audio capture filter
+ if(GetCLSID(pPinOut) == GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}"))
+ && GetCLSID(pBF) == GUIDFromCString(_T("{E30629D2-27E5-11CE-875D-00608CB78066}")))
+ continue;
+
+ pBFs.AddTail(pBF);
+ }
+ EndEnumFilters
+
+ POSITION pos = pBFs.GetHeadPosition();
+ while(pos)
+ {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ if(SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL)))
+ {
+ if(!IsStreamEnd(pBF)) fDeadEnd = false;
+
+ if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn)))
+ return hr;
+ }
+
+ EXECUTE_ASSERT(Disconnect(pPinOut));
+ }
+ }
+
+ // 4. Look up filters in the registry
+
+ {
+ CFGFilterList fl;
+
+ CAtlArray<GUID> types;
+ ExtractMediaTypes(pPinOut, types);
+
+ POSITION pos = m_transform.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_transform.GetNext(pos);
+ if(pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false))
+ fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
+ }
+
+ pos = m_override.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_override.GetNext(pos);
+ if(pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false))
+ fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
+ }
+
+ CComPtr<IEnumMoniker> pEM;
+ if(types.GetCount() > 0
+ && SUCCEEDED(m_pFM->EnumMatchingFilters(
+ &pEM, 0, FALSE, MERIT_DO_NOT_USE+1,
+ TRUE, types.GetCount()/2, types.GetData(), NULL, NULL, FALSE,
+ !!pPinIn, 0, NULL, NULL, NULL)))
+ {
+ for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
+ {
+ CFGFilterRegistry* pFGF = DNew CFGFilterRegistry(pMoniker);
+ fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true));
+ }
+ }
+
+ pos = fl.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = fl.GetNext(pos);
+
+ TRACE(_T("FGM: Connecting '%s'\n"), pFGF->GetName());
+
+ CComPtr<IBaseFilter> pBF;
+ CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
+ if(FAILED(pFGF->Create(&pBF, pUnks)))
+ continue;
+
+ if(FAILED(hr = AddFilter(pBF, pFGF->GetName())))
+ continue;
+
+ hr = E_FAIL;
+
+ if(FAILED(hr))
+ {
+ hr = ConnectFilterDirect(pPinOut, pBF, NULL);
+ }
+/*
+ if(FAILED(hr))
+ {
+ if(types.GetCount() >= 2 && types[0] == MEDIATYPE_Stream && types[1] != GUID_NULL)
+ {
+ CMediaType mt;
+
+ mt.majortype = types[0];
+ mt.subtype = types[1];
+ mt.formattype = FORMAT_None;
+ if(FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
+
+ mt.formattype = GUID_NULL;
+ if(FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
+ }
+ }
+*/
+ if(SUCCEEDED(hr))
+ {
+ if(!IsStreamEnd(pBF)) fDeadEnd = false;
+
+ if (bContinueRender)
+ hr = ConnectFilter(pBF, pPinIn);
+
+ if(SUCCEEDED(hr))
+ {
+ m_pUnks.AddTailList(&pUnks);
+
+ // maybe the application should do this...
+
+ POSITION pos = pUnks.GetHeadPosition();
+ while(pos)
+ {
+ if(CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pUnks.GetNext(pos))
+ pMPC->SetAspectRatioMode(AM_ARMODE_STRETCHED);
+ }
+
+ if(CComQIPtr<IVMRAspectRatioControl> pARC = pBF)
+ pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
+
+ if(CComQIPtr<IVMRAspectRatioControl9> pARC = pBF)
+ pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
+
+ if(CComQIPtr<IVMRMixerControl9> pMC = pBF)
+ m_pUnks.AddTail (pMC);
+
+ if(CComQIPtr<IVMRMixerBitmap9> pMB = pBF)
+ m_pUnks.AddTail (pMB);
+
+ if(CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF)
+ {
+ CComPtr<IMFVideoDisplayControl> pMFVDC;
+ CComPtr<IMFVideoMixerBitmap> pMFMB;
+ if (SUCCEEDED (pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, (void**)&pMFVDC)))
+ m_pUnks.AddTail (pMFVDC);
+
+ if (SUCCEEDED (pMFGS->GetService (MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerBitmap, (void**)&pMFMB)))
+ m_pUnks.AddTail (pMFMB);
// CComPtr<IMFWorkQueueServices> pMFWQS;
// pMFGS->GetService (MF_WORKQUEUE_SERVICES, IID_IMFWorkQueueServices, (void**)&pMFWQS);
// pMFWQS->BeginRegisterPlatformWorkQueueWithMMCSS(
- }
-
- return hr;
- }
- }
-
- EXECUTE_ASSERT(SUCCEEDED(RemoveFilter(pBF)));
-
- TRACE(_T("FGM: Connecting '%s' FAILED!\n"), pFGF->GetName());
- }
- }
-
- if(fDeadEnd)
- {
- CAutoPtr<CStreamDeadEnd> psde(DNew CStreamDeadEnd());
- psde->AddTailList(&m_streampath);
- int skip = 0;
- BeginEnumMediaTypes(pPinOut, pEM, pmt)
- {
- if(pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_NULL) skip++;
- psde->mts.AddTail(CMediaType(*pmt));
- }
- EndEnumMediaTypes(pmt)
- if(skip < psde->mts.GetCount())
- m_deadends.Add(psde);
- }
-
- return pPinIn ? VFW_E_CANNOT_CONNECT : VFW_E_CANNOT_RENDER;
+ }
+
+ return hr;
+ }
+ }
+
+ EXECUTE_ASSERT(SUCCEEDED(RemoveFilter(pBF)));
+
+ TRACE(_T("FGM: Connecting '%s' FAILED!\n"), pFGF->GetName());
+ }
+ }
+
+ if(fDeadEnd)
+ {
+ CAutoPtr<CStreamDeadEnd> psde(DNew CStreamDeadEnd());
+ psde->AddTailList(&m_streampath);
+ int skip = 0;
+ BeginEnumMediaTypes(pPinOut, pEM, pmt)
+ {
+ if(pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_NULL) skip++;
+ psde->mts.AddTail(CMediaType(*pmt));
+ }
+ EndEnumMediaTypes(pmt)
+ if(skip < psde->mts.GetCount())
+ m_deadends.Add(psde);
+ }
+
+ return pPinIn ? VFW_E_CANNOT_CONNECT : VFW_E_CANNOT_RENDER;
}
STDMETHODIMP CFGManager::Render(IPin* pPinOut)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return RenderEx(pPinOut, 0, NULL);
+ return RenderEx(pPinOut, 0, NULL);
}
STDMETHODIMP CFGManager::RenderFile(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrPlayList)
{
- TRACE("--> CFGManager::RenderFile on thread: %d\n", GetCurrentThreadId());
- CAutoLock cAutoLock(this);
+ TRACE("--> CFGManager::RenderFile on thread: %d\n", GetCurrentThreadId());
+ CAutoLock cAutoLock(this);
- m_streampath.RemoveAll();
- m_deadends.RemoveAll();
+ m_streampath.RemoveAll();
+ m_deadends.RemoveAll();
- HRESULT hr;
-
- /*
- CComPtr<IBaseFilter> pBF;
- if(FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF)))
- return hr;
+ HRESULT hr;
- return ConnectFilter(pBF, NULL);
- */
+/*
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF)))
+ return hr;
- CFGFilterList fl;
- if(FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl)))
- return hr;
+ return ConnectFilter(pBF, NULL);
+*/
- CAutoPtrArray<CStreamDeadEnd> deadends;
+ CFGFilterList fl;
+ if(FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl)))
+ return hr;
- hr = VFW_E_CANNOT_RENDER;
+ CAutoPtrArray<CStreamDeadEnd> deadends;
- POSITION pos = fl.GetHeadPosition();
- while(pos)
- {
- CComPtr<IBaseFilter> pBF;
+ hr = VFW_E_CANNOT_RENDER;
- if(SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFileName, &pBF)))
- {
- m_streampath.RemoveAll();
- m_deadends.RemoveAll();
+ POSITION pos = fl.GetHeadPosition();
+ while(pos)
+ {
+ CComPtr<IBaseFilter> pBF;
+
+ if(SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFileName, &pBF)))
+ {
+ m_streampath.RemoveAll();
+ m_deadends.RemoveAll();
- if(SUCCEEDED(hr = ConnectFilter(pBF, NULL)))
- return hr;
+ if(SUCCEEDED(hr = ConnectFilter(pBF, NULL)))
+ return hr;
- NukeDownstream(pBF);
- RemoveFilter(pBF);
+ NukeDownstream(pBF);
+ RemoveFilter(pBF);
- deadends.Append(m_deadends);
- }
- }
+ deadends.Append(m_deadends);
+ }
+ }
- m_deadends.Copy(deadends);
+ m_deadends.Copy(deadends);
- return hr;
+ return hr;
}
STDMETHODIMP CFGManager::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- CFGFilterList fl;
- if(FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl)))
- return hr;
+ CFGFilterList fl;
+ if(FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl)))
+ return hr;
- POSITION pos = fl.GetHeadPosition();
- while(pos)
- {
- if(SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFilterName, ppFilter)))
- return hr;
- }
+ POSITION pos = fl.GetHeadPosition();
+ while(pos)
+ {
+ if(SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFilterName, ppFilter)))
+ return hr;
+ }
- return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
+ return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
}
STDMETHODIMP CFGManager::SetLogFile(DWORD_PTR hFile)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetLogFile(hFile);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetLogFile(hFile);
}
STDMETHODIMP CFGManager::Abort()
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Abort();
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Abort();
}
STDMETHODIMP CFGManager::ShouldOperationContinue()
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ShouldOperationContinue();
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ShouldOperationContinue();
}
// IFilterGraph2
STDMETHODIMP CFGManager::AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddSourceFilterForMoniker(pMoniker, pCtx, lpcwstrFilterName, ppFilter);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddSourceFilterForMoniker(pMoniker, pCtx, lpcwstrFilterName, ppFilter);
}
STDMETHODIMP CFGManager::ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) return E_UNEXPECTED;
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ReconnectEx(ppin, pmt);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ReconnectEx(ppin, pmt);
}
STDMETHODIMP CFGManager::RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext)
{
- CAutoLock cAutoLock(this);
-
- m_streampath.RemoveAll();
- m_deadends.RemoveAll();
-
- if(!pPinOut || dwFlags > AM_RENDEREX_RENDERTOEXISTINGRENDERERS || pvContext)
- return E_INVALIDARG;
-
- HRESULT hr;
-
- if(dwFlags & AM_RENDEREX_RENDERTOEXISTINGRENDERERS)
- {
- CInterfaceList<IBaseFilter> pBFs;
-
- BeginEnumFilters(this, pEF, pBF)
- {
- if(CComQIPtr<IAMFilterMiscFlags> pAMMF = pBF)
- {
- if(pAMMF->GetMiscFlags() & AM_FILTER_MISC_FLAGS_IS_RENDERER)
- {
- pBFs.AddTail(pBF);
- }
- }
- else
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- CComPtr<IPin> pPinIn;
- DWORD size = 1;
- if(SUCCEEDED(pPin->QueryInternalConnections(&pPinIn, &size)) && size == 0)
- {
- pBFs.AddTail(pBF);
- break;
- }
- }
- EndEnumPins
- }
- }
- EndEnumFilters
-
- while(!pBFs.IsEmpty())
- {
- if(SUCCEEDED(hr = ConnectFilter(pPinOut, pBFs.RemoveHead())))
- return hr;
- }
-
- return VFW_E_CANNOT_RENDER;
- }
-
- return Connect(pPinOut, (IPin*)NULL);
+ CAutoLock cAutoLock(this);
+
+ m_streampath.RemoveAll();
+ m_deadends.RemoveAll();
+
+ if(!pPinOut || dwFlags > AM_RENDEREX_RENDERTOEXISTINGRENDERERS || pvContext)
+ return E_INVALIDARG;
+
+ HRESULT hr;
+
+ if(dwFlags & AM_RENDEREX_RENDERTOEXISTINGRENDERERS)
+ {
+ CInterfaceList<IBaseFilter> pBFs;
+
+ BeginEnumFilters(this, pEF, pBF)
+ {
+ if(CComQIPtr<IAMFilterMiscFlags> pAMMF = pBF)
+ {
+ if(pAMMF->GetMiscFlags() & AM_FILTER_MISC_FLAGS_IS_RENDERER)
+ {
+ pBFs.AddTail(pBF);
+ }
+ }
+ else
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ CComPtr<IPin> pPinIn;
+ DWORD size = 1;
+ if(SUCCEEDED(pPin->QueryInternalConnections(&pPinIn, &size)) && size == 0)
+ {
+ pBFs.AddTail(pBF);
+ break;
+ }
+ }
+ EndEnumPins
+ }
+ }
+ EndEnumFilters
+
+ while(!pBFs.IsEmpty())
+ {
+ if(SUCCEEDED(hr = ConnectFilter(pPinOut, pBFs.RemoveHead())))
+ return hr;
+ }
+
+ return VFW_E_CANNOT_RENDER;
+ }
+
+ return Connect(pPinOut, (IPin*)NULL);
}
// IGraphBuilder2
STDMETHODIMP CFGManager::IsPinDirection(IPin* pPin, PIN_DIRECTION dir1)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPin, E_POINTER);
+ CheckPointer(pPin, E_POINTER);
- PIN_DIRECTION dir2;
- if(FAILED(pPin->QueryDirection(&dir2)))
- return E_FAIL;
+ PIN_DIRECTION dir2;
+ if(FAILED(pPin->QueryDirection(&dir2)))
+ return E_FAIL;
- return dir1 == dir2 ? S_OK : S_FALSE;
+ return dir1 == dir2 ? S_OK : S_FALSE;
}
STDMETHODIMP CFGManager::IsPinConnected(IPin* pPin)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPin, E_POINTER);
+ CheckPointer(pPin, E_POINTER);
- CComPtr<IPin> pPinTo;
- return SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo ? S_OK : S_FALSE;
+ CComPtr<IPin> pPinTo;
+ return SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo ? S_OK : S_FALSE;
}
STDMETHODIMP CFGManager::ConnectFilter(IBaseFilter* pBF, IPin* pPinIn)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pBF, E_POINTER);
+ CheckPointer(pBF, E_POINTER);
- if(pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT))
- return VFW_E_INVALID_DIRECTION;
+ if(pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT))
+ return VFW_E_INVALID_DIRECTION;
- int nTotal = 0, nRendered = 0;
+ int nTotal = 0, nRendered = 0;
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(GetPinName(pPin)[0] != '~'
- && S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
- && S_OK != IsPinConnected(pPin))
- {
- m_streampath.Append(pBF, pPin);
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(GetPinName(pPin)[0] != '~'
+ && S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
+ && S_OK != IsPinConnected(pPin))
+ {
+ m_streampath.Append(pBF, pPin);
- HRESULT hr = Connect(pPin, pPinIn);
+ HRESULT hr = Connect(pPin, pPinIn);
- if(SUCCEEDED(hr))
- {
- for(int i = m_deadends.GetCount() - 1; i >= 0; i--)
- if(m_deadends[i]->Compare(m_streampath))
- m_deadends.RemoveAt(i);
+ if(SUCCEEDED(hr))
+ {
+ for(int i = m_deadends.GetCount()-1; i >= 0; i--)
+ if(m_deadends[i]->Compare(m_streampath))
+ m_deadends.RemoveAt(i);
- nRendered++;
- }
+ nRendered++;
+ }
- nTotal++;
+ nTotal++;
- m_streampath.RemoveTail();
+ m_streampath.RemoveTail();
- if(SUCCEEDED(hr) && pPinIn)
- return S_OK;
- }
- }
- EndEnumPins
+ if(SUCCEEDED(hr) && pPinIn)
+ return S_OK;
+ }
+ }
+ EndEnumPins
- return
- nRendered == nTotal ? (nRendered > 0 ? S_OK : S_FALSE) :
- nRendered > 0 ? VFW_S_PARTIAL_RENDER :
- VFW_E_CANNOT_RENDER;
+ return
+ nRendered == nTotal ? (nRendered > 0 ? S_OK : S_FALSE) :
+ nRendered > 0 ? VFW_S_PARTIAL_RENDER :
+ VFW_E_CANNOT_RENDER;
}
STDMETHODIMP CFGManager::ConnectFilter(IPin* pPinOut, IBaseFilter* pBF)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPinOut, E_POINTER);
- CheckPointer(pBF, E_POINTER);
+ CheckPointer(pPinOut, E_POINTER);
+ CheckPointer(pBF, E_POINTER);
- if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT))
- return VFW_E_INVALID_DIRECTION;
+ if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT))
+ return VFW_E_INVALID_DIRECTION;
- HRESULT hr;
+ HRESULT hr;
+
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(GetPinName(pPin)[0] != '~'
+ && S_OK == IsPinDirection(pPin, PINDIR_INPUT)
+ && S_OK != IsPinConnected(pPin)
+ && SUCCEEDED(hr = Connect(pPinOut, pPin)))
+ return hr;
+ }
+ EndEnumPins
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(GetPinName(pPin)[0] != '~'
- && S_OK == IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pPin)
- && SUCCEEDED(hr = Connect(pPinOut, pPin)))
- return hr;
- }
- EndEnumPins
-
- return VFW_E_CANNOT_CONNECT;
+ return VFW_E_CANNOT_CONNECT;
}
STDMETHODIMP CFGManager::ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPinOut, E_POINTER);
- CheckPointer(pBF, E_POINTER);
+ CheckPointer(pPinOut, E_POINTER);
+ CheckPointer(pBF, E_POINTER);
- if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT))
- return VFW_E_INVALID_DIRECTION;
+ if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT))
+ return VFW_E_INVALID_DIRECTION;
- HRESULT hr;
+ HRESULT hr;
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(GetPinName(pPin)[0] != '~'
- && S_OK == IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pPin)
- && SUCCEEDED(hr = ConnectDirect(pPinOut, pPin, pmt)))
- return hr;
- }
- EndEnumPins
-
- return VFW_E_CANNOT_CONNECT;
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(GetPinName(pPin)[0] != '~'
+ && S_OK == IsPinDirection(pPin, PINDIR_INPUT)
+ && S_OK != IsPinConnected(pPin)
+ && SUCCEEDED(hr = ConnectDirect(pPinOut, pPin, pmt)))
+ return hr;
+ }
+ EndEnumPins
+
+ return VFW_E_CANNOT_CONNECT;
}
STDMETHODIMP CFGManager::NukeDownstream(IUnknown* pUnk)
{
- CAutoLock cAutoLock(this);
-
- if(CComQIPtr<IBaseFilter> pBF = pUnk)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- NukeDownstream(pPin);
- }
- EndEnumPins
- }
- else if(CComQIPtr<IPin> pPin = pUnk)
- {
- CComPtr<IPin> pPinTo;
- if(S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
- && SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo)
- {
- if(CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo))
- {
- NukeDownstream(pBF);
- Disconnect(pPinTo);
- Disconnect(pPin);
- RemoveFilter(pBF);
- }
- }
- }
- else
- {
- return E_INVALIDARG;
- }
-
- return S_OK;
+ CAutoLock cAutoLock(this);
+
+ if(CComQIPtr<IBaseFilter> pBF = pUnk)
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ NukeDownstream(pPin);
+ }
+ EndEnumPins
+ }
+ else if(CComQIPtr<IPin> pPin = pUnk)
+ {
+ CComPtr<IPin> pPinTo;
+ if(S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
+ && SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo)
+ {
+ if(CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo))
+ {
+ NukeDownstream(pBF);
+ Disconnect(pPinTo);
+ Disconnect(pPin);
+ RemoveFilter(pBF);
+ }
+ }
+ }
+ else
+ {
+ return E_INVALIDARG;
+ }
+
+ return S_OK;
}
STDMETHODIMP CFGManager::FindInterface(REFIID iid, void** ppv, BOOL bRemove)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- for(POSITION pos = m_pUnks.GetHeadPosition(); pos; m_pUnks.GetNext(pos))
- {
- if(SUCCEEDED(m_pUnks.GetAt(pos)->QueryInterface(iid, ppv)))
- {
- if(bRemove) m_pUnks.RemoveAt(pos);
- return S_OK;
- }
- }
+ for(POSITION pos = m_pUnks.GetHeadPosition(); pos; m_pUnks.GetNext(pos))
+ {
+ if(SUCCEEDED(m_pUnks.GetAt(pos)->QueryInterface(iid, ppv)))
+ {
+ if(bRemove) m_pUnks.RemoveAt(pos);
+ return S_OK;
+ }
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
STDMETHODIMP CFGManager::AddToROT()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
HRESULT hr;
- if(m_dwRegister) return S_FALSE;
+ if(m_dwRegister) return S_FALSE;
CComPtr<IRunningObjectTable> pROT;
- CComPtr<IMoniker> pMoniker;
- WCHAR wsz[256];
+ CComPtr<IMoniker> pMoniker;
+ WCHAR wsz[256];
swprintf(wsz, L"FilterGraph %08p pid %08x (MPC)", (DWORD_PTR)this, GetCurrentProcessId());
if(SUCCEEDED(hr = GetRunningObjectTable(0, &pROT))
- && SUCCEEDED(hr = CreateItemMoniker(L"!", wsz, &pMoniker)))
+ && SUCCEEDED(hr = CreateItemMoniker(L"!", wsz, &pMoniker)))
hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, (IGraphBuilder2*)this, pMoniker, &m_dwRegister);
- return hr;
+ return hr;
}
STDMETHODIMP CFGManager::RemoveFromROT()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if(!m_dwRegister) return S_FALSE;
+ if(!m_dwRegister) return S_FALSE;
- CComPtr<IRunningObjectTable> pROT;
+ CComPtr<IRunningObjectTable> pROT;
if(SUCCEEDED(hr = GetRunningObjectTable(0, &pROT))
- && SUCCEEDED(hr = pROT->Revoke(m_dwRegister)))
- m_dwRegister = 0;
+ && SUCCEEDED(hr = pROT->Revoke(m_dwRegister)))
+ m_dwRegister = 0;
- return hr;
+ return hr;
}
// IGraphBuilderDeadEnd
STDMETHODIMP_(size_t) CFGManager::GetCount()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return m_deadends.GetCount();
+ return m_deadends.GetCount();
}
STDMETHODIMP CFGManager::GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if(iIndex < 0 || iIndex >= m_deadends.GetCount()) return E_FAIL;
+ if(iIndex < 0 || iIndex >= m_deadends.GetCount()) return E_FAIL;
- path.RemoveAll();
- mts.RemoveAll();
+ path.RemoveAll();
+ mts.RemoveAll();
- POSITION pos = m_deadends[iIndex]->GetHeadPosition();
- while(pos)
- {
- const path_t& p = m_deadends[iIndex]->GetNext(pos);
+ POSITION pos = m_deadends[iIndex]->GetHeadPosition();
+ while(pos)
+ {
+ const path_t& p = m_deadends[iIndex]->GetNext(pos);
- CStringW str;
- str.Format(L"%s::%s", p.filter, p.pin);
- path.AddTail(str);
- }
+ CStringW str;
+ str.Format(L"%s::%s", p.filter, p.pin);
+ path.AddTail(str);
+ }
- mts.AddTailList(&m_deadends[iIndex]->mts);
+ mts.AddTailList(&m_deadends[iIndex]->mts);
- return S_OK;
+ return S_OK;
}
//
@@ -1214,1234 +1214,1193 @@ STDMETHODIMP CFGManager::GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlLi
//
CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
- : CFGManager(pName, pUnk)
+ : CFGManager(pName, pUnk)
{
- AppSettings& s = AfxGetAppSettings();
-
- bool bOverrideBroadcom = false;
- CFGFilter* pFGF;
-
- UINT src = s.SrcFilters;
- UINT tra = s.TraFilters;
- UINT dxva_filters = s.DXVAFilters;
- UINT ffmpeg_filters = s.FFmpegFilters;
-
- // Source filters
-
+ AppSettings& s = AfxGetAppSettings();
+
+ bool bOverrideBroadcom = false;
+ CFGFilter* pFGF;
+
+ UINT src = s.SrcFilters;
+ UINT tra = s.TraFilters;
+ UINT dxva_filters = s.DXVAFilters;
+ UINT ffmpeg_filters = s.FFmpegFilters;
+
+ // Source filters
+
#if INTERNAL_SOURCEFILTER_SHOUTCAST
- if(src & SRC_SHOUTCAST)
- {
- pFGF = DNew CFGFilterInternal<CShoutcastSource>();
- pFGF->m_protocols.AddTail(_T("http"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_SHOUTCAST)
+ {
+ pFGF = DNew CFGFilterInternal<CShoutcastSource>();
+ pFGF->m_protocols.AddTail(_T("http"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_UDP
- // if(src & SRC_UDP)
- {
- pFGF = DNew CFGFilterInternal<CUDPReader>();
- pFGF->m_protocols.AddTail(_T("udp"));
- m_source.AddTail(pFGF);
- }
+ // if(src & SRC_UDP)
+ {
+ pFGF = DNew CFGFilterInternal<CUDPReader>();
+ pFGF->m_protocols.AddTail(_T("udp"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_AVI
- if(src & SRC_AVI)
- {
- pFGF = DNew CFGFilterInternal<CAviSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920"));
- pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_AVI)
+ {
+ pFGF = DNew CFGFilterInternal<CAviSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920"));
+ pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MP4
- if(src & SRC_MP4)
- {
- pFGF = DNew CFGFilterInternal<CMP4SourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
- pFGF->m_chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
- pFGF->m_chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
- pFGF->m_chkbytes.AddTail(_T("4,4,,736b6970")); // skip
- pFGF->m_chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
- pFGF->m_chkbytes.AddTail(_T("3,3,,000001")); // raw mpeg4 video
- pFGF->m_extensions.AddTail(_T(".mov"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_MP4)
+ {
+ pFGF = DNew CFGFilterInternal<CMP4SourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
+ pFGF->m_chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
+ pFGF->m_chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
+ pFGF->m_chkbytes.AddTail(_T("4,4,,736b6970")); // skip
+ pFGF->m_chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
+ pFGF->m_chkbytes.AddTail(_T("3,3,,000001")); // raw mpeg4 video
+ pFGF->m_extensions.AddTail(_T(".mov"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_FLV
- if(src & SRC_FLV)
- {
- pFGF = DNew CFGFilterInternal<CFLVSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,464C5601")); // FLV (v1)
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_FLV)
+ {
+ pFGF = DNew CFGFilterInternal<CFLVSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,464C5601")); // FLV (v1)
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- if(src & SRC_MATROSKA)
- {
- pFGF = DNew CFGFilterInternal<CMatroskaSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,1A45DFA3"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_MATROSKA)
+ {
+ pFGF = DNew CFGFilterInternal<CMatroskaSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,1A45DFA3"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- if(src & SRC_REALMEDIA)
- {
- pFGF = DNew CFGFilterInternal<CRealMediaSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,2E524D46"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_REALMEDIA)
+ {
+ pFGF = DNew CFGFilterInternal<CRealMediaSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,2E524D46"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_DSM
- if(src & SRC_DSM)
- {
- pFGF = DNew CFGFilterInternal<CDSMSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,44534D53"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_DSM)
+ {
+ pFGF = DNew CFGFilterInternal<CDSMSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,44534D53"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_FLIC
- if(src & SRC_FLIC)
- {
- pFGF = DNew CFGFilterInternal<CFLICSource>();
- pFGF->m_chkbytes.AddTail(_T("4,2,,11AF"));
- pFGF->m_chkbytes.AddTail(_T("4,2,,12AF"));
- pFGF->m_extensions.AddTail(_T(".fli"));
- pFGF->m_extensions.AddTail(_T(".flc"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_FLIC)
+ {
+ pFGF = DNew CFGFilterInternal<CFLICSource>();
+ pFGF->m_chkbytes.AddTail(_T("4,2,,11AF"));
+ pFGF->m_chkbytes.AddTail(_T("4,2,,12AF"));
+ pFGF->m_extensions.AddTail(_T(".fli"));
+ pFGF->m_extensions.AddTail(_T(".flc"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_FLAC
- if(src & SRC_FLAC)
- {
- pFGF = DNew CFGFilterInternal<CFlacSource>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,664C6143"));
- pFGF->m_extensions.AddTail(_T(".flac"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_FLAC)
+ {
+ pFGF = DNew CFGFilterInternal<CFlacSource>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,664C6143"));
+ pFGF->m_extensions.AddTail(_T(".flac"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_CDDA
- if(src & SRC_CDDA)
- {
- pFGF = DNew CFGFilterInternal<CCDDAReader>();
- pFGF->m_extensions.AddTail(_T(".cda"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_CDDA)
+ {
+ pFGF = DNew CFGFilterInternal<CCDDAReader>();
+ pFGF->m_extensions.AddTail(_T(".cda"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- if(src & SRC_CDXA)
- {
- pFGF = DNew CFGFilterInternal<CCDXAReader>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,43445841"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_CDXA)
+ {
+ pFGF = DNew CFGFilterInternal<CCDXAReader>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,43445841"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_VTS
- if(src & SRC_VTS)
- {
- pFGF = DNew CFGFilterInternal<CVTSReader>();
- pFGF->m_chkbytes.AddTail(_T("0,12,,445644564944454F2D565453"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_VTS)
+ {
+ pFGF = DNew CFGFilterInternal<CVTSReader>();
+ pFGF->m_chkbytes.AddTail(_T("0,12,,445644564944454F2D565453"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_DVSOURCE
// TODOX64 : fix DVSource internal filter
#ifndef _WIN64
- __if_exists(CD2VSource)
- {
- if(src & SRC_D2V)
- {
- pFGF = DNew CFGFilterInternal<CD2VSource>();
- pFGF->m_chkbytes.AddTail(_T("0,18,,4456443241564950726F6A65637446696C65"));
- pFGF->m_extensions.AddTail(_T(".d2v"));
- m_source.AddTail(pFGF);
- }
- }
+ __if_exists(CD2VSource)
+ {
+ if(src & SRC_D2V)
+ {
+ pFGF = DNew CFGFilterInternal<CD2VSource>();
+ pFGF->m_chkbytes.AddTail(_T("0,18,,4456443241564950726F6A65637446696C65"));
+ pFGF->m_extensions.AddTail(_T(".d2v"));
+ m_source.AddTail(pFGF);
+ }
+ }
#endif
#endif
#if INTERNAL_SOURCEFILTER_RADGT
- __if_exists(CRadGtSourceFilter)
- {
- if(src & SRC_RADGT)
- {
- pFGF = DNew CFGFilterInternal<CRadGtSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,3,,534D4B"));
- pFGF->m_chkbytes.AddTail(_T("0,3,,42494B"));
- pFGF->m_extensions.AddTail(_T(".smk"));
- pFGF->m_extensions.AddTail(_T(".bik"));
- m_source.AddTail(pFGF);
- }
- }
+ __if_exists(CRadGtSourceFilter)
+ {
+ if(src & SRC_RADGT)
+ {
+ pFGF = DNew CFGFilterInternal<CRadGtSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,3,,534D4B"));
+ pFGF->m_chkbytes.AddTail(_T("0,3,,42494B"));
+ pFGF->m_extensions.AddTail(_T(".smk"));
+ pFGF->m_extensions.AddTail(_T(".bik"));
+ m_source.AddTail(pFGF);
+ }
+ }
#endif
#if INTERNAL_SOURCEFILTER_ROQ
- if(src & SRC_ROQ)
- {
- pFGF = DNew CFGFilterInternal<CRoQSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,8,,8410FFFFFFFF1E00"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_ROQ)
+ {
+ pFGF = DNew CFGFilterInternal<CRoQSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,8,,8410FFFFFFFF1E00"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_OGG
- if(src & SRC_OGG)
- {
- pFGF = DNew CFGFilterInternal<COggSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,4F676753"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_OGG)
+ {
+ pFGF = DNew CFGFilterInternal<COggSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,4F676753"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_NUT
- __if_exists(CNutSourceFilter)
- {
- if(src & SRC_NUT)
- {
- pFGF = DNew CFGFilterInternal<CNutSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,8,,F9526A624E55544D"));
- m_source.AddTail(pFGF);
- }
- }
+ __if_exists(CNutSourceFilter)
+ {
+ if(src & SRC_NUT)
+ {
+ pFGF = DNew CFGFilterInternal<CNutSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,8,,F9526A624E55544D"));
+ m_source.AddTail(pFGF);
+ }
+ }
#endif
#if INTERNAL_SOURCEFILTER_DIRAC
- __if_exists(CDiracSourceFilter)
- {
- if(src & SRC_DIRAC)
- {
- pFGF = DNew CFGFilterInternal<CDiracSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,8,,4B572D4449524143"));
- m_source.AddTail(pFGF);
- }
- }
+ __if_exists(CDiracSourceFilter)
+ {
+ if(src & SRC_DIRAC)
+ {
+ pFGF = DNew CFGFilterInternal<CDiracSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,8,,4B572D4449524143"));
+ m_source.AddTail(pFGF);
+ }
+ }
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- if(src & SRC_MPEG)
- {
- pFGF = DNew CFGFilterInternal<CMpegSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"));
- pFGF->m_chkbytes.AddTail(_T("0,5,FFFFFFFFC0,000001BA40"));
- pFGF->m_chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
- pFGF->m_chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
- pFGF->m_chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47"));
- pFGF->m_chkbytes.AddTail(_T("0,8,fffffc00ffe00000,4156000055000000"));
- pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330323030")); // MPLS0200
- pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330313030")); // MPLS0100
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_MPEG)
+ {
+ pFGF = DNew CFGFilterInternal<CMpegSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"));
+ pFGF->m_chkbytes.AddTail(_T("0,5,FFFFFFFFC0,000001BA40"));
+ pFGF->m_chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
+ pFGF->m_chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
+ pFGF->m_chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47"));
+ pFGF->m_chkbytes.AddTail(_T("0,8,fffffc00ffe00000,4156000055000000"));
+ pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330323030")); // MPLS0200
+ pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330313030")); // MPLS0100
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_DTSAC3
- if(src & SRC_DTSAC3)
- {
- pFGF = DNew CFGFilterInternal<CDTSAC3Source>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,7FFE8001"));
- pFGF->m_chkbytes.AddTail(_T("0,2,,0B77"));
- pFGF->m_chkbytes.AddTail(_T("0,2,,770B"));
- pFGF->m_extensions.AddTail(_T(".ac3"));
- pFGF->m_extensions.AddTail(_T(".dts"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_DTSAC3)
+ {
+ pFGF = DNew CFGFilterInternal<CDTSAC3Source>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,7FFE8001"));
+ pFGF->m_chkbytes.AddTail(_T("0,2,,0B77"));
+ pFGF->m_chkbytes.AddTail(_T("0,2,,770B"));
+ pFGF->m_extensions.AddTail(_T(".ac3"));
+ pFGF->m_extensions.AddTail(_T(".dts"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- if(src & SRC_MPA)
- {
- pFGF = DNew CFGFilterInternal<CMpaSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
- pFGF->m_chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
- m_source.AddTail(pFGF);
- }
-#endif
-
- if(AfxGetAppSettings().fUseWMASFReader)
- {
- pFGF = DNew CFGFilterRegistry(CLSID_WMAsfReader);
- pFGF->m_chkbytes.AddTail(_T("0,4,,3026B275"));
- pFGF->m_chkbytes.AddTail(_T("0,4,,D129E2D6"));
- m_source.AddTail(pFGF);
- }
+ if(src & SRC_MPA)
+ {
+ pFGF = DNew CFGFilterInternal<CMpaSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
+ pFGF->m_chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
+ m_source.AddTail(pFGF);
+ }
+#endif
+
+ if(AfxGetAppSettings().fUseWMASFReader)
+ {
+ pFGF = DNew CFGFilterRegistry(CLSID_WMAsfReader);
+ pFGF->m_chkbytes.AddTail(_T("0,4,,3026B275"));
+ pFGF->m_chkbytes.AddTail(_T("0,4,,D129E2D6"));
+ m_source.AddTail(pFGF);
+ }
#if INTERNAL_SOURCEFILTER_AVI2AC3
- // hmmm, shouldn't there be an option in the GUI to enable/disable this filter?
- pFGF = DNew CFGFilterInternal<CAVI2AC3Filter>(L"AVI<->AC3/DTS", MERIT64(0x00680000) + 1);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
- m_transform.AddTail(pFGF);
+ // hmmm, shouldn't there be an option in the GUI to enable/disable this filter?
+ pFGF = DNew CFGFilterInternal<CAVI2AC3Filter>(L"AVI<->AC3/DTS", MERIT64(0x00680000)+1);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- if(src & SRC_MATROSKA)
- {
- pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Matroska);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_MATROSKA) {
+ pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Matroska);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- if(src & SRC_REALMEDIA)
- {
- pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RealMedia);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_REALMEDIA) {
+ pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RealMedia);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_AVI
- if(src & SRC_AVI)
- {
- pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Avi);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_AVI) {
+ pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Avi);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_RADGT
- __if_exists(CRadGtSplitterFilter)
- {
- if(src & SRC_RADGT)
- {
- pFGF = DNew CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Bink);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Smacker);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
- }
+ __if_exists(CRadGtSplitterFilter)
+ {
+ if(src & SRC_RADGT) {
+ pFGF = DNew CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Bink);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Smacker);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_ROQ
- if(src & SRC_ROQ)
- {
- pFGF = DNew CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RoQ);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_ROQ) {
+ pFGF = DNew CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RoQ);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_OGG
- if(src & SRC_OGG)
- {
- pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Ogg);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_OGG) {
+ pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Ogg);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_NUT
- __if_exists(CNutSplitterFilter)
- {
- if(src & SRC_NUT)
- {
- pFGF = DNew CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Nut);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
- }
+ __if_exists(CNutSplitterFilter)
+ {
+ if(src & SRC_NUT) {
+ pFGF = DNew CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Nut);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- if(src & SRC_MPEG)
- {
- pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1System);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PROGRAM);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_TRANSPORT);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PVA);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_MPEG) {
+ pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1System);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PROGRAM);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_TRANSPORT);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PVA);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_DIRAC
- __if_exists(CDiracSplitterFilter)
- {
- if(src & SRC_DIRAC)
- {
- pFGF = DNew CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Dirac);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
- }
+ __if_exists(CDiracSplitterFilter)
+ {
+ if(src & SRC_DIRAC) {
+ pFGF = DNew CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Dirac);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- if(src & SRC_MPA)
- {
- pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_MPA) {
+ pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_DSM
- if(src & SRC_DSM)
- {
- pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DirectShowMedia);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_DSM) {
+ pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DirectShowMedia);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_MP4
- if(src & SRC_MP4)
- {
- pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MP4);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_MP4) {
+ pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MP4);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_FLV
- if(src & SRC_FLV)
- {
- pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
- pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter (low merit)", MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_FLV);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if(src & SRC_FLV) {
+ pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter", MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter (low merit)", MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_FLV);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
- // Transform filters
+ // Transform filters
#if INTERNAL_DECODER_MPEG1
- pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
- (tra & TRA_MPEG1) ? ResStr(IDS_FGMANAGER_0) : L"MPEG-1 Video Decoder (low merit)",
- (tra & TRA_MPEG1) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Packet);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Payload);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
+ (tra & TRA_MPEG1) ? ResStr(IDS_FGMANAGER_0) : L"MPEG-1 Video Decoder (low merit)",
+ (tra & TRA_MPEG1) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Packet);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Payload);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_MPEGAUDIO
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_MPA) ? ResStr(IDS_FGMANAGER_2) : L"MPEG-1 Audio Decoder (low merit)",
- (tra & TRA_MPA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1AudioPayload);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Payload);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Packet);
- m_transform.AddTail(pFGF);
-
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_MPA) ? ResStr(IDS_FGMANAGER_3) : L"MPEG-2 Audio Decoder (low merit)",
- (tra & TRA_MPA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_AUDIO);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_MPA) ? ResStr(IDS_FGMANAGER_2) : L"MPEG-1 Audio Decoder (low merit)",
+ (tra & TRA_MPA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1AudioPayload);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Payload);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Packet);
+ m_transform.AddTail(pFGF);
+
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_MPA) ? ResStr(IDS_FGMANAGER_3) : L"MPEG-2 Audio Decoder (low merit)",
+ (tra & TRA_MPA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_AUDIO);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_AMR
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_AMR) ? L"AMR Audio Decoder" : L"AMR Audio Decoder (low merit)",
- (tra & TRA_AMR) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAMR);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AMR);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAWB);
- m_transform.AddTail(pFGF);
+ pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_AMR) ? L"AMR Audio Decoder" : L"AMR Audio Decoder (low merit)",
+ (tra & TRA_AMR) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAMR);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AMR);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAWB);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_LPCM
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_LPCM) ? ResStr(IDS_FGMANAGER_4) : L"LPCM Audio Decoder (low merit)",
- (tra & TRA_LPCM) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_HDMV_LPCM_AUDIO);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_LPCM) ? ResStr(IDS_FGMANAGER_4) : L"LPCM Audio Decoder (low merit)",
+ (tra & TRA_LPCM) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_HDMV_LPCM_AUDIO);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_AC3
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_AC3) ? ResStr(IDS_FGMANAGER_5) : L"AC3 Audio Decoder (low merit)",
- (tra & TRA_AC3) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_AC3) ? ResStr(IDS_FGMANAGER_5) : L"AC3 Audio Decoder (low merit)",
+ (tra & TRA_AC3) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_DTS
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_DTS) ? ResStr(IDS_AG_DTS_DECODER) : L"DTS Decoder (low merit)",
- (tra & TRA_DTS) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_DTS) ? ResStr(IDS_AG_DTS_DECODER) : L"DTS Decoder (low merit)",
+ (tra & TRA_DTS) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_AAC
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_AAC) ? ResStr(IDS_AG_AAC_DECODER) : L"AAC Decoder (low merit)",
- (tra & TRA_AAC) ? MERIT64_ABOVE_DSHOW + 1 : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_mp4a);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_mp4a);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_mp4a);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_mp4a);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_AAC) ? ResStr(IDS_AG_AAC_DECODER) : L"AAC Decoder (low merit)",
+ (tra & TRA_AAC) ? MERIT64_ABOVE_DSHOW+1 : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_mp4a);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_mp4a);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_mp4a);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_mp4a);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_PS2AUDIO
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_PS2AUD) ? ResStr(IDS_FGMANAGER_8) : L"PS2 Audio Decoder (low merit)",
- (tra & TRA_PS2AUD) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_PS2_PCM);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_PS2_PCM);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_PS2_PCM);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PS2_PCM);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_PS2AUD) ? ResStr(IDS_FGMANAGER_8) : L"PS2 Audio Decoder (low merit)",
+ (tra & TRA_PS2AUD) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_PS2_PCM);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_PS2_PCM);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_PS2_PCM);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PS2_PCM);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_REALVIDEO
- pFGF = DNew CFGFilterInternal<CRealVideoDecoder>(
- (tra & TRA_RV) ? ResStr(IDS_FGMANAGER_9) : L"RealVideo Decoder (low merit)",
- (tra & TRA_RV) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV10);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV20);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV30);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV40);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CRealVideoDecoder>(
+ (tra & TRA_RV) ? ResStr(IDS_FGMANAGER_9) : L"RealVideo Decoder (low merit)",
+ (tra & TRA_RV) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV10);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV20);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV30);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV40);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_REALAUDIO
- pFGF = DNew CFGFilterInternal<CRealAudioDecoder>(
- (tra & TRA_RA) ? ResStr(IDS_FGMANAGER_10) : L"RealAudio Decoder (low merit)",
- (tra & TRA_RA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_14_4);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_28_8);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ATRC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_COOK);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DNET);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SIPR);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RAAC);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CRealAudioDecoder>(
+ (tra & TRA_RA) ? ResStr(IDS_FGMANAGER_10) : L"RealAudio Decoder (low merit)",
+ (tra & TRA_RA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_14_4);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_28_8);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ATRC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_COOK);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DNET);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SIPR);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RAAC);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_VORBIS
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_VORBIS) ? ResStr(IDS_FGMANAGER_11) : L"Vorbis Audio Decoder (low merit)",
- (tra & TRA_VORBIS) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_Vorbis2);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_VORBIS) ? ResStr(IDS_FGMANAGER_11) : L"Vorbis Audio Decoder (low merit)",
+ (tra & TRA_VORBIS) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_Vorbis2);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_FLAC
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_FLAC) ? L"Flac Audio Decoder" : L"Flac Audio Decoder (low merit)", // TODO : put in resource !
- (tra & TRA_FLAC) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_FLAC_FRAMED);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_FLAC) ? L"Flac Audio Decoder" : L"Flac Audio Decoder (low merit)", // TODO : put in resource !
+ (tra & TRA_FLAC) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_FLAC_FRAMED);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_NELLYMOSER
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra & TRA_NELLY) ? L"Nellymoser Audio Decoder" : L"Nellymoser Audio Decoder (low merit)", // TODO : put in resource !
- (tra & TRA_NELLY) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NELLYMOSER);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra & TRA_NELLY) ? L"Nellymoser Audio Decoder" : L"Nellymoser Audio Decoder (low merit)", // TODO : put in resource !
+ (tra & TRA_NELLY) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NELLYMOSER);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_ROQ
- pFGF = DNew CFGFilterInternal<CRoQVideoDecoder>(
- (tra & TRA_RV) ? ResStr(IDS_FGMANAGER_12) : L"RoQ Video Decoder (low merit)",
- (tra & TRA_RV) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RoQV);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CRoQVideoDecoder>(
+ (tra & TRA_RV) ? ResStr(IDS_FGMANAGER_12) : L"RoQ Video Decoder (low merit)",
+ (tra & TRA_RV) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RoQV);
+ m_transform.AddTail(pFGF);
- pFGF = DNew CFGFilterInternal<CRoQAudioDecoder>(
- (tra & TRA_RA) ? ResStr(IDS_FGMANAGER_13) : L"RoQ Audio Decoder (low merit)",
- (tra & TRA_RA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RoQA);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CRoQAudioDecoder>(
+ (tra & TRA_RA) ? ResStr(IDS_FGMANAGER_13) : L"RoQ Audio Decoder (low merit)",
+ (tra & TRA_RA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RoQA);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_DIRAC
- __if_exists(CDiracVideoDecoder)
- {
- pFGF = DNew CFGFilterInternal<CDiracVideoDecoder>(
- (tra & TRA_DIRAC) ? ResStr(IDS_FGMANAGER_14) : L"Dirac Video Decoder (low merit)",
- (tra & TRA_DIRAC) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DiracVideo);
- m_transform.AddTail(pFGF);
- }
-#endif
-
- pFGF = DNew CFGFilterInternal<CNullTextRenderer>(L"NullTextRenderer", MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_ScriptCommand, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_Subtitle, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_DVD_SUBPICTURE);
- pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_CVD_SUBPICTURE);
- pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_SVCD_SUBPICTURE);
- m_transform.AddTail(pFGF);
-
- // High merit MPC Video Decoder
+ __if_exists(CDiracVideoDecoder)
+ {
+ pFGF = DNew CFGFilterInternal<CDiracVideoDecoder>(
+ (tra & TRA_DIRAC) ? ResStr(IDS_FGMANAGER_14) : L"Dirac Video Decoder (low merit)",
+ (tra & TRA_DIRAC) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DiracVideo);
+ m_transform.AddTail(pFGF);
+ }
+#endif
+
+ pFGF = DNew CFGFilterInternal<CNullTextRenderer>(L"NullTextRenderer", MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_ScriptCommand, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_Subtitle, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_DVD_SUBPICTURE);
+ pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_CVD_SUBPICTURE);
+ pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_SVCD_SUBPICTURE);
+ m_transform.AddTail(pFGF);
+
+ // High merit MPC Video Decoder
#if INCLUDE_MPC_VIDEO_DECODER | INCLUDE_MPC_DXVA_VIDEO_DECODER
- pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder"), MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder"), MERIT64_ABOVE_DSHOW);
#if INTERNAL_DECODER_FLV
- if(ffmpeg_filters & FFM_FLV4)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
- }
+ if (ffmpeg_filters & FFM_FLV4)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
+ }
#endif
#if INTERNAL_DECODER_VP6
- if(ffmpeg_filters & FFM_VP62)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
- }
+ if (ffmpeg_filters & FFM_VP62)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
+ }
#endif
#if INTERNAL_DECODER_H264 | INTERNAL_DECODER_H264_DXVA
- if((ffmpeg_filters & FFM_H264) || (dxva_filters & DXVA_H264))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
- }
+ if ((ffmpeg_filters & FFM_H264) || (dxva_filters & DXVA_H264))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
+ }
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- if(dxva_filters & DXVA_MPEG2)
- {
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- }
+ if (dxva_filters & DXVA_MPEG2)
+ {
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ }
#endif
#if INTERNAL_DECODER_VC1 | INTERNAL_DECODER_VC1_DXVA
- if((ffmpeg_filters & FFM_VC1) || (dxva_filters & DXVA_VC1))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
- }
+ if ((ffmpeg_filters & FFM_VC1) || (dxva_filters & DXVA_VC1))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
+ }
#endif
#if INTERNAL_DECODER_XVID
- if(ffmpeg_filters & FFM_XVID)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
- }
+ if (ffmpeg_filters & FFM_XVID)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
+ }
#endif
#if INTERNAL_DECODER_DIVX
- if(ffmpeg_filters & FFM_DIVX)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
- }
+ if (ffmpeg_filters & FFM_DIVX)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
+ }
#endif
#if INTERNAL_DECODER_WMV
- if(ffmpeg_filters & FFM_WMV)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
- }
+ if (ffmpeg_filters & FFM_WMV)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
+ }
#endif
#if INTERNAL_DECODER_MSMPEG4
- if(ffmpeg_filters & FFM_MSMPEG4)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
- }
+ if (ffmpeg_filters & FFM_MSMPEG4)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
+ }
#endif
#if INTERNAL_DECODER_SVQ
- if(ffmpeg_filters & FFM_SVQ3)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
- }
+ if (ffmpeg_filters & FFM_SVQ3)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
+ }
#endif
#if INTERNAL_DECODER_H263
- if(ffmpeg_filters & FFM_H263)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_S263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_s263);
- }
+ if (ffmpeg_filters & FFM_H263)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_S263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_s263);
+ }
#endif
#if INTERNAL_DECODER_THEORA
- if(ffmpeg_filters & FFM_THEORA)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
- }
+ if (ffmpeg_filters & FFM_THEORA)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
+ }
#endif
#if INTERNAL_DECODER_AMVV
- if(ffmpeg_filters & FFM_AMVV)
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
- }
+ if (ffmpeg_filters & FFM_AMVV)
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
+ }
#endif
- m_transform.AddTail(pFGF);
+ m_transform.AddTail(pFGF);
- // Low merit MPC Video Decoder
- pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder (low merit)"), MERIT64_DO_USE);
+ // Low merit MPC Video Decoder
+ pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder (low merit)"), MERIT64_DO_USE);
#if INTERNAL_DECODER_FLV
- if(!(ffmpeg_filters & FFM_FLV4))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
- }
+ if (!(ffmpeg_filters & FFM_FLV4))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
+ }
#endif
#if INTERNAL_DECODER_VP6
- if(!(ffmpeg_filters & FFM_VP62))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
- }
+ if (!(ffmpeg_filters & FFM_VP62))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
+ }
#endif
#if INTERNAL_DECODER_H264 | INTERNAL_DECODER_H264_DXVA
- if(!(ffmpeg_filters & FFM_H264) && !(dxva_filters & DXVA_H264))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
- }
+ if (!(ffmpeg_filters & FFM_H264) && !(dxva_filters & DXVA_H264))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
+ }
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- if(!(dxva_filters & DXVA_MPEG2))
- {
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- }
+ if (!(dxva_filters & DXVA_MPEG2))
+ {
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ }
#endif
#if INTERNAL_DECODER_VC1 | INTERNAL_DECODER_VC1_DXVA
- if(!(ffmpeg_filters & FFM_VC1) && !(dxva_filters & DXVA_VC1))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
- }
+ if (!(ffmpeg_filters & FFM_VC1) && !(dxva_filters & DXVA_VC1))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
+ }
#endif
#if INTERNAL_DECODER_XVID
- if(!(ffmpeg_filters & FFM_XVID))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
- }
+ if (!(ffmpeg_filters & FFM_XVID))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
+ }
#endif
#if INTERNAL_DECODER_DIVX
- if(!(ffmpeg_filters & FFM_DIVX))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
- }
+ if (!(ffmpeg_filters & FFM_DIVX))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
+ }
#endif
#if INTERNAL_DECODER_WMV
- if(!(ffmpeg_filters & FFM_WMV))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
- }
+ if (!(ffmpeg_filters & FFM_WMV))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
+ }
#endif
#if INTERNAL_DECODER_MSMPEG4
- if(!(ffmpeg_filters & FFM_MSMPEG4))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
- }
+ if (!(ffmpeg_filters & FFM_MSMPEG4))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
+ }
#endif
#if INTERNAL_DECODER_SVQ
- if(!(ffmpeg_filters & FFM_SVQ3))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
- }
+ if (!(ffmpeg_filters & FFM_SVQ3))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
+ }
#endif
#if INTERNAL_DECODER_H263
- if(!(ffmpeg_filters & FFM_H263))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
- }
+ if (!(ffmpeg_filters & FFM_H263))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
+ }
#endif
#if INTERNAL_DECODER_THEORA
- if(!(ffmpeg_filters & FFM_THEORA))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
- }
+ if (!(ffmpeg_filters & FFM_THEORA))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
+ }
#endif
#if INTERNAL_DECODER_AMVV
- if(!(ffmpeg_filters & FFM_AMVV))
- {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
- }
+ if (!(ffmpeg_filters & FFM_AMVV))
+ {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
+ }
#endif
- m_transform.AddTail(pFGF);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_MPEG2
- // Keep software decoder after DXVA decoder !
- pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
- (tra & TRA_MPEG2) ? ResStr(IDS_FGMANAGER_1) : L"MPEG-2 Video Decoder (low merit)",
- (tra & TRA_MPEG2) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- m_transform.AddTail(pFGF);
-#endif
-
- // Low merit MPC Audio Decoder
- /*
- // TODO : not finished!
- pFGF = DNew CFGFilterInternal<CMPCAudioDecFilter>(_T("MPC Audio Decoder (low merit)"), MERIT64_ABOVE_DSHOW);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_IMA_AMV);
- m_transform.AddTail(pFGF);
- */
+ // Keep software decoder after DXVA decoder !
+ pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
+ (tra & TRA_MPEG2) ? ResStr(IDS_FGMANAGER_1) : L"MPEG-2 Video Decoder (low merit)",
+ (tra & TRA_MPEG2) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ m_transform.AddTail(pFGF);
+#endif
+
+ // Low merit MPC Audio Decoder
+ /*
+ // TODO : not finished!
+ pFGF = DNew CFGFilterInternal<CMPCAudioDecFilter>(_T("MPC Audio Decoder (low merit)"), MERIT64_ABOVE_DSHOW);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_IMA_AMV);
+ m_transform.AddTail(pFGF);
+ */
#if INCLUDE_MPC_VIDEO_DECODER | INCLUDE_MPC_DXVA_VIDEO_DECODER
- CMPCVideoDecFilter::FFmpegFilters = s.FFmpegFilters;
- CMPCVideoDecFilter::DXVAFilters = s.DXVAFilters;
+ CMPCVideoDecFilter::FFmpegFilters = s.FFmpegFilters;
+ CMPCVideoDecFilter::DXVAFilters = s.DXVAFilters;
- CMPCVideoDecFilter::m_ref_frame_count_check_skip = false;
- if((!AfxGetMyApp()->IsVistaOrAbove()) && ((s.iDSVideoRendererType == VIDRNDT_DS_DEFAULT) || (s.iDSVideoRendererType == VIDRNDT_DS_DXR)))
- {
- CMPCVideoDecFilter::m_ref_frame_count_check_skip = true;
- }
+ CMPCVideoDecFilter::m_ref_frame_count_check_skip = false;
+ if((!AfxGetMyApp()->IsVistaOrAbove()) && ((s.iDSVideoRendererType == VIDRNDT_DS_DEFAULT) || (s.iDSVideoRendererType == VIDRNDT_DS_DXR)))
+ {
+ CMPCVideoDecFilter::m_ref_frame_count_check_skip = true;
+ }
#endif
- // Blocked filters
-
- // "Subtitle Mixer" makes an access violation around the
- // 11-12th media type when enumerating them on its output.
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{00A95963-3BE5-48C0-AD9F-3356D67EA09D}")), MERIT64_DO_NOT_USE));
-
- // DiracSplitter.ax is crashing MPC-HC when opening invalid files...
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{09E7F58E-71A1-419D-B0A0-E524AE1454A9}")), MERIT64_DO_NOT_USE));
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{5899CFB9-948F-4869-A999-5544ECB38BA5}")), MERIT64_DO_NOT_USE));
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F78CF248-180E-4713-B107-B13F7B5C31E1}")), MERIT64_DO_NOT_USE));
-
- // ISCR suxx
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}")), MERIT64_DO_NOT_USE));
-
- // Samsung's "mpeg-4 demultiplexor" can even open matroska files, amazing...
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{99EC0C72-4D1B-411B-AB1F-D561EE049D94}")), MERIT64_DO_NOT_USE));
-
- // LG Video Renderer (lgvid.ax) just crashes when trying to connect it
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9F711C60-0668-11D0-94D4-0000C02BA972}")), MERIT64_DO_NOT_USE));
-
- // palm demuxer crashes (even crashes graphedit when dropping an .ac3 onto it)
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{BE2CF8A7-08CE-4A2C-9A25-FD726A999196}")), MERIT64_DO_NOT_USE));
-
- // DCDSPFilter (early versions crash mpc)
- {
- CRegKey key;
-
- TCHAR buff[256];
- ULONG len = sizeof(buff);
- memset(buff, 0, len);
-
- CString clsid = _T("{B38C58A0-1809-11D6-A458-EDAE78F1DF12}");
-
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + clsid + _T("\\InprocServer32"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)
- && GetFileVersion(buff) < 0x0001000000030000ui64)
- {
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(clsid), MERIT64_DO_NOT_USE));
- }
- }
-
- /*
- // NVIDIA Transport Demux crashed for someone, I could not reproduce it
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{735823C1-ACC4-11D3-85AC-006008376FB8}")), MERIT64_DO_NOT_USE));
- */
-
- // mainconcept color space converter
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{272D77A0-A852-4851-ADA4-9091FEAD4C86}")), MERIT64_DO_NOT_USE));
-
- // Block VSFilter when internal subtitle renderer will get used
- if(s.fAutoloadSubtitles && s.fBlockVSFilter)
- {
- if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_DXR || s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- {
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}")), MERIT64_DO_NOT_USE));
- }
- }
-
- // Overrides
-
- WORD merit_low = 1;
-
- POSITION pos = s.filters.GetTailPosition();
- while(pos)
- {
- FilterOverride* fo = s.filters.GetPrev(pos);
-
- if(!fo->fDisabled && fo->name == _T("Broadcom Video Decoder"))
- bOverrideBroadcom = true;
-
- if(fo->fDisabled || fo->type == FilterOverride::EXTERNAL && !CPath(MakeFullPath(fo->path)).FileExists())
- continue;
-
- ULONGLONG merit =
- fo->iLoadType == FilterOverride::PREFERRED ? MERIT64_ABOVE_DSHOW :
- fo->iLoadType == FilterOverride::MERIT ? MERIT64(fo->dwMerit) :
- MERIT64_DO_NOT_USE; // fo->iLoadType == FilterOverride::BLOCKED
-
- merit += merit_low++;
-
- CFGFilter* pFGF = NULL;
-
- if(fo->type == FilterOverride::REGISTERED)
- {
- pFGF = DNew CFGFilterRegistry(fo->dispname, merit);
- }
- else if(fo->type == FilterOverride::EXTERNAL)
- {
- pFGF = DNew CFGFilterFile(fo->clsid, fo->path, CStringW(fo->name), merit);
- }
-
- if(pFGF)
- {
- pFGF->SetTypes(fo->guids);
- m_override.AddTail(pFGF);
- }
- }
-
- /* Use Broadcom decoder (if installed) for VC-1, H.264 and MPEG-2 */
- if(!bOverrideBroadcom)
- {
- pFGF = DNew CFGFilterRegistry(GUIDFromCString(_T("{2DE1D17E-46B1-42A8-9AEC-E20E80D9B1A9}")), MERIT64_ABOVE_DSHOW);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
-
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
-
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- m_transform.AddHead(pFGF);
- }
+ // Blocked filters
+
+ // "Subtitle Mixer" makes an access violation around the
+ // 11-12th media type when enumerating them on its output.
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{00A95963-3BE5-48C0-AD9F-3356D67EA09D}")), MERIT64_DO_NOT_USE));
+
+ // DiracSplitter.ax is crashing MPC-HC when opening invalid files...
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{09E7F58E-71A1-419D-B0A0-E524AE1454A9}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{5899CFB9-948F-4869-A999-5544ECB38BA5}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F78CF248-180E-4713-B107-B13F7B5C31E1}")), MERIT64_DO_NOT_USE));
+
+ // ISCR suxx
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}")), MERIT64_DO_NOT_USE));
+
+ // Samsung's "mpeg-4 demultiplexor" can even open matroska files, amazing...
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{99EC0C72-4D1B-411B-AB1F-D561EE049D94}")), MERIT64_DO_NOT_USE));
+
+ // LG Video Renderer (lgvid.ax) just crashes when trying to connect it
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9F711C60-0668-11D0-94D4-0000C02BA972}")), MERIT64_DO_NOT_USE));
+
+ // palm demuxer crashes (even crashes graphedit when dropping an .ac3 onto it)
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{BE2CF8A7-08CE-4A2C-9A25-FD726A999196}")), MERIT64_DO_NOT_USE));
+
+ // DCDSPFilter (early versions crash mpc)
+ {
+ CRegKey key;
+
+ TCHAR buff[256];
+ ULONG len = sizeof(buff);
+ memset(buff, 0, len);
+
+ CString clsid = _T("{B38C58A0-1809-11D6-A458-EDAE78F1DF12}");
+
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + clsid + _T("\\InprocServer32"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)
+ && GetFileVersion(buff) < 0x0001000000030000ui64)
+ {
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(clsid), MERIT64_DO_NOT_USE));
+ }
+ }
+
+/*
+ // NVIDIA Transport Demux crashed for someone, I could not reproduce it
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{735823C1-ACC4-11D3-85AC-006008376FB8}")), MERIT64_DO_NOT_USE));
+*/
+
+ // mainconcept color space converter
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{272D77A0-A852-4851-ADA4-9091FEAD4C86}")), MERIT64_DO_NOT_USE));
+
+ // Block VSFilter when internal subtitle renderer will get used
+ if(s.fAutoloadSubtitles && s.fBlockVSFilter) {
+ if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_DXR || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}")), MERIT64_DO_NOT_USE));
+ }
+ }
+
+ // Overrides
+
+ WORD merit_low = 1;
+
+ POSITION pos = s.filters.GetTailPosition();
+ while(pos)
+ {
+ FilterOverride* fo = s.filters.GetPrev(pos);
+
+ if (!fo->fDisabled && fo->name == _T("Broadcom Video Decoder"))
+ bOverrideBroadcom = true;
+
+ if(fo->fDisabled || fo->type == FilterOverride::EXTERNAL && !CPath(MakeFullPath(fo->path)).FileExists())
+ continue;
+
+ ULONGLONG merit =
+ fo->iLoadType == FilterOverride::PREFERRED ? MERIT64_ABOVE_DSHOW :
+ fo->iLoadType == FilterOverride::MERIT ? MERIT64(fo->dwMerit) :
+ MERIT64_DO_NOT_USE; // fo->iLoadType == FilterOverride::BLOCKED
+
+ merit += merit_low++;
+
+ CFGFilter* pFGF = NULL;
+
+ if(fo->type == FilterOverride::REGISTERED)
+ {
+ pFGF = DNew CFGFilterRegistry(fo->dispname, merit);
+ }
+ else if(fo->type == FilterOverride::EXTERNAL)
+ {
+ pFGF = DNew CFGFilterFile(fo->clsid, fo->path, CStringW(fo->name), merit);
+ }
+
+ if(pFGF)
+ {
+ pFGF->SetTypes(fo->guids);
+ m_override.AddTail(pFGF);
+ }
+ }
+
+ /* Use Broadcom decoder (if installed) for VC-1, H.264 and MPEG-2 */
+ if (!bOverrideBroadcom)
+ {
+ pFGF = DNew CFGFilterRegistry(GUIDFromCString(_T("{2DE1D17E-46B1-42A8-9AEC-E20E80D9B1A9}")), MERIT64_ABOVE_DSHOW);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
+
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
+
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ m_transform.AddHead(pFGF);
+ }
}
STDMETHODIMP CFGManagerCustom::AddFilter(IBaseFilter* pBF, LPCWSTR pName)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if(FAILED(hr = __super::AddFilter(pBF, pName)))
- return hr;
-
- AppSettings& s = AfxGetAppSettings();
-
- if(GetCLSID(pBF) == CLSID_DMOWrapperFilter)
- {
- if(CComQIPtr<IPropertyBag> pPB = pBF)
- {
- CComVariant var(true);
- pPB->Write(CComBSTR(L"_HIRESOUTPUT"), &var);
- }
- }
-
- if(CComQIPtr<IAudioSwitcherFilter> pASF = pBF)
- {
- pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
- pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
- pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64 * s.tAudioTimeShift : 0);
- pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.AudioBoost);
- }
-
- return hr;
+ if(FAILED(hr = __super::AddFilter(pBF, pName)))
+ return hr;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if(GetCLSID(pBF) == CLSID_DMOWrapperFilter)
+ {
+ if(CComQIPtr<IPropertyBag> pPB = pBF)
+ {
+ CComVariant var(true);
+ pPB->Write(CComBSTR(L"_HIRESOUTPUT"), &var);
+ }
+ }
+
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = pBF)
+ {
+ pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
+ pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
+ pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64*s.tAudioTimeShift : 0);
+ pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.AudioBoost);
+ }
+
+ return hr;
}
//
@@ -2449,151 +2408,151 @@ STDMETHODIMP CFGManagerCustom::AddFilter(IBaseFilter* pBF, LPCWSTR pName)
//
CFGManagerPlayer::CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerCustom(pName, pUnk)
- , m_hWnd(hWnd)
- , m_vrmerit(MERIT64(MERIT_PREFERRED))
- , m_armerit(MERIT64(MERIT_PREFERRED))
+ : CFGManagerCustom(pName, pUnk)
+ , m_hWnd(hWnd)
+ , m_vrmerit(MERIT64(MERIT_PREFERRED))
+ , m_armerit(MERIT64(MERIT_PREFERRED))
{
- TRACE("--> CFGManagerPlayer::CFGManagerPlayer on thread: %d\n", GetCurrentThreadId());
- CFGFilter* pFGF;
-
- AppSettings& s = AfxGetAppSettings();
-
- if(m_pFM)
- {
- CComPtr<IEnumMoniker> pEM;
-
- GUID guids[] = {MEDIATYPE_Video, MEDIASUBTYPE_NULL};
-
- if(SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE + 1,
- TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL)))
- {
- for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
- {
- CFGFilterRegistry f(pMoniker);
- m_vrmerit = max(m_vrmerit, f.GetMerit());
- }
- }
-
- m_vrmerit += 0x100;
- }
-
- if(m_pFM)
- {
- CComPtr<IEnumMoniker> pEM;
-
- GUID guids[] = {MEDIATYPE_Audio, MEDIASUBTYPE_NULL};
-
- if(SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE + 1,
- TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL)))
- {
- for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
- {
- CFGFilterRegistry f(pMoniker);
- m_armerit = max(m_armerit, f.GetMerit());
- }
- }
-
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
- {
- CFGFilterRegistry f(pMoniker);
- m_armerit = max(m_armerit, f.GetMerit());
- }
- EndEnumSysDev
-
- m_armerit += 0x100;
- }
-
- // Switchers
-
- if(s.fEnableAudioSwitcher)
- {
- pFGF = DNew CFGFilterInternal<CAudioSwitcherFilter>(L"Audio Switcher", m_armerit + 0x100);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
-
- // morgan stream switcher
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
- }
-
- // Renderers
-
- if(s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER)
- m_transform.AddTail(DNew CFGFilterRegistry(CLSID_VideoRenderer, m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7WINDOWED)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer, L"Video Mixing Render 7 (Windowed)", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR9WINDOWED)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer9, L"Video Mixing Render 9 (Windowed)", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR7AllocatorPresenter, L"Video Mixing Render 7 (Renderless)", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR9AllocatorPresenter, L"Video Mixing Render 9 (Renderless)", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_EVR)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EnhancedVideoRenderer, L"Enhanced Video Renderer", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EVRAllocatorPresenter, L"Enhanced Video Renderer (custom presenter)", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_DXR)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_DXRAllocatorPresenter, L"Haali's Video Renderer", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_MADVR)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_madVRAllocatorPresenter, L"madVR Renderer", m_vrmerit));
+ TRACE("--> CFGManagerPlayer::CFGManagerPlayer on thread: %d\n", GetCurrentThreadId());
+ CFGFilter* pFGF;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if(m_pFM)
+ {
+ CComPtr<IEnumMoniker> pEM;
+
+ GUID guids[] = {MEDIATYPE_Video, MEDIASUBTYPE_NULL};
+
+ if(SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE+1,
+ TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL)))
+ {
+ for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
+ {
+ CFGFilterRegistry f(pMoniker);
+ m_vrmerit = max(m_vrmerit, f.GetMerit());
+ }
+ }
+
+ m_vrmerit += 0x100;
+ }
+
+ if(m_pFM)
+ {
+ CComPtr<IEnumMoniker> pEM;
+
+ GUID guids[] = {MEDIATYPE_Audio, MEDIASUBTYPE_NULL};
+
+ if(SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE+1,
+ TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL)))
+ {
+ for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
+ {
+ CFGFilterRegistry f(pMoniker);
+ m_armerit = max(m_armerit, f.GetMerit());
+ }
+ }
+
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
+ {
+ CFGFilterRegistry f(pMoniker);
+ m_armerit = max(m_armerit, f.GetMerit());
+ }
+ EndEnumSysDev
+
+ m_armerit += 0x100;
+ }
+
+ // Switchers
+
+ if(s.fEnableAudioSwitcher)
+ {
+ pFGF = DNew CFGFilterInternal<CAudioSwitcherFilter>(L"Audio Switcher", m_armerit + 0x100);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+
+ // morgan stream switcher
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
+ }
+
+ // Renderers
+
+ if(s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER)
+ m_transform.AddTail(DNew CFGFilterRegistry(CLSID_VideoRenderer, m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7WINDOWED)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer, L"Video Mixing Render 7 (Windowed)", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR9WINDOWED)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer9, L"Video Mixing Render 9 (Windowed)", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR7AllocatorPresenter, L"Video Mixing Render 7 (Renderless)", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR9AllocatorPresenter, L"Video Mixing Render 9 (Renderless)", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_EVR)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EnhancedVideoRenderer, L"Enhanced Video Renderer", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EVRAllocatorPresenter, L"Enhanced Video Renderer (custom presenter)", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_DXR)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_DXRAllocatorPresenter, L"Haali's Video Renderer", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_MADVR)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_madVRAllocatorPresenter, L"madVR Renderer", m_vrmerit));
// m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_madVR, L"Madshi Video Renderer", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_SyncAllocatorPresenter, L"Sync Renderer", m_vrmerit));
- else if(s.iDSVideoRendererType == VIDRNDT_DS_NULL_COMP)
- {
- pFGF = DNew CFGFilterInternal<CNullVideoRenderer>(L"Null Video Renderer (Any)", MERIT64_ABOVE_DSHOW + 2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- }
- else if(s.iDSVideoRendererType == VIDRNDT_DS_NULL_UNCOMP)
- {
- pFGF = DNew CFGFilterInternal<CNullUVideoRenderer>(L"Null Video Renderer (Uncompressed)", MERIT64_ABOVE_DSHOW + 2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- }
-
- CString SelAudioRender = s.SelectedAudioRender();
- if(SelAudioRender == AUDRNDT_NULL_COMP)
- {
- pFGF = DNew CFGFilterInternal<CNullAudioRenderer>(AUDRNDT_NULL_COMP, MERIT64_ABOVE_DSHOW + 2);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- }
- else if(SelAudioRender == AUDRNDT_NULL_UNCOMP)
- {
- pFGF = DNew CFGFilterInternal<CNullUAudioRenderer>(AUDRNDT_NULL_UNCOMP, MERIT64_ABOVE_DSHOW + 2);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- }
- else if(SelAudioRender == AUDRNDT_MPC)
- {
- pFGF = DNew CFGFilterInternal<CMpcAudioRenderer>(AUDRNDT_MPC, MERIT64_ABOVE_DSHOW + 2);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- }
- else if(SelAudioRender != "")
- {
- pFGF = DNew CFGFilterRegistry(SelAudioRender, m_armerit);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- }
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_SyncAllocatorPresenter, L"Sync Renderer", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_NULL_COMP)
+ {
+ pFGF = DNew CFGFilterInternal<CNullVideoRenderer>(L"Null Video Renderer (Any)", MERIT64_ABOVE_DSHOW+2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ }
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_NULL_UNCOMP)
+ {
+ pFGF = DNew CFGFilterInternal<CNullUVideoRenderer>(L"Null Video Renderer (Uncompressed)", MERIT64_ABOVE_DSHOW+2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ }
+
+ CString SelAudioRender = s.SelectedAudioRender();
+ if(SelAudioRender == AUDRNDT_NULL_COMP)
+ {
+ pFGF = DNew CFGFilterInternal<CNullAudioRenderer>(AUDRNDT_NULL_COMP, MERIT64_ABOVE_DSHOW+2);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ }
+ else if(SelAudioRender == AUDRNDT_NULL_UNCOMP)
+ {
+ pFGF = DNew CFGFilterInternal<CNullUAudioRenderer>(AUDRNDT_NULL_UNCOMP, MERIT64_ABOVE_DSHOW+2);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ }
+ else if(SelAudioRender == AUDRNDT_MPC)
+ {
+ pFGF = DNew CFGFilterInternal<CMpcAudioRenderer>(AUDRNDT_MPC, MERIT64_ABOVE_DSHOW+2);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ }
+ else if(SelAudioRender!="")
+ {
+ pFGF = DNew CFGFilterRegistry(SelAudioRender, m_armerit);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ }
}
STDMETHODIMP CFGManagerPlayer::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if(GetCLSID(pPinOut) == CLSID_MPEG2Demultiplexer)
- {
- CComQIPtr<IMediaSeeking> pMS = pPinOut;
- REFERENCE_TIME rtDur = 0;
- if(!pMS || FAILED(pMS->GetDuration(&rtDur)) || rtDur <= 0)
- return E_FAIL;
- }
+ if(GetCLSID(pPinOut) == CLSID_MPEG2Demultiplexer)
+ {
+ CComQIPtr<IMediaSeeking> pMS = pPinOut;
+ REFERENCE_TIME rtDur = 0;
+ if(!pMS || FAILED(pMS->GetDuration(&rtDur)) || rtDur <= 0)
+ return E_FAIL;
+ }
- return __super::ConnectDirect(pPinOut, pPinIn, pmt);
+ return __super::ConnectDirect(pPinOut, pPinIn, pmt);
}
//
@@ -2601,16 +2560,16 @@ STDMETHODIMP CFGManagerPlayer::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const
//
CFGManagerDVD::CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerPlayer(pName, pUnk, hWnd)
+ : CFGManagerPlayer(pName, pUnk, hWnd)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- // have to avoid the old video renderer
- if(!s.fXpOrBetter && s.iDSVideoRendererType != VIDRNDT_DS_OVERLAYMIXER || s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER)
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit - 1));
+ // have to avoid the old video renderer
+ if(!s.fXpOrBetter && s.iDSVideoRendererType != VIDRNDT_DS_OVERLAYMIXER || s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER)
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit-1));
- // elecard's decoder isn't suited for dvd playback (atm)
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F50B3F13-19C4-11CF-AA9A-02608C9BABA2}")), MERIT64_DO_NOT_USE));
+ // elecard's decoder isn't suited for dvd playback (atm)
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F50B3F13-19C4-11CF-AA9A-02608C9BABA2}")), MERIT64_DO_NOT_USE));
}
#include "../../decss/VobFile.h"
@@ -2618,77 +2577,73 @@ CFGManagerDVD::CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
class CResetDVD : public CDVDSession
{
public:
- CResetDVD(LPCTSTR path)
- {
- if(Open(path))
- {
- if(BeginSession())
- {
- Authenticate(); /*GetDiscKey();*/
- EndSession();
- }
- Close();
- }
- }
+ CResetDVD(LPCTSTR path)
+ {
+ if(Open(path))
+ {
+ if(BeginSession()) {Authenticate(); /*GetDiscKey();*/ EndSession();}
+ Close();
+ }
+ }
};
STDMETHODIMP CFGManagerDVD::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- CComPtr<IBaseFilter> pBF;
- if(FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF)))
- return hr;
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF)))
+ return hr;
- return ConnectFilter(pBF, NULL);
+ return ConnectFilter(pBF, NULL);
}
STDMETHODIMP CFGManagerDVD::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(lpcwstrFileName, E_POINTER);
- CheckPointer(ppFilter, E_POINTER);
+ CheckPointer(lpcwstrFileName, E_POINTER);
+ CheckPointer(ppFilter, E_POINTER);
- HRESULT hr;
+ HRESULT hr;
- CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
- CStringW protocol = fn.Left(fn.Find(':') + 1).TrimRight(':').MakeLower();
- CStringW ext = CPathW(fn).GetExtension().MakeLower();
+ CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
+ CStringW protocol = fn.Left(fn.Find(':')+1).TrimRight(':').MakeLower();
+ CStringW ext = CPathW(fn).GetExtension().MakeLower();
- GUID clsid = ext == L".ratdvd" ? GUIDFromCString(_T("{482d10b6-376e-4411-8a17-833800A065DB}")) : CLSID_DVDNavigator;
+ GUID clsid = ext == L".ratdvd" ? GUIDFromCString(_T("{482d10b6-376e-4411-8a17-833800A065DB}")) : CLSID_DVDNavigator;
- CComPtr<IBaseFilter> pBF;
- if(FAILED(hr = pBF.CoCreateInstance(clsid))
- || FAILED(hr = AddFilter(pBF, L"DVD Navigator")))
- return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(hr = pBF.CoCreateInstance(clsid))
+ || FAILED(hr = AddFilter(pBF, L"DVD Navigator")))
+ return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
- CComQIPtr<IDvdControl2> pDVDC;
- CComQIPtr<IDvdInfo2> pDVDI;
+ CComQIPtr<IDvdControl2> pDVDC;
+ CComQIPtr<IDvdInfo2> pDVDI;
- if(!((pDVDC = pBF) && (pDVDI = pBF)))
- return E_NOINTERFACE;
+ if(!((pDVDC = pBF) && (pDVDI = pBF)))
+ return E_NOINTERFACE;
- WCHAR buff[_MAX_PATH];
- ULONG len;
- if((!fn.IsEmpty()
- && FAILED(hr = pDVDC->SetDVDDirectory(fn))
- && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"VIDEO_TS"))
- && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"\\VIDEO_TS")))
- || FAILED(hr = pDVDI->GetDVDDirectory(buff, countof(buff), &len)) || len == 0)
- return E_INVALIDARG;
+ WCHAR buff[_MAX_PATH];
+ ULONG len;
+ if((!fn.IsEmpty()
+ && FAILED(hr = pDVDC->SetDVDDirectory(fn))
+ && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"VIDEO_TS"))
+ && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"\\VIDEO_TS")))
+ || FAILED(hr = pDVDI->GetDVDDirectory(buff, countof(buff), &len)) || len == 0)
+ return E_INVALIDARG;
- pDVDC->SetOption(DVD_ResetOnStop, FALSE);
- pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
+ pDVDC->SetOption(DVD_ResetOnStop, FALSE);
+ pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
- if(clsid == CLSID_DVDNavigator)
- CResetDVD(CString(buff));
+ if(clsid == CLSID_DVDNavigator)
+ CResetDVD(CString(buff));
- *ppFilter = pBF.Detach();
+ *ppFilter = pBF.Detach();
- return S_OK;
+ return S_OK;
}
//
@@ -2696,16 +2651,16 @@ STDMETHODIMP CFGManagerDVD::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpc
//
CFGManagerCapture::CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerPlayer(pName, pUnk, hWnd)
+ : CFGManagerPlayer(pName, pUnk, hWnd)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CFGFilter* pFGF = DNew CFGFilterInternal<CDeinterlacerFilter>(L"Deinterlacer", m_vrmerit + 0x100);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
+ CFGFilter* pFGF = DNew CFGFilterInternal<CDeinterlacerFilter>(L"Deinterlacer", m_vrmerit + 0x100);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
- // morgan stream switcher
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
+ // morgan stream switcher
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
}
//
@@ -2713,10 +2668,10 @@ CFGManagerCapture::CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
//
CFGManagerMuxer::CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk)
- : CFGManagerCustom(pName, pUnk)
+ : CFGManagerCustom(pName, pUnk)
{
- m_source.AddTail(DNew CFGFilterInternal<CSubtitleSourceASS>());
- m_source.AddTail(DNew CFGFilterInternal<CSSFSourceFilter>());
+ m_source.AddTail(DNew CFGFilterInternal<CSubtitleSourceASS>());
+ m_source.AddTail(DNew CFGFilterInternal<CSSFSourceFilter>());
}
//
@@ -2724,21 +2679,21 @@ CFGManagerMuxer::CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk)
//
CFGAggregator::CFGAggregator(const CLSID& clsid, LPCTSTR pName, LPUNKNOWN pUnk, HRESULT& hr)
- : CUnknown(pName, pUnk)
+ : CUnknown(pName, pUnk)
{
- hr = m_pUnkInner.CoCreateInstance(clsid, GetOwner());
+ hr = m_pUnkInner.CoCreateInstance(clsid, GetOwner());
}
CFGAggregator::~CFGAggregator()
{
- m_pUnkInner.Release();
+ m_pUnkInner.Release();
}
STDMETHODIMP CFGAggregator::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
diff --git a/src/apps/mplayerc/FGManager.h b/src/apps/mplayerc/FGManager.h
index f1f0ed25c..33cb7970e 100644
--- a/src/apps/mplayerc/FGManager.h
+++ b/src/apps/mplayerc/FGManager.h
@@ -28,148 +28,144 @@
class CFGManager
- : public CUnknown
- , public IGraphBuilder2
- , public IGraphBuilderDeadEnd
- , public CCritSec
+ : public CUnknown
+ , public IGraphBuilder2
+ , public IGraphBuilderDeadEnd
+ , public CCritSec
{
public:
- struct path_t
- {
- CLSID clsid;
- CString filter, pin;
- };
-
- class CStreamPath : public CAtlList<path_t>
- {
- public:
- void Append(IBaseFilter* pBF, IPin* pPin);
- bool Compare(const CStreamPath& path);
- };
-
- class CStreamDeadEnd : public CStreamPath
- {
- public:
- CAtlList<CMediaType> mts;
- };
+ struct path_t {CLSID clsid; CString filter, pin;};
+
+ class CStreamPath : public CAtlList<path_t>
+ {
+ public:
+ void Append(IBaseFilter* pBF, IPin* pPin);
+ bool Compare(const CStreamPath& path);
+ };
+
+ class CStreamDeadEnd : public CStreamPath
+ {
+ public:
+ CAtlList<CMediaType> mts;
+ };
private:
- CComPtr<IUnknown> m_pUnkInner;
- DWORD m_dwRegister;
+ CComPtr<IUnknown> m_pUnkInner;
+ DWORD m_dwRegister;
- CStreamPath m_streampath;
- CAutoPtrArray<CStreamDeadEnd> m_deadends;
+ CStreamPath m_streampath;
+ CAutoPtrArray<CStreamDeadEnd> m_deadends;
protected:
- CComPtr<IFilterMapper2> m_pFM;
- CInterfaceList<IUnknown, &IID_IUnknown> m_pUnks;
- CAtlList<CFGFilter*> m_source, m_transform, m_override;
+ CComPtr<IFilterMapper2> m_pFM;
+ CInterfaceList<IUnknown, &IID_IUnknown> m_pUnks;
+ CAtlList<CFGFilter*> m_source, m_transform, m_override;
- static bool CheckBytes(HANDLE hFile, CString chkbytes);
+ static bool CheckBytes(HANDLE hFile, CString chkbytes);
- HRESULT EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl);
- HRESULT AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppBF);
- HRESULT Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender);
+ HRESULT EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl);
+ HRESULT AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppBF);
+ HRESULT Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender);
- // IFilterGraph
+ // IFilterGraph
- STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
- STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
- STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
- STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
- STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP Reconnect(IPin* ppin);
- STDMETHODIMP Disconnect(IPin* ppin);
- STDMETHODIMP SetDefaultSyncSource();
+ STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
+ STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
+ STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
+ STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
+ STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP Reconnect(IPin* ppin);
+ STDMETHODIMP Disconnect(IPin* ppin);
+ STDMETHODIMP SetDefaultSyncSource();
- // IGraphBuilder
+ // IGraphBuilder
- STDMETHODIMP Connect(IPin* pPinOut, IPin* pPinIn);
- STDMETHODIMP Render(IPin* pPinOut);
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP SetLogFile(DWORD_PTR hFile);
- STDMETHODIMP Abort();
- STDMETHODIMP ShouldOperationContinue();
+ STDMETHODIMP Connect(IPin* pPinOut, IPin* pPinIn);
+ STDMETHODIMP Render(IPin* pPinOut);
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP SetLogFile(DWORD_PTR hFile);
+ STDMETHODIMP Abort();
+ STDMETHODIMP ShouldOperationContinue();
- // IFilterGraph2
+ // IFilterGraph2
- STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
+ STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
- // IGraphBuilder2
+ // IGraphBuilder2
- STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
- STDMETHODIMP IsPinConnected(IPin* pPin);
- STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
- STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
- STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP NukeDownstream(IUnknown* pUnk);
- STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
- STDMETHODIMP AddToROT();
- STDMETHODIMP RemoveFromROT();
+ STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
+ STDMETHODIMP IsPinConnected(IPin* pPin);
+ STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
+ STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
+ STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP NukeDownstream(IUnknown* pUnk);
+ STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
+ STDMETHODIMP AddToROT();
+ STDMETHODIMP RemoveFromROT();
- // IGraphBuilderDeadEnd
+ // IGraphBuilderDeadEnd
- STDMETHODIMP_(size_t) GetCount();
- STDMETHODIMP GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts);
+ STDMETHODIMP_(size_t) GetCount();
+ STDMETHODIMP GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts);
public:
- CFGManager(LPCTSTR pName, LPUNKNOWN pUnk);
- virtual ~CFGManager();
+ CFGManager(LPCTSTR pName, LPUNKNOWN pUnk);
+ virtual ~CFGManager();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
class CFGManagerCustom : public CFGManager
{
public:
- // IFilterGraph
+ // IFilterGraph
- STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
+ STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
public:
- CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk);
+ CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk);
};
class CFGManagerPlayer : public CFGManagerCustom
{
protected:
- HWND m_hWnd;
- UINT64 m_vrmerit, m_armerit;
+ HWND m_hWnd;
+ UINT64 m_vrmerit, m_armerit;
- // IFilterGraph
+ // IFilterGraph
- STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
public:
- CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
};
class CFGManagerDVD : public CFGManagerPlayer
{
protected:
- // IGraphBuilder
+ // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
public:
- CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
};
class CFGManagerCapture : public CFGManagerPlayer
{
public:
- CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
};
class CFGManagerMuxer : public CFGManagerCustom
{
public:
- CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk);
+ CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk);
};
//
@@ -177,12 +173,12 @@ public:
class CFGAggregator : public CUnknown
{
protected:
- CComPtr<IUnknown> m_pUnkInner;
+ CComPtr<IUnknown> m_pUnkInner;
public:
- CFGAggregator(const CLSID& clsid, LPCTSTR pName, LPUNKNOWN pUnk, HRESULT& hr);
- virtual ~CFGAggregator();
+ CFGAggregator(const CLSID& clsid, LPCTSTR pName, LPUNKNOWN pUnk, HRESULT& hr);
+ virtual ~CFGAggregator();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
diff --git a/src/apps/mplayerc/FGManagerBDA.cpp b/src/apps/mplayerc/FGManagerBDA.cpp
index d23f8015d..7155e1e1f 100644
--- a/src/apps/mplayerc/FGManagerBDA.cpp
+++ b/src/apps/mplayerc/FGManagerBDA.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -40,337 +40,320 @@
/// Format, Vidéo MPEG2
-static const MPEG2VIDEOINFO sMpv_fmt =
-{
- {
- // hdr
- {0, 0, 720, 576}, // rcSource
- {0, 0, 0, 0}, // rcTarget
- 0, // dwBitRate
- 0, // dwBitErrorRate
- 0, // AvgTimePerFrame
- 0, // dwInterlaceFlags
- 0, // dwCopyProtectFlags
- 4, // dwPictAspectRatioX
- 3, // dwPictAspectRatioY
- {0}, // dwControlFlag & dwReserved1
- 0, // dwReserved2
- {
- // bmiHeader
- sizeof(BITMAPINFOHEADER),// biSize
- 720, // biWidth
- 576 // biHeight
- }
- // le reste à zéro (implicite)
- }
+static const MPEG2VIDEOINFO sMpv_fmt = {
+ { // hdr
+ {0,0,720,576}, // rcSource
+ {0,0,0,0}, // rcTarget
+ 0, // dwBitRate
+ 0, // dwBitErrorRate
+ 0, // AvgTimePerFrame
+ 0, // dwInterlaceFlags
+ 0, // dwCopyProtectFlags
+ 4, // dwPictAspectRatioX
+ 3, // dwPictAspectRatioY
+ {0}, // dwControlFlag & dwReserved1
+ 0, // dwReserved2
+ { // bmiHeader
+ sizeof(BITMAPINFOHEADER),// biSize
+ 720, // biWidth
+ 576 // biHeight
+ }
+ // le reste à zéro (implicite)
+ }
};
/// Media type, Vidéo MPEG2
-static const AM_MEDIA_TYPE mt_Mpv =
-{
- MEDIATYPE_Video, // majortype
- MEDIASUBTYPE_MPEG2_VIDEO, // subtype
- FALSE, // bFixedSizeSamples
- TRUE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_MPEG2Video, // formattype
- NULL, // pUnk
- sizeof(sMpv_fmt), // cbFormat
- (LPBYTE)&sMpv_fmt // pbFormat
+static const AM_MEDIA_TYPE mt_Mpv = {
+ MEDIATYPE_Video, // majortype
+ MEDIASUBTYPE_MPEG2_VIDEO, // subtype
+ FALSE, // bFixedSizeSamples
+ TRUE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_MPEG2Video, // formattype
+ NULL, // pUnk
+ sizeof(sMpv_fmt), // cbFormat
+ (LPBYTE)&sMpv_fmt // pbFormat
};
#define FCC_h264 MAKEFOURCC('h', '2', '6', '4')
#define MS_NETWORK_PROVIDER "Microsoft Network Provider"
/// Format, Vidéo H264
-static const VIDEOINFOHEADER2 vih2_H264 =
-{
- {0, 0, 0, 0}, // rcSource
- {0, 0, 0, 0}, // rcTarget
- 0, // dwBitRate,
- 0, // dwBitErrorRate
- 0, // AvgTimePerFrame
- 0, // dwInterlaceFlags
- 0, // dwCopyProtectFlags
- 0, // dwPictAspectRatioX
- 0, // dwPictAspectRatioY
- {0}, // dwControlFlag & dwReserved1
- 0, // dwReserved2
- {
- // bmiHeader
- sizeof(BITMAPINFOHEADER), // biSize
- 720, // biWidth
- 576, // biHeight
- 0, // biPlanes
- 0, // biBitCount
- FCC_h264 // biCompression
- }
- // le reste à zéro (implicite)
+static const VIDEOINFOHEADER2 vih2_H264 = {
+ {0,0,0,0}, // rcSource
+ {0,0,0,0}, // rcTarget
+ 0, // dwBitRate,
+ 0, // dwBitErrorRate
+ 0, // AvgTimePerFrame
+ 0, // dwInterlaceFlags
+ 0, // dwCopyProtectFlags
+ 0, // dwPictAspectRatioX
+ 0, // dwPictAspectRatioY
+ {0}, // dwControlFlag & dwReserved1
+ 0, // dwReserved2
+ { // bmiHeader
+ sizeof(BITMAPINFOHEADER), // biSize
+ 720, // biWidth
+ 576, // biHeight
+ 0, // biPlanes
+ 0, // biBitCount
+ FCC_h264 // biCompression
+ }
+ // le reste à zéro (implicite)
};
/// Media type, Vidéo H264
-static const AM_MEDIA_TYPE mt_H264 =
-{
- MEDIATYPE_Video, // majortype
- MEDIASUBTYPE_H264, // subtype
- FALSE, // bFixedSizeSamples
- TRUE, // bTemporalCompression
- 1, // lSampleSize
- FORMAT_VideoInfo2, // formattype
- NULL, // pUnk
- sizeof(vih2_H264), // cbFormat
- (LPBYTE)&vih2_H264 // pbFormat
+static const AM_MEDIA_TYPE mt_H264 = {
+ MEDIATYPE_Video, // majortype
+ MEDIASUBTYPE_H264, // subtype
+ FALSE, // bFixedSizeSamples
+ TRUE, // bTemporalCompression
+ 1, // lSampleSize
+ FORMAT_VideoInfo2, // formattype
+ NULL, // pUnk
+ sizeof(vih2_H264), // cbFormat
+ (LPBYTE)&vih2_H264 // pbFormat
};
/// Format, Audio (commun)
-static const WAVEFORMATEX wf_Audio =
-{
- WAVE_FORMAT_PCM, // wFormatTag
- 2, // nChannels
- 48000, // nSamplesPerSec
- 4 * 48000, // nAvgBytesPerSec
- 4, // nBlockAlign
- 16, // wBitsPerSample
- 0 // cbSize
+static const WAVEFORMATEX wf_Audio = {
+ WAVE_FORMAT_PCM, // wFormatTag
+ 2, // nChannels
+ 48000, // nSamplesPerSec
+ 4*48000, // nAvgBytesPerSec
+ 4, // nBlockAlign
+ 16, // wBitsPerSample
+ 0 // cbSize
};
/// Media type, Audio MPEG2
-static const AM_MEDIA_TYPE mt_Mpa =
-{
- MEDIATYPE_Audio, // majortype
- MEDIASUBTYPE_MPEG2_AUDIO, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_WaveFormatEx, // formattype
- NULL, // pUnk
- sizeof(wf_Audio), // cbFormat
- (LPBYTE)&wf_Audio // pbFormat
+static const AM_MEDIA_TYPE mt_Mpa = {
+ MEDIATYPE_Audio, // majortype
+ MEDIASUBTYPE_MPEG2_AUDIO, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_WaveFormatEx, // formattype
+ NULL, // pUnk
+ sizeof(wf_Audio), // cbFormat
+ (LPBYTE)&wf_Audio // pbFormat
};
/// Media type, Audio AC3
-static const AM_MEDIA_TYPE mt_Ac3 =
-{
- MEDIATYPE_Audio, // majortype
- MEDIASUBTYPE_DOLBY_AC3, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_WaveFormatEx, // formattype
- NULL, // pUnk
- sizeof(wf_Audio), // cbFormat
- (LPBYTE)&wf_Audio, // pbFormat
+static const AM_MEDIA_TYPE mt_Ac3 = {
+ MEDIATYPE_Audio, // majortype
+ MEDIASUBTYPE_DOLBY_AC3, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_WaveFormatEx, // formattype
+ NULL, // pUnk
+ sizeof(wf_Audio), // cbFormat
+ (LPBYTE)&wf_Audio, // pbFormat
};
/// Media type, Audio EAC3
-static const AM_MEDIA_TYPE mt_Eac3 =
-{
- MEDIATYPE_Audio, // majortype
- MEDIASUBTYPE_DOLBY_DDPLUS, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_WaveFormatEx, // formattype
- NULL, // pUnk
- sizeof(wf_Audio), // cbFormat
- (LPBYTE)&wf_Audio, // pbFormat
+static const AM_MEDIA_TYPE mt_Eac3 = {
+ MEDIATYPE_Audio, // majortype
+ MEDIASUBTYPE_DOLBY_DDPLUS, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_WaveFormatEx, // formattype
+ NULL, // pUnk
+ sizeof(wf_Audio), // cbFormat
+ (LPBYTE)&wf_Audio, // pbFormat
};
/// Media type, PSI
-static const AM_MEDIA_TYPE mt_Psi =
-{
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_MPEG2DATA, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL // pbFormat
+static const AM_MEDIA_TYPE mt_Psi = {
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_MPEG2DATA, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL // pbFormat
};
/// Media type, TIF
-static const AM_MEDIA_TYPE mt_Tif =
-{
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_DVB_SI, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL // pbFormat
+static const AM_MEDIA_TYPE mt_Tif = {
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_DVB_SI, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL // pbFormat
};
/// Media type, EPG
-static const AM_MEDIA_TYPE mt_Epg =
-{
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_DVB_SI, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL, // pbFormat
+static const AM_MEDIA_TYPE mt_Epg = {
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_DVB_SI, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL, // pbFormat
};
/// Media type, PMT
-static const AM_MEDIA_TYPE mt_Pmt =
-{
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_DVB_SI, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL // pbFormat
+static const AM_MEDIA_TYPE mt_Pmt = {
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_DVB_SI, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL // pbFormat
};
static const SUBTITLEINFO SubFormat = { 0, "", L"" };
/// Media type, subtitle
-static const AM_MEDIA_TYPE mt_Subtitle =
-{
- MEDIATYPE_Subtitle, // majortype
- MEDIASUBTYPE_DVB_SUBTITLES, // subtype
- FALSE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- sizeof(SubFormat), // cbFormat
- (LPBYTE)&SubFormat // pbFormat
+static const AM_MEDIA_TYPE mt_Subtitle = {
+ MEDIATYPE_Subtitle, // majortype
+ MEDIASUBTYPE_DVB_SUBTITLES, // subtype
+ FALSE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ sizeof(SubFormat), // cbFormat
+ (LPBYTE)&SubFormat // pbFormat
};
/// CLSID pour TIF
// FC772AB0-0C7F-11D3-8FF2-00A0C9224CF4
static CLSID CLSID_BDA_MPEG2_TIF =
-{0xFC772AB0, 0x0C7F, 0x11D3, {0x8F, 0xF2, 0x00, 0xA0, 0xC9, 0x22, 0x4C, 0xF4}};
+ {0xFC772AB0, 0x0C7F, 0x11D3, {0x8F, 0xF2, 0x00, 0xA0, 0xC9, 0x22, 0x4C, 0xF4}};
CFGManagerBDA::CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerPlayer(pName, pUnk, hWnd)
-{
- m_DVBStreams[DVB_MPV] = CDVBStream(L"mpv", &mt_Mpv);
- m_DVBStreams[DVB_H264] = CDVBStream(L"h264", &mt_H264);
- m_DVBStreams[DVB_MPA] = CDVBStream(L"mpa", &mt_Mpa);
- m_DVBStreams[DVB_AC3] = CDVBStream(L"ac3", &mt_Ac3);
- m_DVBStreams[DVB_EAC3] = CDVBStream(L"eac3", &mt_Eac3);
- m_DVBStreams[DVB_PSI] = CDVBStream(L"psi", &mt_Psi, true, MEDIA_MPEG2_PSI);
- m_DVBStreams[DVB_TIF] = CDVBStream(L"tif", &mt_Tif, true);
- m_DVBStreams[DVB_EPG] = CDVBStream(L"epg", &mt_Epg);
-
- // Warning : MEDIA_ELEMENTARY_STREAM didn't works for subtitles with Windows XP!
- if(CMPlayerCApp::IsVistaOrAbove())
- m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle/*, false, MEDIA_TRANSPORT_PAYLOAD*/);
- else
- m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle, false, MEDIA_TRANSPORT_PAYLOAD);
-
- m_nCurVideoType = DVB_MPV;
- m_nCurAudioType = DVB_MPA;
-
- // Hack : remove audio switcher !
- POSITION pos = m_transform.GetHeadPosition();
- while(pos)
- {
- CFGFilter* pFGF = m_transform.GetAt(pos);
- if(pFGF->GetCLSID() == __uuidof(CAudioSwitcherFilter))
- {
- m_transform.RemoveAt(pos);
- delete pFGF;
- break;
- }
- m_transform.GetNext(pos);
- }
+ : CFGManagerPlayer (pName, pUnk, hWnd)
+{
+ m_DVBStreams[DVB_MPV] = CDVBStream(L"mpv", &mt_Mpv);
+ m_DVBStreams[DVB_H264] = CDVBStream(L"h264", &mt_H264);
+ m_DVBStreams[DVB_MPA] = CDVBStream(L"mpa", &mt_Mpa);
+ m_DVBStreams[DVB_AC3] = CDVBStream(L"ac3", &mt_Ac3);
+ m_DVBStreams[DVB_EAC3] = CDVBStream(L"eac3", &mt_Eac3);
+ m_DVBStreams[DVB_PSI] = CDVBStream(L"psi", &mt_Psi, true, MEDIA_MPEG2_PSI);
+ m_DVBStreams[DVB_TIF] = CDVBStream(L"tif", &mt_Tif, true);
+ m_DVBStreams[DVB_EPG] = CDVBStream(L"epg", &mt_Epg);
+
+ // Warning : MEDIA_ELEMENTARY_STREAM didn't works for subtitles with Windows XP!
+ if (CMPlayerCApp::IsVistaOrAbove())
+ m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle/*, false, MEDIA_TRANSPORT_PAYLOAD*/);
+ else
+ m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle, false, MEDIA_TRANSPORT_PAYLOAD);
+
+ m_nCurVideoType = DVB_MPV;
+ m_nCurAudioType = DVB_MPA;
+
+ // Hack : remove audio switcher !
+ POSITION pos = m_transform.GetHeadPosition();
+ while(pos)
+ {
+ CFGFilter* pFGF = m_transform.GetAt(pos);
+ if(pFGF->GetCLSID() == __uuidof(CAudioSwitcherFilter))
+ {
+ m_transform.RemoveAt (pos);
+ delete pFGF;
+ break;
+ }
+ m_transform.GetNext(pos);
+ }
}
CFGManagerBDA::~CFGManagerBDA()
{
- m_DVBStreams.RemoveAll();
+ m_DVBStreams.RemoveAll();
}
HRESULT CFGManagerBDA::CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName)
{
- HRESULT hr = VFW_E_NOT_FOUND;
- BeginEnumSysDev(KSCategory, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)) &&
- SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)) &&
- SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- {
- CStringW Name = CStringW(strName);
- if(Name != DisplayName) continue;
-
- hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)ppBF);
- if(SUCCEEDED(hr)) hr = AddFilter(*ppBF, CStringW(var.bstrVal));
- break;
- }
-
- if(strName) CoTaskMemFree(strName);
- }
- EndEnumSysDev
-
- return hr;
+ HRESULT hr = VFW_E_NOT_FOUND;
+ BeginEnumSysDev (KSCategory, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ LPOLESTR strName = NULL;
+ if (SUCCEEDED (pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)) &&
+ SUCCEEDED (pMoniker->GetDisplayName(NULL, NULL, &strName)) &&
+ SUCCEEDED (pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)) )
+ {
+ CStringW Name = CStringW(strName);
+ if (Name != DisplayName) continue;
+
+ hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)ppBF);
+ if (SUCCEEDED (hr)) hr = AddFilter (*ppBF, CStringW(var.bstrVal));
+ break;
+ }
+
+ if (strName) CoTaskMemFree(strName);
+ }
+ EndEnumSysDev
+
+ return hr;
}
HRESULT CFGManagerBDA::SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk)
{
- CComQIPtr<IBDA_Topology> pTop(pTuner);
- CheckPointer(pTop, E_NOINTERFACE);
+ CComQIPtr<IBDA_Topology> pTop(pTuner);
+ CheckPointer (pTop, E_NOINTERFACE);
- ULONG NodeTypes;
- ULONG NodeType[32];
+ ULONG NodeTypes;
+ ULONG NodeType[32];
- HRESULT hr = pTop->GetNodeTypes(&NodeTypes, _countof(NodeType), NodeType);
+ HRESULT hr = pTop->GetNodeTypes(&NodeTypes, _countof(NodeType), NodeType);
- if(FAILED(hr))
- return hr;
+ if (FAILED(hr))
+ return hr;
- for(ULONG i = 0; i < NodeTypes; i++)
- {
- ULONG nInterfaces;
- GUID aInterface[32];
+ for (ULONG i = 0; i < NodeTypes; i++)
+ {
+ ULONG nInterfaces;
+ GUID aInterface[32];
- hr = pTop->GetNodeInterfaces(NodeType[i], &nInterfaces, _countof(aInterface), aInterface);
+ hr = pTop->GetNodeInterfaces(NodeType[i], &nInterfaces, _countof(aInterface), aInterface);
- if(FAILED(hr))
- continue;
+ if (FAILED(hr))
+ continue;
- for(ULONG j = 0; j < nInterfaces; j++)
- {
- if(aInterface[j] == iid)
- return pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
- }
- }
+ for (ULONG j = 0; j < nInterfaces; j++) {
+ if (aInterface[j] == iid)
+ return pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
+ }
+ }
- return hr;
+ return hr;
}
HRESULT CFGManagerBDA::ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFilter)
{
- HRESULT hr = VFW_E_CANNOT_CONNECT;
- BeginEnumPins(pOutFiter, pEP, pOutPin)
- {
- if(S_OK == IsPinDirection(pOutPin, PINDIR_OUTPUT)
- && S_OK != IsPinConnected(pOutPin))
- {
- BeginEnumPins(pInFilter, pEP, pInPin)
- {
- if(S_OK == IsPinDirection(pInPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pInPin))
- {
- hr = this->ConnectDirect(pOutPin, pInPin, NULL);
+ HRESULT hr = VFW_E_CANNOT_CONNECT;
+ BeginEnumPins(pOutFiter, pEP, pOutPin)
+ {
+ if(S_OK == IsPinDirection(pOutPin, PINDIR_OUTPUT)
+ && S_OK != IsPinConnected(pOutPin))
+ {
+ BeginEnumPins(pInFilter, pEP, pInPin)
+ {
+ if(S_OK == IsPinDirection(pInPin, PINDIR_INPUT)
+ && S_OK != IsPinConnected(pInPin))
+ {
+ hr = this->ConnectDirect(pOutPin, pInPin, NULL);
//#ifdef _DEBUG
// PIN_INFO InfoPinIn, InfoPinOut;
@@ -385,228 +368,228 @@ HRESULT CFGManagerBDA::ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFi
// InfoPinIn.pFilter->Release();
// InfoPinOut.pFilter->Release();
//#endif
- if(SUCCEEDED(hr)) return hr;
- }
- }
- EndEnumPins
- }
- }
- EndEnumPins
-
- return hr;
+ if (SUCCEEDED (hr)) return hr;
+ }
+ }
+ EndEnumPins
+ }
+ }
+ EndEnumPins
+
+ return hr;
}
STDMETHODIMP CFGManagerBDA::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- HRESULT hr;
- AppSettings& s = AfxGetAppSettings();
- CComPtr<IBaseFilter> pNetwork;
- CComPtr<IBaseFilter> pTuner;
- CComPtr<IBaseFilter> pReceiver;
-
- CheckAndLog(CreateKSFilter(&pNetwork, KSCATEGORY_BDA_NETWORK_PROVIDER, s.BDANetworkProvider), "BDA : Network provider creation");
- CheckAndLog(CreateKSFilter(&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.BDATuner), "BDA : Network tuner creation");
- CheckAndLog(CreateKSFilter(&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.BDAReceiver), "BDA : Receiver creation");
-
- CheckAndLog(ConnectFilters(pNetwork, pTuner), "BDA : Network <-> Tuner");
- CheckAndLog(ConnectFilters(pTuner, pReceiver), "BDA : Tuner <-> Receiver");
-
- CComPtr<IBaseFilter> pMpeg2Demux;
- m_pBDAControl = pTuner;
- CheckAndLog(SearchIBDATopology(pTuner, m_pBDAFreq), "BDA : IBDA_FrequencyFilter topology");
- CheckAndLog(SearchIBDATopology(pTuner, m_pBDAStats), "BDA : IBDA_SignalStatistics topology");
-
- // Create Mpeg2 demux
- CheckAndLog(CreateMicrosoftDemux(pReceiver, pMpeg2Demux), "BDA : Microsoft demux creation");
- if(s.BDANetworkProvider.Find(_T(MS_NETWORK_PROVIDER), 0) != -1)
- m_BDANetworkProvider = _T(MS_NETWORK_PROVIDER);
-
- return S_OK;
+ HRESULT hr;
+ AppSettings& s = AfxGetAppSettings();
+ CComPtr<IBaseFilter> pNetwork;
+ CComPtr<IBaseFilter> pTuner;
+ CComPtr<IBaseFilter> pReceiver;
+
+ CheckAndLog (CreateKSFilter (&pNetwork, KSCATEGORY_BDA_NETWORK_PROVIDER, s.BDANetworkProvider), "BDA : Network provider creation");
+ CheckAndLog (CreateKSFilter (&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.BDATuner), "BDA : Network tuner creation");
+ CheckAndLog (CreateKSFilter (&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.BDAReceiver), "BDA : Receiver creation");
+
+ CheckAndLog (ConnectFilters (pNetwork, pTuner), "BDA : Network <-> Tuner");
+ CheckAndLog (ConnectFilters (pTuner, pReceiver), "BDA : Tuner <-> Receiver");
+
+ CComPtr<IBaseFilter> pMpeg2Demux;
+ m_pBDAControl = pTuner;
+ CheckAndLog (SearchIBDATopology (pTuner, m_pBDAFreq), "BDA : IBDA_FrequencyFilter topology");
+ CheckAndLog (SearchIBDATopology (pTuner, m_pBDAStats), "BDA : IBDA_SignalStatistics topology");
+
+ // Create Mpeg2 demux
+ CheckAndLog (CreateMicrosoftDemux (pReceiver, pMpeg2Demux), "BDA : Microsoft demux creation");
+ if (s.BDANetworkProvider.Find(_T(MS_NETWORK_PROVIDER), 0) != -1)
+ m_BDANetworkProvider = _T(MS_NETWORK_PROVIDER);
+
+ return S_OK;
}
STDMETHODIMP CFGManagerBDA::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt)
{
- // Bypass CFGManagerPlayer limitation (IMediaSeeking for Mpeg2 demux)
- return CFGManagerCustom::ConnectDirect(pPinOut, pPinIn, pmt);
+ // Bypass CFGManagerPlayer limitation (IMediaSeeking for Mpeg2 demux)
+ return CFGManagerCustom::ConnectDirect (pPinOut, pPinIn, pmt);
}
-STDMETHODIMP CFGManagerBDA::SetChannel(int nChannelPrefNumber)
+STDMETHODIMP CFGManagerBDA::SetChannel (int nChannelPrefNumber)
{
- HRESULT hr = E_INVALIDARG;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(nChannelPrefNumber);
+ HRESULT hr = E_INVALIDARG;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(nChannelPrefNumber);
- if(pChannel != NULL)
- {
- hr = SetChannelInternal(pChannel);
+ if (pChannel != NULL)
+ {
+ hr = SetChannelInternal (pChannel);
- if(SUCCEEDED(hr))
- s.DVBLastChannel = nChannelPrefNumber;
- }
+ if (SUCCEEDED (hr))
+ s.DVBLastChannel = nChannelPrefNumber;
+ }
- return hr;
+ return hr;
}
-STDMETHODIMP CFGManagerBDA::SetAudio(int nAudioIndex)
+STDMETHODIMP CFGManagerBDA::SetAudio (int nAudioIndex)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CFGManagerBDA::SetFrequency(ULONG freq)
{
- HRESULT hr;
- CheckPointer(m_pBDAControl, E_FAIL);
- CheckPointer(m_pBDAFreq, E_FAIL);
+ HRESULT hr;
+ CheckPointer (m_pBDAControl, E_FAIL);
+ CheckPointer (m_pBDAFreq, E_FAIL);
- CheckAndLog(m_pBDAControl->StartChanges(), "BDA : Setfrequency StartChanges");
- CheckAndLog(m_pBDAFreq->put_Bandwidth(8), "BDA : Setfrequency put_Bandwidth");
- CheckAndLog(m_pBDAFreq->put_Frequency(freq), "BDA : Setfrequency put_Frequency");
- CheckAndLog(m_pBDAControl->CheckChanges(), "BDA : Setfrequency CheckChanges");
- CheckAndLog(m_pBDAControl->CommitChanges(), "BDA : Setfrequency CommitChanges");
+ CheckAndLog (m_pBDAControl->StartChanges(), "BDA : Setfrequency StartChanges");
+ CheckAndLog (m_pBDAFreq->put_Bandwidth(8), "BDA : Setfrequency put_Bandwidth");
+ CheckAndLog (m_pBDAFreq->put_Frequency(freq), "BDA : Setfrequency put_Frequency");
+ CheckAndLog (m_pBDAControl->CheckChanges(), "BDA : Setfrequency CheckChanges");
+ CheckAndLog (m_pBDAControl->CommitChanges(), "BDA : Setfrequency CommitChanges");
- return hr;
+ return hr;
}
STDMETHODIMP CFGManagerBDA::Scan(ULONG ulFrequency, HWND hWnd)
{
- CMpeg2DataParser Parser(m_DVBStreams[DVB_PSI].GetFilter());
+ CMpeg2DataParser Parser (m_DVBStreams[DVB_PSI].GetFilter());
- Parser.ParseSDT(ulFrequency);
- Parser.ParsePAT();
- Parser.ParseNIT();
+ Parser.ParseSDT(ulFrequency);
+ Parser.ParsePAT();
+ Parser.ParseNIT();
- POSITION pos = Parser.Channels.GetStartPosition();
- while(pos)
- {
- CDVBChannel& Channel = Parser.Channels.GetNextValue(pos);
- if(Channel.HasName())
- ::SendMessage(hWnd, WM_TUNER_NEW_CHANNEL, 0, (LPARAM)(LPCTSTR)Channel.ToString());
- }
+ POSITION pos = Parser.Channels.GetStartPosition();
+ while(pos)
+ {
+ CDVBChannel& Channel = Parser.Channels.GetNextValue(pos);
+ if (Channel.HasName())
+ ::SendMessage (hWnd, WM_TUNER_NEW_CHANNEL, 0, (LPARAM)(LPCTSTR)Channel.ToString());
+ }
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CFGManagerBDA::GetStats(BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality)
+STDMETHODIMP CFGManagerBDA::GetStats (BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality)
{
- HRESULT hr;
- CheckPointer(m_pBDAStats, E_UNEXPECTED);
+ HRESULT hr;
+ CheckPointer (m_pBDAStats, E_UNEXPECTED);
- CheckNoLog(m_pBDAStats->get_SignalPresent(&bPresent));
- CheckNoLog(m_pBDAStats->get_SignalLocked(&bLocked));
- CheckNoLog(m_pBDAStats->get_SignalStrength(&lStrength));
- CheckNoLog(m_pBDAStats->get_SignalQuality(&lQuality));
+ CheckNoLog (m_pBDAStats->get_SignalPresent (&bPresent));
+ CheckNoLog (m_pBDAStats->get_SignalLocked (&bLocked));
+ CheckNoLog (m_pBDAStats->get_SignalStrength (&lStrength));
+ CheckNoLog (m_pBDAStats->get_SignalQuality (&lQuality));
- return S_OK;
+ return S_OK;
}
// IAMStreamSelect
STDMETHODIMP CFGManagerBDA::Count(DWORD* pcStreams)
{
- CheckPointer(pcStreams, E_POINTER);
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
+ CheckPointer(pcStreams, E_POINTER);
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
- *pcStreams = 0;
+ *pcStreams = 0;
- if(pChannel != 0)
- *pcStreams = pChannel->GetAudioCount() + pChannel->GetSubtitleCount();
+ if (pChannel != 0)
+ *pcStreams = pChannel->GetAudioCount() + pChannel->GetSubtitleCount();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CFGManagerBDA::Enable(long lIndex, DWORD dwFlags)
{
- HRESULT hr = E_INVALIDARG;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
- DVBStreamInfo* pStreamInfo = NULL;
- CDVBStream* pStream = NULL;
- FILTER_STATE nState;
-
- if(pChannel)
- {
- if(lIndex >= 0 && lIndex < pChannel->GetAudioCount())
- {
- pStreamInfo = pChannel->GetAudio(lIndex);
- pStream = &m_DVBStreams[pStreamInfo->Type];
- if(pStream && pStreamInfo)
- {
- nState = GetState();
- if(m_nCurAudioType != pStreamInfo->Type)
- SwitchStream(m_nCurAudioType, pStreamInfo->Type);
- pStream->Map(pStreamInfo->PID);
- ChangeState((FILTER_STATE)nState);
-
- hr = S_OK;
- }
- }
- else if(lIndex > 0 && lIndex < pChannel->GetAudioCount() + pChannel->GetSubtitleCount())
- {
- pStreamInfo = pChannel->GetSubtitle(lIndex - pChannel->GetAudioCount());
-
- if(pStreamInfo)
- {
- m_DVBStreams[DVB_SUB].Map(pStreamInfo->PID);
- hr = S_OK;
- }
- }
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
+ DVBStreamInfo* pStreamInfo = NULL;
+ CDVBStream* pStream = NULL;
+ FILTER_STATE nState;
+
+ if (pChannel)
+ {
+ if (lIndex>=0 && lIndex < pChannel->GetAudioCount())
+ {
+ pStreamInfo = pChannel->GetAudio(lIndex);
+ pStream = &m_DVBStreams[pStreamInfo->Type];
+ if (pStream && pStreamInfo)
+ {
+ nState = GetState();
+ if (m_nCurAudioType != pStreamInfo->Type)
+ SwitchStream (m_nCurAudioType, pStreamInfo->Type);
+ pStream->Map (pStreamInfo->PID);
+ ChangeState ((FILTER_STATE)nState);
+
+ hr = S_OK;
+ }
+ }
+ else if (lIndex > 0 && lIndex < pChannel->GetAudioCount()+pChannel->GetSubtitleCount())
+ {
+ pStreamInfo = pChannel->GetSubtitle(lIndex-pChannel->GetAudioCount());
+
+ if (pStreamInfo)
+ {
+ m_DVBStreams[DVB_SUB].Map(pStreamInfo->PID);
+ hr = S_OK;
+ }
+ }
+ }
+
+ return hr;
}
STDMETHODIMP CFGManagerBDA::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
{
- HRESULT hr = E_INVALIDARG;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
- DVBStreamInfo* pStreamInfo = NULL;
- CDVBStream* pStream = NULL;
- CDVBStream* pCurrentStream = NULL;
-
- if(pChannel)
- {
- if(lIndex >= 0 && lIndex < pChannel->GetAudioCount())
- {
- pCurrentStream = &m_DVBStreams[m_nCurAudioType];
- pStreamInfo = pChannel->GetAudio(lIndex);
- if(pStreamInfo) pStream = &m_DVBStreams[pStreamInfo->Type];
- if(pdwGroup) *pdwGroup = 1; // Audio group
- }
- else if(lIndex > 0 && lIndex < pChannel->GetAudioCount() + pChannel->GetSubtitleCount())
- {
- pCurrentStream = &m_DVBStreams[DVB_SUB];
- pStreamInfo = pChannel->GetSubtitle(lIndex - pChannel->GetAudioCount());
- if(pStreamInfo) pStream = &m_DVBStreams[pStreamInfo->Type];
- if(pdwGroup) *pdwGroup = 2; // Subtitle group
- }
-
- if(pStreamInfo && pStream && pCurrentStream)
- {
- if(ppmt) *ppmt = CreateMediaType(pStream->GetMediaType());
- if(pdwFlags) *pdwFlags = (pCurrentStream->GetMappedPID() == pStreamInfo->PID) ? AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE : 0;
- if(plcid) *plcid = pStreamInfo->GetLCID();
- if(ppObject) *ppObject = NULL;
- if(ppUnk) *ppUnk = NULL;
- if(ppszName)
- {
- CStringW str;
-
- str = StreamTypeToName(pStreamInfo->PesType);
-
- *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength() + 1) * sizeof(WCHAR));
- if(*ppszName == NULL) return E_OUTOFMEMORY;
- wcscpy_s(*ppszName, str.GetLength() + 1, str);
- }
-
- hr = S_OK;
- }
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
+ DVBStreamInfo* pStreamInfo = NULL;
+ CDVBStream* pStream = NULL;
+ CDVBStream* pCurrentStream = NULL;
+
+ if (pChannel)
+ {
+ if (lIndex>=0 && lIndex < pChannel->GetAudioCount())
+ {
+ pCurrentStream = &m_DVBStreams[m_nCurAudioType];
+ pStreamInfo = pChannel->GetAudio(lIndex);
+ if(pStreamInfo) pStream = &m_DVBStreams[pStreamInfo->Type];
+ if(pdwGroup) *pdwGroup = 1; // Audio group
+ }
+ else if (lIndex > 0 && lIndex < pChannel->GetAudioCount()+pChannel->GetSubtitleCount())
+ {
+ pCurrentStream = &m_DVBStreams[DVB_SUB];
+ pStreamInfo = pChannel->GetSubtitle(lIndex-pChannel->GetAudioCount());
+ if(pStreamInfo) pStream = &m_DVBStreams[pStreamInfo->Type];
+ if(pdwGroup) *pdwGroup = 2; // Subtitle group
+ }
+
+ if (pStreamInfo && pStream && pCurrentStream)
+ {
+ if(ppmt) *ppmt = CreateMediaType(pStream->GetMediaType());
+ if(pdwFlags) *pdwFlags = (pCurrentStream->GetMappedPID() == pStreamInfo->PID) ? AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE : 0;
+ if(plcid) *plcid = pStreamInfo->GetLCID();
+ if(ppObject) *ppObject = NULL;
+ if(ppUnk) *ppUnk = NULL;
+ if(ppszName)
+ {
+ CStringW str;
+
+ str = StreamTypeToName(pStreamInfo->PesType);
+
+ *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
+ if(*ppszName == NULL) return E_OUTOFMEMORY;
+ wcscpy_s(*ppszName, str.GetLength()+1, str);
+ }
+
+ hr = S_OK;
+ }
+ }
+
+ return hr;
}
@@ -614,137 +597,137 @@ STDMETHODIMP CFGManagerBDA::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IBDATuner)
- QI(IAMStreamSelect)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IBDATuner)
+ QI(IAMStreamSelect)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CFGManagerBDA::CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBaseFilter>& pMpeg2Demux)
{
- CComPtr<IMpeg2Demultiplexer> pDemux;
- CComPtr<IBaseFilter> pTIF;
- HRESULT hr;
- AM_MEDIA_TYPE mt;
-
- CheckNoLog(pMpeg2Demux.CoCreateInstance(CLSID_MPEG2Demultiplexer, NULL, CLSCTX_INPROC_SERVER));
- CheckNoLog(AddFilter(pMpeg2Demux, _T("MPEG-2 Demultiplexer")));
- CheckNoLog(ConnectFilters(pReceiver, pMpeg2Demux));
- CheckNoLog(pMpeg2Demux->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux));
-
- // Cleanup unnecessary pins
- //for (int i=0; i<6; i++)
- //{
- // CStringW strPin;
- // strPin.Format(L"%d", i);
- // pDemux->DeleteOutputPin((LPWSTR)(LPCWSTR)strPin);
- //}
-
- POSITION pos = m_DVBStreams.GetStartPosition();
- while(pos)
- {
- CComPtr<IPin> pPin;
- DVB_STREAM_TYPE nType = m_DVBStreams.GetNextKey(pos);
- CDVBStream& Stream = m_DVBStreams[nType];
-
- if(nType != DVB_EPG) // Hack: DVB_EPG stream is identical to DVB_TIF and cannot be connected !!!
- {
- if(!Stream.GetFindExisting() ||
- (pPin = FindPin(pMpeg2Demux, PINDIR_OUTPUT, Stream.GetMediaType())) == NULL)
- {
- CheckNoLog(pDemux->CreateOutputPin((AM_MEDIA_TYPE*)Stream.GetMediaType(), Stream.GetName(), &pPin));
- }
- CheckNoLog(Connect(pPin, NULL, false));
- Stream.SetPin(pPin);
-
- // Complete graph for one audio stream and one video stream (using standard graph builder rules)
- if(nType == m_nCurVideoType || nType == m_nCurAudioType)
- {
- Connect(GetFirstDisconnectedPin(Stream.GetFilter(), PINDIR_OUTPUT), NULL);
- }
- }
- }
-
- return S_OK;
+ CComPtr<IMpeg2Demultiplexer> pDemux;
+ CComPtr<IBaseFilter> pTIF;
+ HRESULT hr;
+ AM_MEDIA_TYPE mt;
+
+ CheckNoLog (pMpeg2Demux.CoCreateInstance (CLSID_MPEG2Demultiplexer, NULL, CLSCTX_INPROC_SERVER));
+ CheckNoLog (AddFilter (pMpeg2Demux, _T("MPEG-2 Demultiplexer")));
+ CheckNoLog (ConnectFilters (pReceiver, pMpeg2Demux));
+ CheckNoLog (pMpeg2Demux->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux));
+
+ // Cleanup unnecessary pins
+ //for (int i=0; i<6; i++)
+ //{
+ // CStringW strPin;
+ // strPin.Format(L"%d", i);
+ // pDemux->DeleteOutputPin((LPWSTR)(LPCWSTR)strPin);
+ //}
+
+ POSITION pos = m_DVBStreams.GetStartPosition();
+ while (pos)
+ {
+ CComPtr<IPin> pPin;
+ DVB_STREAM_TYPE nType = m_DVBStreams.GetNextKey(pos);
+ CDVBStream& Stream = m_DVBStreams[nType];
+
+ if (nType != DVB_EPG) // Hack: DVB_EPG stream is identical to DVB_TIF and cannot be connected !!!
+ {
+ if (!Stream.GetFindExisting() ||
+ (pPin = FindPin (pMpeg2Demux, PINDIR_OUTPUT, Stream.GetMediaType())) == NULL)
+ {
+ CheckNoLog (pDemux->CreateOutputPin ((AM_MEDIA_TYPE*)Stream.GetMediaType(), Stream.GetName(), &pPin));
+ }
+ CheckNoLog (Connect (pPin, NULL, false));
+ Stream.SetPin (pPin);
+
+ // Complete graph for one audio stream and one video stream (using standard graph builder rules)
+ if (nType == m_nCurVideoType || nType == m_nCurAudioType)
+ {
+ Connect (GetFirstDisconnectedPin (Stream.GetFilter(), PINDIR_OUTPUT), NULL);
+ }
+ }
+ }
+
+ return S_OK;
}
-HRESULT CFGManagerBDA::SetChannelInternal(CDVBChannel* pChannel)
+HRESULT CFGManagerBDA::SetChannelInternal (CDVBChannel* pChannel)
{
- HRESULT hr;
- ULONG ulCurFreq;
-
- int nState = GetState();
- if(m_BDANetworkProvider == MS_NETWORK_PROVIDER)
- ChangeState(State_Stopped); // Only stops when using Microsoft Network Provider
- SwitchStream(m_nCurVideoType, pChannel->GetVideoType());
- SwitchStream(m_nCurAudioType, pChannel->GetDefaultAudioType());
-
- CheckNoLog(SetFrequency(pChannel->GetFrequency()));
- CheckNoLog(m_DVBStreams[m_nCurVideoType].Map(pChannel->GetVideoPID()));
- CheckNoLog(m_DVBStreams[m_nCurAudioType].Map(pChannel->GetDefaultAudioPID()));
- if(GetState() == State_Stopped)
- ChangeState((FILTER_STATE)nState);
-
- // TODO : remove sub later!
+ HRESULT hr;
+ ULONG ulCurFreq;
+
+ int nState = GetState();
+ if (m_BDANetworkProvider == MS_NETWORK_PROVIDER)
+ ChangeState (State_Stopped); // Only stops when using Microsoft Network Provider
+ SwitchStream (m_nCurVideoType, pChannel->GetVideoType());
+ SwitchStream (m_nCurAudioType, pChannel->GetDefaultAudioType());
+
+ CheckNoLog (SetFrequency (pChannel->GetFrequency()));
+ CheckNoLog (m_DVBStreams[m_nCurVideoType].Map (pChannel->GetVideoPID()));
+ CheckNoLog (m_DVBStreams[m_nCurAudioType].Map (pChannel->GetDefaultAudioPID()));
+ if (GetState() == State_Stopped)
+ ChangeState ((FILTER_STATE)nState);
+
+ // TODO : remove sub later!
// CheckNoLog (m_DVBStreams[DVB_SUB].Map (pChannel->GetDefaultSubtitlePID()));
- return S_OK;
+ return S_OK;
}
-HRESULT CFGManagerBDA::SwitchStream(DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType)
-{
- if(nNewType != nOldType)
- {
- CComPtr<IBaseFilter> pFGOld = m_DVBStreams[nOldType].GetFilter();
- CComPtr<IBaseFilter> pFGNew = m_DVBStreams[nNewType].GetFilter();
- CComPtr<IPin> pOldOut = GetFirstPin(pFGOld, PINDIR_OUTPUT);
- CComPtr<IPin> pInPin;
- CComPtr<IPin> pNewOut = GetFirstPin(pFGNew, PINDIR_OUTPUT);
-
- if(GetState() != State_Stopped)
- ChangeState(State_Stopped);
- pOldOut->ConnectedTo(&pInPin);
- Disconnect(pOldOut);
- Disconnect(pInPin);
- Connect(pNewOut, pInPin, false);
- nOldType = nNewType;
- }
- return S_OK;
+HRESULT CFGManagerBDA::SwitchStream (DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType)
+{
+ if (nNewType != nOldType)
+ {
+ CComPtr<IBaseFilter> pFGOld = m_DVBStreams[nOldType].GetFilter();
+ CComPtr<IBaseFilter> pFGNew = m_DVBStreams[nNewType].GetFilter();
+ CComPtr<IPin> pOldOut = GetFirstPin (pFGOld, PINDIR_OUTPUT);
+ CComPtr<IPin> pInPin;
+ CComPtr<IPin> pNewOut = GetFirstPin (pFGNew, PINDIR_OUTPUT);
+
+ if (GetState() != State_Stopped)
+ ChangeState (State_Stopped);
+ pOldOut->ConnectedTo(&pInPin);
+ Disconnect (pOldOut);
+ Disconnect (pInPin);
+ Connect (pNewOut, pInPin, false);
+ nOldType = nNewType;
+ }
+ return S_OK;
}
HRESULT CFGManagerBDA::ChangeState(FILTER_STATE nRequested)
{
- OAFilterState nState = nRequested + 1;
-
- CComPtr<IMediaControl> pMC;
- QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
- pMC->GetState(500, &nState);
- if(nState != nRequested)
- {
- switch(nRequested)
- {
- case State_Stopped :
- return pMC->Stop();
- case State_Paused :
- return pMC->Pause();
- case State_Running :
- return pMC->Run();
- }
- }
- return S_OK;
+ OAFilterState nState = nRequested+1;
+
+ CComPtr<IMediaControl> pMC;
+ QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
+ pMC->GetState (500, &nState);
+ if (nState != nRequested)
+ {
+ switch (nRequested)
+ {
+ case State_Stopped :
+ return pMC->Stop();
+ case State_Paused :
+ return pMC->Pause();
+ case State_Running :
+ return pMC->Run();
+ }
+ }
+ return S_OK;
}
FILTER_STATE CFGManagerBDA::GetState()
{
- CComPtr<IMediaControl> pMC;
- OAFilterState nState;
- QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
- pMC->GetState(500, &nState);
+ CComPtr<IMediaControl> pMC;
+ OAFilterState nState;
+ QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
+ pMC->GetState (500, &nState);
- return (FILTER_STATE) nState;
+ return (FILTER_STATE) nState;
}
diff --git a/src/apps/mplayerc/FGManagerBDA.h b/src/apps/mplayerc/FGManagerBDA.h
index c23fca84e..cd50b1c30 100644
--- a/src/apps/mplayerc/FGManagerBDA.h
+++ b/src/apps/mplayerc/FGManagerBDA.h
@@ -1,4 +1,4 @@
-/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -33,161 +33,148 @@
class CDVBStream
{
public :
- CDVBStream() :
- m_ulMappedPID(0)
- {
- }
-
- CDVBStream(LPWSTR strName, const AM_MEDIA_TYPE * pmt, bool bFindExisting = false, MEDIA_SAMPLE_CONTENT nMsc = MEDIA_ELEMENTARY_STREAM) :
- m_Name(strName),
- m_bFindExisting(bFindExisting),
- m_pmt(pmt),
- m_nMsc(nMsc),
- m_ulMappedPID(0)
- {}
-
- LPWSTR GetName() /*const*/
- {
- return m_Name;
- };
- const AM_MEDIA_TYPE* GetMediaType() /*const*/
- {
- return m_pmt;
- };
- bool GetFindExisting() const
- {
- return m_bFindExisting;
- };
- IBaseFilter* GetFilter()
- {
- return m_pFilter;
- };
-
- void SetPin(IPin* pPin)
- {
- CComPtr<IPin> pPinOut;
- PIN_INFO PinInfo;
-
- m_pMap = pPin;
- if(m_pMap &&
- SUCCEEDED(pPin->ConnectedTo(&pPinOut)) &&
- SUCCEEDED(pPinOut->QueryPinInfo(&PinInfo)))
- {
- m_pFilter.Attach(PinInfo.pFilter);
- }
- }
-
- HRESULT Map(ULONG ulPID)
- {
- CheckPointer(m_pMap, E_UNEXPECTED);
- ClearMaps();
- m_ulMappedPID = ulPID;
- return m_pMap->MapPID(1, &ulPID, m_nMsc);
- }
-
- HRESULT Unmap(ULONG ulPID)
- {
- CheckPointer(m_pMap, E_UNEXPECTED);
- m_ulMappedPID = 0;
- return m_pMap->UnmapPID(1, &ulPID);
- }
-
- ULONG GetMappedPID() const
- {
- return m_ulMappedPID;
- }
+ CDVBStream() :
+ m_ulMappedPID(0)
+ {
+ }
+
+ CDVBStream(LPWSTR strName, const AM_MEDIA_TYPE * pmt, bool bFindExisting = false, MEDIA_SAMPLE_CONTENT nMsc=MEDIA_ELEMENTARY_STREAM) :
+ m_Name(strName),
+ m_bFindExisting(bFindExisting),
+ m_pmt(pmt),
+ m_nMsc(nMsc),
+ m_ulMappedPID(0)
+ {}
+
+ LPWSTR GetName() /*const*/ { return m_Name; };
+ const AM_MEDIA_TYPE* GetMediaType() /*const*/ { return m_pmt; };
+ bool GetFindExisting() const { return m_bFindExisting; };
+ IBaseFilter* GetFilter() { return m_pFilter; };
+
+ void SetPin(IPin* pPin)
+ {
+ CComPtr<IPin> pPinOut;
+ PIN_INFO PinInfo;
+
+ m_pMap = pPin;
+ if (m_pMap &&
+ SUCCEEDED (pPin->ConnectedTo (&pPinOut)) &&
+ SUCCEEDED (pPinOut->QueryPinInfo (&PinInfo)))
+ {
+ m_pFilter.Attach (PinInfo.pFilter);
+ }
+ }
+
+ HRESULT Map (ULONG ulPID)
+ {
+ CheckPointer (m_pMap, E_UNEXPECTED);
+ ClearMaps();
+ m_ulMappedPID = ulPID;
+ return m_pMap->MapPID (1, &ulPID, m_nMsc);
+ }
+
+ HRESULT Unmap (ULONG ulPID)
+ {
+ CheckPointer (m_pMap, E_UNEXPECTED);
+ m_ulMappedPID = 0;
+ return m_pMap->UnmapPID (1, &ulPID);
+ }
+
+ ULONG GetMappedPID() const
+ {
+ return m_ulMappedPID;
+ }
private :
- CComQIPtr<IMPEG2PIDMap> m_pMap;
- CComPtr<IBaseFilter> m_pFilter;
- const AM_MEDIA_TYPE* m_pmt;
- bool m_bFindExisting;
- LPWSTR m_Name;
- MEDIA_SAMPLE_CONTENT m_nMsc;
- ULONG m_ulMappedPID;
-
- void ClearMaps()
- {
- HRESULT hr;
- CComPtr<IEnumPIDMap> pEnumMap;
-
- if(SUCCEEDED(hr = m_pMap->EnumPIDMap(&pEnumMap)))
- {
- PID_MAP maps[8];
- ULONG nbPids = 0;
-
- if(pEnumMap->Next(_countof(maps), maps, &nbPids) == S_OK)
- {
- for(ULONG i = 0; i < nbPids; i++)
- {
- ULONG pid = maps[i].ulPID;
-
- m_pMap->UnmapPID(1, &pid);
- }
- }
- }
- }
+ CComQIPtr<IMPEG2PIDMap> m_pMap;
+ CComPtr<IBaseFilter> m_pFilter;
+ const AM_MEDIA_TYPE* m_pmt;
+ bool m_bFindExisting;
+ LPWSTR m_Name;
+ MEDIA_SAMPLE_CONTENT m_nMsc;
+ ULONG m_ulMappedPID;
+
+ void ClearMaps()
+ {
+ HRESULT hr;
+ CComPtr<IEnumPIDMap> pEnumMap;
+
+ if (SUCCEEDED(hr = m_pMap->EnumPIDMap(&pEnumMap)))
+ {
+ PID_MAP maps[8];
+ ULONG nbPids = 0;
+
+ if (pEnumMap->Next(_countof(maps), maps, &nbPids)==S_OK)
+ {
+ for (ULONG i=0; i<nbPids; i++)
+ {
+ ULONG pid = maps[i].ulPID;
+
+ m_pMap->UnmapPID(1, &pid);
+ }
+ }
+ }
+ }
};
class CFGManagerBDA : public CFGManagerPlayer, IBDATuner, IAMStreamSelect
{
public:
- CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
- ~CFGManagerBDA();
+ CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ ~CFGManagerBDA();
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- // IFilterGraph
- STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
+ // IFilterGraph
+ STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
- // IBDATuner
- STDMETHODIMP SetChannel(int nChannelPrefNumber);
- STDMETHODIMP SetAudio(int nAudioIndex);
- STDMETHODIMP SetFrequency(ULONG freq);
- STDMETHODIMP Scan(ULONG ulFrequency, HWND hWnd);
- STDMETHODIMP GetStats(BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality);
+ // IBDATuner
+ STDMETHODIMP SetChannel (int nChannelPrefNumber);
+ STDMETHODIMP SetAudio (int nAudioIndex);
+ STDMETHODIMP SetFrequency(ULONG freq);
+ STDMETHODIMP Scan(ULONG ulFrequency, HWND hWnd);
+ STDMETHODIMP GetStats (BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality);
- // IAMStreamSelect
- STDMETHODIMP Count(DWORD* pcStreams);
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
- STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
+ // IAMStreamSelect
+ STDMETHODIMP Count(DWORD* pcStreams);
+ STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
+ STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
private :
- CComQIPtr<IBDA_DeviceControl> m_pBDAControl;
- CComPtr<IBDA_FrequencyFilter> m_pBDAFreq;
- CComPtr<IBDA_SignalStatistics> m_pBDAStats;
- CAtlMap<DVB_STREAM_TYPE, CDVBStream> m_DVBStreams;
-
- DVB_STREAM_TYPE m_nCurVideoType;
- DVB_STREAM_TYPE m_nCurAudioType;
- CString m_BDANetworkProvider;
-
- HRESULT CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName);
- HRESULT ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFilter);
- HRESULT CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBaseFilter>& pMpeg2Demux);
- HRESULT SetChannelInternal(CDVBChannel* pChannel);
- HRESULT SwitchStream(DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType);
- HRESULT ChangeState(FILTER_STATE nRequested);
- FILTER_STATE GetState();
-
- template <class ITF>
- HRESULT SearchIBDATopology(const CComPtr<IBaseFilter> & pTuner, CComPtr<ITF> & pItf)
- {
- CComPtr<IUnknown> pUnk;
- HRESULT hr = SearchIBDATopology(pTuner, __uuidof(ITF), pUnk);
-
- if(SUCCEEDED(hr))
- {
- hr = pUnk.QueryInterface(&pItf);
- }
- return !pItf ? E_NOINTERFACE : hr;
- }
-
- HRESULT SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk);
+ CComQIPtr<IBDA_DeviceControl> m_pBDAControl;
+ CComPtr<IBDA_FrequencyFilter> m_pBDAFreq;
+ CComPtr<IBDA_SignalStatistics> m_pBDAStats;
+ CAtlMap<DVB_STREAM_TYPE, CDVBStream> m_DVBStreams;
+
+ DVB_STREAM_TYPE m_nCurVideoType;
+ DVB_STREAM_TYPE m_nCurAudioType;
+ CString m_BDANetworkProvider;
+
+ HRESULT CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName);
+ HRESULT ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFilter);
+ HRESULT CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBaseFilter>& pMpeg2Demux);
+ HRESULT SetChannelInternal (CDVBChannel* pChannel);
+ HRESULT SwitchStream (DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType);
+ HRESULT ChangeState(FILTER_STATE nRequested);
+ FILTER_STATE GetState();
+
+ template <class ITF>
+ HRESULT SearchIBDATopology(const CComPtr<IBaseFilter> & pTuner, CComPtr<ITF> & pItf)
+ {
+ CComPtr<IUnknown> pUnk;
+ HRESULT hr = SearchIBDATopology(pTuner, __uuidof(ITF), pUnk);
+
+ if (SUCCEEDED(hr)) {
+ hr = pUnk.QueryInterface(&pItf);
+ }
+ return !pItf ? E_NOINTERFACE : hr;
+ }
+
+ HRESULT SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk);
};
diff --git a/src/apps/mplayerc/FakeFilterMapper2.cpp b/src/apps/mplayerc/FakeFilterMapper2.cpp
index adbff9656..c738669c7 100644
--- a/src/apps/mplayerc/FakeFilterMapper2.cpp
+++ b/src/apps/mplayerc/FakeFilterMapper2.cpp
@@ -32,499 +32,403 @@
#include <detours/detours.h>
-HRESULT(__stdcall * Real_CoCreateInstance)(CONST IID& a0,
- LPUNKNOWN a1,
- DWORD a2,
- CONST IID& a3,
- LPVOID* a4)
-= CoCreateInstance;
-
-LONG(WINAPI * Real_RegCreateKeyExA)(HKEY a0,
- LPCSTR a1,
- DWORD a2,
- LPSTR a3,
- DWORD a4,
- REGSAM a5,
- LPSECURITY_ATTRIBUTES a6,
- PHKEY a7,
- LPDWORD a8)
-= RegCreateKeyExA;
-
-LONG(WINAPI * Real_RegCreateKeyExW)(HKEY a0,
- LPCWSTR a1,
- DWORD a2,
- LPWSTR a3,
- DWORD a4,
- REGSAM a5,
- LPSECURITY_ATTRIBUTES a6,
- PHKEY a7,
- LPDWORD a8)
-= RegCreateKeyExW;
-
-LONG(WINAPI * Real_RegDeleteKeyA)(HKEY a0,
- LPCSTR a1)
-= RegDeleteKeyA;
-
-LONG(WINAPI * Real_RegDeleteKeyW)(HKEY a0,
- LPCWSTR a1)
-= RegDeleteKeyW;
-
-LONG(WINAPI * Real_RegDeleteValueA)(HKEY a0,
- LPCSTR a1)
-= RegDeleteValueA;
-
-
-LONG(WINAPI * Real_RegDeleteValueW)(HKEY a0,
- LPCWSTR a1)
-= RegDeleteValueW;
-
-LONG(WINAPI * Real_RegEnumKeyExA)(HKEY a0,
- DWORD a1,
- LPSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPSTR a5,
- LPDWORD a6,
- struct _FILETIME* a7)
-= RegEnumKeyExA;
-
-LONG(WINAPI * Real_RegEnumKeyExW)(HKEY a0,
- DWORD a1,
- LPWSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPWSTR a5,
- LPDWORD a6,
- struct _FILETIME* a7)
-= RegEnumKeyExW;
-
-LONG(WINAPI * Real_RegEnumValueA)(HKEY a0,
- DWORD a1,
- LPSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPBYTE a6,
- LPDWORD a7)
-= RegEnumValueA;
-
-LONG(WINAPI * Real_RegEnumValueW)(HKEY a0,
- DWORD a1,
- LPWSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPBYTE a6,
- LPDWORD a7)
-= RegEnumValueW;
-
-LONG(WINAPI * Real_RegOpenKeyExA)(HKEY a0,
- LPCSTR a1,
- DWORD a2,
- REGSAM a3,
- PHKEY a4)
-= RegOpenKeyExA;
-
-LONG(WINAPI * Real_RegOpenKeyExW)(HKEY a0,
- LPCWSTR a1,
- DWORD a2,
- REGSAM a3,
- PHKEY a4)
-= RegOpenKeyExW;
-
-LONG(WINAPI * Real_RegQueryInfoKeyA)(HKEY a0,
- LPSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPDWORD a6,
- LPDWORD a7,
- LPDWORD a8,
- LPDWORD a9,
- LPDWORD a10,
- struct _FILETIME* a11)
-= RegQueryInfoKeyA;
-
-LONG(WINAPI * Real_RegQueryInfoKeyW)(HKEY a0,
- LPWSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPDWORD a6,
- LPDWORD a7,
- LPDWORD a8,
- LPDWORD a9,
- LPDWORD a10,
- struct _FILETIME* a11)
-= RegQueryInfoKeyW;
-
-LONG(WINAPI * Real_RegQueryValueExA)(HKEY a0,
+HRESULT (__stdcall * Real_CoCreateInstance)(CONST IID& a0,
+ LPUNKNOWN a1,
+ DWORD a2,
+ CONST IID& a3,
+ LPVOID* a4)
+ = CoCreateInstance;
+
+LONG (WINAPI * Real_RegCreateKeyExA)(HKEY a0,
LPCSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPBYTE a4,
- LPDWORD a5)
-= RegQueryValueExA;
-
-LONG(WINAPI * Real_RegQueryValueExW)(HKEY a0,
+ DWORD a2,
+ LPSTR a3,
+ DWORD a4,
+ REGSAM a5,
+ LPSECURITY_ATTRIBUTES a6,
+ PHKEY a7,
+ LPDWORD a8)
+ = RegCreateKeyExA;
+
+LONG (WINAPI * Real_RegCreateKeyExW)(HKEY a0,
LPCWSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPBYTE a4,
- LPDWORD a5)
-= RegQueryValueExW;
-
-LONG(WINAPI * Real_RegSetValueExA)(HKEY a0,
+ DWORD a2,
+ LPWSTR a3,
+ DWORD a4,
+ REGSAM a5,
+ LPSECURITY_ATTRIBUTES a6,
+ PHKEY a7,
+ LPDWORD a8)
+ = RegCreateKeyExW;
+
+LONG (WINAPI * Real_RegDeleteKeyA)(HKEY a0,
+ LPCSTR a1)
+ = RegDeleteKeyA;
+
+LONG (WINAPI * Real_RegDeleteKeyW)(HKEY a0,
+ LPCWSTR a1)
+ = RegDeleteKeyW;
+
+LONG (WINAPI * Real_RegDeleteValueA)(HKEY a0,
+ LPCSTR a1)
+ = RegDeleteValueA;
+
+
+LONG (WINAPI * Real_RegDeleteValueW)(HKEY a0,
+ LPCWSTR a1)
+ = RegDeleteValueW;
+
+LONG (WINAPI * Real_RegEnumKeyExA)(HKEY a0,
+ DWORD a1,
+ LPSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPSTR a5,
+ LPDWORD a6,
+ struct _FILETIME* a7)
+ = RegEnumKeyExA;
+
+LONG (WINAPI * Real_RegEnumKeyExW)(HKEY a0,
+ DWORD a1,
+ LPWSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPWSTR a5,
+ LPDWORD a6,
+ struct _FILETIME* a7)
+ = RegEnumKeyExW;
+
+LONG (WINAPI * Real_RegEnumValueA)(HKEY a0,
+ DWORD a1,
+ LPSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPBYTE a6,
+ LPDWORD a7)
+ = RegEnumValueA;
+
+LONG (WINAPI * Real_RegEnumValueW)(HKEY a0,
+ DWORD a1,
+ LPWSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPBYTE a6,
+ LPDWORD a7)
+ = RegEnumValueW;
+
+LONG (WINAPI * Real_RegOpenKeyExA)(HKEY a0,
LPCSTR a1,
DWORD a2,
- DWORD a3,
- const BYTE* a4,
- DWORD a5)
-= RegSetValueExA;
+ REGSAM a3,
+ PHKEY a4)
+ = RegOpenKeyExA;
-LONG(WINAPI * Real_RegSetValueExW)(HKEY a0,
+LONG (WINAPI * Real_RegOpenKeyExW)(HKEY a0,
LPCWSTR a1,
DWORD a2,
- DWORD a3,
- const BYTE* a4,
- DWORD a5)
-= RegSetValueExW;
+ REGSAM a3,
+ PHKEY a4)
+ = RegOpenKeyExW;
+
+LONG (WINAPI * Real_RegQueryInfoKeyA)(HKEY a0,
+ LPSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPDWORD a6,
+ LPDWORD a7,
+ LPDWORD a8,
+ LPDWORD a9,
+ LPDWORD a10,
+ struct _FILETIME* a11)
+ = RegQueryInfoKeyA;
+
+LONG (WINAPI * Real_RegQueryInfoKeyW)(HKEY a0,
+ LPWSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPDWORD a6,
+ LPDWORD a7,
+ LPDWORD a8,
+ LPDWORD a9,
+ LPDWORD a10,
+ struct _FILETIME* a11)
+ = RegQueryInfoKeyW;
+
+LONG (WINAPI * Real_RegQueryValueExA)(HKEY a0,
+ LPCSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPBYTE a4,
+ LPDWORD a5)
+ = RegQueryValueExA;
+
+LONG (WINAPI * Real_RegQueryValueExW)(HKEY a0,
+ LPCWSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPBYTE a4,
+ LPDWORD a5)
+ = RegQueryValueExW;
+
+LONG (WINAPI * Real_RegSetValueExA)(HKEY a0,
+ LPCSTR a1,
+ DWORD a2,
+ DWORD a3,
+ const BYTE* a4,
+ DWORD a5)
+ = RegSetValueExA;
+
+LONG (WINAPI * Real_RegSetValueExW)(HKEY a0,
+ LPCWSTR a1,
+ DWORD a2,
+ DWORD a3,
+ const BYTE* a4,
+ DWORD a5)
+ = RegSetValueExW;
-LONG(WINAPI * Real_RegCloseKey)(HKEY a0)
-= RegCloseKey;
+LONG (WINAPI * Real_RegCloseKey)(HKEY a0)
+ = RegCloseKey;
-LONG(WINAPI * Real_RegFlushKey)(HKEY a0)
-= RegFlushKey;
+LONG (WINAPI * Real_RegFlushKey)(HKEY a0)
+ = RegFlushKey;
-LONG(WINAPI * Real_RegCreateKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
-= RegCreateKeyA;
+LONG (WINAPI * Real_RegCreateKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
+ = RegCreateKeyA;
-LONG(WINAPI * Real_RegCreateKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
-= RegCreateKeyW;
+LONG (WINAPI * Real_RegCreateKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
+ = RegCreateKeyW;
-LONG(WINAPI * Real_RegOpenKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
-= RegOpenKeyA;
+LONG (WINAPI * Real_RegOpenKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
+ = RegOpenKeyA;
-LONG(WINAPI * Real_RegOpenKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
-= RegOpenKeyW;
+LONG (WINAPI * Real_RegOpenKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
+ = RegOpenKeyW;
-LONG(WINAPI * Real_RegQueryValueA)(HKEY a0, LPCSTR a1, LPSTR a2, PLONG a3)
-= RegQueryValueA;
+LONG (WINAPI * Real_RegQueryValueA)(HKEY a0, LPCSTR a1, LPSTR a2, PLONG a3)
+ = RegQueryValueA;
-LONG(WINAPI * Real_RegQueryValueW)(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
-= RegQueryValueW;
+LONG (WINAPI * Real_RegQueryValueW)(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
+ = RegQueryValueW;
-LONG(WINAPI * Real_RegSetValueW)(HKEY a0, LPCWSTR a1, DWORD a2, LPCWSTR a3, DWORD a4)
-= RegSetValueW;
+LONG (WINAPI * Real_RegSetValueW)(HKEY a0, LPCWSTR a1, DWORD a2, LPCWSTR a3, DWORD a4)
+ = RegSetValueW;
-LONG(WINAPI * Real_RegSetValueA)(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD a4)
-= RegSetValueA;
+LONG (WINAPI * Real_RegSetValueA)(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD a4)
+ = RegSetValueA;
HRESULT WINAPI Mine_CoCreateInstance(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter,
- IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID FAR* ppv)
-{
- if(CFilterMapper2::m_pFilterMapper2)
- {
- CheckPointer(ppv, E_POINTER);
-
- if(rclsid == CLSID_FilterMapper)
- {
- ASSERT(0);
- return REGDB_E_CLASSNOTREG; // sorry...
- }
-
- if(rclsid == CLSID_FilterMapper2)
- {
- if(pUnkOuter) return CLASS_E_NOAGGREGATION;
-
- if(riid == __uuidof(IUnknown))
- {
- CFilterMapper2::m_pFilterMapper2->AddRef();
- *ppv = (IUnknown*)CFilterMapper2::m_pFilterMapper2;
- return S_OK;
- }
- else if(riid == __uuidof(IFilterMapper2))
- {
- CFilterMapper2::m_pFilterMapper2->AddRef();
- *ppv = (IFilterMapper2*)CFilterMapper2::m_pFilterMapper2;
- return S_OK;
- }
- else
- {
- return E_NOINTERFACE;
- }
- }
- }
- /* else
- {
- if(rclsid == CLSID_FilterMapper2)
- {
- CFilterMapper2* pFM2 = DNew CFilterMapper2(true, false, pUnkOuter);
- CComPtr<IUnknown> pUnk = (IUnknown*)pFM2;
- return pUnk->QueryInterface(riid, ppv);
- }
- }
- */
- if(!pUnkOuter)
- if(rclsid == CLSID_VideoMixingRenderer || rclsid == CLSID_VideoMixingRenderer9
- || rclsid == CLSID_VideoRenderer || rclsid == CLSID_VideoRendererDefault
- || rclsid == CLSID_OverlayMixer)// || rclsid == CLSID_OverlayMixer2 - where is this declared?)
- {
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- CComPtr<IUnknown> pInner;
- HRESULT hr;
- if(SUCCEEDED(hr = Real_CoCreateInstance(rclsid, pUnk, dwClsContext, __uuidof(IUnknown), (void**)&pInner)))
- {
- pMK->SetInner(pInner);
- return pUnk->QueryInterface(riid, ppv);
- }
- }
-
- return Real_CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
+ IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID FAR* ppv)
+{
+ if(CFilterMapper2::m_pFilterMapper2)
+ {
+ CheckPointer(ppv, E_POINTER);
+
+ if(rclsid == CLSID_FilterMapper)
+ {
+ ASSERT(0);
+ return REGDB_E_CLASSNOTREG; // sorry...
+ }
+
+ if(rclsid == CLSID_FilterMapper2)
+ {
+ if(pUnkOuter) return CLASS_E_NOAGGREGATION;
+
+ if(riid == __uuidof(IUnknown))
+ {
+ CFilterMapper2::m_pFilterMapper2->AddRef();
+ *ppv = (IUnknown*)CFilterMapper2::m_pFilterMapper2;
+ return S_OK;
+ }
+ else if(riid == __uuidof(IFilterMapper2))
+ {
+ CFilterMapper2::m_pFilterMapper2->AddRef();
+ *ppv = (IFilterMapper2*)CFilterMapper2::m_pFilterMapper2;
+ return S_OK;
+ }
+ else
+ {
+ return E_NOINTERFACE;
+ }
+ }
+ }
+/* else
+ {
+ if(rclsid == CLSID_FilterMapper2)
+ {
+ CFilterMapper2* pFM2 = DNew CFilterMapper2(true, false, pUnkOuter);
+ CComPtr<IUnknown> pUnk = (IUnknown*)pFM2;
+ return pUnk->QueryInterface(riid, ppv);
+ }
+ }
+*/
+ if(!pUnkOuter)
+ if(rclsid == CLSID_VideoMixingRenderer || rclsid == CLSID_VideoMixingRenderer9
+ || rclsid == CLSID_VideoRenderer || rclsid == CLSID_VideoRendererDefault
+ || rclsid == CLSID_OverlayMixer)// || rclsid == CLSID_OverlayMixer2 - where is this declared?)
+ {
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ CComPtr<IUnknown> pInner;
+ HRESULT hr;
+ if(SUCCEEDED(hr = Real_CoCreateInstance(rclsid, pUnk, dwClsContext, __uuidof(IUnknown), (void**)&pInner)))
+ {
+ pMK->SetInner(pInner);
+ return pUnk->QueryInterface(riid, ppv);
+ }
+ }
+
+ return Real_CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
}
#define FAKEHKEY (HKEY)0x12345678
LONG WINAPI Mine_RegCloseKey(HKEY a0)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_SUCCESS;
- }
- return Real_RegCloseKey(a0);
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_SUCCESS;}
+ return Real_RegCloseKey(a0);
}
LONG WINAPI Mine_RegFlushKey(HKEY a0)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_SUCCESS;
- }
- return Real_RegFlushKey(a0);
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_SUCCESS;}
+ return Real_RegFlushKey(a0);
}
LONG WINAPI Mine_RegCreateKeyA(HKEY a0, LPCSTR a1, PHKEY a2)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyA(a0, a1, a2);
+ if(CFilterMapper2::m_pFilterMapper2) {*a2 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegCreateKeyA(a0, a1, a2);
}
LONG WINAPI Mine_RegCreateKeyW(HKEY a0, LPCWSTR a1, PHKEY a2)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyW(a0, a1, a2);
+ if(CFilterMapper2::m_pFilterMapper2) {*a2 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegCreateKeyW(a0, a1, a2);
}
LONG WINAPI Mine_RegCreateKeyExA(HKEY a0, LPCSTR a1, DWORD a2, LPSTR a3, DWORD a4, REGSAM a5, LPSECURITY_ATTRIBUTES a6, PHKEY a7, LPDWORD a8)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
- *a7 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyExA(a0, a1, a2, a3, a4, a5, a6, a7, a8);
+ if(CFilterMapper2::m_pFilterMapper2) {*a7 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegCreateKeyExA(a0, a1, a2, a3, a4, a5, a6, a7, a8);
}
LONG WINAPI Mine_RegCreateKeyExW(HKEY a0, LPCWSTR a1, DWORD a2, LPWSTR a3, DWORD a4, REGSAM a5, LPSECURITY_ATTRIBUTES a6, PHKEY a7, LPDWORD a8)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
- *a7 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyExW(a0, a1, a2, a3, a4, a5, a6, a7, a8);
+ if(CFilterMapper2::m_pFilterMapper2) {*a7 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegCreateKeyExW(a0, a1, a2, a3, a4, a5, a6, a7, a8);
}
LONG WINAPI Mine_RegDeleteKeyA(HKEY a0, LPCSTR a1)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
- return Real_RegDeleteKeyA(a0, a1);
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
+ return Real_RegDeleteKeyA(a0, a1);
}
LONG WINAPI Mine_RegDeleteKeyW(HKEY a0, LPCWSTR a1)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
- return Real_RegDeleteKeyW(a0, a1);
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
+ return Real_RegDeleteKeyW(a0, a1);
}
LONG WINAPI Mine_RegDeleteValueA(HKEY a0, LPCSTR a1)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
return Real_RegDeleteValueA(a0, a1);
}
LONG WINAPI Mine_RegDeleteValueW(HKEY a0, LPCWSTR a1)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
return Real_RegDeleteValueW(a0, a1);
}
LONG WINAPI Mine_RegEnumKeyExA(HKEY a0, DWORD a1, LPSTR a2, LPDWORD a3, LPDWORD a4, LPSTR a5, LPDWORD a6, struct _FILETIME* a7)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_NO_MORE_ITEMS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_NO_MORE_ITEMS;}
return Real_RegEnumKeyExA(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegEnumKeyExW(HKEY a0, DWORD a1, LPWSTR a2, LPDWORD a3, LPDWORD a4, LPWSTR a5, LPDWORD a6, struct _FILETIME* a7)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_NO_MORE_ITEMS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_NO_MORE_ITEMS;}
return Real_RegEnumKeyExW(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegEnumValueA(HKEY a0, DWORD a1, LPSTR a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPBYTE a6, LPDWORD a7)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_NO_MORE_ITEMS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_NO_MORE_ITEMS;}
return Real_RegEnumValueA(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegEnumValueW(HKEY a0, DWORD a1, LPWSTR a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPBYTE a6, LPDWORD a7)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_NO_MORE_ITEMS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_NO_MORE_ITEMS;}
return Real_RegEnumValueW(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegOpenKeyA(HKEY a0, LPCSTR a1, PHKEY a2)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyA(a0, a1, a2);
+ if(CFilterMapper2::m_pFilterMapper2) {*a2 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegOpenKeyA(a0, a1, a2);
}
LONG WINAPI Mine_RegOpenKeyW(HKEY a0, LPCWSTR a1, PHKEY a2)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyW(a0, a1, a2);
+ if(CFilterMapper2::m_pFilterMapper2) {*a2 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegOpenKeyW(a0, a1, a2);
}
LONG WINAPI Mine_RegOpenKeyExA(HKEY a0, LPCSTR a1, DWORD a2, REGSAM a3, PHKEY a4)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE | KEY_CREATE_SUB_KEY)))
- {
- *a4 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyExA(a0, a1, a2, a3, a4);
+ if(CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE|KEY_CREATE_SUB_KEY))) {*a4 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegOpenKeyExA(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegOpenKeyExW(HKEY a0, LPCWSTR a1, DWORD a2, REGSAM a3, PHKEY a4)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE | KEY_CREATE_SUB_KEY)))
- {
- *a4 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyExW(a0, a1, a2, a3, a4);
+ if(CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE|KEY_CREATE_SUB_KEY))) {*a4 = FAKEHKEY; return ERROR_SUCCESS;}
+ return Real_RegOpenKeyExW(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegQueryInfoKeyA(HKEY a0, LPSTR a1, LPDWORD a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPDWORD a6, LPDWORD a7, LPDWORD a8, LPDWORD a9, LPDWORD a10, struct _FILETIME* a11)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_INVALID_HANDLE;
- }
- return Real_RegQueryInfoKeyA(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_INVALID_HANDLE;}
+ return Real_RegQueryInfoKeyA(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
}
LONG WINAPI Mine_RegQueryInfoKeyW(HKEY a0, LPWSTR a1, LPDWORD a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPDWORD a6, LPDWORD a7, LPDWORD a8, LPDWORD a9, LPDWORD a10, struct _FILETIME* a11)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- return ERROR_INVALID_HANDLE;
- }
- return Real_RegQueryInfoKeyW(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {return ERROR_INVALID_HANDLE;}
+ return Real_RegQueryInfoKeyW(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
}
LONG WINAPI Mine_RegQueryValueA(HKEY a0, LPCSTR a1, LPSTR a2, PLONG a3)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- *a3 = 0;
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {*a3 = 0; return ERROR_SUCCESS;}
return Real_RegQueryValueA(a0, a1, a2, a3);
}
LONG WINAPI Mine_RegQueryValueW(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- *a3 = 0;
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {*a3 = 0; return ERROR_SUCCESS;}
return Real_RegQueryValueW(a0, a1, a2, a3);
}
LONG WINAPI Mine_RegQueryValueExA(HKEY a0, LPCSTR a1, LPDWORD a2, LPDWORD a3, LPBYTE a4, LPDWORD a5)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- *a5 = 0;
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {*a5 = 0; return ERROR_SUCCESS;}
return Real_RegQueryValueExA(a0, a1, a2, a3, a4, a5);
}
LONG WINAPI Mine_RegQueryValueExW(HKEY a0, LPCWSTR a1, LPDWORD a2, LPDWORD a3, LPBYTE a4, LPDWORD a5)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
- *a5 = 0;
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {*a5 = 0; return ERROR_SUCCESS;}
return Real_RegQueryValueExW(a0, a1, a2, a3, a4, a5);
}
LONG WINAPI Mine_RegSetValueA(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD a4)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
return Real_RegSetValueA(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegSetValueW(HKEY a0, LPCWSTR a1, DWORD a2, LPCWSTR a3, DWORD a4)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
return Real_RegSetValueW(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegSetValueExA(HKEY a0, LPCSTR a1, DWORD a2, DWORD a3, BYTE* a4, DWORD a5)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
return Real_RegSetValueExA(a0, a1, a2, a3, a4, a5);
}
LONG WINAPI Mine_RegSetValueExW(HKEY a0, LPCWSTR a1, DWORD a2, DWORD a3, BYTE* a4, DWORD a5)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
- return ERROR_SUCCESS;
- }
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {return ERROR_SUCCESS;}
return Real_RegSetValueExW(a0, a1, a2, a3, a4, a5);
}
@@ -538,200 +442,200 @@ bool CFilterMapper2::fInitialized = false;
void CFilterMapper2::Init()
{
- if(!fInitialized)
- {
- DetourAttach(&(PVOID&)Real_CoCreateInstance, (PVOID)Mine_CoCreateInstance);
- DetourAttach(&(PVOID&)Real_RegCloseKey, (PVOID)Mine_RegCloseKey);
- DetourAttach(&(PVOID&)Real_RegFlushKey, (PVOID)Mine_RegFlushKey);
- DetourAttach(&(PVOID&)Real_RegCreateKeyA, (PVOID)Mine_RegCreateKeyA);
- DetourAttach(&(PVOID&)Real_RegCreateKeyW, (PVOID)Mine_RegCreateKeyW);
- DetourAttach(&(PVOID&)Real_RegCreateKeyExA, (PVOID)Mine_RegCreateKeyExA);
- DetourAttach(&(PVOID&)Real_RegCreateKeyExW, (PVOID)Mine_RegCreateKeyExW);
- DetourAttach(&(PVOID&)Real_RegDeleteKeyA, (PVOID)Mine_RegDeleteKeyA);
- DetourAttach(&(PVOID&)Real_RegDeleteKeyW, (PVOID)Mine_RegDeleteKeyW);
- DetourAttach(&(PVOID&)Real_RegDeleteValueA, (PVOID)Mine_RegDeleteValueA);
- DetourAttach(&(PVOID&)Real_RegDeleteValueW, (PVOID)Mine_RegDeleteValueW);
- DetourAttach(&(PVOID&)Real_RegEnumKeyExA, (PVOID)Mine_RegEnumKeyExA);
- DetourAttach(&(PVOID&)Real_RegEnumKeyExW, (PVOID)Mine_RegEnumKeyExW);
- DetourAttach(&(PVOID&)Real_RegEnumValueA, (PVOID)Mine_RegEnumValueA);
- DetourAttach(&(PVOID&)Real_RegEnumValueW, (PVOID)Mine_RegEnumValueW);
- DetourAttach(&(PVOID&)Real_RegOpenKeyA, (PVOID)Mine_RegOpenKeyA);
- DetourAttach(&(PVOID&)Real_RegOpenKeyW, (PVOID)Mine_RegOpenKeyW);
- DetourAttach(&(PVOID&)Real_RegOpenKeyExA, (PVOID)Mine_RegOpenKeyExA);
- DetourAttach(&(PVOID&)Real_RegOpenKeyExW, (PVOID)Mine_RegOpenKeyExW);
- DetourAttach(&(PVOID&)Real_RegQueryInfoKeyA, (PVOID)Mine_RegQueryInfoKeyA);
- DetourAttach(&(PVOID&)Real_RegQueryInfoKeyW, (PVOID)Mine_RegQueryInfoKeyW);
- DetourAttach(&(PVOID&)Real_RegQueryValueA, (PVOID)Mine_RegQueryValueA);
- DetourAttach(&(PVOID&)Real_RegQueryValueW, (PVOID)Mine_RegQueryValueW);
- DetourAttach(&(PVOID&)Real_RegQueryValueExA, (PVOID)Mine_RegQueryValueExA);
- DetourAttach(&(PVOID&)Real_RegQueryValueExW, (PVOID)Mine_RegQueryValueExW);
- DetourAttach(&(PVOID&)Real_RegSetValueA, (PVOID)Mine_RegSetValueA);
- DetourAttach(&(PVOID&)Real_RegSetValueW, (PVOID)Mine_RegSetValueW);
- DetourAttach(&(PVOID&)Real_RegSetValueExA, (PVOID)Mine_RegSetValueExA);
- DetourAttach(&(PVOID&)Real_RegSetValueExW, (PVOID)Mine_RegSetValueExW);
-
- fInitialized = true;
- }
+ if(!fInitialized)
+ {
+ DetourAttach(&(PVOID&)Real_CoCreateInstance, (PVOID)Mine_CoCreateInstance);
+ DetourAttach(&(PVOID&)Real_RegCloseKey, (PVOID)Mine_RegCloseKey);
+ DetourAttach(&(PVOID&)Real_RegFlushKey, (PVOID)Mine_RegFlushKey);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyA, (PVOID)Mine_RegCreateKeyA);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyW, (PVOID)Mine_RegCreateKeyW);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyExA, (PVOID)Mine_RegCreateKeyExA);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyExW, (PVOID)Mine_RegCreateKeyExW);
+ DetourAttach(&(PVOID&)Real_RegDeleteKeyA, (PVOID)Mine_RegDeleteKeyA);
+ DetourAttach(&(PVOID&)Real_RegDeleteKeyW, (PVOID)Mine_RegDeleteKeyW);
+ DetourAttach(&(PVOID&)Real_RegDeleteValueA, (PVOID)Mine_RegDeleteValueA);
+ DetourAttach(&(PVOID&)Real_RegDeleteValueW, (PVOID)Mine_RegDeleteValueW);
+ DetourAttach(&(PVOID&)Real_RegEnumKeyExA, (PVOID)Mine_RegEnumKeyExA);
+ DetourAttach(&(PVOID&)Real_RegEnumKeyExW, (PVOID)Mine_RegEnumKeyExW);
+ DetourAttach(&(PVOID&)Real_RegEnumValueA, (PVOID)Mine_RegEnumValueA);
+ DetourAttach(&(PVOID&)Real_RegEnumValueW, (PVOID)Mine_RegEnumValueW);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyA, (PVOID)Mine_RegOpenKeyA);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyW, (PVOID)Mine_RegOpenKeyW);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyExA, (PVOID)Mine_RegOpenKeyExA);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyExW, (PVOID)Mine_RegOpenKeyExW);
+ DetourAttach(&(PVOID&)Real_RegQueryInfoKeyA, (PVOID)Mine_RegQueryInfoKeyA);
+ DetourAttach(&(PVOID&)Real_RegQueryInfoKeyW, (PVOID)Mine_RegQueryInfoKeyW);
+ DetourAttach(&(PVOID&)Real_RegQueryValueA, (PVOID)Mine_RegQueryValueA);
+ DetourAttach(&(PVOID&)Real_RegQueryValueW, (PVOID)Mine_RegQueryValueW);
+ DetourAttach(&(PVOID&)Real_RegQueryValueExA, (PVOID)Mine_RegQueryValueExA);
+ DetourAttach(&(PVOID&)Real_RegQueryValueExW, (PVOID)Mine_RegQueryValueExW);
+ DetourAttach(&(PVOID&)Real_RegSetValueA, (PVOID)Mine_RegSetValueA);
+ DetourAttach(&(PVOID&)Real_RegSetValueW, (PVOID)Mine_RegSetValueW);
+ DetourAttach(&(PVOID&)Real_RegSetValueExA, (PVOID)Mine_RegSetValueExA);
+ DetourAttach(&(PVOID&)Real_RegSetValueExW, (PVOID)Mine_RegSetValueExW);
+
+ fInitialized = true;
+ }
}
CFilterMapper2::CFilterMapper2(bool fRefCounted, bool fAllowUnreg, LPUNKNOWN pUnkOuter)
- : CUnknown(NAME("CFilterMapper2"), pUnkOuter)
- , m_fRefCounted(fRefCounted), m_fAllowUnreg(fAllowUnreg)
+ : CUnknown(NAME("CFilterMapper2"), pUnkOuter)
+ , m_fRefCounted(fRefCounted), m_fAllowUnreg(fAllowUnreg)
{
- m_cRef = fRefCounted ? 0 : 1;
+ m_cRef = fRefCounted ? 0 : 1;
- Init();
+ Init();
- HRESULT hr = Real_CoCreateInstance(
- CLSID_FilterMapper2, (IUnknown*)(INonDelegatingUnknown*)this, CLSCTX_ALL,
- __uuidof(IUnknown), (void**)&m_pFM2);
- if(FAILED(hr) || !m_pFM2)
- {
- ASSERT(0);
- return;
- }
+ HRESULT hr = Real_CoCreateInstance(
+ CLSID_FilterMapper2, (IUnknown*)(INonDelegatingUnknown*)this, CLSCTX_ALL,
+ __uuidof(IUnknown), (void**)&m_pFM2);
+ if(FAILED(hr) || !m_pFM2)
+ {
+ ASSERT(0);
+ return;
+ }
}
CFilterMapper2::~CFilterMapper2()
{
- POSITION pos = m_filters.GetHeadPosition();
- while(pos) delete m_filters.GetNext(pos);
+ POSITION pos = m_filters.GetHeadPosition();
+ while(pos) delete m_filters.GetNext(pos);
}
STDMETHODIMP CFilterMapper2::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if(riid == __uuidof(IFilterMapper2))
- return GetInterface((IFilterMapper2*)this, ppv);
+ if(riid == __uuidof(IFilterMapper2))
+ return GetInterface((IFilterMapper2*)this, ppv);
- HRESULT hr = m_pFM2 ? m_pFM2->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ HRESULT hr = m_pFM2 ? m_pFM2->QueryInterface(riid, ppv) : E_NOINTERFACE;
- return
- SUCCEEDED(hr) ? hr :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ SUCCEEDED(hr) ? hr :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CFilterMapper2::Register(CString path)
{
- if(HMODULE h = LoadLibrary(path))
- {
- typedef HRESULT(__stdcall * PDllRegisterServer)();
- if(PDllRegisterServer p = (PDllRegisterServer)GetProcAddress(h, "DllRegisterServer"))
- {
- ASSERT(CFilterMapper2::m_pFilterMapper2 == NULL);
+ if(HMODULE h = LoadLibrary(path))
+ {
+ typedef HRESULT (__stdcall * PDllRegisterServer)();
+ if(PDllRegisterServer p = (PDllRegisterServer)GetProcAddress(h, "DllRegisterServer"))
+ {
+ ASSERT(CFilterMapper2::m_pFilterMapper2 == NULL);
- CFilterMapper2::m_pFilterMapper2 = this;
- m_path = path;
- p();
- m_path.Empty();
- CFilterMapper2::m_pFilterMapper2 = NULL;
- }
+ CFilterMapper2::m_pFilterMapper2 = this;
+ m_path = path;
+ p();
+ m_path.Empty();
+ CFilterMapper2::m_pFilterMapper2 = NULL;
+ }
- FreeLibrary(h);
- }
+ FreeLibrary(h);
+ }
}
// IFilterMapper2
STDMETHODIMP CFilterMapper2::CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description)
{
- if(!m_path.IsEmpty())
- {
- return S_OK;
- }
- else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
- {
- return pFM2->CreateCategory(clsidCategory, dwCategoryMerit, Description);
- }
+ if(!m_path.IsEmpty())
+ {
+ return S_OK;
+ }
+ else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
+ {
+ return pFM2->CreateCategory(clsidCategory, dwCategoryMerit, Description);
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CFilterMapper2::UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter)
{
- if(!m_path.IsEmpty())
- {
- return S_OK;
- }
- else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
- {
- return m_fAllowUnreg
- ? pFM2->UnregisterFilter(pclsidCategory, szInstance, Filter)
- : S_OK;
- }
+ if(!m_path.IsEmpty())
+ {
+ return S_OK;
+ }
+ else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
+ {
+ return m_fAllowUnreg
+ ? pFM2->UnregisterFilter(pclsidCategory, szInstance, Filter)
+ : S_OK;
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-
+
STDMETHODIMP CFilterMapper2::RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2)
{
- if(!m_path.IsEmpty())
- {
- if(FilterOverride* f = DNew FilterOverride)
- {
- f->fDisabled = false;
- f->type = FilterOverride::EXTERNAL;
- f->path = m_path;
- f->name = CStringW(Name);
- f->clsid = clsidFilter;
- f->iLoadType = FilterOverride::MERIT;
- f->dwMerit = prf2->dwMerit;
-
- if(prf2->dwVersion == 1)
- {
- for(ULONG i = 0; i < prf2->cPins; i++)
- {
- const REGFILTERPINS& rgPin = prf2->rgPins[i];
- if(rgPin.bOutput) continue;
-
- for(UINT i = 0; i < rgPin.nMediaTypes; i++)
- {
- if(!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) break;
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
- }
- }
- }
- else if(prf2->dwVersion == 2)
- {
- for(ULONG i = 0; i < prf2->cPins2; i++)
- {
- const REGFILTERPINS2& rgPin = prf2->rgPins2[i];
- if(rgPin.dwFlags & REG_PINFLAG_B_OUTPUT) continue;
-
- for(UINT i = 0; i < rgPin.nMediaTypes; i++)
- {
- if(!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) break;
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
- }
- }
- }
-
- f->backup.AddTailList(&f->guids);
-
- m_filters.AddTail(f);
- }
-
- return S_OK;
- }
- else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
- {
- return pFM2->RegisterFilter(clsidFilter, Name, ppMoniker, pclsidCategory, szInstance, prf2);
- }
-
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CFilterMapper2::EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
- BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
- BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut)
-{
- if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
- {
- pFM2->EnumMatchingFilters(ppEnum, dwFlags, bExactMatch, dwMerit,
- bInputNeeded, cInputTypes, pInputTypes, pMedIn, pPinCategoryIn, bRender,
- bOutputNeeded, cOutputTypes, pOutputTypes, pMedOut, pPinCategoryOut);
- }
-
- return E_NOTIMPL;
+ if(!m_path.IsEmpty())
+ {
+ if(FilterOverride* f = DNew FilterOverride)
+ {
+ f->fDisabled = false;
+ f->type = FilterOverride::EXTERNAL;
+ f->path = m_path;
+ f->name = CStringW(Name);
+ f->clsid = clsidFilter;
+ f->iLoadType = FilterOverride::MERIT;
+ f->dwMerit = prf2->dwMerit;
+
+ if(prf2->dwVersion == 1)
+ {
+ for(ULONG i = 0; i < prf2->cPins; i++)
+ {
+ const REGFILTERPINS& rgPin = prf2->rgPins[i];
+ if(rgPin.bOutput) continue;
+
+ for(UINT i = 0; i < rgPin.nMediaTypes; i++)
+ {
+ if(!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) break;
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
+ }
+ }
+ }
+ else if(prf2->dwVersion == 2)
+ {
+ for(ULONG i = 0; i < prf2->cPins2; i++)
+ {
+ const REGFILTERPINS2& rgPin = prf2->rgPins2[i];
+ if(rgPin.dwFlags&REG_PINFLAG_B_OUTPUT) continue;
+
+ for(UINT i = 0; i < rgPin.nMediaTypes; i++)
+ {
+ if(!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) break;
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
+ }
+ }
+ }
+
+ f->backup.AddTailList(&f->guids);
+
+ m_filters.AddTail(f);
+ }
+
+ return S_OK;
+ }
+ else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
+ {
+ return pFM2->RegisterFilter(clsidFilter, Name, ppMoniker, pclsidCategory, szInstance, prf2);
+ }
+
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CFilterMapper2::EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
+ BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
+ BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut)
+{
+ if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
+ {
+ pFM2->EnumMatchingFilters(ppEnum, dwFlags, bExactMatch, dwMerit,
+ bInputNeeded, cInputTypes, pInputTypes, pMedIn, pPinCategoryIn, bRender,
+ bOutputNeeded, cOutputTypes, pOutputTypes, pMedOut, pPinCategoryOut);
+ }
+
+ return E_NOTIMPL;
}
diff --git a/src/apps/mplayerc/FakeFilterMapper2.h b/src/apps/mplayerc/FakeFilterMapper2.h
index 0cd159c20..ddc1423d3 100644
--- a/src/apps/mplayerc/FakeFilterMapper2.h
+++ b/src/apps/mplayerc/FakeFilterMapper2.h
@@ -29,37 +29,34 @@
class FilterOverride
{
public:
- bool fDisabled, fTemporary;
- enum {REGISTERED, EXTERNAL} type;
- // REGISTERED
- CStringW dispname;
- // EXTERNAL
- CString path, name;
- CLSID clsid;
- // props
- CAtlList<GUID> guids, backup;
- enum {PREFERRED, BLOCK, MERIT};
- int iLoadType;
- DWORD dwMerit;
-
- FilterOverride()
- {
- fTemporary = false;
- }
- FilterOverride(FilterOverride* f)
- {
- fDisabled = f->fDisabled;
- fTemporary = f->fTemporary;
- type = f->type;
- dispname = f->dispname;
- path = f->path;
- name = f->name;
- clsid = f->clsid;
- guids.AddTailList(&f->guids);
- backup.AddTailList(&f->backup);
- iLoadType = f->iLoadType;
- dwMerit = f->dwMerit;
- }
+ bool fDisabled, fTemporary;
+ enum {REGISTERED, EXTERNAL} type;
+ // REGISTERED
+ CStringW dispname;
+ // EXTERNAL
+ CString path, name;
+ CLSID clsid;
+ // props
+ CAtlList<GUID> guids, backup;
+ enum {PREFERRED, BLOCK, MERIT};
+ int iLoadType;
+ DWORD dwMerit;
+
+ FilterOverride() {fTemporary = false;}
+ FilterOverride(FilterOverride* f)
+ {
+ fDisabled = f->fDisabled;
+ fTemporary = f->fTemporary;
+ type = f->type;
+ dispname = f->dispname;
+ path = f->path;
+ name = f->name;
+ clsid = f->clsid;
+ guids.AddTailList(&f->guids);
+ backup.AddTailList(&f->backup);
+ iLoadType = f->iLoadType;
+ dwMerit = f->dwMerit;
+ }
};
/*
class CFilterMapper2 : protected CUnknown, protected IFilterMapper2
@@ -74,15 +71,15 @@ protected:
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IFilterMapper2
-
+
STDMETHODIMP CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description);
- STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
+ STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
STDMETHODIMP RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2);
- STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
- BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
+ STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
+ BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut);
-public:
+public:
CFilterMapper2();
virtual ~CFilterMapper2();
@@ -96,38 +93,35 @@ public:
class CFilterMapper2 : protected CUnknown, public IFilterMapper2
{
- static bool fInitialized;
+ static bool fInitialized;
- CComPtr<IUnknown> m_pFM2;
- CString m_path;
+ CComPtr<IUnknown> m_pFM2;
+ CString m_path;
- bool m_fRefCounted, m_fAllowUnreg;
+ bool m_fRefCounted, m_fAllowUnreg;
protected:
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IFilterMapper2
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- STDMETHODIMP CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description);
- STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
- STDMETHODIMP RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2);
- STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
- BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
- BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut);
+ // IFilterMapper2
+
+ STDMETHODIMP CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description);
+ STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
+ STDMETHODIMP RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2);
+ STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
+ BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
+ BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut);
-public:
- CFilterMapper2(bool fRefCounted, bool fAllowUnreg = false, LPUNKNOWN pUnkOuter = NULL);
- virtual ~CFilterMapper2();
+public:
+ CFilterMapper2(bool fRefCounted, bool fAllowUnreg = false, LPUNKNOWN pUnkOuter = NULL);
+ virtual ~CFilterMapper2();
- void SetInner(IUnknown* pUnk)
- {
- m_pFM2 = pUnk;
- }
+ void SetInner(IUnknown* pUnk) {m_pFM2 = pUnk;}
- static void Init();
+ static void Init();
- static IFilterMapper2* m_pFilterMapper2;
- CList<FilterOverride*> m_filters;
- void Register(CString path);
+ static IFilterMapper2* m_pFilterMapper2;
+ CList<FilterOverride*> m_filters;
+ void Register(CString path);
};
diff --git a/src/apps/mplayerc/FavoriteAddDlg.cpp b/src/apps/mplayerc/FavoriteAddDlg.cpp
index 267c86def..a3e3ed49d 100644
--- a/src/apps/mplayerc/FavoriteAddDlg.cpp
+++ b/src/apps/mplayerc/FavoriteAddDlg.cpp
@@ -31,11 +31,11 @@
IMPLEMENT_DYNAMIC(CFavoriteAddDlg, CCmdUIDialog)
CFavoriteAddDlg::CFavoriteAddDlg(CString shortname, CString fullname, CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CFavoriteAddDlg::IDD, pParent)
- , m_shortname(shortname)
- , m_fullname(fullname)
- , m_bRememberPos(TRUE)
- , m_bRelativeDrive(FALSE)
+ : CCmdUIDialog(CFavoriteAddDlg::IDD, pParent)
+ , m_shortname(shortname)
+ , m_fullname(fullname)
+ , m_bRememberPos(TRUE)
+ , m_bRelativeDrive(FALSE)
{
}
@@ -45,39 +45,39 @@ CFavoriteAddDlg::~CFavoriteAddDlg()
void CFavoriteAddDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_namectrl);
- DDX_CBString(pDX, IDC_COMBO1, m_name);
- DDX_Check(pDX, IDC_CHECK1, m_bRememberPos);
- DDX_Check(pDX, IDC_CHECK2, m_bRelativeDrive);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_namectrl);
+ DDX_CBString(pDX, IDC_COMBO1, m_name);
+ DDX_Check(pDX, IDC_CHECK1, m_bRememberPos);
+ DDX_Check(pDX, IDC_CHECK2, m_bRelativeDrive);
}
BOOL CFavoriteAddDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- if(!m_shortname.IsEmpty())
- m_namectrl.AddString(m_shortname);
+ if ( !m_shortname.IsEmpty() )
+ m_namectrl.AddString( m_shortname );
- if(!m_fullname.IsEmpty())
- m_namectrl.AddString(m_fullname);
+ if ( !m_fullname.IsEmpty() )
+ m_namectrl.AddString( m_fullname );
- ::CorrectComboListWidth(m_namectrl, GetFont());
+ ::CorrectComboListWidth( m_namectrl, GetFont() );
- m_bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
- m_bRelativeDrive = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
+ m_bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
+ m_bRelativeDrive = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
- UpdateData(FALSE); // Update UI
+ UpdateData(FALSE); // Update UI
- m_namectrl.SetCurSel(0);
+ m_namectrl.SetCurSel( 0 );
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CFavoriteAddDlg, CCmdUIDialog)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
END_MESSAGE_MAP()
@@ -85,18 +85,18 @@ END_MESSAGE_MAP()
void CFavoriteAddDlg::OnUpdateOk(CCmdUI *pCmdUI)
{
- UpdateData(); // Retrieve UI values
+ UpdateData(); // Retrieve UI values
- pCmdUI->Enable(!m_name.IsEmpty());
+ pCmdUI->Enable( !m_name.IsEmpty() );
}
void CFavoriteAddDlg::OnOK()
{
- UpdateData(); // Retrieve UI values
+ UpdateData(); // Retrieve UI values
- // Remember settings
- AfxGetApp()->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, m_bRememberPos);
- AfxGetApp()->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, m_bRelativeDrive);
+ // Remember settings
+ AfxGetApp()->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, m_bRememberPos);
+ AfxGetApp()->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, m_bRelativeDrive);
- CCmdUIDialog::OnOK();
+ CCmdUIDialog::OnOK();
}
diff --git a/src/apps/mplayerc/FavoriteAddDlg.h b/src/apps/mplayerc/FavoriteAddDlg.h
index 6b39d07f5..4aa2ea809 100644
--- a/src/apps/mplayerc/FavoriteAddDlg.h
+++ b/src/apps/mplayerc/FavoriteAddDlg.h
@@ -27,31 +27,31 @@
class CFavoriteAddDlg : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CFavoriteAddDlg)
+ DECLARE_DYNAMIC(CFavoriteAddDlg)
private:
- CString m_shortname, m_fullname;
+ CString m_shortname, m_fullname;
public:
- CFavoriteAddDlg(CString shortname, CString fullname, CWnd* pParent = NULL); // standard constructor
- virtual ~CFavoriteAddDlg();
+ CFavoriteAddDlg(CString shortname, CString fullname, CWnd* pParent = NULL); // standard constructor
+ virtual ~CFavoriteAddDlg();
// Dialog Data
- enum { IDD = IDD_FAVADD };
+ enum { IDD = IDD_FAVADD };
- CComboBox m_namectrl;
- CString m_name;
- BOOL m_bRememberPos;
- BOOL m_bRelativeDrive;
+ CComboBox m_namectrl;
+ CString m_name;
+ BOOL m_bRememberPos;
+ BOOL m_bRelativeDrive;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
protected:
- virtual void OnOK();
+ virtual void OnOK();
};
diff --git a/src/apps/mplayerc/FavoriteOrganizeDlg.cpp b/src/apps/mplayerc/FavoriteOrganizeDlg.cpp
index b323bd2f1..828690988 100644
--- a/src/apps/mplayerc/FavoriteOrganizeDlg.cpp
+++ b/src/apps/mplayerc/FavoriteOrganizeDlg.cpp
@@ -30,7 +30,7 @@
//IMPLEMENT_DYNAMIC(CFavoriteOrganizeDlg, CResizableDialog)
CFavoriteOrganizeDlg::CFavoriteOrganizeDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CFavoriteOrganizeDlg::IDD, pParent)
+ : CResizableDialog(CFavoriteOrganizeDlg::IDD, pParent)
{
}
@@ -40,68 +40,68 @@ CFavoriteOrganizeDlg::~CFavoriteOrganizeDlg()
void CFavoriteOrganizeDlg::SetupList(bool fSave)
{
- int i = m_tab.GetCurSel();
-
- if(fSave)
- {
- CAtlList<CString> sl;
-
- for(int j = 0; j < m_list.GetItemCount(); j++)
- {
- CString desc = m_list.GetItemText(j, 0);
- desc.Remove(';');
- CString str = m_sl[i].GetAt((POSITION)m_list.GetItemData(j));
- sl.AddTail(desc + str.Mid(str.Find(';')));
- }
-
- m_sl[i].RemoveAll();
- m_sl[i].AddTailList(&sl);
- }
- else
- {
- m_list.DeleteAllItems();
-
- POSITION pos = m_sl[i].GetHeadPosition(), tmp;
- while(pos)
- {
- tmp = pos;
- CString s = m_sl[i].GetNext(pos);
- int i = s.Find(';');
- if(i >= 0) s = s.Left(i);
- m_list.SetItemData(m_list.InsertItem(m_list.GetItemCount(), s), (DWORD_PTR)tmp);
- }
-
- m_list.SetRedraw(FALSE);
-
- CRect r;
- m_list.GetClientRect(r);
- m_list.SetColumnWidth(0, -1);
- m_list.SetColumnWidth(0, max(m_list.GetColumnWidth(0), r.Size().cx));
-
- m_list.SetRedraw(TRUE);
- }
+ int i = m_tab.GetCurSel();
+
+ if(fSave)
+ {
+ CAtlList<CString> sl;
+
+ for(int j = 0; j < m_list.GetItemCount(); j++)
+ {
+ CString desc = m_list.GetItemText(j, 0);
+ desc.Remove(';');
+ CString str = m_sl[i].GetAt((POSITION)m_list.GetItemData(j));
+ sl.AddTail(desc + str.Mid(str.Find(';')));
+ }
+
+ m_sl[i].RemoveAll();
+ m_sl[i].AddTailList(&sl);
+ }
+ else
+ {
+ m_list.DeleteAllItems();
+
+ POSITION pos = m_sl[i].GetHeadPosition(), tmp;
+ while(pos)
+ {
+ tmp = pos;
+ CString s = m_sl[i].GetNext(pos);
+ int i = s.Find(';');
+ if(i >= 0) s = s.Left(i);
+ m_list.SetItemData(m_list.InsertItem(m_list.GetItemCount(), s), (DWORD_PTR)tmp);
+ }
+
+ m_list.SetRedraw(FALSE);
+
+ CRect r;
+ m_list.GetClientRect(r);
+ m_list.SetColumnWidth(0, -1);
+ m_list.SetColumnWidth(0, max(m_list.GetColumnWidth(0), r.Size().cx));
+
+ m_list.SetRedraw(TRUE);
+ }
}
void CFavoriteOrganizeDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_TAB1, m_tab);
- DDX_Control(pDX, IDC_LIST2, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_TAB1, m_tab);
+ DDX_Control(pDX, IDC_LIST2, m_list);
}
BEGIN_MESSAGE_MAP(CFavoriteOrganizeDlg, CResizableDialog)
- ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
- ON_WM_DRAWITEM()
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
- ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton7)
- ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, OnTcnSelchangingTab1)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_WM_ACTIVATE()
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST2, OnLvnEndlabeleditList2)
- ON_WM_SIZE()
+ ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
+ ON_WM_DRAWITEM()
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
+ ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton7)
+ ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, OnTcnSelchangingTab1)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_WM_ACTIVATE()
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST2, OnLvnEndlabeleditList2)
+ ON_WM_SIZE()
END_MESSAGE_MAP()
@@ -109,175 +109,175 @@ END_MESSAGE_MAP()
BOOL CFavoriteOrganizeDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_tab.InsertItem(0, ResStr(IDS_FAVFILES));
- m_tab.InsertItem(1, ResStr(IDS_FAVDVDS));
+ m_tab.InsertItem(0, ResStr(IDS_FAVFILES));
+ m_tab.InsertItem(1, ResStr(IDS_FAVDVDS));
// m_tab.InsertItem(2, ResStr(IDS_FAVDEVICES));
- m_tab.SetCurSel(0);
-
- m_list.InsertColumn(0, _T(""));
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
-
- AfxGetAppSettings().GetFav(FAV_FILE, m_sl[0]);
- AfxGetAppSettings().GetFav(FAV_DVD, m_sl[1]);
- AfxGetAppSettings().GetFav(FAV_DEVICE, m_sl[2]);
-
- SetupList(false);
-
- AddAnchor(IDC_TAB1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
- AddAnchor(IDC_BUTTON2, TOP_RIGHT);
- AddAnchor(IDC_BUTTON3, TOP_RIGHT);
- AddAnchor(IDC_BUTTON4, TOP_RIGHT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ m_tab.SetCurSel(0);
+
+ m_list.InsertColumn(0, _T(""));
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
+
+ AfxGetAppSettings().GetFav(FAV_FILE, m_sl[0]);
+ AfxGetAppSettings().GetFav(FAV_DVD, m_sl[1]);
+ AfxGetAppSettings().GetFav(FAV_DEVICE, m_sl[2]);
+
+ SetupList(false);
+
+ AddAnchor(IDC_TAB1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON2, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON3, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON4, TOP_RIGHT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CFavoriteOrganizeDlg::OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
- SetupList(false);
+ SetupList(false);
- m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
- *pResult = 0;
+ *pResult = 0;
}
void CFavoriteOrganizeDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_LIST2) return;
+ if(nIDCtl != IDC_LIST2) return;
- int nItem = lpDrawItemStruct->itemID;
- CRect rcItem = lpDrawItemStruct->rcItem;
+ int nItem = lpDrawItemStruct->itemID;
+ CRect rcItem = lpDrawItemStruct->rcItem;
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
- if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
- {
- FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
- FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- }
- else
- {
- CBrush b;
- b.CreateSysColorBrush(COLOR_WINDOW);
- FillRect(pDC->m_hDC, rcItem, b);
- }
+ if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
+ {
+ FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
+ FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
+ }
+ else
+ {
+ CBrush b;
+ b.CreateSysColorBrush(COLOR_WINDOW);
+ FillRect(pDC->m_hDC, rcItem, b);
+ }
- CString str = m_list.GetItemText(nItem, 0);
+ CString str = m_list.GetItemText(nItem, 0);
- pDC->SetTextColor(0);
- pDC->TextOut(rcItem.left + 3, (rcItem.top + rcItem.bottom - pDC->GetTextExtent(str).cy) / 2, str);
+ pDC->SetTextColor(0);
+ pDC->TextOut(rcItem.left+3, (rcItem.top+rcItem.bottom - pDC->GetTextExtent(str).cy)/2, str);
}
void CFavoriteOrganizeDlg::OnBnClickedButton1()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
- m_list.SetFocus();
- m_list.EditLabel(m_list.GetNextSelectedItem(pos));
- }
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition())
+ {
+ m_list.SetFocus();
+ m_list.EditLabel(m_list.GetNextSelectedItem(pos));
+ }
}
void CFavoriteOrganizeDlg::OnLvnEndlabeleditList2(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
- if(pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText)
- m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
- *pResult = 0;
+ NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
+ if(pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText)
+ m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
+ *pResult = 0;
}
void CFavoriteOrganizeDlg::OnBnClickedButton2()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
- int nItem = m_list.GetNextSelectedItem(pos);
- if(nItem < 0 || nItem >= m_list.GetItemCount()) return;
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition())
+ {
+ int nItem = m_list.GetNextSelectedItem(pos);
+ if(nItem < 0 || nItem >= m_list.GetItemCount()) return;
- m_list.DeleteItem(nItem);
+ m_list.DeleteItem(nItem);
- nItem = min(nItem, m_list.GetItemCount() - 1);
+ nItem = min(nItem, m_list.GetItemCount()-1);
- m_list.SetSelectionMark(nItem);
- m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
- }
+ m_list.SetSelectionMark(nItem);
+ m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
+ }
}
void CFavoriteOrganizeDlg::OnBnClickedButton3()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
- int nItem = m_list.GetNextSelectedItem(pos);
- if(nItem <= 0) return;
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition())
+ {
+ int nItem = m_list.GetNextSelectedItem(pos);
+ if(nItem <= 0) return;
- DWORD_PTR data = m_list.GetItemData(nItem);
- CString str = m_list.GetItemText(nItem, 0);
+ DWORD_PTR data = m_list.GetItemData(nItem);
+ CString str = m_list.GetItemText(nItem, 0);
- m_list.DeleteItem(nItem);
+ m_list.DeleteItem(nItem);
- nItem--;
+ nItem--;
- m_list.InsertItem(nItem, str);
- m_list.SetItemData(nItem, data);
- m_list.SetSelectionMark(nItem);
- m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
- }
+ m_list.InsertItem(nItem, str);
+ m_list.SetItemData(nItem, data);
+ m_list.SetSelectionMark(nItem);
+ m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
+ }
}
void CFavoriteOrganizeDlg::OnBnClickedButton7()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
- int nItem = m_list.GetNextSelectedItem(pos);
- if(nItem < 0 || nItem >= m_list.GetItemCount() - 1) return;
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition())
+ {
+ int nItem = m_list.GetNextSelectedItem(pos);
+ if(nItem < 0 || nItem >= m_list.GetItemCount()-1) return;
- DWORD_PTR data = m_list.GetItemData(nItem);
- CString str = m_list.GetItemText(nItem, 0);
+ DWORD_PTR data = m_list.GetItemData(nItem);
+ CString str = m_list.GetItemText(nItem, 0);
- m_list.DeleteItem(nItem);
+ m_list.DeleteItem(nItem);
- nItem++;
+ nItem++;
- m_list.InsertItem(nItem, str);
- m_list.SetItemData(nItem, data);
- m_list.SetSelectionMark(nItem);
- m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
- }
+ m_list.InsertItem(nItem, str);
+ m_list.SetItemData(nItem, data);
+ m_list.SetSelectionMark(nItem);
+ m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
+ }
}
void CFavoriteOrganizeDlg::OnTcnSelchangingTab1(NMHDR *pNMHDR, LRESULT *pResult)
{
- SetupList(true);
+ SetupList(true);
- *pResult = 0;
+ *pResult = 0;
}
void CFavoriteOrganizeDlg::OnBnClickedOk()
{
- SetupList(true);
+ SetupList(true);
- AfxGetAppSettings().SetFav(FAV_FILE, m_sl[0]);
- AfxGetAppSettings().SetFav(FAV_DVD, m_sl[1]);
- AfxGetAppSettings().SetFav(FAV_DEVICE, m_sl[2]);
+ AfxGetAppSettings().SetFav(FAV_FILE, m_sl[0]);
+ AfxGetAppSettings().SetFav(FAV_DVD, m_sl[1]);
+ AfxGetAppSettings().SetFav(FAV_DEVICE, m_sl[2]);
- OnOK();
+ OnOK();
}
void CFavoriteOrganizeDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
- __super::OnActivate(nState, pWndOther, bMinimized);
+ __super::OnActivate(nState, pWndOther, bMinimized);
- if(nState == WA_ACTIVE)
- m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ if(nState == WA_ACTIVE)
+ m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
void CFavoriteOrganizeDlg::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- if(IsWindow(m_list))
- m_list.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
+ if(IsWindow(m_list))
+ m_list.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
}
diff --git a/src/apps/mplayerc/FavoriteOrganizeDlg.h b/src/apps/mplayerc/FavoriteOrganizeDlg.h
index ea28a9511..c784913db 100644
--- a/src/apps/mplayerc/FavoriteOrganizeDlg.h
+++ b/src/apps/mplayerc/FavoriteOrganizeDlg.h
@@ -35,34 +35,34 @@ class CFavoriteOrganizeDlg : public CResizableDialog
// DECLARE_DYNAMIC(CFavoriteOrganizeDlg)
private:
- CAtlList<CString> m_sl[3];
- void SetupList(bool fSave);
+ CAtlList<CString> m_sl[3];
+ void SetupList(bool fSave);
public:
- CFavoriteOrganizeDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CFavoriteOrganizeDlg();
+ CFavoriteOrganizeDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CFavoriteOrganizeDlg();
// Dialog Data
- enum { IDD = IDD_FAVORGANIZE };
+ enum { IDD = IDD_FAVORGANIZE };
- CTabCtrl m_tab;
- CListCtrl m_list;
+ CTabCtrl m_tab;
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnBnClickedButton3();
- afx_msg void OnBnClickedButton7();
- afx_msg void OnTcnSelchangingTab1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBnClickedOk();
- afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
- afx_msg void OnLvnEndlabeleditList2(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnBnClickedButton3();
+ afx_msg void OnBnClickedButton7();
+ afx_msg void OnTcnSelchangingTab1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
+ afx_msg void OnLvnEndlabeleditList2(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
};
diff --git a/src/apps/mplayerc/FileDropTarget.cpp b/src/apps/mplayerc/FileDropTarget.cpp
index b05632f8d..a1e9e8888 100644
--- a/src/apps/mplayerc/FileDropTarget.cpp
+++ b/src/apps/mplayerc/FileDropTarget.cpp
@@ -30,9 +30,9 @@
//IMPLEMENT_DYNAMIC(CFileDropTarget, COleDropTarget)
CFileDropTarget::CFileDropTarget(CDropTarget* pDropTarget)
- : m_pDropTarget(pDropTarget)
+ : m_pDropTarget(pDropTarget)
{
- ASSERT(m_pDropTarget);
+ ASSERT(m_pDropTarget);
}
CFileDropTarget::~CFileDropTarget()
@@ -41,32 +41,32 @@ CFileDropTarget::~CFileDropTarget()
DROPEFFECT CFileDropTarget::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDragEnter(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDragEnter(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
}
DROPEFFECT CFileDropTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDragOver(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDragOver(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
}
BOOL CFileDropTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDrop(pDataObject, dropEffect, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDrop(pDataObject, dropEffect, point) : DROPEFFECT_NONE;
}
DROPEFFECT CFileDropTarget::OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDropEx(pDataObject, dropDefault, dropList, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDropEx(pDataObject, dropDefault, dropList, point) : DROPEFFECT_NONE;
}
void CFileDropTarget::OnDragLeave(CWnd* pWnd)
{
- if(m_pDropTarget) m_pDropTarget->OnDragLeave();
+ if(m_pDropTarget) m_pDropTarget->OnDragLeave();
}
DROPEFFECT CFileDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDragScroll(dwKeyState, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDragScroll(dwKeyState, point) : DROPEFFECT_NONE;
}
BEGIN_MESSAGE_MAP(CFileDropTarget, COleDropTarget)
diff --git a/src/apps/mplayerc/FileDropTarget.h b/src/apps/mplayerc/FileDropTarget.h
index 94a398f84..042604e9b 100644
--- a/src/apps/mplayerc/FileDropTarget.h
+++ b/src/apps/mplayerc/FileDropTarget.h
@@ -29,29 +29,14 @@
class CDropTarget
{
public:
- CDropTarget() {}
+ CDropTarget() {}
- virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
- {
- return DROPEFFECT_NONE;
- }
- virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
- {
- return DROPEFFECT_NONE;
- }
- virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
- {
- return FALSE;
- }
- virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
- {
- return (DROPEFFECT) - 1;
- }
- virtual void OnDragLeave() {}
- virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point)
- {
- return DROPEFFECT_NONE;
- }
+ virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {return DROPEFFECT_NONE;}
+ virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {return DROPEFFECT_NONE;}
+ virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point) {return FALSE;}
+ virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point) {return (DROPEFFECT)-1;}
+ virtual void OnDragLeave() {}
+ virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point) {return DROPEFFECT_NONE;}
};
// CFileDropTarget command target
@@ -61,19 +46,19 @@ class CFileDropTarget : public COleDropTarget
// DECLARE_DYNAMIC(CFileDropTarget)
private:
- CDropTarget* m_pDropTarget;
+ CDropTarget* m_pDropTarget;
public:
- CFileDropTarget(CDropTarget* pDropTarget);
- virtual ~CFileDropTarget();
+ CFileDropTarget(CDropTarget* pDropTarget);
+ virtual ~CFileDropTarget();
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
- DROPEFFECT OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
- void OnDragLeave(CWnd* pWnd);
- DROPEFFECT OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point);
+ DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
+ DROPEFFECT OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
+ void OnDragLeave(CWnd* pWnd);
+ DROPEFFECT OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point);
};
diff --git a/src/apps/mplayerc/FileVersionInfo.cpp b/src/apps/mplayerc/FileVersionInfo.cpp
index 73bafb14d..8a4646187 100644
--- a/src/apps/mplayerc/FileVersionInfo.cpp
+++ b/src/apps/mplayerc/FileVersionInfo.cpp
@@ -2,12 +2,12 @@
*
* Copyright (C) 1999-2000 Sven Wiegand
* Copyright (C) 2000-2001 ToolsCenter
-*
+*
* This file is free software; you can redistribute it and/or
-* modify, but leave the headers intact and do not remove any
+* modify, but leave the headers intact and do not remove any
* copyrights from the source.
*
-* If you have further questions, suggestions or bug fixes, visit
+* If you have further questions, suggestions or bug fixes, visit
* our homepage
*
* http://www.ToolsCenter.org
@@ -23,7 +23,7 @@
CFileVersionInfo::CFileVersionInfo()
{
- Reset();
+ Reset();
}
@@ -33,297 +33,297 @@ CFileVersionInfo::~CFileVersionInfo()
BOOL CFileVersionInfo::GetTranslationId(LPVOID lpData, UINT unBlockSize, WORD wLangId, DWORD &dwId, BOOL bPrimaryEnough/*= FALSE*/)
{
- LPWORD lpwData;
- for(lpwData = (LPWORD)lpData; (LPBYTE)lpwData < ((LPBYTE)lpData) + unBlockSize; lpwData += 2)
- {
- if(*lpwData == wLangId)
- {
- dwId = *((DWORD*)lpwData);
- return TRUE;
- }
- }
-
- if(!bPrimaryEnough)
- return FALSE;
-
- for(lpwData = (LPWORD)lpData; (LPBYTE)lpwData < ((LPBYTE)lpData) + unBlockSize; lpwData += 2)
- {
- if(((*lpwData) & 0x00FF) == (wLangId & 0x00FF))
- {
- dwId = *((DWORD*)lpwData);
- return TRUE;
- }
- }
-
- return FALSE;
+ LPWORD lpwData;
+ for (lpwData = (LPWORD)lpData; (LPBYTE)lpwData < ((LPBYTE)lpData)+unBlockSize; lpwData+=2)
+ {
+ if (*lpwData == wLangId)
+ {
+ dwId = *((DWORD*)lpwData);
+ return TRUE;
+ }
+ }
+
+ if (!bPrimaryEnough)
+ return FALSE;
+
+ for (lpwData = (LPWORD)lpData; (LPBYTE)lpwData < ((LPBYTE)lpData)+unBlockSize; lpwData+=2)
+ {
+ if (((*lpwData)&0x00FF) == (wLangId&0x00FF))
+ {
+ dwId = *((DWORD*)lpwData);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
BOOL CFileVersionInfo::Create(HMODULE hModule /*= NULL*/)
{
- CString strPath;
+ CString strPath;
- GetModuleFileName(hModule, strPath.GetBuffer(_MAX_PATH), _MAX_PATH);
- strPath.ReleaseBuffer();
- return Create(strPath);
+ GetModuleFileName(hModule, strPath.GetBuffer(_MAX_PATH), _MAX_PATH);
+ strPath.ReleaseBuffer();
+ return Create(strPath);
}
BOOL CFileVersionInfo::Create(LPCTSTR lpszFileName)
{
- Reset();
-
- DWORD dwHandle;
- DWORD dwFileVersionInfoSize = GetFileVersionInfoSize((LPTSTR)lpszFileName, &dwHandle);
- if(!dwFileVersionInfoSize)
- return FALSE;
-
- LPVOID lpData = (LPVOID)DNew BYTE[dwFileVersionInfoSize];
- if(!lpData)
- return FALSE;
-
- try
- {
- if(!GetFileVersionInfo((LPTSTR)lpszFileName, dwHandle, dwFileVersionInfoSize, lpData))
- throw FALSE;
-
- // catch default information
- LPVOID lpInfo;
- UINT unInfoLen;
- if(VerQueryValue(lpData, _T("\\"), &lpInfo, &unInfoLen))
- {
- ASSERT(unInfoLen == sizeof(m_FileInfo));
- if(unInfoLen == sizeof(m_FileInfo))
- memcpy(&m_FileInfo, lpInfo, unInfoLen);
- }
-
- // find best matching language and codepage
- VerQueryValue(lpData, _T("\\VarFileInfo\\Translation"), &lpInfo, &unInfoLen);
-
- DWORD dwLangCode = 0;
- if(!GetTranslationId(lpInfo, unInfoLen, GetUserDefaultLangID(), dwLangCode, FALSE))
- {
- if(!GetTranslationId(lpInfo, unInfoLen, GetUserDefaultLangID(), dwLangCode, TRUE))
- {
- if(!GetTranslationId(lpInfo, unInfoLen, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), dwLangCode, TRUE))
- {
- if(!GetTranslationId(lpInfo, unInfoLen, MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), dwLangCode, TRUE))
- // use the first one we can get
- dwLangCode = *((DWORD*)lpInfo);
- }
- }
- }
-
-
- CString strSubBlock;
- strSubBlock.Format(_T("\\StringFileInfo\\%04X%04X\\"), dwLangCode & 0x0000FFFF, (dwLangCode & 0xFFFF0000) >> 16);
-
- // catch string table
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("CompanyName")), &lpInfo, &unInfoLen))
- m_strCompanyName = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("FileDescription")), &lpInfo, &unInfoLen))
- m_strFileDescription = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("FileVersion")), &lpInfo, &unInfoLen))
- m_strFileVersion = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("InternalName")), &lpInfo, &unInfoLen))
- m_strInternalName = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("LegalCopyright")), &lpInfo, &unInfoLen))
- m_strLegalCopyright = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("OriginalFileName")), &lpInfo, &unInfoLen))
- m_strOriginalFileName = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("ProductName")), &lpInfo, &unInfoLen))
- m_strProductName = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("ProductVersion")), &lpInfo, &unInfoLen))
- m_strProductVersion = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("Comments")), &lpInfo, &unInfoLen))
- m_strComments = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("LegalTrademarks")), &lpInfo, &unInfoLen))
- m_strLegalTrademarks = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("PrivateBuild")), &lpInfo, &unInfoLen))
- m_strPrivateBuild = CString((LPCTSTR)lpInfo);
- if(VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock + _T("SpecialBuild")), &lpInfo, &unInfoLen))
- m_strSpecialBuild = CString((LPCTSTR)lpInfo);
-
- delete[] lpData;
- }
- catch(BOOL)
- {
- delete[] lpData;
- return FALSE;
- }
-
- return TRUE;
+ Reset();
+
+ DWORD dwHandle;
+ DWORD dwFileVersionInfoSize = GetFileVersionInfoSize((LPTSTR)lpszFileName, &dwHandle);
+ if (!dwFileVersionInfoSize)
+ return FALSE;
+
+ LPVOID lpData = (LPVOID)DNew BYTE[dwFileVersionInfoSize];
+ if (!lpData)
+ return FALSE;
+
+ try
+ {
+ if (!GetFileVersionInfo((LPTSTR)lpszFileName, dwHandle, dwFileVersionInfoSize, lpData))
+ throw FALSE;
+
+ // catch default information
+ LPVOID lpInfo;
+ UINT unInfoLen;
+ if (VerQueryValue(lpData, _T("\\"), &lpInfo, &unInfoLen))
+ {
+ ASSERT(unInfoLen == sizeof(m_FileInfo));
+ if (unInfoLen == sizeof(m_FileInfo))
+ memcpy(&m_FileInfo, lpInfo, unInfoLen);
+ }
+
+ // find best matching language and codepage
+ VerQueryValue(lpData, _T("\\VarFileInfo\\Translation"), &lpInfo, &unInfoLen);
+
+ DWORD dwLangCode = 0;
+ if (!GetTranslationId(lpInfo, unInfoLen, GetUserDefaultLangID(), dwLangCode, FALSE))
+ {
+ if (!GetTranslationId(lpInfo, unInfoLen, GetUserDefaultLangID(), dwLangCode, TRUE))
+ {
+ if (!GetTranslationId(lpInfo, unInfoLen, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), dwLangCode, TRUE))
+ {
+ if (!GetTranslationId(lpInfo, unInfoLen, MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), dwLangCode, TRUE))
+ // use the first one we can get
+ dwLangCode = *((DWORD*)lpInfo);
+ }
+ }
+ }
+
+
+ CString strSubBlock;
+ strSubBlock.Format(_T("\\StringFileInfo\\%04X%04X\\"), dwLangCode&0x0000FFFF, (dwLangCode&0xFFFF0000)>>16);
+
+ // catch string table
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("CompanyName")), &lpInfo, &unInfoLen))
+ m_strCompanyName = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("FileDescription")), &lpInfo, &unInfoLen))
+ m_strFileDescription = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("FileVersion")), &lpInfo, &unInfoLen))
+ m_strFileVersion = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("InternalName")), &lpInfo, &unInfoLen))
+ m_strInternalName = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("LegalCopyright")), &lpInfo, &unInfoLen))
+ m_strLegalCopyright = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("OriginalFileName")), &lpInfo, &unInfoLen))
+ m_strOriginalFileName = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("ProductName")), &lpInfo, &unInfoLen))
+ m_strProductName = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("ProductVersion")), &lpInfo, &unInfoLen))
+ m_strProductVersion = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("Comments")), &lpInfo, &unInfoLen))
+ m_strComments = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("LegalTrademarks")), &lpInfo, &unInfoLen))
+ m_strLegalTrademarks = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("PrivateBuild")), &lpInfo, &unInfoLen))
+ m_strPrivateBuild = CString((LPCTSTR)lpInfo);
+ if (VerQueryValue(lpData, (LPTSTR)(LPCTSTR)(strSubBlock+_T("SpecialBuild")), &lpInfo, &unInfoLen))
+ m_strSpecialBuild = CString((LPCTSTR)lpInfo);
+
+ delete[] lpData;
+ }
+ catch (BOOL)
+ {
+ delete[] lpData;
+ return FALSE;
+ }
+
+ return TRUE;
}
WORD CFileVersionInfo::GetFileVersion(int nIndex) const
{
- if(nIndex == 0)
- return (WORD)(m_FileInfo.dwFileVersionLS & 0x0000FFFF);
- else if(nIndex == 1)
- return (WORD)((m_FileInfo.dwFileVersionLS & 0xFFFF0000) >> 16);
- else if(nIndex == 2)
- return (WORD)(m_FileInfo.dwFileVersionMS & 0x0000FFFF);
- else if(nIndex == 3)
- return (WORD)((m_FileInfo.dwFileVersionMS & 0xFFFF0000) >> 16);
- else
- return 0;
+ if (nIndex == 0)
+ return (WORD)(m_FileInfo.dwFileVersionLS & 0x0000FFFF);
+ else if (nIndex == 1)
+ return (WORD)((m_FileInfo.dwFileVersionLS & 0xFFFF0000) >> 16);
+ else if (nIndex == 2)
+ return (WORD)(m_FileInfo.dwFileVersionMS & 0x0000FFFF);
+ else if (nIndex == 3)
+ return (WORD)((m_FileInfo.dwFileVersionMS & 0xFFFF0000) >> 16);
+ else
+ return 0;
}
CString CFileVersionInfo::GetFileVersionEx() const
{
- CString strTemp;
-
- strTemp.Format(L"%d.%d.%d.%d",
- (m_FileInfo.dwFileVersionMS & 0xFFFF0000) >> 16,
- (m_FileInfo.dwFileVersionMS & 0x0000FFFF),
- (m_FileInfo.dwFileVersionLS & 0xFFFF0000) >> 16,
- m_FileInfo.dwFileVersionLS & 0x0000FFFF);
- return strTemp;
+ CString strTemp;
+
+ strTemp.Format (L"%d.%d.%d.%d",
+ (m_FileInfo.dwFileVersionMS & 0xFFFF0000) >> 16,
+ (m_FileInfo.dwFileVersionMS & 0x0000FFFF),
+ (m_FileInfo.dwFileVersionLS & 0xFFFF0000) >> 16,
+ m_FileInfo.dwFileVersionLS & 0x0000FFFF);
+ return strTemp;
}
WORD CFileVersionInfo::GetProductVersion(int nIndex) const
{
- if(nIndex == 0)
- return (WORD)(m_FileInfo.dwProductVersionLS & 0x0000FFFF);
- else if(nIndex == 1)
- return (WORD)((m_FileInfo.dwProductVersionLS & 0xFFFF0000) >> 16);
- else if(nIndex == 2)
- return (WORD)(m_FileInfo.dwProductVersionMS & 0x0000FFFF);
- else if(nIndex == 3)
- return (WORD)((m_FileInfo.dwProductVersionMS & 0xFFFF0000) >> 16);
- else
- return 0;
+ if (nIndex == 0)
+ return (WORD)(m_FileInfo.dwProductVersionLS & 0x0000FFFF);
+ else if (nIndex == 1)
+ return (WORD)((m_FileInfo.dwProductVersionLS & 0xFFFF0000) >> 16);
+ else if (nIndex == 2)
+ return (WORD)(m_FileInfo.dwProductVersionMS & 0x0000FFFF);
+ else if (nIndex == 3)
+ return (WORD)((m_FileInfo.dwProductVersionMS & 0xFFFF0000) >> 16);
+ else
+ return 0;
}
DWORD CFileVersionInfo::GetFileFlagsMask() const
{
- return m_FileInfo.dwFileFlagsMask;
+ return m_FileInfo.dwFileFlagsMask;
}
DWORD CFileVersionInfo::GetFileFlags() const
{
- return m_FileInfo.dwFileFlags;
+ return m_FileInfo.dwFileFlags;
}
DWORD CFileVersionInfo::GetFileOs() const
{
- return m_FileInfo.dwFileOS;
+ return m_FileInfo.dwFileOS;
}
DWORD CFileVersionInfo::GetFileType() const
{
- return m_FileInfo.dwFileType;
+ return m_FileInfo.dwFileType;
}
DWORD CFileVersionInfo::GetFileSubtype() const
{
- return m_FileInfo.dwFileSubtype;
+ return m_FileInfo.dwFileSubtype;
}
CTime CFileVersionInfo::GetFileDate() const
{
- FILETIME ft;
- ft.dwLowDateTime = m_FileInfo.dwFileDateLS;
- ft.dwHighDateTime = m_FileInfo.dwFileDateMS;
- return CTime(ft);
+ FILETIME ft;
+ ft.dwLowDateTime = m_FileInfo.dwFileDateLS;
+ ft.dwHighDateTime = m_FileInfo.dwFileDateMS;
+ return CTime(ft);
}
CString CFileVersionInfo::GetCompanyName() const
{
- return m_strCompanyName;
+ return m_strCompanyName;
}
CString CFileVersionInfo::GetFileDescription() const
{
- return m_strFileDescription;
+ return m_strFileDescription;
}
CString CFileVersionInfo::GetFileVersion() const
{
- return m_strFileVersion;
+ return m_strFileVersion;
}
CString CFileVersionInfo::GetInternalName() const
{
- return m_strInternalName;
+ return m_strInternalName;
}
CString CFileVersionInfo::GetLegalCopyright() const
{
- return m_strLegalCopyright;
+ return m_strLegalCopyright;
}
CString CFileVersionInfo::GetOriginalFileName() const
{
- return m_strOriginalFileName;
+ return m_strOriginalFileName;
}
CString CFileVersionInfo::GetProductName() const
{
- return m_strProductName;
+ return m_strProductName;
}
CString CFileVersionInfo::GetProductVersion() const
{
- return m_strProductVersion;
+ return m_strProductVersion;
}
CString CFileVersionInfo::GetComments() const
{
- return m_strComments;
+ return m_strComments;
}
CString CFileVersionInfo::GetLegalTrademarks() const
{
- return m_strLegalTrademarks;
+ return m_strLegalTrademarks;
}
CString CFileVersionInfo::GetPrivateBuild() const
{
- return m_strPrivateBuild;
+ return m_strPrivateBuild;
}
CString CFileVersionInfo::GetSpecialBuild() const
{
- return m_strSpecialBuild;
+ return m_strSpecialBuild;
}
void CFileVersionInfo::Reset()
{
- ZeroMemory(&m_FileInfo, sizeof(m_FileInfo));
- m_strCompanyName.Empty();
- m_strFileDescription.Empty();
- m_strFileVersion.Empty();
- m_strInternalName.Empty();
- m_strLegalCopyright.Empty();
- m_strOriginalFileName.Empty();
- m_strProductName.Empty();
- m_strProductVersion.Empty();
- m_strComments.Empty();
- m_strLegalTrademarks.Empty();
- m_strPrivateBuild.Empty();
- m_strSpecialBuild.Empty();
+ ZeroMemory(&m_FileInfo, sizeof(m_FileInfo));
+ m_strCompanyName.Empty();
+ m_strFileDescription.Empty();
+ m_strFileVersion.Empty();
+ m_strInternalName.Empty();
+ m_strLegalCopyright.Empty();
+ m_strOriginalFileName.Empty();
+ m_strProductName.Empty();
+ m_strProductVersion.Empty();
+ m_strComments.Empty();
+ m_strLegalTrademarks.Empty();
+ m_strPrivateBuild.Empty();
+ m_strSpecialBuild.Empty();
}
diff --git a/src/apps/mplayerc/FileVersionInfo.h b/src/apps/mplayerc/FileVersionInfo.h
index d806dd0b1..4ccce316d 100644
--- a/src/apps/mplayerc/FileVersionInfo.h
+++ b/src/apps/mplayerc/FileVersionInfo.h
@@ -2,12 +2,12 @@
*
* Copyright (C) 1999-2000 Sven Wiegand
* Copyright (C) 2000-2001 ToolsCenter
-*
+*
* This file is free software; you can redistribute it and/or
-* modify, but leave the headers intact and do not remove any
+* modify, but leave the headers intact and do not remove any
* copyrights from the source.
*
-* If you have further questions, suggestions or bug fixes, visit
+* If you have further questions, suggestions or bug fixes, visit
* our homepage
*
* http://www.ToolsCenter.org
@@ -27,60 +27,60 @@ class AFX_EXT_CLASS CFileVersionInfo
{
// construction/destruction
public:
- CFileVersionInfo();
- virtual ~CFileVersionInfo();
+ CFileVersionInfo();
+ virtual ~CFileVersionInfo();
// operations
public:
- BOOL Create(HMODULE hModule = NULL);
- BOOL Create(LPCTSTR lpszFileName);
+ BOOL Create(HMODULE hModule = NULL);
+ BOOL Create(LPCTSTR lpszFileName);
// attribute operations
public:
- WORD GetFileVersion(int nIndex) const;
- CString GetFileVersionEx() const;
- WORD GetProductVersion(int nIndex) const;
- DWORD GetFileFlagsMask() const;
- DWORD GetFileFlags() const;
- DWORD GetFileOs() const;
- DWORD GetFileType() const;
- DWORD GetFileSubtype() const;
- CTime GetFileDate() const;
+ WORD GetFileVersion(int nIndex) const;
+ CString GetFileVersionEx() const;
+ WORD GetProductVersion(int nIndex) const;
+ DWORD GetFileFlagsMask() const;
+ DWORD GetFileFlags() const;
+ DWORD GetFileOs() const;
+ DWORD GetFileType() const;
+ DWORD GetFileSubtype() const;
+ CTime GetFileDate() const;
- CString GetCompanyName() const;
- CString GetFileDescription() const;
- CString GetFileVersion() const;
- CString GetInternalName() const;
- CString GetLegalCopyright() const;
- CString GetOriginalFileName() const;
- CString GetProductName() const;
- CString GetProductVersion() const;
- CString GetComments() const;
- CString GetLegalTrademarks() const;
- CString GetPrivateBuild() const;
- CString GetSpecialBuild() const;
+ CString GetCompanyName() const;
+ CString GetFileDescription() const;
+ CString GetFileVersion() const;
+ CString GetInternalName() const;
+ CString GetLegalCopyright() const;
+ CString GetOriginalFileName() const;
+ CString GetProductName() const;
+ CString GetProductVersion() const;
+ CString GetComments() const;
+ CString GetLegalTrademarks() const;
+ CString GetPrivateBuild() const;
+ CString GetSpecialBuild() const;
// implementation helpers
protected:
- virtual void Reset();
- BOOL GetTranslationId(LPVOID lpData, UINT unBlockSize, WORD wLangId, DWORD &dwId, BOOL bPrimaryEnough = FALSE);
+ virtual void Reset();
+ BOOL GetTranslationId(LPVOID lpData, UINT unBlockSize, WORD wLangId, DWORD &dwId, BOOL bPrimaryEnough = FALSE);
// attributes
private:
- VS_FIXEDFILEINFO m_FileInfo;
+ VS_FIXEDFILEINFO m_FileInfo;
- CString m_strCompanyName;
- CString m_strFileDescription;
- CString m_strFileVersion;
- CString m_strInternalName;
- CString m_strLegalCopyright;
- CString m_strOriginalFileName;
- CString m_strProductName;
- CString m_strProductVersion;
- CString m_strComments;
- CString m_strLegalTrademarks;
- CString m_strPrivateBuild;
- CString m_strSpecialBuild;
+ CString m_strCompanyName;
+ CString m_strFileDescription;
+ CString m_strFileVersion;
+ CString m_strInternalName;
+ CString m_strLegalCopyright;
+ CString m_strOriginalFileName;
+ CString m_strProductName;
+ CString m_strProductVersion;
+ CString m_strComments;
+ CString m_strLegalTrademarks;
+ CString m_strPrivateBuild;
+ CString m_strSpecialBuild;
};
#endif // !defined(AFX_FILEVERSION_H__F828004C_7680_40FE_A08D_7BB4FF05B4CC__INCLUDED_)
diff --git a/src/apps/mplayerc/FloatEdit.cpp b/src/apps/mplayerc/FloatEdit.cpp
index c8a84bd26..d13e45bb9 100644
--- a/src/apps/mplayerc/FloatEdit.cpp
+++ b/src/apps/mplayerc/FloatEdit.cpp
@@ -31,49 +31,49 @@ IMPLEMENT_DYNAMIC(CFloatEdit, CEdit)
bool CFloatEdit::GetFloat(float& f)
{
- CString s;
- GetWindowText(s);
- return(_stscanf(s, _T("%f"), &f) == 1);
+ CString s;
+ GetWindowText(s);
+ return(_stscanf(s, _T("%f"), &f) == 1);
}
double CFloatEdit::operator = (double d)
{
- CString s;
- s.Format(_T("%.4f"), d);
- SetWindowText(s);
- return(d);
+ CString s;
+ s.Format(_T("%.4f"), d);
+ SetWindowText(s);
+ return(d);
}
CFloatEdit::operator double()
{
- CString s;
- GetWindowText(s);
- float f;
- return(_stscanf(s, _T("%f"), &f) == 1 ? f : 0);
+ CString s;
+ GetWindowText(s);
+ float f;
+ return(_stscanf(s, _T("%f"), &f) == 1 ? f : 0);
}
BEGIN_MESSAGE_MAP(CFloatEdit, CEdit)
- ON_WM_CHAR()
+ ON_WM_CHAR()
END_MESSAGE_MAP()
void CFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b'))
- return;
+ if(!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b'))
+ return;
- CString str;
- GetWindowText(str);
+ CString str;
+ GetWindowText(str);
- if(nChar == '.' && (str.Find('.') >= 0 || str.IsEmpty()))
- return;
+ if(nChar == '.' && (str.Find('.') >= 0 || str.IsEmpty()))
+ return;
- int nStartChar, nEndChar;
- GetSel(nStartChar, nEndChar);
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
- if(nChar == '\b' && nStartChar <= 0)
- return;
+ if(nChar == '\b' && nStartChar <= 0)
+ return;
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
// CIntEdit
@@ -81,30 +81,30 @@ void CFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
IMPLEMENT_DYNAMIC(CIntEdit, CEdit)
BEGIN_MESSAGE_MAP(CIntEdit, CEdit)
- ON_WM_CHAR()
+ ON_WM_CHAR()
END_MESSAGE_MAP()
void CIntEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(!(nChar >= '0' && nChar <= '9' || nChar == '-' || nChar == '\b'))
- return;
+ if(!(nChar >= '0' && nChar <= '9' || nChar == '-' || nChar == '\b'))
+ return;
- CString str;
- GetWindowText(str);
+ CString str;
+ GetWindowText(str);
- if(nChar == '-' && !str.IsEmpty() && str[0] == '-')
- return;
+ if(nChar == '-' && !str.IsEmpty() && str[0] == '-')
+ return;
- int nStartChar, nEndChar;
- GetSel(nStartChar, nEndChar);
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
- if(nChar == '\b' && nStartChar <= 0)
- return;
+ if(nChar == '\b' && nStartChar <= 0)
+ return;
- if(nChar == '-' && (nStartChar != 0 || nEndChar != 0))
- return;
+ if(nChar == '-' && (nStartChar != 0 || nEndChar != 0))
+ return;
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
// CHexEdit
@@ -113,48 +113,48 @@ IMPLEMENT_DYNAMIC(CHexEdit, CEdit)
bool CHexEdit::GetDWORD(DWORD& dw)
{
- CString s;
- GetWindowText(s);
- return(_stscanf(s, _T("%x"), &dw) == 1);
+ CString s;
+ GetWindowText(s);
+ return(_stscanf(s, _T("%x"), &dw) == 1);
}
DWORD CHexEdit::operator = (DWORD dw)
{
- CString s;
- s.Format(_T("%08x"), dw);
- SetWindowText(s);
- return(dw);
+ CString s;
+ s.Format(_T("%08x"), dw);
+ SetWindowText(s);
+ return(dw);
}
CHexEdit::operator DWORD()
{
- CString s;
- GetWindowText(s);
- DWORD dw;
- return(_stscanf(s, _T("%x"), &dw) == 1 ? dw : 0);
+ CString s;
+ GetWindowText(s);
+ DWORD dw;
+ return(_stscanf(s, _T("%x"), &dw) == 1 ? dw : 0);
}
BEGIN_MESSAGE_MAP(CHexEdit, CEdit)
- ON_WM_CHAR()
+ ON_WM_CHAR()
END_MESSAGE_MAP()
void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(!(nChar >= 'A' && nChar <= 'F' || nChar >= 'a' && nChar <= 'f'
- || nChar >= '0' && nChar <= '9' || nChar == '\b'))
- return;
+ if(!(nChar >= 'A' && nChar <= 'F' || nChar >= 'a' && nChar <= 'f'
+ || nChar >= '0' && nChar <= '9' || nChar == '\b'))
+ return;
- CString str;
- GetWindowText(str);
+ CString str;
+ GetWindowText(str);
- int nStartChar, nEndChar;
- GetSel(nStartChar, nEndChar);
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
- if(nChar == '\b' && nStartChar <= 0)
- return;
+ if(nChar == '\b' && nStartChar <= 0)
+ return;
- if(nChar != '\b' && nEndChar - nStartChar == 0 && str.GetLength() >= 8)
- return;
+ if(nChar != '\b' && nEndChar - nStartChar == 0 && str.GetLength() >= 8)
+ return;
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
diff --git a/src/apps/mplayerc/FloatEdit.h b/src/apps/mplayerc/FloatEdit.h
index 640c8cba8..127383f9c 100644
--- a/src/apps/mplayerc/FloatEdit.h
+++ b/src/apps/mplayerc/FloatEdit.h
@@ -28,15 +28,15 @@
class CFloatEdit : public CEdit
{
public:
- bool GetFloat(float& f);
- double operator = (double d);
- operator double();
+ bool GetFloat(float& f);
+ double operator = (double d);
+ operator double();
- DECLARE_DYNAMIC(CFloatEdit)
- DECLARE_MESSAGE_MAP()
+ DECLARE_DYNAMIC(CFloatEdit)
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
// CIntEdit
@@ -44,11 +44,11 @@ public:
class CIntEdit : public CEdit
{
public:
- DECLARE_DYNAMIC(CIntEdit)
- DECLARE_MESSAGE_MAP()
+ DECLARE_DYNAMIC(CIntEdit)
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
// CHexEdit
@@ -56,13 +56,13 @@ public:
class CHexEdit : public CEdit
{
public:
- bool GetDWORD(DWORD& dw);
- DWORD operator = (DWORD dw);
- operator DWORD();
+ bool GetDWORD(DWORD& dw);
+ DWORD operator = (DWORD dw);
+ operator DWORD();
- DECLARE_DYNAMIC(CHexEdit)
- DECLARE_MESSAGE_MAP()
+ DECLARE_DYNAMIC(CHexEdit)
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
diff --git a/src/apps/mplayerc/FullscreenWnd.cpp b/src/apps/mplayerc/FullscreenWnd.cpp
index 6316ca4ae..8e49e573e 100644
--- a/src/apps/mplayerc/FullscreenWnd.cpp
+++ b/src/apps/mplayerc/FullscreenWnd.cpp
@@ -32,9 +32,9 @@
IMPLEMENT_DYNAMIC(CFullscreenWnd, CWnd)
CFullscreenWnd::CFullscreenWnd(CMainFrame* pMainFrame)
{
- m_pMainFrame = pMainFrame;
- m_hCursor = ::LoadCursor(NULL, IDC_HAND);
- m_bCursorVisible = false;
+ m_pMainFrame = pMainFrame;
+ m_hCursor = ::LoadCursor(NULL, IDC_HAND);
+ m_bCursorVisible = false;
}
CFullscreenWnd::~CFullscreenWnd()
@@ -43,65 +43,65 @@ CFullscreenWnd::~CFullscreenWnd()
BEGIN_MESSAGE_MAP(CFullscreenWnd, CWnd)
- ON_WM_ERASEBKGND()
- ON_WM_SETCURSOR()
+ ON_WM_ERASEBKGND()
+ ON_WM_SETCURSOR()
END_MESSAGE_MAP()
LRESULT CFullscreenWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
- {
- case WM_COMMAND :
- m_pMainFrame->PostMessage(message, wParam, lParam);
- break;
- }
- return CWnd::WindowProc(message, wParam, lParam);
+ switch (message)
+ {
+ case WM_COMMAND :
+ m_pMainFrame->PostMessage(message, wParam, lParam);
+ break;
+ }
+ return CWnd::WindowProc(message, wParam, lParam);
}
BOOL CFullscreenWnd::PreTranslateMessage(MSG* pMsg)
{
- switch(pMsg->message)
- {
- case WM_MOUSEMOVE :
- case WM_SYSKEYDOWN :
- case WM_SYSKEYUP :
- case WM_SYSCHAR :
- case WM_SYSCOMMAND :
-
- case WM_KEYDOWN :
- case WM_KEYUP :
- case WM_CHAR :
-
- case WM_LBUTTONDOWN :
- case WM_LBUTTONUP :
- case WM_LBUTTONDBLCLK :
- case WM_MBUTTONDOWN :
- case WM_MBUTTONUP :
- case WM_MBUTTONDBLCLK :
- case WM_RBUTTONDOWN :
- case WM_RBUTTONUP :
- case WM_RBUTTONDBLCLK :
-
- case WM_MOUSEWHEEL :
-
- m_pMainFrame->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
- break;
- }
-
- return CWnd::PreTranslateMessage(pMsg);
+ switch (pMsg->message)
+ {
+ case WM_MOUSEMOVE :
+ case WM_SYSKEYDOWN :
+ case WM_SYSKEYUP :
+ case WM_SYSCHAR :
+ case WM_SYSCOMMAND :
+
+ case WM_KEYDOWN :
+ case WM_KEYUP :
+ case WM_CHAR :
+
+ case WM_LBUTTONDOWN :
+ case WM_LBUTTONUP :
+ case WM_LBUTTONDBLCLK :
+ case WM_MBUTTONDOWN :
+ case WM_MBUTTONUP :
+ case WM_MBUTTONDBLCLK :
+ case WM_RBUTTONDOWN :
+ case WM_RBUTTONUP :
+ case WM_RBUTTONDBLCLK :
+
+ case WM_MOUSEWHEEL :
+
+ m_pMainFrame->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
+ break;
+ }
+
+ return CWnd::PreTranslateMessage(pMsg);
}
-BOOL CFullscreenWnd::PreCreateWindow(CREATESTRUCT& cs)
+BOOL CFullscreenWnd::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CWnd::PreCreateWindow(cs))
- return FALSE;
+ if(!CWnd::PreCreateWindow(cs))
+ return FALSE;
- cs.style &= ~WS_BORDER;
- cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, m_hCursor, HBRUSH(COLOR_WINDOW + 1), NULL);
+ cs.style &= ~WS_BORDER;
+ cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, m_hCursor, HBRUSH(COLOR_WINDOW+1), NULL);
- return TRUE;
+ return TRUE;
}
// CFullscreenWnd message handlers
@@ -109,29 +109,29 @@ BOOL CFullscreenWnd::PreCreateWindow(CREATESTRUCT& cs)
BOOL CFullscreenWnd::OnEraseBkgnd(CDC* pDC)
{
- return false;
+ return false;
}
BOOL CFullscreenWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- if(m_bCursorVisible)
- ::SetCursor(m_hCursor);
- else
- ::SetCursor(NULL);
- return FALSE;
+ if (m_bCursorVisible)
+ ::SetCursor(m_hCursor);
+ else
+ ::SetCursor(NULL);
+ return FALSE;
}
void CFullscreenWnd::ShowCursor(bool bVisible)
{
- if(m_bCursorVisible != bVisible)
- {
- m_bCursorVisible = bVisible;
- PostMessage(WM_SETCURSOR, 0, 0);
- }
+ if (m_bCursorVisible != bVisible)
+ {
+ m_bCursorVisible = bVisible;
+ PostMessage (WM_SETCURSOR,0,0);
+ }
}
bool CFullscreenWnd::IsWindow()
{
- return (m_hWnd != NULL);
+ return (m_hWnd != NULL);
}
diff --git a/src/apps/mplayerc/FullscreenWnd.h b/src/apps/mplayerc/FullscreenWnd.h
index 8bf749e9b..c7d2cc5ba 100644
--- a/src/apps/mplayerc/FullscreenWnd.h
+++ b/src/apps/mplayerc/FullscreenWnd.h
@@ -27,27 +27,27 @@ class CMainFrame;
class CFullscreenWnd : public CWnd
{
- DECLARE_DYNAMIC(CFullscreenWnd)
+ DECLARE_DYNAMIC(CFullscreenWnd)
public:
- CFullscreenWnd(CMainFrame* pMainFrame);
- virtual ~CFullscreenWnd();
+ CFullscreenWnd(CMainFrame* pMainFrame);
+ virtual ~CFullscreenWnd();
- void ShowCursor(bool bVisible);
- bool IsWindow();
+ void ShowCursor(bool bVisible);
+ bool IsWindow();
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
+
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
-
- CMainFrame* m_pMainFrame;
- HCURSOR m_hCursor;
- bool m_bCursorVisible;
+ CMainFrame* m_pMainFrame;
+ HCURSOR m_hCursor;
+ bool m_bCursorVisible;
public:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
};
diff --git a/src/apps/mplayerc/GoToDlg.cpp b/src/apps/mplayerc/GoToDlg.cpp
index 73ebe49d5..d9e29c981 100644
--- a/src/apps/mplayerc/GoToDlg.cpp
+++ b/src/apps/mplayerc/GoToDlg.cpp
@@ -32,17 +32,17 @@
IMPLEMENT_DYNAMIC(CGoToDlg, CDialog)
CGoToDlg::CGoToDlg(int time, float fps, CWnd* pParent /*=NULL*/)
- : CDialog(CGoToDlg::IDD, pParent)
- , m_timestr(_T(""))
- , m_framestr(_T(""))
- , m_time(time)
- , m_fps(fps)
+ : CDialog(CGoToDlg::IDD, pParent)
+ , m_timestr(_T(""))
+ , m_framestr(_T(""))
+ , m_time(time)
+ , m_fps(fps)
{
- if(m_fps == 0)
- {
- CString str = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, _T("fps"), _T("0"));
- if(_stscanf_s(str, _T("%f"), &m_fps) != 1) m_fps = 0;
- }
+ if(m_fps == 0)
+ {
+ CString str = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, _T("fps"), _T("0"));
+ if(_stscanf_s(str, _T("%f"), &m_fps) != 1) m_fps = 0;
+ }
}
CGoToDlg::~CGoToDlg()
@@ -51,54 +51,48 @@ CGoToDlg::~CGoToDlg()
void CGoToDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT1, m_timestr);
- DDX_Text(pDX, IDC_EDIT2, m_framestr);
- DDX_Control(pDX, IDC_EDIT1, m_timeedit);
- DDX_Control(pDX, IDC_EDIT2, m_frameedit);
+ CDialog::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT1, m_timestr);
+ DDX_Text(pDX, IDC_EDIT2, m_framestr);
+ DDX_Control(pDX, IDC_EDIT1, m_timeedit);
+ DDX_Control(pDX, IDC_EDIT2, m_frameedit);
}
BOOL CGoToDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
+ CDialog::OnInitDialog();
- if(m_time >= 0)
- {
- m_timestr.Format(_T("%02d:%02d:%02d.%03d"),
- (m_time / (1000 * 60 * 60)) % 60, (m_time / (1000 * 60)) % 60, (m_time / 1000) % 60, m_time % 1000);
+ if(m_time >= 0)
+ {
+ m_timestr.Format(_T("%02d:%02d:%02d.%03d"),
+ (m_time/(1000*60*60))%60, (m_time/(1000*60))%60, (m_time/1000)%60, m_time%1000);
- if(m_fps > 0)
- {
- m_framestr.Format(_T("%d, %.3f"), (int)(m_fps * m_time / 1000), m_fps);
- }
+ if(m_fps > 0)
+ {
+ m_framestr.Format(_T("%d, %.3f"), (int)(m_fps*m_time/1000), m_fps);
+ }
- UpdateData(FALSE);
+ UpdateData(FALSE);
- switch(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 0))
- {
- default:
- case 0:
- m_timeedit.SetFocus();
- m_timeedit.SetSel(0, 0);
- break;
- case 1:
- m_frameedit.SetFocus();
- m_frameedit.SetSel(0, m_framestr.Find(','));
- break;
- }
+ switch(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 0))
+ {
+ default:
+ case 0: m_timeedit.SetFocus(); m_timeedit.SetSel(0, 0); break;
+ case 1: m_frameedit.SetFocus(); m_frameedit.SetSel(0, m_framestr.Find(',')); break;
+ }
- }
+ }
- return FALSE;
+ return FALSE;
// return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CGoToDlg, CDialog)
- ON_BN_CLICKED(IDC_OK1, OnBnClickedOk1)
- ON_BN_CLICKED(IDC_OK2, OnBnClickedOk2)
+ ON_BN_CLICKED(IDC_OK1, OnBnClickedOk1)
+ ON_BN_CLICKED(IDC_OK2, OnBnClickedOk2)
END_MESSAGE_MAP()
@@ -106,105 +100,105 @@ END_MESSAGE_MAP()
void CGoToDlg::OnBnClickedOk1()
{
- UpdateData();
-
- int hh, mm, ss, ms;
- hh = mm = ss = ms = 0;
-
- CAtlRegExp<> re;
-
- REParseError status = re.Parse(_T("{\\z}"), FALSE);
- if(REPARSE_ERROR_OK == status)
- {
- m_timestr += 'A'; // HACK: Without this the while loop below would keep going on X64 on release builds...
- CAtlREMatchContext<> mc;
- const CAtlREMatchContext<>::RECHAR* s = m_timestr.GetBuffer();
- const CAtlREMatchContext<>::RECHAR* e = NULL;
- while(s && re.Match(s, &mc, &e))
- {
- const CAtlREMatchContext<>::RECHAR* szStart = 0;
- const CAtlREMatchContext<>::RECHAR* szEnd = 0;
- mc.GetMatch(0, &szStart, &szEnd);
-
- if(hh != 0 || hh > 59 || mm > 59 || ss > 59)
- {
- AfxMessageBox(_T("Error parsing entered time!"));
- return;
- }
-
- hh = mm;
- mm = ss;
- ss = ms;
- ms = _tcstol(szStart, (TCHAR**)&szStart, 10);
-
- s = e;
- }
-
- m_time = ((hh * 60 + mm) * 60 + ss) * 1000 + ms;
-
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 0);
-
- OnOK();
- }
+ UpdateData();
+
+ int hh, mm, ss, ms;
+ hh = mm = ss = ms = 0;
+
+ CAtlRegExp<> re;
+
+ REParseError status = re.Parse(_T("{\\z}"), FALSE);
+ if(REPARSE_ERROR_OK == status)
+ {
+ m_timestr += 'A'; // HACK: Without this the while loop below would keep going on X64 on release builds...
+ CAtlREMatchContext<> mc;
+ const CAtlREMatchContext<>::RECHAR* s = m_timestr.GetBuffer();
+ const CAtlREMatchContext<>::RECHAR* e = NULL;
+ while(s && re.Match(s, &mc, &e))
+ {
+ const CAtlREMatchContext<>::RECHAR* szStart = 0;
+ const CAtlREMatchContext<>::RECHAR* szEnd = 0;
+ mc.GetMatch(0, &szStart, &szEnd);
+
+ if(hh != 0 || hh > 59 || mm > 59 || ss > 59)
+ {
+ AfxMessageBox(_T("Error parsing entered time!"));
+ return;
+ }
+
+ hh = mm;
+ mm = ss;
+ ss = ms;
+ ms = _tcstol(szStart, (TCHAR**)&szStart, 10);
+
+ s = e;
+ }
+
+ m_time = ((hh*60+mm)*60+ss)*1000+ms;
+
+ AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 0);
+
+ OnOK();
+ }
}
void CGoToDlg::OnBnClickedOk2()
{
- UpdateData();
-
- int frame = 0;
- float fps = 0;
-
- CAtlRegExp<> re;
-
- REParseError status = re.Parse(_T("{\\z}[^0-9\\.]+{[0-9\\.]+}"), FALSE);
- if(REPARSE_ERROR_OK == status)
- {
- CAtlREMatchContext<> mc;
- const CAtlREMatchContext<>::RECHAR* s = m_framestr.GetBuffer();
- const CAtlREMatchContext<>::RECHAR* e = NULL;
- if(re.Match(s, &mc, &e))
- {
- const CAtlREMatchContext<>::RECHAR* szStart = 0;
- const CAtlREMatchContext<>::RECHAR* szEnd = 0;
-
- mc.GetMatch(0, &szStart, &szEnd);
- frame = _tcstol(szStart, (TCHAR**)&szStart, 10);
-
- mc.GetMatch(1, &szStart, &szEnd);
- if(_stscanf_s(szStart, _T("%f"), &fps) != 1) fps = 0;
- else AfxGetApp()->WriteProfileString(IDS_R_SETTINGS, _T("fps"), szStart);
- }
- else
- {
- AfxMessageBox(_T("Error parsing entered text!"));
- return;
- }
-
- if(fps == 0)
- {
- AfxMessageBox(_T("Error parsing entered frame rate!"));
- return;
- }
-
- m_time = (int)(1000.0 * frame / fps) + 1;
-
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 1);
-
- OnOK();
- }
+ UpdateData();
+
+ int frame = 0;
+ float fps = 0;
+
+ CAtlRegExp<> re;
+
+ REParseError status = re.Parse(_T("{\\z}[^0-9\\.]+{[0-9\\.]+}"), FALSE);
+ if(REPARSE_ERROR_OK == status)
+ {
+ CAtlREMatchContext<> mc;
+ const CAtlREMatchContext<>::RECHAR* s = m_framestr.GetBuffer();
+ const CAtlREMatchContext<>::RECHAR* e = NULL;
+ if(re.Match(s, &mc, &e))
+ {
+ const CAtlREMatchContext<>::RECHAR* szStart = 0;
+ const CAtlREMatchContext<>::RECHAR* szEnd = 0;
+
+ mc.GetMatch(0, &szStart, &szEnd);
+ frame = _tcstol(szStart, (TCHAR**)&szStart, 10);
+
+ mc.GetMatch(1, &szStart, &szEnd);
+ if(_stscanf_s(szStart, _T("%f"), &fps) != 1) fps = 0;
+ else AfxGetApp()->WriteProfileString(IDS_R_SETTINGS, _T("fps"), szStart);
+ }
+ else
+ {
+ AfxMessageBox(_T("Error parsing entered text!"));
+ return;
+ }
+
+ if(fps == 0)
+ {
+ AfxMessageBox(_T("Error parsing entered frame rate!"));
+ return;
+ }
+
+ m_time = (int)(1000.0*frame/fps) + 1;
+
+ AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 1);
+
+ OnOK();
+ }
}
BOOL CGoToDlg::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
- {
- if(*GetFocus() == m_timeedit) OnBnClickedOk1();
- else if(*GetFocus() == m_frameedit) OnBnClickedOk2();
+ if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
+ {
+ if(*GetFocus() == m_timeedit) OnBnClickedOk1();
+ else if(*GetFocus() == m_frameedit) OnBnClickedOk2();
- return TRUE;
- }
+ return TRUE;
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
diff --git a/src/apps/mplayerc/GoToDlg.h b/src/apps/mplayerc/GoToDlg.h
index 219aefcfc..1b98ca34d 100644
--- a/src/apps/mplayerc/GoToDlg.h
+++ b/src/apps/mplayerc/GoToDlg.h
@@ -30,31 +30,31 @@
class CGoToDlg : public CDialog
{
- DECLARE_DYNAMIC(CGoToDlg)
+ DECLARE_DYNAMIC(CGoToDlg)
public:
- CGoToDlg(int time = -1, float fps = 0, CWnd* pParent = NULL); // standard constructor
- virtual ~CGoToDlg();
+ CGoToDlg(int time = -1, float fps = 0, CWnd* pParent = NULL); // standard constructor
+ virtual ~CGoToDlg();
- CString m_timestr;
- CString m_framestr;
- CEdit m_timeedit;
- CEdit m_frameedit;
+ CString m_timestr;
+ CString m_framestr;
+ CEdit m_timeedit;
+ CEdit m_frameedit;
- int m_time;
- float m_fps;
+ int m_time;
+ float m_fps;
// Dialog Data
- enum { IDD = IDD_GOTO_DLG };
+ enum { IDD = IDD_GOTO_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedOk1();
- afx_msg void OnBnClickedOk2();
+ afx_msg void OnBnClickedOk1();
+ afx_msg void OnBnClickedOk2();
};
diff --git a/src/apps/mplayerc/IGraphBuilder2.h b/src/apps/mplayerc/IGraphBuilder2.h
index 4e8506aed..6613f2c0f 100644
--- a/src/apps/mplayerc/IGraphBuilder2.h
+++ b/src/apps/mplayerc/IGraphBuilder2.h
@@ -24,38 +24,35 @@
#pragma once
[uuid("165BE9D6-0929-4363-9BA3-580D735AA0F6")]
-interface IGraphBuilder2 :
-public IFilterGraph2
+interface IGraphBuilder2 : public IFilterGraph2
{
- STDMETHOD(IsPinDirection)(IPin* pPin, PIN_DIRECTION dir) = 0;
- STDMETHOD(IsPinConnected)(IPin* pPin) = 0;
- STDMETHOD(ConnectFilter)(IBaseFilter* pBF, IPin* pPinIn) = 0;
- STDMETHOD(ConnectFilter)(IPin* pPinOut, IBaseFilter* pBF) = 0;
- STDMETHOD(ConnectFilterDirect)(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt) = 0;
- STDMETHOD(NukeDownstream)(IUnknown* pUnk) = 0;
- STDMETHOD(FindInterface)(REFIID iid, void** ppv, BOOL bRemove) = 0;
- STDMETHOD(AddToROT)() = 0;
- STDMETHOD(RemoveFromROT)() = 0;
+ STDMETHOD(IsPinDirection) (IPin* pPin, PIN_DIRECTION dir) = 0;
+ STDMETHOD(IsPinConnected) (IPin* pPin) = 0;
+ STDMETHOD(ConnectFilter) (IBaseFilter* pBF, IPin* pPinIn) = 0;
+ STDMETHOD(ConnectFilter) (IPin* pPinOut, IBaseFilter* pBF) = 0;
+ STDMETHOD(ConnectFilterDirect) (IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt) = 0;
+ STDMETHOD(NukeDownstream) (IUnknown* pUnk) = 0;
+ STDMETHOD(FindInterface) (REFIID iid, void** ppv, BOOL bRemove) = 0;
+ STDMETHOD(AddToROT) () = 0;
+ STDMETHOD(RemoveFromROT) () = 0;
};
// private use only
[uuid("43CDA93D-6A4E-4A07-BD3E-49D161073EE7")]
-interface IGraphBuilderDeadEnd :
-public IUnknown
+interface IGraphBuilderDeadEnd : public IUnknown
{
- STDMETHOD_(size_t, GetCount)() = 0;
- STDMETHOD(GetDeadEnd)(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts) = 0;
+ STDMETHOD_(size_t, GetCount)() = 0;
+ STDMETHOD(GetDeadEnd) (int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts) = 0;
};
// private use only
[uuid("43CDA93D-6A4E-4A07-BD3E-49D161073EE7")]
-interface IBDATuner :
-public IUnknown
+interface IBDATuner : public IUnknown
{
- STDMETHOD(SetChannel)(int nChannelPrefNumber) = 0;
- STDMETHOD(SetAudio)(int nAudioIndex) = 0;
- STDMETHOD(SetFrequency)(ULONG ulFrequency) = 0;
- STDMETHOD(Scan)(ULONG ulFrequency, HWND hWnd) = 0;
- STDMETHOD(GetStats)(BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality) = 0;
+ STDMETHOD(SetChannel) (int nChannelPrefNumber) = 0;
+ STDMETHOD(SetAudio) (int nAudioIndex) = 0;
+ STDMETHOD(SetFrequency) (ULONG ulFrequency) = 0;
+ STDMETHOD(Scan) (ULONG ulFrequency, HWND hWnd) = 0;
+ STDMETHOD(GetStats) (BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality) = 0;
};
diff --git a/src/apps/mplayerc/IPinHook.cpp b/src/apps/mplayerc/IPinHook.cpp
index 6387cd09d..98d222524 100644
--- a/src/apps/mplayerc/IPinHook.cpp
+++ b/src/apps/mplayerc/IPinHook.cpp
@@ -51,7 +51,7 @@ typedef struct
const LPCTSTR Description;
} DXVA2_DECODER;
-const DXVA2_DECODER DXVA2Decoder[] =
+const DXVA2_DECODER DXVA2Decoder[] =
{
{ &GUID_NULL, _T("Not using DXVA") },
{ &DXVA2_ModeH264_A, _T("H.264 motion compensation, no FGT") },
@@ -71,7 +71,7 @@ const DXVA2_DECODER DXVA2Decoder[] =
{ &DXVA2_ModeVC1_B, _T("VC-1 motion compensation") },
{ &DXVA2_ModeVC1_C, _T("VC-1 IDCT") },
{ &DXVA2_ModeVC1_D, _T("VC-1 bitstream decoder") },
- { &DXVA2_ModeWMV8_A, _T("WMV 8 post processing.") },
+ { &DXVA2_ModeWMV8_A, _T("WMV 8 post processing.") },
{ &DXVA2_ModeWMV8_B, _T("WMV8 motion compensation") },
{ &DXVA2_ModeWMV9_A, _T("WMV9 post processing") },
{ &DXVA2_ModeWMV9_B, _T("WMV9 motion compensation") },
@@ -81,176 +81,176 @@ const DXVA2_DECODER DXVA2Decoder[] =
typedef struct
{
- const int Format;
- const LPCTSTR Description;
+ const int Format;
+ const LPCTSTR Description;
} D3DFORMAT_TYPE;
-const D3DFORMAT_TYPE D3DFormatType[] =
+const D3DFORMAT_TYPE D3DFormatType[] =
{
- { D3DFMT_UNKNOWN , _T("D3DFMT_UNKNOWN ") },
- { D3DFMT_R8G8B8 , _T("D3DFMT_R8G8B8 ") },
- { D3DFMT_A8R8G8B8 , _T("D3DFMT_A8R8G8B8 ") },
- { D3DFMT_X8R8G8B8 , _T("D3DFMT_X8R8G8B8 ") },
- { D3DFMT_R5G6B5 , _T("D3DFMT_R5G6B5 ") },
- { D3DFMT_X1R5G5B5 , _T("D3DFMT_X1R5G5B5 ") },
- { D3DFMT_A1R5G5B5 , _T("D3DFMT_A1R5G5B5 ") },
- { D3DFMT_A4R4G4B4 , _T("D3DFMT_A4R4G4B4 ") },
- { D3DFMT_R3G3B2 , _T("D3DFMT_R3G3B2 ") },
- { D3DFMT_A8 , _T("D3DFMT_A8 ") },
- { D3DFMT_A8R3G3B2 , _T("D3DFMT_A8R3G3B2 ") },
- { D3DFMT_X4R4G4B4 , _T("D3DFMT_X4R4G4B4 ") },
- { D3DFMT_A2B10G10R10 , _T("D3DFMT_A2B10G10R10 ") },
- { D3DFMT_A8B8G8R8 , _T("D3DFMT_A8B8G8R8 ") },
- { D3DFMT_X8B8G8R8 , _T("D3DFMT_X8B8G8R8 ") },
- { D3DFMT_G16R16 , _T("D3DFMT_G16R16 ") },
- { D3DFMT_A2R10G10B10 , _T("D3DFMT_A2R10G10B10 ") },
- { D3DFMT_A16B16G16R16 , _T("D3DFMT_A16B16G16R16 ") },
- { D3DFMT_A8P8 , _T("D3DFMT_A8P8 ") },
- { D3DFMT_P8 , _T("D3DFMT_P8 ") },
- { D3DFMT_L8 , _T("D3DFMT_L8 ") },
- { D3DFMT_A8L8 , _T("D3DFMT_A8L8 ") },
- { D3DFMT_A4L4 , _T("D3DFMT_A4L4 ") },
- { D3DFMT_X8L8V8U8 , _T("D3DFMT_X8L8V8U8 ") },
- { D3DFMT_Q8W8V8U8 , _T("D3DFMT_Q8W8V8U8 ") },
- { D3DFMT_V16U16 , _T("D3DFMT_V16U16 ") },
- { D3DFMT_A2W10V10U10 , _T("D3DFMT_A2W10V10U10 ") },
- { D3DFMT_UYVY , _T("D3DFMT_UYVY ") },
- { D3DFMT_R8G8_B8G8 , _T("D3DFMT_R8G8_B8G8 ") },
- { D3DFMT_YUY2 , _T("D3DFMT_YUY2 ") },
- { D3DFMT_G8R8_G8B8 , _T("D3DFMT_G8R8_G8B8 ") },
- { D3DFMT_DXT1 , _T("D3DFMT_DXT1 ") },
- { D3DFMT_DXT2 , _T("D3DFMT_DXT2 ") },
- { D3DFMT_DXT3 , _T("D3DFMT_DXT3 ") },
- { D3DFMT_DXT4 , _T("D3DFMT_DXT4 ") },
- { D3DFMT_DXT5 , _T("D3DFMT_DXT5 ") },
- { D3DFMT_D16_LOCKABLE , _T("D3DFMT_D16_LOCKABLE ") },
- { D3DFMT_D32 , _T("D3DFMT_D32 ") },
- { D3DFMT_D15S1 , _T("D3DFMT_D15S1 ") },
- { D3DFMT_D24S8 , _T("D3DFMT_D24S8 ") },
- { D3DFMT_D24X8 , _T("D3DFMT_D24X8 ") },
- { D3DFMT_D24X4S4 , _T("D3DFMT_D24X4S4 ") },
- { D3DFMT_D16 , _T("D3DFMT_D16 ") },
- { D3DFMT_D32F_LOCKABLE , _T("D3DFMT_D32F_LOCKABLE") },
- { D3DFMT_D24FS8 , _T("D3DFMT_D24FS8 ") },
- { D3DFMT_L16 , _T("D3DFMT_L16 ") },
- { D3DFMT_VERTEXDATA , _T("D3DFMT_VERTEXDATA ") },
- { D3DFMT_INDEX16 , _T("D3DFMT_INDEX16 ") },
- { D3DFMT_INDEX32 , _T("D3DFMT_INDEX32 ") },
- { D3DFMT_Q16W16V16U16 , _T("D3DFMT_Q16W16V16U16 ") },
-
- { MAKEFOURCC('N', 'V', '1', '2') , _T("D3DFMT_NV12") },
- { MAKEFOURCC('N', 'V', '2', '4') , _T("D3DFMT_NV24") },
+ { D3DFMT_UNKNOWN , _T("D3DFMT_UNKNOWN ") },
+ { D3DFMT_R8G8B8 , _T("D3DFMT_R8G8B8 ") },
+ { D3DFMT_A8R8G8B8 , _T("D3DFMT_A8R8G8B8 ") },
+ { D3DFMT_X8R8G8B8 , _T("D3DFMT_X8R8G8B8 ") },
+ { D3DFMT_R5G6B5 , _T("D3DFMT_R5G6B5 ") },
+ { D3DFMT_X1R5G5B5 , _T("D3DFMT_X1R5G5B5 ") },
+ { D3DFMT_A1R5G5B5 , _T("D3DFMT_A1R5G5B5 ") },
+ { D3DFMT_A4R4G4B4 , _T("D3DFMT_A4R4G4B4 ") },
+ { D3DFMT_R3G3B2 , _T("D3DFMT_R3G3B2 ") },
+ { D3DFMT_A8 , _T("D3DFMT_A8 ") },
+ { D3DFMT_A8R3G3B2 , _T("D3DFMT_A8R3G3B2 ") },
+ { D3DFMT_X4R4G4B4 , _T("D3DFMT_X4R4G4B4 ") },
+ { D3DFMT_A2B10G10R10 , _T("D3DFMT_A2B10G10R10 ") },
+ { D3DFMT_A8B8G8R8 , _T("D3DFMT_A8B8G8R8 ") },
+ { D3DFMT_X8B8G8R8 , _T("D3DFMT_X8B8G8R8 ") },
+ { D3DFMT_G16R16 , _T("D3DFMT_G16R16 ") },
+ { D3DFMT_A2R10G10B10 , _T("D3DFMT_A2R10G10B10 ") },
+ { D3DFMT_A16B16G16R16 , _T("D3DFMT_A16B16G16R16 ") },
+ { D3DFMT_A8P8 , _T("D3DFMT_A8P8 ") },
+ { D3DFMT_P8 , _T("D3DFMT_P8 ") },
+ { D3DFMT_L8 , _T("D3DFMT_L8 ") },
+ { D3DFMT_A8L8 , _T("D3DFMT_A8L8 ") },
+ { D3DFMT_A4L4 , _T("D3DFMT_A4L4 ") },
+ { D3DFMT_X8L8V8U8 , _T("D3DFMT_X8L8V8U8 ") },
+ { D3DFMT_Q8W8V8U8 , _T("D3DFMT_Q8W8V8U8 ") },
+ { D3DFMT_V16U16 , _T("D3DFMT_V16U16 ") },
+ { D3DFMT_A2W10V10U10 , _T("D3DFMT_A2W10V10U10 ") },
+ { D3DFMT_UYVY , _T("D3DFMT_UYVY ") },
+ { D3DFMT_R8G8_B8G8 , _T("D3DFMT_R8G8_B8G8 ") },
+ { D3DFMT_YUY2 , _T("D3DFMT_YUY2 ") },
+ { D3DFMT_G8R8_G8B8 , _T("D3DFMT_G8R8_G8B8 ") },
+ { D3DFMT_DXT1 , _T("D3DFMT_DXT1 ") },
+ { D3DFMT_DXT2 , _T("D3DFMT_DXT2 ") },
+ { D3DFMT_DXT3 , _T("D3DFMT_DXT3 ") },
+ { D3DFMT_DXT4 , _T("D3DFMT_DXT4 ") },
+ { D3DFMT_DXT5 , _T("D3DFMT_DXT5 ") },
+ { D3DFMT_D16_LOCKABLE , _T("D3DFMT_D16_LOCKABLE ") },
+ { D3DFMT_D32 , _T("D3DFMT_D32 ") },
+ { D3DFMT_D15S1 , _T("D3DFMT_D15S1 ") },
+ { D3DFMT_D24S8 , _T("D3DFMT_D24S8 ") },
+ { D3DFMT_D24X8 , _T("D3DFMT_D24X8 ") },
+ { D3DFMT_D24X4S4 , _T("D3DFMT_D24X4S4 ") },
+ { D3DFMT_D16 , _T("D3DFMT_D16 ") },
+ { D3DFMT_D32F_LOCKABLE , _T("D3DFMT_D32F_LOCKABLE") },
+ { D3DFMT_D24FS8 , _T("D3DFMT_D24FS8 ") },
+ { D3DFMT_L16 , _T("D3DFMT_L16 ") },
+ { D3DFMT_VERTEXDATA , _T("D3DFMT_VERTEXDATA ") },
+ { D3DFMT_INDEX16 , _T("D3DFMT_INDEX16 ") },
+ { D3DFMT_INDEX32 , _T("D3DFMT_INDEX32 ") },
+ { D3DFMT_Q16W16V16U16 , _T("D3DFMT_Q16W16V16U16 ") },
+
+ { MAKEFOURCC('N','V','1','2') , _T("D3DFMT_NV12") },
+ { MAKEFOURCC('N','V','2','4') , _T("D3DFMT_NV24") },
};
const LPCTSTR DXVAVersion[] = { _T("DXVA "), _T("DXVA1"), _T("DXVA2") };
LPCTSTR GetDXVADecoderDescription()
{
- return GetDXVAMode(&g_guidDXVADecoder);
+ return GetDXVAMode (&g_guidDXVADecoder);
}
LPCTSTR GetDXVAVersion()
{
- return DXVAVersion[g_nDXVAVersion];
+ return DXVAVersion[g_nDXVAVersion];
}
LPCTSTR FindD3DFormat(const D3DFORMAT Format)
{
- for(int i = 0; i < countof(D3DFormatType); i++)
- {
- if(Format == D3DFormatType[i].Format)
- return D3DFormatType[i].Description;
- }
+ for (int i=0; i<countof(D3DFormatType); i++)
+ {
+ if (Format == D3DFormatType[i].Format)
+ return D3DFormatType[i].Description;
+ }
- return D3DFormatType[0].Description;
+ return D3DFormatType[0].Description;
}
// === DirectShow hooks
-static HRESULT(STDMETHODCALLTYPE * NewSegmentOrg)(IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate) = NULL;
+static HRESULT (STDMETHODCALLTYPE * NewSegmentOrg)(IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate) = NULL;
static HRESULT STDMETHODCALLTYPE NewSegmentMine(IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate)
{
- g_tSegmentStart = tStart;
- return NewSegmentOrg(This, tStart, tStop, dRate);
+ g_tSegmentStart = tStart;
+ return NewSegmentOrg(This, tStart, tStop, dRate);
}
-static HRESULT(STDMETHODCALLTYPE *ReceiveOrg)(IMemInputPinC * This, IMediaSample *pSample) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *ReceiveOrg )( IMemInputPinC * This, IMediaSample *pSample) = NULL;
static HRESULT STDMETHODCALLTYPE ReceiveMineI(IMemInputPinC * This, IMediaSample *pSample)
{
- REFERENCE_TIME rtStart, rtStop;
- if(pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop)))
- g_tSampleStart = rtStart;
- return ReceiveOrg(This, pSample);
+ REFERENCE_TIME rtStart, rtStop;
+ if(pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop)))
+ g_tSampleStart = rtStart;
+ return ReceiveOrg(This, pSample);
}
static HRESULT STDMETHODCALLTYPE ReceiveMine(IMemInputPinC * This, IMediaSample *pSample)
{
- // Support ffdshow queueing.
- // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with CMainFrame::OnPlayPause.
- if(queue_ffdshow_support)
- {
- CAutoLock lck(&g_ffdshowReceive);
- return ReceiveMineI(This, pSample);
- }
- return ReceiveMineI(This, pSample);
+ // Support ffdshow queueing.
+ // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with CMainFrame::OnPlayPause.
+ if(queue_ffdshow_support)
+ {
+ CAutoLock lck(&g_ffdshowReceive);
+ return ReceiveMineI(This,pSample);
+ }
+ return ReceiveMineI(This,pSample);
}
void UnhookNewSegmentAndReceive()
{
- BOOL res;
- DWORD flOldProtect = 0;
-
- // Casimir666 : unhook previous VTables
- if(g_pPinCVtbl && g_pMemInputPinCVtbl)
- {
- res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if(g_pPinCVtbl->NewSegment == NewSegmentMine)
- g_pPinCVtbl->NewSegment = NewSegmentOrg;
- res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
-
- res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if(g_pMemInputPinCVtbl->Receive == ReceiveMine)
- g_pMemInputPinCVtbl->Receive = ReceiveOrg;
- res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
-
- g_pPinCVtbl = NULL;
- g_pMemInputPinCVtbl = NULL;
- NewSegmentOrg = NULL;
- ReceiveOrg = NULL;
- }
+ BOOL res;
+ DWORD flOldProtect = 0;
+
+ // Casimir666 : unhook previous VTables
+ if (g_pPinCVtbl && g_pMemInputPinCVtbl)
+ {
+ res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (g_pPinCVtbl->NewSegment == NewSegmentMine)
+ g_pPinCVtbl->NewSegment = NewSegmentOrg;
+ res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
+
+ res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (g_pMemInputPinCVtbl->Receive == ReceiveMine)
+ g_pMemInputPinCVtbl->Receive = ReceiveOrg;
+ res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
+
+ g_pPinCVtbl = NULL;
+ g_pMemInputPinCVtbl = NULL;
+ NewSegmentOrg = NULL;
+ ReceiveOrg = NULL;
+ }
}
bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC)
{
- if(!pPinC || !pMemInputPinC || (GetVersion() & 0x80000000))
- return false;
+ if(!pPinC || !pMemInputPinC || (GetVersion()&0x80000000))
+ return false;
- g_tSegmentStart = 0;
- g_tSampleStart = 0;
+ g_tSegmentStart = 0;
+ g_tSampleStart = 0;
- BOOL res;
- DWORD flOldProtect = 0;
+ BOOL res;
+ DWORD flOldProtect = 0;
- UnhookNewSegmentAndReceive();
+ UnhookNewSegmentAndReceive();
- // Casimir666 : change sizeof(IPinC) to sizeof(IPinCVtbl) to fix crash with EVR hack on Vista!
- res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if(NewSegmentOrg == NULL) NewSegmentOrg = pPinC->lpVtbl->NewSegment;
- pPinC->lpVtbl->NewSegment = NewSegmentMine;
- res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
+ // Casimir666 : change sizeof(IPinC) to sizeof(IPinCVtbl) to fix crash with EVR hack on Vista!
+ res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if(NewSegmentOrg == NULL) NewSegmentOrg = pPinC->lpVtbl->NewSegment;
+ pPinC->lpVtbl->NewSegment = NewSegmentMine;
+ res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
- // Casimir666 : change sizeof(IMemInputPinC) to sizeof(IMemInputPinCVtbl) to fix crash with EVR hack on Vista!
- res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if(ReceiveOrg == NULL) ReceiveOrg = pMemInputPinC->lpVtbl->Receive;
- pMemInputPinC->lpVtbl->Receive = ReceiveMine;
- res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
+ // Casimir666 : change sizeof(IMemInputPinC) to sizeof(IMemInputPinCVtbl) to fix crash with EVR hack on Vista!
+ res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if(ReceiveOrg == NULL) ReceiveOrg = pMemInputPinC->lpVtbl->Receive;
+ pMemInputPinC->lpVtbl->Receive = ReceiveMine;
+ res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
- g_pPinCVtbl = pPinC->lpVtbl;
- g_pMemInputPinCVtbl = pMemInputPinC->lpVtbl;
+ g_pPinCVtbl = pPinC->lpVtbl;
+ g_pMemInputPinCVtbl = pMemInputPinC->lpVtbl;
- return true;
+ return true;
}
@@ -260,180 +260,180 @@ bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC)
BYTE* g_ppBuffer[MAX_BUFFER_TYPE];
-static HRESULT(STDMETHODCALLTYPE *GetVideoAcceleratorGUIDsOrg)(IAMVideoAcceleratorC * This,/* [out][in] */ LPDWORD pdwNumGuidsSupported,/* [out][in] */ LPGUID pGuidsSupported) = NULL;
-static HRESULT(STDMETHODCALLTYPE *GetUncompFormatsSupportedOrg)(IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [out][in] */ LPDWORD pdwNumFormatsSupported,/* [out][in] */ LPDDPIXELFORMAT pFormatsSupported) = NULL;
-static HRESULT(STDMETHODCALLTYPE *GetInternalMemInfoOrg)(IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,/* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo) = NULL;
-static HRESULT(STDMETHODCALLTYPE *GetCompBufferInfoOrg)(IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
-static HRESULT(STDMETHODCALLTYPE *GetInternalCompBufferInfoOrg)(IAMVideoAcceleratorC * This,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
-static HRESULT(STDMETHODCALLTYPE *BeginFrameOrg)(IAMVideoAcceleratorC * This,/* [in] */ const AMVABeginFrameInfo *amvaBeginFrameInfo) = NULL;
-static HRESULT(STDMETHODCALLTYPE *EndFrameOrg)(IAMVideoAcceleratorC * This,/* [in] */ const AMVAEndFrameInfo *pEndFrameInfo) = NULL;
-static HRESULT(STDMETHODCALLTYPE *GetBufferOrg)(IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ BOOL bReadOnly,/* [out] */ LPVOID *ppBuffer,/* [out] */ LONG *lpStride) = NULL;
-static HRESULT(STDMETHODCALLTYPE *ReleaseBufferOrg)(IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex) = NULL;
-static HRESULT(STDMETHODCALLTYPE *ExecuteOrg)(IAMVideoAcceleratorC * This,/* [in] */ DWORD dwFunction,/* [in] */ LPVOID lpPrivateInputData,/* [in] */ DWORD cbPrivateInputData,/* [in] */ LPVOID lpPrivateOutputDat,/* [in] */ DWORD cbPrivateOutputData,/* [in] */ DWORD dwNumBuffers,/* [in] */ const AMVABUFFERINFO *pamvaBufferInfo) = NULL;
-static HRESULT(STDMETHODCALLTYPE *QueryRenderStatusOrg)(IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ DWORD dwFlags) = NULL;
-static HRESULT(STDMETHODCALLTYPE *DisplayFrameOrg)(IAMVideoAcceleratorC * This,/* [in] */ DWORD dwFlipToIndex,/* [in] */ IMediaSample *pMediaSample) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *GetVideoAcceleratorGUIDsOrg )( IAMVideoAcceleratorC * This,/* [out][in] */ LPDWORD pdwNumGuidsSupported,/* [out][in] */ LPGUID pGuidsSupported) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *GetUncompFormatsSupportedOrg )( IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [out][in] */ LPDWORD pdwNumFormatsSupported,/* [out][in] */ LPDDPIXELFORMAT pFormatsSupported) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *GetInternalMemInfoOrg )( IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,/* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *GetCompBufferInfoOrg )( IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *GetInternalCompBufferInfoOrg )( IAMVideoAcceleratorC * This,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *BeginFrameOrg )( IAMVideoAcceleratorC * This,/* [in] */ const AMVABeginFrameInfo *amvaBeginFrameInfo) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *EndFrameOrg )( IAMVideoAcceleratorC * This,/* [in] */ const AMVAEndFrameInfo *pEndFrameInfo) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *GetBufferOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ BOOL bReadOnly,/* [out] */ LPVOID *ppBuffer,/* [out] */ LONG *lpStride) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *ReleaseBufferOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *ExecuteOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwFunction,/* [in] */ LPVOID lpPrivateInputData,/* [in] */ DWORD cbPrivateInputData,/* [in] */ LPVOID lpPrivateOutputDat,/* [in] */ DWORD cbPrivateOutputData,/* [in] */ DWORD dwNumBuffers,/* [in] */ const AMVABUFFERINFO *pamvaBufferInfo) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *QueryRenderStatusOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ DWORD dwFlags) = NULL;
+static HRESULT ( STDMETHODCALLTYPE *DisplayFrameOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwFlipToIndex,/* [in] */ IMediaSample *pMediaSample) = NULL;
static void LOG_TOFILE(LPCTSTR FileName, LPCTSTR fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- int nCount = _vsctprintf(fmt, args) + 1;
- if(TCHAR* buff = DNew TCHAR[nCount])
- {
- FILE* f;
- _vstprintf_s(buff, nCount, fmt, args);
- if(_tfopen_s(&f, FileName, _T("at")) == 0)
- {
- fseek(f, 0, 2);
- _ftprintf(f, _T("%s\n"), buff);
- fclose(f);
- }
- delete [] buff;
- }
- va_end(args);
+ va_list args;
+ va_start(args, fmt);
+ int nCount = _vsctprintf(fmt, args) + 1;
+ if(TCHAR* buff = DNew TCHAR[nCount])
+ {
+ FILE* f;
+ _vstprintf_s(buff, nCount, fmt, args);
+ if(_tfopen_s(&f, FileName, _T("at")) == 0)
+ {
+ fseek(f, 0, 2);
+ _ftprintf(f, _T("%s\n"), buff);
+ fclose(f);
+ }
+ delete [] buff;
+ }
+ va_end(args);
}
#ifdef _DEBUG
static void LOG(LPCTSTR fmt, ...)
{
- va_list args;
- va_start(args, fmt);
+ va_list args;
+ va_start(args, fmt);
// int nCount = _vsctprintf(fmt, args) + 1;
- TCHAR buff[3000];
- FILE* f;
- _vstprintf_s(buff, countof(buff), fmt, args);
- if(_tfopen_s(&f, LOG_FILE, _T("at")) == 0)
- {
- fseek(f, 0, 2);
- _ftprintf(f, _T("%s\n"), buff);
- fclose(f);
- }
-
- va_end(args);
+ TCHAR buff[3000];
+ FILE* f;
+ _vstprintf_s(buff, countof(buff), fmt, args);
+ if(_tfopen_s(&f, LOG_FILE, _T("at")) == 0)
+ {
+ fseek(f, 0, 2);
+ _ftprintf(f, _T("%s\n"), buff);
+ fclose(f);
+ }
+
+ va_end(args);
}
static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n)
{
- for(int i = 0; i < n; i++)
- {
- LOG(_T("%s[%d].dwSize = %d"), prefix, i, p[i].dwSize);
- LOG(_T("%s[%d].dwFlags = %08x"), prefix, i, p[i].dwFlags);
- LOG(_T("%s[%d].dwFourCC = %4.4hs"), prefix, i, &p[i].dwFourCC);
- LOG(_T("%s[%d].dwRGBBitCount = %08x"), prefix, i, &p[i].dwRGBBitCount);
- LOG(_T("%s[%d].dwRBitMask = %08x"), prefix, i, &p[i].dwRBitMask);
- LOG(_T("%s[%d].dwGBitMask = %08x"), prefix, i, &p[i].dwGBitMask);
- LOG(_T("%s[%d].dwBBitMask = %08x"), prefix, i, &p[i].dwBBitMask);
- LOG(_T("%s[%d].dwRGBAlphaBitMask = %08x"), prefix, i, &p[i].dwRGBAlphaBitMask);
- }
+ for(int i = 0; i < n; i++)
+ {
+ LOG(_T("%s[%d].dwSize = %d"), prefix, i, p[i].dwSize);
+ LOG(_T("%s[%d].dwFlags = %08x"), prefix, i, p[i].dwFlags);
+ LOG(_T("%s[%d].dwFourCC = %4.4hs"), prefix, i, &p[i].dwFourCC);
+ LOG(_T("%s[%d].dwRGBBitCount = %08x"), prefix, i, &p[i].dwRGBBitCount);
+ LOG(_T("%s[%d].dwRBitMask = %08x"), prefix, i, &p[i].dwRBitMask);
+ LOG(_T("%s[%d].dwGBitMask = %08x"), prefix, i, &p[i].dwGBitMask);
+ LOG(_T("%s[%d].dwBBitMask = %08x"), prefix, i, &p[i].dwBBitMask);
+ LOG(_T("%s[%d].dwRGBAlphaBitMask = %08x"), prefix, i, &p[i].dwRGBAlphaBitMask);
+ }
}
static void LOGUDI(LPCTSTR prefix, const AMVAUncompDataInfo* p, int n)
{
- for(int i = 0; i < n; i++)
- {
- LOG(_T("%s[%d].dwUncompWidth = %d"), prefix, i, p[i].dwUncompWidth);
- LOG(_T("%s[%d].dwUncompHeight = %d"), prefix, i, p[i].dwUncompHeight);
-
- CString prefix2;
- prefix2.Format(_T("%s[%d]"), prefix, i);
- LOGPF(prefix2, &p[i].ddUncompPixelFormat, 1);
- }
+ for(int i = 0; i < n; i++)
+ {
+ LOG(_T("%s[%d].dwUncompWidth = %d"), prefix, i, p[i].dwUncompWidth);
+ LOG(_T("%s[%d].dwUncompHeight = %d"), prefix, i, p[i].dwUncompHeight);
+
+ CString prefix2;
+ prefix2.Format(_T("%s[%d]"), prefix, i);
+ LOGPF(prefix2, &p[i].ddUncompPixelFormat, 1);
+ }
}
-static void LogDXVA_PicParams_H264(DXVA_PicParams_H264* pPic)
+static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic)
{
- CString strRes;
- int i;
- static bool bFirstParam = true;
-
- if(bFirstParam)
- {
- LOG_TOFILE(_T("picture.log"), _T("RefPicFlag,wFrameWidthInMbsMinus1,wFrameHeightInMbsMinus1,CurrPic.Index7Bits,num_ref_frames,wBitFields,bit_depth_luma_minus8,bit_depth_chroma_minus8,Reserved16Bits,StatusReportFeedbackNumber,RFL.Index7Bits[0],") \
- _T("RFL.Index7Bits[1],RFL.Index7Bits[2],RFL.Index7Bits[3],RFL.Index7Bits[4],RFL.Index7Bits[5],") \
- _T("RFL.Index7Bits[6],RFL.Index7Bits[7],RFL.Index7Bits[8],RFL.Index7Bits[9],RFL.Index7Bits[10],") \
- _T("RFL.Index7Bits[11],RFL.Index7Bits[12],RFL.Index7Bits[13],RFL.Index7Bits[14],RFL.Index7Bits[15],") \
- _T("CurrFieldOrderCnt[0], CurrFieldOrderCnt[1],FieldOrderCntList[0][0], FieldOrderCntList[0][1],FieldOrderCntList[1][0], FieldOrderCntList[1][1],FieldOrderCntList[2][0], FieldOrderCntList[2][1],FieldOrderCntList[3][0], FieldOrderCntList[3][1],FieldOrderCntList[4][0], FieldOrderCntList[4][1],FieldOrderCntList[5][0],") \
- _T("FieldOrderCntList[5][1],FieldOrderCntList[6][0], FieldOrderCntList[6][1],FieldOrderCntList[7][0], FieldOrderCntList[7][1],FieldOrderCntList[8][0], FieldOrderCntList[8][1],FieldOrderCntList[9][0], FieldOrderCntList[9][1],FieldOrderCntList[10][0], FieldOrderCntList[10][1],FieldOrderCntList[11][0],")\
- _T("FieldOrderCntList[11][1],FieldOrderCntList[12][0], FieldOrderCntList[12][1],FieldOrderCntList[13][0], FieldOrderCntList[13][1],FieldOrderCntList[14][0], FieldOrderCntList[14][1],FieldOrderCntList[15][0], FieldOrderCntList[15][1],pic_init_qs_minus26,chroma_qp_index_offset,second_chroma_qp_index_offset,")\
- _T("ContinuationFlag,pic_init_qp_minus26,num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,Reserved8BitsA,FrameNumList[0],FrameNumList[1],FrameNumList[2],FrameNumList[3],FrameNumList[4],FrameNumList[5],FrameNumList[6],FrameNumList[7],FrameNumList[8],FrameNumList[9],FrameNumList[10],FrameNumList[11],")\
- _T("FrameNumList[12],FrameNumList[13],FrameNumList[14],FrameNumList[15],UsedForReferenceFlags,NonExistingFrameFlags,frame_num,log2_max_frame_num_minus4,pic_order_cnt_type,log2_max_pic_order_cnt_lsb_minus4,delta_pic_order_always_zero_flag,direct_8x8_inference_flag,entropy_coding_mode_flag,pic_order_present_flag,")\
- _T("num_slice_groups_minus1,slice_group_map_type,deblocking_filter_control_present_flag,redundant_pic_cnt_present_flag,Reserved8BitsB,slice_group_change_rate_minus1"));
-
- }
- bFirstParam = false;
-
- strRes.AppendFormat(_T("%d,"), pPic->RefPicFlag);
- strRes.AppendFormat(_T("%d,"), pPic->wFrameWidthInMbsMinus1);
- strRes.AppendFormat(_T("%d,"), pPic->wFrameHeightInMbsMinus1);
-
- // DXVA_PicEntry_H264 CurrPic)); /* flag is bot field flag */
+ CString strRes;
+ int i;
+ static bool bFirstParam = true;
+
+ if (bFirstParam)
+ {
+ LOG_TOFILE (_T("picture.log"), _T("RefPicFlag,wFrameWidthInMbsMinus1,wFrameHeightInMbsMinus1,CurrPic.Index7Bits,num_ref_frames,wBitFields,bit_depth_luma_minus8,bit_depth_chroma_minus8,Reserved16Bits,StatusReportFeedbackNumber,RFL.Index7Bits[0],") \
+ _T("RFL.Index7Bits[1],RFL.Index7Bits[2],RFL.Index7Bits[3],RFL.Index7Bits[4],RFL.Index7Bits[5],") \
+ _T("RFL.Index7Bits[6],RFL.Index7Bits[7],RFL.Index7Bits[8],RFL.Index7Bits[9],RFL.Index7Bits[10],") \
+ _T("RFL.Index7Bits[11],RFL.Index7Bits[12],RFL.Index7Bits[13],RFL.Index7Bits[14],RFL.Index7Bits[15],") \
+ _T("CurrFieldOrderCnt[0], CurrFieldOrderCnt[1],FieldOrderCntList[0][0], FieldOrderCntList[0][1],FieldOrderCntList[1][0], FieldOrderCntList[1][1],FieldOrderCntList[2][0], FieldOrderCntList[2][1],FieldOrderCntList[3][0], FieldOrderCntList[3][1],FieldOrderCntList[4][0], FieldOrderCntList[4][1],FieldOrderCntList[5][0],") \
+ _T("FieldOrderCntList[5][1],FieldOrderCntList[6][0], FieldOrderCntList[6][1],FieldOrderCntList[7][0], FieldOrderCntList[7][1],FieldOrderCntList[8][0], FieldOrderCntList[8][1],FieldOrderCntList[9][0], FieldOrderCntList[9][1],FieldOrderCntList[10][0], FieldOrderCntList[10][1],FieldOrderCntList[11][0],")\
+ _T("FieldOrderCntList[11][1],FieldOrderCntList[12][0], FieldOrderCntList[12][1],FieldOrderCntList[13][0], FieldOrderCntList[13][1],FieldOrderCntList[14][0], FieldOrderCntList[14][1],FieldOrderCntList[15][0], FieldOrderCntList[15][1],pic_init_qs_minus26,chroma_qp_index_offset,second_chroma_qp_index_offset,")\
+ _T("ContinuationFlag,pic_init_qp_minus26,num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,Reserved8BitsA,FrameNumList[0],FrameNumList[1],FrameNumList[2],FrameNumList[3],FrameNumList[4],FrameNumList[5],FrameNumList[6],FrameNumList[7],FrameNumList[8],FrameNumList[9],FrameNumList[10],FrameNumList[11],")\
+ _T("FrameNumList[12],FrameNumList[13],FrameNumList[14],FrameNumList[15],UsedForReferenceFlags,NonExistingFrameFlags,frame_num,log2_max_frame_num_minus4,pic_order_cnt_type,log2_max_pic_order_cnt_lsb_minus4,delta_pic_order_always_zero_flag,direct_8x8_inference_flag,entropy_coding_mode_flag,pic_order_present_flag,")\
+ _T("num_slice_groups_minus1,slice_group_map_type,deblocking_filter_control_present_flag,redundant_pic_cnt_present_flag,Reserved8BitsB,slice_group_change_rate_minus1"));
+
+ }
+ bFirstParam = false;
+
+ strRes.AppendFormat(_T("%d,"), pPic->RefPicFlag);
+ strRes.AppendFormat(_T("%d,"), pPic->wFrameWidthInMbsMinus1);
+ strRes.AppendFormat(_T("%d,"), pPic->wFrameHeightInMbsMinus1);
+
+ // DXVA_PicEntry_H264 CurrPic)); /* flag is bot field flag */
// strRes.AppendFormat(_T("%d,"), pPic->CurrPic.AssociatedFlag);
// strRes.AppendFormat(_T("%d,"), pPic->CurrPic.bPicEntry);
- strRes.AppendFormat(_T("%d,"), pPic->CurrPic.Index7Bits);
+ strRes.AppendFormat(_T("%d,"), pPic->CurrPic.Index7Bits);
- strRes.AppendFormat(_T("%d,"), pPic->num_ref_frames);
- strRes.AppendFormat(_T("%d,"), pPic->wBitFields);
- strRes.AppendFormat(_T("%d,"), pPic->bit_depth_luma_minus8);
- strRes.AppendFormat(_T("%d,"), pPic->bit_depth_chroma_minus8);
+ strRes.AppendFormat(_T("%d,"), pPic->num_ref_frames);
+ strRes.AppendFormat(_T("%d,"), pPic->wBitFields);
+ strRes.AppendFormat(_T("%d,"), pPic->bit_depth_luma_minus8);
+ strRes.AppendFormat(_T("%d,"), pPic->bit_depth_chroma_minus8);
- strRes.AppendFormat(_T("%d,"), pPic->Reserved16Bits);
- strRes.AppendFormat(_T("%d,"), pPic->StatusReportFeedbackNumber);
+ strRes.AppendFormat(_T("%d,"), pPic->Reserved16Bits);
+ strRes.AppendFormat(_T("%d,"), pPic->StatusReportFeedbackNumber);
- for(i = 0; i < 16; i++)
- {
+ for (i =0; i<16; i++)
+ {
// strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].AssociatedFlag);
// strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].bPicEntry);
- strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].Index7Bits);
- }
+ strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].Index7Bits);
+ }
- strRes.AppendFormat(_T("%d, %d,"), pPic->CurrFieldOrderCnt[0], pPic->CurrFieldOrderCnt[1]);
+ strRes.AppendFormat(_T("%d, %d,"), pPic->CurrFieldOrderCnt[0], pPic->CurrFieldOrderCnt[1]);
- for(int i = 0; i < 16; i++)
- strRes.AppendFormat(_T("%d, %d,"), pPic->FieldOrderCntList[i][0], pPic->FieldOrderCntList[i][1]);
+ for (int i=0; i<16; i++)
+ strRes.AppendFormat(_T("%d, %d,"), pPic->FieldOrderCntList[i][0], pPic->FieldOrderCntList[i][1]);
// strRes.AppendFormat(_T("%d,"), pPic->FieldOrderCntList[16][2]);
- strRes.AppendFormat(_T("%d,"), pPic->pic_init_qs_minus26);
- strRes.AppendFormat(_T("%d,"), pPic->chroma_qp_index_offset); /* also used for QScb */
- strRes.AppendFormat(_T("%d,"), pPic->second_chroma_qp_index_offset); /* also for QScr */
- strRes.AppendFormat(_T("%d,"), pPic->ContinuationFlag);
+ strRes.AppendFormat(_T("%d,"), pPic->pic_init_qs_minus26);
+ strRes.AppendFormat(_T("%d,"), pPic->chroma_qp_index_offset); /* also used for QScb */
+ strRes.AppendFormat(_T("%d,"), pPic->second_chroma_qp_index_offset); /* also for QScr */
+ strRes.AppendFormat(_T("%d,"), pPic->ContinuationFlag);
- /* remainder for parsing */
- strRes.AppendFormat(_T("%d,"), pPic->pic_init_qp_minus26);
- strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l0_active_minus1);
- strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l1_active_minus1);
- strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsA);
+ /* remainder for parsing */
+ strRes.AppendFormat(_T("%d,"), pPic->pic_init_qp_minus26);
+ strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l0_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l1_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsA);
- for(int i = 0; i < 16; i++)
- strRes.AppendFormat(_T("%d,"), pPic->FrameNumList[i]);
+ for (int i=0; i<16; i++)
+ strRes.AppendFormat(_T("%d,"), pPic->FrameNumList[i]);
// strRes.AppendFormat(_T("%d,"), pPic->FrameNumList[16]);
- strRes.AppendFormat(_T("%d,"), pPic->UsedForReferenceFlags);
- strRes.AppendFormat(_T("%d,"), pPic->NonExistingFrameFlags);
- strRes.AppendFormat(_T("%d,"), pPic->frame_num);
+ strRes.AppendFormat(_T("%d,"), pPic->UsedForReferenceFlags);
+ strRes.AppendFormat(_T("%d,"), pPic->NonExistingFrameFlags);
+ strRes.AppendFormat(_T("%d,"), pPic->frame_num);
- strRes.AppendFormat(_T("%d,"), pPic->log2_max_frame_num_minus4);
- strRes.AppendFormat(_T("%d,"), pPic->pic_order_cnt_type);
- strRes.AppendFormat(_T("%d,"), pPic->log2_max_pic_order_cnt_lsb_minus4);
- strRes.AppendFormat(_T("%d,"), pPic->delta_pic_order_always_zero_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->log2_max_frame_num_minus4);
+ strRes.AppendFormat(_T("%d,"), pPic->pic_order_cnt_type);
+ strRes.AppendFormat(_T("%d,"), pPic->log2_max_pic_order_cnt_lsb_minus4);
+ strRes.AppendFormat(_T("%d,"), pPic->delta_pic_order_always_zero_flag);
- strRes.AppendFormat(_T("%d,"), pPic->direct_8x8_inference_flag);
- strRes.AppendFormat(_T("%d,"), pPic->entropy_coding_mode_flag);
- strRes.AppendFormat(_T("%d,"), pPic->pic_order_present_flag);
- strRes.AppendFormat(_T("%d,"), pPic->num_slice_groups_minus1);
+ strRes.AppendFormat(_T("%d,"), pPic->direct_8x8_inference_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->entropy_coding_mode_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->pic_order_present_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->num_slice_groups_minus1);
- strRes.AppendFormat(_T("%d,"), pPic->slice_group_map_type);
- strRes.AppendFormat(_T("%d,"), pPic->deblocking_filter_control_present_flag);
- strRes.AppendFormat(_T("%d,"), pPic->redundant_pic_cnt_present_flag);
- strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsB);
+ strRes.AppendFormat(_T("%d,"), pPic->slice_group_map_type);
+ strRes.AppendFormat(_T("%d,"), pPic->deblocking_filter_control_present_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->redundant_pic_cnt_present_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsB);
- strRes.AppendFormat(_T("%d,"), pPic->slice_group_change_rate_minus1);
+ strRes.AppendFormat(_T("%d,"), pPic->slice_group_change_rate_minus1);
- //for (int i=0; i<810; i++)
- // strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[i]);
+ //for (int i=0; i<810; i++)
+ // strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[i]);
// strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[810]);
- // SABOTAGE !!!
+ // SABOTAGE !!!
//for (int i=0; i<16; i++)
//{
// pPic->FieldOrderCntList[i][0] = pPic->FieldOrderCntList[i][1] = 0;
@@ -442,256 +442,256 @@ static void LogDXVA_PicParams_H264(DXVA_PicParams_H264* pPic)
// pPic->RefFrameList[i].Index7Bits = 127;
//}
- // === Dump PicParams!
- //static FILE* hPict = NULL;
- //if (!hPict) hPict = fopen ("PicParam.bin", "wb");
- //if (hPict)
- //{
- // fwrite (pPic, sizeof (DXVA_PicParams_H264), 1, hPict);
- //}
+ // === Dump PicParams!
+ //static FILE* hPict = NULL;
+ //if (!hPict) hPict = fopen ("PicParam.bin", "wb");
+ //if (hPict)
+ //{
+ // fwrite (pPic, sizeof (DXVA_PicParams_H264), 1, hPict);
+ //}
- LOG_TOFILE(_T("picture.log"), strRes);
+ LOG_TOFILE (_T("picture.log"), strRes);
}
-static void LogH264SliceShort(DXVA_Slice_H264_Short* pSlice, int nCount)
+static void LogH264SliceShort (DXVA_Slice_H264_Short* pSlice, int nCount)
{
- CString strRes;
- static bool bFirstSlice = true;
-
- if(bFirstSlice)
- {
- strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping");
- LOG_TOFILE(_T("sliceshort.log"), strRes);
- strRes = "";
- bFirstSlice = false;
- }
-
- for(int i = 0; i < nCount; i++)
- {
- strRes.AppendFormat(_T("%d,"), i);
- strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
- strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
- strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
-
- LOG_TOFILE(_T("sliceshort.log"), strRes);
- strRes = "";
- }
+ CString strRes;
+ static bool bFirstSlice = true;
+
+ if (bFirstSlice)
+ {
+ strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping");
+ LOG_TOFILE (_T("sliceshort.log"), strRes);
+ strRes = "";
+ bFirstSlice = false;
+ }
+
+ for (int i=0; i<nCount; i++)
+ {
+ strRes.AppendFormat(_T("%d,"), i);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
+ strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
+
+ LOG_TOFILE (_T("sliceshort.log"), strRes);
+ strRes = "";
+ }
}
-static void LogSliceInfo(DXVA_SliceInfo* pSlice, int nCount)
+static void LogSliceInfo (DXVA_SliceInfo* pSlice, int nCount)
{
- CString strRes;
- static bool bFirstSlice = true;
-
- if(bFirstSlice)
- {
- strRes = _T("nCnt, wHorizontalPosition, wVerticalPosition, dwSliceBitsInBuffer,dwSliceDataLocation, bStartCodeBitOffset, bReservedBits, wMBbitOffset, wNumberMBsInSlice, wQuantizerScaleCode, wBadSliceChopping");
-
- LOG_TOFILE(_T("sliceshort.log"), strRes);
- strRes = "";
- bFirstSlice = false;
- }
-
- for(int i = 0; i < nCount; i++)
- {
- strRes.AppendFormat(_T("%d,"), i);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wHorizontalPosition);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wVerticalPosition);
- strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceBitsInBuffer);
- strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceDataLocation);
- strRes.AppendFormat(_T("%d,"), pSlice[i].bStartCodeBitOffset);
- strRes.AppendFormat(_T("%d,"), pSlice[i].bReservedBits);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wMBbitOffset);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wNumberMBsInSlice);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wQuantizerScaleCode);
- strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
-
- LOG_TOFILE(_T("sliceshort.log"), strRes);
- strRes = "";
- }
+ CString strRes;
+ static bool bFirstSlice = true;
+
+ if (bFirstSlice)
+ {
+ strRes = _T("nCnt, wHorizontalPosition, wVerticalPosition, dwSliceBitsInBuffer,dwSliceDataLocation, bStartCodeBitOffset, bReservedBits, wMBbitOffset, wNumberMBsInSlice, wQuantizerScaleCode, wBadSliceChopping");
+
+ LOG_TOFILE (_T("sliceshort.log"), strRes);
+ strRes = "";
+ bFirstSlice = false;
+ }
+
+ for (int i=0; i<nCount; i++)
+ {
+ strRes.AppendFormat(_T("%d,"), i);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wHorizontalPosition);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wVerticalPosition);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceBitsInBuffer);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceDataLocation);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].bStartCodeBitOffset);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].bReservedBits);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wMBbitOffset);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wNumberMBsInSlice);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wQuantizerScaleCode);
+ strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
+
+ LOG_TOFILE (_T("sliceshort.log"), strRes);
+ strRes = "";
+ }
}
-static void LogH264SliceLong(DXVA_Slice_H264_Long* pSlice, int nCount)
+static void LogH264SliceLong (DXVA_Slice_H264_Long* pSlice, int nCount)
{
- static bool bFirstSlice = true;
- CString strRes;
-
- if(bFirstSlice)
- {
- strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping,") \
- _T("first_mb_in_slice, NumMbsForSlice, BitOffsetToSliceData, slice_type,luma_log2_weight_denom,chroma_log2_weight_denom,") \
- _T("num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,slice_alpha_c0_offset_div2,slice_beta_offset_div2,") \
- _T("Reserved8Bits,slice_qs_delta,slice_qp_delta,redundant_pic_cnt,direct_spatial_mv_pred_flag,cabac_init_idc,") \
- _T("disable_deblocking_filter_idc,slice_id,");
-
- for(int i = 0; i < 2; i++) /* L0 & L1 */
- {
- for(int j = 0; j < 32; j++)
- {
- strRes.AppendFormat(_T("R[%d][%d].AssociatedFlag,"), i, j);
- strRes.AppendFormat(_T("R[%d][%d].bPicEntry,"), i, j);
- strRes.AppendFormat(_T("R[%d][%d].Index7Bits,"), i, j);
- }
- }
-
- for(int a = 0; a < 2; a++) /* L0 & L1; Y, Cb, Cr */
- {
- for(int b = 0; b < 32; b++)
- {
- for(int c = 0; c < 3; c++)
- {
- for(int d = 0; d < 2; d++)
- {
- strRes.AppendFormat(_T("W[%d][%d][%d][%d],"), a, b, c, d);
- }
- }
- }
- }
-
-
- LOG_TOFILE(_T("slicelong.log"), strRes);
- strRes = "";
- }
- bFirstSlice = false;
-
- for(int i = 0; i < nCount; i++)
- {
- strRes.AppendFormat(_T("%d,"), i);
- strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
- strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wBadSliceChopping);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].first_mb_in_slice);
- strRes.AppendFormat(_T("%d,"), pSlice[i].NumMbsForSlice);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].BitOffsetToSliceData);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_type);
- strRes.AppendFormat(_T("%d,"), pSlice[i].luma_log2_weight_denom);
- strRes.AppendFormat(_T("%d,"), pSlice[i].chroma_log2_weight_denom);
- strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l0_active_minus1);
- strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l1_active_minus1);
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_alpha_c0_offset_div2);
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_beta_offset_div2);
- strRes.AppendFormat(_T("%d,"), pSlice[i].Reserved8Bits);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qs_delta);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qp_delta);
- strRes.AppendFormat(_T("%d,"), pSlice[i].redundant_pic_cnt);
- strRes.AppendFormat(_T("%d,"), pSlice[i].direct_spatial_mv_pred_flag);
- strRes.AppendFormat(_T("%d,"), pSlice[i].cabac_init_idc);
- strRes.AppendFormat(_T("%d,"), pSlice[i].disable_deblocking_filter_idc);
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_id);
-
- for(int a = 0; a < 2; a++) /* L0 & L1 */
- {
- for(int b = 0; b < 32; b++)
- {
- strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].AssociatedFlag);
- strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].bPicEntry);
- strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].Index7Bits);
- }
- }
-
- for(int a = 0; a < 2; a++) /* L0 & L1; Y, Cb, Cr */
- {
- for(int b = 0; b < 32; b++)
- {
- for(int c = 0; c < 3; c++)
- {
- for(int d = 0; d < 2; d++)
- {
- strRes.AppendFormat(_T("%d,"), pSlice[i].Weights[a][b][c][d]);
- }
- }
- }
- }
-
- LOG_TOFILE(_T("slicelong.log"), strRes);
- strRes = "";
- }
+ static bool bFirstSlice = true;
+ CString strRes;
+
+ if (bFirstSlice)
+ {
+ strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping,") \
+ _T("first_mb_in_slice, NumMbsForSlice, BitOffsetToSliceData, slice_type,luma_log2_weight_denom,chroma_log2_weight_denom,") \
+ _T("num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,slice_alpha_c0_offset_div2,slice_beta_offset_div2,") \
+ _T("Reserved8Bits,slice_qs_delta,slice_qp_delta,redundant_pic_cnt,direct_spatial_mv_pred_flag,cabac_init_idc,") \
+ _T("disable_deblocking_filter_idc,slice_id,");
+
+ for (int i=0; i<2; i++) /* L0 & L1 */
+ {
+ for (int j=0; j<32; j++)
+ {
+ strRes.AppendFormat(_T("R[%d][%d].AssociatedFlag,"), i, j);
+ strRes.AppendFormat(_T("R[%d][%d].bPicEntry,"), i, j);
+ strRes.AppendFormat(_T("R[%d][%d].Index7Bits,"), i, j);
+ }
+ }
+
+ for (int a=0; a<2; a++) /* L0 & L1; Y, Cb, Cr */
+ {
+ for (int b=0; b<32; b++)
+ {
+ for (int c=0; c<3; c++)
+ {
+ for (int d=0; d<2; d++)
+ {
+ strRes.AppendFormat(_T("W[%d][%d][%d][%d],"), a,b,c,d);
+ }
+ }
+ }
+ }
+
+
+ LOG_TOFILE (_T("slicelong.log"), strRes);
+ strRes = "";
+ }
+ bFirstSlice = false;
+
+ for (int i=0; i<nCount; i++)
+ {
+ strRes.AppendFormat(_T("%d,"), i);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wBadSliceChopping);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].first_mb_in_slice);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].NumMbsForSlice);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].BitOffsetToSliceData);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_type);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].luma_log2_weight_denom);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].chroma_log2_weight_denom);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l0_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l1_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_alpha_c0_offset_div2);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_beta_offset_div2);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].Reserved8Bits);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qs_delta);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qp_delta);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].redundant_pic_cnt);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].direct_spatial_mv_pred_flag);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].cabac_init_idc);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].disable_deblocking_filter_idc);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_id);
+
+ for (int a=0; a<2; a++) /* L0 & L1 */
+ {
+ for (int b=0; b<32; b++)
+ {
+ strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].AssociatedFlag);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].bPicEntry);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].Index7Bits);
+ }
+ }
+
+ for (int a=0; a<2; a++) /* L0 & L1; Y, Cb, Cr */
+ {
+ for (int b=0; b<32; b++)
+ {
+ for (int c=0; c<3; c++)
+ {
+ for (int d=0; d<2; d++)
+ {
+ strRes.AppendFormat(_T("%d,"), pSlice[i].Weights[a][b][c][d]);
+ }
+ }
+ }
+ }
+
+ LOG_TOFILE (_T("slicelong.log"), strRes);
+ strRes = "";
+ }
}
-static void LogDXVA_PictureParameters(DXVA_PictureParameters* pPic)
+static void LogDXVA_PictureParameters (DXVA_PictureParameters* pPic)
{
- static bool bFirstPictureParam = true;
- CString strRes;
-
- if(bFirstPictureParam)
- LOG_TOFILE(_T("picture.log"), _T("wDecodedPictureIndex,wDeblockedPictureIndex,wForwardRefPictureIndex,wBackwardRefPictureIndex,wPicWidthInMBminus1,wPicHeightInMBminus1,bMacroblockWidthMinus1,bMacroblockHeightMinus1,bBlockWidthMinus1,bBlockHeightMinus1,bBPPminus1,bPicStructure,bSecondField,bPicIntra,bPicBackwardPrediction,bBidirectionalAveragingMode,bMVprecisionAndChromaRelation,bChromaFormat,bPicScanFixed,bPicScanMethod,bPicReadbackRequests,bRcontrol,bPicSpatialResid8,bPicOverflowBlocks,bPicExtrapolation,bPicDeblocked,bPicDeblockConfined,bPic4MVallowed,bPicOBMC,bPicBinPB,bMV_RPS,bReservedBits,wBitstreamFcodes,wBitstreamPCEelements,bBitstreamConcealmentNeed,bBitstreamConcealmentMethod"));
- bFirstPictureParam = false;
-
- strRes.Format(_T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"),
- pPic->wDecodedPictureIndex,
- pPic->wDeblockedPictureIndex,
- pPic->wForwardRefPictureIndex,
- pPic->wBackwardRefPictureIndex,
- pPic->wPicWidthInMBminus1,
- pPic->wPicHeightInMBminus1,
- pPic->bMacroblockWidthMinus1,
- pPic->bMacroblockHeightMinus1,
- pPic->bBlockWidthMinus1,
- pPic->bBlockHeightMinus1,
- pPic->bBPPminus1,
- pPic->bPicStructure,
- pPic->bSecondField,
- pPic->bPicIntra,
- pPic->bPicBackwardPrediction,
- pPic->bBidirectionalAveragingMode,
- pPic->bMVprecisionAndChromaRelation,
- pPic->bChromaFormat,
- pPic->bPicScanFixed,
- pPic->bPicScanMethod,
- pPic->bPicReadbackRequests,
- pPic->bRcontrol,
- pPic->bPicSpatialResid8,
- pPic->bPicOverflowBlocks,
- pPic->bPicExtrapolation,
- pPic->bPicDeblocked,
- pPic->bPicDeblockConfined,
- pPic->bPic4MVallowed,
- pPic->bPicOBMC,
- pPic->bPicBinPB,
- pPic->bMV_RPS,
- pPic->bReservedBits,
- pPic->wBitstreamFcodes,
- pPic->wBitstreamPCEelements,
- pPic->bBitstreamConcealmentNeed,
- pPic->bBitstreamConcealmentMethod);
-
- LOG_TOFILE(_T("picture.log"), strRes);
+ static bool bFirstPictureParam = true;
+ CString strRes;
+
+ if (bFirstPictureParam)
+ LOG_TOFILE (_T("picture.log"), _T("wDecodedPictureIndex,wDeblockedPictureIndex,wForwardRefPictureIndex,wBackwardRefPictureIndex,wPicWidthInMBminus1,wPicHeightInMBminus1,bMacroblockWidthMinus1,bMacroblockHeightMinus1,bBlockWidthMinus1,bBlockHeightMinus1,bBPPminus1,bPicStructure,bSecondField,bPicIntra,bPicBackwardPrediction,bBidirectionalAveragingMode,bMVprecisionAndChromaRelation,bChromaFormat,bPicScanFixed,bPicScanMethod,bPicReadbackRequests,bRcontrol,bPicSpatialResid8,bPicOverflowBlocks,bPicExtrapolation,bPicDeblocked,bPicDeblockConfined,bPic4MVallowed,bPicOBMC,bPicBinPB,bMV_RPS,bReservedBits,wBitstreamFcodes,wBitstreamPCEelements,bBitstreamConcealmentNeed,bBitstreamConcealmentMethod"));
+ bFirstPictureParam = false;
+
+ strRes.Format (_T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"),
+ pPic->wDecodedPictureIndex,
+ pPic->wDeblockedPictureIndex,
+ pPic->wForwardRefPictureIndex,
+ pPic->wBackwardRefPictureIndex,
+ pPic->wPicWidthInMBminus1,
+ pPic->wPicHeightInMBminus1,
+ pPic->bMacroblockWidthMinus1,
+ pPic->bMacroblockHeightMinus1,
+ pPic->bBlockWidthMinus1,
+ pPic->bBlockHeightMinus1,
+ pPic->bBPPminus1,
+ pPic->bPicStructure,
+ pPic->bSecondField,
+ pPic->bPicIntra,
+ pPic->bPicBackwardPrediction,
+ pPic->bBidirectionalAveragingMode,
+ pPic->bMVprecisionAndChromaRelation,
+ pPic->bChromaFormat,
+ pPic->bPicScanFixed,
+ pPic->bPicScanMethod,
+ pPic->bPicReadbackRequests,
+ pPic->bRcontrol,
+ pPic->bPicSpatialResid8,
+ pPic->bPicOverflowBlocks,
+ pPic->bPicExtrapolation,
+ pPic->bPicDeblocked,
+ pPic->bPicDeblockConfined,
+ pPic->bPic4MVallowed,
+ pPic->bPicOBMC,
+ pPic->bPicBinPB,
+ pPic->bMV_RPS,
+ pPic->bReservedBits,
+ pPic->wBitstreamFcodes,
+ pPic->wBitstreamPCEelements,
+ pPic->bBitstreamConcealmentNeed,
+ pPic->bBitstreamConcealmentMethod);
+
+ LOG_TOFILE (_T("picture.log"), strRes);
}
void LogDXVA_Bitstream(BYTE* pBuffer, int nSize)
{
- CString strRes;
- static bool bFirstBitstream = true;
-
- if(bFirstBitstream)
- LOG_TOFILE(_T("bitstream.log"), _T("Size,Start, Stop"));
- bFirstBitstream = false;
-
- strRes.Format(_T("%d, -"), nSize);
-
- for(int i = 0; i < 20; i++)
- {
- if(i < nSize)
- strRes.AppendFormat(_T(" %02x"), pBuffer[i]);
- else
- strRes.Append(_T(" --"));
- }
-
- strRes.Append(_T(", -"), nSize);
- for(int i = 0; i < 20; i++)
- {
- if(nSize - i >= 0)
- strRes.AppendFormat(_T(" %02x"), pBuffer[i]);
- else
- strRes.Append(_T(" --"));
- }
-
- LOG_TOFILE(_T("bitstream.log"), strRes);
+ CString strRes;
+ static bool bFirstBitstream = true;
+
+ if (bFirstBitstream)
+ LOG_TOFILE (_T("bitstream.log"), _T("Size,Start, Stop"));
+ bFirstBitstream = false;
+
+ strRes.Format (_T("%d, -"), nSize);
+
+ for (int i=0; i<20; i++)
+ {
+ if (i < nSize)
+ strRes.AppendFormat (_T(" %02x"), pBuffer[i]);
+ else
+ strRes.Append(_T(" --"));
+ }
+
+ strRes.Append (_T(", -"), nSize);
+ for (int i=0; i<20; i++)
+ {
+ if (nSize-i >= 0)
+ strRes.AppendFormat (_T(" %02x"), pBuffer[i]);
+ else
+ strRes.Append(_T(" --"));
+ }
+
+ LOG_TOFILE (_T("bitstream.log"), strRes);
}
@@ -699,8 +699,8 @@ void LogDXVA_Bitstream(BYTE* pBuffer, int nSize)
inline static void LOG(...) { }
inline static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n) {}
inline static void LOGUDI(LPCTSTR prefix, const AMVAUncompDataInfo* p, int n) {}
-inline static void LogDXVA_PicParams_H264(DXVA_PicParams_H264* pPic) {}
-inline static void LogDXVA_PictureParameters(DXVA_PictureParameters* pPic) {}
+inline static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic) {}
+inline static void LogDXVA_PictureParameters (DXVA_PictureParameters* pPic) {}
inline static void LogDXVA_Bitstream(BYTE* pBuffer, int nSize) {}
#endif
@@ -708,392 +708,392 @@ inline static void LogDXVA_Bitstream(BYTE* pBuffer, int nSize) {}
static HRESULT STDMETHODCALLTYPE GetVideoAcceleratorGUIDsMine(IAMVideoAcceleratorC * This, LPDWORD pdwNumGuidsSupported, LPGUID pGuidsSupported)
{
- LOG(_T("\nGetVideoAcceleratorGUIDs"));
+ LOG(_T("\nGetVideoAcceleratorGUIDs"));
- if(pdwNumGuidsSupported)
- {
- LOG(_T("[in] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
- }
+ if(pdwNumGuidsSupported)
+ {
+ LOG(_T("[in] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
+ }
- HRESULT hr = GetVideoAcceleratorGUIDsOrg(This, pdwNumGuidsSupported, pGuidsSupported);
+ HRESULT hr = GetVideoAcceleratorGUIDsOrg(This, pdwNumGuidsSupported, pGuidsSupported);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- if(pdwNumGuidsSupported)
- {
- LOG(_T("[out] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
+ if(pdwNumGuidsSupported)
+ {
+ LOG(_T("[out] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
- if(pGuidsSupported)
- {
- for(DWORD i = 0; i < *pdwNumGuidsSupported; i++)
- {
- LOG(_T("[out] pGuidsSupported[%d] = %s"), i, CStringFromGUID(pGuidsSupported[i]));
- }
- }
- }
+ if(pGuidsSupported)
+ {
+ for(DWORD i = 0; i < *pdwNumGuidsSupported; i++)
+ {
+ LOG(_T("[out] pGuidsSupported[%d] = %s"), i, CStringFromGUID(pGuidsSupported[i]));
+ }
+ }
+ }
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE GetUncompFormatsSupportedMine(IAMVideoAcceleratorC * This, const GUID *pGuid, LPDWORD pdwNumFormatsSupported, LPDDPIXELFORMAT pFormatsSupported)
{
- LOG(_T("\nGetUncompFormatsSupported"));
+ LOG(_T("\nGetUncompFormatsSupported"));
- if(pGuid)
- {
- LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
- }
+ if(pGuid)
+ {
+ LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
+ }
- if(pdwNumFormatsSupported)
- {
- LOG(_T("[in] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
- }
+ if(pdwNumFormatsSupported)
+ {
+ LOG(_T("[in] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
+ }
- HRESULT hr = GetUncompFormatsSupportedOrg(This, pGuid, pdwNumFormatsSupported, pFormatsSupported);
+ HRESULT hr = GetUncompFormatsSupportedOrg(This, pGuid, pdwNumFormatsSupported, pFormatsSupported);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- if(pdwNumFormatsSupported)
- {
- LOG(_T("[out] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
+ if(pdwNumFormatsSupported)
+ {
+ LOG(_T("[out] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
- if(pFormatsSupported)
- {
- LOGPF(_T("[out] pFormatsSupported"), pFormatsSupported, *pdwNumFormatsSupported);
- }
- }
+ if(pFormatsSupported)
+ {
+ LOGPF(_T("[out] pFormatsSupported"), pFormatsSupported, *pdwNumFormatsSupported);
+ }
+ }
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE GetInternalMemInfoMine(IAMVideoAcceleratorC * This, const GUID *pGuid, const AMVAUncompDataInfo *pamvaUncompDataInfo, LPAMVAInternalMemInfo pamvaInternalMemInfo)
{
- LOG(_T("\nGetInternalMemInfo"));
+ LOG(_T("\nGetInternalMemInfo"));
- HRESULT hr = GetInternalMemInfoOrg(This, pGuid, pamvaUncompDataInfo, pamvaInternalMemInfo);
+ HRESULT hr = GetInternalMemInfoOrg(This, pGuid, pamvaUncompDataInfo, pamvaInternalMemInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE GetCompBufferInfoMine(IAMVideoAcceleratorC * This, const GUID *pGuid, const AMVAUncompDataInfo *pamvaUncompDataInfo, LPDWORD pdwNumTypesCompBuffers, LPAMVACompBufferInfo pamvaCompBufferInfo)
{
- LOG(_T("\nGetCompBufferInfo"));
+ LOG(_T("\nGetCompBufferInfo"));
- if(pGuid)
- {
- g_guidDXVADecoder = *pGuid;
- g_nDXVAVersion = 1;
- LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
+ if(pGuid)
+ {
+ g_guidDXVADecoder = *pGuid;
+ g_nDXVAVersion = 1;
+ LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
- if(pdwNumTypesCompBuffers)
- {
- LOG(_T("[in] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
- }
- }
+ if(pdwNumTypesCompBuffers)
+ {
+ LOG(_T("[in] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
+ }
+ }
- HRESULT hr = GetCompBufferInfoOrg(This, pGuid, pamvaUncompDataInfo, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
+ HRESULT hr = GetCompBufferInfoOrg(This, pGuid, pamvaUncompDataInfo, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- //if(pdwNumTypesCompBuffers)
- //{
- // LOG(_T("[out] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
+ //if(pdwNumTypesCompBuffers)
+ //{
+ // LOG(_T("[out] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
- // if(pamvaUncompDataInfo)
- // {
- // LOGUDI(_T("[out] pamvaUncompDataInfo"), pamvaUncompDataInfo, *pdwNumTypesCompBuffers);
- // }
- //}
+ // if(pamvaUncompDataInfo)
+ // {
+ // LOGUDI(_T("[out] pamvaUncompDataInfo"), pamvaUncompDataInfo, *pdwNumTypesCompBuffers);
+ // }
+ //}
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE GetInternalCompBufferInfoMine(IAMVideoAcceleratorC * This, LPDWORD pdwNumTypesCompBuffers, LPAMVACompBufferInfo pamvaCompBufferInfo)
{
- LOG(_T("\nGetInternalCompBufferInfo"));
+ LOG(_T("\nGetInternalCompBufferInfo"));
- HRESULT hr = GetInternalCompBufferInfoOrg(This, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
+ HRESULT hr = GetInternalCompBufferInfoOrg(This, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE BeginFrameMine(IAMVideoAcceleratorC * This, const AMVABeginFrameInfo *amvaBeginFrameInfo)
{
- LOG(_T("\nBeginFrame"));
+ LOG(_T("\nBeginFrame"));
- if(amvaBeginFrameInfo)
- {
- LOG(_T("[in] amvaBeginFrameInfo->dwDestSurfaceIndex = %08x"), amvaBeginFrameInfo->dwDestSurfaceIndex);
- LOG(_T("[in] amvaBeginFrameInfo->pInputData = %08x"), amvaBeginFrameInfo->pInputData);
- LOG(_T("[in] amvaBeginFrameInfo->dwSizeInputData = %08x"), amvaBeginFrameInfo->dwSizeInputData);
- LOG(_T("[in] amvaBeginFrameInfo->pOutputData = %08x"), amvaBeginFrameInfo->pOutputData);
- LOG(_T("[in] amvaBeginFrameInfo->dwSizeOutputData = %08x"), amvaBeginFrameInfo->dwSizeOutputData);
- }
- if(amvaBeginFrameInfo && (amvaBeginFrameInfo->dwSizeInputData == 4))
- {
- LOG(_T("[in] amvaBeginFrameInfo->pInputData => dwDestSurfaceIndex = %ld "),
- ((DWORD*)amvaBeginFrameInfo->pInputData)[0]);
- }
+ if(amvaBeginFrameInfo)
+ {
+ LOG(_T("[in] amvaBeginFrameInfo->dwDestSurfaceIndex = %08x"), amvaBeginFrameInfo->dwDestSurfaceIndex);
+ LOG(_T("[in] amvaBeginFrameInfo->pInputData = %08x"), amvaBeginFrameInfo->pInputData);
+ LOG(_T("[in] amvaBeginFrameInfo->dwSizeInputData = %08x"), amvaBeginFrameInfo->dwSizeInputData);
+ LOG(_T("[in] amvaBeginFrameInfo->pOutputData = %08x"), amvaBeginFrameInfo->pOutputData);
+ LOG(_T("[in] amvaBeginFrameInfo->dwSizeOutputData = %08x"), amvaBeginFrameInfo->dwSizeOutputData);
+ }
+ if(amvaBeginFrameInfo && (amvaBeginFrameInfo->dwSizeInputData == 4))
+ {
+ LOG(_T("[in] amvaBeginFrameInfo->pInputData => dwDestSurfaceIndex = %ld "),
+ ((DWORD*)amvaBeginFrameInfo->pInputData)[0]);
+ }
- HRESULT hr = BeginFrameOrg(This, amvaBeginFrameInfo);
+ HRESULT hr = BeginFrameOrg(This, amvaBeginFrameInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
-
+
static HRESULT STDMETHODCALLTYPE EndFrameMine(IAMVideoAcceleratorC * This, const AMVAEndFrameInfo *pEndFrameInfo)
{
- LOG(_T("\nEndFrame"));
+ LOG(_T("\nEndFrame"));
- if(pEndFrameInfo)
- {
- LOG(_T("[in] pEndFrameInfo->dwSizeMiscData = %08x"), pEndFrameInfo->dwSizeMiscData);
- LOG(_T("[in] pEndFrameInfo->pMiscData = %08x"), pEndFrameInfo->pMiscData);
+ if(pEndFrameInfo)
+ {
+ LOG(_T("[in] pEndFrameInfo->dwSizeMiscData = %08x"), pEndFrameInfo->dwSizeMiscData);
+ LOG(_T("[in] pEndFrameInfo->pMiscData = %08x"), pEndFrameInfo->pMiscData);
- if(pEndFrameInfo->dwSizeMiscData >= 4)
- LOG(_T("[out] pEndFrameInfo->pMiscData = %02x %02x %02x %02x "),
- ((BYTE*)pEndFrameInfo->pMiscData)[0],
- ((BYTE*)pEndFrameInfo->pMiscData)[1],
- ((BYTE*)pEndFrameInfo->pMiscData)[2],
- ((BYTE*)pEndFrameInfo->pMiscData)[3]);
+ if (pEndFrameInfo->dwSizeMiscData >= 4)
+ LOG(_T("[out] pEndFrameInfo->pMiscData = %02x %02x %02x %02x "),
+ ((BYTE*)pEndFrameInfo->pMiscData)[0],
+ ((BYTE*)pEndFrameInfo->pMiscData)[1],
+ ((BYTE*)pEndFrameInfo->pMiscData)[2],
+ ((BYTE*)pEndFrameInfo->pMiscData)[3]);
- }
+ }
- HRESULT hr = EndFrameOrg(This, pEndFrameInfo);
+ HRESULT hr = EndFrameOrg(This, pEndFrameInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE GetBufferMine(IAMVideoAcceleratorC * This, DWORD dwTypeIndex, DWORD dwBufferIndex, BOOL bReadOnly, LPVOID *ppBuffer, LONG *lpStride)
{
- HRESULT hr = GetBufferOrg(This, dwTypeIndex, dwBufferIndex, bReadOnly, ppBuffer, lpStride);
+ HRESULT hr = GetBufferOrg(This, dwTypeIndex, dwBufferIndex, bReadOnly, ppBuffer, lpStride);
- LOG(_T("\nGetBuffer"));
+ LOG(_T("\nGetBuffer"));
- LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
- LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
- LOG(_T("[in] bReadOnly = %08x"), bReadOnly);
- LOG(_T("[in] ppBuffer = %08x"), ppBuffer);
- LOG(_T("[out] *lpStride = %08x"), *lpStride);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
+ LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
+ LOG(_T("[in] bReadOnly = %08x"), bReadOnly);
+ LOG(_T("[in] ppBuffer = %08x"), ppBuffer);
+ LOG(_T("[out] *lpStride = %08x"), *lpStride);
+ LOG(_T("hr = %08x"), hr);
- g_ppBuffer [dwTypeIndex] = (BYTE*) * ppBuffer;
- //LOG(_T("[out] *ppBuffer = %02x %02x %02x %02x ..."), ((BYTE*)*ppBuffer)[0], ((BYTE*)*ppBuffer)[1], ((BYTE*)*ppBuffer)[2], ((BYTE*)*ppBuffer)[3]);
+ g_ppBuffer [dwTypeIndex] = (BYTE*)*ppBuffer;
+ //LOG(_T("[out] *ppBuffer = %02x %02x %02x %02x ..."), ((BYTE*)*ppBuffer)[0], ((BYTE*)*ppBuffer)[1], ((BYTE*)*ppBuffer)[2], ((BYTE*)*ppBuffer)[3]);
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE ReleaseBufferMine(IAMVideoAcceleratorC * This, DWORD dwTypeIndex, DWORD dwBufferIndex)
{
- LOG(_T("\nReleaseBuffer"));
+ LOG(_T("\nReleaseBuffer"));
- LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
- LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
+ LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
+ LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
- HRESULT hr = ReleaseBufferOrg(This, dwTypeIndex, dwBufferIndex);
+ HRESULT hr = ReleaseBufferOrg(This, dwTypeIndex, dwBufferIndex);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD dwFunction, LPVOID lpPrivateInputData, DWORD cbPrivateInputData,
- LPVOID lpPrivateOutputData, DWORD cbPrivateOutputData, DWORD dwNumBuffers, const AMVABUFFERINFO *pamvaBufferInfo)
+ LPVOID lpPrivateOutputData, DWORD cbPrivateOutputData, DWORD dwNumBuffers, const AMVABUFFERINFO *pamvaBufferInfo)
{
#ifdef _DEBUG
- LOG(_T("\nExecute"));
- LOG(_T("[in] dwFunction = %08x"), dwFunction);
- if(lpPrivateInputData)
- {
- if(dwFunction == 0x01000000)
- {
- DXVA_BufferDescription* pBuffDesc = (DXVA_BufferDescription*)lpPrivateInputData;
-
- for(DWORD i = 0; i < dwNumBuffers; i++)
- {
- LOG(_T("[in] lpPrivateInputData, buffer description %d"), i);
- LOG(_T(" pBuffDesc->dwTypeIndex = %d"), pBuffDesc[i].dwTypeIndex);
- LOG(_T(" pBuffDesc->dwBufferIndex = %d"), pBuffDesc[i].dwBufferIndex);
- LOG(_T(" pBuffDesc->dwDataOffset = %d"), pBuffDesc[i].dwDataOffset);
- LOG(_T(" pBuffDesc->dwDataSize = %d"), pBuffDesc[i].dwDataSize);
- LOG(_T(" pBuffDesc->dwFirstMBaddress = %d"), pBuffDesc[i].dwFirstMBaddress);
- LOG(_T(" pBuffDesc->dwHeight = %d"), pBuffDesc[i].dwHeight);
- LOG(_T(" pBuffDesc->dwStride = %d"), pBuffDesc[i].dwStride);
- LOG(_T(" pBuffDesc->dwWidth = %d"), pBuffDesc[i].dwWidth);
- LOG(_T(" pBuffDesc->dwNumMBsInBuffer = %d"), pBuffDesc[i].dwNumMBsInBuffer);
- LOG(_T(" pBuffDesc->dwReservedBits = %d"), pBuffDesc[i].dwReservedBits);
- }
- }
- else if((dwFunction == 0xfffff101) || (dwFunction == 0xfffff501))
- {
- DXVA_ConfigPictureDecode* ConfigRequested = (DXVA_ConfigPictureDecode*)lpPrivateInputData;
- LOG(_T("[in] lpPrivateInputData, config requested"));
- LOG(_T(" pBuffDesc->dwTypeIndex = %d"), ConfigRequested->bConfig4GroupedCoefs);
- LOG(_T(" ConfigRequested->bConfigBitstreamRaw = %d"), ConfigRequested->bConfigBitstreamRaw);
- LOG(_T(" ConfigRequested->bConfigHostInverseScan = %d"), ConfigRequested->bConfigHostInverseScan);
- LOG(_T(" ConfigRequested->bConfigIntraResidUnsigned = %d"), ConfigRequested->bConfigIntraResidUnsigned);
- LOG(_T(" ConfigRequested->bConfigMBcontrolRasterOrder = %d"), ConfigRequested->bConfigMBcontrolRasterOrder);
- LOG(_T(" ConfigRequested->bConfigResid8Subtraction = %d"), ConfigRequested->bConfigResid8Subtraction);
- LOG(_T(" ConfigRequested->bConfigResidDiffAccelerator = %d"), ConfigRequested->bConfigResidDiffAccelerator);
- LOG(_T(" ConfigRequested->bConfigResidDiffHost = %d"), ConfigRequested->bConfigResidDiffHost);
- LOG(_T(" ConfigRequested->bConfigSpatialHost8or9Clipping= %d"), ConfigRequested->bConfigSpatialHost8or9Clipping);
- LOG(_T(" ConfigRequested->bConfigSpatialResid8 = %d"), ConfigRequested->bConfigSpatialResid8);
- LOG(_T(" ConfigRequested->bConfigSpatialResidInterleaved= %d"), ConfigRequested->bConfigSpatialResidInterleaved);
- LOG(_T(" ConfigRequested->bConfigSpecificIDCT = %d"), ConfigRequested->bConfigSpecificIDCT);
- LOG(_T(" ConfigRequested->dwFunction = %d"), ConfigRequested->dwFunction);
- LOG(_T(" ConfigRequested->guidConfigBitstreamEncryption = %s"), CStringFromGUID(ConfigRequested->guidConfigBitstreamEncryption));
- LOG(_T(" ConfigRequested->guidConfigMBcontrolEncryption = %s"), CStringFromGUID(ConfigRequested->guidConfigMBcontrolEncryption));
- LOG(_T(" ConfigRequested->guidConfigResidDiffEncryption = %s"), CStringFromGUID(ConfigRequested->guidConfigResidDiffEncryption));
- }
- else
- LOG(_T("[in] lpPrivateInputData = %02x %02x %02x %02x ..."),
- ((BYTE*)lpPrivateInputData)[0],
- ((BYTE*)lpPrivateInputData)[1],
- ((BYTE*)lpPrivateInputData)[2],
- ((BYTE*)lpPrivateInputData)[3]);
- }
- LOG(_T("[in] cbPrivateInputData = %08x"), cbPrivateInputData);
- LOG(_T("[in] lpPrivateOutputData = %08x"), lpPrivateOutputData);
- LOG(_T("[in] cbPrivateOutputData = %08x"), cbPrivateOutputData);
- LOG(_T("[in] dwNumBuffers = %08x"), dwNumBuffers);
- if(pamvaBufferInfo)
- {
- for(DWORD i = 0; i < dwNumBuffers; i++)
- {
- LOG(_T("[in] pamvaBufferInfo, buffer description %d"), i);
- LOG(_T("[in] pamvaBufferInfo->dwTypeIndex = %08x"), pamvaBufferInfo[i].dwTypeIndex);
- LOG(_T("[in] pamvaBufferInfo->dwBufferIndex = %08x"), pamvaBufferInfo[i].dwBufferIndex);
- LOG(_T("[in] pamvaBufferInfo->dwDataOffset = %08x"), pamvaBufferInfo[i].dwDataOffset);
- LOG(_T("[in] pamvaBufferInfo->dwDataSize = %08x"), pamvaBufferInfo[i].dwDataSize);
- }
- }
-
-
- for(DWORD i = 0; i < dwNumBuffers; i++)
- {
- if(pamvaBufferInfo[i].dwTypeIndex == DXVA_PICTURE_DECODE_BUFFER)
- {
- if(g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo)
- LogDXVA_PicParams_H264((DXVA_PicParams_H264*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
- else if(g_guidDXVADecoder == DXVA2_ModeVC1_D)
- LogDXVA_PictureParameters((DXVA_PictureParameters*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
- }
- else if(pamvaBufferInfo[i].dwTypeIndex == DXVA_SLICE_CONTROL_BUFFER && (pamvaBufferInfo[i].dwDataSize % sizeof(DXVA_Slice_H264_Short)) == 0)
- {
- for(WORD j = 0; j < pamvaBufferInfo[i].dwDataSize / sizeof(DXVA_Slice_H264_Short); j++)
- {
- DXVA_Slice_H264_Short* pSlice = &(((DXVA_Slice_H264_Short*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex])[j]);
- LOG(_T(" - BSNALunitDataLocation %d"), pSlice->BSNALunitDataLocation);
- LOG(_T(" - SliceBytesInBuffer %d"), pSlice->SliceBytesInBuffer);
- LOG(_T(" - wBadSliceChopping %d"), pSlice->wBadSliceChopping);
- }
- }
- else if(pamvaBufferInfo[i].dwTypeIndex == DXVA_BITSTREAM_DATA_BUFFER)
- {
-
- LogDXVA_Bitstream(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex], pamvaBufferInfo[i].dwDataSize);
+ LOG(_T("\nExecute"));
+ LOG(_T("[in] dwFunction = %08x"), dwFunction);
+ if(lpPrivateInputData)
+ {
+ if (dwFunction == 0x01000000)
+ {
+ DXVA_BufferDescription* pBuffDesc = (DXVA_BufferDescription*)lpPrivateInputData;
+
+ for (DWORD i=0; i<dwNumBuffers; i++)
+ {
+ LOG(_T("[in] lpPrivateInputData, buffer description %d"), i);
+ LOG(_T(" pBuffDesc->dwTypeIndex = %d"), pBuffDesc[i].dwTypeIndex);
+ LOG(_T(" pBuffDesc->dwBufferIndex = %d"), pBuffDesc[i].dwBufferIndex);
+ LOG(_T(" pBuffDesc->dwDataOffset = %d"), pBuffDesc[i].dwDataOffset);
+ LOG(_T(" pBuffDesc->dwDataSize = %d"), pBuffDesc[i].dwDataSize);
+ LOG(_T(" pBuffDesc->dwFirstMBaddress = %d"), pBuffDesc[i].dwFirstMBaddress);
+ LOG(_T(" pBuffDesc->dwHeight = %d"), pBuffDesc[i].dwHeight);
+ LOG(_T(" pBuffDesc->dwStride = %d"), pBuffDesc[i].dwStride);
+ LOG(_T(" pBuffDesc->dwWidth = %d"), pBuffDesc[i].dwWidth);
+ LOG(_T(" pBuffDesc->dwNumMBsInBuffer = %d"), pBuffDesc[i].dwNumMBsInBuffer);
+ LOG(_T(" pBuffDesc->dwReservedBits = %d"), pBuffDesc[i].dwReservedBits);
+ }
+ }
+ else if ((dwFunction == 0xfffff101) || (dwFunction == 0xfffff501))
+ {
+ DXVA_ConfigPictureDecode* ConfigRequested = (DXVA_ConfigPictureDecode*)lpPrivateInputData;
+ LOG(_T("[in] lpPrivateInputData, config requested"));
+ LOG(_T(" pBuffDesc->dwTypeIndex = %d"), ConfigRequested->bConfig4GroupedCoefs);
+ LOG(_T(" ConfigRequested->bConfigBitstreamRaw = %d"), ConfigRequested->bConfigBitstreamRaw);
+ LOG(_T(" ConfigRequested->bConfigHostInverseScan = %d"), ConfigRequested->bConfigHostInverseScan);
+ LOG(_T(" ConfigRequested->bConfigIntraResidUnsigned = %d"), ConfigRequested->bConfigIntraResidUnsigned);
+ LOG(_T(" ConfigRequested->bConfigMBcontrolRasterOrder = %d"), ConfigRequested->bConfigMBcontrolRasterOrder);
+ LOG(_T(" ConfigRequested->bConfigResid8Subtraction = %d"), ConfigRequested->bConfigResid8Subtraction);
+ LOG(_T(" ConfigRequested->bConfigResidDiffAccelerator = %d"), ConfigRequested->bConfigResidDiffAccelerator);
+ LOG(_T(" ConfigRequested->bConfigResidDiffHost = %d"), ConfigRequested->bConfigResidDiffHost);
+ LOG(_T(" ConfigRequested->bConfigSpatialHost8or9Clipping= %d"), ConfigRequested->bConfigSpatialHost8or9Clipping);
+ LOG(_T(" ConfigRequested->bConfigSpatialResid8 = %d"), ConfigRequested->bConfigSpatialResid8);
+ LOG(_T(" ConfigRequested->bConfigSpatialResidInterleaved= %d"), ConfigRequested->bConfigSpatialResidInterleaved);
+ LOG(_T(" ConfigRequested->bConfigSpecificIDCT = %d"), ConfigRequested->bConfigSpecificIDCT);
+ LOG(_T(" ConfigRequested->dwFunction = %d"), ConfigRequested->dwFunction);
+ LOG(_T(" ConfigRequested->guidConfigBitstreamEncryption = %s"), CStringFromGUID (ConfigRequested->guidConfigBitstreamEncryption));
+ LOG(_T(" ConfigRequested->guidConfigMBcontrolEncryption = %s"), CStringFromGUID (ConfigRequested->guidConfigMBcontrolEncryption));
+ LOG(_T(" ConfigRequested->guidConfigResidDiffEncryption = %s"), CStringFromGUID (ConfigRequested->guidConfigResidDiffEncryption));
+ }
+ else
+ LOG(_T("[in] lpPrivateInputData = %02x %02x %02x %02x ..."),
+ ((BYTE*)lpPrivateInputData)[0],
+ ((BYTE*)lpPrivateInputData)[1],
+ ((BYTE*)lpPrivateInputData)[2],
+ ((BYTE*)lpPrivateInputData)[3]);
+ }
+ LOG(_T("[in] cbPrivateInputData = %08x"), cbPrivateInputData);
+ LOG(_T("[in] lpPrivateOutputData = %08x"), lpPrivateOutputData);
+ LOG(_T("[in] cbPrivateOutputData = %08x"), cbPrivateOutputData);
+ LOG(_T("[in] dwNumBuffers = %08x"), dwNumBuffers);
+ if(pamvaBufferInfo)
+ {
+ for (DWORD i=0; i<dwNumBuffers; i++)
+ {
+ LOG(_T("[in] pamvaBufferInfo, buffer description %d"), i);
+ LOG(_T("[in] pamvaBufferInfo->dwTypeIndex = %08x"), pamvaBufferInfo[i].dwTypeIndex);
+ LOG(_T("[in] pamvaBufferInfo->dwBufferIndex = %08x"), pamvaBufferInfo[i].dwBufferIndex);
+ LOG(_T("[in] pamvaBufferInfo->dwDataOffset = %08x"), pamvaBufferInfo[i].dwDataOffset);
+ LOG(_T("[in] pamvaBufferInfo->dwDataSize = %08x"), pamvaBufferInfo[i].dwDataSize);
+ }
+ }
+
+
+ for (DWORD i=0; i<dwNumBuffers; i++)
+ {
+ if (pamvaBufferInfo[i].dwTypeIndex == DXVA_PICTURE_DECODE_BUFFER)
+ {
+ if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo)
+ LogDXVA_PicParams_H264 ((DXVA_PicParams_H264*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
+ else if (g_guidDXVADecoder == DXVA2_ModeVC1_D)
+ LogDXVA_PictureParameters((DXVA_PictureParameters*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
+ }
+ else if (pamvaBufferInfo[i].dwTypeIndex == DXVA_SLICE_CONTROL_BUFFER && (pamvaBufferInfo[i].dwDataSize % sizeof(DXVA_Slice_H264_Short)) == 0)
+ {
+ for (WORD j=0; j<pamvaBufferInfo[i].dwDataSize / sizeof(DXVA_Slice_H264_Short); j++)
+ {
+ DXVA_Slice_H264_Short* pSlice = &(((DXVA_Slice_H264_Short*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex])[j]);
+ LOG(_T(" - BSNALunitDataLocation %d"), pSlice->BSNALunitDataLocation);
+ LOG(_T(" - SliceBytesInBuffer %d"), pSlice->SliceBytesInBuffer);
+ LOG(_T(" - wBadSliceChopping %d"), pSlice->wBadSliceChopping);
+ }
+ }
+ else if (pamvaBufferInfo[i].dwTypeIndex == DXVA_BITSTREAM_DATA_BUFFER)
+ {
+
+ LogDXVA_Bitstream(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex], pamvaBufferInfo[i].dwDataSize);
#if defined(LOG_BITSTREAM) && defined(_DEBUG)
- char strFile[_MAX_PATH];
- static int nNb = 1;
- sprintf(strFile, "BitStream%d.bin", nNb++);
- FILE* hFile = fopen(strFile, "wb");
- if(hFile)
- {
- fwrite(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex],
- 1,
- pamvaBufferInfo[i].dwDataSize,
- hFile);
- fclose(hFile);
- }
+ char strFile[_MAX_PATH];
+ static int nNb = 1;
+ sprintf (strFile, "BitStream%d.bin", nNb++);
+ FILE* hFile = fopen (strFile, "wb");
+ if (hFile)
+ {
+ fwrite (g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex],
+ 1,
+ pamvaBufferInfo[i].dwDataSize,
+ hFile);
+ fclose (hFile);
+ }
#endif
- }
- }
+ }
+ }
#endif
- HRESULT hr = ExecuteOrg(This, dwFunction, lpPrivateInputData, cbPrivateInputData, lpPrivateOutputData, cbPrivateOutputData, dwNumBuffers, pamvaBufferInfo);
+ HRESULT hr = ExecuteOrg(This, dwFunction, lpPrivateInputData, cbPrivateInputData, lpPrivateOutputData, cbPrivateOutputData, dwNumBuffers, pamvaBufferInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- if(lpPrivateOutputData && (dwFunction == 0x01000000))
- {
- LOG(_T("[out] *lpPrivateOutputData : Result = %08x"), ((DWORD*)lpPrivateOutputData)[0]);
- }
+ if(lpPrivateOutputData && (dwFunction == 0x01000000))
+ {
+ LOG(_T("[out] *lpPrivateOutputData : Result = %08x"), ((DWORD*)lpPrivateOutputData)[0]);
+ }
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE QueryRenderStatusMine(IAMVideoAcceleratorC * This, DWORD dwTypeIndex, DWORD dwBufferIndex, DWORD dwFlags)
{
- HRESULT hr = QueryRenderStatusOrg(This, dwTypeIndex, dwBufferIndex, dwFlags);
- LOG(_T("\nQueryRenderStatus Type=%d Index=%d hr = %08x"), dwTypeIndex, dwBufferIndex, hr);
+ HRESULT hr = QueryRenderStatusOrg(This, dwTypeIndex, dwBufferIndex, dwFlags);
+ LOG(_T("\nQueryRenderStatus Type=%d Index=%d hr = %08x"), dwTypeIndex, dwBufferIndex, hr);
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE DisplayFrameMine(IAMVideoAcceleratorC * This, DWORD dwFlipToIndex, IMediaSample *pMediaSample)
{
- LOG(_T("\nEnter DisplayFrame : %d"), dwFlipToIndex);
+ LOG(_T("\nEnter DisplayFrame : %d"), dwFlipToIndex);
- HRESULT hr = DisplayFrameOrg(This, dwFlipToIndex, pMediaSample);
+ HRESULT hr = DisplayFrameOrg(This, dwFlipToIndex, pMediaSample);
- LOG(_T("Leave DisplayFrame : hr = %08x"), hr);
+ LOG(_T("Leave DisplayFrame : hr = %08x"), hr);
- return hr;
+ return hr;
}
void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC)
{
- BOOL res;
- DWORD flOldProtect = 0;
- res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_WRITECOPY, &flOldProtect);
-
- g_guidDXVADecoder = GUID_NULL;
- g_nDXVAVersion = 0;
-
- if(GetVideoAcceleratorGUIDsOrg == NULL) GetVideoAcceleratorGUIDsOrg = pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs;
- if(GetUncompFormatsSupportedOrg == NULL) GetUncompFormatsSupportedOrg = pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported;
- if(GetInternalMemInfoOrg == NULL) GetInternalMemInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo;
- if(GetCompBufferInfoOrg == NULL) GetCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo;
- if(GetInternalCompBufferInfoOrg == NULL) GetInternalCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo;
- if(BeginFrameOrg == NULL) BeginFrameOrg = pAMVideoAcceleratorC->lpVtbl->BeginFrame;
- if(EndFrameOrg == NULL) EndFrameOrg = pAMVideoAcceleratorC->lpVtbl->EndFrame;
- if(GetBufferOrg == NULL) GetBufferOrg = pAMVideoAcceleratorC->lpVtbl->GetBuffer;
- if(ReleaseBufferOrg == NULL) ReleaseBufferOrg = pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer;
- if(ExecuteOrg == NULL) ExecuteOrg = pAMVideoAcceleratorC->lpVtbl->Execute;
- if(QueryRenderStatusOrg == NULL) QueryRenderStatusOrg = pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus;
- if(DisplayFrameOrg == NULL) DisplayFrameOrg = pAMVideoAcceleratorC->lpVtbl->DisplayFrame;
-
- pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs = GetVideoAcceleratorGUIDsMine;
- pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported = GetUncompFormatsSupportedMine;
- pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo = GetInternalMemInfoMine;
- pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo = GetCompBufferInfoMine;
- pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo = GetInternalCompBufferInfoMine;
- pAMVideoAcceleratorC->lpVtbl->BeginFrame = BeginFrameMine;
- pAMVideoAcceleratorC->lpVtbl->EndFrame = EndFrameMine;
- pAMVideoAcceleratorC->lpVtbl->GetBuffer = GetBufferMine;
- pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer = ReleaseBufferMine;
- pAMVideoAcceleratorC->lpVtbl->Execute = ExecuteMine;
- pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus = QueryRenderStatusMine;
- pAMVideoAcceleratorC->lpVtbl->DisplayFrame = DisplayFrameMine;
-
- res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_EXECUTE, &flOldProtect);
+ BOOL res;
+ DWORD flOldProtect = 0;
+ res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_WRITECOPY, &flOldProtect);
+
+ g_guidDXVADecoder = GUID_NULL;
+ g_nDXVAVersion = 0;
+
+ if(GetVideoAcceleratorGUIDsOrg == NULL) GetVideoAcceleratorGUIDsOrg = pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs;
+ if(GetUncompFormatsSupportedOrg == NULL) GetUncompFormatsSupportedOrg = pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported;
+ if(GetInternalMemInfoOrg == NULL) GetInternalMemInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo;
+ if(GetCompBufferInfoOrg == NULL) GetCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo;
+ if(GetInternalCompBufferInfoOrg == NULL) GetInternalCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo;
+ if(BeginFrameOrg == NULL) BeginFrameOrg = pAMVideoAcceleratorC->lpVtbl->BeginFrame;
+ if(EndFrameOrg == NULL) EndFrameOrg = pAMVideoAcceleratorC->lpVtbl->EndFrame;
+ if(GetBufferOrg == NULL) GetBufferOrg = pAMVideoAcceleratorC->lpVtbl->GetBuffer;
+ if(ReleaseBufferOrg == NULL) ReleaseBufferOrg = pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer;
+ if(ExecuteOrg == NULL) ExecuteOrg = pAMVideoAcceleratorC->lpVtbl->Execute;
+ if(QueryRenderStatusOrg == NULL) QueryRenderStatusOrg = pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus;
+ if(DisplayFrameOrg == NULL) DisplayFrameOrg = pAMVideoAcceleratorC->lpVtbl->DisplayFrame;
+
+ pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs = GetVideoAcceleratorGUIDsMine;
+ pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported = GetUncompFormatsSupportedMine;
+ pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo = GetInternalMemInfoMine;
+ pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo = GetCompBufferInfoMine;
+ pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo = GetInternalCompBufferInfoMine;
+ pAMVideoAcceleratorC->lpVtbl->BeginFrame = BeginFrameMine;
+ pAMVideoAcceleratorC->lpVtbl->EndFrame = EndFrameMine;
+ pAMVideoAcceleratorC->lpVtbl->GetBuffer = GetBufferMine;
+ pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer = ReleaseBufferMine;
+ pAMVideoAcceleratorC->lpVtbl->Execute = ExecuteMine;
+ pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus = QueryRenderStatusMine;
+ pAMVideoAcceleratorC->lpVtbl->DisplayFrame = DisplayFrameMine;
+
+ res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_EXECUTE, &flOldProtect);
#ifdef _DEBUG
- ::DeleteFile(LOG_FILE);
- ::DeleteFile(_T("picture.log"));
- ::DeleteFile(_T("slicelong.log"));
- ::DeleteFile(_T("sliceshort.log"));
- ::DeleteFile(_T("bitstream.log"));
+ ::DeleteFile (LOG_FILE);
+ ::DeleteFile (_T("picture.log"));
+ ::DeleteFile (_T("slicelong.log"));
+ ::DeleteFile (_T("sliceshort.log"));
+ ::DeleteFile (_T("bitstream.log"));
#endif
}
@@ -1104,237 +1104,237 @@ void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC)
static void LogDecodeBufferDesc(DXVA2_DecodeBufferDesc* pDecodeBuff)
{
- LOG(_T("DecodeBufferDesc type : %d Size=%d NumMBsInBuffer=%d"), pDecodeBuff->CompressedBufferType, pDecodeBuff->DataSize, pDecodeBuff->NumMBsInBuffer);
- //LOG(_T(" - BufferIndex %d"), pDecodeBuff->BufferIndex);
- //LOG(_T(" - DataOffset %d"), pDecodeBuff->DataOffset);
- //LOG(_T(" - DataSize %d"), pDecodeBuff->DataSize);
- //LOG(_T(" - FirstMBaddress %d"), pDecodeBuff->FirstMBaddress);
- //LOG(_T(" - NumMBsInBuffer %d"), pDecodeBuff->NumMBsInBuffer);
- //LOG(_T(" - Width %d"), pDecodeBuff->Width);
- //LOG(_T(" - Height %d"), pDecodeBuff->Height);
- //LOG(_T(" - Stride %d"), pDecodeBuff->Stride);
- //LOG(_T(" - ReservedBits %d"), pDecodeBuff->ReservedBits);
- //LOG(_T(" - pvPVPState %d"), pDecodeBuff->pvPVPState);
+ LOG(_T("DecodeBufferDesc type : %d Size=%d NumMBsInBuffer=%d"), pDecodeBuff->CompressedBufferType, pDecodeBuff->DataSize, pDecodeBuff->NumMBsInBuffer);
+ //LOG(_T(" - BufferIndex %d"), pDecodeBuff->BufferIndex);
+ //LOG(_T(" - DataOffset %d"), pDecodeBuff->DataOffset);
+ //LOG(_T(" - DataSize %d"), pDecodeBuff->DataSize);
+ //LOG(_T(" - FirstMBaddress %d"), pDecodeBuff->FirstMBaddress);
+ //LOG(_T(" - NumMBsInBuffer %d"), pDecodeBuff->NumMBsInBuffer);
+ //LOG(_T(" - Width %d"), pDecodeBuff->Width);
+ //LOG(_T(" - Height %d"), pDecodeBuff->Height);
+ //LOG(_T(" - Stride %d"), pDecodeBuff->Stride);
+ //LOG(_T(" - ReservedBits %d"), pDecodeBuff->ReservedBits);
+ //LOG(_T(" - pvPVPState %d"), pDecodeBuff->pvPVPState);
}
-class CFakeDirectXVideoDecoder : public CUnknown, public IDirectXVideoDecoder
+class CFakeDirectXVideoDecoder : public CUnknown, public IDirectXVideoDecoder
{
private :
- CComPtr<IDirectXVideoDecoder> m_pDec;
- BYTE* m_ppBuffer[MAX_BUFFER_TYPE];
- UINT m_ppBufferLen[MAX_BUFFER_TYPE];
+ CComPtr<IDirectXVideoDecoder> m_pDec;
+ BYTE* m_ppBuffer[MAX_BUFFER_TYPE];
+ UINT m_ppBufferLen[MAX_BUFFER_TYPE];
public :
- CFakeDirectXVideoDecoder(LPUNKNOWN pUnk, IDirectXVideoDecoder* pDec) : CUnknown(_T("Fake DXVA2 Dec"), pUnk)
- {
- m_pDec.Attach(pDec);
- memset(m_ppBuffer, 0, sizeof(m_ppBuffer));
- }
-
- ~CFakeDirectXVideoDecoder()
- {
- LOG(_T("CFakeDirectXVideoDecoder destroyed !\n"));
- }
-
- DECLARE_IUNKNOWN;
-
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- if(riid == __uuidof(IDirectXVideoDecoder))
- return GetInterface((IDirectXVideoDecoder*)this, ppv);
- else
- return __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoDecoderService(IDirectXVideoDecoderService **ppService)
- {
- HRESULT hr = m_pDec->GetVideoDecoderService(ppService);
- LOG(_T("IDirectXVideoDecoder::GetVideoDecoderService hr = %08x\n"), hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetCreationParameters(GUID *pDeviceGuid, DXVA2_VideoDesc *pVideoDesc, DXVA2_ConfigPictureDecode *pConfig, IDirect3DSurface9 ***pDecoderRenderTargets, UINT *pNumSurfaces)
- {
- HRESULT hr = m_pDec->GetCreationParameters(pDeviceGuid, pVideoDesc, pConfig, pDecoderRenderTargets, pNumSurfaces);
- LOG(_T("IDirectXVideoDecoder::GetCreationParameters hr = %08x\n"), hr);
- return hr;
- }
-
-
- virtual HRESULT STDMETHODCALLTYPE GetBuffer(UINT BufferType, void **ppBuffer, UINT *pBufferSize)
- {
- HRESULT hr = m_pDec->GetBuffer(BufferType, ppBuffer, pBufferSize);
-
- if(BufferType < MAX_BUFFER_TYPE)
- {
- m_ppBuffer[BufferType] = (BYTE*) * ppBuffer;
- m_ppBufferLen[BufferType] = *pBufferSize;
- }
+ CFakeDirectXVideoDecoder(LPUNKNOWN pUnk, IDirectXVideoDecoder* pDec) : CUnknown(_T("Fake DXVA2 Dec"), pUnk)
+ {
+ m_pDec.Attach (pDec);
+ memset (m_ppBuffer, 0, sizeof(m_ppBuffer));
+ }
+
+ ~CFakeDirectXVideoDecoder()
+ {
+ LOG(_T("CFakeDirectXVideoDecoder destroyed !\n"));
+ }
+
+ DECLARE_IUNKNOWN;
+
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ if(riid == __uuidof(IDirectXVideoDecoder))
+ return GetInterface((IDirectXVideoDecoder*)this, ppv);
+ else
+ return __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetVideoDecoderService(IDirectXVideoDecoderService **ppService)
+ {
+ HRESULT hr = m_pDec->GetVideoDecoderService (ppService);
+ LOG(_T("IDirectXVideoDecoder::GetVideoDecoderService hr = %08x\n"), hr);
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetCreationParameters(GUID *pDeviceGuid, DXVA2_VideoDesc *pVideoDesc, DXVA2_ConfigPictureDecode *pConfig, IDirect3DSurface9 ***pDecoderRenderTargets, UINT *pNumSurfaces)
+ {
+ HRESULT hr = m_pDec->GetCreationParameters(pDeviceGuid, pVideoDesc, pConfig, pDecoderRenderTargets, pNumSurfaces);
+ LOG(_T("IDirectXVideoDecoder::GetCreationParameters hr = %08x\n"), hr);
+ return hr;
+ }
+
+
+ virtual HRESULT STDMETHODCALLTYPE GetBuffer(UINT BufferType, void **ppBuffer, UINT *pBufferSize)
+ {
+ HRESULT hr = m_pDec->GetBuffer(BufferType, ppBuffer, pBufferSize);
+
+ if (BufferType < MAX_BUFFER_TYPE)
+ {
+ m_ppBuffer[BufferType] = (BYTE*)*ppBuffer;
+ m_ppBufferLen[BufferType] = *pBufferSize;
+ }
// LOG(_T("IDirectXVideoDecoder::GetBuffer Type = %d, hr = %08x"), BufferType, hr);
-
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(UINT BufferType)
- {
- HRESULT hr = m_pDec->ReleaseBuffer(BufferType);
+
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(UINT BufferType)
+ {
+ HRESULT hr = m_pDec->ReleaseBuffer (BufferType);
// LOG(_T("IDirectXVideoDecoder::ReleaseBuffer Type = %d, hr = %08x"), BufferType, hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE BeginFrame(IDirect3DSurface9 *pRenderTarget, void *pvPVPData)
- {
- HRESULT hr = m_pDec->BeginFrame(pRenderTarget, pvPVPData);
- LOG(_T("IDirectXVideoDecoder::BeginFrame pRenderTarget = %08x, hr = %08x"), pRenderTarget, hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE EndFrame(HANDLE *pHandleComplete)
- {
- HRESULT hr = m_pDec->EndFrame(pHandleComplete);
- LOG(_T("IDirectXVideoDecoder::EndFrame Handle=0x%08x hr = %08x\n"), pHandleComplete, hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Execute(const DXVA2_DecodeExecuteParams *pExecuteParams)
- {
- for(DWORD i = 0; i < pExecuteParams->NumCompBuffers; i++)
- {
- CString strBuffer;
-
- LogDecodeBufferDesc(&pExecuteParams->pCompressedBuffers[i]);
- /*
- for (int j=0; j<4000 && j<pExecuteParams->pCompressedBuffers[i].DataSize; j++)
- strBuffer.AppendFormat (_T("%02x "), m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType][j]);
-
- LOG (_T(" - Buffer type=%d, offset=%d, size=%d"),
- pExecuteParams->pCompressedBuffers[i].CompressedBufferType,
- pExecuteParams->pCompressedBuffers[i].DataOffset,
- pExecuteParams->pCompressedBuffers[i].DataSize);
-
- LOG (strBuffer);*/
-
- if(pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_PictureParametersBufferType)
- {
- if(g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo)
- LogDXVA_PicParams_H264((DXVA_PicParams_H264*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
- else if(g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD)
- LogDXVA_PictureParameters((DXVA_PictureParameters*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
- }
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE BeginFrame(IDirect3DSurface9 *pRenderTarget, void *pvPVPData)
+ {
+ HRESULT hr = m_pDec->BeginFrame (pRenderTarget, pvPVPData);
+ LOG(_T("IDirectXVideoDecoder::BeginFrame pRenderTarget = %08x, hr = %08x"), pRenderTarget, hr);
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE EndFrame(HANDLE *pHandleComplete)
+ {
+ HRESULT hr = m_pDec->EndFrame (pHandleComplete);
+ LOG(_T("IDirectXVideoDecoder::EndFrame Handle=0x%08x hr = %08x\n"), pHandleComplete, hr);
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Execute(const DXVA2_DecodeExecuteParams *pExecuteParams)
+ {
+ for (DWORD i=0; i<pExecuteParams->NumCompBuffers; i++)
+ {
+ CString strBuffer;
+
+ LogDecodeBufferDesc (&pExecuteParams->pCompressedBuffers[i]);
+ /*
+ for (int j=0; j<4000 && j<pExecuteParams->pCompressedBuffers[i].DataSize; j++)
+ strBuffer.AppendFormat (_T("%02x "), m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType][j]);
+
+ LOG (_T(" - Buffer type=%d, offset=%d, size=%d"),
+ pExecuteParams->pCompressedBuffers[i].CompressedBufferType,
+ pExecuteParams->pCompressedBuffers[i].DataOffset,
+ pExecuteParams->pCompressedBuffers[i].DataSize);
+
+ LOG (strBuffer);*/
+
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_PictureParametersBufferType)
+ {
+ if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo)
+ LogDXVA_PicParams_H264 ((DXVA_PicParams_H264*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
+ else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD)
+ LogDXVA_PictureParameters((DXVA_PictureParameters*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
+ }
#if defined(_DEBUG)
- if(g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo)
- {
- if(pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType)
- {
- if(pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Long) == 0)
- {
- DXVA_Slice_H264_Long* pSlice = (DXVA_Slice_H264_Long*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
- LogH264SliceLong(pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Long));
- }
- else if(pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Short) == 0)
- {
- DXVA_Slice_H264_Short* pSlice = (DXVA_Slice_H264_Short*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
- LogH264SliceShort(pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Short));
- }
- }
- }
- else if(g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD)
- {
- if(pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType)
- {
- DXVA_SliceInfo* pSlice = (DXVA_SliceInfo*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
- LogSliceInfo(pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_SliceInfo));
- }
- }
+ if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo)
+ {
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType)
+ {
+ if (pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Long) == 0)
+ {
+ DXVA_Slice_H264_Long* pSlice = (DXVA_Slice_H264_Long*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
+ LogH264SliceLong (pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Long));
+ }
+ else if (pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Short) == 0)
+ {
+ DXVA_Slice_H264_Short* pSlice = (DXVA_Slice_H264_Short*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
+ LogH264SliceShort (pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Short));
+ }
+ }
+ }
+ else if (g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD)
+ {
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType)
+ {
+ DXVA_SliceInfo* pSlice = (DXVA_SliceInfo*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
+ LogSliceInfo (pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_SliceInfo));
+ }
+ }
#endif
#if defined(LOG_MATRIX) && defined(_DEBUG)
- if(pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_InverseQuantizationMatrixBufferType)
- {
- char strFile[_MAX_PATH];
- static int nNb = 1;
- sprintf(strFile, "Matrix%d.bin", nNb++);
- FILE* hFile = fopen(strFile, "wb");
- if(hFile)
- {
- fwrite(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
- 1,
- pExecuteParams->pCompressedBuffers[i].DataSize,
- hFile);
- fclose(hFile);
- }
- }
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_InverseQuantizationMatrixBufferType)
+ {
+ char strFile[_MAX_PATH];
+ static int nNb = 1;
+ sprintf (strFile, "Matrix%d.bin", nNb++);
+ FILE* hFile = fopen (strFile, "wb");
+ if (hFile)
+ {
+ fwrite (m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
+ 1,
+ pExecuteParams->pCompressedBuffers[i].DataSize,
+ hFile);
+ fclose (hFile);
+ }
+ }
#endif
#if defined(_DEBUG)
- if(pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_BitStreamDateBufferType)
- {
- LogDXVA_Bitstream(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType], pExecuteParams->pCompressedBuffers[i].DataSize);
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_BitStreamDateBufferType)
+ {
+ LogDXVA_Bitstream(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType], pExecuteParams->pCompressedBuffers[i].DataSize);
#if defined(LOG_BITSTREAM)
- char strFile[_MAX_PATH];
- static int nNb = 1;
- sprintf(strFile, "BitStream%d.bin", nNb++);
- FILE* hFile = fopen(strFile, "wb");
- if(hFile)
- {
- fwrite(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
- 1,
- pExecuteParams->pCompressedBuffers[i].DataSize,
- hFile);
- fclose(hFile);
- }
+ char strFile[_MAX_PATH];
+ static int nNb = 1;
+ sprintf (strFile, "BitStream%d.bin", nNb++);
+ FILE* hFile = fopen (strFile, "wb");
+ if (hFile)
+ {
+ fwrite (m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
+ 1,
+ pExecuteParams->pCompressedBuffers[i].DataSize,
+ hFile);
+ fclose (hFile);
+ }
#endif
- }
+ }
#endif
- }
-
- HRESULT hr = m_pDec->Execute(pExecuteParams);
-
- if(pExecuteParams->pExtensionData)
- LOG(_T("IDirectXVideoDecoder::Execute %d buffer, fct = %d (in=%d, out=%d), hr = %08x"),
- pExecuteParams->NumCompBuffers,
- pExecuteParams->pExtensionData->Function,
- pExecuteParams->pExtensionData->PrivateInputDataSize,
- pExecuteParams->pExtensionData->PrivateOutputDataSize,
- hr);
- else
- LOG(_T("IDirectXVideoDecoder::Execute %d buffer, hr = %08x"), pExecuteParams->NumCompBuffers, hr);
- return hr;
- }
+ }
+
+ HRESULT hr = m_pDec->Execute (pExecuteParams);
+
+ if (pExecuteParams->pExtensionData)
+ LOG(_T("IDirectXVideoDecoder::Execute %d buffer, fct = %d (in=%d, out=%d), hr = %08x"),
+ pExecuteParams->NumCompBuffers,
+ pExecuteParams->pExtensionData->Function,
+ pExecuteParams->pExtensionData->PrivateInputDataSize,
+ pExecuteParams->pExtensionData->PrivateOutputDataSize,
+ hr);
+ else
+ LOG(_T("IDirectXVideoDecoder::Execute %d buffer, hr = %08x"), pExecuteParams->NumCompBuffers, hr);
+ return hr;
+ }
};
interface IDirectXVideoDecoderServiceC;
struct IDirectXVideoDecoderServiceCVtbl
{
- BEGIN_INTERFACE
- HRESULT(STDMETHODCALLTYPE *QueryInterface)(IDirectXVideoDecoderServiceC* pThis, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject);
- ULONG(STDMETHODCALLTYPE *AddRef)(IDirectXVideoDecoderServiceC* pThis);
- ULONG(STDMETHODCALLTYPE *Release)(IDirectXVideoDecoderServiceC* pThis);
- HRESULT(STDMETHODCALLTYPE* CreateSurface)(IDirectXVideoDecoderServiceC* pThis, __in UINT Width, __in UINT Height, __in UINT BackBuffers, __in D3DFORMAT Format, __in D3DPOOL Pool, __in DWORD Usage, __in DWORD DxvaType, __out_ecount(BackBuffers + 1) IDirect3DSurface9 **ppSurface, __inout_opt HANDLE *pSharedHandle);
-
- HRESULT(STDMETHODCALLTYPE* GetDecoderDeviceGuids)(
- IDirectXVideoDecoderServiceC* pThis,
+ BEGIN_INTERFACE
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IDirectXVideoDecoderServiceC* pThis, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
+ ULONG ( STDMETHODCALLTYPE *AddRef )(IDirectXVideoDecoderServiceC* pThis);
+ ULONG ( STDMETHODCALLTYPE *Release )(IDirectXVideoDecoderServiceC* pThis);
+ HRESULT (STDMETHODCALLTYPE* CreateSurface)(IDirectXVideoDecoderServiceC* pThis, __in UINT Width, __in UINT Height, __in UINT BackBuffers, __in D3DFORMAT Format, __in D3DPOOL Pool, __in DWORD Usage, __in DWORD DxvaType, __out_ecount(BackBuffers+1) IDirect3DSurface9 **ppSurface, __inout_opt HANDLE *pSharedHandle);
+
+ HRESULT (STDMETHODCALLTYPE* GetDecoderDeviceGuids)(
+ IDirectXVideoDecoderServiceC* pThis,
__out UINT* pCount,
__deref_out_ecount_opt(*pCount) GUID** pGuids);
-
- HRESULT(STDMETHODCALLTYPE* GetDecoderRenderTargets)(
- IDirectXVideoDecoderServiceC* pThis,
+
+ HRESULT (STDMETHODCALLTYPE* GetDecoderRenderTargets)(
+ IDirectXVideoDecoderServiceC* pThis,
__in REFGUID Guid,
__out UINT* pCount,
__deref_out_ecount_opt(*pCount) D3DFORMAT** pFormats);
-
- HRESULT(STDMETHODCALLTYPE* GetDecoderConfigurations)(
- IDirectXVideoDecoderServiceC* pThis,
+
+ HRESULT (STDMETHODCALLTYPE* GetDecoderConfigurations)(
+ IDirectXVideoDecoderServiceC* pThis,
__in REFGUID Guid,
__in const DXVA2_VideoDesc* pVideoDesc,
__reserved void* pReserved,
__out UINT* pCount,
__deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs);
-
- HRESULT(STDMETHODCALLTYPE* CreateVideoDecoder)(
- IDirectXVideoDecoderServiceC* pThis,
+
+ HRESULT (STDMETHODCALLTYPE* CreateVideoDecoder)(
+ IDirectXVideoDecoderServiceC* pThis,
__in REFGUID Guid,
__in const DXVA2_VideoDesc* pVideoDesc,
__in const DXVA2_ConfigPictureDecode* pConfig,
@@ -1342,243 +1342,243 @@ struct IDirectXVideoDecoderServiceCVtbl
__in UINT NumRenderTargets,
__deref_out IDirectXVideoDecoder** ppDecode);
- END_INTERFACE
+ END_INTERFACE
};
interface IDirectXVideoDecoderServiceC
{
- CONST_VTBL struct IDirectXVideoDecoderServiceCVtbl *lpVtbl;
+ CONST_VTBL struct IDirectXVideoDecoderServiceCVtbl *lpVtbl;
};
IDirectXVideoDecoderServiceCVtbl* g_pIDirectXVideoDecoderServiceCVtbl;
-static HRESULT(STDMETHODCALLTYPE* CreateVideoDecoderOrg)(IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __in const DXVA2_ConfigPictureDecode* pConfig, __in_ecount(NumRenderTargets) IDirect3DSurface9 **ppDecoderRenderTargets, __in UINT NumRenderTargets, __deref_out IDirectXVideoDecoder** ppDecode) = NULL;
-static HRESULT(STDMETHODCALLTYPE* GetDecoderDeviceGuidsOrg)(IDirectXVideoDecoderServiceC* pThis, __out UINT* pCount, __deref_out_ecount_opt(*pCount) GUID** pGuids) = NULL;
-static HRESULT(STDMETHODCALLTYPE* GetDecoderConfigurationsOrg)(IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __reserved void* pReserved, __out UINT* pCount, __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs) = NULL;
+static HRESULT (STDMETHODCALLTYPE* CreateVideoDecoderOrg ) (IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __in const DXVA2_ConfigPictureDecode* pConfig, __in_ecount(NumRenderTargets) IDirect3DSurface9 **ppDecoderRenderTargets, __in UINT NumRenderTargets, __deref_out IDirectXVideoDecoder** ppDecode) = NULL;
+static HRESULT (STDMETHODCALLTYPE* GetDecoderDeviceGuidsOrg)(IDirectXVideoDecoderServiceC* pThis, __out UINT* pCount, __deref_out_ecount_opt(*pCount) GUID** pGuids) = NULL;
+static HRESULT (STDMETHODCALLTYPE* GetDecoderConfigurationsOrg) (IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __reserved void* pReserved, __out UINT* pCount, __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs) = NULL;
-static void LogDXVA2Config(const DXVA2_ConfigPictureDecode* pConfig)
+static void LogDXVA2Config (const DXVA2_ConfigPictureDecode* pConfig)
{
- LOG(_T("Config"));
- LOG(_T(" - Config4GroupedCoefs %d"), pConfig->Config4GroupedCoefs);
- LOG(_T(" - ConfigBitstreamRaw %d"), pConfig->ConfigBitstreamRaw);
- LOG(_T(" - ConfigDecoderSpecific %d"), pConfig->ConfigDecoderSpecific);
- LOG(_T(" - ConfigHostInverseScan %d"), pConfig->ConfigHostInverseScan);
- LOG(_T(" - ConfigIntraResidUnsigned %d"), pConfig->ConfigIntraResidUnsigned);
- LOG(_T(" - ConfigMBcontrolRasterOrder %d"), pConfig->ConfigMBcontrolRasterOrder);
- LOG(_T(" - ConfigMinRenderTargetBuffCount %d"), pConfig->ConfigMinRenderTargetBuffCount);
- LOG(_T(" - ConfigResid8Subtraction %d"), pConfig->ConfigResid8Subtraction);
- LOG(_T(" - ConfigResidDiffAccelerator %d"), pConfig->ConfigResidDiffAccelerator);
- LOG(_T(" - ConfigResidDiffHost %d"), pConfig->ConfigResidDiffHost);
- LOG(_T(" - ConfigSpatialHost8or9Clipping %d"), pConfig->ConfigSpatialHost8or9Clipping);
- LOG(_T(" - ConfigSpatialResid8 %d"), pConfig->ConfigSpatialResid8);
- LOG(_T(" - ConfigSpatialResidInterleaved %d"), pConfig->ConfigSpatialResidInterleaved);
- LOG(_T(" - ConfigSpecificIDCT %d"), pConfig->ConfigSpecificIDCT);
- LOG(_T(" - guidConfigBitstreamEncryption %s"), CStringFromGUID(pConfig->guidConfigBitstreamEncryption));
- LOG(_T(" - guidConfigMBcontrolEncryption %s"), CStringFromGUID(pConfig->guidConfigMBcontrolEncryption));
- LOG(_T(" - guidConfigResidDiffEncryption %s"), CStringFromGUID(pConfig->guidConfigResidDiffEncryption));
+ LOG(_T("Config"));
+ LOG(_T(" - Config4GroupedCoefs %d"), pConfig->Config4GroupedCoefs);
+ LOG(_T(" - ConfigBitstreamRaw %d"), pConfig->ConfigBitstreamRaw);
+ LOG(_T(" - ConfigDecoderSpecific %d"), pConfig->ConfigDecoderSpecific);
+ LOG(_T(" - ConfigHostInverseScan %d"), pConfig->ConfigHostInverseScan);
+ LOG(_T(" - ConfigIntraResidUnsigned %d"), pConfig->ConfigIntraResidUnsigned);
+ LOG(_T(" - ConfigMBcontrolRasterOrder %d"), pConfig->ConfigMBcontrolRasterOrder);
+ LOG(_T(" - ConfigMinRenderTargetBuffCount %d"), pConfig->ConfigMinRenderTargetBuffCount);
+ LOG(_T(" - ConfigResid8Subtraction %d"), pConfig->ConfigResid8Subtraction);
+ LOG(_T(" - ConfigResidDiffAccelerator %d"), pConfig->ConfigResidDiffAccelerator);
+ LOG(_T(" - ConfigResidDiffHost %d"), pConfig->ConfigResidDiffHost);
+ LOG(_T(" - ConfigSpatialHost8or9Clipping %d"), pConfig->ConfigSpatialHost8or9Clipping);
+ LOG(_T(" - ConfigSpatialResid8 %d"), pConfig->ConfigSpatialResid8);
+ LOG(_T(" - ConfigSpatialResidInterleaved %d"), pConfig->ConfigSpatialResidInterleaved);
+ LOG(_T(" - ConfigSpecificIDCT %d"), pConfig->ConfigSpecificIDCT);
+ LOG(_T(" - guidConfigBitstreamEncryption %s"), CStringFromGUID(pConfig->guidConfigBitstreamEncryption));
+ LOG(_T(" - guidConfigMBcontrolEncryption %s"), CStringFromGUID(pConfig->guidConfigMBcontrolEncryption));
+ LOG(_T(" - guidConfigResidDiffEncryption %s"), CStringFromGUID(pConfig->guidConfigResidDiffEncryption));
}
-static void LogDXVA2VideoDesc(const DXVA2_VideoDesc* pVideoDesc)
+static void LogDXVA2VideoDesc (const DXVA2_VideoDesc* pVideoDesc)
{
- LOG(_T("VideoDesc"));
- LOG(_T(" - Format %s (0x%08x)"), FindD3DFormat(pVideoDesc->Format), pVideoDesc->Format);
- LOG(_T(" - InputSampleFreq %d/%d"), pVideoDesc->InputSampleFreq.Numerator, pVideoDesc->InputSampleFreq.Denominator);
- LOG(_T(" - OutputFrameFreq %d/%d"), pVideoDesc->OutputFrameFreq.Numerator, pVideoDesc->OutputFrameFreq.Denominator);
- LOG(_T(" - SampleFormat %d"), pVideoDesc->SampleFormat.value);
- LOG(_T(" - SampleHeight %d"), pVideoDesc->SampleHeight);
- LOG(_T(" - SampleWidth %d"), pVideoDesc->SampleWidth);
- LOG(_T(" - UABProtectionLevel %d"), pVideoDesc->UABProtectionLevel);
+ LOG(_T("VideoDesc"));
+ LOG(_T(" - Format %s (0x%08x)"), FindD3DFormat(pVideoDesc->Format), pVideoDesc->Format);
+ LOG(_T(" - InputSampleFreq %d/%d"), pVideoDesc->InputSampleFreq.Numerator, pVideoDesc->InputSampleFreq.Denominator);
+ LOG(_T(" - OutputFrameFreq %d/%d"), pVideoDesc->OutputFrameFreq.Numerator, pVideoDesc->OutputFrameFreq.Denominator);
+ LOG(_T(" - SampleFormat %d"), pVideoDesc->SampleFormat.value);
+ LOG(_T(" - SampleHeight %d"), pVideoDesc->SampleHeight);
+ LOG(_T(" - SampleWidth %d"), pVideoDesc->SampleWidth);
+ LOG(_T(" - UABProtectionLevel %d"), pVideoDesc->UABProtectionLevel);
}
static void LogVideoCardCaps(IDirectXVideoDecoderService* pDecoderService)
{
- HRESULT hr;
+ HRESULT hr;
UINT cDecoderGuids = 0;
GUID* pDecoderGuids = NULL;
- hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
- if(SUCCEEDED(hr))
+ hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
+ if (SUCCEEDED(hr))
{
// Look for the decoder GUIDs we want.
- for(UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++)
+ for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++)
{
- LOG(_T("=== New mode : %s"), GetDXVAMode(&pDecoderGuids[iGuid]));
-
- // Find a configuration that we support.
- UINT cFormats = 0;
- UINT cConfigurations = 0;
- D3DFORMAT* pFormats = NULL;
- DXVA2_ConfigPictureDecode* pConfig = NULL;
- DXVA2_VideoDesc m_VideoDesc;
-
- hr = pDecoderService->GetDecoderRenderTargets(pDecoderGuids[iGuid], &cFormats, &pFormats);
-
- if(SUCCEEDED(hr))
- {
- // Look for a format that matches our output format.
- for(UINT iFormat = 0; iFormat < cFormats; iFormat++)
- {
- LOG(_T("Direct 3D format : %s"), FindD3DFormat(pFormats[iFormat]));
- // Fill in the video description. Set the width, height, format, and frame rate.
- memset(&m_VideoDesc, 0, sizeof(m_VideoDesc));
- m_VideoDesc.SampleWidth = 1280;
- m_VideoDesc.SampleHeight = 720;
- m_VideoDesc.Format = pFormats[iFormat];
-
- // Get the available configurations.
- hr = pDecoderService->GetDecoderConfigurations(pDecoderGuids[iGuid], &m_VideoDesc, NULL, &cConfigurations, &pConfig);
-
- if(SUCCEEDED(hr))
- {
-
- // Find a supported configuration.
- for(UINT iConfig = 0; iConfig < cConfigurations; iConfig++)
- {
- LogDXVA2Config(&pConfig[iConfig]);
- }
-
- CoTaskMemFree(pConfig);
- }
- }
- }
-
- LOG(_T("\n"));
- CoTaskMemFree(pFormats);
+ LOG (_T("=== New mode : %s"), GetDXVAMode (&pDecoderGuids[iGuid]));
+
+ // Find a configuration that we support.
+ UINT cFormats = 0;
+ UINT cConfigurations = 0;
+ D3DFORMAT* pFormats = NULL;
+ DXVA2_ConfigPictureDecode* pConfig = NULL;
+ DXVA2_VideoDesc m_VideoDesc;
+
+ hr = pDecoderService->GetDecoderRenderTargets(pDecoderGuids[iGuid], &cFormats, &pFormats);
+
+ if (SUCCEEDED(hr))
+ {
+ // Look for a format that matches our output format.
+ for (UINT iFormat = 0; iFormat < cFormats; iFormat++)
+ {
+ LOG (_T("Direct 3D format : %s"), FindD3DFormat(pFormats[iFormat]));
+ // Fill in the video description. Set the width, height, format, and frame rate.
+ memset(&m_VideoDesc, 0, sizeof(m_VideoDesc));
+ m_VideoDesc.SampleWidth = 1280;
+ m_VideoDesc.SampleHeight = 720;
+ m_VideoDesc.Format = pFormats[iFormat];
+
+ // Get the available configurations.
+ hr = pDecoderService->GetDecoderConfigurations(pDecoderGuids[iGuid], &m_VideoDesc, NULL, &cConfigurations, &pConfig);
+
+ if (SUCCEEDED(hr))
+ {
+
+ // Find a supported configuration.
+ for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++)
+ {
+ LogDXVA2Config (&pConfig[iConfig]);
+ }
+
+ CoTaskMemFree(pConfig);
+ }
+ }
+ }
+
+ LOG(_T("\n"));
+ CoTaskMemFree(pFormats);
}
- }
+ }
}
-static HRESULT STDMETHODCALLTYPE CreateVideoDecoderMine(
- IDirectXVideoDecoderServiceC* pThis,
- __in REFGUID Guid,
- __in const DXVA2_VideoDesc* pVideoDesc,
- __in const DXVA2_ConfigPictureDecode* pConfig,
- __in_ecount(NumRenderTargets) IDirect3DSurface9 **ppDecoderRenderTargets,
- __in UINT NumRenderTargets,
- __deref_out IDirectXVideoDecoder** ppDecode)
+static HRESULT STDMETHODCALLTYPE CreateVideoDecoderMine(
+ IDirectXVideoDecoderServiceC* pThis,
+ __in REFGUID Guid,
+ __in const DXVA2_VideoDesc* pVideoDesc,
+ __in const DXVA2_ConfigPictureDecode* pConfig,
+ __in_ecount(NumRenderTargets) IDirect3DSurface9 **ppDecoderRenderTargets,
+ __in UINT NumRenderTargets,
+ __deref_out IDirectXVideoDecoder** ppDecode)
{
// DebugBreak();
// ((DXVA2_VideoDesc*)pVideoDesc)->Format = (D3DFORMAT)0x3231564E;
- g_guidDXVADecoder = Guid;
- g_nDXVAVersion = 2;
+ g_guidDXVADecoder = Guid;
+ g_nDXVAVersion = 2;
#ifdef _DEBUG
- LOG(_T("\n\n"));
- LogDXVA2VideoDesc(pVideoDesc);
- LogDXVA2Config(pConfig);
+ LOG(_T("\n\n"));
+ LogDXVA2VideoDesc(pVideoDesc);
+ LogDXVA2Config(pConfig);
#endif
- HRESULT hr = CreateVideoDecoderOrg(pThis, Guid, pVideoDesc, pConfig, ppDecoderRenderTargets, NumRenderTargets, ppDecode);
+ HRESULT hr = CreateVideoDecoderOrg(pThis, Guid, pVideoDesc, pConfig, ppDecoderRenderTargets, NumRenderTargets, ppDecode);
- if(FAILED(hr))
- g_guidDXVADecoder = GUID_NULL;
- else
- {
+ if (FAILED (hr))
+ g_guidDXVADecoder = GUID_NULL;
+ else
+ {
#ifdef _DEBUG
- if((Guid == DXVA2_ModeH264_E) ||
- (Guid == DXVA2_ModeVC1_D) ||
- (Guid == DXVA_Intel_H264_ClearVideo) ||
- (Guid == DXVA2_ModeMPEG2_VLD))
- {
- *ppDecode = DNew CFakeDirectXVideoDecoder(NULL, *ppDecode);
- (*ppDecode)->AddRef();
- }
-
- for(DWORD i = 0; i < NumRenderTargets; i++)
- LOG(_T(" - Surf %d : %08x"), i, ppDecoderRenderTargets[i]);
+ if ((Guid == DXVA2_ModeH264_E) ||
+ (Guid == DXVA2_ModeVC1_D) ||
+ (Guid == DXVA_Intel_H264_ClearVideo) ||
+ (Guid == DXVA2_ModeMPEG2_VLD))
+ {
+ *ppDecode = DNew CFakeDirectXVideoDecoder (NULL, *ppDecode);
+ (*ppDecode)->AddRef();
+ }
+
+ for (DWORD i=0; i<NumRenderTargets; i++)
+ LOG(_T(" - Surf %d : %08x"), i, ppDecoderRenderTargets[i]);
#endif
- }
+ }
- LOG(_T("IDirectXVideoDecoderService::CreateVideoDecoder %s (%d render targets) hr = %08x"), GetDXVAMode(&g_guidDXVADecoder), NumRenderTargets, hr);
+ LOG(_T("IDirectXVideoDecoderService::CreateVideoDecoder %s (%d render targets) hr = %08x"), GetDXVAMode(&g_guidDXVADecoder), NumRenderTargets, hr);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE GetDecoderDeviceGuidsMine(IDirectXVideoDecoderServiceC* pThis,
- __out UINT* pCount,
- __deref_out_ecount_opt(*pCount) GUID** pGuids)
+static HRESULT STDMETHODCALLTYPE GetDecoderDeviceGuidsMine (IDirectXVideoDecoderServiceC* pThis,
+ __out UINT* pCount,
+ __deref_out_ecount_opt(*pCount) GUID** pGuids)
{
- HRESULT hr = GetDecoderDeviceGuidsOrg(pThis, pCount, pGuids);
- LOG(_T("IDirectXVideoDecoderService::GetDecoderDeviceGuids hr = %08x\n"), hr);
+ HRESULT hr = GetDecoderDeviceGuidsOrg(pThis, pCount, pGuids);
+ LOG(_T("IDirectXVideoDecoderService::GetDecoderDeviceGuids hr = %08x\n"), hr);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE GetDecoderConfigurationsMine(IDirectXVideoDecoderServiceC* pThis,
- __in REFGUID Guid,
- __in const DXVA2_VideoDesc* pVideoDesc,
- __reserved void* pReserved,
- __out UINT* pCount,
- __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs)
+static HRESULT STDMETHODCALLTYPE GetDecoderConfigurationsMine (IDirectXVideoDecoderServiceC* pThis,
+ __in REFGUID Guid,
+ __in const DXVA2_VideoDesc* pVideoDesc,
+ __reserved void* pReserved,
+ __out UINT* pCount,
+ __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs)
{
- HRESULT hr = GetDecoderConfigurationsOrg(pThis, Guid, pVideoDesc, pReserved, pCount, ppConfigs);
+ HRESULT hr = GetDecoderConfigurationsOrg(pThis, Guid, pVideoDesc, pReserved, pCount, ppConfigs);
- // Force LongSlice decoding !
+ // Force LongSlice decoding !
// memcpy (&(*ppConfigs)[1], &(*ppConfigs)[0], sizeof(DXVA2_ConfigPictureDecode));
- return hr;
+ return hr;
}
void HookDirectXVideoDecoderService(void* pIDirectXVideoDecoderService)
{
- IDirectXVideoDecoderServiceC* pIDirectXVideoDecoderServiceC = (IDirectXVideoDecoderServiceC*) pIDirectXVideoDecoderService;
+ IDirectXVideoDecoderServiceC* pIDirectXVideoDecoderServiceC = (IDirectXVideoDecoderServiceC*) pIDirectXVideoDecoderService;
- BOOL res;
- DWORD flOldProtect = 0;
+ BOOL res;
+ DWORD flOldProtect = 0;
- // Casimir666 : unhook previous VTables
- if(g_pIDirectXVideoDecoderServiceCVtbl)
- {
- res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if(g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder == CreateVideoDecoderMine)
- g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder = CreateVideoDecoderOrg;
+ // Casimir666 : unhook previous VTables
+ if (g_pIDirectXVideoDecoderServiceCVtbl)
+ {
+ res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder == CreateVideoDecoderMine)
+ g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder = CreateVideoDecoderOrg;
#ifdef _DEBUG
- if(g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations == GetDecoderConfigurationsMine)
- g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations = GetDecoderConfigurationsOrg;
+ if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations == GetDecoderConfigurationsMine)
+ g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations = GetDecoderConfigurationsOrg;
- //if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids == GetDecoderDeviceGuidsMine)
- // g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsOrg;
+ //if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids == GetDecoderDeviceGuidsMine)
+ // g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsOrg;
#endif
- res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
+ res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
- g_pIDirectXVideoDecoderServiceCVtbl = NULL;
- CreateVideoDecoderOrg = NULL;
- GetDecoderConfigurationsOrg = NULL;
- g_guidDXVADecoder = GUID_NULL;
- g_nDXVAVersion = 0;
- }
+ g_pIDirectXVideoDecoderServiceCVtbl = NULL;
+ CreateVideoDecoderOrg = NULL;
+ GetDecoderConfigurationsOrg = NULL;
+ g_guidDXVADecoder = GUID_NULL;
+ g_nDXVAVersion = 0;
+ }
- // TODO : remove log file !!
+ // TODO : remove log file !!
#ifdef _DEBUG
- ::DeleteFile(LOG_FILE);
- ::DeleteFile(_T("picture.log"));
- ::DeleteFile(_T("slicelong.log"));
+ ::DeleteFile (LOG_FILE);
+ ::DeleteFile (_T("picture.log"));
+ ::DeleteFile (_T("slicelong.log"));
#endif
- if(pIDirectXVideoDecoderService)
- {
- res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (pIDirectXVideoDecoderService)
+ {
+ res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
- CreateVideoDecoderOrg = pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder;
- pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder = CreateVideoDecoderMine;
+ CreateVideoDecoderOrg = pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder;
+ pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder = CreateVideoDecoderMine;
#ifdef _DEBUG
- GetDecoderConfigurationsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations;
- pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations = GetDecoderConfigurationsMine;
+ GetDecoderConfigurationsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations;
+ pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations = GetDecoderConfigurationsMine;
- //GetDecoderDeviceGuidsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids;
- //pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsMine;
+ //GetDecoderDeviceGuidsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids;
+ //pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsMine;
#endif
- res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
+ res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
- g_pIDirectXVideoDecoderServiceCVtbl = pIDirectXVideoDecoderServiceC->lpVtbl;
- }
+ g_pIDirectXVideoDecoderServiceCVtbl = pIDirectXVideoDecoderServiceC->lpVtbl;
+ }
} \ No newline at end of file
diff --git a/src/apps/mplayerc/IPinHook.h b/src/apps/mplayerc/IPinHook.h
index 2a50dc433..9b9b68790 100644
--- a/src/apps/mplayerc/IPinHook.h
+++ b/src/apps/mplayerc/IPinHook.h
@@ -27,26 +27,26 @@ interface IPinC;
typedef struct IPinCVtbl
{
- BEGIN_INTERFACE
- HRESULT(STDMETHODCALLTYPE *QueryInterface)(IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject);
- ULONG(STDMETHODCALLTYPE *AddRef)(IPinC * This);
- ULONG(STDMETHODCALLTYPE *Release)(IPinC * This);
- HRESULT(STDMETHODCALLTYPE *Connect)(IPinC * This, /* [in] */ IPinC *pReceivePin, /* [in] */ const AM_MEDIA_TYPE *pmt);
- HRESULT(STDMETHODCALLTYPE *ReceiveConnection)(IPinC * This, /* [in] */ IPinC *pConnector, /* [in] */ const AM_MEDIA_TYPE *pmt);
- HRESULT(STDMETHODCALLTYPE *Disconnect)(IPinC * This);
- HRESULT(STDMETHODCALLTYPE *ConnectedTo)(IPinC * This, /* [out] */ IPinC **pPin);
- HRESULT(STDMETHODCALLTYPE *ConnectionMediaType)(IPinC * This, /* [out] */ AM_MEDIA_TYPE *pmt);
- HRESULT(STDMETHODCALLTYPE *QueryPinInfo)(IPinC * This, /* [out] */ PIN_INFO *pInfo);
- HRESULT(STDMETHODCALLTYPE *QueryDirection)(IPinC * This, /* [out] */ PIN_DIRECTION *pPinDir);
- HRESULT(STDMETHODCALLTYPE *QueryId)(IPinC * This, /* [out] */ LPWSTR *Id);
- HRESULT(STDMETHODCALLTYPE *QueryAccept)(IPinC * This, /* [in] */ const AM_MEDIA_TYPE *pmt);
- HRESULT(STDMETHODCALLTYPE *EnumMediaTypes)(IPinC * This, /* [out] */ IEnumMediaTypes **ppEnum);
- HRESULT(STDMETHODCALLTYPE *QueryInternalConnections)(IPinC * This, /* [out] */ IPinC **apPin, /* [out][in] */ ULONG *nPin);
- HRESULT(STDMETHODCALLTYPE *EndOfStream)(IPinC * This);
- HRESULT(STDMETHODCALLTYPE *BeginFlush)(IPinC * This);
- HRESULT(STDMETHODCALLTYPE *EndFlush)(IPinC * This);
- HRESULT(STDMETHODCALLTYPE *NewSegment)(IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate);
- END_INTERFACE
+ BEGIN_INTERFACE
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
+ ULONG ( STDMETHODCALLTYPE *AddRef )( IPinC * This );
+ ULONG ( STDMETHODCALLTYPE *Release )( IPinC * This );
+ HRESULT ( STDMETHODCALLTYPE *Connect )( IPinC * This, /* [in] */ IPinC *pReceivePin, /* [in] */ const AM_MEDIA_TYPE *pmt );
+ HRESULT ( STDMETHODCALLTYPE *ReceiveConnection )( IPinC * This, /* [in] */ IPinC *pConnector, /* [in] */ const AM_MEDIA_TYPE *pmt );
+ HRESULT ( STDMETHODCALLTYPE *Disconnect )( IPinC * This );
+ HRESULT ( STDMETHODCALLTYPE *ConnectedTo )( IPinC * This, /* [out] */ IPinC **pPin );
+ HRESULT ( STDMETHODCALLTYPE *ConnectionMediaType )( IPinC * This, /* [out] */ AM_MEDIA_TYPE *pmt );
+ HRESULT ( STDMETHODCALLTYPE *QueryPinInfo )( IPinC * This, /* [out] */ PIN_INFO *pInfo );
+ HRESULT ( STDMETHODCALLTYPE *QueryDirection )( IPinC * This, /* [out] */ PIN_DIRECTION *pPinDir );
+ HRESULT ( STDMETHODCALLTYPE *QueryId )( IPinC * This, /* [out] */ LPWSTR *Id );
+ HRESULT ( STDMETHODCALLTYPE *QueryAccept )( IPinC * This, /* [in] */ const AM_MEDIA_TYPE *pmt );
+ HRESULT ( STDMETHODCALLTYPE *EnumMediaTypes )( IPinC * This, /* [out] */ IEnumMediaTypes **ppEnum );
+ HRESULT ( STDMETHODCALLTYPE *QueryInternalConnections )( IPinC * This, /* [out] */ IPinC **apPin, /* [out][in] */ ULONG *nPin );
+ HRESULT ( STDMETHODCALLTYPE *EndOfStream )( IPinC * This );
+ HRESULT ( STDMETHODCALLTYPE *BeginFlush )( IPinC * This );
+ HRESULT ( STDMETHODCALLTYPE *EndFlush )( IPinC * This );
+ HRESULT ( STDMETHODCALLTYPE *NewSegment )( IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate );
+ END_INTERFACE
} IPinCVtbl;
interface IPinC
@@ -58,17 +58,17 @@ interface IMemInputPinC;
typedef struct IMemInputPinCVtbl
{
- BEGIN_INTERFACE
- HRESULT(STDMETHODCALLTYPE *QueryInterface)(IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject);
- ULONG(STDMETHODCALLTYPE *AddRef)(IPinC * This);
- ULONG(STDMETHODCALLTYPE *Release)(IPinC * This);
- HRESULT(STDMETHODCALLTYPE *GetAllocator)(IMemInputPinC * This, IMemAllocator **ppAllocator);
- HRESULT(STDMETHODCALLTYPE *NotifyAllocator)(IMemInputPinC * This, IMemAllocator *pAllocator, BOOL bReadOnly);
- HRESULT(STDMETHODCALLTYPE *GetAllocatorRequirements)(IMemInputPinC * This, ALLOCATOR_PROPERTIES *pProps);
- HRESULT(STDMETHODCALLTYPE *Receive)(IMemInputPinC * This, IMediaSample *pSample);
- HRESULT(STDMETHODCALLTYPE *ReceiveMultiple)(IMemInputPinC * This, IMediaSample **pSamples, long nSamples, long *nSamplesProcessed);
- HRESULT(STDMETHODCALLTYPE *ReceiveCanBlock)(IMemInputPinC * This);
- END_INTERFACE
+ BEGIN_INTERFACE
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
+ ULONG ( STDMETHODCALLTYPE *AddRef )( IPinC * This );
+ ULONG ( STDMETHODCALLTYPE *Release )( IPinC * This );
+ HRESULT ( STDMETHODCALLTYPE *GetAllocator )( IMemInputPinC * This, IMemAllocator **ppAllocator);
+ HRESULT ( STDMETHODCALLTYPE *NotifyAllocator )( IMemInputPinC * This, IMemAllocator *pAllocator, BOOL bReadOnly);
+ HRESULT ( STDMETHODCALLTYPE *GetAllocatorRequirements )( IMemInputPinC * This, ALLOCATOR_PROPERTIES *pProps);
+ HRESULT ( STDMETHODCALLTYPE *Receive )( IMemInputPinC * This, IMediaSample *pSample);
+ HRESULT ( STDMETHODCALLTYPE *ReceiveMultiple )( IMemInputPinC * This, IMediaSample **pSamples, long nSamples, long *nSamplesProcessed);
+ HRESULT ( STDMETHODCALLTYPE *ReceiveCanBlock )( IMemInputPinC * This);
+ END_INTERFACE
} IMemInputPinCVtbl;
interface IMemInputPinC
@@ -88,96 +88,96 @@ interface IAMVideoAcceleratorC;
typedef struct IAMVideoAcceleratorCVtbl
{
- BEGIN_INTERFACE
-
- HRESULT(STDMETHODCALLTYPE *QueryInterface)(
- IAMVideoAcceleratorC * This,
- /* [in] */ REFIID riid,
- /* [iid_is][out] */ void **ppvObject);
-
- ULONG(STDMETHODCALLTYPE *AddRef)(
- IAMVideoAcceleratorC * This);
-
- ULONG(STDMETHODCALLTYPE *Release)(
- IAMVideoAcceleratorC * This);
-
- HRESULT(STDMETHODCALLTYPE *GetVideoAcceleratorGUIDs)(
- IAMVideoAcceleratorC * This,
- /* [out][in] */ LPDWORD pdwNumGuidsSupported,
- /* [out][in] */ LPGUID pGuidsSupported);
-
- HRESULT(STDMETHODCALLTYPE *GetUncompFormatsSupported)(
- IAMVideoAcceleratorC * This,
- /* [in] */ const GUID *pGuid,
- /* [out][in] */ LPDWORD pdwNumFormatsSupported,
- /* [out][in] */ LPDDPIXELFORMAT pFormatsSupported);
-
- HRESULT(STDMETHODCALLTYPE *GetInternalMemInfo)(
- IAMVideoAcceleratorC * This,
- /* [in] */ const GUID *pGuid,
- /* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,
- /* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo);
-
- HRESULT(STDMETHODCALLTYPE *GetCompBufferInfo)(
- IAMVideoAcceleratorC * This,
- /* [in] */ const GUID *pGuid,
- /* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,
- /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
- /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
-
- HRESULT(STDMETHODCALLTYPE *GetInternalCompBufferInfo)(
- IAMVideoAcceleratorC * This,
- /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
- /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
-
- HRESULT(STDMETHODCALLTYPE *BeginFrame)(
- IAMVideoAcceleratorC * This,
- /* [in] */ const AMVABeginFrameInfo *amvaBeginFrameInfo);
-
- HRESULT(STDMETHODCALLTYPE *EndFrame)(
- IAMVideoAcceleratorC * This,
- /* [in] */ const AMVAEndFrameInfo *pEndFrameInfo);
-
- HRESULT(STDMETHODCALLTYPE *GetBuffer)(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwTypeIndex,
- /* [in] */ DWORD dwBufferIndex,
- /* [in] */ BOOL bReadOnly,
- /* [out] */ LPVOID *ppBuffer,
- /* [out] */ LONG *lpStride);
-
- HRESULT(STDMETHODCALLTYPE *ReleaseBuffer)(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwTypeIndex,
- /* [in] */ DWORD dwBufferIndex);
-
- HRESULT(STDMETHODCALLTYPE *Execute)(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwFunction,
- /* [in] */ LPVOID lpPrivateInputData,
- /* [in] */ DWORD cbPrivateInputData,
- /* [in] */ LPVOID lpPrivateOutputDat,
- /* [in] */ DWORD cbPrivateOutputData,
- /* [in] */ DWORD dwNumBuffers,
- /* [in] */ const AMVABUFFERINFO *pamvaBufferInfo);
-
- HRESULT(STDMETHODCALLTYPE *QueryRenderStatus)(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwTypeIndex,
- /* [in] */ DWORD dwBufferIndex,
- /* [in] */ DWORD dwFlags);
-
- HRESULT(STDMETHODCALLTYPE *DisplayFrame)(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwFlipToIndex,
- /* [in] */ IMediaSample *pMediaSample);
-
- END_INTERFACE
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ IAMVideoAcceleratorC * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ IAMVideoAcceleratorC * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetVideoAcceleratorGUIDs )(
+ IAMVideoAcceleratorC * This,
+ /* [out][in] */ LPDWORD pdwNumGuidsSupported,
+ /* [out][in] */ LPGUID pGuidsSupported);
+
+ HRESULT ( STDMETHODCALLTYPE *GetUncompFormatsSupported )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ const GUID *pGuid,
+ /* [out][in] */ LPDWORD pdwNumFormatsSupported,
+ /* [out][in] */ LPDDPIXELFORMAT pFormatsSupported);
+
+ HRESULT ( STDMETHODCALLTYPE *GetInternalMemInfo )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ const GUID *pGuid,
+ /* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,
+ /* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCompBufferInfo )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ const GUID *pGuid,
+ /* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,
+ /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
+ /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
+
+ HRESULT ( STDMETHODCALLTYPE *GetInternalCompBufferInfo )(
+ IAMVideoAcceleratorC * This,
+ /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
+ /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
+
+ HRESULT ( STDMETHODCALLTYPE *BeginFrame )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ const AMVABeginFrameInfo *amvaBeginFrameInfo);
+
+ HRESULT ( STDMETHODCALLTYPE *EndFrame )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ const AMVAEndFrameInfo *pEndFrameInfo);
+
+ HRESULT ( STDMETHODCALLTYPE *GetBuffer )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ DWORD dwTypeIndex,
+ /* [in] */ DWORD dwBufferIndex,
+ /* [in] */ BOOL bReadOnly,
+ /* [out] */ LPVOID *ppBuffer,
+ /* [out] */ LONG *lpStride);
+
+ HRESULT ( STDMETHODCALLTYPE *ReleaseBuffer )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ DWORD dwTypeIndex,
+ /* [in] */ DWORD dwBufferIndex);
+
+ HRESULT ( STDMETHODCALLTYPE *Execute )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ DWORD dwFunction,
+ /* [in] */ LPVOID lpPrivateInputData,
+ /* [in] */ DWORD cbPrivateInputData,
+ /* [in] */ LPVOID lpPrivateOutputDat,
+ /* [in] */ DWORD cbPrivateOutputData,
+ /* [in] */ DWORD dwNumBuffers,
+ /* [in] */ const AMVABUFFERINFO *pamvaBufferInfo);
+
+ HRESULT ( STDMETHODCALLTYPE *QueryRenderStatus )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ DWORD dwTypeIndex,
+ /* [in] */ DWORD dwBufferIndex,
+ /* [in] */ DWORD dwFlags);
+
+ HRESULT ( STDMETHODCALLTYPE *DisplayFrame )(
+ IAMVideoAcceleratorC * This,
+ /* [in] */ DWORD dwFlipToIndex,
+ /* [in] */ IMediaSample *pMediaSample);
+
+ END_INTERFACE
} IAMVideoAcceleratorCVtbl;
interface IAMVideoAcceleratorC
{
- CONST_VTBL struct IAMVideoAcceleratorCVtbl *lpVtbl;
+ CONST_VTBL struct IAMVideoAcceleratorCVtbl *lpVtbl;
};
extern void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC);
diff --git a/src/apps/mplayerc/IQTVideoSurface.h b/src/apps/mplayerc/IQTVideoSurface.h
index 65ff87b10..5349cfc66 100644
--- a/src/apps/mplayerc/IQTVideoSurface.h
+++ b/src/apps/mplayerc/IQTVideoSurface.h
@@ -28,9 +28,8 @@
//
[uuid("A6AE36F7-A6F2-4157-AF54-6599857E4E20")]
-interface IQTVideoSurface :
-public IUnknown
+interface IQTVideoSurface : public IUnknown
{
- STDMETHOD(BeginBlt)(const BITMAP& bm) PURE;
- STDMETHOD(DoBlt)(const BITMAP& bm) PURE;
+ STDMETHOD (BeginBlt) (const BITMAP& bm) PURE;
+ STDMETHOD (DoBlt) (const BITMAP& bm) PURE;
};
diff --git a/src/apps/mplayerc/ISDb.cpp b/src/apps/mplayerc/ISDb.cpp
index 8d61bd64d..c5870cf3f 100644
--- a/src/apps/mplayerc/ISDb.cpp
+++ b/src/apps/mplayerc/ISDb.cpp
@@ -28,86 +28,86 @@
bool hash(LPCTSTR fn, filehash& fh)
{
- CFile f;
- CFileException fe;
- if(!f.Open(fn, CFile::modeRead | CFile::osSequentialScan | CFile::shareDenyNone, &fe))
+ CFile f;
+ CFileException fe;
+ if(!f.Open(fn, CFile::modeRead|CFile::osSequentialScan|CFile::shareDenyNone, &fe))
return false;
- CPath p(fn);
- p.StripPath();
- fh.name = (LPCTSTR)p;
+ CPath p(fn);
+ p.StripPath();
+ fh.name = (LPCTSTR)p;
- fh.size = f.GetLength();
+ fh.size = f.GetLength();
+
+ fh.hash = fh.size;
+ for(UINT64 tmp = 0, i = 0; i < 65536/sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.hash += tmp, i++);
+ f.Seek(max(0, (INT64)fh.size - 65536), CFile::begin);
+ for(UINT64 tmp = 0, i = 0; i < 65536/sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.hash += tmp, i++);
- fh.hash = fh.size;
- for(UINT64 tmp = 0, i = 0; i < 65536 / sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.hash += tmp, i++);
- f.Seek(max(0, (INT64)fh.size - 65536), CFile::begin);
- for(UINT64 tmp = 0, i = 0; i < 65536 / sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.hash += tmp, i++);
-
- return true;
+ return true;
}
void hash(CPlaylist& pl, CList<filehash>& fhs)
{
- fhs.RemoveAll();
+ fhs.RemoveAll();
- POSITION pos = pl.GetHeadPosition();
- while(pos)
- {
- CString fn = pl.GetNext(pos).m_fns.GetHead();
- if(AfxGetAppSettings().Formats.FindExt(CPath(fn).GetExtension().MakeLower(), true))
- continue;
+ POSITION pos = pl.GetHeadPosition();
+ while(pos)
+ {
+ CString fn = pl.GetNext(pos).m_fns.GetHead();
+ if(AfxGetAppSettings().Formats.FindExt(CPath(fn).GetExtension().MakeLower(), true))
+ continue;
- filehash fh;
- if(!hash(fn, fh))
- continue;
+ filehash fh;
+ if(!hash(fn, fh))
+ continue;
- fhs.AddTail(fh);
- }
+ fhs.AddTail(fh);
+ }
}
CStringA makeargs(CPlaylist& pl)
{
- CList<filehash> fhs;
- hash(pl, fhs);
+ CList<filehash> fhs;
+ hash(pl, fhs);
- CAtlList<CStringA> args;
+ CAtlList<CStringA> args;
- POSITION pos = fhs.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
- filehash& fh = fhs.GetNext(pos);
+ POSITION pos = fhs.GetHeadPosition();
+ for(int i = 0; pos; i++)
+ {
+ filehash& fh = fhs.GetNext(pos);
- CStringA str;
- str.Format("name[%d]=%s&size[%d]=%016I64x&hash[%d]=%016I64x",
- i, UrlEncode(CStringA(fh.name)),
- i, fh.size,
- i, fh.hash);
+ CStringA str;
+ str.Format("name[%d]=%s&size[%d]=%016I64x&hash[%d]=%016I64x",
+ i, UrlEncode(CStringA(fh.name)),
+ i, fh.size,
+ i, fh.hash);
- args.AddTail(str);
- }
+ args.AddTail(str);
+ }
- return Implode(args, '&');
+ return Implode(args, '&');
}
bool OpenUrl(CInternetSession& is, CString url, CStringA& str)
{
- str.Empty();
+ str.Empty();
- try
- {
- CAutoPtr<CStdioFile> f(is.OpenURL(url, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_EXISTING_CONNECT));
+ try
+ {
+ CAutoPtr<CStdioFile> f(is.OpenURL(url, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT));
- char buff[1024];
- for(int len; (len = f->Read(buff, sizeof(buff))) > 0; str += CStringA(buff, len));
+ char buff[1024];
+ for(int len; (len = f->Read(buff, sizeof(buff))) > 0; str += CStringA(buff, len));
- f->Close(); // must close it because the desctructor doesn't seem to do it and we will get an exception when "is" is destroying
- }
- catch(CInternetException* ie)
- {
- ie->Delete();
- return false;
- }
+ f->Close(); // must close it because the desctructor doesn't seem to do it and we will get an exception when "is" is destroying
+ }
+ catch(CInternetException* ie)
+ {
+ ie->Delete();
+ return false;
+ }
- return true;
+ return true;
}
diff --git a/src/apps/mplayerc/ISDb.h b/src/apps/mplayerc/ISDb.h
index bf55a0c8e..096714b4b 100644
--- a/src/apps/mplayerc/ISDb.h
+++ b/src/apps/mplayerc/ISDb.h
@@ -32,42 +32,27 @@
struct isdb_subtitle
{
- int id, discs, disc_no;
- CStringA name, format, language, iso639_2, nick, email;
- struct isdb_subtitle()
- {
- reset();
- }
- void reset()
- {
- id = discs = disc_no = 0;
- format = language = nick = email = "";
- }
+ int id, discs, disc_no;
+ CStringA name, format, language, iso639_2, nick, email;
+ struct isdb_subtitle() {reset();}
+ void reset() {id = discs = disc_no = 0; format = language = nick = email = "";}
};
struct isdb_movie
{
- CAtlList<CStringA> titles;
- CAtlList<isdb_subtitle> subs;
- void reset()
- {
- titles.RemoveAll();
- subs.RemoveAll();
- }
- void operator = (const struct isdb_movie& m)
- {
- titles.RemoveAll();
- titles.AddTailList(&m.titles);
- subs.RemoveAll();
- subs.AddTailList(&m.subs);
- }
+ CAtlList<CStringA> titles;
+ CAtlList<isdb_subtitle> subs;
+ void reset() {titles.RemoveAll(); subs.RemoveAll();}
+ void operator = (const struct isdb_movie& m)
+ {
+ titles.RemoveAll();
+ titles.AddTailList(&m.titles);
+ subs.RemoveAll();
+ subs.AddTailList(&m.subs);
+ }
};
-struct filehash
-{
- CString name;
- UINT64 size, hash;
-};
+struct filehash {CString name; UINT64 size, hash;};
extern bool hash(LPCTSTR fn, filehash& fh);
extern void hash(CPlaylist& pl, CList<filehash>& fhs);
diff --git a/src/apps/mplayerc/Ifo.cpp b/src/apps/mplayerc/Ifo.cpp
index 52fe77bbb..8f036c953 100644
--- a/src/apps/mplayerc/Ifo.cpp
+++ b/src/apps/mplayerc/Ifo.cpp
@@ -70,12 +70,12 @@
#define IFO_HDR_LEN 8
#define LU_SUB_LEN 8
-extern HANDLE(__stdcall * Real_CreateFileW)(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
+extern HANDLE (__stdcall * Real_CreateFileW)(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
-unsigned __int32 get4bytes(const BYTE* buf)
+unsigned __int32 get4bytes (const BYTE* buf)
{
- return be2me_32(*((unsigned __int32 *)buf));
+ return be2me_32 (*((unsigned __int32 *)buf));
}
@@ -89,182 +89,180 @@ unsigned __int32 get4bytes(const BYTE* buf)
CIfo::CIfo()
{
- m_pBuffer = NULL;
- m_pPGCI = NULL;
- m_pPGCIT = NULL;
- m_dwSize = 0;
+ m_pBuffer = NULL;
+ m_pPGCI = NULL;
+ m_pPGCIT = NULL;
+ m_dwSize = 0;
}
-int CIfo::GetMiscPGCI(CIfo::ifo_hdr_t *hdr, int title, uint8_t **ptr)
+int CIfo::GetMiscPGCI (CIfo::ifo_hdr_t *hdr, int title, uint8_t **ptr)
{
- pgci_sub_t *pgci_sub;
+ pgci_sub_t *pgci_sub;
- *ptr = (uint8_t *) hdr;
- *ptr += IFO_HDR_LEN;
- pgci_sub = (pgci_sub_t *) * ptr + title;
+ *ptr = (uint8_t *) hdr;
+ *ptr += IFO_HDR_LEN;
+ pgci_sub = (pgci_sub_t *) *ptr + title;
- *ptr = (uint8_t *) hdr + be2me_32(pgci_sub->start);
+ *ptr = (uint8_t *) hdr + be2me_32 (pgci_sub->start);
- return 0;
+ return 0;
}
-void CIfo::RemovePgciUOPs(uint8_t *ptr)
+void CIfo::RemovePgciUOPs (uint8_t *ptr)
{
- ifo_hdr_t* hdr = (ifo_hdr_t *) ptr;
- uint16_t num;
- int i;
-
- ptr += IFO_HDR_LEN;
- num = be2me_16(hdr->num);
-
- for(i = 1; i <= num; i++)
- {
- lu_sub_t *lu_sub = (lu_sub_t *) ptr;
-
- ptr += LU_SUB_LEN;
- }
-
- for(i = 0; i < be2me_16(hdr->num); i++)
- {
- uint8_t *ptr;
-
- if(GetMiscPGCI(hdr, i, &ptr) >= 0)
- {
- pgc_t* pgc = (pgc_t*) ptr;
- pgc->prohibited_ops = 0;
- }
- }
+ ifo_hdr_t* hdr = (ifo_hdr_t *) ptr;
+ uint16_t num;
+ int i;
+
+ ptr += IFO_HDR_LEN;
+ num = be2me_16(hdr->num);
+
+ for (i=1; i<=num; i++) {
+ lu_sub_t *lu_sub = (lu_sub_t *) ptr;
+
+ ptr += LU_SUB_LEN;
+ }
+
+ for (i=0; i<be2me_16(hdr->num); i++) {
+ uint8_t *ptr;
+
+ if (GetMiscPGCI (hdr, i, &ptr) >= 0)
+ {
+ pgc_t* pgc = (pgc_t*) ptr;
+ pgc->prohibited_ops = 0;
+ }
+ }
}
CIfo::pgc_t* CIfo::GetFirstPGC()
{
- if(m_pBuffer)
- return (pgc_t*)(m_pBuffer + 0x0400);
- else
- return NULL;
+ if (m_pBuffer)
+ return (pgc_t*) (m_pBuffer + 0x0400);
+ else
+ return NULL;
}
CIfo::pgc_t* CIfo::GetPGCI(const int title, const ifo_hdr_t* hdr)
{
- CIfo::pgci_sub_t *pgci_sub;
- uint8_t *ptr;
+ CIfo::pgci_sub_t *pgci_sub;
+ uint8_t *ptr;
- ptr = (uint8_t *) hdr;
- ptr += IFO_HDR_LEN;
+ ptr = (uint8_t *) hdr;
+ ptr += IFO_HDR_LEN;
- pgci_sub = (pgci_sub_t *) ptr + title;
+ pgci_sub = (pgci_sub_t *) ptr + title;
- ptr = (uint8_t *) hdr + be2me_32(pgci_sub->start);
+ ptr = (uint8_t *) hdr + be2me_32 (pgci_sub->start);
- /* jdw */
- if(ptr >= ((uint8_t *) hdr + be2me_32(hdr->len)))
- {
- return NULL ;
- }
- /* /jdw */
+ /* jdw */
+ if ( ptr >= ( (uint8_t *) hdr + be2me_32 ( hdr->len )))
+ {
+ return NULL ;
+ }
+ /* /jdw */
- return (pgc_t *) ptr;
+ return (pgc_t *) ptr;
}
bool CIfo::IsVTS()
{
- if(m_dwSize < 12 || (strncmp((char*)m_pBuffer, "DVDVIDEO-VTS", 12) != 0))
- return false;
+ if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VTS", 12)!=0))
+ return false;
- return true;
+ return true;
}
bool CIfo::IsVMG()
{
- if(m_dwSize < 12 || (strncmp((char*)m_pBuffer, "DVDVIDEO-VMG", 12) != 0))
- return false;
+ if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VMG", 12)!=0))
+ return false;
- return true;
+ return true;
}
-bool CIfo::OpenFile(LPCTSTR strFile)
+bool CIfo::OpenFile (LPCTSTR strFile)
{
- bool bRet = false;
- HANDLE hFile;
-
- hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- ASSERT(hFile != INVALID_HANDLE_VALUE);
-
- if(hFile != INVALID_HANDLE_VALUE)
- {
- DWORD dwSize = GetFileSize(hFile, NULL);
- m_pBuffer = DNew BYTE [dwSize];
- ReadFile(hFile, m_pBuffer, dwSize, &m_dwSize, NULL);
- CloseHandle(hFile);
-
- if(IsVTS() && (OFF_VTSM_PGCI_UT(m_pBuffer) != 0))
- {
- m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VTSM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
- m_pPGCIT = (ifo_hdr_t*)(m_pBuffer + OFF_VTS_PGCIT(m_pBuffer) * DVD_VIDEO_LB_LEN);
- }
- else if(IsVMG() && (OFF_VMGM_PGCI_UT(m_pBuffer) != 0))
- m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VMGM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
-
- bRet = (m_pPGCI != NULL);
- }
-
- return bRet;
+ bool bRet = false;
+ HANDLE hFile;
+
+ hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ ASSERT (hFile != INVALID_HANDLE_VALUE);
+
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ DWORD dwSize = GetFileSize (hFile, NULL);
+ m_pBuffer = DNew BYTE [dwSize];
+ ReadFile (hFile, m_pBuffer, dwSize, &m_dwSize, NULL);
+ CloseHandle (hFile);
+
+ if (IsVTS() && (OFF_VTSM_PGCI_UT(m_pBuffer)!=0))
+ {
+ m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VTSM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
+ m_pPGCIT = (ifo_hdr_t*)(m_pBuffer + OFF_VTS_PGCIT(m_pBuffer) * DVD_VIDEO_LB_LEN);
+ }
+ else if (IsVMG() && (OFF_VMGM_PGCI_UT(m_pBuffer)!=0))
+ m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VMGM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
+
+ bRet = (m_pPGCI != NULL);
+ }
+
+ return bRet;
}
bool CIfo::RemoveUOPs()
{
- pgc_t* pgc;
-
- if(m_pPGCI)
- {
- pgc = GetFirstPGC();
- pgc->prohibited_ops = 0;
-
- for(int i = 0; i < be2me_16(m_pPGCI->num); i++)
- {
- if(pgc = GetPGCI(i, m_pPGCI))
- RemovePgciUOPs((uint8_t*)pgc);
- }
- }
- if(m_pPGCIT)
- {
- for(int i = 0; i < be2me_16(m_pPGCIT->num); i++)
- {
- if(pgc = GetPGCI(i, m_pPGCIT))
- pgc->prohibited_ops = 0;
- }
- }
- return true;
+ pgc_t* pgc;
+
+ if (m_pPGCI)
+ {
+ pgc = GetFirstPGC();
+ pgc->prohibited_ops = 0;
+
+ for (int i=0; i<be2me_16(m_pPGCI->num); i++)
+ {
+ if (pgc = GetPGCI(i, m_pPGCI))
+ RemovePgciUOPs ((uint8_t*)pgc);
+ }
+ }
+ if (m_pPGCIT)
+ {
+ for (int i=0; i<be2me_16(m_pPGCIT->num); i++)
+ {
+ if (pgc = GetPGCI(i, m_pPGCIT))
+ pgc->prohibited_ops = 0;
+ }
+ }
+ return true;
}
-bool CIfo::SaveFile(LPCTSTR strFile)
+bool CIfo::SaveFile (LPCTSTR strFile)
{
- bool bRet = false;
- HANDLE m_hFile;
-
- if(m_pBuffer)
- {
- m_hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- ASSERT(m_hFile != INVALID_HANDLE_VALUE);
-
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
- DWORD dwSize;
- WriteFile(m_hFile, m_pBuffer, m_dwSize, &dwSize, NULL);
- CloseHandle(m_hFile);
- bRet = true;
- }
- }
-
- return bRet;
+ bool bRet = false;
+ HANDLE m_hFile;
+
+ if (m_pBuffer)
+ {
+ m_hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ ASSERT (m_hFile != INVALID_HANDLE_VALUE);
+
+ if (m_hFile != INVALID_HANDLE_VALUE)
+ {
+ DWORD dwSize;
+ WriteFile (m_hFile, m_pBuffer, m_dwSize, &dwSize, NULL);
+ CloseHandle(m_hFile);
+ bRet = true;
+ }
+ }
+
+ return bRet;
}
CIfo::~CIfo(void)
{
- delete[] m_pBuffer;
+ delete[] m_pBuffer;
}
diff --git a/src/apps/mplayerc/Ifo.h b/src/apps/mplayerc/Ifo.h
index ae9204dae..88b506ece 100644
--- a/src/apps/mplayerc/Ifo.h
+++ b/src/apps/mplayerc/Ifo.h
@@ -34,170 +34,170 @@ typedef unsigned __int32 uint32_t;
class CIfo
{
public:
- CIfo();
+ CIfo();
- bool OpenFile(LPCTSTR strFile);
- bool SaveFile(LPCTSTR strFile);
- bool RemoveUOPs();
+ bool OpenFile (LPCTSTR strFile);
+ bool SaveFile (LPCTSTR strFile);
+ bool RemoveUOPs();
- ~CIfo(void);
+ ~CIfo(void);
private :
- typedef struct
- {
- uint16_t id : 16; // Language
- uint16_t : 16; // don't know
- uint32_t start : 32; // Start of unit
- } pgci_sub_t;
-
- typedef struct
- {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- uint8_t frame_u; // The two high bits are the frame rate.
- } dvd_time_t;
-
- typedef uint8_t command_data_t[8];
-#define COMMAND_DATA_SIZE 8
-
- typedef struct // PGC Command Table
- {
- uint16_t nr_of_pre;
- uint16_t nr_of_post;
- uint16_t nr_of_cell;
- uint16_t tbl_len;
- command_data_t *pre_commands;
- command_data_t *post_commands;
- command_data_t *cell_commands;
- } pgc_command_tbl_t;
-#define PGC_COMMAND_TBL_SIZE 8
-
- typedef uint8_t pgc_program_map_t;
-
- typedef struct // Cell Playback Information
- {
- uint8_t chain_info : 8; // 0x5e 0xde(2 angles, no overlay), 0x5f 0x9f 0x9f 0xdf(4 angles overlay), 0x2 0xa 0x8(1 angle)
- uint8_t foo; // parental control ??
- uint8_t still_time;
- uint8_t cell_cmd;
-
- dvd_time_t playback_time;
- uint32_t vobu_start; // 1st vobu start
- uint32_t ilvu_end;
- uint32_t vobu_last_start;
- uint32_t vobu_last_end;
- } ifo_pgci_caddr_t;
-
- typedef struct // Cell Position Information
- {
- uint16_t vob_id : 16; // Video Object Identifier
- uint8_t foo : 8; // Unknown
- uint8_t cell_id : 8; // Cell Identifier
- } ifo_pgc_cpos_t;
-
-#ifndef CLUT_T
-#define CLUT_T
-
- typedef struct // CLUT == Color LookUp Table
- {
- uint8_t foo : 8; // UNKNOWN: 0x00?
- uint8_t y : 8;
- uint8_t cr : 8;
- uint8_t cb : 8;
- } clut_t;
-#endif
-
- typedef struct // Audio Status
- {
-#if BYTE_ORDER == BIG_ENDIAN
- uint8_t available : 1;
- uint8_t link : 7;
-#else
- uint8_t link : 7;
- uint8_t available : 1;
-#endif
- uint8_t foo : 8; // UNKNOWN
- } audio_status_t;
-
-
- typedef struct // Subpicture status
- {
-#if BYTE_ORDER == BIG_ENDIAN
- uint8_t available : 1;
- uint8_t format4_3 : 7;
-#else
- uint8_t format4_3 : 7;
- uint8_t available : 1;
-#endif
- uint8_t wide : 8;
- uint8_t letter : 8;
- uint8_t pan : 8;
- } subp_status_t;
-
-
- typedef struct // Program Chain Information
- {
- uint16_t zero_1;
- uint8_t nr_of_programs;
- uint8_t nr_of_cells;
- dvd_time_t playback_time;
- uint32_t prohibited_ops; // New type?
- audio_status_t audio_status[8];
- subp_status_t subp_status[32];
- uint16_t next_pgc_nr;
- uint16_t prev_pgc_nr;
- uint16_t goup_pgc_nr;
- uint8_t still_time;
- uint8_t pg_playback_mode;
- clut_t clut[16];
- uint16_t pgc_command_tbl_offset;
- uint16_t pgc_program_map_offset;
- uint16_t cell_playback_tbl_offset;
- uint16_t cell_position_tbl_offset;
- pgc_command_tbl_t *pgc_command_tbl;
- pgc_program_map_t *pgc_program_map;
- ifo_pgci_caddr_t *cell_playback_tbl;
- ifo_pgc_cpos_t *cell_position_tbl;
- } pgc_t;
-#define PGC_SIZE 236
-
- typedef struct
- {
- uint16_t num : 16; // number of entries
- uint16_t : 16; // UNKNOWN
- uint32_t len : 32; // length of table
- } ifo_hdr_t;
-
- typedef struct
- {
-#if BYTE_ORDER == BIG_ENDIAN
- uint16_t foo1 : 4; // don't know
- uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
- // 5=audio, 6=angle, 7=ptt
-#else
- uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
- // 5=audio, 6=angle, 7=ptt
- uint16_t foo1 : 4; // don't know
-#endif
- uint16_t foo2 : 8; // don't know
- uint16_t bar : 16; // don't know
- uint32_t start : 32; // Start of unit
- } lu_sub_t;
-
-
- BYTE* m_pBuffer;
- DWORD m_dwSize;
-
- ifo_hdr_t* m_pPGCI;
- ifo_hdr_t* m_pPGCIT;
-
- bool IsVTS();
- bool IsVMG();
-
- pgc_t* GetFirstPGC();
- pgc_t* GetPGCI(const int title, const ifo_hdr_t* hdr);
- int GetMiscPGCI(ifo_hdr_t *hdr, int title, uint8_t **ptr);
- void RemovePgciUOPs(uint8_t *ptr);
+ typedef struct
+ {
+ uint16_t id : 16; // Language
+ uint16_t : 16; // don't know
+ uint32_t start : 32; // Start of unit
+ } pgci_sub_t;
+
+ typedef struct
+ {
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ uint8_t frame_u; // The two high bits are the frame rate.
+ } dvd_time_t;
+
+ typedef uint8_t command_data_t[8];
+ #define COMMAND_DATA_SIZE 8
+
+ typedef struct // PGC Command Table
+ {
+ uint16_t nr_of_pre;
+ uint16_t nr_of_post;
+ uint16_t nr_of_cell;
+ uint16_t tbl_len;
+ command_data_t *pre_commands;
+ command_data_t *post_commands;
+ command_data_t *cell_commands;
+ } pgc_command_tbl_t;
+ #define PGC_COMMAND_TBL_SIZE 8
+
+ typedef uint8_t pgc_program_map_t;
+
+ typedef struct // Cell Playback Information
+ {
+ uint8_t chain_info : 8; // 0x5e 0xde(2 angles, no overlay), 0x5f 0x9f 0x9f 0xdf(4 angles overlay), 0x2 0xa 0x8(1 angle)
+ uint8_t foo; // parental control ??
+ uint8_t still_time;
+ uint8_t cell_cmd;
+
+ dvd_time_t playback_time;
+ uint32_t vobu_start; // 1st vobu start
+ uint32_t ilvu_end;
+ uint32_t vobu_last_start;
+ uint32_t vobu_last_end;
+ } ifo_pgci_caddr_t;
+
+ typedef struct // Cell Position Information
+ {
+ uint16_t vob_id : 16; // Video Object Identifier
+ uint8_t foo : 8; // Unknown
+ uint8_t cell_id : 8; // Cell Identifier
+ } ifo_pgc_cpos_t;
+
+ #ifndef CLUT_T
+ #define CLUT_T
+
+ typedef struct // CLUT == Color LookUp Table
+ {
+ uint8_t foo : 8; // UNKNOWN: 0x00?
+ uint8_t y : 8;
+ uint8_t cr : 8;
+ uint8_t cb : 8;
+ } clut_t;
+ #endif
+
+ typedef struct // Audio Status
+ {
+ #if BYTE_ORDER == BIG_ENDIAN
+ uint8_t available : 1;
+ uint8_t link : 7;
+ #else
+ uint8_t link : 7;
+ uint8_t available : 1;
+ #endif
+ uint8_t foo : 8; // UNKNOWN
+ } audio_status_t;
+
+
+ typedef struct // Subpicture status
+ {
+ #if BYTE_ORDER == BIG_ENDIAN
+ uint8_t available : 1;
+ uint8_t format4_3 : 7;
+ #else
+ uint8_t format4_3 : 7;
+ uint8_t available : 1;
+ #endif
+ uint8_t wide : 8;
+ uint8_t letter : 8;
+ uint8_t pan : 8;
+ } subp_status_t;
+
+
+ typedef struct // Program Chain Information
+ {
+ uint16_t zero_1;
+ uint8_t nr_of_programs;
+ uint8_t nr_of_cells;
+ dvd_time_t playback_time;
+ uint32_t prohibited_ops; // New type?
+ audio_status_t audio_status[8];
+ subp_status_t subp_status[32];
+ uint16_t next_pgc_nr;
+ uint16_t prev_pgc_nr;
+ uint16_t goup_pgc_nr;
+ uint8_t still_time;
+ uint8_t pg_playback_mode;
+ clut_t clut[16];
+ uint16_t pgc_command_tbl_offset;
+ uint16_t pgc_program_map_offset;
+ uint16_t cell_playback_tbl_offset;
+ uint16_t cell_position_tbl_offset;
+ pgc_command_tbl_t *pgc_command_tbl;
+ pgc_program_map_t *pgc_program_map;
+ ifo_pgci_caddr_t *cell_playback_tbl;
+ ifo_pgc_cpos_t *cell_position_tbl;
+ } pgc_t;
+ #define PGC_SIZE 236
+
+ typedef struct
+ {
+ uint16_t num : 16; // number of entries
+ uint16_t : 16; // UNKNOWN
+ uint32_t len : 32; // length of table
+ } ifo_hdr_t;
+
+ typedef struct
+ {
+ #if BYTE_ORDER == BIG_ENDIAN
+ uint16_t foo1 : 4; // don't know
+ uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
+ // 5=audio, 6=angle, 7=ptt
+ #else
+ uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
+ // 5=audio, 6=angle, 7=ptt
+ uint16_t foo1 : 4; // don't know
+ #endif
+ uint16_t foo2 : 8; // don't know
+ uint16_t bar : 16; // don't know
+ uint32_t start : 32; // Start of unit
+ } lu_sub_t;
+
+
+ BYTE* m_pBuffer;
+ DWORD m_dwSize;
+
+ ifo_hdr_t* m_pPGCI;
+ ifo_hdr_t* m_pPGCIT;
+
+ bool IsVTS();
+ bool IsVMG();
+
+ pgc_t* GetFirstPGC();
+ pgc_t* GetPGCI(const int title, const ifo_hdr_t* hdr);
+ int GetMiscPGCI (ifo_hdr_t *hdr, int title, uint8_t **ptr);
+ void RemovePgciUOPs (uint8_t *ptr);
};
diff --git a/src/apps/mplayerc/KeyProvider.cpp b/src/apps/mplayerc/KeyProvider.cpp
index c9295e52d..4a252ba79 100644
--- a/src/apps/mplayerc/KeyProvider.cpp
+++ b/src/apps/mplayerc/KeyProvider.cpp
@@ -26,30 +26,30 @@
#include "../../DSUtil/DSUtil.h"
-CKeyProvider::CKeyProvider()
- : CUnknown(NAME("CKeyProvider"), NULL)
+CKeyProvider::CKeyProvider()
+ : CUnknown(NAME("CKeyProvider"), NULL)
{
}
STDMETHODIMP CKeyProvider::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IServiceProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IServiceProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
STDMETHODIMP CKeyProvider::QueryService(REFIID siid, REFIID riid, void **ppv)
{
- /*
+ /*
if(siid == __uuidof(IWMReader) && riid == IID_IUnknown)
- {
+ {
CComPtr<IUnknown> punkCert;
HRESULT hr = WMCreateCertificate(&punkCert);
- if(SUCCEEDED(hr))
- *ppv = (void*)punkCert.Detach();
+ if(SUCCEEDED(hr))
+ *ppv = (void*)punkCert.Detach();
return hr;
}
- */
+ */
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
diff --git a/src/apps/mplayerc/KeyProvider.h b/src/apps/mplayerc/KeyProvider.h
index 352329b97..5d95b0707 100644
--- a/src/apps/mplayerc/KeyProvider.h
+++ b/src/apps/mplayerc/KeyProvider.h
@@ -28,9 +28,9 @@
// Declare and implement a key provider class derived from IServiceProvider.
-class CKeyProvider
- : public CUnknown
- , public IServiceProvider
+class CKeyProvider
+ : public CUnknown
+ , public IServiceProvider
{
public:
CKeyProvider();
diff --git a/src/apps/mplayerc/LcdSupport.cpp b/src/apps/mplayerc/LcdSupport.cpp
index 97c1ce541..5a421c437 100644
--- a/src/apps/mplayerc/LcdSupport.cpp
+++ b/src/apps/mplayerc/LcdSupport.cpp
@@ -37,41 +37,41 @@
#define LCD_UPD_TIMER 40
-void LCD_UpdateThread(void * Control)
+void LCD_UpdateThread(void * Control)
{
- CMPC_Lcd * ctrl = static_cast<CMPC_Lcd *>(Control);
- wchar_t str[40];
- __time64_t ltime;
- __time64_t otime = 0;
- struct tm thetime;
- _tsetlocale(LC_ALL, _T("")); // set current system locale
-
- while(ctrl->Thread_Loop)
- {
- EnterCriticalSection(&ctrl->cs);
- if(_time64(&ltime) != otime) // Retrieve the time
- {
- otime = ltime;
- _localtime64_s(&thetime, &ltime);
-
- // Format the current time structure into a string
- // using %#x is the long date representation,
- // appropriate to the current locale
- if(wcsftime(str, sizeof(str) / sizeof(wchar_t), _T("%#x"), (const struct tm *)&thetime) &&
- (ltime > ctrl->nThread_tTimeout || ltime < otime)) // message displayed, no update until timeout
- ctrl->m_Manager.m_Text[0].SetText(str);
-
- if(wcsftime(str, sizeof(str) / sizeof(wchar_t), _T("%X"), (const struct tm *)&thetime))
- ctrl->m_Manager.m_Text[1].SetText(str);
- }
-
- ctrl->m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
- ctrl->m_Output.Draw(); // This invokes OnDraw for the active screen
- LeaveCriticalSection(&ctrl->cs);
- Sleep(LCD_UPD_TIMER);
- }
-
- _endthread();
+ CMPC_Lcd * ctrl = static_cast<CMPC_Lcd *> (Control);
+ wchar_t str[40];
+ __time64_t ltime;
+ __time64_t otime = 0;
+ struct tm thetime;
+ _tsetlocale(LC_ALL, _T("")); // set current system locale
+
+ while (ctrl->Thread_Loop)
+ {
+ EnterCriticalSection(&ctrl->cs);
+ if (_time64(&ltime) != otime) // Retrieve the time
+ {
+ otime = ltime;
+ _localtime64_s(&thetime, &ltime);
+
+ // Format the current time structure into a string
+ // using %#x is the long date representation,
+ // appropriate to the current locale
+ if (wcsftime(str, sizeof(str)/sizeof(wchar_t), _T("%#x"), (const struct tm *)&thetime) &&
+ (ltime > ctrl->nThread_tTimeout || ltime < otime)) // message displayed, no update until timeout
+ ctrl->m_Manager.m_Text[0].SetText(str);
+
+ if (wcsftime(str, sizeof(str)/sizeof(wchar_t), _T("%X"), (const struct tm *)&thetime))
+ ctrl->m_Manager.m_Text[1].SetText(str);
+ }
+
+ ctrl->m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
+ ctrl->m_Output.Draw(); // This invokes OnDraw for the active screen
+ LeaveCriticalSection(&ctrl->cs);
+ Sleep(LCD_UPD_TIMER);
+ }
+
+ _endthread();
}
@@ -80,112 +80,108 @@ void LCD_UpdateThread(void * Control)
HRESULT CLCDMyManager::Initialize()
{
- LOGFONT lf;
- HFONT hFont;
- unsigned int x, y;
-
- // max dims: 160 x 43
- x = 10;
- y = 0;
-
- // Initialize the text control (media)
- m_Text1.Initialize();
- m_Text1.SetOrigin(x, y);
- m_Text1.SetSize(160 - x, 13);
- m_Text1.SetAlignment(DT_CENTER);
- m_Text1.SetWordWrap(false);
- m_Text1.SetText(_T(""));
- m_Text1.SetStartDelay(5000);
- m_Text1.SetEndDelay(2000);
- m_Text1.EnableRepeat(true);
- m_Text1.SetScrollDirection(CLCDScrollingText::SCROLL_HORZ);
- m_Text1.SetSpeed(24);
-
- // Initialize the progressbar control (media progress)
- y += 15;
- m_ProgBar[1].Initialize();
- m_ProgBar[1].SetOrigin(x + 10, y);
- m_ProgBar[1].SetSize(160 - x - 10, 7);
- m_ProgBar[1].SetPos(0);
- m_ProgBar[1].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_H);
-
- // gfx
- m_PlayState.Initialize();
- m_PlayState.SetOrigin(x, y);
- m_PlayState.SetSize(7, 7);
-
- // Initialize the text control (time / mpc messages)
- y += 7;
- m_Text[0].Initialize();
- m_Text[0].SetOrigin(x, y);
- m_Text[0].SetSize(160 - x, /*13*/25);
- m_Text[0].SetAlignment(DT_CENTER);
- m_Text[0].SetWordWrap(false);
- m_Text[0].SetText(_T(""));
- m_Text[0].SetFontPointSize(7);
- hFont = m_Text[0].GetFont();
- GetObject(hFont, sizeof(LOGFONT), &lf);
- wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
- m_Text[0].SetFont(lf);
-
- y += 11;
- m_Text[1].Initialize();
- m_Text[1].SetOrigin(x, y);
- m_Text[1].SetSize(160 - x, /*13*/25);
- m_Text[1].SetAlignment(DT_CENTER);
- m_Text[1].SetWordWrap(false);
- m_Text[1].SetText(_T(""));
- m_Text[1].SetFontPointSize(7);
- hFont = m_Text[1].GetFont();
- GetObject(hFont, sizeof(LOGFONT), &lf);
- wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
- m_Text[1].SetFont(lf);
-
- // Initialize the progressbar control (volume)
- m_ProgBar[0].Initialize();
- m_ProgBar[0].SetOrigin(0, 0);
- m_ProgBar[0].SetSize(7, 43);
- m_ProgBar[0].SetPos(0);
- m_ProgBar[0].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_V);
-
- AddObject(&m_Text1);
- AddObject(&m_Text[0]);
- AddObject(&m_Text[1]);
- AddObject(&m_ProgBar[0]);
- AddObject(&m_ProgBar[1]);
- AddObject(&m_PlayState);
-
- return CLCDManager::Initialize();
+ LOGFONT lf;
+ HFONT hFont;
+ unsigned int x, y;
+
+ // max dims: 160 x 43
+ x = 10;
+ y = 0;
+
+ // Initialize the text control (media)
+ m_Text1.Initialize();
+ m_Text1.SetOrigin(x, y);
+ m_Text1.SetSize(160-x, 13);
+ m_Text1.SetAlignment(DT_CENTER);
+ m_Text1.SetWordWrap(false);
+ m_Text1.SetText(_T(""));
+ m_Text1.SetStartDelay(5000);
+ m_Text1.SetEndDelay(2000);
+ m_Text1.EnableRepeat(true);
+ m_Text1.SetScrollDirection(CLCDScrollingText::SCROLL_HORZ);
+ m_Text1.SetSpeed(24);
+
+ // Initialize the progressbar control (media progress)
+ y += 15;
+ m_ProgBar[1].Initialize();
+ m_ProgBar[1].SetOrigin(x+10, y);
+ m_ProgBar[1].SetSize(160-x-10, 7);
+ m_ProgBar[1].SetPos(0);
+ m_ProgBar[1].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_H);
+
+ // gfx
+ m_PlayState.Initialize();
+ m_PlayState.SetOrigin(x, y);
+ m_PlayState.SetSize(7, 7);
+
+ // Initialize the text control (time / mpc messages)
+ y += 7;
+ m_Text[0].Initialize();
+ m_Text[0].SetOrigin(x, y);
+ m_Text[0].SetSize(160-x, /*13*/25);
+ m_Text[0].SetAlignment(DT_CENTER);
+ m_Text[0].SetWordWrap(false);
+ m_Text[0].SetText(_T(""));
+ m_Text[0].SetFontPointSize(7);
+ hFont = m_Text[0].GetFont();
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+ wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
+ m_Text[0].SetFont(lf);
+
+ y += 11;
+ m_Text[1].Initialize();
+ m_Text[1].SetOrigin(x, y);
+ m_Text[1].SetSize(160-x, /*13*/25);
+ m_Text[1].SetAlignment(DT_CENTER);
+ m_Text[1].SetWordWrap(false);
+ m_Text[1].SetText(_T(""));
+ m_Text[1].SetFontPointSize(7);
+ hFont = m_Text[1].GetFont();
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+ wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
+ m_Text[1].SetFont(lf);
+
+ // Initialize the progressbar control (volume)
+ m_ProgBar[0].Initialize();
+ m_ProgBar[0].SetOrigin(0, 0);
+ m_ProgBar[0].SetSize(7, 43);
+ m_ProgBar[0].SetPos(0);
+ m_ProgBar[0].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_V);
+
+ AddObject(&m_Text1);
+ AddObject(&m_Text[0]);
+ AddObject(&m_Text[1]);
+ AddObject(&m_ProgBar[0]);
+ AddObject(&m_ProgBar[1]);
+ AddObject(&m_PlayState);
+
+ return CLCDManager::Initialize();
}
void CLCDMyManager::OnLCDButtonUp(int nButton)
{
- switch(nButton)
- {
- case LGLCDBUTTON_BUTTON0:
- {
- /* LOGFONT lf;
- HFONT hFont = m_Text1.GetFont();
-
- GetObject(hFont, sizeof(LOGFONT), &lf);
-
- CFontDialog cfd(&lf);
- if (cfd.DoModal() == IDOK)
- {
- cfd.GetCurrentFont(&lf);
- m_Text1.SetFont(lf);
- }
- */ break;
- }
- case LGLCDBUTTON_BUTTON1:
- break;
- case LGLCDBUTTON_BUTTON2:
- break;
- case LGLCDBUTTON_BUTTON3:
- break;
- default:
- break;
- }
+ switch(nButton)
+ {
+ case LGLCDBUTTON_BUTTON0:
+ {
+/* LOGFONT lf;
+ HFONT hFont = m_Text1.GetFont();
+
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+
+ CFontDialog cfd(&lf);
+ if (cfd.DoModal() == IDOK)
+ {
+ cfd.GetCurrentFont(&lf);
+ m_Text1.SetFont(lf);
+ }
+*/ break;
+ }
+ case LGLCDBUTTON_BUTTON1: break;
+ case LGLCDBUTTON_BUTTON2: break;
+ case LGLCDBUTTON_BUTTON3: break;
+ default: break;
+ }
}
@@ -195,182 +191,179 @@ void CLCDMyManager::OnLCDButtonUp(int nButton)
/* attach to an available lcd */
CMPC_Lcd::CMPC_Lcd(void)
{
- BYTE bPause[] = {0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF
- };
-
- BYTE bStop[] = {0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00
- };
-
- BYTE bPlay[] = {0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
- 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
- 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F
- };
-
- hBmp[PS_PLAY] = CreateBitmap(56, 7, 1, 1, bPlay);
- hBmp[PS_PAUSE] = CreateBitmap(14, 7, 1, 1, bPause);
- hBmp[PS_STOP] = CreateBitmap(8, 7, 1, 1, bStop);
-
- InitializeCriticalSection(&cs);
- hLCD_UpdateThread = NULL;
-
- // lcd init
- ZeroMemory(&m_ConnCtx, sizeof(m_ConnCtx));
-
- m_ConnCtx.appFriendlyName = _T(LCD_APP_NAME);
- m_ConnCtx.isPersistent = FALSE;
- m_ConnCtx.isAutostartable = FALSE;
- m_ConnCtx.onConfigure.configCallback = NULL; // we don't have a configuration screen
- m_ConnCtx.onConfigure.configContext = NULL;
- m_ConnCtx.connection = LGLCD_INVALID_CONNECTION; // the "connection" member will be returned upon return
-
- if(m_Output.Initialize(&m_ConnCtx) != ERROR_SUCCESS || // Initialize the output object
- m_Manager.Initialize() != ERROR_SUCCESS)
- {
- //_tperror(_T("Initialize"));
- return;
- }
-
- m_Manager.SetExpiration(INFINITE); // Set the expiration on the sample screen
-
- // Add and lock the screen onto our output manager
- m_Output.AddScreen(&m_Manager);
- m_Output.LockScreen(&m_Manager);
-
- m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
- m_Output.Draw(); // This invokes OnDraw for the active screen
-
- if(m_Output.IsOpened())
- {
- Thread_Loop = true;
- SetPlayState(PS_STOP);
- hLCD_UpdateThread = (HANDLE) _beginthread(LCD_UpdateThread, 512 /* stack */, (void*) this /* arg */);
- }
+ BYTE bPause[] = {0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF};
+
+ BYTE bStop[] = {0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00};
+
+ BYTE bPlay[] = {0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
+ 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
+
+ hBmp[PS_PLAY] = CreateBitmap(56, 7, 1, 1, bPlay);
+ hBmp[PS_PAUSE] = CreateBitmap(14, 7, 1, 1, bPause);
+ hBmp[PS_STOP] = CreateBitmap( 8, 7, 1, 1, bStop);
+
+ InitializeCriticalSection(&cs);
+ hLCD_UpdateThread = NULL;
+
+ // lcd init
+ ZeroMemory(&m_ConnCtx, sizeof(m_ConnCtx));
+
+ m_ConnCtx.appFriendlyName = _T(LCD_APP_NAME);
+ m_ConnCtx.isPersistent = FALSE;
+ m_ConnCtx.isAutostartable = FALSE;
+ m_ConnCtx.onConfigure.configCallback = NULL; // we don't have a configuration screen
+ m_ConnCtx.onConfigure.configContext = NULL;
+ m_ConnCtx.connection = LGLCD_INVALID_CONNECTION; // the "connection" member will be returned upon return
+
+ if (m_Output.Initialize(&m_ConnCtx) != ERROR_SUCCESS || // Initialize the output object
+ m_Manager.Initialize() != ERROR_SUCCESS)
+ {
+ //_tperror(_T("Initialize"));
+ return;
+ }
+
+ m_Manager.SetExpiration(INFINITE); // Set the expiration on the sample screen
+
+ // Add and lock the screen onto our output manager
+ m_Output.AddScreen(&m_Manager);
+ m_Output.LockScreen(&m_Manager);
+
+ m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
+ m_Output.Draw(); // This invokes OnDraw for the active screen
+
+ if (m_Output.IsOpened())
+ {
+ Thread_Loop = true;
+ SetPlayState(PS_STOP);
+ hLCD_UpdateThread = (HANDLE) _beginthread(LCD_UpdateThread, 512 /* stack */, (void*) this /* arg */);
+ }
}
/* detach from lcd */
CMPC_Lcd::~CMPC_Lcd(void)
{
- if(m_Output.IsOpened())
- {
- Thread_Loop = false;
- WaitForSingleObject(hLCD_UpdateThread, LCD_UPD_TIMER * 2 /* timeout */);
- hLCD_UpdateThread = NULL;
- }
+ if ( m_Output.IsOpened() )
+ {
+ Thread_Loop = false;
+ WaitForSingleObject( hLCD_UpdateThread, LCD_UPD_TIMER * 2 /* timeout */ );
+ hLCD_UpdateThread = NULL;
+ }
- DeleteCriticalSection(&cs);
+ DeleteCriticalSection( &cs );
- m_Output.Shutdown();
+ m_Output.Shutdown();
}
/* update title name */
void CMPC_Lcd::SetMediaTitle(const _TCHAR * text)
{
- EnterCriticalSection(&cs);
- m_Manager.m_Text1.SetText(text);
- m_Manager.m_ProgBar[1].SetPos(0);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_Text1.SetText(text);
+ m_Manager.m_ProgBar[1].SetPos(0);
+ LeaveCriticalSection(&cs);
}
/* set volume min/max */
void CMPC_Lcd::SetVolumeRange(__int64 nStart, __int64 nStop)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[0].SetRange(nStart, nStop);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[0].SetRange(nStart, nStop);
+ LeaveCriticalSection(&cs);
}
/* update volume */
void CMPC_Lcd::SetVolume(__int64 nVol)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[0].SetPos(nVol);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[0].SetPos(nVol);
+ LeaveCriticalSection(&cs);
}
/* set media min/max */
void CMPC_Lcd::SetMediaRange(__int64 nStart, __int64 nStop)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[1].SetRange(nStart, nStop);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[1].SetRange(nStart, nStop);
+ LeaveCriticalSection(&cs);
}
/* update media position */
void CMPC_Lcd::SetMediaPos(__int64 nPos)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[1].SetPos(nPos);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[1].SetPos(nPos);
+ LeaveCriticalSection(&cs);
}
/* update status message (displayed for nTimeOut milliseconds) */
void CMPC_Lcd::SetStatusMessage(const _TCHAR * text, int nTimeOut)
{
- if(!m_Output.IsOpened())
- return;
-
- __time64_t ltime;
- _time64(&ltime);
- if((nTimeOut /= 1000) < 1)
- nTimeOut = 1;
-
- EnterCriticalSection(&cs);
- nThread_tTimeout = ltime + nTimeOut;
- m_Manager.m_Text[0].SetText(text);
- LeaveCriticalSection(&cs);
+ if (!m_Output.IsOpened())
+ return;
+
+ __time64_t ltime;
+ _time64(&ltime);
+ if ((nTimeOut /= 1000) < 1)
+ nTimeOut = 1;
+
+ EnterCriticalSection(&cs);
+ nThread_tTimeout = ltime + nTimeOut;
+ m_Manager.m_Text[0].SetText(text);
+ LeaveCriticalSection(&cs);
}
/* update play state bitmap */
void CMPC_Lcd::SetPlayState(CMPC_Lcd::PlayState ps)
{
- if(!m_Output.IsOpened())
- return;
-
- EnterCriticalSection(&cs);
- switch(ps)
- {
- case PS_PLAY:
- m_Output.SetAsForeground(true);
- m_Manager.m_PlayState.SetBitmap(hBmp[PS_PLAY]);
- m_Manager.m_PlayState.ResetUpdate();
- m_Manager.m_PlayState.SetSubpicWidth(7);
- m_Manager.m_PlayState.SetAnimationRate(300);
- break;
-
- case PS_PAUSE:
- m_Manager.m_PlayState.SetBitmap(hBmp[PS_PAUSE]);
- m_Manager.m_PlayState.ResetUpdate();
- m_Manager.m_PlayState.SetSubpicWidth(7);
- m_Manager.m_PlayState.SetAnimationRate(800);
- break;
-
- case PS_STOP:
- m_Output.SetAsForeground(false);
- m_Manager.m_ProgBar[1].SetPos(0);
- m_Manager.m_PlayState.SetBitmap(hBmp[PS_STOP]);
- m_Manager.m_PlayState.ResetUpdate();
- m_Manager.m_PlayState.SetSubpicWidth(7);
- m_Manager.m_PlayState.SetAnimationRate(5000); // dummy, only one picture
- break;
-
- default:
- break;
- }
- LeaveCriticalSection(&cs);
+ if (!m_Output.IsOpened())
+ return;
+
+ EnterCriticalSection(&cs);
+ switch (ps)
+ {
+ case PS_PLAY:
+ m_Output.SetAsForeground(true);
+ m_Manager.m_PlayState.SetBitmap(hBmp[PS_PLAY]);
+ m_Manager.m_PlayState.ResetUpdate();
+ m_Manager.m_PlayState.SetSubpicWidth(7);
+ m_Manager.m_PlayState.SetAnimationRate(300);
+ break;
+
+ case PS_PAUSE:
+ m_Manager.m_PlayState.SetBitmap(hBmp[PS_PAUSE]);
+ m_Manager.m_PlayState.ResetUpdate();
+ m_Manager.m_PlayState.SetSubpicWidth(7);
+ m_Manager.m_PlayState.SetAnimationRate(800);
+ break;
+
+ case PS_STOP:
+ m_Output.SetAsForeground(false);
+ m_Manager.m_ProgBar[1].SetPos(0);
+ m_Manager.m_PlayState.SetBitmap(hBmp[PS_STOP]);
+ m_Manager.m_PlayState.ResetUpdate();
+ m_Manager.m_PlayState.SetSubpicWidth(7);
+ m_Manager.m_PlayState.SetAnimationRate(5000); // dummy, only one picture
+ break;
+
+ default:
+ break;
+ }
+ LeaveCriticalSection(&cs);
}
diff --git a/src/apps/mplayerc/LcdSupport.h b/src/apps/mplayerc/LcdSupport.h
index 436b5c0d7..8bf7ee0cd 100644
--- a/src/apps/mplayerc/LcdSupport.h
+++ b/src/apps/mplayerc/LcdSupport.h
@@ -33,49 +33,48 @@
#include "../../ui/LCDUI/LCDAnimatedBitmap.h"
-class CLCDMyManager : public CLCDManager
+class CLCDMyManager : public CLCDManager
{
-public:
- virtual HRESULT Initialize(void);
- virtual void OnLCDButtonUp(int nButton);
+ public:
+ virtual HRESULT Initialize(void);
+ virtual void OnLCDButtonUp(int nButton);
- CLCDScrollingText m_Text1;
- CLCDText m_Text[2];
- CLCDProgressBar m_ProgBar[2];
- CLCDAnimatedBitmap m_PlayState;
+ CLCDScrollingText m_Text1;
+ CLCDText m_Text[2];
+ CLCDProgressBar m_ProgBar[2];
+ CLCDAnimatedBitmap m_PlayState;
};
class CMPC_Lcd
{
-public:
- enum PlayState
- {
- PS_PLAY = 0,
- PS_PAUSE = 1,
- PS_STOP = 2,
- PS_UNUSED = 3
- };
+ public:
+ enum PlayState {
+ PS_PLAY = 0,
+ PS_PAUSE = 1,
+ PS_STOP = 2,
+ PS_UNUSED = 3
+ };
-private:
- lgLcdConnectContext m_ConnCtx;
- HANDLE hLCD_UpdateThread;
- HBITMAP hBmp[PS_UNUSED];
+ private:
+ lgLcdConnectContext m_ConnCtx;
+ HANDLE hLCD_UpdateThread;
+ HBITMAP hBmp[PS_UNUSED];
-public:
- CLCDOutput m_Output;
- CLCDMyManager m_Manager;
- bool Thread_Loop;
- __time64_t nThread_tTimeout;
- CRITICAL_SECTION cs;
+ public:
+ CLCDOutput m_Output;
+ CLCDMyManager m_Manager;
+ bool Thread_Loop;
+ __time64_t nThread_tTimeout;
+ CRITICAL_SECTION cs;
- CMPC_Lcd();
- ~CMPC_Lcd();
+ CMPC_Lcd();
+ ~CMPC_Lcd();
- void SetMediaTitle(const _TCHAR * text);
- void SetMediaRange(__int64 nStart, __int64 nStop);
- void SetMediaPos(__int64 nPos);
- void SetVolumeRange(__int64 nStart, __int64 nStop);
- void SetVolume(__int64 nVol);
- void SetStatusMessage(const _TCHAR * text, int nTimeOut);
- void SetPlayState(PlayState ps);
+ void SetMediaTitle(const _TCHAR * text);
+ void SetMediaRange(__int64 nStart, __int64 nStop);
+ void SetMediaPos(__int64 nPos);
+ void SetVolumeRange(__int64 nStart, __int64 nStop);
+ void SetVolume(__int64 nVol);
+ void SetStatusMessage(const _TCHAR * text, int nTimeOut);
+ void SetPlayState(PlayState ps);
};
diff --git a/src/apps/mplayerc/LineNumberEdit.cpp b/src/apps/mplayerc/LineNumberEdit.cpp
index 3f2dcb59a..9566e2cdd 100644
--- a/src/apps/mplayerc/LineNumberEdit.cpp
+++ b/src/apps/mplayerc/LineNumberEdit.cpp
@@ -2,19 +2,19 @@
CLineNumberEdit
Author : Johan Rosengren, Abstrakt Mekanik AB
Date : 2004-03-09
- Purpose : CLineNumberEdit is a CEdit-derived class that displays
+ Purpose : CLineNumberEdit is a CEdit-derived class that displays
line numbers to the left of the text.
- Description : The class uses the edit rect to make space for the line
- numbers. The line numbers are relized through a special
- CStatic-derived class, CLineNumberStatic. As soon as the
- text is updated, the CLineNumberStatic is updated as
+ Description : The class uses the edit rect to make space for the line
+ numbers. The line numbers are relized through a special
+ CStatic-derived class, CLineNumberStatic. As soon as the
+ text is updated, the CLineNumberStatic is updated as
well.
- Usage : The control can be dynamically created, or created from
- a dialog template. The formatting string for the line
- numbers can be set by calling SetLineNumberFormat (the
- same format string as for CString::Format). By calling
- SetMarginForegroundColor or SetMarginBackgroundColor
- the fore- and background colors for the line number
+ Usage : The control can be dynamically created, or created from
+ a dialog template. The formatting string for the line
+ numbers can be set by calling SetLineNumberFormat (the
+ same format string as for CString::Format). By calling
+ SetMarginForegroundColor or SetMarginBackgroundColor
+ the fore- and background colors for the line number
display is set.
========================================================================
Update : Keith Bowes
@@ -49,8 +49,8 @@
values may have unexpected results.
- CLineNumberEdit::m_format creates a duplicate of
CLineNumberStatic::m_format, is this needed?
- JRO: Even though the the two classes are thightly coupled,
- this duplication of data makes it easier to decouple them.
+ JRO: Even though the the two classes are thightly coupled,
+ this duplication of data makes it easier to decouple them.
A small matter, but code reuse is Politically Correct,
and as such A Desirable Feature.
- Added options could allow different system colours to be
@@ -58,22 +58,22 @@
- if m_maxval is exceeded in the edit box, new lines
are added without line numbers. This might not be the
desired behaviour.
- JRO: I think this is rather nifty, actually. If I, as a
- developer, sets the max number of lines to be numbered,
+ JRO: I think this is rather nifty, actually. If I, as a
+ developer, sets the max number of lines to be numbered,
I also expect this to be the case :-)))
- It's not spelled wrong, just differently. ;0)
========================================================================
Update : Johan Rosengren
Date : 2004-04-14
- Purpose : 1. Allow deriving of CLineNumberEdit.
+ Purpose : 1. Allow deriving of CLineNumberEdit.
Description : 1. Made the message handlers virtual.
- Usage : 1. Declare message handlers as virtual in derived
- classes. Note that CLineNumberEdit is not built to
+ Usage : 1. Declare message handlers as virtual in derived
+ classes. Note that CLineNumberEdit is not built to
be derived from, however.
========================================================================
Update : Keith Bowes
Date : 2004-04-22
- Purpose : To allow processing of WM_LINESCROLL messages.
+ Purpose : To allow processing of WM_LINESCROLL messages.
Description : Added OnLineScroll to handle the message.
Usage : Now will call UpdateTopAndBottom if the message is
received.
@@ -89,9 +89,9 @@
#include "stdafx.h"
#include "LineNumberEdit.h"
-// Registered message to allow selection of complete
+// Registered message to allow selection of complete
// lines by clicking the line number
-UINT urm_SELECTLINE = ::RegisterWindowMessage(_T("_LINE_NUMBER_EDIT_SELECTLINE_"));
+UINT urm_SELECTLINE = ::RegisterWindowMessage( _T("_LINE_NUMBER_EDIT_SELECTLINE_") );
/////////////////////////////////////////////////////////////////////////////
// CLineNumberEdit
@@ -99,37 +99,37 @@ CLineNumberEdit::CLineNumberEdit()
/* ============================================================
Function : CLineNumberEdit::CLineNumberEdit
Description : constructor
-
+
Return : void
Parameters : none
- Usage :
+ Usage :
============================================================*/
{
- m_hWnd = NULL;
- m_line.m_hWnd = NULL;
- m_zero.cx = 0;
- m_zero.cy = 0;
- m_format = _T("%03i");
- m_LineDelta = 1;
+ m_hWnd = NULL;
+ m_line.m_hWnd = NULL;
+ m_zero.cx = 0;
+ m_zero.cy = 0;
+ m_format = _T( "%03i" );
+ m_LineDelta = 1;
- // Could default m_maxval to 99,999, but may cause problems
- // if m_format is changed and m_maxval is not...
- m_maxval = 998;
+ // Could default m_maxval to 99,999, but may cause problems
+ // if m_format is changed and m_maxval is not...
+ m_maxval = 998;
- // Setting up so by defult the original hard-coded colour
- // scheme is used when enabled and the system colours are
- // used when disabled.
- m_bUseEnabledSystemColours = FALSE;
- m_bUseDisabledSystemColours = TRUE;
- m_EnabledFgCol = RGB(0, 0, 0);
- m_EnabledBgCol = RGB(200, 200, 200);
- m_DisabledFgCol = GetSysColor(COLOR_GRAYTEXT);
- m_DisabledBgCol = GetSysColor(COLOR_3DFACE);
+ // Setting up so by defult the original hard-coded colour
+ // scheme is used when enabled and the system colours are
+ // used when disabled.
+ m_bUseEnabledSystemColours = FALSE;
+ m_bUseDisabledSystemColours = TRUE;
+ m_EnabledFgCol = RGB( 0, 0, 0 );
+ m_EnabledBgCol = RGB( 200, 200, 200 );
+ m_DisabledFgCol = GetSysColor( COLOR_GRAYTEXT );
+ m_DisabledBgCol = GetSysColor( COLOR_3DFACE );
- SetWindowColour();
+ SetWindowColour();
}
@@ -137,35 +137,35 @@ CLineNumberEdit::~CLineNumberEdit()
/* ============================================================
Function : CLineNumberEdit::~CLineNumberEdit
Description : destructor
-
+
Return : void
Parameters : none
- Usage :
+ Usage :
============================================================*/
{
}
BEGIN_MESSAGE_MAP(CLineNumberEdit, CEdit)
- ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
- ON_WM_VSCROLL()
- ON_CONTROL_REFLECT(EN_VSCROLL, OnVscroll)
- ON_MESSAGE(WM_SETFONT, OnSetFont)
- ON_WM_SIZE()
- ON_MESSAGE(WM_SETTEXT, OnSetText)
- ON_WM_SYSCOLORCHANGE()
- ON_WM_ENABLE()
- ON_MESSAGE(EM_LINESCROLL, OnLineScroll)
- ON_REGISTERED_MESSAGE(urm_SELECTLINE, OnSelectLine)
+ ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
+ ON_WM_VSCROLL()
+ ON_CONTROL_REFLECT(EN_VSCROLL, OnVscroll)
+ ON_MESSAGE(WM_SETFONT, OnSetFont)
+ ON_WM_SIZE()
+ ON_MESSAGE(WM_SETTEXT, OnSetText)
+ ON_WM_SYSCOLORCHANGE()
+ ON_WM_ENABLE()
+ ON_MESSAGE(EM_LINESCROLL, OnLineScroll)
+ ON_REGISTERED_MESSAGE(urm_SELECTLINE, OnSelectLine)
END_MESSAGE_MAP()
-void CLineNumberEdit::PreSubclassWindow()
+void CLineNumberEdit::PreSubclassWindow()
/* ============================================================
Function : CLineNumberEdit::PreSubclassWindow
- Description : This function is called before the control
- is subclassed for a control on a dialog
- template, and during creation for
+ Description : This function is called before the control
+ is subclassed for a control on a dialog
+ template, and during creation for
dynamically created controls.
Return : void
@@ -176,24 +176,24 @@ void CLineNumberEdit::PreSubclassWindow()
============================================================*/
{
- // Unfortunately, we can't change to ES_MULTILINE
- // during run-time.
- ASSERT(GetStyle() & ES_MULTILINE);
+ // Unfortunately, we can't change to ES_MULTILINE
+ // during run-time.
+ ASSERT( GetStyle() & ES_MULTILINE );
- // Creating the line number control
- SetLineNumberFormat(m_format);
+ // Creating the line number control
+ SetLineNumberFormat( m_format );
}
/////////////////////////////////////////////////////////////////////////////
// CLineNumberEdit message handlers
-void CLineNumberEdit::OnSysColorChange()
+void CLineNumberEdit::OnSysColorChange()
/* ============================================================
Function : CLineNumberEdit::OnSysColorChange
Description : Handles WM_SYSCOLORCHANGE. User has changed
the system colours, want to refresh.
-
+
Return : void
Parameters : void
@@ -202,19 +202,19 @@ void CLineNumberEdit::OnSysColorChange()
============================================================*/
{
- CEdit::OnSysColorChange();
+ CEdit::OnSysColorChange();
// update the CStatic with the new colours
- SetWindowColour(IsWindowEnabled());
+ SetWindowColour( IsWindowEnabled() );
}
-LRESULT CLineNumberEdit::OnSetText(WPARAM wParam, LPARAM lParam)
+LRESULT CLineNumberEdit::OnSetText( WPARAM wParam, LPARAM lParam )
/* ============================================================
Function : CLineNumberEdit::OnSetText
- Description : Handles WM_SETTEXT. We must update the line
+ Description : Handles WM_SETTEXT. We must update the line
numbers in the line number control as well.
-
+
Return : LRESULT - From Def proc
Parameters : WPARAM wParam - From Windows
LPARAM lParam - From Windows
@@ -224,20 +224,20 @@ LRESULT CLineNumberEdit::OnSetText(WPARAM wParam, LPARAM lParam)
============================================================*/
{
- // Default processing
- LRESULT retval = DefWindowProc(WM_SETTEXT, wParam, lParam);
- UpdateTopAndBottom();
- return retval;
+ // Default processing
+ LRESULT retval = DefWindowProc( WM_SETTEXT, wParam, lParam );
+ UpdateTopAndBottom();
+ return retval;
}
-void CLineNumberEdit::OnChange()
+void CLineNumberEdit::OnChange()
/* ============================================================
Function : CLineNumberEdit::OnChange
- Description : Mapped to EN_CHANGE. We must handle
- EN_CHANGE to let the line-number control
+ Description : Mapped to EN_CHANGE. We must handle
+ EN_CHANGE to let the line-number control
reflect changes to the edit box content.
-
+
Return : void
Parameters : none
@@ -246,16 +246,16 @@ void CLineNumberEdit::OnChange()
============================================================*/
{
- UpdateTopAndBottom();
+ UpdateTopAndBottom();
}
-void CLineNumberEdit::OnVscroll()
+void CLineNumberEdit::OnVscroll()
/* ============================================================
Function : CLineNumberEdit::OnVscroll
- Description : Mapped to EN_VSCROLL. We update the line
+ Description : Mapped to EN_VSCROLL. We update the line
numbers in the line number control
-
+
Return : void
Parameters : none
@@ -264,17 +264,17 @@ void CLineNumberEdit::OnVscroll()
============================================================*/
{
- UpdateTopAndBottom();
+ UpdateTopAndBottom();
}
-void CLineNumberEdit::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
+void CLineNumberEdit::OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar )
/* ============================================================
Function : CLineNumberEdit::OnVScroll
- Description : Handles WM_VSCROLL. We handle WM_VSCROLL
- in addition to the notification EN_VSCROLL,
+ Description : Handles WM_VSCROLL. We handle WM_VSCROLL
+ in addition to the notification EN_VSCROLL,
to handle scrollbar dragging as well
-
+
Return : void
Parameters : UINT nSBCode - From Windows
UINT nPos - From Windows
@@ -285,36 +285,36 @@ void CLineNumberEdit::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
============================================================*/
{
- CEdit::OnVScroll(nSBCode, nPos, pScrollBar);
- UpdateTopAndBottom();
+ CEdit::OnVScroll( nSBCode, nPos, pScrollBar );
+ UpdateTopAndBottom();
}
-LRESULT CLineNumberEdit::OnLineScroll(WPARAM wParam, LPARAM lParam)
+LRESULT CLineNumberEdit::OnLineScroll( WPARAM wParam, LPARAM lParam )
/* ============================================================
Function : CLineNumberEdit::OnLineScroll
- Description : Mapped to EM_LINESCROLL. We update the line
+ Description : Mapped to EM_LINESCROLL. We update the line
numbers in the line number control.
-
+
Return : void
Parameters : none
Usage : Called from Windows
============================================================*/
{
- // Default processing
- LRESULT retval = DefWindowProc(EM_LINESCROLL, wParam, lParam);
- UpdateTopAndBottom();
- return retval;
+ // Default processing
+ LRESULT retval = DefWindowProc( EM_LINESCROLL, wParam, lParam );
+ UpdateTopAndBottom();
+ return retval;
}
-LRESULT CLineNumberEdit::OnSetFont(WPARAM wParam, LPARAM lParam)
+LRESULT CLineNumberEdit::OnSetFont( WPARAM wParam, LPARAM lParam )
/* ============================================================
Function : CLineNumberEdit::OnSetFont
- Description : Mapped to WM_SETFONT. We must recalculate
+ Description : Mapped to WM_SETFONT. We must recalculate
the line number control size as well.
-
+
Return : LRESULT - Always 0
Parameters : WPARAM wParam - From Windows
LPARAM lParam - From Windows
@@ -324,20 +324,20 @@ LRESULT CLineNumberEdit::OnSetFont(WPARAM wParam, LPARAM lParam)
============================================================*/
{
- DefWindowProc(WM_SETFONT, wParam, lParam);
- // We resize the line-number
- // field
- Prepare();
- return 0;
+ DefWindowProc( WM_SETFONT, wParam, lParam );
+ // We resize the line-number
+ // field
+ Prepare();
+ return 0;
}
-void CLineNumberEdit::OnSize(UINT nType, int cx, int cy)
+void CLineNumberEdit::OnSize( UINT nType, int cx, int cy )
/* ============================================================
Function : CLineNumberEdit::OnSize
- Description : Handles WM_SIZE. Recalculates the line
+ Description : Handles WM_SIZE. Recalculates the line
number control size as well.
-
+
Return : void
Parameters : UINT nType - From Windows
int cx - From Windows
@@ -348,21 +348,21 @@ void CLineNumberEdit::OnSize(UINT nType, int cx, int cy)
============================================================*/
{
- CEdit::OnSize(nType, cx, cy);
-
- // If we have the line-number
- // control, it must be resized
- // as well.
- if(m_line.m_hWnd)
- Prepare();
+ CEdit::OnSize( nType, cx, cy );
+ // If we have the line-number
+ // control, it must be resized
+ // as well.
+ if( m_line.m_hWnd )
+ Prepare();
+
}
-void CLineNumberEdit::OnEnable(BOOL bEnable)
+void CLineNumberEdit::OnEnable( BOOL bEnable )
/* ============================================================
Function : CLineNumberEdit::OnEnable
Description : Handles WM_ENABLE. Calls to set colours.
-
+
Return : void
Parameters : BOOL bEnable - From Windows
@@ -371,44 +371,44 @@ void CLineNumberEdit::OnEnable(BOOL bEnable)
============================================================*/
{
- CEdit::OnEnable(bEnable);
- SetWindowColour(bEnable);
+ CEdit::OnEnable( bEnable );
+ SetWindowColour( bEnable );
}
-LRESULT CLineNumberEdit::OnSelectLine(WPARAM wParam, LPARAM /*lParam*/)
+LRESULT CLineNumberEdit::OnSelectLine(WPARAM wParam, LPARAM /*lParam*/ )
/* ============================================================
Function : CLineNumberEdit::OnSelectLine
Description : Handler for the urm_SELECTLINE registered
message. Will select the line in wParam.
-
+
Return : LRESULT - Not used
Parameters : WPARAM wParam - The line to select
LPARAM lParam - Not used
-
- Usage : Called from MFC. Use
- SendMessage( urm_SELECTLINE, line ) from
+
+ Usage : Called from MFC. Use
+ SendMessage( urm_SELECTLINE, line ) from
code.
============================================================*/
{
- // Calc start and end position of the line
- int lineno = wParam + GetScrollPos(SB_VERT);
- int start = LineIndex(lineno);
- int end = LineIndex(lineno + 1);
- SetSel(start, end - 1);
- return 0;
+ // Calc start and end position of the line
+ int lineno = wParam + GetScrollPos( SB_VERT );
+ int start = LineIndex( lineno );
+ int end = LineIndex( lineno + 1 );
+ SetSel( start, end - 1 );
+ return 0;
}
-void CLineNumberEdit::SetWindowColour(BOOL bEnable /*= TRUE*/)
+void CLineNumberEdit::SetWindowColour( BOOL bEnable /*= TRUE*/ )
/* ============================================================
Function : CLineNumberEdit::SetWindowColour
Description : Handles changing window colours.
-
+
Return : void
- Parameters : BOOL bEnable - flag if set enabled/disabled
+ Parameters : BOOL bEnable - flag if set enabled/disabled
colours
Usage : Called to change colours in the edit box.
@@ -416,43 +416,41 @@ void CLineNumberEdit::SetWindowColour(BOOL bEnable /*= TRUE*/)
============================================================*/
{
- if(m_bUseEnabledSystemColours)
+ if (m_bUseEnabledSystemColours)
{
- // re-query the system colours in case they have changed.
- m_EnabledFgCol = GetSysColor(COLOR_WINDOWTEXT);
- m_EnabledBgCol = GetSysColor(COLOR_WINDOW);
+ // re-query the system colours in case they have changed.
+ m_EnabledFgCol = GetSysColor( COLOR_WINDOWTEXT );
+ m_EnabledBgCol = GetSysColor( COLOR_WINDOW );
}
- if(m_bUseDisabledSystemColours)
+ if (m_bUseDisabledSystemColours)
{
- // re-query the system colours in case they have changed.
- m_DisabledFgCol = GetSysColor(COLOR_GRAYTEXT);
- m_DisabledBgCol = GetSysColor(COLOR_3DFACE);
+ // re-query the system colours in case they have changed.
+ m_DisabledFgCol = GetSysColor( COLOR_GRAYTEXT );
+ m_DisabledBgCol = GetSysColor( COLOR_3DFACE );
}
// change the colour based on bEnable
- if(bEnable)
+ if (bEnable)
{
- m_line.SetFgColor(m_EnabledFgCol, TRUE);
- m_line.SetBgColor(m_EnabledBgCol, TRUE);
- }
- else
- {
- m_line.SetFgColor(m_DisabledFgCol, TRUE);
- m_line.SetBgColor(m_DisabledBgCol, TRUE);
+ m_line.SetFgColor( m_EnabledFgCol, TRUE );
+ m_line.SetBgColor( m_EnabledBgCol, TRUE );
+ } else {
+ m_line.SetFgColor( m_DisabledFgCol, TRUE );
+ m_line.SetBgColor( m_DisabledBgCol, TRUE );
}
}
-void CLineNumberEdit::UseSystemColours(BOOL bUseEnabled /*= TRUE*/, BOOL bUseDisabled /*= TRUE*/)
+void CLineNumberEdit::UseSystemColours( BOOL bUseEnabled /*= TRUE*/, BOOL bUseDisabled /*= TRUE*/ )
/* ============================================================
Function : CLineNumberEdit::UseSystemColours
Description : Sets the Use*SystemColours flags.
-
+
Return : void
- Parameters : BOOL bEnabled - flag if to use enabled
+ Parameters : BOOL bEnabled - flag if to use enabled
system colours
- BOOL bDisabled - flag if to use disabled
+ BOOL bDisabled - flag if to use disabled
system colours
Usage : Called to change colours in the edit box
@@ -463,10 +461,10 @@ void CLineNumberEdit::UseSystemColours(BOOL bUseEnabled /*= TRUE*/, BOOL bUseDis
m_bUseEnabledSystemColours = bUseEnabled;
m_bUseDisabledSystemColours = bUseDisabled;
BOOL bEnable = TRUE;
- if(::IsWindow(m_hWnd))
+ if (::IsWindow(m_hWnd))
bEnable = IsWindowEnabled();
- SetWindowColour(bEnable);
+ SetWindowColour( bEnable );
}
@@ -476,138 +474,138 @@ void CLineNumberEdit::UseSystemColours(BOOL bUseEnabled /*= TRUE*/, BOOL bUseDis
void CLineNumberEdit::Prepare()
/* ============================================================
Function : CLineNumberEdit::Prepare
- Description : Setting the edit rect for the control and
- either create or move the line number
- control. Also sets the top- and bottom
+ Description : Setting the edit rect for the control and
+ either create or move the line number
+ control. Also sets the top- and bottom
line numbers.
-
+
Return : void
Parameters : none
- Usage : Must be called to (re)establish the edit
- rect, must also be called as soon as the
+ Usage : Must be called to (re)establish the edit
+ rect, must also be called as soon as the
control changes size.
============================================================*/
{
- // Calc sizes
- int width = CalcLineNumberWidth();
- CRect rect;
- GetClientRect(&rect);
- CRect rectEdit(rect);
- rect.right = width;
- rectEdit.left = rect.right + 3;
+ // Calc sizes
+ int width = CalcLineNumberWidth();
+ CRect rect;
+ GetClientRect( &rect );
+ CRect rectEdit( rect );
+ rect.right = width;
+ rectEdit.left = rect.right + 3;
- // Setting the edit rect and
- // creating or moving child control
- SetRect(&rectEdit);
- if(m_line.m_hWnd)
- m_line.MoveWindow(0, 0, width, rect.Height());
- else
- m_line.Create(NULL, WS_CHILD | WS_VISIBLE | SS_NOTIFY, rect, this, 1);
+ // Setting the edit rect and
+ // creating or moving child control
+ SetRect( &rectEdit );
+ if( m_line.m_hWnd )
+ m_line.MoveWindow( 0, 0, width, rect.Height() );
+ else
+ m_line.Create(NULL,WS_CHILD | WS_VISIBLE | SS_NOTIFY, rect, this, 1 );
- GetRect(&rectEdit);
+ GetRect( &rectEdit );
- // Update line number control data
- m_line.SetTopMargin(rectEdit.top);
- UpdateTopAndBottom();
+ // Update line number control data
+ m_line.SetTopMargin( rectEdit.top );
+ UpdateTopAndBottom();
}
int CLineNumberEdit::CalcLineNumberWidth()
/* ============================================================
Function : CLineNumberEdit::CalcLineNumberWidth
- Description : Calculates the desired width of the line
- number control, using the current format
- string and the max number of chars allowed
- (pessimistic - assumes one character per
+ Description : Calculates the desired width of the line
+ number control, using the current format
+ string and the max number of chars allowed
+ (pessimistic - assumes one character per
line).
-
+
Return : int - The width in pixels
Parameters : none
- Usage : Called as soon as the format string is
+ Usage : Called as soon as the format string is
changed.
============================================================*/
{
- CClientDC dc(this);
+ CClientDC dc( this );
- // If a new font is set during runtime,
- // we must explicitly select the font into
- // the CClientDC to measure it.
- CFont* font = GetFont();
- CFont* oldFont = dc.SelectObject(font);
+ // If a new font is set during runtime,
+ // we must explicitly select the font into
+ // the CClientDC to measure it.
+ CFont* font = GetFont();
+ CFont* oldFont = dc.SelectObject( font );
- m_zero = dc.GetTextExtent(_T("0"));
- CString format;
+ m_zero=dc.GetTextExtent( _T( "0" ) );
+ CString format;
// GetLimitText returns the number of bytes the edit box may contain,
// not the max number of lines...
- //... which is the max number of lines, given one character per d:o :-)
- int maxval = GetLimitText();
- if(m_maxval > 0)
+ //... which is the max number of lines, given one character per d:o :-)
+ int maxval = GetLimitText();
+ if (m_maxval > 0)
maxval = m_maxval + m_LineDelta;
- format.Format(m_format, maxval);
- CSize fmt = dc.GetTextExtent(format);
- dc.SelectObject(oldFont);
+ format.Format( m_format, maxval );
+ CSize fmt = dc.GetTextExtent( format );
+ dc.SelectObject( oldFont );
- // Calculate the size of the line-
- // number field. We add a 5 pixel margin
- // to the max size of the format string
- return fmt.cx + 5;
+ // Calculate the size of the line-
+ // number field. We add a 5 pixel margin
+ // to the max size of the format string
+ return fmt.cx + 5;
}
-void CLineNumberEdit::UpdateTopAndBottom()
+void CLineNumberEdit::UpdateTopAndBottom()
/* ============================================================
Function : CLineNumberEdit::UpdateTopAndBottom
- Description : Updates the top- and bottom line number
+ Description : Updates the top- and bottom line number
for the line number control.
-
+
Return : void
Parameters : none
- Usage : Should be called as soon as the contents of
+ Usage : Should be called as soon as the contents of
the control is changed.
============================================================*/
{
- CRect rect;
- GetClientRect(&rect);
- int maxline = GetLineCount() + m_LineDelta;
+ CRect rect;
+ GetClientRect( &rect );
+ int maxline = GetLineCount() + m_LineDelta;
- // Height for individual lines
- int lineheight = m_zero.cy;
+ // Height for individual lines
+ int lineheight = m_zero.cy;
- // Calculate the number of lines to draw
- int topline = GetFirstVisibleLine() + m_LineDelta;
- if((topline + (rect.Height() / lineheight)) < maxline)
- maxline = topline + (rect.Height() / lineheight);
+ // Calculate the number of lines to draw
+ int topline = GetFirstVisibleLine() + m_LineDelta;
+ if( ( topline + ( rect.Height() / lineheight ) ) < maxline )
+ maxline = topline + ( rect.Height() / lineheight );
- if(m_maxval > 0 && maxline > m_maxval + m_LineDelta)
+ if ( m_maxval > 0 && maxline > m_maxval + m_LineDelta )
maxline = m_maxval + m_LineDelta;
- m_line.SetTopAndBottom(topline, maxline);
+ m_line.SetTopAndBottom( topline, maxline );
}
/////////////////////////////////////////////////////////////////////////////
// CLineNumberEdit public implementation
-void CLineNumberEdit::SetMarginForegroundColor(COLORREF col, BOOL redraw, BOOL bEnabled /*= TRUE*/)
+void CLineNumberEdit::SetMarginForegroundColor( COLORREF col, BOOL redraw, BOOL bEnabled /*= TRUE*/ )
/* ============================================================
Function : CLineNumberEdit::SetMarginForegroundColor
- Description : Sets the text color for the number
+ Description : Sets the text color for the number
margin.
-
+
Return : void
- Parameters : COLORREF col - The new text color
- BOOL redraw - TRUE if the control
- should be redrawn
+ Parameters : COLORREF col - The new text color
+ BOOL redraw - TRUE if the control
+ should be redrawn
(default)
Usage : Call to set a new text color for the line
@@ -617,81 +615,77 @@ void CLineNumberEdit::SetMarginForegroundColor(COLORREF col, BOOL redraw, BOOL b
============================================================*/
{
- m_line.SetFgColor(col, redraw);
- if(bEnabled)
+ m_line.SetFgColor( col, redraw );
+ if (bEnabled)
{
m_bUseEnabledSystemColours = FALSE;
m_EnabledFgCol = col;
- }
- else
- {
+ } else {
m_bUseDisabledSystemColours = FALSE;
m_DisabledFgCol = col;
}
}
-void CLineNumberEdit::SetMarginBackgroundColor(COLORREF col, BOOL redraw, BOOL bEnabled /*= TRUE*/)
+void CLineNumberEdit::SetMarginBackgroundColor( COLORREF col, BOOL redraw, BOOL bEnabled /*= TRUE*/ )
/* ============================================================
Function : CLineNumberEdit::SetMarginBackgroundColor
- Description : Sets the background color for the number
+ Description : Sets the background color for the number
margin.
-
+
Return : void
- Parameters : COLORREF col - The new background color
- BOOL redraw - TRUE if the control
- should be redrawn
+ Parameters : COLORREF col - The new background color
+ BOOL redraw - TRUE if the control
+ should be redrawn
(default)
- Usage : Call to set a new background color for the
- line number margin. The control will be
+ Usage : Call to set a new background color for the
+ line number margin. The control will be
redrawn if it exists.
============================================================*/
{
- m_line.SetBgColor(col, redraw);
- if(bEnabled)
+ m_line.SetBgColor( col, redraw );
+ if (bEnabled)
{
m_bUseEnabledSystemColours = FALSE;
m_EnabledBgCol = col;
- }
- else
- {
+ } else {
m_bUseDisabledSystemColours = FALSE;
m_DisabledBgCol = col;
}
}
-void CLineNumberEdit::SetLineNumberFormat(CString format)
+void CLineNumberEdit::SetLineNumberFormat( CString format )
/* ============================================================
Function : CLineNumberEdit::SetLineNumberFormat
- Description : Changes the way line numbers are presented
- on screen.
-
+ Description : Changes the way line numbers are presented
+ on screen.
+
Return : void
Parameters : CString format - The new format string
- Usage : Call with a format string using the same
- format as CString::Format. It should contain
+ Usage : Call with a format string using the same
+ format as CString::Format. It should contain
one and only one numeric type.
============================================================*/
{
- m_format = format;
- m_line.SetLineNumberFormat(format);
- if(m_hWnd)
- Prepare();
+ m_format = format;
+ m_line.SetLineNumberFormat( format );
+ if( m_hWnd )
+ Prepare();
}
-void CLineNumberEdit::SetLineNumberRange(UINT nMin, UINT nMax /*= 0*/)
+void CLineNumberEdit::SetLineNumberRange( UINT nMin, UINT nMax /*= 0*/ )
/* ============================================================
Function : CLineNumberEdit::SetLineNumberRange
- Description : Changes the default min and max line numbers.
-
+ Description : Changes the default min and max line numbers.
+
Return : void
Parameters : int nMin - changes the line offset
int nMax - changes the max line number
@@ -701,8 +695,8 @@ void CLineNumberEdit::SetLineNumberRange(UINT nMin, UINT nMax /*= 0*/)
============================================================*/
{
- m_LineDelta = (int) nMin;
- m_maxval = (int) nMax;
+ m_LineDelta = ( int ) nMin;
+ m_maxval = ( int ) nMax;
}
@@ -713,18 +707,18 @@ CLineNumberStatic::CLineNumberStatic()
/* ============================================================
Function : CLineNumberStatic::CLineNumberStatic
Description : constructor
-
+
Return : void
Parameters : none
- Usage :
+ Usage :
============================================================*/
{
- m_bgcol = RGB(255, 255, 248);
- m_fgcol = RGB(0, 0, 0);
- m_format = _T("%05i");
+ m_bgcol = RGB( 255, 255, 248 );
+ m_fgcol = RGB( 0, 0, 0 );
+ m_format = _T( "%05i" );
m_topline = 0;
m_bottomline = 0;
}
@@ -733,30 +727,30 @@ CLineNumberStatic::~CLineNumberStatic()
/* ============================================================
Function : CLineNumberStatic::~CLineNumberStatic
Description : destructor
-
+
Return : void
Parameters : none
- Usage :
+ Usage :
============================================================*/
{
}
BEGIN_MESSAGE_MAP(CLineNumberStatic, CStatic)
- ON_WM_PAINT()
- ON_WM_ERASEBKGND()
- ON_WM_LBUTTONDOWN()
+ ON_WM_PAINT()
+ ON_WM_ERASEBKGND()
+ ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLineNumberStatic message handlers
-void CLineNumberStatic::OnPaint()
+void CLineNumberStatic::OnPaint()
/* ============================================================
Function : CLineNumberStatic::OnPaint
- Description : Handler for WM_PAINT.
-
+ Description : Handler for WM_PAINT.
+
Return : void
Parameters : none
@@ -765,60 +759,60 @@ void CLineNumberStatic::OnPaint()
============================================================*/
{
- CPaintDC dcPaint(this);
+ CPaintDC dcPaint( this );
- CRect rect;
- GetClientRect(&rect);
+ CRect rect;
+ GetClientRect( &rect );
- // We double buffer the drawing -
- // preparing the memory CDC
- CDC dc;
- dc.CreateCompatibleDC(&dcPaint);
- int saved = dc.SaveDC();
+ // We double buffer the drawing -
+ // preparing the memory CDC
+ CDC dc;
+ dc.CreateCompatibleDC( &dcPaint );
+ int saved = dc.SaveDC();
- // Create GDI and select objects
- CBitmap bmp;
- CPen pen;
- bmp.CreateCompatibleBitmap(&dcPaint, rect.Width(), rect.Height());
- pen.CreatePen(PS_SOLID, 1, m_fgcol);
- dc.SelectObject(&bmp);
- dc.SelectObject(&pen);
+ // Create GDI and select objects
+ CBitmap bmp;
+ CPen pen;
+ bmp.CreateCompatibleBitmap( &dcPaint, rect.Width(), rect.Height() );
+ pen.CreatePen( PS_SOLID, 1, m_fgcol );
+ dc.SelectObject( &bmp );
+ dc.SelectObject( &pen );
- // Painting the background
- dc.FillSolidRect(&rect, m_bgcol);
- dc.MoveTo(rect.right - 1, 0);
- dc.LineTo(rect.right - 1, rect.bottom);
+ // Painting the background
+ dc.FillSolidRect( &rect, m_bgcol );
+ dc.MoveTo( rect.right - 1, 0 );
+ dc.LineTo( rect.right - 1, rect.bottom );
- // Setting other attributes
- dc.SetTextColor(m_fgcol);
- dc.SetBkColor(m_bgcol);
- dc.SelectObject(GetParent()->GetFont());
+ // Setting other attributes
+ dc.SetTextColor( m_fgcol );
+ dc.SetBkColor( m_bgcol );
+ dc.SelectObject( GetParent()->GetFont() );
- // Output the line numbers
- if(m_bottomline)
- {
- int lineheight = dc.GetTextExtent(_T("0")).cy;
- for(int t = m_topline ; t < m_bottomline ; t++)
- {
- CString output;
- output.Format(m_format, t);
- int topposition = m_topmargin + lineheight * (t - m_topline);
- dc.TextOut(2, topposition, output);
- }
- }
+ // Output the line numbers
+ if( m_bottomline )
+ {
+ int lineheight = dc.GetTextExtent( _T( "0" ) ).cy;
+ for( int t = m_topline ; t < m_bottomline ; t++ )
+ {
+ CString output;
+ output.Format( m_format, t );
+ int topposition = m_topmargin + lineheight * ( t - m_topline );
+ dc.TextOut( 2, topposition, output );
+ }
+ }
- dcPaint.BitBlt(0, 0, rect. right, rect.bottom, &dc, 0, 0, SRCCOPY);
- dc.RestoreDC(saved);
+ dcPaint.BitBlt( 0, 0, rect. right, rect.bottom, &dc, 0, 0, SRCCOPY );
+ dc.RestoreDC( saved );
}
-BOOL CLineNumberStatic::OnEraseBkgnd(CDC*)
+BOOL CLineNumberStatic::OnEraseBkgnd( CDC* )
/* ============================================================
Function : CLineNumberStatic::OnEraseBkgnd
Description : Mapped to WM_ERASEBKGND. Handled to avoid
- flicker, as we redraw the complete control
+ flicker, as we redraw the complete control
in OnPaint
-
+
Return : BOOL - Always TRUE
Parameters : CDC* - From Windows
@@ -827,52 +821,52 @@ BOOL CLineNumberStatic::OnEraseBkgnd(CDC*)
============================================================*/
{
- return TRUE;
+ return TRUE;
}
-void CLineNumberStatic::OnLButtonDown(UINT nFlags, CPoint point)
+void CLineNumberStatic::OnLButtonDown( UINT nFlags, CPoint point )
/* ============================================================
Function : CLineNumberStatic::OnLButtonDown
Description : Called when the control is clicked. Will
- send the urm_SELECTLINE registered message
+ send the urm_SELECTLINE registered message
to the parent to select the line clicked on.
-
+
Return : void
Parameters : UINT nFlags - Not used
CPoint point - Position of cursor
-
+
Usage : Called from Windows.
============================================================*/
{
- // Find the line clicked on
- CClientDC dc(this);
- dc.SelectObject(GetParent()->GetFont());
- int lineheight = dc.GetTextExtent(_T("0")).cy;
- int lineno = (int)((double) point.y / (double) lineheight);
+ // Find the line clicked on
+ CClientDC dc( this );
+ dc.SelectObject( GetParent()->GetFont() );
+ int lineheight = dc.GetTextExtent( _T( "0" ) ).cy;
+ int lineno = ( int ) ( ( double ) point.y / ( double ) lineheight );
- // Select this line in the edit control
- GetParent()->SendMessage(urm_SELECTLINE, lineno);
+ // Select this line in the edit control
+ GetParent()->SendMessage( urm_SELECTLINE, lineno );
- CStatic::OnLButtonDown(nFlags, point);
+ CStatic::OnLButtonDown( nFlags, point );
}
/////////////////////////////////////////////////////////////////////////////
// CLineNumberStatic public implementation
-void CLineNumberStatic::SetBgColor(COLORREF col, BOOL redraw)
+void CLineNumberStatic::SetBgColor( COLORREF col, BOOL redraw )
/* ============================================================
Function : CLineNumberStatic::SetBgColor
- Description : This function sets the panel background
+ Description : This function sets the panel background
color
-
+
Return : void
Parameters : COLORREF col - New background color
- BOOL redraw - TRUE if the control
- should be redrawn
+ BOOL redraw - TRUE if the control
+ should be redrawn
(default)
Usage : Called from the parent.
@@ -880,92 +874,92 @@ void CLineNumberStatic::SetBgColor(COLORREF col, BOOL redraw)
============================================================*/
{
- m_bgcol = col;
- if(m_hWnd && redraw)
- RedrawWindow();
+ m_bgcol = col;
+ if( m_hWnd && redraw )
+ RedrawWindow();
}
-void CLineNumberStatic::SetFgColor(COLORREF col, BOOL redraw)
+void CLineNumberStatic::SetFgColor( COLORREF col, BOOL redraw )
/* ============================================================
Function : CLineNumberStatic::SetFgColor
- Description : This function sets the panel foreground
+ Description : This function sets the panel foreground
color
-
+
Return : void
Parameters : COLORREF col - New text color
- BOOL redraw - TRUE if the control
- should be redrawn
+ BOOL redraw - TRUE if the control
+ should be redrawn
(default)
-
+
Usage : Called from the parent.
============================================================*/
{
- m_fgcol = col;
- if(m_hWnd && redraw)
- RedrawWindow();
+ m_fgcol = col;
+ if( m_hWnd && redraw )
+ RedrawWindow();
}
-void CLineNumberStatic::SetTopAndBottom(int topline, int bottomline)
+void CLineNumberStatic::SetTopAndBottom( int topline, int bottomline )
/* ============================================================
Function : CLineNumberStatic::SetTopAndBottom
- Description : Sets the top- and bottom line and redraw
+ Description : Sets the top- and bottom line and redraw
the control (if it exists)
-
+
Return : void
Parameters : int topline - The top line number
int bottomline - The bottom line number
-
- Usage : Called when the top and bottom line is
+
+ Usage : Called when the top and bottom line is
changed in the parent.
============================================================*/
{
- m_topline = topline;
- m_bottomline = bottomline;
- if(m_hWnd)
- RedrawWindow();
+ m_topline = topline;
+ m_bottomline = bottomline;
+ if( m_hWnd )
+ RedrawWindow();
}
-void CLineNumberStatic::SetTopMargin(int topmargin)
+void CLineNumberStatic::SetTopMargin( int topmargin )
/* ============================================================
Function : CLineNumberStatic::SetTopMargin
Description : Sets the top margin for painting.
-
+
Return : void
Parameters : int topmargin - The top margin to set
-
- Usage : Will be called with the value of GetRect
+
+ Usage : Will be called with the value of GetRect
from the parent.
============================================================*/
{
- m_topmargin = topmargin;
+ m_topmargin = topmargin;
}
-void CLineNumberStatic::SetLineNumberFormat(CString format)
+void CLineNumberStatic::SetLineNumberFormat( CString format )
/* ============================================================
Function : CLineNumberStatic::SetLineNumberFormat
Description : Sets the format string of the control
-
+
Return : void
- Parameters : CString format - Format string to use
-
- Usage : Called from the parent when the format
+ Parameters : CString format - Format string to use
+
+ Usage : Called from the parent when the format
string is changed.
============================================================*/
{
- m_format = format;
- if(m_hWnd)
- RedrawWindow();
+ m_format = format;
+ if( m_hWnd )
+ RedrawWindow();
}
diff --git a/src/apps/mplayerc/LineNumberEdit.h b/src/apps/mplayerc/LineNumberEdit.h
index cfedebf8c..649197ad8 100644
--- a/src/apps/mplayerc/LineNumberEdit.h
+++ b/src/apps/mplayerc/LineNumberEdit.h
@@ -8,32 +8,32 @@ class CLineNumberStatic : public CStatic
{
// Construction/destruction
public:
- CLineNumberStatic();
- virtual ~CLineNumberStatic();
+ CLineNumberStatic();
+ virtual ~CLineNumberStatic();
// Operations
public:
- void SetFgColor(COLORREF col, BOOL redraw);
- void SetBgColor(COLORREF col, BOOL redraw);
- void SetTopAndBottom(int topline, int bottomline);
- void SetTopMargin(int topmargin);
- void SetLineNumberFormat(CString format);
+ void SetFgColor( COLORREF col, BOOL redraw );
+ void SetBgColor( COLORREF col, BOOL redraw );
+ void SetTopAndBottom( int topline, int bottomline );
+ void SetTopMargin( int topmargin );
+ void SetLineNumberFormat( CString format );
protected:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnPaint();
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- DECLARE_MESSAGE_MAP()
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnPaint();
+ afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
+ DECLARE_MESSAGE_MAP()
private:
// Attributes
- COLORREF m_fgcol;
- COLORREF m_bgcol;
- CString m_format;
+ COLORREF m_fgcol;
+ COLORREF m_bgcol;
+ CString m_format;
- int m_topmargin; // Current top margin
- int m_topline; // Current top line number
- int m_bottomline; // Current bottom line number
+ int m_topmargin; // Current top margin
+ int m_topline; // Current top line number
+ int m_bottomline; // Current bottom line number
};
@@ -44,57 +44,54 @@ class CLineNumberEdit : public CEdit
{
// Construction/destruction
public:
- CLineNumberEdit();
- virtual ~CLineNumberEdit();
+ CLineNumberEdit();
+ virtual ~CLineNumberEdit();
// Operations
public:
- void SetMarginForegroundColor(COLORREF col, BOOL redraw = TRUE, BOOL bEnabled = TRUE);
- void SetMarginBackgroundColor(COLORREF col, BOOL redraw = TRUE, BOOL bEnabled = TRUE);
- void SetLineNumberFormat(CString format);
- void SetLineNumberRange(UINT nMin, UINT nMax = 0);
- void UseSystemColours(BOOL bUseEnabled = TRUE, BOOL bUseDisabled = TRUE);
+ void SetMarginForegroundColor( COLORREF col, BOOL redraw = TRUE, BOOL bEnabled = TRUE );
+ void SetMarginBackgroundColor( COLORREF col, BOOL redraw = TRUE, BOOL bEnabled = TRUE );
+ void SetLineNumberFormat( CString format );
+ void SetLineNumberRange( UINT nMin, UINT nMax = 0 );
+ void UseSystemColours( BOOL bUseEnabled = TRUE, BOOL bUseDisabled = TRUE );
- int GetLineHeight()
- {
- return m_zero.cy;
- }
+ int GetLineHeight() {return m_zero.cy;}
protected:
- virtual void PreSubclassWindow();
-
- virtual afx_msg void OnEnable(BOOL bEnable);
- virtual afx_msg void OnSysColorChange();
- virtual afx_msg void OnChange();
- virtual afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- virtual afx_msg void OnVscroll();
- virtual afx_msg void OnSize(UINT nType, int cx, int cy);
- virtual afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam); // Maps to WM_SETFONT
- virtual afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam); // Maps to WM_SETTEXT
- virtual afx_msg LRESULT OnLineScroll(WPARAM wParam, LPARAM lParam); // Maps to EM_LINESCROLL
- virtual afx_msg LRESULT OnSelectLine(WPARAM wParam, LPARAM lParam);
- DECLARE_MESSAGE_MAP()
+ virtual void PreSubclassWindow();
+
+ virtual afx_msg void OnEnable( BOOL bEnable );
+ virtual afx_msg void OnSysColorChange();
+ virtual afx_msg void OnChange();
+ virtual afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ virtual afx_msg void OnVscroll();
+ virtual afx_msg void OnSize(UINT nType, int cx, int cy);
+ virtual afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam); // Maps to WM_SETFONT
+ virtual afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam); // Maps to WM_SETTEXT
+ virtual afx_msg LRESULT OnLineScroll(WPARAM wParam, LPARAM lParam); // Maps to EM_LINESCROLL
+ virtual afx_msg LRESULT OnSelectLine(WPARAM wParam, LPARAM lParam);
+ DECLARE_MESSAGE_MAP()
private:
- void Prepare();
- int CalcLineNumberWidth();
- void UpdateTopAndBottom();
+ void Prepare();
+ int CalcLineNumberWidth();
+ void UpdateTopAndBottom();
// Method to set window colour only
- void SetWindowColour(BOOL bEnable = TRUE);
+ void SetWindowColour( BOOL bEnable = TRUE );
// Attributes
- BOOL m_bUseEnabledSystemColours;
- COLORREF m_EnabledFgCol;
- COLORREF m_EnabledBgCol;
- BOOL m_bUseDisabledSystemColours;
- COLORREF m_DisabledFgCol;
- COLORREF m_DisabledBgCol;
-
- CLineNumberStatic m_line;
- CSize m_zero;
- int m_maxval;
- CString m_format;
+ BOOL m_bUseEnabledSystemColours;
+ COLORREF m_EnabledFgCol;
+ COLORREF m_EnabledBgCol;
+ BOOL m_bUseDisabledSystemColours;
+ COLORREF m_DisabledFgCol;
+ COLORREF m_DisabledBgCol;
+
+ CLineNumberStatic m_line;
+ CSize m_zero;
+ int m_maxval;
+ CString m_format;
int m_LineDelta; // Introduced to provide an offset to the first line number
};
diff --git a/src/apps/mplayerc/MacrovisionKicker.cpp b/src/apps/mplayerc/MacrovisionKicker.cpp
index 9d65ab2e0..1802582f1 100644
--- a/src/apps/mplayerc/MacrovisionKicker.cpp
+++ b/src/apps/mplayerc/MacrovisionKicker.cpp
@@ -30,7 +30,7 @@
//
CMacrovisionKicker::CMacrovisionKicker(const TCHAR* pName, LPUNKNOWN pUnk)
- : CUnknown(pName, pUnk)
+ : CUnknown(pName, pUnk)
{
}
@@ -40,56 +40,56 @@ CMacrovisionKicker::~CMacrovisionKicker()
void CMacrovisionKicker::SetInner(CComPtr<IUnknown> pUnk)
{
- m_pInner = pUnk;
+ m_pInner = pUnk;
}
STDMETHODIMP CMacrovisionKicker::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if(riid == __uuidof(IUnknown))
- return __super::NonDelegatingQueryInterface(riid, ppv);
- if(riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner))
- return GetInterface((IKsPropertySet*)this, ppv);
+ if(riid == __uuidof(IUnknown))
+ return __super::NonDelegatingQueryInterface(riid, ppv);
+ if(riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner))
+ return GetInterface((IKsPropertySet*)this, ppv);
- HRESULT hr = m_pInner ? m_pInner->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ HRESULT hr = m_pInner ? m_pInner->QueryInterface(riid, ppv) : E_NOINTERFACE;
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
}
// IKsPropertySet
STDMETHODIMP CMacrovisionKicker::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
- {
- if(PropSet == AM_KSPROPSETID_CopyProt && Id == AM_PROPERTY_COPY_MACROVISION
- /*&& DataLength == 4 && *(DWORD*)pPropertyData*/)
- {
- TRACE(_T("Oops, no-no-no, no macrovision please\n"));
- return S_OK;
- }
-
- return pKsPS->Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
- }
-
- return E_UNEXPECTED;
+ if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
+ {
+ if(PropSet == AM_KSPROPSETID_CopyProt && Id == AM_PROPERTY_COPY_MACROVISION
+ /*&& DataLength == 4 && *(DWORD*)pPropertyData*/)
+ {
+ TRACE(_T("Oops, no-no-no, no macrovision please\n"));
+ return S_OK;
+ }
+
+ return pKsPS->Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+ }
+
+ return E_UNEXPECTED;
}
STDMETHODIMP CMacrovisionKicker::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
- {
- return pKsPS->Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
- }
-
- return E_UNEXPECTED;
+ if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
+ {
+ return pKsPS->Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
+ }
+
+ return E_UNEXPECTED;
}
STDMETHODIMP CMacrovisionKicker::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
- {
- return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
- }
-
- return E_UNEXPECTED;
+ if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
+ {
+ return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
+ }
+
+ return E_UNEXPECTED;
}
diff --git a/src/apps/mplayerc/MacrovisionKicker.h b/src/apps/mplayerc/MacrovisionKicker.h
index f635ea927..6aaade2db 100644
--- a/src/apps/mplayerc/MacrovisionKicker.h
+++ b/src/apps/mplayerc/MacrovisionKicker.h
@@ -24,22 +24,22 @@
#pragma once
class CMacrovisionKicker
- : public CUnknown
- , public IKsPropertySet
+ : public CUnknown
+ , public IKsPropertySet
{
- CComPtr<IUnknown> m_pInner;
+ CComPtr<IUnknown> m_pInner;
public:
- CMacrovisionKicker(const TCHAR* pName, LPUNKNOWN pUnk);
- virtual ~CMacrovisionKicker();
+ CMacrovisionKicker(const TCHAR* pName, LPUNKNOWN pUnk);
+ virtual ~CMacrovisionKicker();
- void SetInner(CComPtr<IUnknown> pUnk);
+ void SetInner(CComPtr<IUnknown> pUnk);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength);
- STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned);
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
+ // IKsPropertySet
+ STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength);
+ STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned);
+ STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
};
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp
index 4bfe23ccc..40fb81ad5 100644
--- a/src/apps/mplayerc/MainFrm.cpp
+++ b/src/apps/mplayerc/MainFrm.cpp
@@ -100,33 +100,23 @@ DWORD last_run = 0;
class CSubClock : public CUnknown, public ISubClock
{
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- return
- QI(ISubClock)
- CUnknown::NonDelegatingQueryInterface(riid, ppv);
- }
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ return
+ QI(ISubClock)
+ CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ }
- REFERENCE_TIME m_rt;
+ REFERENCE_TIME m_rt;
public:
- CSubClock() : CUnknown(NAME("CSubClock"), NULL)
- {
- m_rt = 0;
- }
+ CSubClock() : CUnknown(NAME("CSubClock"), NULL) {m_rt = 0;}
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
- // ISubClock
- STDMETHODIMP SetTime(REFERENCE_TIME rt)
- {
- m_rt = rt;
- return S_OK;
- }
- STDMETHODIMP_(REFERENCE_TIME) GetTime()
- {
- return(m_rt);
- }
+ // ISubClock
+ STDMETHODIMP SetTime(REFERENCE_TIME rt) {m_rt = rt; return S_OK;}
+ STDMETHODIMP_(REFERENCE_TIME) GetTime() {return(m_rt);}
};
bool m_PlayListBarVisible = false;
@@ -141,7 +131,7 @@ bool m_PlayListBarVisible = false;
\
if(__fs != State_Stopped) \
SendMessage(WM_COMMAND, ID_PLAY_STOP); \
-
+
#define RestoreMediaState \
if(m_iMediaLoadState == MLS_LOADED) \
@@ -155,7 +145,7 @@ bool m_PlayListBarVisible = false;
else if(__fs == State_Running) \
SendMessage(WM_COMMAND, ID_PLAY_PLAY); \
} \
-
+
bool m_Change_Monitor = false;
/////////////////////////////////////////////////////////////////////////////
@@ -164,919 +154,919 @@ bool m_Change_Monitor = false;
IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_CLOSE()
-
- ON_REGISTERED_MESSAGE(s_uTaskbarRestart, OnTaskBarRestart)
- ON_REGISTERED_MESSAGE(WM_NOTIFYICON, OnNotifyIcon)
-
- ON_REGISTERED_MESSAGE(s_uTBBC, OnTaskBarThumbnailsCreate)
-
- ON_WM_SETFOCUS()
- ON_WM_GETMINMAXINFO()
- ON_WM_MOVE()
- ON_WM_MOVING()
- ON_WM_SIZE()
- ON_WM_SIZING()
- ON_MESSAGE_VOID(WM_DISPLAYCHANGE, OnDisplayChange)
-
- ON_WM_SYSCOMMAND()
- ON_WM_ACTIVATEAPP()
- ON_MESSAGE(WM_APPCOMMAND, OnAppCommand)
- ON_WM_INPUT()
- ON_MESSAGE(WM_HOTKEY, OnHotKey)
-
- ON_WM_TIMER()
-
- ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
- ON_MESSAGE(WM_REARRANGERENDERLESS, OnRepaintRenderLess)
- ON_MESSAGE(WM_RESUMEFROMSTATE, OnResumeFromState)
-
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_LBUTTONDBLCLK()
- ON_WM_MBUTTONDOWN()
- ON_WM_MBUTTONUP()
- ON_WM_MBUTTONDBLCLK()
- ON_WM_RBUTTONDOWN()
- ON_WM_RBUTTONUP()
- ON_WM_RBUTTONDBLCLK()
- ON_MESSAGE(WM_XBUTTONDOWN, OnXButtonDown)
- ON_MESSAGE(WM_XBUTTONUP, OnXButtonUp)
- ON_MESSAGE(WM_XBUTTONDBLCLK, OnXButtonDblClk)
- ON_WM_MOUSEWHEEL()
- ON_WM_MOUSEMOVE()
-
- ON_WM_NCHITTEST()
-
- ON_WM_HSCROLL()
-
- ON_WM_INITMENU()
- ON_WM_INITMENUPOPUP()
-
- ON_COMMAND(ID_MENU_PLAYER_SHORT, OnMenuPlayerShort)
- ON_COMMAND(ID_MENU_PLAYER_LONG, OnMenuPlayerLong)
- ON_COMMAND(ID_MENU_FILTERS, OnMenuFilters)
-
- ON_UPDATE_COMMAND_UI(IDC_PLAYERSTATUS, OnUpdatePlayerStatus)
-
- ON_COMMAND(ID_FILE_POST_OPENMEDIA, OnFilePostOpenmedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_POST_OPENMEDIA, OnUpdateFilePostOpenmedia)
- ON_COMMAND(ID_FILE_POST_CLOSEMEDIA, OnFilePostClosemedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_POST_CLOSEMEDIA, OnUpdateFilePostClosemedia)
-
- ON_COMMAND(ID_BOSS, OnBossKey)
-
- ON_COMMAND_RANGE(ID_STREAM_AUDIO_NEXT, ID_STREAM_AUDIO_PREV, OnStreamAudio)
- ON_COMMAND_RANGE(ID_STREAM_SUB_NEXT, ID_STREAM_SUB_PREV, OnStreamSub)
- ON_COMMAND(ID_STREAM_SUB_ONOFF, OnStreamSubOnOff)
- ON_COMMAND_RANGE(ID_OGM_AUDIO_NEXT, ID_OGM_AUDIO_PREV, OnOgmAudio)
- ON_COMMAND_RANGE(ID_OGM_SUB_NEXT, ID_OGM_SUB_PREV, OnOgmSub)
- ON_COMMAND_RANGE(ID_DVD_ANGLE_NEXT, ID_DVD_ANGLE_PREV, OnDvdAngle)
- ON_COMMAND_RANGE(ID_DVD_AUDIO_NEXT, ID_DVD_AUDIO_PREV, OnDvdAudio)
- ON_COMMAND_RANGE(ID_DVD_SUB_NEXT, ID_DVD_SUB_PREV, OnDvdSub)
- ON_COMMAND(ID_DVD_SUB_ONOFF, OnDvdSubOnOff)
-
-
- ON_COMMAND(ID_FILE_OPENQUICK, OnFileOpenQuick)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
- ON_COMMAND(ID_FILE_OPENMEDIA, OnFileOpenmedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
- ON_WM_COPYDATA()
- ON_COMMAND(ID_FILE_OPENDVD, OnFileOpendvd)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENDVD, OnUpdateFileOpen)
- ON_COMMAND(ID_FILE_OPENDEVICE, OnFileOpendevice)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENDEVICE, OnUpdateFileOpen)
- ON_COMMAND_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnFileOpenCD)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnUpdateFileOpen)
- ON_WM_DROPFILES()
- ON_COMMAND(ID_FILE_SAVE_COPY, OnFileSaveAs)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_COPY, OnUpdateFileSaveAs)
- ON_COMMAND(ID_FILE_SAVE_IMAGE, OnFileSaveImage)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE, OnUpdateFileSaveImage)
- ON_COMMAND(ID_FILE_SAVE_IMAGE_AUTO, OnFileSaveImageAuto)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE_AUTO, OnUpdateFileSaveImage)
- ON_COMMAND(ID_FILE_SAVE_THUMBNAILS, OnFileSaveThumbnails)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_THUMBNAILS, OnUpdateFileSaveThumbnails)
- ON_COMMAND(ID_FILE_CONVERT, OnFileConvert)
- ON_UPDATE_COMMAND_UI(ID_FILE_CONVERT, OnUpdateFileConvert)
- ON_COMMAND(ID_FILE_LOAD_SUBTITLE, OnFileLoadsubtitle)
- ON_UPDATE_COMMAND_UI(ID_FILE_LOAD_SUBTITLE, OnUpdateFileLoadsubtitle)
- ON_COMMAND(ID_FILE_SAVE_SUBTITLE, OnFileSavesubtitle)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_SUBTITLE, OnUpdateFileSavesubtitle)
- ON_COMMAND(ID_FILE_ISDB_SEARCH, OnFileISDBSearch)
- ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_SEARCH, OnUpdateFileISDBSearch)
- ON_COMMAND(ID_FILE_ISDB_UPLOAD, OnFileISDBUpload)
- ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_UPLOAD, OnUpdateFileISDBUpload)
- ON_COMMAND(ID_FILE_ISDB_DOWNLOAD, OnFileISDBDownload)
- ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_DOWNLOAD, OnUpdateFileISDBDownload)
- ON_COMMAND(ID_FILE_PROPERTIES, OnFileProperties)
- ON_UPDATE_COMMAND_UI(ID_FILE_PROPERTIES, OnUpdateFileProperties)
- ON_COMMAND(ID_FILE_CLOSEPLAYLIST, OnFileClosePlaylist)
- ON_COMMAND(ID_FILE_CLOSEMEDIA, OnFileCloseMedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_CLOSEMEDIA, OnUpdateFileClose)
-
- ON_COMMAND(ID_VIEW_CAPTIONMENU, OnViewCaptionmenu)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTIONMENU, OnUpdateViewCaptionmenu)
- ON_COMMAND_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnViewControlBar)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnUpdateViewControlBar)
- ON_COMMAND(ID_VIEW_SUBRESYNC, OnViewSubresync)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SUBRESYNC, OnUpdateViewSubresync)
- ON_COMMAND(ID_VIEW_PLAYLIST, OnViewPlaylist)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PLAYLIST, OnUpdateViewPlaylist)
- ON_COMMAND(ID_VIEW_EDITLISTEDITOR, OnViewEditListEditor)
- ON_COMMAND(ID_EDL_IN, OnEDLIn)
- ON_UPDATE_COMMAND_UI(ID_EDL_IN, OnUpdateEDLIn)
- ON_COMMAND(ID_EDL_OUT, OnEDLOut)
- ON_UPDATE_COMMAND_UI(ID_EDL_OUT, OnUpdateEDLOut)
- ON_COMMAND(ID_EDL_NEWCLIP, OnEDLNewClip)
- ON_UPDATE_COMMAND_UI(ID_EDL_NEWCLIP, OnUpdateEDLNewClip)
- ON_COMMAND(ID_VIEW_CAPTURE, OnViewCapture)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTURE, OnUpdateViewCapture)
- ON_COMMAND(ID_VIEW_SHADEREDITOR, OnViewShaderEditor)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SHADEREDITOR, OnUpdateViewShaderEditor)
- ON_COMMAND(ID_VIEW_PRESETS_MINIMAL, OnViewMinimal)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_MINIMAL, OnUpdateViewMinimal)
- ON_COMMAND(ID_VIEW_PRESETS_COMPACT, OnViewCompact)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_COMPACT, OnUpdateViewCompact)
- ON_COMMAND(ID_VIEW_PRESETS_NORMAL, OnViewNormal)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_NORMAL, OnUpdateViewNormal)
- ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullscreen)
- ON_COMMAND(ID_VIEW_FULLSCREEN_SECONDARY, OnViewFullscreenSecondary)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateViewFullscreen)
- ON_COMMAND_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnViewZoom)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnUpdateViewZoom)
- ON_COMMAND(ID_VIEW_ZOOM_AUTOFIT, OnViewZoomAutoFit)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_AUTOFIT, OnUpdateViewZoom)
- ON_COMMAND_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_FROMOUTSIDE, OnViewDefaultVideoFrame)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_FROMOUTSIDE, OnUpdateViewDefaultVideoFrame)
- ON_COMMAND(ID_VIEW_VF_KEEPASPECTRATIO, OnViewKeepaspectratio)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VF_KEEPASPECTRATIO, OnUpdateViewKeepaspectratio)
- ON_COMMAND(ID_VIEW_VF_COMPMONDESKARDIFF, OnViewCompMonDeskARDiff)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VF_COMPMONDESKARDIFF, OnUpdateViewCompMonDeskARDiff)
- ON_COMMAND_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnViewPanNScan)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnUpdateViewPanNScan)
- ON_COMMAND_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnViewPanNScanPresets)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnUpdateViewPanNScanPresets)
- ON_COMMAND_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnViewRotate)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnUpdateViewRotate)
- ON_COMMAND_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnViewAspectRatio)
- ON_UPDATE_COMMAND_UI_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnUpdateViewAspectRatio)
- ON_COMMAND(ID_ASPECTRATIO_NEXT, OnViewAspectRatioNext)
- ON_COMMAND_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYING, OnViewOntop)
- ON_UPDATE_COMMAND_UI_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYING, OnUpdateViewOntop)
- ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions)
-
- // Casimir666
- ON_UPDATE_COMMAND_UI(ID_VIEW_TEARING_TEST, OnUpdateViewTearingTest)
- ON_COMMAND(ID_VIEW_TEARING_TEST, OnViewTearingTest)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYSTATS, OnUpdateViewDisplayStats)
- ON_COMMAND(ID_VIEW_RESETSTATS, OnViewResetStats)
- ON_COMMAND(ID_VIEW_DISPLAYSTATS, OnViewDisplayStatsSC)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREENGUISUPPORT, OnUpdateViewFullscreenGUISupport)
- ON_UPDATE_COMMAND_UI(ID_VIEW_HIGHCOLORRESOLUTION, OnUpdateViewHighColorResolution)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnUpdateViewEnableFrameTimeCorrection)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNC, OnUpdateViewVSync)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET, OnUpdateViewVSyncOffset)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCACCURATE, OnUpdateViewVSyncAccurate)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEVIDEO, OnUpdateViewSynchronizeVideo)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEDISPLAY, OnUpdateViewSynchronizeDisplay)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZENEAREST, OnUpdateViewSynchronizeNearest)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_0_255, OnUpdateViewEVROutputRange)
- ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_16_235, OnUpdateViewEVROutputRange)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnUpdateViewFlushGPU)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnUpdateViewFlushGPU)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_WAIT, OnUpdateViewFlushGPU)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_D3DFULLSCREEN, OnUpdateViewD3DFullscreen)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnUpdateViewDisableDesktopComposition)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ALTERNATIVEVSYNC, OnUpdateViewAlternativeVSync)
-
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_INCREASE, OnUpdateViewVSyncOffsetIncrease)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_DECREASE, OnUpdateViewVSyncOffsetDecrease)
- ON_COMMAND(ID_VIEW_FULLSCREENGUISUPPORT, OnViewFullscreenGUISupport)
- ON_COMMAND(ID_VIEW_HIGHCOLORRESOLUTION, OnViewHighColorResolution)
- ON_COMMAND(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnViewEnableFrameTimeCorrection)
- ON_COMMAND(ID_VIEW_VSYNC, OnViewVSync)
- ON_COMMAND(ID_VIEW_VSYNCACCURATE, OnViewVSyncAccurate)
-
- ON_COMMAND(ID_VIEW_SYNCHRONIZEVIDEO, OnViewSynchronizeVideo)
- ON_COMMAND(ID_VIEW_SYNCHRONIZEDISPLAY, OnViewSynchronizeDisplay)
- ON_COMMAND(ID_VIEW_SYNCHRONIZENEAREST, OnViewSynchronizeNearest)
-
- ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_0_255, OnViewEVROutputRange_0_255)
- ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_16_235, OnViewEVROutputRange_16_235)
-
- ON_COMMAND(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnViewFlushGPUBeforeVSync)
- ON_COMMAND(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnViewFlushGPUAfterVSync)
- ON_COMMAND(ID_VIEW_FLUSHGPU_WAIT, OnViewFlushGPUWait)
-
- ON_COMMAND(ID_VIEW_D3DFULLSCREEN, OnViewD3DFullScreen)
- ON_COMMAND(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnViewDisableDesktopComposition)
- ON_COMMAND(ID_VIEW_ALTERNATIVEVSYNC, OnViewAlternativeVSync)
- ON_COMMAND(ID_VIEW_RESET_DEFAULT, OnViewResetDefault)
- ON_COMMAND(ID_VIEW_RESET_OPTIMAL, OnViewResetOptimal)
-
- ON_COMMAND(ID_VIEW_VSYNCOFFSET_INCREASE, OnViewVSyncOffsetIncrease)
- ON_COMMAND(ID_VIEW_VSYNCOFFSET_DECREASE, OnViewVSyncOffsetDecrease)
- ON_UPDATE_COMMAND_UI(ID_SHADER_TOGGLE, OnUpdateShaderToggle)
- ON_COMMAND(ID_SHADER_TOGGLE, OnShaderToggle)
- ON_UPDATE_COMMAND_UI(ID_SHADER_TOGGLESCREENSPACE, OnUpdateShaderToggleScreenSpace)
- ON_COMMAND(ID_SHADER_TOGGLESCREENSPACE, OnShaderToggleScreenSpace)
- ON_UPDATE_COMMAND_UI(ID_VIEW_REMAINING_TIME, OnUpdateViewRemainingTime)
- ON_COMMAND(ID_VIEW_REMAINING_TIME, OnViewRemainingTime)
- ON_COMMAND(ID_D3DFULLSCREEN_TOGGLE, OnD3DFullscreenToggle)
- ON_COMMAND_RANGE(ID_GOTO_PREV_SUB, ID_GOTO_NEXT_SUB, OnGotoSubtitle)
- ON_COMMAND_RANGE(ID_SHIFT_SUB_DOWN, ID_SHIFT_SUB_UP, OnShiftSubtitle)
- ON_COMMAND_RANGE(ID_SUB_DELAY_DOWN, ID_SUB_DELAY_UP, OnSubtitleDelay)
- ON_COMMAND_RANGE(ID_LANGUAGE_ENGLISH, ID_LANGUAGE_LAST, OnLanguage)
- ON_UPDATE_COMMAND_UI_RANGE(ID_LANGUAGE_ENGLISH, ID_LANGUAGE_LAST, OnUpdateLanguage)
-
- ON_COMMAND(ID_PLAY_PLAY, OnPlayPlay)
- ON_COMMAND(ID_PLAY_PAUSE, OnPlayPause)
- ON_COMMAND(ID_PLAY_PLAYPAUSE, OnPlayPlaypause)
- ON_COMMAND(ID_PLAY_STOP, OnPlayStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_PLAY, OnUpdatePlayPauseStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_PAUSE, OnUpdatePlayPauseStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_PLAYPAUSE, OnUpdatePlayPauseStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_STOP, OnUpdatePlayPauseStop)
- ON_COMMAND_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnPlayFramestep)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnUpdatePlayFramestep)
- ON_COMMAND_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnPlaySeek)
- ON_COMMAND_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnPlaySeekKey)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnUpdatePlaySeek)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnUpdatePlaySeek)
- ON_COMMAND(ID_PLAY_GOTO, OnPlayGoto)
- ON_UPDATE_COMMAND_UI(ID_PLAY_GOTO, OnUpdateGoto)
- ON_COMMAND_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnPlayChangeRate)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnUpdatePlayChangeRate)
- ON_COMMAND(ID_PLAY_RESETRATE, OnPlayResetRate)
- ON_UPDATE_COMMAND_UI(ID_PLAY_RESETRATE, OnUpdatePlayResetRate)
- ON_COMMAND_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnPlayChangeAudDelay)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnUpdatePlayChangeAudDelay)
- ON_COMMAND_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnPlayFilters)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnUpdatePlayFilters)
- ON_COMMAND_RANGE(ID_SHADERS_START, ID_SHADERS_END, OnPlayShaders)
- ON_UPDATE_COMMAND_UI_RANGE(ID_SHADERS_START, ID_SHADERS_END, OnUpdatePlayShaders)
- ON_COMMAND_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnPlayAudio)
- ON_UPDATE_COMMAND_UI_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnUpdatePlayAudio)
- ON_COMMAND_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnPlaySubtitles)
- ON_UPDATE_COMMAND_UI_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnUpdatePlaySubtitles)
- ON_COMMAND_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnPlayLanguage)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnUpdatePlayLanguage)
- ON_COMMAND_RANGE(ID_VOLUME_UP, ID_VOLUME_MUTE, OnPlayVolume)
- ON_COMMAND_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnPlayVolumeBoost)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnUpdatePlayVolumeBoost)
- ON_COMMAND_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnAfterplayback)
- ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnUpdateAfterplayback)
- ON_COMMAND_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnAfterplayback)
- ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnUpdateAfterplayback)
-
- ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnNavigateSkip)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnUpdateNavigateSkip)
- ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACKPLITEM, ID_NAVIGATE_SKIPFORWARDPLITEM, OnNavigateSkipPlaylistItem)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACKPLITEM, ID_NAVIGATE_SKIPFORWARDPLITEM, OnUpdateNavigateSkipPlaylistItem)
- ON_COMMAND_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnNavigateMenu)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnUpdateNavigateMenu)
- ON_COMMAND_RANGE(ID_NAVIGATE_AUDIO_SUBITEM_START, ID_NAVIGATE_AUDIO_SUBITEM_END, OnNavigateAudio)
- ON_COMMAND_RANGE(ID_NAVIGATE_SUBP_SUBITEM_START, ID_NAVIGATE_SUBP_SUBITEM_END, OnNavigateSubpic)
- ON_COMMAND_RANGE(ID_NAVIGATE_ANGLE_SUBITEM_START, ID_NAVIGATE_ANGLE_SUBITEM_END, OnNavigateAngle)
- ON_COMMAND_RANGE(ID_NAVIGATE_CHAP_SUBITEM_START, ID_NAVIGATE_CHAP_SUBITEM_END, OnNavigateChapters)
- ON_COMMAND_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnNavigateMenuItem)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnUpdateNavigateMenuItem)
- ON_COMMAND(ID_NAVIGATE_TUNERSCAN, OnTunerScan)
- ON_UPDATE_COMMAND_UI(ID_NAVIGATE_TUNERSCAN, OnUpdateTunerScan)
-
- ON_COMMAND(ID_FAVORITES_ADD, OnFavoritesAdd)
- ON_UPDATE_COMMAND_UI(ID_FAVORITES_ADD, OnUpdateFavoritesAdd)
- ON_COMMAND(ID_FAVORITES_QUICKADDFAVORITE, OnFavoritesQuickAddFavorite)
- ON_COMMAND(ID_FAVORITES_ORGANIZE, OnFavoritesOrganize)
- ON_UPDATE_COMMAND_UI(ID_FAVORITES_ORGANIZE, OnUpdateFavoritesOrganize)
- ON_COMMAND_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnFavoritesFile)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnUpdateFavoritesFile)
- ON_COMMAND_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnFavoritesDVD)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnUpdateFavoritesDVD)
- ON_COMMAND_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnFavoritesDevice)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnUpdateFavoritesDevice)
-
- ON_COMMAND(ID_RECENT_FILES_CLEAR, OnRecentFileClear)
- ON_UPDATE_COMMAND_UI(ID_RECENT_FILES_CLEAR, OnUpdateRecentFileClear)
- ON_COMMAND_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnRecentFile)
- ON_UPDATE_COMMAND_UI_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnUpdateRecentFile)
-
- ON_COMMAND(ID_HELP_HOMEPAGE, OnHelpHomepage)
- ON_COMMAND(ID_HELP_DOCUMENTATION, OnHelpDocumentation)
- ON_COMMAND(ID_HELP_DONATE, OnHelpDonate)
-
- // Open Dir incl. SubDir
- ON_COMMAND(ID_FILE_OPENDIRECTORY, OnFileOpendirectory)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENDIRECTORY, OnUpdateFileOpen)
- ON_WM_POWERBROADCAST()
-
- // Navigation pannel
- ON_COMMAND(ID_VIEW_NAVIGATION, OnViewNavigation)
- ON_UPDATE_COMMAND_UI(ID_VIEW_NAVIGATION, OnUpdateViewNavigation)
-END_MESSAGE_MAP()
+ ON_WM_CREATE()
+ ON_WM_DESTROY()
+ ON_WM_CLOSE()
+
+ ON_REGISTERED_MESSAGE(s_uTaskbarRestart, OnTaskBarRestart)
+ ON_REGISTERED_MESSAGE(WM_NOTIFYICON, OnNotifyIcon)
+
+ ON_REGISTERED_MESSAGE(s_uTBBC, OnTaskBarThumbnailsCreate)
+
+ ON_WM_SETFOCUS()
+ ON_WM_GETMINMAXINFO()
+ ON_WM_MOVE()
+ ON_WM_MOVING()
+ ON_WM_SIZE()
+ ON_WM_SIZING()
+ ON_MESSAGE_VOID(WM_DISPLAYCHANGE, OnDisplayChange)
+
+ ON_WM_SYSCOMMAND()
+ ON_WM_ACTIVATEAPP()
+ ON_MESSAGE(WM_APPCOMMAND, OnAppCommand)
+ ON_WM_INPUT()
+ ON_MESSAGE(WM_HOTKEY, OnHotKey)
+
+ ON_WM_TIMER()
+
+ ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
+ ON_MESSAGE(WM_REARRANGERENDERLESS, OnRepaintRenderLess)
+ ON_MESSAGE(WM_RESUMEFROMSTATE, OnResumeFromState)
+
+ ON_WM_LBUTTONDOWN()
+ ON_WM_LBUTTONUP()
+ ON_WM_LBUTTONDBLCLK()
+ ON_WM_MBUTTONDOWN()
+ ON_WM_MBUTTONUP()
+ ON_WM_MBUTTONDBLCLK()
+ ON_WM_RBUTTONDOWN()
+ ON_WM_RBUTTONUP()
+ ON_WM_RBUTTONDBLCLK()
+ ON_MESSAGE(WM_XBUTTONDOWN, OnXButtonDown)
+ ON_MESSAGE(WM_XBUTTONUP, OnXButtonUp)
+ ON_MESSAGE(WM_XBUTTONDBLCLK, OnXButtonDblClk)
+ ON_WM_MOUSEWHEEL()
+ ON_WM_MOUSEMOVE()
+
+ ON_WM_NCHITTEST()
+
+ ON_WM_HSCROLL()
+
+ ON_WM_INITMENU()
+ ON_WM_INITMENUPOPUP()
+
+ ON_COMMAND(ID_MENU_PLAYER_SHORT, OnMenuPlayerShort)
+ ON_COMMAND(ID_MENU_PLAYER_LONG, OnMenuPlayerLong)
+ ON_COMMAND(ID_MENU_FILTERS, OnMenuFilters)
+
+ ON_UPDATE_COMMAND_UI(IDC_PLAYERSTATUS, OnUpdatePlayerStatus)
+
+ ON_COMMAND(ID_FILE_POST_OPENMEDIA, OnFilePostOpenmedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_POST_OPENMEDIA, OnUpdateFilePostOpenmedia)
+ ON_COMMAND(ID_FILE_POST_CLOSEMEDIA, OnFilePostClosemedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_POST_CLOSEMEDIA, OnUpdateFilePostClosemedia)
+
+ ON_COMMAND(ID_BOSS, OnBossKey)
+
+ ON_COMMAND_RANGE(ID_STREAM_AUDIO_NEXT, ID_STREAM_AUDIO_PREV, OnStreamAudio)
+ ON_COMMAND_RANGE(ID_STREAM_SUB_NEXT, ID_STREAM_SUB_PREV, OnStreamSub)
+ ON_COMMAND(ID_STREAM_SUB_ONOFF, OnStreamSubOnOff)
+ ON_COMMAND_RANGE(ID_OGM_AUDIO_NEXT, ID_OGM_AUDIO_PREV, OnOgmAudio)
+ ON_COMMAND_RANGE(ID_OGM_SUB_NEXT, ID_OGM_SUB_PREV, OnOgmSub)
+ ON_COMMAND_RANGE(ID_DVD_ANGLE_NEXT, ID_DVD_ANGLE_PREV, OnDvdAngle)
+ ON_COMMAND_RANGE(ID_DVD_AUDIO_NEXT, ID_DVD_AUDIO_PREV, OnDvdAudio)
+ ON_COMMAND_RANGE(ID_DVD_SUB_NEXT, ID_DVD_SUB_PREV, OnDvdSub)
+ ON_COMMAND(ID_DVD_SUB_ONOFF, OnDvdSubOnOff)
+
+
+ ON_COMMAND(ID_FILE_OPENQUICK, OnFileOpenQuick)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
+ ON_COMMAND(ID_FILE_OPENMEDIA, OnFileOpenmedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
+ ON_WM_COPYDATA()
+ ON_COMMAND(ID_FILE_OPENDVD, OnFileOpendvd)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENDVD, OnUpdateFileOpen)
+ ON_COMMAND(ID_FILE_OPENDEVICE, OnFileOpendevice)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENDEVICE, OnUpdateFileOpen)
+ ON_COMMAND_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnFileOpenCD)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnUpdateFileOpen)
+ ON_WM_DROPFILES()
+ ON_COMMAND(ID_FILE_SAVE_COPY, OnFileSaveAs)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_COPY, OnUpdateFileSaveAs)
+ ON_COMMAND(ID_FILE_SAVE_IMAGE, OnFileSaveImage)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE, OnUpdateFileSaveImage)
+ ON_COMMAND(ID_FILE_SAVE_IMAGE_AUTO, OnFileSaveImageAuto)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE_AUTO, OnUpdateFileSaveImage)
+ ON_COMMAND(ID_FILE_SAVE_THUMBNAILS, OnFileSaveThumbnails)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_THUMBNAILS, OnUpdateFileSaveThumbnails)
+ ON_COMMAND(ID_FILE_CONVERT, OnFileConvert)
+ ON_UPDATE_COMMAND_UI(ID_FILE_CONVERT, OnUpdateFileConvert)
+ ON_COMMAND(ID_FILE_LOAD_SUBTITLE, OnFileLoadsubtitle)
+ ON_UPDATE_COMMAND_UI(ID_FILE_LOAD_SUBTITLE, OnUpdateFileLoadsubtitle)
+ ON_COMMAND(ID_FILE_SAVE_SUBTITLE, OnFileSavesubtitle)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_SUBTITLE, OnUpdateFileSavesubtitle)
+ ON_COMMAND(ID_FILE_ISDB_SEARCH, OnFileISDBSearch)
+ ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_SEARCH, OnUpdateFileISDBSearch)
+ ON_COMMAND(ID_FILE_ISDB_UPLOAD, OnFileISDBUpload)
+ ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_UPLOAD, OnUpdateFileISDBUpload)
+ ON_COMMAND(ID_FILE_ISDB_DOWNLOAD, OnFileISDBDownload)
+ ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_DOWNLOAD, OnUpdateFileISDBDownload)
+ ON_COMMAND(ID_FILE_PROPERTIES, OnFileProperties)
+ ON_UPDATE_COMMAND_UI(ID_FILE_PROPERTIES, OnUpdateFileProperties)
+ ON_COMMAND(ID_FILE_CLOSEPLAYLIST, OnFileClosePlaylist)
+ ON_COMMAND(ID_FILE_CLOSEMEDIA, OnFileCloseMedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_CLOSEMEDIA, OnUpdateFileClose)
+
+ ON_COMMAND(ID_VIEW_CAPTIONMENU, OnViewCaptionmenu)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTIONMENU, OnUpdateViewCaptionmenu)
+ ON_COMMAND_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnViewControlBar)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnUpdateViewControlBar)
+ ON_COMMAND(ID_VIEW_SUBRESYNC, OnViewSubresync)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SUBRESYNC, OnUpdateViewSubresync)
+ ON_COMMAND(ID_VIEW_PLAYLIST, OnViewPlaylist)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PLAYLIST, OnUpdateViewPlaylist)
+ ON_COMMAND(ID_VIEW_EDITLISTEDITOR, OnViewEditListEditor)
+ ON_COMMAND(ID_EDL_IN, OnEDLIn)
+ ON_UPDATE_COMMAND_UI(ID_EDL_IN, OnUpdateEDLIn)
+ ON_COMMAND(ID_EDL_OUT, OnEDLOut)
+ ON_UPDATE_COMMAND_UI(ID_EDL_OUT, OnUpdateEDLOut)
+ ON_COMMAND(ID_EDL_NEWCLIP, OnEDLNewClip)
+ ON_UPDATE_COMMAND_UI(ID_EDL_NEWCLIP, OnUpdateEDLNewClip)
+ ON_COMMAND(ID_VIEW_CAPTURE, OnViewCapture)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTURE, OnUpdateViewCapture)
+ ON_COMMAND(ID_VIEW_SHADEREDITOR, OnViewShaderEditor)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SHADEREDITOR, OnUpdateViewShaderEditor)
+ ON_COMMAND(ID_VIEW_PRESETS_MINIMAL, OnViewMinimal)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_MINIMAL, OnUpdateViewMinimal)
+ ON_COMMAND(ID_VIEW_PRESETS_COMPACT, OnViewCompact)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_COMPACT, OnUpdateViewCompact)
+ ON_COMMAND(ID_VIEW_PRESETS_NORMAL, OnViewNormal)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_NORMAL, OnUpdateViewNormal)
+ ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullscreen)
+ ON_COMMAND(ID_VIEW_FULLSCREEN_SECONDARY, OnViewFullscreenSecondary)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateViewFullscreen)
+ ON_COMMAND_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnViewZoom)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnUpdateViewZoom)
+ ON_COMMAND(ID_VIEW_ZOOM_AUTOFIT, OnViewZoomAutoFit)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_AUTOFIT, OnUpdateViewZoom)
+ ON_COMMAND_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_FROMOUTSIDE, OnViewDefaultVideoFrame)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_FROMOUTSIDE, OnUpdateViewDefaultVideoFrame)
+ ON_COMMAND(ID_VIEW_VF_KEEPASPECTRATIO, OnViewKeepaspectratio)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VF_KEEPASPECTRATIO, OnUpdateViewKeepaspectratio)
+ ON_COMMAND(ID_VIEW_VF_COMPMONDESKARDIFF, OnViewCompMonDeskARDiff)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VF_COMPMONDESKARDIFF, OnUpdateViewCompMonDeskARDiff)
+ ON_COMMAND_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnViewPanNScan)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnUpdateViewPanNScan)
+ ON_COMMAND_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnViewPanNScanPresets)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnUpdateViewPanNScanPresets)
+ ON_COMMAND_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnViewRotate)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnUpdateViewRotate)
+ ON_COMMAND_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnViewAspectRatio)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnUpdateViewAspectRatio)
+ ON_COMMAND(ID_ASPECTRATIO_NEXT, OnViewAspectRatioNext)
+ ON_COMMAND_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYING, OnViewOntop)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYING, OnUpdateViewOntop)
+ ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions)
+
+ // Casimir666
+ ON_UPDATE_COMMAND_UI(ID_VIEW_TEARING_TEST, OnUpdateViewTearingTest)
+ ON_COMMAND(ID_VIEW_TEARING_TEST, OnViewTearingTest)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYSTATS, OnUpdateViewDisplayStats)
+ ON_COMMAND(ID_VIEW_RESETSTATS, OnViewResetStats)
+ ON_COMMAND(ID_VIEW_DISPLAYSTATS, OnViewDisplayStatsSC)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREENGUISUPPORT, OnUpdateViewFullscreenGUISupport)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_HIGHCOLORRESOLUTION, OnUpdateViewHighColorResolution)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnUpdateViewEnableFrameTimeCorrection)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNC, OnUpdateViewVSync)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET, OnUpdateViewVSyncOffset)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCACCURATE, OnUpdateViewVSyncAccurate)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEVIDEO, OnUpdateViewSynchronizeVideo)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEDISPLAY, OnUpdateViewSynchronizeDisplay)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZENEAREST, OnUpdateViewSynchronizeNearest)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_0_255, OnUpdateViewEVROutputRange)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_16_235, OnUpdateViewEVROutputRange)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnUpdateViewFlushGPU)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnUpdateViewFlushGPU)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_WAIT, OnUpdateViewFlushGPU)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_D3DFULLSCREEN, OnUpdateViewD3DFullscreen)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnUpdateViewDisableDesktopComposition)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ALTERNATIVEVSYNC, OnUpdateViewAlternativeVSync)
+
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_INCREASE, OnUpdateViewVSyncOffsetIncrease)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_DECREASE, OnUpdateViewVSyncOffsetDecrease)
+ ON_COMMAND(ID_VIEW_FULLSCREENGUISUPPORT, OnViewFullscreenGUISupport)
+ ON_COMMAND(ID_VIEW_HIGHCOLORRESOLUTION, OnViewHighColorResolution)
+ ON_COMMAND(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnViewEnableFrameTimeCorrection)
+ ON_COMMAND(ID_VIEW_VSYNC, OnViewVSync)
+ ON_COMMAND(ID_VIEW_VSYNCACCURATE, OnViewVSyncAccurate)
+
+ ON_COMMAND(ID_VIEW_SYNCHRONIZEVIDEO, OnViewSynchronizeVideo)
+ ON_COMMAND(ID_VIEW_SYNCHRONIZEDISPLAY, OnViewSynchronizeDisplay)
+ ON_COMMAND(ID_VIEW_SYNCHRONIZENEAREST, OnViewSynchronizeNearest)
+
+ ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_0_255, OnViewEVROutputRange_0_255)
+ ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_16_235, OnViewEVROutputRange_16_235)
+
+ ON_COMMAND(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnViewFlushGPUBeforeVSync)
+ ON_COMMAND(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnViewFlushGPUAfterVSync)
+ ON_COMMAND(ID_VIEW_FLUSHGPU_WAIT, OnViewFlushGPUWait)
+
+ ON_COMMAND(ID_VIEW_D3DFULLSCREEN, OnViewD3DFullScreen)
+ ON_COMMAND(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnViewDisableDesktopComposition)
+ ON_COMMAND(ID_VIEW_ALTERNATIVEVSYNC, OnViewAlternativeVSync)
+ ON_COMMAND(ID_VIEW_RESET_DEFAULT, OnViewResetDefault)
+ ON_COMMAND(ID_VIEW_RESET_OPTIMAL, OnViewResetOptimal)
+
+ ON_COMMAND(ID_VIEW_VSYNCOFFSET_INCREASE, OnViewVSyncOffsetIncrease)
+ ON_COMMAND(ID_VIEW_VSYNCOFFSET_DECREASE, OnViewVSyncOffsetDecrease)
+ ON_UPDATE_COMMAND_UI(ID_SHADER_TOGGLE, OnUpdateShaderToggle)
+ ON_COMMAND(ID_SHADER_TOGGLE, OnShaderToggle)
+ ON_UPDATE_COMMAND_UI(ID_SHADER_TOGGLESCREENSPACE, OnUpdateShaderToggleScreenSpace)
+ ON_COMMAND(ID_SHADER_TOGGLESCREENSPACE, OnShaderToggleScreenSpace)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_REMAINING_TIME, OnUpdateViewRemainingTime)
+ ON_COMMAND(ID_VIEW_REMAINING_TIME, OnViewRemainingTime)
+ ON_COMMAND(ID_D3DFULLSCREEN_TOGGLE, OnD3DFullscreenToggle)
+ ON_COMMAND_RANGE(ID_GOTO_PREV_SUB, ID_GOTO_NEXT_SUB, OnGotoSubtitle)
+ ON_COMMAND_RANGE(ID_SHIFT_SUB_DOWN, ID_SHIFT_SUB_UP, OnShiftSubtitle)
+ ON_COMMAND_RANGE(ID_SUB_DELAY_DOWN, ID_SUB_DELAY_UP, OnSubtitleDelay)
+ ON_COMMAND_RANGE(ID_LANGUAGE_ENGLISH, ID_LANGUAGE_LAST, OnLanguage)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_LANGUAGE_ENGLISH, ID_LANGUAGE_LAST, OnUpdateLanguage)
+
+ ON_COMMAND(ID_PLAY_PLAY, OnPlayPlay)
+ ON_COMMAND(ID_PLAY_PAUSE, OnPlayPause)
+ ON_COMMAND(ID_PLAY_PLAYPAUSE, OnPlayPlaypause)
+ ON_COMMAND(ID_PLAY_STOP, OnPlayStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_PLAY, OnUpdatePlayPauseStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_PAUSE, OnUpdatePlayPauseStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_PLAYPAUSE, OnUpdatePlayPauseStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_STOP, OnUpdatePlayPauseStop)
+ ON_COMMAND_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnPlayFramestep)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnUpdatePlayFramestep)
+ ON_COMMAND_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnPlaySeek)
+ ON_COMMAND_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnPlaySeekKey)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnUpdatePlaySeek)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnUpdatePlaySeek)
+ ON_COMMAND(ID_PLAY_GOTO, OnPlayGoto)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_GOTO, OnUpdateGoto)
+ ON_COMMAND_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnPlayChangeRate)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnUpdatePlayChangeRate)
+ ON_COMMAND(ID_PLAY_RESETRATE, OnPlayResetRate)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_RESETRATE, OnUpdatePlayResetRate)
+ ON_COMMAND_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnPlayChangeAudDelay)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnUpdatePlayChangeAudDelay)
+ ON_COMMAND_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnPlayFilters)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnUpdatePlayFilters)
+ ON_COMMAND_RANGE(ID_SHADERS_START, ID_SHADERS_END, OnPlayShaders)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_SHADERS_START, ID_SHADERS_END, OnUpdatePlayShaders)
+ ON_COMMAND_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnPlayAudio)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnUpdatePlayAudio)
+ ON_COMMAND_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnPlaySubtitles)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnUpdatePlaySubtitles)
+ ON_COMMAND_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnPlayLanguage)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnUpdatePlayLanguage)
+ ON_COMMAND_RANGE(ID_VOLUME_UP, ID_VOLUME_MUTE, OnPlayVolume)
+ ON_COMMAND_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnPlayVolumeBoost)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnUpdatePlayVolumeBoost)
+ ON_COMMAND_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnAfterplayback)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnUpdateAfterplayback)
+ ON_COMMAND_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnAfterplayback)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnUpdateAfterplayback)
+
+ ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnNavigateSkip)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnUpdateNavigateSkip)
+ ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACKPLITEM, ID_NAVIGATE_SKIPFORWARDPLITEM, OnNavigateSkipPlaylistItem)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACKPLITEM, ID_NAVIGATE_SKIPFORWARDPLITEM, OnUpdateNavigateSkipPlaylistItem)
+ ON_COMMAND_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnNavigateMenu)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnUpdateNavigateMenu)
+ ON_COMMAND_RANGE(ID_NAVIGATE_AUDIO_SUBITEM_START, ID_NAVIGATE_AUDIO_SUBITEM_END, OnNavigateAudio)
+ ON_COMMAND_RANGE(ID_NAVIGATE_SUBP_SUBITEM_START, ID_NAVIGATE_SUBP_SUBITEM_END, OnNavigateSubpic)
+ ON_COMMAND_RANGE(ID_NAVIGATE_ANGLE_SUBITEM_START, ID_NAVIGATE_ANGLE_SUBITEM_END, OnNavigateAngle)
+ ON_COMMAND_RANGE(ID_NAVIGATE_CHAP_SUBITEM_START, ID_NAVIGATE_CHAP_SUBITEM_END, OnNavigateChapters)
+ ON_COMMAND_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnNavigateMenuItem)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnUpdateNavigateMenuItem)
+ ON_COMMAND(ID_NAVIGATE_TUNERSCAN, OnTunerScan)
+ ON_UPDATE_COMMAND_UI(ID_NAVIGATE_TUNERSCAN, OnUpdateTunerScan)
+
+ ON_COMMAND(ID_FAVORITES_ADD, OnFavoritesAdd)
+ ON_UPDATE_COMMAND_UI(ID_FAVORITES_ADD, OnUpdateFavoritesAdd)
+ ON_COMMAND(ID_FAVORITES_QUICKADDFAVORITE, OnFavoritesQuickAddFavorite)
+ ON_COMMAND(ID_FAVORITES_ORGANIZE, OnFavoritesOrganize)
+ ON_UPDATE_COMMAND_UI(ID_FAVORITES_ORGANIZE, OnUpdateFavoritesOrganize)
+ ON_COMMAND_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnFavoritesFile)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnUpdateFavoritesFile)
+ ON_COMMAND_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnFavoritesDVD)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnUpdateFavoritesDVD)
+ ON_COMMAND_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnFavoritesDevice)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnUpdateFavoritesDevice)
+
+ ON_COMMAND(ID_RECENT_FILES_CLEAR, OnRecentFileClear)
+ ON_UPDATE_COMMAND_UI(ID_RECENT_FILES_CLEAR, OnUpdateRecentFileClear)
+ ON_COMMAND_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnRecentFile)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnUpdateRecentFile)
+
+ ON_COMMAND(ID_HELP_HOMEPAGE, OnHelpHomepage)
+ ON_COMMAND(ID_HELP_DOCUMENTATION, OnHelpDocumentation)
+ ON_COMMAND(ID_HELP_DONATE, OnHelpDonate)
+
+ // Open Dir incl. SubDir
+ ON_COMMAND(ID_FILE_OPENDIRECTORY, OnFileOpendirectory)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENDIRECTORY, OnUpdateFileOpen)
+ ON_WM_POWERBROADCAST()
+
+ // Navigation pannel
+ ON_COMMAND(ID_VIEW_NAVIGATION, OnViewNavigation)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_NAVIGATION, OnUpdateViewNavigation)
+ END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
#pragma warning(disable : 4355)
-CMainFrame::CMainFrame() :
- m_dwRegister(0),
- m_iMediaLoadState(MLS_CLOSED),
- m_iPlaybackMode(PM_NONE),
- m_iSpeedLevel(0),
- m_rtDurationOverride(-1),
- m_fFullScreen(false),
- m_fFirstFSAfterLaunchOnFS(false),
- m_fHideCursor(false),
- m_lastMouseMove(-1, -1),
- m_pLastBar(NULL),
- m_nLoops(0),
- m_iSubtitleSel(-1),
- m_ZoomX(1), m_ZoomY(1), m_PosX(0.5), m_PosY(0.5),
- m_AngleX(0), m_AngleY(0), m_AngleZ(0),
- m_fCustomGraph(false),
- m_fRealMediaGraph(false), m_fShockwaveGraph(false), m_fQuicktimeGraph(false),
- m_fFrameSteppingActive(false),
- m_fEndOfStream(false),
- m_fCapturing(false),
- m_fLiveWM(false),
- m_fOpeningAborted(false),
- m_fBuffering(false),
- m_fileDropTarget(this),
- m_fTrayIcon(false),
- m_pFullscreenWnd(NULL),
- m_pVideoWnd(NULL),
- m_bRemainingTime(false),
- m_nCurSubtitle(-1),
- m_lSubtitleShift(0),
- m_bToggleShader(false),
- m_nStepForwardCount(0),
- m_rtStepForwardStart(0),
- m_bToggleShaderScreenSpace(false),
- m_bInOptions(false),
- m_pTaskbarList(NULL),
- m_pGraphThread(NULL)
-{
- m_Lcd.SetVolumeRange(1, 100);
+CMainFrame::CMainFrame() :
+ m_dwRegister(0),
+ m_iMediaLoadState(MLS_CLOSED),
+ m_iPlaybackMode(PM_NONE),
+ m_iSpeedLevel(0),
+ m_rtDurationOverride(-1),
+ m_fFullScreen(false),
+ m_fFirstFSAfterLaunchOnFS(false),
+ m_fHideCursor(false),
+ m_lastMouseMove(-1, -1),
+ m_pLastBar(NULL),
+ m_nLoops(0),
+ m_iSubtitleSel(-1),
+ m_ZoomX(1), m_ZoomY(1), m_PosX(0.5), m_PosY(0.5),
+ m_AngleX(0), m_AngleY(0), m_AngleZ(0),
+ m_fCustomGraph(false),
+ m_fRealMediaGraph(false), m_fShockwaveGraph(false), m_fQuicktimeGraph(false),
+ m_fFrameSteppingActive(false),
+ m_fEndOfStream(false),
+ m_fCapturing(false),
+ m_fLiveWM(false),
+ m_fOpeningAborted(false),
+ m_fBuffering(false),
+ m_fileDropTarget(this),
+ m_fTrayIcon(false),
+ m_pFullscreenWnd(NULL),
+ m_pVideoWnd(NULL),
+ m_bRemainingTime(false),
+ m_nCurSubtitle(-1),
+ m_lSubtitleShift(0),
+ m_bToggleShader(false),
+ m_nStepForwardCount(0),
+ m_rtStepForwardStart(0),
+ m_bToggleShaderScreenSpace(false),
+ m_bInOptions(false),
+ m_pTaskbarList(NULL),
+ m_pGraphThread(NULL)
+{
+ m_Lcd.SetVolumeRange(1, 100);
}
CMainFrame::~CMainFrame()
{
// m_owner.DestroyWindow();
- //delete m_pFullscreenWnd; // double delete see CMainFrame::OnDestroy
+ //delete m_pFullscreenWnd; // double delete see CMainFrame::OnDestroy
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(__super::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- m_popup.LoadMenu(IDR_POPUP);
- m_popupmain.LoadMenu(IDR_POPUPMAIN);
-
- GetMenu()->ModifyMenu(ID_FAVORITES, MF_BYCOMMAND | MF_STRING, IDR_MAINFRAME, ResStr(IDS_FAVORITES_POPUP));
-
- // create a view to occupy the client area of the frame
- if(!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
- CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
- {
- TRACE0("Failed to create view window\n");
- return -1;
- }
-
- // static bars
-
- if(!m_wndStatusBar.Create(this)
- || !m_wndStatsBar.Create(this)
- || !m_wndInfoBar.Create(this)
- || !m_wndToolBar.Create(this)
- || !m_wndSeekBar.Create(this))
- {
- TRACE0("Failed to create all control bars\n");
- return -1; // fail to create
- }
+ if(__super::OnCreate(lpCreateStruct) == -1)
+ return -1;
- m_pFullscreenWnd = DNew CFullscreenWnd(this);
+ m_popup.LoadMenu(IDR_POPUP);
+ m_popupmain.LoadMenu(IDR_POPUPMAIN);
- m_bars.AddTail(&m_wndSeekBar);
- m_bars.AddTail(&m_wndToolBar);
- m_bars.AddTail(&m_wndInfoBar);
- m_bars.AddTail(&m_wndStatsBar);
- m_bars.AddTail(&m_wndStatusBar);
+ GetMenu()->ModifyMenu(ID_FAVORITES, MF_BYCOMMAND|MF_STRING, IDR_MAINFRAME, ResStr(IDS_FAVORITES_POPUP));
- m_wndSeekBar.Enable(false);
+ // create a view to occupy the client area of the frame
+ if(!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
+ CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
+ {
+ TRACE0("Failed to create view window\n");
+ return -1;
+ }
- // dockable bars
+ // static bars
- EnableDocking(CBRS_ALIGN_ANY);
+ if(!m_wndStatusBar.Create(this)
+ || !m_wndStatsBar.Create(this)
+ || !m_wndInfoBar.Create(this)
+ || !m_wndToolBar.Create(this)
+ || !m_wndSeekBar.Create(this))
+ {
+ TRACE0("Failed to create all control bars\n");
+ return -1; // fail to create
+ }
+
+ m_pFullscreenWnd = DNew CFullscreenWnd(this);
+
+ m_bars.AddTail(&m_wndSeekBar);
+ m_bars.AddTail(&m_wndToolBar);
+ m_bars.AddTail(&m_wndInfoBar);
+ m_bars.AddTail(&m_wndStatsBar);
+ m_bars.AddTail(&m_wndStatusBar);
+
+ m_wndSeekBar.Enable(false);
- m_dockingbars.RemoveAll();
+ // dockable bars
- m_wndSubresyncBar.Create(this, &m_csSubLock);
- m_wndSubresyncBar.SetBarStyle(m_wndSubresyncBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndSubresyncBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndSubresyncBar.SetHeight(200);
- LoadControlBar(&m_wndSubresyncBar, AFX_IDW_DOCKBAR_TOP);
+ EnableDocking(CBRS_ALIGN_ANY);
- m_wndPlaylistBar.Create(this);
- m_wndPlaylistBar.SetBarStyle(m_wndPlaylistBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndPlaylistBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndPlaylistBar.SetHeight(100);
- LoadControlBar(&m_wndPlaylistBar, AFX_IDW_DOCKBAR_BOTTOM);
- m_wndPlaylistBar.LoadPlaylist(GetRecentFile());
+ m_dockingbars.RemoveAll();
- m_wndEditListEditor.Create(this);
- m_wndEditListEditor.SetBarStyle(m_wndEditListEditor.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndEditListEditor.EnableDocking(CBRS_ALIGN_ANY);
- LoadControlBar(&m_wndEditListEditor, AFX_IDW_DOCKBAR_RIGHT);
- m_wndEditListEditor.SetHeight(100);
+ m_wndSubresyncBar.Create(this, &m_csSubLock);
+ m_wndSubresyncBar.SetBarStyle(m_wndSubresyncBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndSubresyncBar.EnableDocking(CBRS_ALIGN_ANY);
+ m_wndSubresyncBar.SetHeight(200);
+ LoadControlBar(&m_wndSubresyncBar, AFX_IDW_DOCKBAR_TOP);
- m_wndCaptureBar.Create(this);
- m_wndCaptureBar.SetBarStyle(m_wndCaptureBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndCaptureBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
- LoadControlBar(&m_wndCaptureBar, AFX_IDW_DOCKBAR_LEFT);
+ m_wndPlaylistBar.Create(this);
+ m_wndPlaylistBar.SetBarStyle(m_wndPlaylistBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndPlaylistBar.EnableDocking(CBRS_ALIGN_ANY);
+ m_wndPlaylistBar.SetHeight(100);
+ LoadControlBar(&m_wndPlaylistBar, AFX_IDW_DOCKBAR_BOTTOM);
+ m_wndPlaylistBar.LoadPlaylist(GetRecentFile());
- m_wndNavigationBar.Create(this);
- m_wndNavigationBar.SetBarStyle(m_wndNavigationBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndNavigationBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
- LoadControlBar(&m_wndNavigationBar, AFX_IDW_DOCKBAR_LEFT);
+ m_wndEditListEditor.Create(this);
+ m_wndEditListEditor.SetBarStyle(m_wndEditListEditor.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndEditListEditor.EnableDocking(CBRS_ALIGN_ANY);
+ LoadControlBar(&m_wndEditListEditor, AFX_IDW_DOCKBAR_RIGHT);
+ m_wndEditListEditor.SetHeight(100);
- m_wndShaderEditorBar.Create(this);
- m_wndShaderEditorBar.SetBarStyle(m_wndShaderEditorBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndShaderEditorBar.EnableDocking(CBRS_ALIGN_ANY);
- LoadControlBar(&m_wndShaderEditorBar, AFX_IDW_DOCKBAR_TOP);
+ m_wndCaptureBar.Create(this);
+ m_wndCaptureBar.SetBarStyle(m_wndCaptureBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndCaptureBar.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
+ LoadControlBar(&m_wndCaptureBar, AFX_IDW_DOCKBAR_LEFT);
- m_fileDropTarget.Register(this);
+ m_wndNavigationBar.Create(this);
+ m_wndNavigationBar.SetBarStyle(m_wndNavigationBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndNavigationBar.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
+ LoadControlBar(&m_wndNavigationBar, AFX_IDW_DOCKBAR_LEFT);
- GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
+ m_wndShaderEditorBar.Create(this);
+ m_wndShaderEditorBar.SetBarStyle(m_wndShaderEditorBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndShaderEditorBar.EnableDocking(CBRS_ALIGN_ANY);
+ LoadControlBar(&m_wndShaderEditorBar, AFX_IDW_DOCKBAR_TOP);
- AppSettings& s = AfxGetAppSettings();
+ m_fileDropTarget.Register(this);
- ShowControls(s.nCS);
+ GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
- SetAlwaysOnTop(s.iOnTop);
+ AppSettings& s = AfxGetAppSettings();
- ShowTrayIcon(s.fTrayIcon);
+ ShowControls(s.nCS);
- SetFocus();
+ SetAlwaysOnTop(s.iOnTop);
- m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
+ ShowTrayIcon(s.fTrayIcon);
- if(m_pGraphThread)
- m_pGraphThread->SetMainFrame(this);
+ SetFocus();
- if(s.fEnableWebServer)
- StartWebServer(s.nWebServerPort);
+ m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
- // Casimir666 : rechargement des Shaders
- {
- CString strList = AfxGetAppSettings().strShaderList;
- CString strRes;
- int curPos = 0;
+ if(m_pGraphThread)
+ m_pGraphThread->SetMainFrame(this);
- strRes = strList.Tokenize(_T("|"), curPos);
- while(strRes != _T(""))
- {
- m_shaderlabels.AddTail(strRes);
- strRes = strList.Tokenize(_T("|"), curPos);
- }
- }
- {
- CString strList = AfxGetAppSettings().strShaderListScreenSpace;
- CString strRes;
- int curPos = 0;
+ if(s.fEnableWebServer)
+ StartWebServer(s.nWebServerPort);
- strRes = strList.Tokenize(_T("|"), curPos);
- while(strRes != _T(""))
- {
- m_shaderlabelsScreenSpace.AddTail(strRes);
- strRes = strList.Tokenize(_T("|"), curPos);
- }
- }
+ // Casimir666 : rechargement des Shaders
+ {
+ CString strList = AfxGetAppSettings().strShaderList;
+ CString strRes;
+ int curPos= 0;
+
+ strRes = strList.Tokenize (_T("|"), curPos);
+ while (strRes != _T(""))
+ {
+ m_shaderlabels.AddTail (strRes);
+ strRes = strList.Tokenize(_T("|"),curPos);
+ }
+ }
+ {
+ CString strList = AfxGetAppSettings().strShaderListScreenSpace;
+ CString strRes;
+ int curPos= 0;
+
+ strRes = strList.Tokenize (_T("|"), curPos);
+ while (strRes != _T(""))
+ {
+ m_shaderlabelsScreenSpace.AddTail (strRes);
+ strRes = strList.Tokenize(_T("|"),curPos);
+ }
+ }
- m_bToggleShader = AfxGetAppSettings().m_bToggleShader;
- m_bToggleShaderScreenSpace = AfxGetAppSettings().m_bToggleShaderScreenSpace;
+ m_bToggleShader = AfxGetAppSettings().m_bToggleShader;
+ m_bToggleShaderScreenSpace = AfxGetAppSettings().m_bToggleShaderScreenSpace;
+
+ m_strTitle.Format (L"%s - v%s", ResStr(IDR_MAINFRAME), AfxGetMyApp()->m_strVersion);
+ SetWindowText(m_strTitle);
+ m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
- m_strTitle.Format(L"%s - v%s", ResStr(IDR_MAINFRAME), AfxGetMyApp()->m_strVersion);
- SetWindowText(m_strTitle);
- m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
+ SendAPICommand (CMD_CONNECT, L"%d", GetSafeHwnd());
- SendAPICommand(CMD_CONNECT, L"%d", GetSafeHwnd());
-
- return 0;
+ return 0;
}
void CMainFrame::OnDestroy()
{
- ShowTrayIcon(false);
+ ShowTrayIcon( false );
- m_fileDropTarget.Revoke();
+ m_fileDropTarget.Revoke();
- if(m_pGraphThread)
- {
- CAMEvent e;
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_EXIT, 0, (LPARAM)&e);
- if(!e.Wait(5000))
- {
- TRACE(_T("ERROR: Must call TerminateThread() on CMainFrame::m_pGraphThread->m_hThread\n"));
- TerminateThread(m_pGraphThread->m_hThread, -1);
- }
- }
+ if ( m_pGraphThread )
+ {
+ CAMEvent e;
+ m_pGraphThread->PostThreadMessage( CGraphThread::TM_EXIT, 0, (LPARAM)&e );
+ if( !e.Wait(5000) )
+ {
+ TRACE(_T("ERROR: Must call TerminateThread() on CMainFrame::m_pGraphThread->m_hThread\n"));
+ TerminateThread( m_pGraphThread->m_hThread, -1 );
+ }
+ }
- if(m_pFullscreenWnd)
- {
- if(m_pFullscreenWnd->IsWindow())
- m_pFullscreenWnd->DestroyWindow();
- delete m_pFullscreenWnd;
- }
+ if ( m_pFullscreenWnd )
+ {
+ if ( m_pFullscreenWnd->IsWindow() )
+ m_pFullscreenWnd->DestroyWindow();
+ delete m_pFullscreenWnd;
+ }
- __super::OnDestroy();
+ __super::OnDestroy();
}
void CMainFrame::OnClose()
{
- // Casimir666 : sauvegarde de la liste des shaders
- {
- POSITION pos;
- CString strList = "";
-
- pos = m_shaderlabels.GetHeadPosition();
- while(pos)
- {
- strList += m_shaderlabels.GetAt(pos) + "|";
- m_dockingbars.GetNext(pos);
- }
- AfxGetAppSettings().strShaderList = strList;
- }
- {
- POSITION pos;
- CString strList = "";
-
- pos = m_shaderlabelsScreenSpace.GetHeadPosition();
- while(pos)
- {
- strList += m_shaderlabelsScreenSpace.GetAt(pos) + "|";
- m_dockingbars.GetNext(pos);
- }
- AfxGetAppSettings().strShaderListScreenSpace = strList;
- }
-
- AfxGetAppSettings().m_bToggleShader = m_bToggleShader;
- AfxGetAppSettings().m_bToggleShaderScreenSpace = m_bToggleShaderScreenSpace;
-
- m_wndPlaylistBar.SavePlaylist();
-
- SaveControlBars();
-
- ShowWindow(SW_HIDE);
-
- CloseMedia();
-
- __super::OnClose();
+ // Casimir666 : sauvegarde de la liste des shaders
+ {
+ POSITION pos;
+ CString strList = "";
+
+ pos = m_shaderlabels.GetHeadPosition();
+ while(pos)
+ {
+ strList += m_shaderlabels.GetAt (pos) + "|";
+ m_dockingbars.GetNext(pos);
+ }
+ AfxGetAppSettings().strShaderList = strList;
+ }
+ {
+ POSITION pos;
+ CString strList = "";
+
+ pos = m_shaderlabelsScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ strList += m_shaderlabelsScreenSpace.GetAt (pos) + "|";
+ m_dockingbars.GetNext(pos);
+ }
+ AfxGetAppSettings().strShaderListScreenSpace = strList;
+ }
+
+ AfxGetAppSettings().m_bToggleShader = m_bToggleShader;
+ AfxGetAppSettings().m_bToggleShaderScreenSpace = m_bToggleShaderScreenSpace;
+
+ m_wndPlaylistBar.SavePlaylist();
+
+ SaveControlBars();
+
+ ShowWindow(SW_HIDE);
+
+ CloseMedia();
+
+ __super::OnClose();
}
DROPEFFECT CMainFrame::OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- return DROPEFFECT_NONE;
+ return DROPEFFECT_NONE;
}
DROPEFFECT CMainFrame::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
- return pDataObject->IsDataAvailable(CF_URL) ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+ UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
+ return pDataObject->IsDataAvailable(CF_URL) ? DROPEFFECT_COPY : DROPEFFECT_NONE;
}
BOOL CMainFrame::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
{
- UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
+ UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
- BOOL bResult = FALSE;
+ BOOL bResult = FALSE;
- if(pDataObject->IsDataAvailable(CF_URL))
- {
- FORMATETC fmt = {CF_URL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- if(HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt))
- {
- LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
- if(AfxIsValidString(pText))
- {
- CStringA url(pText);
-
- SetForegroundWindow();
-
- CAtlList<CString> sl;
- sl.AddTail(CString(url));
-
- if(m_wndPlaylistBar.IsWindowVisible())
- {
- m_wndPlaylistBar.Append(sl, true);
- }
- else
- {
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
- }
-
- GlobalUnlock(hGlobal);
- bResult = TRUE;
- }
- }
- }
+ if(pDataObject->IsDataAvailable(CF_URL))
+ {
+ FORMATETC fmt = {CF_URL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
+ if(HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt))
+ {
+ LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
+ if(AfxIsValidString(pText))
+ {
+ CStringA url(pText);
- return bResult;
+ SetForegroundWindow();
+
+ CAtlList<CString> sl;
+ sl.AddTail(CString(url));
+
+ if(m_wndPlaylistBar.IsWindowVisible())
+ {
+ m_wndPlaylistBar.Append(sl, true);
+ }
+ else
+ {
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
+ }
+
+ GlobalUnlock(hGlobal);
+ bResult = TRUE;
+ }
+ }
+ }
+
+ return bResult;
}
DROPEFFECT CMainFrame::OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
{
- return (DROPEFFECT) - 1;
+ return (DROPEFFECT)-1;
}
void CMainFrame::OnDragLeave()
{
}
DROPEFFECT CMainFrame::OnDragScroll(DWORD dwKeyState, CPoint point)
{
- return DROPEFFECT_NONE;
+ return DROPEFFECT_NONE;
}
LPCTSTR CMainFrame::GetRecentFile()
{
- CRecentFileList& MRU = AfxGetAppSettings().MRU;
- MRU.ReadList();
- for(int i = 0; i < MRU.GetSize(); i++)
- {
- if(!MRU[i].IsEmpty())
- return MRU[i].GetString();
- }
- return NULL;
+ CRecentFileList& MRU = AfxGetAppSettings().MRU;
+ MRU.ReadList();
+ for(int i = 0; i < MRU.GetSize();i++)
+ {
+ if(!MRU[i].IsEmpty())
+ return MRU[i].GetString();
+ }
+ return NULL;
}
void CMainFrame::LoadControlBar(CControlBar* pBar, UINT defDockBarID)
{
- if(!pBar) return;
+ if(!pBar) return;
- CString str;
- pBar->GetWindowText(str);
- if(str.IsEmpty()) return;
- CString section = _T("ToolBars\\") + str;
+ CString str;
+ pBar->GetWindowText(str);
+ if(str.IsEmpty()) return;
+ CString section = _T("ToolBars\\") + str;
- CWinApp* pApp = AfxGetApp();
+ CWinApp* pApp = AfxGetApp();
- UINT nID = pApp->GetProfileInt(section, _T("DockState"), defDockBarID);
+ UINT nID = pApp->GetProfileInt(section, _T("DockState"), defDockBarID);
- if(nID != AFX_IDW_DOCKBAR_FLOAT)
- {
- DockControlBar(pBar, nID);
- }
+ if(nID != AFX_IDW_DOCKBAR_FLOAT)
+ {
+ DockControlBar(pBar, nID);
+ }
- pBar->ShowWindow(
- pApp->GetProfileInt(section, _T("Visible"), FALSE)
- && pBar != &m_wndSubresyncBar
- && pBar != &m_wndCaptureBar
- && pBar != &m_wndShaderEditorBar
- && pBar != &m_wndNavigationBar
- ? SW_SHOW
- : SW_HIDE);
+ pBar->ShowWindow(
+ pApp->GetProfileInt(section, _T("Visible"), FALSE)
+ && pBar != &m_wndSubresyncBar
+ && pBar != &m_wndCaptureBar
+ && pBar != &m_wndShaderEditorBar
+ && pBar != &m_wndNavigationBar
+ ? SW_SHOW
+ : SW_HIDE);
- if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar))
- {
- pSCB->LoadState(section + _T("\\State"));
- m_dockingbars.AddTail(pSCB);
- }
+ if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar))
+ {
+ pSCB->LoadState(section + _T("\\State"));
+ m_dockingbars.AddTail(pSCB);
+ }
}
void CMainFrame::RestoreFloatingControlBars()
{
- CWinApp* pApp = AfxGetApp();
+ CWinApp* pApp = AfxGetApp();
- CRect r;
- GetWindowRect(r);
+ CRect r;
+ GetWindowRect(r);
- POSITION pos = m_dockingbars.GetHeadPosition();
- while(pos)
- {
- CSizingControlBar* pBar = m_dockingbars.GetNext(pos);
+ POSITION pos = m_dockingbars.GetHeadPosition();
+ while(pos)
+ {
+ CSizingControlBar* pBar = m_dockingbars.GetNext(pos);
- CString str;
- pBar->GetWindowText(str);
- if(str.IsEmpty()) return;
- CString section = _T("ToolBars\\") + str;
+ CString str;
+ pBar->GetWindowText(str);
+ if(str.IsEmpty()) return;
+ CString section = _T("ToolBars\\") + str;
- if(pApp->GetProfileInt(section, _T("DockState"), ~AFX_IDW_DOCKBAR_FLOAT) == AFX_IDW_DOCKBAR_FLOAT)
- {
- CPoint p;
- p.x = pApp->GetProfileInt(section, _T("DockPosX"), r.right);
- p.y = pApp->GetProfileInt(section, _T("DockPosY"), r.top);
- if(p.x < m_rcDesktop.left) p.x = m_rcDesktop.left;
- if(p.y < m_rcDesktop.top) p.y = m_rcDesktop.top;
- if(p.x >= m_rcDesktop.right) p.x = m_rcDesktop.right - 1;
- if(p.y >= m_rcDesktop.bottom) p.y = m_rcDesktop.bottom - 1;
- FloatControlBar(pBar, p);
- }
- }
+ if(pApp->GetProfileInt(section, _T("DockState"), ~AFX_IDW_DOCKBAR_FLOAT) == AFX_IDW_DOCKBAR_FLOAT)
+ {
+ CPoint p;
+ p.x = pApp->GetProfileInt(section, _T("DockPosX"), r.right);
+ p.y = pApp->GetProfileInt(section, _T("DockPosY"), r.top);
+ if(p.x < m_rcDesktop.left) p.x = m_rcDesktop.left;
+ if(p.y < m_rcDesktop.top) p.y = m_rcDesktop.top;
+ if(p.x >= m_rcDesktop.right) p.x = m_rcDesktop.right-1;
+ if(p.y >= m_rcDesktop.bottom) p.y = m_rcDesktop.bottom-1;
+ FloatControlBar(pBar, p);
+ }
+ }
}
void CMainFrame::SaveControlBars()
{
- CWinApp* pApp = AfxGetApp();
+ CWinApp* pApp = AfxGetApp();
- POSITION pos = m_dockingbars.GetHeadPosition();
- while(pos)
- {
- CSizingControlBar* pBar = m_dockingbars.GetNext(pos);
+ POSITION pos = m_dockingbars.GetHeadPosition();
+ while(pos)
+ {
+ CSizingControlBar* pBar = m_dockingbars.GetNext(pos);
- CString str;
- pBar->GetWindowText(str);
- if(str.IsEmpty()) return;
- CString section = _T("ToolBars\\") + str;
+ CString str;
+ pBar->GetWindowText(str);
+ if(str.IsEmpty()) return;
+ CString section = _T("ToolBars\\") + str;
- pApp->WriteProfileInt(section, _T("Visible"), pBar->IsWindowVisible());
+ pApp->WriteProfileInt(section, _T("Visible"), pBar->IsWindowVisible());
- if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar))
- {
- pSCB->SaveState(section + _T("\\State"));
- }
+ if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar))
+ {
+ pSCB->SaveState(section + _T("\\State"));
+ }
- UINT nID = pBar->GetParent()->GetDlgCtrlID();
+ UINT nID = pBar->GetParent()->GetDlgCtrlID();
+
+ if(nID == AFX_IDW_DOCKBAR_FLOAT)
+ {
+ CRect r;
+ pBar->GetParent()->GetParent()->GetWindowRect(r);
+ pApp->WriteProfileInt(section, _T("DockPosX"), r.left);
+ pApp->WriteProfileInt(section, _T("DockPosY"), r.top);
+ }
- if(nID == AFX_IDW_DOCKBAR_FLOAT)
- {
- CRect r;
- pBar->GetParent()->GetParent()->GetWindowRect(r);
- pApp->WriteProfileInt(section, _T("DockPosX"), r.left);
- pApp->WriteProfileInt(section, _T("DockPosY"), r.top);
- }
-
- pApp->WriteProfileInt(section, _T("DockState"), nID);
- }
+ pApp->WriteProfileInt(section, _T("DockState"), nID);
+ }
}
LRESULT CMainFrame::OnTaskBarRestart(WPARAM, LPARAM)
{
- m_fTrayIcon = false;
- ShowTrayIcon(AfxGetAppSettings().fTrayIcon);
+ m_fTrayIcon = false;
+ ShowTrayIcon(AfxGetAppSettings().fTrayIcon);
- return 0;
+ return 0;
}
LRESULT CMainFrame::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
if((UINT)wParam != IDR_MAINFRAME)
- return -1;
-
- switch((UINT)lParam)
- {
- case WM_LBUTTONDOWN:
- ShowWindow(SW_SHOW);
- MoveVideoWindow();
- SetForegroundWindow();
- break;
-
- case WM_LBUTTONDBLCLK:
- PostMessage(WM_COMMAND, ID_FILE_OPENMEDIA);
- break;
-
- case WM_RBUTTONDOWN:
- {
- POINT p;
- GetCursorPos(&p);
- SetForegroundWindow();
- m_popupmain.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_NOANIMATION, p.x, p.y, GetModalParent());
- PostMessage(WM_NULL);
- break;
- }
-
- case WM_MOUSEMOVE:
- {
- CString str;
- GetWindowText(str);
- SetTrayTip(str);
- break;
- }
-
- default:
- break;
- }
-
- return 0;
+ return -1;
+
+ switch((UINT)lParam)
+ {
+ case WM_LBUTTONDOWN:
+ ShowWindow(SW_SHOW);
+ MoveVideoWindow();
+ SetForegroundWindow();
+ break;
+
+ case WM_LBUTTONDBLCLK:
+ PostMessage(WM_COMMAND, ID_FILE_OPENMEDIA);
+ break;
+
+ case WM_RBUTTONDOWN:
+ {
+ POINT p;
+ GetCursorPos(&p);
+ SetForegroundWindow();
+ m_popupmain.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NOANIMATION, p.x, p.y, GetModalParent());
+ PostMessage(WM_NULL);
+ break;
+ }
+
+ case WM_MOUSEMOVE:
+ {
+ CString str;
+ GetWindowText(str);
+ SetTrayTip(str);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return 0;
}
LRESULT CMainFrame::OnTaskBarThumbnailsCreate(WPARAM, LPARAM)
{
- return CreateThumbnailToolbar();
+ return CreateThumbnailToolbar();
}
-
+
void CMainFrame::ShowTrayIcon(bool fShow)
{
BOOL bWasVisible = ShowWindow(SW_HIDE);
- NOTIFYICONDATA tnid;
-
- ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
- tnid.cbSize = sizeof(NOTIFYICONDATA);
- tnid.hWnd = m_hWnd;
- tnid.uID = IDR_MAINFRAME;
-
- if(fShow)
- {
- if(!m_fTrayIcon)
- {
- tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
- tnid.uCallbackMessage = WM_NOTIFYICON;
- StringCchCopy(tnid.szTip, countof(tnid.szTip), TEXT("Media Player Classic"));
- Shell_NotifyIcon(NIM_ADD, &tnid);
-
- m_fTrayIcon = true;
- }
- }
- else
- {
- if(m_fTrayIcon)
- {
- Shell_NotifyIcon(NIM_DELETE, &tnid);
-
- m_fTrayIcon = false;
- }
- }
-
- if(bWasVisible)
- ShowWindow(SW_SHOW);
+ NOTIFYICONDATA tnid;
+
+ ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = m_hWnd;
+ tnid.uID = IDR_MAINFRAME;
+
+ if(fShow)
+ {
+ if(!m_fTrayIcon)
+ {
+ tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ tnid.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
+ tnid.uCallbackMessage = WM_NOTIFYICON;
+ StringCchCopy(tnid.szTip, countof(tnid.szTip), TEXT("Media Player Classic"));
+ Shell_NotifyIcon(NIM_ADD, &tnid);
+
+ m_fTrayIcon = true;
+ }
+ }
+ else
+ {
+ if(m_fTrayIcon)
+ {
+ Shell_NotifyIcon(NIM_DELETE, &tnid);
+
+ m_fTrayIcon = false;
+ }
+ }
+
+ if(bWasVisible)
+ ShowWindow(SW_SHOW);
}
void CMainFrame::SetTrayTip(CString str)
{
- NOTIFYICONDATA tnid;
- tnid.cbSize = sizeof(NOTIFYICONDATA);
- tnid.hWnd = m_hWnd;
- tnid.uID = IDR_MAINFRAME;
- tnid.uFlags = NIF_TIP;
- StringCchCopy(tnid.szTip, countof(tnid.szTip), str);
- Shell_NotifyIcon(NIM_MODIFY, &tnid);
+ NOTIFYICONDATA tnid;
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = m_hWnd;
+ tnid.uID = IDR_MAINFRAME;
+ tnid.uFlags = NIF_TIP;
+ StringCchCopy(tnid.szTip, countof(tnid.szTip), str);
+ Shell_NotifyIcon(NIM_MODIFY, &tnid);
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!__super::PreCreateWindow(cs))
- return FALSE;
+ if(!__super::PreCreateWindow(cs))
+ return FALSE;
- cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
+ cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
- cs.lpszClass = MPC_WND_CLASS_NAME; //AfxRegisterWndClass(0);
+ cs.lpszClass = MPC_WND_CLASS_NAME; //AfxRegisterWndClass(0);
- return TRUE;
+ return TRUE;
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- /* if(m_fShockwaveGraph
- && (pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT
- || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN))
- return FALSE;
- */
- if(pMsg->wParam == VK_ESCAPE && m_iMediaLoadState == MLS_LOADED && m_fFullScreen)
- {
- OnViewFullscreen();
- PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
- return TRUE;
- }
- else if(pMsg->wParam == VK_ESCAPE && (IsCaptionMenuHidden()))
- {
- PostMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- return TRUE;
- }
- else if(pMsg->wParam == VK_LEFT && pAMTuner)
- {
- PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACK);
- return TRUE;
- }
- else if(pMsg->wParam == VK_RIGHT && pAMTuner)
- {
- PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- return TRUE;
- }
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if(pMsg->message == WM_KEYDOWN)
+ {
+/* if(m_fShockwaveGraph
+ && (pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT
+ || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN))
+ return FALSE;
+*/
+ if(pMsg->wParam == VK_ESCAPE && m_iMediaLoadState == MLS_LOADED && m_fFullScreen)
+ {
+ OnViewFullscreen();
+ PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ return TRUE;
+ }
+ else if(pMsg->wParam == VK_ESCAPE && (IsCaptionMenuHidden()))
+ {
+ PostMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ return TRUE;
+ }
+ else if(pMsg->wParam == VK_LEFT && pAMTuner)
+ {
+ PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACK);
+ return TRUE;
+ }
+ else if(pMsg->wParam == VK_RIGHT && pAMTuner)
+ {
+ PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ return TRUE;
+ }
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
void CMainFrame::RecalcLayout(BOOL bNotify)
{
- __super::RecalcLayout(bNotify);
+ __super::RecalcLayout(bNotify);
- CRect r;
- GetWindowRect(&r);
- MINMAXINFO mmi;
- memset(&mmi, 0, sizeof(mmi));
- SendMessage(WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
- r |= CRect(r.TopLeft(), CSize(r.Width(), mmi.ptMinTrackSize.y));
- MoveWindow(&r);
+ CRect r;
+ GetWindowRect(&r);
+ MINMAXINFO mmi;
+ memset(&mmi, 0, sizeof(mmi));
+ SendMessage(WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
+ r |= CRect(r.TopLeft(), CSize(r.Width(), mmi.ptMinTrackSize.y));
+ MoveWindow(&r);
}
/////////////////////////////////////////////////////////////////////////////
@@ -1085,12 +1075,12 @@ void CMainFrame::RecalcLayout(BOOL bNotify)
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
- __super::AssertValid();
+ __super::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
- __super::Dump(dc);
+ __super::Dump(dc);
}
#endif //_DEBUG
@@ -1099,454 +1089,454 @@ void CMainFrame::Dump(CDumpContext& dc) const
// CMainFrame message handlers
void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- // forward focus to the view window
- if(IsWindow(m_wndView.m_hWnd))
- m_wndView.SetFocus();
+ // forward focus to the view window
+ if(IsWindow(m_wndView.m_hWnd))
+ m_wndView.SetFocus();
}
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
- // let the view have first crack at the command
- if(m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
+ // let the view have first crack at the command
+ if(m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
+ return TRUE;
- POSITION pos = m_bars.GetHeadPosition();
- while(pos)
- {
- if(m_bars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
- }
+ POSITION pos = m_bars.GetHeadPosition();
+ while(pos)
+ {
+ if(m_bars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
+ return TRUE;
+ }
- pos = m_dockingbars.GetHeadPosition();
- while(pos)
- {
- if(m_dockingbars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
- return TRUE;
- }
+ pos = m_dockingbars.GetHeadPosition();
+ while(pos)
+ {
+ if(m_dockingbars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
+ return TRUE;
+ }
- // otherwise, do default handling
- return __super::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
+ // otherwise, do default handling
+ return __super::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
- DWORD style = GetStyle();
-
- MENUBARINFO mbi;
- memset(&mbi, 0, sizeof(mbi));
- mbi.cbSize = sizeof(mbi);
- ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- lpMMI->ptMinTrackSize.x = 0;
- if(!IsCaptionMenuHidden())
- {
- // Calculate menu's horizontal length in pixels
- lpMMI->ptMinTrackSize.x = 10;
- CRect r;
- for(int i = 0; ::GetMenuItemRect(m_hWnd, mbi.hMenu, i, &r); i++)
- lpMMI->ptMinTrackSize.x += r.Width();
- lpMMI->ptMinTrackSize.x = max(m_wndToolBar.GetMinWidth(), lpMMI->ptMinTrackSize.x);
- }
- if(style & WS_THICKFRAME)
- lpMMI->ptMinTrackSize.x += GetSystemMetrics((style & WS_CAPTION) ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2;
-
- // This doesn't give correct menu pixel size
- //memset(&mbi, 0, sizeof(mbi));
- //mbi.cbSize = sizeof(mbi);
- //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- lpMMI->ptMinTrackSize.y = 0;
- if(style & WS_CAPTION)
- {
- lpMMI->ptMinTrackSize.y += GetSystemMetrics(SM_CYCAPTION);
- // If we have a caption then we have a menu bar
- lpMMI->ptMinTrackSize.y += GetSystemMetrics(SM_CYMENU); //(mbi.rcBar.bottom - mbi.rcBar.top);
- }
- if(style & WS_THICKFRAME)
- lpMMI->ptMinTrackSize.y += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
- // foxx1337: believe the below line isn't needed anymore since we're using system metrics numbers above
- // JonasNo: Correct
- //if ( !AfxGetAppSettings().fHideCaptionMenu ) lpMMI->ptMinTrackSize.y += 3;
-
- POSITION pos = m_bars.GetHeadPosition();
- while(pos)
- {
- CControlBar *pCB = m_bars.GetNext(pos);
- if(!IsWindow(pCB->m_hWnd) || !pCB->IsVisible())
- continue;
-
- lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy;
- }
-
- pos = m_dockingbars.GetHeadPosition();
- while(pos)
- {
- CSizingControlBar *pCB = m_dockingbars.GetNext(pos);
- if(IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating())
- lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2; // 2 is a magic value from CSizingControlBar class, i guess this should be GetSystemMetrics( SM_CXBORDER ) or similar
- }
-
- __super::OnGetMinMaxInfo(lpMMI);
+ DWORD style = GetStyle();
+
+ MENUBARINFO mbi;
+ memset(&mbi, 0, sizeof(mbi));
+ mbi.cbSize = sizeof(mbi);
+ ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+
+ lpMMI->ptMinTrackSize.x = 0;
+ if ( !IsCaptionMenuHidden() )
+ {
+ // Calculate menu's horizontal length in pixels
+ lpMMI->ptMinTrackSize.x = 10;
+ CRect r;
+ for (int i = 0; ::GetMenuItemRect(m_hWnd, mbi.hMenu, i, &r); i++)
+ lpMMI->ptMinTrackSize.x += r.Width();
+ lpMMI->ptMinTrackSize.x = max( m_wndToolBar.GetMinWidth(), lpMMI->ptMinTrackSize.x );
+ }
+ if ( style & WS_THICKFRAME )
+ lpMMI->ptMinTrackSize.x += GetSystemMetrics( (style & WS_CAPTION) ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME ) * 2;
+
+ // This doesn't give correct menu pixel size
+ //memset(&mbi, 0, sizeof(mbi));
+ //mbi.cbSize = sizeof(mbi);
+ //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+
+ lpMMI->ptMinTrackSize.y = 0;
+ if ( style & WS_CAPTION )
+ {
+ lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYCAPTION );
+ // If we have a caption then we have a menu bar
+ lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYMENU ); //(mbi.rcBar.bottom - mbi.rcBar.top);
+ }
+ if ( style & WS_THICKFRAME )
+ lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYSIZEFRAME ) * 2;
+ // foxx1337: believe the below line isn't needed anymore since we're using system metrics numbers above
+ // JonasNo: Correct
+ //if ( !AfxGetAppSettings().fHideCaptionMenu ) lpMMI->ptMinTrackSize.y += 3;
+
+ POSITION pos = m_bars.GetHeadPosition();
+ while ( pos )
+ {
+ CControlBar *pCB = m_bars.GetNext( pos );
+ if ( !IsWindow(pCB->m_hWnd) || !pCB->IsVisible() )
+ continue;
+
+ lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy;
+ }
+
+ pos = m_dockingbars.GetHeadPosition();
+ while ( pos )
+ {
+ CSizingControlBar *pCB = m_dockingbars.GetNext( pos );
+ if ( IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating() )
+ lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2; // 2 is a magic value from CSizingControlBar class, i guess this should be GetSystemMetrics( SM_CXBORDER ) or similar
+ }
+
+ __super::OnGetMinMaxInfo( lpMMI );
}
void CMainFrame::OnMove(int x, int y)
{
- __super::OnMove(x, y);
+ __super::OnMove(x, y);
- //MoveVideoWindow(); // This isn't needed, based on my limited tests. If it is needed then please add a description the scenario(s) where it is needed.
- m_wndView.Invalidate();
+ //MoveVideoWindow(); // This isn't needed, based on my limited tests. If it is needed then please add a description the scenario(s) where it is needed.
+ m_wndView.Invalidate();
- WINDOWPLACEMENT wp;
- GetWindowPlacement(&wp);
- if(!m_fFullScreen && wp.flags != WPF_RESTORETOMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED)
- GetWindowRect(AfxGetAppSettings().rcLastWindowPos);
+ WINDOWPLACEMENT wp;
+ GetWindowPlacement(&wp);
+ if(!m_fFullScreen && wp.flags != WPF_RESTORETOMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED)
+ GetWindowRect(AfxGetAppSettings().rcLastWindowPos);
}
void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect)
{
- __super::OnMoving(fwSide, pRect);
+ __super::OnMoving(fwSide, pRect);
- if(AfxGetAppSettings().fSnapToDesktopEdges)
- {
- const CPoint threshold(3, 3);
+ if(AfxGetAppSettings().fSnapToDesktopEdges)
+ {
+ const CPoint threshold(3, 3);
- CRect r0 = m_rcDesktop;
- CRect r1 = r0 + threshold;
- CRect r2 = r0 - threshold;
+ CRect r0 = m_rcDesktop;
+ CRect r1 = r0 + threshold;
+ CRect r2 = r0 - threshold;
- RECT& wr = *pRect;
- CSize ws = CRect(wr).Size();
+ RECT& wr = *pRect;
+ CSize ws = CRect(wr).Size();
- if(wr.left < r1.left && wr.left > r2.left)
- wr.right = (wr.left = r0.left) + ws.cx;
+ if(wr.left < r1.left && wr.left > r2.left)
+ wr.right = (wr.left = r0.left) + ws.cx;
- if(wr.top < r1.top && wr.top > r2.top)
- wr.bottom = (wr.top = r0.top) + ws.cy;
+ if(wr.top < r1.top && wr.top > r2.top)
+ wr.bottom = (wr.top = r0.top) + ws.cy;
- if(wr.right < r1.right && wr.right > r2.right)
- wr.left = (wr.right = r0.right) - ws.cx;
+ if(wr.right < r1.right && wr.right > r2.right)
+ wr.left = (wr.right = r0.right) - ws.cx;
- if(wr.bottom < r1.bottom && wr.bottom > r2.bottom)
- wr.top = (wr.bottom = r0.bottom) - ws.cy;
- }
+ if(wr.bottom < r1.bottom && wr.bottom > r2.bottom)
+ wr.top = (wr.bottom = r0.bottom) - ws.cy;
+ }
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- m_OSD.OnSize(nType, cx, cy);
+ m_OSD.OnSize (nType, cx, cy);
- if(nType == SIZE_RESTORED && m_fTrayIcon)
- {
- ShowWindow(SW_SHOW);
- }
+ if(nType == SIZE_RESTORED && m_fTrayIcon)
+ {
+ ShowWindow(SW_SHOW);
+ }
- if(!m_fFullScreen)
- {
- AppSettings& s = AfxGetAppSettings();
- if(nType != SIZE_MAXIMIZED && nType != SIZE_MINIMIZED)
- GetWindowRect(s.rcLastWindowPos);
- s.lastWindowType = nType;
- }
+ if(!m_fFullScreen)
+ {
+ AppSettings& s = AfxGetAppSettings();
+ if(nType != SIZE_MAXIMIZED && nType != SIZE_MINIMIZED)
+ GetWindowRect(s.rcLastWindowPos);
+ s.lastWindowType = nType;
+ }
}
void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
{
- __super::OnSizing(fwSide, pRect);
-
- AppSettings& s = AfxGetAppSettings();
-
- bool fCtrl = !!(GetAsyncKeyState(VK_CONTROL) & 0x80000000);
-
- if(m_iMediaLoadState != MLS_LOADED || m_fFullScreen
- || s.iDefaultVideoSize == DVS_STRETCH
- || (fCtrl == s.fLimitWindowProportions)) // remember that fCtrl is initialized with !!whatever(), same with fLimitWindowProportions
- return;
-
- CSize wsize(pRect->right - pRect->left, pRect->bottom - pRect->top);
- CSize vsize = GetVideoSize();
- CSize fsize(0, 0);
-
- if(!vsize.cx || !vsize.cy)
- return;
-
- // TODO
- {
- DWORD style = GetStyle();
-
- // This doesn't give correct menu pixel size
- //MENUBARINFO mbi;
- //memset(&mbi, 0, sizeof(mbi));
- //mbi.cbSize = sizeof(mbi);
- //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- if(style & WS_THICKFRAME)
- fsize.cx += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
-
- if(style & WS_CAPTION)
- {
- fsize.cy += GetSystemMetrics(SM_CYCAPTION);
- // If we have a caption then we have a menu bar
- fsize.cy += GetSystemMetrics(SM_CYMENU); //mbi.rcBar.bottom - mbi.rcBar.top;
- }
- if(style & WS_THICKFRAME)
- fsize.cy += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
- //if ( !AfxGetAppSettings().fHideCaptionMenu ) fsize.cy += 3; // Now using correct window calculation
-
- POSITION pos = m_bars.GetHeadPosition();
- while(pos)
- {
- CControlBar * pCB = m_bars.GetNext(pos);
- if(IsWindow(pCB->m_hWnd) && pCB->IsVisible())
- fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy;
- }
-
- pos = m_dockingbars.GetHeadPosition();
- while(pos)
- {
- CSizingControlBar *pCB = m_dockingbars.GetNext(pos);
-
- if(IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible())
- {
- if(pCB->IsHorzDocked())
- fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2;
- else if(pCB->IsVertDocked())
- fsize.cx += pCB->CalcFixedLayout(TRUE, FALSE).cx;
- }
- }
- }
-
- wsize -= fsize;
-
- bool fWider = wsize.cy < wsize.cx;
-
- wsize.SetSize(
- wsize.cy * vsize.cx / vsize.cy,
- wsize.cx * vsize.cy / vsize.cx);
-
- wsize += fsize;
-
- if(fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM || !fWider && (fwSide == WMSZ_TOPRIGHT || fwSide == WMSZ_BOTTOMRIGHT))
- {
- pRect->right = pRect->left + wsize.cx;
- }
- else if(fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT || fWider && (fwSide == WMSZ_BOTTOMLEFT || fwSide == WMSZ_BOTTOMRIGHT))
- {
- pRect->bottom = pRect->top + wsize.cy;
- }
- else if(!fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_BOTTOMLEFT))
- {
- pRect->left = pRect->right - wsize.cx;
- }
- else if(fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_TOPRIGHT))
- {
- pRect->top = pRect->bottom - wsize.cy;
- }
+ __super::OnSizing(fwSide, pRect);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fCtrl = !!(GetAsyncKeyState(VK_CONTROL)&0x80000000);
+
+ if(m_iMediaLoadState != MLS_LOADED || m_fFullScreen
+ || s.iDefaultVideoSize == DVS_STRETCH
+ || (fCtrl == s.fLimitWindowProportions)) // remember that fCtrl is initialized with !!whatever(), same with fLimitWindowProportions
+ return;
+
+ CSize wsize(pRect->right - pRect->left, pRect->bottom - pRect->top);
+ CSize vsize = GetVideoSize();
+ CSize fsize(0, 0);
+
+ if(!vsize.cx || !vsize.cy)
+ return;
+
+ // TODO
+ {
+ DWORD style = GetStyle();
+
+ // This doesn't give correct menu pixel size
+ //MENUBARINFO mbi;
+ //memset(&mbi, 0, sizeof(mbi));
+ //mbi.cbSize = sizeof(mbi);
+ //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+
+ if ( style & WS_THICKFRAME )
+ fsize.cx += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
+
+ if ( style & WS_CAPTION )
+ {
+ fsize.cy += GetSystemMetrics( SM_CYCAPTION );
+ // If we have a caption then we have a menu bar
+ fsize.cy += GetSystemMetrics( SM_CYMENU ); //mbi.rcBar.bottom - mbi.rcBar.top;
+ }
+ if ( style & WS_THICKFRAME )
+ fsize.cy += GetSystemMetrics( SM_CYSIZEFRAME ) * 2;
+ //if ( !AfxGetAppSettings().fHideCaptionMenu ) fsize.cy += 3; // Now using correct window calculation
+
+ POSITION pos = m_bars.GetHeadPosition();
+ while ( pos )
+ {
+ CControlBar * pCB = m_bars.GetNext( pos );
+ if ( IsWindow(pCB->m_hWnd) && pCB->IsVisible() )
+ fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy;
+ }
+
+ pos = m_dockingbars.GetHeadPosition();
+ while ( pos )
+ {
+ CSizingControlBar *pCB = m_dockingbars.GetNext( pos );
+
+ if ( IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() )
+ {
+ if ( pCB->IsHorzDocked() )
+ fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2;
+ else if ( pCB->IsVertDocked() )
+ fsize.cx += pCB->CalcFixedLayout(TRUE, FALSE).cx;
+ }
+ }
+ }
+
+ wsize -= fsize;
+
+ bool fWider = wsize.cy < wsize.cx;
+
+ wsize.SetSize(
+ wsize.cy * vsize.cx / vsize.cy,
+ wsize.cx * vsize.cy / vsize.cx);
+
+ wsize += fsize;
+
+ if(fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM || !fWider && (fwSide == WMSZ_TOPRIGHT || fwSide == WMSZ_BOTTOMRIGHT))
+ {
+ pRect->right = pRect->left + wsize.cx;
+ }
+ else if(fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT || fWider && (fwSide == WMSZ_BOTTOMLEFT || fwSide == WMSZ_BOTTOMRIGHT))
+ {
+ pRect->bottom = pRect->top + wsize.cy;
+ }
+ else if(!fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_BOTTOMLEFT))
+ {
+ pRect->left = pRect->right - wsize.cx;
+ }
+ else if(fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_TOPRIGHT))
+ {
+ pRect->top = pRect->bottom - wsize.cy;
+ }
}
void CMainFrame::OnDisplayChange() // untested, not sure if it's working...
{
- TRACE(_T("*** CMainFrame::OnDisplayChange()\n"));
- /*
- if(m_iMediaLoadState == MLS_LOADED && m_pCAP)
- m_pCAP->OnDisplayChange();
- */
+ TRACE(_T("*** CMainFrame::OnDisplayChange()\n"));
+/*
+ if(m_iMediaLoadState == MLS_LOADED && m_pCAP)
+ m_pCAP->OnDisplayChange();
+*/
- GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
- if(m_pFullscreenWnd && m_pFullscreenWnd->IsWindow())
- {
- MONITORINFO MonitorInfo;
- HMONITOR hMonitor;
- ZeroMemory(&MonitorInfo, sizeof(MonitorInfo));
- MonitorInfo.cbSize = sizeof(MonitorInfo);
- hMonitor = MonitorFromWindow(m_pFullscreenWnd->m_hWnd, 0);
- if(GetMonitorInfo(hMonitor, &MonitorInfo))
- {
- CRect MonitorRect = CRect(MonitorInfo.rcMonitor);
- m_fullWndSize.cx = MonitorRect.Width();
- m_fullWndSize.cy = MonitorRect.Height();
- m_pFullscreenWnd->SetWindowPos(NULL,
- MonitorRect.left,
- MonitorRect.top,
- MonitorRect.Width(),
- MonitorRect.Height(), SWP_NOZORDER);
- MoveVideoWindow();
- }
- }
+ GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
+ if (m_pFullscreenWnd && m_pFullscreenWnd->IsWindow())
+ {
+ MONITORINFO MonitorInfo;
+ HMONITOR hMonitor;
+ ZeroMemory (&MonitorInfo, sizeof(MonitorInfo));
+ MonitorInfo.cbSize = sizeof(MonitorInfo);
+ hMonitor = MonitorFromWindow (m_pFullscreenWnd->m_hWnd, 0);
+ if (GetMonitorInfo (hMonitor, &MonitorInfo))
+ {
+ CRect MonitorRect = CRect (MonitorInfo.rcMonitor);
+ m_fullWndSize.cx = MonitorRect.Width();
+ m_fullWndSize.cy = MonitorRect.Height();
+ m_pFullscreenWnd->SetWindowPos (NULL,
+ MonitorRect.left,
+ MonitorRect.top,
+ MonitorRect.Width(),
+ MonitorRect.Height(), SWP_NOZORDER);
+ MoveVideoWindow();
+ }
+ }
}
#include <psapi.h>
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
- // Only stop screensaver if video playing; allow for audio only
- if((GetMediaState() == State_Running && !m_fAudioOnly) && (((nID & 0xFFF0) == SC_SCREENSAVE) || ((nID & 0xFFF0) == SC_MONITORPOWER)))
- {
- TRACE(_T("SC_SCREENSAVE, nID = %d, lParam = %d\n"), nID, lParam);
- return;
- }
- else if((nID & 0xFFF0) == SC_MINIMIZE && m_fTrayIcon)
- {
- ShowWindow(SW_HIDE);
- return;
- }
+ // Only stop screensaver if video playing; allow for audio only
+ if ((GetMediaState() == State_Running && !m_fAudioOnly) && (((nID & 0xFFF0) == SC_SCREENSAVE) || ((nID & 0xFFF0) == SC_MONITORPOWER)))
+ {
+ TRACE(_T("SC_SCREENSAVE, nID = %d, lParam = %d\n"), nID, lParam);
+ return;
+ }
+ else if((nID & 0xFFF0) == SC_MINIMIZE && m_fTrayIcon)
+ {
+ ShowWindow(SW_HIDE);
+ return;
+ }
- __super::OnSysCommand(nID, lParam);
+ __super::OnSysCommand(nID, lParam);
}
void CMainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID)
{
- __super::OnActivateApp(bActive, dwThreadID);
+ __super::OnActivateApp(bActive, dwThreadID);
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
- if(!bActive && (mi.dwFlags & MONITORINFOF_PRIMARY) && m_fFullScreen && m_iMediaLoadState == MLS_LOADED)
- {
- bool fExitFullscreen = true;
+ if(!bActive && (mi.dwFlags&MONITORINFOF_PRIMARY) && m_fFullScreen && m_iMediaLoadState == MLS_LOADED)
+ {
+ bool fExitFullscreen = true;
- if(CWnd* pWnd = GetForegroundWindow())
- {
- HMONITOR hMonitor1 = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- HMONITOR hMonitor2 = MonitorFromWindow(pWnd->m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor1 && hMonitor2 && hMonitor1 != hMonitor2) fExitFullscreen = false;
-
- CString title;
- pWnd->GetWindowText(title);
-
- CString module;
-
- if(GetVersion() & 0x80000000)
- {
- module.ReleaseBufferSetLength(GetWindowModuleFileName(pWnd->m_hWnd, module.GetBuffer(MAX_PATH), MAX_PATH));
- }
- else
- {
- DWORD pid;
- GetWindowThreadProcessId(pWnd->m_hWnd, &pid);
-
- if(HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid))
- {
- HMODULE hMod;
- DWORD cbNeeded;
-
- if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
- {
- module.ReleaseBufferSetLength(GetModuleFileNameEx(hProcess, hMod, module.GetBuffer(MAX_PATH), MAX_PATH));
- }
-
- CloseHandle(hProcess);
- }
- }
-
- CPath p(module);
- p.StripPath();
- module = (LPCTSTR)p;
- module.MakeLower();
-
- CString str;
- str.Format(ResStr(IDS_MAINFRM_2), module, title);
- SendStatusMessage(str, 5000);
- }
+ if(CWnd* pWnd = GetForegroundWindow())
+ {
+ HMONITOR hMonitor1 = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ HMONITOR hMonitor2 = MonitorFromWindow(pWnd->m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(hMonitor1 && hMonitor2 && hMonitor1 != hMonitor2) fExitFullscreen = false;
- if(fExitFullscreen) OnViewFullscreen();
- }
+ CString title;
+ pWnd->GetWindowText(title);
+
+ CString module;
+
+ if(GetVersion()&0x80000000)
+ {
+ module.ReleaseBufferSetLength(GetWindowModuleFileName(pWnd->m_hWnd, module.GetBuffer(MAX_PATH), MAX_PATH));
+ }
+ else
+ {
+ DWORD pid;
+ GetWindowThreadProcessId(pWnd->m_hWnd, &pid);
+
+ if(HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid))
+ {
+ HMODULE hMod;
+ DWORD cbNeeded;
+
+ if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
+ {
+ module.ReleaseBufferSetLength(GetModuleFileNameEx(hProcess, hMod, module.GetBuffer(MAX_PATH), MAX_PATH));
+ }
+
+ CloseHandle(hProcess);
+ }
+ }
+
+ CPath p(module);
+ p.StripPath();
+ module = (LPCTSTR)p;
+ module.MakeLower();
+
+ CString str;
+ str.Format(ResStr(IDS_MAINFRM_2), module, title);
+ SendStatusMessage(str, 5000);
+ }
+
+ if(fExitFullscreen) OnViewFullscreen();
+ }
}
LRESULT CMainFrame::OnAppCommand(WPARAM wParam, LPARAM lParam)
{
- UINT cmd = GET_APPCOMMAND_LPARAM(lParam);
- UINT uDevice = GET_DEVICE_LPARAM(lParam);
- UINT dwKeys = GET_KEYSTATE_LPARAM(lParam);
+ UINT cmd = GET_APPCOMMAND_LPARAM(lParam);
+ UINT uDevice = GET_DEVICE_LPARAM(lParam);
+ UINT dwKeys = GET_KEYSTATE_LPARAM(lParam);
- if(uDevice != FAPPCOMMAND_OEM ||
- cmd == APPCOMMAND_MEDIA_PLAY || cmd == APPCOMMAND_MEDIA_PAUSE || cmd == APPCOMMAND_MEDIA_CHANNEL_UP ||
- cmd == APPCOMMAND_MEDIA_CHANNEL_DOWN || cmd == APPCOMMAND_MEDIA_RECORD ||
- cmd == APPCOMMAND_MEDIA_FAST_FORWARD || cmd == APPCOMMAND_MEDIA_REWIND)
- {
- AppSettings& s = AfxGetAppSettings();
+ if(uDevice != FAPPCOMMAND_OEM ||
+ cmd == APPCOMMAND_MEDIA_PLAY || cmd == APPCOMMAND_MEDIA_PAUSE || cmd == APPCOMMAND_MEDIA_CHANNEL_UP ||
+ cmd == APPCOMMAND_MEDIA_CHANNEL_DOWN || cmd == APPCOMMAND_MEDIA_RECORD ||
+ cmd == APPCOMMAND_MEDIA_FAST_FORWARD || cmd == APPCOMMAND_MEDIA_REWIND )
+ {
+ AppSettings& s = AfxGetAppSettings();
- BOOL fRet = FALSE;
+ BOOL fRet = FALSE;
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- if(wc.appcmd == cmd && TRUE == SendMessage(WM_COMMAND, wc.cmd))
- fRet = TRUE;
- }
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos)
+ {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ if(wc.appcmd == cmd && TRUE == SendMessage(WM_COMMAND, wc.cmd))
+ fRet = TRUE;
+ }
- if(fRet) return TRUE;
- }
+ if(fRet) return TRUE;
+ }
- return Default();
+ return Default();
}
void CMainFrame::OnRawInput(UINT nInputcode, HRAWINPUT hRawInput)
{
- AppSettings& s = AfxGetAppSettings();
- UINT nMceCmd = 0;
-
- nMceCmd = AfxGetMyApp()->GetRemoteControlCode(nInputcode, hRawInput);
- switch(nMceCmd)
- {
- case MCE_DETAILS :
- case MCE_GUIDE :
- case MCE_TVJUMP :
- case MCE_STANDBY :
- case MCE_OEM1 :
- case MCE_OEM2 :
- case MCE_MYTV :
- case MCE_MYVIDEOS :
- case MCE_MYPICTURES :
- case MCE_MYMUSIC :
- case MCE_RECORDEDTV :
- case MCE_DVDANGLE :
- case MCE_DVDAUDIO :
- case MCE_DVDMENU :
- case MCE_DVDSUBTITLE :
- case MCE_RED :
- case MCE_GREEN :
- case MCE_YELLOW :
- case MCE_BLUE :
- case MCE_MEDIA_NEXTTRACK :
- case MCE_MEDIA_PREVIOUSTRACK :
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- if(wc.appcmd == nMceCmd)
- {
- SendMessage(WM_COMMAND, wc.cmd);
- break;
- }
- }
- break;
- }
+ AppSettings& s = AfxGetAppSettings();
+ UINT nMceCmd = 0;
+
+ nMceCmd = AfxGetMyApp()->GetRemoteControlCode (nInputcode, hRawInput);
+ switch (nMceCmd)
+ {
+ case MCE_DETAILS :
+ case MCE_GUIDE :
+ case MCE_TVJUMP :
+ case MCE_STANDBY :
+ case MCE_OEM1 :
+ case MCE_OEM2 :
+ case MCE_MYTV :
+ case MCE_MYVIDEOS :
+ case MCE_MYPICTURES :
+ case MCE_MYMUSIC :
+ case MCE_RECORDEDTV :
+ case MCE_DVDANGLE :
+ case MCE_DVDAUDIO :
+ case MCE_DVDMENU :
+ case MCE_DVDSUBTITLE :
+ case MCE_RED :
+ case MCE_GREEN :
+ case MCE_YELLOW :
+ case MCE_BLUE :
+ case MCE_MEDIA_NEXTTRACK :
+ case MCE_MEDIA_PREVIOUSTRACK :
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos)
+ {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ if(wc.appcmd == nMceCmd)
+ {
+ SendMessage(WM_COMMAND, wc.cmd);
+ break;
+ }
+ }
+ break;
+ }
}
LRESULT CMainFrame::OnHotKey(WPARAM wParam, LPARAM lParam)
{
- AppSettings& s = AfxGetAppSettings();
- BOOL fRet = FALSE;
+ AppSettings& s = AfxGetAppSettings();
+ BOOL fRet = FALSE;
- if(GetActiveWindow() == this || s.fGlobalMedia == TRUE)
- {
- POSITION pos = s.wmcmds.GetHeadPosition();
+ if (GetActiveWindow() == this || s.fGlobalMedia == TRUE)
+ {
+ POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- if(wc.appcmd == wParam && TRUE == SendMessage(WM_COMMAND, wc.cmd))
- fRet = TRUE;
- }
- }
+ while(pos)
+ {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ if (wc.appcmd == wParam && TRUE == SendMessage(WM_COMMAND, wc.cmd))
+ fRet = TRUE;
+ }
+ }
- return fRet;
+ return fRet;
}
bool g_bNoDuration = false;
@@ -1554,542 +1544,512 @@ bool g_bExternalSubtitleTime = false;
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == TIMER_STREAMPOSPOLLER && m_iMediaLoadState == MLS_LOADED)
- {
- REFERENCE_TIME rtNow = 0, rtDur = 0;
-
- if(m_iPlaybackMode == PM_FILE)
- {
- pMS->GetCurrentPosition(&rtNow);
- pMS->GetDuration(&rtDur);
-
- // Casimir666 : autosave subtitle sync after play
- if((m_nCurSubtitle >= 0) && (m_rtCurSubPos != rtNow))
- {
- if(m_lSubtitleShift != 0)
- {
- if(m_wndSubresyncBar.SaveToDisk())
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_AG_SUBTITLES_SAVED), 500);
- else
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_MAINFRM_4));
- }
- m_nCurSubtitle = -1;
- m_lSubtitleShift = 0;
- }
-
- if(!m_fEndOfStream)
- {
- FILE_POSITION* FilePosition = AfxGetAppSettings().CurrentFilePosition();
- if(FilePosition) FilePosition->llPosition = rtNow;
- }
-
- if(m_rtDurationOverride >= 0) rtDur = m_rtDurationOverride;
-
- g_bNoDuration = rtDur <= 0;
- m_wndSeekBar.Enable(rtDur > 0);
- m_wndSeekBar.SetRange(0, rtDur);
- m_wndSeekBar.SetPos(rtNow);
- m_OSD.SetRange(0, rtDur);
- m_OSD.SetPos(rtNow);
- m_Lcd.SetMediaRange(0, rtDur);
- m_Lcd.SetMediaPos(rtNow);
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- pMS->GetCurrentPosition(&rtNow);
- if(m_fCapturing && m_wndCaptureBar.m_capdlg.m_pMux)
- {
- CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
- if(!pMuxMS || FAILED(pMuxMS->GetCurrentPosition(&rtNow))) rtNow = 0;
- }
-
- if(m_rtDurationOverride >= 0) rtDur = m_rtDurationOverride;
-
- g_bNoDuration = rtDur <= 0;
- m_wndSeekBar.Enable(false);
- m_wndSeekBar.SetRange(0, rtDur);
- m_wndSeekBar.SetPos(rtNow);
- m_OSD.SetRange(0, rtDur);
- m_OSD.SetPos(rtNow);
- m_Lcd.SetMediaRange(0, rtDur);
- m_Lcd.SetMediaPos(rtNow);
- /*
- if(m_fCapturing)
- {
- if(rtNow > 10000i64*1000*60*60*3)
- {
- m_wndCaptureBar.m_capdlg.OnRecord();
- }
- }
- */
- }
-
- if(m_pCAP && m_iPlaybackMode != PM_FILE)
- {
- g_bExternalSubtitleTime = true;
- if(pDVDI)
- {
- DVD_PLAYBACK_LOCATION2 Location;
- if(pDVDI->GetCurrentLocation(&Location) == S_OK)
- {
- double fps = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
- : 25.0;
-
- LONGLONG rtTimeCode = HMSF2RT(Location.TimeCode, fps);
- m_pCAP->SetTime(rtTimeCode);
- }
- else
- m_pCAP->SetTime(/*rtNow*/m_wndSeekBar.GetPos());
- }
- else
- {
- // Set rtNow to support DVB subtitle
- m_pCAP->SetTime(rtNow);
- }
- }
- else
- g_bExternalSubtitleTime = false;
- }
- else if(nIDEvent == TIMER_STREAMPOSPOLLER2 && m_iMediaLoadState == MLS_LOADED)
- {
- __int64 start, stop, pos;
- m_wndSeekBar.GetRange(start, stop);
- pos = m_wndSeekBar.GetPosReal();
-
- GUID tf;
- pMS->GetTimeFormat(&tf);
-
- if(m_iPlaybackMode == PM_CAPTURE && !m_fCapturing)
- {
- CString str = _T("Live");
-
- long lChannel = 0, lVivSub = 0, lAudSub = 0;
- if(pAMTuner
- && m_wndCaptureBar.m_capdlg.IsTunerActive()
- && SUCCEEDED(pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub)))
- {
- CString ch;
- ch.Format(_T(" (ch%d)"), lChannel);
- str += ch;
- }
-
- m_wndStatusBar.SetStatusTimer(str);
- }
- else
- {
- m_wndStatusBar.SetStatusTimer(pos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
- if(m_bRemainingTime) m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer());
-
- }
-
- m_wndSubresyncBar.SetTime(pos);
-
- if(m_pCAP && GetMediaState() == State_Paused)
- m_pCAP->Paint(false);
- }
- else if(nIDEvent == TIMER_FULLSCREENCONTROLBARHIDER)
- {
- CPoint p;
- GetCursorPos(&p);
-
- CRect r;
- GetWindowRect(r);
- bool fCursorOutside = !r.PtInRect(p);
-
- CWnd* pWnd = WindowFromPoint(p);
- if(pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside))
- {
- if(AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut >= 0)
- ShowControls(CS_NONE, false);
- }
- }
- else if(nIDEvent == TIMER_FULLSCREENMOUSEHIDER)
- {
- CPoint p;
- GetCursorPos(&p);
-
- CRect r;
- GetWindowRect(r);
- bool fCursorOutside = !r.PtInRect(p);
-
- if(m_pFullscreenWnd->IsWindow())
- {
- TRACE("==> HIDE!\n");
- if(!m_bInOptions)
- m_pFullscreenWnd->ShowCursor(false);
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- }
- else
- {
- CWnd* pWnd = WindowFromPoint(p);
- if(pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside))
- {
- m_fHideCursor = true;
- SetCursor(NULL);
- }
- }
- }
- else if(nIDEvent == TIMER_STATS)
- {
- if(pQP)
- {
- CString rate;
- if(m_iSpeedLevel >= -11 && m_iSpeedLevel <= 3 && m_iSpeedLevel != -4)
- {
- CString speeds[] = {_T("1/8"), _T("1/4"), _T("1/2"), _T("1"), _T("2"), _T("4"), _T("8")};
- rate = speeds[(m_iSpeedLevel >= -3 ? m_iSpeedLevel : (-m_iSpeedLevel - 8)) + 3];
- if(m_iSpeedLevel < -4) rate = _T("-") + rate;
- if(!rate.IsEmpty()) rate = _T("(") + rate + _T("X)");
- }
-
- CString info;
- int val;
-
- pQP->get_AvgFrameRate(&val);
- info.Format(_T("%d.%02d %s"), val / 100, val % 100, rate);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
-
- int avg, dev;
- pQP->get_AvgSyncOffset(&avg);
- pQP->get_DevSyncOffset(&dev);
- info.Format(_T("avg: %d ms, dev: %d ms"), avg, dev);
- m_wndStatsBar.SetLine(_T("Sync Offset"), info);
-
- int drawn, dropped;
- pQP->get_FramesDrawn(&drawn);
- pQP->get_FramesDroppedInRenderer(&dropped);
- info.Format(ResStr(IDS_MAINFRM_6), drawn, dropped);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
-
- pQP->get_Jitter(&val);
- info.Format(_T("%d ms"), val);
- m_wndStatsBar.SetLine(_T("Jitter"), info);
- }
-
- if(pBI)
- {
- CAtlList<CString> sl;
-
- for(int i = 0, j = pBI->GetCount(); i < j; i++)
- {
- int samples, size;
- if(S_OK == pBI->GetStatus(i, samples, size))
- {
- CString str;
- str.Format(_T("[%d]: %03d/%d KB"), i, samples, size / 1024);
- sl.AddTail(str);
- }
- }
-
- if(!sl.IsEmpty())
- {
- CString str;
- str.Format(_T("%s (p%d)"), Implode(sl, ' '), pBI->GetPriority());
-
- m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), str);
- }
- }
-
- CInterfaceList<IBitRateInfo> pBRIs;
-
- BeginEnumFilters(pGB, pEF, pBF)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(CComQIPtr<IBitRateInfo> pBRI = pPin)
- {
- pBRIs.AddTail(pBRI);
- }
- }
- EndEnumPins
-
- if(!pBRIs.IsEmpty())
- {
- CAtlList<CString> sl;
-
- POSITION pos = pBRIs.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
- IBitRateInfo* pBRI = pBRIs.GetNext(pos);
-
- DWORD cur = pBRI->GetCurrentBitRate() / 1000;
- DWORD avg = pBRI->GetAverageBitRate() / 1000;
-
- if(avg == 0) continue;
-
- CString str;
- if(cur != avg) str.Format(_T("[%d]: %d/%d Kb/s"), i, avg, cur);
- else str.Format(_T("[%d]: %d Kb/s"), i, avg);
- sl.AddTail(str);
- }
-
- if(!sl.IsEmpty())
- {
- m_wndStatsBar.SetLine(_T("Bitrate"), Implode(sl, ' ') + _T(" (avg/cur)"));
- }
-
- break;
- }
- }
- EndEnumFilters
-
- if(m_iPlaybackMode == PM_FILE)
- {
- SetupChapters();
- }
-
- if(m_iPlaybackMode == PM_DVD) // we also use this timer to update the info panel for dvd playback
- {
- ULONG ulAvailable, ulCurrent;
-
- // Location
-
- CString Location('-');
-
- DVD_PLAYBACK_LOCATION2 loc;
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles;
- ULONG ulNumOfChapters;
-
- if(SUCCEEDED(pDVDI->GetCurrentLocation(&loc))
- && SUCCEEDED(pDVDI->GetNumberOfChapters(loc.TitleNum, &ulNumOfChapters))
- && SUCCEEDED(pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles)))
- {
- Location.Format(ResStr(IDS_MAINFRM_9),
- ulVolume, ulNumOfVolumes,
- loc.TitleNum, ulNumOfTitles,
- loc.ChapterNum, ulNumOfChapters);
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), Location);
-
- // Video
-
- CString Video('-');
-
- DVD_VideoAttributes VATR;
-
- if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAvailable, &ulCurrent))
- && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR)))
- {
- Video.Format(ResStr(IDS_MAINFRM_10),
- ulAvailable, ulCurrent,
- VATR.ulSourceResolutionX, VATR.ulSourceResolutionY, VATR.ulFrameRate,
- VATR.ulAspectX, VATR.ulAspectY);
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), Video);
-
- // Audio
-
- CString Audio('-');
-
- DVD_AudioAttributes AATR;
-
- if(SUCCEEDED(pDVDI->GetCurrentAudio(&ulAvailable, &ulCurrent))
- && SUCCEEDED(pDVDI->GetAudioAttributes(ulCurrent, &AATR)))
- {
- CString lang;
- int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len - 1, 0));
-
- switch(AATR.LanguageExtension)
- {
- case DVD_AUD_EXT_NotSpecified:
- default:
- break;
- case DVD_AUD_EXT_Captions:
- lang += _T(" (Captions)");
- break;
- case DVD_AUD_EXT_VisuallyImpaired:
- lang += _T(" (Visually Impaired)");
- break;
- case DVD_AUD_EXT_DirectorComments1:
- lang += _T(" (Director Comments 1)");
- break;
- case DVD_AUD_EXT_DirectorComments2:
- lang += _T(" (Director Comments 2)");
- break;
- }
-
- CString format = GetDVDAudioFormatName(AATR);
-
- Audio.Format(ResStr(IDS_MAINFRM_11),
- lang,
- format,
- AATR.dwFrequency,
- AATR.bQuantization,
- AATR.bNumberOfChannels,
- (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
-
- m_wndStatusBar.SetStatusBitmap(
- AATR.bNumberOfChannels == 1 ? IDB_MONO
- : AATR.bNumberOfChannels >= 2 ? IDB_STEREO
- : IDB_NOAUDIO);
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), Audio);
-
- // Subtitles
-
- CString Subtitles('-');
-
- BOOL bIsDisabled;
- DVD_SubpictureAttributes SATR;
-
- if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulAvailable, &ulCurrent, &bIsDisabled))
- && SUCCEEDED(pDVDI->GetSubpictureAttributes(ulCurrent, &SATR)))
- {
- CString lang;
- int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len - 1, 0));
-
- switch(SATR.LanguageExtension)
- {
- case DVD_SP_EXT_NotSpecified:
- default:
- break;
- case DVD_SP_EXT_Caption_Normal:
- lang += _T("");
- break;
- case DVD_SP_EXT_Caption_Big:
- lang += _T(" (Big)");
- break;
- case DVD_SP_EXT_Caption_Children:
- lang += _T(" (Children)");
- break;
- case DVD_SP_EXT_CC_Normal:
- lang += _T(" (CC)");
- break;
- case DVD_SP_EXT_CC_Big:
- lang += _T(" (CC Big)");
- break;
- case DVD_SP_EXT_CC_Children:
- lang += _T(" (CC Children)");
- break;
- case DVD_SP_EXT_Forced:
- lang += _T(" (Forced)");
- break;
- case DVD_SP_EXT_DirectorComments_Normal:
- lang += _T(" (Director Comments)");
- break;
- case DVD_SP_EXT_DirectorComments_Big:
- lang += _T(" (Director Comments, Big)");
- break;
- case DVD_SP_EXT_DirectorComments_Children:
- lang += _T(" (Director Comments, Children)");
- break;
- }
-
- if(bIsDisabled) lang = _T("-");
-
- Subtitles.Format(_T("%s"),
- lang);
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), Subtitles);
- }
-
- if(GetMediaState() == State_Running && !m_fAudioOnly)
- {
- UINT fSaverActive = 0;
- if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fSaverActive, 0))
- {
- SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
- SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
- }
-
- fSaverActive = 0;
- if(SystemParametersInfo(SPI_GETPOWEROFFACTIVE, 0, (PVOID)&fSaverActive, 0))
- {
- SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
- SystemParametersInfo(SPI_SETPOWEROFFACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
- }
- // prevent screensaver activate, monitor sleep/turn off after playback
- SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
- }
- }
- else if(nIDEvent == TIMER_STATUSERASER)
- {
- KillTimer(TIMER_STATUSERASER);
- m_playingmsg.Empty();
- }
-
- __super::OnTimer(nIDEvent);
+ if(nIDEvent == TIMER_STREAMPOSPOLLER && m_iMediaLoadState == MLS_LOADED)
+ {
+ REFERENCE_TIME rtNow = 0, rtDur = 0;
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ pMS->GetCurrentPosition(&rtNow);
+ pMS->GetDuration(&rtDur);
+
+ // Casimir666 : autosave subtitle sync after play
+ if ((m_nCurSubtitle >= 0) && (m_rtCurSubPos != rtNow))
+ {
+ if (m_lSubtitleShift != 0)
+ {
+ if (m_wndSubresyncBar.SaveToDisk())
+ m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_AG_SUBTITLES_SAVED), 500);
+ else
+ m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_MAINFRM_4));
+ }
+ m_nCurSubtitle = -1;
+ m_lSubtitleShift = 0;
+ }
+
+ if(!m_fEndOfStream)
+ {
+ FILE_POSITION* FilePosition = AfxGetAppSettings().CurrentFilePosition();
+ if (FilePosition) FilePosition->llPosition = rtNow;
+ }
+
+ if(m_rtDurationOverride >= 0) rtDur = m_rtDurationOverride;
+
+ g_bNoDuration = rtDur <= 0;
+ m_wndSeekBar.Enable(rtDur > 0);
+ m_wndSeekBar.SetRange(0, rtDur);
+ m_wndSeekBar.SetPos(rtNow);
+ m_OSD.SetRange (0, rtDur);
+ m_OSD.SetPos (rtNow);
+ m_Lcd.SetMediaRange(0, rtDur);
+ m_Lcd.SetMediaPos(rtNow);
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ pMS->GetCurrentPosition(&rtNow);
+ if(m_fCapturing && m_wndCaptureBar.m_capdlg.m_pMux)
+ {
+ CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
+ if(!pMuxMS || FAILED(pMuxMS->GetCurrentPosition(&rtNow))) rtNow = 0;
+ }
+
+ if(m_rtDurationOverride >= 0) rtDur = m_rtDurationOverride;
+
+ g_bNoDuration = rtDur <= 0;
+ m_wndSeekBar.Enable(false);
+ m_wndSeekBar.SetRange(0, rtDur);
+ m_wndSeekBar.SetPos(rtNow);
+ m_OSD.SetRange (0, rtDur);
+ m_OSD.SetPos (rtNow);
+ m_Lcd.SetMediaRange(0, rtDur);
+ m_Lcd.SetMediaPos(rtNow);
+/*
+ if(m_fCapturing)
+ {
+ if(rtNow > 10000i64*1000*60*60*3)
+ {
+ m_wndCaptureBar.m_capdlg.OnRecord();
+ }
+ }
+*/
+ }
+
+ if(m_pCAP && m_iPlaybackMode != PM_FILE)
+ {
+ g_bExternalSubtitleTime = true;
+ if (pDVDI)
+ {
+ DVD_PLAYBACK_LOCATION2 Location;
+ if (pDVDI->GetCurrentLocation(&Location) == S_OK)
+ {
+ double fps = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
+ : 25.0;
+
+ LONGLONG rtTimeCode = HMSF2RT(Location.TimeCode, fps);
+ m_pCAP->SetTime(rtTimeCode);
+ }
+ else
+ m_pCAP->SetTime(/*rtNow*/m_wndSeekBar.GetPos());
+ }
+ else
+ {
+ // Set rtNow to support DVB subtitle
+ m_pCAP->SetTime(rtNow);
+ }
+ }
+ else
+ g_bExternalSubtitleTime = false;
+ }
+ else if(nIDEvent == TIMER_STREAMPOSPOLLER2 && m_iMediaLoadState == MLS_LOADED)
+ {
+ __int64 start, stop, pos;
+ m_wndSeekBar.GetRange(start, stop);
+ pos = m_wndSeekBar.GetPosReal();
+
+ GUID tf;
+ pMS->GetTimeFormat(&tf);
+
+ if(m_iPlaybackMode == PM_CAPTURE && !m_fCapturing)
+ {
+ CString str = _T("Live");
+
+ long lChannel = 0, lVivSub = 0, lAudSub = 0;
+ if(pAMTuner
+ && m_wndCaptureBar.m_capdlg.IsTunerActive()
+ && SUCCEEDED(pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub)))
+ {
+ CString ch;
+ ch.Format(_T(" (ch%d)"), lChannel);
+ str += ch;
+ }
+
+ m_wndStatusBar.SetStatusTimer(str);
+ }
+ else
+ {
+ m_wndStatusBar.SetStatusTimer(pos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
+ if (m_bRemainingTime) m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer());
+
+ }
+
+ m_wndSubresyncBar.SetTime(pos);
+
+ if(m_pCAP && GetMediaState() == State_Paused)
+ m_pCAP->Paint(false);
+ }
+ else if(nIDEvent == TIMER_FULLSCREENCONTROLBARHIDER)
+ {
+ CPoint p;
+ GetCursorPos(&p);
+
+ CRect r;
+ GetWindowRect(r);
+ bool fCursorOutside = !r.PtInRect(p);
+
+ CWnd* pWnd = WindowFromPoint(p);
+ if(pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside))
+ {
+ if(AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut >= 0)
+ ShowControls(CS_NONE, false);
+ }
+ }
+ else if(nIDEvent == TIMER_FULLSCREENMOUSEHIDER)
+ {
+ CPoint p;
+ GetCursorPos(&p);
+
+ CRect r;
+ GetWindowRect(r);
+ bool fCursorOutside = !r.PtInRect(p);
+
+ if (m_pFullscreenWnd->IsWindow())
+ {
+ TRACE ("==> HIDE!\n");
+ if (!m_bInOptions)
+ m_pFullscreenWnd->ShowCursor(false);
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ }
+ else
+ {
+ CWnd* pWnd = WindowFromPoint(p);
+ if(pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside))
+ {
+ m_fHideCursor = true;
+ SetCursor(NULL);
+ }
+ }
+ }
+ else if(nIDEvent == TIMER_STATS)
+ {
+ if(pQP)
+ {
+ CString rate;
+ if(m_iSpeedLevel >= -11 && m_iSpeedLevel <= 3 && m_iSpeedLevel != -4)
+ {
+ CString speeds[] = {_T("1/8"),_T("1/4"),_T("1/2"),_T("1"),_T("2"),_T("4"),_T("8")};
+ rate = speeds[(m_iSpeedLevel >= -3 ? m_iSpeedLevel : (-m_iSpeedLevel - 8)) + 3];
+ if(m_iSpeedLevel < -4) rate = _T("-") + rate;
+ if(!rate.IsEmpty()) rate = _T("(") + rate + _T("X)");
+ }
+
+ CString info;
+ int val;
+
+ pQP->get_AvgFrameRate(&val);
+ info.Format(_T("%d.%02d %s"), val/100, val%100, rate);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
+
+ int avg, dev;
+ pQP->get_AvgSyncOffset(&avg);
+ pQP->get_DevSyncOffset(&dev);
+ info.Format(_T("avg: %d ms, dev: %d ms"), avg, dev);
+ m_wndStatsBar.SetLine(_T("Sync Offset"), info);
+
+ int drawn, dropped;
+ pQP->get_FramesDrawn(&drawn);
+ pQP->get_FramesDroppedInRenderer(&dropped);
+ info.Format(ResStr(IDS_MAINFRM_6), drawn, dropped);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
+
+ pQP->get_Jitter(&val);
+ info.Format(_T("%d ms"), val);
+ m_wndStatsBar.SetLine(_T("Jitter"), info);
+ }
+
+ if(pBI)
+ {
+ CAtlList<CString> sl;
+
+ for(int i = 0, j = pBI->GetCount(); i < j; i++)
+ {
+ int samples, size;
+ if(S_OK == pBI->GetStatus(i, samples, size))
+ {
+ CString str;
+ str.Format(_T("[%d]: %03d/%d KB"), i, samples, size / 1024);
+ sl.AddTail(str);
+ }
+ }
+
+ if(!sl.IsEmpty())
+ {
+ CString str;
+ str.Format(_T("%s (p%d)"), Implode(sl, ' '), pBI->GetPriority());
+
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), str);
+ }
+ }
+
+ CInterfaceList<IBitRateInfo> pBRIs;
+
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(CComQIPtr<IBitRateInfo> pBRI = pPin)
+ {
+ pBRIs.AddTail(pBRI);
+ }
+ }
+ EndEnumPins
+
+ if(!pBRIs.IsEmpty())
+ {
+ CAtlList<CString> sl;
+
+ POSITION pos = pBRIs.GetHeadPosition();
+ for(int i = 0; pos; i++)
+ {
+ IBitRateInfo* pBRI = pBRIs.GetNext(pos);
+
+ DWORD cur = pBRI->GetCurrentBitRate() / 1000;
+ DWORD avg = pBRI->GetAverageBitRate() / 1000;
+
+ if(avg == 0) continue;
+
+ CString str;
+ if(cur != avg) str.Format(_T("[%d]: %d/%d Kb/s"), i, avg, cur);
+ else str.Format(_T("[%d]: %d Kb/s"), i, avg);
+ sl.AddTail(str);
+ }
+
+ if(!sl.IsEmpty())
+ {
+ m_wndStatsBar.SetLine(_T("Bitrate"), Implode(sl, ' ') + _T(" (avg/cur)"));
+ }
+
+ break;
+ }
+ }
+ EndEnumFilters
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ SetupChapters();
+ }
+
+ if(m_iPlaybackMode == PM_DVD) // we also use this timer to update the info panel for dvd playback
+ {
+ ULONG ulAvailable, ulCurrent;
+
+ // Location
+
+ CString Location('-');
+
+ DVD_PLAYBACK_LOCATION2 loc;
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles;
+ ULONG ulNumOfChapters;
+
+ if(SUCCEEDED(pDVDI->GetCurrentLocation(&loc))
+ && SUCCEEDED(pDVDI->GetNumberOfChapters(loc.TitleNum, &ulNumOfChapters))
+ && SUCCEEDED(pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles)))
+ {
+ Location.Format(ResStr(IDS_MAINFRM_9),
+ ulVolume, ulNumOfVolumes,
+ loc.TitleNum, ulNumOfTitles,
+ loc.ChapterNum, ulNumOfChapters);
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), Location);
+
+ // Video
+
+ CString Video('-');
+
+ DVD_VideoAttributes VATR;
+
+ if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAvailable, &ulCurrent))
+ && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR)))
+ {
+ Video.Format(ResStr(IDS_MAINFRM_10),
+ ulAvailable, ulCurrent,
+ VATR.ulSourceResolutionX, VATR.ulSourceResolutionY, VATR.ulFrameRate,
+ VATR.ulAspectX, VATR.ulAspectY);
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), Video);
+
+ // Audio
+
+ CString Audio('-');
+
+ DVD_AudioAttributes AATR;
+
+ if(SUCCEEDED(pDVDI->GetCurrentAudio(&ulAvailable, &ulCurrent))
+ && SUCCEEDED(pDVDI->GetAudioAttributes(ulCurrent, &AATR)))
+ {
+ CString lang;
+ int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len-1, 0));
+
+ switch(AATR.LanguageExtension)
+ {
+ case DVD_AUD_EXT_NotSpecified:
+ default: break;
+ case DVD_AUD_EXT_Captions: lang += _T(" (Captions)"); break;
+ case DVD_AUD_EXT_VisuallyImpaired: lang += _T(" (Visually Impaired)"); break;
+ case DVD_AUD_EXT_DirectorComments1: lang += _T(" (Director Comments 1)"); break;
+ case DVD_AUD_EXT_DirectorComments2: lang += _T(" (Director Comments 2)"); break;
+ }
+
+ CString format = GetDVDAudioFormatName(AATR);
+
+ Audio.Format(ResStr(IDS_MAINFRM_11),
+ lang,
+ format,
+ AATR.dwFrequency,
+ AATR.bQuantization,
+ AATR.bNumberOfChannels,
+ (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
+
+ m_wndStatusBar.SetStatusBitmap(
+ AATR.bNumberOfChannels == 1 ? IDB_MONO
+ : AATR.bNumberOfChannels >= 2 ? IDB_STEREO
+ : IDB_NOAUDIO);
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), Audio);
+
+ // Subtitles
+
+ CString Subtitles('-');
+
+ BOOL bIsDisabled;
+ DVD_SubpictureAttributes SATR;
+
+ if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulAvailable, &ulCurrent, &bIsDisabled))
+ && SUCCEEDED(pDVDI->GetSubpictureAttributes(ulCurrent, &SATR)))
+ {
+ CString lang;
+ int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len-1, 0));
+
+ switch(SATR.LanguageExtension)
+ {
+ case DVD_SP_EXT_NotSpecified:
+ default: break;
+ case DVD_SP_EXT_Caption_Normal: lang += _T(""); break;
+ case DVD_SP_EXT_Caption_Big: lang += _T(" (Big)"); break;
+ case DVD_SP_EXT_Caption_Children: lang += _T(" (Children)"); break;
+ case DVD_SP_EXT_CC_Normal: lang += _T(" (CC)"); break;
+ case DVD_SP_EXT_CC_Big: lang += _T(" (CC Big)"); break;
+ case DVD_SP_EXT_CC_Children: lang += _T(" (CC Children)"); break;
+ case DVD_SP_EXT_Forced: lang += _T(" (Forced)"); break;
+ case DVD_SP_EXT_DirectorComments_Normal: lang += _T(" (Director Comments)"); break;
+ case DVD_SP_EXT_DirectorComments_Big: lang += _T(" (Director Comments, Big)"); break;
+ case DVD_SP_EXT_DirectorComments_Children: lang += _T(" (Director Comments, Children)"); break;
+ }
+
+ if(bIsDisabled) lang = _T("-");
+
+ Subtitles.Format(_T("%s"),
+ lang);
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), Subtitles);
+ }
+
+ if(GetMediaState() == State_Running && !m_fAudioOnly)
+ {
+ UINT fSaverActive = 0;
+ if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fSaverActive, 0))
+ {
+ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
+ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
+ }
+
+ fSaverActive = 0;
+ if(SystemParametersInfo(SPI_GETPOWEROFFACTIVE, 0, (PVOID)&fSaverActive, 0))
+ {
+ SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
+ SystemParametersInfo(SPI_SETPOWEROFFACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
+ }
+ // prevent screensaver activate, monitor sleep/turn off after playback
+ SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
+ }
+ }
+ else if(nIDEvent == TIMER_STATUSERASER)
+ {
+ KillTimer(TIMER_STATUSERASER);
+ m_playingmsg.Empty();
+ }
+
+ __super::OnTimer(nIDEvent);
}
static bool SetShutdownPrivilege()
{
- HANDLE hToken;
- TOKEN_PRIVILEGES tkp;
-
- SetThreadExecutionState(ES_CONTINUOUS);
- // Get a token for this process.
-
- if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
- return(false);
-
- // Get the LUID for the shutdown privilege.
+ HANDLE hToken;
+ TOKEN_PRIVILEGES tkp;
- LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
-
- tkp.PrivilegeCount = 1; // one privilege to set
- tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-
- // Get the shutdown privilege for this process.
-
- AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
-
- if(GetLastError() != ERROR_SUCCESS)
- return false;
+ SetThreadExecutionState (ES_CONTINUOUS);
+ // Get a token for this process.
+
+ if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+ return(false);
+
+ // Get the LUID for the shutdown privilege.
+
+ LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
+
+ tkp.PrivilegeCount = 1; // one privilege to set
+ tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+ // Get the shutdown privilege for this process.
+
+ AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
+
+ if(GetLastError() != ERROR_SUCCESS)
+ return false;
- return true;
+ return true;
}
bool CMainFrame::DoAfterPlaybackEvent()
{
- AppSettings& s = AfxGetAppSettings();
-
- bool fExit = false;
-
- if(s.nCLSwitches & CLSW_CLOSE || s.m_fExitAfterPlayback)
- {
- fExit = true;
- }
-
- if(s.nCLSwitches & CLSW_STANDBY)
- {
- SetShutdownPrivilege();
- SetSystemPowerState(TRUE, FALSE);
- fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
- }
- else if(s.nCLSwitches & CLSW_HIBERNATE)
- {
- SetShutdownPrivilege();
- SetSystemPowerState(FALSE, FALSE);
- fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
- }
- else if(s.nCLSwitches & CLSW_SHUTDOWN)
- {
- SetShutdownPrivilege();
- ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCEIFHUNG, 0);
- fExit = true;
- }
- else if(s.nCLSwitches & CLSW_LOGOFF)
- {
- SetShutdownPrivilege();
- ExitWindowsEx(EWX_LOGOFF | EWX_FORCEIFHUNG, 0);
- fExit = true;
- }
-
- if(!fExit) return false;
-
- SendMessage(WM_COMMAND, ID_FILE_EXIT);
-
- return true;
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fExit = false;
+
+ if(s.nCLSwitches&CLSW_CLOSE || s.m_fExitAfterPlayback)
+ {
+ fExit = true;
+ }
+
+ if(s.nCLSwitches&CLSW_STANDBY)
+ {
+ SetShutdownPrivilege();
+ SetSystemPowerState(TRUE, FALSE);
+ fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
+ }
+ else if(s.nCLSwitches&CLSW_HIBERNATE)
+ {
+ SetShutdownPrivilege();
+ SetSystemPowerState(FALSE, FALSE);
+ fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
+ }
+ else if(s.nCLSwitches&CLSW_SHUTDOWN)
+ {
+ SetShutdownPrivilege();
+ ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF|EWX_FORCEIFHUNG, 0);
+ fExit = true;
+ }
+ else if(s.nCLSwitches&CLSW_LOGOFF)
+ {
+ SetShutdownPrivilege();
+ ExitWindowsEx(EWX_LOGOFF|EWX_FORCEIFHUNG, 0);
+ fExit = true;
+ }
+
+ if(!fExit) return false;
+
+ SendMessage(WM_COMMAND, ID_FILE_EXIT);
+
+ return true;
}
//
@@ -2098,1606 +2058,1579 @@ bool CMainFrame::DoAfterPlaybackEvent()
#include <comdef.h>
LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
HRESULT hr = S_OK;
- LONG evCode;
- LONG_PTR evParam1, evParam2;
+ LONG evCode; LONG_PTR evParam1, evParam2;
while(pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0)))
{
- TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: %x\n", GetCurrentThreadId(), evCode);
- CString str;
+ TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: %x\n", GetCurrentThreadId(), evCode);
+ CString str;
- if(m_fCustomGraph)
- {
- if(EC_BG_ERROR == evCode)
- {
- str = CString((char*)evParam1);
- }
- }
+ if(m_fCustomGraph)
+ {
+ if(EC_BG_ERROR == evCode)
+ {
+ str = CString((char*)evParam1);
+ }
+ }
- if(!m_fFrameSteppingActive) m_nStepForwardCount = 0;
+ if (!m_fFrameSteppingActive) m_nStepForwardCount = 0;
- hr = pME->FreeEventParams(evCode, evParam1, evParam2);
+ hr = pME->FreeEventParams(evCode, evParam1, evParam2);
if(EC_COMPLETE == evCode)
{
- FILE_POSITION* FilePosition = s.CurrentFilePosition();
- if(FilePosition) FilePosition->llPosition = 0;
-
- if(m_wndPlaylistBar.GetCount() <= 1)
- {
- m_nLoops++;
-
- if(DoAfterPlaybackEvent()) return hr;
-
- if(s.fLoopForever || m_nLoops < s.nLoops)
- {
- if(GetMediaState() == State_Stopped)
- {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
- else
- {
- LONGLONG pos = 0;
- pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
-
- if(GetMediaState() == State_Paused)
- {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
- }
- }
- else
- {
- int NextMediaExist = false;
- if(s.m_fNextInDirAfterPlayback)
- {
- NextMediaExist = SearchInDir(true);
- }
- if(!s.m_fNextInDirAfterPlayback || !(NextMediaExist > 1))
- {
- if(s.fRewind) SendMessage(WM_COMMAND, ID_PLAY_STOP);
- else
- {
- m_fEndOfStream = true;
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- m_OSD.ClearMessage();
-
- if(m_fFullScreen && s.fExitFullScreenAtTheEnd)
- OnViewFullscreen();
- }
- if(s.m_fNextInDirAfterPlayback && !NextMediaExist)
- {
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_NO_MORE_MEDIA));
- // Don't move it. Else OSD message "Pause" will rewrite this message.
- }
- }
- }
- else if(m_wndPlaylistBar.GetCount() > 1)
- {
- if(m_wndPlaylistBar.IsAtEnd())
- {
- if(DoAfterPlaybackEvent()) return hr;
-
- m_nLoops++;
- }
-
- if(s.fLoopForever || m_nLoops < s.nLoops)
- {
- int nLoops = m_nLoops;
- PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- m_nLoops = nLoops;
- }
- else
- {
- if(m_fFullScreen && s.fExitFullScreenAtTheEnd)
- OnViewFullscreen();
-
- if(s.fRewind)
- {
- s.nCLSwitches |= CLSW_OPEN; // HACK
- PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- }
- else
- {
- m_fEndOfStream = true;
- PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- }
- }
- }
- else if(EC_ERRORABORT == evCode)
- {
- TRACE(_T("EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
+ FILE_POSITION* FilePosition = s.CurrentFilePosition();
+ if (FilePosition) FilePosition->llPosition = 0;
+
+ if(m_wndPlaylistBar.GetCount() <= 1)
+ {
+ m_nLoops++;
+
+ if(DoAfterPlaybackEvent()) return hr;
+
+ if(s.fLoopForever || m_nLoops < s.nLoops)
+ {
+ if(GetMediaState() == State_Stopped)
+ {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+ else
+ {
+ LONGLONG pos = 0;
+ pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+
+ if(GetMediaState() == State_Paused)
+ {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+ }
+ }
+ else
+ {
+ int NextMediaExist = false;
+ if (s.m_fNextInDirAfterPlayback)
+ {
+ NextMediaExist = SearchInDir(true);
+ }
+ if (!s.m_fNextInDirAfterPlayback || !(NextMediaExist>1))
+ {
+ if(s.fRewind) SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ else
+ {
+ m_fEndOfStream = true;
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ m_OSD.ClearMessage();
+
+ if(m_fFullScreen && s.fExitFullScreenAtTheEnd)
+ OnViewFullscreen();
+ }
+ if (s.m_fNextInDirAfterPlayback && !NextMediaExist)
+ {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_NO_MORE_MEDIA));
+ // Don't move it. Else OSD message "Pause" will rewrite this message.
+ }
+ }
+ }
+ else if(m_wndPlaylistBar.GetCount() > 1)
+ {
+ if(m_wndPlaylistBar.IsAtEnd())
+ {
+ if(DoAfterPlaybackEvent()) return hr;
+
+ m_nLoops++;
+ }
+
+ if(s.fLoopForever || m_nLoops < s.nLoops)
+ {
+ int nLoops = m_nLoops;
+ PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ m_nLoops = nLoops;
+ }
+ else
+ {
+ if(m_fFullScreen && s.fExitFullScreenAtTheEnd)
+ OnViewFullscreen();
+
+ if(s.fRewind)
+ {
+ s.nCLSwitches |= CLSW_OPEN; // HACK
+ PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ }
+ else
+ {
+ m_fEndOfStream = true;
+ PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ }
+ }
+ }
+ else if(EC_ERRORABORT == evCode)
+ {
+ TRACE(_T("EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
// SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
// m_closingmsg = _com_error((HRESULT)evParam1).ErrorMessage();
- }
- else if(EC_REPAINT == evCode)
- {
- TRACE(_T("EC_REPAINT\n"));
- }
- else if(EC_BUFFERING_DATA == evCode)
- {
- TRACE(_T("EC_BUFFERING_DATA, %d, %d\n"), (HRESULT)evParam1, evParam2);
-
- m_fBuffering = ((HRESULT)evParam1 != S_OK);
- }
- else if(EC_STEP_COMPLETE == evCode)
- {
- if(m_fFrameSteppingActive)
- {
- m_nStepForwardCount++;
- m_fFrameSteppingActive = false;
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- }
- }
- else if(EC_DEVICE_LOST == evCode)
- {
- CComQIPtr<IBaseFilter> pBF;
- if(m_iPlaybackMode == PM_CAPTURE
- && (!pVidCap && pVidCap == (pBF = (IUnknown*)evParam1)
- || !pAudCap && pAudCap == (pBF = (IUnknown*)evParam1))
- && evParam2 == 0)
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- }
- }
- else if(EC_DVD_TITLE_CHANGE == evCode)
- {
- // Casimir666 : Mémoriser le chapitre en cours
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
- if(DvdPos) DvdPos->lTitle = (DWORD)evParam1;
-
- if(m_iPlaybackMode == PM_FILE)
- {
- SetupChapters();
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- m_iDVDTitle = (DWORD)evParam1;
-
- if(m_iDVDDomain == DVD_DOMAIN_Title)
- {
- CString Domain;
- Domain.Format(ResStr(IDS_AG_TITLE), m_iDVDTitle);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
- }
- }
- }
- else if(EC_DVD_DOMAIN_CHANGE == evCode)
- {
- m_iDVDDomain = (DVD_DOMAIN)evParam1;
-
- CString Domain('-');
-
- switch(m_iDVDDomain)
- {
- case DVD_DOMAIN_FirstPlay:
- ULONGLONG llDVDGuid;
-
- if(pDVDI && SUCCEEDED(pDVDI->GetDiscID(NULL, &llDVDGuid)))
- {
- if(s.lDVDTitle != 0)
- {
- s.NewDvd(llDVDGuid);
- // Set command line position
- pDVDC->PlayTitle(s.lDVDTitle, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- if(s.lDVDChapter > 1)
- pDVDC->PlayChapterInTitle(s.lDVDTitle, s.lDVDChapter, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- else
- {
- // Trick : skip trailers with somes DVDs
- pDVDC->Resume(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- pDVDC->PlayAtTime(&s.DVDPosition, DVD_CMD_FLAG_Flush, NULL);
- }
-
- m_iDVDTitle = s.lDVDTitle;
- s.lDVDTitle = 0;
- s.lDVDChapter = 0;
- }
- else if(!s.NewDvd(llDVDGuid) && s.fRememberDVDPos)
- {
- // Set last remembered position (if founded...)
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
-
- pDVDC->PlayTitle(DvdPos->lTitle, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- pDVDC->Resume(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- if(SUCCEEDED(hr = pDVDC->PlayAtTime(&DvdPos->Timecode, DVD_CMD_FLAG_Flush, NULL)))
- {
- m_iDVDTitle = DvdPos->lTitle;
- }
- }
- }
- Domain = _T("First Play");
- break;
- case DVD_DOMAIN_VideoManagerMenu:
- Domain = _T("Video Manager Menu");
- break;
- case DVD_DOMAIN_VideoTitleSetMenu:
- Domain = _T("Video Title Set Menu");
- break;
- case DVD_DOMAIN_Title:
- Domain.Format(ResStr(IDS_AG_TITLE), m_iDVDTitle);
- DVD_POSITION* DvdPos;
- DvdPos = s.CurrentDVDPosition();
- if(DvdPos)
- DvdPos->lTitle = m_iDVDTitle;
- break;
- case DVD_DOMAIN_Stop:
- Domain = ResStr(IDS_AG_STOP);
- break;
- default:
- Domain = _T("-");
- break;
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
-
- MoveVideoWindow(); // AR might have changed
- }
- else if(EC_DVD_CURRENT_HMSF_TIME == evCode)
- {
- double fps = evParam2 == DVD_TC_FLAG_25fps ? 25.0
- : evParam2 == DVD_TC_FLAG_30fps ? 30.0
- : evParam2 == DVD_TC_FLAG_DropFrame ? 29.97
- : 25.0;
-
- REFERENCE_TIME rtDur = 0;
-
- DVD_HMSF_TIMECODE tcDur;
- ULONG ulFlags;
- if(SUCCEEDED(pDVDI->GetTotalTitleTime(&tcDur, &ulFlags)))
- rtDur = HMSF2RT(tcDur, fps);
-
- g_bNoDuration = rtDur <= 0;
- m_wndSeekBar.Enable(rtDur > 0);
- m_wndSeekBar.SetRange(0, rtDur);
- m_OSD.SetRange(0, rtDur);
- m_Lcd.SetMediaRange(0, rtDur);
-
- REFERENCE_TIME rtNow = HMSF2RT(*((DVD_HMSF_TIMECODE*)&evParam1), fps);
-
- // Casimir666 : Mémoriser le timecode courant dans le chapitre
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
- if(DvdPos)
- memcpy(&DvdPos->Timecode, (void*)&evParam1, sizeof(DVD_HMSF_TIMECODE));
-
- m_wndSeekBar.SetPos(rtNow);
- m_OSD.SetPos(rtNow);
- m_Lcd.SetMediaPos(rtNow);
-
- if(m_pSubClock) m_pSubClock->SetTime(rtNow);
- }
- else if(EC_DVD_ERROR == evCode)
- {
- TRACE(_T("EC_DVD_ERROR %d %d\n"), evParam1, evParam2);
-
- CString err;
-
- switch(evParam1)
- {
- case DVD_ERROR_Unexpected:
- default:
- err = ResStr(IDS_MAINFRM_16);
- break;
- case DVD_ERROR_CopyProtectFail:
- err = ResStr(IDS_MAINFRM_17);
- break;
- case DVD_ERROR_InvalidDVD1_0Disc:
- err = ResStr(IDS_MAINFRM_18);
- break;
- case DVD_ERROR_InvalidDiscRegion:
- err = ResStr(IDS_MAINFRM_19);
- break;
- case DVD_ERROR_LowParentalLevel:
- err = ResStr(IDS_MAINFRM_20);
- break;
- case DVD_ERROR_MacrovisionFail:
- err = ResStr(IDS_MAINFRM_21);
- break;
- case DVD_ERROR_IncompatibleSystemAndDecoderRegions:
- err = ResStr(IDS_MAINFRM_22);
- break;
- case DVD_ERROR_IncompatibleDiscAndDecoderRegions:
- err = ResStr(IDS_MAINFRM_23);
- break;
- }
-
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
-
- m_closingmsg = err;
- }
- else if(EC_DVD_WARNING == evCode)
- {
- TRACE(_T("EC_DVD_WARNING %d %d\n"), evParam1, evParam2);
- }
- else if(EC_VIDEO_SIZE_CHANGED == evCode)
- {
- TRACE(_T("EC_VIDEO_SIZE_CHANGED %dx%d\n"), CSize(evParam1));
-
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
-
- CSize size(evParam1);
- m_fAudioOnly = (size.cx <= 0 || size.cy <= 0);
-
- if(s.fRememberZoomLevel
- && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED))
- {
- ZoomVideoWindow();
- }
- else
- {
- MoveVideoWindow();
- }
- }
- else if(EC_LENGTH_CHANGED == evCode)
- {
- __int64 rtDur = 0;
- pMS->GetDuration(&rtDur);
- m_wndPlaylistBar.SetCurTime(rtDur);
- }
- else if(!m_fCustomGraph)
- {
- //TRACE(_T("evCode: %d\n"), evCode);
- }
- else if(EC_BG_AUDIO_CHANGED == evCode)
- {
- int nAudioChannels = evParam1;
-
- m_wndStatusBar.SetStatusBitmap(nAudioChannels == 1 ? IDB_MONO
- : nAudioChannels >= 2 ? IDB_STEREO
- : IDB_NOAUDIO);
- }
- else if(EC_BG_ERROR == evCode)
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- m_closingmsg = !str.IsEmpty() ? str : _T("Unspecified graph error");
- m_wndPlaylistBar.SetCurValid(false);
- break;
- }
- else if(EC_DVD_PLAYBACK_RATE_CHANGE == evCode)
- {
- if(AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && m_fFullScreen
- && m_iDVDDomain == DVD_DOMAIN_Title) AutoChangeMonitorMode();
- }
- }
+ }
+ else if(EC_REPAINT == evCode)
+ {
+ TRACE(_T("EC_REPAINT\n"));
+ }
+ else if(EC_BUFFERING_DATA == evCode)
+ {
+ TRACE(_T("EC_BUFFERING_DATA, %d, %d\n"), (HRESULT)evParam1, evParam2);
+
+ m_fBuffering = ((HRESULT)evParam1 != S_OK);
+ }
+ else if(EC_STEP_COMPLETE == evCode)
+ {
+ if(m_fFrameSteppingActive)
+ {
+ m_nStepForwardCount++;
+ m_fFrameSteppingActive = false;
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ }
+ }
+ else if(EC_DEVICE_LOST == evCode)
+ {
+ CComQIPtr<IBaseFilter> pBF;
+ if(m_iPlaybackMode == PM_CAPTURE
+ && (!pVidCap && pVidCap == (pBF = (IUnknown*)evParam1)
+ || !pAudCap && pAudCap == (pBF = (IUnknown*)evParam1))
+ && evParam2 == 0)
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ }
+ }
+ else if(EC_DVD_TITLE_CHANGE == evCode)
+ {
+ // Casimir666 : Mémoriser le chapitre en cours
+ DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+ if (DvdPos) DvdPos->lTitle = (DWORD)evParam1;
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ SetupChapters();
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ m_iDVDTitle = (DWORD)evParam1;
+
+ if(m_iDVDDomain == DVD_DOMAIN_Title)
+ {
+ CString Domain;
+ Domain.Format(ResStr(IDS_AG_TITLE), m_iDVDTitle);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
+ }
+ }
+ }
+ else if(EC_DVD_DOMAIN_CHANGE == evCode)
+ {
+ m_iDVDDomain = (DVD_DOMAIN)evParam1;
+
+ CString Domain('-');
+
+ switch(m_iDVDDomain)
+ {
+ case DVD_DOMAIN_FirstPlay:
+ ULONGLONG llDVDGuid;
+
+ if (pDVDI && SUCCEEDED (pDVDI->GetDiscID (NULL, &llDVDGuid)))
+ {
+ if (s.lDVDTitle != 0)
+ {
+ s.NewDvd (llDVDGuid);
+ // Set command line position
+ pDVDC->PlayTitle(s.lDVDTitle, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ if (s.lDVDChapter > 1)
+ pDVDC->PlayChapterInTitle(s.lDVDTitle, s.lDVDChapter, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ else
+ {
+ // Trick : skip trailers with somes DVDs
+ pDVDC->Resume(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ pDVDC->PlayAtTime(&s.DVDPosition, DVD_CMD_FLAG_Flush, NULL);
+ }
+
+ m_iDVDTitle = s.lDVDTitle;
+ s.lDVDTitle = 0;
+ s.lDVDChapter = 0;
+ }
+ else if (!s.NewDvd (llDVDGuid) && s.fRememberDVDPos)
+ {
+ // Set last remembered position (if founded...)
+ DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+
+ pDVDC->PlayTitle(DvdPos->lTitle, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ pDVDC->Resume(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ if (SUCCEEDED (hr = pDVDC->PlayAtTime (&DvdPos->Timecode, DVD_CMD_FLAG_Flush, NULL)))
+ {
+ m_iDVDTitle = DvdPos->lTitle;
+ }
+ }
+ }
+ Domain = _T("First Play"); break;
+ case DVD_DOMAIN_VideoManagerMenu: Domain = _T("Video Manager Menu"); break;
+ case DVD_DOMAIN_VideoTitleSetMenu: Domain = _T("Video Title Set Menu"); break;
+ case DVD_DOMAIN_Title:
+ Domain.Format(ResStr(IDS_AG_TITLE), m_iDVDTitle);
+ DVD_POSITION* DvdPos;
+ DvdPos = s.CurrentDVDPosition();
+ if (DvdPos)
+ DvdPos->lTitle = m_iDVDTitle;
+ break;
+ case DVD_DOMAIN_Stop: Domain = ResStr(IDS_AG_STOP); break;
+ default: Domain = _T("-"); break;
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
+
+ MoveVideoWindow(); // AR might have changed
+ }
+ else if(EC_DVD_CURRENT_HMSF_TIME == evCode)
+ {
+ double fps = evParam2 == DVD_TC_FLAG_25fps ? 25.0
+ : evParam2 == DVD_TC_FLAG_30fps ? 30.0
+ : evParam2 == DVD_TC_FLAG_DropFrame ? 29.97
+ : 25.0;
+
+ REFERENCE_TIME rtDur = 0;
+
+ DVD_HMSF_TIMECODE tcDur;
+ ULONG ulFlags;
+ if(SUCCEEDED(pDVDI->GetTotalTitleTime(&tcDur, &ulFlags)))
+ rtDur = HMSF2RT(tcDur, fps);
+
+ g_bNoDuration = rtDur <= 0;
+ m_wndSeekBar.Enable(rtDur > 0);
+ m_wndSeekBar.SetRange(0, rtDur);
+ m_OSD.SetRange (0, rtDur);
+ m_Lcd.SetMediaRange(0, rtDur);
+
+ REFERENCE_TIME rtNow = HMSF2RT(*((DVD_HMSF_TIMECODE*)&evParam1), fps);
+
+ // Casimir666 : Mémoriser le timecode courant dans le chapitre
+ DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+ if (DvdPos)
+ memcpy (&DvdPos->Timecode, (void*)&evParam1, sizeof(DVD_HMSF_TIMECODE));
+
+ m_wndSeekBar.SetPos(rtNow);
+ m_OSD.SetPos(rtNow);
+ m_Lcd.SetMediaPos(rtNow);
+
+ if(m_pSubClock) m_pSubClock->SetTime(rtNow);
+ }
+ else if(EC_DVD_ERROR == evCode)
+ {
+ TRACE(_T("EC_DVD_ERROR %d %d\n"), evParam1, evParam2);
+
+ CString err;
+
+ switch(evParam1)
+ {
+ case DVD_ERROR_Unexpected: default: err = ResStr(IDS_MAINFRM_16); break;
+ case DVD_ERROR_CopyProtectFail: err = ResStr(IDS_MAINFRM_17); break;
+ case DVD_ERROR_InvalidDVD1_0Disc: err = ResStr(IDS_MAINFRM_18); break;
+ case DVD_ERROR_InvalidDiscRegion: err = ResStr(IDS_MAINFRM_19); break;
+ case DVD_ERROR_LowParentalLevel: err = ResStr(IDS_MAINFRM_20); break;
+ case DVD_ERROR_MacrovisionFail: err = ResStr(IDS_MAINFRM_21); break;
+ case DVD_ERROR_IncompatibleSystemAndDecoderRegions: err = ResStr(IDS_MAINFRM_22); break;
+ case DVD_ERROR_IncompatibleDiscAndDecoderRegions: err = ResStr(IDS_MAINFRM_23); break;
+ }
+
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+
+ m_closingmsg = err;
+ }
+ else if(EC_DVD_WARNING == evCode)
+ {
+ TRACE(_T("EC_DVD_WARNING %d %d\n"), evParam1, evParam2);
+ }
+ else if(EC_VIDEO_SIZE_CHANGED == evCode)
+ {
+ TRACE(_T("EC_VIDEO_SIZE_CHANGED %dx%d\n"), CSize(evParam1));
+
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
+
+ CSize size(evParam1);
+ m_fAudioOnly = (size.cx <= 0 || size.cy <= 0);
+
+ if(s.fRememberZoomLevel
+ && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED))
+ {
+ ZoomVideoWindow();
+ }
+ else
+ {
+ MoveVideoWindow();
+ }
+ }
+ else if(EC_LENGTH_CHANGED == evCode)
+ {
+ __int64 rtDur = 0;
+ pMS->GetDuration(&rtDur);
+ m_wndPlaylistBar.SetCurTime(rtDur);
+ }
+ else if(!m_fCustomGraph)
+ {
+ //TRACE(_T("evCode: %d\n"), evCode);
+ }
+ else if(EC_BG_AUDIO_CHANGED == evCode)
+ {
+ int nAudioChannels = evParam1;
+
+ m_wndStatusBar.SetStatusBitmap(nAudioChannels == 1 ? IDB_MONO
+ : nAudioChannels >= 2 ? IDB_STEREO
+ : IDB_NOAUDIO);
+ }
+ else if(EC_BG_ERROR == evCode)
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ m_closingmsg = !str.IsEmpty() ? str : _T("Unspecified graph error");
+ m_wndPlaylistBar.SetCurValid(false);
+ break;
+ }
+ else if(EC_DVD_PLAYBACK_RATE_CHANGE == evCode)
+ {
+ if(AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && m_fFullScreen
+ && m_iDVDDomain == DVD_DOMAIN_Title) AutoChangeMonitorMode();
+ }
+ }
return hr;
}
LRESULT CMainFrame::OnRepaintRenderLess(WPARAM wParam, LPARAM lParam)
{
- MoveVideoWindow();
- return TRUE;
+ MoveVideoWindow();
+ return TRUE;
}
LRESULT CMainFrame::OnResumeFromState(WPARAM wParam, LPARAM lParam)
{
- int iPlaybackMode = (int)wParam;
-
- if(iPlaybackMode == PM_FILE)
- {
- SeekTo(10000i64 * int(lParam));
- }
- else if(iPlaybackMode == PM_DVD)
- {
- CComPtr<IDvdState> pDvdState;
- pDvdState.Attach((IDvdState*)lParam);
- if(pDVDC) pDVDC->SetState(pDvdState, DVD_CMD_FLAG_Block, NULL);
- }
- else if(iPlaybackMode == PM_CAPTURE)
- {
- // not implemented
- }
- else
- {
- ASSERT(0);
- return FALSE;
- }
-
- return TRUE;
+ int iPlaybackMode = (int)wParam;
+
+ if(iPlaybackMode == PM_FILE)
+ {
+ SeekTo(10000i64*int(lParam));
+ }
+ else if(iPlaybackMode == PM_DVD)
+ {
+ CComPtr<IDvdState> pDvdState;
+ pDvdState.Attach((IDvdState*)lParam);
+ if(pDVDC) pDVDC->SetState(pDvdState, DVD_CMD_FLAG_Block, NULL);
+ }
+ else if(iPlaybackMode == PM_CAPTURE)
+ {
+ // not implemented
+ }
+ else
+ {
+ ASSERT(0);
+ return FALSE;
+ }
+
+ return TRUE;
}
BOOL CMainFrame::OnButton(UINT id, UINT nFlags, CPoint point)
{
- SetFocus();
+ SetFocus();
- CRect r;
- if(m_pFullscreenWnd->IsWindow())
- {
- m_pFullscreenWnd->GetClientRect(r);
- }
- else
- {
- m_wndView.GetClientRect(r);
- m_wndView.MapWindowPoints(this, &r);
- }
+ CRect r;
+ if (m_pFullscreenWnd->IsWindow())
+ {
+ m_pFullscreenWnd->GetClientRect(r);
+ }
+ else
+ {
+ m_wndView.GetClientRect(r);
+ m_wndView.MapWindowPoints(this, &r);
+ }
- if(id != wmcmd::WDOWN && id != wmcmd::WUP && !r.PtInRect(point)) return FALSE;
+ if(id != wmcmd::WDOWN && id != wmcmd::WUP && !r.PtInRect(point)) return FALSE;
- BOOL ret = FALSE;
+ BOOL ret = FALSE;
- AppSettings& s = AfxGetAppSettings();
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- if(wc.mouse == id)
- {
- SendMessage(WM_COMMAND, wc.cmd);
- ret = true;
- }
- }
+ AppSettings& s = AfxGetAppSettings();
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos)
+ {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ if(wc.mouse == id)
+ {
+ SendMessage(WM_COMMAND, wc.cmd);
+ ret = true;
+ }
+ }
- return ret;
+ return ret;
}
static bool s_fLDown = false;
void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
{
- if(!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonDown(nFlags, point))
- {
- SetFocus();
-
- bool fClicked = false;
-
- if(m_iPlaybackMode == PM_DVD)
- {
- CPoint p = point - m_wndView.GetVideoRect().TopLeft();
-
- if(SUCCEEDED(pDVDC->ActivateAtPosition(p))
- || m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
- || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu)
- fClicked = true;
- }
-
- if(!fClicked)
- {
- bool fLeftMouseBtnUnassigned = true;
- AppSettings& s = AfxGetAppSettings();
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos && fLeftMouseBtnUnassigned)
- if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
- fLeftMouseBtnUnassigned = false;
-
- if(!m_fFullScreen && (IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
- {
- PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- }
- else
- {
- s_fLDown = true;
- if(OnButton(wmcmd::LDOWN, nFlags, point))
- return;
- }
- }
-
- __super::OnLButtonDown(nFlags, point);
- }
+ if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonDown (nFlags, point))
+ {
+ SetFocus();
+
+ bool fClicked = false;
+
+ if(m_iPlaybackMode == PM_DVD)
+ {
+ CPoint p = point - m_wndView.GetVideoRect().TopLeft();
+
+ if(SUCCEEDED(pDVDC->ActivateAtPosition(p))
+ || m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
+ || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu)
+ fClicked = true;
+ }
+
+ if(!fClicked)
+ {
+ bool fLeftMouseBtnUnassigned = true;
+ AppSettings& s = AfxGetAppSettings();
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos && fLeftMouseBtnUnassigned)
+ if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
+ fLeftMouseBtnUnassigned = false;
+
+ if(!m_fFullScreen && (IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
+ {
+ PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
+ }
+ else
+ {
+ s_fLDown = true;
+ if(OnButton(wmcmd::LDOWN, nFlags, point))
+ return;
+ }
+ }
+
+ __super::OnLButtonDown(nFlags, point);
+ }
}
void CMainFrame::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonUp(nFlags, point))
- {
- if(!OnButton(wmcmd::LUP, nFlags, point))
- __super::OnLButtonUp(nFlags, point);
- }
+ if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonUp (nFlags, point))
+ {
+ if(!OnButton(wmcmd::LUP, nFlags, point))
+ __super::OnLButtonUp(nFlags, point);
+ }
}
void CMainFrame::OnLButtonDblClk(UINT nFlags, CPoint point)
{
- if(s_fLDown)
- {
- SendMessage(WM_LBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
- s_fLDown = false;
- }
- if(!OnButton(wmcmd::LDBLCLK, nFlags, point))
- __super::OnLButtonDblClk(nFlags, point);
+if(s_fLDown)
+{
+ SendMessage(WM_LBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
+s_fLDown = false;
+}
+ if(!OnButton(wmcmd::LDBLCLK, nFlags, point))
+ __super::OnLButtonDblClk(nFlags, point);
}
void CMainFrame::OnMButtonDown(UINT nFlags, CPoint point)
{
- SendMessage(WM_CANCELMODE);
- if(!OnButton(wmcmd::MDOWN, nFlags, point))
- __super::OnMButtonDown(nFlags, point);
+ SendMessage(WM_CANCELMODE);
+ if(!OnButton(wmcmd::MDOWN, nFlags, point))
+ __super::OnMButtonDown(nFlags, point);
}
void CMainFrame::OnMButtonUp(UINT nFlags, CPoint point)
{
- if(!OnButton(wmcmd::MUP, nFlags, point))
- __super::OnMButtonUp(nFlags, point);
+ if(!OnButton(wmcmd::MUP, nFlags, point))
+ __super::OnMButtonUp(nFlags, point);
}
void CMainFrame::OnMButtonDblClk(UINT nFlags, CPoint point)
{
- SendMessage(WM_MBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
- if(!OnButton(wmcmd::MDBLCLK, nFlags, point))
- __super::OnMButtonDblClk(nFlags, point);
+ SendMessage(WM_MBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
+ if(!OnButton(wmcmd::MDBLCLK, nFlags, point))
+ __super::OnMButtonDblClk(nFlags, point);
}
void CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
- if(!OnButton(wmcmd::RDOWN, nFlags, point))
- __super::OnRButtonDown(nFlags, point);
+ if(!OnButton(wmcmd::RDOWN, nFlags, point))
+ __super::OnRButtonDown(nFlags, point);
}
void CMainFrame::OnRButtonUp(UINT nFlags, CPoint point)
{
- if(!OnButton(wmcmd::RUP, nFlags, point))
- __super::OnRButtonUp(nFlags, point);
+ if(!OnButton(wmcmd::RUP, nFlags, point))
+ __super::OnRButtonUp(nFlags, point);
}
void CMainFrame::OnRButtonDblClk(UINT nFlags, CPoint point)
{
- SendMessage(WM_RBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
- if(!OnButton(wmcmd::RDBLCLK, nFlags, point))
- __super::OnRButtonDblClk(nFlags, point);
+ SendMessage(WM_RBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
+ if(!OnButton(wmcmd::RDBLCLK, nFlags, point))
+ __super::OnRButtonDblClk(nFlags, point);
}
LRESULT CMainFrame::OnXButtonDown(WPARAM wParam, LPARAM lParam)
{
- SendMessage(WM_CANCELMODE);
- UINT fwButton = GET_XBUTTON_WPARAM(wParam);
- return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DOWN : fwButton == XBUTTON2 ? wmcmd::X2DOWN : wmcmd::NONE,
- GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
+ SendMessage(WM_CANCELMODE);
+ UINT fwButton = GET_XBUTTON_WPARAM(wParam);
+ return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DOWN : fwButton == XBUTTON2 ? wmcmd::X2DOWN : wmcmd::NONE,
+ GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
}
LRESULT CMainFrame::OnXButtonUp(WPARAM wParam, LPARAM lParam)
{
- UINT fwButton = GET_XBUTTON_WPARAM(wParam);
- return OnButton(fwButton == XBUTTON1 ? wmcmd::X1UP : fwButton == XBUTTON2 ? wmcmd::X2UP : wmcmd::NONE,
- GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
+ UINT fwButton = GET_XBUTTON_WPARAM(wParam);
+ return OnButton(fwButton == XBUTTON1 ? wmcmd::X1UP : fwButton == XBUTTON2 ? wmcmd::X2UP : wmcmd::NONE,
+ GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
}
LRESULT CMainFrame::OnXButtonDblClk(WPARAM wParam, LPARAM lParam)
{
- SendMessage(WM_XBUTTONDOWN, wParam, lParam);
- UINT fwButton = GET_XBUTTON_WPARAM(wParam);
- return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DBLCLK : fwButton == XBUTTON2 ? wmcmd::X2DBLCLK : wmcmd::NONE,
- GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
+ SendMessage(WM_XBUTTONDOWN, wParam, lParam);
+ UINT fwButton = GET_XBUTTON_WPARAM(wParam);
+ return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DBLCLK : fwButton == XBUTTON2 ? wmcmd::X2DBLCLK : wmcmd::NONE,
+ GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
}
BOOL CMainFrame::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
{
- ScreenToClient(&point);
+ ScreenToClient(&point);
- BOOL fRet =
- zDelta > 0 ? OnButton(wmcmd::WUP, nFlags, point) :
- zDelta < 0 ? OnButton(wmcmd::WDOWN, nFlags, point) :
- FALSE;
+ BOOL fRet =
+ zDelta > 0 ? OnButton(wmcmd::WUP, nFlags, point) :
+ zDelta < 0 ? OnButton(wmcmd::WDOWN, nFlags, point) :
+ FALSE;
- return fRet;
+ return fRet;
}
void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
{
- // Waffs : ignore mousemoves when entering fullscreen
- if(m_lastMouseMove.x == -1 && m_lastMouseMove.y == -1)
- {
- m_lastMouseMove.x = point.x;
- m_lastMouseMove.y = point.y;
- }
-
- if(!m_OSD.OnMouseMove(nFlags, point))
- {
- if(m_iPlaybackMode == PM_DVD)
- {
- CPoint vp = point - m_wndView.GetVideoRect().TopLeft();
- pDVDC->SelectAtPosition(vp);
- }
-
- CSize diff = m_lastMouseMove - point;
-
- if(m_pFullscreenWnd->IsWindow() && (abs(diff.cx) + abs(diff.cy)) >= 1)
- {
- // TRACE ("==> SHOW!\n");
- m_pFullscreenWnd->ShowCursor(true);
-
- // Casimir666 : en dehors du menu DVD, cacher le curseur
- if((m_iPlaybackMode == PM_FILE) || (m_iPlaybackMode == PM_DVD))
- {
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- }
- }
- else if(m_fFullScreen && (abs(diff.cx) + abs(diff.cy)) >= 1)
- {
- int nTimeOut = AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut;
-
- if(nTimeOut < 0)
- {
- m_fHideCursor = false;
- if(AfxGetAppSettings().fShowBarsWhenFullScreen)
- ShowControls(AfxGetAppSettings().nCS);
-
- KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- }
- else if(nTimeOut == 0)
- {
- CRect r;
- GetClientRect(r);
- r.top = r.bottom;
-
- POSITION pos = m_bars.GetHeadPosition();
- for(int i = 1; pos; i <<= 1)
- {
- CControlBar* pNext = m_bars.GetNext(pos);
- CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
- if(AfxGetAppSettings().nCS & i) r.top -= s.cy;
- }
-
-
- // HACK: the controls would cover the menu too early hiding some buttons
- if(m_iPlaybackMode == PM_DVD
- && (m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
- || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu))
- r.top = r.bottom - 10;
-
- m_fHideCursor = false;
-
- if(r.PtInRect(point))
- {
- if(AfxGetAppSettings().fShowBarsWhenFullScreen)
- ShowControls(AfxGetAppSettings().nCS);
- }
- else
- {
- if(AfxGetAppSettings().fShowBarsWhenFullScreen)
- ShowControls(CS_NONE, false);
- }
-
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- }
- else
- {
- m_fHideCursor = false;
- if(AfxGetAppSettings().fShowBarsWhenFullScreen)
- ShowControls(AfxGetAppSettings().nCS);
-
- SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut * 1000, NULL);
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut * 1000, 2000), NULL);
- }
- }
-
- m_lastMouseMove = point;
-
- __super::OnMouseMove(nFlags, point);
- }
+ // Waffs : ignore mousemoves when entering fullscreen
+ if (m_lastMouseMove.x == -1 && m_lastMouseMove.y == -1)
+ {
+ m_lastMouseMove.x = point.x;
+ m_lastMouseMove.y = point.y;
+ }
+
+ if (!m_OSD.OnMouseMove (nFlags, point))
+ {
+ if(m_iPlaybackMode == PM_DVD)
+ {
+ CPoint vp = point - m_wndView.GetVideoRect().TopLeft();
+ pDVDC->SelectAtPosition(vp);
+ }
+
+ CSize diff = m_lastMouseMove - point;
+
+ if (m_pFullscreenWnd->IsWindow() && (abs(diff.cx)+abs(diff.cy)) >= 1)
+ {
+ // TRACE ("==> SHOW!\n");
+ m_pFullscreenWnd->ShowCursor(true);
+
+ // Casimir666 : en dehors du menu DVD, cacher le curseur
+ if ((m_iPlaybackMode == PM_FILE) || (m_iPlaybackMode == PM_DVD))
+ {
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
+ }
+ }
+ else if(m_fFullScreen && (abs(diff.cx)+abs(diff.cy)) >= 1)
+ {
+ int nTimeOut = AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut;
+
+ if(nTimeOut < 0)
+ {
+ m_fHideCursor = false;
+ if(AfxGetAppSettings().fShowBarsWhenFullScreen)
+ ShowControls(AfxGetAppSettings().nCS);
+
+ KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
+ }
+ else if(nTimeOut == 0)
+ {
+ CRect r;
+ GetClientRect(r);
+ r.top = r.bottom;
+
+ POSITION pos = m_bars.GetHeadPosition();
+ for(int i = 1; pos; i <<= 1)
+ {
+ CControlBar* pNext = m_bars.GetNext(pos);
+ CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
+ if(AfxGetAppSettings().nCS&i) r.top -= s.cy;
+ }
+
+
+ // HACK: the controls would cover the menu too early hiding some buttons
+ if(m_iPlaybackMode == PM_DVD
+ && (m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
+ || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu))
+ r.top = r.bottom - 10;
+
+ m_fHideCursor = false;
+
+ if(r.PtInRect(point))
+ {
+ if(AfxGetAppSettings().fShowBarsWhenFullScreen)
+ ShowControls(AfxGetAppSettings().nCS);
+ }
+ else
+ {
+ if(AfxGetAppSettings().fShowBarsWhenFullScreen)
+ ShowControls(CS_NONE, false);
+ }
+
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
+ }
+ else
+ {
+ m_fHideCursor = false;
+ if(AfxGetAppSettings().fShowBarsWhenFullScreen)
+ ShowControls(AfxGetAppSettings().nCS);
+
+ SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut*1000, NULL);
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut*1000, 2000), NULL);
+ }
+ }
+
+ m_lastMouseMove = point;
+
+ __super::OnMouseMove(nFlags, point);
+ }
}
LRESULT CMainFrame::OnNcHitTest(CPoint point)
{
- LRESULT nHitTest = __super::OnNcHitTest(point);
- return ((IsCaptionMenuHidden()) && nHitTest == HTCLIENT) ? HTCAPTION : nHitTest;
+ LRESULT nHitTest = __super::OnNcHitTest(point);
+ return ((IsCaptionMenuHidden()) && nHitTest == HTCLIENT) ? HTCAPTION : nHitTest;
}
void CMainFrame::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(pScrollBar->IsKindOf(RUNTIME_CLASS(CVolumeCtrl)))
- {
- OnPlayVolume(0);
- }
- else if(pScrollBar->IsKindOf(RUNTIME_CLASS(CPlayerSeekBar)) && m_iMediaLoadState == MLS_LOADED)
- {
- SeekTo(m_wndSeekBar.GetPos(), !!(::GetKeyState(VK_SHIFT) & 0x8000));
- }
- else if(m_pVideoWnd == m_pVideoWnd)
- {
- SeekTo(m_OSD.GetPos(), !!(::GetKeyState(VK_SHIFT) & 0x8000));
- }
+ if(pScrollBar->IsKindOf(RUNTIME_CLASS(CVolumeCtrl)))
+ {
+ OnPlayVolume(0);
+ }
+ else if(pScrollBar->IsKindOf(RUNTIME_CLASS(CPlayerSeekBar)) && m_iMediaLoadState == MLS_LOADED)
+ {
+ SeekTo(m_wndSeekBar.GetPos(), !!(::GetKeyState(VK_SHIFT)&0x8000));
+ }
+ else if (m_pVideoWnd == m_pVideoWnd)
+ {
+ SeekTo(m_OSD.GetPos(), !!(::GetKeyState(VK_SHIFT)&0x8000));
+ }
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CMainFrame::OnInitMenu(CMenu* pMenu)
{
- __super::OnInitMenu(pMenu);
+ __super::OnInitMenu(pMenu);
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
- for(UINT i = 0, j = pMenu->GetMenuItemCount(); i < j; i++)
- {
- CString str;
- pMenu->GetMenuString(i, str, MF_BYPOSITION);
+ for(UINT i = 0, j = pMenu->GetMenuItemCount(); i < j; i++)
+ {
+ CString str;
+ pMenu->GetMenuString(i, str, MF_BYPOSITION);
- CMenu* pSubMenu = NULL;
+ CMenu* pSubMenu = NULL;
- if(str == ResStr(IDS_FAVORITES_POPUP))
- {
- SetupFavoritesSubMenu();
- pSubMenu = &m_favorites;
- }
- if(str == ResStr(IDS_RECENT_FILES_POPUP))
- {
- SetupRecentFilesSubMenu();
- pSubMenu = &m_recentfiles;
- }
+ if(str == ResStr(IDS_FAVORITES_POPUP))
+ {
+ SetupFavoritesSubMenu();
+ pSubMenu = &m_favorites;
+ }
+ if(str == ResStr(IDS_RECENT_FILES_POPUP))
+ {
+ SetupRecentFilesSubMenu();
+ pSubMenu = &m_recentfiles;
+ }
- if(pSubMenu)
- {
- mii.fMask = MIIM_STATE | MIIM_SUBMENU;
- mii.fType = MF_POPUP;
- mii.hSubMenu = pSubMenu->m_hMenu;
- mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED | MF_GRAYED));
- pMenu->SetMenuItemInfo(i, &mii, TRUE);
- }
- }
+ if(pSubMenu)
+ {
+ mii.fMask = MIIM_STATE|MIIM_SUBMENU;
+ mii.fType = MF_POPUP;
+ mii.hSubMenu = pSubMenu->m_hMenu;
+ mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED|MF_GRAYED));
+ pMenu->SetMenuItemInfo(i, &mii, TRUE);
+ }
+ }
}
void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
- __super::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
-
- static CAtlStringMap<UINT> transl;
-
- //if(transl.IsEmpty())
- {
- transl[ResStr(IDS_AG_NAVIGATE)] = IDS_NAVIGATE_POPUP;
- transl[ResStr(IDS_AG_OPEN_DISC)] = IDS_OPENCDROM_POPUP;
- transl[ResStr(IDS_AG_FILTERS)] = IDS_FILTERS_POPUP;
- transl[_T("Audio")] = IDS_AUDIO_POPUP;
- transl[ResStr(IDS_AG_SUBTITLES)] = IDS_SUBTITLES_POPUP;
- transl[ResStr(IDS_MAINFRM_28)] = IDS_AUDIOLANGUAGE_POPUP;
- transl[ResStr(IDS_MAINFRM_29)] = IDS_SUBTITLELANGUAGE_POPUP;
- transl[ResStr(IDS_AG_VIDEO_ANGLE)] = IDS_VIDEOANGLE_POPUP;
- transl[ResStr(IDS_AG_JUMP_TO)] = IDS_JUMPTO_POPUP;
- transl[ResStr(IDS_AG_FAVORITES)] = IDS_FAVORITES_POPUP;
- transl[ResStr(IDS_AG_SHADERS)] = IDS_SHADER_POPUP;
- transl[ResStr(IDS_AG_VIDEO_FRAME)] = IDS_VIDEOFRAME_POPUP;
- transl[ResStr(IDS_AG_PANSCAN)] = IDS_PANSCAN_POPUP;
- transl[ResStr(IDS_AG_ASPECT_RATIO)] = IDS_ASPECTRATIO_POPUP;
- transl[_T("Zoom")] = IDS_ZOOM_POPUP;
- //transl[ResStr(IDS_RECENT_FILES_POPUP)] = IDS_RECENT_FILES_POPUP;
- }
-
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
-
- for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
- {
- CString str;
- pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
-
- CString lookupstr = str;
- lookupstr.Remove('&');
-
- CMenu* pSubMenu = NULL;
-
- UINT id;
- if(transl.Lookup(lookupstr, id))
- {
- str = ResStr(id);
- // pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, 0, str);
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STRING;
- mii.dwTypeData = (LPTSTR)(LPCTSTR)str;
- pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
- }
-
- if(str == ResStr(IDS_NAVIGATE_POPUP))
- {
- UINT fState = (m_iMediaLoadState == MLS_LOADED
- && (1/*m_iPlaybackMode == PM_DVD *//*|| (m_iPlaybackMode == PM_FILE && m_PlayList.GetCount() > 0)*/))
- ? MF_ENABLED
- : (MF_DISABLED | MF_GRAYED);
-
- pPopupMenu->EnableMenuItem(i, MF_BYPOSITION | fState);
- }
- else if(str == ResStr(IDS_VIDEOFRAME_POPUP)
- || str == ResStr(IDS_PANSCAN_POPUP)
- || str == ResStr(IDS_ASPECTRATIO_POPUP)
- || str == ResStr(IDS_ZOOM_POPUP))
- {
- UINT fState = (m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly)
- ? MF_ENABLED
- : (MF_DISABLED | MF_GRAYED);
-
- pPopupMenu->EnableMenuItem(i, MF_BYPOSITION | fState);
- }
- else if(str == ResStr(IDS_OPENCDROM_POPUP))
- {
- SetupOpenCDSubMenu();
- pSubMenu = &m_opencds;
- }
- else if(str == ResStr(IDS_FILTERS_POPUP))
- {
- SetupFiltersSubMenu();
- pSubMenu = &m_filters;
- }
- else if(str == ResStr(IDS_AUDIO_POPUP))
- {
- SetupAudioSwitcherSubMenu();
- pSubMenu = &m_audios;
- }
- else if(str == ResStr(IDS_SUBTITLES_POPUP))
- {
- SetupSubtitlesSubMenu();
- pSubMenu = &m_subtitles;
- }
- else if(str == ResStr(IDS_AUDIOLANGUAGE_POPUP))
- {
- SetupNavAudioSubMenu();
- pSubMenu = &m_navaudio;
- }
- else if(str == ResStr(IDS_SUBTITLELANGUAGE_POPUP))
- {
- SetupNavSubtitleSubMenu();
- pSubMenu = &m_navsubtitle;
- }
- else if(str == ResStr(IDS_VIDEOANGLE_POPUP))
- {
- SetupNavAngleSubMenu();
- pSubMenu = &m_navangle;
- }
- else if(str == ResStr(IDS_JUMPTO_POPUP))
- {
- SetupNavChaptersSubMenu();
- pSubMenu = &m_navchapters;
- }
- else if(str == ResStr(IDS_FAVORITES_POPUP))
- {
- SetupFavoritesSubMenu();
- pSubMenu = &m_favorites;
- }
- else if(str == ResStr(IDS_RECENT_FILES_POPUP))
- {
- SetupRecentFilesSubMenu();
- pSubMenu = &m_recentfiles;
- }
- else if(str == ResStr(IDS_SHADER_POPUP))
- {
- SetupShadersSubMenu();
- pSubMenu = &m_shaders;
- }
-
- if(pSubMenu)
- {
- mii.fMask = MIIM_STATE | MIIM_SUBMENU;
- mii.fType = MF_POPUP;
- mii.hSubMenu = pSubMenu->m_hMenu;
- mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED | MF_GRAYED));
- pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
- }
- }
-
- //
-
- for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
- {
- UINT nID = pPopupMenu->GetMenuItemID(i);
- if(nID == ID_SEPARATOR || nID == -1
- || nID >= ID_FAVORITES_FILE_START && nID <= ID_FAVORITES_FILE_END
- || nID >= ID_RECENT_FILE_START && nID <= ID_RECENT_FILE_END
- || nID >= ID_NAVIGATE_CHAP_SUBITEM_START && nID <= ID_NAVIGATE_CHAP_SUBITEM_END)
- continue;
-
- CString str;
- pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
- int k = str.Find('\t');
- if(k > 0) str = str.Left(k);
-
- CString key = CPPageAccelTbl::MakeAccelShortcutLabel(nID);
- if(!key.IsEmpty()) str += _T("\t") + key;
-
- if(key.IsEmpty() && i < 0) continue;
-
- // BUG(?): this disables menu item update ui calls for some reason...
+ __super::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
+
+ static CAtlStringMap<UINT> transl;
+
+ //if(transl.IsEmpty())
+ {
+ transl[ResStr(IDS_AG_NAVIGATE)] = IDS_NAVIGATE_POPUP;
+ transl[ResStr(IDS_AG_OPEN_DISC)] = IDS_OPENCDROM_POPUP;
+ transl[ResStr(IDS_AG_FILTERS)] = IDS_FILTERS_POPUP;
+ transl[_T("Audio")] = IDS_AUDIO_POPUP;
+ transl[ResStr(IDS_AG_SUBTITLES)] = IDS_SUBTITLES_POPUP;
+ transl[ResStr(IDS_MAINFRM_28)] = IDS_AUDIOLANGUAGE_POPUP;
+ transl[ResStr(IDS_MAINFRM_29)] = IDS_SUBTITLELANGUAGE_POPUP;
+ transl[ResStr(IDS_AG_VIDEO_ANGLE)] = IDS_VIDEOANGLE_POPUP;
+ transl[ResStr(IDS_AG_JUMP_TO)] = IDS_JUMPTO_POPUP;
+ transl[ResStr(IDS_AG_FAVORITES)] = IDS_FAVORITES_POPUP;
+ transl[ResStr(IDS_AG_SHADERS)] = IDS_SHADER_POPUP;
+ transl[ResStr(IDS_AG_VIDEO_FRAME)] = IDS_VIDEOFRAME_POPUP;
+ transl[ResStr(IDS_AG_PANSCAN)] = IDS_PANSCAN_POPUP;
+ transl[ResStr(IDS_AG_ASPECT_RATIO)] = IDS_ASPECTRATIO_POPUP;
+ transl[_T("Zoom")] = IDS_ZOOM_POPUP;
+ //transl[ResStr(IDS_RECENT_FILES_POPUP)] = IDS_RECENT_FILES_POPUP;
+ }
+
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+
+ for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
+ {
+ CString str;
+ pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
+
+ CString lookupstr = str;
+ lookupstr.Remove('&');
+
+ CMenu* pSubMenu = NULL;
+
+ UINT id;
+ if(transl.Lookup(lookupstr, id))
+ {
+ str = ResStr(id);
+ // pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, 0, str);
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STRING;
+ mii.dwTypeData = (LPTSTR)(LPCTSTR)str;
+ pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
+ }
+
+ if(str == ResStr(IDS_NAVIGATE_POPUP))
+ {
+ UINT fState = (m_iMediaLoadState == MLS_LOADED
+ && (1/*m_iPlaybackMode == PM_DVD *//*|| (m_iPlaybackMode == PM_FILE && m_PlayList.GetCount() > 0)*/))
+ ? MF_ENABLED
+ : (MF_DISABLED|MF_GRAYED);
+
+ pPopupMenu->EnableMenuItem(i, MF_BYPOSITION|fState);
+ }
+ else if(str == ResStr(IDS_VIDEOFRAME_POPUP)
+ || str == ResStr(IDS_PANSCAN_POPUP)
+ || str == ResStr(IDS_ASPECTRATIO_POPUP)
+ || str == ResStr(IDS_ZOOM_POPUP))
+ {
+ UINT fState = (m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly)
+ ? MF_ENABLED
+ : (MF_DISABLED|MF_GRAYED);
+
+ pPopupMenu->EnableMenuItem(i, MF_BYPOSITION|fState);
+ }
+ else if(str == ResStr(IDS_OPENCDROM_POPUP))
+ {
+ SetupOpenCDSubMenu();
+ pSubMenu = &m_opencds;
+ }
+ else if(str == ResStr(IDS_FILTERS_POPUP))
+ {
+ SetupFiltersSubMenu();
+ pSubMenu = &m_filters;
+ }
+ else if(str == ResStr(IDS_AUDIO_POPUP))
+ {
+ SetupAudioSwitcherSubMenu();
+ pSubMenu = &m_audios;
+ }
+ else if(str == ResStr(IDS_SUBTITLES_POPUP))
+ {
+ SetupSubtitlesSubMenu();
+ pSubMenu = &m_subtitles;
+ }
+ else if(str == ResStr(IDS_AUDIOLANGUAGE_POPUP))
+ {
+ SetupNavAudioSubMenu();
+ pSubMenu = &m_navaudio;
+ }
+ else if(str == ResStr(IDS_SUBTITLELANGUAGE_POPUP))
+ {
+ SetupNavSubtitleSubMenu();
+ pSubMenu = &m_navsubtitle;
+ }
+ else if(str == ResStr(IDS_VIDEOANGLE_POPUP))
+ {
+ SetupNavAngleSubMenu();
+ pSubMenu = &m_navangle;
+ }
+ else if(str == ResStr(IDS_JUMPTO_POPUP))
+ {
+ SetupNavChaptersSubMenu();
+ pSubMenu = &m_navchapters;
+ }
+ else if(str == ResStr(IDS_FAVORITES_POPUP))
+ {
+ SetupFavoritesSubMenu();
+ pSubMenu = &m_favorites;
+ }
+ else if(str == ResStr(IDS_RECENT_FILES_POPUP))
+ {
+ SetupRecentFilesSubMenu();
+ pSubMenu = &m_recentfiles;
+ }
+ else if(str == ResStr(IDS_SHADER_POPUP))
+ {
+ SetupShadersSubMenu();
+ pSubMenu = &m_shaders;
+ }
+
+ if(pSubMenu)
+ {
+ mii.fMask = MIIM_STATE|MIIM_SUBMENU;
+ mii.fType = MF_POPUP;
+ mii.hSubMenu = pSubMenu->m_hMenu;
+ mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED|MF_GRAYED));
+ pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
+ }
+ }
+
+ //
+
+ for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
+ {
+ UINT nID = pPopupMenu->GetMenuItemID(i);
+ if(nID == ID_SEPARATOR || nID == -1
+ || nID >= ID_FAVORITES_FILE_START && nID <= ID_FAVORITES_FILE_END
+ || nID >= ID_RECENT_FILE_START && nID <= ID_RECENT_FILE_END
+ || nID >= ID_NAVIGATE_CHAP_SUBITEM_START && nID <= ID_NAVIGATE_CHAP_SUBITEM_END)
+ continue;
+
+ CString str;
+ pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
+ int k = str.Find('\t');
+ if(k > 0) str = str.Left(k);
+
+ CString key = CPPageAccelTbl::MakeAccelShortcutLabel(nID);
+ if(!key.IsEmpty()) str += _T("\t") + key;
+
+ if(key.IsEmpty() && i < 0) continue;
+
+ // BUG(?): this disables menu item update ui calls for some reason...
// pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, nID, str);
- // this works fine
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STRING;
- mii.dwTypeData = (LPTSTR)(LPCTSTR)str;
- pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
-
- }
-
- //
-
- bool fPnSPresets = false;
-
- for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
- {
- UINT nID = pPopupMenu->GetMenuItemID(i);
-
- if(nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END)
- {
- do
- {
- nID = pPopupMenu->GetMenuItemID(i);
- pPopupMenu->DeleteMenu(i, MF_BYPOSITION);
- j--;
- }
- while(i < j && nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END);
-
- nID = pPopupMenu->GetMenuItemID(i);
- }
-
- if(nID == ID_VIEW_RESET)
- {
- fPnSPresets = true;
- }
- }
-
- if(fPnSPresets)
- {
- AppSettings& s = AfxGetAppSettings();
- int i = 0, j = s.m_pnspresets.GetCount();
- for(; i < j; i++)
- {
- int k = 0;
- CString label = s.m_pnspresets[i].Tokenize(_T(","), k);
- pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START + i, label);
- }
+ // this works fine
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STRING;
+ mii.dwTypeData = (LPTSTR)(LPCTSTR)str;
+ pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
+
+ }
+
+ //
+
+ bool fPnSPresets = false;
+
+ for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
+ {
+ UINT nID = pPopupMenu->GetMenuItemID(i);
+
+ if(nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END)
+ {
+ do
+ {
+ nID = pPopupMenu->GetMenuItemID(i);
+ pPopupMenu->DeleteMenu(i, MF_BYPOSITION);
+ j--;
+ }
+ while(i < j && nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END);
+
+ nID = pPopupMenu->GetMenuItemID(i);
+ }
+
+ if(nID == ID_VIEW_RESET)
+ {
+ fPnSPresets = true;
+ }
+ }
+
+ if(fPnSPresets)
+ {
+ AppSettings& s = AfxGetAppSettings();
+ int i = 0, j = s.m_pnspresets.GetCount();
+ for(; i < j; i++)
+ {
+ int k = 0;
+ CString label = s.m_pnspresets[i].Tokenize(_T(","), k);
+ pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START+i, label);
+ }
// if(j > 0)
- {
- pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START + i, ResStr(IDS_PANSCAN_EDIT));
- pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND | MF_SEPARATOR);
- }
- }
+ {
+ pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START+i, ResStr(IDS_PANSCAN_EDIT));
+ pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND|MF_SEPARATOR);
+ }
+ }
}
BOOL CMainFrame::OnMenu(CMenu* pMenu)
{
- if(!pMenu) return FALSE;
- AppSettings& s = AfxGetAppSettings();
- // Do not show popup menu in D3D fullscreen for Sync Renderer. It has several adverse effects.
- if(IsD3DFullScreenMode() && s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- return FALSE;
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- m_fHideCursor = false;
+ if(!pMenu) return FALSE;
+ AppSettings& s = AfxGetAppSettings();
+ // Do not show popup menu in D3D fullscreen for Sync Renderer. It has several adverse effects.
+ if (IsD3DFullScreenMode() && s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
+ return FALSE;
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ m_fHideCursor = false;
- CWnd *pModalParent = GetModalParent();
- CPoint point;
- GetCursorPos(&point);
+ CWnd *pModalParent = GetModalParent();
+ CPoint point;
+ GetCursorPos(&point);
- pMenu->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_NOANIMATION, point.x + 1, point.y + 1, this);
+ pMenu->TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NOANIMATION, point.x+1, point.y+1, this);
- return TRUE;
+ return TRUE;
}
void CMainFrame::OnMenuPlayerShort()
{
- if(IsCaptionMenuHidden() || m_pFullscreenWnd->IsWindow())
- {
- OnMenu(m_popupmain.GetSubMenu(0));
- }
- else
- {
- OnMenu(m_popup.GetSubMenu(0));
- }
+ if(IsCaptionMenuHidden() || m_pFullscreenWnd->IsWindow())
+ {
+ OnMenu(m_popupmain.GetSubMenu(0));
+ }
+ else
+ {
+ OnMenu(m_popup.GetSubMenu(0));
+ }
}
void CMainFrame::OnMenuPlayerLong()
{
- OnMenu(m_popupmain.GetSubMenu(0));
+ OnMenu(m_popupmain.GetSubMenu(0));
}
void CMainFrame::OnMenuFilters()
{
- SetupFiltersSubMenu();
- OnMenu(&m_filters);
+ SetupFiltersSubMenu();
+ OnMenu(&m_filters);
}
void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
{
- if(m_iMediaLoadState == MLS_LOADING)
- {
- pCmdUI->SetText(ResStr(IDS_CONTROLS_OPENING));
- if((AfxGetAppSettings().m_fUseWin7TaskBar) && (m_pTaskbarList)) m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
- }
- else if(m_iMediaLoadState == MLS_LOADED)
- {
- CString msg;
-
- if(!m_playingmsg.IsEmpty())
- {
- msg = m_playingmsg;
- }
- else if(m_fCapturing)
- {
- msg = ResStr(IDS_CONTROLS_CAPTURING);
-
- if(pAMDF)
- {
- long lDropped = 0;
- pAMDF->GetNumDropped(&lDropped);
- long lNotDropped = 0;
- pAMDF->GetNumNotDropped(&lNotDropped);
-
- if((lDropped + lNotDropped) > 0)
- {
- CString str;
- str.Format(ResStr(IDS_MAINFRM_37), lDropped + lNotDropped, lDropped);
- msg += str;
- }
- }
-
- CComPtr<IPin> pPin;
- if(SUCCEEDED(pCGB->FindPin(m_wndCaptureBar.m_capdlg.m_pDst, PINDIR_INPUT, NULL, NULL, FALSE, 0, &pPin)))
- {
- LONGLONG size = 0;
- if(CComQIPtr<IStream> pStream = pPin)
- {
- pStream->Commit(STGC_DEFAULT);
-
- WIN32_FIND_DATA findFileData;
- HANDLE h = FindFirstFile(m_wndCaptureBar.m_capdlg.m_file, &findFileData);
- if(h != INVALID_HANDLE_VALUE)
- {
- size = ((LONGLONG)findFileData.nFileSizeHigh << 32) | findFileData.nFileSizeLow;
-
- CString str;
- if(size < 1024i64 * 1024)
- str.Format(ResStr(IDS_MAINFRM_38), size / 1024);
- else //if(size < 1024i64*1024*1024)
- str.Format(ResStr(IDS_MAINFRM_39), size / 1024 / 1024);
- msg += str;
-
- FindClose(h);
- }
- }
-
- ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
- if(GetDiskFreeSpaceEx(
- m_wndCaptureBar.m_capdlg.m_file.Left(m_wndCaptureBar.m_capdlg.m_file.ReverseFind('\\') + 1),
- &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes))
- {
- CString str;
- if(FreeBytesAvailable.QuadPart < 1024i64 * 1024)
- str.Format(ResStr(IDS_MAINFRM_40), FreeBytesAvailable.QuadPart / 1024);
- else //if(FreeBytesAvailable.QuadPart < 1024i64*1024*1024)
- str.Format(ResStr(IDS_MAINFRM_41), FreeBytesAvailable.QuadPart / 1024 / 1024);
- msg += str;
- }
-
- if(m_wndCaptureBar.m_capdlg.m_pMux)
- {
- __int64 pos = 0;
- CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
- if(pMuxMS && SUCCEEDED(pMuxMS->GetCurrentPosition(&pos)) && pos > 0)
- {
- double bytepersec = 10000000.0 * size / pos;
- if(bytepersec > 0)
- m_rtDurationOverride = __int64(10000000.0 * (FreeBytesAvailable.QuadPart + size) / bytepersec);
- }
- }
-
- if(m_wndCaptureBar.m_capdlg.m_pVidBuffer
- || m_wndCaptureBar.m_capdlg.m_pAudBuffer)
- {
- int nFreeVidBuffers = 0, nFreeAudBuffers = 0;
- if(CComQIPtr<IBufferFilter> pVB = m_wndCaptureBar.m_capdlg.m_pVidBuffer)
- nFreeVidBuffers = pVB->GetFreeBuffers();
- if(CComQIPtr<IBufferFilter> pAB = m_wndCaptureBar.m_capdlg.m_pAudBuffer)
- nFreeAudBuffers = pAB->GetFreeBuffers();
-
- CString str;
- str.Format(ResStr(IDS_MAINFRM_42), nFreeVidBuffers, nFreeAudBuffers);
- msg += str;
- }
- }
- }
- else if(m_fBuffering)
- {
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF)
- {
- long BufferingProgress = 0;
- if(SUCCEEDED(pAMNS->get_BufferingProgress(&BufferingProgress)) && BufferingProgress > 0)
- {
- msg.Format(ResStr(IDS_CONTROLS_BUFFERING), BufferingProgress);
-
- __int64 start = 0, stop = 0;
- m_wndSeekBar.GetRange(start, stop);
- m_fLiveWM = (stop == start);
- }
- break;
- }
- }
- EndEnumFilters
- }
- else if(pAMOP)
- {
- __int64 t = 0, c = 0;
- if(SUCCEEDED(pAMOP->QueryProgress(&t, &c)) && t > 0 && c < t)
- msg.Format(ResStr(IDS_CONTROLS_BUFFERING), c * 100 / t);
-
- if(m_fUpdateInfoBar)
- OpenSetupInfoBar();
- }
-
- OAFilterState fs = GetMediaState();
- CString UI_Text =
- !msg.IsEmpty() ? msg :
- fs == State_Stopped ? ResStr(IDS_CONTROLS_STOPPED) :
- (fs == State_Paused || m_fFrameSteppingActive) ? ResStr(IDS_CONTROLS_PAUSED) :
- fs == State_Running ? ResStr(IDS_CONTROLS_PLAYING) :
- _T("");
- if((!m_fAudioOnly) && (fs == State_Running))
- {
- CString DXVA_Text = GetDXVADecoderDescription();
- if(!(_T("Not using DXVA") == DXVA_Text) || (_T("Unknown") == DXVA_Text))
- UI_Text += _T(" [DXVA]");
- }
- pCmdUI->SetText(UI_Text);
- }
- else if(m_iMediaLoadState == MLS_CLOSING)
- {
- pCmdUI->SetText(ResStr(IDS_CONTROLS_CLOSING));
- if((AfxGetAppSettings().m_fUseWin7TaskBar) && (m_pTaskbarList)) m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
- }
- else
- {
- pCmdUI->SetText(m_closingmsg);
- }
+ if(m_iMediaLoadState == MLS_LOADING)
+ {
+ pCmdUI->SetText(ResStr(IDS_CONTROLS_OPENING));
+ if((AfxGetAppSettings().m_fUseWin7TaskBar) && (m_pTaskbarList)) m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
+ }
+ else if(m_iMediaLoadState == MLS_LOADED)
+ {
+ CString msg;
+
+ if(!m_playingmsg.IsEmpty())
+ {
+ msg = m_playingmsg;
+ }
+ else if(m_fCapturing)
+ {
+ msg = ResStr(IDS_CONTROLS_CAPTURING);
+
+ if(pAMDF)
+ {
+ long lDropped = 0;
+ pAMDF->GetNumDropped(&lDropped);
+ long lNotDropped = 0;
+ pAMDF->GetNumNotDropped(&lNotDropped);
+
+ if((lDropped + lNotDropped) > 0)
+ {
+ CString str;
+ str.Format(ResStr(IDS_MAINFRM_37), lDropped + lNotDropped, lDropped);
+ msg += str;
+ }
+ }
+
+ CComPtr<IPin> pPin;
+ if(SUCCEEDED(pCGB->FindPin(m_wndCaptureBar.m_capdlg.m_pDst, PINDIR_INPUT, NULL, NULL, FALSE, 0, &pPin)))
+ {
+ LONGLONG size = 0;
+ if(CComQIPtr<IStream> pStream = pPin)
+ {
+ pStream->Commit(STGC_DEFAULT);
+
+ WIN32_FIND_DATA findFileData;
+ HANDLE h = FindFirstFile(m_wndCaptureBar.m_capdlg.m_file, &findFileData);
+ if(h != INVALID_HANDLE_VALUE)
+ {
+ size = ((LONGLONG)findFileData.nFileSizeHigh << 32) | findFileData.nFileSizeLow;
+
+ CString str;
+ if(size < 1024i64*1024)
+ str.Format(ResStr(IDS_MAINFRM_38), size/1024);
+ else //if(size < 1024i64*1024*1024)
+ str.Format(ResStr(IDS_MAINFRM_39), size/1024/1024);
+ msg += str;
+
+ FindClose(h);
+ }
+ }
+
+ ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
+ if(GetDiskFreeSpaceEx(
+ m_wndCaptureBar.m_capdlg.m_file.Left(m_wndCaptureBar.m_capdlg.m_file.ReverseFind('\\')+1),
+ &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes))
+ {
+ CString str;
+ if(FreeBytesAvailable.QuadPart < 1024i64*1024)
+ str.Format(ResStr(IDS_MAINFRM_40), FreeBytesAvailable.QuadPart/1024);
+ else //if(FreeBytesAvailable.QuadPart < 1024i64*1024*1024)
+ str.Format(ResStr(IDS_MAINFRM_41), FreeBytesAvailable.QuadPart/1024/1024);
+ msg += str;
+ }
+
+ if(m_wndCaptureBar.m_capdlg.m_pMux)
+ {
+ __int64 pos = 0;
+ CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
+ if(pMuxMS && SUCCEEDED(pMuxMS->GetCurrentPosition(&pos)) && pos > 0)
+ {
+ double bytepersec = 10000000.0 * size / pos;
+ if(bytepersec > 0)
+ m_rtDurationOverride = __int64(10000000.0 * (FreeBytesAvailable.QuadPart+size) / bytepersec);
+ }
+ }
+
+ if(m_wndCaptureBar.m_capdlg.m_pVidBuffer
+ || m_wndCaptureBar.m_capdlg.m_pAudBuffer)
+ {
+ int nFreeVidBuffers = 0, nFreeAudBuffers = 0;
+ if(CComQIPtr<IBufferFilter> pVB = m_wndCaptureBar.m_capdlg.m_pVidBuffer)
+ nFreeVidBuffers = pVB->GetFreeBuffers();
+ if(CComQIPtr<IBufferFilter> pAB = m_wndCaptureBar.m_capdlg.m_pAudBuffer)
+ nFreeAudBuffers = pAB->GetFreeBuffers();
+
+ CString str;
+ str.Format(ResStr(IDS_MAINFRM_42), nFreeVidBuffers, nFreeAudBuffers);
+ msg += str;
+ }
+ }
+ }
+ else if(m_fBuffering)
+ {
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF)
+ {
+ long BufferingProgress = 0;
+ if(SUCCEEDED(pAMNS->get_BufferingProgress(&BufferingProgress)) && BufferingProgress > 0)
+ {
+ msg.Format(ResStr(IDS_CONTROLS_BUFFERING), BufferingProgress);
+
+ __int64 start = 0, stop = 0;
+ m_wndSeekBar.GetRange(start, stop);
+ m_fLiveWM = (stop == start);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+ else if(pAMOP)
+ {
+ __int64 t = 0, c = 0;
+ if(SUCCEEDED(pAMOP->QueryProgress(&t, &c)) && t > 0 && c < t)
+ msg.Format(ResStr(IDS_CONTROLS_BUFFERING), c*100/t);
+
+ if(m_fUpdateInfoBar)
+ OpenSetupInfoBar();
+ }
+
+ OAFilterState fs = GetMediaState();
+ CString UI_Text =
+ !msg.IsEmpty() ? msg :
+ fs == State_Stopped ? ResStr(IDS_CONTROLS_STOPPED) :
+ (fs == State_Paused || m_fFrameSteppingActive) ? ResStr(IDS_CONTROLS_PAUSED) :
+ fs == State_Running ? ResStr(IDS_CONTROLS_PLAYING) :
+ _T("");
+ if((!m_fAudioOnly) && (fs == State_Running))
+ {
+ CString DXVA_Text = GetDXVADecoderDescription();
+ if(!(_T("Not using DXVA")==DXVA_Text) || (_T("Unknown")==DXVA_Text))
+ UI_Text += _T(" [DXVA]");
+ }
+ pCmdUI->SetText(UI_Text);
+ }
+ else if(m_iMediaLoadState == MLS_CLOSING)
+ {
+ pCmdUI->SetText(ResStr(IDS_CONTROLS_CLOSING));
+ if((AfxGetAppSettings().m_fUseWin7TaskBar) && (m_pTaskbarList)) m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
+ }
+ else
+ {
+ pCmdUI->SetText(m_closingmsg);
+ }
}
void CMainFrame::OnFilePostOpenmedia()
{
- OpenSetupInfoBar();
+ OpenSetupInfoBar();
- OpenSetupStatsBar();
+ OpenSetupStatsBar();
- OpenSetupStatusBar();
+ OpenSetupStatusBar();
- // OpenSetupToolBar();
+ // OpenSetupToolBar();
- OpenSetupCaptureBar();
+ OpenSetupCaptureBar();
- __int64 rtDur = 0;
- pMS->GetDuration(&rtDur);
- m_wndPlaylistBar.SetCurTime(rtDur);
+ __int64 rtDur = 0;
+ pMS->GetDuration(&rtDur);
+ m_wndPlaylistBar.SetCurTime(rtDur);
- if(m_iPlaybackMode == PM_CAPTURE)
- {
- ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
+ if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
// ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
// ShowControlBar(&m_wndCaptureBar, TRUE, TRUE);
- }
-
- m_nCurSubtitle = -1;
- m_lSubtitleShift = 0;
- if(m_pCAP) m_pCAP->SetSubtitleDelay(0);
-
- SetLoadState(MLS_LOADED);
-
- // IMPORTANT: must not call any windowing msgs before
- // this point, it will deadlock when OpenMediaPrivate is
- // still running and the renderer window was created on
- // the same worker-thread
-
- {
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
-
- // restore magnification
- if(IsWindowVisible() && AfxGetAppSettings().fRememberZoomLevel
- && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED))
- {
- ZoomVideoWindow();
- }
- }
-
- // Waffs : PnS command line
- if(!AfxGetAppSettings().sPnSPreset.IsEmpty())
- {
- for(int i = 0; i < AfxGetAppSettings().m_pnspresets.GetCount(); i++)
- {
- int j = 0;
- CString str = AfxGetAppSettings().m_pnspresets[i];
- CString label = str.Tokenize(_T(","), j);
- if(AfxGetAppSettings().sPnSPreset == label) OnViewPanNScanPresets(i + ID_PANNSCAN_PRESETS_START);
- }
- AfxGetAppSettings().sPnSPreset.Empty();
- }
- SendNowPlayingToMSN();
- SendNowPlayingTomIRC();
- SendNowPlayingToApi();
+ }
+
+ m_nCurSubtitle = -1;
+ m_lSubtitleShift = 0;
+ if(m_pCAP) m_pCAP->SetSubtitleDelay(0);
+
+ SetLoadState (MLS_LOADED);
+
+ // IMPORTANT: must not call any windowing msgs before
+ // this point, it will deadlock when OpenMediaPrivate is
+ // still running and the renderer window was created on
+ // the same worker-thread
+
+ {
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
+
+ // restore magnification
+ if(IsWindowVisible() && AfxGetAppSettings().fRememberZoomLevel
+ && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED))
+ {
+ ZoomVideoWindow();
+ }
+ }
+
+ // Waffs : PnS command line
+ if(!AfxGetAppSettings().sPnSPreset.IsEmpty())
+ {
+ for(int i = 0; i < AfxGetAppSettings().m_pnspresets.GetCount(); i++)
+ {
+ int j = 0;
+ CString str = AfxGetAppSettings().m_pnspresets[i];
+ CString label = str.Tokenize(_T(","), j);
+ if(AfxGetAppSettings().sPnSPreset == label) OnViewPanNScanPresets(i+ID_PANNSCAN_PRESETS_START);
+ }
+ AfxGetAppSettings().sPnSPreset.Empty();
+ }
+ SendNowPlayingToMSN();
+ SendNowPlayingTomIRC();
+ SendNowPlayingToApi();
}
void CMainFrame::OnUpdateFilePostOpenmedia(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADING);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADING);
}
void CMainFrame::OnFilePostClosemedia()
{
- if(IsD3DFullScreenMode())
- {
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
- m_fHideCursor = false;
- }
- m_wndView.SetVideoRect();
- m_wndSeekBar.Enable(false);
- m_wndSeekBar.SetPos(0);
- m_wndInfoBar.RemoveAllLines();
- m_wndStatsBar.RemoveAllLines();
- m_wndStatusBar.Clear();
- m_wndStatusBar.ShowTimer(false);
-
- if(AfxGetAppSettings().fEnableEDLEditor)
- m_wndEditListEditor.CloseFile();
-
- if(IsWindow(m_wndSubresyncBar.m_hWnd))
- {
- ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
- SetSubtitle(NULL);
- }
-
- if(IsWindow(m_wndCaptureBar.m_hWnd))
- {
- ShowControlBar(&m_wndCaptureBar, FALSE, TRUE);
- m_wndCaptureBar.m_capdlg.SetupVideoControls(_T(""), NULL, NULL, NULL);
- m_wndCaptureBar.m_capdlg.SetupAudioControls(_T(""), NULL, CInterfaceArray<IAMAudioInputMixer>());
- }
-
- RecalcLayout();
-
- SetWindowText(m_strTitle);
- m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
-
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
-
- // this will prevent any further UI updates on the dynamically added menu items
- SetupFiltersSubMenu();
- SetupAudioSwitcherSubMenu();
- SetupSubtitlesSubMenu();
- SetupNavAudioSubMenu();
- SetupNavSubtitleSubMenu();
- SetupNavAngleSubMenu();
- SetupNavChaptersSubMenu();
- SetupFavoritesSubMenu();
- SetupRecentFilesSubMenu();
-
- SendNowPlayingToMSN();
+ if (IsD3DFullScreenMode())
+ {
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
+ m_fHideCursor = false;
+ }
+ m_wndView.SetVideoRect();
+ m_wndSeekBar.Enable(false);
+ m_wndSeekBar.SetPos(0);
+ m_wndInfoBar.RemoveAllLines();
+ m_wndStatsBar.RemoveAllLines();
+ m_wndStatusBar.Clear();
+ m_wndStatusBar.ShowTimer(false);
+
+ if (AfxGetAppSettings().fEnableEDLEditor)
+ m_wndEditListEditor.CloseFile();
+
+ if(IsWindow(m_wndSubresyncBar.m_hWnd))
+ {
+ ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
+ SetSubtitle(NULL);
+ }
+
+ if(IsWindow(m_wndCaptureBar.m_hWnd))
+ {
+ ShowControlBar(&m_wndCaptureBar, FALSE, TRUE);
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(_T(""), NULL, NULL, NULL);
+ m_wndCaptureBar.m_capdlg.SetupAudioControls(_T(""), NULL, CInterfaceArray<IAMAudioInputMixer>());
+ }
+
+ RecalcLayout();
+
+ SetWindowText(m_strTitle);
+ m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
+
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+
+ // this will prevent any further UI updates on the dynamically added menu items
+ SetupFiltersSubMenu();
+ SetupAudioSwitcherSubMenu();
+ SetupSubtitlesSubMenu();
+ SetupNavAudioSubMenu();
+ SetupNavSubtitleSubMenu();
+ SetupNavAngleSubMenu();
+ SetupNavChaptersSubMenu();
+ SetupFavoritesSubMenu();
+ SetupRecentFilesSubMenu();
+
+ SendNowPlayingToMSN();
}
void CMainFrame::OnUpdateFilePostClosemedia(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!m_hWnd && m_iMediaLoadState == MLS_CLOSING);
+ pCmdUI->Enable(!!m_hWnd && m_iMediaLoadState == MLS_CLOSING);
}
void CMainFrame::OnBossKey()
{
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- if(m_fFullScreen) SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
- SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, -1);
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ if(m_fFullScreen) SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
+ SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, -1);
}
void CMainFrame::OnStreamAudio(UINT nID)
{
- nID -= ID_STREAM_AUDIO_NEXT;
-
- if(m_iMediaLoadState != MLS_LOADED) return;
-
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
-
- DWORD cStreams = 0;
- if(pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
- {
- nID = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(nID)); // remember that the audio streams are reordered according to user preference, so have to figure out which stream from the original order was clicked
- for(int i = 0; i < (int)cStreams; i++)
- {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- return;
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
-
- if(dwFlags&(AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE))
- {
- pSS->Enable((i + (nID == 0 ? 1 : cStreams - 1)) % cStreams, AMSTREAMSELECTENABLE_ENABLE);
- break;
- }
- }
- }
- else if(m_iPlaybackMode == PM_FILE) SendMessage(WM_COMMAND, ID_OGM_AUDIO_NEXT + nID);
- else if(m_iPlaybackMode == PM_DVD) SendMessage(WM_COMMAND, ID_DVD_AUDIO_NEXT + nID);
+ nID -= ID_STREAM_AUDIO_NEXT;
+
+ if(m_iMediaLoadState != MLS_LOADED) return;
+
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+
+ DWORD cStreams = 0;
+ if(pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
+ {
+ nID = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(nID)); // remember that the audio streams are reordered according to user preference, so have to figure out which stream from the original order was clicked
+ for(int i = 0; i < (int)cStreams; i++)
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+ return;
+ if(pmt) DeleteMediaType(pmt);
+ if(pszName) CoTaskMemFree(pszName);
+
+ if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE))
+ {
+ pSS->Enable((i+(nID==0?1:cStreams-1))%cStreams, AMSTREAMSELECTENABLE_ENABLE);
+ break;
+ }
+ }
+ }
+ else if(m_iPlaybackMode == PM_FILE) SendMessage(WM_COMMAND, ID_OGM_AUDIO_NEXT+nID);
+ else if(m_iPlaybackMode == PM_DVD) SendMessage(WM_COMMAND, ID_DVD_AUDIO_NEXT+nID);
}
void CMainFrame::OnStreamSub(UINT nID)
{
- nID -= ID_STREAM_SUB_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ nID -= ID_STREAM_SUB_NEXT;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- int cnt = 0;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ int cnt = 0;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos) cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
- if(cnt > 1)
- {
- int i = ((m_iSubtitleSel & 0x7fffffff) + (nID == 0 ? 1 : cnt - 1)) % cnt;
- m_iSubtitleSel = i | (m_iSubtitleSel & 0x80000000);
- UpdateSubtitle();
- SetFocus();
- }
- else if(m_iPlaybackMode == PM_FILE) SendMessage(WM_COMMAND, ID_OGM_SUB_NEXT + nID);
- else if(m_iPlaybackMode == PM_DVD) SendMessage(WM_COMMAND, ID_DVD_SUB_NEXT + nID);
+ if(cnt > 1)
+ {
+ int i = ((m_iSubtitleSel&0x7fffffff)+(nID==0?1:cnt-1))%cnt;
+ m_iSubtitleSel = i | (m_iSubtitleSel&0x80000000);
+ UpdateSubtitle();
+ SetFocus();
+ }
+ else if(m_iPlaybackMode == PM_FILE) SendMessage(WM_COMMAND, ID_OGM_SUB_NEXT+nID);
+ else if(m_iPlaybackMode == PM_DVD) SendMessage(WM_COMMAND, ID_DVD_SUB_NEXT+nID);
}
void CMainFrame::OnStreamSubOnOff()
{
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- int cnt = 0;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ int cnt = 0;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos) cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
- if(cnt > 0)
- {
- m_iSubtitleSel ^= 0x80000000;
- UpdateSubtitle();
- SetFocus();
- }
- else if(m_iPlaybackMode == PM_DVD) SendMessage(WM_COMMAND, ID_DVD_SUB_ONOFF);
+ if(cnt > 0)
+ {
+ m_iSubtitleSel ^= 0x80000000;
+ UpdateSubtitle();
+ SetFocus();
+ }
+ else if(m_iPlaybackMode == PM_DVD) SendMessage(WM_COMMAND, ID_DVD_SUB_ONOFF);
}
void CMainFrame::OnOgmAudio(UINT nID)
{
- nID -= ID_OGM_AUDIO_NEXT;
+ nID -= ID_OGM_AUDIO_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if(!pSS) return;
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if(!pSS) return;
CAtlArray<int> snds;
- int iSel = -1;
-
- DWORD cStreams = 0;
- if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
- {
- for(int i = 0; i < (int)cStreams; i++)
- {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- return;
-
- if(dwGroup == 1)
- {
- if(dwFlags&(AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE))
- iSel = snds.GetCount();
- snds.Add(i);
- }
-
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
-
- }
-
- int cnt = snds.GetCount();
- if(cnt > 1 && iSel >= 0)
- {
- int nNewStream = snds[(iSel+(nID==0?1:cnt-1))%cnt];
- pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
-
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
-
- if(SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- {
- CString lang;
- CString strMessage;
- if(lcid == 0)
- strMessage.Format(_T("Audio : %s - %s"), ResStr(IDS_AG_UNKNOWN_STREAM), pszName);
- else
- {
- int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len - 1, 0));
- strMessage.Format(_T("Audio : %s"), lang);
- }
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
-
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
- }
- }
- }
+ int iSel = -1;
+
+ DWORD cStreams = 0;
+ if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
+ {
+ for(int i = 0; i < (int)cStreams; i++)
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+ return;
+
+ if(dwGroup == 1)
+ {
+ if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE))
+ iSel = snds.GetCount();
+ snds.Add(i);
+ }
+
+ if(pmt) DeleteMediaType(pmt);
+ if(pszName) CoTaskMemFree(pszName);
+
+ }
+
+ int cnt = snds.GetCount();
+ if(cnt > 1 && iSel >= 0)
+ {
+ int nNewStream = snds[(iSel+(nID==0?1:cnt-1))%cnt];
+ pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+
+ if(SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+ {
+ CString lang;
+ CString strMessage;
+ if (lcid == 0)
+ strMessage.Format (_T("Audio : %s - %s"), ResStr(IDS_AG_UNKNOWN_STREAM), pszName);
+ else
+ {
+ int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len-1, 0));
+ strMessage.Format (_T("Audio : %s"), lang);
+ }
+ m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
+
+ if(pmt) DeleteMediaType(pmt);
+ if(pszName) CoTaskMemFree(pszName);
+ }
+ }
+ }
}
void CMainFrame::OnOgmSub(UINT nID)
{
- nID -= ID_OGM_SUB_NEXT;
+ nID -= ID_OGM_SUB_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if(!pSS) return;
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if(!pSS) return;
CArray<int> subs;
- int iSel = -1;
-
- DWORD cStreams = 0;
- if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
- {
- for(int i = 0; i < (int)cStreams; i++)
- {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- return;
-
- if(dwGroup == 2)
- {
- if(dwFlags&(AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE))
- iSel = subs.GetCount();
- subs.Add(i);
- }
-
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
-
- }
-
- int cnt = subs.GetCount();
- if(cnt > 1 && iSel >= 0)
- {
- int nNewStream = subs[(iSel+(nID==0?1:cnt-1))%cnt];
- pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
-
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if(SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- {
- CString lang;
- CString strMessage;
- if(lcid == 0)
- lang = pszName;
- else
- {
- int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len - 1, 0));
- }
-
- strMessage.Format(ResStr(IDS_MAINFRM_45), lang, _T(""));
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
- }
- }
- }
+ int iSel = -1;
+
+ DWORD cStreams = 0;
+ if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
+ {
+ for(int i = 0; i < (int)cStreams; i++)
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+ return;
+
+ if(dwGroup == 2)
+ {
+ if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE))
+ iSel = subs.GetCount();
+ subs.Add(i);
+ }
+
+ if(pmt) DeleteMediaType(pmt);
+ if(pszName) CoTaskMemFree(pszName);
+
+ }
+
+ int cnt = subs.GetCount();
+ if(cnt > 1 && iSel >= 0)
+ {
+ int nNewStream = subs[(iSel+(nID==0?1:cnt-1))%cnt];
+ pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if(SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+ {
+ CString lang;
+ CString strMessage;
+ if (lcid == 0)
+ lang = pszName;
+ else
+ {
+ int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len-1, 0));
+ }
+
+ strMessage.Format (ResStr(IDS_MAINFRM_45), lang, _T(""));
+ m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
+ if(pmt) DeleteMediaType(pmt);
+ if(pszName) CoTaskMemFree(pszName);
+ }
+ }
+ }
}
void CMainFrame::OnDvdAngle(UINT nID)
{
- nID -= ID_DVD_ANGLE_NEXT;
+ nID -= ID_DVD_ANGLE_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- if(pDVDI && pDVDC)
- {
- ULONG ulAnglesAvailable, ulCurrentAngle;
- if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAnglesAvailable, &ulCurrentAngle)) && ulAnglesAvailable > 1)
- {
- ulCurrentAngle += nID == 0 ? 1 : ulAnglesAvailable - 1;
- if(ulCurrentAngle > ulAnglesAvailable) ulCurrentAngle = 1;
- else if(ulCurrentAngle < 1) ulCurrentAngle = ulAnglesAvailable;
- pDVDC->SelectAngle(ulCurrentAngle, DVD_CMD_FLAG_Block, NULL);
- }
- }
+ if(pDVDI && pDVDC)
+ {
+ ULONG ulAnglesAvailable, ulCurrentAngle;
+ if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAnglesAvailable, &ulCurrentAngle)) && ulAnglesAvailable > 1)
+ {
+ ulCurrentAngle += nID==0 ? 1 : ulAnglesAvailable-1;
+ if(ulCurrentAngle > ulAnglesAvailable) ulCurrentAngle = 1;
+ else if(ulCurrentAngle < 1) ulCurrentAngle = ulAnglesAvailable;
+ pDVDC->SelectAngle(ulCurrentAngle, DVD_CMD_FLAG_Block, NULL);
+ }
+ }
}
void CMainFrame::OnDvdAudio(UINT nID)
{
- HRESULT hr;
- nID -= ID_DVD_AUDIO_NEXT;
-
- if(m_iMediaLoadState != MLS_LOADED) return;
-
- if(pDVDI && pDVDC)
- {
- ULONG nStreamsAvailable, nCurrentStream;
- if(SUCCEEDED(pDVDI->GetCurrentAudio(&nStreamsAvailable, &nCurrentStream)) && nStreamsAvailable > 1)
- {
- DVD_AudioAttributes AATR;
- UINT nNextStream = (nCurrentStream + (nID == 0 ? 1 : nStreamsAvailable - 1)) % nStreamsAvailable;
-
- hr = pDVDC->SelectAudioStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
- if(SUCCEEDED(pDVDI->GetAudioAttributes(nNextStream, &AATR)))
- {
- CString lang;
- CString strMessage;
- int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len - 1, 0));
- strMessage.Format(_T("Audio : %s - %s %s"), lang, GetDVDAudioFormatName(AATR), FAILED(hr) ? ResStr(IDS_AG_ERROR) : _T(""));
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
- }
- }
- }
+ HRESULT hr;
+ nID -= ID_DVD_AUDIO_NEXT;
+
+ if(m_iMediaLoadState != MLS_LOADED) return;
+
+ if(pDVDI && pDVDC)
+ {
+ ULONG nStreamsAvailable, nCurrentStream;
+ if(SUCCEEDED(pDVDI->GetCurrentAudio(&nStreamsAvailable, &nCurrentStream)) && nStreamsAvailable > 1)
+ {
+ DVD_AudioAttributes AATR;
+ UINT nNextStream = (nCurrentStream+(nID==0?1:nStreamsAvailable-1))%nStreamsAvailable;
+
+ hr = pDVDC->SelectAudioStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
+ if (SUCCEEDED(pDVDI->GetAudioAttributes(nNextStream, &AATR)))
+ {
+ CString lang;
+ CString strMessage;
+ int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len-1, 0));
+ strMessage.Format (_T("Audio : %s - %s %s"), lang, GetDVDAudioFormatName(AATR), FAILED(hr)?ResStr(IDS_AG_ERROR):_T(""));
+ m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
+ }
+ }
+ }
}
void CMainFrame::OnDvdSub(UINT nID)
{
- HRESULT hr;
- nID -= ID_DVD_SUB_NEXT;
+ HRESULT hr;
+ nID -= ID_DVD_SUB_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- if(pDVDI && pDVDC)
- {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
- && ulStreamsAvailable > 1)
- {
+ if(pDVDI && pDVDC)
+ {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
+ && ulStreamsAvailable > 1)
+ {
// UINT nNextStream = (ulCurrentStream+(nID==0?1:ulStreamsAvailable-1))%ulStreamsAvailable;
- int nNextStream;
-
- if(!bIsDisabled)
- nNextStream = ulCurrentStream + (nID == 0 ? 1 : -1);
- else
- nNextStream = (nID == 0 ? 0 : ulStreamsAvailable - 1);
-
- if(!bIsDisabled && ((nNextStream < 0) || (nNextStream >= ulStreamsAvailable)))
- {
- pDVDC->SetSubpictureState(FALSE, DVD_CMD_FLAG_Block, NULL);
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_MAINFRM_44));
- }
- else
- {
- hr = pDVDC->SelectSubpictureStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
-
- DVD_SubpictureAttributes SATR;
- pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
- if(SUCCEEDED(pDVDI->GetSubpictureAttributes(nNextStream, &SATR)))
- {
- CString lang;
- CString strMessage;
- int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len - 1, 0));
- strMessage.Format(ResStr(IDS_MAINFRM_45), lang, FAILED(hr) ? _T("Error") : _T(""));
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
- }
- }
- }
- }
+ int nNextStream;
+
+ if (!bIsDisabled)
+ nNextStream = ulCurrentStream+ (nID==0?1:-1);
+ else
+ nNextStream = (nID==0?0:ulStreamsAvailable-1);
+
+ if (!bIsDisabled && ((nNextStream < 0) || (nNextStream >= ulStreamsAvailable)))
+ {
+ pDVDC->SetSubpictureState(FALSE, DVD_CMD_FLAG_Block, NULL);
+ m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_MAINFRM_44));
+ }
+ else
+ {
+ hr = pDVDC->SelectSubpictureStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
+
+ DVD_SubpictureAttributes SATR;
+ pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
+ if(SUCCEEDED(pDVDI->GetSubpictureAttributes(nNextStream, &SATR)))
+ {
+ CString lang;
+ CString strMessage;
+ int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len-1, 0));
+ strMessage.Format (ResStr(IDS_MAINFRM_45), lang, FAILED(hr)?_T("Error"):_T(""));
+ m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
+ }
+ }
+ }
+ }
}
void CMainFrame::OnDvdSubOnOff()
{
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- if(pDVDI && pDVDC)
- {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
- {
- pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
- }
- }
+ if(pDVDI && pDVDC)
+ {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
+ {
+ pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
+ }
+ }
}
//
@@ -3708,294 +3641,286 @@ void CMainFrame::OnDvdSubOnOff()
void CMainFrame::OnFileOpenQuick()
{
- if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) return;
+ if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) return;
- CString filter;
- CAtlArray<CString> mask;
- AfxGetAppSettings().Formats.GetFilter(filter, mask);
- COpenFileDlg fd(mask, true, NULL, NULL,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_ENABLEINCLUDENOTIFY,
- filter, GetModalParent());
- if(fd.DoModal() != IDOK) return;
+ CString filter;
+ CAtlArray<CString> mask;
+ AfxGetAppSettings().Formats.GetFilter(filter, mask);
+ COpenFileDlg fd(mask, true, NULL, NULL,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY,
+ filter, GetModalParent());
+ if(fd.DoModal() != IDOK) return;
- CAtlList<CString> fns;
+ CAtlList<CString> fns;
- POSITION pos = fd.GetStartPosition();
- while(pos) fns.AddTail(fd.GetNextPathName(pos));
+ POSITION pos = fd.GetStartPosition();
+ while(pos) fns.AddTail(fd.GetNextPathName(pos));
- bool fMultipleFiles = false;
+ bool fMultipleFiles = false;
- if(fns.GetCount() > 1
- || fns.GetCount() == 1
- && (fns.GetHead()[fns.GetHead().GetLength()-1] == '\\'
- || fns.GetHead()[fns.GetHead().GetLength()-1] == '*'))
- {
- fMultipleFiles = true;
- }
+ if(fns.GetCount() > 1
+ || fns.GetCount() == 1
+ && (fns.GetHead()[fns.GetHead().GetLength()-1] == '\\'
+ || fns.GetHead()[fns.GetHead().GetLength()-1] == '*'))
+ {
+ fMultipleFiles = true;
+ }
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- ShowWindow(SW_SHOW);
- SetForegroundWindow();
+ ShowWindow(SW_SHOW);
+ SetForegroundWindow();
- m_wndPlaylistBar.Open(fns, fMultipleFiles);
+ m_wndPlaylistBar.Open(fns, fMultipleFiles);
- if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating())
- {
- ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
- }
-
- OpenCurPlaylistItem();
+ if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating())
+ {
+ ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
+ }
+
+ OpenCurPlaylistItem();
}
void CMainFrame::OnFileOpenmedia()
{
- if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar) || m_pFullscreenWnd->IsWindow()) return;
+ if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar) || m_pFullscreenWnd->IsWindow()) return;
- COpenDlg dlg;
- if(dlg.DoModal() != IDOK || dlg.m_fns.GetCount() == 0) return;
+ COpenDlg dlg;
+ if(dlg.DoModal() != IDOK || dlg.m_fns.GetCount() == 0) return;
- if(!dlg.m_fAppendPlaylist)
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- }
+ if(!dlg.m_fAppendPlaylist)
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ }
- ShowWindow(SW_SHOW);
- SetForegroundWindow();
+ ShowWindow(SW_SHOW);
+ SetForegroundWindow();
- if(dlg.m_fAppendPlaylist)
- {
- m_wndPlaylistBar.Append(dlg.m_fns, dlg.m_fMultipleFiles);
- return;
- }
+ if(dlg.m_fAppendPlaylist)
+ {
+ m_wndPlaylistBar.Append(dlg.m_fns, dlg.m_fMultipleFiles);
+ return;
+ }
- m_wndPlaylistBar.Open(dlg.m_fns, dlg.m_fMultipleFiles);
+ m_wndPlaylistBar.Open(dlg.m_fns, dlg.m_fMultipleFiles);
- if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating())
- {
- ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
- }
+ if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating())
+ {
+ ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
+ }
- OpenCurPlaylistItem();
+ OpenCurPlaylistItem();
}
void CMainFrame::OnUpdateFileOpen(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState != MLS_LOADING);
+ pCmdUI->Enable(m_iMediaLoadState != MLS_LOADING);
}
bool is_dir(CString dirname)
{
- WIN32_FIND_DATA w32fd;
- HANDLE h = FindFirstFile(dirname, &w32fd);
- return (h != INVALID_HANDLE_VALUE) && ((w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
+ WIN32_FIND_DATA w32fd;
+ HANDLE h = FindFirstFile(dirname, &w32fd);
+ return (h!=INVALID_HANDLE_VALUE)&&((w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)!=0);
}
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
{
- AppSettings& s = AfxGetAppSettings();
-
- if(s.hMasterWnd)
- {
- ProcessAPICommand(pCDS);
- return TRUE;
- }
-
- /*
- if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar))
- return FALSE;
- */
-
- if(pCDS->dwData != 0x6ABE51 || pCDS->cbData < sizeof(DWORD))
- return FALSE;
-
- DWORD len = *((DWORD*)pCDS->lpData);
- TCHAR* pBuff = (TCHAR*)((DWORD*)pCDS->lpData + 1);
- TCHAR* pBuffEnd = (TCHAR*)((BYTE*)pBuff + pCDS->cbData - sizeof(DWORD));
-
- CAtlList<CString> cmdln;
-
- while(len-- > 0)
- {
- CString str;
- while(pBuff < pBuffEnd && *pBuff) str += *pBuff++;
- pBuff++;
- cmdln.AddTail(str);
- }
-
- s.ParseCommandLine(cmdln);
-
- if(s.nCLSwitches & CLSW_SLAVE)
- {
- SendAPICommand(CMD_CONNECT, L"%d", GetSafeHwnd());
- }
-
- POSITION pos = s.slFilters.GetHeadPosition();
- while(pos)
- {
- CString fullpath = MakeFullPath(s.slFilters.GetNext(pos));
-
- CPath tmp(fullpath);
- tmp.RemoveFileSpec();
- tmp.AddBackslash();
- CString path = tmp;
-
- WIN32_FIND_DATA fd = {0};
- HANDLE hFind = FindFirstFile(fullpath, &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
-
- CFilterMapper2 fm2(false);
- fm2.Register(path + fd.cFileName);
- while(!fm2.m_filters.IsEmpty())
- {
- if(FilterOverride* f = fm2.m_filters.RemoveTail())
- {
- f->fTemporary = true;
-
- bool fFound = false;
-
- POSITION pos2 = s.filters.GetHeadPosition();
- while(pos2)
- {
- FilterOverride* f2 = s.filters.GetNext(pos2);
- if(f2->type == FilterOverride::EXTERNAL && !f2->path.CompareNoCase(f->path))
- {
- fFound = true;
- break;
- }
- }
-
- if(!fFound)
- {
- CAutoPtr<FilterOverride> p(f);
- s.filters.AddHead(p);
- }
- }
- }
- }
- while(FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
- }
-
- bool fSetForegroundWindow = false;
-
- if((s.nCLSwitches & CLSW_DVD) && !s.slFiles.IsEmpty())
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if(p)
- {
- p->path = s.slFiles.GetHead();
- p->subs.AddTailList(&s.slSubs);
- }
- OpenMedia(p);
- }
- else if(s.nCLSwitches & CLSW_CD)
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- CAtlList<CString> sl;
-
- if(!s.slFiles.IsEmpty())
- {
- GetCDROMType(s.slFiles.GetHead()[0], sl);
- }
- else
- {
- CString dir;
- dir.ReleaseBufferSetLength(GetCurrentDirectory(MAX_PATH, dir.GetBuffer(MAX_PATH)));
-
- GetCDROMType(dir[0], sl);
-
- for(TCHAR drive = 'C'; sl.IsEmpty() && drive <= 'Z'; drive++)
- {
- GetCDROMType(drive, sl);
- }
- }
-
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
- }
- else if(!s.slFiles.IsEmpty())
- {
- bool fMulti = s.slFiles.GetCount() > 1;
-
- CAtlList<CString> sl;
- sl.AddTailList(&s.slFiles);
- if(!fMulti) sl.AddTailList(&s.slDubs);
-
- CString dvd_path = s.slFiles.GetHead() + _T("\\VIDEO_TS");
- if((!fMulti) && (is_dir(dvd_path)))
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if(p)
- {
- p->path = s.slFiles.GetHead();
- p->subs.AddTailList(&s.slSubs);
- }
- OpenMedia(p);
- }
- else
- {
-
- if(last_run && ((GetTickCount() - last_run) < 500)) s.nCLSwitches |= CLSW_ADD;
- last_run = GetTickCount();
-
- if((s.nCLSwitches & CLSW_ADD) && m_wndPlaylistBar.GetCount() > 0)
- {
- m_wndPlaylistBar.Append(sl, fMulti, &s.slSubs);
-
- if(s.nCLSwitches&(CLSW_OPEN | CLSW_PLAY))
- {
- m_wndPlaylistBar.SetLast();
- OpenCurPlaylistItem();
- }
- }
- else
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- m_wndPlaylistBar.Open(sl, fMulti, &s.slSubs);
- OpenCurPlaylistItem((s.nCLSwitches & CLSW_STARTVALID) ? s.rtStart : 0);
-
- s.nCLSwitches &= ~CLSW_STARTVALID;
- s.rtStart = 0;
- }
- }
- }
- else
- {
- s.nCLSwitches = CLSW_NONE;
- }
-
- if(fSetForegroundWindow && !(s.nCLSwitches & CLSW_NOFOCUS))
- SetForegroundWindow();
-
- s.nCLSwitches &= ~CLSW_NOFOCUS;
-
- return TRUE;
-}
-
-int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
-{
- switch(uMsg)
- {
- case BFFM_INITIALIZED:
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.hMasterWnd)
+ {
+ ProcessAPICommand(pCDS);
+ return TRUE;
+ }
+
+ /*
+ if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar))
+ return FALSE;
+ */
+
+ if(pCDS->dwData != 0x6ABE51 || pCDS->cbData < sizeof(DWORD))
+ return FALSE;
+
+ DWORD len = *((DWORD*)pCDS->lpData);
+ TCHAR* pBuff = (TCHAR*)((DWORD*)pCDS->lpData + 1);
+ TCHAR* pBuffEnd = (TCHAR*)((BYTE*)pBuff + pCDS->cbData - sizeof(DWORD));
+
+ CAtlList<CString> cmdln;
+
+ while(len-- > 0)
+ {
+ CString str;
+ while(pBuff < pBuffEnd && *pBuff) str += *pBuff++;
+ pBuff++;
+ cmdln.AddTail(str);
+ }
+
+ s.ParseCommandLine(cmdln);
+
+ if(s.nCLSwitches&CLSW_SLAVE)
+ {
+ SendAPICommand (CMD_CONNECT, L"%d", GetSafeHwnd());
+ }
+
+ POSITION pos = s.slFilters.GetHeadPosition();
+ while(pos)
+ {
+ CString fullpath = MakeFullPath(s.slFilters.GetNext(pos));
+
+ CPath tmp(fullpath);
+ tmp.RemoveFileSpec();
+ tmp.AddBackslash();
+ CString path = tmp;
+
+ WIN32_FIND_DATA fd = {0};
+ HANDLE hFind = FindFirstFile(fullpath, &fd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
+
+ CFilterMapper2 fm2(false);
+ fm2.Register(path + fd.cFileName);
+ while(!fm2.m_filters.IsEmpty())
+ {
+ if(FilterOverride* f = fm2.m_filters.RemoveTail())
+ {
+ f->fTemporary = true;
+
+ bool fFound = false;
+
+ POSITION pos2 = s.filters.GetHeadPosition();
+ while(pos2)
+ {
+ FilterOverride* f2 = s.filters.GetNext(pos2);
+ if(f2->type == FilterOverride::EXTERNAL && !f2->path.CompareNoCase(f->path))
+ {
+ fFound = true;
+ break;
+ }
+ }
+
+ if(!fFound)
+ {
+ CAutoPtr<FilterOverride> p(f);
+ s.filters.AddHead(p);
+ }
+ }
+ }
+ }
+ while(FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+ }
+
+ bool fSetForegroundWindow = false;
+
+ if((s.nCLSwitches&CLSW_DVD) && !s.slFiles.IsEmpty())
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if(p) {p->path = s.slFiles.GetHead(); p->subs.AddTailList(&s.slSubs);}
+ OpenMedia(p);
+ }
+ else if(s.nCLSwitches&CLSW_CD)
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ CAtlList<CString> sl;
+
+ if(!s.slFiles.IsEmpty())
+ {
+ GetCDROMType(s.slFiles.GetHead()[0], sl);
+ }
+ else
+ {
+ CString dir;
+ dir.ReleaseBufferSetLength(GetCurrentDirectory(MAX_PATH, dir.GetBuffer(MAX_PATH)));
+
+ GetCDROMType(dir[0], sl);
+
+ for(TCHAR drive = 'C'; sl.IsEmpty() && drive <= 'Z'; drive++)
+ {
+ GetCDROMType(drive, sl);
+ }
+ }
+
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
+ }
+ else if(!s.slFiles.IsEmpty())
+ {
+ bool fMulti = s.slFiles.GetCount() > 1;
+
+ CAtlList<CString> sl;
+ sl.AddTailList(&s.slFiles);
+ if(!fMulti) sl.AddTailList(&s.slDubs);
+
+ CString dvd_path = s.slFiles.GetHead() + _T("\\VIDEO_TS");
+ if((!fMulti) && (is_dir(dvd_path)))
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if(p) {p->path = s.slFiles.GetHead(); p->subs.AddTailList(&s.slSubs);}
+ OpenMedia(p);
+ }
+ else
+ {
+
+ if(last_run && ((GetTickCount()-last_run)<500)) s.nCLSwitches |= CLSW_ADD;
+ last_run = GetTickCount();
+
+ if((s.nCLSwitches&CLSW_ADD) && m_wndPlaylistBar.GetCount() > 0)
+ {
+ m_wndPlaylistBar.Append(sl, fMulti, &s.slSubs);
+
+ if(s.nCLSwitches&(CLSW_OPEN|CLSW_PLAY))
+ {
+ m_wndPlaylistBar.SetLast();
+ OpenCurPlaylistItem();
+ }
+ }
+ else
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ m_wndPlaylistBar.Open(sl, fMulti, &s.slSubs);
+ OpenCurPlaylistItem((s.nCLSwitches&CLSW_STARTVALID) ? s.rtStart : 0);
+
+ s.nCLSwitches &= ~CLSW_STARTVALID;
+ s.rtStart = 0;
+ }
+ }
+ }
+ else
+ {
+ s.nCLSwitches = CLSW_NONE;
+ }
+
+ if(fSetForegroundWindow && !(s.nCLSwitches&CLSW_NOFOCUS))
+ SetForegroundWindow();
+
+ s.nCLSwitches &= ~CLSW_NOFOCUS;
+
+ return TRUE;
+}
+
+int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
+{
+ switch(uMsg)
+ {
+ case BFFM_INITIALIZED:
//Initial directory is set here
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)AfxGetAppSettings().sDVDPath);
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE,(LPARAM)(LPCTSTR)AfxGetAppSettings().sDVDPath);
break;
default:
break;
@@ -4007,356 +3932,327 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
void CMainFrame::OnFileOpendvd()
{
- if((m_iMediaLoadState == MLS_LOADING) || m_pFullscreenWnd->IsWindow()) return;
+ if ((m_iMediaLoadState == MLS_LOADING) || m_pFullscreenWnd->IsWindow()) return;
- /*
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- SetForegroundWindow();
+ /*
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SetForegroundWindow();
- ShowWindow(SW_SHOW);
+ ShowWindow(SW_SHOW);
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if(p)
- {
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if(p)
+ {
AppSettings& s = AfxGetAppSettings();
- if(s.fUseDVDPath && !s.sDVDPath.IsEmpty())
- {
- p->path = s.sDVDPath;
- p->path.Replace('/', '\\');
- if(p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
- }
- }
- OpenMedia(p);*/
-
- AppSettings& s = AfxGetAppSettings();
- TCHAR path[_MAX_PATH];
-
- CString strTitle = ResStr(IDS_MAINFRM_46);
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = path;
- bi.lpszTitle = strTitle;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
- bi.lpfn = BrowseCallbackProc;
- bi.lParam = 0;
- bi.iImage = 0;
-
- static LPITEMIDLIST iil;
-
- if(iil = SHBrowseForFolder(&bi))
- {
- CHdmvClipInfo ClipInfo;
- CString strPlaylistFile;
- CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
- SHGetPathFromIDList(iil, path);
- s.sDVDPath = path;
-
- if(SUCCEEDED(ClipInfo.FindMainMovie(path, strPlaylistFile, MainPlaylist)))
- {
- CAutoPtr<OpenFileData> p(DNew OpenFileData());
- p->fns.AddTail(strPlaylistFile);
- OpenMedia(p);
- }
- else
- {
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- p->path = path;
- p->path.Replace('/', '\\');
- if(p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
-
- OpenMedia(p);
- }
- }
+ if(s.fUseDVDPath && !s.sDVDPath.IsEmpty())
+ {
+ p->path = s.sDVDPath;
+ p->path.Replace('/', '\\');
+ if(p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
+ }
+ }
+ OpenMedia(p);*/
+
+ AppSettings& s = AfxGetAppSettings();
+ TCHAR path[_MAX_PATH];
+
+ CString strTitle = ResStr(IDS_MAINFRM_46);
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = path;
+ bi.lpszTitle = strTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
+ bi.lpfn = BrowseCallbackProc;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ static LPITEMIDLIST iil;
+
+ if(iil = SHBrowseForFolder(&bi))
+ {
+ CHdmvClipInfo ClipInfo;
+ CString strPlaylistFile;
+ CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
+ SHGetPathFromIDList(iil, path);
+ s.sDVDPath = path;
+
+ if (SUCCEEDED (ClipInfo.FindMainMovie (path, strPlaylistFile, MainPlaylist)))
+ {
+ CAutoPtr<OpenFileData> p(DNew OpenFileData());
+ p->fns.AddTail(strPlaylistFile);
+ OpenMedia(p);
+ }
+ else
+ {
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ p->path = path;
+ p->path.Replace('/', '\\');
+ if(p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
+
+ OpenMedia(p);
+ }
+ }
}
void CMainFrame::OnFileOpendevice()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if(m_iMediaLoadState == MLS_LOADING) return;
+ if(m_iMediaLoadState == MLS_LOADING) return;
- //COpenCapDeviceDlg capdlg;
- //if(capdlg.DoModal() != IDOK)
- // return;
+ //COpenCapDeviceDlg capdlg;
+ //if(capdlg.DoModal() != IDOK)
+ // return;
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- SetForegroundWindow();
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SetForegroundWindow();
- ShowWindow(SW_SHOW);
+ ShowWindow(SW_SHOW);
- m_wndPlaylistBar.Empty();
+ m_wndPlaylistBar.Empty();
- CAutoPtr<OpenDeviceData> p(DNew OpenDeviceData());
- if(p)
- {
- p->DisplayName[0] = s.strAnalogVideo;
- p->DisplayName[1] = s.strAnalogAudio;
- }
- OpenMedia(p);
+ CAutoPtr<OpenDeviceData> p(DNew OpenDeviceData());
+ if(p) {p->DisplayName[0] = s.strAnalogVideo; p->DisplayName[1] = s.strAnalogAudio;}
+ OpenMedia(p);
}
void CMainFrame::OnFileOpenCD(UINT nID)
{
- nID -= ID_FILE_OPEN_CD_START;
+ nID -= ID_FILE_OPEN_CD_START;
- nID++;
- for(TCHAR drive = 'C'; drive <= 'Z'; drive++)
- {
- CAtlList<CString> sl;
+ nID++;
+ for(TCHAR drive = 'C'; drive <= 'Z'; drive++)
+ {
+ CAtlList<CString> sl;
- switch(GetCDROMType(drive, sl))
- {
- case CDROM_Audio:
- case CDROM_VideoCD:
- case CDROM_DVDVideo:
- nID--;
- break;
- default:
- break;
- }
+ switch(GetCDROMType(drive, sl))
+ {
+ case CDROM_Audio:
+ case CDROM_VideoCD:
+ case CDROM_DVDVideo:
+ nID--;
+ break;
+ default:
+ break;
+ }
- if(nID == 0)
- {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- SetForegroundWindow();
+ if(nID == 0)
+ {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SetForegroundWindow();
- ShowWindow(SW_SHOW);
+ ShowWindow(SW_SHOW);
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
- break;
- }
- }
+ break;
+ }
+ }
}
void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
- SetForegroundWindow();
+ SetForegroundWindow();
- if(m_wndPlaylistBar.IsWindowVisible())
- {
- m_wndPlaylistBar.OnDropFiles(hDropInfo);
- return;
- }
+ if(m_wndPlaylistBar.IsWindowVisible())
+ {
+ m_wndPlaylistBar.OnDropFiles(hDropInfo);
+ return;
+ }
- CAtlList<CString> sl;
+ CAtlList<CString> sl;
- UINT nFiles = ::DragQueryFile(hDropInfo, (UINT) - 1, NULL, 0);
+ UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
- for(UINT iFile = 0; iFile < nFiles; iFile++)
- {
- CString fn;
- fn.ReleaseBuffer(::DragQueryFile(hDropInfo, iFile, fn.GetBuffer(MAX_PATH), MAX_PATH));
- sl.AddTail(fn);
- }
+ for(UINT iFile = 0; iFile < nFiles; iFile++)
+ {
+ CString fn;
+ fn.ReleaseBuffer(::DragQueryFile(hDropInfo, iFile, fn.GetBuffer(MAX_PATH), MAX_PATH));
+ sl.AddTail(fn);
+ }
- ::DragFinish(hDropInfo);
+ ::DragFinish(hDropInfo);
- if(sl.IsEmpty()) return;
+ if(sl.IsEmpty()) return;
- if(sl.GetCount() == 1 && m_iMediaLoadState == MLS_LOADED && m_pCAP)
- {
- ISubStream *pSubStream = NULL;
- if(LoadSubtitle(sl.GetHead(), &pSubStream))
- {
- SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
- CPath p(sl.GetHead());
- p.StripPath();
- SendStatusMessage(CString((LPCTSTR)p) + ResStr(IDS_MAINFRM_47), 3000);
- return;
- }
- }
+ if(sl.GetCount() == 1 && m_iMediaLoadState == MLS_LOADED && m_pCAP)
+ {
+ ISubStream *pSubStream = NULL;
+ if(LoadSubtitle(sl.GetHead(), &pSubStream))
+ {
+ SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
+ CPath p(sl.GetHead());
+ p.StripPath();
+ SendStatusMessage(CString((LPCTSTR)p) + ResStr(IDS_MAINFRM_47), 3000);
+ return;
+ }
+ }
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
}
void CMainFrame::OnFileSaveAs()
{
- CString ext, in = m_wndPlaylistBar.GetCur(), out = in;
+ CString ext, in = m_wndPlaylistBar.GetCur(), out = in;
- if(out.Find(_T("://")) < 0)
- {
- ext = CString(CPath(out).GetExtension()).MakeLower();
- if(ext == _T(".cda")) out = out.Left(out.GetLength() - 4) + _T(".wav");
- else if(ext == _T(".ifo")) out = out.Left(out.GetLength() - 4) + _T(".vob");
- }
- else
- {
- out.Empty();
- }
+ if(out.Find(_T("://")) < 0)
+ {
+ ext = CString(CPath(out).GetExtension()).MakeLower();
+ if(ext == _T(".cda")) out = out.Left(out.GetLength()-4) + _T(".wav");
+ else if(ext == _T(".ifo")) out = out.Left(out.GetLength()-4) + _T(".vob");
+ }
+ else
+ {
+ out.Empty();
+ }
- CFileDialog fd(FALSE, 0, out,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
- ResStr(IDS_MAINFRM_48), GetModalParent(), 0);
- if(fd.DoModal() != IDOK || !in.CompareNoCase(fd.GetPathName())) return;
+ CFileDialog fd(FALSE, 0, out,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
+ ResStr(IDS_MAINFRM_48), GetModalParent(), 0);
+ if(fd.DoModal() != IDOK || !in.CompareNoCase(fd.GetPathName())) return;
- CPath p(fd.GetPathName());
- if(!ext.IsEmpty()) p.AddExtension(ext);
+ CPath p(fd.GetPathName());
+ if(!ext.IsEmpty()) p.AddExtension(ext);
- OAFilterState fs = State_Stopped;
- pMC->GetState(0, &fs);
- if(fs == State_Running) pMC->Pause();
+ OAFilterState fs = State_Stopped;
+ pMC->GetState(0, &fs);
+ if(fs == State_Running) pMC->Pause();
- CSaveDlg dlg(in, p);
- dlg.DoModal();
+ CSaveDlg dlg(in, p);
+ dlg.DoModal();
- if(fs == State_Running) pMC->Run();
+ if(fs == State_Running) pMC->Run();
}
void CMainFrame::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
{
- if(m_iMediaLoadState != MLS_LOADED || m_iPlaybackMode != PM_FILE)
- {
- pCmdUI->Enable(FALSE);
- return;
- }
+ if(m_iMediaLoadState != MLS_LOADED || m_iPlaybackMode != PM_FILE)
+ {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
CString fn = m_wndPlaylistBar.GetCur();
- CString ext = fn.Mid(fn.ReverseFind('.') + 1).MakeLower();
+ CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
- if(fn.Find(_T("://")) >= 0)
- {
- pCmdUI->Enable(FALSE);
- return;
- }
+ if(fn.Find(_T("://")) >= 0)
+ {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
- if((GetVersion() & 0x80000000) && (ext == _T("cda") || ext == _T("ifo")))
- {
- pCmdUI->Enable(FALSE);
- return;
- }
+ if((GetVersion()&0x80000000) && (ext == _T("cda") || ext == _T("ifo")))
+ {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
- pCmdUI->Enable(TRUE);
+ pCmdUI->Enable(TRUE);
}
bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent)
{
- if(!ppData) return false;
+ if(!ppData) return false;
- *ppData = NULL;
- size = 0;
+ *ppData = NULL;
+ size = 0;
- bool fNeedsToPause = !m_pCAP;
- if(fNeedsToPause) fNeedsToPause = !IsVMR7InGraph(pGB);
- if(fNeedsToPause) fNeedsToPause = !IsVMR9InGraph(pGB);
+ bool fNeedsToPause = !m_pCAP;
+ if(fNeedsToPause) fNeedsToPause = !IsVMR7InGraph(pGB);
+ if(fNeedsToPause) fNeedsToPause = !IsVMR9InGraph(pGB);
- OAFilterState fs = GetMediaState();
+ OAFilterState fs = GetMediaState();
- if(!(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running)))
- return false;
+ if(!(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running)))
+ return false;
- if(fs == State_Running && fNeedsToPause)
- {
- pMC->Pause();
- GetMediaState(); // wait for completion of the pause command
- }
+ if(fs == State_Running && fNeedsToPause)
+ {
+ pMC->Pause();
+ GetMediaState(); // wait for completion of the pause command
+ }
- HRESULT hr = S_OK;
- CString errmsg;
+ HRESULT hr = S_OK;
+ CString errmsg;
- do
- {
- if(m_pCAP)
- {
- hr = m_pCAP->GetDIB(NULL, (DWORD*)&size);
- if(FAILED(hr))
- {
- errmsg.Format(ResStr(IDS_MAINFRM_49), hr);
- break;
- }
+ do
+ {
+ if(m_pCAP)
+ {
+ hr = m_pCAP->GetDIB(NULL, (DWORD*)&size);
+ if(FAILED(hr)) {errmsg.Format(ResStr(IDS_MAINFRM_49), hr); break;}
- if(!(*ppData = DNew BYTE[size])) return false;
+ if(!(*ppData = DNew BYTE[size])) return false;
- hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
+ hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
// if(FAILED(hr)) {errmsg.Format(_T("GetDIB failed, hr = %08x"), hr); break;}
- if(FAILED(hr))
- {
- OnPlayPause();
- GetMediaState(); // Pause and retry to support ffdshow queueing.
- int retry = 0;
- while(FAILED(hr) && retry < 20)
- {
- hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
- if(SUCCEEDED(hr)) break;
- Sleep(1);
- retry++;
- }
- if(FAILED(hr))
- {
- errmsg.Format(ResStr(IDS_MAINFRM_49), hr);
- break;
- }
- }
- }
- else if(m_pMFVDC)
- {
- // Capture with EVR
- BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER)};
- BYTE* pDib;
- DWORD dwSize;
- REFERENCE_TIME rtImage = 0;
- hr = m_pMFVDC->GetCurrentImage(&bih, &pDib, &dwSize, &rtImage);
- if(FAILED(hr) || dwSize == 0)
- {
- errmsg.Format(ResStr(IDS_MAINFRM_51), hr);
- break;
- }
-
- size = (long)dwSize + sizeof(BITMAPINFOHEADER);
- if(!(*ppData = DNew BYTE[size])) return false;
- memcpy_s(*ppData, size, &bih, sizeof(BITMAPINFOHEADER));
- memcpy_s(*ppData + sizeof(BITMAPINFOHEADER), size - sizeof(BITMAPINFOHEADER), pDib, dwSize);
- CoTaskMemFree(pDib);
- }
- else
- {
- hr = pBV->GetCurrentImage(&size, NULL);
- if(FAILED(hr) || size == 0)
- {
- errmsg.Format(ResStr(IDS_MAINFRM_51), hr);
- break;
- }
-
- if(!(*ppData = DNew BYTE[size])) return false;
-
- hr = pBV->GetCurrentImage(&size, (long*) * ppData);
- if(FAILED(hr))
- {
- errmsg.Format(ResStr(IDS_MAINFRM_51), hr);
- break;
- }
- }
- }
- while(0);
-
- if(!fSilent)
- {
- if(!errmsg.IsEmpty())
- {
- AfxMessageBox(errmsg, MB_OK);
- }
- }
-
- if(fs == State_Running && GetMediaState() != State_Running)
- {
- pMC->Run();
- }
-
- if(FAILED(hr))
- {
- if(*ppData)
- {
- ASSERT(0); // huh?
- delete [] *ppData;
- *ppData = NULL;
- }
- return false;
- }
-
- return true;
+ if(FAILED(hr))
+ {
+ OnPlayPause();GetMediaState(); // Pause and retry to support ffdshow queueing.
+ int retry = 0;
+ while(FAILED(hr) && retry < 20)
+ {
+ hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
+ if(SUCCEEDED(hr)) break;
+ Sleep(1);
+ retry++;
+ }
+ if(FAILED(hr))
+ {errmsg.Format(ResStr(IDS_MAINFRM_49), hr); break;}
+ }
+ }
+ else if (m_pMFVDC)
+ {
+ // Capture with EVR
+ BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER)};
+ BYTE* pDib;
+ DWORD dwSize;
+ REFERENCE_TIME rtImage = 0;
+ hr = m_pMFVDC->GetCurrentImage (&bih, &pDib, &dwSize, &rtImage);
+ if(FAILED(hr) || dwSize == 0) {errmsg.Format(ResStr(IDS_MAINFRM_51), hr); break;}
+
+ size = (long)dwSize+sizeof(BITMAPINFOHEADER);
+ if(!(*ppData = DNew BYTE[size])) return false;
+ memcpy_s (*ppData, size, &bih, sizeof(BITMAPINFOHEADER));
+ memcpy_s (*ppData+sizeof(BITMAPINFOHEADER), size-sizeof(BITMAPINFOHEADER), pDib, dwSize);
+ CoTaskMemFree (pDib);
+ }
+ else
+ {
+ hr = pBV->GetCurrentImage(&size, NULL);
+ if(FAILED(hr) || size == 0) {errmsg.Format(ResStr(IDS_MAINFRM_51), hr); break;}
+
+ if(!(*ppData = DNew BYTE[size])) return false;
+
+ hr = pBV->GetCurrentImage(&size, (long*)*ppData);
+ if(FAILED(hr)) {errmsg.Format(ResStr(IDS_MAINFRM_51), hr); break;}
+ }
+ }
+ while(0);
+
+ if(!fSilent)
+ {
+ if(!errmsg.IsEmpty())
+ {
+ AfxMessageBox(errmsg, MB_OK);
+ }
+ }
+
+ if(fs == State_Running && GetMediaState() != State_Running)
+ {
+ pMC->Run();
+ }
+
+ if(FAILED(hr))
+ {
+ if(*ppData) {ASSERT(0); delete [] *ppData; *ppData = NULL;} // huh?
+ return false;
+ }
+
+ return true;
}
#include "jpeg.h"
@@ -4364,712 +4260,692 @@ bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent)
void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size)
{
- CString ext = CString(CPath(fn).GetExtension()).MakeLower();
-
- if(ext == _T(".bmp"))
- {
- if(FILE* f = _tfopen(fn, _T("wb")))
- {
- BITMAPINFO* bi = (BITMAPINFO*)pData;
-
- BITMAPFILEHEADER bfh;
- bfh.bfType = 'MB';
- bfh.bfOffBits = sizeof(bfh) + sizeof(bi->bmiHeader);
- bfh.bfSize = sizeof(bfh) + size;
- bfh.bfReserved1 = bfh.bfReserved2 = 0;
-
- if(bi->bmiHeader.biBitCount <= 8)
- {
- if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
- }
-
- fwrite(&bfh, 1, sizeof(bfh), f);
- fwrite(pData, 1, size, f);
-
- fclose(f);
- }
- else
- {
- AfxMessageBox(ResStr(IDS_MAINFRM_53), MB_OK);
- }
- }
- else if(ext == _T(".png"))
- {
- DWORD bmpsize = size;
- LPBITMAPINFOHEADER pdib;
- LPBITMAPFILEHEADER pbmfh;
- void *pbits;
- PNGDIB *pngdib;
- int ret;
-
- BITMAPINFO* bi = (BITMAPINFO*)pData;
-
- BITMAPFILEHEADER bfh;
- bfh.bfType = 'MB';
- bfh.bfOffBits = sizeof(bfh) + sizeof(bi->bmiHeader);
- bfh.bfSize = sizeof(bfh) + size;
- bfh.bfReserved1 = bfh.bfReserved2 = 0;
-
- if(bi->bmiHeader.biBitCount <= 8)
- {
- if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
- }
- pbmfh = (LPBITMAPFILEHEADER)&bfh;
- pbits = &pData[pbmfh->bfOffBits-sizeof(bfh)];
- pdib = (LPBITMAPINFOHEADER)pData;
- pngdib = pngdib_d2p_init();
- pngdib_d2p_set_dib(pngdib, pdib, bmpsize, pbits, 0);
- pngdib_d2p_set_png_filename(pngdib, fn);
- pngdib_d2p_set_gamma_label(pngdib, 1, PNGDIB_DEFAULT_FILE_GAMMA);
- ret = pngdib_d2p_run(pngdib);
- pngdib_done(pngdib);
- if(ret)
- {
- CString err_str;
- err_str.Format(_T("%s\n%s (%d)"), IDS_MAINFRM_53, pngdib_get_error_msg(pngdib), ret);
- AfxMessageBox(err_str, MB_OK);
- }
- }
- else if(ext == _T(".jpg"))
- {
- CJpegEncoderFile(fn).Encode(pData);
- }
-
- CPath p(fn);
-
- if(CDC* pDC = m_wndStatusBar.m_status.GetDC())
- {
- CRect r;
- m_wndStatusBar.m_status.GetClientRect(r);
- p.CompactPath(pDC->m_hDC, r.Width());
- m_wndStatusBar.m_status.ReleaseDC(pDC);
- }
-
- SendStatusMessage((LPCTSTR)p, 3000);
+ CString ext = CString(CPath(fn).GetExtension()).MakeLower();
+
+ if(ext == _T(".bmp"))
+ {
+ if(FILE* f = _tfopen(fn, _T("wb")))
+ {
+ BITMAPINFO* bi = (BITMAPINFO*)pData;
+
+ BITMAPFILEHEADER bfh;
+ bfh.bfType = 'MB';
+ bfh.bfOffBits = sizeof(bfh) + sizeof(bi->bmiHeader);
+ bfh.bfSize = sizeof(bfh) + size;
+ bfh.bfReserved1 = bfh.bfReserved2 = 0;
+
+ if(bi->bmiHeader.biBitCount <= 8)
+ {
+ if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
+ else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ }
+
+ fwrite(&bfh, 1, sizeof(bfh), f);
+ fwrite(pData, 1, size, f);
+
+ fclose(f);
+ }
+ else
+ {
+ AfxMessageBox(ResStr(IDS_MAINFRM_53), MB_OK);
+ }
+ }
+ else if(ext == _T(".png"))
+ {
+ DWORD bmpsize = size;
+ LPBITMAPINFOHEADER pdib;
+ LPBITMAPFILEHEADER pbmfh;
+ void *pbits;
+ PNGDIB *pngdib;
+ int ret;
+
+ BITMAPINFO* bi = (BITMAPINFO*)pData;
+
+ BITMAPFILEHEADER bfh;
+ bfh.bfType = 'MB';
+ bfh.bfOffBits = sizeof(bfh) + sizeof(bi->bmiHeader);
+ bfh.bfSize = sizeof(bfh) + size;
+ bfh.bfReserved1 = bfh.bfReserved2 = 0;
+
+ if(bi->bmiHeader.biBitCount <= 8)
+ {
+ if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
+ else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ }
+ pbmfh = (LPBITMAPFILEHEADER)&bfh;
+ pbits = &pData[pbmfh->bfOffBits-sizeof(bfh)];
+ pdib = (LPBITMAPINFOHEADER)pData;
+ pngdib = pngdib_d2p_init();
+ pngdib_d2p_set_dib(pngdib,pdib,bmpsize,pbits,0);
+ pngdib_d2p_set_png_filename(pngdib, fn);
+ pngdib_d2p_set_gamma_label(pngdib, 1, PNGDIB_DEFAULT_FILE_GAMMA);
+ ret = pngdib_d2p_run(pngdib);
+ pngdib_done(pngdib);
+ if(ret) {
+ CString err_str;
+ err_str.Format(_T("%s\n%s (%d)"), IDS_MAINFRM_53, pngdib_get_error_msg(pngdib), ret);
+ AfxMessageBox(err_str, MB_OK);
+ }
+ }
+ else if(ext == _T(".jpg"))
+ {
+ CJpegEncoderFile(fn).Encode(pData);
+ }
+
+ CPath p(fn);
+
+ if(CDC* pDC = m_wndStatusBar.m_status.GetDC())
+ {
+ CRect r;
+ m_wndStatusBar.m_status.GetClientRect(r);
+ p.CompactPath(pDC->m_hDC, r.Width());
+ m_wndStatusBar.m_status.ReleaseDC(pDC);
+ }
+
+ SendStatusMessage((LPCTSTR)p, 3000);
}
void CMainFrame::SaveImage(LPCTSTR fn)
{
- BYTE* pData = NULL;
- long size = 0;
+ BYTE* pData = NULL;
+ long size = 0;
- if(GetDIB(&pData, size))
- {
- SaveDIB(fn, pData, size);
- delete [] pData;
- }
+ if(GetDIB(&pData, size))
+ {
+ SaveDIB(fn, pData, size);
+ delete [] pData;
+ }
}
void CMainFrame::SaveThumbnails(LPCTSTR fn)
{
- if(!pMC || !pMS || m_iPlaybackMode != PM_FILE /*&& m_iPlaybackMode != PM_DVD*/)
- return;
+ if(!pMC || !pMS || m_iPlaybackMode != PM_FILE /*&& m_iPlaybackMode != PM_DVD*/)
+ return;
+
+ REFERENCE_TIME rtPos = GetPos();
+ REFERENCE_TIME rtDur = GetDur();
+
+ if(rtDur <= 0)
+ {
+ AfxMessageBox(ResStr(IDS_MAINFRM_54));
+ return;
+ }
+
+ pMC->Pause();
+ GetMediaState(); // wait for completion of the pause command
+
+ //
+
+ CSize video, wh(0, 0), arxy(0, 0);
+
+ if (m_pMFVDC)
+ {
+ m_pMFVDC->GetNativeVideoSize(&wh, &arxy);
+ }
+ else if(m_pCAP)
+ {
+ wh = m_pCAP->GetVideoSize(false);
+ arxy = m_pCAP->GetVideoSize(true);
+ }
+ else
+ {
+ pBV->GetVideoSize(&wh.cx, &wh.cy);
+
+ long arx = 0, ary = 0;
+ CComQIPtr<IBasicVideo2> pBV2 = pBV;
+ if(pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0)
+ arxy.SetSize(arx, ary);
+ }
+
+ if(wh.cx <= 0 || wh.cy <= 0)
+ {
+ AfxMessageBox(ResStr(IDS_MAINFRM_55));
+ return;
+ }
+
+ // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
+ DVD_VideoAttributes VATR;
+ if(m_iPlaybackMode == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR)))
+ arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
+
+ video = (arxy.cx <= 0 || arxy.cy <= 0) ? wh : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
+
+ //
+
+ AppSettings& s = AfxGetAppSettings();
+
+ int cols = max (1, min (8, s.ThumbCols)), rows = max(1, min (8, s.ThumbRows));
+
+ int margin = 5;
+ int infoheight = 70;
+ int width = max (256, min (2048, s.ThumbWidth));
+ int height = width * video.cy / video.cx * rows / cols + infoheight;
+
+ int dibsize = sizeof(BITMAPINFOHEADER) + width*height*4;
+
+ CAutoVectorPtr<BYTE> dib;
+ if(!dib.Allocate(dibsize))
+ {
+ AfxMessageBox(ResStr(IDS_MAINFRM_56));
+ return;
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)(BYTE*)dib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = width;
+ bih->biHeight = height;
+ bih->biPlanes = 1;
+ bih->biBitCount = 32;
+ bih->biCompression = BI_RGB;
+ bih->biSizeImage = width*height*4;
+ memsetd(bih + 1, 0xffffff, bih->biSizeImage);
+
+ SubPicDesc spd;
+ spd.w = width;
+ spd.h = height;
+ spd.bpp = 32;
+ spd.pitch = -width*4;
+ spd.vidrect = CRect(0, 0, width, height);
+ spd.bits = (BYTE*)(bih + 1) + (width*4)*(height-1);
+
+ {
+ BYTE* p = (BYTE*)spd.bits;
+ for(int y = 0; y < spd.h; y++, p += spd.pitch)
+ for(int x = 0; x < spd.w; x++)
+ ((DWORD*)p)[x] = 0x010101 * (0xe0 + 0x08*y/spd.h + 0x18*(spd.w-x)/spd.w);
+ }
+
+ CCritSec csSubLock;
+ RECT bbox;
+
+ for(int i = 1, pics = cols*rows; i <= pics; i++)
+ {
+ REFERENCE_TIME rt = rtDur * i / (pics+1);
+ DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt, 25);
+
+ SeekTo(rt);
+
+ m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
+ pBA->put_Volume(-10000);
+
+ HRESULT hr = pFS ? pFS->Step(1, NULL) : E_FAIL;
+
+ if(FAILED(hr))
+ {
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ AfxMessageBox(_T("Cannot frame step, try a different video renderer."));
+ return;
+ }
+
+ HANDLE hGraphEvent = NULL;
+ pME->GetEventHandle((OAEVENT*)&hGraphEvent);
+
+ while(hGraphEvent && WaitForSingleObject(hGraphEvent, INFINITE) == WAIT_OBJECT_0)
+ {
+ LONG evCode = 0, evParam1, evParam2;
+ while(SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0)))
+ {
+ pME->FreeEventParams(evCode, evParam1, evParam2);
+ if(EC_STEP_COMPLETE == evCode) hGraphEvent = NULL;
+ }
+ }
+
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+
+ int col = (i-1)%cols;
+ int row = (i-1)/cols;
+
+ CSize s((width-margin*2)/cols, (height-margin*2-infoheight)/rows);
+ CPoint p(margin+col*s.cx, margin+row*s.cy+infoheight);
+ CRect r(p, s);
+ r.DeflateRect(margin, margin);
+
+ CRenderedTextSubtitle rts(&csSubLock);
+ rts.CreateDefaultStyle(0);
+ rts.m_dstScreenSize.SetSize(width, height);
+ STSStyle* style = DNew STSStyle();
+ style->marginRect.SetRectEmpty();
+ rts.AddStyle(_T("thumbs"), style);
+
+ CStringW str;
+ str.Format(L"{\\an7\\1c&Hffffff&\\4a&Hb0&\\bord1\\shad4\\be1}{\\p1}m %d %d l %d %d %d %d %d %d{\\p}",
+ r.left, r.top, r.right, r.top, r.right, r.bottom, r.left, r.bottom);
+ rts.Add(str, true, 0, 1, _T("thumbs"));
+ str.Format(L"{\\an3\\1c&Hffffff&\\3c&H000000&\\alpha&H80&\\fs16\\b1\\bord2\\shad0\\pos(%d,%d)}%02d:%02d:%02d",
+ r.right-5, r.bottom-3, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
+ rts.Add(str, true, 1, 2, _T("thumbs"));
+
+ rts.Render(spd, 0, 25, bbox);
+
+ BYTE* pData = NULL;
+ long size = 0;
+ if(!GetDIB(&pData, size)) return;
+
+ BITMAPINFO* bi = (BITMAPINFO*)pData;
+
+ if(bi->bmiHeader.biBitCount != 32)
+ {
+ delete [] pData;
+ CString str;
+ str.Format(ResStr(IDS_MAINFRM_57), bi->bmiHeader.biBitCount);
+ AfxMessageBox(str);
+ return;
+ }
+
+ int sw = bi->bmiHeader.biWidth;
+ int sh = abs(bi->bmiHeader.biHeight);
+ int sp = sw*4;
+ const BYTE* src = pData + sizeof(bi->bmiHeader);
+ if(bi->bmiHeader.biHeight >= 0) {src += sp*(sh-1); sp = -sp;}
+
+ int dw = spd.w;
+ int dh = spd.h;
+ int dp = spd.pitch;
+ BYTE* dst = (BYTE*)spd.bits + spd.pitch*r.top + r.left*4;
+
+ for(DWORD h = r.bottom - r.top, y = 0, yd = (sh<<8)/h; h > 0; y += yd, h--)
+ {
+ DWORD yf = y&0xff;
+ DWORD yi = y>>8;
+
+ DWORD* s0 = (DWORD*)(src + (int)yi*sp);
+ DWORD* s1 = (DWORD*)(src + (int)yi*sp + sp);
+ DWORD* d = (DWORD*)dst;
+
+ for(DWORD w = r.right - r.left, x = 0, xd = (sw<<8)/w; w > 0; x += xd, w--)
+ {
+ DWORD xf = x&0xff;
+ DWORD xi = x>>8;
+
+ DWORD c0 = s0[xi];
+ DWORD c1 = s0[xi+1];
+ DWORD c2 = s1[xi];
+ DWORD c3 = s1[xi+1];
+
+ c0 = ((c0&0xff00ff) + ((((c1&0xff00ff) - (c0&0xff00ff)) * xf) >> 8)) & 0xff00ff
+ | ((c0&0x00ff00) + ((((c1&0x00ff00) - (c0&0x00ff00)) * xf) >> 8)) & 0x00ff00;
+
+ c2 = ((c2&0xff00ff) + ((((c3&0xff00ff) - (c2&0xff00ff)) * xf) >> 8)) & 0xff00ff
+ | ((c2&0x00ff00) + ((((c3&0x00ff00) - (c2&0x00ff00)) * xf) >> 8)) & 0x00ff00;
+
+ c0 = ((c0&0xff00ff) + ((((c2&0xff00ff) - (c0&0xff00ff)) * yf) >> 8)) & 0xff00ff
+ | ((c0&0x00ff00) + ((((c2&0x00ff00) - (c0&0x00ff00)) * yf) >> 8)) & 0x00ff00;
+
+ *d++ = c0;
+ }
+
+ dst += dp;
+ }
+
+ rts.Render(spd, 10000, 25, bbox);
+
+ delete [] pData;
+ }
+
+ {
+ CRenderedTextSubtitle rts(&csSubLock);
+ rts.CreateDefaultStyle(0);
+ rts.m_dstScreenSize.SetSize(width, height);
+ STSStyle* style = DNew STSStyle();
+ style->marginRect.SetRect(margin*2, margin*2, margin*2, height-infoheight-margin);
+ rts.AddStyle(_T("thumbs"), style);
- REFERENCE_TIME rtPos = GetPos();
- REFERENCE_TIME rtDur = GetDur();
+ CStringW str;
+ str.Format(L"{\\an9\\fs%d\\b1\\bord0\\shad0\\1c&Hffffff&}%s", infoheight-10, width >= 550 ? L"Media Player Classic" : L"MPC");
+
+ rts.Add(str, true, 0, 1, _T("thumbs"), _T(""), _T(""), CRect(0,0,0,0), -1);
- if(rtDur <= 0)
- {
- AfxMessageBox(ResStr(IDS_MAINFRM_54));
- return;
- }
-
- pMC->Pause();
- GetMediaState(); // wait for completion of the pause command
-
- //
-
- CSize video, wh(0, 0), arxy(0, 0);
-
- if(m_pMFVDC)
- {
- m_pMFVDC->GetNativeVideoSize(&wh, &arxy);
- }
- else if(m_pCAP)
- {
- wh = m_pCAP->GetVideoSize(false);
- arxy = m_pCAP->GetVideoSize(true);
- }
- else
- {
- pBV->GetVideoSize(&wh.cx, &wh.cy);
-
- long arx = 0, ary = 0;
- CComQIPtr<IBasicVideo2> pBV2 = pBV;
- if(pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0)
- arxy.SetSize(arx, ary);
- }
-
- if(wh.cx <= 0 || wh.cy <= 0)
- {
- AfxMessageBox(ResStr(IDS_MAINFRM_55));
- return;
- }
-
- // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
- DVD_VideoAttributes VATR;
- if(m_iPlaybackMode == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR)))
- arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
-
- video = (arxy.cx <= 0 || arxy.cy <= 0) ? wh : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
-
- //
-
- AppSettings& s = AfxGetAppSettings();
-
- int cols = max(1, min(8, s.ThumbCols)), rows = max(1, min(8, s.ThumbRows));
+ DVD_HMSF_TIMECODE hmsf = RT2HMSF(rtDur, 25);
+
+ CPath path(m_wndPlaylistBar.GetCur());
+ path.StripPath();
+ CStringW fn = (LPCTSTR)path;
+
+ CStringW fs;
+ WIN32_FIND_DATA wfd;
+ HANDLE hFind = FindFirstFile(m_wndPlaylistBar.GetCur(), &wfd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ FindClose(hFind);
- int margin = 5;
- int infoheight = 70;
- int width = max(256, min(2048, s.ThumbWidth));
- int height = width * video.cy / video.cx * rows / cols + infoheight;
+ __int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
+ __int64 shortsize = size;
+ CStringW measure = _T("B");
+ if(shortsize > 10240) shortsize /= 1024, measure = L"KB";
+ if(shortsize > 10240) shortsize /= 1024, measure = L"MB";
+ if(shortsize > 10240) shortsize /= 1024, measure = L"GB";
+ fs.Format(ResStr(IDS_MAINFRM_58), shortsize, measure, size);
+ }
- int dibsize = sizeof(BITMAPINFOHEADER) + width * height * 4;
-
- CAutoVectorPtr<BYTE> dib;
- if(!dib.Allocate(dibsize))
- {
- AfxMessageBox(ResStr(IDS_MAINFRM_56));
- return;
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)(BYTE*)dib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = width;
- bih->biHeight = height;
- bih->biPlanes = 1;
- bih->biBitCount = 32;
- bih->biCompression = BI_RGB;
- bih->biSizeImage = width * height * 4;
- memsetd(bih + 1, 0xffffff, bih->biSizeImage);
-
- SubPicDesc spd;
- spd.w = width;
- spd.h = height;
- spd.bpp = 32;
- spd.pitch = -width * 4;
- spd.vidrect = CRect(0, 0, width, height);
- spd.bits = (BYTE*)(bih + 1) + (width * 4) * (height - 1);
-
- {
- BYTE* p = (BYTE*)spd.bits;
- for(int y = 0; y < spd.h; y++, p += spd.pitch)
- for(int x = 0; x < spd.w; x++)
- ((DWORD*)p)[x] = 0x010101 * (0xe0 + 0x08 * y / spd.h + 0x18 * (spd.w - x) / spd.w);
- }
-
- CCritSec csSubLock;
- RECT bbox;
-
- for(int i = 1, pics = cols * rows; i <= pics; i++)
- {
- REFERENCE_TIME rt = rtDur * i / (pics + 1);
- DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt, 25);
-
- SeekTo(rt);
-
- m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
- pBA->put_Volume(-10000);
-
- HRESULT hr = pFS ? pFS->Step(1, NULL) : E_FAIL;
-
- if(FAILED(hr))
- {
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- AfxMessageBox(_T("Cannot frame step, try a different video renderer."));
- return;
- }
-
- HANDLE hGraphEvent = NULL;
- pME->GetEventHandle((OAEVENT*)&hGraphEvent);
-
- while(hGraphEvent && WaitForSingleObject(hGraphEvent, INFINITE) == WAIT_OBJECT_0)
- {
- LONG evCode = 0, evParam1, evParam2;
- while(SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0)))
- {
- pME->FreeEventParams(evCode, evParam1, evParam2);
- if(EC_STEP_COMPLETE == evCode) hGraphEvent = NULL;
- }
- }
+ CStringW ar;
+ if(arxy.cx > 0 && arxy.cy > 0 && arxy.cx != wh.cx && arxy.cy != wh.cy)
+ ar.Format(L"(%d:%d)", arxy.cx, arxy.cy);
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ str.Format(ResStr(IDS_MAINFRM_59),
+ fn, fs, wh.cx, wh.cy, ar, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
+ rts.Add(str, true, 0, 1, _T("thumbs"));
- int col = (i - 1) % cols;
- int row = (i - 1) / cols;
-
- CSize s((width - margin * 2) / cols, (height - margin * 2 - infoheight) / rows);
- CPoint p(margin + col * s.cx, margin + row * s.cy + infoheight);
- CRect r(p, s);
- r.DeflateRect(margin, margin);
-
- CRenderedTextSubtitle rts(&csSubLock);
- rts.CreateDefaultStyle(0);
- rts.m_dstScreenSize.SetSize(width, height);
- STSStyle* style = DNew STSStyle();
- style->marginRect.SetRectEmpty();
- rts.AddStyle(_T("thumbs"), style);
-
- CStringW str;
- str.Format(L"{\\an7\\1c&Hffffff&\\4a&Hb0&\\bord1\\shad4\\be1}{\\p1}m %d %d l %d %d %d %d %d %d{\\p}",
- r.left, r.top, r.right, r.top, r.right, r.bottom, r.left, r.bottom);
- rts.Add(str, true, 0, 1, _T("thumbs"));
- str.Format(L"{\\an3\\1c&Hffffff&\\3c&H000000&\\alpha&H80&\\fs16\\b1\\bord2\\shad0\\pos(%d,%d)}%02d:%02d:%02d",
- r.right - 5, r.bottom - 3, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
- rts.Add(str, true, 1, 2, _T("thumbs"));
-
- rts.Render(spd, 0, 25, bbox);
-
- BYTE* pData = NULL;
- long size = 0;
- if(!GetDIB(&pData, size)) return;
-
- BITMAPINFO* bi = (BITMAPINFO*)pData;
-
- if(bi->bmiHeader.biBitCount != 32)
- {
- delete [] pData;
- CString str;
- str.Format(ResStr(IDS_MAINFRM_57), bi->bmiHeader.biBitCount);
- AfxMessageBox(str);
- return;
- }
-
- int sw = bi->bmiHeader.biWidth;
- int sh = abs(bi->bmiHeader.biHeight);
- int sp = sw * 4;
- const BYTE* src = pData + sizeof(bi->bmiHeader);
- if(bi->bmiHeader.biHeight >= 0)
- {
- src += sp * (sh - 1);
- sp = -sp;
- }
-
- int dw = spd.w;
- int dh = spd.h;
- int dp = spd.pitch;
- BYTE* dst = (BYTE*)spd.bits + spd.pitch * r.top + r.left * 4;
-
- for(DWORD h = r.bottom - r.top, y = 0, yd = (sh << 8) / h; h > 0; y += yd, h--)
- {
- DWORD yf = y & 0xff;
- DWORD yi = y >> 8;
-
- DWORD* s0 = (DWORD*)(src + (int)yi * sp);
- DWORD* s1 = (DWORD*)(src + (int)yi * sp + sp);
- DWORD* d = (DWORD*)dst;
-
- for(DWORD w = r.right - r.left, x = 0, xd = (sw << 8) / w; w > 0; x += xd, w--)
- {
- DWORD xf = x & 0xff;
- DWORD xi = x >> 8;
-
- DWORD c0 = s0[xi];
- DWORD c1 = s0[xi+1];
- DWORD c2 = s1[xi];
- DWORD c3 = s1[xi+1];
-
- c0 = ((c0 & 0xff00ff) + ((((c1 & 0xff00ff) - (c0 & 0xff00ff)) * xf) >> 8)) & 0xff00ff
- | ((c0 & 0x00ff00) + ((((c1 & 0x00ff00) - (c0 & 0x00ff00)) * xf) >> 8)) & 0x00ff00;
-
- c2 = ((c2 & 0xff00ff) + ((((c3 & 0xff00ff) - (c2 & 0xff00ff)) * xf) >> 8)) & 0xff00ff
- | ((c2 & 0x00ff00) + ((((c3 & 0x00ff00) - (c2 & 0x00ff00)) * xf) >> 8)) & 0x00ff00;
-
- c0 = ((c0 & 0xff00ff) + ((((c2 & 0xff00ff) - (c0 & 0xff00ff)) * yf) >> 8)) & 0xff00ff
- | ((c0 & 0x00ff00) + ((((c2 & 0x00ff00) - (c0 & 0x00ff00)) * yf) >> 8)) & 0x00ff00;
-
- *d++ = c0;
- }
-
- dst += dp;
- }
-
- rts.Render(spd, 10000, 25, bbox);
-
- delete [] pData;
- }
-
- {
- CRenderedTextSubtitle rts(&csSubLock);
- rts.CreateDefaultStyle(0);
- rts.m_dstScreenSize.SetSize(width, height);
- STSStyle* style = DNew STSStyle();
- style->marginRect.SetRect(margin * 2, margin * 2, margin * 2, height - infoheight - margin);
- rts.AddStyle(_T("thumbs"), style);
-
- CStringW str;
- str.Format(L"{\\an9\\fs%d\\b1\\bord0\\shad0\\1c&Hffffff&}%s", infoheight - 10, width >= 550 ? L"Media Player Classic" : L"MPC");
-
- rts.Add(str, true, 0, 1, _T("thumbs"), _T(""), _T(""), CRect(0, 0, 0, 0), -1);
-
- DVD_HMSF_TIMECODE hmsf = RT2HMSF(rtDur, 25);
-
- CPath path(m_wndPlaylistBar.GetCur());
- path.StripPath();
- CStringW fn = (LPCTSTR)path;
-
- CStringW fs;
- WIN32_FIND_DATA wfd;
- HANDLE hFind = FindFirstFile(m_wndPlaylistBar.GetCur(), &wfd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- FindClose(hFind);
-
- __int64 size = (__int64(wfd.nFileSizeHigh) << 32) | wfd.nFileSizeLow;
- __int64 shortsize = size;
- CStringW measure = _T("B");
- if(shortsize > 10240) shortsize /= 1024, measure = L"KB";
- if(shortsize > 10240) shortsize /= 1024, measure = L"MB";
- if(shortsize > 10240) shortsize /= 1024, measure = L"GB";
- fs.Format(ResStr(IDS_MAINFRM_58), shortsize, measure, size);
- }
-
- CStringW ar;
- if(arxy.cx > 0 && arxy.cy > 0 && arxy.cx != wh.cx && arxy.cy != wh.cy)
- ar.Format(L"(%d:%d)", arxy.cx, arxy.cy);
-
- str.Format(ResStr(IDS_MAINFRM_59),
- fn, fs, wh.cx, wh.cy, ar, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
- rts.Add(str, true, 0, 1, _T("thumbs"));
-
- rts.Render(spd, 0, 25, bbox);
- }
+ rts.Render(spd, 0, 25, bbox);
+ }
- SaveDIB(fn, (BYTE*)dib, dibsize);
+ SaveDIB(fn, (BYTE*)dib, dibsize);
- SeekTo(rtPos);
+ SeekTo(rtPos);
}
static CString MakeSnapshotFileName(LPCTSTR prefix)
{
- CTime t = CTime::GetCurrentTime();
- CString fn;
- fn.Format(_T("%s_[%s]%s"), prefix, t.Format(_T("%Y.%m.%d_%H.%M.%S")), AfxGetAppSettings().SnapShotExt);
- return fn;
+ CTime t = CTime::GetCurrentTime();
+ CString fn;
+ fn.Format(_T("%s_[%s]%s"), prefix, t.Format(_T("%Y.%m.%d_%H.%M.%S")), AfxGetAppSettings().SnapShotExt);
+ return fn;
}
BOOL CMainFrame::IsRendererCompatibleWithSaveImage()
{
- BOOL result = TRUE;
- AppSettings& s = AfxGetAppSettings();
-
- if(m_fRealMediaGraph)
- {
- if(s.iRMVideoRendererType == VIDRNDT_RM_DEFAULT)
- {
- AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work with the default video renderer for RealMedia.\nSelect one of the DirectX renderers for RealMedia in MPC's output options and reopen the file."));
- result = FALSE;
- }
- }
- else
- {
- if(m_fQuicktimeGraph)
- {
- if(s.iQTVideoRendererType == VIDRNDT_QT_DEFAULT)
- {
- AfxMessageBox(_T("The 'Save Image and 'Save Thumbnails' functions do not work with the default video renderer for QuickTime.\nSelect one of the DirectX renderers for QuickTime in MPC's output options and reopen the file."));
- result = FALSE;
- }
- }
- else
- {
- if(m_fShockwaveGraph)
- {
- AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work for Shockwave files."));
- result = FALSE;
- }
- else
- {
- if(s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER)
- {
- AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work with the Overlay Mixer video renderer.\nChange the video renderer in MPC's output options and reopen the file."));
- result = FALSE;
- }
- }
- }
- }
- return result;
+ BOOL result = TRUE;
+ AppSettings& s = AfxGetAppSettings();
+
+ if(m_fRealMediaGraph) {
+ if(s.iRMVideoRendererType == VIDRNDT_RM_DEFAULT) {
+ AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work with the default video renderer for RealMedia.\nSelect one of the DirectX renderers for RealMedia in MPC's output options and reopen the file."));
+ result = FALSE;
+ }
+ } else {
+ if(m_fQuicktimeGraph) {
+ if(s.iQTVideoRendererType == VIDRNDT_QT_DEFAULT) {
+ AfxMessageBox(_T("The 'Save Image and 'Save Thumbnails' functions do not work with the default video renderer for QuickTime.\nSelect one of the DirectX renderers for QuickTime in MPC's output options and reopen the file."));
+ result = FALSE;
+ }
+ } else {
+ if(m_fShockwaveGraph) {
+ AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work for Shockwave files."));
+ result = FALSE;
+ } else {
+ if(s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER) {
+ AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work with the Overlay Mixer video renderer.\nChange the video renderer in MPC's output options and reopen the file."));
+ result = FALSE;
+ }
+ }
+ }
+ }
+ return result;
}
CString CMainFrame::GetVidPos()
{
- CString posstr = _T("");
- if((m_iPlaybackMode == PM_FILE) || (m_iPlaybackMode == PM_DVD))
- {
- __int64 start, stop, pos;
- m_wndSeekBar.GetRange(start, stop);
- pos = m_wndSeekBar.GetPosReal();
+ CString posstr = _T("");
+ if((m_iPlaybackMode == PM_FILE) || (m_iPlaybackMode == PM_DVD))
+ {
+ __int64 start, stop, pos;
+ m_wndSeekBar.GetRange(start, stop);
+ pos = m_wndSeekBar.GetPosReal();
- DVD_HMSF_TIMECODE tcNow = RT2HMSF(pos);
- DVD_HMSF_TIMECODE tcDur = RT2HMSF(stop);
+ DVD_HMSF_TIMECODE tcNow = RT2HMSF(pos);
+ DVD_HMSF_TIMECODE tcDur = RT2HMSF(stop);
- if(tcDur.bHours > 0 || (pos >= stop && tcNow.bHours > 0))
- posstr.Format(_T("%02d.%02d.%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
- else
- posstr.Format(_T("%02d.%02d"), tcNow.bMinutes, tcNow.bSeconds);
- }
+ if(tcDur.bHours > 0 || (pos >= stop && tcNow.bHours > 0))
+ posstr.Format(_T("%02d.%02d.%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
+ else
+ posstr.Format(_T("%02d.%02d"), tcNow.bMinutes, tcNow.bSeconds);
+ }
- return posstr;
+ return posstr;
}
void CMainFrame::OnFileSaveImage()
{
- AppSettings& s = AfxGetAppSettings();
-
- /* Check if a compatible renderer is being used */
- if(!IsRendererCompatibleWithSaveImage())
- {
- return;
- }
+ AppSettings& s = AfxGetAppSettings();
- CPath psrc(s.SnapShotPath);
+ /* Check if a compatible renderer is being used */
+ if(!IsRendererCompatibleWithSaveImage()) {
+ return;
+ }
- CStringW prefix = _T("snapshot");
- if(m_iPlaybackMode == PM_FILE)
- {
- CPath path(m_wndPlaylistBar.GetCur());
- path.StripPath();
- prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- prefix = _T("snapshot_dvd");
- prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
- }
- psrc.Combine(s.SnapShotPath, MakeSnapshotFileName(prefix));
+ CPath psrc(s.SnapShotPath);
- CFileDialog fd(FALSE, 0, (LPCTSTR)psrc,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
- _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent(), 0);
+ CStringW prefix = _T("snapshot");
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CPath path(m_wndPlaylistBar.GetCur());
+ path.StripPath();
+ prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ prefix = _T("snapshot_dvd");
+ prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
+ }
+ psrc.Combine(s.SnapShotPath, MakeSnapshotFileName(prefix));
- if(s.SnapShotExt == _T(".bmp")) fd.m_pOFN->nFilterIndex = 1;
- else if(s.SnapShotExt == _T(".jpg")) fd.m_pOFN->nFilterIndex = 2;
- else if(s.SnapShotExt == _T(".png")) fd.m_pOFN->nFilterIndex = 3;
+ CFileDialog fd(FALSE, 0, (LPCTSTR)psrc,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
+ _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent(), 0);
- if(fd.DoModal() != IDOK) return;
+ if(s.SnapShotExt == _T(".bmp")) fd.m_pOFN->nFilterIndex = 1;
+ else if(s.SnapShotExt == _T(".jpg")) fd.m_pOFN->nFilterIndex = 2;
+ else if(s.SnapShotExt == _T(".png")) fd.m_pOFN->nFilterIndex = 3;
+
+ if(fd.DoModal() != IDOK) return;
- if(fd.m_pOFN->nFilterIndex == 1) s.SnapShotExt = _T(".bmp");
- else if(fd.m_pOFN->nFilterIndex == 2) s.SnapShotExt = _T(".jpg");
- else if(fd.m_pOFN->nFilterIndex = 3) s.SnapShotExt = _T(".png");
+ if(fd.m_pOFN->nFilterIndex == 1) s.SnapShotExt = _T(".bmp");
+ else if(fd.m_pOFN->nFilterIndex == 2) s.SnapShotExt = _T(".jpg");
+ else if(fd.m_pOFN->nFilterIndex = 3) s.SnapShotExt = _T(".png");
- CPath pdst(fd.GetPathName());
- if(pdst.GetExtension().MakeLower() != s.SnapShotExt) pdst.RenameExtension(s.SnapShotExt);
- CString path = (LPCTSTR)pdst;
- pdst.RemoveFileSpec();
- s.SnapShotPath = (LPCTSTR)pdst;
+ CPath pdst(fd.GetPathName());
+ if(pdst.GetExtension().MakeLower() != s.SnapShotExt) pdst.RenameExtension(s.SnapShotExt);
+ CString path = (LPCTSTR)pdst;
+ pdst.RemoveFileSpec();
+ s.SnapShotPath = (LPCTSTR)pdst;
- SaveImage(path);
+ SaveImage(path);
}
void CMainFrame::OnFileSaveImageAuto()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- /* Check if a compatible renderer is being used */
- if(!IsRendererCompatibleWithSaveImage())
- {
- return;
- }
+ /* Check if a compatible renderer is being used */
+ if(!IsRendererCompatibleWithSaveImage()) {
+ return;
+ }
- CStringW prefix = _T("snapshot");
- if(m_iPlaybackMode == PM_FILE)
- {
- CPath path(m_wndPlaylistBar.GetCur());
- path.StripPath();
- prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
- }
+ CStringW prefix = _T("snapshot");
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CPath path(m_wndPlaylistBar.GetCur());
+ path.StripPath();
+ prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
+ }
- CString fn;
- fn.Format(_T("%s\\%s"), AfxGetAppSettings().SnapShotPath, MakeSnapshotFileName(prefix));
- SaveImage(fn);
+ CString fn;
+ fn.Format(_T("%s\\%s"), AfxGetAppSettings().SnapShotPath, MakeSnapshotFileName(prefix));
+ SaveImage(fn);
}
void CMainFrame::OnUpdateFileSaveImage(CCmdUI* pCmdUI)
{
- OAFilterState fs = GetMediaState();
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running));
+ OAFilterState fs = GetMediaState();
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running));
}
void CMainFrame::OnFileSaveThumbnails()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- /* Check if a compatible renderer is being used */
- if(!IsRendererCompatibleWithSaveImage())
- {
- return;
- }
+ /* Check if a compatible renderer is being used */
+ if(!IsRendererCompatibleWithSaveImage()) {
+ return;
+ }
- CPath psrc(s.SnapShotPath);
- CStringW prefix = _T("thumbs");
- if(m_iPlaybackMode == PM_FILE)
- {
- CPath path(m_wndPlaylistBar.GetCur());
- path.StripPath();
- prefix.Format(_T("%s_thumbs"), path);
- }
- psrc.Combine(s.SnapShotPath, MakeSnapshotFileName(prefix));
+ CPath psrc(s.SnapShotPath);
+ CStringW prefix = _T("thumbs");
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CPath path(m_wndPlaylistBar.GetCur());
+ path.StripPath();
+ prefix.Format(_T("%s_thumbs"), path);
+ }
+ psrc.Combine(s.SnapShotPath, MakeSnapshotFileName(prefix));
- CSaveThumbnailsDialog fd(
- s.ThumbRows, s.ThumbCols, s.ThumbWidth,
- 0, (LPCTSTR)psrc,
- _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent());
+ CSaveThumbnailsDialog fd(
+ s.ThumbRows, s.ThumbCols, s.ThumbWidth,
+ 0, (LPCTSTR)psrc,
+ _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent());
- if(s.SnapShotExt == _T(".bmp")) fd.m_pOFN->nFilterIndex = 1;
- else if(s.SnapShotExt == _T(".jpg")) fd.m_pOFN->nFilterIndex = 2;
- else if(s.SnapShotExt == _T(".png")) fd.m_pOFN->nFilterIndex = 3;
+ if(s.SnapShotExt == _T(".bmp")) fd.m_pOFN->nFilterIndex = 1;
+ else if(s.SnapShotExt == _T(".jpg")) fd.m_pOFN->nFilterIndex = 2;
+ else if(s.SnapShotExt == _T(".png")) fd.m_pOFN->nFilterIndex = 3;
- if(fd.DoModal() != IDOK) return;
+ if(fd.DoModal() != IDOK) return;
- if(fd.m_pOFN->nFilterIndex == 1) s.SnapShotExt = _T(".bmp");
- else if(fd.m_pOFN->nFilterIndex == 2) s.SnapShotExt = _T(".jpg");
- else if(fd.m_pOFN->nFilterIndex = 3) s.SnapShotExt = _T(".png");
+ if(fd.m_pOFN->nFilterIndex == 1) s.SnapShotExt = _T(".bmp");
+ else if(fd.m_pOFN->nFilterIndex == 2) s.SnapShotExt = _T(".jpg");
+ else if(fd.m_pOFN->nFilterIndex = 3) s.SnapShotExt = _T(".png");
- s.ThumbRows = fd.m_rows;
- s.ThumbCols = fd.m_cols;
- s.ThumbWidth = fd.m_width;
+ s.ThumbRows = fd.m_rows;
+ s.ThumbCols = fd.m_cols;
+ s.ThumbWidth = fd.m_width;
- CPath pdst(fd.GetPathName());
- if(pdst.GetExtension().MakeLower() != s.SnapShotExt) pdst.RenameExtension(s.SnapShotExt);
- CString path = (LPCTSTR)pdst;
- pdst.RemoveFileSpec();
- s.SnapShotPath = (LPCTSTR)pdst;
+ CPath pdst(fd.GetPathName());
+ if(pdst.GetExtension().MakeLower() != s.SnapShotExt) pdst.RenameExtension(s.SnapShotExt);
+ CString path = (LPCTSTR)pdst;
+ pdst.RemoveFileSpec();
+ s.SnapShotPath = (LPCTSTR)pdst;
- SaveThumbnails(path);
+ SaveThumbnails(path);
}
void CMainFrame::OnUpdateFileSaveThumbnails(CCmdUI* pCmdUI)
{
- OAFilterState fs = GetMediaState();
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (m_iPlaybackMode == PM_FILE /*|| m_iPlaybackMode == PM_DVD*/));
+ OAFilterState fs = GetMediaState();
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (m_iPlaybackMode == PM_FILE /*|| m_iPlaybackMode == PM_DVD*/));
}
void CMainFrame::OnFileConvert()
{
- CConvertDlg().DoModal();
+ CConvertDlg().DoModal();
}
void CMainFrame::OnUpdateFileConvert(CCmdUI* pCmdUI)
{
- // TODO: Add your command update UI handler code here
+ // TODO: Add your command update UI handler code here
}
void CMainFrame::OnFileLoadsubtitle()
{
- if(!m_pCAP)
- {
- AfxMessageBox(ResStr(IDS_MAINFRM_60) +
- ResStr(IDS_MAINFRM_61) +
- ResStr(IDS_MAINFRM_62) +
- ResStr(IDS_MAINFRM_63) +
- ResStr(IDS_MAINFRM_64)
- , MB_OK);
- return;
- }
+ if(!m_pCAP)
+ {
+ AfxMessageBox(ResStr(IDS_MAINFRM_60)+
+ ResStr(IDS_MAINFRM_61)+
+ ResStr(IDS_MAINFRM_62)+
+ ResStr(IDS_MAINFRM_63)+
+ ResStr(IDS_MAINFRM_64)
+ , MB_OK);
+ return;
+ }
- static TCHAR BASED_CODE szFilter[] =
- _T(".srt .sub .ssa .ass .smi .psb .txt .idx .usf .xss|")
- _T("*.srt;*.sub;*.ssa;*.ass;*smi;*.psb;*.txt;*.idx;*.usf;*.xss||");
+ static TCHAR BASED_CODE szFilter[] =
+ _T(".srt .sub .ssa .ass .smi .psb .txt .idx .usf .xss|")
+ _T("*.srt;*.sub;*.ssa;*.ass;*smi;*.psb;*.txt;*.idx;*.usf;*.xss||");
- CFileDialog fd(TRUE, NULL, NULL,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
- szFilter, GetModalParent(), 0);
+ CFileDialog fd(TRUE, NULL, NULL,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
+ szFilter, GetModalParent(), 0);
- if(fd.DoModal() != IDOK) return;
+ if(fd.DoModal() != IDOK) return;
- ISubStream *pSubStream = NULL;
- if(LoadSubtitle(fd.GetPathName(), &pSubStream))
- SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
+ ISubStream *pSubStream = NULL;
+ if(LoadSubtitle(fd.GetPathName(), &pSubStream))
+ SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
}
void CMainFrame::OnUpdateFileLoadsubtitle(CCmdUI *pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && /*m_pCAP &&*/ !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && /*m_pCAP &&*/ !m_fAudioOnly);
}
void CMainFrame::OnFileSavesubtitle()
{
- int i = m_iSubtitleSel;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- if(i < pSubStream->GetStreamCount())
- {
- CLSID clsid;
- if(FAILED(pSubStream->GetClassID(&clsid)))
- continue;
-
- OpenMediaData *pOMD = m_wndPlaylistBar.GetCurOMD();
- CString suggestedFileName("");
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD))
- {
- // HACK: get the file name from the current playlist item
- suggestedFileName = m_wndPlaylistBar.GetCur();
- suggestedFileName = suggestedFileName.Left(suggestedFileName.ReverseFind('.')); // exclude the extension, it will be auto completed
- }
-
- if(clsid == __uuidof(CVobSubFile))
- {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
-
- // remember to set lpszDefExt to the first extension in the filter so that the save dialog autocompletes the extension
- // and tracks attempts to overwrite in a graceful manner
- CFileDialog fd(FALSE, _T("idx"), suggestedFileName,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
- _T("VobSub (*.idx, *.sub)|*.idx;*.sub||"), GetModalParent(), 0);
-
- if(fd.DoModal() == IDOK)
- {
- CAutoLock cAutoLock(&m_csSubLock);
- pVSF->Save(fd.GetPathName());
- }
-
- return;
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
-
- CString filter;
- // WATCH the order in GFN.h for exttype
- filter += _T("SubRip (*.srt)|*.srt|");
- filter += _T("MicroDVD (*.sub)|*.sub|");
- filter += _T("SAMI (*.smi)|*.smi|");
- filter += _T("PowerDivX (*.psb)|*.psb|");
- filter += _T("SubStation Alpha (*.ssa)|*.ssa|");
- filter += _T("Advanced SubStation Alpha (*.ass)|*.ass|");
- filter += _T("|");
-
- // same thing as in the case of CVobSubFile above for lpszDefExt
- CSaveTextFileDialog fd(pRTS->m_encoding, _T("srt"), suggestedFileName, filter, GetModalParent());
-
- if(fd.DoModal() == IDOK)
- {
- CAutoLock cAutoLock(&m_csSubLock);
- pRTS->SaveAs(fd.GetPathName(), (exttype)(fd.m_ofn.nFilterIndex - 1), m_pCAP->GetFPS(), fd.GetEncoding());
- }
-
- return;
- }
- }
-
- i -= pSubStream->GetStreamCount();
- }
+ int i = m_iSubtitleSel;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos && i >= 0)
+ {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ if(i < pSubStream->GetStreamCount())
+ {
+ CLSID clsid;
+ if(FAILED(pSubStream->GetClassID(&clsid)))
+ continue;
+
+ OpenMediaData *pOMD = m_wndPlaylistBar.GetCurOMD();
+ CString suggestedFileName("");
+ if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD))
+ {
+ // HACK: get the file name from the current playlist item
+ suggestedFileName = m_wndPlaylistBar.GetCur();
+ suggestedFileName = suggestedFileName.Left(suggestedFileName.ReverseFind('.')); // exclude the extension, it will be auto completed
+ }
+
+ if(clsid == __uuidof(CVobSubFile))
+ {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
+
+ // remember to set lpszDefExt to the first extension in the filter so that the save dialog autocompletes the extension
+ // and tracks attempts to overwrite in a graceful manner
+ CFileDialog fd(FALSE, _T("idx"), suggestedFileName,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
+ _T("VobSub (*.idx, *.sub)|*.idx;*.sub||"), GetModalParent(), 0);
+
+ if(fd.DoModal() == IDOK)
+ {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pVSF->Save(fd.GetPathName());
+ }
+
+ return;
+ }
+ else if(clsid == __uuidof(CRenderedTextSubtitle))
+ {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
+
+ CString filter;
+ // WATCH the order in GFN.h for exttype
+ filter += _T("SubRip (*.srt)|*.srt|");
+ filter += _T("MicroDVD (*.sub)|*.sub|");
+ filter += _T("SAMI (*.smi)|*.smi|");
+ filter += _T("PowerDivX (*.psb)|*.psb|");
+ filter += _T("SubStation Alpha (*.ssa)|*.ssa|");
+ filter += _T("Advanced SubStation Alpha (*.ass)|*.ass|");
+ filter += _T("|");
+
+ // same thing as in the case of CVobSubFile above for lpszDefExt
+ CSaveTextFileDialog fd(pRTS->m_encoding, _T("srt"), suggestedFileName, filter, GetModalParent());
+
+ if(fd.DoModal() == IDOK)
+ {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pRTS->SaveAs(fd.GetPathName(), (exttype)(fd.m_ofn.nFilterIndex-1), m_pCAP->GetFPS(), fd.GetEncoding());
+ }
+
+ return;
+ }
+ }
+
+ i -= pSubStream->GetStreamCount();
+ }
}
void CMainFrame::OnUpdateFileSavesubtitle(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iSubtitleSel >= 0);
+ pCmdUI->Enable(m_iSubtitleSel >= 0);
}
///////////////
@@ -5079,864 +4955,850 @@ void CMainFrame::OnUpdateFileSavesubtitle(CCmdUI* pCmdUI)
void CMainFrame::OnFileISDBSearch()
{
- CStringA url = "http://" + AfxGetAppSettings().ISDb + "/index.php?";
- CStringA args = makeargs(m_wndPlaylistBar.m_pl);
- ShellExecute(m_hWnd, _T("open"), CString(url + args), NULL, NULL, SW_SHOWDEFAULT);
+ CStringA url = "http://" + AfxGetAppSettings().ISDb + "/index.php?";
+ CStringA args = makeargs(m_wndPlaylistBar.m_pl);
+ ShellExecute(m_hWnd, _T("open"), CString(url+args), NULL, NULL, SW_SHOWDEFAULT);
}
void CMainFrame::OnUpdateFileISDBSearch(CCmdUI *pCmdUI)
{
- pCmdUI->Enable(TRUE);
+ pCmdUI->Enable(TRUE);
}
void CMainFrame::OnFileISDBUpload()
{
- CStringA url = "http://" + AfxGetAppSettings().ISDb + "/ul.php?";
- CStringA args = makeargs(m_wndPlaylistBar.m_pl);
- ShellExecute(m_hWnd, _T("open"), CString(url + args), NULL, NULL, SW_SHOWDEFAULT);
+ CStringA url = "http://" + AfxGetAppSettings().ISDb + "/ul.php?";
+ CStringA args = makeargs(m_wndPlaylistBar.m_pl);
+ ShellExecute(m_hWnd, _T("open"), CString(url+args), NULL, NULL, SW_SHOWDEFAULT);
}
void CMainFrame::OnUpdateFileISDBUpload(CCmdUI *pCmdUI)
{
- pCmdUI->Enable(m_wndPlaylistBar.GetCount() > 0);
+ pCmdUI->Enable(m_wndPlaylistBar.GetCount() > 0);
}
void CMainFrame::OnFileISDBDownload()
{
- filehash fh;
- if(!::hash((CString)m_wndPlaylistBar.GetCur(), fh))
- {
- MessageBeep(-1);
- return;
- }
-
- // TODO: put this on a worker thread
-
- CStringA url = "http://" + AfxGetAppSettings().ISDb + "/index.php?";
- CStringA args;
- args.Format("player=mpc&name[0]=%s&size[0]=%016I64x&hash[0]=%016I64x",
- UrlEncode(CStringA(fh.name)), fh.size, fh.hash);
-
- try
- {
- CInternetSession is;
-
- CStringA str;
- if(!OpenUrl(is, CString(url + args), str))
- {
- AfxMessageBox(_T("Cannot connect to subtitle database site"), MB_OK);
- return;
- }
-
- CStringA ticket;
- CList<isdb_movie> movies;
- isdb_movie m;
- isdb_subtitle s;
-
- CAtlList<CStringA> sl;
- Explode(str, sl, '\n');
-
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- str = sl.GetNext(pos);
-
- CStringA param = str.Left(max(0, str.Find('=')));
- CStringA value = str.Mid(str.Find('=') + 1);
-
- if(param == "ticket") ticket = value;
- else if(param == "movie")
- {
- m.reset();
- Explode(value, m.titles, '|');
- }
- else if(param == "subtitle")
- {
- s.reset();
- s.id = atoi(value);
- }
- else if(param == "name") s.name = value;
- else if(param == "discs") s.discs = atoi(value);
- else if(param == "disc_no") s.disc_no = atoi(value);
- else if(param == "format") s.format = value;
- else if(param == "iso639_2") s.iso639_2 = value;
- else if(param == "language") s.language = value;
- else if(param == "nick") s.nick = value;
- else if(param == "email") s.email = value;
- else if(param == "" && value == "endsubtitle")
- {
- m.subs.AddTail(s);
- }
- else if(param == "" && value == "endmovie")
- {
- movies.AddTail(m);
- }
- else if(param == "" && value == "end") break;
- }
-
- CSubtitleDlDlg dlg(movies, GetModalParent());
- if(IDOK == dlg.DoModal())
- {
- if(dlg.m_fReplaceSubs)
- m_pSubStreams.RemoveAll();
-
- CComPtr<ISubStream> pSubStreamToSet;
-
- POSITION pos = dlg.m_selsubs.GetHeadPosition();
- while(pos)
- {
- isdb_subtitle& s = dlg.m_selsubs.GetNext(pos);
-
- CStringA url = "http://" + AfxGetAppSettings().ISDb + "/dl.php?";
- CStringA args;
- args.Format("id=%d&ticket=%s", s.id, UrlEncode(ticket));
-
- if(OpenUrl(is, CString(url + args), str))
- {
- CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &AfxGetAppSettings().subdefstyle, AfxGetAppSettings().fUseDefaultSubtitlesStyle));
- if(pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(s.name)) && pRTS->GetStreamCount() > 0)
- {
- CComPtr<ISubStream> pSubStream = pRTS.Detach();
- m_pSubStreams.AddTail(pSubStream);
- if(!pSubStreamToSet) pSubStreamToSet = pSubStream;
- }
- }
- }
-
- if(pSubStreamToSet)
- SetSubtitle(pSubStreamToSet);
- }
- }
- catch(CInternetException* ie)
- {
- ie->Delete();
- return;
- }
+ filehash fh;
+ if(!::hash((CString)m_wndPlaylistBar.GetCur(), fh))
+ {
+ MessageBeep(-1);
+ return;
+ }
+
+ // TODO: put this on a worker thread
+
+ CStringA url = "http://" + AfxGetAppSettings().ISDb + "/index.php?";
+ CStringA args;
+ args.Format("player=mpc&name[0]=%s&size[0]=%016I64x&hash[0]=%016I64x",
+ UrlEncode(CStringA(fh.name)), fh.size, fh.hash);
+
+ try
+ {
+ CInternetSession is;
+
+ CStringA str;
+ if(!OpenUrl(is, CString(url+args), str))
+ {
+ AfxMessageBox(_T("Cannot connect to subtitle database site"), MB_OK);
+ return;
+ }
+
+ CStringA ticket;
+ CList<isdb_movie> movies;
+ isdb_movie m;
+ isdb_subtitle s;
+
+ CAtlList<CStringA> sl;
+ Explode(str, sl, '\n');
+
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ str = sl.GetNext(pos);
+
+ CStringA param = str.Left(max(0, str.Find('=')));
+ CStringA value = str.Mid(str.Find('=')+1);
+
+ if(param == "ticket") ticket = value;
+ else if(param == "movie") {m.reset(); Explode(value, m.titles, '|');}
+ else if(param == "subtitle") {s.reset(); s.id = atoi(value);}
+ else if(param == "name") s.name = value;
+ else if(param == "discs") s.discs = atoi(value);
+ else if(param == "disc_no") s.disc_no = atoi(value);
+ else if(param == "format") s.format = value;
+ else if(param == "iso639_2") s.iso639_2 = value;
+ else if(param == "language") s.language = value;
+ else if(param == "nick") s.nick = value;
+ else if(param == "email") s.email = value;
+ else if(param == "" && value == "endsubtitle") {m.subs.AddTail(s);}
+ else if(param == "" && value == "endmovie") {movies.AddTail(m);}
+ else if(param == "" && value == "end") break;
+ }
+
+ CSubtitleDlDlg dlg(movies, GetModalParent());
+ if(IDOK == dlg.DoModal())
+ {
+ if(dlg.m_fReplaceSubs)
+ m_pSubStreams.RemoveAll();
+
+ CComPtr<ISubStream> pSubStreamToSet;
+
+ POSITION pos = dlg.m_selsubs.GetHeadPosition();
+ while(pos)
+ {
+ isdb_subtitle& s = dlg.m_selsubs.GetNext(pos);
+
+ CStringA url = "http://" + AfxGetAppSettings().ISDb + "/dl.php?";
+ CStringA args;
+ args.Format("id=%d&ticket=%s", s.id, UrlEncode(ticket));
+
+ if(OpenUrl(is, CString(url+args), str))
+ {
+ CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &AfxGetAppSettings().subdefstyle, AfxGetAppSettings().fUseDefaultSubtitlesStyle));
+ if(pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(s.name)) && pRTS->GetStreamCount() > 0)
+ {
+ CComPtr<ISubStream> pSubStream = pRTS.Detach();
+ m_pSubStreams.AddTail(pSubStream);
+ if(!pSubStreamToSet) pSubStreamToSet = pSubStream;
+ }
+ }
+ }
+
+ if(pSubStreamToSet)
+ SetSubtitle(pSubStreamToSet);
+ }
+ }
+ catch(CInternetException* ie)
+ {
+ ie->Delete();
+ return;
+ }
}
void CMainFrame::OnUpdateFileISDBDownload(CCmdUI *pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_pCAP && !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_pCAP && !m_fAudioOnly);
}
void CMainFrame::OnFileProperties()
{
- CPPageFileInfoSheet m_fileinfo(m_wndPlaylistBar.GetCur(), this, GetModalParent());
- m_fileinfo.DoModal();
+ CPPageFileInfoSheet m_fileinfo(m_wndPlaylistBar.GetCur(), this, GetModalParent());
+ m_fileinfo.DoModal();
}
void CMainFrame::OnUpdateFileProperties(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_iPlaybackMode == PM_FILE);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_iPlaybackMode == PM_FILE);
}
void CMainFrame::OnFileCloseMedia()
{
- CloseMedia();
+ CloseMedia();
}
void CMainFrame::OnUpdateViewTearingTest(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(TRUE);
- pCmdUI->SetCheck(AfxGetMyApp()->m_fTearingTest);
+ pCmdUI->Enable (TRUE);
+ pCmdUI->SetCheck (AfxGetMyApp()->m_fTearingTest);
}
void CMainFrame::OnViewTearingTest()
{
- AfxGetMyApp()->m_fTearingTest = ! AfxGetMyApp()->m_fTearingTest;
+ AfxGetMyApp()->m_fTearingTest = ! AfxGetMyApp()->m_fTearingTest;
}
void CMainFrame::OnUpdateViewDisplayStats(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D;
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D;
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(supported && (AfxGetMyApp()->m_fDisplayStats));
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck (supported && (AfxGetMyApp()->m_fDisplayStats));
}
void CMainFrame::OnViewResetStats()
{
- AfxGetMyApp()->m_bResetStats = true; // Reset by "consumer"
+ AfxGetMyApp()->m_bResetStats = true; // Reset by "consumer"
}
void CMainFrame::OnViewDisplayStatsSC()
{
- ++AfxGetMyApp()->m_fDisplayStats;
- if(AfxGetMyApp()->m_fDisplayStats > 3)
- AfxGetMyApp()->m_fDisplayStats = 0;
+ ++AfxGetMyApp()->m_fDisplayStats;
+ if (AfxGetMyApp()->m_fDisplayStats > 3)
+ AfxGetMyApp()->m_fDisplayStats = 0;
}
void CMainFrame::OnUpdateViewVSync(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(!supported || (s.m_RenderSettings.iVMR9VSync));
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck (!supported || (s.m_RenderSettings.iVMR9VSync));
}
void CMainFrame::OnUpdateViewVSyncOffset(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync;
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync;
- pCmdUI->Enable(supported);
- CString Temp;
- Temp.Format(L"%d", s.m_RenderSettings.iVMR9VSyncOffset);
- pCmdUI->SetText(Temp);
+ pCmdUI->Enable(supported);
+ CString Temp;
+ Temp.Format(L"%d", s.m_RenderSettings.iVMR9VSyncOffset);
+ pCmdUI->SetText(Temp);
}
void CMainFrame::OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.iVMR9VSyncAccurate);
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMR9VSyncAccurate);
}
void CMainFrame::OnUpdateViewSynchronizeVideo(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && m_iPlaybackMode == PM_NONE);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && m_iPlaybackMode == PM_NONE);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.bSynchronizeVideo);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.bSynchronizeVideo);
}
void CMainFrame::OnUpdateViewSynchronizeDisplay(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && m_iPlaybackMode == PM_NONE);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && m_iPlaybackMode == PM_NONE);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.bSynchronizeDisplay);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.bSynchronizeDisplay);
}
void CMainFrame::OnUpdateViewSynchronizeNearest(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_SYNC);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_SYNC);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.bSynchronizeNearest);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.bSynchronizeNearest);
}
void CMainFrame::OnUpdateViewEVROutputRange(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
+ pCmdUI->Enable (supported);
- if(pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_0_255)
- pCmdUI->SetCheck(s.m_RenderSettings.iEVROutputRange == 0);
- else if(pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_16_235)
- pCmdUI->SetCheck(s.m_RenderSettings.iEVROutputRange == 1);
+ if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_0_255)
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVROutputRange == 0);
+ else if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_16_235)
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVROutputRange == 1);
}
void CMainFrame::OnUpdateViewFlushGPU(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
-
- pCmdUI->Enable(supported);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- if(pCmdUI->m_nID == ID_VIEW_FLUSHGPU_BEFOREVSYNC)
- pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUBeforeVSync != 0);
- else if(pCmdUI->m_nID == ID_VIEW_FLUSHGPU_AFTERPRESENT)
- pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUAfterPresent != 0);
- else if(pCmdUI->m_nID == ID_VIEW_FLUSHGPU_WAIT)
- pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUWait != 0);
+ pCmdUI->Enable (supported);
+ if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_BEFOREVSYNC)
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUBeforeVSync != 0);
+ else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_AFTERPRESENT)
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUAfterPresent != 0);
+ else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_WAIT)
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUWait != 0);
+
}
void CMainFrame::OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.fD3DFullscreen);
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.fD3DFullscreen);
}
void CMainFrame::OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.iVMRDisableDesktopComposition);
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRDisableDesktopComposition);
}
void CMainFrame::OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.fVMR9AlterativeVSync);
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.fVMR9AlterativeVSync);
}
void CMainFrame::OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.iVMR9FullscreenGUISupport);
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMR9FullscreenGUISupport);
}
void CMainFrame::OnUpdateViewHighColorResolution(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.iEVRHighColorResolution);
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVRHighColorResolution);
}
void CMainFrame::OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(s.m_RenderSettings.iEVREnableFrameTimeCorrection);
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVREnableFrameTimeCorrection);
}
void CMainFrame::OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC || (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC || (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync);
- pCmdUI->Enable(supported);
+ pCmdUI->Enable (supported);
}
void CMainFrame::OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC || (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync);
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC || (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync);
- pCmdUI->Enable(supported);
+ pCmdUI->Enable (supported);
}
void CMainFrame::OnViewVSync()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iVMR9VSync = !s.m_RenderSettings.iVMR9VSync;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"VSync: %s", s.m_RenderSettings.iVMR9VSync ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMR9VSync = !s.m_RenderSettings.iVMR9VSync;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"VSync: %s", s.m_RenderSettings.iVMR9VSync? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewVSyncAccurate()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iVMR9VSyncAccurate = !s.m_RenderSettings.iVMR9VSyncAccurate;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Accurate VSync: %s", s.m_RenderSettings.iVMR9VSyncAccurate ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMR9VSyncAccurate = !s.m_RenderSettings.iVMR9VSyncAccurate;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Accurate VSync: %s", s.m_RenderSettings.iVMR9VSyncAccurate? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewSynchronizeVideo()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.bSynchronizeVideo = !s.m_RenderSettings.bSynchronizeVideo;
- if(s.m_RenderSettings.bSynchronizeVideo)
- {
- s.m_RenderSettings.bSynchronizeDisplay = false;
- s.m_RenderSettings.bSynchronizeNearest = false;
- s.m_RenderSettings.iVMR9VSync = false;
- s.m_RenderSettings.iVMR9VSyncAccurate = false;
- s.m_RenderSettings.fVMR9AlterativeVSync = false;
- }
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.bSynchronizeVideo = !s.m_RenderSettings.bSynchronizeVideo;
+ if (s.m_RenderSettings.bSynchronizeVideo)
+ {
+ s.m_RenderSettings.bSynchronizeDisplay = false;
+ s.m_RenderSettings.bSynchronizeNearest = false;
+ s.m_RenderSettings.iVMR9VSync = false;
+ s.m_RenderSettings.iVMR9VSyncAccurate = false;
+ s.m_RenderSettings.fVMR9AlterativeVSync = false;
+ }
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Synchronize Video to Display: %s", s.m_RenderSettings.bSynchronizeVideo ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Synchronize Video to Display: %s", s.m_RenderSettings.bSynchronizeVideo? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewSynchronizeDisplay()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.bSynchronizeDisplay = !s.m_RenderSettings.bSynchronizeDisplay;
- if(s.m_RenderSettings.bSynchronizeDisplay)
- {
- s.m_RenderSettings.bSynchronizeVideo = false;
- s.m_RenderSettings.bSynchronizeNearest = false;
- s.m_RenderSettings.iVMR9VSync = false;
- s.m_RenderSettings.iVMR9VSyncAccurate = false;
- s.m_RenderSettings.fVMR9AlterativeVSync = false;
- }
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.bSynchronizeDisplay = !s.m_RenderSettings.bSynchronizeDisplay;
+ if (s.m_RenderSettings.bSynchronizeDisplay)
+ {
+ s.m_RenderSettings.bSynchronizeVideo = false;
+ s.m_RenderSettings.bSynchronizeNearest = false;
+ s.m_RenderSettings.iVMR9VSync = false;
+ s.m_RenderSettings.iVMR9VSyncAccurate = false;
+ s.m_RenderSettings.fVMR9AlterativeVSync = false;
+ }
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Synchronize Display to Video: %s", s.m_RenderSettings.bSynchronizeDisplay ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Synchronize Display to Video: %s", s.m_RenderSettings.bSynchronizeDisplay? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewSynchronizeNearest()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.bSynchronizeNearest = !s.m_RenderSettings.bSynchronizeNearest;
- if(s.m_RenderSettings.bSynchronizeNearest)
- {
- s.m_RenderSettings.bSynchronizeVideo = false;
- s.m_RenderSettings.bSynchronizeDisplay = false;
- s.m_RenderSettings.iVMR9VSync = false;
- s.m_RenderSettings.iVMR9VSyncAccurate = false;
- s.m_RenderSettings.fVMR9AlterativeVSync = false;
- }
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.bSynchronizeNearest = !s.m_RenderSettings.bSynchronizeNearest;
+ if (s.m_RenderSettings.bSynchronizeNearest)
+ {
+ s.m_RenderSettings.bSynchronizeVideo = false;
+ s.m_RenderSettings.bSynchronizeDisplay = false;
+ s.m_RenderSettings.iVMR9VSync = false;
+ s.m_RenderSettings.iVMR9VSyncAccurate = false;
+ s.m_RenderSettings.fVMR9AlterativeVSync = false;
+ }
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Present at Nearest VSync: %s", s.m_RenderSettings.bSynchronizeNearest ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Present at Nearest VSync: %s", s.m_RenderSettings.bSynchronizeNearest? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewEVROutputRange_0_255()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iEVROutputRange = 0;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Output Range: 0 - 255");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVROutputRange = 0;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Output Range: 0 - 255");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewEVROutputRange_16_235()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iEVROutputRange = 1;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Output Range: 16 - 235");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVROutputRange = 1;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Output Range: 16 - 235");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewFlushGPUBeforeVSync()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iVMRFlushGPUBeforeVSync = !s.m_RenderSettings.iVMRFlushGPUBeforeVSync;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Flush GPU before VSync: %s", s.m_RenderSettings.iVMRFlushGPUBeforeVSync ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRFlushGPUBeforeVSync = !s.m_RenderSettings.iVMRFlushGPUBeforeVSync;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Flush GPU before VSync: %s", s.m_RenderSettings.iVMRFlushGPUBeforeVSync? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewFlushGPUAfterVSync()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iVMRFlushGPUAfterPresent = !s.m_RenderSettings.iVMRFlushGPUAfterPresent;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Flush GPU after Present: %s", s.m_RenderSettings.iVMRFlushGPUAfterPresent ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRFlushGPUAfterPresent = !s.m_RenderSettings.iVMRFlushGPUAfterPresent;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Flush GPU after Present: %s", s.m_RenderSettings.iVMRFlushGPUAfterPresent? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewFlushGPUWait()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iVMRFlushGPUWait = !s.m_RenderSettings.iVMRFlushGPUWait;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Wait for GPU Flush: %s", s.m_RenderSettings.iVMRFlushGPUWait ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRFlushGPUWait = !s.m_RenderSettings.iVMRFlushGPUWait;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Wait for GPU Flush: %s", s.m_RenderSettings.iVMRFlushGPUWait? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewD3DFullScreen()
{
- AppSettings& s = AfxGetAppSettings();
- s.fD3DFullscreen = !s.fD3DFullscreen;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"D3D Fullscreen (Requires restart): %s", s.fD3DFullscreen ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.fD3DFullscreen = !s.fD3DFullscreen;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"D3D Fullscreen (Requires restart): %s", s.fD3DFullscreen? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewDisableDesktopComposition()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iVMRDisableDesktopComposition = !s.m_RenderSettings.iVMRDisableDesktopComposition;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Disable desktop composition: %s", s.m_RenderSettings.iVMRDisableDesktopComposition ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRDisableDesktopComposition = !s.m_RenderSettings.iVMRDisableDesktopComposition;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Disable desktop composition: %s", s.m_RenderSettings.iVMRDisableDesktopComposition? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewAlternativeVSync()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.fVMR9AlterativeVSync = !s.m_RenderSettings.fVMR9AlterativeVSync;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Alternative VSync: %s", s.m_RenderSettings.fVMR9AlterativeVSync ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.fVMR9AlterativeVSync = !s.m_RenderSettings.fVMR9AlterativeVSync;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Alternative VSync: %s", s.m_RenderSettings.fVMR9AlterativeVSync? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewResetDefault()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.SetDefault();
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Renderer settings reset to default");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.SetDefault();
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Renderer settings reset to default");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewResetOptimal()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.SetOptimal();
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Renderer settings reset to optimal");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.SetOptimal();
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Renderer settings reset to optimal");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewFullscreenGUISupport()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iVMR9FullscreenGUISupport = !s.m_RenderSettings.iVMR9FullscreenGUISupport;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"D3D Fullscreen GUI Support: %s", s.m_RenderSettings.iVMR9FullscreenGUISupport ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMR9FullscreenGUISupport = !s.m_RenderSettings.iVMR9FullscreenGUISupport;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"D3D Fullscreen GUI Support: %s", s.m_RenderSettings.iVMR9FullscreenGUISupport? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewHighColorResolution()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iEVRHighColorResolution = !s.m_RenderSettings.iEVRHighColorResolution;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"10 bit RGB: %s", s.m_RenderSettings.iEVRHighColorResolution ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVRHighColorResolution = !s.m_RenderSettings.iEVRHighColorResolution;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"10 bit RGB: %s", s.m_RenderSettings.iEVRHighColorResolution? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewEnableFrameTimeCorrection()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_RenderSettings.iEVREnableFrameTimeCorrection = !s.m_RenderSettings.iEVREnableFrameTimeCorrection;
- s.UpdateData(true);
- CString Format;
- Format.Format(L"Frame Time Correction: %s", s.m_RenderSettings.iEVREnableFrameTimeCorrection ? L"On" : L"Off");
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVREnableFrameTimeCorrection = !s.m_RenderSettings.iEVREnableFrameTimeCorrection;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Frame Time Correction: %s", s.m_RenderSettings.iEVREnableFrameTimeCorrection? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewVSyncOffsetIncrease()
{
- AppSettings& s = AfxGetAppSettings();
- CString Format;
- if(s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- {
- s.m_RenderSettings.fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset - 0.5; // Yeah, it should be a "-"
- s.UpdateData(true);
- Format.Format(L"Target VSync Offset: %.1f", s.m_RenderSettings.fTargetSyncOffset);
- }
- else
- {
- ++s.m_RenderSettings.iVMR9VSyncOffset;
- s.UpdateData(true);
- Format.Format(L"VSync Offset: %d", s.m_RenderSettings.iVMR9VSyncOffset);
- }
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ CString Format;
+ if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
+ {
+ s.m_RenderSettings.fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset - 0.5; // Yeah, it should be a "-"
+ s.UpdateData(true);
+ Format.Format(L"Target VSync Offset: %.1f", s.m_RenderSettings.fTargetSyncOffset);
+ }
+ else
+ {
+ ++s.m_RenderSettings.iVMR9VSyncOffset;
+ s.UpdateData(true);
+ Format.Format(L"VSync Offset: %d", s.m_RenderSettings.iVMR9VSyncOffset);
+ }
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
}
void CMainFrame::OnViewVSyncOffsetDecrease()
{
- AppSettings& s = AfxGetAppSettings();
- CString Format;
- if(s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- {
- s.m_RenderSettings.fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset + 0.5;
- s.UpdateData(true);
- Format.Format(L"Target VSync Offset: %.1f", s.m_RenderSettings.fTargetSyncOffset);
- }
- else
- {
- --s.m_RenderSettings.iVMR9VSyncOffset;
- s.UpdateData(true);
- Format.Format(L"VSync Offset: %d", s.m_RenderSettings.iVMR9VSyncOffset);
- }
- m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
+ AppSettings& s = AfxGetAppSettings();
+ CString Format;
+ if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
+ {
+ s.m_RenderSettings.fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset + 0.5;
+ s.UpdateData(true);
+ Format.Format(L"Target VSync Offset: %.1f", s.m_RenderSettings.fTargetSyncOffset);
+ }
+ else
+ {
+ --s.m_RenderSettings.iVMR9VSyncOffset;
+ s.UpdateData(true);
+ Format.Format(L"VSync Offset: %d", s.m_RenderSettings.iVMR9VSyncOffset);
+ }
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, Format);
}
void CMainFrame::OnUpdateViewRemainingTime(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- pCmdUI->Enable(s.fShowOSD && (m_iMediaLoadState != MLS_CLOSED));
- pCmdUI->SetCheck(m_bRemainingTime);
+ AppSettings& s = AfxGetAppSettings();
+ pCmdUI->Enable (s.fShowOSD && (m_iMediaLoadState != MLS_CLOSED));
+ pCmdUI->SetCheck (m_bRemainingTime);
}
void CMainFrame::OnViewRemainingTime()
{
- m_bRemainingTime = !m_bRemainingTime;
- if(!m_bRemainingTime) m_OSD.ClearMessage();
+ m_bRemainingTime = !m_bRemainingTime;
+ if (!m_bRemainingTime) m_OSD.ClearMessage();
}
void CMainFrame::OnUpdateShaderToggle(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(TRUE);
- pCmdUI->SetCheck(m_bToggleShader);
+ pCmdUI->Enable (TRUE);
+ pCmdUI->SetCheck (m_bToggleShader);
}
void CMainFrame::OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(TRUE);
- pCmdUI->SetCheck(m_bToggleShaderScreenSpace);
+ pCmdUI->Enable (TRUE);
+ pCmdUI->SetCheck (m_bToggleShaderScreenSpace);
}
void CMainFrame::OnShaderToggle()
{
- m_bToggleShader = !m_bToggleShader;
- if(!m_bToggleShader)
- {
- SetShaders();
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_65));
- }
- else
- {
- if(m_pCAP)
- m_pCAP->SetPixelShader(NULL, NULL);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_66));
- }
+ m_bToggleShader = !m_bToggleShader;
+ if (!m_bToggleShader)
+ {
+ SetShaders();
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_65));
+ }
+ else
+ {
+ if (m_pCAP)
+ m_pCAP->SetPixelShader(NULL, NULL);
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_66));
+ }
}
void CMainFrame::OnShaderToggleScreenSpace()
{
- m_bToggleShaderScreenSpace = !m_bToggleShaderScreenSpace;
- if(!m_bToggleShaderScreenSpace)
- {
- SetShaders();
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPONSCR));
- }
- else
- {
- if(m_pCAP2)
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPOFFSCR));
- }
+ m_bToggleShaderScreenSpace = !m_bToggleShaderScreenSpace;
+ if (!m_bToggleShaderScreenSpace)
+ {
+ SetShaders();
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPONSCR));
+ }
+ else
+ {
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPOFFSCR));
+ }
}
void CMainFrame::OnD3DFullscreenToggle()
{
- AppSettings& s = AfxGetAppSettings();
- LPCTSTR strMsg;
-
- s.fD3DFullscreen = !s.fD3DFullscreen;
- strMsg = s.fD3DFullscreen ? ResStr(IDS_MAINFRM_67) : _T("D3D Fullscreen off");
+ AppSettings& s = AfxGetAppSettings();
+ LPCTSTR strMsg;
- if(m_iMediaLoadState == MLS_CLOSED)
- m_closingmsg = strMsg;
- else
- m_OSD.DisplayMessage(OSD_TOPRIGHT, strMsg);
+ s.fD3DFullscreen = !s.fD3DFullscreen;
+ strMsg = s.fD3DFullscreen ? ResStr(IDS_MAINFRM_67) : _T("D3D Fullscreen off");
+
+ if (m_iMediaLoadState == MLS_CLOSED)
+ m_closingmsg = strMsg;
+ else
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, strMsg);
}
void CMainFrame::OnFileClosePlaylist()
{
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- RestoreDefaultWindowRect();
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ RestoreDefaultWindowRect();
}
void CMainFrame::OnUpdateFileClose(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED || m_iMediaLoadState == MLS_LOADING);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED || m_iMediaLoadState == MLS_LOADING);
}
// view
void CMainFrame::OnViewCaptionmenu()
{
- bool fHideCaptionMenu = AfxGetAppSettings().fHideCaptionMenu;
+ bool fHideCaptionMenu = AfxGetAppSettings().fHideCaptionMenu;
- AfxGetAppSettings().fHideCaptionMenu = !fHideCaptionMenu;
+ AfxGetAppSettings().fHideCaptionMenu = !fHideCaptionMenu;
- if(m_fFullScreen)
- return;
+ if ( m_fFullScreen )
+ return;
- DWORD dwRemove = 0, dwAdd = 0;
- HMENU hMenu;
+ DWORD dwRemove = 0, dwAdd = 0;
+ HMENU hMenu;
- CRect wr;
- GetWindowRect(&wr);
+ CRect wr;
+ GetWindowRect( &wr );
- if(!fHideCaptionMenu)
- {
- dwRemove = WS_CAPTION | WS_THICKFRAME; // leave the window borderless
- hMenu = NULL;
- wr.right -= (GetSystemMetrics(SM_CXSIZEFRAME) * 2); // "Resize" borders
- wr.bottom -= (GetSystemMetrics(SM_CYSIZEFRAME) * 2); // "Resize" borders
- wr.bottom -= (GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU));
- }
- else
- {
- dwAdd = WS_CAPTION | WS_THICKFRAME;
- hMenu = m_hMenuDefault;
- wr.right += (GetSystemMetrics(SM_CXSIZEFRAME) * 2);
- wr.bottom += (GetSystemMetrics(SM_CYSIZEFRAME) * 2);
- wr.bottom += (GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU));
- }
+ if ( !fHideCaptionMenu )
+ {
+ dwRemove = WS_CAPTION | WS_THICKFRAME; // leave the window borderless
+ hMenu = NULL;
+ wr.right -= (GetSystemMetrics( SM_CXSIZEFRAME ) * 2); // "Resize" borders
+ wr.bottom -= (GetSystemMetrics( SM_CYSIZEFRAME ) * 2); // "Resize" borders
+ wr.bottom -= (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYMENU ));
+ }
+ else
+ {
+ dwAdd = WS_CAPTION | WS_THICKFRAME;
+ hMenu = m_hMenuDefault;
+ wr.right += (GetSystemMetrics( SM_CXSIZEFRAME ) * 2);
+ wr.bottom += (GetSystemMetrics( SM_CYSIZEFRAME ) * 2);
+ wr.bottom += (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYMENU ));
+ }
- ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
- ::SetMenu(m_hWnd, hMenu);
- // NOTE: r.left and r.top are ignored due to SWP_NOMOVE flag
- SetWindowPos(NULL, wr.left, wr.top, wr.Width(), wr.Height(), SWP_FRAMECHANGED |/*SWP_NOSIZE|*/SWP_NOMOVE | SWP_NOZORDER);
+ ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
+ ::SetMenu(m_hWnd, hMenu);
+ // NOTE: r.left and r.top are ignored due to SWP_NOMOVE flag
+ SetWindowPos(NULL, wr.left, wr.top, wr.Width(), wr.Height(), SWP_FRAMECHANGED|/*SWP_NOSIZE|*/SWP_NOMOVE|SWP_NOZORDER);
- MoveVideoWindow();
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewCaptionmenu(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(!AfxGetAppSettings().fHideCaptionMenu);
+ pCmdUI->SetCheck(!AfxGetAppSettings().fHideCaptionMenu);
}
void CMainFrame::OnViewControlBar(UINT nID)
{
- nID -= ID_VIEW_SEEKER;
- ShowControls(AfxGetAppSettings().nCS ^(1 << nID));
+ nID -= ID_VIEW_SEEKER;
+ ShowControls(AfxGetAppSettings().nCS ^ (1<<nID));
}
void CMainFrame::OnUpdateViewControlBar(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_VIEW_SEEKER;
- pCmdUI->SetCheck(!!(AfxGetAppSettings().nCS & (1 << nID)));
+ UINT nID = pCmdUI->m_nID - ID_VIEW_SEEKER;
+ pCmdUI->SetCheck(!!(AfxGetAppSettings().nCS & (1<<nID)));
}
void CMainFrame::OnViewSubresync()
{
- ShowControlBar(&m_wndSubresyncBar, !m_wndSubresyncBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndSubresyncBar, !m_wndSubresyncBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewSubresync(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndSubresyncBar.IsWindowVisible());
- pCmdUI->Enable(m_pCAP && m_iSubtitleSel >= 0);
+ pCmdUI->SetCheck(m_wndSubresyncBar.IsWindowVisible());
+ pCmdUI->Enable(m_pCAP && m_iSubtitleSel >= 0);
}
void CMainFrame::OnViewPlaylist()
{
- ShowControlBar(&m_wndPlaylistBar, !m_wndPlaylistBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndPlaylistBar, !m_wndPlaylistBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewPlaylist(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndPlaylistBar.IsWindowVisible());
- pCmdUI->Enable(m_iMediaLoadState == MLS_CLOSED && m_iMediaLoadState != MLS_LOADED
- || m_iMediaLoadState == MLS_LOADED /*&& (m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE)*/);
+ pCmdUI->SetCheck(m_wndPlaylistBar.IsWindowVisible());
+ pCmdUI->Enable(m_iMediaLoadState == MLS_CLOSED && m_iMediaLoadState != MLS_LOADED
+ || m_iMediaLoadState == MLS_LOADED /*&& (m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE)*/);
}
void CMainFrame::OnViewEditListEditor()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if(s.fEnableEDLEditor || (AfxMessageBox(_T("Do you want to activate EDL editor?"), MB_YESNO) == IDYES))
- {
- s.fEnableEDLEditor = true;
- ShowControlBar(&m_wndEditListEditor, !m_wndEditListEditor.IsWindowVisible(), TRUE);
- }
+ if (s.fEnableEDLEditor || (AfxMessageBox(_T("Do you want to activate EDL editor?"), MB_YESNO) == IDYES))
+ {
+ s.fEnableEDLEditor = true;
+ ShowControlBar(&m_wndEditListEditor, !m_wndEditListEditor.IsWindowVisible(), TRUE);
+ }
}
void CMainFrame::OnEDLIn()
{
- if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (m_iPlaybackMode == PM_FILE))
- {
- REFERENCE_TIME rt;
+ if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (m_iPlaybackMode == PM_FILE))
+ {
+ REFERENCE_TIME rt;
- pMS->GetCurrentPosition(&rt);
- m_wndEditListEditor.SetIn(rt);
- }
+ pMS->GetCurrentPosition(&rt);
+ m_wndEditListEditor.SetIn(rt);
+ }
}
void CMainFrame::OnUpdateEDLIn(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
+ pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
}
void CMainFrame::OnEDLOut()
{
- if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (m_iPlaybackMode == PM_FILE))
- {
- REFERENCE_TIME rt;
+ if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (m_iPlaybackMode == PM_FILE))
+ {
+ REFERENCE_TIME rt;
- pMS->GetCurrentPosition(&rt);
- m_wndEditListEditor.SetOut(rt);
- }
+ pMS->GetCurrentPosition(&rt);
+ m_wndEditListEditor.SetOut(rt);
+ }
}
void CMainFrame::OnUpdateEDLOut(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
+ pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
}
void CMainFrame::OnEDLNewClip()
{
- if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (m_iPlaybackMode == PM_FILE))
- {
- REFERENCE_TIME rt;
+ if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (m_iPlaybackMode == PM_FILE))
+ {
+ REFERENCE_TIME rt;
- pMS->GetCurrentPosition(&rt);
- m_wndEditListEditor.NewClip(rt);
- }
+ pMS->GetCurrentPosition(&rt);
+ m_wndEditListEditor.NewClip(rt);
+ }
}
void CMainFrame::OnUpdateEDLNewClip(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
+ pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
}
// Navigation menu
void CMainFrame::OnViewNavigation()
{
- m_wndNavigationBar.m_navdlg.UpdateElementList();
- ShowControlBar(&m_wndNavigationBar, !m_wndNavigationBar.IsWindowVisible(), TRUE);
+ m_wndNavigationBar.m_navdlg.UpdateElementList();
+ ShowControlBar(&m_wndNavigationBar, !m_wndNavigationBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewNavigation(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndNavigationBar.IsWindowVisible());
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_iPlaybackMode == PM_CAPTURE);
+ pCmdUI->SetCheck(m_wndNavigationBar.IsWindowVisible());
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_iPlaybackMode == PM_CAPTURE);
}
void CMainFrame::OnViewCapture()
{
- ShowControlBar(&m_wndCaptureBar, !m_wndCaptureBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndCaptureBar, !m_wndCaptureBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewCapture(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndCaptureBar.IsWindowVisible());
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_iPlaybackMode == PM_CAPTURE);
+ pCmdUI->SetCheck(m_wndCaptureBar.IsWindowVisible());
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_iPlaybackMode == PM_CAPTURE);
}
void CMainFrame::OnViewShaderEditor()
{
- ShowControlBar(&m_wndShaderEditorBar, !m_wndShaderEditorBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndShaderEditorBar, !m_wndShaderEditorBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewShaderEditor(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndShaderEditorBar.IsWindowVisible());
- pCmdUI->Enable(TRUE);
+ pCmdUI->SetCheck(m_wndShaderEditorBar.IsWindowVisible());
+ pCmdUI->Enable(TRUE);
}
void CMainFrame::OnViewMinimal()
{
- if(!AfxGetAppSettings().fHideCaptionMenu)
- SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- ShowControls(CS_NONE);
+ if(!AfxGetAppSettings().fHideCaptionMenu)
+ SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ ShowControls(CS_NONE);
}
void CMainFrame::OnUpdateViewMinimal(CCmdUI* pCmdUI)
@@ -5945,9 +5807,9 @@ void CMainFrame::OnUpdateViewMinimal(CCmdUI* pCmdUI)
void CMainFrame::OnViewCompact()
{
- if(AfxGetAppSettings().fHideCaptionMenu)
- SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- ShowControls(CS_TOOLBAR);
+ if(AfxGetAppSettings().fHideCaptionMenu)
+ SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ ShowControls(CS_TOOLBAR);
}
void CMainFrame::OnUpdateViewCompact(CCmdUI* pCmdUI)
@@ -5956,9 +5818,9 @@ void CMainFrame::OnUpdateViewCompact(CCmdUI* pCmdUI)
void CMainFrame::OnViewNormal()
{
- if(AfxGetAppSettings().fHideCaptionMenu)
- SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- ShowControls(CS_SEEKBAR | CS_TOOLBAR | CS_STATUSBAR | CS_INFOBAR);
+ if(AfxGetAppSettings().fHideCaptionMenu)
+ SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ ShowControls(CS_SEEKBAR|CS_TOOLBAR|CS_STATUSBAR|CS_INFOBAR);
}
void CMainFrame::OnUpdateViewNormal(CCmdUI* pCmdUI)
@@ -5967,324 +5829,264 @@ void CMainFrame::OnUpdateViewNormal(CCmdUI* pCmdUI)
void CMainFrame::OnViewFullscreen()
{
- ToggleFullscreen(true, true);
+ ToggleFullscreen(true, true);
}
void CMainFrame::OnViewFullscreenSecondary()
{
- ToggleFullscreen(true, false);
+ ToggleFullscreen(true, false);
}
void CMainFrame::OnUpdateViewFullscreen(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly || m_fFullScreen);
- pCmdUI->SetCheck(m_fFullScreen);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly || m_fFullScreen);
+ pCmdUI->SetCheck(m_fFullScreen);
}
void CMainFrame::OnViewZoom(UINT nID)
{
- ZoomVideoWindow(nID == ID_VIEW_ZOOM_50 ? 0.5 : nID == ID_VIEW_ZOOM_200 ? 2.0 : 1.0);
+ ZoomVideoWindow(nID == ID_VIEW_ZOOM_50 ? 0.5 : nID == ID_VIEW_ZOOM_200 ? 2.0 : 1.0);
}
void CMainFrame::OnUpdateViewZoom(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
}
void CMainFrame::OnViewZoomAutoFit()
{
- ZoomVideoWindow(GetZoomAutoFitScale());
+ ZoomVideoWindow(GetZoomAutoFitScale());
}
void CMainFrame::OnViewDefaultVideoFrame(UINT nID)
{
- AfxGetAppSettings().iDefaultVideoSize = nID - ID_VIEW_VF_HALF;
- m_ZoomX = m_ZoomY = 1;
- m_PosX = m_PosY = 0.5;
- MoveVideoWindow();
+ AfxGetAppSettings().iDefaultVideoSize = nID - ID_VIEW_VF_HALF;
+ m_ZoomX = m_ZoomY = 1;
+ m_PosX = m_PosY = 0.5;
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewDefaultVideoFrame(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- pCmdUI->SetRadio(AfxGetAppSettings().iDefaultVideoSize == (pCmdUI->m_nID - ID_VIEW_VF_HALF));
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetRadio(AfxGetAppSettings().iDefaultVideoSize == (pCmdUI->m_nID - ID_VIEW_VF_HALF));
}
void CMainFrame::OnViewKeepaspectratio()
{
- AfxGetAppSettings().fKeepAspectRatio = !AfxGetAppSettings().fKeepAspectRatio;
- MoveVideoWindow();
+ AfxGetAppSettings().fKeepAspectRatio = !AfxGetAppSettings().fKeepAspectRatio;
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewKeepaspectratio(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- pCmdUI->SetCheck(AfxGetAppSettings().fKeepAspectRatio);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetCheck(AfxGetAppSettings().fKeepAspectRatio);
}
void CMainFrame::OnViewCompMonDeskARDiff()
{
- AfxGetAppSettings().fCompMonDeskARDiff = !AfxGetAppSettings().fCompMonDeskARDiff;
- MoveVideoWindow();
+ AfxGetAppSettings().fCompMonDeskARDiff = !AfxGetAppSettings().fCompMonDeskARDiff;
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewCompMonDeskARDiff(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- pCmdUI->SetCheck(AfxGetAppSettings().fCompMonDeskARDiff);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetCheck(AfxGetAppSettings().fCompMonDeskARDiff);
}
void CMainFrame::OnViewPanNScan(UINT nID)
{
- if(m_iMediaLoadState != MLS_LOADED) return;
-
- int x = 0, y = 0;
- int dx = 0, dy = 0;
-
- switch(nID)
- {
- case ID_VIEW_RESET:
- m_ZoomX = m_ZoomY = 1.0;
- m_PosX = m_PosY = 0.5;
- m_AngleX = m_AngleY = m_AngleZ = 0;
- break;
- case ID_VIEW_INCSIZE:
- x = y = 1;
- break;
- case ID_VIEW_DECSIZE:
- x = y = -1;
- break;
- case ID_VIEW_INCWIDTH:
- x = 1;
- break;
- case ID_VIEW_DECWIDTH:
- x = -1;
- break;
- case ID_VIEW_INCHEIGHT:
- y = 1;
- break;
- case ID_VIEW_DECHEIGHT:
- y = -1;
- break;
- case ID_PANSCAN_CENTER:
- m_PosX = m_PosY = 0.5;
- break;
- case ID_PANSCAN_MOVELEFT:
- dx = -1;
- break;
- case ID_PANSCAN_MOVERIGHT:
- dx = 1;
- break;
- case ID_PANSCAN_MOVEUP:
- dy = -1;
- break;
- case ID_PANSCAN_MOVEDOWN:
- dy = 1;
- break;
- case ID_PANSCAN_MOVEUPLEFT:
- dx = dy = -1;
- break;
- case ID_PANSCAN_MOVEUPRIGHT:
- dx = 1;
- dy = -1;
- break;
- case ID_PANSCAN_MOVEDOWNLEFT:
- dx = -1;
- dy = 1;
- break;
- case ID_PANSCAN_MOVEDOWNRIGHT:
- dx = dy = 1;
- break;
- default:
- break;
- }
-
- if(x > 0 && m_ZoomX < 3) m_ZoomX *= 1.02;
- if(x < 0 && m_ZoomX > 0.2) m_ZoomX /= 1.02;
- if(y > 0 && m_ZoomY < 3) m_ZoomY *= 1.02;
- if(y < 0 && m_ZoomY > 0.2) m_ZoomY /= 1.02;
-
- if(dx < 0 && m_PosX > 0) m_PosX = max(m_PosX - 0.005 * m_ZoomX, 0);
- if(dx > 0 && m_PosX < 1) m_PosX = min(m_PosX + 0.005 * m_ZoomX, 1);
- if(dy < 0 && m_PosY > 0) m_PosY = max(m_PosY - 0.005 * m_ZoomY, 0);
- if(dy > 0 && m_PosY < 1) m_PosY = min(m_PosY + 0.005 * m_ZoomY, 1);
-
- MoveVideoWindow(true);
+ if(m_iMediaLoadState != MLS_LOADED) return;
+
+ int x = 0, y = 0;
+ int dx = 0, dy = 0;
+
+ switch(nID)
+ {
+ case ID_VIEW_RESET: m_ZoomX = m_ZoomY = 1.0; m_PosX = m_PosY = 0.5; m_AngleX = m_AngleY = m_AngleZ = 0; break;
+ case ID_VIEW_INCSIZE: x = y = 1; break;
+ case ID_VIEW_DECSIZE: x = y = -1; break;
+ case ID_VIEW_INCWIDTH: x = 1; break;
+ case ID_VIEW_DECWIDTH: x = -1; break;
+ case ID_VIEW_INCHEIGHT: y = 1; break;
+ case ID_VIEW_DECHEIGHT: y = -1; break;
+ case ID_PANSCAN_CENTER: m_PosX = m_PosY = 0.5; break;
+ case ID_PANSCAN_MOVELEFT: dx = -1; break;
+ case ID_PANSCAN_MOVERIGHT: dx = 1; break;
+ case ID_PANSCAN_MOVEUP: dy = -1; break;
+ case ID_PANSCAN_MOVEDOWN: dy = 1; break;
+ case ID_PANSCAN_MOVEUPLEFT: dx = dy = -1; break;
+ case ID_PANSCAN_MOVEUPRIGHT: dx = 1; dy = -1; break;
+ case ID_PANSCAN_MOVEDOWNLEFT: dx = -1; dy = 1; break;
+ case ID_PANSCAN_MOVEDOWNRIGHT: dx = dy = 1; break;
+ default: break;
+ }
+
+ if(x > 0 && m_ZoomX < 3) m_ZoomX *= 1.02;
+ if(x < 0 && m_ZoomX > 0.2) m_ZoomX /= 1.02;
+ if(y > 0 && m_ZoomY < 3) m_ZoomY *= 1.02;
+ if(y < 0 && m_ZoomY > 0.2) m_ZoomY /= 1.02;
+
+ if(dx < 0 && m_PosX > 0) m_PosX = max(m_PosX - 0.005*m_ZoomX, 0);
+ if(dx > 0 && m_PosX < 1) m_PosX = min(m_PosX + 0.005*m_ZoomX, 1);
+ if(dy < 0 && m_PosY > 0) m_PosY = max(m_PosY - 0.005*m_ZoomY, 0);
+ if(dy > 0 && m_PosY < 1) m_PosY = min(m_PosY + 0.005*m_ZoomY, 1);
+
+ MoveVideoWindow(true);
}
void CMainFrame::OnUpdateViewPanNScan(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
}
void CMainFrame::OnViewPanNScanPresets(UINT nID)
{
- if(m_iMediaLoadState != MLS_LOADED) return;
-
- AppSettings& s = AfxGetAppSettings();
-
- nID -= ID_PANNSCAN_PRESETS_START;
-
- if(nID == s.m_pnspresets.GetCount())
- {
- CPnSPresetsDlg dlg;
- dlg.m_pnspresets.Copy(s.m_pnspresets);
- if(dlg.DoModal() == IDOK)
- {
- s.m_pnspresets.Copy(dlg.m_pnspresets);
- s.UpdateData(true);
- }
- return;
- }
-
- m_PosX = 0.5;
- m_PosY = 0.5;
- m_ZoomX = 1.0;
- m_ZoomY = 1.0;
-
- CString str = s.m_pnspresets[nID];
-
- int i = 0, j = 0;
- for(CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++)
- {
- float f = 0;
- if(_stscanf_s(token, _T("%f"), &f) != 1) continue;
-
- switch(j)
- {
- case 0:
- break;
- case 1:
- m_PosX = f;
- break;
- case 2:
- m_PosY = f;
- break;
- case 3:
- m_ZoomX = f;
- break;
- case 4:
- m_ZoomY = f;
- break;
- default:
- break;
- }
- }
-
- if(j != 5) return;
-
- m_PosX = min(max(m_PosX, 0), 1);
- m_PosY = min(max(m_PosY, 0), 1);
- m_ZoomX = min(max(m_ZoomX, 0.2), 3);
- m_ZoomY = min(max(m_ZoomY, 0.2), 3);
-
- MoveVideoWindow(true);
+ if(m_iMediaLoadState != MLS_LOADED) return;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ nID -= ID_PANNSCAN_PRESETS_START;
+
+ if(nID == s.m_pnspresets.GetCount())
+ {
+ CPnSPresetsDlg dlg;
+ dlg.m_pnspresets.Copy(s.m_pnspresets);
+ if(dlg.DoModal() == IDOK)
+ {
+ s.m_pnspresets.Copy(dlg.m_pnspresets);
+ s.UpdateData(true);
+ }
+ return;
+ }
+
+ m_PosX = 0.5;
+ m_PosY = 0.5;
+ m_ZoomX = 1.0;
+ m_ZoomY = 1.0;
+
+ CString str = s.m_pnspresets[nID];
+
+ int i = 0, j = 0;
+ for(CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++)
+ {
+ float f = 0;
+ if(_stscanf_s(token, _T("%f"), &f) != 1) continue;
+
+ switch(j)
+ {
+ case 0: break;
+ case 1: m_PosX = f; break;
+ case 2: m_PosY = f; break;
+ case 3: m_ZoomX = f; break;
+ case 4: m_ZoomY = f; break;
+ default: break;
+ }
+ }
+
+ if(j != 5) return;
+
+ m_PosX = min(max(m_PosX, 0), 1);
+ m_PosY = min(max(m_PosY, 0), 1);
+ m_ZoomX = min(max(m_ZoomX, 0.2), 3);
+ m_ZoomY = min(max(m_ZoomY, 0.2), 3);
+
+ MoveVideoWindow(true);
}
void CMainFrame::OnUpdateViewPanNScanPresets(CCmdUI* pCmdUI)
{
- int nID = pCmdUI->m_nID - ID_PANNSCAN_PRESETS_START;
- AppSettings& s = AfxGetAppSettings();
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && nID >= 0 && nID <= s.m_pnspresets.GetCount());
+ int nID = pCmdUI->m_nID - ID_PANNSCAN_PRESETS_START;
+ AppSettings& s = AfxGetAppSettings();
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && nID >= 0 && nID <= s.m_pnspresets.GetCount());
}
void CMainFrame::OnViewRotate(UINT nID)
{
- if(!m_pCAP) return;
+ if(!m_pCAP) return;
- switch(nID)
- {
- case ID_PANSCAN_ROTATEXP:
- m_AngleX += 2;
- break;
- case ID_PANSCAN_ROTATEXM:
- m_AngleX -= 2;
- break;
- case ID_PANSCAN_ROTATEYP:
- m_AngleY += 2;
- break;
- case ID_PANSCAN_ROTATEYM:
- m_AngleY -= 2;
- break;
- case ID_PANSCAN_ROTATEZP:
- m_AngleZ += 2;
- break;
- case ID_PANSCAN_ROTATEZM:
- m_AngleZ -= 2;
- break;
- default:
- return;
- }
+ switch(nID)
+ {
+ case ID_PANSCAN_ROTATEXP: m_AngleX += 2; break;
+ case ID_PANSCAN_ROTATEXM: m_AngleX -= 2; break;
+ case ID_PANSCAN_ROTATEYP: m_AngleY += 2; break;
+ case ID_PANSCAN_ROTATEYM: m_AngleY -= 2; break;
+ case ID_PANSCAN_ROTATEZP: m_AngleZ += 2; break;
+ case ID_PANSCAN_ROTATEZM: m_AngleZ -= 2; break;
+ default: return;
+ }
- m_pCAP->SetVideoAngle(Vector(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ)));
+ m_pCAP->SetVideoAngle(Vector(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ)));
- CString info;
- info.Format(_T("x: %d, y: %d, z: %d"), m_AngleX, m_AngleY, m_AngleZ);
- SendStatusMessage(info, 3000);
+ CString info;
+ info.Format(_T("x: %d, y: %d, z: %d"), m_AngleX, m_AngleY, m_AngleZ);
+ SendStatusMessage(info, 3000);
}
void CMainFrame::OnUpdateViewRotate(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && m_pCAP);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && m_pCAP);
}
// FIXME
-const static SIZE s_ar[] = {{0, 0}, {4, 3}, {5, 4}, {16, 9}, {235, 100}, {185, 100}};
+const static SIZE s_ar[] = {{0,0}, {4,3}, {5,4}, {16,9}, {235,100}, {185,100}};
void CMainFrame::OnViewAspectRatio(UINT nID)
{
- CSize& ar = AfxGetAppSettings().AspectRatio;
+ CSize& ar = AfxGetAppSettings().AspectRatio;
- ar = s_ar[nID - ID_ASPECTRATIO_START];
+ ar = s_ar[nID - ID_ASPECTRATIO_START];
- CString info;
- if(ar.cx && ar.cy) info.Format(ResStr(IDS_MAINFRM_68), ar.cx, ar.cy);
- else info.Format(ResStr(IDS_MAINFRM_69));
- SendStatusMessage(info, 3000);
+ CString info;
+ if(ar.cx && ar.cy) info.Format(ResStr(IDS_MAINFRM_68), ar.cx, ar.cy);
+ else info.Format(ResStr(IDS_MAINFRM_69));
+ SendStatusMessage(info, 3000);
- MoveVideoWindow();
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewAspectRatio(CCmdUI* pCmdUI)
{
- pCmdUI->SetRadio(AfxGetAppSettings().AspectRatio == s_ar[pCmdUI->m_nID - ID_ASPECTRATIO_START]);
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetRadio(AfxGetAppSettings().AspectRatio == s_ar[pCmdUI->m_nID - ID_ASPECTRATIO_START]);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
}
void CMainFrame::OnViewAspectRatioNext()
{
- CSize& ar = AfxGetAppSettings().AspectRatio;
+ CSize& ar = AfxGetAppSettings().AspectRatio;
- UINT nID = ID_ASPECTRATIO_START;
+ UINT nID = ID_ASPECTRATIO_START;
- for(int i = 0; i < countof(s_ar); i++)
- {
- if(ar == s_ar[i])
- {
- nID += (i + 1) % countof(s_ar);
- break;
- }
- }
+ for(int i = 0; i < countof(s_ar); i++)
+ {
+ if(ar == s_ar[i])
+ {
+ nID += (i + 1) % countof(s_ar);
+ break;
+ }
+ }
- OnViewAspectRatio(nID);
+ OnViewAspectRatio(nID);
}
void CMainFrame::OnViewOntop(UINT nID)
{
- nID -= ID_ONTOP_NEVER;
- if(AfxGetAppSettings().iOnTop == nID)
- nID = !nID;
- SetAlwaysOnTop(nID);
+ nID -= ID_ONTOP_NEVER;
+ if(AfxGetAppSettings().iOnTop == nID)
+ nID = !nID;
+ SetAlwaysOnTop(nID);
}
void CMainFrame::OnUpdateViewOntop(CCmdUI* pCmdUI)
{
- pCmdUI->SetRadio(AfxGetAppSettings().iOnTop == (pCmdUI->m_nID - ID_ONTOP_NEVER));
+ pCmdUI->SetRadio(AfxGetAppSettings().iOnTop == (pCmdUI->m_nID - ID_ONTOP_NEVER));
}
void CMainFrame::OnViewOptions()
{
- ShowOptions();
+ ShowOptions();
}
// play
@@ -6292,2951 +6094,2838 @@ void CMainFrame::OnViewOptions()
void CMainFrame::OnPlayPlay()
{
- if(m_iMediaLoadState == MLS_CLOSED)
- OpenCurPlaylistItem();
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- if(GetMediaState() == State_Stopped) m_iSpeedLevel = 0;
-
- if(m_iPlaybackMode == PM_FILE)
- {
- m_iSpeedLevel = 0;
- if(m_fEndOfStream) SendMessage(WM_COMMAND, ID_PLAY_STOP);
- pMS->SetRate(1.0);
- pMC->Run();
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- double dRate = 1.0;
- m_iSpeedLevel = 0;
-
- pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
- pDVDC->Pause(FALSE);
- pMC->Run();
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- pMC->Stop(); // audio preview won't be in sync if we run it from paused state
- pMC->Run();
- if(AfxGetAppSettings().iDefaultCaptureDevice == 1)
- {
- CComQIPtr<IBDATuner> pTun = pGB;
- if(pTun)
- {
- pTun->SetChannel(AfxGetAppSettings().DVBLastChannel);
- DisplayCurrentChannelOSD();
- }
- }
- }
-
- SetTimer(TIMER_STREAMPOSPOLLER, 40, NULL);
- SetTimer(TIMER_STREAMPOSPOLLER2, 500, NULL);
- SetTimer(TIMER_STATS, 1000, NULL);
-
- if(m_fFrameSteppingActive) // FIXME
- {
- m_fFrameSteppingActive = false;
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- }
-
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- }
-
- MoveVideoWindow();
- m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PLAYING), 3000);
- SetPlayState(PS_PLAY);
+ if(m_iMediaLoadState == MLS_CLOSED)
+ OpenCurPlaylistItem();
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ if(GetMediaState() == State_Stopped) m_iSpeedLevel = 0;
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ m_iSpeedLevel = 0;
+ if(m_fEndOfStream) SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ pMS->SetRate (1.0);
+ pMC->Run();
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ double dRate = 1.0;
+ m_iSpeedLevel = 0;
+
+ pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
+ pDVDC->Pause(FALSE);
+ pMC->Run();
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ pMC->Stop(); // audio preview won't be in sync if we run it from paused state
+ pMC->Run();
+ if (AfxGetAppSettings().iDefaultCaptureDevice == 1)
+ {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun)
+ {
+ pTun->SetChannel (AfxGetAppSettings().DVBLastChannel);
+ DisplayCurrentChannelOSD();
+ }
+ }
+ }
+
+ SetTimer(TIMER_STREAMPOSPOLLER, 40, NULL);
+ SetTimer(TIMER_STREAMPOSPOLLER2, 500, NULL);
+ SetTimer(TIMER_STATS, 1000, NULL);
+
+ if(m_fFrameSteppingActive) // FIXME
+ {
+ m_fFrameSteppingActive = false;
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ }
+
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ }
+
+ MoveVideoWindow();
+ m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PLAYING), 3000);
+ SetPlayState (PS_PLAY);
}
void CMainFrame::OnPlayPauseI()
{
- if(m_iMediaLoadState == MLS_LOADED)
- {
- //SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ //SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- if(m_iPlaybackMode == PM_FILE)
- {
- pMC->Pause();
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- pMC->Pause();
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- pMC->Pause();
- }
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ pMC->Pause();
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ pMC->Pause();
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ pMC->Pause();
+ }
- SetTimer(TIMER_STREAMPOSPOLLER, 40, NULL);
- SetTimer(TIMER_STREAMPOSPOLLER2, 500, NULL);
- SetTimer(TIMER_STATS, 1000, NULL);
+ SetTimer(TIMER_STREAMPOSPOLLER, 40, NULL);
+ SetTimer(TIMER_STREAMPOSPOLLER2, 500, NULL);
+ SetTimer(TIMER_STATS, 1000, NULL);
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- }
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ }
- MoveVideoWindow();
- m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PAUSED), 3000);
- SetPlayState(PS_PAUSE);
+ MoveVideoWindow();
+ m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PAUSED), 3000);
+ SetPlayState (PS_PAUSE);
}
void CMainFrame::OnPlayPause()
{
- // Support ffdshow queueing.
- // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with ReceiveMine.
- if(queue_ffdshow_support)
- {
- CAutoLock lck(&g_ffdshowReceive);
- return OnPlayPauseI();
- }
- OnPlayPauseI();
+ // Support ffdshow queueing.
+ // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with ReceiveMine.
+ if(queue_ffdshow_support)
+ {
+ CAutoLock lck(&g_ffdshowReceive);
+ return OnPlayPauseI();
+ }
+ OnPlayPauseI();
}
void CMainFrame::OnPlayPlaypause()
{
- OAFilterState fs = GetMediaState();
- if(fs == State_Running) SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- else if(fs == State_Stopped || fs == State_Paused) SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ OAFilterState fs = GetMediaState();
+ if(fs == State_Running) SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ else if(fs == State_Stopped || fs == State_Paused) SendMessage(WM_COMMAND, ID_PLAY_PLAY);
}
void CMainFrame::OnPlayStop()
{
- if(m_iMediaLoadState == MLS_LOADED)
- {
- if(m_iPlaybackMode == PM_FILE)
- {
- LONGLONG pos = 0;
- pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- pMC->Stop();
-
- // BUG: after pause or stop the netshow url source filter won't continue
- // on the next play command, unless we cheat it by setting the file name again.
- //
- // Note: WMPx may be using some undocumented interface to restart streaming.
-
- BeginEnumFilters(pGB, pEF, pBF)
- {
- CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF;
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if(pAMNS && pFSF)
- {
- WCHAR* pFN = NULL;
- AM_MEDIA_TYPE mt;
- if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN)
- {
- pFSF->Load(pFN, NULL);
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- pDVDC->SetOption(DVD_ResetOnStop, TRUE);
- pMC->Stop();
- pDVDC->SetOption(DVD_ResetOnStop, FALSE);
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- pMC->Stop();
- }
-
- m_iSpeedLevel = 0;
-
- if(m_fFrameSteppingActive) // FIXME
- {
- m_fFrameSteppingActive = false;
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- }
-
- m_fEndOfStream = false;
- }
-
- m_nLoops = 0;
-
- if(m_hWnd)
- {
- KillTimer(TIMER_STREAMPOSPOLLER2);
- KillTimer(TIMER_STREAMPOSPOLLER);
- KillTimer(TIMER_STATS);
-
- MoveVideoWindow();
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
- GUID tf;
- pMS->GetTimeFormat(&tf);
- m_wndStatusBar.SetStatusTimer(m_wndSeekBar.GetPosReal(), stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
-
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- }
- }
-
- m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_STOPPED), 3000);
- SetPlayState(PS_STOP);
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ LONGLONG pos = 0;
+ pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ pMC->Stop();
+
+ // BUG: after pause or stop the netshow url source filter won't continue
+ // on the next play command, unless we cheat it by setting the file name again.
+ //
+ // Note: WMPx may be using some undocumented interface to restart streaming.
+
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF;
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if(pAMNS && pFSF)
+ {
+ WCHAR* pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN)
+ {
+ pFSF->Load(pFN, NULL);
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ pDVDC->SetOption(DVD_ResetOnStop, TRUE);
+ pMC->Stop();
+ pDVDC->SetOption(DVD_ResetOnStop, FALSE);
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ pMC->Stop();
+ }
+
+ m_iSpeedLevel = 0;
+
+ if(m_fFrameSteppingActive) // FIXME
+ {
+ m_fFrameSteppingActive = false;
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ }
+
+ m_fEndOfStream = false;
+ }
+
+ m_nLoops = 0;
+
+ if(m_hWnd)
+ {
+ KillTimer(TIMER_STREAMPOSPOLLER2);
+ KillTimer(TIMER_STREAMPOSPOLLER);
+ KillTimer(TIMER_STATS);
+
+ MoveVideoWindow();
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+ GUID tf;
+ pMS->GetTimeFormat(&tf);
+ m_wndStatusBar.SetStatusTimer(m_wndSeekBar.GetPosReal(), stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
+
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ }
+ }
+
+ m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_STOPPED), 3000);
+ SetPlayState (PS_STOP);
}
void CMainFrame::OnUpdatePlayPauseStop(CCmdUI* pCmdUI)
{
- OAFilterState fs = m_fFrameSteppingActive ? State_Paused : GetMediaState();
+ OAFilterState fs = m_fFrameSteppingActive ? State_Paused : GetMediaState();
- pCmdUI->SetCheck(fs == State_Running && pCmdUI->m_nID == ID_PLAY_PLAY
- || fs == State_Paused && pCmdUI->m_nID == ID_PLAY_PAUSE
- || fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_STOP
- || (fs == State_Paused || fs == State_Running) && pCmdUI->m_nID == ID_PLAY_PLAYPAUSE);
+ pCmdUI->SetCheck(fs == State_Running && pCmdUI->m_nID == ID_PLAY_PLAY
+ || fs == State_Paused && pCmdUI->m_nID == ID_PLAY_PAUSE
+ || fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_STOP
+ || (fs == State_Paused || fs == State_Running) && pCmdUI->m_nID == ID_PLAY_PLAYPAUSE);
- bool fEnable = false;
+ bool fEnable = false;
- if(fs >= 0)
- {
- if(m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE)
- {
- fEnable = true;
+ if(fs >= 0)
+ {
+ if(m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE)
+ {
+ fEnable = true;
- if(fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE && m_fRealMediaGraph) fEnable = false; // can't go into paused state from stopped with rm
- else if(m_fCapturing) fEnable = false;
- else if(m_fLiveWM && pCmdUI->m_nID == ID_PLAY_PAUSE) fEnable = false;
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- fEnable = m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
- && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu;
+ if(fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE && m_fRealMediaGraph) fEnable = false; // can't go into paused state from stopped with rm
+ else if(m_fCapturing) fEnable = false;
+ else if(m_fLiveWM && pCmdUI->m_nID == ID_PLAY_PAUSE) fEnable = false;
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ fEnable = m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
+ && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu;
- if(fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE) fEnable = false;
- }
- }
- else if(pCmdUI->m_nID == ID_PLAY_PLAY && m_wndPlaylistBar.GetCount() > 0)
- fEnable = true;
+ if(fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE) fEnable = false;
+ }
+ }
+ else if (pCmdUI->m_nID == ID_PLAY_PLAY && m_wndPlaylistBar.GetCount() > 0)
+ fEnable = true;
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayFramestep(UINT nID)
{
- REFERENCE_TIME rt;
- AppSettings& s = AfxGetAppSettings();
-
- if(pFS && m_fQuicktimeGraph)
- {
- if(GetMediaState() != State_Paused)
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- pFS->Step(nID == ID_PLAY_FRAMESTEP ? 1 : -1, NULL);
- }
- else if(pFS && nID == ID_PLAY_FRAMESTEP)
- {
- if(GetMediaState() != State_Paused && !queue_ffdshow_support)
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- // To support framestep back, store the initial position when
- // stepping forward
- if(m_nStepForwardCount == 0)
- pMS->GetCurrentPosition(&m_rtStepForwardStart);
-
- m_fFrameSteppingActive = true;
-
- m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
- pBA->put_Volume(-10000);
-
- pFS->Step(1, NULL);
- }
- else if(S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME))
- {
- if(GetMediaState() != State_Paused)
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- pMS->SetTimeFormat(&TIME_FORMAT_FRAME);
- pMS->GetCurrentPosition(&rt);
- if(nID == ID_PLAY_FRAMESTEP) rt++;
- else if(nID == ID_PLAY_FRAMESTEPCANCEL) rt--;
- pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- pMS->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME);
- }
- else //if (s.iDSVideoRendererType != VIDRNDT_DS_VMR9WINDOWED && s.iDSVideoRendererType != VIDRNDT_DS_VMR9RENDERLESS)
- {
- if(GetMediaState() != State_Paused)
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- REFERENCE_TIME rtAvgTime;
- BeginEnumFilters(pGB, pEF, pBF)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- AM_MEDIA_TYPE mt;
- pPin->ConnectionMediaType(&mt);
-
- if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo)
- {
- rtAvgTime = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- }
- else if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2)
- {
- rtAvgTime = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
- }
- }
- EndEnumPins
- }
- EndEnumFilters
-
- // Exit of framestep forward : calculate the initial position
- if(m_nStepForwardCount != 0)
- {
- pFS->CancelStep();
- rt = m_rtStepForwardStart + m_nStepForwardCount * rtAvgTime;
- m_nStepForwardCount = 0;
- }
- else
- pMS->GetCurrentPosition(&rt);
- if(nID == ID_PLAY_FRAMESTEP)
- rt += rtAvgTime;
- else if(nID == ID_PLAY_FRAMESTEPCANCEL)
- rt -= rtAvgTime;
- pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
+ REFERENCE_TIME rt;
+ AppSettings& s = AfxGetAppSettings();
+
+ if(pFS && m_fQuicktimeGraph)
+ {
+ if(GetMediaState() != State_Paused)
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ pFS->Step(nID == ID_PLAY_FRAMESTEP ? 1 : -1, NULL);
+ }
+ else if(pFS && nID == ID_PLAY_FRAMESTEP)
+ {
+ if(GetMediaState() != State_Paused && !queue_ffdshow_support)
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ // To support framestep back, store the initial position when
+ // stepping forward
+ if (m_nStepForwardCount == 0)
+ pMS->GetCurrentPosition(&m_rtStepForwardStart);
+
+ m_fFrameSteppingActive = true;
+
+ m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
+ pBA->put_Volume(-10000);
+
+ pFS->Step(1, NULL);
+ }
+ else if(S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME))
+ {
+ if(GetMediaState() != State_Paused)
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ pMS->SetTimeFormat(&TIME_FORMAT_FRAME);
+ pMS->GetCurrentPosition(&rt);
+ if(nID == ID_PLAY_FRAMESTEP) rt++;
+ else if(nID == ID_PLAY_FRAMESTEPCANCEL) rt--;
+ pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ pMS->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME);
+ }
+ else //if (s.iDSVideoRendererType != VIDRNDT_DS_VMR9WINDOWED && s.iDSVideoRendererType != VIDRNDT_DS_VMR9RENDERLESS)
+ {
+ if(GetMediaState() != State_Paused)
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ REFERENCE_TIME rtAvgTime;
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ AM_MEDIA_TYPE mt;
+ pPin->ConnectionMediaType(&mt);
+
+ if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo)
+ {
+ rtAvgTime = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
+ }
+ else if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2)
+ {
+ rtAvgTime = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
+ }
+ }
+ EndEnumPins
+ }
+ EndEnumFilters
+
+ // Exit of framestep forward : calculate the initial position
+ if (m_nStepForwardCount != 0)
+ {
+ pFS->CancelStep();
+ rt = m_rtStepForwardStart + m_nStepForwardCount*rtAvgTime;
+ m_nStepForwardCount = 0;
+ }
+ else
+ pMS->GetCurrentPosition(&rt);
+ if(nID == ID_PLAY_FRAMESTEP)
+ rt += rtAvgTime;
+ else if(nID == ID_PLAY_FRAMESTEPCANCEL)
+ rt -= rtAvgTime;
+ pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
}
void CMainFrame::OnUpdatePlayFramestep(CCmdUI* pCmdUI)
{
- bool fEnable = false;
+ bool fEnable = false;
- if(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly
- && (m_iPlaybackMode != PM_DVD || m_iDVDDomain == DVD_DOMAIN_Title)
- && m_iPlaybackMode != PM_CAPTURE
- && !m_fLiveWM)
- {
- REFTIME AvgTimePerFrame = 0;
+ if(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly
+ && (m_iPlaybackMode != PM_DVD || m_iDVDDomain == DVD_DOMAIN_Title)
+ && m_iPlaybackMode != PM_CAPTURE
+ && !m_fLiveWM)
+ {
+ REFTIME AvgTimePerFrame = 0;
if(S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME)
- || pCmdUI->m_nID == ID_PLAY_FRAMESTEP || pCmdUI->m_nID == ID_PLAY_FRAMESTEPCANCEL && pFS && pFS->CanStep(0, NULL) == S_OK
- || m_fQuicktimeGraph && pFS)
- {
- fEnable = true;
- }
- }
+ || pCmdUI->m_nID == ID_PLAY_FRAMESTEP || pCmdUI->m_nID == ID_PLAY_FRAMESTEPCANCEL && pFS && pFS->CanStep(0, NULL) == S_OK
+ || m_fQuicktimeGraph && pFS)
+ {
+ fEnable = true;
+ }
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlaySeek(UINT nID)
{
- AppSettings& s = AfxGetAppSettings();
-
- REFERENCE_TIME dt =
- nID == ID_PLAY_SEEKBACKWARDSMALL ? -10000i64 * s.nJumpDistS :
- nID == ID_PLAY_SEEKFORWARDSMALL ? +10000i64 * s.nJumpDistS :
- nID == ID_PLAY_SEEKBACKWARDMED ? -10000i64 * s.nJumpDistM :
- nID == ID_PLAY_SEEKFORWARDMED ? +10000i64 * s.nJumpDistM :
- nID == ID_PLAY_SEEKBACKWARDLARGE ? -10000i64 * s.nJumpDistL :
- nID == ID_PLAY_SEEKFORWARDLARGE ? +10000i64 * s.nJumpDistL :
- 0;
+ AppSettings& s = AfxGetAppSettings();
+
+ REFERENCE_TIME dt =
+ nID == ID_PLAY_SEEKBACKWARDSMALL ? -10000i64*s.nJumpDistS :
+ nID == ID_PLAY_SEEKFORWARDSMALL ? +10000i64*s.nJumpDistS :
+ nID == ID_PLAY_SEEKBACKWARDMED ? -10000i64*s.nJumpDistM :
+ nID == ID_PLAY_SEEKFORWARDMED ? +10000i64*s.nJumpDistM :
+ nID == ID_PLAY_SEEKBACKWARDLARGE ? -10000i64*s.nJumpDistL :
+ nID == ID_PLAY_SEEKFORWARDLARGE ? +10000i64*s.nJumpDistL :
+ 0;
- if(!dt) return;
+ if(!dt) return;
- // HACK: the custom graph should support frame based seeking instead
- if(m_fShockwaveGraph) dt /= 10000i64 * 100;
+ // HACK: the custom graph should support frame based seeking instead
+ if(m_fShockwaveGraph) dt /= 10000i64*100;
- SeekTo(m_wndSeekBar.GetPos() + dt);
+ SeekTo(m_wndSeekBar.GetPos() + dt);
}
static int rangebsearch(REFERENCE_TIME val, CAtlArray<REFERENCE_TIME>& rta)
{
- int i = 0, j = rta.GetCount() - 1, ret = -1;
+ int i = 0, j = rta.GetCount() - 1, ret = -1;
- if(j >= 0 && val >= rta[j]) return(j);
+ if(j >= 0 && val >= rta[j]) return(j);
- while(i < j)
- {
- int mid = (i + j) >> 1;
- REFERENCE_TIME midt = rta[mid];
- if(val == midt)
- {
- ret = mid;
- break;
- }
- else if(val < midt)
- {
- ret = -1;
- if(j == mid) mid--;
- j = mid;
- }
- else if(val > midt)
- {
- ret = mid;
- if(i == mid) mid++;
- i = mid;
- }
- }
+ while(i < j)
+ {
+ int mid = (i + j) >> 1;
+ REFERENCE_TIME midt = rta[mid];
+ if(val == midt) {ret = mid; break;}
+ else if(val < midt) {ret = -1; if(j == mid) mid--; j = mid;}
+ else if(val > midt) {ret = mid; if(i == mid) mid++; i = mid;}
+ }
- return(ret);
+ return(ret);
}
void CMainFrame::OnPlaySeekKey(UINT nID)
{
- if(m_kfs.GetCount() > 0)
- {
- HRESULT hr;
+ if(m_kfs.GetCount() > 0)
+ {
+ HRESULT hr;
- if(GetMediaState() == State_Stopped)
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ if(GetMediaState() == State_Stopped)
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- REFERENCE_TIME rtCurrent, rtDur;
- hr = pMS->GetCurrentPosition(&rtCurrent);
- hr = pMS->GetDuration(&rtDur);
+ REFERENCE_TIME rtCurrent, rtDur;
+ hr = pMS->GetCurrentPosition(&rtCurrent);
+ hr = pMS->GetDuration(&rtDur);
- int dec = 1;
- int i = rangebsearch(rtCurrent, m_kfs);
- if(i > 0) dec = (UINT)max(min(rtCurrent - m_kfs[i-1], 10000000), 0);
+ int dec = 1;
+ int i = rangebsearch(rtCurrent, m_kfs);
+ if(i > 0) dec = (UINT)max(min(rtCurrent - m_kfs[i-1], 10000000), 0);
- rtCurrent =
- nID == ID_PLAY_SEEKKEYBACKWARD ? max(rtCurrent - dec, 0) :
- nID == ID_PLAY_SEEKKEYFORWARD ? rtCurrent : 0;
+ rtCurrent =
+ nID == ID_PLAY_SEEKKEYBACKWARD ? max(rtCurrent - dec, 0) :
+ nID == ID_PLAY_SEEKKEYFORWARD ? rtCurrent : 0;
- i = rangebsearch(rtCurrent, m_kfs);
+ i = rangebsearch(rtCurrent, m_kfs);
- if(nID == ID_PLAY_SEEKKEYBACKWARD)
- rtCurrent = m_kfs[max(i, 0)];
- else if(nID == ID_PLAY_SEEKKEYFORWARD && i < m_kfs.GetCount() - 1)
- rtCurrent = m_kfs[i+1];
- else
- return;
+ if(nID == ID_PLAY_SEEKKEYBACKWARD)
+ rtCurrent = m_kfs[max(i, 0)];
+ else if(nID == ID_PLAY_SEEKKEYFORWARD && i < m_kfs.GetCount()-1)
+ rtCurrent = m_kfs[i+1];
+ else
+ return;
- // HACK: if d3d or something changes fpu control word the values of
- // m_kfs may be different now (if it was asked again), adding a little
- // to the seek position eliminates this error usually.
+ // HACK: if d3d or something changes fpu control word the values of
+ // m_kfs may be different now (if it was asked again), adding a little
+ // to the seek position eliminates this error usually.
- rtCurrent += 10;
+ rtCurrent += 10;
- hr = pMS->SetPositions(
- &rtCurrent, AM_SEEKING_AbsolutePositioning | AM_SEEKING_SeekToKeyFrame,
- NULL, AM_SEEKING_NoPositioning);
- }
+ hr = pMS->SetPositions(
+ &rtCurrent, AM_SEEKING_AbsolutePositioning|AM_SEEKING_SeekToKeyFrame,
+ NULL, AM_SEEKING_NoPositioning);
+ }
}
void CMainFrame::OnUpdatePlaySeek(CCmdUI* pCmdUI)
{
- bool fEnable = false;
+ bool fEnable = false;
- OAFilterState fs = GetMediaState();
+ OAFilterState fs = GetMediaState();
- if(m_iMediaLoadState == MLS_LOADED && (fs == State_Paused || fs == State_Running))
- {
- fEnable = true;
- if(m_iPlaybackMode == PM_DVD && (m_iDVDDomain != DVD_DOMAIN_Title || fs != State_Running)) fEnable = false;
- else if(m_iPlaybackMode == PM_CAPTURE) fEnable = false;
- }
+ if(m_iMediaLoadState == MLS_LOADED && (fs == State_Paused || fs == State_Running))
+ {
+ fEnable = true;
+ if(m_iPlaybackMode == PM_DVD && (m_iDVDDomain != DVD_DOMAIN_Title || fs != State_Running)) fEnable = false;
+ else if(m_iPlaybackMode == PM_CAPTURE) fEnable = false;
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayGoto()
{
- if((m_iMediaLoadState != MLS_LOADED) || m_pFullscreenWnd->IsWindow())
- return;
+ if ((m_iMediaLoadState != MLS_LOADED) || m_pFullscreenWnd->IsWindow())
+ return;
- REFTIME atpf = 0;
- if(FAILED(pBV->get_AvgTimePerFrame(&atpf)) || atpf < 0)
- {
- atpf = 0;
+ REFTIME atpf = 0;
+ if(FAILED(pBV->get_AvgTimePerFrame(&atpf)) || atpf < 0)
+ {
+ atpf = 0;
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(atpf > 0) break;
-
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(atpf > 0) break;
-
- AM_MEDIA_TYPE mt;
- pPin->ConnectionMediaType(&mt);
-
- if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo)
- {
- atpf = (REFTIME)((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
- }
- else if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2)
- {
- atpf = (REFTIME)((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
- }
- }
- EndEnumPins
- }
- EndEnumFilters
- }
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(atpf > 0) break;
+
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(atpf > 0) break;
- CGoToDlg dlg((int)(m_wndSeekBar.GetPos() / 10000), atpf > 0 ? (float)(1.0 / atpf) : 0);
- if(IDOK != dlg.DoModal() || dlg.m_time < 0) return;
+ AM_MEDIA_TYPE mt;
+ pPin->ConnectionMediaType(&mt);
- SeekTo(10000i64 * dlg.m_time);
+ if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo)
+ {
+ atpf = (REFTIME)((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
+ }
+ else if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2)
+ {
+ atpf = (REFTIME)((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
+ }
+ }
+ EndEnumPins
+ }
+ EndEnumFilters
+ }
+
+ CGoToDlg dlg((int)(m_wndSeekBar.GetPos()/10000), atpf > 0 ? (float)(1.0/atpf) : 0);
+ if(IDOK != dlg.DoModal() || dlg.m_time < 0) return;
+
+ SeekTo(10000i64 * dlg.m_time);
}
void CMainFrame::OnUpdateGoto(CCmdUI* pCmdUI)
{
- bool fEnable = false;
+ bool fEnable = false;
- if(m_iMediaLoadState == MLS_LOADED)
- {
- fEnable = true;
- if(m_iPlaybackMode == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) fEnable = false;
- else if(m_iPlaybackMode == PM_CAPTURE) fEnable = false;
- }
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ fEnable = true;
+ if(m_iPlaybackMode == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) fEnable = false;
+ else if(m_iPlaybackMode == PM_CAPTURE) fEnable = false;
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayChangeRate(UINT nID)
{
- if(m_iMediaLoadState != MLS_LOADED)
- return;
+ if(m_iMediaLoadState != MLS_LOADED)
+ return;
- if(m_iPlaybackMode == PM_CAPTURE)
- {
- if(GetMediaState() != State_Running)
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ if(GetMediaState() != State_Running)
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- long lChannelMin = 0, lChannelMax = 0;
- pAMTuner->ChannelMinMax(&lChannelMin, &lChannelMax);
- long lChannel = 0, lVivSub = 0, lAudSub = 0;
- pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
+ long lChannelMin = 0, lChannelMax = 0;
+ pAMTuner->ChannelMinMax(&lChannelMin, &lChannelMax);
+ long lChannel = 0, lVivSub = 0, lAudSub = 0;
+ pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
- long lFreqOrg = 0, lFreqNew = -1;
- pAMTuner->get_VideoFrequency(&lFreqOrg);
+ long lFreqOrg = 0, lFreqNew = -1;
+ pAMTuner->get_VideoFrequency(&lFreqOrg);
// long lSignalStrength;
- do
- {
- if(nID == ID_PLAY_DECRATE) lChannel--;
- else if(nID == ID_PLAY_INCRATE) lChannel++;
+ do
+ {
+ if(nID == ID_PLAY_DECRATE) lChannel--;
+ else if(nID == ID_PLAY_INCRATE) lChannel++;
// if(lChannel < lChannelMin) lChannel = lChannelMax;
// if(lChannel > lChannelMax) lChannel = lChannelMin;
- if(lChannel < lChannelMin || lChannel > lChannelMax)
- break;
-
- if(FAILED(pAMTuner->put_Channel(lChannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT)))
- break;
-
- long flFoundSignal;
- pAMTuner->AutoTune(lChannel, &flFoundSignal);
-
- pAMTuner->get_VideoFrequency(&lFreqNew);
- }
- while(FALSE);
- /* SUCCEEDED(pAMTuner->SignalPresent(&lSignalStrength))
- && (lSignalStrength != AMTUNER_SIGNALPRESENT || lFreqNew == lFreqOrg));*/
-
- }
- else
- {
- int iNewSpeedLevel;
-
- if(nID == ID_PLAY_INCRATE) iNewSpeedLevel = m_iSpeedLevel + 1;
- else if(nID == ID_PLAY_DECRATE) iNewSpeedLevel = m_iSpeedLevel - 1;
- else return;
-
- HRESULT hr = E_FAIL;
-
- if((iNewSpeedLevel == -4) && (m_iPlaybackMode == PM_FILE))
- {
- if(GetMediaState() != State_Paused)
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- if(GetMediaState() == State_Paused) hr = S_OK;
- }
- else
- {
- double dRate;
-
- if(GetMediaState() != State_Running)
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
-
- if(m_iPlaybackMode == PM_FILE)
- {
- dRate = pow(2.0, iNewSpeedLevel >= -3 ? iNewSpeedLevel : (-iNewSpeedLevel - 8));
- if(fabs(dRate - 1.0) < 0.01) dRate = 1.0;
- hr = pMS->SetRate(dRate);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- dRate = pow(2.0, abs(iNewSpeedLevel));
- if(iNewSpeedLevel >= 0)
- hr = pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
- else
- hr = pDVDC->PlayBackwards(dRate, DVD_CMD_FLAG_Block, NULL);
- }
-
- if(SUCCEEDED(hr))
- {
- CString strMessage;
- m_iSpeedLevel = iNewSpeedLevel;
-
- if(dRate == 1.0)
- m_OSD.DisplayMessage(OSD_TOPRIGHT, _T("Play"));
- else
- {
- strMessage.Format(_T("%s x %.01f"), (iNewSpeedLevel > 0) ? _T(">") : _T("<"), fabs(dRate));
- m_OSD.DisplayMessage(OSD_TOPRIGHT, strMessage);
- }
- }
- }
-
- }
+ if(lChannel < lChannelMin || lChannel > lChannelMax)
+ break;
+
+ if(FAILED(pAMTuner->put_Channel(lChannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT)))
+ break;
+
+ long flFoundSignal;
+ pAMTuner->AutoTune(lChannel, &flFoundSignal);
+
+ pAMTuner->get_VideoFrequency(&lFreqNew);
+ }
+ while(FALSE);
+/* SUCCEEDED(pAMTuner->SignalPresent(&lSignalStrength))
+ && (lSignalStrength != AMTUNER_SIGNALPRESENT || lFreqNew == lFreqOrg));*/
+
+ }
+ else
+ {
+ int iNewSpeedLevel;
+
+ if(nID == ID_PLAY_INCRATE) iNewSpeedLevel = m_iSpeedLevel+1;
+ else if(nID == ID_PLAY_DECRATE) iNewSpeedLevel = m_iSpeedLevel-1;
+ else return;
+
+ HRESULT hr = E_FAIL;
+
+ if((iNewSpeedLevel == -4) && (m_iPlaybackMode == PM_FILE))
+ {
+ if(GetMediaState() != State_Paused)
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ if(GetMediaState() == State_Paused) hr = S_OK;
+ }
+ else
+ {
+ double dRate;
+
+ if(GetMediaState() != State_Running)
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ dRate = pow(2.0, iNewSpeedLevel >= -3 ? iNewSpeedLevel : (-iNewSpeedLevel - 8));
+ if(fabs(dRate - 1.0) < 0.01) dRate = 1.0;
+ hr = pMS->SetRate(dRate);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ dRate = pow(2.0, abs(iNewSpeedLevel));
+ if(iNewSpeedLevel >= 0)
+ hr = pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
+ else
+ hr = pDVDC->PlayBackwards(dRate, DVD_CMD_FLAG_Block, NULL);
+ }
+
+ if(SUCCEEDED(hr))
+ {
+ CString strMessage;
+ m_iSpeedLevel = iNewSpeedLevel;
+
+ if (dRate == 1.0)
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, _T("Play"));
+ else
+ {
+ strMessage.Format (_T("%s x %.01f"), (iNewSpeedLevel > 0)?_T(">"):_T("<"), fabs(dRate));
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, strMessage);
+ }
+ }
+ }
+
+ }
}
void CMainFrame::OnUpdatePlayChangeRate(CCmdUI* pCmdUI)
{
- bool fEnable = false;
+ bool fEnable = false;
- if(m_iMediaLoadState == MLS_LOADED)
- {
- bool fInc = pCmdUI->m_nID == ID_PLAY_INCRATE;
-
- fEnable = true;
- if(fInc && m_iSpeedLevel >= 7) fEnable = false;
- else if(!fInc && m_iPlaybackMode == PM_FILE && m_iSpeedLevel <= -4) fEnable = false;
- else if(!fInc && m_iPlaybackMode == PM_DVD && m_iSpeedLevel <= -11) fEnable = false;
- else if(m_iPlaybackMode == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) fEnable = false;
- else if(m_fRealMediaGraph || m_fShockwaveGraph) fEnable = false;
- else if(m_iPlaybackMode == PM_CAPTURE && (!m_wndCaptureBar.m_capdlg.IsTunerActive() || m_fCapturing)) fEnable = false;
- else if(m_fLiveWM) fEnable = false;
- }
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ bool fInc = pCmdUI->m_nID == ID_PLAY_INCRATE;
+
+ fEnable = true;
+ if(fInc && m_iSpeedLevel >= 7) fEnable = false;
+ else if(!fInc && m_iPlaybackMode == PM_FILE && m_iSpeedLevel <= -4) fEnable = false;
+ else if(!fInc && m_iPlaybackMode == PM_DVD && m_iSpeedLevel <= -11) fEnable = false;
+ else if(m_iPlaybackMode == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) fEnable = false;
+ else if(m_fRealMediaGraph || m_fShockwaveGraph) fEnable = false;
+ else if(m_iPlaybackMode == PM_CAPTURE && (!m_wndCaptureBar.m_capdlg.IsTunerActive() || m_fCapturing)) fEnable = false;
+ else if(m_fLiveWM) fEnable = false;
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayResetRate()
{
- if(m_iMediaLoadState != MLS_LOADED)
- return;
+ if(m_iMediaLoadState != MLS_LOADED)
+ return;
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if(GetMediaState() != State_Running)
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ if(GetMediaState() != State_Running)
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- if(m_iPlaybackMode == PM_FILE)
- {
- hr = pMS->SetRate(1.0);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- hr = pDVDC->PlayForwards(1.0, DVD_CMD_FLAG_Block, NULL);
- }
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ hr = pMS->SetRate(1.0);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ hr = pDVDC->PlayForwards(1.0, DVD_CMD_FLAG_Block, NULL);
+ }
- if(SUCCEEDED(hr))
- m_iSpeedLevel = 0;
+ if(SUCCEEDED(hr))
+ m_iSpeedLevel = 0;
}
void CMainFrame::OnUpdatePlayResetRate(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED);
}
void CMainFrame::SetAudioDelay(REFERENCE_TIME rtShift)
{
- if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
- {
- pASF->SetAudioTimeShift(rtShift);
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
+ {
+ pASF->SetAudioTimeShift(rtShift);
- CString str;
- str.Format(ResStr(IDS_MAINFRM_70), rtShift / 10000);
- SendStatusMessage(str, 3000);
- m_OSD.DisplayMessage(OSD_TOPLEFT, str);
- }
+ CString str;
+ str.Format(ResStr(IDS_MAINFRM_70), rtShift/10000);
+ SendStatusMessage(str, 3000);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, str);
+ }
}
void CMainFrame::SetSubtitleDelay(int delay_ms)
{
- if(m_pCAP)
- {
- m_pCAP->SetSubtitleDelay(delay_ms);
+ if(m_pCAP) {
+ m_pCAP->SetSubtitleDelay(delay_ms);
- CString strSubDelay;
- strSubDelay.Format(ResStr(IDS_MAINFRM_139), delay_ms);
- SendStatusMessage(strSubDelay, 3000);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strSubDelay);
- }
+ CString strSubDelay;
+ strSubDelay.Format (ResStr(IDS_MAINFRM_139), delay_ms);
+ SendStatusMessage(strSubDelay, 3000);
+ m_OSD.DisplayMessage (OSD_TOPLEFT, strSubDelay);
+ }
}
void CMainFrame::OnPlayChangeAudDelay(UINT nID)
{
- if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
- {
- REFERENCE_TIME rtShift = pASF->GetAudioTimeShift();
- rtShift +=
- nID == ID_PLAY_INCAUDDELAY ? 100000 :
- nID == ID_PLAY_DECAUDDELAY ? -100000 :
- 0;
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
+ {
+ REFERENCE_TIME rtShift = pASF->GetAudioTimeShift();
+ rtShift +=
+ nID == ID_PLAY_INCAUDDELAY ? 100000 :
+ nID == ID_PLAY_DECAUDDELAY ? -100000 :
+ 0;
- SetAudioDelay(rtShift);
- }
+ SetAudioDelay (rtShift);
+ }
}
void CMainFrame::OnUpdatePlayChangeAudDelay(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!pGB /*&& !!FindFilter(__uuidof(CAudioSwitcherFilter), pGB)*/);
+ pCmdUI->Enable(!!pGB /*&& !!FindFilter(__uuidof(CAudioSwitcherFilter), pGB)*/);
}
void CMainFrame::OnPlayFilters(UINT nID)
{
// ShowPPage(m_spparray[nID - ID_FILTERS_SUBITEM_START], m_hWnd);
- CComPtr<IUnknown> pUnk = m_pparray[nID - ID_FILTERS_SUBITEM_START];
+ CComPtr<IUnknown> pUnk = m_pparray[nID - ID_FILTERS_SUBITEM_START];
- CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), GetModalParent());
+ CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), GetModalParent());
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk)
- {
- ps.AddPages(pSPP);
- }
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk)
+ {
+ ps.AddPages(pSPP);
+ }
- if(CComQIPtr<IBaseFilter> pBF = pUnk)
- {
- HRESULT hr;
- CComPtr<IPropertyPage> pPP = DNew CInternalPropertyPageTempl<CPinInfoWnd>(NULL, &hr);
- ps.AddPage(pPP, pBF);
- }
+ if(CComQIPtr<IBaseFilter> pBF = pUnk)
+ {
+ HRESULT hr;
+ CComPtr<IPropertyPage> pPP = DNew CInternalPropertyPageTempl<CPinInfoWnd>(NULL, &hr);
+ ps.AddPage(pPP, pBF);
+ }
- if(ps.GetPageCount() > 0)
- {
- ps.DoModal();
- OpenSetupStatusBar();
- }
+ if(ps.GetPageCount() > 0)
+ {
+ ps.DoModal();
+ OpenSetupStatusBar();
+ }
}
void CMainFrame::OnUpdatePlayFilters(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!m_fCapturing);
+ pCmdUI->Enable(!m_fCapturing);
}
enum
{
- ID_SHADERS_OFF = ID_SHADERS_START,
- ID_SHADERS_COMBINE,
- ID_SHADERS_EDIT,
- ID_SHADERS_STARTSCR,
- ID_SHADERS_OFFSCR = ID_SHADERS_STARTSCR,
- ID_SHADERS_COMBINESCR,
- ID_SHADERS_ENDSCR,
- ID_SHADERS_DYNAMIC = ID_SHADERS_ENDSCR,
+ ID_SHADERS_OFF = ID_SHADERS_START,
+ ID_SHADERS_COMBINE,
+ ID_SHADERS_EDIT,
+ ID_SHADERS_STARTSCR,
+ ID_SHADERS_OFFSCR = ID_SHADERS_STARTSCR,
+ ID_SHADERS_COMBINESCR,
+ ID_SHADERS_ENDSCR,
+ ID_SHADERS_DYNAMIC = ID_SHADERS_ENDSCR,
};
void CMainFrame::OnPlayShaders(UINT nID)
{
- if(nID == ID_SHADERS_EDIT)
- {
- ShowControlBar(&m_wndShaderEditorBar, TRUE, TRUE);
- return;
- }
-
- if(!m_pCAP) return;
-
- if(nID == ID_SHADERS_OFF)
- {
- m_shaderlabels.RemoveAll();
- }
- else if(nID == ID_SHADERS_OFFSCR)
- {
- m_shaderlabelsScreenSpace.RemoveAll();
- }
- else if(nID == ID_SHADERS_COMBINE)
- {
- if(IDOK != CShaderCombineDlg(m_shaderlabels, GetModalParent(), false).DoModal())
- return;
- }
- else if(nID == ID_SHADERS_COMBINESCR)
- {
- if(IDOK != CShaderCombineDlg(m_shaderlabelsScreenSpace, GetModalParent(), true).DoModal())
- return;
- }
- else if(nID >= ID_SHADERS_DYNAMIC)
- {
- MENUITEMINFO mii;
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_DATA;
- m_shaders.GetMenuItemInfo(nID, &mii);
-
- m_shaderlabels.RemoveAll();
- m_shaderlabels.AddTail(((const AppSettings::Shader*)mii.dwItemData)->label);
- }
-
- SetShaders();
+ if(nID == ID_SHADERS_EDIT)
+ {
+ ShowControlBar(&m_wndShaderEditorBar, TRUE, TRUE);
+ return;
+ }
+
+ if(!m_pCAP) return;
+
+ if(nID == ID_SHADERS_OFF)
+ {
+ m_shaderlabels.RemoveAll();
+ }
+ else if(nID == ID_SHADERS_OFFSCR)
+ {
+ m_shaderlabelsScreenSpace.RemoveAll();
+ }
+ else if(nID == ID_SHADERS_COMBINE)
+ {
+ if(IDOK != CShaderCombineDlg(m_shaderlabels, GetModalParent(), false).DoModal())
+ return;
+ }
+ else if(nID == ID_SHADERS_COMBINESCR)
+ {
+ if(IDOK != CShaderCombineDlg(m_shaderlabelsScreenSpace, GetModalParent(), true).DoModal())
+ return;
+ }
+ else if(nID >= ID_SHADERS_DYNAMIC)
+ {
+ MENUITEMINFO mii;
+ memset(&mii, 0, sizeof(mii));
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_DATA;
+ m_shaders.GetMenuItemInfo(nID, &mii);
+
+ m_shaderlabels.RemoveAll();
+ m_shaderlabels.AddTail(((const AppSettings::Shader*)mii.dwItemData)->label);
+ }
+
+ SetShaders();
}
void CMainFrame::OnUpdatePlayShaders(CCmdUI* pCmdUI)
{
- if(pCmdUI->m_nID >= ID_SHADERS_START)
- {
- if(pCmdUI->m_nID >= ID_SHADERS_STARTSCR && pCmdUI->m_nID < ID_SHADERS_ENDSCR)
- pCmdUI->Enable(!!m_pCAP2);
- else
- pCmdUI->Enable(!!m_pCAP);
-
- if(pCmdUI->m_nID == ID_SHADERS_OFF)
- {
- pCmdUI->SetRadio(m_shaderlabels.IsEmpty());
- }
- else if(pCmdUI->m_nID == ID_SHADERS_OFFSCR)
- {
- pCmdUI->SetRadio(m_shaderlabelsScreenSpace.IsEmpty());
- }
- else if(pCmdUI->m_nID == ID_SHADERS_COMBINE)
- {
- pCmdUI->SetRadio(m_shaderlabels.GetCount() > 1);
- }
- else if(pCmdUI->m_nID == ID_SHADERS_COMBINESCR)
- {
- pCmdUI->SetRadio(m_shaderlabelsScreenSpace.GetCount() > 0);
- }
- else if(pCmdUI->m_nID == ID_SHADERS_EDIT)
- {
- pCmdUI->Enable(TRUE);
- }
- else
- {
- MENUITEMINFO mii;
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_DATA;
- m_shaders.GetMenuItemInfo(pCmdUI->m_nID, &mii);
-
- pCmdUI->SetRadio(m_shaderlabels.GetCount() == 1
- && m_shaderlabels.GetHead() == ((AppSettings::Shader*)mii.dwItemData)->label);
- }
- }
+ if(pCmdUI->m_nID >= ID_SHADERS_START)
+ {
+ if (pCmdUI->m_nID >= ID_SHADERS_STARTSCR && pCmdUI->m_nID < ID_SHADERS_ENDSCR )
+ pCmdUI->Enable(!!m_pCAP2);
+ else
+ pCmdUI->Enable(!!m_pCAP);
+
+ if(pCmdUI->m_nID == ID_SHADERS_OFF)
+ {
+ pCmdUI->SetRadio(m_shaderlabels.IsEmpty());
+ }
+ else if(pCmdUI->m_nID == ID_SHADERS_OFFSCR)
+ {
+ pCmdUI->SetRadio(m_shaderlabelsScreenSpace.IsEmpty());
+ }
+ else if(pCmdUI->m_nID == ID_SHADERS_COMBINE)
+ {
+ pCmdUI->SetRadio(m_shaderlabels.GetCount() > 1);
+ }
+ else if(pCmdUI->m_nID == ID_SHADERS_COMBINESCR)
+ {
+ pCmdUI->SetRadio(m_shaderlabelsScreenSpace.GetCount() > 0);
+ }
+ else if(pCmdUI->m_nID == ID_SHADERS_EDIT)
+ {
+ pCmdUI->Enable(TRUE);
+ }
+ else
+ {
+ MENUITEMINFO mii;
+ memset(&mii, 0, sizeof(mii));
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_DATA;
+ m_shaders.GetMenuItemInfo(pCmdUI->m_nID, &mii);
+
+ pCmdUI->SetRadio(m_shaderlabels.GetCount() == 1
+ && m_shaderlabels.GetHead() == ((AppSettings::Shader*)mii.dwItemData)->label);
+ }
+ }
}
void CMainFrame::OnPlayAudio(UINT nID)
{
- int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
+ int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
- if(i == -1)
- {
- ShowOptions(CPPageAudioSwitcher::IDD);
- }
- else if(i >= 0 && pSS)
- {
- i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // don't forget that the audio streams are reordered, so have to figure which one from the initial order is used here
- pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
- }
+ if(i == -1)
+ {
+ ShowOptions(CPPageAudioSwitcher::IDD);
+ }
+ else if(i >= 0 && pSS)
+ {
+ i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // don't forget that the audio streams are reordered, so have to figure which one from the initial order is used here
+ pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
+ }
}
void CMainFrame::OnUpdatePlayAudio(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID;
- int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
-
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
-
- /*if(i == -1)
- {
- // TODO****
- }
- else*/
- if(i >= 0 && pSS)
- {
- i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // audio streams are reordered, so figure out which one from the initial order is used here
- DWORD flags = 0;
-
- if(SUCCEEDED(pSS->Info(i, NULL, &flags, NULL, NULL, NULL, NULL, NULL)))
- {
- if(flags & AMSTREAMSELECTINFO_EXCLUSIVE) pCmdUI->SetRadio(TRUE);
- else if(flags & AMSTREAMSELECTINFO_ENABLED) pCmdUI->SetCheck(TRUE);
- else pCmdUI->SetCheck(FALSE);
- }
- else
- {
- pCmdUI->Enable(FALSE);
- }
- }
+ UINT nID = pCmdUI->m_nID;
+ int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
+
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+
+ /*if(i == -1)
+ {
+ // TODO****
+ }
+ else*/ if(i >= 0 && pSS)
+ {
+ i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // audio streams are reordered, so figure out which one from the initial order is used here
+ DWORD flags = 0;
+
+ if(SUCCEEDED(pSS->Info(i, NULL, &flags, NULL, NULL, NULL, NULL, NULL)))
+ {
+ if(flags&AMSTREAMSELECTINFO_EXCLUSIVE) pCmdUI->SetRadio(TRUE);
+ else if(flags&AMSTREAMSELECTINFO_ENABLED) pCmdUI->SetCheck(TRUE);
+ else pCmdUI->SetCheck(FALSE);
+ }
+ else
+ {
+ pCmdUI->Enable(FALSE);
+ }
+ }
}
void CMainFrame::OnPlaySubtitles(UINT nID)
{
- int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // currently the subtitles submenu contains 5 items, apart from the actual subtitles list
-
- if(i == -5)
- {
- // options
- ShowOptions(CPPageSubtitles::IDD);
- }
- else if(i == -4)
- {
- // styles
- int i = m_iSubtitleSel;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- if(i < pSubStream->GetStreamCount())
- {
- CLSID clsid;
- if(FAILED(pSubStream->GetClassID(&clsid)))
- continue;
-
- if(clsid == __uuidof(CRenderedTextSubtitle))
- {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
-
- CAutoPtrArray<CPPageSubStyle> pages;
- CAtlArray<STSStyle*> styles;
-
- POSITION pos = pRTS->m_styles.GetStartPosition();
- for(int i = 0; pos; i++)
- {
- CString key;
- STSStyle* val;
- pRTS->m_styles.GetNextAssoc(pos, key, val);
-
- CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
- page->InitStyle(key, *val);
- pages.Add(page);
- styles.Add(val);
- }
-
- CPropertySheet dlg(_T("Styles..."), GetModalParent());
- for(int i = 0; i < (int)pages.GetCount(); i++)
- dlg.AddPage(pages[i]);
-
- if(dlg.DoModal() == IDOK)
- {
- for(int j = 0; j < (int)pages.GetCount(); j++)
- pages[j]->GetStyle(*styles[j]);
- UpdateSubtitle(false);
- }
-
- return;
- }
- }
-
- i -= pSubStream->GetStreamCount();
- }
- }
- else if(i == -3)
- {
- // reload
- ReloadSubtitle();
- }
- else if(i == -2)
- {
- // enable
- if(m_iSubtitleSel == -1) m_iSubtitleSel = 0;
- else m_iSubtitleSel ^= (1 << 31);
- UpdateSubtitle();
- }
- else if(i == -1)
- {
- // override default style
- // TODO: default subtitles style toggle here
- AfxGetAppSettings().fUseDefaultSubtitlesStyle = !AfxGetAppSettings().fUseDefaultSubtitlesStyle;
- UpdateSubtitle();
- }
- else if(i >= 0)
- {
- // this is an actual item from the subtitles list
- m_iSubtitleSel = i;
- UpdateSubtitle();
- }
-
- AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
+ int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // currently the subtitles submenu contains 5 items, apart from the actual subtitles list
+
+ if(i == -5)
+ {
+ // options
+ ShowOptions(CPPageSubtitles::IDD);
+ }
+ else if(i == -4)
+ {
+ // styles
+ int i = m_iSubtitleSel;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos && i >= 0)
+ {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ if(i < pSubStream->GetStreamCount())
+ {
+ CLSID clsid;
+ if(FAILED(pSubStream->GetClassID(&clsid)))
+ continue;
+
+ if(clsid == __uuidof(CRenderedTextSubtitle))
+ {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
+
+ CAutoPtrArray<CPPageSubStyle> pages;
+ CAtlArray<STSStyle*> styles;
+
+ POSITION pos = pRTS->m_styles.GetStartPosition();
+ for(int i = 0; pos; i++)
+ {
+ CString key;
+ STSStyle* val;
+ pRTS->m_styles.GetNextAssoc(pos, key, val);
+
+ CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
+ page->InitStyle(key, *val);
+ pages.Add(page);
+ styles.Add(val);
+ }
+
+ CPropertySheet dlg(_T("Styles..."), GetModalParent());
+ for(int i = 0; i < (int)pages.GetCount(); i++)
+ dlg.AddPage(pages[i]);
+
+ if(dlg.DoModal() == IDOK)
+ {
+ for(int j = 0; j < (int)pages.GetCount(); j++)
+ pages[j]->GetStyle(*styles[j]);
+ UpdateSubtitle(false);
+ }
+
+ return;
+ }
+ }
+
+ i -= pSubStream->GetStreamCount();
+ }
+ }
+ else if(i == -3)
+ {
+ // reload
+ ReloadSubtitle();
+ }
+ else if(i == -2)
+ {
+ // enable
+ if(m_iSubtitleSel == -1) m_iSubtitleSel = 0;
+ else m_iSubtitleSel ^= (1<<31);
+ UpdateSubtitle();
+ }
+ else if(i == -1)
+ {
+ // override default style
+ // TODO: default subtitles style toggle here
+ AfxGetAppSettings().fUseDefaultSubtitlesStyle = !AfxGetAppSettings().fUseDefaultSubtitlesStyle;
+ UpdateSubtitle();
+ }
+ else if(i >= 0)
+ {
+ // this is an actual item from the subtitles list
+ m_iSubtitleSel = i;
+ UpdateSubtitle();
+ }
+
+ AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
}
void CMainFrame::OnUpdatePlaySubtitles(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID;
- int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // again, 5 pre-set subtitles options before the actual list
-
- pCmdUI->Enable(m_pCAP && !m_fAudioOnly);
-
- if(i == -4)
- {
- // styles
- pCmdUI->Enable(FALSE);
-
- int i = m_iSubtitleSel;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- if(i < pSubStream->GetStreamCount())
- {
- CLSID clsid;
- if(FAILED(pSubStream->GetClassID(&clsid)))
- continue;
-
- if(clsid == __uuidof(CRenderedTextSubtitle))
- {
- pCmdUI->Enable(TRUE);
- break;
- }
- }
-
- i -= pSubStream->GetStreamCount();
- }
- }
- else if(i == -2)
- {
- // enabled
- pCmdUI->SetCheck(AfxGetAppSettings().fEnableSubtitles/*m_iSubtitleSel >= 0*/);
- }
- else if(i == -1)
- {
- // override
- // TODO: foxX - default subtitles style toggle here; still wip
- pCmdUI->SetCheck(AfxGetAppSettings().fUseDefaultSubtitlesStyle);
- pCmdUI->Enable(AfxGetAppSettings().fEnableSubtitles);
- }
- else if(i >= 0)
- {
- pCmdUI->SetRadio(i == abs(m_iSubtitleSel));
- }
+ UINT nID = pCmdUI->m_nID;
+ int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // again, 5 pre-set subtitles options before the actual list
+
+ pCmdUI->Enable(m_pCAP && !m_fAudioOnly);
+
+ if(i == -4)
+ {
+ // styles
+ pCmdUI->Enable(FALSE);
+
+ int i = m_iSubtitleSel;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos && i >= 0)
+ {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ if(i < pSubStream->GetStreamCount())
+ {
+ CLSID clsid;
+ if(FAILED(pSubStream->GetClassID(&clsid)))
+ continue;
+
+ if(clsid == __uuidof(CRenderedTextSubtitle))
+ {
+ pCmdUI->Enable(TRUE);
+ break;
+ }
+ }
+
+ i -= pSubStream->GetStreamCount();
+ }
+ }
+ else if(i == -2)
+ {
+ // enabled
+ pCmdUI->SetCheck(AfxGetAppSettings().fEnableSubtitles/*m_iSubtitleSel >= 0*/);
+ }
+ else if(i == -1)
+ {
+ // override
+ // TODO: foxX - default subtitles style toggle here; still wip
+ pCmdUI->SetCheck(AfxGetAppSettings().fUseDefaultSubtitlesStyle);
+ pCmdUI->Enable(AfxGetAppSettings().fEnableSubtitles);
+ }
+ else if(i >= 0)
+ {
+ pCmdUI->SetRadio(i == abs(m_iSubtitleSel));
+ }
}
void CMainFrame::OnPlayLanguage(UINT nID)
{
- nID -= ID_FILTERSTREAMS_SUBITEM_START;
- CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
- UINT i = nID;
- while(i > 0 && pAMSS == m_ssarray[i-1]) i--;
- if(FAILED(pAMSS->Enable(nID - i, AMSTREAMSELECTENABLE_ENABLE)))
- MessageBeep(-1);
+ nID -= ID_FILTERSTREAMS_SUBITEM_START;
+ CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
+ UINT i = nID;
+ while(i > 0 && pAMSS == m_ssarray[i-1]) i--;
+ if(FAILED(pAMSS->Enable(nID-i, AMSTREAMSELECTENABLE_ENABLE)))
+ MessageBeep(-1);
- OpenSetupStatusBar();
+ OpenSetupStatusBar();
}
void CMainFrame::OnUpdatePlayLanguage(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID;
- nID -= ID_FILTERSTREAMS_SUBITEM_START;
- CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
- UINT i = nID;
- while(i > 0 && pAMSS == m_ssarray[i-1]) i--;
- DWORD flags = 0;
- pAMSS->Info(nID - i, NULL, &flags, NULL, NULL, NULL, NULL, NULL);
- if(flags & AMSTREAMSELECTINFO_EXCLUSIVE) pCmdUI->SetRadio(TRUE);
- else if(flags & AMSTREAMSELECTINFO_ENABLED) pCmdUI->SetCheck(TRUE);
- else pCmdUI->SetCheck(FALSE);
+ UINT nID = pCmdUI->m_nID;
+ nID -= ID_FILTERSTREAMS_SUBITEM_START;
+ CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
+ UINT i = nID;
+ while(i > 0 && pAMSS == m_ssarray[i-1]) i--;
+ DWORD flags = 0;
+ pAMSS->Info(nID-i, NULL, &flags, NULL, NULL, NULL, NULL, NULL);
+ if(flags&AMSTREAMSELECTINFO_EXCLUSIVE) pCmdUI->SetRadio(TRUE);
+ else if(flags&AMSTREAMSELECTINFO_ENABLED) pCmdUI->SetCheck(TRUE);
+ else pCmdUI->SetCheck(FALSE);
}
void CMainFrame::OnPlayVolume(UINT nID)
{
- if(m_iMediaLoadState == MLS_LOADED)
- {
- CString strVolume;
- pBA->put_Volume(m_wndToolBar.Volume);
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ CString strVolume;
+ pBA->put_Volume(m_wndToolBar.Volume);
- //strVolume.Format (L"Vol : %d dB", m_wndToolBar.Volume / 100);
- if(m_wndToolBar.Volume == -10000)
- {
- strVolume.Format(ResStr(IDS_VOLUME_OSD), 0);
- }
- else
- {
- strVolume.Format(ResStr(IDS_VOLUME_OSD), m_wndToolBar.m_volctrl.GetPos());
- }
- m_OSD.DisplayMessage(OSD_TOPLEFT, strVolume);
- }
+ //strVolume.Format (L"Vol : %d dB", m_wndToolBar.Volume / 100);
+ if(m_wndToolBar.Volume == -10000)
+ {
+ strVolume.Format(ResStr(IDS_VOLUME_OSD), 0);
+ }
+ else
+ {
+ strVolume.Format(ResStr(IDS_VOLUME_OSD), m_wndToolBar.m_volctrl.GetPos());
+ }
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strVolume);
+ }
- m_Lcd.SetVolume((m_wndToolBar.Volume > -10000 ? m_wndToolBar.m_volctrl.GetPos() : 1));
+ m_Lcd.SetVolume((m_wndToolBar.Volume > -10000 ? m_wndToolBar.m_volctrl.GetPos() : 1));
}
void CMainFrame::OnPlayVolumeBoost(UINT nID)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- int i = (int)(50.0f * log10(s.AudioBoost));
+ int i = (int)(50.0f*log10(s.AudioBoost));
- switch(nID)
- {
- case ID_VOLUME_BOOST_INC:
- i = min(i + 10, 100);
- break;
- case ID_VOLUME_BOOST_DEC:
- i = max(i - 10, 0);
- break;
- case ID_VOLUME_BOOST_MIN:
- i = 0;
- break;
- case ID_VOLUME_BOOST_MAX:
- i = 100;
- break;
- }
+ switch(nID)
+ {
+ case ID_VOLUME_BOOST_INC: i = min(i+10, 100); break;
+ case ID_VOLUME_BOOST_DEC: i = max(i-10, 0); break;
+ case ID_VOLUME_BOOST_MIN: i = 0; break;
+ case ID_VOLUME_BOOST_MAX: i = 100; break;
+ }
- s.AudioBoost = pow(10.0f, (float)i / 50);
+ s.AudioBoost = pow(10.0f, (float)i/50);
- if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
- {
- bool fNormalize, fNormalizeRecover;
- float boost;
- pASF->GetNormalizeBoost(fNormalize, fNormalizeRecover, boost);
- pASF->SetNormalizeBoost(fNormalize, fNormalizeRecover, s.AudioBoost);
- }
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
+ {
+ bool fNormalize, fNormalizeRecover;
+ float boost;
+ pASF->GetNormalizeBoost(fNormalize, fNormalizeRecover, boost);
+ pASF->SetNormalizeBoost(fNormalize, fNormalizeRecover, s.AudioBoost);
+ }
}
void CMainFrame::OnUpdatePlayVolumeBoost(CCmdUI* pCmdUI)
{
- pCmdUI->Enable();
+ pCmdUI->Enable();
}
void CMainFrame::OnAfterplayback(UINT nID)
{
- AppSettings& s = AfxGetAppSettings();
-
- s.nCLSwitches &= ~CLSW_AFTERPLAYBACK_MASK;
-
- switch(nID)
- {
- case ID_AFTERPLAYBACK_NEXT :
- s.m_fNextInDirAfterPlayback = true;
- s.m_fExitAfterPlayback = false;
- break;
- case ID_AFTERPLAYBACK_EXIT :
- s.m_fExitAfterPlayback = true;
- s.m_fNextInDirAfterPlayback = false;
- break;
- case ID_AFTERPLAYBACK_DONOTHING:
- s.m_fExitAfterPlayback = false;
- s.m_fNextInDirAfterPlayback = false;
- break;
- case ID_AFTERPLAYBACK_CLOSE:
- s.nCLSwitches |= CLSW_CLOSE;
- break;
- case ID_AFTERPLAYBACK_STANDBY:
- s.nCLSwitches |= CLSW_STANDBY;
- break;
- case ID_AFTERPLAYBACK_HIBERNATE:
- s.nCLSwitches |= CLSW_HIBERNATE;
- break;
- case ID_AFTERPLAYBACK_SHUTDOWN:
- s.nCLSwitches |= CLSW_SHUTDOWN;
- break;
- case ID_AFTERPLAYBACK_LOGOFF:
- s.nCLSwitches |= CLSW_LOGOFF;
- break;
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ s.nCLSwitches &= ~CLSW_AFTERPLAYBACK_MASK;
+
+ switch(nID)
+ {
+ case ID_AFTERPLAYBACK_NEXT :
+ s.m_fNextInDirAfterPlayback = true;
+ s.m_fExitAfterPlayback = false;
+ break;
+ case ID_AFTERPLAYBACK_EXIT :
+ s.m_fExitAfterPlayback = true;
+ s.m_fNextInDirAfterPlayback = false;
+ break;
+ case ID_AFTERPLAYBACK_DONOTHING:
+ s.m_fExitAfterPlayback = false;
+ s.m_fNextInDirAfterPlayback = false;
+ break;
+ case ID_AFTERPLAYBACK_CLOSE: s.nCLSwitches |= CLSW_CLOSE; break;
+ case ID_AFTERPLAYBACK_STANDBY: s.nCLSwitches |= CLSW_STANDBY; break;
+ case ID_AFTERPLAYBACK_HIBERNATE: s.nCLSwitches |= CLSW_HIBERNATE; break;
+ case ID_AFTERPLAYBACK_SHUTDOWN: s.nCLSwitches |= CLSW_SHUTDOWN; break;
+ case ID_AFTERPLAYBACK_LOGOFF: s.nCLSwitches |= CLSW_LOGOFF; break;
+ }
}
void CMainFrame::OnUpdateAfterplayback(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- bool fChecked = false;
+ bool fChecked = false;
- switch(pCmdUI->m_nID)
- {
- case ID_AFTERPLAYBACK_EXIT:
- fChecked = !!s.m_fExitAfterPlayback;
- break;
- case ID_AFTERPLAYBACK_NEXT:
- fChecked = !!s.m_fNextInDirAfterPlayback;
- break;
- case ID_AFTERPLAYBACK_CLOSE:
- fChecked = !!(s.nCLSwitches & CLSW_CLOSE);
- break;
- case ID_AFTERPLAYBACK_STANDBY:
- fChecked = !!(s.nCLSwitches & CLSW_STANDBY);
- break;
- case ID_AFTERPLAYBACK_HIBERNATE:
- fChecked = !!(s.nCLSwitches & CLSW_HIBERNATE);
- break;
- case ID_AFTERPLAYBACK_SHUTDOWN:
- fChecked = !!(s.nCLSwitches & CLSW_SHUTDOWN);
- break;
- case ID_AFTERPLAYBACK_LOGOFF:
- fChecked = !!(s.nCLSwitches & CLSW_LOGOFF);
- break;
- case ID_AFTERPLAYBACK_DONOTHING:
- fChecked = (!s.m_fExitAfterPlayback) && (!s.m_fNextInDirAfterPlayback);
- break;
- }
+ switch(pCmdUI->m_nID)
+ {
+ case ID_AFTERPLAYBACK_EXIT: fChecked = !!s.m_fExitAfterPlayback; break;
+ case ID_AFTERPLAYBACK_NEXT: fChecked = !!s.m_fNextInDirAfterPlayback; break;
+ case ID_AFTERPLAYBACK_CLOSE: fChecked = !!(s.nCLSwitches & CLSW_CLOSE); break;
+ case ID_AFTERPLAYBACK_STANDBY: fChecked = !!(s.nCLSwitches & CLSW_STANDBY); break;
+ case ID_AFTERPLAYBACK_HIBERNATE: fChecked = !!(s.nCLSwitches & CLSW_HIBERNATE); break;
+ case ID_AFTERPLAYBACK_SHUTDOWN: fChecked = !!(s.nCLSwitches & CLSW_SHUTDOWN); break;
+ case ID_AFTERPLAYBACK_LOGOFF: fChecked = !!(s.nCLSwitches & CLSW_LOGOFF); break;
+ case ID_AFTERPLAYBACK_DONOTHING: fChecked = (!s.m_fExitAfterPlayback) && (!s.m_fNextInDirAfterPlayback); break;
+ }
- pCmdUI->SetRadio(fChecked);
+ pCmdUI->SetRadio(fChecked);
}
// navigate
void CMainFrame::OnNavigateSkip(UINT nID)
{
- if(m_iPlaybackMode == PM_FILE)
- {
- if(m_iPlaybackMode == PM_FILE) SetupChapters();
-
- if(DWORD nChapters = m_pCB->ChapGetCount())
- {
- REFERENCE_TIME rtCur;
- pMS->GetCurrentPosition(&rtCur);
-
- REFERENCE_TIME rt = rtCur;
- CComBSTR name;
- long i;
-
- if(nID == ID_NAVIGATE_SKIPBACK)
- {
- rt -= 30000000;
- i = m_pCB->ChapLookup(&rt, &name);
- }
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
- {
- i = m_pCB->ChapLookup(&rt, &name) + 1;
- name.Empty();
- if(i < nChapters) m_pCB->ChapGet(i, &rt, &name);
- }
-
- if(i >= 0 && i < nChapters)
- {
- SeekTo(rt);
- SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
- return;
- }
- }
-
- if((nID == ID_NAVIGATE_SKIPBACK) && (m_wndPlaylistBar.GetCount() != 1))
- {
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACKPLITEM);
- }
- else if((nID == ID_NAVIGATE_SKIPFORWARD) && (m_wndPlaylistBar.GetCount() != 1))
- {
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARDPLITEM);
- }
- else if((nID == ID_NAVIGATE_SKIPBACK) && (m_wndPlaylistBar.GetCount() == 1) && !AfxGetAppSettings().m_fDontUseSearchInFolder)
- {
- if(!SearchInDir(false)) m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_FIRST_IN_FOLDER));
- }
- else if((nID == ID_NAVIGATE_SKIPFORWARD) && (m_wndPlaylistBar.GetCount() == 1) && !AfxGetAppSettings().m_fDontUseSearchInFolder)
- {
- if(!SearchInDir(true)) m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_LAST_IN_FOLDER));
- }
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- m_iSpeedLevel = 0;
-
- if(GetMediaState() != State_Running)
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
-
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles = 0;
- pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
-
- ULONG ulNumOfChapters = 0;
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
-
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ if(m_iPlaybackMode == PM_FILE) SetupChapters();
+
+ if(DWORD nChapters = m_pCB->ChapGetCount())
+ {
+ REFERENCE_TIME rtCur;
+ pMS->GetCurrentPosition(&rtCur);
+
+ REFERENCE_TIME rt = rtCur;
+ CComBSTR name;
+ long i;
+
+ if(nID == ID_NAVIGATE_SKIPBACK)
+ {
+ rt -= 30000000;
+ i = m_pCB->ChapLookup(&rt, &name);
+ }
+ else if(nID == ID_NAVIGATE_SKIPFORWARD)
+ {
+ i = m_pCB->ChapLookup(&rt, &name) + 1;
+ name.Empty();
+ if(i < nChapters) m_pCB->ChapGet(i, &rt, &name);
+ }
+
+ if(i >= 0 && i < nChapters)
+ {
+ SeekTo(rt);
+ SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
+ return;
+ }
+ }
+
+ if((nID == ID_NAVIGATE_SKIPBACK) && (m_wndPlaylistBar.GetCount() != 1))
+ {
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACKPLITEM);
+ }
+ else if((nID == ID_NAVIGATE_SKIPFORWARD) && (m_wndPlaylistBar.GetCount() != 1))
+ {
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARDPLITEM);
+ }
+ else if((nID == ID_NAVIGATE_SKIPBACK) && (m_wndPlaylistBar.GetCount() == 1) && !AfxGetAppSettings().m_fDontUseSearchInFolder)
+ {
+ if (!SearchInDir(false)) m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_FIRST_IN_FOLDER));
+ }
+ else if((nID == ID_NAVIGATE_SKIPFORWARD) && (m_wndPlaylistBar.GetCount() == 1) && !AfxGetAppSettings().m_fDontUseSearchInFolder)
+ {
+ if (!SearchInDir(true)) m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_LAST_IN_FOLDER));
+ }
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ m_iSpeedLevel = 0;
+
+ if(GetMediaState() != State_Running)
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles = 0;
+ pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+
+ ULONG ulNumOfChapters = 0;
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+
+ if(nID == ID_NAVIGATE_SKIPBACK)
+ {
+ if(Location.ChapterNum == 1 && Location.TitleNum > 1)
+ {
+ pDVDI->GetNumberOfChapters(Location.TitleNum-1, &ulNumOfChapters);
+ pDVDC->PlayChapterInTitle(Location.TitleNum-1, ulNumOfChapters, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ }
+ else
+ {
+ pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ }
+ }
+ else if(nID == ID_NAVIGATE_SKIPFORWARD)
+ {
+ if(Location.ChapterNum == ulNumOfChapters && Location.TitleNum < ulNumOfTitles)
+ {
+ pDVDC->PlayChapterInTitle(Location.TitleNum+1, 1, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ }
+ else
+ {
+ pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ }
+ }
+/*
if(nID == ID_NAVIGATE_SKIPBACK)
- {
- if(Location.ChapterNum == 1 && Location.TitleNum > 1)
- {
- pDVDI->GetNumberOfChapters(Location.TitleNum - 1, &ulNumOfChapters);
- pDVDC->PlayChapterInTitle(Location.TitleNum - 1, ulNumOfChapters, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- }
- else
- {
- pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- }
- }
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
- {
- if(Location.ChapterNum == ulNumOfChapters && Location.TitleNum < ulNumOfTitles)
- {
- pDVDC->PlayChapterInTitle(Location.TitleNum + 1, 1, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- }
- else
- {
- pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- }
- }
- /*
- if(nID == ID_NAVIGATE_SKIPBACK)
- pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block, NULL);
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
- pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block, NULL);
- */
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- if(AfxGetAppSettings().iDefaultCaptureDevice == 1)
- {
- CComQIPtr<IBDATuner> pTun = pGB;
- if(pTun)
- {
- int nCurrentChannel;
- AppSettings& s = AfxGetAppSettings();
-
- nCurrentChannel = s.DVBLastChannel;
-
- if(nID == ID_NAVIGATE_SKIPBACK)
- {
- pTun->SetChannel(nCurrentChannel - 1);
- DisplayCurrentChannelOSD();
- if(m_wndNavigationBar.IsVisible())
- m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel - 1);
- }
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
- {
- pTun->SetChannel(nCurrentChannel + 1);
- DisplayCurrentChannelOSD();
- if(m_wndNavigationBar.IsVisible())
- m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel + 1);
- }
-
- }
- }
-
- }
+ pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block, NULL);
+ else if(nID == ID_NAVIGATE_SKIPFORWARD)
+ pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block, NULL);
+*/
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ if (AfxGetAppSettings().iDefaultCaptureDevice == 1)
+ {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun)
+ {
+ int nCurrentChannel;
+ AppSettings& s = AfxGetAppSettings();
+
+ nCurrentChannel = s.DVBLastChannel;
+
+ if(nID == ID_NAVIGATE_SKIPBACK)
+ {
+ pTun->SetChannel (nCurrentChannel - 1);
+ DisplayCurrentChannelOSD();
+ if (m_wndNavigationBar.IsVisible())
+ m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel - 1);
+ }
+ else if(nID == ID_NAVIGATE_SKIPFORWARD)
+ {
+ pTun->SetChannel (nCurrentChannel + 1);
+ DisplayCurrentChannelOSD();
+ if (m_wndNavigationBar.IsVisible())
+ m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel + 1);
+ }
+
+ }
+ }
+
+ }
}
void CMainFrame::OnUpdateNavigateSkip(CCmdUI* pCmdUI)
{
- // moved to the timer callback function, that runs less frequent
+ // moved to the timer callback function, that runs less frequent
// if(m_iPlaybackMode == PM_FILE) SetupChapters();
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
- && ((m_iPlaybackMode == PM_DVD
- && m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
- && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu)
- || (m_iPlaybackMode == PM_FILE && !AfxGetAppSettings().m_fDontUseSearchInFolder)
- || (m_iPlaybackMode == PM_FILE && AfxGetAppSettings().m_fDontUseSearchInFolder && (m_wndPlaylistBar.GetCount() > 1 || m_pCB->ChapGetCount() > 1))
- || (m_iPlaybackMode == PM_CAPTURE && !m_fCapturing)));
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
+ && ((m_iPlaybackMode == PM_DVD
+ && m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
+ && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu)
+ || (m_iPlaybackMode == PM_FILE && !AfxGetAppSettings().m_fDontUseSearchInFolder)
+ || (m_iPlaybackMode == PM_FILE && AfxGetAppSettings().m_fDontUseSearchInFolder && (m_wndPlaylistBar.GetCount() > 1 || m_pCB->ChapGetCount() > 1))
+ || (m_iPlaybackMode == PM_CAPTURE && !m_fCapturing)));
}
void CMainFrame::OnNavigateSkipPlaylistItem(UINT nID)
{
- if(m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE)
- {
- if(m_wndPlaylistBar.GetCount() == 1)
- {
- SendMessage(WM_COMMAND, ID_PLAY_STOP); // do not remove this, unless you want a circular call with OnPlayPlay()
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
- else
- {
- if(nID == ID_NAVIGATE_SKIPBACKPLITEM)
- {
- m_wndPlaylistBar.SetPrev();
- }
- else if(nID == ID_NAVIGATE_SKIPFORWARDPLITEM)
- {
- m_wndPlaylistBar.SetNext();
- }
-
- OpenCurPlaylistItem();
- }
- }
+ if(m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE)
+ {
+ if(m_wndPlaylistBar.GetCount() == 1)
+ {
+ SendMessage(WM_COMMAND, ID_PLAY_STOP); // do not remove this, unless you want a circular call with OnPlayPlay()
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+ else
+ {
+ if(nID == ID_NAVIGATE_SKIPBACKPLITEM)
+ {
+ m_wndPlaylistBar.SetPrev();
+ }
+ else if(nID == ID_NAVIGATE_SKIPFORWARDPLITEM)
+ {
+ m_wndPlaylistBar.SetNext();
+ }
+
+ OpenCurPlaylistItem();
+ }
+ }
}
void CMainFrame::OnUpdateNavigateSkipPlaylistItem(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
- && ((m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE && !m_fCapturing) && m_wndPlaylistBar.GetCount() > 1/*0*/));
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
+ && ((m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_CAPTURE && !m_fCapturing) && m_wndPlaylistBar.GetCount() > 1/*0*/));
}
void CMainFrame::OnNavigateMenu(UINT nID)
{
- nID -= ID_NAVIGATE_TITLEMENU;
+ nID -= ID_NAVIGATE_TITLEMENU;
- if(m_iMediaLoadState != MLS_LOADED || m_iPlaybackMode != PM_DVD)
- return;
+ if(m_iMediaLoadState != MLS_LOADED || m_iPlaybackMode != PM_DVD)
+ return;
- m_iSpeedLevel = 0;
+ m_iSpeedLevel = 0;
- if(GetMediaState() != State_Running)
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ if(GetMediaState() != State_Running)
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- pDVDC->ShowMenu((DVD_MENU_ID)(nID + 2), DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ pDVDC->ShowMenu((DVD_MENU_ID)(nID+2), DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
}
void CMainFrame::OnUpdateNavigateMenu(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_NAVIGATE_TITLEMENU;
- ULONG ulUOPs;
+ UINT nID = pCmdUI->m_nID - ID_NAVIGATE_TITLEMENU;
+ ULONG ulUOPs;
- if(m_iMediaLoadState != MLS_LOADED || m_iPlaybackMode != PM_DVD
- || FAILED(pDVDI->GetCurrentUOPS(&ulUOPs)))
- {
- pCmdUI->Enable(FALSE);
- return;
- }
+ if(m_iMediaLoadState != MLS_LOADED || m_iPlaybackMode != PM_DVD
+ || FAILED(pDVDI->GetCurrentUOPS(&ulUOPs)))
+ {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
- pCmdUI->Enable(!(ulUOPs & (UOP_FLAG_ShowMenu_Title << nID)));
+ pCmdUI->Enable(!(ulUOPs & (UOP_FLAG_ShowMenu_Title << nID)));
}
void CMainFrame::OnNavigateAudio(UINT nID)
{
- nID -= ID_NAVIGATE_AUDIO_SUBITEM_START;
+ nID -= ID_NAVIGATE_AUDIO_SUBITEM_START;
- if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
- {
- OnNavStreamSelectSubMenu(nID, 1);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- pDVDC->SelectAudioStream(nID, DVD_CMD_FLAG_Block, NULL);
- }
+ if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
+ {
+ OnNavStreamSelectSubMenu(nID, 1);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ pDVDC->SelectAudioStream(nID, DVD_CMD_FLAG_Block, NULL);
+ }
}
void CMainFrame::OnNavigateSubpic(UINT nID)
{
- if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
- {
- OnNavStreamSelectSubMenu(nID - ID_NAVIGATE_SUBP_SUBITEM_START, 2);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- int i = (int)nID - (1 + ID_NAVIGATE_SUBP_SUBITEM_START);
-
- if(i == -1)
- {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
- pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
- }
- else
- {
- pDVDC->SelectSubpictureStream(i, DVD_CMD_FLAG_Block, NULL);
- pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
- }
- }
+ if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
+ {
+ OnNavStreamSelectSubMenu(nID - ID_NAVIGATE_SUBP_SUBITEM_START, 2);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ int i = (int)nID - (1 + ID_NAVIGATE_SUBP_SUBITEM_START);
+
+ if(i == -1)
+ {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
+ pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
+ }
+ else
+ {
+ pDVDC->SelectSubpictureStream(i, DVD_CMD_FLAG_Block, NULL);
+ pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
+ }
+ }
}
void CMainFrame::OnNavigateAngle(UINT nID)
{
- nID -= ID_NAVIGATE_ANGLE_SUBITEM_START;
+ nID -= ID_NAVIGATE_ANGLE_SUBITEM_START;
- if(m_iPlaybackMode == PM_FILE)
- {
- OnNavStreamSelectSubMenu(nID, 0);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- pDVDC->SelectAngle(nID + 1, DVD_CMD_FLAG_Block, NULL);
- }
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ OnNavStreamSelectSubMenu(nID, 0);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ pDVDC->SelectAngle(nID+1, DVD_CMD_FLAG_Block, NULL);
+ }
}
void CMainFrame::OnNavigateChapters(UINT nID)
{
- nID -= ID_NAVIGATE_CHAP_SUBITEM_START;
-
- if(m_iPlaybackMode == PM_FILE)
- {
- if((int)nID >= 0 && nID < m_pCB->ChapGetCount())
- {
- REFERENCE_TIME rt;
- CComBSTR name;
- if(SUCCEEDED(m_pCB->ChapGet(nID, &rt, &name)))
- {
- SeekTo(rt);
- SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
- }
- return;
- }
-
- nID -= m_pCB->ChapGetCount();
-
- if((int)nID >= 0 && (int)nID < m_wndPlaylistBar.GetCount()
- && m_wndPlaylistBar.GetSelIdx() != (int)nID)
- {
- m_wndPlaylistBar.SetSelIdx(nID);
- OpenCurPlaylistItem();
- }
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles = 0;
- pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
-
- ULONG ulNumOfChapters = 0;
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
-
- nID++;
-
- if(nID > 0 && nID <= ulNumOfTitles)
- {
- pDVDC->PlayTitle(nID, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL); // sometimes this does not do anything ...
- pDVDC->PlayChapterInTitle(nID, 1, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL); // ... but this does!
- return;
- }
-
- nID -= ulNumOfTitles;
-
- if(nID > 0 && nID <= ulNumOfChapters)
- {
- pDVDC->PlayChapter(nID, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- return;
- }
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- if(AfxGetAppSettings().iDefaultCaptureDevice == 1)
- {
- CComQIPtr<IBDATuner> pTun = pGB;
- if(pTun)
- {
- pTun->SetChannel(nID);
- DisplayCurrentChannelOSD();
- if(m_wndNavigationBar.IsVisible())
- m_wndNavigationBar.m_navdlg.UpdatePos(nID);
- }
- }
- }
+ nID -= ID_NAVIGATE_CHAP_SUBITEM_START;
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ if((int)nID >= 0 && nID < m_pCB->ChapGetCount())
+ {
+ REFERENCE_TIME rt;
+ CComBSTR name;
+ if(SUCCEEDED(m_pCB->ChapGet(nID, &rt, &name)))
+ {
+ SeekTo(rt);
+ SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
+ }
+ return;
+ }
+
+ nID -= m_pCB->ChapGetCount();
+
+ if((int)nID >= 0 && (int)nID < m_wndPlaylistBar.GetCount()
+ && m_wndPlaylistBar.GetSelIdx() != (int)nID)
+ {
+ m_wndPlaylistBar.SetSelIdx(nID);
+ OpenCurPlaylistItem();
+ }
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles = 0;
+ pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+
+ ULONG ulNumOfChapters = 0;
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+
+ nID++;
+
+ if(nID > 0 && nID <= ulNumOfTitles)
+ {
+ pDVDC->PlayTitle(nID, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL); // sometimes this does not do anything ...
+ pDVDC->PlayChapterInTitle(nID, 1, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL); // ... but this does!
+ return;
+ }
+
+ nID -= ulNumOfTitles;
+
+ if(nID > 0 && nID <= ulNumOfChapters)
+ {
+ pDVDC->PlayChapter(nID, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ return;
+ }
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ if (AfxGetAppSettings().iDefaultCaptureDevice == 1)
+ {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun)
+ {
+ pTun->SetChannel (nID);
+ DisplayCurrentChannelOSD();
+ if (m_wndNavigationBar.IsVisible())
+ m_wndNavigationBar.m_navdlg.UpdatePos(nID);
+ }
+ }
+ }
}
void CMainFrame::OnNavigateMenuItem(UINT nID)
{
- nID -= ID_NAVIGATE_MENU_LEFT;
-
- if(m_iPlaybackMode == PM_DVD)
- {
- switch(nID)
- {
- case 0:
- pDVDC->SelectRelativeButton(DVD_Relative_Left);
- break;
- case 1:
- pDVDC->SelectRelativeButton(DVD_Relative_Right);
- break;
- case 2:
- pDVDC->SelectRelativeButton(DVD_Relative_Upper);
- break;
- case 3:
- pDVDC->SelectRelativeButton(DVD_Relative_Lower);
- break;
- case 4:
- if(m_iDVDDomain != DVD_DOMAIN_Title) // Casimir666 : pour télécommande
- pDVDC->ActivateButton();
- else
- OnPlayPlay();
- break;
- case 5:
- pDVDC->ReturnFromSubmenu(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- break;
- case 6:
- pDVDC->Resume(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
- break;
- default:
- break;
- }
- }
- else if(m_iPlaybackMode = PM_FILE) OnPlayPlay();
+ nID -= ID_NAVIGATE_MENU_LEFT;
+
+ if(m_iPlaybackMode == PM_DVD)
+ {
+ switch(nID)
+ {
+ case 0: pDVDC->SelectRelativeButton(DVD_Relative_Left); break;
+ case 1: pDVDC->SelectRelativeButton(DVD_Relative_Right); break;
+ case 2: pDVDC->SelectRelativeButton(DVD_Relative_Upper); break;
+ case 3: pDVDC->SelectRelativeButton(DVD_Relative_Lower); break;
+ case 4:
+ if (m_iDVDDomain != DVD_DOMAIN_Title) // Casimir666 : pour télécommande
+ pDVDC->ActivateButton();
+ else
+ OnPlayPlay();
+ break;
+ case 5: pDVDC->ReturnFromSubmenu(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL); break;
+ case 6: pDVDC->Resume(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL); break;
+ default: break;
+ }
+ }
+ else if (m_iPlaybackMode = PM_FILE) OnPlayPlay();
}
void CMainFrame::OnUpdateNavigateMenuItem(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_NAVIGATE_MENU_LEFT;
- pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) && ((m_iPlaybackMode == PM_DVD) || (m_iPlaybackMode == PM_FILE)));
+ UINT nID = pCmdUI->m_nID - ID_NAVIGATE_MENU_LEFT;
+ pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) && ((m_iPlaybackMode == PM_DVD) || (m_iPlaybackMode == PM_FILE)));
}
void CMainFrame::OnTunerScan()
{
- CTunerScanDlg Dlg;
- Dlg.DoModal();
+ CTunerScanDlg Dlg;
+ Dlg.DoModal();
}
void CMainFrame::OnUpdateTunerScan(CCmdUI* pCmdUI)
{
- pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) &&
- (AfxGetAppSettings().iDefaultCaptureDevice == 1) &&
- ((m_iPlaybackMode == PM_CAPTURE)));
+ pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) &&
+ (AfxGetAppSettings().iDefaultCaptureDevice == 1) &&
+ ((m_iPlaybackMode == PM_CAPTURE)));
}
// favorites
class CDVDStateStream : public CUnknown, public IStream
{
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- return
- QI(IStream)
- CUnknown::NonDelegatingQueryInterface(riid, ppv);
- }
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ return
+ QI(IStream)
+ CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ }
- __int64 m_pos;
+ __int64 m_pos;
public:
- CDVDStateStream() : CUnknown(NAME("CDVDStateStream"), NULL)
- {
- m_pos = 0;
- }
+ CDVDStateStream() : CUnknown(NAME("CDVDStateStream"), NULL) {m_pos = 0;}
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
- CAtlArray<BYTE> m_data;
+ CAtlArray<BYTE> m_data;
// ISequentialStream
- STDMETHODIMP Read(void* pv, ULONG cb, ULONG* pcbRead)
- {
- __int64 cbRead = min(m_data.GetCount() - m_pos, (__int64)cb);
- cbRead = max(cbRead, 0);
- memcpy(pv, &m_data[(INT_PTR)m_pos], (int)cbRead);
- if(pcbRead) *pcbRead = (ULONG)cbRead;
- m_pos += cbRead;
- return S_OK;
- }
- STDMETHODIMP Write(const void* pv, ULONG cb, ULONG* pcbWritten)
- {
- BYTE* p = (BYTE*)pv;
- ULONG cbWritten = -1;
- while(++cbWritten < cb)
- m_data.Add(*p++);
- if(pcbWritten) *pcbWritten = cbWritten;
- return S_OK;
- }
-
- // IStream
- STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP Commit(DWORD grfCommitFlags)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP Revert()
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP Stat(STATSTG* pstatstg, DWORD grfStatFlag)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP Clone(IStream** ppstm)
- {
- return E_NOTIMPL;
- }
+ STDMETHODIMP Read(void* pv, ULONG cb, ULONG* pcbRead)
+ {
+ __int64 cbRead = min(m_data.GetCount() - m_pos, (__int64)cb);
+ cbRead = max(cbRead, 0);
+ memcpy(pv, &m_data[(INT_PTR)m_pos], (int)cbRead);
+ if(pcbRead) *pcbRead = (ULONG)cbRead;
+ m_pos += cbRead;
+ return S_OK;
+ }
+ STDMETHODIMP Write(const void* pv, ULONG cb, ULONG* pcbWritten)
+ {
+ BYTE* p = (BYTE*)pv;
+ ULONG cbWritten = -1;
+ while(++cbWritten < cb)
+ m_data.Add(*p++);
+ if(pcbWritten) *pcbWritten = cbWritten;
+ return S_OK;
+ }
+
+ // IStream
+ STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) {return E_NOTIMPL;}
+ STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize) {return E_NOTIMPL;}
+ STDMETHODIMP CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {return E_NOTIMPL;}
+ STDMETHODIMP Commit(DWORD grfCommitFlags) {return E_NOTIMPL;}
+ STDMETHODIMP Revert() {return E_NOTIMPL;}
+ STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {return E_NOTIMPL;}
+ STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {return E_NOTIMPL;}
+ STDMETHODIMP Stat(STATSTG* pstatstg, DWORD grfStatFlag) {return E_NOTIMPL;}
+ STDMETHODIMP Clone(IStream** ppstm) {return E_NOTIMPL;}
};
void CMainFrame::OnFavoritesAdd()
{
- AppSettings& s = AfxGetAppSettings();
-
- if(m_iPlaybackMode == PM_FILE)
- {
- CString fn = m_wndPlaylistBar.GetCur();
- if(fn.IsEmpty()) return;
-
- CString desc = fn;
- desc.Replace('\\', '/');
- int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
- if(i >= 0) desc = j >= 0 ? desc.Left(j) : desc;
- else if(k >= 0) desc = desc.Mid(k + 1);
-
- CFavoriteAddDlg dlg(desc, fn);
- if(dlg.DoModal() != IDOK) return;
-
- // Name
- CString str = dlg.m_name;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if(dlg.m_bRememberPos)
- pos.Format(_T("%I64d"), GetPos());
-
- str += ';';
- str += pos;
-
- // RelativeDrive
- CString relativeDrive;
- relativeDrive.Format(_T("%d"), dlg.m_bRelativeDrive);
-
- str += ';';
- str += relativeDrive;
-
- // Paths
- CPlaylistItem pli;
- if(m_wndPlaylistBar.GetCur(pli))
- {
- POSITION pos = pli.m_fns.GetHeadPosition();
- while(pos) str += _T(";") + pli.m_fns.GetNext(pos);
- }
-
- s.AddFav(FAV_FILE, str);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- WCHAR path[_MAX_PATH];
- ULONG len = 0;
- pDVDI->GetDVDDirectory(path, MAX_PATH, &len);
- CString fn = path;
- fn.TrimRight(_T("/\\"));
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
- CString desc;
- desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
- Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
-
- CFavoriteAddDlg dlg(fn, desc);
- if(dlg.DoModal() != IDOK) return;
-
- // Name
- CString str = dlg.m_name;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if(dlg.m_bRememberPos)
- {
- CDVDStateStream stream;
- stream.AddRef();
-
- CComPtr<IDvdState> pStateData;
- CComQIPtr<IPersistStream> pPersistStream;
- if(SUCCEEDED(pDVDI->GetState(&pStateData))
- && (pPersistStream = pStateData)
- && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream)))
- {
- pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
- }
- }
-
- str += ';';
- str += pos;
-
- // Paths
- str += ';';
- str += fn;
-
- s.AddFav(FAV_DVD, str);
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- // TODO
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CString fn = m_wndPlaylistBar.GetCur();
+ if(fn.IsEmpty()) return;
+
+ CString desc = fn;
+ desc.Replace('\\', '/');
+ int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
+ if(i >= 0) desc = j >= 0 ? desc.Left(j) : desc;
+ else if(k >= 0) desc = desc.Mid(k+1);
+
+ CFavoriteAddDlg dlg(desc, fn);
+ if(dlg.DoModal() != IDOK) return;
+
+ // Name
+ CString str = dlg.m_name;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if(dlg.m_bRememberPos)
+ pos.Format(_T("%I64d"), GetPos());
+
+ str += ';';
+ str += pos;
+
+ // RelativeDrive
+ CString relativeDrive;
+ relativeDrive.Format( _T("%d"), dlg.m_bRelativeDrive );
+
+ str += ';';
+ str += relativeDrive;
+
+ // Paths
+ CPlaylistItem pli;
+ if(m_wndPlaylistBar.GetCur(pli))
+ {
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while(pos) str += _T(";") + pli.m_fns.GetNext(pos);
+ }
+
+ s.AddFav(FAV_FILE, str);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ WCHAR path[_MAX_PATH];
+ ULONG len = 0;
+ pDVDI->GetDVDDirectory(path, MAX_PATH, &len);
+ CString fn = path;
+ fn.TrimRight(_T("/\\"));
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+ CString desc;
+ desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
+ Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
+
+ CFavoriteAddDlg dlg(fn, desc);
+ if(dlg.DoModal() != IDOK) return;
+
+ // Name
+ CString str = dlg.m_name;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if(dlg.m_bRememberPos)
+ {
+ CDVDStateStream stream;
+ stream.AddRef();
+
+ CComPtr<IDvdState> pStateData;
+ CComQIPtr<IPersistStream> pPersistStream;
+ if(SUCCEEDED(pDVDI->GetState(&pStateData))
+ && (pPersistStream = pStateData)
+ && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream)))
+ {
+ pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
+ }
+ }
+
+ str += ';';
+ str += pos;
+
+ // Paths
+ str += ';';
+ str += fn;
+
+ s.AddFav(FAV_DVD, str);
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ // TODO
+ }
}
void CMainFrame::OnUpdateFavoritesAdd(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_DVD);
+ pCmdUI->Enable(m_iPlaybackMode == PM_FILE || m_iPlaybackMode == PM_DVD);
}
// TODO: OnFavoritesAdd and OnFavoritesQuickAddFavorite use nearly the same code, do something about it
void CMainFrame::OnFavoritesQuickAddFavorite()
{
- AppSettings& s = AfxGetAppSettings();
-
- if(m_iPlaybackMode == PM_FILE)
- {
- CString fn = m_wndPlaylistBar.GetCur();
- if(fn.IsEmpty()) return;
-
- CString desc = fn;
- desc.Replace('\\', '/');
- int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
- if(i >= 0) desc = j >= 0 ? desc.Left(j) : desc;
- else if(k >= 0) desc = desc.Mid(k + 1);
-
- // TODO: Make this proper code
- BOOL bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
- BOOL bRelativeDrive = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
-
- CString fn_with_pos(desc);
- if(bRememberPos)
- fn_with_pos.Format(_T("%s_%s"), desc, GetVidPos()); // Add file position (time format) so it will be easier to organize later
-
- // Name
- CString str = fn_with_pos;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if(bRememberPos)
- pos.Format(_T("%I64d"), GetPos());
-
- str += ';';
- str += pos;
-
- // RelativeDrive
- CString relativeDrive;
- relativeDrive.Format(_T("%d"), bRelativeDrive);
-
- str += ';';
- str += relativeDrive;
-
- // Paths
- CPlaylistItem pli;
- if(m_wndPlaylistBar.GetCur(pli))
- {
- POSITION pos = pli.m_fns.GetHeadPosition();
- while(pos) str += _T(";") + pli.m_fns.GetNext(pos);
- }
-
- s.AddFav(FAV_FILE, str);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- WCHAR path[_MAX_PATH];
- ULONG len = 0;
- pDVDI->GetDVDDirectory(path, MAX_PATH, &len);
- CString fn = path;
- fn.TrimRight(_T("/\\"));
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
- CString desc;
- desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
- Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
-
- // TODO: Make this proper code
- BOOL bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
-
- // Name
- CString str = bRememberPos ? desc : fn;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if(bRememberPos)
- {
- CDVDStateStream stream;
- stream.AddRef();
-
- CComPtr<IDvdState> pStateData;
- CComQIPtr<IPersistStream> pPersistStream;
- if(SUCCEEDED(pDVDI->GetState(&pStateData))
- && (pPersistStream = pStateData)
- && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream)))
- {
- pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
- }
- }
-
- str += ';';
- str += pos;
-
- // Paths
- str += ';';
- str += fn;
-
- s.AddFav(FAV_DVD, str);
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- // TODO
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CString fn = m_wndPlaylistBar.GetCur();
+ if(fn.IsEmpty()) return;
+
+ CString desc = fn;
+ desc.Replace('\\', '/');
+ int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
+ if(i >= 0) desc = j >= 0 ? desc.Left(j) : desc;
+ else if(k >= 0) desc = desc.Mid(k+1);
+
+ // TODO: Make this proper code
+ BOOL bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
+ BOOL bRelativeDrive = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
+
+ CString fn_with_pos(desc);
+ if(bRememberPos)
+ fn_with_pos.Format(_T("%s_%s"), desc, GetVidPos()); // Add file position (time format) so it will be easier to organize later
+
+ // Name
+ CString str = fn_with_pos;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if(bRememberPos)
+ pos.Format(_T("%I64d"), GetPos());
+
+ str += ';';
+ str += pos;
+
+ // RelativeDrive
+ CString relativeDrive;
+ relativeDrive.Format( _T("%d"), bRelativeDrive );
+
+ str += ';';
+ str += relativeDrive;
+
+ // Paths
+ CPlaylistItem pli;
+ if(m_wndPlaylistBar.GetCur(pli))
+ {
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while(pos) str += _T(";") + pli.m_fns.GetNext(pos);
+ }
+
+ s.AddFav(FAV_FILE, str);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ WCHAR path[_MAX_PATH];
+ ULONG len = 0;
+ pDVDI->GetDVDDirectory(path, MAX_PATH, &len);
+ CString fn = path;
+ fn.TrimRight(_T("/\\"));
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+ CString desc;
+ desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
+ Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
+
+ // TODO: Make this proper code
+ BOOL bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
+
+ // Name
+ CString str = bRememberPos ? desc : fn;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if(bRememberPos)
+ {
+ CDVDStateStream stream;
+ stream.AddRef();
+
+ CComPtr<IDvdState> pStateData;
+ CComQIPtr<IPersistStream> pPersistStream;
+ if(SUCCEEDED(pDVDI->GetState(&pStateData))
+ && (pPersistStream = pStateData)
+ && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream)))
+ {
+ pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
+ }
+ }
+
+ str += ';';
+ str += pos;
+
+ // Paths
+ str += ';';
+ str += fn;
+
+ s.AddFav(FAV_DVD, str);
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ // TODO
+ }
}
void CMainFrame::OnFavoritesOrganize()
{
- CFavoriteOrganizeDlg dlg;
- dlg.DoModal();
+ CFavoriteOrganizeDlg dlg;
+ dlg.DoModal();
}
void CMainFrame::OnUpdateFavoritesOrganize(CCmdUI* pCmdUI)
{
- // TODO: Add your command update UI handler code here
+ // TODO: Add your command update UI handler code here
}
void CMainFrame::OnRecentFileClear()
{
- if(IDYES != AfxMessageBox(ResStr(IDS_RECENT_FILES_QUESTION), MB_YESNO))
- return;
+ if(IDYES != AfxMessageBox(ResStr(IDS_RECENT_FILES_QUESTION), MB_YESNO))
+ return;
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- for(int i = 0; i < s.MRU.GetSize(); i++) s.MRU[i] = _T("");
- for(int i = 0; i < s.MRUDub.GetSize(); i++) s.MRUDub[i] = _T("");
- s.MRU.WriteList();
- s.MRUDub.WriteList();
+ for(int i = 0; i < s.MRU.GetSize(); i++) s.MRU[i] = _T("");
+ for(int i = 0; i < s.MRUDub.GetSize(); i++) s.MRUDub[i] = _T("");
+ s.MRU.WriteList();
+ s.MRUDub.WriteList();
}
void CMainFrame::OnUpdateRecentFileClear(CCmdUI* pCmdUI)
{
- // TODO: Add your command update UI handler code here
+ // TODO: Add your command update UI handler code here
}
void CMainFrame::OnFavoritesFile(UINT nID)
{
- nID -= ID_FAVORITES_FILE_START;
-
- CAtlList<CString> sl;
- AfxGetAppSettings().GetFav(FAV_FILE, sl);
-
- if(POSITION pos = sl.FindIndex(nID))
- {
- CAtlList<CString> fns;
- REFERENCE_TIME rtStart = 0;
- BOOL bRelativeDrive = FALSE;
-
- int i = 0, j = 0;
- for(CString s1 = sl.GetAt(pos), s2 = s1.Tokenize(_T(";"), i);
- !s2.IsEmpty();
- s2 = s1.Tokenize(_T(";"), i), j++)
- {
- if(j == 0) ; // desc / name
- else if(j == 1) _stscanf_s(s2, _T("%I64d"), &rtStart); // pos
- else if(j == 2) _stscanf_s(s2, _T("%d"), &bRelativeDrive); // relative drive
- else fns.AddTail(s2); // paths
- }
-
- // NOTE: This is just for the favorites but we could add a global settings that does this always when on. Could be useful when using removable devices.
- // All you have to do then is plug in your 500 gb drive, full with movies and/or music, start mpc-hc (from the 500 gb drive) with a preloaded playlist and press play.
- if(bRelativeDrive)
- {
- // Get the drive mpc-hc is on and apply it to the path list
- CString exePath;
- DWORD dwLength = GetModuleFileName(AfxGetInstanceHandle(), exePath.GetBuffer(MAX_PATH), MAX_PATH);
- exePath.ReleaseBuffer(dwLength);
-
- CPath exeDrive(exePath);
-
- if(exeDrive.StripToRoot())
- {
- POSITION pos = fns.GetHeadPosition();
-
- while(pos != NULL)
- {
- CString &stringPath = fns.GetNext(pos);
- CPath path(stringPath);
-
- int rootLength = path.SkipRoot();
-
- if(path.StripToRoot())
- {
- if(_tcsicmp(exeDrive, path) != 0) // Do we need to replace the drive letter ?
- {
- // Replace drive letter
- CString newPath(exeDrive);
-
- newPath += stringPath.Mid(rootLength); //newPath += stringPath.Mid( 3 );
-
- stringPath = newPath;
- }
- }
- }
- }
- }
-
- m_wndPlaylistBar.Open(fns, false);
- OpenCurPlaylistItem(max(rtStart, 0));
- }
+ nID -= ID_FAVORITES_FILE_START;
+
+ CAtlList<CString> sl;
+ AfxGetAppSettings().GetFav(FAV_FILE, sl);
+
+ if(POSITION pos = sl.FindIndex(nID))
+ {
+ CAtlList<CString> fns;
+ REFERENCE_TIME rtStart = 0;
+ BOOL bRelativeDrive = FALSE;
+
+ int i = 0, j = 0;
+ for(CString s1 = sl.GetAt(pos), s2 = s1.Tokenize(_T(";"), i);
+ !s2.IsEmpty();
+ s2 = s1.Tokenize(_T(";"), i), j++)
+ {
+ if(j == 0) ; // desc / name
+ else if(j == 1) _stscanf_s(s2, _T("%I64d"), &rtStart); // pos
+ else if(j == 2) _stscanf_s(s2, _T("%d"), &bRelativeDrive); // relative drive
+ else fns.AddTail(s2); // paths
+ }
+
+ // NOTE: This is just for the favorites but we could add a global settings that does this always when on. Could be useful when using removable devices.
+ // All you have to do then is plug in your 500 gb drive, full with movies and/or music, start mpc-hc (from the 500 gb drive) with a preloaded playlist and press play.
+ if ( bRelativeDrive )
+ {
+ // Get the drive mpc-hc is on and apply it to the path list
+ CString exePath;
+ DWORD dwLength = GetModuleFileName( AfxGetInstanceHandle(), exePath.GetBuffer(MAX_PATH), MAX_PATH );
+ exePath.ReleaseBuffer( dwLength );
+
+ CPath exeDrive( exePath );
+
+ if ( exeDrive.StripToRoot() )
+ {
+ POSITION pos = fns.GetHeadPosition();
+
+ while ( pos != NULL )
+ {
+ CString &stringPath = fns.GetNext( pos );
+ CPath path( stringPath );
+
+ int rootLength = path.SkipRoot();
+
+ if ( path.StripToRoot() )
+ {
+ if ( _tcsicmp(exeDrive, path) != 0 ) // Do we need to replace the drive letter ?
+ {
+ // Replace drive letter
+ CString newPath( exeDrive );
+
+ newPath += stringPath.Mid( rootLength );//newPath += stringPath.Mid( 3 );
+
+ stringPath = newPath;
+ }
+ }
+ }
+ }
+ }
+
+ m_wndPlaylistBar.Open(fns, false);
+ OpenCurPlaylistItem(max(rtStart, 0));
+ }
}
void CMainFrame::OnUpdateFavoritesFile(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_FAVORITES_FILE_START;
+ UINT nID = pCmdUI->m_nID - ID_FAVORITES_FILE_START;
}
void CMainFrame::OnRecentFile(UINT nID)
{
- nID -= ID_RECENT_FILE_START;
- CString str;
- m_recentfiles.GetMenuString(nID + 2, str, MF_BYPOSITION);
- CAtlList<CString> fns;
- fns.AddTail(str);
- m_wndPlaylistBar.Open(fns, false);
- OpenCurPlaylistItem(0);
+ nID -= ID_RECENT_FILE_START;
+ CString str;
+ m_recentfiles.GetMenuString(nID+2, str, MF_BYPOSITION);
+ CAtlList<CString> fns;
+ fns.AddTail(str);
+ m_wndPlaylistBar.Open(fns, false);
+ OpenCurPlaylistItem(0);
}
void CMainFrame::OnUpdateRecentFile(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_RECENT_FILE_START;
+ UINT nID = pCmdUI->m_nID - ID_RECENT_FILE_START;
}
void CMainFrame::OnFavoritesDVD(UINT nID)
{
- nID -= ID_FAVORITES_DVD_START;
+ nID -= ID_FAVORITES_DVD_START;
- CAtlList<CString> sl;
- AfxGetAppSettings().GetFav(FAV_DVD, sl);
+ CAtlList<CString> sl;
+ AfxGetAppSettings().GetFav(FAV_DVD, sl);
- if(POSITION pos = sl.FindIndex(nID))
- {
- CString fn;
+ if(POSITION pos = sl.FindIndex(nID))
+ {
+ CString fn;
- CDVDStateStream stream;
- stream.AddRef();
+ CDVDStateStream stream;
+ stream.AddRef();
- int i = 0, j = 0;
- for(CString s1 = sl.GetAt(pos), s2 = s1.Tokenize(_T(";"), i);
- !s2.IsEmpty();
- s2 = s1.Tokenize(_T(";"), i), j++)
- {
- if(j == 0) ; // desc
- else if(j == 1 && s2 != _T("0")) // state
- {
- CStringToBin(s2, stream.m_data);
- }
- else if(j == 2) fn = s2; // path
- }
+ int i = 0, j = 0;
+ for(CString s1 = sl.GetAt(pos), s2 = s1.Tokenize(_T(";"), i);
+ !s2.IsEmpty();
+ s2 = s1.Tokenize(_T(";"), i), j++)
+ {
+ if(j == 0) ; // desc
+ else if(j == 1 && s2 != _T("0")) // state
+ {
+ CStringToBin(s2, stream.m_data);
+ }
+ else if(j == 2) fn = s2; // path
+ }
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- CComPtr<IDvdState> pDvdState;
- HRESULT hr = OleLoadFromStream((IStream*)&stream, IID_IDvdState, (void**)&pDvdState);
+ CComPtr<IDvdState> pDvdState;
+ HRESULT hr = OleLoadFromStream((IStream*)&stream, IID_IDvdState, (void**)&pDvdState);
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if(p)
- {
- p->path = fn;
- p->pDvdState = pDvdState;
- }
- OpenMedia(p);
- }
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if(p) {p->path = fn; p->pDvdState = pDvdState;}
+ OpenMedia(p);
+ }
}
void CMainFrame::OnUpdateFavoritesDVD(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_FAVORITES_DVD_START;
+ UINT nID = pCmdUI->m_nID - ID_FAVORITES_DVD_START;
}
void CMainFrame::OnFavoritesDevice(UINT nID)
{
- nID -= ID_FAVORITES_DEVICE_START;
+ nID -= ID_FAVORITES_DEVICE_START;
}
void CMainFrame::OnUpdateFavoritesDevice(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_FAVORITES_DEVICE_START;
+ UINT nID = pCmdUI->m_nID - ID_FAVORITES_DEVICE_START;
}
// help
void CMainFrame::OnHelpHomepage()
{
- ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/about-homepage.html"), NULL, NULL, SW_SHOWDEFAULT);
+ ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/about-homepage.html"), NULL, NULL, SW_SHOWDEFAULT);
}
void CMainFrame::OnHelpDocumentation()
{
- ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=144472"), NULL, NULL, SW_SHOWDEFAULT);
+ ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=144472"), NULL, NULL, SW_SHOWDEFAULT);
}
void CMainFrame::OnHelpDonate()
{
- const TCHAR URL[] = _T("http://sourceforge.net/project/showfiles.php?group_id=170561");
- if(CString(URL).Find(CString(_T("A4N")).MakeReverse()) >= 0)
- ShellExecute(m_hWnd, _T("open"), URL, NULL, NULL, SW_SHOWDEFAULT);
+ const TCHAR URL[] = _T("http://sourceforge.net/project/showfiles.php?group_id=170561");
+ if(CString(URL).Find(CString(_T("A4N")).MakeReverse()) >= 0)
+ ShellExecute(m_hWnd, _T("open"), URL, NULL, NULL, SW_SHOWDEFAULT);
}
//////////////////////////////////
static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
- CAtlArray<HMONITOR>* ml = (CAtlArray<HMONITOR>*)dwData;
- ml->Add(hMonitor);
- return TRUE;
+ CAtlArray<HMONITOR>* ml = (CAtlArray<HMONITOR>*)dwData;
+ ml->Add(hMonitor);
+ return TRUE;
}
void CMainFrame::SetDefaultWindowRect(int iMonitor)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- {
- boolean m_center = true;
-
- CRect r1, r2;
- GetClientRect(&r1);
- m_wndView.GetClientRect(&r2);
+ {
+ boolean m_center = true;
+
+ CRect r1, r2;
+ GetClientRect(&r1);
+ m_wndView.GetClientRect(&r2);
- CSize logosize = m_wndView.GetLogoSize();
- int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
- int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
+ CSize logosize = m_wndView.GetLogoSize();
+ int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
+ int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
- if(GetSystemMetrics(SM_REMOTESESSION))
- _DEFCLIENTH = 0;
+ if(GetSystemMetrics(SM_REMOTESESSION))
+ _DEFCLIENTH = 0;
- DWORD style = GetStyle();
+ DWORD style = GetStyle();
- MENUBARINFO mbi;
- memset(&mbi, 0, sizeof(mbi));
- mbi.cbSize = sizeof(mbi);
- ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+ MENUBARINFO mbi;
+ memset(&mbi, 0, sizeof(mbi));
+ mbi.cbSize = sizeof(mbi);
+ ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
- int w = _DEFCLIENTW + ((style & WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME) * 2 : 0)
- + r1.Width() - r2.Width();
- int h = _DEFCLIENTH + ((style & WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME) * 2 : 0)
- + (mbi.rcBar.bottom - mbi.rcBar.top)
- + r1.Height() - r2.Height()
- + 1; // ???
+ int w = _DEFCLIENTW + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME)*2 : 0)
+ + r1.Width() - r2.Width();
+ int h = _DEFCLIENTH + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
+ + (mbi.rcBar.bottom - mbi.rcBar.top)
+ + r1.Height() - r2.Height()
+ + 1; // ???
// + 2; // ???
- if(style & WS_CAPTION) h += GetSystemMetrics(SM_CYCAPTION);
-
- if(s.HasFixedWindowSize())
- {
- w = s.fixedWindowSize.cx;
- h = s.fixedWindowSize.cy;
- }
- else if(s.fRememberWindowSize)
- {
- w = s.rcLastWindowPos.Width();
- h = s.rcLastWindowPos.Height();
- m_center = false;
- }
-
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
-
- if(iMonitor > 0)
- {
- iMonitor--;
- CAtlArray<HMONITOR> ml;
- EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&ml);
- if(iMonitor < ml.GetCount()) hMonitor = ml[iMonitor];
- }
-
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(hMonitor, &mi);
-
- int x = (mi.rcWork.left + mi.rcWork.right - w) / 2;
- int y = (mi.rcWork.top + mi.rcWork.bottom - h) / 2;
-
- if(s.fRememberWindowPos)
- {
- CRect r = s.rcLastWindowPos;
+ if(style&WS_CAPTION) h += GetSystemMetrics(SM_CYCAPTION);
+
+ if(s.HasFixedWindowSize())
+ {
+ w = s.fixedWindowSize.cx;
+ h = s.fixedWindowSize.cy;
+ }
+ else if(s.fRememberWindowSize)
+ {
+ w = s.rcLastWindowPos.Width();
+ h = s.rcLastWindowPos.Height();
+ m_center = false;
+ }
+
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+
+ if(iMonitor > 0)
+ {
+ iMonitor--;
+ CAtlArray<HMONITOR> ml;
+ EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&ml);
+ if(iMonitor < ml.GetCount()) hMonitor = ml[iMonitor];
+ }
+
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfo(hMonitor, &mi);
+
+ int x = (mi.rcWork.left+mi.rcWork.right-w)/2;
+ int y = (mi.rcWork.top+mi.rcWork.bottom-h)/2;
+
+ if(s.fRememberWindowPos)
+ {
+ CRect r = s.rcLastWindowPos;
// x = r.CenterPoint().x - w/2;
// y = r.CenterPoint().y - h/2;
- x = r.TopLeft().x;
- y = r.TopLeft().y;
- m_center = false;
- }
-
- UINT lastWindowType = s.lastWindowType;
-
- MoveWindow(x, y, w, h);
-
- // Center main window ...
- if(m_center) CenterWindow();
-
- // Waffs : fullscreen command line
- if(!(s.nCLSwitches & CLSW_ADD) && (s.nCLSwitches & CLSW_FULLSCREEN) && !s.slFiles.IsEmpty())
- {
- ToggleFullscreen(true, true);
- SetCursor(NULL);
- AfxGetAppSettings().nCLSwitches &= ~CLSW_FULLSCREEN;
- m_fFirstFSAfterLaunchOnFS = true;
- }
-
- if(s.fRememberWindowSize && s.fRememberWindowPos)
- {
- WINDOWPLACEMENT wp;
- memset(&wp, 0, sizeof(wp));
- wp.length = sizeof(WINDOWPLACEMENT);
- if(lastWindowType == SIZE_MAXIMIZED)
- ShowWindow(SW_MAXIMIZE);
- else if(lastWindowType == SIZE_MINIMIZED)
- ShowWindow(SW_MINIMIZE);
-
- // Casimir666 : remettre le full screen si tel était de cas
- if(!m_fFullScreen && s.fLastFullScreen) ToggleFullscreen(true, true);
- }
- }
-
- if(s.fHideCaptionMenu)
- {
- ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0, SWP_NOZORDER);
- ::SetMenu(m_hWnd, NULL);
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
- }
+ x = r.TopLeft().x;
+ y = r.TopLeft().y;
+ m_center = false;
+ }
+
+ UINT lastWindowType = s.lastWindowType;
+
+ MoveWindow(x, y, w, h);
+
+ // Center main window ...
+ if(m_center) CenterWindow();
+
+ // Waffs : fullscreen command line
+ if(!(s.nCLSwitches&CLSW_ADD) && (s.nCLSwitches&CLSW_FULLSCREEN) && !s.slFiles.IsEmpty())
+ {
+ ToggleFullscreen(true, true);
+ SetCursor(NULL);
+ AfxGetAppSettings().nCLSwitches &= ~CLSW_FULLSCREEN;
+ m_fFirstFSAfterLaunchOnFS = true;
+ }
+
+ if(s.fRememberWindowSize && s.fRememberWindowPos)
+ {
+ WINDOWPLACEMENT wp;
+ memset(&wp, 0, sizeof(wp));
+ wp.length = sizeof(WINDOWPLACEMENT);
+ if(lastWindowType == SIZE_MAXIMIZED)
+ ShowWindow(SW_MAXIMIZE);
+ else if(lastWindowType == SIZE_MINIMIZED)
+ ShowWindow(SW_MINIMIZE);
+
+ // Casimir666 : remettre le full screen si tel était de cas
+ if (!m_fFullScreen && s.fLastFullScreen) ToggleFullscreen(true, true);
+ }
+ }
+
+ if(s.fHideCaptionMenu)
+ {
+ ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0, SWP_NOZORDER);
+ ::SetMenu(m_hWnd, NULL);
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER);
+ }
}
void CMainFrame::RestoreDefaultWindowRect()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- WINDOWPLACEMENT wp;
- GetWindowPlacement(&wp);
- if(!m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED
+ WINDOWPLACEMENT wp;
+ GetWindowPlacement(&wp);
+ if(!m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED
// && (GetExStyle()&WS_EX_APPWINDOW)
- && !s.fRememberWindowSize)
- {
- CRect r1, r2;
- GetClientRect(&r1);
- m_wndView.GetClientRect(&r2);
-
- CSize logosize = m_wndView.GetLogoSize();
- int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
- int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
-
- DWORD style = GetStyle();
-
- MENUBARINFO mbi;
- memset(&mbi, 0, sizeof(mbi));
- mbi.cbSize = sizeof(mbi);
- ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- int w = _DEFCLIENTW + ((style & WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME) * 2 : 0)
- + r1.Width() - r2.Width();
- int h = _DEFCLIENTH + ((style & WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME) * 2 : 0)
- + (mbi.rcBar.bottom - mbi.rcBar.top)
- + r1.Height() - r2.Height()
- + 1; // ???
+ && !s.fRememberWindowSize)
+ {
+ CRect r1, r2;
+ GetClientRect(&r1);
+ m_wndView.GetClientRect(&r2);
+
+ CSize logosize = m_wndView.GetLogoSize();
+ int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
+ int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
+
+ DWORD style = GetStyle();
+
+ MENUBARINFO mbi;
+ memset(&mbi, 0, sizeof(mbi));
+ mbi.cbSize = sizeof(mbi);
+ ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+
+ int w = _DEFCLIENTW + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME)*2 : 0)
+ + r1.Width() - r2.Width();
+ int h = _DEFCLIENTH + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
+ + (mbi.rcBar.bottom - mbi.rcBar.top)
+ + r1.Height() - r2.Height()
+ + 1; // ???
// + 2; // ???
- if(style & WS_CAPTION) h += GetSystemMetrics(SM_CYCAPTION);
+ if(style&WS_CAPTION) h += GetSystemMetrics(SM_CYCAPTION);
- if(s.HasFixedWindowSize())
- {
- w = s.fixedWindowSize.cx;
- h = s.fixedWindowSize.cy;
- }
+ if(s.HasFixedWindowSize())
+ {
+ w = s.fixedWindowSize.cx;
+ h = s.fixedWindowSize.cy;
+ }
- CRect r;
- GetWindowRect(r);
+ CRect r;
+ GetWindowRect(r);
- int x = r.CenterPoint().x - w / 2;
- int y = r.CenterPoint().y - h / 2;
+ int x = r.CenterPoint().x - w/2;
+ int y = r.CenterPoint().y - h/2;
- if(s.fRememberWindowPos)
- {
- CRect r = s.rcLastWindowPos;
+ if(s.fRememberWindowPos)
+ {
+ CRect r = s.rcLastWindowPos;
- x = r.TopLeft().x;
- y = r.TopLeft().y;
- }
+ x = r.TopLeft().x;
+ y = r.TopLeft().y;
+ }
- MoveWindow(x, y, w, h);
+ MoveWindow(x, y, w, h);
- if(!s.fRememberWindowPos) CenterWindow();
- }
+ if(!s.fRememberWindowPos) CenterWindow();
+ }
}
OAFilterState CMainFrame::GetMediaState()
{
- OAFilterState ret = -1;
- if(m_iMediaLoadState == MLS_LOADED) pMC->GetState(0, &ret);
- return(ret);
+ OAFilterState ret = -1;
+ if(m_iMediaLoadState == MLS_LOADED) pMC->GetState(0, &ret);
+ return(ret);
}
CSize CMainFrame::GetVideoSize()
{
- bool fKeepAspectRatio = AfxGetAppSettings().fKeepAspectRatio;
- bool fCompMonDeskARDiff = AfxGetAppSettings().fCompMonDeskARDiff;
-
- CSize ret(0, 0);
- if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly)
- return ret;
-
- CSize wh(0, 0), arxy(0, 0);
-
- if(m_pMFVDC)
- {
- m_pMFVDC->GetNativeVideoSize(&wh, &arxy); // TODO : check AR !!
- }
- else if(m_pCAP)
- {
- wh = m_pCAP->GetVideoSize(false);
- arxy = m_pCAP->GetVideoSize(fKeepAspectRatio);
- }
- else
- {
- pBV->GetVideoSize(&wh.cx, &wh.cy);
-
- long arx = 0, ary = 0;
- CComQIPtr<IBasicVideo2> pBV2 = pBV;
- if(pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) // FIXME: It can hang here, for few seconds (CPU goes to 100%), after the window have been moving over to another screen, due to GetPreferredAspectRatio, if it happens before CAudioSwitcherFilter::DeliverEndFlush, it seems.
- arxy.SetSize(arx, ary);
- }
-
- if(wh.cx <= 0 || wh.cy <= 0)
- return ret;
-
- // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
- DVD_VideoAttributes VATR;
- if(m_iPlaybackMode == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR)))
- arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
-
- CSize& ar = AfxGetAppSettings().AspectRatio;
- if(ar.cx && ar.cy) arxy = ar;
-
- ret = (!fKeepAspectRatio || arxy.cx <= 0 || arxy.cy <= 0)
- ? wh
- : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
-
- if(fCompMonDeskARDiff)
- if(HDC hDC = ::GetDC(0))
- {
- int _HORZSIZE = GetDeviceCaps(hDC, HORZSIZE);
- int _VERTSIZE = GetDeviceCaps(hDC, VERTSIZE);
- int _HORZRES = GetDeviceCaps(hDC, HORZRES);
- int _VERTRES = GetDeviceCaps(hDC, VERTRES);
-
- if(_HORZSIZE > 0 && _VERTSIZE > 0 && _HORZRES > 0 && _VERTRES > 0)
- {
- double a = 1.0 * _HORZSIZE / _VERTSIZE;
- double b = 1.0 * _HORZRES / _VERTRES;
-
- if(b < a)
- ret.cy = (DWORD)(1.0 * ret.cy * a / b);
- else if(a < b)
- ret.cx = (DWORD)(1.0 * ret.cx * b / a);
- }
-
- ::ReleaseDC(0, hDC);
- }
-
- return ret;
+ bool fKeepAspectRatio = AfxGetAppSettings().fKeepAspectRatio;
+ bool fCompMonDeskARDiff = AfxGetAppSettings().fCompMonDeskARDiff;
+
+ CSize ret(0,0);
+ if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly)
+ return ret;
+
+ CSize wh(0, 0), arxy(0, 0);
+
+ if (m_pMFVDC)
+ {
+ m_pMFVDC->GetNativeVideoSize(&wh, &arxy); // TODO : check AR !!
+ }
+ else if(m_pCAP)
+ {
+ wh = m_pCAP->GetVideoSize(false);
+ arxy = m_pCAP->GetVideoSize(fKeepAspectRatio);
+ }
+ else
+ {
+ pBV->GetVideoSize(&wh.cx, &wh.cy);
+
+ long arx = 0, ary = 0;
+ CComQIPtr<IBasicVideo2> pBV2 = pBV;
+ if(pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) // FIXME: It can hang here, for few seconds (CPU goes to 100%), after the window have been moving over to another screen, due to GetPreferredAspectRatio, if it happens before CAudioSwitcherFilter::DeliverEndFlush, it seems.
+ arxy.SetSize(arx, ary);
+ }
+
+ if(wh.cx <= 0 || wh.cy <= 0)
+ return ret;
+
+ // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
+ DVD_VideoAttributes VATR;
+ if(m_iPlaybackMode == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR)))
+ arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
+
+ CSize& ar = AfxGetAppSettings().AspectRatio;
+ if(ar.cx && ar.cy) arxy = ar;
+
+ ret = (!fKeepAspectRatio || arxy.cx <= 0 || arxy.cy <= 0)
+ ? wh
+ : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
+
+ if(fCompMonDeskARDiff)
+ if(HDC hDC = ::GetDC(0))
+ {
+ int _HORZSIZE = GetDeviceCaps(hDC, HORZSIZE);
+ int _VERTSIZE = GetDeviceCaps(hDC, VERTSIZE);
+ int _HORZRES = GetDeviceCaps(hDC, HORZRES);
+ int _VERTRES = GetDeviceCaps(hDC, VERTRES);
+
+ if(_HORZSIZE > 0 && _VERTSIZE > 0 && _HORZRES > 0 && _VERTRES > 0)
+ {
+ double a = 1.0*_HORZSIZE/_VERTSIZE;
+ double b = 1.0*_HORZRES/_VERTRES;
+
+ if(b < a)
+ ret.cy = (DWORD)(1.0*ret.cy * a / b);
+ else if(a < b)
+ ret.cx = (DWORD)(1.0*ret.cx * b / a);
+ }
+
+ ::ReleaseDC(0, hDC);
+ }
+
+ return ret;
}
void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasTo)
{
- AppSettings& s = AfxGetAppSettings();
- CRect r;
- DWORD dwRemove = 0, dwAdd = 0;
- DWORD dwRemoveEx = 0, dwAddEx = 0;
- HMENU hMenu;
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
-
- HMONITOR hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- HMONITOR hm_cur = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
-
- CMonitors monitors;
-
- if(!m_fFullScreen)
- {
- m_PlayListBarVisible = m_wndPlaylistBar.IsVisible();
- if((AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)) && (m_PlayListBarVisible)) ShowControlBar(&m_wndPlaylistBar, !m_PlayListBarVisible, TRUE);
-
- if(!m_fFirstFSAfterLaunchOnFS) GetWindowRect(&m_lastWindowRect);
- if(AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && fSwitchScreenResWhenHasTo && (m_iPlaybackMode != PM_NONE)) AutoChangeMonitorMode();
- m_LastWindow_HM = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
-
- CString str;
- CMonitor monitor;
- if(s.f_hmonitor == _T("Current"))
- {
- hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
- else
- {
- for(int i = 0; i < monitors.GetCount(); i++)
- {
- monitor = monitors.GetMonitor(i);
- monitor.GetName(str);
- if((monitor.IsMonitor()) && (s.f_hmonitor == str))
- {
- hm = monitor.operator HMONITOR();
- break;
- }
- }
- if(!hm) hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
-
- dwRemove = WS_CAPTION | WS_THICKFRAME;
- GetMonitorInfo(hm, &mi);
- if(fToNearest) r = mi.rcMonitor;
- else GetDesktopWindow()->GetWindowRect(&r);
- hMenu = NULL;
- }
- else
- {
- if(AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && AfxGetAppSettings().AutoChangeFullscrRes.bApplyDefault)
- SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenResOther, s.f_hmonitor);
-
- dwAdd = (AfxGetAppSettings().fHideCaptionMenu ? 0 : WS_CAPTION | WS_THICKFRAME);
- if(!m_fFirstFSAfterLaunchOnFS) r = m_lastWindowRect;
- hMenu = AfxGetAppSettings().fHideCaptionMenu ? NULL : m_hMenuDefault;
-
- if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)) ShowControlBar(&m_wndPlaylistBar, m_PlayListBarVisible, TRUE);
- }
-
- m_lastMouseMove.x = m_lastMouseMove.y = -1;
-
- bool fAudioOnly = m_fAudioOnly;
- m_fAudioOnly = true;
-
- m_fFullScreen = !m_fFullScreen;
- s.fLastFullScreen = m_fFullScreen;
-
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
-
- ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
- ModifyStyleEx(dwRemoveEx, dwAddEx, SWP_NOZORDER);
- ::SetMenu(m_hWnd, hMenu);
-
- // try disable shader when move from one monitor to other ...
- if(m_fFullScreen)
- {
- m_Change_Monitor = (hm != hm_cur) ? true : false;
- if((m_Change_Monitor) && (!m_bToggleShader))
- {
- if(m_pCAP)
- m_pCAP->SetPixelShader(NULL, NULL);
- }
- if((m_Change_Monitor) && (!m_bToggleShaderScreenSpace))
- {
- if(m_pCAP2)
- m_pCAP2->SetPixelShader2(NULL, NULL, 1);
- }
-
- }
- else
- {
- if((m_Change_Monitor) && (!m_bToggleShader))
- {
- if(m_pCAP) m_pCAP->SetPixelShader(NULL, NULL);
- }
- }
-
- if(m_fFullScreen)
- {
- m_fHideCursor = true;
+ AppSettings& s = AfxGetAppSettings();
+ CRect r;
+ DWORD dwRemove = 0, dwAdd = 0;
+ DWORD dwRemoveEx = 0, dwAddEx = 0;
+ HMENU hMenu;
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+
+ HMONITOR hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ HMONITOR hm_cur = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+
+ CMonitors monitors;
+
+ if(!m_fFullScreen)
+ {
+ m_PlayListBarVisible = m_wndPlaylistBar.IsVisible();
+ if((AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)) && (m_PlayListBarVisible)) ShowControlBar(&m_wndPlaylistBar, !m_PlayListBarVisible, TRUE);
+
+ if(!m_fFirstFSAfterLaunchOnFS) GetWindowRect(&m_lastWindowRect);
+ if(AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && fSwitchScreenResWhenHasTo && (m_iPlaybackMode != PM_NONE)) AutoChangeMonitorMode();
+ m_LastWindow_HM = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+
+ CString str;
+ CMonitor monitor;
+ if(s.f_hmonitor == _T("Current"))
+ {
+ hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ }
+ else
+ {
+ for ( int i = 0; i < monitors.GetCount(); i++ )
+ {
+ monitor = monitors.GetMonitor( i );
+ monitor.GetName(str);
+ if((monitor.IsMonitor()) && (s.f_hmonitor == str))
+ {
+ hm = monitor.operator HMONITOR();
+ break;
+ }
+ }
+ if(!hm) hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ }
+
+ dwRemove = WS_CAPTION|WS_THICKFRAME;
+ GetMonitorInfo(hm, &mi);
+ if(fToNearest) r = mi.rcMonitor;
+ else GetDesktopWindow()->GetWindowRect(&r);
+ hMenu = NULL;
+ }
+ else
+ {
+ if(AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && AfxGetAppSettings().AutoChangeFullscrRes.bApplyDefault)
+ SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenResOther, s.f_hmonitor);
+
+ dwAdd = (AfxGetAppSettings().fHideCaptionMenu ? 0 : WS_CAPTION | WS_THICKFRAME);
+ if (!m_fFirstFSAfterLaunchOnFS) r = m_lastWindowRect;
+ hMenu = AfxGetAppSettings().fHideCaptionMenu ? NULL : m_hMenuDefault;
+
+ if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)) ShowControlBar(&m_wndPlaylistBar, m_PlayListBarVisible, TRUE);
+ }
+
+ m_lastMouseMove.x = m_lastMouseMove.y = -1;
+
+ bool fAudioOnly = m_fAudioOnly;
+ m_fAudioOnly = true;
+
+ m_fFullScreen = !m_fFullScreen;
+ s.fLastFullScreen = m_fFullScreen;
+
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+
+ ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
+ ModifyStyleEx(dwRemoveEx, dwAddEx, SWP_NOZORDER);
+ ::SetMenu(m_hWnd, hMenu);
+
+ // try disable shader when move from one monitor to other ...
+ if(m_fFullScreen)
+ {
+ m_Change_Monitor = (hm != hm_cur) ? true : false;
+ if((m_Change_Monitor) && (!m_bToggleShader))
+ {
+ if (m_pCAP)
+ m_pCAP->SetPixelShader(NULL, NULL);
+ }
+ if((m_Change_Monitor) && (!m_bToggleShaderScreenSpace))
+ {
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, 1);
+ }
+
+ }
+ else
+ {
+ if((m_Change_Monitor) && (!m_bToggleShader))
+ {
+ if (m_pCAP) m_pCAP->SetPixelShader(NULL, NULL);
+ }
+ }
+
+ if(m_fFullScreen)
+ {
+ m_fHideCursor = true;
ShowControls(CS_NONE, false);
- if(s.m_fPreventMinimize)
- {
- if(hm != hm_cur) ModifyStyle(WS_MINIMIZEBOX, 0, SWP_NOZORDER);
- }
- }
- else
- {
- ModifyStyle(0, WS_MINIMIZEBOX, SWP_NOZORDER);
- KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- m_fHideCursor = false;
+ if(s.m_fPreventMinimize)
+ {
+ if(hm != hm_cur) ModifyStyle(WS_MINIMIZEBOX, 0, SWP_NOZORDER);
+ }
+ }
+ else
+ {
+ ModifyStyle(0, WS_MINIMIZEBOX, SWP_NOZORDER);
+ KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ m_fHideCursor = false;
ShowControls(AfxGetAppSettings().nCS);
- }
-
- m_fAudioOnly = fAudioOnly;
-
- if(m_fFirstFSAfterLaunchOnFS) //Play started in Fullscreen
- {
- if(m_LastWindow_HM != hm_cur)
- {
- GetMonitorInfo(m_LastWindow_HM, &mi);
- r = mi.rcMonitor;
- ShowWindow(SW_HIDE);
- SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER | SWP_NOSENDCHANGING);
- }
- ZoomVideoWindow();
- if(m_LastWindow_HM != hm_cur) ShowWindow(SW_SHOW);
- m_fFirstFSAfterLaunchOnFS = false;
- }
- else
- {
- SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER | SWP_NOSENDCHANGING);
- }
-
- MoveVideoWindow();
-
- if((m_Change_Monitor) && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) // Enabled shader ...
- {
- SetShaders();
- }
-}
-
+ }
+
+ m_fAudioOnly = fAudioOnly;
+
+ if (m_fFirstFSAfterLaunchOnFS) //Play started in Fullscreen
+ {
+ if(m_LastWindow_HM != hm_cur)
+ {
+ GetMonitorInfo(m_LastWindow_HM, &mi);
+ r = mi.rcMonitor;
+ ShowWindow(SW_HIDE);
+ SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER|SWP_NOSENDCHANGING);
+ }
+ ZoomVideoWindow();
+ if(m_LastWindow_HM != hm_cur) ShowWindow(SW_SHOW);
+ m_fFirstFSAfterLaunchOnFS = false;
+ }
+ else
+ {
+ SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER|SWP_NOSENDCHANGING);
+ }
+
+ MoveVideoWindow();
+
+ if((m_Change_Monitor) && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) // Enabled shader ...
+ {
+ SetShaders();
+ }
+}
+
void CMainFrame::AutoChangeMonitorMode()
{
- CStringW mf_hmonitor = AfxGetAppSettings().f_hmonitor;
- double MediaFPS;
-
- if(m_iPlaybackMode == PM_FILE)
- {
- LONGLONG m_rtTimePerFrame = 1;
- // if ExtractAvgTimePerFrame isn't executed then MediaFPS=10000000.0,
- // (int)(MediaFPS + 0.5)=10000000 and SetDispMode is executed to Default.
- BeginEnumFilters(pGB, pEF, pBF)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- CMediaTypeEx mt;
- PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
- || FAILED(pPin->ConnectionMediaType(&mt))) continue;
- ExtractAvgTimePerFrame(&mt, m_rtTimePerFrame);
- if(m_rtTimePerFrame == 0) m_rtTimePerFrame = 1;
- }
- EndEnumPins
- }
- EndEnumFilters
- MediaFPS = 10000000.0 / m_rtTimePerFrame;
- }
-
- if(m_iPlaybackMode == PM_DVD)
- {
- DVD_PLAYBACK_LOCATION2 Location;
- if(pDVDI->GetCurrentLocation(&Location) == S_OK)
- {
- MediaFPS = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
- : 25.0;
- }
- }
-
- if((MediaFPS > 23.971) && (MediaFPS < 23.981) && CMPlayerCApp::IsVistaOrAbove())
- {
- SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes23d976Hz, mf_hmonitor);
- return;
- }
- if((MediaFPS > 29.965) && (MediaFPS < 29.975) && CMPlayerCApp::IsVistaOrAbove())
- {
- SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes29d97Hz, mf_hmonitor);
- return;
- }
-
- switch((int)(MediaFPS + 0.5))
- {
- case 24 :
- SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes24Hz, mf_hmonitor);
- break;
- case 25 :
- SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes25Hz, mf_hmonitor);
- break;
- case 30 :
- SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes30Hz, mf_hmonitor);
- break;
- default:
- SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenResOther, mf_hmonitor);
- }
+ CStringW mf_hmonitor = AfxGetAppSettings().f_hmonitor;
+ double MediaFPS;
+
+ if (m_iPlaybackMode == PM_FILE)
+ {
+ LONGLONG m_rtTimePerFrame = 1;
+ // if ExtractAvgTimePerFrame isn't executed then MediaFPS=10000000.0,
+ // (int)(MediaFPS + 0.5)=10000000 and SetDispMode is executed to Default.
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ CMediaTypeEx mt;
+ PIN_DIRECTION dir;
+ if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
+ || FAILED(pPin->ConnectionMediaType(&mt))) continue;
+ ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
+ if (m_rtTimePerFrame == 0) m_rtTimePerFrame=1;
+ }
+ EndEnumPins
+ }
+ EndEnumFilters
+ MediaFPS = 10000000.0 / m_rtTimePerFrame;
+ }
+
+ if (m_iPlaybackMode == PM_DVD)
+ {
+ DVD_PLAYBACK_LOCATION2 Location;
+ if (pDVDI->GetCurrentLocation(&Location) == S_OK)
+ {
+ MediaFPS = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
+ : 25.0;
+ }
+ }
+
+ if ((MediaFPS > 23.971) && (MediaFPS < 23.981) && CMPlayerCApp::IsVistaOrAbove())
+ {
+ SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes23d976Hz, mf_hmonitor);
+ return;
+ }
+ if ((MediaFPS > 29.965) && (MediaFPS < 29.975) && CMPlayerCApp::IsVistaOrAbove())
+ {
+ SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes29d97Hz, mf_hmonitor);
+ return;
+ }
+
+ switch ((int)(MediaFPS + 0.5))
+ {
+ case 24 :
+ SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes24Hz, mf_hmonitor);
+ break;
+ case 25 :
+ SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes25Hz, mf_hmonitor);
+ break;
+ case 30 :
+ SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenRes30Hz, mf_hmonitor);
+ break;
+ default:
+ SetDispMode(AfxGetAppSettings().AutoChangeFullscrRes.dmFullscreenResOther, mf_hmonitor);
+ }
}
void CMainFrame::MoveVideoWindow(bool fShowStats)
{
- if(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && IsWindowVisible())
- {
- CRect wr;
- if(m_pFullscreenWnd->IsWindow())
- m_pFullscreenWnd->GetClientRect(&wr);
- else if(!m_fFullScreen)
- {
- m_wndView.GetClientRect(&wr);
- //if ( !AfxGetAppSettings().fHideCaptionMenu )
- // wr.DeflateRect(2, 2);
- }
- else
- {
- GetWindowRect(&wr);
-
- // it's code need for work in fullscreen on secondary monitor;
- CRect r;
- m_wndView.GetWindowRect(&r);
- wr -= r.TopLeft();
- }
-
- CRect vr = CRect(0, 0, 0, 0);
-
- OAFilterState fs = GetMediaState();
- if(fs == State_Paused || fs == State_Running || fs == State_Stopped && (m_fShockwaveGraph || m_fQuicktimeGraph))
- {
- CSize arxy = GetVideoSize();
-
- int iDefaultVideoSize = AfxGetAppSettings().iDefaultVideoSize;
-
- CSize ws =
- iDefaultVideoSize == DVS_HALF ? CSize(arxy.cx / 2, arxy.cy / 2) :
- iDefaultVideoSize == DVS_NORMAL ? arxy :
- iDefaultVideoSize == DVS_DOUBLE ? CSize(arxy.cx * 2, arxy.cy * 2) :
- wr.Size();
-
- int w = ws.cx;
- int h = ws.cy;
-
- if(!m_fShockwaveGraph) //&& !m_fQuicktimeGraph)
- {
- if(iDefaultVideoSize == DVS_FROMINSIDE || iDefaultVideoSize == DVS_FROMOUTSIDE)
- {
- h = ws.cy;
- w = MulDiv(h, arxy.cx, arxy.cy);
-
- if(iDefaultVideoSize == DVS_FROMINSIDE && w > ws.cx
- || iDefaultVideoSize == DVS_FROMOUTSIDE && w < ws.cx)
- {
- w = ws.cx;
- h = MulDiv(w, arxy.cy, arxy.cx);
- }
- }
- }
-
- CSize size(
- (int)(m_ZoomX * w),
- (int)(m_ZoomY * h));
-
- CPoint pos(
- (int)(m_PosX*(wr.Width() * 3 - m_ZoomX * w) - wr.Width()),
- (int)(m_PosY*(wr.Height() * 3 - m_ZoomY * h) - wr.Height()));
-
- /* CPoint pos(
- (int)(m_PosX*(wr.Width() - size.cx)),
- (int)(m_PosY*(wr.Height() - size.cy)));
-
- */
- vr = CRect(pos, size);
- }
-
- // What does this do exactly ?
- // Add comments when you add this kind of code !
- //wr |= CRect(0,0,0,0);
- //vr |= CRect(0,0,0,0);
-
- if(m_pCAP)
- {
- m_pCAP->SetPosition(wr, vr);
- m_pCAP->SetVideoAngle(Vector(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ)));
- }
- else
- {
- HRESULT hr;
- hr = pBV->SetDefaultSourcePosition();
- hr = pBV->SetDestinationPosition(vr.left, vr.top, vr.Width(), vr.Height());
- hr = pVW->SetWindowPosition(wr.left, wr.top, wr.Width(), wr.Height());
-
- if(m_pMFVDC) m_pMFVDC->SetVideoPosition(NULL, wr);
- }
+ if(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && IsWindowVisible())
+ {
+ CRect wr;
+ if (m_pFullscreenWnd->IsWindow())
+ m_pFullscreenWnd->GetClientRect(&wr);
+ else if(!m_fFullScreen)
+ {
+ m_wndView.GetClientRect(&wr);
+ //if ( !AfxGetAppSettings().fHideCaptionMenu )
+ // wr.DeflateRect(2, 2);
+ }
+ else
+ {
+ GetWindowRect(&wr);
+
+ // it's code need for work in fullscreen on secondary monitor;
+ CRect r;
+ m_wndView.GetWindowRect(&r);
+ wr -= r.TopLeft();
+ }
+
+ CRect vr = CRect(0,0,0,0);
+
+ OAFilterState fs = GetMediaState();
+ if(fs == State_Paused || fs == State_Running || fs == State_Stopped && (m_fShockwaveGraph || m_fQuicktimeGraph))
+ {
+ CSize arxy = GetVideoSize();
+
+ int iDefaultVideoSize = AfxGetAppSettings().iDefaultVideoSize;
+
+ CSize ws =
+ iDefaultVideoSize == DVS_HALF ? CSize(arxy.cx/2, arxy.cy/2) :
+ iDefaultVideoSize == DVS_NORMAL ? arxy :
+ iDefaultVideoSize == DVS_DOUBLE ? CSize(arxy.cx*2, arxy.cy*2) :
+ wr.Size();
+
+ int w = ws.cx;
+ int h = ws.cy;
+
+ if(!m_fShockwaveGraph) //&& !m_fQuicktimeGraph)
+ {
+ if(iDefaultVideoSize == DVS_FROMINSIDE || iDefaultVideoSize == DVS_FROMOUTSIDE)
+ {
+ h = ws.cy;
+ w = MulDiv(h, arxy.cx, arxy.cy);
+
+ if(iDefaultVideoSize == DVS_FROMINSIDE && w > ws.cx
+ || iDefaultVideoSize == DVS_FROMOUTSIDE && w < ws.cx)
+ {
+ w = ws.cx;
+ h = MulDiv(w, arxy.cy, arxy.cx);
+ }
+ }
+ }
+
+ CSize size(
+ (int)(m_ZoomX*w),
+ (int)(m_ZoomY*h));
+
+ CPoint pos(
+ (int)(m_PosX*(wr.Width()*3 - m_ZoomX*w) - wr.Width()),
+ (int)(m_PosY*(wr.Height()*3 - m_ZoomY*h) - wr.Height()));
+
+/* CPoint pos(
+ (int)(m_PosX*(wr.Width() - size.cx)),
+ (int)(m_PosY*(wr.Height() - size.cy)));
- m_wndView.SetVideoRect(wr);
-
- if(fShowStats && vr.Height() > 0)
- {
- CString info;
- info.Format(_T("Pos %.2f %.2f, Zoom %.2f %.2f, AR %.2f"), m_PosX, m_PosY, m_ZoomX, m_ZoomY, (float)vr.Width() / vr.Height());
- SendStatusMessage(info, 3000);
- }
- }
- else
- {
- m_wndView.SetVideoRect();
- }
-
- UpdateThumbnailClip();
+*/
+ vr = CRect(pos, size);
+ }
+
+ // What does this do exactly ?
+ // Add comments when you add this kind of code !
+ //wr |= CRect(0,0,0,0);
+ //vr |= CRect(0,0,0,0);
+
+ if(m_pCAP)
+ {
+ m_pCAP->SetPosition(wr, vr);
+ m_pCAP->SetVideoAngle(Vector(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ)));
+ }
+ else
+ {
+ HRESULT hr;
+ hr = pBV->SetDefaultSourcePosition();
+ hr = pBV->SetDestinationPosition(vr.left, vr.top, vr.Width(), vr.Height());
+ hr = pVW->SetWindowPosition(wr.left, wr.top, wr.Width(), wr.Height());
+
+ if (m_pMFVDC) m_pMFVDC->SetVideoPosition (NULL, wr);
+ }
+
+ m_wndView.SetVideoRect(wr);
+
+ if(fShowStats && vr.Height() > 0)
+ {
+ CString info;
+ info.Format(_T("Pos %.2f %.2f, Zoom %.2f %.2f, AR %.2f"), m_PosX, m_PosY, m_ZoomX, m_ZoomY, (float)vr.Width()/vr.Height());
+ SendStatusMessage(info, 3000);
+ }
+ }
+ else
+ {
+ m_wndView.SetVideoRect();
+ }
+
+ UpdateThumbnailClip();
}
void CMainFrame::ZoomVideoWindow(double scale)
{
- if(m_iMediaLoadState != MLS_LOADED)
- return;
-
- AppSettings& s = AfxGetAppSettings();
-
- if(scale <= 0)
- {
- scale =
- s.iZoomLevel == 0 ? 0.5 :
- s.iZoomLevel == 1 ? 1.0 :
- s.iZoomLevel == 2 ? 2.0 :
- s.iZoomLevel == 3 ? GetZoomAutoFitScale() :
- 1.0;
- }
-
- if(m_fFullScreen)
- {
- OnViewFullscreen();
- }
-
- MINMAXINFO mmi;
- OnGetMinMaxInfo(&mmi);
-
- CRect r;
- int w = 0, h = 0;
-
- if(!m_fAudioOnly)
- {
- CSize arxy = GetVideoSize();
-
- long lWidth = int(arxy.cx * scale + 0.5);
- long lHeight = int(arxy.cy * scale + 0.5);
-
- DWORD style = GetStyle();
-
- CRect r1, r2;
- GetClientRect(&r1);
- m_wndView.GetClientRect(&r2);
-
- w = ((style & WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME) * 2 : 0)
- + r1.Width() - r2.Width()
- + lWidth;
-
- // This doesn't give correct menu pixel size
- //MENUBARINFO mbi;
- //memset(&mbi, 0, sizeof(mbi));
- //mbi.cbSize = sizeof(mbi);
- //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- h = ((style & WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME) * 2 : 0)
- //+ (mbi.rcBar.bottom - mbi.rcBar.top)
- + r1.Height() - r2.Height()
- + lHeight;
-
- if(style & WS_CAPTION)
- {
- h += GetSystemMetrics(SM_CYCAPTION);
- // If we have a caption then we have a menu bar
- h += GetSystemMetrics(SM_CYMENU);
- // Do not use magic values please !
- //w += 2; h += 2; // for the 1 pixel wide sunken frame
- //w += 2; h += 3; // for the inner black border
- }
-
- GetWindowRect(r);
-
- w = max(w, mmi.ptMinTrackSize.x);
- h = max(h, mmi.ptMinTrackSize.y);
- }
- else
- {
- GetWindowRect(r);
-
- w = r.Width(); // mmi.ptMinTrackSize.x;
- h = mmi.ptMinTrackSize.y;
- }
-
- //Prevention of going beyond the scopes of screen
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
- w = min(w, (mi.rcWork.right - mi.rcWork.left));
- h = min(h, (mi.rcWork.bottom - mi.rcWork.top));
-
- // center window
- if(!s.fRememberWindowPos)
- {
- CPoint cp = r.CenterPoint();
- r.left = cp.x - w / 2;
- r.top = cp.y - h / 2;
- }
-
- r.right = r.left + w;
- r.bottom = r.top + h;
-
- /*
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
- */
- if(r.right > mi.rcWork.right) r.OffsetRect(mi.rcWork.right - r.right, 0);
- if(r.left < mi.rcWork.left) r.OffsetRect(mi.rcWork.left - r.left, 0);
- if(r.bottom > mi.rcWork.bottom) r.OffsetRect(0, mi.rcWork.bottom - r.bottom);
- if(r.top < mi.rcWork.top) r.OffsetRect(0, mi.rcWork.top - r.top);
-
- if((m_fFullScreen || !s.HasFixedWindowSize()) && !m_pFullscreenWnd->IsWindow())
- {
- MoveWindow(r);
- }
+ if(m_iMediaLoadState != MLS_LOADED)
+ return;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if(scale <= 0)
+ {
+ scale =
+ s.iZoomLevel == 0 ? 0.5 :
+ s.iZoomLevel == 1 ? 1.0 :
+ s.iZoomLevel == 2 ? 2.0 :
+ s.iZoomLevel == 3 ? GetZoomAutoFitScale() :
+ 1.0;
+ }
+
+ if(m_fFullScreen)
+ {
+ OnViewFullscreen();
+ }
+
+ MINMAXINFO mmi;
+ OnGetMinMaxInfo(&mmi);
+
+ CRect r;
+ int w = 0, h = 0;
+
+ if(!m_fAudioOnly)
+ {
+ CSize arxy = GetVideoSize();
+
+ long lWidth = int(arxy.cx * scale + 0.5);
+ long lHeight = int(arxy.cy * scale + 0.5);
+
+ DWORD style = GetStyle();
+
+ CRect r1, r2;
+ GetClientRect(&r1);
+ m_wndView.GetClientRect(&r2);
+
+ w = ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME)*2 : 0)
+ + r1.Width() - r2.Width()
+ + lWidth;
+
+ // This doesn't give correct menu pixel size
+ //MENUBARINFO mbi;
+ //memset(&mbi, 0, sizeof(mbi));
+ //mbi.cbSize = sizeof(mbi);
+ //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+
+ h = ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
+ //+ (mbi.rcBar.bottom - mbi.rcBar.top)
+ + r1.Height() - r2.Height()
+ + lHeight;
+
+ if ( style & WS_CAPTION )
+ {
+ h += GetSystemMetrics( SM_CYCAPTION );
+ // If we have a caption then we have a menu bar
+ h += GetSystemMetrics( SM_CYMENU );
+ // Do not use magic values please !
+ //w += 2; h += 2; // for the 1 pixel wide sunken frame
+ //w += 2; h += 3; // for the inner black border
+ }
+
+ GetWindowRect(r);
+
+ w = max(w, mmi.ptMinTrackSize.x);
+ h = max(h, mmi.ptMinTrackSize.y);
+ }
+ else
+ {
+ GetWindowRect(r);
+
+ w = r.Width(); // mmi.ptMinTrackSize.x;
+ h = mmi.ptMinTrackSize.y;
+ }
+
+ //Prevention of going beyond the scopes of screen
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
+ w = min(w, (mi.rcWork.right - mi.rcWork.left));
+ h = min(h, (mi.rcWork.bottom - mi.rcWork.top));
+
+ // center window
+ if(!s.fRememberWindowPos)
+ {
+ CPoint cp = r.CenterPoint();
+ r.left = cp.x - w/2;
+ r.top = cp.y - h/2;
+ }
+
+ r.right = r.left + w;
+ r.bottom = r.top + h;
+
+ /*
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
+ */
+ if(r.right > mi.rcWork.right) r.OffsetRect(mi.rcWork.right-r.right, 0);
+ if(r.left < mi.rcWork.left) r.OffsetRect(mi.rcWork.left-r.left, 0);
+ if(r.bottom > mi.rcWork.bottom) r.OffsetRect(0, mi.rcWork.bottom-r.bottom);
+ if(r.top < mi.rcWork.top) r.OffsetRect(0, mi.rcWork.top-r.top);
+
+ if((m_fFullScreen || !s.HasFixedWindowSize()) && !m_pFullscreenWnd->IsWindow())
+ {
+ MoveWindow(r);
+ }
// ShowWindow(SW_SHOWNORMAL);
- MoveVideoWindow();
+ MoveVideoWindow();
}
double CMainFrame::GetZoomAutoFitScale()
{
- if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly)
- return 1.0;
+ if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly)
+ return 1.0;
- CSize arxy = GetVideoSize();
+ CSize arxy = GetVideoSize();
- double sx = 2.0 / 3 * m_rcDesktop.Width() / arxy.cx;
- double sy = 2.0 / 3 * m_rcDesktop.Height() / arxy.cy;
+ double sx = 2.0/3 * m_rcDesktop.Width() / arxy.cx;
+ double sy = 2.0/3 * m_rcDesktop.Height() / arxy.cy;
- return sx < sy ? sx : sy;
+ return sx < sy ? sx : sy;
}
void CMainFrame::RepaintVideo()
{
- if(m_pCAP)
- m_pCAP->Paint(false);
+ if(m_pCAP)
+ m_pCAP->Paint(false);
}
void CMainFrame::SetShaders()
{
- if(!m_pCAP) return;
-
- AppSettings& s = AfxGetAppSettings();
-
- CAtlStringMap<const AppSettings::Shader*> s2s;
-
- POSITION pos = s.m_shaders.GetHeadPosition();
- while(pos)
- {
- const AppSettings::Shader* pShader = &s.m_shaders.GetNext(pos);
- s2s[pShader->label] = pShader;
- }
-
- m_pCAP->SetPixelShader(NULL, NULL);
- if(m_pCAP2)
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
-
- for(int i = 0; i < 2; ++i)
- {
- if(i == 0 && m_bToggleShader)
- continue;
- if(i == 1 && m_bToggleShaderScreenSpace)
- continue;
- CAtlList<CString> labels;
-
- CAtlList<CString> *pLabels;
- if(i == 0)
- pLabels = &m_shaderlabels;
- else
- {
- if(!m_pCAP2)
- break;
- pLabels = &m_shaderlabelsScreenSpace;
- }
-
- pos = pLabels->GetHeadPosition();
- while(pos)
- {
- const AppSettings::Shader* pShader = NULL;
- if(s2s.Lookup(pLabels->GetNext(pos), pShader))
- {
- CStringA target = pShader->target;
- CStringA srcdata = pShader->srcdata;
-
- HRESULT hr;
- if(i == 0)
- hr = m_pCAP->SetPixelShader(srcdata, target);
- else
- hr = m_pCAP2->SetPixelShader2(srcdata, target, true);
-
- if(FAILED(hr))
- {
- m_pCAP->SetPixelShader(NULL, NULL);
- if(m_pCAP2)
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
- SendStatusMessage(ResStr(IDS_MAINFRM_73) + pShader->label, 3000);
- return;
- }
-
- labels.AddTail(pShader->label);
- }
- }
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- CString str = Implode(labels, '|');
- str.Replace(_T("|"), _T(", "));
- SendStatusMessage(ResStr(IDS_AG_SHADER) + str, 3000);
- }
- }
+ if(!m_pCAP) return;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CAtlStringMap<const AppSettings::Shader*> s2s;
+
+ POSITION pos = s.m_shaders.GetHeadPosition();
+ while(pos)
+ {
+ const AppSettings::Shader* pShader = &s.m_shaders.GetNext(pos);
+ s2s[pShader->label] = pShader;
+ }
+
+ m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+
+ for (int i = 0; i < 2; ++i)
+ {
+ if (i == 0 && m_bToggleShader)
+ continue;
+ if (i == 1 && m_bToggleShaderScreenSpace)
+ continue;
+ CAtlList<CString> labels;
+
+ CAtlList<CString> *pLabels;
+ if (i == 0)
+ pLabels = &m_shaderlabels;
+ else
+ {
+ if (!m_pCAP2)
+ break;
+ pLabels = &m_shaderlabelsScreenSpace;
+ }
+
+ pos = pLabels->GetHeadPosition();
+ while(pos)
+ {
+ const AppSettings::Shader* pShader = NULL;
+ if(s2s.Lookup(pLabels->GetNext(pos), pShader))
+ {
+ CStringA target = pShader->target;
+ CStringA srcdata = pShader->srcdata;
+
+ HRESULT hr;
+ if (i == 0)
+ hr = m_pCAP->SetPixelShader(srcdata, target);
+ else
+ hr = m_pCAP2->SetPixelShader2(srcdata, target, true);
+
+ if(FAILED(hr))
+ {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ SendStatusMessage(ResStr(IDS_MAINFRM_73) + pShader->label, 3000);
+ return;
+ }
+
+ labels.AddTail(pShader->label);
+ }
+ }
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ CString str = Implode(labels, '|');
+ str.Replace(_T("|"), _T(", "));
+ SendStatusMessage(ResStr(IDS_AG_SHADER) + str, 3000);
+ }
+ }
}
void CMainFrame::UpdateShaders(CString label)
{
- if(!m_pCAP) return;
+ if(!m_pCAP) return;
- if(m_shaderlabels.GetCount() <= 1)
- m_shaderlabels.RemoveAll();
+ if(m_shaderlabels.GetCount() <= 1)
+ m_shaderlabels.RemoveAll();
- if(m_shaderlabels.IsEmpty() && !label.IsEmpty())
- m_shaderlabels.AddTail(label);
+ if(m_shaderlabels.IsEmpty() && !label.IsEmpty())
+ m_shaderlabels.AddTail(label);
- bool fUpdate = m_shaderlabels.IsEmpty();
+ bool fUpdate = m_shaderlabels.IsEmpty();
- POSITION pos = m_shaderlabels.GetHeadPosition();
- while(pos)
- {
- if(label == m_shaderlabels.GetNext(pos))
- {
- fUpdate = true;
- break;
- }
- }
+ POSITION pos = m_shaderlabels.GetHeadPosition();
+ while(pos)
+ {
+ if(label == m_shaderlabels.GetNext(pos))
+ {
+ fUpdate = true;
+ break;
+ }
+ }
- if(fUpdate) SetShaders();
+ if(fUpdate) SetShaders();
}
void CMainFrame::SetBalance(int balance)
{
- AfxGetAppSettings().nBalance = balance;
+ AfxGetAppSettings().nBalance = balance;
- int sign = balance > 0 ? -1 : 1;
- balance = max(100 - abs(balance), 1);
- balance = (int)((log10(1.0 * balance) - 2) * 5000 * sign);
- balance = max(min(balance, 10000), -10000);
+ int sign = balance>0?-1:1;
+ balance = max(100-abs(balance), 1);
+ balance = (int)((log10(1.0*balance)-2)*5000*sign);
+ balance = max(min(balance, 10000), -10000);
- if(m_iMediaLoadState == MLS_LOADED)
- pBA->put_Balance(balance);
+ if(m_iMediaLoadState == MLS_LOADED)
+ pBA->put_Balance(balance);
}
void CMainFrame::SetupIViAudReg()
{
- if(!AfxGetAppSettings().fAutoSpeakerConf) return;
-
- DWORD spc = 0, defchnum = 0;
-
- if(AfxGetAppSettings().fAutoSpeakerConf)
- {
- CComPtr<IDirectSound> pDS;
- if(SUCCEEDED(DirectSoundCreate(NULL, &pDS, NULL))
- && SUCCEEDED(pDS->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL)))
- {
- if(SUCCEEDED(pDS->GetSpeakerConfig(&spc)))
- {
- switch(spc)
- {
- case DSSPEAKER_DIRECTOUT:
- defchnum = 6;
- break;
- case DSSPEAKER_HEADPHONE:
- defchnum = 2;
- break;
- case DSSPEAKER_MONO:
- defchnum = 1;
- break;
- case DSSPEAKER_QUAD:
- defchnum = 4;
- break;
- default:
- case DSSPEAKER_STEREO:
- defchnum = 2;
- break;
- case DSSPEAKER_SURROUND:
- defchnum = 2;
- break;
- case DSSPEAKER_5POINT1:
- defchnum = 5;
- break;
- case DSSPEAKER_7POINT1:
- defchnum = 5;
- break;
- }
- }
- }
- }
- else
- {
- defchnum = 2;
- }
-
- CRegKey iviaud;
- if(ERROR_SUCCESS == iviaud.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\InterVideo\\Common\\AudioDec")))
- {
- DWORD chnum = 0;
- if(FAILED(iviaud.QueryDWORDValue(_T("AUDIO"), chnum))) chnum = 0;
- if(chnum <= defchnum) // check if the user has already set it..., but we won't skip if it's lower than sensible :P
- iviaud.SetDWORDValue(_T("AUDIO"), defchnum);
- }
+ if(!AfxGetAppSettings().fAutoSpeakerConf) return;
+
+ DWORD spc = 0, defchnum = 0;
+
+ if(AfxGetAppSettings().fAutoSpeakerConf)
+ {
+ CComPtr<IDirectSound> pDS;
+ if(SUCCEEDED(DirectSoundCreate(NULL, &pDS, NULL))
+ && SUCCEEDED(pDS->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL)))
+ {
+ if(SUCCEEDED(pDS->GetSpeakerConfig(&spc)))
+ {
+ switch(spc)
+ {
+ case DSSPEAKER_DIRECTOUT: defchnum = 6; break;
+ case DSSPEAKER_HEADPHONE: defchnum = 2; break;
+ case DSSPEAKER_MONO: defchnum = 1; break;
+ case DSSPEAKER_QUAD: defchnum = 4; break;
+ default:
+ case DSSPEAKER_STEREO: defchnum = 2; break;
+ case DSSPEAKER_SURROUND: defchnum = 2; break;
+ case DSSPEAKER_5POINT1: defchnum = 5; break;
+ case DSSPEAKER_7POINT1: defchnum = 5; break;
+ }
+ }
+ }
+ }
+ else
+ {
+ defchnum = 2;
+ }
+
+ CRegKey iviaud;
+ if(ERROR_SUCCESS == iviaud.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\InterVideo\\Common\\AudioDec")))
+ {
+ DWORD chnum = 0;
+ if(FAILED(iviaud.QueryDWORDValue(_T("AUDIO"), chnum))) chnum = 0;
+ if(chnum <= defchnum) // check if the user has already set it..., but we won't skip if it's lower than sensible :P
+ iviaud.SetDWORDValue(_T("AUDIO"), defchnum);
+ }
}
//
@@ -9245,852 +8934,825 @@ void CMainFrame::SetupIViAudReg()
bool CMainFrame::IsRealEngineCompatible(CString strFilename)
{
- // Real Media engine didn't support Unicode filename (nor filenames with # characters)
- for(int i = 0; i < strFilename.GetLength(); i++)
- {
- WCHAR Char = strFilename[i];
- if(Char < 32 || Char > 126 || Char == 35)
- return false;
- }
- return true;
+ // Real Media engine didn't support Unicode filename (nor filenames with # characters)
+ for(int i=0; i<strFilename.GetLength(); i++)
+ {
+ WCHAR Char = strFilename[i];
+ if (Char<32 || Char>126 || Char==35)
+ return false;
+ }
+ return true;
}
void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD)
{
- ASSERT(pGB == NULL);
-
- m_fCustomGraph = false;
- m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
-
- AppSettings& s = AfxGetAppSettings();
-
- // CASIMIR666 todo
- if(s.IsD3DFullscreen() && ((s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) || (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) || (s.iDSVideoRendererType == VIDRNDT_DS_SYNC)))
- {
- CreateFullScreenWindow();
- m_pVideoWnd = m_pFullscreenWnd;
- }
- else
- {
- m_pVideoWnd = &m_wndView;
- }
-
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD))
- {
- engine_t engine = s.Formats.GetEngine(p->fns.GetHead());
-
- CStringA ct = GetContentType(p->fns.GetHead());
-
- if(ct == "video/x-ms-asf")
- {
- // TODO: put something here to make the windows media source filter load later
- }
- else if(ct == "audio/x-pn-realaudio"
- || ct == "audio/x-pn-realaudio-plugin"
- || ct == "audio/x-realaudio-secure"
- || ct == "video/vnd.rn-realvideo-secure"
- || ct == "application/vnd.rn-realmedia"
- || ct.Find("vnd.rn-") >= 0
- || ct.Find("realaudio") >= 0
- || ct.Find("realvideo") >= 0)
- {
- engine = RealMedia;
- }
- else if(ct == "application/x-shockwave-flash")
- {
- engine = ShockWave;
- }
- else if(ct == "video/quicktime"
- || ct == "application/x-quicktimeplayer")
- {
- engine = QuickTime;
- }
-
- HRESULT hr;
- CComPtr<IUnknown> pUnk;
-
- if(engine == RealMedia)
- {
- // TODO : see why Real SDK crash here ...
- //if (!IsRealEngineCompatible(p->fns.GetHead()))
- // throw ResStr(IDS_REALVIDEO_INCOMPATIBLE);
-
- if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CRealMediaGraph(m_pVideoWnd->m_hWnd, hr)))
- throw ResStr(IDS_AG_OUT_OF_MEMORY);
-
- if(SUCCEEDED(hr) && !!(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
- m_fRealMediaGraph = true;
- }
- else if(engine == ShockWave)
- {
+ ASSERT(pGB == NULL);
+
+ m_fCustomGraph = false;
+ m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ // CASIMIR666 todo
+ if (s.IsD3DFullscreen() && ((s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) || (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) || (s.iDSVideoRendererType == VIDRNDT_DS_SYNC)))
+ {
+ CreateFullScreenWindow();
+ m_pVideoWnd = m_pFullscreenWnd;
+ }
+ else
+ {
+ m_pVideoWnd = &m_wndView;
+ }
+
+ if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD))
+ {
+ engine_t engine = s.Formats.GetEngine(p->fns.GetHead());
+
+ CStringA ct = GetContentType(p->fns.GetHead());
+
+ if(ct == "video/x-ms-asf")
+ {
+ // TODO: put something here to make the windows media source filter load later
+ }
+ else if(ct == "audio/x-pn-realaudio"
+ || ct == "audio/x-pn-realaudio-plugin"
+ || ct == "audio/x-realaudio-secure"
+ || ct == "video/vnd.rn-realvideo-secure"
+ || ct == "application/vnd.rn-realmedia"
+ || ct.Find("vnd.rn-") >= 0
+ || ct.Find("realaudio") >= 0
+ || ct.Find("realvideo") >= 0)
+ {
+ engine = RealMedia;
+ }
+ else if(ct == "application/x-shockwave-flash")
+ {
+ engine = ShockWave;
+ }
+ else if(ct == "video/quicktime"
+ || ct == "application/x-quicktimeplayer")
+ {
+ engine = QuickTime;
+ }
+
+ HRESULT hr;
+ CComPtr<IUnknown> pUnk;
+
+ if(engine == RealMedia)
+ {
+ // TODO : see why Real SDK crash here ...
+ //if (!IsRealEngineCompatible(p->fns.GetHead()))
+ // throw ResStr(IDS_REALVIDEO_INCOMPATIBLE);
+
+ if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CRealMediaGraph(m_pVideoWnd->m_hWnd, hr)))
+ throw ResStr(IDS_AG_OUT_OF_MEMORY);
+
+ if(SUCCEEDED(hr) && !!(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
+ m_fRealMediaGraph = true;
+ }
+ else if(engine == ShockWave)
+ {
#ifdef _WIN64 // No flash on x64
- MessageBox(ResStr(IDS_MAINFRM_76), _T(""), MB_OK);
+ MessageBox(ResStr(IDS_MAINFRM_76), _T(""), MB_OK);
#else
- if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CShockwaveGraph(m_pVideoWnd->m_hWnd, hr)))
- throw ResStr(IDS_AG_OUT_OF_MEMORY);
+ if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CShockwaveGraph(m_pVideoWnd->m_hWnd, hr)))
+ throw ResStr(IDS_AG_OUT_OF_MEMORY);
- if(FAILED(hr) || !(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
- throw ResStr(IDS_MAINFRM_77);
- m_fShockwaveGraph = true;
+ if(FAILED(hr) || !(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
+ throw ResStr(IDS_MAINFRM_77);
+ m_fShockwaveGraph = true;
#endif
- }
- else if(engine == QuickTime)
- {
+ }
+ else if(engine == QuickTime)
+ {
#ifdef _WIN64 // TODOX64
- // MessageBox (ResStr(IDS_MAINFRM_78), _T(""), MB_OK);
+ // MessageBox (ResStr(IDS_MAINFRM_78), _T(""), MB_OK);
#else
- if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CQuicktimeGraph(m_pVideoWnd->m_hWnd, hr)))
- throw ResStr(IDS_AG_OUT_OF_MEMORY);
+ if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CQuicktimeGraph(m_pVideoWnd->m_hWnd, hr)))
+ throw ResStr(IDS_AG_OUT_OF_MEMORY);
- if(SUCCEEDED(hr) && !!(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
+ if(SUCCEEDED(hr) && !!(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
m_fQuicktimeGraph = true;
#endif
- }
-
- m_fCustomGraph = m_fRealMediaGraph || m_fShockwaveGraph || m_fQuicktimeGraph;
-
- if(!m_fCustomGraph)
- {
- pGB = DNew CFGManagerPlayer(_T("CFGManagerPlayer"), NULL, m_pVideoWnd->m_hWnd);
- }
- }
- else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD))
- {
- pGB = DNew CFGManagerDVD(_T("CFGManagerDVD"), NULL, m_pVideoWnd->m_hWnd);
- }
- else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD))
- {
- if(s.iDefaultCaptureDevice == 1)
- pGB = DNew CFGManagerBDA(_T("CFGManagerBDA"), NULL, m_pVideoWnd->m_hWnd);
- else
- pGB = DNew CFGManagerCapture(_T("CFGManagerCapture"), NULL, m_pVideoWnd->m_hWnd);
- }
-
- if(!pGB)
- {
- throw ResStr(IDS_MAINFRM_80);
- }
-
- pGB->AddToROT();
-
- pMC = pGB;
- pME = pGB;
- pMS = pGB; // general
- pVW = pGB;
- pBV = pGB; // video
- pBA = pGB; // audio
- pFS = pGB;
-
- if(!(pMC && pME && pMS)
- || !(pVW && pBV)
- || !(pBA))
- {
- throw _T("Failed to query the needed interfaces for playback");
- }
-
- if(FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
- {
- throw _T("Could not set target window for graph notification");
- }
-
- m_pProv = (IUnknown*)DNew CKeyProvider();
-
- if(CComQIPtr<IObjectWithSite> pObjectWithSite = pGB)
- pObjectWithSite->SetSite(m_pProv);
-
- m_pCB = DNew CDSMChapterBag(NULL, NULL);
+ }
+
+ m_fCustomGraph = m_fRealMediaGraph || m_fShockwaveGraph || m_fQuicktimeGraph;
+
+ if(!m_fCustomGraph)
+ {
+ pGB = DNew CFGManagerPlayer(_T("CFGManagerPlayer"), NULL, m_pVideoWnd->m_hWnd);
+ }
+ }
+ else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD))
+ {
+ pGB = DNew CFGManagerDVD(_T("CFGManagerDVD"), NULL, m_pVideoWnd->m_hWnd);
+ }
+ else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD))
+ {
+ if (s.iDefaultCaptureDevice == 1)
+ pGB = DNew CFGManagerBDA(_T("CFGManagerBDA"), NULL, m_pVideoWnd->m_hWnd);
+ else
+ pGB = DNew CFGManagerCapture(_T("CFGManagerCapture"), NULL, m_pVideoWnd->m_hWnd);
+ }
+
+ if(!pGB)
+ {
+ throw ResStr(IDS_MAINFRM_80);
+ }
+
+ pGB->AddToROT();
+
+ pMC = pGB; pME = pGB; pMS = pGB; // general
+ pVW = pGB; pBV = pGB; // video
+ pBA = pGB; // audio
+ pFS = pGB;
+
+ if(!(pMC && pME && pMS)
+ || !(pVW && pBV)
+ || !(pBA))
+ {
+ throw _T("Failed to query the needed interfaces for playback");
+ }
+
+ if(FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
+ {
+ throw _T("Could not set target window for graph notification");
+ }
+
+ m_pProv = (IUnknown*)DNew CKeyProvider();
+
+ if(CComQIPtr<IObjectWithSite> pObjectWithSite = pGB)
+ pObjectWithSite->SetSite(m_pProv);
+
+ m_pCB = DNew CDSMChapterBag(NULL, NULL);
}
CWnd *CMainFrame::GetModalParent()
{
- AppSettings& s = AfxGetAppSettings();
- CWnd *pParentWnd = this;
- if(m_pFullscreenWnd->IsWindow() && s.m_RenderSettings.iVMR9FullscreenGUISupport)
- pParentWnd = m_pFullscreenWnd;
- return pParentWnd;
+ AppSettings& s = AfxGetAppSettings();
+ CWnd *pParentWnd = this;
+ if (m_pFullscreenWnd->IsWindow() && s.m_RenderSettings.iVMR9FullscreenGUISupport)
+ pParentWnd = m_pFullscreenWnd;
+ return pParentWnd;
}
void CMainFrame::OpenFile(OpenFileData* pOFD)
{
- if(pOFD->fns.IsEmpty())
- throw ResStr(IDS_MAINFRM_81);
-
- AppSettings& s = AfxGetAppSettings();
-
- bool fFirst = true;
-
- POSITION pos = pOFD->fns.GetHeadPosition();
- while(pos)
- {
- CString fn = pOFD->fns.GetNext(pos);
-
- fn.Trim();
- if(fn.IsEmpty() && !fFirst)
- break;
-
- HRESULT hr = pGB->RenderFile(CStringW(fn), NULL);
-
- if(!AfxGetAppSettings().NewFile(fn) && AfxGetAppSettings().fRememberFilePos)
- {
- REFERENCE_TIME rtPos = AfxGetAppSettings().CurrentFilePosition()->llPosition;
- if(pMS) pMS->SetPositions(&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
-
- if(FAILED(hr))
- {
- if(fFirst)
- {
- if(s.fReportFailedPins)
- {
- CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
- }
-
- CString err;
-
- switch(hr)
- {
- case E_ABORT:
- err = ResStr(IDS_MAINFRM_82);
- break;
- case E_FAIL:
- case E_POINTER:
- default:
- err = ResStr(IDS_MAINFRM_83);
- break;
- case E_INVALIDARG:
- err = ResStr(IDS_MAINFRM_84);
- break;
- case E_OUTOFMEMORY:
- err = ResStr(IDS_AG_OUT_OF_MEMORY);
- break;
- case VFW_E_CANNOT_CONNECT:
- err = ResStr(IDS_MAINFRM_86);
- break;
- case VFW_E_CANNOT_LOAD_SOURCE_FILTER:
- err = ResStr(IDS_MAINFRM_87);
- break;
- case VFW_E_CANNOT_RENDER:
- err = ResStr(IDS_MAINFRM_88);
- break;
- case VFW_E_INVALID_FILE_FORMAT:
- err = ResStr(IDS_MAINFRM_89);
- break;
- case VFW_E_NOT_FOUND:
- err = ResStr(IDS_MAINFRM_90);
- break;
- case VFW_E_UNKNOWN_FILE_TYPE:
- err = ResStr(IDS_MAINFRM_91);
- break;
- case VFW_E_UNSUPPORTED_STREAM:
- err = ResStr(IDS_MAINFRM_92);
- break;
- }
-
- throw err;
- }
- }
-
- if(s.fKeepHistory)
- {
- CRecentFileList* pMRU = fFirst ? &s.MRU : &s.MRUDub;
- pMRU->ReadList();
- pMRU->Add(fn);
- pMRU->WriteList();
- SHAddToRecentDocs(SHARD_PATH, fn);
- }
-
- if(fFirst)
- {
- pOFD->title = fn;
- }
-
- fFirst = false;
-
- if(m_fCustomGraph) break;
- }
-
- if(s.fReportFailedPins)
- {
- CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
- }
-
- if(!(pAMOP = pGB))
- {
- BeginEnumFilters(pGB, pEF, pBF)
- if(pAMOP = pBF) break;
- EndEnumFilters
- }
-
- if(FindFilter(__uuidof(CShoutcastSource), pGB))
- m_fUpdateInfoBar = true;
-
- SetupChapters();
-
- CComQIPtr<IKeyFrameInfo> pKFI;
- BeginEnumFilters(pGB, pEF, pBF)
- if(pKFI = pBF) break;
- EndEnumFilters
- UINT nKFs = 0, nKFsTmp = 0;
- if(pKFI && S_OK == pKFI->GetKeyFrameCount(nKFs) && nKFs > 0)
- {
- m_kfs.SetCount(nKFsTmp = nKFs);
- if(S_OK != pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.GetData(), nKFsTmp) || nKFsTmp != nKFs)
- m_kfs.RemoveAll();
- }
-
- m_iPlaybackMode = PM_FILE;
+ if(pOFD->fns.IsEmpty())
+ throw ResStr(IDS_MAINFRM_81);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fFirst = true;
+
+ POSITION pos = pOFD->fns.GetHeadPosition();
+ while(pos)
+ {
+ CString fn = pOFD->fns.GetNext(pos);
+
+ fn.Trim();
+ if(fn.IsEmpty() && !fFirst)
+ break;
+
+ HRESULT hr = pGB->RenderFile(CStringW(fn), NULL);
+
+ if (!AfxGetAppSettings().NewFile (fn) && AfxGetAppSettings().fRememberFilePos)
+ {
+ REFERENCE_TIME rtPos = AfxGetAppSettings().CurrentFilePosition()->llPosition;
+ if (pMS) pMS->SetPositions (&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
+
+ if(FAILED(hr))
+ {
+ if(fFirst)
+ {
+ if(s.fReportFailedPins)
+ {
+ CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
+ if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
+
+ CString err;
+
+ switch(hr)
+ {
+ case E_ABORT: err = ResStr(IDS_MAINFRM_82); break;
+ case E_FAIL: case E_POINTER: default: err = ResStr(IDS_MAINFRM_83); break;
+ case E_INVALIDARG: err = ResStr(IDS_MAINFRM_84); break;
+ case E_OUTOFMEMORY: err = ResStr(IDS_AG_OUT_OF_MEMORY); break;
+ case VFW_E_CANNOT_CONNECT: err = ResStr(IDS_MAINFRM_86); break;
+ case VFW_E_CANNOT_LOAD_SOURCE_FILTER: err = ResStr(IDS_MAINFRM_87); break;
+ case VFW_E_CANNOT_RENDER: err = ResStr(IDS_MAINFRM_88); break;
+ case VFW_E_INVALID_FILE_FORMAT: err = ResStr(IDS_MAINFRM_89); break;
+ case VFW_E_NOT_FOUND: err = ResStr(IDS_MAINFRM_90); break;
+ case VFW_E_UNKNOWN_FILE_TYPE: err = ResStr(IDS_MAINFRM_91); break;
+ case VFW_E_UNSUPPORTED_STREAM: err = ResStr(IDS_MAINFRM_92); break;
+ }
+
+ throw err;
+ }
+ }
+
+ if(s.fKeepHistory)
+ {
+ CRecentFileList* pMRU = fFirst ? &s.MRU : &s.MRUDub;
+ pMRU->ReadList();
+ pMRU->Add(fn);
+ pMRU->WriteList();
+ SHAddToRecentDocs(SHARD_PATH, fn);
+ }
+
+ if(fFirst)
+ {
+ pOFD->title = fn;
+ }
+
+ fFirst = false;
+
+ if(m_fCustomGraph) break;
+ }
+
+ if(s.fReportFailedPins)
+ {
+ CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
+ if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
+
+ if(!(pAMOP = pGB))
+ {
+ BeginEnumFilters(pGB, pEF, pBF)
+ if(pAMOP = pBF) break;
+ EndEnumFilters
+ }
+
+ if(FindFilter(__uuidof(CShoutcastSource), pGB))
+ m_fUpdateInfoBar = true;
+
+ SetupChapters();
+
+ CComQIPtr<IKeyFrameInfo> pKFI;
+ BeginEnumFilters(pGB, pEF, pBF)
+ if(pKFI = pBF) break;
+ EndEnumFilters
+ UINT nKFs = 0, nKFsTmp = 0;
+ if(pKFI && S_OK == pKFI->GetKeyFrameCount(nKFs) && nKFs > 0)
+ {
+ m_kfs.SetCount(nKFsTmp = nKFs);
+ if(S_OK != pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.GetData(), nKFsTmp) || nKFsTmp != nKFs)
+ m_kfs.RemoveAll();
+ }
+
+ m_iPlaybackMode = PM_FILE;
}
void CMainFrame::SetupChapters()
{
- ASSERT(m_pCB);
-
- m_pCB->ChapRemoveAll();
-
- CInterfaceList<IBaseFilter> pBFs;
- BeginEnumFilters(pGB, pEF, pBF)
- pBFs.AddTail(pBF);
- EndEnumFilters
-
- POSITION pos;
-
- pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- CComQIPtr<IDSMChapterBag> pCB = pBF;
- if(!pCB) continue;
-
- for(DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++)
- {
- REFERENCE_TIME rt;
- CComBSTR name;
- if(SUCCEEDED(pCB->ChapGet(i, &rt, &name)))
- m_pCB->ChapAppend(rt, name);
- }
- }
-
- pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- CComQIPtr<IChapterInfo> pCI = pBF;
- if(!pCI) continue;
-
- CHAR iso6391[3];
- ::GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, iso6391, 3);
- CStringA iso6392 = ISO6391To6392(iso6391);
- if(iso6392.GetLength() < 3) iso6392 = "eng";
-
- UINT cnt = pCI->GetChapterCount(CHAPTER_ROOT_ID);
- for(UINT i = 1; i <= cnt; i++)
- {
- UINT cid = pCI->GetChapterId(CHAPTER_ROOT_ID, i);
-
- ChapterElement ce;
- if(pCI->GetChapterInfo(cid, &ce))
- {
- char pl[3] = {iso6392[0], iso6392[1], iso6392[2]};
- char cc[] = " ";
- CComBSTR name;
- name.Attach(pCI->GetChapterStringInfo(cid, pl, cc));
- m_pCB->ChapAppend(ce.rtStart, name);
- }
- }
- }
-
- pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- CComQIPtr<IAMExtendedSeeking, &IID_IAMExtendedSeeking> pES = pBF;
- if(!pES) continue;
-
- long MarkerCount = 0;
- if(SUCCEEDED(pES->get_MarkerCount(&MarkerCount)))
- {
- for(long i = 1; i <= MarkerCount; i++)
- {
- double MarkerTime = 0;
- if(SUCCEEDED(pES->GetMarkerTime(i, &MarkerTime)))
- {
- CStringW name;
- name.Format(L"Chapter %d", i);
-
- CComBSTR bstr;
- if(S_OK == pES->GetMarkerName(i, &bstr))
- name = bstr;
-
- m_pCB->ChapAppend(REFERENCE_TIME(MarkerTime * 10000000), name);
- }
- }
- }
- }
-
- pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- if(GetCLSID(pBF) != CLSID_OggSplitter)
- continue;
-
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(m_pCB->ChapGetCount()) break;
-
- if(CComQIPtr<IPropertyBag> pPB = pPin)
- {
- for(int i = 1; ; i++)
- {
- CStringW str;
- CComVariant var;
-
- var.Clear();
- str.Format(L"CHAPTER%02d", i);
- if(S_OK != pPB->Read(str, &var, NULL))
- break;
-
- int h, m, s, ms;
- WCHAR wc;
- if(7 != swscanf_s(CStringW(var), L"%d%c%d%c%d%c%d", &h, &wc, &m, &wc, &s, &wc, &ms))
- break;
-
- CStringW name;
- name.Format(L"Chapter %d", i);
- var.Clear();
+ ASSERT(m_pCB);
+
+ m_pCB->ChapRemoveAll();
+
+ CInterfaceList<IBaseFilter> pBFs;
+ BeginEnumFilters(pGB, pEF, pBF)
+ pBFs.AddTail(pBF);
+ EndEnumFilters
+
+ POSITION pos;
+
+ pos = pBFs.GetHeadPosition();
+ while(pos && !m_pCB->ChapGetCount())
+ {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ CComQIPtr<IDSMChapterBag> pCB = pBF;
+ if(!pCB) continue;
+
+ for(DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++)
+ {
+ REFERENCE_TIME rt;
+ CComBSTR name;
+ if(SUCCEEDED(pCB->ChapGet(i, &rt, &name)))
+ m_pCB->ChapAppend(rt, name);
+ }
+ }
+
+ pos = pBFs.GetHeadPosition();
+ while(pos && !m_pCB->ChapGetCount())
+ {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ CComQIPtr<IChapterInfo> pCI = pBF;
+ if(!pCI) continue;
+
+ CHAR iso6391[3];
+ ::GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, iso6391, 3);
+ CStringA iso6392 = ISO6391To6392(iso6391);
+ if(iso6392.GetLength() < 3) iso6392 = "eng";
+
+ UINT cnt = pCI->GetChapterCount(CHAPTER_ROOT_ID);
+ for(UINT i = 1; i <= cnt; i++)
+ {
+ UINT cid = pCI->GetChapterId(CHAPTER_ROOT_ID, i);
+
+ ChapterElement ce;
+ if(pCI->GetChapterInfo(cid, &ce))
+ {
+ char pl[3] = {iso6392[0], iso6392[1], iso6392[2]};
+ char cc[] = " ";
+ CComBSTR name;
+ name.Attach(pCI->GetChapterStringInfo(cid, pl, cc));
+ m_pCB->ChapAppend(ce.rtStart, name);
+ }
+ }
+ }
+
+ pos = pBFs.GetHeadPosition();
+ while(pos && !m_pCB->ChapGetCount())
+ {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ CComQIPtr<IAMExtendedSeeking, &IID_IAMExtendedSeeking> pES = pBF;
+ if(!pES) continue;
+
+ long MarkerCount = 0;
+ if(SUCCEEDED(pES->get_MarkerCount(&MarkerCount)))
+ {
+ for(long i = 1; i <= MarkerCount; i++)
+ {
+ double MarkerTime = 0;
+ if(SUCCEEDED(pES->GetMarkerTime(i, &MarkerTime)))
+ {
+ CStringW name;
+ name.Format(L"Chapter %d", i);
+
+ CComBSTR bstr;
+ if(S_OK == pES->GetMarkerName(i, &bstr))
+ name = bstr;
+
+ m_pCB->ChapAppend(REFERENCE_TIME(MarkerTime*10000000), name);
+ }
+ }
+ }
+ }
+
+ pos = pBFs.GetHeadPosition();
+ while(pos && !m_pCB->ChapGetCount())
+ {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ if(GetCLSID(pBF) != CLSID_OggSplitter)
+ continue;
+
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(m_pCB->ChapGetCount()) break;
+
+ if(CComQIPtr<IPropertyBag> pPB = pPin)
+ {
+ for(int i = 1; ; i++)
+ {
+ CStringW str;
+ CComVariant var;
+
+ var.Clear();
+ str.Format(L"CHAPTER%02d", i);
+ if(S_OK != pPB->Read(str, &var, NULL))
+ break;
+
+ int h, m, s, ms;
+ WCHAR wc;
+ if(7 != swscanf_s(CStringW(var), L"%d%c%d%c%d%c%d", &h, &wc, &m, &wc, &s, &wc, &ms))
+ break;
+
+ CStringW name;
+ name.Format(L"Chapter %d", i);
+ var.Clear();
str += L"NAME";
- if(S_OK == pPB->Read(str, &var, NULL))
- name = var;
+ if(S_OK == pPB->Read(str, &var, NULL))
+ name = var;
- m_pCB->ChapAppend(10000i64 *(((h * 60 + m) * 60 + s) * 1000 + ms), name);
- }
- }
- }
- EndEnumPins
- }
+ m_pCB->ChapAppend(10000i64*(((h*60 + m)*60 + s)*1000 + ms), name);
+ }
+ }
+ }
+ EndEnumPins
+ }
- m_pCB->ChapSort();
+ m_pCB->ChapSort();
}
void CMainFrame::OpenDVD(OpenDVDData* pODD)
{
- HRESULT hr = pGB->RenderFile(CStringW(pODD->path), NULL);
+ HRESULT hr = pGB->RenderFile(CStringW(pODD->path), NULL);
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if(s.fReportFailedPins)
- {
- CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
- }
+ if(s.fReportFailedPins)
+ {
+ CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
+ if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if((pDVDC = pBF) && (pDVDI = pBF))
- break;
- }
- EndEnumFilters
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if((pDVDC = pBF) && (pDVDI = pBF))
+ break;
+ }
+ EndEnumFilters
- if(hr == E_INVALIDARG)
- throw ResStr(IDS_MAINFRM_93);
- else if(hr == VFW_E_CANNOT_RENDER)
- throw _T("Failed to render all pins of the DVD Navigator filter");
- else if(hr == VFW_S_PARTIAL_RENDER)
- throw _T("Failed to render some of the pins of the DVD Navigator filter");
- else if(hr == E_NOINTERFACE || !pDVDC || !pDVDI)
- throw _T("Failed to query the needed interfaces for DVD playback");
- else if(hr == VFW_E_CANNOT_LOAD_SOURCE_FILTER)
- throw ResStr(IDS_MAINFRM_94);
- else if(FAILED(hr))
- throw ResStr(IDS_AG_FAILED);
+ if(hr == E_INVALIDARG)
+ throw ResStr(IDS_MAINFRM_93);
+ else if(hr == VFW_E_CANNOT_RENDER)
+ throw _T("Failed to render all pins of the DVD Navigator filter");
+ else if(hr == VFW_S_PARTIAL_RENDER)
+ throw _T("Failed to render some of the pins of the DVD Navigator filter");
+ else if(hr == E_NOINTERFACE || !pDVDC || !pDVDI)
+ throw _T("Failed to query the needed interfaces for DVD playback");
+ else if(hr == VFW_E_CANNOT_LOAD_SOURCE_FILTER)
+ throw ResStr(IDS_MAINFRM_94);
+ else if(FAILED(hr))
+ throw ResStr(IDS_AG_FAILED);
- WCHAR buff[_MAX_PATH];
- ULONG len = 0;
- if(SUCCEEDED(hr = pDVDI->GetDVDDirectory(buff, countof(buff), &len)))
- pODD->title = CString(CStringW(buff));
+ WCHAR buff[_MAX_PATH];
+ ULONG len = 0;
+ if(SUCCEEDED(hr = pDVDI->GetDVDDirectory(buff, countof(buff), &len)))
+ pODD->title = CString(CStringW(buff));
- // TODO: resetdvd
- pDVDC->SetOption(DVD_ResetOnStop, FALSE);
- pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
+ // TODO: resetdvd
+ pDVDC->SetOption(DVD_ResetOnStop, FALSE);
+ pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
- if(s.idMenuLang) pDVDC->SelectDefaultMenuLanguage(s.idMenuLang);
- if(s.idAudioLang) pDVDC->SelectDefaultAudioLanguage(s.idAudioLang, DVD_AUD_EXT_NotSpecified);
- if(s.idSubtitlesLang) pDVDC->SelectDefaultSubpictureLanguage(s.idSubtitlesLang, DVD_SP_EXT_NotSpecified);
+ if(s.idMenuLang) pDVDC->SelectDefaultMenuLanguage(s.idMenuLang);
+ if(s.idAudioLang) pDVDC->SelectDefaultAudioLanguage(s.idAudioLang, DVD_AUD_EXT_NotSpecified);
+ if(s.idSubtitlesLang) pDVDC->SelectDefaultSubpictureLanguage(s.idSubtitlesLang, DVD_SP_EXT_NotSpecified);
- m_iDVDDomain = DVD_DOMAIN_Stop;
+ m_iDVDDomain = DVD_DOMAIN_Stop;
- m_iPlaybackMode = PM_DVD;
+ m_iPlaybackMode = PM_DVD;
}
void CMainFrame::OpenBDAGraph()
{
- pGB->RenderFile(L"", L"");
- AddTextPassThruFilter();
- m_iPlaybackMode = PM_CAPTURE;
+ pGB->RenderFile (L"",L"");
+ AddTextPassThruFilter();
+ m_iPlaybackMode = PM_CAPTURE;
}
void CMainFrame::OpenCapture(OpenDeviceData* pODD)
{
- CStringW vidfrname, audfrname;
- CComPtr<IBaseFilter> pVidCapTmp, pAudCapTmp;
-
- m_VidDispName = pODD->DisplayName[0];
-
- if(!m_VidDispName.IsEmpty())
- {
- if(!CreateFilter(m_VidDispName, &pVidCapTmp, vidfrname))
- throw ResStr(IDS_MAINFRM_96);
- }
-
- m_AudDispName = pODD->DisplayName[1];
-
- if(!m_AudDispName.IsEmpty())
- {
- if(!CreateFilter(m_AudDispName, &pAudCapTmp, audfrname))
- throw ResStr(IDS_MAINFRM_96);
- }
-
- if(!pVidCapTmp && !pAudCapTmp)
- {
- throw ResStr(IDS_MAINFRM_98);
- }
-
- pCGB = NULL;
- pVidCap = NULL;
- pAudCap = NULL;
-
- if(FAILED(pCGB.CoCreateInstance(CLSID_CaptureGraphBuilder2)))
- {
- throw ResStr(IDS_MAINFRM_99);
- }
-
- HRESULT hr;
-
- pCGB->SetFiltergraph(pGB);
-
- if(pVidCapTmp)
- {
- if(FAILED(hr = pGB->AddFilter(pVidCapTmp, vidfrname)))
- {
- throw _T("Can't add video capture filter to the graph");
- }
-
- pVidCap = pVidCapTmp;
-
- if(!pAudCapTmp)
- {
- if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap)))
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
-
- if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev)))
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
-
- if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void **)&pAMASC))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void **)&pAMASC)))
- {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
- }
- else
- {
- pAudCap = pVidCap;
- }
- }
- else
- {
- if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap)))
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
-
- if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev)))
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
- }
-
- if(FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMCrossbar, (void**)&pAMXBar)))
- TRACE(_T("Warning: No IAMCrossbar interface was found\n"));
-
- if(FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMTVTuner, (void**)&pAMTuner)))
- TRACE(_T("Warning: No IAMTVTuner interface was found\n"));
- /*
- if(pAMVSCCap)
- {
- //DumpStreamConfig(_T("c:\\mpclog.txt"), pAMVSCCap);
- CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
- if(!pAMXBar && pVfwCD)
- {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pVfwCD);
- }
- else
- {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pAMXBar, pAMTuner);
- }
- }
- */
- // TODO: init pAMXBar
-
- if(pAMTuner) // load saved channel
- {
- pAMTuner->put_CountryCode(AfxGetApp()->GetProfileInt(_T("Capture"), _T("Country"), 1));
-
- int vchannel = pODD->vchannel;
- if(vchannel < 0) vchannel = AfxGetApp()->GetProfileInt(_T("Capture\\") + CString(m_VidDispName), _T("Channel"), -1);
- if(vchannel >= 0)
- {
- OAFilterState fs = State_Stopped;
- pMC->GetState(0, &fs);
- if(fs == State_Running) pMC->Pause();
- pAMTuner->put_Channel(vchannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
- if(fs == State_Running) pMC->Run();
- }
- }
- }
-
- if(pAudCapTmp)
- {
- if(FAILED(hr = pGB->AddFilter(pAudCapTmp, CStringW(audfrname))))
- {
- throw _T("Can't add audio capture filter to the graph");
- }
-
- pAudCap = pAudCapTmp;
-
- if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void **)&pAMASC))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void **)&pAMASC)))
- {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
- }
- /*
- CInterfaceArray<IAMAudioInputMixer> pAMAIM;
-
- BeginEnumPins(pAudCap, pEP, pPin)
- {
- PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_INPUT)
- continue;
-
- if(CComQIPtr<IAMAudioInputMixer> pAIM = pPin)
- pAMAIM.Add(pAIM);
- }
- EndEnumPins
-
- if(pAMASC)
- {
- m_wndCaptureBar.m_capdlg.SetupAudioControls(auddispname, pAMASC, pAMAIM);
- }
- */
- }
-
- if(!(pVidCap || pAudCap))
- {
- throw ResStr(IDS_MAINFRM_108);
- }
+ CStringW vidfrname, audfrname;
+ CComPtr<IBaseFilter> pVidCapTmp, pAudCapTmp;
+
+ m_VidDispName = pODD->DisplayName[0];
+
+ if(!m_VidDispName.IsEmpty())
+ {
+ if(!CreateFilter(m_VidDispName, &pVidCapTmp, vidfrname))
+ throw ResStr(IDS_MAINFRM_96);
+ }
+
+ m_AudDispName = pODD->DisplayName[1];
+
+ if(!m_AudDispName.IsEmpty())
+ {
+ if(!CreateFilter(m_AudDispName, &pAudCapTmp, audfrname))
+ throw ResStr(IDS_MAINFRM_96);
+ }
+
+ if(!pVidCapTmp && !pAudCapTmp)
+ {
+ throw ResStr(IDS_MAINFRM_98);
+ }
+
+ pCGB = NULL;
+ pVidCap = NULL;
+ pAudCap = NULL;
+
+ if(FAILED(pCGB.CoCreateInstance(CLSID_CaptureGraphBuilder2)))
+ {
+ throw ResStr(IDS_MAINFRM_99);
+ }
+
+ HRESULT hr;
+
+ pCGB->SetFiltergraph(pGB);
+
+ if(pVidCapTmp)
+ {
+ if(FAILED(hr = pGB->AddFilter(pVidCapTmp, vidfrname)))
+ {
+ throw _T("Can't add video capture filter to the graph");
+ }
+
+ pVidCap = pVidCapTmp;
+
+ if(!pAudCapTmp)
+ {
+ if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap)))
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+
+ if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev)))
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+
+ if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void **)&pAMASC))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void **)&pAMASC)))
+ {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
+ }
+ else
+ {
+ pAudCap = pVidCap;
+ }
+ }
+ else
+ {
+ if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap)))
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+
+ if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev)))
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+ }
+
+ if(FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMCrossbar, (void**)&pAMXBar)))
+ TRACE(_T("Warning: No IAMCrossbar interface was found\n"));
+
+ if(FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMTVTuner, (void**)&pAMTuner)))
+ TRACE(_T("Warning: No IAMTVTuner interface was found\n"));
+/*
+ if(pAMVSCCap)
+ {
+//DumpStreamConfig(_T("c:\\mpclog.txt"), pAMVSCCap);
+ CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
+ if(!pAMXBar && pVfwCD)
+ {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pVfwCD);
+ }
+ else
+ {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pAMXBar, pAMTuner);
+ }
+ }
+*/
+ // TODO: init pAMXBar
+
+ if(pAMTuner) // load saved channel
+ {
+ pAMTuner->put_CountryCode(AfxGetApp()->GetProfileInt(_T("Capture"), _T("Country"), 1));
+
+ int vchannel = pODD->vchannel;
+ if(vchannel < 0) vchannel = AfxGetApp()->GetProfileInt(_T("Capture\\") + CString(m_VidDispName), _T("Channel"), -1);
+ if(vchannel >= 0)
+ {
+ OAFilterState fs = State_Stopped;
+ pMC->GetState(0, &fs);
+ if(fs == State_Running) pMC->Pause();
+ pAMTuner->put_Channel(vchannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
+ if(fs == State_Running) pMC->Run();
+ }
+ }
+ }
+
+ if(pAudCapTmp)
+ {
+ if(FAILED(hr = pGB->AddFilter(pAudCapTmp, CStringW(audfrname))))
+ {
+ throw _T("Can't add audio capture filter to the graph");
+ }
+
+ pAudCap = pAudCapTmp;
+
+ if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void **)&pAMASC))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void **)&pAMASC)))
+ {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
+ }
+/*
+ CInterfaceArray<IAMAudioInputMixer> pAMAIM;
+
+ BeginEnumPins(pAudCap, pEP, pPin)
+ {
+ PIN_DIRECTION dir;
+ if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_INPUT)
+ continue;
+
+ if(CComQIPtr<IAMAudioInputMixer> pAIM = pPin)
+ pAMAIM.Add(pAIM);
+ }
+ EndEnumPins
+
+ if(pAMASC)
+ {
+ m_wndCaptureBar.m_capdlg.SetupAudioControls(auddispname, pAMASC, pAMAIM);
+ }
+*/
+ }
- pODD->title = _T("Live");
+ if(!(pVidCap || pAudCap))
+ {
+ throw ResStr(IDS_MAINFRM_108);
+ }
- m_iPlaybackMode = PM_CAPTURE;
+ pODD->title = _T("Live");
+
+ m_iPlaybackMode = PM_CAPTURE;
}
void CMainFrame::OpenCustomizeGraph()
{
- if(m_iPlaybackMode == PM_CAPTURE)
- return;
-
- CleanGraph();
-
- if(m_iPlaybackMode == PM_FILE)
- {
- if(m_pCAP && AfxGetAppSettings().fAutoloadSubtitles)
- AddTextPassThruFilter();
- }
-
- AppSettings& s = AfxGetAppSettings();
- if(s.m_RenderSettings.bSynchronizeVideo && s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- {
- HRESULT hr;
- m_pRefClock = DNew CSyncClockFilter(NULL, &hr);
- CStringW name;
- name.Format(L"SyncClock Filter");
- pGB->AddFilter(m_pRefClock, name);
-
- CComPtr<IReferenceClock> refClock;
- m_pRefClock->QueryInterface(IID_IReferenceClock, reinterpret_cast<void**>(&refClock));
- CComPtr<IMediaFilter> mediaFilter;
- pGB->QueryInterface(IID_IMediaFilter, reinterpret_cast<void**>(&mediaFilter));
- mediaFilter->SetSyncSource(refClock);
- mediaFilter = NULL;
- refClock = NULL;
-
- m_pRefClock->QueryInterface(IID_ISyncClock, reinterpret_cast<void**>(&m_pSyncClock));
- }
-
- if(m_iPlaybackMode == PM_DVD)
- {
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(CComQIPtr<IDirectVobSub2> pDVS2 = pBF)
- {
+ if(m_iPlaybackMode == PM_CAPTURE)
+ return;
+
+ CleanGraph();
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ if(m_pCAP && AfxGetAppSettings().fAutoloadSubtitles)
+ AddTextPassThruFilter();
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+ if (s.m_RenderSettings.bSynchronizeVideo && s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
+ {
+ HRESULT hr;
+ m_pRefClock = DNew CSyncClockFilter(NULL, &hr);
+ CStringW name;
+ name.Format(L"SyncClock Filter");
+ pGB->AddFilter(m_pRefClock, name);
+
+ CComPtr<IReferenceClock> refClock;
+ m_pRefClock->QueryInterface(IID_IReferenceClock, reinterpret_cast<void**>(&refClock));
+ CComPtr<IMediaFilter> mediaFilter;
+ pGB->QueryInterface(IID_IMediaFilter, reinterpret_cast<void**>(&mediaFilter));
+ mediaFilter->SetSyncSource(refClock);
+ mediaFilter = NULL;
+ refClock = NULL;
+
+ m_pRefClock->QueryInterface(IID_ISyncClock, reinterpret_cast<void**>(&m_pSyncClock));
+ }
+
+ if(m_iPlaybackMode == PM_DVD)
+ {
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(CComQIPtr<IDirectVobSub2> pDVS2 = pBF)
+ {
// pDVS2->AdviseSubClock(m_pSubClock = DNew CSubClock);
// break;
- // TODO: test multiple dvobsub instances with one clock
- if(!m_pSubClock) m_pSubClock = DNew CSubClock;
- pDVS2->AdviseSubClock(m_pSubClock);
- }
- }
- EndEnumFilters
- }
-
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(GetCLSID(pBF) == CLSID_OggSplitter)
- {
- if(CComQIPtr<IAMStreamSelect> pSS = pBF)
- {
- LCID idAudio = AfxGetAppSettings().idAudioLang;
- if(!idAudio) idAudio = GetUserDefaultLCID();
- LCID idSub = AfxGetAppSettings().idSubtitlesLang;
- if(!idSub) idSub = GetUserDefaultLCID();
-
- DWORD cnt = 0;
- pSS->Count(&cnt);
- for(DWORD i = 0; i < cnt; i++)
- {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if(SUCCEEDED(pSS->Info((long)i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- {
- CStringW name(pszName), sound(ResStr(IDS_AG_SOUND)), subtitle(L"Subtitle");
-
- if(idAudio != -1 && (idAudio & 0x3ff) == (lcid & 0x3ff) // sublang seems to be zeroed out in ogm...
- && name.GetLength() > sound.GetLength()
- && !name.Left(sound.GetLength()).CompareNoCase(sound))
- {
- if(SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE)))
- idAudio = -1;
- }
-
- if(idSub != -1 && (idSub & 0x3ff) == (lcid & 0x3ff) // sublang seems to be zeroed out in ogm...
- && name.GetLength() > subtitle.GetLength()
- && !name.Left(subtitle.GetLength()).CompareNoCase(subtitle)
- && name.Mid(subtitle.GetLength()).Trim().CompareNoCase(L"off"))
- {
- if(SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE)))
- idSub = -1;
- }
-
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
- }
- }
- }
- }
- }
- EndEnumFilters
-
- CleanGraph();
+ // TODO: test multiple dvobsub instances with one clock
+ if(!m_pSubClock) m_pSubClock = DNew CSubClock;
+ pDVS2->AdviseSubClock(m_pSubClock);
+ }
+ }
+ EndEnumFilters
+ }
+
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(GetCLSID(pBF) == CLSID_OggSplitter)
+ {
+ if(CComQIPtr<IAMStreamSelect> pSS = pBF)
+ {
+ LCID idAudio = AfxGetAppSettings().idAudioLang;
+ if(!idAudio) idAudio = GetUserDefaultLCID();
+ LCID idSub = AfxGetAppSettings().idSubtitlesLang;
+ if(!idSub) idSub = GetUserDefaultLCID();
+
+ DWORD cnt = 0;
+ pSS->Count(&cnt);
+ for(DWORD i = 0; i < cnt; i++)
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if(SUCCEEDED(pSS->Info((long)i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+ {
+ CStringW name(pszName), sound(ResStr(IDS_AG_SOUND)), subtitle(L"Subtitle");
+
+ if(idAudio != -1 && (idAudio&0x3ff) == (lcid&0x3ff) // sublang seems to be zeroed out in ogm...
+ && name.GetLength() > sound.GetLength()
+ && !name.Left(sound.GetLength()).CompareNoCase(sound))
+ {
+ if(SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE)))
+ idAudio = -1;
+ }
+
+ if(idSub != -1 && (idSub&0x3ff) == (lcid&0x3ff) // sublang seems to be zeroed out in ogm...
+ && name.GetLength() > subtitle.GetLength()
+ && !name.Left(subtitle.GetLength()).CompareNoCase(subtitle)
+ && name.Mid(subtitle.GetLength()).Trim().CompareNoCase(L"off"))
+ {
+ if(SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE)))
+ idSub = -1;
+ }
+
+ if(pmt) DeleteMediaType(pmt);
+ if(pszName) CoTaskMemFree(pszName);
+ }
+ }
+ }
+ }
+ }
+ EndEnumFilters
+
+ CleanGraph();
}
void CMainFrame::OpenSetupVideo()
{
- m_fAudioOnly = true;
-
- if(m_pMFVDC) // EVR
- {
- m_fAudioOnly = false;
- }
- else if(m_pCAP)
- {
- CSize vs = m_pCAP->GetVideoSize();
- m_fAudioOnly = (vs.cx <= 0 || vs.cy <= 0);
- }
- else
- {
- {
- long w = 0, h = 0;
-
- if(CComQIPtr<IBasicVideo> pBV = pGB)
- {
- pBV->GetVideoSize(&w, &h);
- }
-
- if(w > 0 && h > 0)
- {
- m_fAudioOnly = false;
- }
- }
-
- if(m_fAudioOnly)
- {
- BeginEnumFilters(pGB, pEF, pBF)
- {
- long w = 0, h = 0;
-
- if(CComQIPtr<IVideoWindow> pVW = pBF)
- {
- long lVisible;
- if(FAILED(pVW->get_Visible(&lVisible)))
- continue;
-
- pVW->get_Width(&w);
- pVW->get_Height(&h);
- }
-
- if(w > 0 && h > 0)
- {
- m_fAudioOnly = false;
- break;
- }
- }
- EndEnumFilters
- }
- }
-
- if(m_fShockwaveGraph)
- {
- m_fAudioOnly = false;
- }
-
- if(m_pCAP)
- {
- SetShaders();
- }
- // else
- {
- // TESTME
-
- pVW->put_Owner((OAHWND)m_pVideoWnd->m_hWnd);
- pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
- pVW->put_MessageDrain((OAHWND)m_hWnd);
-
- for(CWnd* pWnd = m_wndView.GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
- pWnd->EnableWindow(FALSE); // little trick to let WM_SETCURSOR thru
- }
-
- if(m_fAudioOnly && m_pFullscreenWnd->IsWindow())
- m_pFullscreenWnd->DestroyWindow();
+ m_fAudioOnly = true;
+
+ if (m_pMFVDC) // EVR
+ {
+ m_fAudioOnly = false;
+ }
+ else if(m_pCAP)
+ {
+ CSize vs = m_pCAP->GetVideoSize();
+ m_fAudioOnly = (vs.cx <= 0 || vs.cy <= 0);
+ }
+ else
+ {
+ {
+ long w = 0, h = 0;
+
+ if(CComQIPtr<IBasicVideo> pBV = pGB)
+ {
+ pBV->GetVideoSize(&w, &h);
+ }
+
+ if(w > 0 && h > 0)
+ {
+ m_fAudioOnly = false;
+ }
+ }
+
+ if(m_fAudioOnly)
+ {
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ long w = 0, h = 0;
+
+ if(CComQIPtr<IVideoWindow> pVW = pBF)
+ {
+ long lVisible;
+ if(FAILED(pVW->get_Visible(&lVisible)))
+ continue;
+
+ pVW->get_Width(&w);
+ pVW->get_Height(&h);
+ }
+
+ if(w > 0 && h > 0)
+ {
+ m_fAudioOnly = false;
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+ }
+
+ if(m_fShockwaveGraph)
+ {
+ m_fAudioOnly = false;
+ }
+
+ if(m_pCAP)
+ {
+ SetShaders();
+ }
+ // else
+ {
+ // TESTME
+
+ pVW->put_Owner((OAHWND)m_pVideoWnd->m_hWnd);
+ pVW->put_WindowStyle(WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN);
+ pVW->put_MessageDrain((OAHWND)m_hWnd);
+
+ for(CWnd* pWnd = m_wndView.GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ pWnd->EnableWindow(FALSE); // little trick to let WM_SETCURSOR thru
+ }
+
+ if (m_fAudioOnly && m_pFullscreenWnd->IsWindow())
+ m_pFullscreenWnd->DestroyWindow();
}
void CMainFrame::OpenSetupAudio()
{
- pBA->put_Volume(m_wndToolBar.Volume);
+ pBA->put_Volume(m_wndToolBar.Volume);
- // FIXME
- int balance = AfxGetAppSettings().nBalance;
- int sign = balance > 0 ? -1 : 1;
- balance = max(100 - abs(balance), 1);
- balance = (int)((log10(1.0 * balance) - 2) * 5000 * sign);
- balance = max(min(balance, 10000), -10000);
- pBA->put_Balance(balance);
+ // FIXME
+ int balance = AfxGetAppSettings().nBalance;
+ int sign = balance>0?-1:1;
+ balance = max(100-abs(balance), 1);
+ balance = (int)((log10(1.0*balance)-2)*5000*sign);
+ balance = max(min(balance, 10000), -10000);
+ pBA->put_Balance(balance);
}
/*
void CMainFrame::OpenSetupToolBar()
@@ -10101,2980 +9763,2885 @@ void CMainFrame::OpenSetupToolBar()
*/
void CMainFrame::OpenSetupCaptureBar()
{
- if(m_iPlaybackMode == PM_CAPTURE)
- {
- if(pVidCap && pAMVSCCap)
- {
+ if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ if(pVidCap && pAMVSCCap)
+ {
CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
- if(!pAMXBar && pVfwCD)
- {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pVfwCD);
- }
- else
- {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pAMXBar, pAMTuner);
- }
- }
+ if(!pAMXBar && pVfwCD)
+ {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pVfwCD);
+ }
+ else
+ {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pAMXBar, pAMTuner);
+ }
+ }
- if(pAudCap && pAMASC)
- {
- CInterfaceArray<IAMAudioInputMixer> pAMAIM;
+ if(pAudCap && pAMASC)
+ {
+ CInterfaceArray<IAMAudioInputMixer> pAMAIM;
- BeginEnumPins(pAudCap, pEP, pPin)
- {
- if(CComQIPtr<IAMAudioInputMixer> pAIM = pPin)
- pAMAIM.Add(pAIM);
- }
- EndEnumPins
+ BeginEnumPins(pAudCap, pEP, pPin)
+ {
+ if(CComQIPtr<IAMAudioInputMixer> pAIM = pPin)
+ pAMAIM.Add(pAIM);
+ }
+ EndEnumPins
- m_wndCaptureBar.m_capdlg.SetupAudioControls(m_AudDispName, pAMASC, pAMAIM);
- }
- }
+ m_wndCaptureBar.m_capdlg.SetupAudioControls(m_AudDispName, pAMASC, pAMAIM);
+ }
+ }
- BuildGraphVideoAudio(
- m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
- m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
+ BuildGraphVideoAudio(
+ m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
+ m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
}
void CMainFrame::OpenSetupInfoBar()
{
- if(m_iPlaybackMode == PM_FILE)
- {
- bool fEmpty = true;
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
- {
- CComBSTR bstr;
- if(SUCCEEDED(pAMMC->get_Title(&bstr)))
- {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_TITLE), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_AuthorName(&bstr)))
- {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUTHOR), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_Copyright(&bstr)))
- {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_COPYRIGHT), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_Rating(&bstr)))
- {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_RATING), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_Description(&bstr)))
- {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DESCRIPTION), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
- }
- if(!fEmpty)
- {
- RecalcLayout();
- break;
- }
- }
- }
- EndEnumFilters
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- CString info('-');
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), info);
- RecalcLayout();
- }
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ bool fEmpty = true;
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
+ {
+ CComBSTR bstr;
+ if(SUCCEEDED(pAMMC->get_Title(&bstr))) {m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_TITLE), bstr.m_str); if(bstr.Length()) fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_AuthorName(&bstr))) {m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUTHOR), bstr.m_str); if(bstr.Length()) fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_Copyright(&bstr))) {m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_COPYRIGHT), bstr.m_str); if(bstr.Length()) fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_Rating(&bstr))) {m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_RATING), bstr.m_str); if(bstr.Length()) fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_Description(&bstr))) {m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DESCRIPTION), bstr.m_str); if(bstr.Length()) fEmpty = false;}
+ if(!fEmpty)
+ {
+ RecalcLayout();
+ break;
+ }
+ }
+ }
+ EndEnumFilters
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ CString info('-');
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), info);
+ RecalcLayout();
+ }
}
void CMainFrame::OpenSetupStatsBar()
{
- CString info('-');
-
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(!pQP && (pQP = pBF))
- {
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
- m_wndStatsBar.SetLine(_T("Sync Offset"), info);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
- m_wndStatsBar.SetLine(_T("Jitter"), info);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
- m_wndStatsBar.SetLine(_T("Bitrate"), info);
- RecalcLayout();
- }
-
- if(!pBI && (pBI = pBF))
- {
- m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
- m_wndStatsBar.SetLine(_T("Bitrate"), info); // FIXME: shouldn't be here
- RecalcLayout();
- }
- }
- EndEnumFilters
+ CString info('-');
+
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(!pQP && (pQP = pBF))
+ {
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
+ m_wndStatsBar.SetLine(_T("Sync Offset"), info);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
+ m_wndStatsBar.SetLine(_T("Jitter"), info);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
+ m_wndStatsBar.SetLine(_T("Bitrate"), info);
+ RecalcLayout();
+ }
+
+ if(!pBI && (pBI = pBF))
+ {
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
+ m_wndStatsBar.SetLine(_T("Bitrate"), info); // FIXME: shouldn't be here
+ RecalcLayout();
+ }
+ }
+ EndEnumFilters
}
void CMainFrame::OpenSetupStatusBar()
{
- m_wndStatusBar.ShowTimer(true);
-
- //
-
- if(!m_fCustomGraph)
- {
- UINT id = IDB_NOAUDIO;
-
- BeginEnumFilters(pGB, pEF, pBF)
- {
- CComQIPtr<IBasicAudio> pBA = pBF;
- if(!pBA) continue;
-
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(S_OK == pGB->IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK == pGB->IsPinConnected(pPin))
- {
- AM_MEDIA_TYPE mt;
- memset(&mt, 0, sizeof(mt));
- pPin->ConnectionMediaType(&mt);
-
- if(mt.majortype == MEDIATYPE_Audio && mt.formattype == FORMAT_WaveFormatEx)
- {
- switch(((WAVEFORMATEX*)mt.pbFormat)->nChannels)
- {
- case 1:
- id = IDB_MONO;
- break;
- case 2:
- default:
- id = IDB_STEREO;
- break;
- }
- break;
- }
- else if(mt.majortype == MEDIATYPE_Midi)
- {
- id = NULL;
- break;
- }
- }
- }
- EndEnumPins
-
- if(id != IDB_NOAUDIO)
- {
- break;
- }
- }
- EndEnumFilters
-
- m_wndStatusBar.SetStatusBitmap(id);
- }
-
- //
-
- HICON hIcon = NULL;
-
- if(m_iPlaybackMode == PM_FILE)
- {
- CString fn = m_wndPlaylistBar.GetCur();
- CString ext = fn.Mid(fn.ReverseFind('.') + 1);
- hIcon = LoadIcon(ext, true);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- hIcon = LoadIcon(_T(".ifo"), true);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- // hIcon = ; // TODO
- }
-
- m_wndStatusBar.SetStatusTypeIcon(hIcon);
+ m_wndStatusBar.ShowTimer(true);
+
+ //
+
+ if(!m_fCustomGraph)
+ {
+ UINT id = IDB_NOAUDIO;
+
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ CComQIPtr<IBasicAudio> pBA = pBF;
+ if(!pBA) continue;
+
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(S_OK == pGB->IsPinDirection(pPin, PINDIR_INPUT)
+ && S_OK == pGB->IsPinConnected(pPin))
+ {
+ AM_MEDIA_TYPE mt;
+ memset(&mt, 0, sizeof(mt));
+ pPin->ConnectionMediaType(&mt);
+
+ if(mt.majortype == MEDIATYPE_Audio && mt.formattype == FORMAT_WaveFormatEx)
+ {
+ switch(((WAVEFORMATEX*)mt.pbFormat)->nChannels)
+ {
+ case 1: id = IDB_MONO; break;
+ case 2: default: id = IDB_STEREO; break;
+ }
+ break;
+ }
+ else if(mt.majortype == MEDIATYPE_Midi)
+ {
+ id = NULL;
+ break;
+ }
+ }
+ }
+ EndEnumPins
+
+ if(id != IDB_NOAUDIO)
+ {
+ break;
+ }
+ }
+ EndEnumFilters
+
+ m_wndStatusBar.SetStatusBitmap(id);
+ }
+
+ //
+
+ HICON hIcon = NULL;
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CString fn = m_wndPlaylistBar.GetCur();
+ CString ext = fn.Mid(fn.ReverseFind('.')+1);
+ hIcon = LoadIcon(ext, true);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ hIcon = LoadIcon(_T(".ifo"), true);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ // hIcon = ; // TODO
+ }
+
+ m_wndStatusBar.SetStatusTypeIcon(hIcon);
}
void CMainFrame::OpenSetupWindowTitle(CString fn)
{
- CString title(MAKEINTRESOURCE(IDR_MAINFRAME));
-
- AppSettings& s = AfxGetAppSettings();
-
- int i = s.iTitleBarTextStyle;
-
- if(!fn.IsEmpty() && (i == 0 || i == 1))
- {
- if(i == 1)
- {
- if(m_iPlaybackMode == PM_FILE)
- {
- fn.Replace('\\', '/');
- CString fn2 = fn.Mid(fn.ReverseFind('/') + 1);
- if(!fn2.IsEmpty()) fn = fn2;
- if(s.fTitleBarTextTitle)
- {
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
- {
- CComBSTR bstr;
- if(SUCCEEDED(pAMMC->get_Title(&bstr)) && bstr.Length())
- {
- fn = CString(bstr.m_str);
- break;
- }
- }
- }
- EndEnumFilters
- }
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- fn = _T("DVD");
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- fn = _T("Live");
- }
- }
-
- title = fn + _T(" - ") + m_strTitle;
- }
-
- SetWindowText(title);
- m_Lcd.SetMediaTitle(LPCTSTR(fn));
+ CString title(MAKEINTRESOURCE(IDR_MAINFRAME));
+
+ AppSettings& s = AfxGetAppSettings();
+
+ int i = s.iTitleBarTextStyle;
+
+ if(!fn.IsEmpty() && (i == 0 || i == 1))
+ {
+ if(i == 1)
+ {
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ fn.Replace('\\', '/');
+ CString fn2 = fn.Mid(fn.ReverseFind('/')+1);
+ if(!fn2.IsEmpty()) fn = fn2;
+ if(s.fTitleBarTextTitle)
+ {
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
+ {
+ CComBSTR bstr;
+ if(SUCCEEDED(pAMMC->get_Title(&bstr)) && bstr.Length())
+ {
+ fn = CString(bstr.m_str);
+ break;
+ }
+ }
+ }
+ EndEnumFilters
+ }
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ fn = _T("DVD");
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ fn = _T("Live");
+ }
+ }
+
+ title = fn + _T(" - ") + m_strTitle;
+ }
+
+ SetWindowText(title);
+ m_Lcd.SetMediaTitle(LPCTSTR(fn));
}
// foxX: simply global now, figures out if, based on the options selected by the user
// the language of audio stream a from pSS is more ``important" than that of audio b
bool DoesAudioPrecede(const CComPtr<IAMStreamSelect> &pSS, int a, int b)
{
- WCHAR* pName = NULL;
- if(FAILED(pSS->Info(a, NULL, NULL, NULL, NULL, &pName, NULL, NULL)))
- return false;
- CString nameA(pName);
- nameA = nameA.Mid(nameA.ReverseFind('/') + 2);
- CoTaskMemFree(pName);
-
- if(FAILED(pSS->Info(b, NULL, NULL, NULL, NULL, &pName, NULL, NULL)))
- return false;
- CString nameB(pName);
- nameB = nameB.Mid(nameB.ReverseFind('/') + 2);
- CoTaskMemFree(pName);
-
- int ia = -1;
- int ib = -1;
- CStringW alo = AfxGetAppSettings().m_audiosLanguageOrder;
- int tPos = 0;
- CStringW lang = alo.Tokenize(_T(",; "), tPos);
- while(tPos != -1 && ia == -1 && ib == -1)
- {
- int ll = lang.GetLength();
- if(nameA.Left(ll).CompareNoCase(lang) == 0)
- ia = tPos;
- if(nameB.Left(ll).CompareNoCase(lang) == 0)
- ib = tPos;
- lang = alo.Tokenize(_T(",; "), tPos);
- }
- if(ia != -1 && ib == -1)
- return true;
- return false;
-
- return false;
+ WCHAR* pName = NULL;
+ if(FAILED(pSS->Info(a, NULL, NULL, NULL, NULL, &pName, NULL, NULL)))
+ return false;
+ CString nameA(pName);
+ nameA = nameA.Mid(nameA.ReverseFind('/') + 2);
+ CoTaskMemFree(pName);
+
+ if(FAILED(pSS->Info(b, NULL, NULL, NULL, NULL, &pName, NULL, NULL)))
+ return false;
+ CString nameB(pName);
+ nameB = nameB.Mid(nameB.ReverseFind('/') + 2);
+ CoTaskMemFree(pName);
+
+ int ia = -1;
+ int ib = -1;
+ CStringW alo = AfxGetAppSettings().m_audiosLanguageOrder;
+ int tPos = 0;
+ CStringW lang = alo.Tokenize(_T(",; "), tPos);
+ while(tPos != -1 && ia == -1 && ib == -1)
+ {
+ int ll = lang.GetLength();
+ if(nameA.Left(ll).CompareNoCase(lang) == 0)
+ ia = tPos;
+ if(nameB.Left(ll).CompareNoCase(lang) == 0)
+ ib = tPos;
+ lang = alo.Tokenize(_T(",; "), tPos);
+ }
+ if(ia != -1 && ib == -1)
+ return true;
+ return false;
+
+ return false;
}
// foxX: does the naive insertion, in a separate list of audio streams indexes, of stream number i
// from the original ordering of audio streams, based on language order preference
void CMainFrame::InsertAudioStream(const CComQIPtr<IAMStreamSelect> &pSS, int i)
{
- POSITION pos = m_iAudioStreams.GetHeadPosition();
- bool processed = false;
- while(!processed && pos)
- {
- POSITION prevPos = pos;
- int j = m_iAudioStreams.GetNext(pos);
- if(DoesAudioPrecede(pSS, i, j))
- {
- if(prevPos == m_iAudioStreams.GetHeadPosition())
- m_iAudioStreams.AddHead(i);
- else
- m_iAudioStreams.InsertBefore(prevPos, i);
- processed = true;
- }
- }
- if(!processed)
- m_iAudioStreams.AddTail(i);
+ POSITION pos = m_iAudioStreams.GetHeadPosition();
+ bool processed = false;
+ while(!processed && pos)
+ {
+ POSITION prevPos = pos;
+ int j = m_iAudioStreams.GetNext(pos);
+ if(DoesAudioPrecede(pSS, i, j))
+ {
+ if(prevPos == m_iAudioStreams.GetHeadPosition())
+ m_iAudioStreams.AddHead(i);
+ else
+ m_iAudioStreams.InsertBefore(prevPos, i);
+ processed = true;
+ }
+ }
+ if(!processed)
+ m_iAudioStreams.AddTail(i);
}
// foxX: creates a mapping of audio streams, where they're ordered based on their language and the user language order options
void CMainFrame::SetupAudioStreams()
{
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
- DWORD cStreams = 0;
- if(pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0)
- {
- for(int i = 0; i < (int)cStreams; i++)
- {
- InsertAudioStream(pSS, i);
- }
- }
+ DWORD cStreams = 0;
+ if(pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0)
+ {
+ for(int i = 0; i < (int)cStreams; i++)
+ {
+ InsertAudioStream(pSS, i);
+ }
+ }
}
bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if(m_iMediaLoadState != MLS_CLOSED)
- {
- ASSERT(0);
- return(false);
- }
+ if(m_iMediaLoadState != MLS_CLOSED)
+ {
+ ASSERT(0);
+ return(false);
+ }
- if(!dynamic_cast<OpenFileData*>(pOMD.m_p)
- && !dynamic_cast<OpenDVDData*>(pOMD.m_p)
- && !dynamic_cast<OpenDeviceData*>(pOMD.m_p))
- {
- ASSERT(0);
- return(false);
- }
+ if(!dynamic_cast<OpenFileData*>(pOMD.m_p)
+ && !dynamic_cast<OpenDVDData*>(pOMD.m_p)
+ && !dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ {
+ ASSERT(0);
+ return(false);
+ }
#ifdef _DEBUG
- // Debug trace code - Begin
- // Check for bad / buggy auto loading file code
- if(OpenFileData *pOFD = dynamic_cast<OpenFileData *>(pOMD.m_p))
- {
- POSITION pos = pOFD->fns.GetHeadPosition();
- UINT index = 0;
- while(pos != NULL)
- {
- CString path = pOFD->fns.GetNext(pos);
- TRACE("--> CMainFrame::OpenMediaPrivate - pOFD->fns[%d]: %ws\n", index, path.GetString()); // %ws - wide character string always
- index++;
- }
- }
- // Debug trace code - End
+ // Debug trace code - Begin
+ // Check for bad / buggy auto loading file code
+ if ( OpenFileData *pOFD = dynamic_cast<OpenFileData *>(pOMD.m_p) )
+ {
+ POSITION pos = pOFD->fns.GetHeadPosition();
+ UINT index = 0;
+ while ( pos != NULL )
+ {
+ CString path = pOFD->fns.GetNext( pos );
+ TRACE("--> CMainFrame::OpenMediaPrivate - pOFD->fns[%d]: %ws\n", index, path.GetString()); // %ws - wide character string always
+ index++;
+ }
+ }
+ // Debug trace code - End
#endif
- if(OpenFileData* pOFD = dynamic_cast<OpenFileData*>(pOMD.m_p))
- {
- if(pOFD->fns.IsEmpty())
- return(false);
-
- CString fn = pOFD->fns.GetHead();
-
- int i = fn.Find(_T(":\\"));
- if(i > 0)
- {
- CString drive = fn.Left(i + 2);
- UINT type = GetDriveType(drive);
- CAtlList<CString> sl;
- if(type == DRIVE_REMOVABLE || type == DRIVE_CDROM && GetCDROMType(drive[0], sl) != CDROM_Audio)
- {
- int ret = IDRETRY;
- while(ret == IDRETRY)
- {
- WIN32_FIND_DATA findFileData;
- HANDLE h = FindFirstFile(fn, &findFileData);
- if(h != INVALID_HANDLE_VALUE)
- {
- FindClose(h);
- ret = IDOK;
- }
- else
- {
- CString msg;
- msg.Format(ResStr(IDS_MAINFRM_114), fn);
- ret = AfxMessageBox(msg, MB_RETRYCANCEL);
- }
- }
-
- if(ret != IDOK)
- return(false);
- }
- }
- }
-
- SetLoadState(MLS_LOADING);
-
- // FIXME: Don't show "Closed" initially
- PostMessage(WM_KICKIDLE);
-
- CString err, aborted(ResStr(IDS_AG_ABORTED));
-
- m_fUpdateInfoBar = false;
-
- try
- {
- CComPtr<IVMRMixerBitmap9> pVMB;
- CComPtr<IMFVideoMixerBitmap> pMFVMB;
- if(m_fOpeningAborted) throw aborted;
-
- OpenCreateGraphObject(pOMD);
-
- if(m_fOpeningAborted) throw aborted;
-
- SetupIViAudReg();
-
- if(m_fOpeningAborted) throw aborted;
-
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p)) OpenFile(p);
- else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD.m_p)) OpenDVD(p);
- else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
- {
- if(s.iDefaultCaptureDevice == 1)
- OpenBDAGraph();
- else
- OpenCapture(p);
- }
- else throw _T("Can't open, invalid input parameters");
-
- m_pCAP2 = NULL;
- m_pCAP = NULL;
-
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
- pGB->FindInterface(__uuidof(IVMRMixerControl9), (void**)&m_pMC, TRUE);
- pGB->FindInterface(__uuidof(IVMRMixerBitmap9), (void**)&pVMB, TRUE);
- pGB->FindInterface(__uuidof(IMFVideoMixerBitmap), (void**)&pMFVMB, TRUE);
- if(pVMB && s.fShowOSD)
- m_OSD.Start(m_pVideoWnd, pVMB);
- else if(pMFVMB && s.fShowOSD)
- m_OSD.Start(m_pVideoWnd, pMFVMB);
- if(m_pMC)
- {
- m_pMC->GetProcAmpControlRange(0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl(Brightness));
- m_pMC->GetProcAmpControlRange(0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl(Contrast));
- m_pMC->GetProcAmpControlRange(0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl(Hue));
- m_pMC->GetProcAmpControlRange(0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl(Saturation));
- SetVMR9ColorControl(s.dBrightness, s.dContrast, s.dHue, s.dSaturation);
- }
-
- // === EVR !
- pGB->FindInterface(__uuidof(IMFVideoDisplayControl), (void**)&m_pMFVDC, TRUE);
- if(m_pMFVDC)
- {
- RECT Rect;
- ::GetClientRect(m_pVideoWnd->m_hWnd, &Rect);
- m_pMFVDC->SetVideoWindow(m_pVideoWnd->m_hWnd);
- m_pMFVDC->SetVideoPosition(NULL, &Rect);
- }
-
- if(m_fOpeningAborted) throw aborted;
-
- OpenCustomizeGraph();
-
- if(m_fOpeningAborted) throw aborted;
-
- OpenSetupVideo();
-
- if(m_fOpeningAborted) throw aborted;
-
- OpenSetupAudio();
-
- if(m_fOpeningAborted) throw aborted;
-
- if(m_pCAP && (!m_fAudioOnly || m_fRealMediaGraph))
- {
- POSITION pos = pOMD->subs.GetHeadPosition();
- while(pos) LoadSubtitle(pOMD->subs.GetNext(pos));
-
- if(AfxGetAppSettings().fEnableSubtitles && m_pSubStreams.GetCount() > 0)
- SetSubtitle(m_pSubStreams.GetHead());
- }
-
- if(m_fOpeningAborted) throw aborted;
-
- OpenSetupWindowTitle(pOMD->title);
-
- if(s.fEnableEDLEditor)
- m_wndEditListEditor.OpenFile(pOMD->title);
-
- if(::GetCurrentThreadId() == AfxGetApp()->m_nThreadID)
- {
- OnFilePostOpenmedia();
- }
- else
- {
- PostMessage(WM_COMMAND, ID_FILE_POST_OPENMEDIA);
- }
-
- while(m_iMediaLoadState != MLS_LOADED
- && m_iMediaLoadState != MLS_CLOSING // FIXME
- )
- {
- Sleep(50);
- }
-
- SetupAudioStreams(); // reorder audio streams so that they're according to user's options
-
- // PostMessage instead of SendMessage because the user might call CloseMedia and then we would deadlock
-
- PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- if(!(AfxGetAppSettings().nCLSwitches & CLSW_OPEN))
- PostMessage(WM_COMMAND, ID_PLAY_PLAY);
-
- // foxX: i haven't figured out how audio starts playing
- // so i'll leave it do its stuff, and after some time passes i simply switch the audio stream
- // to the one prefered by the user from options
- // hack :(
- if(m_iAudioStreams.GetCount() > 0)
- PostMessage(WM_COMMAND, ID_AUDIO_SUBITEM_START + 1);
-
- AfxGetAppSettings().nCLSwitches &= ~CLSW_OPEN;
-
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p))
- {
- if(p->rtStart > 0)
- PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_FILE, (LPARAM)(p->rtStart / 10000)); // REFERENCE_TIME doesn't fit in LPARAM under a 32bit env.
- }
- else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD.m_p))
- {
- if(p->pDvdState)
- PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_DVD, (LPARAM)(CComPtr<IDvdState>(p->pDvdState).Detach())); // must be released by the called message handler
- }
- else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
- {
- m_wndCaptureBar.m_capdlg.SetVideoInput(p->vinput);
- m_wndCaptureBar.m_capdlg.SetVideoChannel(p->vchannel);
- m_wndCaptureBar.m_capdlg.SetAudioInput(p->ainput);
- }
- }
- catch(LPCTSTR msg)
- {
- err = msg;
- }
- catch(CString msg)
- {
- err = msg;
- }
-
- if(!err.IsEmpty())
- {
- CloseMediaPrivate();
- m_closingmsg = err;
-
- OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p);
- if(p && err != aborted)
- {
- m_wndPlaylistBar.SetCurValid(false);
- if(m_wndPlaylistBar.GetCount() > 1)
- {
- CPlaylistItem pli[2];
- m_wndPlaylistBar.GetCur(pli[0]);
- m_wndPlaylistBar.SetNext();
- m_wndPlaylistBar.GetCur(pli[1]);
- if(pli[0].m_id != pli[1].m_id)
- {
- CAutoPtr<OpenMediaData> p(m_wndPlaylistBar.GetCurOMD());
- if(p) OpenMediaPrivate(p);
- }
- }
- }
- }
- else
- {
- m_wndPlaylistBar.SetCurValid(true);
-
- // Apply command line audio shift
- if(s.rtShift != 0)
- {
- SetAudioDelay(s.rtShift);
- s.rtShift = 0;
- }
- }
-
- if(AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && m_fFullScreen) AutoChangeMonitorMode();
- if(m_fFullScreen && AfxGetAppSettings().fRememberZoomLevel) m_fFirstFSAfterLaunchOnFS = true;
-
- m_LastOpenFile = pOMD->title;
-
- PostMessage(WM_KICKIDLE); // calls main thread to update things
-
- return(err.IsEmpty());
+ if(OpenFileData* pOFD = dynamic_cast<OpenFileData*>(pOMD.m_p))
+ {
+ if(pOFD->fns.IsEmpty())
+ return(false);
+
+ CString fn = pOFD->fns.GetHead();
+
+ int i = fn.Find(_T(":\\"));
+ if(i > 0)
+ {
+ CString drive = fn.Left(i+2);
+ UINT type = GetDriveType(drive);
+ CAtlList<CString> sl;
+ if(type == DRIVE_REMOVABLE || type == DRIVE_CDROM && GetCDROMType(drive[0], sl) != CDROM_Audio)
+ {
+ int ret = IDRETRY;
+ while(ret == IDRETRY)
+ {
+ WIN32_FIND_DATA findFileData;
+ HANDLE h = FindFirstFile(fn, &findFileData);
+ if(h != INVALID_HANDLE_VALUE)
+ {
+ FindClose(h);
+ ret = IDOK;
+ }
+ else
+ {
+ CString msg;
+ msg.Format(ResStr(IDS_MAINFRM_114), fn);
+ ret = AfxMessageBox(msg, MB_RETRYCANCEL);
+ }
+ }
+
+ if(ret != IDOK)
+ return(false);
+ }
+ }
+ }
+
+ SetLoadState (MLS_LOADING);
+
+ // FIXME: Don't show "Closed" initially
+ PostMessage(WM_KICKIDLE);
+
+ CString err, aborted(ResStr(IDS_AG_ABORTED));
+
+ m_fUpdateInfoBar = false;
+
+ try
+ {
+ CComPtr<IVMRMixerBitmap9> pVMB;
+ CComPtr<IMFVideoMixerBitmap> pMFVMB;
+ if(m_fOpeningAborted) throw aborted;
+
+ OpenCreateGraphObject(pOMD);
+
+ if(m_fOpeningAborted) throw aborted;
+
+ SetupIViAudReg();
+
+ if(m_fOpeningAborted) throw aborted;
+
+ if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p)) OpenFile(p);
+ else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD.m_p)) OpenDVD(p);
+ else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ {
+ if (s.iDefaultCaptureDevice == 1)
+ OpenBDAGraph();
+ else
+ OpenCapture(p);
+ }
+ else throw _T("Can't open, invalid input parameters");
+
+ m_pCAP2 = NULL;
+ m_pCAP = NULL;
+
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
+ pGB->FindInterface(__uuidof(IVMRMixerControl9), (void**)&m_pMC, TRUE);
+ pGB->FindInterface(__uuidof(IVMRMixerBitmap9), (void**)&pVMB, TRUE);
+ pGB->FindInterface(__uuidof(IMFVideoMixerBitmap), (void**)&pMFVMB, TRUE);
+ if (pVMB && s.fShowOSD)
+ m_OSD.Start (m_pVideoWnd, pVMB);
+ else if (pMFVMB && s.fShowOSD)
+ m_OSD.Start (m_pVideoWnd, pMFVMB);
+ if (m_pMC)
+ {
+ m_pMC->GetProcAmpControlRange (0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl (Brightness));
+ m_pMC->GetProcAmpControlRange (0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl (Contrast));
+ m_pMC->GetProcAmpControlRange (0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl (Hue));
+ m_pMC->GetProcAmpControlRange (0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl (Saturation));
+ SetVMR9ColorControl(s.dBrightness, s.dContrast, s.dHue, s.dSaturation);
+ }
+
+ // === EVR !
+ pGB->FindInterface(__uuidof(IMFVideoDisplayControl), (void**)&m_pMFVDC, TRUE);
+ if (m_pMFVDC)
+ {
+ RECT Rect;
+ ::GetClientRect (m_pVideoWnd->m_hWnd, &Rect);
+ m_pMFVDC->SetVideoWindow (m_pVideoWnd->m_hWnd);
+ m_pMFVDC->SetVideoPosition(NULL, &Rect);
+ }
+
+ if(m_fOpeningAborted) throw aborted;
+
+ OpenCustomizeGraph();
+
+ if(m_fOpeningAborted) throw aborted;
+
+ OpenSetupVideo();
+
+ if(m_fOpeningAborted) throw aborted;
+
+ OpenSetupAudio();
+
+ if(m_fOpeningAborted) throw aborted;
+
+ if(m_pCAP && (!m_fAudioOnly || m_fRealMediaGraph))
+ {
+ POSITION pos = pOMD->subs.GetHeadPosition();
+ while(pos) LoadSubtitle(pOMD->subs.GetNext(pos));
+
+ if(AfxGetAppSettings().fEnableSubtitles && m_pSubStreams.GetCount() > 0)
+ SetSubtitle(m_pSubStreams.GetHead());
+ }
+
+ if(m_fOpeningAborted) throw aborted;
+
+ OpenSetupWindowTitle(pOMD->title);
+
+ if (s.fEnableEDLEditor)
+ m_wndEditListEditor.OpenFile(pOMD->title);
+
+ if(::GetCurrentThreadId() == AfxGetApp()->m_nThreadID)
+ {
+ OnFilePostOpenmedia();
+ }
+ else
+ {
+ PostMessage(WM_COMMAND, ID_FILE_POST_OPENMEDIA);
+ }
+
+ while(m_iMediaLoadState != MLS_LOADED
+ && m_iMediaLoadState != MLS_CLOSING // FIXME
+ )
+ {
+ Sleep(50);
+ }
+
+ SetupAudioStreams(); // reorder audio streams so that they're according to user's options
+
+ // PostMessage instead of SendMessage because the user might call CloseMedia and then we would deadlock
+
+ PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ if(!(AfxGetAppSettings().nCLSwitches&CLSW_OPEN))
+ PostMessage(WM_COMMAND, ID_PLAY_PLAY);
+
+ // foxX: i haven't figured out how audio starts playing
+ // so i'll leave it do its stuff, and after some time passes i simply switch the audio stream
+ // to the one prefered by the user from options
+ // hack :(
+ if(m_iAudioStreams.GetCount() > 0)
+ PostMessage(WM_COMMAND, ID_AUDIO_SUBITEM_START + 1);
+
+ AfxGetAppSettings().nCLSwitches &= ~CLSW_OPEN;
+
+ if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p))
+ {
+ if(p->rtStart > 0)
+ PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_FILE, (LPARAM)(p->rtStart/10000)); // REFERENCE_TIME doesn't fit in LPARAM under a 32bit env.
+ }
+ else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD.m_p))
+ {
+ if(p->pDvdState)
+ PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_DVD, (LPARAM)(CComPtr<IDvdState>(p->pDvdState).Detach())); // must be released by the called message handler
+ }
+ else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ {
+ m_wndCaptureBar.m_capdlg.SetVideoInput(p->vinput);
+ m_wndCaptureBar.m_capdlg.SetVideoChannel(p->vchannel);
+ m_wndCaptureBar.m_capdlg.SetAudioInput(p->ainput);
+ }
+ }
+ catch(LPCTSTR msg)
+ {
+ err = msg;
+ }
+ catch(CString msg)
+ {
+ err = msg;
+ }
+
+ if(!err.IsEmpty())
+ {
+ CloseMediaPrivate();
+ m_closingmsg = err;
+
+ OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p);
+ if(p && err != aborted)
+ {
+ m_wndPlaylistBar.SetCurValid(false);
+ if(m_wndPlaylistBar.GetCount() > 1)
+ {
+ CPlaylistItem pli[2];
+ m_wndPlaylistBar.GetCur(pli[0]);
+ m_wndPlaylistBar.SetNext();
+ m_wndPlaylistBar.GetCur(pli[1]);
+ if(pli[0].m_id != pli[1].m_id)
+ {
+ CAutoPtr<OpenMediaData> p(m_wndPlaylistBar.GetCurOMD());
+ if(p) OpenMediaPrivate(p);
+ }
+ }
+ }
+ }
+ else
+ {
+ m_wndPlaylistBar.SetCurValid(true);
+
+ // Apply command line audio shift
+ if (s.rtShift != 0)
+ {
+ SetAudioDelay (s.rtShift);
+ s.rtShift = 0;
+ }
+ }
+
+ if (AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && m_fFullScreen) AutoChangeMonitorMode();
+ if (m_fFullScreen && AfxGetAppSettings().fRememberZoomLevel) m_fFirstFSAfterLaunchOnFS = true;
+
+ m_LastOpenFile = pOMD->title;
+
+ PostMessage(WM_KICKIDLE); // calls main thread to update things
+
+ return(err.IsEmpty());
}
void CMainFrame::CloseMediaPrivate()
{
- SetLoadState(MLS_CLOSING);
+ SetLoadState (MLS_CLOSING);
OnPlayStop(); // SendMessage(WM_COMMAND, ID_PLAY_STOP);
- m_iPlaybackMode = PM_NONE;
- m_iSpeedLevel = 0;
+ m_iPlaybackMode = PM_NONE;
+ m_iSpeedLevel = 0;
- m_fLiveWM = false;
+ m_fLiveWM = false;
- m_fEndOfStream = false;
+ m_fEndOfStream = false;
- m_rtDurationOverride = -1;
+ m_rtDurationOverride = -1;
- m_kfs.RemoveAll();
+ m_kfs.RemoveAll();
- m_pCB = NULL;
+ m_pCB = NULL;
// if(pVW) pVW->put_Visible(OAFALSE);
// if(pVW) pVW->put_MessageDrain((OAHWND)NULL), pVW->put_Owner((OAHWND)NULL);
- m_pCAP = NULL; // IMPORTANT: IVMRSurfaceAllocatorNotify/IVMRSurfaceAllocatorNotify9 has to be released before the VMR/VMR9, otherwise it will crash in Release()
- m_pCAP2 = NULL;
- m_pMC = NULL;
- m_pMFVDC = NULL;
- m_OSD.Stop();
-
- pAMXBar.Release();
- pAMTuner.Release();
- pAMDF.Release();
- pAMVCCap.Release();
- pAMVCPrev.Release();
- pAMVSCCap.Release();
- pAMVSCPrev.Release();
- pAMASC.Release();
- pVidCap.Release();
- pAudCap.Release();
- pCGB.Release();
- pDVDC.Release();
- pDVDI.Release();
- pQP.Release();
- pBI.Release();
- pAMOP.Release();
- pFS.Release();
- pMC.Release();
- pME.Release();
- pMS.Release();
- pVW.Release();
- pBV.Release();
- pBA.Release();
-
- if(pGB)
- {
- pGB->RemoveFromROT();
- pGB.Release();
- }
+ m_pCAP = NULL; // IMPORTANT: IVMRSurfaceAllocatorNotify/IVMRSurfaceAllocatorNotify9 has to be released before the VMR/VMR9, otherwise it will crash in Release()
+ m_pCAP2 = NULL;
+ m_pMC = NULL;
+ m_pMFVDC = NULL;
+ m_OSD.Stop();
- if(m_pFullscreenWnd->IsWindow())
- m_pFullscreenWnd->DestroyWindow(); // TODO : still freezing sometimes...
+ pAMXBar.Release(); pAMTuner.Release(); pAMDF.Release();
+ pAMVCCap.Release(); pAMVCPrev.Release(); pAMVSCCap.Release(); pAMVSCPrev.Release(); pAMASC.Release();
+ pVidCap.Release(); pAudCap.Release();
+ pCGB.Release();
+ pDVDC.Release(); pDVDI.Release();
+ pQP.Release(); pBI.Release(); pAMOP.Release(); pFS.Release();
+ pMC.Release(); pME.Release(); pMS.Release();
+ pVW.Release(); pBV.Release();
+ pBA.Release();
- m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
+ if(pGB)
+ {
+ pGB->RemoveFromROT();
+ pGB.Release();
+ }
+
+ if (m_pFullscreenWnd->IsWindow())
+ m_pFullscreenWnd->DestroyWindow(); // TODO : still freezing sometimes...
- m_pSubClock = NULL;
+ m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
- m_pProv.Release();
+ m_pSubClock = NULL;
- {
- CAutoLock cAutoLock(&m_csSubLock);
- m_pSubStreams.RemoveAll();
- }
+ m_pProv.Release();
+
+ {
+ CAutoLock cAutoLock(&m_csSubLock);
+ m_pSubStreams.RemoveAll();
+ }
- m_VidDispName.Empty();
- m_AudDispName.Empty();
+ m_VidDispName.Empty();
+ m_AudDispName.Empty();
- m_closingmsg = ResStr(IDS_CONTROLS_CLOSED);
+ m_closingmsg = ResStr(IDS_CONTROLS_CLOSED);
- AfxGetAppSettings().nCLSwitches &= CLSW_OPEN | CLSW_PLAY | CLSW_AFTERPLAYBACK_MASK | CLSW_NOFOCUS;
- AfxGetAppSettings().ResetPositions();
+ AfxGetAppSettings().nCLSwitches &= CLSW_OPEN|CLSW_PLAY|CLSW_AFTERPLAYBACK_MASK|CLSW_NOFOCUS;
+ AfxGetAppSettings().ResetPositions();
- SetLoadState(MLS_CLOSED);
+ SetLoadState (MLS_CLOSED);
}
int CMainFrame::SearchInDir(bool DirForward)
{
- CAtlList<CString> Play_sl;
- CAtlList<CString> sl;
- Play_sl.RemoveAll();
- sl.RemoveAll();
-
- CMediaFormats& mf = AfxGetAppSettings().Formats;
-
- CString dir = m_LastOpenFile.Mid(0, m_LastOpenFile.ReverseFind('\\') + 1);
- CString mask = dir + _T("*.*");
- WIN32_FIND_DATA fd;
- HANDLE h = FindFirstFile(mask, &fd);
- if(h != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
-
- CString fn = fd.cFileName;
- CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
- CString path = dir + fd.cFileName;
- if(mf.FindExt(ext))
- {
- for(int i = 0; i < mf.GetCount(); i++)
- {
- sl.AddTail(path);
- break;
- }
- }
- }
- while(FindNextFile(h, &fd));
- FindClose(h);
- }
-
- if(sl.GetCount() == 1) return true;
-
- POSITION Pos;
- Pos = sl.Find(m_LastOpenFile);
- if(DirForward)
- {
- if(Pos == sl.GetTailPosition()) return(false);
- sl.GetNext(Pos);
-
- }
- else
- {
- if(Pos == sl.GetHeadPosition()) return(false);
- sl.GetPrev(Pos);
- }
- Play_sl.AddHead(sl.GetAt(Pos));
- m_wndPlaylistBar.Open(Play_sl, false);
- OpenCurPlaylistItem();
- return(sl.GetCount());
+ CAtlList<CString> Play_sl;
+ CAtlList<CString> sl;
+ Play_sl.RemoveAll();
+ sl.RemoveAll();
+
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+
+ CString dir = m_LastOpenFile.Mid(0,m_LastOpenFile.ReverseFind('\\')+1);
+ CString mask = dir + _T("*.*");
+ WIN32_FIND_DATA fd;
+ HANDLE h = FindFirstFile(mask, &fd);
+ if(h != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
+
+ CString fn = fd.cFileName;
+ CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
+ CString path = dir + fd.cFileName;
+ if(mf.FindExt(ext))
+ {
+ for(int i = 0; i < mf.GetCount(); i++)
+ {
+ sl.AddTail(path);
+ break;
+ }
+ }
+ }
+ while(FindNextFile(h, &fd));
+ FindClose(h);
+ }
+
+ if(sl.GetCount() == 1) return true;
+
+ POSITION Pos;
+ Pos = sl.Find(m_LastOpenFile);
+ if (DirForward)
+ {
+ if (Pos == sl.GetTailPosition()) return(false);
+ sl.GetNext(Pos);
+
+ }
+ else
+ {
+ if (Pos == sl.GetHeadPosition()) return(false);
+ sl.GetPrev(Pos);
+ }
+ Play_sl.AddHead(sl.GetAt(Pos));
+ m_wndPlaylistBar.Open(Play_sl,false);
+ OpenCurPlaylistItem();
+ return(sl.GetCount());
}
void CMainFrame::DoTunerScan(TunerScanData* pTSD)
{
- if(m_iPlaybackMode == PM_CAPTURE)
- {
- CComQIPtr<IBDATuner> pTun = pGB;
- if(pTun)
- {
- BOOLEAN bPresent;
- BOOLEAN bLocked;
- LONG lStrength;
- LONG lQuality;
- int nProgress;
- m_bStopTunerScan = false;
- for(ULONG ulFrequency = pTSD->FrequencyStart; ulFrequency <= pTSD->FrequencyStop; ulFrequency += pTSD->Bandwidth)
- {
- pTun->SetFrequency(ulFrequency);
- Sleep(200);
- if(SUCCEEDED(pTun->GetStats(bPresent, bLocked, lStrength, lQuality)) && bPresent)
- {
- ::SendMessage(pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
- pTun->Scan(ulFrequency, pTSD->Hwnd);
- }
-
- nProgress = MulDiv(ulFrequency - pTSD->FrequencyStart, 100, pTSD->FrequencyStop - pTSD->FrequencyStart);
- ::SendMessage(pTSD->Hwnd, WM_TUNER_SCAN_PROGRESS, nProgress, 0);
- ::SendMessage(pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
- if(m_bStopTunerScan) break;
- }
-
- ::SendMessage(pTSD->Hwnd, WM_TUNER_SCAN_END, 0, 0);
- }
- }
+ if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun)
+ {
+ BOOLEAN bPresent;
+ BOOLEAN bLocked;
+ LONG lStrength;
+ LONG lQuality;
+ int nProgress;
+ m_bStopTunerScan = false;
+ for(ULONG ulFrequency = pTSD->FrequencyStart; ulFrequency <= pTSD->FrequencyStop; ulFrequency += pTSD->Bandwidth)
+ {
+ pTun->SetFrequency (ulFrequency);
+ Sleep (200);
+ if (SUCCEEDED (pTun->GetStats (bPresent, bLocked, lStrength, lQuality)) && bPresent)
+ {
+ ::SendMessage (pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
+ pTun->Scan (ulFrequency, pTSD->Hwnd);
+ }
+
+ nProgress = MulDiv(ulFrequency-pTSD->FrequencyStart, 100, pTSD->FrequencyStop-pTSD->FrequencyStart);
+ ::SendMessage (pTSD->Hwnd, WM_TUNER_SCAN_PROGRESS, nProgress,0);
+ ::SendMessage (pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
+ if (m_bStopTunerScan) break;
+ }
+
+ ::SendMessage (pTSD->Hwnd, WM_TUNER_SCAN_END, 0, 0);
+ }
+ }
}
// msn
void CMainFrame::SendNowPlayingToMSN()
{
- if(!AfxGetAppSettings().fNotifyMSN)
- return;
-
- CString title, author;
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
-
- if(title.IsEmpty())
- {
- CPlaylistItem pli;
- m_wndPlaylistBar.GetCur(pli);
-
- if(!pli.m_fns.IsEmpty())
- {
- CString label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
-
- if(m_iPlaybackMode == PM_FILE)
- {
- CString fn = label;
- if(fn.Find(_T("://")) >= 0)
- {
- int i = fn.Find('?');
- if(i >= 0) fn = fn.Left(i);
- }
- CPath path(fn);
- path.StripPath();
- path.MakePretty();
- path.RemoveExtension();
- title = (LPCTSTR)path;
- author.Empty();
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- title = label != pli.m_fns.GetHead() ? label : _T("Live");
- author.Empty();
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- title = _T("DVD");
- author.Empty();
- }
- }
- }
- }
-
- CStringW buff;
- buff += L"\\0Music\\0";
- buff += title.IsEmpty() ? L"0" : L"1";
- buff += L"\\0";
- buff += author.IsEmpty() ? L"{0}" : L"{0} - {1}";
- buff += L"\\0";
- if(!author.IsEmpty())
- {
- buff += CStringW(author) + L"\\0";
- }
- buff += CStringW(title) + L"\\0";
- buff += L"\\0\\0";
-
- COPYDATASTRUCT data;
+ if(!AfxGetAppSettings().fNotifyMSN)
+ return;
+
+ CString title, author;
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
+
+ if(title.IsEmpty())
+ {
+ CPlaylistItem pli;
+ m_wndPlaylistBar.GetCur(pli);
+
+ if(!pli.m_fns.IsEmpty())
+ {
+ CString label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CString fn = label;
+ if(fn.Find(_T("://")) >= 0) {int i = fn.Find('?'); if(i >= 0) fn = fn.Left(i);}
+ CPath path(fn);
+ path.StripPath();
+ path.MakePretty();
+ path.RemoveExtension();
+ title = (LPCTSTR)path;
+ author.Empty();
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ title = label != pli.m_fns.GetHead() ? label : _T("Live");
+ author.Empty();
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ title = _T("DVD");
+ author.Empty();
+ }
+ }
+ }
+ }
+
+ CStringW buff;
+ buff += L"\\0Music\\0";
+ buff += title.IsEmpty() ? L"0" : L"1";
+ buff += L"\\0";
+ buff += author.IsEmpty() ? L"{0}" : L"{0} - {1}";
+ buff += L"\\0";
+ if(!author.IsEmpty()) {buff += CStringW(author) + L"\\0";}
+ buff += CStringW(title) + L"\\0";
+ buff += L"\\0\\0";
+
+ COPYDATASTRUCT data;
data.dwData = 0x0547;
data.lpData = (PVOID)(LPCWSTR)buff;
data.cbData = buff.GetLength() * 2 + 2;
- HWND hWnd = NULL;
- while(hWnd = ::FindWindowEx(NULL, hWnd, _T("MsnMsgrUIManager"), NULL))
- ::SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&data);
+ HWND hWnd = NULL;
+ while(hWnd = ::FindWindowEx(NULL, hWnd, _T("MsnMsgrUIManager"), NULL))
+ ::SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&data);
}
// mIRC
void CMainFrame::SendNowPlayingTomIRC()
{
- if(!AfxGetAppSettings().fNotifyGTSdll)
- return;
-
- for(int i = 0; i < 20; i++)
- {
- HANDLE hFMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 1024, _T("mIRC"));
- if(!hFMap) return;
+ if(!AfxGetAppSettings().fNotifyGTSdll)
+ return;
- if(GetLastError() == ERROR_ALREADY_EXISTS)
- {
- CloseHandle(hFMap);
- Sleep(50);
- continue;
- }
+ for(int i = 0; i < 20; i++)
+ {
+ HANDLE hFMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 1024, _T("mIRC"));
+ if(!hFMap) return;
- if(LPVOID lpMappingAddress = MapViewOfFile(hFMap, FILE_MAP_WRITE, 0, 0, 0))
- {
- LPCSTR cmd = m_fAudioOnly ? "/.timerAUDGTS 1 5 mpcaud" : "/.timerVIDGTS 1 5 mpcvid";
- strcpy((char*)lpMappingAddress, cmd);
+ if(GetLastError() == ERROR_ALREADY_EXISTS)
+ {
+ CloseHandle(hFMap);
+ Sleep(50);
+ continue;
+ }
- if(HWND hWnd = ::FindWindow(_T("mIRC"), NULL))
- ::SendMessage(hWnd, (WM_USER + 200), (WPARAM)1, (LPARAM)0);
+ if(LPVOID lpMappingAddress = MapViewOfFile(hFMap, FILE_MAP_WRITE, 0, 0, 0))
+ {
+ LPCSTR cmd = m_fAudioOnly ? "/.timerAUDGTS 1 5 mpcaud" : "/.timerVIDGTS 1 5 mpcvid";
+ strcpy((char*)lpMappingAddress, cmd);
- UnmapViewOfFile(lpMappingAddress);
- }
+ if(HWND hWnd = ::FindWindow(_T("mIRC"), NULL))
+ ::SendMessage(hWnd, (WM_USER + 200), (WPARAM)1, (LPARAM)0);
- CloseHandle(hFMap);
+ UnmapViewOfFile(lpMappingAddress);
+ }
+
+ CloseHandle(hFMap);
- break;
- }
+ break;
+ }
}
// dynamic menus
void CMainFrame::SetupOpenCDSubMenu()
{
- CMenu* pSub = &m_opencds;
+ CMenu* pSub = &m_opencds;
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
- if(m_iMediaLoadState == MLS_LOADING) return;
+ if(m_iMediaLoadState == MLS_LOADING) return;
- if(AfxGetAppSettings().fHideCDROMsSubMenu) return;
+ if(AfxGetAppSettings().fHideCDROMsSubMenu) return;
- UINT id = ID_FILE_OPEN_CD_START;
+ UINT id = ID_FILE_OPEN_CD_START;
- for(TCHAR drive = 'C'; drive <= 'Z'; drive++)
- {
- CString label = GetDriveLabel(drive), str;
+ for(TCHAR drive = 'C'; drive <= 'Z'; drive++)
+ {
+ CString label = GetDriveLabel(drive), str;
- CAtlList<CString> files;
- switch(GetCDROMType(drive, files))
- {
- case CDROM_Audio:
- if(label.IsEmpty()) label = _T("Audio CD");
- str.Format(_T("%s (%c:)"), label, drive);
- break;
- case CDROM_VideoCD:
- if(label.IsEmpty()) label = _T("(S)VCD");
- str.Format(_T("%s (%c:)"), label, drive);
- break;
- case CDROM_DVDVideo:
- if(label.IsEmpty()) label = _T("DVD Video");
- str.Format(_T("%s (%c:)"), label, drive);
- break;
- default:
- break;
- }
+ CAtlList<CString> files;
+ switch(GetCDROMType(drive, files))
+ {
+ case CDROM_Audio:
+ if(label.IsEmpty()) label = _T("Audio CD");
+ str.Format(_T("%s (%c:)"), label, drive);
+ break;
+ case CDROM_VideoCD:
+ if(label.IsEmpty()) label = _T("(S)VCD");
+ str.Format(_T("%s (%c:)"), label, drive);
+ break;
+ case CDROM_DVDVideo:
+ if(label.IsEmpty()) label = _T("DVD Video");
+ str.Format(_T("%s (%c:)"), label, drive);
+ break;
+ default:
+ break;
+ }
- if(!str.IsEmpty())
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, str);
- }
+ if(!str.IsEmpty())
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, str);
+ }
}
void CMainFrame::SetupFiltersSubMenu()
{
- CMenu* pSub = &m_filters;
-
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
-
- m_filterpopups.RemoveAll();
-
- m_pparray.RemoveAll();
- m_ssarray.RemoveAll();
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- UINT idf = 0;
- UINT ids = ID_FILTERS_SUBITEM_START;
- UINT idl = ID_FILTERSTREAMS_SUBITEM_START;
-
- BeginEnumFilters(pGB, pEF, pBF)
- {
- CString name(GetFilterName(pBF));
- if(name.GetLength() >= 43) name = name.Left(40) + _T("...");
-
- CLSID clsid = GetCLSID(pBF);
- if(clsid == CLSID_AVIDec)
- {
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- AM_MEDIA_TYPE mt;
- if(pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt)))
- {
- DWORD c = ((VIDEOINFOHEADER*)mt.pbFormat)->bmiHeader.biCompression;
- switch(c)
- {
- case BI_RGB:
- name += _T(" (RGB)");
- break;
- case BI_RLE4:
- name += _T(" (RLE4)");
- break;
- case BI_RLE8:
- name += _T(" (RLE8)");
- break;
- case BI_BITFIELDS:
- name += _T(" (BITF)");
- break;
- default:
- name.Format(_T("%s (%c%c%c%c)"),
- CString(name), (TCHAR)((c >> 0) & 0xff), (TCHAR)((c >> 8) & 0xff), (TCHAR)((c >> 16) & 0xff), (TCHAR)((c >> 24) & 0xff));
- break;
- }
- }
- }
- else if(clsid == CLSID_ACMWrapper)
- {
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- AM_MEDIA_TYPE mt;
- if(pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt)))
- {
- WORD c = ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag;
- name.Format(_T("%s (0x%04x)"), CString(name), (int)c);
- }
- }
- else if(clsid == __uuidof(CTextPassThruFilter) || clsid == __uuidof(CNullTextRenderer)
- || clsid == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) // ISCR
- {
- // hide these
- continue;
- }
-
- CAutoPtr<CMenu> pSubSub(DNew CMenu);
- pSubSub->CreatePopupMenu();
-
- int nPPages = 0;
-
- CComQIPtr<ISpecifyPropertyPages> pSPP = pBF;
-
- /* if(pSPP)
- {
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0)
- {
- */
- m_pparray.Add(pBF);
- pSubSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ids, ResStr(IDS_MAINFRM_116));
- /*
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- */
- nPPages++;
- /* }
- }
- */
- BeginEnumPins(pBF, pEP, pPin)
- {
- CString name = GetPinName(pPin);
- name.Replace(_T("&"), _T("&&"));
-
- if(pSPP = pPin)
- {
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0)
- {
- m_pparray.Add(pPin);
- pSubSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ids + nPPages, name + ResStr(IDS_MAINFRM_117));
-
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
-
- nPPages++;
- }
- }
- }
- EndEnumPins
-
- CComQIPtr<IAMStreamSelect> pSS = pBF;
- if(pSS)
- {
- DWORD nStreams = 0, flags, group, prevgroup = -1;
- LCID lcid;
- WCHAR* wname = NULL;
- CComPtr<IUnknown> pObj, pUnk;
-
- pSS->Count(&nStreams);
-
- if(nStreams > 0 && nPPages > 0) pSubSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
-
- UINT idlstart = idl;
-
- for(DWORD i = 0; i < nStreams; i++, pObj = NULL, pUnk = NULL)
- {
- m_ssarray.Add(pSS);
-
- flags = group = 0;
- wname = NULL;
- pSS->Info(i, NULL, &flags, &lcid, &group, &wname, &pObj, &pUnk);
-
- if(group != prevgroup && idl > idlstart)
- pSubSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
- prevgroup = group;
-
- if(flags & AMSTREAMSELECTINFO_EXCLUSIVE)
- {
- }
- else if(flags & AMSTREAMSELECTINFO_ENABLED)
- {
- }
-
- if(!wname)
- {
- CStringW stream(ResStr(IDS_AG_UNKNOWN_STREAM));
- wname = (WCHAR*)CoTaskMemAlloc((stream.GetLength() + 3 + 1) * sizeof(WCHAR));
- swprintf(wname, L"%s %d", stream, min(i + 1, 999));
- }
-
- CString name(wname);
- name.Replace(_T("&"), _T("&&"));
-
- pSubSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, idl++, name);
-
- CoTaskMemFree(wname);
- }
-
- if(nStreams == 0) pSS.Release();
- }
-
- if(nPPages == 1 && !pSS)
- {
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ids, name);
- }
- else
- {
- pSub->AppendMenu(MF_BYPOSITION | MF_STRING | MF_DISABLED | MF_GRAYED, idf, name);
-
- if(nPPages > 0 || pSS)
- {
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STATE | MIIM_SUBMENU;
- mii.fType = MF_POPUP;
- mii.hSubMenu = pSubSub->m_hMenu;
- mii.fState = (pSPP || pSS) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED);
- pSub->SetMenuItemInfo(idf, &mii, TRUE);
-
- m_filterpopups.Add(pSubSub);
- }
- }
-
- ids += nPPages;
- idf++;
- }
- EndEnumFilters
- }
+ CMenu* pSub = &m_filters;
+
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+
+ m_filterpopups.RemoveAll();
+
+ m_pparray.RemoveAll();
+ m_ssarray.RemoveAll();
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ UINT idf = 0;
+ UINT ids = ID_FILTERS_SUBITEM_START;
+ UINT idl = ID_FILTERSTREAMS_SUBITEM_START;
+
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ CString name(GetFilterName(pBF));
+ if(name.GetLength() >= 43) name = name.Left(40) + _T("...");
+
+ CLSID clsid = GetCLSID(pBF);
+ if(clsid == CLSID_AVIDec)
+ {
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ AM_MEDIA_TYPE mt;
+ if(pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt)))
+ {
+ DWORD c = ((VIDEOINFOHEADER*)mt.pbFormat)->bmiHeader.biCompression;
+ switch(c)
+ {
+ case BI_RGB: name += _T(" (RGB)"); break;
+ case BI_RLE4: name += _T(" (RLE4)"); break;
+ case BI_RLE8: name += _T(" (RLE8)"); break;
+ case BI_BITFIELDS: name += _T(" (BITF)"); break;
+ default: name.Format(_T("%s (%c%c%c%c)"),
+ CString(name), (TCHAR)((c>>0)&0xff), (TCHAR)((c>>8)&0xff), (TCHAR)((c>>16)&0xff), (TCHAR)((c>>24)&0xff)); break;
+ }
+ }
+ }
+ else if(clsid == CLSID_ACMWrapper)
+ {
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ AM_MEDIA_TYPE mt;
+ if(pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt)))
+ {
+ WORD c = ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag;
+ name.Format(_T("%s (0x%04x)"), CString(name), (int)c);
+ }
+ }
+ else if(clsid == __uuidof(CTextPassThruFilter) || clsid == __uuidof(CNullTextRenderer)
+ || clsid == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) // ISCR
+ {
+ // hide these
+ continue;
+ }
+
+ CAutoPtr<CMenu> pSubSub(DNew CMenu);
+ pSubSub->CreatePopupMenu();
+
+ int nPPages = 0;
+
+ CComQIPtr<ISpecifyPropertyPages> pSPP = pBF;
+
+/* if(pSPP)
+ {
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if(SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0)
+ {
+*/ m_pparray.Add(pBF);
+ pSubSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ids, ResStr(IDS_MAINFRM_116));
+/*
+ if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+*/
+ nPPages++;
+/* }
+ }
+*/
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ CString name = GetPinName(pPin);
+ name.Replace(_T("&"), _T("&&"));
+
+ if(pSPP = pPin)
+ {
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if(SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0)
+ {
+ m_pparray.Add(pPin);
+ pSubSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ids+nPPages, name + ResStr(IDS_MAINFRM_117));
+
+ if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+
+ nPPages++;
+ }
+ }
+ }
+ EndEnumPins
+
+ CComQIPtr<IAMStreamSelect> pSS = pBF;
+ if(pSS)
+ {
+ DWORD nStreams = 0, flags, group, prevgroup = -1;
+ LCID lcid;
+ WCHAR* wname = NULL;
+ CComPtr<IUnknown> pObj, pUnk;
+
+ pSS->Count(&nStreams);
+
+ if(nStreams > 0 && nPPages > 0) pSubSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
+
+ UINT idlstart = idl;
+
+ for(DWORD i = 0; i < nStreams; i++, pObj = NULL, pUnk = NULL)
+ {
+ m_ssarray.Add(pSS);
+
+ flags = group = 0;
+ wname = NULL;
+ pSS->Info(i, NULL, &flags, &lcid, &group, &wname, &pObj, &pUnk);
+
+ if(group != prevgroup && idl > idlstart)
+ pSubSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
+ prevgroup = group;
+
+ if(flags & AMSTREAMSELECTINFO_EXCLUSIVE)
+ {
+ }
+ else if(flags & AMSTREAMSELECTINFO_ENABLED)
+ {
+ }
+
+ if(!wname)
+ {
+ CStringW stream(ResStr(IDS_AG_UNKNOWN_STREAM));
+ wname = (WCHAR*)CoTaskMemAlloc((stream.GetLength()+3+1)*sizeof(WCHAR));
+ swprintf(wname, L"%s %d", stream, min(i+1,999));
+ }
+
+ CString name(wname);
+ name.Replace(_T("&"), _T("&&"));
+
+ pSubSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, idl++, name);
+
+ CoTaskMemFree(wname);
+ }
+
+ if(nStreams == 0) pSS.Release();
+ }
+
+ if(nPPages == 1 && !pSS)
+ {
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ids, name);
+ }
+ else
+ {
+ pSub->AppendMenu(MF_BYPOSITION|MF_STRING|MF_DISABLED|MF_GRAYED, idf, name);
+
+ if(nPPages > 0 || pSS)
+ {
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STATE|MIIM_SUBMENU;
+ mii.fType = MF_POPUP;
+ mii.hSubMenu = pSubSub->m_hMenu;
+ mii.fState = (pSPP || pSS) ? MF_ENABLED : (MF_DISABLED|MF_GRAYED);
+ pSub->SetMenuItemInfo(idf, &mii, TRUE);
+
+ m_filterpopups.Add(pSubSub);
+ }
+ }
+
+ ids += nPPages;
+ idf++;
+ }
+ EndEnumFilters
+ }
}
void CMainFrame::SetupAudioSwitcherSubMenu()
{
- CMenu* pSub = &m_audios;
-
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- UINT id = ID_AUDIO_SUBITEM_START;
-
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
-
- if(pSS)
- {
- DWORD cStreams = 0;
- if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0)
- {
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
- pSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
-
- for(int i = 0; i < (int)cStreams; i++)
- {
- WCHAR* pName = NULL;
- if(FAILED(pSS->Info(m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)), NULL, NULL, NULL, NULL, &pName, NULL, NULL))) // audio streams are reordered, so find the index from the initial order
- break;
-
- CString name(pName);
- name.Replace(_T("&"), _T("&&"));
-
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, name);
-
- CoTaskMemFree(pName);
- }
- }
- }
- }
-}
-
-void CMainFrame::SetupSubtitlesSubMenu()
-{
- CMenu* pSub = &m_subtitles;
+ CMenu* pSub = &m_audios;
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
- if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly || !m_pCAP)
- return;
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ UINT id = ID_AUDIO_SUBITEM_START;
- UINT id = ID_SUBTITLES_SUBITEM_START;
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
- POSITION pos = m_pSubStreams.GetHeadPosition();
+ if(pSS)
+ {
+ DWORD cStreams = 0;
+ if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0)
+ {
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
+ pSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
- if(pos)
- {
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_STYLES));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_RELOAD));
- pSub->AppendMenu(MF_SEPARATOR);
-
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_ENABLE));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_DEFAULT_STYLE));
- pSub->AppendMenu(MF_SEPARATOR);
- }
+ for(int i = 0; i < (int)cStreams; i++)
+ {
+ WCHAR* pName = NULL;
+ if(FAILED(pSS->Info(m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)), NULL, NULL, NULL, NULL, &pName, NULL, NULL))) // audio streams are reordered, so find the index from the initial order
+ break;
- while(pos)
- {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(!pSubStream) continue;
+ CString name(pName);
+ name.Replace(_T("&"), _T("&&"));
- for(int i = 0, j = pSubStream->GetStreamCount(); i < j; i++)
- {
- WCHAR* pName = NULL;
- if(SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL)))
- {
- CString name(pName);
- name.Replace(_T("&"), _T("&&"));
-
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, name);
- CoTaskMemFree(pName);
- }
- else
- {
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_AG_UNKNOWN));
- }
- }
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, name);
- // TODO: find a better way to group these entries
- if(pos && m_pSubStreams.GetAt(pos))
- {
- CLSID cur, next;
- pSubStream->GetClassID(&cur);
- m_pSubStreams.GetAt(pos)->GetClassID(&next);
+ CoTaskMemFree(pName);
+ }
+ }
+ }
+ }
+}
- if(cur != next)
- pSub->AppendMenu(MF_SEPARATOR);
- }
- }
+void CMainFrame::SetupSubtitlesSubMenu()
+{
+ CMenu* pSub = &m_subtitles;
+
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+
+ if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly || !m_pCAP)
+ return;
+
+ UINT id = ID_SUBTITLES_SUBITEM_START;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+
+ if(pos)
+ {
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_STYLES));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_RELOAD));
+ pSub->AppendMenu(MF_SEPARATOR);
+
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_ENABLE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_DEFAULT_STYLE));
+ pSub->AppendMenu(MF_SEPARATOR);
+ }
+
+ while(pos)
+ {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+ if(!pSubStream) continue;
+
+ for(int i = 0, j = pSubStream->GetStreamCount(); i < j; i++)
+ {
+ WCHAR* pName = NULL;
+ if(SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL)))
+ {
+ CString name(pName);
+ name.Replace(_T("&"), _T("&&"));
+
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, name);
+ CoTaskMemFree(pName);
+ }
+ else
+ {
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_AG_UNKNOWN));
+ }
+ }
+
+ // TODO: find a better way to group these entries
+ if(pos && m_pSubStreams.GetAt(pos))
+ {
+ CLSID cur, next;
+ pSubStream->GetClassID(&cur);
+ m_pSubStreams.GetAt(pos)->GetClassID(&next);
+
+ if(cur != next)
+ pSub->AppendMenu(MF_SEPARATOR);
+ }
+ }
}
void CMainFrame::SetupNavAudioSubMenu()
{
- CMenu* pSub = &m_navaudio;
+ CMenu* pSub = &m_navaudio;
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- UINT id = ID_NAVIGATE_AUDIO_SUBITEM_START;
+ UINT id = ID_NAVIGATE_AUDIO_SUBITEM_START;
- if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
- {
- SetupNavStreamSelectSubMenu(pSub, id, 1);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- ULONG ulStreamsAvailable, ulCurrentStream;
- if(FAILED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream)))
- return;
+ if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
+ {
+ SetupNavStreamSelectSubMenu(pSub, id, 1);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ if(FAILED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream)))
+ return;
- LCID DefLanguage;
- DVD_AUDIO_LANG_EXT ext;
- if(FAILED(pDVDI->GetDefaultAudioLanguage(&DefLanguage, &ext)))
- return;
+ LCID DefLanguage;
+ DVD_AUDIO_LANG_EXT ext;
+ if(FAILED(pDVDI->GetDefaultAudioLanguage(&DefLanguage, &ext)))
+ return;
for(ULONG i = 0; i < ulStreamsAvailable; i++)
- {
- LCID Language;
- if(FAILED(pDVDI->GetAudioLanguage(i, &Language)))
- continue;
+ {
+ LCID Language;
+ if(FAILED(pDVDI->GetAudioLanguage(i, &Language)))
+ continue;
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(Language == DefLanguage) flags |= MF_DEFAULT;
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(Language == DefLanguage) flags |= MF_DEFAULT;
if(i == ulCurrentStream) flags |= MF_CHECKED;
- CString str(ResStr(IDS_AG_UNKNOWN));
- if(Language)
- {
- int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
- str.ReleaseBufferSetLength(max(len - 1, 0));
- }
-
- DVD_AudioAttributes ATR;
- if(SUCCEEDED(pDVDI->GetAudioAttributes(i, &ATR)))
- {
- switch(ATR.LanguageExtension)
- {
- case DVD_AUD_EXT_NotSpecified:
- default:
- break;
- case DVD_AUD_EXT_Captions:
- str += _T(" (Captions)");
- break;
- case DVD_AUD_EXT_VisuallyImpaired:
- str += _T(" (Visually Impaired)");
- break;
- case DVD_AUD_EXT_DirectorComments1:
- str += ResStr(IDS_MAINFRM_121);
- break;
- case DVD_AUD_EXT_DirectorComments2:
- str += ResStr(IDS_MAINFRM_122);
- break;
- }
-
- CString format = GetDVDAudioFormatName(ATR);
-
- if(!format.IsEmpty())
- {
- str.Format(ResStr(IDS_MAINFRM_11),
- CString(str),
- format,
- ATR.dwFrequency,
- ATR.bQuantization,
- ATR.bNumberOfChannels,
- (ATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
- }
- }
-
- str.Replace(_T("&"), _T("&&"));
-
- pSub->AppendMenu(flags, id++, str);
- }
- }
+ CString str(ResStr(IDS_AG_UNKNOWN));
+ if(Language)
+ {
+ int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
+ str.ReleaseBufferSetLength(max(len-1, 0));
+ }
+
+ DVD_AudioAttributes ATR;
+ if(SUCCEEDED(pDVDI->GetAudioAttributes(i, &ATR)))
+ {
+ switch(ATR.LanguageExtension)
+ {
+ case DVD_AUD_EXT_NotSpecified:
+ default: break;
+ case DVD_AUD_EXT_Captions: str += _T(" (Captions)"); break;
+ case DVD_AUD_EXT_VisuallyImpaired: str += _T(" (Visually Impaired)"); break;
+ case DVD_AUD_EXT_DirectorComments1: str += ResStr(IDS_MAINFRM_121); break;
+ case DVD_AUD_EXT_DirectorComments2: str += ResStr(IDS_MAINFRM_122); break;
+ }
+
+ CString format = GetDVDAudioFormatName(ATR);
+
+ if(!format.IsEmpty())
+ {
+ str.Format(ResStr(IDS_MAINFRM_11),
+ CString(str),
+ format,
+ ATR.dwFrequency,
+ ATR.bQuantization,
+ ATR.bNumberOfChannels,
+ (ATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
+ }
+ }
+
+ str.Replace(_T("&"), _T("&&"));
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+ }
}
void CMainFrame::SetupNavSubtitleSubMenu()
{
- CMenu* pSub = &m_navsubtitle;
+ CMenu* pSub = &m_navsubtitle;
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- UINT id = ID_NAVIGATE_SUBP_SUBITEM_START;
+ UINT id = ID_NAVIGATE_SUBP_SUBITEM_START;
- if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
- {
- SetupNavStreamSelectSubMenu(pSub, id, 2);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if(FAILED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
- || ulStreamsAvailable == 0)
- return;
+ if(m_iPlaybackMode == PM_FILE || (m_iPlaybackMode == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
+ {
+ SetupNavStreamSelectSubMenu(pSub, id, 2);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if(FAILED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
+ || ulStreamsAvailable == 0)
+ return;
- LCID DefLanguage;
- DVD_SUBPICTURE_LANG_EXT ext;
- if(FAILED(pDVDI->GetDefaultSubpictureLanguage(&DefLanguage, &ext)))
- return;
+ LCID DefLanguage;
+ DVD_SUBPICTURE_LANG_EXT ext;
+ if(FAILED(pDVDI->GetDefaultSubpictureLanguage(&DefLanguage, &ext)))
+ return;
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | (bIsDisabled ? 0 : MF_CHECKED), id++, ResStr(IDS_AG_ENABLED));
- pSub->AppendMenu(MF_BYCOMMAND | MF_SEPARATOR | MF_ENABLED);
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|(bIsDisabled?0:MF_CHECKED), id++, ResStr(IDS_AG_ENABLED));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_SEPARATOR|MF_ENABLED);
for(ULONG i = 0; i < ulStreamsAvailable; i++)
- {
- LCID Language;
- if(FAILED(pDVDI->GetSubpictureLanguage(i, &Language)))
- continue;
+ {
+ LCID Language;
+ if(FAILED(pDVDI->GetSubpictureLanguage(i, &Language)))
+ continue;
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(Language == DefLanguage) flags |= MF_DEFAULT;
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(Language == DefLanguage) flags |= MF_DEFAULT;
if(i == ulCurrentStream) flags |= MF_CHECKED;
- CString str(ResStr(IDS_AG_UNKNOWN));
- if(Language)
- {
- int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
- str.ReleaseBufferSetLength(max(len - 1, 0));
- }
-
- DVD_SubpictureAttributes ATR;
- if(SUCCEEDED(pDVDI->GetSubpictureAttributes(i, &ATR)))
- {
- switch(ATR.LanguageExtension)
- {
- case DVD_SP_EXT_NotSpecified:
- default:
- break;
- case DVD_SP_EXT_Caption_Normal:
- str += _T("");
- break;
- case DVD_SP_EXT_Caption_Big:
- str += _T(" (Big)");
- break;
- case DVD_SP_EXT_Caption_Children:
- str += _T(" (Children)");
- break;
- case DVD_SP_EXT_CC_Normal:
- str += _T(" (CC)");
- break;
- case DVD_SP_EXT_CC_Big:
- str += _T(" (CC Big)");
- break;
- case DVD_SP_EXT_CC_Children:
- str += _T(" (CC Children)");
- break;
- case DVD_SP_EXT_Forced:
- str += _T(" (Forced)");
- break;
- case DVD_SP_EXT_DirectorComments_Normal:
- str += _T(" (Director Comments)");
- break;
- case DVD_SP_EXT_DirectorComments_Big:
- str += _T(" (Director Comments, Big)");
- break;
- case DVD_SP_EXT_DirectorComments_Children:
- str += _T(" (Director Comments, Children)");
- break;
- }
- }
-
- str.Replace(_T("&"), _T("&&"));
-
- pSub->AppendMenu(flags, id++, str);
- }
- }
+ CString str(ResStr(IDS_AG_UNKNOWN));
+ if(Language)
+ {
+ int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
+ str.ReleaseBufferSetLength(max(len-1, 0));
+ }
+
+ DVD_SubpictureAttributes ATR;
+ if(SUCCEEDED(pDVDI->GetSubpictureAttributes(i, &ATR)))
+ {
+ switch(ATR.LanguageExtension)
+ {
+ case DVD_SP_EXT_NotSpecified:
+ default: break;
+ case DVD_SP_EXT_Caption_Normal: str += _T(""); break;
+ case DVD_SP_EXT_Caption_Big: str += _T(" (Big)"); break;
+ case DVD_SP_EXT_Caption_Children: str += _T(" (Children)"); break;
+ case DVD_SP_EXT_CC_Normal: str += _T(" (CC)"); break;
+ case DVD_SP_EXT_CC_Big: str += _T(" (CC Big)"); break;
+ case DVD_SP_EXT_CC_Children: str += _T(" (CC Children)"); break;
+ case DVD_SP_EXT_Forced: str += _T(" (Forced)"); break;
+ case DVD_SP_EXT_DirectorComments_Normal: str += _T(" (Director Comments)"); break;
+ case DVD_SP_EXT_DirectorComments_Big: str += _T(" (Director Comments, Big)"); break;
+ case DVD_SP_EXT_DirectorComments_Children: str += _T(" (Director Comments, Children)"); break;
+ }
+ }
+
+ str.Replace(_T("&"), _T("&&"));
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+ }
}
void CMainFrame::SetupNavAngleSubMenu()
{
- CMenu* pSub = &m_navangle;
+ CMenu* pSub = &m_navangle;
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) return;
- UINT id = ID_NAVIGATE_ANGLE_SUBITEM_START;
+ UINT id = ID_NAVIGATE_ANGLE_SUBITEM_START;
- if(m_iPlaybackMode == PM_FILE)
- {
- SetupNavStreamSelectSubMenu(pSub, id, 0);
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- ULONG ulStreamsAvailable, ulCurrentStream;
- if(FAILED(pDVDI->GetCurrentAngle(&ulStreamsAvailable, &ulCurrentStream)))
- return;
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ SetupNavStreamSelectSubMenu(pSub, id, 0);
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ if(FAILED(pDVDI->GetCurrentAngle(&ulStreamsAvailable, &ulCurrentStream)))
+ return;
- if(ulStreamsAvailable < 2) return; // one choice is not a choice...
+ if(ulStreamsAvailable < 2) return; // one choice is not a choice...
for(ULONG i = 1; i <= ulStreamsAvailable; i++)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
if(i == ulCurrentStream) flags |= MF_CHECKED;
- CString str;
- str.Format(ResStr(IDS_AG_ANGLE), i);
+ CString str;
+ str.Format(ResStr(IDS_AG_ANGLE), i);
- pSub->AppendMenu(flags, id++, str);
- }
- }
+ pSub->AppendMenu(flags, id++, str);
+ }
+ }
}
void CMainFrame::SetupNavChaptersSubMenu()
{
- CMenu* pSub = &m_navchapters;
-
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
-
- if(m_iMediaLoadState != MLS_LOADED)
- return;
-
- UINT id = ID_NAVIGATE_CHAP_SUBITEM_START;
-
- if(m_iPlaybackMode == PM_FILE)
- {
- SetupChapters();
-
- REFERENCE_TIME rt = GetPos();
- DWORD j = m_pCB->ChapLookup(&rt, NULL);
-
- for(DWORD i = 0; i < m_pCB->ChapGetCount(); i++, id++)
- {
- rt = 0;
- CComBSTR bstr;
- if(FAILED(m_pCB->ChapGet(i, &rt, &bstr)))
- continue;
-
- int s = (int)((rt / 10000000) % 60);
- int m = (int)((rt / 10000000 / 60) % 60);
- int h = (int)((rt / 10000000 / 60 / 60));
-
- CString time;
- time.Format(_T("[%02d:%02d:%02d] "), h, m, s);
-
- CString name = CString(bstr);
- name.Replace(_T("&"), _T("&&"));
- name.Replace(_T("\t"), _T(" "));
-
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(i == j) flags |= MF_CHECKED;
- if(id != ID_NAVIGATE_CHAP_SUBITEM_START && i == 0) pSub->AppendMenu(MF_SEPARATOR);
- pSub->AppendMenu(flags, id, name + '\t' + time);
- }
-
- if(m_wndPlaylistBar.GetCount() > 1)
- {
- POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition();
- while(pos)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(pos == m_wndPlaylistBar.m_pl.GetPos()) flags |= MF_CHECKED;
- if(id != ID_NAVIGATE_CHAP_SUBITEM_START && pos == m_wndPlaylistBar.m_pl.GetHeadPosition())
- pSub->AppendMenu(MF_SEPARATOR);
- CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
- CString name = pli.GetLabel();
- name.Replace(_T("&"), _T("&&"));
- pSub->AppendMenu(flags, id++, name);
- }
- }
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles = 0;
- pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
-
- ULONG ulNumOfChapters = 0;
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
-
- ULONG ulUOPs = 0;
- pDVDI->GetCurrentUOPS(&ulUOPs);
-
- for(ULONG i = 1; i <= ulNumOfTitles; i++)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(i == Location.TitleNum) flags |= MF_CHECKED;
- if(ulUOPs & UOP_FLAG_Play_Title) flags |= MF_DISABLED | MF_GRAYED;
-
- CString str;
- str.Format(ResStr(IDS_AG_TITLE), i);
-
- pSub->AppendMenu(flags, id++, str);
- }
-
- for(ULONG i = 1; i <= ulNumOfChapters; i++)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(i == Location.ChapterNum) flags |= MF_CHECKED;
- if(ulUOPs & UOP_FLAG_Play_Chapter) flags |= MF_DISABLED | MF_GRAYED;
- if(i == 1) flags |= MF_MENUBARBREAK;
-
- CString str;
- str.Format(ResStr(IDS_AG_CHAPTER), i);
-
- pSub->AppendMenu(flags, id++, str);
- }
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- AppSettings& s = AfxGetAppSettings();
-
- POSITION pos = s.DVBChannels.GetHeadPosition();
- while(pos)
- {
- CDVBChannel& Channel = s.DVBChannels.GetNext(pos);
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
-
- if(Channel.GetPrefNumber() == s.DVBLastChannel)
- flags |= MF_CHECKED;
- pSub->AppendMenu(flags, ID_NAVIGATE_CHAP_SUBITEM_START + Channel.GetPrefNumber(), Channel.GetName());
- }
- }
+ CMenu* pSub = &m_navchapters;
+
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+
+ if(m_iMediaLoadState != MLS_LOADED)
+ return;
+
+ UINT id = ID_NAVIGATE_CHAP_SUBITEM_START;
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ SetupChapters();
+
+ REFERENCE_TIME rt = GetPos();
+ DWORD j = m_pCB->ChapLookup(&rt, NULL);
+
+ for(DWORD i = 0; i < m_pCB->ChapGetCount(); i++, id++)
+ {
+ rt = 0;
+ CComBSTR bstr;
+ if(FAILED(m_pCB->ChapGet(i, &rt, &bstr)))
+ continue;
+
+ int s = (int)((rt/10000000)%60);
+ int m = (int)((rt/10000000/60)%60);
+ int h = (int)((rt/10000000/60/60));
+
+ CString time;
+ time.Format(_T("[%02d:%02d:%02d] "), h, m, s);
+
+ CString name = CString(bstr);
+ name.Replace(_T("&"), _T("&&"));
+ name.Replace(_T("\t"), _T(" "));
+
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(i == j) flags |= MF_CHECKED;
+ if(id != ID_NAVIGATE_CHAP_SUBITEM_START && i == 0) pSub->AppendMenu(MF_SEPARATOR);
+ pSub->AppendMenu(flags, id, name + '\t' + time);
+ }
+
+ if(m_wndPlaylistBar.GetCount() > 1)
+ {
+ POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition();
+ while(pos)
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(pos == m_wndPlaylistBar.m_pl.GetPos()) flags |= MF_CHECKED;
+ if(id != ID_NAVIGATE_CHAP_SUBITEM_START && pos == m_wndPlaylistBar.m_pl.GetHeadPosition())
+ pSub->AppendMenu(MF_SEPARATOR);
+ CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
+ CString name = pli.GetLabel();
+ name.Replace(_T("&"), _T("&&"));
+ pSub->AppendMenu(flags, id++, name);
+ }
+ }
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles = 0;
+ pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+
+ ULONG ulNumOfChapters = 0;
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+
+ ULONG ulUOPs = 0;
+ pDVDI->GetCurrentUOPS(&ulUOPs);
+
+ for(ULONG i = 1; i <= ulNumOfTitles; i++)
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(i == Location.TitleNum) flags |= MF_CHECKED;
+ if(ulUOPs&UOP_FLAG_Play_Title) flags |= MF_DISABLED|MF_GRAYED;
+
+ CString str;
+ str.Format(ResStr(IDS_AG_TITLE), i);
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+
+ for(ULONG i = 1; i <= ulNumOfChapters; i++)
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(i == Location.ChapterNum) flags |= MF_CHECKED;
+ if(ulUOPs&UOP_FLAG_Play_Chapter) flags |= MF_DISABLED|MF_GRAYED;
+ if(i == 1) flags |= MF_MENUBARBREAK;
+
+ CString str;
+ str.Format(ResStr(IDS_AG_CHAPTER), i);
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ AppSettings& s = AfxGetAppSettings();
+
+ POSITION pos = s.DVBChannels.GetHeadPosition();
+ while (pos)
+ {
+ CDVBChannel& Channel = s.DVBChannels.GetNext(pos);
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+
+ if (Channel.GetPrefNumber() == s.DVBLastChannel)
+ flags |= MF_CHECKED;
+ pSub->AppendMenu(flags, ID_NAVIGATE_CHAP_SUBITEM_START + Channel.GetPrefNumber(), Channel.GetName());
+ }
+ }
}
IBaseFilter* CMainFrame::FindSourceSelectableFilter()
{
- IBaseFilter* pSF = NULL;
+ IBaseFilter* pSF = NULL;
- pSF = FindFilter(CLSID_OggSplitter, pGB);
- if(!pSF) pSF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGB);
- if(!pSF) pSF = FindFilter(__uuidof(CMpegSplitterFilter), pGB);
- if(!pSF) pSF = FindFilter(__uuidof(CMpegSourceFilter), pGB);
+ pSF = FindFilter(CLSID_OggSplitter, pGB);
+ if(!pSF) pSF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGB);
+ if(!pSF) pSF = FindFilter(__uuidof(CMpegSplitterFilter), pGB);
+ if(!pSF) pSF = FindFilter(__uuidof(CMpegSourceFilter), pGB);
- return pSF;
+ return pSF;
}
void CMainFrame::SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGroup)
{
- UINT baseid = id;
+ UINT baseid = id;
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if(!pSS) pSS = pGB;
- if(!pSS) return;
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if (!pSS) pSS = pGB;
+ if(!pSS) return;
- DWORD cStreams;
- if(FAILED(pSS->Count(&cStreams)))
- return;
+ DWORD cStreams;
+ if(FAILED(pSS->Count(&cStreams)))
+ return;
- DWORD dwPrevGroup = -1;
+ DWORD dwPrevGroup = -1;
- for(int i = 0, j = cStreams; i < j; i++)
- {
- DWORD dwFlags, dwGroup;
- LCID lcid;
- WCHAR* pszName = NULL;
+ for(int i = 0, j = cStreams; i < j; i++)
+ {
+ DWORD dwFlags, dwGroup;
+ LCID lcid;
+ WCHAR* pszName = NULL;
- if(FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
- || !pszName)
- continue;
+ if(FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
+ || !pszName)
+ continue;
- CString name(pszName);
- CString lcname = CString(name).MakeLower();
+ CString name(pszName);
+ CString lcname = CString(name).MakeLower();
- if(pszName) CoTaskMemFree(pszName);
+ if(pszName) CoTaskMemFree(pszName);
- if(dwGroup != dwSelGroup)
- continue;
+ if(dwGroup != dwSelGroup)
+ continue;
- if(dwPrevGroup != -1 && dwPrevGroup != dwGroup)
- pSub->AppendMenu(MF_SEPARATOR);
- dwPrevGroup = dwGroup;
+ if(dwPrevGroup != -1 && dwPrevGroup != dwGroup)
+ pSub->AppendMenu(MF_SEPARATOR);
+ dwPrevGroup = dwGroup;
- CString str;
+ CString str;
- if(lcname.Find(_T(" off")) >= 0)
- {
- str = ResStr(IDS_AG_DISABLED);
- }
- else
- {
- if(lcid == 0)
- {
- str.Format(ResStr(IDS_AG_UNKNOWN), id - baseid);
- }
- else
- {
- int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, str.GetBuffer(64), 64);
- str.ReleaseBufferSetLength(max(len - 1, 0));
- }
-
- CString lcstr = CString(str).MakeLower();
-
- if(str.IsEmpty() || lcname.Find(lcstr) >= 0) str = name;
- else if(!name.IsEmpty()) str = CString(name) + _T(" (") + str + _T(")");
- }
+ if(lcname.Find(_T(" off")) >= 0)
+ {
+ str = ResStr(IDS_AG_DISABLED);
+ }
+ else
+ {
+ if(lcid == 0)
+ {
+ str.Format(ResStr(IDS_AG_UNKNOWN), id - baseid);
+ }
+ else
+ {
+ int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, str.GetBuffer(64), 64);
+ str.ReleaseBufferSetLength(max(len-1, 0));
+ }
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(dwFlags) flags |= MF_CHECKED;
+ CString lcstr = CString(str).MakeLower();
- str.Replace(_T("&"), _T("&&"));
- pSub->AppendMenu(flags, id++, str);
- }
+ if(str.IsEmpty() || lcname.Find(lcstr) >= 0) str = name;
+ else if(!name.IsEmpty()) str = CString(name) + _T(" (") + str + _T(")");
+ }
+
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(dwFlags) flags |= MF_CHECKED;
+
+ str.Replace(_T("&"), _T("&&"));
+ pSub->AppendMenu(flags, id++, str);
+ }
}
void CMainFrame::OnNavStreamSelectSubMenu(UINT id, DWORD dwSelGroup)
{
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if(!pSS) pSS = pGB;
- if(!pSS) return;
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if (!pSS) pSS = pGB;
+ if(!pSS) return;
- DWORD cStreams;
- if(FAILED(pSS->Count(&cStreams)))
- return;
+ DWORD cStreams;
+ if(FAILED(pSS->Count(&cStreams)))
+ return;
- for(int i = 0, j = cStreams; i < j; i++)
- {
- DWORD dwFlags, dwGroup;
- LCID lcid;
- WCHAR* pszName = NULL;
+ for(int i = 0, j = cStreams; i < j; i++)
+ {
+ DWORD dwFlags, dwGroup;
+ LCID lcid;
+ WCHAR* pszName = NULL;
- if(FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
- || !pszName)
- continue;
+ if(FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
+ || !pszName)
+ continue;
- if(pszName) CoTaskMemFree(pszName);
+ if(pszName) CoTaskMemFree(pszName);
- if(dwGroup != dwSelGroup)
- continue;
+ if(dwGroup != dwSelGroup)
+ continue;
- if(id == 0)
- {
- pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
- break;
- }
+ if(id == 0)
+ {
+ pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
+ break;
+ }
- id--;
- }
+ id--;
+ }
}
void CMainFrame::SetupRecentFilesSubMenu()
{
- CMenu* pSub = &m_recentfiles;
-
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
-
- UINT id = ID_RECENT_FILE_START;
- CRecentFileList& MRU = AfxGetAppSettings().MRU;
- MRU.ReadList();
-
- int mru_count = 0;
- for(int i = 0; i < MRU.GetSize(); i++)
- {
- if(!MRU[i].IsEmpty())
- {
- mru_count++;
- break;
- }
- }
- if(mru_count)
- {
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_RECENT_FILES_CLEAR, ResStr(IDS_RECENT_FILES_CLEAR));
- pSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
- }
-
- for(int i = 0; i < MRU.GetSize(); i++)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- if(!MRU[i].IsEmpty())
- {
- pSub->AppendMenu(flags, id, MRU[i]);
- }
- id++;
- }
+ CMenu* pSub = &m_recentfiles;
+
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+
+ UINT id = ID_RECENT_FILE_START;
+ CRecentFileList& MRU = AfxGetAppSettings().MRU;
+ MRU.ReadList();
+
+ int mru_count=0;
+ for(int i = 0; i < MRU.GetSize();i++)
+ {
+ if(!MRU[i].IsEmpty())
+ {
+ mru_count++;
+ break;
+ }
+ }
+ if(mru_count)
+ {
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_RECENT_FILES_CLEAR, ResStr(IDS_RECENT_FILES_CLEAR));
+ pSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
+ }
+
+ for(int i = 0; i < MRU.GetSize();i++)
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ if(!MRU[i].IsEmpty())
+ {
+ pSub->AppendMenu(flags, id, MRU[i]);
+ }
+ id++;
+ }
}
void CMainFrame::SetupFavoritesSubMenu()
{
- CMenu* pSub = &m_favorites;
+ CMenu* pSub = &m_favorites;
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_FAVORITES_ADD, ResStr(IDS_FAVORITES_ADD));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_FAVORITES_ORGANIZE, ResStr(IDS_FAVORITES_ORGANIZE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_FAVORITES_ADD, ResStr(IDS_FAVORITES_ADD));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_FAVORITES_ORGANIZE, ResStr(IDS_FAVORITES_ORGANIZE));
- int nLastGroupStart = pSub->GetMenuItemCount();
+ int nLastGroupStart = pSub->GetMenuItemCount();
- UINT id = ID_FAVORITES_FILE_START;
+ UINT id = ID_FAVORITES_FILE_START;
- CAtlList<CString> sl;
- AfxGetAppSettings().GetFav(FAV_FILE, sl);
+ CAtlList<CString> sl;
+ AfxGetAppSettings().GetFav(FAV_FILE, sl);
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- CString str = sl.GetNext(pos);
- str.Replace(_T("&"), _T("&&"));
- str.Replace(_T("\t"), _T(" "));
+ CString str = sl.GetNext(pos);
+ str.Replace(_T("&"), _T("&&"));
+ str.Replace(_T("\t"), _T(" "));
- CAtlList<CString> sl;
- Explode(str, sl, ';', 3);
+ CAtlList<CString> sl;
+ Explode(str, sl, ';', 3);
- str = sl.RemoveHead();
+ str = sl.RemoveHead();
- if(!sl.IsEmpty())
- {
- bool bPositionDataPresent = false;
-
- // pos
- REFERENCE_TIME rt = 0;
- if(1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0)
- {
- DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt, 0);
- str.Format(_T("%s\t[%02d:%02d:%02d]"), CString(str), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
- bPositionDataPresent = true;
- }
-
- // relative drive
- if(sl.GetCount() > 1) // Here to prevent crash if old favorites settings are present
- {
- sl.RemoveHead();
-
- BOOL bRelativeDrive = FALSE;
- if(_stscanf_s(sl.GetHead(), _T("%d"), &bRelativeDrive) == 1)
- {
- str.Format(_T("%s%s[RD: %s]"), CString(str), bPositionDataPresent ? _T(" ") : _T("\t"), bRelativeDrive ? _T("On") : _T("Off"));
- }
- }
- }
+ if(!sl.IsEmpty())
+ {
+ bool bPositionDataPresent = false;
- if(!str.IsEmpty())
- pSub->AppendMenu(flags, id, str);
+ // pos
+ REFERENCE_TIME rt = 0;
+ if(1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0)
+ {
+ DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt, 0);
+ str.Format(_T("%s\t[%02d:%02d:%02d]"), CString(str), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
+ bPositionDataPresent = true;
+ }
+
+ // relative drive
+ if ( sl.GetCount() > 1 ) // Here to prevent crash if old favorites settings are present
+ {
+ sl.RemoveHead();
- id++;
- }
+ BOOL bRelativeDrive = FALSE;
+ if ( _stscanf_s(sl.GetHead(), _T("%d"), &bRelativeDrive) == 1 )
+ {
+ str.Format(_T("%s%s[RD: %s]"), CString(str), bPositionDataPresent ? _T(" ") : _T("\t"), bRelativeDrive ? _T("On") : _T("Off"));
+ }
+ }
+ }
- if(id > ID_FAVORITES_FILE_START)
- pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR | MF_ENABLED | MF_BYPOSITION);
+ if(!str.IsEmpty())
+ pSub->AppendMenu(flags, id, str);
- nLastGroupStart = pSub->GetMenuItemCount();
+ id++;
+ }
- id = ID_FAVORITES_DVD_START;
+ if(id > ID_FAVORITES_FILE_START)
+ pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR|MF_ENABLED|MF_BYPOSITION);
- AfxGetAppSettings().GetFav(FAV_DVD, sl);
+ nLastGroupStart = pSub->GetMenuItemCount();
- pos = sl.GetHeadPosition();
- while(pos)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ id = ID_FAVORITES_DVD_START;
- CString str = sl.GetNext(pos);
- str.Replace(_T("&"), _T("&&"));
+ AfxGetAppSettings().GetFav(FAV_DVD, sl);
- CAtlList<CString> sl;
- Explode(str, sl, ';', 2);
+ pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- str = sl.RemoveHead();
+ CString str = sl.GetNext(pos);
+ str.Replace(_T("&"), _T("&&"));
- if(!sl.IsEmpty())
- {
- // TODO
- }
+ CAtlList<CString> sl;
+ Explode(str, sl, ';', 2);
- if(!str.IsEmpty())
- pSub->AppendMenu(flags, id, str);
+ str = sl.RemoveHead();
- id++;
- }
+ if(!sl.IsEmpty())
+ {
+ // TODO
+ }
- if(id > ID_FAVORITES_DVD_START)
- pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR | MF_ENABLED | MF_BYPOSITION);
+ if(!str.IsEmpty())
+ pSub->AppendMenu(flags, id, str);
- nLastGroupStart = pSub->GetMenuItemCount();
+ id++;
+ }
- id = ID_FAVORITES_DEVICE_START;
+ if(id > ID_FAVORITES_DVD_START)
+ pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR|MF_ENABLED|MF_BYPOSITION);
- AfxGetAppSettings().GetFav(FAV_DEVICE, sl);
+ nLastGroupStart = pSub->GetMenuItemCount();
- pos = sl.GetHeadPosition();
- while(pos)
- {
- UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ id = ID_FAVORITES_DEVICE_START;
- CString str = sl.GetNext(pos);
- str.Replace(_T("&"), _T("&&"));
+ AfxGetAppSettings().GetFav(FAV_DEVICE, sl);
- CAtlList<CString> sl;
- Explode(str, sl, ';', 2);
+ pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- str = sl.RemoveHead();
+ CString str = sl.GetNext(pos);
+ str.Replace(_T("&"), _T("&&"));
- if(!str.IsEmpty())
- pSub->AppendMenu(flags, id, str);
+ CAtlList<CString> sl;
+ Explode(str, sl, ';', 2);
- id++;
- }
+ str = sl.RemoveHead();
+
+ if(!str.IsEmpty())
+ pSub->AppendMenu(flags, id, str);
+
+ id++;
+ }
}
void CMainFrame::SetupShadersSubMenu()
{
- CMenu* pSub = &m_shaders;
+ CMenu* pSub = &m_shaders;
- if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
- else while(pSub->RemoveMenu(0, MF_BYPOSITION));
+ if(!IsMenu(pSub->m_hMenu)) pSub->CreatePopupMenu();
+ else while(pSub->RemoveMenu(0, MF_BYPOSITION));
- CWinApp* pApp = AfxGetApp();
+ CWinApp* pApp = AfxGetApp();
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_OFF, ResStr(IDS_SHADER_OFF));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_OFF, ResStr(IDS_SHADER_OFF));
- if(POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition())
- {
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_COMBINE, ResStr(IDS_SHADER_COMBINE));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_EDIT, ResStr(IDS_SHADER_EDIT));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADER_TOGGLE, ResStr(IDS_SHADER_TOGGLE));
- pSub->AppendMenu(MF_SEPARATOR);
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_OFFSCR, ResStr(IDS_SHADER_OFFSCREENSPACE));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_COMBINESCR, ResStr(IDS_SHADER_COMBINESCREENSPACE));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADER_TOGGLESCREENSPACE, ResStr(IDS_SHADER_TOGGLESCREENSPACE));
- pSub->AppendMenu(MF_SEPARATOR);
-
- UINT id = ID_SHADERS_DYNAMIC;
-
- MENUITEMINFO mii;
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask |= MIIM_DATA;
-
- while(pos)
- {
- const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
- CString label = s.label;
- label.Replace(_T("&"), _T("&&"));
- pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id, label);
- mii.dwItemData = (ULONG_PTR)&s;
- pSub->SetMenuItemInfo(id, &mii);
- id++;
- }
- }
+ if(POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition())
+ {
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_COMBINE, ResStr(IDS_SHADER_COMBINE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_EDIT, ResStr(IDS_SHADER_EDIT));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADER_TOGGLE, ResStr(IDS_SHADER_TOGGLE));
+ pSub->AppendMenu(MF_SEPARATOR);
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_OFFSCR, ResStr(IDS_SHADER_OFFSCREENSPACE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_COMBINESCR, ResStr(IDS_SHADER_COMBINESCREENSPACE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADER_TOGGLESCREENSPACE, ResStr(IDS_SHADER_TOGGLESCREENSPACE));
+ pSub->AppendMenu(MF_SEPARATOR);
+
+ UINT id = ID_SHADERS_DYNAMIC;
+
+ MENUITEMINFO mii;
+ memset(&mii, 0, sizeof(mii));
+ mii.cbSize = sizeof(mii);
+ mii.fMask |= MIIM_DATA;
+
+ while(pos)
+ {
+ const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
+ CString label = s.label;
+ label.Replace(_T("&"), _T("&&"));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id, label);
+ mii.dwItemData = (ULONG_PTR)&s;
+ pSub->SetMenuItemInfo(id, &mii);
+ id++;
+ }
+ }
}
/////////////
void CMainFrame::ShowControls(int nCS, bool fSave)
{
- int nCSprev = AfxGetAppSettings().nCS;
- int hbefore = 0, hafter = 0;
+ int nCSprev = AfxGetAppSettings().nCS;
+ int hbefore = 0, hafter = 0;
- m_pLastBar = NULL;
+ m_pLastBar = NULL;
- POSITION pos = m_bars.GetHeadPosition();
- for(int i = 1; pos; i <<= 1)
- {
- CControlBar* pNext = m_bars.GetNext(pos);
- ShowControlBar(pNext, !!(nCS & i), TRUE);
- if(nCS & i) m_pLastBar = pNext;
+ POSITION pos = m_bars.GetHeadPosition();
+ for(int i = 1; pos; i <<= 1)
+ {
+ CControlBar* pNext = m_bars.GetNext(pos);
+ ShowControlBar(pNext, !!(nCS&i), TRUE);
+ if(nCS&i) m_pLastBar = pNext;
- CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
- if(nCSprev & i) hbefore += s.cy;
- if(nCS & i) hafter += s.cy;
- }
+ CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
+ if(nCSprev&i) hbefore += s.cy;
+ if(nCS&i) hafter += s.cy;
+ }
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
- if(wp.showCmd != SW_SHOWMAXIMIZED && !m_fFullScreen)
- {
- CRect r;
- GetWindowRect(r);
- MoveWindow(r.left, r.top, r.Width(), r.Height() + (hafter - hbefore));
- }
+ if(wp.showCmd != SW_SHOWMAXIMIZED && !m_fFullScreen)
+ {
+ CRect r;
+ GetWindowRect(r);
+ MoveWindow(r.left, r.top, r.Width(), r.Height()+(hafter-hbefore));
+ }
if(fSave)
- AfxGetAppSettings().nCS = nCS;
+ AfxGetAppSettings().nCS = nCS;
- RecalcLayout();
+ RecalcLayout();
}
void CMainFrame::SetAlwaysOnTop(int i)
{
- AfxGetAppSettings().iOnTop = i;
+ AfxGetAppSettings().iOnTop = i;
- if(!m_fFullScreen)
- {
- const CWnd* pInsertAfter = NULL;
+ if(!m_fFullScreen)
+ {
+ const CWnd* pInsertAfter = NULL;
- if(i == 0)
- pInsertAfter = &wndNoTopMost;
- else if(i == 1)
- pInsertAfter = &wndTopMost;
- else // if(i == 2)
- pInsertAfter = GetMediaState() == State_Running ? &wndTopMost : &wndNoTopMost;
+ if(i == 0)
+ pInsertAfter = &wndNoTopMost;
+ else if(i == 1)
+ pInsertAfter = &wndTopMost;
+ else // if(i == 2)
+ pInsertAfter = GetMediaState() == State_Running ? &wndTopMost : &wndNoTopMost;
- SetWindowPos(pInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
- else if(!(GetWindowLong(m_hWnd, GWL_EXSTYLE)&WS_EX_TOPMOST))
- {
- if(!AfxGetAppSettings().IsD3DFullscreen())
- SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
+ SetWindowPos(pInsertAfter, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+ else if(!(GetWindowLong(m_hWnd, GWL_EXSTYLE)&WS_EX_TOPMOST))
+ {
+ if (!AfxGetAppSettings().IsD3DFullscreen())
+ SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
}
// foxX: as with audio streams, this one will tell if a subtitle comes before the other,
// in accordance with user options regarding subtitle language order
bool DoesSubPrecede(const CComPtr<ISubStream> &a, const CComPtr<ISubStream> &b)
{
- WCHAR *pName;
- if(!SUCCEEDED(a->GetStreamInfo(0, &pName, NULL)))
- return false;
- CStringW nameA(pName);
- CoTaskMemFree(pName);
-
- if(!SUCCEEDED(b->GetStreamInfo(0, &pName, NULL)))
- return false;
- CStringW nameB(pName);
- CoTaskMemFree(pName);
-
- int ia = -1;
- int ib = -1;
- CStringW slo = AfxGetAppSettings().m_subtitlesLanguageOrder;
- int tPos = 0;
- CStringW lang = slo.Tokenize(_T(",; "), tPos);
- while(tPos != -1 && ia == -1 && ib == -1)
- {
- int ll = lang.GetLength();
- if(nameA.Left(ll).CompareNoCase(lang) == 0)
- ia = tPos;
- if(nameB.Left(ll).CompareNoCase(lang) == 0)
- ib = tPos;
- lang = slo.Tokenize(_T(",; "), tPos);
- }
- if(ia != -1 && ib == -1)
- return true;
- return false;
+ WCHAR *pName;
+ if(!SUCCEEDED(a->GetStreamInfo(0, &pName, NULL)))
+ return false;
+ CStringW nameA(pName);
+ CoTaskMemFree(pName);
+
+ if(!SUCCEEDED(b->GetStreamInfo(0, &pName, NULL)))
+ return false;
+ CStringW nameB(pName);
+ CoTaskMemFree(pName);
+
+ int ia = -1;
+ int ib = -1;
+ CStringW slo = AfxGetAppSettings().m_subtitlesLanguageOrder;
+ int tPos = 0;
+ CStringW lang = slo.Tokenize(_T(",; "), tPos);
+ while(tPos != -1 && ia == -1 && ib == -1)
+ {
+ int ll = lang.GetLength();
+ if(nameA.Left(ll).CompareNoCase(lang) == 0)
+ ia = tPos;
+ if(nameB.Left(ll).CompareNoCase(lang) == 0)
+ ib = tPos;
+ lang = slo.Tokenize(_T(",; "), tPos);
+ }
+ if(ia != -1 && ib == -1)
+ return true;
+ return false;
}
// foxX: inserts the subtitle stream exactly where it should be, base on user preference
ISubStream *InsertSubStream(CInterfaceList<ISubStream> *subStreams, const CComPtr<ISubStream> &theSubStream)
{
- POSITION pos = subStreams->GetHeadPosition();
- POSITION newPos = NULL;
- bool processed = false;
- while(!processed && pos)
- {
- POSITION prevPos = pos;
- CComPtr<ISubStream> pSubStream = subStreams->GetNext(pos);
- if(DoesSubPrecede(theSubStream, pSubStream))
- {
- if(prevPos == subStreams->GetHeadPosition())
- newPos = subStreams->AddHead(theSubStream);
- else
- newPos = subStreams->InsertBefore(prevPos, theSubStream);
- processed = true;
- }
- }
- if(!processed)
- newPos = subStreams->AddTail(theSubStream);
- if(newPos == NULL)
- newPos = subStreams->GetTailPosition();
- if(newPos == NULL)
- return NULL;
- return subStreams->GetAt(newPos);
+ POSITION pos = subStreams->GetHeadPosition();
+ POSITION newPos = NULL;
+ bool processed = false;
+ while(!processed && pos)
+ {
+ POSITION prevPos = pos;
+ CComPtr<ISubStream> pSubStream = subStreams->GetNext(pos);
+ if(DoesSubPrecede(theSubStream, pSubStream))
+ {
+ if(prevPos == subStreams->GetHeadPosition())
+ newPos = subStreams->AddHead(theSubStream);
+ else
+ newPos = subStreams->InsertBefore(prevPos, theSubStream);
+ processed = true;
+ }
+ }
+ if(!processed)
+ newPos = subStreams->AddTail(theSubStream);
+ if(newPos == NULL)
+ newPos = subStreams->GetTailPosition();
+ if(newPos == NULL)
+ return NULL;
+ return subStreams->GetAt(newPos);
}
void CMainFrame::AddTextPassThruFilter()
{
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(!IsSplitter(pBF)) continue;
-
- BeginEnumPins(pBF, pEP, pPin)
- {
- CComPtr<IPin> pPinTo;
- AM_MEDIA_TYPE mt;
- if(FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
- || FAILED(pPin->ConnectionMediaType(&mt))
- || mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle)
- continue;
-
- CComQIPtr<IBaseFilter> pTPTF = DNew CTextPassThruFilter(this);
- CStringW name;
- name.Format(L"TextPassThru%08x", pTPTF);
- if(FAILED(pGB->AddFilter(pTPTF, name)))
- continue;
-
- HRESULT hr;
-
- hr = pPinTo->Disconnect();
- hr = pPin->Disconnect();
-
- if(FAILED(hr = pGB->ConnectDirect(pPin, GetFirstPin(pTPTF, PINDIR_INPUT), NULL))
- || FAILED(hr = pGB->ConnectDirect(GetFirstPin(pTPTF, PINDIR_OUTPUT), pPinTo, NULL)))
- hr = pGB->ConnectDirect(pPin, pPinTo, NULL);
- else
- {
- InsertSubStream(&m_pSubStreams, CComQIPtr<ISubStream>(pTPTF));
- }
- }
- EndEnumPins
- }
- EndEnumFilters
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ if(!IsSplitter(pBF)) continue;
+
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ CComPtr<IPin> pPinTo;
+ AM_MEDIA_TYPE mt;
+ if(FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
+ || FAILED(pPin->ConnectionMediaType(&mt))
+ || mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle)
+ continue;
+
+ CComQIPtr<IBaseFilter> pTPTF = DNew CTextPassThruFilter(this);
+ CStringW name;
+ name.Format(L"TextPassThru%08x", pTPTF);
+ if(FAILED(pGB->AddFilter(pTPTF, name)))
+ continue;
+
+ HRESULT hr;
+
+ hr = pPinTo->Disconnect();
+ hr = pPin->Disconnect();
+
+ if(FAILED(hr = pGB->ConnectDirect(pPin, GetFirstPin(pTPTF, PINDIR_INPUT), NULL))
+ || FAILED(hr = pGB->ConnectDirect(GetFirstPin(pTPTF, PINDIR_OUTPUT), pPinTo, NULL)))
+ hr = pGB->ConnectDirect(pPin, pPinTo, NULL);
+ else {
+ InsertSubStream(&m_pSubStreams, CComQIPtr<ISubStream>(pTPTF));
+ }
+ }
+ EndEnumPins
+ }
+ EndEnumFilters
}
bool CMainFrame::LoadSubtitle(CString fn, ISubStream **actualStream)
{
- CComPtr<ISubStream> pSubStream;
-
- // TMP: maybe this will catch something for those who get a runtime error dialog when opening subtitles from cds
- try
- {
- if(!pSubStream)
- {
- CAutoPtr<CVobSubFile> pVSF(DNew CVobSubFile(&m_csSubLock));
- if(CString(CPath(fn).GetExtension()).MakeLower() == _T(".idx") && pVSF && pVSF->Open(fn) && pVSF->GetStreamCount() > 0)
- pSubStream = pVSF.Detach();
- }
-
- if(!pSubStream)
- {
- CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &AfxGetAppSettings().subdefstyle, AfxGetAppSettings().fUseDefaultSubtitlesStyle));
- if(pRTS && pRTS->Open(fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0)
- pSubStream = pRTS.Detach();
- }
- }
- catch(CException* e)
- {
- e->Delete();
- }
-
- if(pSubStream)
- {
- //m_pSubStreams.AddTail(pSubStream);
- ISubStream *r = InsertSubStream(&m_pSubStreams, pSubStream);
- if(actualStream != NULL)
- *actualStream = r;
- }
-
- return(!!pSubStream);
+ CComPtr<ISubStream> pSubStream;
+
+ // TMP: maybe this will catch something for those who get a runtime error dialog when opening subtitles from cds
+ try
+ {
+ if(!pSubStream)
+ {
+ CAutoPtr<CVobSubFile> pVSF(DNew CVobSubFile(&m_csSubLock));
+ if(CString(CPath(fn).GetExtension()).MakeLower() == _T(".idx") && pVSF && pVSF->Open(fn) && pVSF->GetStreamCount() > 0)
+ pSubStream = pVSF.Detach();
+ }
+
+ if(!pSubStream)
+ {
+ CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &AfxGetAppSettings().subdefstyle, AfxGetAppSettings().fUseDefaultSubtitlesStyle));
+ if(pRTS && pRTS->Open(fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0)
+ pSubStream = pRTS.Detach();
+ }
+ }
+ catch(CException* e)
+ {
+ e->Delete();
+ }
+
+ if(pSubStream)
+ {
+ //m_pSubStreams.AddTail(pSubStream);
+ ISubStream *r = InsertSubStream(&m_pSubStreams, pSubStream);
+ if(actualStream != NULL)
+ *actualStream = r;
+ }
+
+ return(!!pSubStream);
}
void CMainFrame::UpdateSubtitle(bool fApplyDefStyle)
{
- if(!m_pCAP) return;
+ if(!m_pCAP) return;
- int i = m_iSubtitleSel;
+ int i = m_iSubtitleSel;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos && i >= 0)
+ {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
- CAutoLock cAutoLock(&m_csSubLock);
- pSubStream->SetStream(i);
- SetSubtitle(pSubStream, fApplyDefStyle);
- return;
- }
+ if(i < pSubStream->GetStreamCount())
+ {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pSubStream->SetStream(i);
+ SetSubtitle(pSubStream, fApplyDefStyle);
+ return;
+ }
- i -= pSubStream->GetStreamCount();
- }
+ i -= pSubStream->GetStreamCount();
+ }
- m_pCAP->SetSubPicProvider(NULL);
+ m_pCAP->SetSubPicProvider(NULL);
}
void CMainFrame::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
{
- AppSettings& s = AfxGetAppSettings();
-
- if(pSubStream)
- {
- CLSID clsid;
- pSubStream->GetClassID(&clsid);
-
- if(clsid == __uuidof(CVobSubFile))
- {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
-
- if(fApplyDefStyle)
- {
- pVSF->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
- }
- }
- else if(clsid == __uuidof(CVobSubStream))
- {
- CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
-
- if(fApplyDefStyle)
- {
- pVSS->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
- }
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
-
- STSStyle style;
-
- if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle)
- {
- style = s.subdefstyle;
-
- if(s.fOverridePlacement)
- {
- style.scrAlignment = 2;
- int w = pRTS->m_dstScreenSize.cx;
- int h = pRTS->m_dstScreenSize.cy;
- int mw = w - style.marginRect.left - style.marginRect.right;
- style.marginRect.bottom = h - MulDiv(h, s.nVerPos, 100);
- style.marginRect.left = MulDiv(w, s.nHorPos, 100) - mw / 2;
- style.marginRect.right = w - (style.marginRect.left + mw);
- }
-
- bool res = pRTS->SetDefaultStyle(style);
- }
-
- if(pRTS->GetDefaultStyle(style) && style.relativeTo == 2)
- {
- style.relativeTo = s.subdefstyle.relativeTo;
- pRTS->SetDefaultStyle(style);
- }
-
- pRTS->SetOverride(s.fUseDefaultSubtitlesStyle, &s.subdefstyle);
-
- pRTS->Deinit();
- }
- }
-
- if(!fApplyDefStyle)
- {
- m_iSubtitleSel = -1;
-
- if(pSubStream)
- {
-
- int i = 0;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
- CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
-
- if(pSubStream == pSubStream2)
- {
- m_iSubtitleSel = i + pSubStream2->GetStream();
- break;
- }
-
- i += pSubStream2->GetStreamCount();
- }
-
- }
- }
-
- m_nSubtitleId = (DWORD_PTR)pSubStream;
-
- if(m_pCAP)
- {
- m_pCAP->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
- m_wndSubresyncBar.SetSubtitle(pSubStream, m_pCAP->GetFPS());
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ if(pSubStream)
+ {
+ CLSID clsid;
+ pSubStream->GetClassID(&clsid);
+
+ if(clsid == __uuidof(CVobSubFile))
+ {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
+
+ if(fApplyDefStyle)
+ {
+ pVSF->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
+ }
+ }
+ else if(clsid == __uuidof(CVobSubStream))
+ {
+ CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
+
+ if(fApplyDefStyle)
+ {
+ pVSS->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
+ }
+ }
+ else if(clsid == __uuidof(CRenderedTextSubtitle))
+ {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
+
+ STSStyle style;
+
+ if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle)
+ {
+ style = s.subdefstyle;
+
+ if(s.fOverridePlacement)
+ {
+ style.scrAlignment = 2;
+ int w = pRTS->m_dstScreenSize.cx;
+ int h = pRTS->m_dstScreenSize.cy;
+ int mw = w - style.marginRect.left - style.marginRect.right;
+ style.marginRect.bottom = h - MulDiv(h, s.nVerPos, 100);
+ style.marginRect.left = MulDiv(w, s.nHorPos, 100) - mw/2;
+ style.marginRect.right = w - (style.marginRect.left + mw);
+ }
+
+ bool res = pRTS->SetDefaultStyle(style);
+ }
+
+ if(pRTS->GetDefaultStyle(style) && style.relativeTo == 2)
+ {
+ style.relativeTo = s.subdefstyle.relativeTo;
+ pRTS->SetDefaultStyle(style);
+ }
+
+ pRTS->SetOverride(s.fUseDefaultSubtitlesStyle, &s.subdefstyle);
+
+ pRTS->Deinit();
+ }
+ }
+
+ if(!fApplyDefStyle)
+ {
+ m_iSubtitleSel = -1;
+
+ if(pSubStream)
+ {
+
+ int i = 0;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos)
+ {
+ CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
+
+ if(pSubStream == pSubStream2)
+ {
+ m_iSubtitleSel = i + pSubStream2->GetStream();
+ break;
+ }
+
+ i += pSubStream2->GetStreamCount();
+ }
+
+ }
+ }
+
+ m_nSubtitleId = (DWORD_PTR)pSubStream;
+
+ if(m_pCAP)
+ {
+ m_pCAP->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
+ m_wndSubresyncBar.SetSubtitle(pSubStream, m_pCAP->GetFPS());
+ }
}
void CMainFrame::ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStreamNew)
{
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
- POSITION cur = pos;
- if(pSubStreamOld == m_pSubStreams.GetNext(pos))
- {
- m_pSubStreams.SetAt(cur, pSubStreamNew);
- UpdateSubtitle();
- break;
- }
- }
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos)
+ {
+ POSITION cur = pos;
+ if(pSubStreamOld == m_pSubStreams.GetNext(pos))
+ {
+ m_pSubStreams.SetAt(cur, pSubStreamNew);
+ UpdateSubtitle();
+ break;
+ }
+ }
}
void CMainFrame::InvalidateSubtitle(DWORD_PTR nSubtitleId, REFERENCE_TIME rtInvalidate)
{
- if(m_pCAP)
- {
- if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId)
- m_pCAP->Invalidate(rtInvalidate);
- }
+ if(m_pCAP)
+ {
+ if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId)
+ m_pCAP->Invalidate(rtInvalidate);
+ }
}
void CMainFrame::ReloadSubtitle()
{
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) m_pSubStreams.GetNext(pos)->Reload();
- UpdateSubtitle();
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while(pos) m_pSubStreams.GetNext(pos)->Reload();
+ UpdateSubtitle();
}
-void CMainFrame::SetSubtitleTrackIdx(int index)
-{
- if(m_iMediaLoadState == MLS_LOADED)
- {
- if(index < 0)
- {
- m_iSubtitleSel ^= 0x80000000;
- }
- else
- {
- POSITION pos = m_pSubStreams.FindIndex(index);
- if(pos)
- m_iSubtitleSel = index;
- }
- UpdateSubtitle();
- }
+void CMainFrame::SetSubtitleTrackIdx(int index) {
+ if(m_iMediaLoadState == MLS_LOADED) {
+ if (index < 0) {
+ m_iSubtitleSel ^= 0x80000000;
+ } else {
+ POSITION pos = m_pSubStreams.FindIndex(index);
+ if(pos)
+ m_iSubtitleSel = index;
+ }
+ UpdateSubtitle();
+ }
}
-void CMainFrame::SetAudioTrackIdx(int index)
-{
- if(m_iMediaLoadState == MLS_LOADED)
- {
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
-
- DWORD cStreams = 0;
- DWORD dwFlags = AMSTREAMSELECTENABLE_ENABLE;
- if(pSS && SUCCEEDED(pSS->Count(&cStreams)))
- if((index >= 0) && (index < ((int)cStreams)))
- pSS->Enable(index, dwFlags);
- }
+void CMainFrame::SetAudioTrackIdx(int index) {
+ if(m_iMediaLoadState == MLS_LOADED) {
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+
+ DWORD cStreams = 0;
+ DWORD dwFlags = AMSTREAMSELECTENABLE_ENABLE;
+ if(pSS && SUCCEEDED(pSS->Count(&cStreams)))
+ if((index >= 0) && (index < ((int)cStreams)))
+ pSS->Enable(index, dwFlags);
+ }
}
REFERENCE_TIME CMainFrame::GetPos()
{
- return(m_iMediaLoadState == MLS_LOADED ? m_wndSeekBar.GetPos() : 0);
+ return(m_iMediaLoadState == MLS_LOADED ? m_wndSeekBar.GetPos() : 0);
}
REFERENCE_TIME CMainFrame::GetDur()
{
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
- return(m_iMediaLoadState == MLS_LOADED ? stop : 0);
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+ return(m_iMediaLoadState == MLS_LOADED ? stop : 0);
}
void CMainFrame::SeekTo(REFERENCE_TIME rtPos, bool fSeekToKeyFrame)
{
- OAFilterState fs = GetMediaState();
-
- if(rtPos < 0) rtPos = 0;
-
- m_nStepForwardCount = 0;
- AppSettings &s = AfxGetAppSettings();
- if(m_iPlaybackMode != PM_CAPTURE)
- {
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
- GUID tf;
- pMS->GetTimeFormat(&tf);
- m_wndStatusBar.SetStatusTimer(rtPos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
- }
-
- if(m_iPlaybackMode == PM_FILE)
- {
- if(fs == State_Stopped)
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- HRESULT hr;
-
- if(fSeekToKeyFrame)
- {
- if(!m_kfs.IsEmpty())
- {
- int i = rangebsearch(rtPos, m_kfs);
- if(i >= 0 && i < m_kfs.GetCount())
- rtPos = m_kfs[i];
- }
- }
-
- hr = pMS->SetPositions(&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
- else if(m_iPlaybackMode == PM_DVD && m_iDVDDomain == DVD_DOMAIN_Title)
- {
- if(fs != State_Running)
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
-
- DVD_HMSF_TIMECODE tc = RT2HMSF(rtPos);
- pDVDC->PlayAtTime(&tc, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ OAFilterState fs = GetMediaState();
+
+ if(rtPos < 0) rtPos = 0;
+
+ m_nStepForwardCount = 0;
+ AppSettings &s = AfxGetAppSettings();
+ if(m_iPlaybackMode != PM_CAPTURE)
+ {
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+ GUID tf;
+ pMS->GetTimeFormat(&tf);
+ m_wndStatusBar.SetStatusTimer(rtPos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
+ }
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ if(fs == State_Stopped)
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ HRESULT hr;
+
+ if(fSeekToKeyFrame)
+ {
+ if(!m_kfs.IsEmpty())
+ {
+ int i = rangebsearch(rtPos, m_kfs);
+ if(i >= 0 && i < m_kfs.GetCount())
+ rtPos = m_kfs[i];
+ }
+ }
+
+ hr = pMS->SetPositions(&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
+ else if(m_iPlaybackMode == PM_DVD && m_iDVDDomain == DVD_DOMAIN_Title)
+ {
+ if(fs != State_Running)
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+
+ DVD_HMSF_TIMECODE tc = RT2HMSF(rtPos);
+ pDVDC->PlayAtTime(&tc, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
// if(fs != State_Running)
// SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- TRACE(_T("Warning (CMainFrame::SeekTo): Trying to seek in capture mode"));
- }
- m_fEndOfStream = false;
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ TRACE(_T("Warning (CMainFrame::SeekTo): Trying to seek in capture mode"));
+ }
+ m_fEndOfStream = false;
}
void CMainFrame::CleanGraph()
{
- if(!pGB) return;
+ if(!pGB) return;
- BeginEnumFilters(pGB, pEF, pBF)
- {
- CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if(pAMMF && (pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE))
- continue;
+ BeginEnumFilters(pGB, pEF, pBF)
+ {
+ CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
+ if(pAMMF && (pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE))
+ continue;
- // some capture filters forget to set AM_FILTER_MISC_FLAGS_IS_SOURCE
- // or to implement the IAMFilterMiscFlags interface
- if(pBF == pVidCap || pBF == pAudCap)
- continue;
+ // some capture filters forget to set AM_FILTER_MISC_FLAGS_IS_SOURCE
+ // or to implement the IAMFilterMiscFlags interface
+ if(pBF == pVidCap || pBF == pAudCap)
+ continue;
- if(CComQIPtr<IFileSourceFilter>(pBF))
- continue;
+ if(CComQIPtr<IFileSourceFilter>(pBF))
+ continue;
- int nIn, nOut, nInC, nOutC;
- if(CountPins(pBF, nIn, nOut, nInC, nOutC) > 0 && (nInC + nOutC) == 0)
- {
- TRACE(CStringW(L"Removing: ") + GetFilterName(pBF) + '\n');
+ int nIn, nOut, nInC, nOutC;
+ if(CountPins(pBF, nIn, nOut, nInC, nOutC) > 0 && (nInC+nOutC) == 0)
+ {
+ TRACE(CStringW(L"Removing: ") + GetFilterName(pBF) + '\n');
- pGB->RemoveFilter(pBF);
- pEF->Reset();
- }
- }
- EndEnumFilters
+ pGB->RemoveFilter(pBF);
+ pEF->Reset();
+ }
+ }
+ EndEnumFilters
}
#define AUDIOBUFFERLEN 500
static void SetLatency(IBaseFilter* pBF, int cbBuffer)
{
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(CComQIPtr<IAMBufferNegotiation> pAMBN = pPin)
- {
- ALLOCATOR_PROPERTIES ap;
- ap.cbAlign = -1; // -1 means no preference.
- ap.cbBuffer = cbBuffer;
- ap.cbPrefix = -1;
- ap.cBuffers = -1;
- pAMBN->SuggestAllocatorProperties(&ap);
- }
- }
- EndEnumPins
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(CComQIPtr<IAMBufferNegotiation> pAMBN = pPin)
+ {
+ ALLOCATOR_PROPERTIES ap;
+ ap.cbAlign = -1; // -1 means no preference.
+ ap.cbBuffer = cbBuffer;
+ ap.cbPrefix = -1;
+ ap.cBuffers = -1;
+ pAMBN->SuggestAllocatorProperties(&ap);
+ }
+ }
+ EndEnumPins
}
HRESULT CMainFrame::BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& majortype, AM_MEDIA_TYPE* pmt)
{
- IBaseFilter* pBuff = pBF[0];
- IBaseFilter* pEnc = pBF[1];
- IBaseFilter* pMux = pBF[2];
-
- if(!pPin || !pMux) return E_FAIL;
-
- CString err;
-
- HRESULT hr = S_OK;
-
- CFilterInfo fi;
- if(FAILED(pMux->QueryFilterInfo(&fi)) || !fi.pGraph)
- pGB->AddFilter(pMux, L"Multiplexer");
-
- CStringW prefix, prefixl;
- if(majortype == MEDIATYPE_Video) prefix = L"Video ";
- else if(majortype == MEDIATYPE_Audio) prefix = L"Audio ";
- prefixl = prefix;
- prefixl.MakeLower();
-
- if(pBuff)
- {
- hr = pGB->AddFilter(pBuff, prefix + L"Buffer");
- if(FAILED(hr))
- {
- err = _T("Can't add ") + CString(prefixl) + _T("buffer filter");
- AfxMessageBox(err);
- return hr;
- }
-
- hr = pGB->ConnectFilter(pPin, pBuff);
- if(FAILED(hr))
- {
- err = _T("Error connecting the ") + CString(prefixl) + _T("buffer filter");
- AfxMessageBox(err);
- return(hr);
- }
-
- pPin = GetFirstPin(pBuff, PINDIR_OUTPUT);
- }
-
- if(pEnc)
- {
- hr = pGB->AddFilter(pEnc, prefix + L"Encoder");
- if(FAILED(hr))
- {
- err = _T("Can't add ") + CString(prefixl) + _T("encoder filter");
- AfxMessageBox(err);
- return hr;
- }
-
- hr = pGB->ConnectFilter(pPin, pEnc);
- if(FAILED(hr))
- {
- err = _T("Error connecting the ") + CString(prefixl) + _T("encoder filter");
- AfxMessageBox(err);
- return(hr);
- }
-
- pPin = GetFirstPin(pEnc, PINDIR_OUTPUT);
-
- if(CComQIPtr<IAMStreamConfig> pAMSC = pPin)
- {
- if(pmt->majortype == majortype)
- {
- hr = pAMSC->SetFormat(pmt);
- if(FAILED(hr))
- {
- err = _T("Can't set compression format on the ") + CString(prefixl) + _T("encoder filter");
- AfxMessageBox(err);
- return(hr);
- }
- }
- }
-
- }
+ IBaseFilter* pBuff = pBF[0];
+ IBaseFilter* pEnc = pBF[1];
+ IBaseFilter* pMux = pBF[2];
+
+ if(!pPin || !pMux) return E_FAIL;
+
+ CString err;
+
+ HRESULT hr = S_OK;
+
+ CFilterInfo fi;
+ if(FAILED(pMux->QueryFilterInfo(&fi)) || !fi.pGraph)
+ pGB->AddFilter(pMux, L"Multiplexer");
+
+ CStringW prefix, prefixl;
+ if(majortype == MEDIATYPE_Video) prefix = L"Video ";
+ else if(majortype == MEDIATYPE_Audio) prefix = L"Audio ";
+ prefixl = prefix;
+ prefixl.MakeLower();
+
+ if(pBuff)
+ {
+ hr = pGB->AddFilter(pBuff, prefix + L"Buffer");
+ if(FAILED(hr))
+ {
+ err = _T("Can't add ") + CString(prefixl) + _T("buffer filter");
+ AfxMessageBox(err);
+ return hr;
+ }
+
+ hr = pGB->ConnectFilter(pPin, pBuff);
+ if(FAILED(hr))
+ {
+ err = _T("Error connecting the ") + CString(prefixl) + _T("buffer filter");
+ AfxMessageBox(err);
+ return(hr);
+ }
+
+ pPin = GetFirstPin(pBuff, PINDIR_OUTPUT);
+ }
+
+ if(pEnc)
+ {
+ hr = pGB->AddFilter(pEnc, prefix + L"Encoder");
+ if(FAILED(hr))
+ {
+ err = _T("Can't add ") + CString(prefixl) + _T("encoder filter");
+ AfxMessageBox(err);
+ return hr;
+ }
+
+ hr = pGB->ConnectFilter(pPin, pEnc);
+ if(FAILED(hr))
+ {
+ err = _T("Error connecting the ") + CString(prefixl) + _T("encoder filter");
+ AfxMessageBox(err);
+ return(hr);
+ }
+
+ pPin = GetFirstPin(pEnc, PINDIR_OUTPUT);
+
+ if(CComQIPtr<IAMStreamConfig> pAMSC = pPin)
+ {
+ if(pmt->majortype == majortype)
+ {
+ hr = pAMSC->SetFormat(pmt);
+ if(FAILED(hr))
+ {
+ err = _T("Can't set compression format on the ") + CString(prefixl) + _T("encoder filter");
+ AfxMessageBox(err);
+ return(hr);
+ }
+ }
+ }
+
+ }
// if(pMux)
- {
- hr = pGB->ConnectFilter(pPin, pMux);
- if(FAILED(hr))
- {
- err = _T("Error connecting ") + CString(prefixl) + _T(" to the muliplexer filter");
- AfxMessageBox(err);
- return(hr);
- }
- }
+ {
+ hr = pGB->ConnectFilter(pPin, pMux);
+ if(FAILED(hr))
+ {
+ err = _T("Error connecting ") + CString(prefixl) + _T(" to the muliplexer filter");
+ AfxMessageBox(err);
+ return(hr);
+ }
+ }
- CleanGraph();
+ CleanGraph();
- return S_OK;
+ return S_OK;
}
bool CMainFrame::BuildToCapturePreviewPin(
- IBaseFilter* pVidCap, IPin** ppVidCapPin, IPin** ppVidPrevPin,
- IBaseFilter* pAudCap, IPin** ppAudCapPin, IPin** ppAudPrevPin)
-{
- HRESULT hr;
-
- *ppVidCapPin = *ppVidPrevPin = NULL;
- *ppAudCapPin = *ppAudPrevPin = NULL;
-
- CComPtr<IPin> pDVAudPin;
-
- if(pVidCap)
- {
- CComPtr<IPin> pPin;
- if(!pAudCap // only look for interleaved stream when we don't use any other audio capture source
- && SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, TRUE, 0, &pPin)))
- {
- CComPtr<IBaseFilter> pDVSplitter;
- hr = pDVSplitter.CoCreateInstance(CLSID_DVSplitter);
- hr = pGB->AddFilter(pDVSplitter, L"DV Splitter");
-
- hr = pCGB->RenderStream(NULL, &MEDIATYPE_Interleaved, pPin, NULL, pDVSplitter);
-
- pPin = NULL;
- hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
- hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Audio, TRUE, 0, &pDVAudPin);
-
- CComPtr<IBaseFilter> pDVDec;
- hr = pDVDec.CoCreateInstance(CLSID_DVVideoCodec);
- hr = pGB->AddFilter(pDVDec, L"DV Video Decoder");
-
- hr = pGB->ConnectFilter(pPin, pDVDec);
-
- pPin = NULL;
- hr = pCGB->FindPin(pDVDec, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
- }
- else if(SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, TRUE, 0, &pPin)))
- {
- }
- else
- {
- AfxMessageBox(_T("No video capture pin was found"));
- return(false);
- }
-
- CComPtr<IBaseFilter> pSmartTee;
- hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
- hr = pGB->AddFilter(pSmartTee, L"Smart Tee (video)");
-
- hr = pGB->ConnectFilter(pPin, pSmartTee);
-
- hr = pSmartTee->FindPin(L"Preview", ppVidPrevPin);
- hr = pSmartTee->FindPin(L"Capture", ppVidCapPin);
- }
-
- if(pAudCap || pDVAudPin)
- {
- CComPtr<IPin> pPin;
- if(pDVAudPin)
- {
- pPin = pDVAudPin;
- }
- else if(SUCCEEDED(pCGB->FindPin(pAudCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, TRUE, 0, &pPin)))
- {
- }
- else
- {
- AfxMessageBox(_T("No audio capture pin was found"));
- return(false);
- }
-
- CComPtr<IBaseFilter> pSmartTee;
- hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
- hr = pGB->AddFilter(pSmartTee, L"Smart Tee (audio)");
-
- hr = pGB->ConnectFilter(pPin, pSmartTee);
-
- hr = pSmartTee->FindPin(L"Preview", ppAudPrevPin);
- hr = pSmartTee->FindPin(L"Capture", ppAudCapPin);
- }
-
- return(true);
+ IBaseFilter* pVidCap, IPin** ppVidCapPin, IPin** ppVidPrevPin,
+ IBaseFilter* pAudCap, IPin** ppAudCapPin, IPin** ppAudPrevPin)
+{
+ HRESULT hr;
+
+ *ppVidCapPin = *ppVidPrevPin = NULL;
+ *ppAudCapPin = *ppAudPrevPin = NULL;
+
+ CComPtr<IPin> pDVAudPin;
+
+ if(pVidCap)
+ {
+ CComPtr<IPin> pPin;
+ if(!pAudCap // only look for interleaved stream when we don't use any other audio capture source
+ && SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, TRUE, 0, &pPin)))
+ {
+ CComPtr<IBaseFilter> pDVSplitter;
+ hr = pDVSplitter.CoCreateInstance(CLSID_DVSplitter);
+ hr = pGB->AddFilter(pDVSplitter, L"DV Splitter");
+
+ hr = pCGB->RenderStream(NULL, &MEDIATYPE_Interleaved, pPin, NULL, pDVSplitter);
+
+ pPin = NULL;
+ hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
+ hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Audio, TRUE, 0, &pDVAudPin);
+
+ CComPtr<IBaseFilter> pDVDec;
+ hr = pDVDec.CoCreateInstance(CLSID_DVVideoCodec);
+ hr = pGB->AddFilter(pDVDec, L"DV Video Decoder");
+
+ hr = pGB->ConnectFilter(pPin, pDVDec);
+
+ pPin = NULL;
+ hr = pCGB->FindPin(pDVDec, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
+ }
+ else if(SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, TRUE, 0, &pPin)))
+ {
+ }
+ else
+ {
+ AfxMessageBox(_T("No video capture pin was found"));
+ return(false);
+ }
+
+ CComPtr<IBaseFilter> pSmartTee;
+ hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
+ hr = pGB->AddFilter(pSmartTee, L"Smart Tee (video)");
+
+ hr = pGB->ConnectFilter(pPin, pSmartTee);
+
+ hr = pSmartTee->FindPin(L"Preview", ppVidPrevPin);
+ hr = pSmartTee->FindPin(L"Capture", ppVidCapPin);
+ }
+
+ if(pAudCap || pDVAudPin)
+ {
+ CComPtr<IPin> pPin;
+ if(pDVAudPin)
+ {
+ pPin = pDVAudPin;
+ }
+ else if(SUCCEEDED(pCGB->FindPin(pAudCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, TRUE, 0, &pPin)))
+ {
+ }
+ else
+ {
+ AfxMessageBox(_T("No audio capture pin was found"));
+ return(false);
+ }
+
+ CComPtr<IBaseFilter> pSmartTee;
+ hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
+ hr = pGB->AddFilter(pSmartTee, L"Smart Tee (audio)");
+
+ hr = pGB->ConnectFilter(pPin, pSmartTee);
+
+ hr = pSmartTee->FindPin(L"Preview", ppAudPrevPin);
+ hr = pSmartTee->FindPin(L"Capture", ppAudCapPin);
+ }
+
+ return(true);
}
bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPreview, bool fACapture)
{
- if(!pCGB) return(false);
+ if(!pCGB) return(false);
- SaveMediaState;
+ SaveMediaState;
- HRESULT hr;
+ HRESULT hr;
- pGB->NukeDownstream(pVidCap);
- pGB->NukeDownstream(pAudCap);
+ pGB->NukeDownstream(pVidCap);
+ pGB->NukeDownstream(pAudCap);
- CleanGraph();
+ CleanGraph();
- if(pAMVSCCap) hr = pAMVSCCap->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
- if(pAMVSCPrev) hr = pAMVSCPrev->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
- if(pAMASC) hr = pAMASC->SetFormat(&m_wndCaptureBar.m_capdlg.m_mta);
+ if(pAMVSCCap) hr = pAMVSCCap->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
+ if(pAMVSCPrev) hr = pAMVSCPrev->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
+ if(pAMASC) hr = pAMASC->SetFormat(&m_wndCaptureBar.m_capdlg.m_mta);
- CComPtr<IBaseFilter> pVidBuffer = m_wndCaptureBar.m_capdlg.m_pVidBuffer;
- CComPtr<IBaseFilter> pAudBuffer = m_wndCaptureBar.m_capdlg.m_pAudBuffer;
- CComPtr<IBaseFilter> pVidEnc = m_wndCaptureBar.m_capdlg.m_pVidEnc;
- CComPtr<IBaseFilter> pAudEnc = m_wndCaptureBar.m_capdlg.m_pAudEnc;
- CComPtr<IBaseFilter> pMux = m_wndCaptureBar.m_capdlg.m_pMux;
- CComPtr<IBaseFilter> pDst = m_wndCaptureBar.m_capdlg.m_pDst;
- CComPtr<IBaseFilter> pAudMux = m_wndCaptureBar.m_capdlg.m_pAudMux;
- CComPtr<IBaseFilter> pAudDst = m_wndCaptureBar.m_capdlg.m_pAudDst;
+ CComPtr<IBaseFilter> pVidBuffer = m_wndCaptureBar.m_capdlg.m_pVidBuffer;
+ CComPtr<IBaseFilter> pAudBuffer = m_wndCaptureBar.m_capdlg.m_pAudBuffer;
+ CComPtr<IBaseFilter> pVidEnc = m_wndCaptureBar.m_capdlg.m_pVidEnc;
+ CComPtr<IBaseFilter> pAudEnc = m_wndCaptureBar.m_capdlg.m_pAudEnc;
+ CComPtr<IBaseFilter> pMux = m_wndCaptureBar.m_capdlg.m_pMux;
+ CComPtr<IBaseFilter> pDst = m_wndCaptureBar.m_capdlg.m_pDst;
+ CComPtr<IBaseFilter> pAudMux = m_wndCaptureBar.m_capdlg.m_pAudMux;
+ CComPtr<IBaseFilter> pAudDst = m_wndCaptureBar.m_capdlg.m_pAudDst;
- bool fFileOutput = (pMux && pDst) || (pAudMux && pAudDst);
- bool fCapture = (fVCapture || fACapture);
+ bool fFileOutput = (pMux && pDst) || (pAudMux && pAudDst);
+ bool fCapture = (fVCapture || fACapture);
- if(pAudCap)
- {
- AM_MEDIA_TYPE* pmt = &m_wndCaptureBar.m_capdlg.m_mta;
- int ms = (fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput) ? AUDIOBUFFERLEN : 60;
- if(pMux != pAudMux && fACapture) SetLatency(pAudCap, -1);
- else if(pmt->pbFormat) SetLatency(pAudCap, ((WAVEFORMATEX*)pmt->pbFormat)->nAvgBytesPerSec * ms / 1000);
- }
+ if(pAudCap)
+ {
+ AM_MEDIA_TYPE* pmt = &m_wndCaptureBar.m_capdlg.m_mta;
+ int ms = (fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput) ? AUDIOBUFFERLEN : 60;
+ if(pMux != pAudMux && fACapture) SetLatency(pAudCap, -1);
+ else if(pmt->pbFormat) SetLatency(pAudCap, ((WAVEFORMATEX*)pmt->pbFormat)->nAvgBytesPerSec * ms / 1000);
+ }
- CComPtr<IPin> pVidCapPin, pVidPrevPin, pAudCapPin, pAudPrevPin;
- BuildToCapturePreviewPin(pVidCap, &pVidCapPin, &pVidPrevPin, pAudCap, &pAudCapPin, &pAudPrevPin);
+ CComPtr<IPin> pVidCapPin, pVidPrevPin, pAudCapPin, pAudPrevPin;
+ BuildToCapturePreviewPin(pVidCap, &pVidCapPin, &pVidPrevPin, pAudCap, &pAudCapPin, &pAudPrevPin);
// if(pVidCap)
- {
- bool fVidPrev = pVidPrevPin && fVPreview;
- bool fVidCap = pVidCapPin && fVCapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fVidOutput;
-
- if(fVPreview == 2 && !fVidCap && pVidCapPin)
- {
- pVidPrevPin = pVidCapPin;
- pVidCapPin = NULL;
- }
-
- if(fVidPrev)
- {
- m_pCAP = NULL;
- m_pCAP2 = NULL;
- pGB->Render(pVidPrevPin);
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
- }
-
- if(fVidCap)
- {
- IBaseFilter* pBF[3] = {pVidBuffer, pVidEnc, pMux};
- HRESULT hr = BuildCapture(pVidCapPin, pBF, MEDIATYPE_Video, &m_wndCaptureBar.m_capdlg.m_mtcv);
- }
-
- pAMDF = NULL;
- pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMDroppedFrames, (void**)&pAMDF);
- }
+ {
+ bool fVidPrev = pVidPrevPin && fVPreview;
+ bool fVidCap = pVidCapPin && fVCapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fVidOutput;
+
+ if(fVPreview == 2 && !fVidCap && pVidCapPin)
+ {
+ pVidPrevPin = pVidCapPin;
+ pVidCapPin = NULL;
+ }
+
+ if(fVidPrev)
+ {
+ m_pCAP = NULL;
+ m_pCAP2 = NULL;
+ pGB->Render(pVidPrevPin);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
+ }
+
+ if(fVidCap)
+ {
+ IBaseFilter* pBF[3] = {pVidBuffer, pVidEnc, pMux};
+ HRESULT hr = BuildCapture(pVidCapPin, pBF, MEDIATYPE_Video, &m_wndCaptureBar.m_capdlg.m_mtcv);
+ }
+
+ pAMDF = NULL;
+ pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMDroppedFrames, (void**)&pAMDF);
+ }
// if(pAudCap)
- {
- bool fAudPrev = pAudPrevPin && fAPreview;
- bool fAudCap = pAudCapPin && fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput;
-
- if(fAPreview == 2 && !fAudCap && pAudCapPin)
- {
- pAudPrevPin = pAudCapPin;
- pAudCapPin = NULL;
- }
-
- if(fAudPrev)
- {
- pGB->Render(pAudPrevPin);
- }
-
- if(fAudCap)
- {
- IBaseFilter* pBF[3] = {pAudBuffer, pAudEnc, pAudMux ? pAudMux : pMux};
- HRESULT hr = BuildCapture(pAudCapPin, pBF, MEDIATYPE_Audio, &m_wndCaptureBar.m_capdlg.m_mtca);
- }
- }
-
- if((pVidCap || pAudCap) && fCapture && fFileOutput)
- {
- if(pMux != pDst)
- {
- hr = pGB->AddFilter(pDst, L"File Writer V/A");
- hr = pGB->ConnectFilter(GetFirstPin(pMux, PINDIR_OUTPUT), pDst);
- }
-
- if(CComQIPtr<IConfigAviMux> pCAM = pMux)
- {
- int nIn, nOut, nInC, nOutC;
- CountPins(pMux, nIn, nOut, nInC, nOutC);
- pCAM->SetMasterStream(nInC - 1);
+ {
+ bool fAudPrev = pAudPrevPin && fAPreview;
+ bool fAudCap = pAudCapPin && fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput;
+
+ if(fAPreview == 2 && !fAudCap && pAudCapPin)
+ {
+ pAudPrevPin = pAudCapPin;
+ pAudCapPin = NULL;
+ }
+
+ if(fAudPrev)
+ {
+ pGB->Render(pAudPrevPin);
+ }
+
+ if(fAudCap)
+ {
+ IBaseFilter* pBF[3] = {pAudBuffer, pAudEnc, pAudMux ? pAudMux : pMux};
+ HRESULT hr = BuildCapture(pAudCapPin, pBF, MEDIATYPE_Audio, &m_wndCaptureBar.m_capdlg.m_mtca);
+ }
+ }
+
+ if((pVidCap || pAudCap) && fCapture && fFileOutput)
+ {
+ if(pMux != pDst)
+ {
+ hr = pGB->AddFilter(pDst, L"File Writer V/A");
+ hr = pGB->ConnectFilter(GetFirstPin(pMux, PINDIR_OUTPUT), pDst);
+ }
+
+ if(CComQIPtr<IConfigAviMux> pCAM = pMux)
+ {
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pMux, nIn, nOut, nInC, nOutC);
+ pCAM->SetMasterStream(nInC-1);
// pCAM->SetMasterStream(-1);
- pCAM->SetOutputCompatibilityIndex(FALSE);
- }
+ pCAM->SetOutputCompatibilityIndex(FALSE);
+ }
- if(CComQIPtr<IConfigInterleaving> pCI = pMux)
- {
+ if(CComQIPtr<IConfigInterleaving> pCI = pMux)
+ {
// if(FAILED(pCI->put_Mode(INTERLEAVE_CAPTURE)))
- if(FAILED(pCI->put_Mode(INTERLEAVE_NONE_BUFFERED)))
- pCI->put_Mode(INTERLEAVE_NONE);
+ if(FAILED(pCI->put_Mode(INTERLEAVE_NONE_BUFFERED)))
+ pCI->put_Mode(INTERLEAVE_NONE);
- REFERENCE_TIME rtInterleave = 10000i64 * AUDIOBUFFERLEN, rtPreroll = 0; //10000i64*500
- pCI->put_Interleaving(&rtInterleave, &rtPreroll);
- }
+ REFERENCE_TIME rtInterleave = 10000i64*AUDIOBUFFERLEN, rtPreroll = 0;//10000i64*500
+ pCI->put_Interleaving(&rtInterleave, &rtPreroll);
+ }
- if(pMux != pAudMux && pAudMux != pAudDst)
- {
- hr = pGB->AddFilter(pAudDst, L"File Writer A");
- hr = pGB->ConnectFilter(GetFirstPin(pAudMux, PINDIR_OUTPUT), pAudDst);
- }
- }
+ if(pMux != pAudMux && pAudMux != pAudDst)
+ {
+ hr = pGB->AddFilter(pAudDst, L"File Writer A");
+ hr = pGB->ConnectFilter(GetFirstPin(pAudMux, PINDIR_OUTPUT), pAudDst);
+ }
+ }
- REFERENCE_TIME stop = MAX_TIME;
- hr = pCGB->ControlStream(&PIN_CATEGORY_CAPTURE, NULL, NULL, NULL, &stop, 0, 0); // stop in the infinite
+ REFERENCE_TIME stop = MAX_TIME;
+ hr = pCGB->ControlStream(&PIN_CATEGORY_CAPTURE, NULL, NULL, NULL, &stop, 0, 0); // stop in the infinite
- CleanGraph();
+ CleanGraph();
- OpenSetupVideo();
- OpenSetupAudio();
- OpenSetupStatsBar();
- OpenSetupStatusBar();
+ OpenSetupVideo();
+ OpenSetupAudio();
+ OpenSetupStatsBar();
+ OpenSetupStatusBar();
- RestoreMediaState;
+ RestoreMediaState;
- return(true);
+ return(true);
}
bool CMainFrame::StartCapture()
{
- if(!pCGB || m_fCapturing) return(false);
+ if(!pCGB || m_fCapturing) return(false);
- if(!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) return(false);
+ if(!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) return(false);
- HRESULT hr;
+ HRESULT hr;
- ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+ ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
- // rare to see two capture filters to support IAMPushSource at the same time...
+ // rare to see two capture filters to support IAMPushSource at the same time...
// hr = CComQIPtr<IAMGraphStreams>(pGB)->SyncUsingStreamOffset(TRUE); // TODO:
- BuildGraphVideoAudio(
- m_wndCaptureBar.m_capdlg.m_fVidPreview, true,
- m_wndCaptureBar.m_capdlg.m_fAudPreview, true);
+ BuildGraphVideoAudio(
+ m_wndCaptureBar.m_capdlg.m_fVidPreview, true,
+ m_wndCaptureBar.m_capdlg.m_fAudPreview, true);
- hr = pME->CancelDefaultHandling(EC_REPAINT);
+ hr = pME->CancelDefaultHandling(EC_REPAINT);
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- m_fCapturing = true;
+ m_fCapturing = true;
- return(true);
+ return(true);
}
bool CMainFrame::StopCapture()
{
- if(!pCGB || !m_fCapturing) return(false);
+ if(!pCGB || !m_fCapturing) return(false);
- if(!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) return(false);
+ if(!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) return(false);
- HRESULT hr;
+ HRESULT hr;
- m_wndStatusBar.SetStatusMessage(ResStr(IDS_CONTROLS_COMPLETING));
+ m_wndStatusBar.SetStatusMessage(ResStr(IDS_CONTROLS_COMPLETING));
- m_fCapturing = false;
+ m_fCapturing = false;
- BuildGraphVideoAudio(
- m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
- m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
+ BuildGraphVideoAudio(
+ m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
+ m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
- hr = pME->RestoreDefaultHandling(EC_REPAINT);
+ hr = pME->RestoreDefaultHandling(EC_REPAINT);
- ::SetPriorityClass(::GetCurrentProcess(), AfxGetAppSettings().priority);
+ ::SetPriorityClass(::GetCurrentProcess(), AfxGetAppSettings().priority);
- m_rtDurationOverride = -1;
+ m_rtDurationOverride = -1;
- return(true);
+ return(true);
}
//
void CMainFrame::ShowOptions(int idPage)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), pGB, GetModalParent(), idPage);
+ CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), pGB, GetModalParent(), idPage);
- m_bInOptions = true;
- if(options.DoModal() == IDOK)
- {
- m_bInOptions = false;
- if(!m_fFullScreen)
- SetAlwaysOnTop(s.iOnTop);
+ m_bInOptions = true;
+ if(options.DoModal() == IDOK)
+ {
+ m_bInOptions = false;
+ if(!m_fFullScreen)
+ SetAlwaysOnTop(s.iOnTop);
- m_wndView.LoadLogo();
+ m_wndView.LoadLogo();
- s.UpdateData(true);
- }
- m_bInOptions = false;
+ s.UpdateData(true);
+ }
+ m_bInOptions = false;
}
void CMainFrame::StartWebServer(int nPort)
{
- if(!m_pWebServer)
- m_pWebServer.Attach(DNew CWebServer(this, nPort));
+ if(!m_pWebServer)
+ m_pWebServer.Attach(DNew CWebServer(this, nPort));
}
void CMainFrame::StopWebServer()
{
- if(m_pWebServer)
- m_pWebServer.Free();
+ if(m_pWebServer)
+ m_pWebServer.Free();
}
CString CMainFrame::GetStatusMessage()
{
- CString str;
- m_wndStatusBar.m_status.GetWindowText(str);
- return str;
+ CString str;
+ m_wndStatusBar.m_status.GetWindowText(str);
+ return str;
}
void CMainFrame::SendStatusMessage(CString msg, int nTimeOut)
{
- KillTimer(TIMER_STATUSERASER);
+ KillTimer(TIMER_STATUSERASER);
- m_playingmsg.Empty();
- if(nTimeOut <= 0) return;
+ m_playingmsg.Empty();
+ if(nTimeOut <= 0) return;
- m_playingmsg = msg;
- SetTimer(TIMER_STATUSERASER, nTimeOut, NULL);
- m_Lcd.SetStatusMessage(msg, nTimeOut);
+ m_playingmsg = msg;
+ SetTimer(TIMER_STATUSERASER, nTimeOut, NULL);
+ m_Lcd.SetStatusMessage(msg, nTimeOut);
}
void CMainFrame::OpenCurPlaylistItem(REFERENCE_TIME rtStart)
{
- if(m_wndPlaylistBar.GetCount() == 0)
- return;
+ if(m_wndPlaylistBar.GetCount() == 0)
+ return;
- CPlaylistItem pli;
- if(!m_wndPlaylistBar.GetCur(pli)) m_wndPlaylistBar.SetFirstSelected();
- if(!m_wndPlaylistBar.GetCur(pli)) return;
+ CPlaylistItem pli;
+ if(!m_wndPlaylistBar.GetCur(pli)) m_wndPlaylistBar.SetFirstSelected();
+ if(!m_wndPlaylistBar.GetCur(pli)) return;
- CAutoPtr<OpenMediaData> p(m_wndPlaylistBar.GetCurOMD(rtStart));
- if(p) OpenMedia(p);
+ CAutoPtr<OpenMediaData> p(m_wndPlaylistBar.GetCurOMD(rtStart));
+ if(p) OpenMedia(p);
}
void CMainFrame::AddCurDevToPlaylist()
{
- if(m_iPlaybackMode == PM_CAPTURE)
- {
- m_wndPlaylistBar.Append(
- m_VidDispName,
- m_AudDispName,
- m_wndCaptureBar.m_capdlg.GetVideoInput(),
- m_wndCaptureBar.m_capdlg.GetVideoChannel(),
- m_wndCaptureBar.m_capdlg.GetAudioInput()
- );
- }
+ if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ m_wndPlaylistBar.Append(
+ m_VidDispName,
+ m_AudDispName,
+ m_wndCaptureBar.m_capdlg.GetVideoInput(),
+ m_wndCaptureBar.m_capdlg.GetVideoChannel(),
+ m_wndCaptureBar.m_capdlg.GetAudioInput()
+ );
+ }
}
static int s_fOpenedThruThread = false;
void CMainFrame::OpenMedia(CAutoPtr<OpenMediaData> pOMD)
{
- // shortcut
- if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
- {
- if(m_iMediaLoadState == MLS_LOADED && pAMTuner
- && m_VidDispName == p->DisplayName[0] && m_AudDispName == p->DisplayName[1])
- {
- m_wndCaptureBar.m_capdlg.SetVideoInput(p->vinput);
- m_wndCaptureBar.m_capdlg.SetVideoChannel(p->vchannel);
- m_wndCaptureBar.m_capdlg.SetAudioInput(p->ainput);
- SendNowPlayingToMSN();
- SendNowPlayingTomIRC();
- return;
- }
- }
-
- if(m_iMediaLoadState != MLS_CLOSED)
- CloseMedia();
+ // shortcut
+ if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ {
+ if(m_iMediaLoadState == MLS_LOADED && pAMTuner
+ && m_VidDispName == p->DisplayName[0] && m_AudDispName == p->DisplayName[1])
+ {
+ m_wndCaptureBar.m_capdlg.SetVideoInput(p->vinput);
+ m_wndCaptureBar.m_capdlg.SetVideoChannel(p->vchannel);
+ m_wndCaptureBar.m_capdlg.SetAudioInput(p->ainput);
+ SendNowPlayingToMSN();
+ SendNowPlayingTomIRC();
+ return;
+ }
+ }
+
+ if(m_iMediaLoadState != MLS_CLOSED)
+ CloseMedia();
// m_iMediaLoadState = MLS_LOADING; // HACK: hides the logo
- AppSettings& s = AfxGetAppSettings();
-
- bool fUseThread = true;
-
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p))
- {
- if(p->fns.GetCount() > 0)
- {
- engine_t e = s.Formats.GetEngine(p->fns.GetHead());
- fUseThread = e == DirectShow /*|| e == RealMedia || e == QuickTime*/;
- }
- }
- else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
- {
- fUseThread = false;
- }
-
- if(m_pGraphThread && fUseThread
- && AfxGetAppSettings().fEnableWorkerThreadForOpening)
- {
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_OPEN, 0, (LPARAM)pOMD.Detach());
- s_fOpenedThruThread = true;
- }
- else
- {
- OpenMediaPrivate(pOMD);
- s_fOpenedThruThread = false;
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fUseThread = true;
+
+ if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p))
+ {
+ if(p->fns.GetCount() > 0)
+ {
+ engine_t e = s.Formats.GetEngine(p->fns.GetHead());
+ fUseThread = e == DirectShow /*|| e == RealMedia || e == QuickTime*/;
+ }
+ }
+ else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
+ {
+ fUseThread = false;
+ }
+
+ if(m_pGraphThread && fUseThread
+ && AfxGetAppSettings().fEnableWorkerThreadForOpening)
+ {
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_OPEN, 0, (LPARAM)pOMD.Detach());
+ s_fOpenedThruThread = true;
+ }
+ else
+ {
+ OpenMediaPrivate(pOMD);
+ s_fOpenedThruThread = false;
+ }
}
void CMainFrame::CloseMedia()
{
- if(m_iMediaLoadState == MLS_CLOSING)
- {
- TRACE(_T("WARNING: CMainFrame::CloseMedia() called twice or more\n"));
- return;
- }
+ if(m_iMediaLoadState == MLS_CLOSING)
+ {
+ TRACE(_T("WARNING: CMainFrame::CloseMedia() called twice or more\n"));
+ return;
+ }
- int nTimeWaited = 0;
+ int nTimeWaited = 0;
- while(m_iMediaLoadState == MLS_LOADING)
- {
- m_fOpeningAborted = true;
+ while(m_iMediaLoadState == MLS_LOADING)
+ {
+ m_fOpeningAborted = true;
- if(pGB) pGB->Abort(); // TODO: lock on graph objects somehow, this is not thread safe
+ if(pGB) pGB->Abort(); // TODO: lock on graph objects somehow, this is not thread safe
- if(nTimeWaited > 5 * 1000 && m_pGraphThread)
- {
- MessageBeep(MB_ICONEXCLAMATION);
- TRACE(_T("CRITICAL ERROR: !!! Must kill opener thread !!!"));
- TerminateThread(m_pGraphThread->m_hThread, -1);
- m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
- s_fOpenedThruThread = false;
- break;
- }
+ if(nTimeWaited > 5*1000 && m_pGraphThread)
+ {
+ MessageBeep(MB_ICONEXCLAMATION);
+ TRACE(_T("CRITICAL ERROR: !!! Must kill opener thread !!!"));
+ TerminateThread(m_pGraphThread->m_hThread, -1);
+ m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
+ s_fOpenedThruThread = false;
+ break;
+ }
- Sleep(50);
+ Sleep(50);
- nTimeWaited += 50;
- }
+ nTimeWaited += 50;
+ }
- m_fOpeningAborted = false;
+ m_fOpeningAborted = false;
- m_closingmsg.Empty();
+ m_closingmsg.Empty();
- SetLoadState(MLS_CLOSING);
+ SetLoadState (MLS_CLOSING);
- OnFilePostClosemedia();
+ OnFilePostClosemedia();
- if(m_pGraphThread && s_fOpenedThruThread)
- {
- CAMEvent e;
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_CLOSE, 0, (LPARAM)&e);
- e.Wait(); // either opening or closing has to be blocked to prevent reentering them, closing is the better choice
- }
- else
- {
- CloseMediaPrivate();
- }
+ if(m_pGraphThread && s_fOpenedThruThread)
+ {
+ CAMEvent e;
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_CLOSE, 0, (LPARAM)&e);
+ e.Wait(); // either opening or closing has to be blocked to prevent reentering them, closing is the better choice
+ }
+ else
+ {
+ CloseMediaPrivate();
+ }
- UnloadExternalObjects();
+ UnloadExternalObjects();
- if(m_pFullscreenWnd->IsWindow())
- m_pFullscreenWnd->ShowWindow(SW_HIDE);
+ if (m_pFullscreenWnd->IsWindow())
+ m_pFullscreenWnd->ShowWindow (SW_HIDE);
}
void CMainFrame::StartTunerScan(CAutoPtr<TunerScanData> pTSD)
{
- if(m_pGraphThread)
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_TUNER_SCAN, 0, (LPARAM)pTSD.Detach());
- else
- DoTunerScan(pTSD);
+ if(m_pGraphThread)
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_TUNER_SCAN, 0, (LPARAM)pTSD.Detach());
+ else
+ DoTunerScan(pTSD);
}
void CMainFrame::StopTunerScan()
{
- m_bStopTunerScan = true;
+ m_bStopTunerScan = true;
}
void CMainFrame::DisplayCurrentChannelOSD()
{
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
- CString osd;
- CString strDescription;
- int i = osd.Find(_T("\n"));
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.DVBLastChannel);
+ CString osd;
+ CString strDescription;
+ int i = osd.Find(_T("\n"));
- if(pChannel != NULL)
- {
- osd = pChannel->GetName();
- if(i > 0) osd.Delete(i, osd.GetLength() - i);
- m_OSD.DisplayMessage(OSD_TOPLEFT, osd , 2000);
- }
+ if (pChannel != NULL)
+ {
+ osd = pChannel->GetName();
+ if(i > 0) osd.Delete(i, osd.GetLength()-i);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, osd ,2000);
+ }
}
//
@@ -13085,617 +12652,606 @@ IMPLEMENT_DYNCREATE(CGraphThread, CWinThread)
BOOL CGraphThread::InitInstance()
{
- AfxSocketInit();
- return SUCCEEDED(CoInitialize(0)) ? TRUE : FALSE;
+ AfxSocketInit();
+ return SUCCEEDED(CoInitialize(0)) ? TRUE : FALSE;
}
int CGraphThread::ExitInstance()
{
- CoUninitialize();
- return __super::ExitInstance();
+ CoUninitialize();
+ return __super::ExitInstance();
}
BEGIN_MESSAGE_MAP(CGraphThread, CWinThread)
- ON_THREAD_MESSAGE(TM_EXIT, OnExit)
- ON_THREAD_MESSAGE(TM_OPEN, OnOpen)
- ON_THREAD_MESSAGE(TM_CLOSE, OnClose)
- ON_THREAD_MESSAGE(TM_TUNER_SCAN, OnTunerScan)
+ ON_THREAD_MESSAGE(TM_EXIT, OnExit)
+ ON_THREAD_MESSAGE(TM_OPEN, OnOpen)
+ ON_THREAD_MESSAGE(TM_CLOSE, OnClose)
+ ON_THREAD_MESSAGE(TM_TUNER_SCAN, OnTunerScan)
END_MESSAGE_MAP()
void CGraphThread::OnExit(WPARAM wParam, LPARAM lParam)
{
- PostQuitMessage(0);
- if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
+ PostQuitMessage(0);
+ if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
}
void CGraphThread::OnOpen(WPARAM wParam, LPARAM lParam)
{
- TRACE("--> CGraphThread::OnOpen on thread: %d\n", GetCurrentThreadId());
- if(m_pMainFrame)
- {
- CAutoPtr<OpenMediaData> pOMD((OpenMediaData*)lParam);
- m_pMainFrame->OpenMediaPrivate(pOMD);
- }
+ TRACE("--> CGraphThread::OnOpen on thread: %d\n", GetCurrentThreadId());
+ if(m_pMainFrame)
+ {
+ CAutoPtr<OpenMediaData> pOMD((OpenMediaData*)lParam);
+ m_pMainFrame->OpenMediaPrivate(pOMD);
+ }
}
void CGraphThread::OnClose(WPARAM wParam, LPARAM lParam)
{
- if(m_pMainFrame) m_pMainFrame->CloseMediaPrivate();
- if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
+ if(m_pMainFrame) m_pMainFrame->CloseMediaPrivate();
+ if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
}
void CGraphThread::OnTunerScan(WPARAM wParam, LPARAM lParam)
{
- if(m_pMainFrame)
- {
- CAutoPtr<TunerScanData> pTSD((TunerScanData*)lParam);
- m_pMainFrame->DoTunerScan(pTSD);
- }
+ if(m_pMainFrame)
+ {
+ CAutoPtr<TunerScanData> pTSD((TunerScanData*)lParam);
+ m_pMainFrame->DoTunerScan(pTSD);
+ }
}
// ==== Added by CASIMIR666
void CMainFrame::SetLoadState(MPC_LOADSTATE iState)
{
- m_iMediaLoadState = iState;
- SendAPICommand(CMD_STATE, L"%d", m_iMediaLoadState);
+ m_iMediaLoadState = iState;
+ SendAPICommand (CMD_STATE, L"%d", m_iMediaLoadState);
}
void CMainFrame::SetPlayState(MPC_PLAYSTATE iState)
{
- m_Lcd.SetPlayState((CMPC_Lcd::PlayState)iState);
- SendAPICommand(CMD_PLAYMODE, L"%d", iState);
+ m_Lcd.SetPlayState((CMPC_Lcd::PlayState)iState);
+ SendAPICommand (CMD_PLAYMODE, L"%d", iState);
- // Prevent sleep when playing audio and/or video, but allow screensaver when only audio
- if(!m_fAudioOnly)
- SetThreadExecutionState(iState == PS_PLAY ? ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
- else
- SetThreadExecutionState(iState == PS_PLAY ? ES_CONTINUOUS | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
+ // Prevent sleep when playing audio and/or video, but allow screensaver when only audio
+ if(!m_fAudioOnly)
+ SetThreadExecutionState (iState == PS_PLAY ? ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
+ else
+ SetThreadExecutionState (iState == PS_PLAY ? ES_CONTINUOUS | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
- // Set thumbnails button state
- UpdateThumbarButton();
+ // Set thumbnails button state
+ UpdateThumbarButton();
}
bool CMainFrame::CreateFullScreenWindow()
{
- HMONITOR hMonitor;
- MONITORINFOEX MonitorInfo;
- CRect MonitorRect;
-
- if(m_pFullscreenWnd->IsWindow())
- m_pFullscreenWnd->DestroyWindow();
-
- ZeroMemory(&MonitorInfo, sizeof(MonitorInfo));
- MonitorInfo.cbSize = sizeof(MonitorInfo);
-
- CMonitors monitors;
- CString str;
- CMonitor monitor;
- AppSettings& s = AfxGetAppSettings();
- hMonitor = NULL;
-
- if(!s.iMonitor)
- {
- if(s.f_hmonitor == _T("Current"))
- {
- hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
- else
- {
- for(int i = 0; i < monitors.GetCount(); i++)
- {
- monitor = monitors.GetMonitor(i);
- monitor.GetName(str);
-
- if((monitor.IsMonitor()) && (s.f_hmonitor == str))
- {
- hMonitor = monitor.operator HMONITOR();
- break;
- }
- }
- if(!hMonitor) hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
- }
- else
- {
- hMonitor = MonitorFromWindow(m_hWnd, 0);
- }
- if(GetMonitorInfo(hMonitor, &MonitorInfo))
- {
- MonitorRect = CRect(MonitorInfo.rcMonitor);
- // Creation de la fenetre
- DWORD dwStyle = WS_POPUP | WS_VISIBLE ;
- m_fullWndSize.cx = MonitorRect.Width();
- m_fullWndSize.cy = MonitorRect.Height();
-
- m_pFullscreenWnd->CreateEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, _T(""), ResStr(IDS_MAINFRM_136), dwStyle, MonitorRect.left, MonitorRect.top, MonitorRect.Width(), MonitorRect.Height(), NULL, NULL, NULL);
+ HMONITOR hMonitor;
+ MONITORINFOEX MonitorInfo;
+ CRect MonitorRect;
+
+ if (m_pFullscreenWnd->IsWindow())
+ m_pFullscreenWnd->DestroyWindow();
+
+ ZeroMemory (&MonitorInfo, sizeof(MonitorInfo));
+ MonitorInfo.cbSize = sizeof(MonitorInfo);
+
+ CMonitors monitors;
+ CString str;
+ CMonitor monitor;
+ AppSettings& s = AfxGetAppSettings();
+ hMonitor = NULL;
+
+ if(!s.iMonitor)
+ {
+ if(s.f_hmonitor == _T("Current"))
+ {
+ hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ }
+ else
+ {
+ for ( int i = 0; i < monitors.GetCount(); i++ )
+ {
+ monitor = monitors.GetMonitor( i );
+ monitor.GetName(str);
+
+ if((monitor.IsMonitor()) && (s.f_hmonitor == str))
+ {
+ hMonitor = monitor.operator HMONITOR();
+ break;
+ }
+ }
+ if(!hMonitor) hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ }
+ }
+ else
+ {
+ hMonitor = MonitorFromWindow (m_hWnd, 0);
+ }
+ if (GetMonitorInfo (hMonitor, &MonitorInfo))
+ {
+ MonitorRect = CRect (MonitorInfo.rcMonitor);
+ // Creation de la fenetre
+ DWORD dwStyle = WS_POPUP | WS_VISIBLE ;
+ m_fullWndSize.cx = MonitorRect.Width();
+ m_fullWndSize.cy = MonitorRect.Height();
+
+ m_pFullscreenWnd->CreateEx (WS_EX_TOPMOST | WS_EX_TOOLWINDOW, _T(""), ResStr(IDS_MAINFRM_136), dwStyle, MonitorRect.left, MonitorRect.top, MonitorRect.Width(), MonitorRect.Height(), NULL, NULL, NULL);
// SetWindowLong(m_pFullscreenWnd->m_hWnd, GWL_EXSTYLE, WS_EX_TOPMOST); // TODO : still freezing sometimes...
- /*
- CRect r;
- GetWindowRect(r);
-
- int x = MonitorRect.left + (MonitorRect.Width()/2)-(r.Width()/2);
- int y = MonitorRect.top + (MonitorRect.Height()/2)-(r.Height()/2);
- int w = r.Width();
- int h = r.Height();
- MoveWindow(x, y, w, h);
- */
- }
+ /*
+ CRect r;
+ GetWindowRect(r);
+
+ int x = MonitorRect.left + (MonitorRect.Width()/2)-(r.Width()/2);
+ int y = MonitorRect.top + (MonitorRect.Height()/2)-(r.Height()/2);
+ int w = r.Width();
+ int h = r.Height();
+ MoveWindow(x, y, w, h);
+ */
+ }
- return m_pFullscreenWnd->IsWindow();
+ return m_pFullscreenWnd->IsWindow();
}
bool CMainFrame::IsD3DFullScreenMode()
{
- return m_pFullscreenWnd->IsWindow();
+ return m_pFullscreenWnd->IsWindow();
};
void CMainFrame::SetVMR9ColorControl(float dBrightness, float dContrast, float dHue, float dSaturation)
{
- VMR9ProcAmpControl ClrControl;
-
- if(m_pMC && !AfxGetAppSettings().fVMR9MixerYUV)
- {
- ClrControl.dwSize = sizeof(ClrControl);
- ClrControl.dwFlags = ProcAmpControl9_Mask;
- ClrControl.Brightness = dBrightness;
- ClrControl.Contrast = dContrast;
- ClrControl.Hue = dHue;
- ClrControl.Saturation = dSaturation;
-
- m_pMC->SetProcAmpControl(0, &ClrControl);
- }
-}
-
-LPCTSTR CMainFrame::GetDVDAudioFormatName(DVD_AudioAttributes& ATR)
-{
- switch(ATR.AudioFormat)
- {
- case DVD_AudioFormat_AC3:
- return _T("AC3");
- case DVD_AudioFormat_MPEG1:
- case DVD_AudioFormat_MPEG1_DRC:
- return _T("MPEG1");
- case DVD_AudioFormat_MPEG2:
- case DVD_AudioFormat_MPEG2_DRC:
- return _T("MPEG2");
- case DVD_AudioFormat_LPCM:
- return _T("LPCM");
- case DVD_AudioFormat_DTS:
- return _T("DTS");
- case DVD_AudioFormat_SDDS:
- return _T("SDDS");
- case DVD_AudioFormat_Other:
- default:
- return ResStr(IDS_MAINFRM_137);
- }
+ VMR9ProcAmpControl ClrControl;
+
+ if(m_pMC && !AfxGetAppSettings().fVMR9MixerYUV)
+ {
+ ClrControl.dwSize = sizeof(ClrControl);
+ ClrControl.dwFlags = ProcAmpControl9_Mask;
+ ClrControl.Brightness = dBrightness;
+ ClrControl.Contrast = dContrast;
+ ClrControl.Hue = dHue;
+ ClrControl.Saturation = dSaturation;
+
+ m_pMC->SetProcAmpControl (0, &ClrControl);
+ }
+}
+
+LPCTSTR CMainFrame::GetDVDAudioFormatName (DVD_AudioAttributes& ATR)
+{
+ switch(ATR.AudioFormat)
+ {
+ case DVD_AudioFormat_AC3:
+ return _T("AC3");
+ case DVD_AudioFormat_MPEG1:
+ case DVD_AudioFormat_MPEG1_DRC:
+ return _T("MPEG1");
+ case DVD_AudioFormat_MPEG2:
+ case DVD_AudioFormat_MPEG2_DRC:
+ return _T("MPEG2");
+ case DVD_AudioFormat_LPCM:
+ return _T("LPCM");
+ case DVD_AudioFormat_DTS:
+ return _T("DTS");
+ case DVD_AudioFormat_SDDS:
+ return _T("SDDS");
+ case DVD_AudioFormat_Other:
+ default:
+ return ResStr(IDS_MAINFRM_137);
+ }
}
afx_msg void CMainFrame::OnGotoSubtitle(UINT nID)
{
- OnPlayPause();
- m_rtCurSubPos = m_wndSeekBar.GetPosReal();
- m_lSubtitleShift = 0;
- m_nCurSubtitle = m_wndSubresyncBar.FindNearestSub(m_rtCurSubPos, (nID == ID_GOTO_NEXT_SUB));
- if((m_nCurSubtitle != -1) && pMS)
- pMS->SetPositions(&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ OnPlayPause();
+ m_rtCurSubPos = m_wndSeekBar.GetPosReal();
+ m_lSubtitleShift = 0;
+ m_nCurSubtitle = m_wndSubresyncBar.FindNearestSub (m_rtCurSubPos, (nID == ID_GOTO_NEXT_SUB));
+ if ((m_nCurSubtitle != -1) && pMS)
+ pMS->SetPositions (&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
}
afx_msg void CMainFrame::OnShiftSubtitle(UINT nID)
{
- if(m_nCurSubtitle >= 0)
- {
- long lShift = (nID == ID_SHIFT_SUB_DOWN) ? -100 : 100;
- CString strSubShift;
+ if (m_nCurSubtitle >= 0)
+ {
+ long lShift = (nID == ID_SHIFT_SUB_DOWN) ? -100 : 100;
+ CString strSubShift;
- if(m_wndSubresyncBar.ShiftSubtitle(m_nCurSubtitle, lShift, m_rtCurSubPos))
- {
- m_lSubtitleShift += lShift;
- if(pMS) pMS->SetPositions(&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
+ if (m_wndSubresyncBar.ShiftSubtitle (m_nCurSubtitle, lShift, m_rtCurSubPos))
+ {
+ m_lSubtitleShift += lShift;
+ if (pMS) pMS->SetPositions (&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
- strSubShift.Format(ResStr(IDS_MAINFRM_138), m_lSubtitleShift);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strSubShift);
- }
+ strSubShift.Format (ResStr(IDS_MAINFRM_138), m_lSubtitleShift);
+ m_OSD.DisplayMessage (OSD_TOPLEFT, strSubShift);
+ }
}
afx_msg void CMainFrame::OnSubtitleDelay(UINT nID)
{
- if(m_pCAP)
- {
- if(m_pSubStreams.IsEmpty())
+ if(m_pCAP)
+ {
+ if (m_pSubStreams.IsEmpty())
{
SendStatusMessage(ResStr(IDS_SUBTITLES_ERROR), 3000);
return;
}
- int newDelay;
- int oldDelay = m_pCAP->GetSubtitleDelay();
+ int newDelay;
+ int oldDelay = m_pCAP->GetSubtitleDelay();
- if(nID == ID_SUB_DELAY_DOWN)
- newDelay = oldDelay - AfxGetAppSettings().nSubDelayInterval;
- else
- newDelay = oldDelay + AfxGetAppSettings().nSubDelayInterval;
+ if(nID == ID_SUB_DELAY_DOWN)
+ newDelay = oldDelay-AfxGetAppSettings().nSubDelayInterval;
+ else
+ newDelay = oldDelay+AfxGetAppSettings().nSubDelayInterval;
- SetSubtitleDelay(newDelay);
- }
+ SetSubtitleDelay(newDelay);
+ }
}
afx_msg void CMainFrame::OnLanguage(UINT nID)
{
- CMenu DefaultMenu;
- CMenu* OldMenu;
-
- AfxGetMyApp()->SetLanguage(nID - ID_LANGUAGE_ENGLISH);
-
- m_opencds.DestroyMenu();
- m_filters.DestroyMenu();
- m_subtitles.DestroyMenu();
- m_audios.DestroyMenu();
- m_navaudio.DestroyMenu();
- m_navsubtitle.DestroyMenu();
- m_navangle.DestroyMenu();
- m_navchapters.DestroyMenu();
- m_favorites.DestroyMenu();
- m_shaders.DestroyMenu();
- m_recentfiles.DestroyMenu();
-
- m_popup.DestroyMenu();
- m_popup.LoadMenu(IDR_POPUP);
- m_popupmain.DestroyMenu();
- m_popupmain.LoadMenu(IDR_POPUPMAIN);
-
- OldMenu = GetMenu();
- DefaultMenu.LoadMenu(IDR_MAINFRAME);
-
- SetMenu(&DefaultMenu);
- m_hMenuDefault = DefaultMenu;
- DefaultMenu.Detach();
- // TODO : destroy old menu ???
+ CMenu DefaultMenu;
+ CMenu* OldMenu;
+
+ AfxGetMyApp()->SetLanguage (nID - ID_LANGUAGE_ENGLISH);
+
+ m_opencds.DestroyMenu();
+ m_filters.DestroyMenu();
+ m_subtitles.DestroyMenu();
+ m_audios.DestroyMenu();
+ m_navaudio.DestroyMenu();
+ m_navsubtitle.DestroyMenu();
+ m_navangle.DestroyMenu();
+ m_navchapters.DestroyMenu();
+ m_favorites.DestroyMenu();
+ m_shaders.DestroyMenu();
+ m_recentfiles.DestroyMenu();
+
+ m_popup.DestroyMenu();
+ m_popup.LoadMenu(IDR_POPUP);
+ m_popupmain.DestroyMenu();
+ m_popupmain.LoadMenu(IDR_POPUPMAIN);
+
+ OldMenu = GetMenu();
+ DefaultMenu.LoadMenu(IDR_MAINFRAME);
+
+ SetMenu(&DefaultMenu);
+ m_hMenuDefault = DefaultMenu;
+ DefaultMenu.Detach();
+ // TODO : destroy old menu ???
// OldMenu->DestroyMenu();
}
afx_msg void CMainFrame::OnUpdateLanguage(CCmdUI* pCmdUI)
{
- AppSettings &s = AfxGetAppSettings();
- int nLang = pCmdUI->m_nID - ID_LANGUAGE_ENGLISH;
- LPCTSTR strSatellite = AfxGetMyApp()->GetSatelliteDll(nLang);
+ AppSettings &s = AfxGetAppSettings();
+ int nLang = pCmdUI->m_nID - ID_LANGUAGE_ENGLISH;
+ LPCTSTR strSatellite = AfxGetMyApp()->GetSatelliteDll(nLang);
- if(strSatellite)
- {
- HMODULE lib = NULL;
- if((lib = LoadLibrary(strSatellite)) != NULL)
- FreeLibrary(lib);
+ if (strSatellite)
+ {
+ HMODULE lib = NULL;
+ if ((lib = LoadLibrary(strSatellite)) != NULL)
+ FreeLibrary(lib);
- pCmdUI->Enable(lib != NULL);
- }
+ pCmdUI->Enable(lib != NULL);
+ }
- pCmdUI->SetCheck(nLang == s.iLanguage);
+ pCmdUI->SetCheck(nLang == s.iLanguage);
}
void CMainFrame::ProcessAPICommand(COPYDATASTRUCT* pCDS)
{
- CAtlList<CString> fns;
- REFERENCE_TIME rtPos = 0;
- long lPos = 0;
-
- switch(pCDS->dwData)
- {
- case CMD_OPENFILE :
- fns.AddHead((LPCWSTR)pCDS->lpData);
- m_wndPlaylistBar.Open(fns, false);
- OpenCurPlaylistItem();
- break;
- case CMD_STOP :
- OnPlayStop();
- break;
- case CMD_CLOSEFILE :
- CloseMedia();
- break;
- case CMD_PLAYPAUSE :
- OnPlayPlaypause();
- break;
- case CMD_ADDTOPLAYLIST :
- fns.AddHead((LPCWSTR)pCDS->lpData);
- m_wndPlaylistBar.Append(fns, true);
- break;
- case CMD_STARTPLAYLIST :
- OpenCurPlaylistItem();
- break;
- case CMD_CLEARPLAYLIST :
- m_wndPlaylistBar.Empty();
- break;
- case CMD_SETPOSITION :
- DVD_HMSF_TIMECODE tcPos;
-
- lPos = _wtol((LPCWSTR)pCDS->lpData);
- tcPos.bHours = lPos / 3600;
- tcPos.bMinutes = (lPos / 60) % 60;
- tcPos.bSeconds = lPos % 60;
- rtPos = HMSF2RT(tcPos);
- SeekTo(rtPos);
- break;
- case CMD_SETAUDIODELAY :
- rtPos = _wtol((LPCWSTR)pCDS->lpData) * 10000;
- SetAudioDelay(rtPos);
- break;
- case CMD_SETSUBTITLEDELAY :
- SetSubtitleDelay(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_SETINDEXPLAYLIST :
- //m_wndPlaylistBar.SetSelIdx(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_SETAUDIOTRACK :
- SetAudioTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_SETSUBTITLETRACK :
- SetSubtitleTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_GETSUBTITLETRACKS :
- SendSubtitleTracksToApi();
- break;
- case CMD_GETAUDIOTRACKS :
- SendAudioTracksToApi();
- break;
- case CMD_GETPLAYLIST :
- SendPlaylistToApi();
- break;
- case CMD_JUMPFORWARDMED :
- OnPlaySeek(ID_PLAY_SEEKFORWARDMED);
- break;
- case CMD_JUMPBACKWARDMED :
- OnPlaySeek(ID_PLAY_SEEKBACKWARDMED);
- break;
- case CMD_TOGGLEFULLSCREEN :
- OnViewFullscreen();
- break;
- case CMD_INCREASEVOLUME :
- m_wndToolBar.m_volctrl.IncreaseVolume();
- break;
- case CMD_DECREASEVOLUME :
- m_wndToolBar.m_volctrl.DecreaseVolume();
- break;
- case CMD_SHADER_TOGGLE :
- OnShaderToggle();
- break;
- case CMD_CLOSEAPP :
- PostMessage(WM_CLOSE);
- break;
- }
-}
-
-
-void CMainFrame::SendAPICommand(MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...)
-{
- AppSettings& s = AfxGetAppSettings();
-
- if(s.hMasterWnd)
- {
- COPYDATASTRUCT CDS;
- TCHAR buff[800];
-
- va_list args;
- va_start(args, fmt);
- _vstprintf(buff, fmt, args);
-
- CDS.cbData = (_tcslen(buff) + 1) * sizeof(TCHAR);
- CDS.dwData = nCommand;
- CDS.lpData = (LPVOID)buff;
-
- ::SendMessage(s.hMasterWnd, WM_COPYDATA, (WPARAM)GetSafeHwnd(), (LPARAM)&CDS);
-
- va_end(args);
- }
+ CAtlList<CString> fns;
+ REFERENCE_TIME rtPos = 0;
+ long lPos = 0;
+
+ switch (pCDS->dwData)
+ {
+ case CMD_OPENFILE :
+ fns.AddHead ((LPCWSTR)pCDS->lpData);
+ m_wndPlaylistBar.Open(fns, false);
+ OpenCurPlaylistItem();
+ break;
+ case CMD_STOP :
+ OnPlayStop();
+ break;
+ case CMD_CLOSEFILE :
+ CloseMedia();
+ break;
+ case CMD_PLAYPAUSE :
+ OnPlayPlaypause();
+ break;
+ case CMD_ADDTOPLAYLIST :
+ fns.AddHead ((LPCWSTR)pCDS->lpData);
+ m_wndPlaylistBar.Append(fns, true);
+ break;
+ case CMD_STARTPLAYLIST :
+ OpenCurPlaylistItem();
+ break;
+ case CMD_CLEARPLAYLIST :
+ m_wndPlaylistBar.Empty();
+ break;
+ case CMD_SETPOSITION :
+ DVD_HMSF_TIMECODE tcPos;
+
+ lPos = _wtol ((LPCWSTR)pCDS->lpData);
+ tcPos.bHours = lPos/3600;
+ tcPos.bMinutes = (lPos/60) % 60;
+ tcPos.bSeconds = lPos%60;
+ rtPos = HMSF2RT(tcPos);
+ SeekTo(rtPos);
+ break;
+ case CMD_SETAUDIODELAY :
+ rtPos = _wtol ((LPCWSTR)pCDS->lpData) * 10000;
+ SetAudioDelay (rtPos);
+ break;
+ case CMD_SETSUBTITLEDELAY :
+ SetSubtitleDelay(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_SETINDEXPLAYLIST :
+ //m_wndPlaylistBar.SetSelIdx(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_SETAUDIOTRACK :
+ SetAudioTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_SETSUBTITLETRACK :
+ SetSubtitleTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_GETSUBTITLETRACKS :
+ SendSubtitleTracksToApi();
+ break;
+ case CMD_GETAUDIOTRACKS :
+ SendAudioTracksToApi();
+ break;
+ case CMD_GETPLAYLIST :
+ SendPlaylistToApi();
+ break;
+ case CMD_JUMPFORWARDMED :
+ OnPlaySeek(ID_PLAY_SEEKFORWARDMED);
+ break;
+ case CMD_JUMPBACKWARDMED :
+ OnPlaySeek(ID_PLAY_SEEKBACKWARDMED);
+ break;
+ case CMD_TOGGLEFULLSCREEN :
+ OnViewFullscreen();
+ break;
+ case CMD_INCREASEVOLUME :
+ m_wndToolBar.m_volctrl.IncreaseVolume();
+ break;
+ case CMD_DECREASEVOLUME :
+ m_wndToolBar.m_volctrl.DecreaseVolume();
+ break;
+ case CMD_SHADER_TOGGLE :
+ OnShaderToggle();
+ break;
+ case CMD_CLOSEAPP :
+ PostMessage(WM_CLOSE);
+ break;
+ }
+}
+
+
+void CMainFrame::SendAPICommand (MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...)
+{
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.hMasterWnd)
+ {
+ COPYDATASTRUCT CDS;
+ TCHAR buff[800];
+
+ va_list args;
+ va_start(args, fmt);
+ _vstprintf(buff, fmt, args);
+
+ CDS.cbData = (_tcslen (buff) + 1) * sizeof(TCHAR);
+ CDS.dwData = nCommand;
+ CDS.lpData = (LPVOID)buff;
+
+ ::SendMessage(s.hMasterWnd, WM_COPYDATA, (WPARAM)GetSafeHwnd(), (LPARAM)&CDS);
+
+ va_end(args);
+ }
}
void CMainFrame::SendNowPlayingToApi()
{
- if(!AfxGetAppSettings().hMasterWnd)
- return;
-
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- CPlaylistItem pli;
- CString title, author, description;
- CString label;
- long lDuration = 0;
- REFERENCE_TIME rtDur;
-
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_DESCRIPTION), description);
-
- m_wndPlaylistBar.GetCur(pli);
- if(!pli.m_fns.IsEmpty())
- {
- label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
- if(m_iPlaybackMode == PM_FILE)
- {
- pMS->GetDuration(&rtDur);
- DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
- lDuration = tcDur.bHours * 60 * 60 + tcDur.bMinutes * 60 + tcDur.bSeconds;
- }
- /* CString label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
-
- if(m_iPlaybackMode == PM_FILE)
- {
- CString fn = label;
- if(fn.Find(_T("://")) >= 0) {int i = fn.Find('?'); if(i >= 0) fn = fn.Left(i);}
- CPath path(fn);
- path.StripPath();
- path.MakePretty();
- path.RemoveExtension();
- title = (LPCTSTR)path;
- author.Empty();
- }
- else if(m_iPlaybackMode == PM_CAPTURE)
- {
- title = label != pli.m_fns.GetHead() ? label : _T("Live");
- author.Empty();
- }
- else if(m_iPlaybackMode == PM_DVD)
- {
- title = _T("DVD");
- author.Empty();
- }*/
- }
-
- title.Replace(L"|", L"\\|");
- author.Replace(L"|", L"\\|");
- description.Replace(L"|", L"\\|");
- label.Replace(L"|", L"\\|");
-
- CStringW buff;
- buff.Format(L"%s|%s|%s|%s|%d", title, author, description, label, lDuration);
-
- SendAPICommand(CMD_NOWPLAYING, buff);
- SendSubtitleTracksToApi();
- SendAudioTracksToApi();
- }
+ if(!AfxGetAppSettings().hMasterWnd)
+ return;
+
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ CPlaylistItem pli;
+ CString title, author, description;
+ CString label;
+ long lDuration = 0;
+ REFERENCE_TIME rtDur;
+
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_DESCRIPTION), description);
+
+ m_wndPlaylistBar.GetCur(pli);
+ if(!pli.m_fns.IsEmpty())
+ {
+ label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ pMS->GetDuration(&rtDur);
+ DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
+ lDuration = tcDur.bHours*60*60 + tcDur.bMinutes*60 + tcDur.bSeconds;
+ }
+/* CString label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
+
+ if(m_iPlaybackMode == PM_FILE)
+ {
+ CString fn = label;
+ if(fn.Find(_T("://")) >= 0) {int i = fn.Find('?'); if(i >= 0) fn = fn.Left(i);}
+ CPath path(fn);
+ path.StripPath();
+ path.MakePretty();
+ path.RemoveExtension();
+ title = (LPCTSTR)path;
+ author.Empty();
+ }
+ else if(m_iPlaybackMode == PM_CAPTURE)
+ {
+ title = label != pli.m_fns.GetHead() ? label : _T("Live");
+ author.Empty();
+ }
+ else if(m_iPlaybackMode == PM_DVD)
+ {
+ title = _T("DVD");
+ author.Empty();
+ }*/
+ }
+
+ title.Replace(L"|", L"\\|");
+ author.Replace(L"|", L"\\|");
+ description.Replace(L"|", L"\\|");
+ label.Replace(L"|", L"\\|");
+
+ CStringW buff;
+ buff.Format (L"%s|%s|%s|%s|%d", title, author, description, label, lDuration);
+
+ SendAPICommand (CMD_NOWPLAYING, buff);
+ SendSubtitleTracksToApi();
+ SendAudioTracksToApi();
+ }
}
void CMainFrame::SendSubtitleTracksToApi()
{
- CStringW strSubs;
- POSITION pos = m_pSubStreams.GetHeadPosition();
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- if(pos)
- {
- while(pos)
- {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- for(int i = 0, j = pSubStream->GetStreamCount(); i < j; i++)
- {
- WCHAR* pName = NULL;
- if(SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL)))
- {
- CString name(pName);
- if(!strSubs.IsEmpty())
- strSubs.Append(L"|");
- name.Replace(L"|", L"\\|");
- strSubs.AppendFormat(L"%s", name);
- CoTaskMemFree(pName);
- }
- }
- }
- if(AfxGetAppSettings().fEnableSubtitles)
- {
- if(m_iSubtitleSel >= 0)
- strSubs.AppendFormat(L"|%i", m_iSubtitleSel);
- else
- strSubs.Append(L"|-1");
- }
- else
- {
- strSubs.Append(L"|-1");
- }
- }
- else
- {
- strSubs.Append(L"-1");
- }
- }
- else
- {
- strSubs.Append(L"-2");
- }
- SendAPICommand(CMD_LISTSUBTITLETRACKS, strSubs);
+ CStringW strSubs;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ if (pos)
+ {
+ while(pos)
+ {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ for(int i = 0, j = pSubStream->GetStreamCount(); i < j; i++)
+ {
+ WCHAR* pName = NULL;
+ if(SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL)))
+ {
+ CString name(pName);
+ if (!strSubs.IsEmpty())
+ strSubs.Append (L"|");
+ name.Replace(L"|", L"\\|");
+ strSubs.AppendFormat(L"%s", name);
+ CoTaskMemFree(pName);
+ }
+ }
+ }
+ if(AfxGetAppSettings().fEnableSubtitles) {
+ if(m_iSubtitleSel >= 0)
+ strSubs.AppendFormat(L"|%i", m_iSubtitleSel);
+ else
+ strSubs.Append(L"|-1");
+ } else {
+ strSubs.Append (L"|-1");
+ }
+ } else {
+ strSubs.Append (L"-1");
+ }
+ } else {
+ strSubs.Append (L"-2");
+ }
+ SendAPICommand (CMD_LISTSUBTITLETRACKS, strSubs);
}
void CMainFrame::SendAudioTracksToApi()
{
- CStringW strAudios;
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
-
- DWORD cStreams = 0;
- if(pSS && SUCCEEDED(pSS->Count(&cStreams)))
- {
- int currentStream = -1;
- for(int i = 0; i < (int)cStreams; i++)
- {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- return;
- if(dwFlags == AMSTREAMSELECTINFO_EXCLUSIVE)
- currentStream = i;
- CString name(pszName);
- if(!strAudios.IsEmpty())
- strAudios.Append(L"|");
- name.Replace(L"|", L"\\|");
- strAudios.AppendFormat(L"%s", name);
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
- }
- strAudios.AppendFormat(L"|%i", currentStream);
-
- }
- else
- {
- strAudios.Append(L"-1");
- }
- }
- else
- {
- strAudios.Append(L"-2");
- }
- SendAPICommand(CMD_LISTAUDIOTRACKS, strAudios);
-
+ CStringW strAudios;
+
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+
+ DWORD cStreams = 0;
+ if(pSS && SUCCEEDED(pSS->Count(&cStreams)))
+ {
+ int currentStream = -1;
+ for(int i = 0; i < (int)cStreams; i++)
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+ return;
+ if(dwFlags == AMSTREAMSELECTINFO_EXCLUSIVE)
+ currentStream = i;
+ CString name(pszName);
+ if (!strAudios.IsEmpty())
+ strAudios.Append (L"|");
+ name.Replace(L"|", L"\\|");
+ strAudios.AppendFormat(L"%s", name);
+ if(pmt) DeleteMediaType(pmt);
+ if(pszName) CoTaskMemFree(pszName);
+ }
+ strAudios.AppendFormat(L"|%i", currentStream);
+
+ } else {
+ strAudios.Append(L"-1");
+ }
+ } else {
+ strAudios.Append(L"-2");
+ }
+ SendAPICommand (CMD_LISTAUDIOTRACKS, strAudios);
+
}
void CMainFrame::SendPlaylistToApi()
{
- CStringW strPlaylist;
- int index;
-
- POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition(), pos2;
- while(pos)
- {
- CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
-
- if(pli.m_type == CPlaylistItem::file)
- {
- pos2 = pli.m_fns.GetHeadPosition();
- while(pos2)
- {
- CString fn = pli.m_fns.GetNext(pos2);
- if(!strPlaylist.IsEmpty())
- strPlaylist.Append(L"|");
- fn.Replace(L"|", L"\\|");
- strPlaylist.AppendFormat(L"%s", fn);
- }
- }
- }
- index = m_wndPlaylistBar.GetSelIdx();
- if(strPlaylist.IsEmpty())
- strPlaylist.Append(L"-1");
- else
- strPlaylist.AppendFormat(L"|%i", index);
- SendAPICommand(CMD_PLAYLIST, strPlaylist);
+ CStringW strPlaylist;
+ int index;
+
+ POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition(), pos2;
+ while(pos)
+ {
+ CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
+
+ if(pli.m_type == CPlaylistItem::file)
+ {
+ pos2 = pli.m_fns.GetHeadPosition();
+ while(pos2)
+ {
+ CString fn = pli.m_fns.GetNext(pos2);
+ if (!strPlaylist.IsEmpty())
+ strPlaylist.Append (L"|");
+ fn.Replace(L"|", L"\\|");
+ strPlaylist.AppendFormat(L"%s", fn);
+ }
+ }
+ }
+ index = m_wndPlaylistBar.GetSelIdx();
+ if (strPlaylist.IsEmpty())
+ strPlaylist.Append(L"-1");
+ else
+ strPlaylist.AppendFormat(L"|%i", index);
+ SendAPICommand (CMD_PLAYLIST, strPlaylist);
}
@@ -13803,499 +13359,499 @@ WNDPROC CBProc;
bool m_incl_subdir;
CString f_lastOpenDir;
-void SetFont(HWND hwnd, LPTSTR FontName, int FontSize)
-{
- HFONT hf;
- LOGFONT lf = {0};
- HDC hdc = GetDC(hwnd);
-
- GetObject(GetWindowFont(hwnd), sizeof(lf), &lf);
- lf.lfWeight = FW_REGULAR;
- lf.lfHeight = (LONG)FontSize;
- lstrcpy(lf.lfFaceName, FontName);
- hf = CreateFontIndirect(&lf);
- SetBkMode(hdc, OPAQUE);
- SendMessage(hwnd, WM_SETFONT, (WPARAM)hf, TRUE);
- ReleaseDC(hwnd, hdc);
-
-}
-
-// Subclass procedure
-LRESULT APIENTRY CheckBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- if(uMsg == WM_LBUTTONUP)
- {
- if((SendMessage(hwnd, BM_GETCHECK, 0, 0)) == 1)
- {
- m_incl_subdir = FALSE;
- }
- else
- {
- m_incl_subdir = TRUE;
- }
- }
- return CallWindowProc(CBProc, hwnd, uMsg, wParam, lParam);
-}
-
-int __stdcall BrowseCallbackProcDIR(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
-{
- HWND checkbox;
-
- //Initialization callback message
- if(uMsg == BFFM_INITIALIZED)
- {
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)f_lastOpenDir);
-
- RECT ListViewRect;
- RECT Dialog;
- RECT ClientArea;
- RECT ButtonRect;
-
- checkbox = CreateWindowEx(0, _T("BUTTON"), ResStr(IDS_MAINFRM_DIR_CHECK),
- WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | BS_AUTOCHECKBOX | BS_MULTILINE, 0, 100, 100,
- 50, hwnd, 0, AfxGetApp()->m_hInstance, NULL);
-
- HWND ListView = FindWindowEx(hwnd, NULL, _T("SysTreeView32"), NULL);
-
- HWND id_ok = GetDlgItem(hwnd, IDOK);
- HWND id_cancel = GetDlgItem(hwnd, IDCANCEL);
-
- GetWindowRect(hwnd, &Dialog);
- MoveWindow(hwnd, Dialog.left, Dialog.top, Dialog.right - Dialog.left + 50, Dialog.bottom - Dialog.top + 70, TRUE);
- GetWindowRect(hwnd, &Dialog);
-
- GetClientRect(hwnd, &ClientArea);
-
- GetWindowRect(ListView, &ListViewRect);
- MoveWindow(ListView, ListViewRect.left - Dialog.left - 3, ListViewRect.top - Dialog.top - 55, ListViewRect.right - ListViewRect.left + 49, ListViewRect.bottom - ListViewRect.top + 115, TRUE);
- GetWindowRect(ListView, &ListViewRect);
-
- GetWindowRect(id_ok, &ButtonRect);
- MoveWindow(id_ok, ButtonRect.left - Dialog.left + 49, ButtonRect.top - Dialog.top + 50, ButtonRect.right - ButtonRect.left, ButtonRect.bottom - ButtonRect.top, TRUE);
-
- GetWindowRect(id_cancel, &ButtonRect);
- MoveWindow(id_cancel, ButtonRect.left - Dialog.left + 49, ButtonRect.top - Dialog.top + 50, ButtonRect.right - ButtonRect.left, ButtonRect.bottom - ButtonRect.top, TRUE);
-
- SetWindowPos(checkbox, HWND_BOTTOM, (ListViewRect.left - Dialog.left - 3), ClientArea.bottom - 35, 120, 27, SWP_SHOWWINDOW);
- SetFont(checkbox, _T("Tahoma"), 13);
-
- CBProc = (WNDPROC) SetWindowLongPtr(checkbox, GWLP_WNDPROC, (LONG_PTR) CheckBoxSubclassProc);
- SendMessage(checkbox, BM_SETCHECK, (WPARAM)m_incl_subdir, 0);
- }
- return 0;
+void SetFont(HWND hwnd,LPTSTR FontName,int FontSize)
+{
+ HFONT hf;
+ LOGFONT lf={0};
+ HDC hdc=GetDC(hwnd);
+
+ GetObject(GetWindowFont(hwnd),sizeof(lf),&lf);
+ lf.lfWeight = FW_REGULAR;
+ lf.lfHeight = (LONG)FontSize;
+ lstrcpy( lf.lfFaceName, FontName );
+ hf=CreateFontIndirect(&lf);
+ SetBkMode(hdc,OPAQUE);
+ SendMessage(hwnd,WM_SETFONT,(WPARAM)hf,TRUE);
+ ReleaseDC(hwnd,hdc);
+
+}
+
+// Subclass procedure
+LRESULT APIENTRY CheckBoxSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
+{
+ if(uMsg==WM_LBUTTONUP)
+ {
+ if((SendMessage(hwnd,BM_GETCHECK,0,0))==1)
+ {
+ m_incl_subdir = FALSE;
+ }
+ else
+ {
+ m_incl_subdir = TRUE;
+ }
+ }
+ return CallWindowProc(CBProc, hwnd, uMsg, wParam, lParam);
+}
+
+int __stdcall BrowseCallbackProcDIR(HWND hwnd,UINT uMsg,LPARAM lParam,LPARAM lpData)
+{
+ HWND checkbox;
+
+ //Initialization callback message
+ if(uMsg==BFFM_INITIALIZED)
+ {
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)f_lastOpenDir);
+
+ RECT ListViewRect;
+ RECT Dialog;
+ RECT ClientArea;
+ RECT ButtonRect;
+
+ checkbox = CreateWindowEx(0, _T("BUTTON"), ResStr(IDS_MAINFRM_DIR_CHECK),
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | BS_AUTOCHECKBOX | BS_MULTILINE, 0, 100, 100,
+ 50, hwnd, 0, AfxGetApp()->m_hInstance, NULL);
+
+ HWND ListView=FindWindowEx(hwnd,NULL,_T("SysTreeView32"),NULL);
+
+ HWND id_ok = GetDlgItem(hwnd, IDOK);
+ HWND id_cancel = GetDlgItem(hwnd, IDCANCEL);
+
+ GetWindowRect(hwnd,&Dialog);
+ MoveWindow(hwnd, Dialog.left, Dialog.top, Dialog.right-Dialog.left+50, Dialog.bottom-Dialog.top+70, TRUE);
+ GetWindowRect(hwnd,&Dialog);
+
+ GetClientRect(hwnd,&ClientArea);
+
+ GetWindowRect(ListView,&ListViewRect);
+ MoveWindow(ListView, ListViewRect.left-Dialog.left-3, ListViewRect.top-Dialog.top-55, ListViewRect.right-ListViewRect.left+49, ListViewRect.bottom-ListViewRect.top+115, TRUE);
+ GetWindowRect(ListView,&ListViewRect);
+
+ GetWindowRect(id_ok,&ButtonRect);
+ MoveWindow(id_ok, ButtonRect.left-Dialog.left+49, ButtonRect.top-Dialog.top+50, ButtonRect.right-ButtonRect.left, ButtonRect.bottom-ButtonRect.top, TRUE);
+
+ GetWindowRect(id_cancel,&ButtonRect);
+ MoveWindow(id_cancel, ButtonRect.left-Dialog.left+49, ButtonRect.top-Dialog.top+50, ButtonRect.right-ButtonRect.left, ButtonRect.bottom-ButtonRect.top, TRUE);
+
+ SetWindowPos(checkbox, HWND_BOTTOM, (ListViewRect.left-Dialog.left-3), ClientArea.bottom - 35, 120, 27, SWP_SHOWWINDOW);
+ SetFont(checkbox,_T("Tahoma"),13);
+
+ CBProc = (WNDPROC) SetWindowLongPtr(checkbox, GWLP_WNDPROC, (LONG_PTR) CheckBoxSubclassProc);
+ SendMessage(checkbox,BM_SETCHECK,(WPARAM)m_incl_subdir,0);
+ }
+ return 0;
}
void RecurseAddDir(CString path, CAtlList<CString>* sl)
{
- WIN32_FIND_DATA fd = {0};
-
- HANDLE hFind = FindFirstFile(path + _T("*.*"), &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- CString f_name = fd.cFileName;
- if((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (f_name != _T(".")) && (f_name != _T("..")))
- {
- CString fullpath = path + f_name;
- if(fullpath[fullpath.GetLength()-1] != '\\') fullpath += '\\';
- sl->AddTail(fullpath);
- RecurseAddDir(fullpath, sl);
- }
- else
- {
- continue;
- }
- }
- while(FindNextFile(hFind, &fd));
- FindClose(hFind);
- }
+ WIN32_FIND_DATA fd = {0};
+
+ HANDLE hFind = FindFirstFile(path + _T("*.*"), &fd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ CString f_name = fd.cFileName;
+ if((fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (f_name!=_T(".")) && (f_name!=_T("..")))
+ {
+ CString fullpath = path + f_name;
+ if(fullpath[fullpath.GetLength()-1] != '\\') fullpath += '\\';
+ sl->AddTail(fullpath);
+ RecurseAddDir(fullpath, sl);
+ }
+ else
+ {
+ continue;
+ }
+ }
+ while(FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
}
void CMainFrame::OnFileOpendirectory()
{
- if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) return;
-
- AppSettings& s = AfxGetAppSettings();
-
- CString filter;
- CAtlArray<CString> mask;
- s.Formats.GetFilter(filter, mask);
-
- f_lastOpenDir = s.f_lastOpenDir;
-
- TCHAR path[_MAX_PATH];
- m_incl_subdir = TRUE;
-
- CString strTitle = ResStr(IDS_MAINFRM_DIR_TITLE);
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = path;
- bi.lpszTitle = strTitle;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_STATUSTEXT;
- bi.lpfn = BrowseCallbackProcDIR;
- bi.lParam = 0;
- bi.iImage = 0;
-
- static LPITEMIDLIST iil;
-
- if(iil = SHBrowseForFolder(&bi))
- {
- SHGetPathFromIDList(iil, path);
- CString _path = path;
- _path.Replace('/', '\\');
- if(_path[_path.GetLength()-1] != '\\') _path += '\\';
- s.f_lastOpenDir = _path;
-
- CAtlList<CString> sl;
- sl.AddTail(_path);
- if(m_incl_subdir) RecurseAddDir(_path, &sl);
-
- if(m_wndPlaylistBar.IsWindowVisible())
- {
- m_wndPlaylistBar.Append(sl, true);
- }
- else
- {
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
- }
- }
+ if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) return;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CString filter;
+ CAtlArray<CString> mask;
+ s.Formats.GetFilter(filter, mask);
+
+ f_lastOpenDir = s.f_lastOpenDir;
+
+ TCHAR path[_MAX_PATH];
+ m_incl_subdir = TRUE;
+
+ CString strTitle = ResStr(IDS_MAINFRM_DIR_TITLE);
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = path;
+ bi.lpszTitle = strTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_STATUSTEXT;
+ bi.lpfn = BrowseCallbackProcDIR;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ static LPITEMIDLIST iil;
+
+ if(iil = SHBrowseForFolder(&bi))
+ {
+ SHGetPathFromIDList(iil, path);
+ CString _path = path;
+ _path.Replace('/', '\\');
+ if(_path[_path.GetLength()-1] != '\\') _path += '\\';
+ s.f_lastOpenDir = _path;
+
+ CAtlList<CString> sl;
+ sl.AddTail(_path);
+ if(m_incl_subdir) RecurseAddDir(_path, &sl);
+
+ if(m_wndPlaylistBar.IsWindowVisible())
+ {
+ m_wndPlaylistBar.Append(sl, true);
+ }
+ else
+ {
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
+ }
+ }
}
#define GetAValue(rgb) (rgb >> 24)
HRESULT CMainFrame::CreateThumbnailToolbar()
{
- if(!AfxGetAppSettings().m_fUseWin7TaskBar) return false;
-
- DWORD dwMajor = LOBYTE(LOWORD(GetVersion()));
- DWORD dwMinor = HIBYTE(LOWORD(GetVersion()));
- if(!(dwMajor > 6 || (dwMajor == 6 && dwMinor > 0))) return false;
-
- if(m_pTaskbarList) m_pTaskbarList->Release();
- HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList));
- if(SUCCEEDED(hr))
- {
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
- Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
-
- CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource;
- if(!pBitmap->Load(_T("W7_TOOLBAR"), _T("PNG")))
- {
- delete pBitmap;
- Gdiplus::GdiplusShutdown(m_gdiplusToken);
- m_pTaskbarList->Release();
- return false;
- }
- unsigned long Color = 0xFFFFFFFF;
- unsigned int A = GetAValue(Color);
- unsigned int R = GetRValue(Color);
- unsigned int G = GetGValue(Color);
- unsigned int B = GetBValue(Color);
- Gdiplus::Color co(A, R, G, B);
- HBITMAP hB = 0;
- pBitmap->m_pBitmap->GetHBITMAP(co, &hB);
-
- if(!hB)
- {
- m_pTaskbarList->Release();
- delete pBitmap;
- Gdiplus::GdiplusShutdown(m_gdiplusToken);
- return false;
- }
-
- // Check dimensions
- BITMAP bi = {0};
- GetObject((HANDLE)hB, sizeof(bi), &bi);
- if(bi.bmHeight == 0)
- {
- DeleteObject(hB);
- m_pTaskbarList->Release();
- delete pBitmap;
- Gdiplus::GdiplusShutdown(m_gdiplusToken);
- return false;
- }
-
- int nI = bi.bmWidth / bi.bmHeight;
- HIMAGELIST himl = ImageList_Create(bi.bmHeight, bi.bmHeight, ILC_COLOR32, nI, 0);
-
- // Add the bitmap
- ImageList_Add(himl, hB, 0);
- hr = m_pTaskbarList->ThumbBarSetImageList(m_hWnd, himl);
- DeleteObject(hB);
-
- if(SUCCEEDED(hr))
- {
- THUMBBUTTON buttons[5] = {};
-
- // SEEK BACKWARD
- buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[0].dwFlags = THBF_DISABLED;//THBF_ENABLED;
- buttons[0].iId = IDTB_BUTTON3;
- buttons[0].iBitmap = 0;
- StringCchCopy(buttons[0].szTip, countof(buttons[0].szTip), ResStr(IDS_MPLAYERC_26));
-
- // STOP
- buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[1].dwFlags = THBF_DISABLED;//THBF_ENABLED;
- buttons[1].iId = IDTB_BUTTON1;
- buttons[1].iBitmap = 1;
- StringCchCopy(buttons[1].szTip, countof(buttons[1].szTip), ResStr(IDS_AG_STOP));
-
- // PLAY/PAUSE
- buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[2].dwFlags = THBF_DISABLED;//THBF_ENABLED;
- buttons[2].iId = IDTB_BUTTON2;
- buttons[2].iBitmap = 3;
- StringCchCopy(buttons[2].szTip, countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE));
-
- // SEEK FORWARD
- buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[3].dwFlags = THBF_DISABLED;//THBF_ENABLED;
- buttons[3].iId = IDTB_BUTTON4;
- buttons[3].iBitmap = 4;
- StringCchCopy(buttons[3].szTip, countof(buttons[3].szTip), ResStr(IDS_MPLAYERC_25));
-
- // FULLSCREEN
- buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[4].dwFlags = THBF_DISABLED;//THBF_ENABLED;
- buttons[4].iId = IDTB_BUTTON5;
- buttons[4].iBitmap = 5;
- StringCchCopy(buttons[4].szTip, countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN));
-
- hr = m_pTaskbarList->ThumbBarAddButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
- }
- ImageList_Destroy(himl);
- delete pBitmap;
- Gdiplus::GdiplusShutdown(m_gdiplusToken);
- }
-
- return hr;
+ if(!AfxGetAppSettings().m_fUseWin7TaskBar) return false;
+
+ DWORD dwMajor = LOBYTE(LOWORD(GetVersion()));
+ DWORD dwMinor = HIBYTE(LOWORD(GetVersion()));
+ if (!( dwMajor > 6 || ( dwMajor == 6 && dwMinor > 0 ))) return false;
+
+ if(m_pTaskbarList) m_pTaskbarList->Release();
+ HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList));
+ if (SUCCEEDED(hr))
+ {
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
+
+ CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource;
+ if (!pBitmap->Load(_T("W7_TOOLBAR"), _T("PNG")))
+ {
+ delete pBitmap;
+ Gdiplus::GdiplusShutdown(m_gdiplusToken);
+ m_pTaskbarList->Release();
+ return false;
+ }
+ unsigned long Color = 0xFFFFFFFF;
+ unsigned int A = GetAValue(Color);
+ unsigned int R = GetRValue(Color);
+ unsigned int G = GetGValue(Color);
+ unsigned int B = GetBValue(Color);
+ Gdiplus::Color co(A,R,G,B);
+ HBITMAP hB = 0;
+ pBitmap->m_pBitmap->GetHBITMAP(co,&hB);
+
+ if (!hB)
+ {
+ m_pTaskbarList->Release();
+ delete pBitmap;
+ Gdiplus::GdiplusShutdown(m_gdiplusToken);
+ return false;
+ }
+
+ // Check dimensions
+ BITMAP bi = {0};
+ GetObject((HANDLE)hB,sizeof(bi),&bi);
+ if (bi.bmHeight == 0)
+ {
+ DeleteObject(hB);
+ m_pTaskbarList->Release();
+ delete pBitmap;
+ Gdiplus::GdiplusShutdown(m_gdiplusToken);
+ return false;
+ }
+
+ int nI = bi.bmWidth/bi.bmHeight;
+ HIMAGELIST himl = ImageList_Create(bi.bmHeight,bi.bmHeight,ILC_COLOR32,nI,0);
+
+ // Add the bitmap
+ ImageList_Add(himl,hB,0);
+ hr = m_pTaskbarList->ThumbBarSetImageList(m_hWnd,himl);
+ DeleteObject(hB);
+
+ if (SUCCEEDED(hr))
+ {
+ THUMBBUTTON buttons[5] = {};
+
+ // SEEK BACKWARD
+ buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[0].dwFlags = THBF_DISABLED;//THBF_ENABLED;
+ buttons[0].iId = IDTB_BUTTON3;
+ buttons[0].iBitmap = 0;
+ StringCchCopy(buttons[0].szTip, countof(buttons[0].szTip), ResStr(IDS_MPLAYERC_26));
+
+ // STOP
+ buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[1].dwFlags = THBF_DISABLED;//THBF_ENABLED;
+ buttons[1].iId = IDTB_BUTTON1;
+ buttons[1].iBitmap = 1;
+ StringCchCopy(buttons[1].szTip, countof(buttons[1].szTip), ResStr(IDS_AG_STOP));
+
+ // PLAY/PAUSE
+ buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[2].dwFlags = THBF_DISABLED;//THBF_ENABLED;
+ buttons[2].iId = IDTB_BUTTON2;
+ buttons[2].iBitmap = 3;
+ StringCchCopy(buttons[2].szTip, countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE));
+
+ // SEEK FORWARD
+ buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[3].dwFlags = THBF_DISABLED;//THBF_ENABLED;
+ buttons[3].iId = IDTB_BUTTON4;
+ buttons[3].iBitmap = 4;
+ StringCchCopy(buttons[3].szTip, countof(buttons[3].szTip), ResStr(IDS_MPLAYERC_25));
+
+ // FULLSCREEN
+ buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[4].dwFlags = THBF_DISABLED;//THBF_ENABLED;
+ buttons[4].iId = IDTB_BUTTON5;
+ buttons[4].iBitmap = 5;
+ StringCchCopy(buttons[4].szTip, countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN));
+
+ hr = m_pTaskbarList->ThumbBarAddButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
+ }
+ ImageList_Destroy(himl);
+ delete pBitmap;
+ Gdiplus::GdiplusShutdown(m_gdiplusToken);
+ }
+
+ return hr;
}
HRESULT CMainFrame::UpdateThumbarButton()
{
- if(!m_pTaskbarList)
- return false;
-
- if(!AfxGetAppSettings().m_fUseWin7TaskBar)
- {
- m_pTaskbarList->SetOverlayIcon(m_hWnd, NULL, L"");
- m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
-
- THUMBBUTTON buttons[5] = {};
-
- buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[0].dwFlags = THBF_HIDDEN;
- buttons[0].iId = IDTB_BUTTON3;
-
- buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[1].dwFlags = THBF_HIDDEN;
- buttons[1].iId = IDTB_BUTTON1;
-
- buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[2].dwFlags = THBF_HIDDEN;
- buttons[2].iId = IDTB_BUTTON2;
-
- buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[3].dwFlags = THBF_HIDDEN;
- buttons[3].iId = IDTB_BUTTON4;
-
- buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[4].dwFlags = THBF_HIDDEN;
- buttons[4].iId = IDTB_BUTTON5;
-
- HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
- return hr;
- }
-
- THUMBBUTTON buttons[5] = {};
-
- buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[0].dwFlags = THBF_ENABLED;
- buttons[0].iId = IDTB_BUTTON3;
- buttons[0].iBitmap = 0;
- StringCchCopy(buttons[0].szTip, _countof(buttons[0].szTip), ResStr(IDS_MPLAYERC_26));
-
- buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[1].iId = IDTB_BUTTON1;
- buttons[1].iBitmap = 1;
- StringCchCopy(buttons[1].szTip, _countof(buttons[1].szTip), ResStr(IDS_AG_STOP));
-
- buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[2].iId = IDTB_BUTTON2;
- buttons[2].iBitmap = 3;
- StringCchCopy(buttons[2].szTip, _countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE));
-
- buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[3].dwFlags = THBF_ENABLED;
- buttons[3].iId = IDTB_BUTTON4;
- buttons[3].iBitmap = 4;
- StringCchCopy(buttons[3].szTip, _countof(buttons[3].szTip), ResStr(IDS_MPLAYERC_25));
-
- buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[4].dwFlags = THBF_ENABLED;
- buttons[4].iId = IDTB_BUTTON5;
- buttons[4].iBitmap = 5;
- StringCchCopy(buttons[4].szTip, _countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN));
-
- HICON hIcon = NULL;
-
- if(m_iMediaLoadState == MLS_LOADED)
- {
- OAFilterState fs = GetMediaState();
- if(fs == State_Running)
- {
- buttons[1].dwFlags = THBF_ENABLED;
- buttons[2].dwFlags = THBF_ENABLED;
- buttons[2].iBitmap = 2;
-
- hIcon = AfxGetApp()->LoadIcon(IDR_TB_PLAY);
- m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
- }
- else if(fs == State_Stopped)
- {
- buttons[0].dwFlags = THBF_DISABLED;
- buttons[1].dwFlags = THBF_DISABLED;
- buttons[2].dwFlags = THBF_ENABLED;
- buttons[2].iBitmap = 3;
- buttons[3].dwFlags = THBF_DISABLED;
-
- hIcon = AfxGetApp()->LoadIcon(IDR_TB_STOP);
- m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
- }
- else if(fs == State_Paused)
- {
- buttons[1].dwFlags = THBF_ENABLED;
- buttons[2].dwFlags = THBF_ENABLED;
- buttons[2].iBitmap = 3;
-
- hIcon = AfxGetApp()->LoadIcon(IDR_TB_PAUSE);
- m_pTaskbarList->SetProgressState(m_hWnd, TBPF_PAUSED);
- }
-
- if(m_fAudioOnly)
- buttons[4].dwFlags = THBF_DISABLED;
-
- m_pTaskbarList->SetOverlayIcon(m_hWnd, hIcon, L"");
-
- if(hIcon != NULL)
- DestroyIcon(hIcon);
- }
- else
- {
- buttons[0].dwFlags = THBF_DISABLED;
- buttons[1].dwFlags = THBF_DISABLED;
- buttons[2].dwFlags = THBF_DISABLED;
- buttons[3].dwFlags = THBF_DISABLED;
- buttons[4].dwFlags = THBF_DISABLED;
-
- m_pTaskbarList->SetOverlayIcon(m_hWnd, NULL, L"");
- m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
- }
-
- HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
-
- UpdateThumbnailClip();
-
- return hr;
+ if ( !m_pTaskbarList )
+ return false;
+
+ if ( !AfxGetAppSettings().m_fUseWin7TaskBar )
+ {
+ m_pTaskbarList->SetOverlayIcon( m_hWnd, NULL, L"" );
+ m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
+
+ THUMBBUTTON buttons[5] = {};
+
+ buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[0].dwFlags = THBF_HIDDEN;
+ buttons[0].iId = IDTB_BUTTON3;
+
+ buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[1].dwFlags = THBF_HIDDEN;
+ buttons[1].iId = IDTB_BUTTON1;
+
+ buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[2].dwFlags = THBF_HIDDEN;
+ buttons[2].iId = IDTB_BUTTON2;
+
+ buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[3].dwFlags = THBF_HIDDEN;
+ buttons[3].iId = IDTB_BUTTON4;
+
+ buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[4].dwFlags = THBF_HIDDEN;
+ buttons[4].iId = IDTB_BUTTON5;
+
+ HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons( m_hWnd, ARRAYSIZE(buttons), buttons );
+ return hr;
+ }
+
+ THUMBBUTTON buttons[5] = {};
+
+ buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[0].dwFlags = THBF_ENABLED;
+ buttons[0].iId = IDTB_BUTTON3;
+ buttons[0].iBitmap = 0;
+ StringCchCopy( buttons[0].szTip, _countof(buttons[0].szTip), ResStr(IDS_MPLAYERC_26) );
+
+ buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[1].iId = IDTB_BUTTON1;
+ buttons[1].iBitmap = 1;
+ StringCchCopy( buttons[1].szTip, _countof(buttons[1].szTip), ResStr(IDS_AG_STOP) );
+
+ buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[2].iId = IDTB_BUTTON2;
+ buttons[2].iBitmap = 3;
+ StringCchCopy( buttons[2].szTip, _countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE) );
+
+ buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[3].dwFlags = THBF_ENABLED;
+ buttons[3].iId = IDTB_BUTTON4;
+ buttons[3].iBitmap = 4;
+ StringCchCopy( buttons[3].szTip, _countof(buttons[3].szTip), ResStr(IDS_MPLAYERC_25) );
+
+ buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[4].dwFlags = THBF_ENABLED;
+ buttons[4].iId = IDTB_BUTTON5;
+ buttons[4].iBitmap = 5;
+ StringCchCopy( buttons[4].szTip, _countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN) );
+
+ HICON hIcon = NULL;
+
+ if ( m_iMediaLoadState == MLS_LOADED )
+ {
+ OAFilterState fs = GetMediaState();
+ if ( fs == State_Running )
+ {
+ buttons[1].dwFlags = THBF_ENABLED;
+ buttons[2].dwFlags = THBF_ENABLED;
+ buttons[2].iBitmap = 2;
+
+ hIcon = AfxGetApp()->LoadIcon( IDR_TB_PLAY );
+ m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NORMAL );
+ }
+ else if ( fs == State_Stopped )
+ {
+ buttons[0].dwFlags = THBF_DISABLED;
+ buttons[1].dwFlags = THBF_DISABLED;
+ buttons[2].dwFlags = THBF_ENABLED;
+ buttons[2].iBitmap = 3;
+ buttons[3].dwFlags = THBF_DISABLED;
+
+ hIcon = AfxGetApp()->LoadIcon( IDR_TB_STOP );
+ m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
+ }
+ else if ( fs == State_Paused )
+ {
+ buttons[1].dwFlags = THBF_ENABLED;
+ buttons[2].dwFlags = THBF_ENABLED;
+ buttons[2].iBitmap = 3;
+
+ hIcon = AfxGetApp()->LoadIcon( IDR_TB_PAUSE );
+ m_pTaskbarList->SetProgressState( m_hWnd, TBPF_PAUSED );
+ }
+
+ if ( m_fAudioOnly )
+ buttons[4].dwFlags = THBF_DISABLED;
+
+ m_pTaskbarList->SetOverlayIcon( m_hWnd, hIcon, L"" );
+
+ if ( hIcon != NULL )
+ DestroyIcon( hIcon );
+ }
+ else
+ {
+ buttons[0].dwFlags = THBF_DISABLED;
+ buttons[1].dwFlags = THBF_DISABLED;
+ buttons[2].dwFlags = THBF_DISABLED;
+ buttons[3].dwFlags = THBF_DISABLED;
+ buttons[4].dwFlags = THBF_DISABLED;
+
+ m_pTaskbarList->SetOverlayIcon( m_hWnd, NULL, L"" );
+ m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
+ }
+
+ HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons( m_hWnd, ARRAYSIZE(buttons), buttons );
+
+ UpdateThumbnailClip();
+
+ return hr;
}
HRESULT CMainFrame::UpdateThumbnailClip()
{
- if(!m_pTaskbarList)
- return false;
+ if ( !m_pTaskbarList )
+ return false;
- if((!AfxGetAppSettings().m_fUseWin7TaskBar) || (m_iMediaLoadState != MLS_LOADED) || (m_fAudioOnly) || m_fFullScreen)
- {
- return m_pTaskbarList->SetThumbnailClip(m_hWnd, NULL);
- }
+ if ( (!AfxGetAppSettings().m_fUseWin7TaskBar) || (m_iMediaLoadState != MLS_LOADED) || (m_fAudioOnly) || m_fFullScreen )
+ {
+ return m_pTaskbarList->SetThumbnailClip( m_hWnd, NULL );
+ }
- RECT vid_rect, result_rect;
- m_wndView.GetClientRect(&vid_rect);
+ RECT vid_rect, result_rect;
+ m_wndView.GetClientRect( &vid_rect );
- // NOTE: For remove menu from thumbnail clip preview
- result_rect.left = 2;
- result_rect.right = result_rect.left + (vid_rect.right - vid_rect.left) - 4;
- result_rect.top = 22;
- result_rect.bottom = result_rect.top + (vid_rect.bottom - vid_rect.top) - 4;
+ // NOTE: For remove menu from thumbnail clip preview
+ result_rect.left = 2;
+ result_rect.right = result_rect.left + (vid_rect.right - vid_rect.left) - 4;
+ result_rect.top = 22;
+ result_rect.bottom = result_rect.top + (vid_rect.bottom - vid_rect.top) - 4;
- return m_pTaskbarList->SetThumbnailClip(m_hWnd, &result_rect);
+ return m_pTaskbarList->SetThumbnailClip( m_hWnd, &result_rect );
}
LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if((message == WM_COMMAND) && (THBN_CLICKED == HIWORD(wParam)))
- {
- int const wmId = LOWORD(wParam);
- switch(wmId)
- {
- case IDTB_BUTTON1:
- SendMessage(WM_COMMAND, ID_PLAY_STOP);
- break;
-
- case IDTB_BUTTON2:
- SendMessage(WM_COMMAND, ID_PLAY_PLAYPAUSE);
- break;
-
- case IDTB_BUTTON3:
- SendMessage(WM_COMMAND, ID_PLAY_SEEKBACKWARDMED);
- break;
-
- case IDTB_BUTTON4:
- SendMessage(WM_COMMAND, ID_PLAY_SEEKFORWARDMED);
- break;
-
- case IDTB_BUTTON5:
- WINDOWPLACEMENT wp;
- GetWindowPlacement(&wp);
- if(wp.showCmd == SW_SHOWMINIMIZED)
- {
- SendMessage(WM_SYSCOMMAND, SC_RESTORE, -1);
- }
- SetForegroundWindow();
-
- SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
- break;
-
- default:
- break;
- }
- return 0;
- }
-
- return __super::WindowProc(message, wParam, lParam);
+ if((message == WM_COMMAND) && (THBN_CLICKED == HIWORD(wParam)))
+ {
+ int const wmId = LOWORD(wParam);
+ switch(wmId)
+ {
+ case IDTB_BUTTON1:
+ SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ break;
+
+ case IDTB_BUTTON2:
+ SendMessage(WM_COMMAND, ID_PLAY_PLAYPAUSE);
+ break;
+
+ case IDTB_BUTTON3:
+ SendMessage(WM_COMMAND, ID_PLAY_SEEKBACKWARDMED);
+ break;
+
+ case IDTB_BUTTON4:
+ SendMessage(WM_COMMAND, ID_PLAY_SEEKFORWARDMED);
+ break;
+
+ case IDTB_BUTTON5:
+ WINDOWPLACEMENT wp;
+ GetWindowPlacement(&wp);
+ if(wp.showCmd == SW_SHOWMINIMIZED)
+ {
+ SendMessage(WM_SYSCOMMAND, SC_RESTORE, -1);
+ }
+ SetForegroundWindow();
+
+ SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+ }
+
+ return __super::WindowProc(message, wParam, lParam);
}
UINT CMainFrame::OnPowerBroadcast(UINT nPowerEvent, UINT nEventData)
{
- static BOOL bWasPausedBeforeSuspention;
- OAFilterState mediaState;
-
- switch(nPowerEvent)
- {
- case PBT_APMSUSPEND: // System is suspending operation.
- TRACE("OnPowerBroadcast - suspending\n"); // For user tracking
-
- bWasPausedBeforeSuspention = FALSE; // Reset value
-
- mediaState = GetMediaState();
- if(mediaState == State_Running)
- {
- bWasPausedBeforeSuspention = TRUE;
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE); // Pause
- }
- break;
- case PBT_APMRESUMEAUTOMATIC: // Operation is resuming automatically from a low-power state. This message is sent every time the system resumes.
- TRACE("OnPowerBroadcast - resuming\n"); // For user tracking
-
- // Resume if we paused before suspention.
- if(bWasPausedBeforeSuspention)
- SendMessage(WM_COMMAND, ID_PLAY_PLAY); // Resume
- break;
- }
-
- return __super::OnPowerBroadcast(nPowerEvent, nEventData);
+ static BOOL bWasPausedBeforeSuspention;
+ OAFilterState mediaState;
+
+ switch ( nPowerEvent )
+ {
+ case PBT_APMSUSPEND: // System is suspending operation.
+ TRACE("OnPowerBroadcast - suspending\n"); // For user tracking
+
+ bWasPausedBeforeSuspention = FALSE; // Reset value
+
+ mediaState = GetMediaState();
+ if ( mediaState == State_Running )
+ {
+ bWasPausedBeforeSuspention = TRUE;
+ SendMessage( WM_COMMAND, ID_PLAY_PAUSE ); // Pause
+ }
+ break;
+ case PBT_APMRESUMEAUTOMATIC: // Operation is resuming automatically from a low-power state. This message is sent every time the system resumes.
+ TRACE("OnPowerBroadcast - resuming\n"); // For user tracking
+
+ // Resume if we paused before suspention.
+ if ( bWasPausedBeforeSuspention )
+ SendMessage( WM_COMMAND, ID_PLAY_PLAY ); // Resume
+ break;
+ }
+
+ return __super::OnPowerBroadcast(nPowerEvent, nEventData);
}
diff --git a/src/apps/mplayerc/MainFrm.h b/src/apps/mplayerc/MainFrm.h
index aaafbdd4c..b25e16193 100644
--- a/src/apps/mplayerc/MainFrm.h
+++ b/src/apps/mplayerc/MainFrm.h
@@ -80,72 +80,66 @@ class OpenMediaData
{
public:
// OpenMediaData() {}
- virtual ~OpenMediaData() {} // one virtual funct is needed to enable rtti
- CString title;
- CAtlList<CString> subs;
+ virtual ~OpenMediaData() {} // one virtual funct is needed to enable rtti
+ CString title;
+ CAtlList<CString> subs;
};
-class OpenFileData : public OpenMediaData
+class OpenFileData : public OpenMediaData
{
public:
- OpenFileData() : rtStart(0) {}
- CAtlList<CString> fns;
- REFERENCE_TIME rtStart;
+ OpenFileData() : rtStart(0) {}
+ CAtlList<CString> fns;
+ REFERENCE_TIME rtStart;
};
-class OpenDVDData : public OpenMediaData
+class OpenDVDData : public OpenMediaData
{
-public:
+public:
// OpenDVDData() {}
- CString path;
- CComPtr<IDvdState> pDvdState;
+ CString path;
+ CComPtr<IDvdState> pDvdState;
};
class OpenDeviceData : public OpenMediaData
{
-public:
- OpenDeviceData()
- {
- vinput = vchannel = ainput = -1;
- }
- CStringW DisplayName[2];
- int vinput, vchannel, ainput;
+public:
+ OpenDeviceData() {vinput = vchannel = ainput = -1;}
+ CStringW DisplayName[2];
+ int vinput, vchannel, ainput;
};
class TunerScanData
{
public :
- ULONG FrequencyStart;
- ULONG FrequencyStop;
- ULONG Bandwidth;
- HWND Hwnd;
+ ULONG FrequencyStart;
+ ULONG FrequencyStop;
+ ULONG Bandwidth;
+ HWND Hwnd;
};
class CMainFrame;
class CGraphThread : public CWinThread
{
- CMainFrame* m_pMainFrame;
+ CMainFrame* m_pMainFrame;
- DECLARE_DYNCREATE(CGraphThread);
+ DECLARE_DYNCREATE(CGraphThread);
public:
- CGraphThread() : m_pMainFrame(NULL) {}
-
- void SetMainFrame(CMainFrame* pMainFrame)
- {
- m_pMainFrame = pMainFrame;
- }
-
- BOOL InitInstance();
- int ExitInstance();
-
- enum {TM_EXIT = WM_APP, TM_OPEN, TM_CLOSE, TM_TUNER_SCAN};
- DECLARE_MESSAGE_MAP()
- afx_msg void OnExit(WPARAM wParam, LPARAM lParam);
- afx_msg void OnOpen(WPARAM wParam, LPARAM lParam);
- afx_msg void OnClose(WPARAM wParam, LPARAM lParam);
- afx_msg void OnTunerScan(WPARAM wParam, LPARAM lParam);
+ CGraphThread() : m_pMainFrame(NULL) {}
+
+ void SetMainFrame(CMainFrame* pMainFrame) {m_pMainFrame = pMainFrame;}
+
+ BOOL InitInstance();
+ int ExitInstance();
+
+ enum {TM_EXIT=WM_APP, TM_OPEN, TM_CLOSE, TM_TUNER_SCAN};
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnExit(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnOpen(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnClose(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnTunerScan(WPARAM wParam, LPARAM lParam);
};
/*
class CKeyFrameFinderThread : public CWinThread, public CCritSec
@@ -154,7 +148,7 @@ class CKeyFrameFinderThread : public CWinThread, public CCritSec
public:
CKeyFrameFinderThread() {}
-
+
CUIntArray m_kfs; // protected by (CCritSec*)this
BOOL InitInstance();
@@ -171,732 +165,711 @@ interface ISubClock;
class CMainFrame : public CFrameWnd, public CDropTarget
{
- enum
- {
- TIMER_STREAMPOSPOLLER = 1,
- TIMER_STREAMPOSPOLLER2,
- TIMER_FULLSCREENCONTROLBARHIDER,
- TIMER_FULLSCREENMOUSEHIDER,
- TIMER_STATS,
- TIMER_LEFTCLICK,
- TIMER_STATUSERASER
- };
-
- friend class CPPageFileInfoSheet;
- friend class CPPageLogo;
-
- // TODO: wrap these graph objects into a class to make it look cleaner
-
- DWORD m_dwRegister;
-
- CComPtr<IGraphBuilder2> pGB;
- CComQIPtr<IMediaControl> pMC;
- CComQIPtr<IMediaEventEx> pME;
- CComQIPtr<IVideoWindow> pVW;
- CComQIPtr<IBasicVideo> pBV;
- CComQIPtr<IBasicAudio> pBA;
- CComQIPtr<IMediaSeeking> pMS;
- CComQIPtr<IVideoFrameStep> pFS;
- CComQIPtr<IQualProp, &IID_IQualProp> pQP;
- CComQIPtr<IBufferInfo> pBI;
- CComQIPtr<IAMOpenProgress> pAMOP;
+ enum
+ {
+ TIMER_STREAMPOSPOLLER = 1,
+ TIMER_STREAMPOSPOLLER2,
+ TIMER_FULLSCREENCONTROLBARHIDER,
+ TIMER_FULLSCREENMOUSEHIDER,
+ TIMER_STATS,
+ TIMER_LEFTCLICK,
+ TIMER_STATUSERASER
+ };
+
+ friend class CPPageFileInfoSheet;
+ friend class CPPageLogo;
+
+ // TODO: wrap these graph objects into a class to make it look cleaner
+
+ DWORD m_dwRegister;
+
+ CComPtr<IGraphBuilder2> pGB;
+ CComQIPtr<IMediaControl> pMC;
+ CComQIPtr<IMediaEventEx> pME;
+ CComQIPtr<IVideoWindow> pVW;
+ CComQIPtr<IBasicVideo> pBV;
+ CComQIPtr<IBasicAudio> pBA;
+ CComQIPtr<IMediaSeeking> pMS;
+ CComQIPtr<IVideoFrameStep> pFS;
+ CComQIPtr<IQualProp, &IID_IQualProp> pQP;
+ CComQIPtr<IBufferInfo> pBI;
+ CComQIPtr<IAMOpenProgress> pAMOP;
- CComQIPtr<IDvdControl2> pDVDC;
- CComQIPtr<IDvdInfo2> pDVDI;
+ CComQIPtr<IDvdControl2> pDVDC;
+ CComQIPtr<IDvdInfo2> pDVDI;
- CComPtr<ICaptureGraphBuilder2> pCGB;
- CStringW m_VidDispName, m_AudDispName;
- CComPtr<IBaseFilter> pVidCap, pAudCap;
- CComPtr<IAMVideoCompression> pAMVCCap, pAMVCPrev;
- CComPtr<IAMStreamConfig> pAMVSCCap, pAMVSCPrev, pAMASC;
- CComPtr<IAMCrossbar> pAMXBar;
- CComPtr<IAMTVTuner> pAMTuner;
- CComPtr<IAMDroppedFrames> pAMDF;
+ CComPtr<ICaptureGraphBuilder2> pCGB;
+ CStringW m_VidDispName, m_AudDispName;
+ CComPtr<IBaseFilter> pVidCap, pAudCap;
+ CComPtr<IAMVideoCompression> pAMVCCap, pAMVCPrev;
+ CComPtr<IAMStreamConfig> pAMVSCCap, pAMVSCPrev, pAMASC;
+ CComPtr<IAMCrossbar> pAMXBar;
+ CComPtr<IAMTVTuner> pAMTuner;
+ CComPtr<IAMDroppedFrames> pAMDF;
- CComPtr<ISubPicAllocatorPresenter> m_pCAP;
- CComPtr<ISubPicAllocatorPresenter2> m_pCAP2;
+ CComPtr<ISubPicAllocatorPresenter> m_pCAP;
+ CComPtr<ISubPicAllocatorPresenter2> m_pCAP2;
- void SetBalance(int balance);
+ void SetBalance(int balance);
- // subtitles
+ // subtitles
- CCritSec m_csSubLock;
- CInterfaceList<ISubStream> m_pSubStreams;
- CAtlList<int> m_iAudioStreams; // foxX uses this to keep a mapping of audio streams, in which they're ordered based by language user preference
- int m_iSubtitleSel; // if(m_iSubtitleSel&(1<<31)): disabled
- DWORD_PTR m_nSubtitleId;
+ CCritSec m_csSubLock;
+ CInterfaceList<ISubStream> m_pSubStreams;
+ CAtlList<int> m_iAudioStreams; // foxX uses this to keep a mapping of audio streams, in which they're ordered based by language user preference
+ int m_iSubtitleSel; // if(m_iSubtitleSel&(1<<31)): disabled
+ DWORD_PTR m_nSubtitleId;
- friend class CTextPassThruFilter;
+ friend class CTextPassThruFilter;
- // windowing
+ // windowing
- CRect m_lastWindowRect;
- CPoint m_lastMouseMove;
+ CRect m_lastWindowRect;
+ CPoint m_lastMouseMove;
- CRect m_rcDesktop;
+ CRect m_rcDesktop;
- void ShowControls(int nCS, bool fSave = true);
+ void ShowControls(int nCS, bool fSave = true);
- void SetDefaultWindowRect(int iMonitor = 0);
- void RestoreDefaultWindowRect();
- void ZoomVideoWindow(double scale = -1);
- double GetZoomAutoFitScale();
+ void SetDefaultWindowRect(int iMonitor = 0);
+ void RestoreDefaultWindowRect();
+ void ZoomVideoWindow(double scale = -1);
+ double GetZoomAutoFitScale();
- void SetAlwaysOnTop(int i);
+ void SetAlwaysOnTop(int i);
- // dynamic menus
+ // dynamic menus
- void SetupOpenCDSubMenu();
- void SetupFiltersSubMenu();
- void SetupAudioSwitcherSubMenu();
- void SetupSubtitlesSubMenu();
- void SetupNavAudioSubMenu();
- void SetupNavSubtitleSubMenu();
- void SetupNavAngleSubMenu();
- void SetupNavChaptersSubMenu();
- void SetupFavoritesSubMenu();
- void SetupShadersSubMenu();
- void SetupRecentFilesSubMenu();
+ void SetupOpenCDSubMenu();
+ void SetupFiltersSubMenu();
+ void SetupAudioSwitcherSubMenu();
+ void SetupSubtitlesSubMenu();
+ void SetupNavAudioSubMenu();
+ void SetupNavSubtitleSubMenu();
+ void SetupNavAngleSubMenu();
+ void SetupNavChaptersSubMenu();
+ void SetupFavoritesSubMenu();
+ void SetupShadersSubMenu();
+ void SetupRecentFilesSubMenu();
- IBaseFilter* FindSourceSelectableFilter();
- void SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGroup);
- void OnNavStreamSelectSubMenu(UINT id, DWORD dwSelGroup);
+ IBaseFilter* FindSourceSelectableFilter();
+ void SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGroup);
+ void OnNavStreamSelectSubMenu(UINT id, DWORD dwSelGroup);
- CMenu m_popupmain, m_popup;
- CMenu m_opencds;
- CMenu m_filters, m_subtitles, m_audios;
- CAutoPtrArray<CMenu> m_filterpopups;
- CMenu m_navangle;
- CMenu m_navchapters;
- CMenu m_favorites;
- CMenu m_shaders;
- CMenu m_recentfiles;
+ CMenu m_popupmain, m_popup;
+ CMenu m_opencds;
+ CMenu m_filters, m_subtitles, m_audios;
+ CAutoPtrArray<CMenu> m_filterpopups;
+ CMenu m_navangle;
+ CMenu m_navchapters;
+ CMenu m_favorites;
+ CMenu m_shaders;
+ CMenu m_recentfiles;
- CInterfaceArray<IUnknown, &IID_IUnknown> m_pparray;
- CInterfaceArray<IAMStreamSelect> m_ssarray;
+ CInterfaceArray<IUnknown, &IID_IUnknown> m_pparray;
+ CInterfaceArray<IAMStreamSelect> m_ssarray;
- // chapters (file mode)
- CComPtr<IDSMChapterBag> m_pCB;
- void SetupChapters();
+ // chapters (file mode)
+ CComPtr<IDSMChapterBag> m_pCB;
+ void SetupChapters();
- //
+ //
- void SetupIViAudReg();
+ void SetupIViAudReg();
- void AddTextPassThruFilter();
+ void AddTextPassThruFilter();
- int m_nLoops;
+ int m_nLoops;
- bool m_fCustomGraph;
- bool m_fRealMediaGraph, m_fShockwaveGraph, m_fQuicktimeGraph;
+ bool m_fCustomGraph;
+ bool m_fRealMediaGraph, m_fShockwaveGraph, m_fQuicktimeGraph;
- CComPtr<ISubClock> m_pSubClock;
+ CComPtr<ISubClock> m_pSubClock;
- int m_fFrameSteppingActive;
- int m_nStepForwardCount;
- REFERENCE_TIME m_rtStepForwardStart;
- int m_VolumeBeforeFrameStepping;
+ int m_fFrameSteppingActive;
+ int m_nStepForwardCount;
+ REFERENCE_TIME m_rtStepForwardStart;
+ int m_VolumeBeforeFrameStepping;
- bool m_fEndOfStream;
+ bool m_fEndOfStream;
- bool m_fBuffering;
+ bool m_fBuffering;
- bool m_fLiveWM;
+ bool m_fLiveWM;
- bool m_fUpdateInfoBar;
+ bool m_fUpdateInfoBar;
- void SendStatusMessage(CString msg, int nTimeOut);
- CString m_playingmsg, m_closingmsg;
+ void SendStatusMessage(CString msg, int nTimeOut);
+ CString m_playingmsg, m_closingmsg;
- REFERENCE_TIME m_rtDurationOverride;
+ REFERENCE_TIME m_rtDurationOverride;
- CComPtr<IUnknown> m_pProv;
+ CComPtr<IUnknown> m_pProv;
- void CleanGraph();
+ void CleanGraph();
- CComPtr<IBaseFilter> pAudioDubSrc;
+ CComPtr<IBaseFilter> pAudioDubSrc;
- void ShowOptions(int idPage = 0);
+ void ShowOptions(int idPage = 0);
- bool GetDIB(BYTE** ppData, long& size, bool fSilent = false);
- void SaveDIB(LPCTSTR fn, BYTE* pData, long size);
- BOOL IsRendererCompatibleWithSaveImage();
- void SaveImage(LPCTSTR fn);
- void SaveThumbnails(LPCTSTR fn);
+ bool GetDIB(BYTE** ppData, long& size, bool fSilent = false);
+ void SaveDIB(LPCTSTR fn, BYTE* pData, long size);
+ BOOL IsRendererCompatibleWithSaveImage();
+ void SaveImage(LPCTSTR fn);
+ void SaveThumbnails(LPCTSTR fn);
- //
+ //
- friend class CWebClientSocket;
- friend class CWebServer;
- CAutoPtr<CWebServer> m_pWebServer;
+ friend class CWebClientSocket;
+ friend class CWebServer;
+ CAutoPtr<CWebServer> m_pWebServer;
public:
- void StartWebServer(int nPort);
- void StopWebServer();
-
- CString GetStatusMessage();
- bool IsMuted()
- {
- return m_wndToolBar.GetVolume() == -10000;
- }
- int GetVolume()
- {
- return m_wndToolBar.m_volctrl.GetPos();
- }
+ void StartWebServer(int nPort);
+ void StopWebServer();
+
+ CString GetStatusMessage();
+ bool IsMuted() {return m_wndToolBar.GetVolume() == -10000;}
+ int GetVolume() {return m_wndToolBar.m_volctrl.GetPos();}
public:
- CMainFrame();
+ CMainFrame();
- DECLARE_DYNAMIC(CMainFrame)
+ DECLARE_DYNAMIC(CMainFrame)
// Attributes
public:
- int m_iPlaybackMode;
-
- bool m_fFullScreen;
- bool m_fFirstFSAfterLaunchOnFS;
- bool m_fHideCursor;
- CMenu m_navaudio, m_navsubtitle;
-
- CComPtr<IBaseFilter> m_pRefClock; // Adjustable reference clock. GothSync
- CComPtr<ISyncClock> m_pSyncClock;
-
- bool IsFrameLessWindow()
- {
- return(m_fFullScreen || AfxGetAppSettings().fHideCaptionMenu);
- }
- bool IsCaptionMenuHidden()
- {
- return(!m_fFullScreen && AfxGetAppSettings().fHideCaptionMenu);
- }
- bool IsSomethingLoaded()
- {
- return((m_iMediaLoadState == MLS_LOADING || m_iMediaLoadState == MLS_LOADED) && !IsD3DFullScreenMode());
- }
- bool IsPlaylistEmpty()
- {
- return(m_wndPlaylistBar.GetCount() == 0);
- }
- bool IsInteractiveVideo()
- {
- return(AfxGetAppSettings().fIntRealMedia && m_fRealMediaGraph || m_fShockwaveGraph);
- }
- bool IsD3DFullScreenMode();
-
- CControlBar* m_pLastBar;
+ int m_iPlaybackMode;
-protected:
- int m_iMediaLoadState;
+ bool m_fFullScreen;
+ bool m_fFirstFSAfterLaunchOnFS;
+ bool m_fHideCursor;
+ CMenu m_navaudio, m_navsubtitle;
+
+ CComPtr<IBaseFilter> m_pRefClock; // Adjustable reference clock. GothSync
+ CComPtr<ISyncClock> m_pSyncClock;
- bool m_fAudioOnly;
- dispmode m_dmBeforeFullscreen;
- CString m_LastOpenFile;
- HMONITOR m_LastWindow_HM;
+ bool IsFrameLessWindow() {return(m_fFullScreen || AfxGetAppSettings().fHideCaptionMenu);}
+ bool IsCaptionMenuHidden() {return(!m_fFullScreen && AfxGetAppSettings().fHideCaptionMenu);}
+ bool IsSomethingLoaded() {return((m_iMediaLoadState == MLS_LOADING || m_iMediaLoadState == MLS_LOADED) && !IsD3DFullScreenMode());}
+ bool IsPlaylistEmpty() {return(m_wndPlaylistBar.GetCount() == 0);}
+ bool IsInteractiveVideo() {return(AfxGetAppSettings().fIntRealMedia && m_fRealMediaGraph || m_fShockwaveGraph);}
+ bool IsD3DFullScreenMode();
- DVD_DOMAIN m_iDVDDomain;
- DWORD m_iDVDTitle;
- int m_iSpeedLevel;
+ CControlBar* m_pLastBar;
- double m_ZoomX, m_ZoomY, m_PosX, m_PosY;
- int m_AngleX, m_AngleY, m_AngleZ;
+protected:
+ int m_iMediaLoadState;
+
+ bool m_fAudioOnly;
+ dispmode m_dmBeforeFullscreen;
+ CString m_LastOpenFile;
+ HMONITOR m_LastWindow_HM;
+
+ DVD_DOMAIN m_iDVDDomain;
+ DWORD m_iDVDTitle;
+ int m_iSpeedLevel;
+
+ double m_ZoomX, m_ZoomY, m_PosX, m_PosY;
+ int m_AngleX, m_AngleY, m_AngleZ;
// Operations
- bool OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD);
- void CloseMediaPrivate();
- void DoTunerScan(TunerScanData* pTSD);
-
- void SendNowPlayingToMSN();
- void SendNowPlayingTomIRC();
-
- CWnd *GetModalParent();
-
- void OpenCreateGraphObject(OpenMediaData* pOMD);
- void OpenFile(OpenFileData* pOFD);
- void OpenDVD(OpenDVDData* pODD);
- void OpenCapture(OpenDeviceData* pODD);
- void OpenBDAGraph();
- void OpenCustomizeGraph();
- void OpenSetupVideo();
- void OpenSetupAudio();
- void OpenSetupInfoBar();
- void OpenSetupStatsBar();
- void OpenSetupStatusBar();
- // void OpenSetupToolBar();
- void OpenSetupCaptureBar();
- void OpenSetupWindowTitle(CString fn = _T(""));
- void AutoChangeMonitorMode();
-
- friend class CGraphThread;
- CGraphThread* m_pGraphThread;
-
- CAtlArray<REFERENCE_TIME> m_kfs;
-
- bool m_fOpeningAborted;
+ bool OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD);
+ void CloseMediaPrivate();
+ void DoTunerScan(TunerScanData* pTSD);
+
+ void SendNowPlayingToMSN();
+ void SendNowPlayingTomIRC();
+
+ CWnd *GetModalParent();
+
+ void OpenCreateGraphObject(OpenMediaData* pOMD);
+ void OpenFile(OpenFileData* pOFD);
+ void OpenDVD(OpenDVDData* pODD);
+ void OpenCapture(OpenDeviceData* pODD);
+ void OpenBDAGraph();
+ void OpenCustomizeGraph();
+ void OpenSetupVideo();
+ void OpenSetupAudio();
+ void OpenSetupInfoBar();
+ void OpenSetupStatsBar();
+ void OpenSetupStatusBar();
+ // void OpenSetupToolBar();
+ void OpenSetupCaptureBar();
+ void OpenSetupWindowTitle(CString fn = _T(""));
+ void AutoChangeMonitorMode();
+
+ friend class CGraphThread;
+ CGraphThread* m_pGraphThread;
+
+ CAtlArray<REFERENCE_TIME> m_kfs;
+
+ bool m_fOpeningAborted;
public:
- void OpenCurPlaylistItem(REFERENCE_TIME rtStart = 0);
- void OpenMedia(CAutoPtr<OpenMediaData> pOMD);
- void CloseMedia();
- void StartTunerScan(CAutoPtr<TunerScanData> pTSD);
- void StopTunerScan();
-
- void AddCurDevToPlaylist();
-
- bool m_fTrayIcon;
- void ShowTrayIcon(bool fShow);
- void SetTrayTip(CString str);
-
- CSize GetVideoSize();
- void ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasTo);
- void MoveVideoWindow(bool fShowStats = false);
- void RepaintVideo();
-
- OAFilterState GetMediaState();
- REFERENCE_TIME GetPos(), GetDur();
- void SeekTo(REFERENCE_TIME rt, bool fSeekToKeyFrame = false);
-
- // audio streams order functions
- void InsertAudioStream(const CComQIPtr<IAMStreamSelect> &pSS, int i);
- void SetupAudioStreams();
- // subtitle streams order function
- bool LoadSubtitle(CString fn, ISubStream **actualStream = NULL);
-
- void UpdateSubtitle(bool fApplyDefStyle = false);
- void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = false);
- void ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStreamNew);
- void InvalidateSubtitle(DWORD_PTR nSubtitleId = -1, REFERENCE_TIME rtInvalidate = -1);
- void ReloadSubtitle();
-
- void SetAudioTrackIdx(int index);
- void SetSubtitleTrackIdx(int index);
-
- // shaders
- CAtlList<CString> m_shaderlabels;
- CAtlList<CString> m_shaderlabelsScreenSpace;
- void SetShaders();
- void UpdateShaders(CString label);
-
- // capturing
- bool m_fCapturing;
- HRESULT BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& majortype, AM_MEDIA_TYPE* pmt); // pBF: 0 buff, 1 enc, 2 mux, pmt is for 1 enc
- bool BuildToCapturePreviewPin(
- IBaseFilter* pVidCap, IPin** pVidCapPin, IPin** pVidPrevPin,
- IBaseFilter* pAudCap, IPin** pAudCapPin, IPin** pAudPrevPin);
- bool BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPreview, bool fACapture);
- bool DoCapture(), StartCapture(), StopCapture();
-
- bool DoAfterPlaybackEvent();
- int SearchInDir(bool DirForward);
-
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
- virtual void RecalcLayout(BOOL bNotify = TRUE);
-
- // Dvb capture
- void DisplayCurrentChannelOSD();
+ void OpenCurPlaylistItem(REFERENCE_TIME rtStart = 0);
+ void OpenMedia(CAutoPtr<OpenMediaData> pOMD);
+ void CloseMedia();
+ void StartTunerScan(CAutoPtr<TunerScanData> pTSD);
+ void StopTunerScan();
+
+ void AddCurDevToPlaylist();
+
+ bool m_fTrayIcon;
+ void ShowTrayIcon(bool fShow);
+ void SetTrayTip(CString str);
+
+ CSize GetVideoSize();
+ void ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasTo);
+ void MoveVideoWindow(bool fShowStats = false);
+ void RepaintVideo();
+
+ OAFilterState GetMediaState();
+ REFERENCE_TIME GetPos(), GetDur();
+ void SeekTo(REFERENCE_TIME rt, bool fSeekToKeyFrame = false);
+
+ // audio streams order functions
+ void InsertAudioStream(const CComQIPtr<IAMStreamSelect> &pSS, int i);
+ void SetupAudioStreams();
+ // subtitle streams order function
+ bool LoadSubtitle(CString fn, ISubStream **actualStream = NULL);
+
+ void UpdateSubtitle(bool fApplyDefStyle = false);
+ void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = false);
+ void ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStreamNew);
+ void InvalidateSubtitle(DWORD_PTR nSubtitleId = -1, REFERENCE_TIME rtInvalidate = -1);
+ void ReloadSubtitle();
+
+ void SetAudioTrackIdx(int index);
+ void SetSubtitleTrackIdx(int index);
+
+ // shaders
+ CAtlList<CString> m_shaderlabels;
+ CAtlList<CString> m_shaderlabelsScreenSpace;
+ void SetShaders();
+ void UpdateShaders(CString label);
+
+ // capturing
+ bool m_fCapturing;
+ HRESULT BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& majortype, AM_MEDIA_TYPE* pmt); // pBF: 0 buff, 1 enc, 2 mux, pmt is for 1 enc
+ bool BuildToCapturePreviewPin(
+ IBaseFilter* pVidCap, IPin** pVidCapPin, IPin** pVidPrevPin,
+ IBaseFilter* pAudCap, IPin** pAudCapPin, IPin** pAudPrevPin);
+ bool BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPreview, bool fACapture);
+ bool DoCapture(), StartCapture(), StopCapture();
+
+ bool DoAfterPlaybackEvent();
+ int SearchInDir(bool DirForward);
+
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
+ virtual void RecalcLayout(BOOL bNotify = TRUE);
+
+ // Dvb capture
+ void DisplayCurrentChannelOSD();
// Implementation
public:
- virtual ~CMainFrame();
+ virtual ~CMainFrame();
#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
+ virtual void AssertValid() const;
+ virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
- CChildView m_wndView;
-
- CPlayerSeekBar m_wndSeekBar;
- CPlayerToolBar m_wndToolBar;
- CPlayerInfoBar m_wndInfoBar;
- CPlayerInfoBar m_wndStatsBar;
- CPlayerStatusBar m_wndStatusBar;
- CList<CControlBar*> m_bars;
-
- CPlayerSubresyncBar m_wndSubresyncBar;
- CPlayerPlaylistBar m_wndPlaylistBar;
- CPlayerCaptureBar m_wndCaptureBar;
- CPlayerNavigationBar m_wndNavigationBar;
- CPlayerShaderEditorBar m_wndShaderEditorBar;
- CEditListEditor m_wndEditListEditor;
- CList<CSizingControlBar*> m_dockingbars;
-
- CFileDropTarget m_fileDropTarget;
- // TODO
- DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
- DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
- void OnDragLeave();
- DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point);
-
- LPCTSTR GetRecentFile();
-
- friend class CPPagePlayback; // TODO
- friend class CMPlayerCApp; // TODO
-
- void LoadControlBar(CControlBar* pBar, UINT defDockBarID);
- void RestoreFloatingControlBars();
- void SaveControlBars();
+ CChildView m_wndView;
+
+ CPlayerSeekBar m_wndSeekBar;
+ CPlayerToolBar m_wndToolBar;
+ CPlayerInfoBar m_wndInfoBar;
+ CPlayerInfoBar m_wndStatsBar;
+ CPlayerStatusBar m_wndStatusBar;
+ CList<CControlBar*> m_bars;
+
+ CPlayerSubresyncBar m_wndSubresyncBar;
+ CPlayerPlaylistBar m_wndPlaylistBar;
+ CPlayerCaptureBar m_wndCaptureBar;
+ CPlayerNavigationBar m_wndNavigationBar;
+ CPlayerShaderEditorBar m_wndShaderEditorBar;
+ CEditListEditor m_wndEditListEditor;
+ CList<CSizingControlBar*> m_dockingbars;
+
+ CFileDropTarget m_fileDropTarget;
+ // TODO
+ DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
+ DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
+ void OnDragLeave();
+ DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point);
+
+ LPCTSTR GetRecentFile();
+
+ friend class CPPagePlayback; // TODO
+ friend class CMPlayerCApp; // TODO
+
+ void LoadControlBar(CControlBar* pBar, UINT defDockBarID);
+ void RestoreFloatingControlBars();
+ void SaveControlBars();
// Generated message map functions
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnDestroy();
-
- afx_msg LRESULT OnTaskBarRestart(WPARAM, LPARAM);
- afx_msg LRESULT OnNotifyIcon(WPARAM, LPARAM);
- afx_msg LRESULT OnTaskBarThumbnailsCreate(WPARAM, LPARAM);
-
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
- afx_msg void OnMove(int x, int y);
- afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
- afx_msg void OnDisplayChange();
-
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
- afx_msg LRESULT OnAppCommand(WPARAM wParam, LPARAM lParam);
- afx_msg void OnRawInput(UINT nInputcode, HRAWINPUT hRawInput);
-
- afx_msg LRESULT OnHotKey(WPARAM wParam, LPARAM lParam);
-
- afx_msg void OnTimer(UINT_PTR nIDEvent);
-
- afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnRepaintRenderLess(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnResumeFromState(WPARAM wParam, LPARAM lParam);
-
- BOOL OnButton(UINT id, UINT nFlags, CPoint point);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
- afx_msg LRESULT OnXButtonDown(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnXButtonUp(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnXButtonDblClk(WPARAM wParam, LPARAM lParam);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
-
- afx_msg LRESULT OnNcHitTest(CPoint point);
-
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
-
- afx_msg void OnInitMenu(CMenu* pMenu);
- afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
-
- BOOL OnMenu(CMenu* pMenu);
- afx_msg void OnMenuPlayerShort();
- afx_msg void OnMenuPlayerLong();
- afx_msg void OnMenuFilters();
-
- afx_msg void OnUpdatePlayerStatus(CCmdUI* pCmdUI);
-
- afx_msg void OnFilePostOpenmedia();
- afx_msg void OnUpdateFilePostOpenmedia(CCmdUI* pCmdUI);
- afx_msg void OnFilePostClosemedia();
- afx_msg void OnUpdateFilePostClosemedia(CCmdUI* pCmdUI);
-
- afx_msg void OnBossKey();
-
- afx_msg void OnStreamAudio(UINT nID);
- afx_msg void OnStreamSub(UINT nID);
- afx_msg void OnStreamSubOnOff();
- afx_msg void OnOgmAudio(UINT nID);
- afx_msg void OnOgmSub(UINT nID);
- afx_msg void OnDvdAngle(UINT nID);
- afx_msg void OnDvdAudio(UINT nID);
- afx_msg void OnDvdSub(UINT nID);
- afx_msg void OnDvdSubOnOff();
-
-
- // menu item handlers
-
- afx_msg void OnFileOpenQuick();
- afx_msg void OnFileOpenmedia();
- afx_msg void OnUpdateFileOpen(CCmdUI* pCmdUI);
- afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
- afx_msg void OnFileOpendvd();
- afx_msg void OnFileOpendevice();
- afx_msg void OnFileOpenCD(UINT nID);
- afx_msg void OnDropFiles(HDROP hDropInfo); // no menu item
- afx_msg void OnFileSaveAs();
- afx_msg void OnUpdateFileSaveAs(CCmdUI* pCmdUI);
- afx_msg void OnFileSaveImage();
- afx_msg void OnFileSaveImageAuto();
- afx_msg void OnUpdateFileSaveImage(CCmdUI* pCmdUI);
- afx_msg void OnFileSaveThumbnails();
- afx_msg void OnUpdateFileSaveThumbnails(CCmdUI* pCmdUI);
- afx_msg void OnFileConvert();
- afx_msg void OnUpdateFileConvert(CCmdUI* pCmdUI);
- afx_msg void OnFileLoadsubtitle();
- afx_msg void OnUpdateFileLoadsubtitle(CCmdUI* pCmdUI);
- afx_msg void OnFileSavesubtitle();
- afx_msg void OnUpdateFileSavesubtitle(CCmdUI* pCmdUI);
- afx_msg void OnFileISDBSearch();
- afx_msg void OnUpdateFileISDBSearch(CCmdUI* pCmdUI);
- afx_msg void OnFileISDBUpload();
- afx_msg void OnUpdateFileISDBUpload(CCmdUI* pCmdUI);
- afx_msg void OnFileISDBDownload();
- afx_msg void OnUpdateFileISDBDownload(CCmdUI* pCmdUI);
- afx_msg void OnFileProperties();
- afx_msg void OnUpdateFileProperties(CCmdUI* pCmdUI);
- afx_msg void OnFileClosePlaylist();
- afx_msg void OnFileCloseMedia(); // no menu item
- afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
-
- afx_msg void OnViewCaptionmenu();
- afx_msg void OnViewNavigation();
- afx_msg void OnUpdateViewCaptionmenu(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewNavigation(CCmdUI* pCmdUI);
- afx_msg void OnViewControlBar(UINT nID);
- afx_msg void OnUpdateViewControlBar(CCmdUI* pCmdUI);
- afx_msg void OnViewSubresync();
- afx_msg void OnUpdateViewSubresync(CCmdUI* pCmdUI);
- afx_msg void OnViewPlaylist();
- afx_msg void OnUpdateViewPlaylist(CCmdUI* pCmdUI);
- afx_msg void OnViewEditListEditor();
- afx_msg void OnEDLIn();
- afx_msg void OnUpdateEDLIn(CCmdUI* pCmdUI);
- afx_msg void OnEDLOut();
- afx_msg void OnUpdateEDLOut(CCmdUI* pCmdUI);
- afx_msg void OnEDLNewClip();
- afx_msg void OnUpdateEDLNewClip(CCmdUI* pCmdUI);
- afx_msg void OnViewCapture();
- afx_msg void OnUpdateViewCapture(CCmdUI* pCmdUI);
- afx_msg void OnViewShaderEditor();
- afx_msg void OnUpdateViewShaderEditor(CCmdUI* pCmdUI);
- afx_msg void OnViewMinimal();
- afx_msg void OnUpdateViewMinimal(CCmdUI* pCmdUI);
- afx_msg void OnViewCompact();
- afx_msg void OnUpdateViewCompact(CCmdUI* pCmdUI);
- afx_msg void OnViewNormal();
- afx_msg void OnUpdateViewNormal(CCmdUI* pCmdUI);
- afx_msg void OnViewFullscreen();
- afx_msg void OnViewFullscreenSecondary();
- afx_msg void OnUpdateViewFullscreen(CCmdUI* pCmdUI);
- afx_msg void OnViewZoom(UINT nID);
- afx_msg void OnUpdateViewZoom(CCmdUI* pCmdUI);
- afx_msg void OnViewZoomAutoFit();
- afx_msg void OnViewDefaultVideoFrame(UINT nID);
- afx_msg void OnUpdateViewDefaultVideoFrame(CCmdUI* pCmdUI);
- afx_msg void OnViewKeepaspectratio();
- afx_msg void OnUpdateViewKeepaspectratio(CCmdUI* pCmdUI);
- afx_msg void OnViewCompMonDeskARDiff();
- afx_msg void OnUpdateViewCompMonDeskARDiff(CCmdUI* pCmdUI);
- afx_msg void OnViewPanNScan(UINT nID);
- afx_msg void OnUpdateViewPanNScan(CCmdUI* pCmdUI);
- afx_msg void OnViewPanNScanPresets(UINT nID);
- afx_msg void OnUpdateViewPanNScanPresets(CCmdUI* pCmdUI);
- afx_msg void OnViewRotate(UINT nID);
- afx_msg void OnUpdateViewRotate(CCmdUI* pCmdUI);
- afx_msg void OnViewAspectRatio(UINT nID);
- afx_msg void OnUpdateViewAspectRatio(CCmdUI* pCmdUI);
- afx_msg void OnViewAspectRatioNext();
- afx_msg void OnViewOntop(UINT nID);
- afx_msg void OnUpdateViewOntop(CCmdUI* pCmdUI);
- afx_msg void OnViewOptions();
- afx_msg void OnUpdateViewTearingTest(CCmdUI* pCmdUI);
- afx_msg void OnViewTearingTest();
- afx_msg void OnUpdateViewDisplayStats(CCmdUI* pCmdUI);
- afx_msg void OnViewResetStats();
- afx_msg void OnViewDisplayStatsSC();
- afx_msg void OnUpdateViewVSync(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncOffset(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewFlushGPU(CCmdUI* pCmdUI);
-
- afx_msg void OnUpdateViewSynchronizeVideo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewSynchronizeDisplay(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewSynchronizeNearest(CCmdUI* pCmdUI);
-
- afx_msg void OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI);
-
- afx_msg void OnUpdateViewEVROutputRange(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewHighColorResolution(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI);
- afx_msg void OnViewVSync();
- afx_msg void OnViewVSyncAccurate();
-
- afx_msg void OnViewSynchronizeVideo();
- afx_msg void OnViewSynchronizeDisplay();
- afx_msg void OnViewSynchronizeNearest();
-
- afx_msg void OnViewEVROutputRange_0_255();
- afx_msg void OnViewEVROutputRange_16_235();
-
- afx_msg void OnViewFlushGPUBeforeVSync();
- afx_msg void OnViewFlushGPUAfterVSync();
- afx_msg void OnViewFlushGPUWait();
-
- afx_msg void OnViewD3DFullScreen();
- afx_msg void OnViewDisableDesktopComposition();
- afx_msg void OnViewAlternativeVSync();
- afx_msg void OnViewResetDefault();
- afx_msg void OnViewResetOptimal();
-
- afx_msg void OnViewFullscreenGUISupport();
- afx_msg void OnViewHighColorResolution();
- afx_msg void OnViewEnableFrameTimeCorrection();
- afx_msg void OnViewVSyncOffsetIncrease();
- afx_msg void OnViewVSyncOffsetDecrease();
- afx_msg void OnUpdateShaderToggle(CCmdUI* pCmdUI);
- afx_msg void OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI);
- afx_msg void OnShaderToggle();
- afx_msg void OnShaderToggleScreenSpace();
- afx_msg void OnUpdateViewRemainingTime(CCmdUI* pCmdUI);
- afx_msg void OnViewRemainingTime();
- afx_msg void OnD3DFullscreenToggle();
- afx_msg void OnGotoSubtitle(UINT nID);
- afx_msg void OnShiftSubtitle(UINT nID);
- afx_msg void OnSubtitleDelay(UINT nID);
-
-
- afx_msg void OnPlayPlay();
- afx_msg void OnPlayPause();
- afx_msg void OnPlayPauseI();
- afx_msg void OnPlayPlaypause();
- afx_msg void OnPlayStop();
- afx_msg void OnUpdatePlayPauseStop(CCmdUI* pCmdUI);
- afx_msg void OnPlayFramestep(UINT nID);
- afx_msg void OnUpdatePlayFramestep(CCmdUI* pCmdUI);
- afx_msg void OnPlaySeek(UINT nID);
- afx_msg void OnPlaySeekKey(UINT nID); // no menu item
- afx_msg void OnUpdatePlaySeek(CCmdUI* pCmdUI);
- afx_msg void OnPlayGoto();
- afx_msg void OnUpdateGoto(CCmdUI* pCmdUI);
- afx_msg void OnPlayChangeRate(UINT nID);
- afx_msg void OnUpdatePlayChangeRate(CCmdUI* pCmdUI);
- afx_msg void OnPlayResetRate();
- afx_msg void OnUpdatePlayResetRate(CCmdUI* pCmdUI);
- afx_msg void OnPlayChangeAudDelay(UINT nID);
- afx_msg void OnUpdatePlayChangeAudDelay(CCmdUI* pCmdUI);
- afx_msg void OnPlayFilters(UINT nID);
- afx_msg void OnUpdatePlayFilters(CCmdUI* pCmdUI);
- afx_msg void OnPlayShaders(UINT nID);
- afx_msg void OnUpdatePlayShaders(CCmdUI* pCmdUI);
- afx_msg void OnPlayAudio(UINT nID);
- afx_msg void OnUpdatePlayAudio(CCmdUI* pCmdUI);
- afx_msg void OnPlaySubtitles(UINT nID);
- afx_msg void OnUpdatePlaySubtitles(CCmdUI* pCmdUI);
- afx_msg void OnPlayLanguage(UINT nID);
- afx_msg void OnUpdatePlayLanguage(CCmdUI* pCmdUI);
- afx_msg void OnPlayVolume(UINT nID);
- afx_msg void OnPlayVolumeBoost(UINT nID);
- afx_msg void OnUpdatePlayVolumeBoost(CCmdUI* pCmdUI);
- afx_msg void OnAfterplayback(UINT nID);
- afx_msg void OnUpdateAfterplayback(CCmdUI* pCmdUI);
-
- afx_msg void OnNavigateSkip(UINT nID);
- afx_msg void OnUpdateNavigateSkip(CCmdUI* pCmdUI);
- afx_msg void OnNavigateSkipPlaylistItem(UINT nID);
- afx_msg void OnUpdateNavigateSkipPlaylistItem(CCmdUI* pCmdUI);
- afx_msg void OnNavigateMenu(UINT nID);
- afx_msg void OnUpdateNavigateMenu(CCmdUI* pCmdUI);
- afx_msg void OnNavigateAudio(UINT nID);
- afx_msg void OnNavigateSubpic(UINT nID);
- afx_msg void OnNavigateAngle(UINT nID);
- afx_msg void OnNavigateChapters(UINT nID);
- afx_msg void OnNavigateMenuItem(UINT nID);
- afx_msg void OnUpdateNavigateMenuItem(CCmdUI* pCmdUI);
- afx_msg void OnTunerScan();
- afx_msg void OnUpdateTunerScan(CCmdUI* pCmdUI);
-
- afx_msg void OnFavoritesAdd();
- afx_msg void OnUpdateFavoritesAdd(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesQuickAddFavorite();
- afx_msg void OnFavoritesOrganize();
- afx_msg void OnUpdateFavoritesOrganize(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesFile(UINT nID);
- afx_msg void OnUpdateFavoritesFile(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesDVD(UINT nID);
- afx_msg void OnUpdateFavoritesDVD(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesDevice(UINT nID);
- afx_msg void OnUpdateFavoritesDevice(CCmdUI* pCmdUI);
- afx_msg void OnRecentFileClear();
- afx_msg void OnUpdateRecentFileClear(CCmdUI* pCmdUI);
- afx_msg void OnRecentFile(UINT nID);
- afx_msg void OnUpdateRecentFile(CCmdUI* pCmdUI);
-
-
- afx_msg void OnHelpHomepage();
- afx_msg void OnHelpDocumentation();
- afx_msg void OnHelpDonate();
-
- afx_msg void OnClose();
-
- afx_msg void OnLanguage(UINT nID);
- afx_msg void OnUpdateLanguage(CCmdUI* pCmdUI);
-
-
- CMPC_Lcd m_Lcd;
-
- // ==== Added by CASIMIR666
- CWnd* m_pVideoWnd; // Current Video (main display screen or 2nd)
- SIZE m_fullWndSize;
- CFullscreenWnd* m_pFullscreenWnd;
- CComPtr<IVMRMixerControl9> m_pMC;
- CComPtr<IMFVideoDisplayControl> m_pMFVDC;
- CVMROSD m_OSD;
- bool m_bRemainingTime;
- int m_nCurSubtitle;
- long m_lSubtitleShift;
- __int64 m_rtCurSubPos;
- CString m_strTitle;
- bool m_bToggleShader;
- bool m_bToggleShaderScreenSpace;
- bool m_bInOptions;
- bool m_bStopTunerScan;
-
- void SetLoadState(MPC_LOADSTATE iState);
- void SetPlayState(MPC_PLAYSTATE iState);
- bool CreateFullScreenWindow();
- void SetVMR9ColorControl(float Brightness, float Contrast, float Hue, float Saturation);
- LPCTSTR GetDVDAudioFormatName(DVD_AudioAttributes& ATR);
- void SetAudioDelay(REFERENCE_TIME rtShift);
- void SetSubtitleDelay(int delay_ms);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnDestroy();
+
+ afx_msg LRESULT OnTaskBarRestart(WPARAM, LPARAM);
+ afx_msg LRESULT OnNotifyIcon(WPARAM, LPARAM);
+ afx_msg LRESULT OnTaskBarThumbnailsCreate(WPARAM, LPARAM);
+
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
+ afx_msg void OnMove(int x, int y);
+ afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
+ afx_msg void OnDisplayChange();
+
+ afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+ afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
+ afx_msg LRESULT OnAppCommand(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnRawInput(UINT nInputcode, HRAWINPUT hRawInput);
+
+ afx_msg LRESULT OnHotKey(WPARAM wParam, LPARAM lParam);
+
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+
+ afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnRepaintRenderLess(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnResumeFromState(WPARAM wParam, LPARAM lParam);
+
+ BOOL OnButton(UINT id, UINT nFlags, CPoint point);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg LRESULT OnXButtonDown(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnXButtonUp(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnXButtonDblClk(WPARAM wParam, LPARAM lParam);
+ afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+
+ afx_msg void OnInitMenu(CMenu* pMenu);
+ afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
+
+ BOOL OnMenu(CMenu* pMenu);
+ afx_msg void OnMenuPlayerShort();
+ afx_msg void OnMenuPlayerLong();
+ afx_msg void OnMenuFilters();
+
+ afx_msg void OnUpdatePlayerStatus(CCmdUI* pCmdUI);
+
+ afx_msg void OnFilePostOpenmedia();
+ afx_msg void OnUpdateFilePostOpenmedia(CCmdUI* pCmdUI);
+ afx_msg void OnFilePostClosemedia();
+ afx_msg void OnUpdateFilePostClosemedia(CCmdUI* pCmdUI);
+
+ afx_msg void OnBossKey();
+
+ afx_msg void OnStreamAudio(UINT nID);
+ afx_msg void OnStreamSub(UINT nID);
+ afx_msg void OnStreamSubOnOff();
+ afx_msg void OnOgmAudio(UINT nID);
+ afx_msg void OnOgmSub(UINT nID);
+ afx_msg void OnDvdAngle(UINT nID);
+ afx_msg void OnDvdAudio(UINT nID);
+ afx_msg void OnDvdSub(UINT nID);
+ afx_msg void OnDvdSubOnOff();
+
+
+ // menu item handlers
+
+ afx_msg void OnFileOpenQuick();
+ afx_msg void OnFileOpenmedia();
+ afx_msg void OnUpdateFileOpen(CCmdUI* pCmdUI);
+ afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
+ afx_msg void OnFileOpendvd();
+ afx_msg void OnFileOpendevice();
+ afx_msg void OnFileOpenCD(UINT nID);
+ afx_msg void OnDropFiles(HDROP hDropInfo); // no menu item
+ afx_msg void OnFileSaveAs();
+ afx_msg void OnUpdateFileSaveAs(CCmdUI* pCmdUI);
+ afx_msg void OnFileSaveImage();
+ afx_msg void OnFileSaveImageAuto();
+ afx_msg void OnUpdateFileSaveImage(CCmdUI* pCmdUI);
+ afx_msg void OnFileSaveThumbnails();
+ afx_msg void OnUpdateFileSaveThumbnails(CCmdUI* pCmdUI);
+ afx_msg void OnFileConvert();
+ afx_msg void OnUpdateFileConvert(CCmdUI* pCmdUI);
+ afx_msg void OnFileLoadsubtitle();
+ afx_msg void OnUpdateFileLoadsubtitle(CCmdUI* pCmdUI);
+ afx_msg void OnFileSavesubtitle();
+ afx_msg void OnUpdateFileSavesubtitle(CCmdUI* pCmdUI);
+ afx_msg void OnFileISDBSearch();
+ afx_msg void OnUpdateFileISDBSearch(CCmdUI* pCmdUI);
+ afx_msg void OnFileISDBUpload();
+ afx_msg void OnUpdateFileISDBUpload(CCmdUI* pCmdUI);
+ afx_msg void OnFileISDBDownload();
+ afx_msg void OnUpdateFileISDBDownload(CCmdUI* pCmdUI);
+ afx_msg void OnFileProperties();
+ afx_msg void OnUpdateFileProperties(CCmdUI* pCmdUI);
+ afx_msg void OnFileClosePlaylist();
+ afx_msg void OnFileCloseMedia(); // no menu item
+ afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
+
+ afx_msg void OnViewCaptionmenu();
+ afx_msg void OnViewNavigation();
+ afx_msg void OnUpdateViewCaptionmenu(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewNavigation(CCmdUI* pCmdUI);
+ afx_msg void OnViewControlBar(UINT nID);
+ afx_msg void OnUpdateViewControlBar(CCmdUI* pCmdUI);
+ afx_msg void OnViewSubresync();
+ afx_msg void OnUpdateViewSubresync(CCmdUI* pCmdUI);
+ afx_msg void OnViewPlaylist();
+ afx_msg void OnUpdateViewPlaylist(CCmdUI* pCmdUI);
+ afx_msg void OnViewEditListEditor();
+ afx_msg void OnEDLIn();
+ afx_msg void OnUpdateEDLIn(CCmdUI* pCmdUI);
+ afx_msg void OnEDLOut();
+ afx_msg void OnUpdateEDLOut(CCmdUI* pCmdUI);
+ afx_msg void OnEDLNewClip();
+ afx_msg void OnUpdateEDLNewClip(CCmdUI* pCmdUI);
+ afx_msg void OnViewCapture();
+ afx_msg void OnUpdateViewCapture(CCmdUI* pCmdUI);
+ afx_msg void OnViewShaderEditor();
+ afx_msg void OnUpdateViewShaderEditor(CCmdUI* pCmdUI);
+ afx_msg void OnViewMinimal();
+ afx_msg void OnUpdateViewMinimal(CCmdUI* pCmdUI);
+ afx_msg void OnViewCompact();
+ afx_msg void OnUpdateViewCompact(CCmdUI* pCmdUI);
+ afx_msg void OnViewNormal();
+ afx_msg void OnUpdateViewNormal(CCmdUI* pCmdUI);
+ afx_msg void OnViewFullscreen();
+ afx_msg void OnViewFullscreenSecondary();
+ afx_msg void OnUpdateViewFullscreen(CCmdUI* pCmdUI);
+ afx_msg void OnViewZoom(UINT nID);
+ afx_msg void OnUpdateViewZoom(CCmdUI* pCmdUI);
+ afx_msg void OnViewZoomAutoFit();
+ afx_msg void OnViewDefaultVideoFrame(UINT nID);
+ afx_msg void OnUpdateViewDefaultVideoFrame(CCmdUI* pCmdUI);
+ afx_msg void OnViewKeepaspectratio();
+ afx_msg void OnUpdateViewKeepaspectratio(CCmdUI* pCmdUI);
+ afx_msg void OnViewCompMonDeskARDiff();
+ afx_msg void OnUpdateViewCompMonDeskARDiff(CCmdUI* pCmdUI);
+ afx_msg void OnViewPanNScan(UINT nID);
+ afx_msg void OnUpdateViewPanNScan(CCmdUI* pCmdUI);
+ afx_msg void OnViewPanNScanPresets(UINT nID);
+ afx_msg void OnUpdateViewPanNScanPresets(CCmdUI* pCmdUI);
+ afx_msg void OnViewRotate(UINT nID);
+ afx_msg void OnUpdateViewRotate(CCmdUI* pCmdUI);
+ afx_msg void OnViewAspectRatio(UINT nID);
+ afx_msg void OnUpdateViewAspectRatio(CCmdUI* pCmdUI);
+ afx_msg void OnViewAspectRatioNext();
+ afx_msg void OnViewOntop(UINT nID);
+ afx_msg void OnUpdateViewOntop(CCmdUI* pCmdUI);
+ afx_msg void OnViewOptions();
+ afx_msg void OnUpdateViewTearingTest(CCmdUI* pCmdUI);
+ afx_msg void OnViewTearingTest();
+ afx_msg void OnUpdateViewDisplayStats(CCmdUI* pCmdUI);
+ afx_msg void OnViewResetStats();
+ afx_msg void OnViewDisplayStatsSC();
+ afx_msg void OnUpdateViewVSync(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffset(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewFlushGPU(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewSynchronizeVideo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewSynchronizeDisplay(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewSynchronizeNearest(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewEVROutputRange(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewHighColorResolution(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI);
+ afx_msg void OnViewVSync();
+ afx_msg void OnViewVSyncAccurate();
+
+ afx_msg void OnViewSynchronizeVideo();
+ afx_msg void OnViewSynchronizeDisplay();
+ afx_msg void OnViewSynchronizeNearest();
+
+ afx_msg void OnViewEVROutputRange_0_255();
+ afx_msg void OnViewEVROutputRange_16_235();
+
+ afx_msg void OnViewFlushGPUBeforeVSync();
+ afx_msg void OnViewFlushGPUAfterVSync();
+ afx_msg void OnViewFlushGPUWait();
+
+ afx_msg void OnViewD3DFullScreen();
+ afx_msg void OnViewDisableDesktopComposition();
+ afx_msg void OnViewAlternativeVSync();
+ afx_msg void OnViewResetDefault();
+ afx_msg void OnViewResetOptimal();
+
+ afx_msg void OnViewFullscreenGUISupport();
+ afx_msg void OnViewHighColorResolution();
+ afx_msg void OnViewEnableFrameTimeCorrection();
+ afx_msg void OnViewVSyncOffsetIncrease();
+ afx_msg void OnViewVSyncOffsetDecrease();
+ afx_msg void OnUpdateShaderToggle(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI);
+ afx_msg void OnShaderToggle();
+ afx_msg void OnShaderToggleScreenSpace();
+ afx_msg void OnUpdateViewRemainingTime(CCmdUI* pCmdUI);
+ afx_msg void OnViewRemainingTime();
+ afx_msg void OnD3DFullscreenToggle();
+ afx_msg void OnGotoSubtitle(UINT nID);
+ afx_msg void OnShiftSubtitle(UINT nID);
+ afx_msg void OnSubtitleDelay(UINT nID);
+
+
+ afx_msg void OnPlayPlay();
+ afx_msg void OnPlayPause();
+ afx_msg void OnPlayPauseI();
+ afx_msg void OnPlayPlaypause();
+ afx_msg void OnPlayStop();
+ afx_msg void OnUpdatePlayPauseStop(CCmdUI* pCmdUI);
+ afx_msg void OnPlayFramestep(UINT nID);
+ afx_msg void OnUpdatePlayFramestep(CCmdUI* pCmdUI);
+ afx_msg void OnPlaySeek(UINT nID);
+ afx_msg void OnPlaySeekKey(UINT nID); // no menu item
+ afx_msg void OnUpdatePlaySeek(CCmdUI* pCmdUI);
+ afx_msg void OnPlayGoto();
+ afx_msg void OnUpdateGoto(CCmdUI* pCmdUI);
+ afx_msg void OnPlayChangeRate(UINT nID);
+ afx_msg void OnUpdatePlayChangeRate(CCmdUI* pCmdUI);
+ afx_msg void OnPlayResetRate();
+ afx_msg void OnUpdatePlayResetRate(CCmdUI* pCmdUI);
+ afx_msg void OnPlayChangeAudDelay(UINT nID);
+ afx_msg void OnUpdatePlayChangeAudDelay(CCmdUI* pCmdUI);
+ afx_msg void OnPlayFilters(UINT nID);
+ afx_msg void OnUpdatePlayFilters(CCmdUI* pCmdUI);
+ afx_msg void OnPlayShaders(UINT nID);
+ afx_msg void OnUpdatePlayShaders(CCmdUI* pCmdUI);
+ afx_msg void OnPlayAudio(UINT nID);
+ afx_msg void OnUpdatePlayAudio(CCmdUI* pCmdUI);
+ afx_msg void OnPlaySubtitles(UINT nID);
+ afx_msg void OnUpdatePlaySubtitles(CCmdUI* pCmdUI);
+ afx_msg void OnPlayLanguage(UINT nID);
+ afx_msg void OnUpdatePlayLanguage(CCmdUI* pCmdUI);
+ afx_msg void OnPlayVolume(UINT nID);
+ afx_msg void OnPlayVolumeBoost(UINT nID);
+ afx_msg void OnUpdatePlayVolumeBoost(CCmdUI* pCmdUI);
+ afx_msg void OnAfterplayback(UINT nID);
+ afx_msg void OnUpdateAfterplayback(CCmdUI* pCmdUI);
+
+ afx_msg void OnNavigateSkip(UINT nID);
+ afx_msg void OnUpdateNavigateSkip(CCmdUI* pCmdUI);
+ afx_msg void OnNavigateSkipPlaylistItem(UINT nID);
+ afx_msg void OnUpdateNavigateSkipPlaylistItem(CCmdUI* pCmdUI);
+ afx_msg void OnNavigateMenu(UINT nID);
+ afx_msg void OnUpdateNavigateMenu(CCmdUI* pCmdUI);
+ afx_msg void OnNavigateAudio(UINT nID);
+ afx_msg void OnNavigateSubpic(UINT nID);
+ afx_msg void OnNavigateAngle(UINT nID);
+ afx_msg void OnNavigateChapters(UINT nID);
+ afx_msg void OnNavigateMenuItem(UINT nID);
+ afx_msg void OnUpdateNavigateMenuItem(CCmdUI* pCmdUI);
+ afx_msg void OnTunerScan();
+ afx_msg void OnUpdateTunerScan(CCmdUI* pCmdUI);
+
+ afx_msg void OnFavoritesAdd();
+ afx_msg void OnUpdateFavoritesAdd(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesQuickAddFavorite();
+ afx_msg void OnFavoritesOrganize();
+ afx_msg void OnUpdateFavoritesOrganize(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesFile(UINT nID);
+ afx_msg void OnUpdateFavoritesFile(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesDVD(UINT nID);
+ afx_msg void OnUpdateFavoritesDVD(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesDevice(UINT nID);
+ afx_msg void OnUpdateFavoritesDevice(CCmdUI* pCmdUI);
+ afx_msg void OnRecentFileClear();
+ afx_msg void OnUpdateRecentFileClear(CCmdUI* pCmdUI);
+ afx_msg void OnRecentFile(UINT nID);
+ afx_msg void OnUpdateRecentFile(CCmdUI* pCmdUI);
+
+
+ afx_msg void OnHelpHomepage();
+ afx_msg void OnHelpDocumentation();
+ afx_msg void OnHelpDonate();
+
+ afx_msg void OnClose();
+
+ afx_msg void OnLanguage(UINT nID);
+ afx_msg void OnUpdateLanguage(CCmdUI* pCmdUI);
+
+
+ CMPC_Lcd m_Lcd;
+
+ // ==== Added by CASIMIR666
+ CWnd* m_pVideoWnd; // Current Video (main display screen or 2nd)
+ SIZE m_fullWndSize;
+ CFullscreenWnd* m_pFullscreenWnd;
+ CComPtr<IVMRMixerControl9> m_pMC;
+ CComPtr<IMFVideoDisplayControl> m_pMFVDC;
+ CVMROSD m_OSD;
+ bool m_bRemainingTime;
+ int m_nCurSubtitle;
+ long m_lSubtitleShift;
+ __int64 m_rtCurSubPos;
+ CString m_strTitle;
+ bool m_bToggleShader;
+ bool m_bToggleShaderScreenSpace;
+ bool m_bInOptions;
+ bool m_bStopTunerScan;
+
+ void SetLoadState(MPC_LOADSTATE iState);
+ void SetPlayState(MPC_PLAYSTATE iState);
+ bool CreateFullScreenWindow();
+ void SetVMR9ColorControl(float Brightness, float Contrast, float Hue, float Saturation);
+ LPCTSTR GetDVDAudioFormatName (DVD_AudioAttributes& ATR);
+ void SetAudioDelay(REFERENCE_TIME rtShift);
+ void SetSubtitleDelay(int delay_ms);
// void AutoSelectTracks();
- bool IsRealEngineCompatible(CString strFilename);
+ bool IsRealEngineCompatible(CString strFilename);
- // MPC API functions
- void ProcessAPICommand(COPYDATASTRUCT* pCDS);
- void SendAPICommand(MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...);
- void SendNowPlayingToApi();
- void SendSubtitleTracksToApi();
- void SendAudioTracksToApi();
- void SendPlaylistToApi();
- afx_msg void OnFileOpendirectory();
+ // MPC API functions
+ void ProcessAPICommand(COPYDATASTRUCT* pCDS);
+ void SendAPICommand (MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...);
+ void SendNowPlayingToApi();
+ void SendSubtitleTracksToApi();
+ void SendAudioTracksToApi();
+ void SendPlaylistToApi();
+ afx_msg void OnFileOpendirectory();
- CString GetVidPos();
+ CString GetVidPos();
- ITaskbarList3* m_pTaskbarList;
- HRESULT CreateThumbnailToolbar();
- HRESULT UpdateThumbarButton();
- HRESULT UpdateThumbnailClip();
+ ITaskbarList3* m_pTaskbarList;
+ HRESULT CreateThumbnailToolbar();
+ HRESULT UpdateThumbarButton();
+ HRESULT UpdateThumbnailClip();
protected:
- // GDI+
- ULONG_PTR m_gdiplusToken;
+ // GDI+
+ ULONG_PTR m_gdiplusToken;
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
public:
- afx_msg UINT OnPowerBroadcast(UINT nPowerEvent, UINT nEventData);
+ afx_msg UINT OnPowerBroadcast(UINT nPowerEvent, UINT nEventData);
};
diff --git a/src/apps/mplayerc/MediaFormats.cpp b/src/apps/mplayerc/MediaFormats.cpp
index 9c4b20b16..71c950383 100644
--- a/src/apps/mplayerc/MediaFormats.cpp
+++ b/src/apps/mplayerc/MediaFormats.cpp
@@ -31,35 +31,35 @@
//
CMediaFormatCategory::CMediaFormatCategory()
- : m_fAudioOnly(false)
+ : m_fAudioOnly(false)
{
}
CMediaFormatCategory::CMediaFormatCategory(
- CString label, CAtlList<CString>& exts, bool fAudioOnly,
- CString specreqnote, engine_t engine)
+ CString label, CAtlList<CString>& exts, bool fAudioOnly,
+ CString specreqnote, engine_t engine)
{
- m_label = label;
- m_exts.AddTailList(&exts);
- m_backupexts.AddTailList(&m_exts);
- m_specreqnote = specreqnote;
- m_fAudioOnly = fAudioOnly;
- m_engine = engine;
+ m_label = label;
+ m_exts.AddTailList(&exts);
+ m_backupexts.AddTailList(&m_exts);
+ m_specreqnote = specreqnote;
+ m_fAudioOnly = fAudioOnly;
+ m_engine = engine;
}
CMediaFormatCategory::CMediaFormatCategory(
- CString label, CString exts, bool fAudioOnly,
- CString specreqnote, engine_t engine)
+ CString label, CString exts, bool fAudioOnly,
+ CString specreqnote, engine_t engine)
{
- m_label = label;
- ExplodeMin(exts, m_exts, ' ');
- POSITION pos = m_exts.GetHeadPosition();
- while(pos) m_exts.GetNext(pos).TrimLeft('.');
-
- m_backupexts.AddTailList(&m_exts);
- m_specreqnote = specreqnote;
- m_fAudioOnly = fAudioOnly;
- m_engine = engine;
+ m_label = label;
+ ExplodeMin(exts, m_exts, ' ');
+ POSITION pos = m_exts.GetHeadPosition();
+ while(pos) m_exts.GetNext(pos).TrimLeft('.');
+
+ m_backupexts.AddTailList(&m_exts);
+ m_specreqnote = specreqnote;
+ m_fAudioOnly = fAudioOnly;
+ m_engine = engine;
}
CMediaFormatCategory::~CMediaFormatCategory()
@@ -68,98 +68,94 @@ CMediaFormatCategory::~CMediaFormatCategory()
void CMediaFormatCategory::UpdateData(bool fSave)
{
- if(fSave)
- {
- AfxGetApp()->WriteProfileString(_T("FileFormats"), m_label, GetExts(true));
- }
- else
- {
- SetExts(AfxGetApp()->GetProfileString(_T("FileFormats"), m_label, GetExts(true)));
- }
+ if(fSave)
+ {
+ AfxGetApp()->WriteProfileString(_T("FileFormats"), m_label, GetExts(true));
+ }
+ else
+ {
+ SetExts(AfxGetApp()->GetProfileString(_T("FileFormats"), m_label, GetExts(true)));
+ }
}
CMediaFormatCategory::CMediaFormatCategory(const CMediaFormatCategory& mfc)
{
- *this = mfc;
+ *this = mfc;
}
CMediaFormatCategory& CMediaFormatCategory::operator = (const CMediaFormatCategory& mfc)
{
- m_label = mfc.m_label;
- m_specreqnote = mfc.m_specreqnote;
- m_exts.RemoveAll();
- m_exts.AddTailList(&mfc.m_exts);
- m_backupexts.RemoveAll();
- m_backupexts.AddTailList(&mfc.m_backupexts);
- m_fAudioOnly = mfc.m_fAudioOnly;
- m_engine = mfc.m_engine;
- return *this;
+ m_label = mfc.m_label;
+ m_specreqnote = mfc.m_specreqnote;
+ m_exts.RemoveAll();
+ m_exts.AddTailList(&mfc.m_exts);
+ m_backupexts.RemoveAll();
+ m_backupexts.AddTailList(&mfc.m_backupexts);
+ m_fAudioOnly = mfc.m_fAudioOnly;
+ m_engine = mfc.m_engine;
+ return *this;
}
void CMediaFormatCategory::RestoreDefaultExts()
{
- m_exts.RemoveAll();
- m_exts.AddTailList(&m_backupexts);
+ m_exts.RemoveAll();
+ m_exts.AddTailList(&m_backupexts);
}
void CMediaFormatCategory::SetExts(CAtlList<CString>& exts)
{
- m_exts.RemoveAll();
- m_exts.AddTailList(&exts);
+ m_exts.RemoveAll();
+ m_exts.AddTailList(&exts);
}
void CMediaFormatCategory::SetExts(CString exts)
{
- m_exts.RemoveAll();
- ExplodeMin(exts, m_exts, ' ');
- POSITION pos = m_exts.GetHeadPosition();
- while(pos)
- {
- POSITION cur = pos;
- CString& ext = m_exts.GetNext(pos);
- if(ext[0] == '\\')
- {
- m_engine = (engine_t)_tcstol(ext.TrimLeft('\\'), NULL, 10);
- m_exts.RemoveAt(cur);
- }
- else ext.TrimLeft('.');
- }
+ m_exts.RemoveAll();
+ ExplodeMin(exts, m_exts, ' ');
+ POSITION pos = m_exts.GetHeadPosition();
+ while(pos)
+ {
+ POSITION cur = pos;
+ CString& ext = m_exts.GetNext(pos);
+ if(ext[0] == '\\') {m_engine = (engine_t)_tcstol(ext.TrimLeft('\\'), NULL, 10); m_exts.RemoveAt(cur);}
+ else ext.TrimLeft('.');
+ }
}
CString CMediaFormatCategory::GetFilter()
{
- CString filter;
- POSITION pos = m_exts.GetHeadPosition();
- while(pos) filter += _T("*.") + m_exts.GetNext(pos) + _T(";");
- filter.TrimRight(_T(";")); // cheap...
- return(filter);
+ CString filter;
+ POSITION pos = m_exts.GetHeadPosition();
+ while(pos) filter += _T("*.") + m_exts.GetNext(pos) + _T(";");
+ filter.TrimRight(_T(";")); // cheap...
+ return(filter);
}
CString CMediaFormatCategory::GetExts(bool fAppendEngine)
{
- CString exts = Implode(m_exts, ' ');
- if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
- return(exts);
+ CString exts = Implode(m_exts, ' ');
+ if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ return(exts);
}
CString CMediaFormatCategory::GetExtsWithPeriod(bool fAppendEngine)
{
- CString exts;
- POSITION pos = m_exts.GetHeadPosition();
- while(pos) exts += _T(".") + m_exts.GetNext(pos) + _T(" ");
- exts.TrimRight(_T(" ")); // cheap...
- if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
- return(exts);
+ CString exts;
+ POSITION pos = m_exts.GetHeadPosition();
+ while(pos) exts += _T(".") + m_exts.GetNext(pos) + _T(" ");
+ exts.TrimRight(_T(" ")); // cheap...
+ if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ return(exts);
}
CString CMediaFormatCategory::GetBackupExtsWithPeriod(bool fAppendEngine)
{
- CString exts;
- POSITION pos = m_backupexts.GetHeadPosition();
- while(pos) exts += _T(".") + m_backupexts.GetNext(pos) + _T(" ");
- exts.TrimRight(_T(" ")); // cheap...
- if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
- return(exts);
+ CString exts;
+ POSITION pos = m_backupexts.GetHeadPosition();
+ while(pos) exts += _T(".") + m_backupexts.GetNext(pos) + _T(" ");
+ exts.TrimRight(_T(" ")); // cheap...
+ if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ return(exts);
}
//
@@ -176,209 +172,209 @@ CMediaFormats::~CMediaFormats()
void CMediaFormats::UpdateData(bool fSave)
{
- if(fSave)
- {
- AfxGetApp()->WriteProfileString(_T("FileFormats"), NULL, NULL);
+ if(fSave)
+ {
+ AfxGetApp()->WriteProfileString(_T("FileFormats"), NULL, NULL);
- AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspHandler"), m_iRtspHandler);
- AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), m_fRtspFileExtFirst);
- }
- else
- {
- RemoveAll();
+ AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspHandler"), m_iRtspHandler);
+ AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), m_fRtspFileExtFirst);
+ }
+ else
+ {
+ RemoveAll();
#define ADDFMT(f) Add(CMediaFormatCategory##f)
- ADDFMT((ResStr(IDS_MEDIAFORMATS_0), _T("wmv wmp wm asf")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_1), _T("wma"), true));
- ADDFMT((ResStr(IDS_AG_VIDEO_FILE), _T("avi")));
- ADDFMT((ResStr(IDS_AG_AUDIO_FILE), _T("wav"), true));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_4), _T("mpg mpeg mpe m1v m2v mpv2 mp2v ts tp tpr pva m2ts m2t mts evo m2p")));
- ADDFMT((_T("VCD file"), _T("dat")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_5), _T("mpa mp2 m1a m2a"), true));
- ADDFMT((ResStr(IDS_AG_DVD_FILE), _T("vob ifo")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_7), _T("ac3 dts"), true));
- ADDFMT((_T("MP3 Format Sound"), _T("mp3"), true));
- ADDFMT((ResStr(IDS_AG_MIDI_FILE), _T("mid midi rmi"), true));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_9), _T("ivf")));
- ADDFMT((_T("AIFF Format Sound"), _T("aif aifc aiff"), true));
- ADDFMT((_T("AU Format Sound"), _T("au snd"), true));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_10), _T("ogm ogv")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_11), _T("ogg oga"), true));
- ADDFMT((_T("CD Audio Track"), _T("cda"), true, ResStr(IDS_MEDIAFORMATS_12)));
- ADDFMT((ResStr(IDS_AG_FLIC_FILE), _T("fli flc flic")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_14), _T("d2v")));
- ADDFMT((ResStr(IDS_AG_MPEG4_FILE), _T("mp4 m4v mp4v mpv4 hdmov 3gp 3gpp")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_16), _T("m4a m4b aac"), true, _T(""), QuickTime));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_17), _T("mkv")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_18), _T("mka"), true));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_19), _T("smk bik"), false, _T("smackw32/binkw32.dll in dll path")));
- ADDFMT((ResStr(IDS_AG_RATDVD_FILE), _T("ratdvd"), false, _T("ratdvd media file")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_21), _T("roq")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_0), _T("wmv wmp wm asf")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_1), _T("wma"), true));
+ ADDFMT((ResStr(IDS_AG_VIDEO_FILE), _T("avi")));
+ ADDFMT((ResStr(IDS_AG_AUDIO_FILE), _T("wav"), true));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_4), _T("mpg mpeg mpe m1v m2v mpv2 mp2v ts tp tpr pva m2ts m2t mts evo m2p")));
+ ADDFMT((_T("VCD file"), _T("dat")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_5), _T("mpa mp2 m1a m2a"), true));
+ ADDFMT((ResStr(IDS_AG_DVD_FILE), _T("vob ifo")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_7), _T("ac3 dts"), true));
+ ADDFMT((_T("MP3 Format Sound"), _T("mp3"), true));
+ ADDFMT((ResStr(IDS_AG_MIDI_FILE), _T("mid midi rmi"), true));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_9), _T("ivf")));
+ ADDFMT((_T("AIFF Format Sound"), _T("aif aifc aiff"), true));
+ ADDFMT((_T("AU Format Sound"), _T("au snd"), true));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_10), _T("ogm ogv")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_11), _T("ogg oga"), true));
+ ADDFMT((_T("CD Audio Track"), _T("cda"), true, ResStr(IDS_MEDIAFORMATS_12)));
+ ADDFMT((ResStr(IDS_AG_FLIC_FILE), _T("fli flc flic")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_14), _T("d2v")));
+ ADDFMT((ResStr(IDS_AG_MPEG4_FILE), _T("mp4 m4v mp4v mpv4 hdmov 3gp 3gpp")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_16), _T("m4a m4b aac"), true, _T(""), QuickTime));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_17), _T("mkv")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_18), _T("mka"), true));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_19), _T("smk bik"), false, _T("smackw32/binkw32.dll in dll path")));
+ ADDFMT((ResStr(IDS_AG_RATDVD_FILE), _T("ratdvd"), false, _T("ratdvd media file")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_21), _T("roq")));
#ifdef _WIN64
- ADDFMT((ResStr(IDS_MEDIAFORMATS_22), _T("rm ram rpm rmm")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_23), _T("ra"), true));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_24), _T("rt rp smi smil")));
-#else
- ADDFMT((ResStr(IDS_MEDIAFORMATS_22), _T("rm ram rpm rmm"), false, _T("RealPlayer or Real Alternative"), RealMedia));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_23), _T("ra"), true, _T("RealPlayer or Real Alternative"), RealMedia));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_24), _T("rt rp smi smil"), false, _T("RealPlayer or Real Alternative"), RealMedia));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_22), _T("rm ram rpm rmm")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_23), _T("ra"), true));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_24), _T("rt rp smi smil")));
+#else
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_22), _T("rm ram rpm rmm"), false, _T("RealPlayer or Real Alternative"), RealMedia));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_23), _T("ra"), true, _T("RealPlayer or Real Alternative"), RealMedia));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_24), _T("rt rp smi smil"), false, _T("RealPlayer or Real Alternative"), RealMedia));
#endif
- ADDFMT((ResStr(IDS_MEDIAFORMATS_25), _T("drc")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_26), _T("dsm dsv dsa dss")));
- ADDFMT((ResStr(IDS_AG_MUSEPACK_FILE), _T("mpc"), true));
- ADDFMT((_T("FLAC Audio file"), _T("flac"), true));
- ADDFMT((_T("WavPack Audio file"), _T("wv"), true));
- ADDFMT((_T("ALAC Audio file"), _T("alac"), true));
- ADDFMT((_T("OptimFrog Audio file"), _T("ofr ofs"), true));
- ADDFMT((_T("Monkey's Audio file"), _T("ape apl"), true));
- ADDFMT((_T("True Audio file"), _T("tta"), true));
- ADDFMT((_T("AMR Audio file"), _T("amr"), true));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_28), _T("flv iflv f4v")));
- ADDFMT((ResStr(IDS_MEDIAFORMATS_29), _T("swf"), false, _T("ShockWave ActiveX control"), ShockWave));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_25), _T("drc")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_26), _T("dsm dsv dsa dss")));
+ ADDFMT((ResStr(IDS_AG_MUSEPACK_FILE), _T("mpc"), true));
+ ADDFMT((_T("FLAC Audio file"), _T("flac"), true));
+ ADDFMT((_T("WavPack Audio file"), _T("wv"), true));
+ ADDFMT((_T("ALAC Audio file"), _T("alac"), true));
+ ADDFMT((_T("OptimFrog Audio file"), _T("ofr ofs"), true));
+ ADDFMT((_T("Monkey's Audio file"), _T("ape apl"), true));
+ ADDFMT((_T("True Audio file"), _T("tta"), true));
+ ADDFMT((_T("AMR Audio file"), _T("amr"), true));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_28), _T("flv iflv f4v")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_29), _T("swf"), false, _T("ShockWave ActiveX control"), ShockWave));
#ifdef _WIN64
- ADDFMT((ResStr(IDS_MEDIAFORMATS_30), _T("mov 3g2 3gp2")));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_30), _T("mov 3g2 3gp2")));
#else
- ADDFMT((ResStr(IDS_MEDIAFORMATS_30), _T("mov 3g2 3gp2"), false, _T("QuickTime (Alternative)"), QuickTime));
+ ADDFMT((ResStr(IDS_MEDIAFORMATS_30), _T("mov 3g2 3gp2"), false, _T("QuickTime (Alternative)"), QuickTime));
#endif
- ADDFMT((ResStr(IDS_AG_PLAYLIST_FILE), _T("asx m3u pls wvx wax wmx mpcpl")));
- ADDFMT((_T("Blu-ray playlist file"), _T("mpls bdmv")));
- ADDFMT((ResStr(IDS_AG_OTHER), _T("divx vp6 rmvb amv")));
+ ADDFMT((ResStr(IDS_AG_PLAYLIST_FILE), _T("asx m3u pls wvx wax wmx mpcpl")));
+ ADDFMT((_T("Blu-ray playlist file"), _T("mpls bdmv")));
+ ADDFMT((ResStr(IDS_AG_OTHER), _T("divx vp6 rmvb amv")));
#undef ADDFMT
- m_iRtspHandler = (engine_t)AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspHandler"), (int)RealMedia);
- m_fRtspFileExtFirst = !!AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), 1);
- }
+ m_iRtspHandler = (engine_t)AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspHandler"), (int)RealMedia);
+ m_fRtspFileExtFirst = !!AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), 1);
+ }
- for(int i = 0; i < GetCount(); i++)
- GetAt(i).UpdateData(fSave);
+ for(int i = 0; i < GetCount(); i++)
+ GetAt(i).UpdateData(fSave);
}
engine_t CMediaFormats::GetRtspHandler(bool& fRtspFileExtFirst)
{
- fRtspFileExtFirst = m_fRtspFileExtFirst;
- return m_iRtspHandler;
+ fRtspFileExtFirst = m_fRtspFileExtFirst;
+ return m_iRtspHandler;
}
void CMediaFormats::SetRtspHandler(engine_t e, bool fRtspFileExtFirst)
{
- m_iRtspHandler = e;
- m_fRtspFileExtFirst = fRtspFileExtFirst;
+ m_iRtspHandler = e;
+ m_fRtspFileExtFirst = fRtspFileExtFirst;
}
bool CMediaFormats::IsUsingEngine(CString path, engine_t e)
{
- return(GetEngine(path) == e);
+ return(GetEngine(path) == e);
}
engine_t CMediaFormats::GetEngine(CString path)
{
- path.Trim().MakeLower();
-
- if(!m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0)
- return m_iRtspHandler;
-
- CString ext = CPath(path).GetExtension();
- ext.MakeLower();
- if(!ext.IsEmpty())
- {
- if(path.Find(_T("rtsp://")) == 0)
- {
- if(ext == _T(".ram") || ext == _T(".rm") || ext == _T(".ra"))
- return RealMedia;
- if(ext == _T(".qt") || ext == _T(".mov"))
- return QuickTime;
- }
-
- for(int i = 0; i < GetCount(); i++)
- {
- CMediaFormatCategory& mfc = GetAt(i);
- if(mfc.FindExt(ext))
- return mfc.GetEngineType();
- }
- }
-
- if(m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0)
- return m_iRtspHandler;
-
- return DirectShow;
+ path.Trim().MakeLower();
+
+ if(!m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0)
+ return m_iRtspHandler;
+
+ CString ext = CPath(path).GetExtension();
+ ext.MakeLower();
+ if(!ext.IsEmpty())
+ {
+ if(path.Find(_T("rtsp://")) == 0)
+ {
+ if(ext == _T(".ram") || ext == _T(".rm") || ext == _T(".ra"))
+ return RealMedia;
+ if(ext == _T(".qt") || ext == _T(".mov"))
+ return QuickTime;
+ }
+
+ for(int i = 0; i < GetCount(); i++)
+ {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if(mfc.FindExt(ext))
+ return mfc.GetEngineType();
+ }
+ }
+
+ if(m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0)
+ return m_iRtspHandler;
+
+ return DirectShow;
}
bool CMediaFormats::FindExt(CString ext, bool fAudioOnly)
{
- ext.TrimLeft(_T("."));
-
- if(!ext.IsEmpty())
- {
- for(int i = 0; i < GetCount(); i++)
- {
- CMediaFormatCategory& mfc = GetAt(i);
- if((!fAudioOnly || mfc.IsAudioOnly()) && mfc.FindExt(ext))
- return(true);
- }
- }
-
- return(false);
+ ext.TrimLeft(_T("."));
+
+ if(!ext.IsEmpty())
+ {
+ for(int i = 0; i < GetCount(); i++)
+ {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if((!fAudioOnly || mfc.IsAudioOnly()) && mfc.FindExt(ext))
+ return(true);
+ }
+ }
+
+ return(false);
}
void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask)
{
- CString strTemp;
-
- filter += ResStr(IDS_MEDIAFORMATS_34);
- mask.Add(_T(""));
-
- for(int i = 0; i < GetCount(); i++)
- {
- strTemp = GetAt(i).GetFilter() + _T(";");
- mask[0] += strTemp;
- filter += strTemp;
- }
- mask[0].TrimRight(_T(";"));
- filter.TrimRight(_T(";"));
- filter += _T("|");
-
- for(int i = 0; i < GetCount(); i++)
- {
- CMediaFormatCategory& mfc = GetAt(i);
- filter += mfc.GetLabel() + _T("|" + GetAt(i).GetFilter() + _T("|"));
- mask.Add(mfc.GetFilter());
- }
-
- filter += ResStr(IDS_MEDIAFORMATS_35);
- mask.Add(_T("*.*"));
-
- filter += _T("|");
+ CString strTemp;
+
+ filter += ResStr(IDS_MEDIAFORMATS_34);
+ mask.Add(_T(""));
+
+ for(int i = 0; i < GetCount(); i++)
+ {
+ strTemp = GetAt(i).GetFilter() + _T(";");
+ mask[0] += strTemp;
+ filter += strTemp;
+ }
+ mask[0].TrimRight(_T(";"));
+ filter.TrimRight(_T(";"));
+ filter += _T("|");
+
+ for(int i = 0; i < GetCount(); i++)
+ {
+ CMediaFormatCategory& mfc = GetAt(i);
+ filter += mfc.GetLabel() + _T("|" + GetAt(i).GetFilter() + _T("|"));
+ mask.Add(mfc.GetFilter());
+ }
+
+ filter += ResStr(IDS_MEDIAFORMATS_35);
+ mask.Add(_T("*.*"));
+
+ filter += _T("|");
}
void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask)
{
- CString strTemp;
- filter += ResStr(IDS_MEDIAFORMATS_36);
- mask.Add(_T(""));
-
- for(int i = 0; i < GetCount(); i++)
- {
- CMediaFormatCategory& mfc = GetAt(i);
- if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
- strTemp = GetAt(i).GetFilter() + _T(";");
- mask[0] += strTemp;
- filter += strTemp;
- }
-
- mask[0].TrimRight(_T(";"));
- filter.TrimRight(_T(";"));
- filter += _T("|");
-
- for(int i = 0; i < GetCount(); i++)
- {
- CMediaFormatCategory& mfc = GetAt(i);
- if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
- filter += mfc.GetLabel() + _T("|") + GetAt(i).GetFilter() + _T("|");
- mask.Add(mfc.GetFilter());
- }
-
- filter += ResStr(IDS_MEDIAFORMATS_35);
- mask.Add(_T("*.*"));
-
- filter += _T("|");
+ CString strTemp;
+ filter += ResStr(IDS_MEDIAFORMATS_36);
+ mask.Add(_T(""));
+
+ for(int i = 0; i < GetCount(); i++)
+ {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
+ strTemp = GetAt(i).GetFilter() + _T(";");
+ mask[0] += strTemp;
+ filter += strTemp;
+ }
+
+ mask[0].TrimRight(_T(";"));
+ filter.TrimRight(_T(";"));
+ filter += _T("|");
+
+ for(int i = 0; i < GetCount(); i++)
+ {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
+ filter += mfc.GetLabel() + _T("|") + GetAt(i).GetFilter() + _T("|");
+ mask.Add(mfc.GetFilter());
+ }
+
+ filter += ResStr(IDS_MEDIAFORMATS_35);
+ mask.Add(_T("*.*"));
+
+ filter += _T("|");
}
diff --git a/src/apps/mplayerc/MediaFormats.h b/src/apps/mplayerc/MediaFormats.h
index 15a606827..d79b1db8d 100644
--- a/src/apps/mplayerc/MediaFormats.h
+++ b/src/apps/mplayerc/MediaFormats.h
@@ -30,81 +30,63 @@
class CMediaFormatCategory
{
protected:
- CString m_label, m_specreqnote;
- CAtlList<CString> m_exts, m_backupexts;
- bool m_fAudioOnly;
- engine_t m_engine;
+ CString m_label, m_specreqnote;
+ CAtlList<CString> m_exts, m_backupexts;
+ bool m_fAudioOnly;
+ engine_t m_engine;
public:
- CMediaFormatCategory();
- CMediaFormatCategory(
- CString label, CAtlList<CString>& exts, bool fAudioOnly = false,
- CString specreqnote = _T(""), engine_t e = DirectShow);
- CMediaFormatCategory(
- CString label, CString exts, bool fAudioOnly = false,
- CString specreqnote = _T(""), engine_t e = DirectShow);
- virtual ~CMediaFormatCategory();
-
- void UpdateData(bool fSave);
-
- CMediaFormatCategory(const CMediaFormatCategory& mfc);
- CMediaFormatCategory& operator = (const CMediaFormatCategory& mfc);
-
- void RestoreDefaultExts();
- void SetExts(CAtlList<CString>& exts);
- void SetExts(CString exts);
-
- bool FindExt(CString ext)
- {
- return m_exts.Find(ext.TrimLeft(_T(".")).MakeLower()) != NULL;
- }
-
- CString GetLabel() const
- {
- return m_label;
- }
- CString GetFilter();
- CString GetExts(bool fAppendEngine = false);
- CString GetExtsWithPeriod(bool fAppendEngine = false);
- CString GetBackupExtsWithPeriod(bool fAppendEngine = false);
- CString GetSpecReqNote() const
- {
- return m_specreqnote;
- }
- bool IsAudioOnly() const
- {
- return m_fAudioOnly;
- }
- engine_t GetEngineType() const
- {
- return m_engine;
- }
- void SetEngineType(engine_t e)
- {
- m_engine = e;
- }
+ CMediaFormatCategory();
+ CMediaFormatCategory(
+ CString label, CAtlList<CString>& exts, bool fAudioOnly = false,
+ CString specreqnote = _T(""), engine_t e = DirectShow);
+ CMediaFormatCategory(
+ CString label, CString exts, bool fAudioOnly = false,
+ CString specreqnote = _T(""), engine_t e = DirectShow);
+ virtual ~CMediaFormatCategory();
+
+ void UpdateData(bool fSave);
+
+ CMediaFormatCategory(const CMediaFormatCategory& mfc);
+ CMediaFormatCategory& operator = (const CMediaFormatCategory& mfc);
+
+ void RestoreDefaultExts();
+ void SetExts(CAtlList<CString>& exts);
+ void SetExts(CString exts);
+
+ bool FindExt(CString ext) {return m_exts.Find(ext.TrimLeft(_T(".")).MakeLower()) != NULL;}
+
+ CString GetLabel() const {return m_label;}
+ CString GetFilter();
+ CString GetExts(bool fAppendEngine = false);
+ CString GetExtsWithPeriod(bool fAppendEngine = false);
+ CString GetBackupExtsWithPeriod(bool fAppendEngine = false);
+ CString GetSpecReqNote() const {return m_specreqnote;}
+ bool IsAudioOnly() const {return m_fAudioOnly;}
+ engine_t GetEngineType() const {return m_engine;}
+ void SetEngineType(engine_t e) {m_engine = e;}
};
class CMediaFormats : public CAtlArray<CMediaFormatCategory>
{
protected:
- engine_t m_iRtspHandler;
- bool m_fRtspFileExtFirst;
+ engine_t m_iRtspHandler;
+ bool m_fRtspFileExtFirst;
public:
- CMediaFormats();
- virtual ~CMediaFormats();
+ CMediaFormats();
+ virtual ~CMediaFormats();
- void UpdateData(bool fSave);
+ void UpdateData(bool fSave);
- engine_t GetRtspHandler(bool& fRtspFileExtFirst);
- void SetRtspHandler(engine_t e, bool fRtspFileExtFirst);
+ engine_t GetRtspHandler(bool& fRtspFileExtFirst);
+ void SetRtspHandler(engine_t e, bool fRtspFileExtFirst);
- bool IsUsingEngine(CString path, engine_t e);
- engine_t GetEngine(CString path);
+ bool IsUsingEngine(CString path, engine_t e);
+ engine_t GetEngine(CString path);
- bool FindExt(CString ext, bool fAudioOnly = false);
+ bool FindExt(CString ext, bool fAudioOnly = false);
- void GetFilter(CString& filter, CAtlArray<CString>& mask);
- void GetAudioFilter(CString& filter, CAtlArray<CString>& mask);
+ void GetFilter(CString& filter, CAtlArray<CString>& mask);
+ void GetAudioFilter(CString& filter, CAtlArray<CString>& mask);
};
diff --git a/src/apps/mplayerc/MediaTypesDlg.cpp b/src/apps/mplayerc/MediaTypesDlg.cpp
index 209b8a498..b261bdde9 100644
--- a/src/apps/mplayerc/MediaTypesDlg.cpp
+++ b/src/apps/mplayerc/MediaTypesDlg.cpp
@@ -32,11 +32,11 @@
//IMPLEMENT_DYNAMIC(CMediaTypesDlg, CResizableDialog)
CMediaTypesDlg::CMediaTypesDlg(IGraphBuilderDeadEnd* pGBDE, CWnd* pParent /*=NULL*/)
- : CResizableDialog(CMediaTypesDlg::IDD, pParent)
- , m_pGBDE(pGBDE)
+ : CResizableDialog(CMediaTypesDlg::IDD, pParent)
+ , m_pGBDE(pGBDE)
{
- m_subtype = GUID_NULL;
- m_type = UNKNOWN;
+ m_subtype = GUID_NULL;
+ m_type = UNKNOWN;
}
CMediaTypesDlg::~CMediaTypesDlg()
@@ -45,34 +45,34 @@ CMediaTypesDlg::~CMediaTypesDlg()
void CMediaTypesDlg::DoDataExchange(CDataExchange* pDX)
{
- CResizableDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_pins);
- DDX_Control(pDX, IDC_EDIT1, m_report);
+ CResizableDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_pins);
+ DDX_Control(pDX, IDC_EDIT1, m_report);
}
void CMediaTypesDlg::AddLine(CString str)
{
- str.Replace(_T("\n"), _T("\r\n"));
- int len = m_report.GetWindowTextLength();
- m_report.SetSel(len, len, TRUE);
- m_report.ReplaceSel(str);
+ str.Replace(_T("\n"), _T("\r\n"));
+ int len = m_report.GetWindowTextLength();
+ m_report.SetSel(len, len, TRUE);
+ m_report.ReplaceSel(str);
}
void CMediaTypesDlg::AddMediaType(AM_MEDIA_TYPE* pmt)
{
- m_subtype = pmt->subtype;
- if(pmt->majortype == MEDIATYPE_Video) m_type = VIDEO;
- else if(pmt->majortype == MEDIATYPE_Audio) m_type = AUDIO;
- else m_type = UNKNOWN;
-
- CAtlList<CString> sl;
- CMediaTypeEx(*pmt).Dump(sl);
- POSITION pos = sl.GetHeadPosition();
- while(pos) AddLine(sl.GetNext(pos) + '\n');
+ m_subtype = pmt->subtype;
+ if(pmt->majortype == MEDIATYPE_Video) m_type = VIDEO;
+ else if(pmt->majortype == MEDIATYPE_Audio) m_type = AUDIO;
+ else m_type = UNKNOWN;
+
+ CAtlList<CString> sl;
+ CMediaTypeEx(*pmt).Dump(sl);
+ POSITION pos = sl.GetHeadPosition();
+ while(pos) AddLine(sl.GetNext(pos) + '\n');
}
BEGIN_MESSAGE_MAP(CMediaTypesDlg, CResizableDialog)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
END_MESSAGE_MAP()
@@ -80,62 +80,62 @@ END_MESSAGE_MAP()
BOOL CMediaTypesDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- CAtlList<CStringW> path;
- CAtlList<CMediaType> mts;
+ CAtlList<CStringW> path;
+ CAtlList<CMediaType> mts;
- for(int i = 0; S_OK == m_pGBDE->GetDeadEnd(i, path, mts); i++)
- {
- if(!path.GetCount()) continue;
- m_pins.SetItemData(m_pins.AddString(CString(path.GetTail())), (DWORD_PTR)i);
- }
+ for(int i = 0; S_OK == m_pGBDE->GetDeadEnd(i, path, mts); i++)
+ {
+ if(!path.GetCount()) continue;
+ m_pins.SetItemData(m_pins.AddString(CString(path.GetTail())), (DWORD_PTR)i);
+ }
- m_pins.SetCurSel(0);
- OnCbnSelchangeCombo1();
+ m_pins.SetCurSel(0);
+ OnCbnSelchangeCombo1();
- AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_STATIC2, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
+ AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_STATIC2, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
- SetMinTrackSize(CSize(300, 200));
+ SetMinTrackSize(CSize(300, 200));
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CMediaTypesDlg::OnCbnSelchangeCombo1()
{
- m_report.SetWindowText(_T(""));
-
- int i = m_pins.GetCurSel();
- if(i < 0) return;
-
- CAtlList<CStringW> path;
- CAtlList<CMediaType> mts;
-
- if(FAILED(m_pGBDE->GetDeadEnd(i, path, mts)) || !path.GetCount())
- return;
-
- POSITION pos = path.GetHeadPosition();
- while(pos)
- {
- AddLine(CString(path.GetNext(pos)) + _T("\n"));
- if(!pos) AddLine(_T("\n"));
- }
-
- pos = mts.GetHeadPosition();
- for(int j = 0; pos; j++)
- {
- CString str;
- str.Format(_T("Media Type %d:\n"), j);
- AddLine(str);
- AddLine(_T("--------------------------\n"));
- AddMediaType(&mts.GetNext(pos));
- AddLine();
- }
-
- m_report.SetSel(0, 0);
+ m_report.SetWindowText(_T(""));
+
+ int i = m_pins.GetCurSel();
+ if(i < 0) return;
+
+ CAtlList<CStringW> path;
+ CAtlList<CMediaType> mts;
+
+ if(FAILED(m_pGBDE->GetDeadEnd(i, path, mts)) || !path.GetCount())
+ return;
+
+ POSITION pos = path.GetHeadPosition();
+ while(pos)
+ {
+ AddLine(CString(path.GetNext(pos)) + _T("\n"));
+ if(!pos) AddLine(_T("\n"));
+ }
+
+ pos = mts.GetHeadPosition();
+ for(int j = 0; pos; j++)
+ {
+ CString str;
+ str.Format(_T("Media Type %d:\n"), j);
+ AddLine(str);
+ AddLine(_T("--------------------------\n"));
+ AddMediaType(&mts.GetNext(pos));
+ AddLine();
+ }
+
+ m_report.SetSel(0, 0);
}
diff --git a/src/apps/mplayerc/MediaTypesDlg.h b/src/apps/mplayerc/MediaTypesDlg.h
index 466154655..ea343b2ff 100644
--- a/src/apps/mplayerc/MediaTypesDlg.h
+++ b/src/apps/mplayerc/MediaTypesDlg.h
@@ -35,26 +35,26 @@ class CMediaTypesDlg : public CResizableDialog
// DECLARE_DYNAMIC(CMediaTypesDlg)
private:
- CComPtr<IGraphBuilderDeadEnd> m_pGBDE;
- enum {UNKNOWN, VIDEO, AUDIO} m_type;
- GUID m_subtype;
- void AddLine(CString str = _T("\n"));
- void AddMediaType(AM_MEDIA_TYPE* pmt);
+ CComPtr<IGraphBuilderDeadEnd> m_pGBDE;
+ enum {UNKNOWN, VIDEO, AUDIO} m_type;
+ GUID m_subtype;
+ void AddLine(CString str = _T("\n"));
+ void AddMediaType(AM_MEDIA_TYPE* pmt);
public:
- CMediaTypesDlg(IGraphBuilderDeadEnd* pGBDE, CWnd* pParent = NULL); // standard constructor
- virtual ~CMediaTypesDlg();
+ CMediaTypesDlg(IGraphBuilderDeadEnd* pGBDE, CWnd* pParent = NULL); // standard constructor
+ virtual ~CMediaTypesDlg();
// Dialog Data
- enum { IDD = IDD_MEDIATYPES_DLG };
- CComboBox m_pins;
- CEdit m_report;
+ enum { IDD = IDD_MEDIATYPES_DLG };
+ CComboBox m_pins;
+ CEdit m_report;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnCbnSelchangeCombo1();
+ afx_msg void OnCbnSelchangeCombo1();
};
diff --git a/src/apps/mplayerc/MiniDump.cpp b/src/apps/mplayerc/MiniDump.cpp
index f3ab75434..41272e9d3 100644
--- a/src/apps/mplayerc/MiniDump.cpp
+++ b/src/apps/mplayerc/MiniDump.cpp
@@ -32,136 +32,136 @@ CMiniDump _Singleton;
bool CMiniDump::m_bMiniDumpEnabled = false;
-typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
- CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
- CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
- CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
- );
+typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)( HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
+ CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
+ CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
+ CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
+ );
CMiniDump::CMiniDump()
{
#ifndef _DEBUG
- SetUnhandledExceptionFilter(UnhandledExceptionFilter);
+ SetUnhandledExceptionFilter( UnhandledExceptionFilter );
#ifndef _WIN64
- // Enable catching in CRT (http://blog.kalmbachnet.de/?postid=75)
+ // Enable catching in CRT (http://blog.kalmbachnet.de/?postid=75)
// PreventSetUnhandledExceptionFilter();
#endif
#endif
}
-LPTOP_LEVEL_EXCEPTION_FILTER WINAPI MyDummySetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
+LPTOP_LEVEL_EXCEPTION_FILTER WINAPI MyDummySetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter )
{
- return NULL;
+ return NULL;
}
BOOL CMiniDump::PreventSetUnhandledExceptionFilter()
{
- HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
- if(hKernel32 == NULL)
- return FALSE;
-
- void *pOrgEntry = GetProcAddress(hKernel32, "SetUnhandledExceptionFilter");
- if(pOrgEntry == NULL)
- return FALSE;
-
- unsigned char newJump[ 100 ];
- DWORD dwOrgEntryAddr = (DWORD) pOrgEntry;
- dwOrgEntryAddr += 5; // add 5 for 5 op-codes for jmp far
- void *pNewFunc = &MyDummySetUnhandledExceptionFilter;
- DWORD dwNewEntryAddr = (DWORD) pNewFunc;
- DWORD dwRelativeAddr = dwNewEntryAddr - dwOrgEntryAddr;
-
- newJump[ 0 ] = 0xE9; // JMP absolute
- memcpy(&newJump[ 1 ], &dwRelativeAddr, sizeof(pNewFunc));
- SIZE_T bytesWritten;
- BOOL bRet = WriteProcessMemory(GetCurrentProcess(), pOrgEntry, newJump, sizeof(pNewFunc) + 1, &bytesWritten);
- FreeLibrary(hKernel32);
- return bRet;
+ HMODULE hKernel32 = LoadLibrary( _T("kernel32.dll") );
+ if ( hKernel32 == NULL )
+ return FALSE;
+
+ void *pOrgEntry = GetProcAddress( hKernel32, "SetUnhandledExceptionFilter" );
+ if ( pOrgEntry == NULL )
+ return FALSE;
+
+ unsigned char newJump[ 100 ];
+ DWORD dwOrgEntryAddr = (DWORD) pOrgEntry;
+ dwOrgEntryAddr += 5; // add 5 for 5 op-codes for jmp far
+ void *pNewFunc = &MyDummySetUnhandledExceptionFilter;
+ DWORD dwNewEntryAddr = (DWORD) pNewFunc;
+ DWORD dwRelativeAddr = dwNewEntryAddr - dwOrgEntryAddr;
+
+ newJump[ 0 ] = 0xE9; // JMP absolute
+ memcpy( &newJump[ 1 ], &dwRelativeAddr, sizeof(pNewFunc) );
+ SIZE_T bytesWritten;
+ BOOL bRet = WriteProcessMemory( GetCurrentProcess(), pOrgEntry, newJump, sizeof(pNewFunc) + 1, &bytesWritten );
+ FreeLibrary( hKernel32 );
+ return bRet;
}
-LONG WINAPI CMiniDump::UnhandledExceptionFilter(_EXCEPTION_POINTERS *lpTopLevelExceptionFilter)
+LONG WINAPI CMiniDump::UnhandledExceptionFilter( _EXCEPTION_POINTERS *lpTopLevelExceptionFilter )
{
- LONG retval = EXCEPTION_CONTINUE_SEARCH;
- HWND hParent = NULL;
- HMODULE hDll = NULL;
- _TCHAR szResult[ 800 ];
- _TCHAR szDbgHelpPath[ _MAX_PATH ];
-
- if(!m_bMiniDumpEnabled)
- return 0;
-
- // firstly see if dbghelp.dll is around and has the function we need
- // look next to the EXE first, as the one in System32 might be old
- // (e.g. Windows 2000)
-
- if(GetModuleFileName(NULL, szDbgHelpPath, _MAX_PATH))
- {
- _TCHAR *pSlash = _tcsrchr(szDbgHelpPath, _T('\\'));
- if(pSlash != NULL)
- {
- _tcscpy_s(pSlash + 1, _MAX_PATH + szDbgHelpPath - pSlash, _T("DBGHELP.DLL"));
- hDll = ::LoadLibrary(szDbgHelpPath);
- }
- }
-
- if(hDll == NULL)
- {
- // load any version we can
- hDll = ::LoadLibrary(_T("DBGHELP.DLL"));
- }
-
- if(hDll != NULL)
- {
- MINIDUMPWRITEDUMP pMiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress(hDll, "MiniDumpWriteDump");
- if(pMiniDumpWriteDump != NULL)
- {
- _TCHAR szDumpPath[ _MAX_PATH ];
- _TCHAR szVersion[ 40 ];
-
- GetModuleFileName(NULL, szDumpPath, _MAX_PATH);
- _stprintf_s(szVersion, countof(szVersion), _T(".%d.%d.%d.%d"), VERSION_MAJOR, VERSION_MINOR, VERSION_REV, VERSION_PATCH);
- _tcscat_s(szDumpPath, _MAX_PATH, szVersion);
- _tcscat_s(szDumpPath, _MAX_PATH, _T(".dmp"));
-
- // create the file
- HANDLE hFile = ::CreateFile(szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL, NULL);
-
- if(hFile != INVALID_HANDLE_VALUE)
- {
- _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
-
- ExInfo.ThreadId = ::GetCurrentThreadId();
- ExInfo.ExceptionPointers = lpTopLevelExceptionFilter;
- ExInfo.ClientPointers = NULL;
-
- // write the dump
- BOOL bOK = pMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL);
- if(bOK)
- {
- _stprintf_s(szResult, countof(szResult), ResStr(IDS_MPC_CRASH), szDumpPath);
- retval = EXCEPTION_EXECUTE_HANDLER;
- }
- else
- {
- _stprintf_s(szResult, countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), szDumpPath, GetLastError());
- }
-
- ::CloseHandle(hFile);
- }
- else
- {
- _stprintf_s(szResult, countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), szDumpPath, GetLastError());
- }
- }
- FreeLibrary(hDll);
- }
-
- if(szResult)
- MessageBox(NULL, szResult, _T("MPC-HC Mini Dump"), MB_OK);
-
- return retval;
+ LONG retval = EXCEPTION_CONTINUE_SEARCH;
+ HWND hParent = NULL;
+ HMODULE hDll = NULL;
+ _TCHAR szResult[ 800 ];
+ _TCHAR szDbgHelpPath[ _MAX_PATH ];
+
+ if ( !m_bMiniDumpEnabled )
+ return 0;
+
+ // firstly see if dbghelp.dll is around and has the function we need
+ // look next to the EXE first, as the one in System32 might be old
+ // (e.g. Windows 2000)
+
+ if ( GetModuleFileName(NULL, szDbgHelpPath, _MAX_PATH) )
+ {
+ _TCHAR *pSlash = _tcsrchr( szDbgHelpPath, _T('\\') );
+ if ( pSlash != NULL )
+ {
+ _tcscpy_s( pSlash + 1, _MAX_PATH + szDbgHelpPath - pSlash, _T("DBGHELP.DLL") );
+ hDll = ::LoadLibrary( szDbgHelpPath );
+ }
+ }
+
+ if ( hDll == NULL )
+ {
+ // load any version we can
+ hDll = ::LoadLibrary( _T("DBGHELP.DLL") );
+ }
+
+ if ( hDll != NULL )
+ {
+ MINIDUMPWRITEDUMP pMiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
+ if ( pMiniDumpWriteDump != NULL )
+ {
+ _TCHAR szDumpPath[ _MAX_PATH ];
+ _TCHAR szVersion[ 40 ];
+
+ GetModuleFileName( NULL, szDumpPath, _MAX_PATH );
+ _stprintf_s( szVersion, countof(szVersion), _T(".%d.%d.%d.%d"), VERSION_MAJOR, VERSION_MINOR, VERSION_REV, VERSION_PATCH );
+ _tcscat_s( szDumpPath, _MAX_PATH, szVersion );
+ _tcscat_s( szDumpPath, _MAX_PATH, _T(".dmp") );
+
+ // create the file
+ HANDLE hFile = ::CreateFile( szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL );
+
+ if ( hFile != INVALID_HANDLE_VALUE )
+ {
+ _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
+
+ ExInfo.ThreadId = ::GetCurrentThreadId();
+ ExInfo.ExceptionPointers = lpTopLevelExceptionFilter;
+ ExInfo.ClientPointers = NULL;
+
+ // write the dump
+ BOOL bOK = pMiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL );
+ if ( bOK )
+ {
+ _stprintf_s( szResult, countof(szResult), ResStr(IDS_MPC_CRASH), szDumpPath );
+ retval = EXCEPTION_EXECUTE_HANDLER;
+ }
+ else
+ {
+ _stprintf_s( szResult, countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), szDumpPath, GetLastError() );
+ }
+
+ ::CloseHandle( hFile );
+ }
+ else
+ {
+ _stprintf_s( szResult, countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), szDumpPath, GetLastError() );
+ }
+ }
+ FreeLibrary( hDll );
+ }
+
+ if ( szResult )
+ MessageBox( NULL, szResult, _T("MPC-HC Mini Dump"), MB_OK );
+
+ return retval;
}
diff --git a/src/apps/mplayerc/MiniDump.h b/src/apps/mplayerc/MiniDump.h
index 87c142ce9..f1af5f1df 100644
--- a/src/apps/mplayerc/MiniDump.h
+++ b/src/apps/mplayerc/MiniDump.h
@@ -22,19 +22,18 @@
#pragma once
-class CMiniDump
-{
+class CMiniDump {
public:
- CMiniDump();
+ CMiniDump();
- static void Enable()
- {
- m_bMiniDumpEnabled = true;
- };
+ static void Enable()
+ {
+ m_bMiniDumpEnabled = true;
+ };
private :
- static LONG WINAPI UnhandledExceptionFilter(_EXCEPTION_POINTERS *lpTopLevelExceptionFilter);
- static BOOL PreventSetUnhandledExceptionFilter();
- static bool m_bMiniDumpEnabled;
+ static LONG WINAPI UnhandledExceptionFilter( _EXCEPTION_POINTERS *lpTopLevelExceptionFilter );
+ static BOOL PreventSetUnhandledExceptionFilter();
+ static bool m_bMiniDumpEnabled;
};
diff --git a/src/apps/mplayerc/Monitors.cpp b/src/apps/mplayerc/Monitors.cpp
index e06a0599d..0b9a31aa3 100644
--- a/src/apps/mplayerc/Monitors.cpp
+++ b/src/apps/mplayerc/Monitors.cpp
@@ -30,171 +30,171 @@
CMonitors::CMonitors()
{
- // WARNING : GetSystemMetrics(SM_CMONITORS) return only visible display monitors, and EnumDisplayMonitors
- // enumerate visible and pseudo invisible monitors !!!
+ // WARNING : GetSystemMetrics(SM_CMONITORS) return only visible display monitors, and EnumDisplayMonitors
+ // enumerate visible and pseudo invisible monitors !!!
// m_MonitorArray.SetSize( GetMonitorCount() );
- ADDMONITOR addMonitor;
- addMonitor.pMonitors = &m_MonitorArray;
- addMonitor.currentIndex = 0;
+ ADDMONITOR addMonitor;
+ addMonitor.pMonitors = &m_MonitorArray;
+ addMonitor.currentIndex = 0;
- ::EnumDisplayMonitors(NULL, NULL, AddMonitorsCallBack, (LPARAM)&addMonitor);
+ ::EnumDisplayMonitors( NULL, NULL, AddMonitorsCallBack, (LPARAM)&addMonitor );
}
CMonitors::~CMonitors()
{
- for(int i = 0; i < m_MonitorArray.GetSize(); i++)
- delete m_MonitorArray.GetAt(i);
+ for ( int i = 0; i < m_MonitorArray.GetSize(); i++ )
+ delete m_MonitorArray.GetAt( i );
}
// CMonitors member functions
-BOOL CALLBACK CMonitors::AddMonitorsCallBack(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
+BOOL CALLBACK CMonitors::AddMonitorsCallBack( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
{
- LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;
+ LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;
- CMonitor* pMonitor = DNew CMonitor;
- pMonitor->Attach(hMonitor);
+ CMonitor* pMonitor = DNew CMonitor;
+ pMonitor->Attach( hMonitor );
- pAddMonitor->pMonitors->Add(pMonitor);
- pAddMonitor->currentIndex++;
+ pAddMonitor->pMonitors->Add( pMonitor );
+ pAddMonitor->currentIndex++;
- return TRUE;
+ return TRUE;
}
//
// returns the primary monitor
CMonitor CMonitors::GetPrimaryMonitor()
{
- //the primary monitor always has its origin at 0,0
- HMONITOR hMonitor = ::MonitorFromPoint(CPoint(0, 0), MONITOR_DEFAULTTOPRIMARY);
- ASSERT(IsMonitor(hMonitor));
+ //the primary monitor always has its origin at 0,0
+ HMONITOR hMonitor = ::MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
+ ASSERT( IsMonitor( hMonitor ) );
- CMonitor monitor;
- monitor.Attach(hMonitor);
- ASSERT(monitor.IsPrimaryMonitor());
+ CMonitor monitor;
+ monitor.Attach( hMonitor );
+ ASSERT( monitor.IsPrimaryMonitor() );
- return monitor;
+ return monitor;
}
//
// is the given handle a valid monitor handle
-BOOL CMonitors::IsMonitor(const HMONITOR hMonitor)
+BOOL CMonitors::IsMonitor( const HMONITOR hMonitor )
{
- if(hMonitor == NULL)
- return FALSE;
+ if ( hMonitor == NULL )
+ return FALSE;
- MATCHMONITOR match;
- match.target = hMonitor;
- match.foundMatch = FALSE;
+ MATCHMONITOR match;
+ match.target = hMonitor;
+ match.foundMatch = FALSE;
- ::EnumDisplayMonitors(NULL, NULL, FindMatchingMonitorHandle, (LPARAM)&match);
+ ::EnumDisplayMonitors( NULL, NULL, FindMatchingMonitorHandle, (LPARAM)&match );
- return match.foundMatch;
+ return match.foundMatch;
}
//this is the callback method that gets called via IsMontior
-BOOL CALLBACK CMonitors::FindMatchingMonitorHandle(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
+BOOL CALLBACK CMonitors::FindMatchingMonitorHandle( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
{
- LPMATCHMONITOR pMatch = (LPMATCHMONITOR)dwData;
+ LPMATCHMONITOR pMatch = (LPMATCHMONITOR)dwData;
- if(hMonitor == pMatch->target)
- {
- //found a monitor with the same handle we are looking for
- pMatch->foundMatch = TRUE;
- return FALSE; //stop enumerating
- }
+ if ( hMonitor == pMatch->target )
+ {
+ //found a monitor with the same handle we are looking for
+ pMatch->foundMatch = TRUE;
+ return FALSE; //stop enumerating
+ }
- //haven't found a match yet
- pMatch->foundMatch = FALSE;
- return TRUE; //keep enumerating
+ //haven't found a match yet
+ pMatch->foundMatch = FALSE;
+ return TRUE; //keep enumerating
}
BOOL CMonitors::AllMonitorsShareDisplayFormat()
{
- return ::GetSystemMetrics(SM_SAMEDISPLAYFORMAT);
+ return ::GetSystemMetrics( SM_SAMEDISPLAYFORMAT );
}
//
// the number of monitors on the system
int CMonitors::GetMonitorCount()
-{
- return ::GetSystemMetrics(SM_CMONITORS);
+{
+ return ::GetSystemMetrics(SM_CMONITORS);
}
-CMonitor CMonitors::GetMonitor(const int index) const
+CMonitor CMonitors::GetMonitor( const int index ) const
{
#if _MFC_VER >= 0x0700
- ASSERT(index >= 0 && index < m_MonitorArray.GetCount());
+ ASSERT( index >= 0 && index < m_MonitorArray.GetCount() );
#else
- ASSERT(index >= 0 && index < m_MonitorArray.GetSize());
+ ASSERT( index >= 0 && index < m_MonitorArray.GetSize() );
#endif
- CMonitor* pMonitor = static_cast<CMonitor*>(m_MonitorArray.GetAt(index));
+ CMonitor* pMonitor = static_cast<CMonitor*>(m_MonitorArray.GetAt( index ));
- return *pMonitor;
+ return *pMonitor;
}
//
// returns the rectangle that is the union of all active monitors
-void CMonitors::GetVirtualDesktopRect(LPRECT lprc)
+void CMonitors::GetVirtualDesktopRect( LPRECT lprc )
{
- ::SetRect(lprc,
- ::GetSystemMetrics(SM_XVIRTUALSCREEN),
- ::GetSystemMetrics(SM_YVIRTUALSCREEN),
- ::GetSystemMetrics(SM_CXVIRTUALSCREEN),
- ::GetSystemMetrics(SM_CYVIRTUALSCREEN));
-
+ ::SetRect( lprc,
+ ::GetSystemMetrics( SM_XVIRTUALSCREEN ),
+ ::GetSystemMetrics( SM_YVIRTUALSCREEN ),
+ ::GetSystemMetrics( SM_CXVIRTUALSCREEN ),
+ ::GetSystemMetrics( SM_CYVIRTUALSCREEN ) );
+
}
//
// these methods determine wheter the given item is
// visible on any monitor
-BOOL CMonitors::IsOnScreen(const LPRECT lprc)
+BOOL CMonitors::IsOnScreen( const LPRECT lprc )
{
- return ::MonitorFromRect(lprc, MONITOR_DEFAULTTONULL) != NULL;
+ return ::MonitorFromRect( lprc, MONITOR_DEFAULTTONULL ) != NULL;
}
-BOOL CMonitors::IsOnScreen(const POINT pt)
+BOOL CMonitors::IsOnScreen( const POINT pt )
{
- return ::MonitorFromPoint(pt, MONITOR_DEFAULTTONULL) != NULL;
+ return ::MonitorFromPoint( pt, MONITOR_DEFAULTTONULL ) != NULL;
}
-BOOL CMonitors::IsOnScreen(const CWnd* pWnd)
+BOOL CMonitors::IsOnScreen( const CWnd* pWnd )
{
- return ::MonitorFromWindow(pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONULL) != NULL;
+ return ::MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONULL ) != NULL;
}
-CMonitor CMonitors::GetNearestMonitor(const LPRECT lprc)
+CMonitor CMonitors::GetNearestMonitor( const LPRECT lprc )
{
- CMonitor monitor;
- monitor.Attach(::MonitorFromRect(lprc, MONITOR_DEFAULTTONEAREST));
+ CMonitor monitor;
+ monitor.Attach( ::MonitorFromRect( lprc, MONITOR_DEFAULTTONEAREST ) );
- return monitor;
+ return monitor;
}
-CMonitor CMonitors::GetNearestMonitor(const POINT pt)
+CMonitor CMonitors::GetNearestMonitor( const POINT pt )
{
- CMonitor monitor;
- monitor.Attach(::MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST));
+ CMonitor monitor;
+ monitor.Attach( ::MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST ) );
- return monitor;
+ return monitor;
}
-CMonitor CMonitors::GetNearestMonitor(const CWnd* pWnd)
+CMonitor CMonitors::GetNearestMonitor( const CWnd* pWnd )
{
- ASSERT(pWnd);
- ASSERT(::IsWindow(pWnd->m_hWnd));
+ ASSERT( pWnd );
+ ASSERT( ::IsWindow( pWnd->m_hWnd ) );
- CMonitor monitor;
- monitor.Attach(::MonitorFromWindow(pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONEAREST));
+ CMonitor monitor;
+ monitor.Attach( ::MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONEAREST ) );
- return monitor;
+ return monitor;
}
diff --git a/src/apps/mplayerc/Monitors.h b/src/apps/mplayerc/Monitors.h
index 2fd0a046e..c86d217d7 100644
--- a/src/apps/mplayerc/Monitors.h
+++ b/src/apps/mplayerc/Monitors.h
@@ -31,71 +31,65 @@
class CMonitors : public CObject
{
public:
- CMonitors();
- virtual ~CMonitors();
+ CMonitors();
+ virtual ~CMonitors();
- CMonitor GetMonitor(const int index) const;
+ CMonitor GetMonitor( const int index ) const;
#if _MFC_VER >= 0x0700
- int GetCount() const
- {
- return (int)m_MonitorArray.GetCount();
- }
+ int GetCount() const { return (int)m_MonitorArray.GetCount(); }
#else
- int GetCount() const
- {
- return (int)m_MonitorArray.GetSize();
- }
+ int GetCount() const { return (int)m_MonitorArray.GetSize(); }
#endif
//static members
- static CMonitor GetNearestMonitor(const LPRECT lprc);
- static CMonitor GetNearestMonitor(const POINT pt);
- static CMonitor GetNearestMonitor(const CWnd* pWnd);
+ static CMonitor GetNearestMonitor( const LPRECT lprc );
+ static CMonitor GetNearestMonitor( const POINT pt );
+ static CMonitor GetNearestMonitor( const CWnd* pWnd );
- static BOOL IsOnScreen(const POINT pt);
- static BOOL IsOnScreen(const CWnd* pWnd);
- static BOOL IsOnScreen(const LPRECT lprc);
+ static BOOL IsOnScreen( const POINT pt );
+ static BOOL IsOnScreen( const CWnd* pWnd );
+ static BOOL IsOnScreen( const LPRECT lprc );
- static void GetVirtualDesktopRect(LPRECT lprc);
+ static void GetVirtualDesktopRect( LPRECT lprc );
- static BOOL IsMonitor(const HMONITOR hMonitor);
+ static BOOL IsMonitor( const HMONITOR hMonitor );
- static CMonitor GetPrimaryMonitor();
- static BOOL AllMonitorsShareDisplayFormat();
+ static CMonitor GetPrimaryMonitor();
+ static BOOL AllMonitorsShareDisplayFormat();
- static int GetMonitorCount();
+ static int GetMonitorCount();
private:
- CObArray m_MonitorArray;
-
- typedef struct tagMATCHMONITOR
- {
- HMONITOR target;
- BOOL foundMatch;
- } MATCHMONITOR, *LPMATCHMONITOR;
-
- static BOOL CALLBACK FindMatchingMonitorHandle(
- HMONITOR hMonitor, // handle to display monitor
- HDC hdcMonitor, // handle to monitor DC
- LPRECT lprcMonitor, // monitor intersection rectangle
- LPARAM dwData // data
- );
-
-
- typedef struct tagADDMONITOR
- {
- CObArray* pMonitors;
- int currentIndex;
- } ADDMONITOR, *LPADDMONITOR;
-
- static BOOL CALLBACK AddMonitorsCallBack(
- HMONITOR hMonitor, // handle to display monitor
- HDC hdcMonitor, // handle to monitor DC
- LPRECT lprcMonitor, // monitor intersection rectangle
- LPARAM dwData // data
- );
+ CObArray m_MonitorArray;
+
+ typedef struct tagMATCHMONITOR
+ {
+ HMONITOR target;
+ BOOL foundMatch;
+ } MATCHMONITOR, *LPMATCHMONITOR;
+
+ static BOOL CALLBACK FindMatchingMonitorHandle(
+ HMONITOR hMonitor, // handle to display monitor
+ HDC hdcMonitor, // handle to monitor DC
+ LPRECT lprcMonitor, // monitor intersection rectangle
+ LPARAM dwData // data
+ );
+
+
+ typedef struct tagADDMONITOR
+ {
+ CObArray* pMonitors;
+ int currentIndex;
+ } ADDMONITOR, *LPADDMONITOR;
+
+ static BOOL CALLBACK AddMonitorsCallBack(
+ HMONITOR hMonitor, // handle to display monitor
+ HDC hdcMonitor, // handle to monitor DC
+ LPRECT lprcMonitor, // monitor intersection rectangle
+ LPARAM dwData // data
+ );
};
diff --git a/src/apps/mplayerc/MpcApi.h b/src/apps/mplayerc/MpcApi.h
index 1e20e52b6..db5ef9c56 100644
--- a/src/apps/mplayerc/MpcApi.h
+++ b/src/apps/mplayerc/MpcApi.h
@@ -46,160 +46,160 @@
typedef enum MPC_LOADSTATE
{
- MLS_CLOSED,
- MLS_LOADING,
- MLS_LOADED,
- MLS_CLOSING
+ MLS_CLOSED,
+ MLS_LOADING,
+ MLS_LOADED,
+ MLS_CLOSING
};
typedef enum MPC_PLAYSTATE
{
- PS_PLAY = 0,
- PS_PAUSE = 1,
- PS_STOP = 2,
- PS_UNUSED = 3
+ PS_PLAY = 0,
+ PS_PAUSE = 1,
+ PS_STOP = 2,
+ PS_UNUSED = 3
};
typedef enum MPCAPI_COMMAND
{
- // ==== Commands from MPC to host
-
- // Send after connection
- // Par 1 : MPC window handle (command should be send to this HWnd)
- CMD_CONNECT = 0x50000000,
-
- // Send when opening or closing file
- // Par 1 : current state (see MPC_LOADSTATE enum)
- CMD_STATE = 0x50000001,
-
- // Send when playing, pausing or closing file
- // Par 1 : current play mode (see MPC_PLAYSTATE enum)
- CMD_PLAYMODE = 0x50000002,
-
- // Send after opening a new file
- // Par 1 : title
- // Par 2 : author
- // Par 3 : description
- // Par 4 : complete filename (path included)
- // Par 5 : duration in seconds
- CMD_NOWPLAYING = 0x50000003,
-
- // List of subtitle tracks
- // Par 1 : Subtitle track name 0
- // Par 2 : Subtitle track name 1
- // ...
- // Par n : Active subtitle track, -1 if subtitles disabled
- //
- // if no subtitle track present, returns -1
- // if no file loaded, returns -2
- CMD_LISTSUBTITLETRACKS = 0x50000004,
-
- // List of audio tracks
- // Par 1 : Audio track name 0
- // Par 2 : Audio track name 1
- // ...
- // Par n : Active audio track
- //
- // if no audio track present, returns -1
- // if no file loaded, returns -2
- CMD_LISTAUDIOTRACKS = 0x50000005,
+ // ==== Commands from MPC to host
+
+ // Send after connection
+ // Par 1 : MPC window handle (command should be send to this HWnd)
+ CMD_CONNECT = 0x50000000,
+
+ // Send when opening or closing file
+ // Par 1 : current state (see MPC_LOADSTATE enum)
+ CMD_STATE = 0x50000001,
+
+ // Send when playing, pausing or closing file
+ // Par 1 : current play mode (see MPC_PLAYSTATE enum)
+ CMD_PLAYMODE = 0x50000002,
+
+ // Send after opening a new file
+ // Par 1 : title
+ // Par 2 : author
+ // Par 3 : description
+ // Par 4 : complete filename (path included)
+ // Par 5 : duration in seconds
+ CMD_NOWPLAYING = 0x50000003,
+
+ // List of subtitle tracks
+ // Par 1 : Subtitle track name 0
+ // Par 2 : Subtitle track name 1
+ // ...
+ // Par n : Active subtitle track, -1 if subtitles disabled
+ //
+ // if no subtitle track present, returns -1
+ // if no file loaded, returns -2
+ CMD_LISTSUBTITLETRACKS = 0x50000004,
+
+ // List of audio tracks
+ // Par 1 : Audio track name 0
+ // Par 2 : Audio track name 1
+ // ...
+ // Par n : Active audio track
+ //
+ // if no audio track present, returns -1
+ // if no file loaded, returns -2
+ CMD_LISTAUDIOTRACKS = 0x50000005,
+
+ // List of files in the playlist
+ // Par 1 : file path 0
+ // Par 2 : file path 1
+ // ...
+ // Par n : active file, -1 if no active file
+ CMD_PLAYLIST = 0x50000006,
+
+
+ // ==== Commands from host to MPC
+
+ // Open new file
+ // Par 1 : file path
+ CMD_OPENFILE = 0xA0000000,
+
+ // Stop playback, but keep file / playlist
+ CMD_STOP = 0xA0000001,
+
+ // Stop playback and close file / playlist
+ CMD_CLOSEFILE = 0xA0000002,
+
+ // Pause or restart playback
+ CMD_PLAYPAUSE = 0xA0000003,
+
+ // Add a new file to playlist (did not start playing)
+ // Par 1 : file path
+ CMD_ADDTOPLAYLIST = 0xA0001000,
+
+ // Remove all files from playlist
+ CMD_CLEARPLAYLIST = 0xA0001001,
+
+ // Start playing playlist
+ CMD_STARTPLAYLIST = 0xA0001002,
+
+ CMD_REMOVEFROMPLAYLIST = 0xA0001003, // TODO
+
+ // Cue current file to specific position
+ // Par 1 : new position in seconds
+ CMD_SETPOSITION = 0xA0002000,
+
+ // Set the audio delay
+ // Par 1 : new audio delay in ms
+ CMD_SETAUDIODELAY = 0xA0002001,
+
+ // Set the subtitle delay
+ // Par 1 : new subtitle delay in ms
+ CMD_SETSUBTITLEDELAY = 0xA0002002,
+
+ // Set the active file in the playlist
+ // Par 1 : index of the active file, -1 for no file selected
+ // DOESN'T WORK
+ CMD_SETINDEXPLAYLIST = 0xA0002003,
+
+ // Set the audio track
+ // Par 1 : index of the audio track
+ CMD_SETAUDIOTRACK = 0xA0002004,
+
+ // Set the subtitle track
+ // Par 1 : index of the subtitle track, -1 for disabling subtitles
+ CMD_SETSUBTITLETRACK = 0xA0002005,
+
+ // Ask for a list of the subtitles tracks of the file
+ // return a CMD_LISTSUBTITLETRACKS
+ CMD_GETSUBTITLETRACKS = 0xA0003000,
+
+ // Ask for a list of the audio tracks of the file
+ // return a CMD_LISTAUDIOTRACKS
+ CMD_GETAUDIOTRACKS = 0xA0003001,
+
+ // Ask for the properties of the current loaded file
+ // return a CMD_NOWPLAYING
+ CMD_GETNOWPLAYING = 0xA0003002,
+
+ // Ask for the current playlist
+ // return a CMD_PLAYLIST
+ CMD_GETPLAYLIST = 0xA0003003,
+
+ // Toggle FullScreen
+ CMD_TOGGLEFULLSCREEN = 0xA0004000,
+
+ // Jump forward(medium)
+ CMD_JUMPFORWARDMED = 0xA0004001,
+
+ // Jump backward(medium)
+ CMD_JUMPBACKWARDMED = 0xA0004002,
+
+ // Increase Volume
+ CMD_INCREASEVOLUME = 0xA0004003,
- // List of files in the playlist
- // Par 1 : file path 0
- // Par 2 : file path 1
- // ...
- // Par n : active file, -1 if no active file
- CMD_PLAYLIST = 0x50000006,
+ // Decrease volume
+ CMD_DECREASEVOLUME = 0xA0004004,
+ // Shader toggle
+ CMD_SHADER_TOGGLE = 0xA0004005,
- // ==== Commands from host to MPC
-
- // Open new file
- // Par 1 : file path
- CMD_OPENFILE = 0xA0000000,
-
- // Stop playback, but keep file / playlist
- CMD_STOP = 0xA0000001,
-
- // Stop playback and close file / playlist
- CMD_CLOSEFILE = 0xA0000002,
-
- // Pause or restart playback
- CMD_PLAYPAUSE = 0xA0000003,
-
- // Add a new file to playlist (did not start playing)
- // Par 1 : file path
- CMD_ADDTOPLAYLIST = 0xA0001000,
-
- // Remove all files from playlist
- CMD_CLEARPLAYLIST = 0xA0001001,
-
- // Start playing playlist
- CMD_STARTPLAYLIST = 0xA0001002,
-
- CMD_REMOVEFROMPLAYLIST = 0xA0001003, // TODO
-
- // Cue current file to specific position
- // Par 1 : new position in seconds
- CMD_SETPOSITION = 0xA0002000,
-
- // Set the audio delay
- // Par 1 : new audio delay in ms
- CMD_SETAUDIODELAY = 0xA0002001,
-
- // Set the subtitle delay
- // Par 1 : new subtitle delay in ms
- CMD_SETSUBTITLEDELAY = 0xA0002002,
-
- // Set the active file in the playlist
- // Par 1 : index of the active file, -1 for no file selected
- // DOESN'T WORK
- CMD_SETINDEXPLAYLIST = 0xA0002003,
-
- // Set the audio track
- // Par 1 : index of the audio track
- CMD_SETAUDIOTRACK = 0xA0002004,
-
- // Set the subtitle track
- // Par 1 : index of the subtitle track, -1 for disabling subtitles
- CMD_SETSUBTITLETRACK = 0xA0002005,
-
- // Ask for a list of the subtitles tracks of the file
- // return a CMD_LISTSUBTITLETRACKS
- CMD_GETSUBTITLETRACKS = 0xA0003000,
-
- // Ask for a list of the audio tracks of the file
- // return a CMD_LISTAUDIOTRACKS
- CMD_GETAUDIOTRACKS = 0xA0003001,
-
- // Ask for the properties of the current loaded file
- // return a CMD_NOWPLAYING
- CMD_GETNOWPLAYING = 0xA0003002,
-
- // Ask for the current playlist
- // return a CMD_PLAYLIST
- CMD_GETPLAYLIST = 0xA0003003,
-
- // Toggle FullScreen
- CMD_TOGGLEFULLSCREEN = 0xA0004000,
-
- // Jump forward(medium)
- CMD_JUMPFORWARDMED = 0xA0004001,
-
- // Jump backward(medium)
- CMD_JUMPBACKWARDMED = 0xA0004002,
-
- // Increase Volume
- CMD_INCREASEVOLUME = 0xA0004003,
-
- // Decrease volume
- CMD_DECREASEVOLUME = 0xA0004004,
-
- // Shader toggle
- CMD_SHADER_TOGGLE = 0xA0004005,
-
- // Close App
- CMD_CLOSEAPP = 0xA0004006,
+ // Close App
+ CMD_CLOSEAPP = 0xA0004006,
};
diff --git a/src/apps/mplayerc/Mpeg2SectionData.cpp b/src/apps/mplayerc/Mpeg2SectionData.cpp
index e8db1bc4c..997b8769f 100644
--- a/src/apps/mplayerc/Mpeg2SectionData.cpp
+++ b/src/apps/mplayerc/Mpeg2SectionData.cpp
@@ -24,339 +24,338 @@
CMpeg2DataParser::CMpeg2DataParser(IBaseFilter* pFilter)
{
- m_pData = pFilter;
+ m_pData = pFilter;
- memset(&m_Filter, 0, sizeof(m_Filter));
- m_Filter.bVersionNumber = 1;
- m_Filter.wFilterSize = MPEG2_FILTER_VERSION_1_SIZE;
- m_Filter.fSpecifySectionNumber = TRUE;
+ memset(&m_Filter, 0, sizeof(m_Filter));
+ m_Filter.bVersionNumber = 1;
+ m_Filter.wFilterSize = MPEG2_FILTER_VERSION_1_SIZE;
+ m_Filter.fSpecifySectionNumber = TRUE;
}
-CString CMpeg2DataParser::ConvertString(BYTE* pBuffer, int nLength)
+CString CMpeg2DataParser::ConvertString (BYTE* pBuffer, int nLength)
{
- static const UINT16 codepages[0x20] =
- {
- 28591, // 00 - ISO 8859-1 Latin I
- 28595, // 01 - ISO 8859-5 Cyrillic
- 28596, // 02 - ISO 8859-6 Arabic
- 28597, // 03 - ISO 8859-7 Greek
- 28598, // 04 - ISO 8859-8 Hebrew
- 28599, // 05 - ISO 8859-9 Latin 5
- 28591, // 06 - ??? - ISO/IEC 8859-10 - Latin alphabet No. 6
- 28591, // 07 - ??? - ISO/IEC 8859-11 - Latin/Thai (draft only)
- 28591, // 08 - ??? - ISO/IEC 8859-12 - possibly reserved for Indian
- 28591, // 09 - ??? - ISO/IEC 8859-13 - Latin alphabet No. 7
- 28591, // 0a - ??? - ISO/IEC 8859-14 - Latin alphabet No. 8 (Celtic)
- 28605, // 0b - ISO 8859-15 Latin 9
- 28591, // 0c - réservé
- 28591, // 0d - réservé
- 28591, // 0e - réservé
- 28591, // 0f - réservé
-
- // TODO !
- 28591, 28591, 28591, 28591, 28591, 28591, 28591, 28591,
- 28591, 28591, 28591, 28591, 28591, 28591, 28591, 28591
- };
-
- UINT cp = CP_ACP;
- int nDestSize;
- CString strResult;
-
- if(nLength > 0 && pBuffer[0] < 0x20)
- {
- cp = codepages[pBuffer[0]];
- pBuffer++;
- nLength--;
- }
-
- nDestSize = MultiByteToWideChar(cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, NULL, 0);
- if(nDestSize < 0) return strResult;
-
- MultiByteToWideChar(cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, strResult.GetBuffer(nLength), nDestSize);
- strResult.ReleaseBuffer();
-
- return strResult;
+ static const UINT16 codepages[0x20] =
+ {
+ 28591, // 00 - ISO 8859-1 Latin I
+ 28595, // 01 - ISO 8859-5 Cyrillic
+ 28596, // 02 - ISO 8859-6 Arabic
+ 28597, // 03 - ISO 8859-7 Greek
+ 28598, // 04 - ISO 8859-8 Hebrew
+ 28599, // 05 - ISO 8859-9 Latin 5
+ 28591, // 06 - ??? - ISO/IEC 8859-10 - Latin alphabet No. 6
+ 28591, // 07 - ??? - ISO/IEC 8859-11 - Latin/Thai (draft only)
+ 28591, // 08 - ??? - ISO/IEC 8859-12 - possibly reserved for Indian
+ 28591, // 09 - ??? - ISO/IEC 8859-13 - Latin alphabet No. 7
+ 28591, // 0a - ??? - ISO/IEC 8859-14 - Latin alphabet No. 8 (Celtic)
+ 28605, // 0b - ISO 8859-15 Latin 9
+ 28591, // 0c - réservé
+ 28591, // 0d - réservé
+ 28591, // 0e - réservé
+ 28591, // 0f - réservé
+
+ // TODO !
+ 28591, 28591, 28591, 28591, 28591, 28591, 28591, 28591,
+ 28591, 28591, 28591, 28591, 28591, 28591, 28591, 28591
+ };
+
+ UINT cp = CP_ACP;
+ int nDestSize;
+ CString strResult;
+
+ if (nLength>0 && pBuffer[0]<0x20)
+ {
+ cp = codepages[pBuffer[0]];
+ pBuffer++; nLength--;
+ }
+
+ nDestSize = MultiByteToWideChar (cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, NULL, 0);
+ if(nDestSize < 0) return strResult;
+
+ MultiByteToWideChar (cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, strResult.GetBuffer(nLength), nDestSize);
+ strResult.ReleaseBuffer();
+
+ return strResult;
}
DVB_STREAM_TYPE CMpeg2DataParser::ConvertToDVBType(PES_STREAM_TYPE nType)
{
- switch(nType)
- {
- case VIDEO_STREAM_MPEG1 :
- case VIDEO_STREAM_MPEG2 :
- return DVB_MPV;
- case AUDIO_STREAM_MPEG1 :
- case AUDIO_STREAM_MPEG2 :
- return DVB_MPA;
- case VIDEO_STREAM_H264 :
- return DVB_H264;
- case AUDIO_STREAM_AC3 :
- return DVB_AC3;
- case AUDIO_STREAM_AC3_PLUS :
- return DVB_EAC3;
- case SUBTITLE_STREAM :
- return DVB_SUBTITLE;
- }
-
- return DVB_UNKNOWN;
+ switch (nType)
+ {
+ case VIDEO_STREAM_MPEG1 :
+ case VIDEO_STREAM_MPEG2 :
+ return DVB_MPV;
+ case AUDIO_STREAM_MPEG1 :
+ case AUDIO_STREAM_MPEG2 :
+ return DVB_MPA;
+ case VIDEO_STREAM_H264 :
+ return DVB_H264;
+ case AUDIO_STREAM_AC3 :
+ return DVB_AC3;
+ case AUDIO_STREAM_AC3_PLUS :
+ return DVB_EAC3;
+ case SUBTITLE_STREAM :
+ return DVB_SUBTITLE;
+ }
+
+ return DVB_UNKNOWN;
}
HRESULT CMpeg2DataParser::ParseSIHeader(CGolombBuffer& gb, DVB_SI SIType, WORD& wSectionLength, WORD& wTSID)
{
- if(gb.BitRead(8) != SIType) return ERROR_INVALID_DATA; // table_id
- gb.BitRead(1); // section_syntax_indicator
- gb.BitRead(1); // reserved_future_use
- gb.BitRead(2); // reserved
- wSectionLength = gb.BitRead(12); // section_length
- wTSID = gb.BitRead(16); // transport_stream_id
- gb.BitRead(2); // reserved
- gb.BitRead(5); // version_number
- gb.BitRead(1); // current_next_indicator
- gb.BitRead(8); // section_number
- gb.BitRead(8); // last_section_number
-
- return S_OK;
+ if (gb.BitRead(8) != SIType) return ERROR_INVALID_DATA; // table_id
+ gb.BitRead(1); // section_syntax_indicator
+ gb.BitRead(1); // reserved_future_use
+ gb.BitRead(2); // reserved
+ wSectionLength = gb.BitRead(12); // section_length
+ wTSID = gb.BitRead(16); // transport_stream_id
+ gb.BitRead(2); // reserved
+ gb.BitRead(5); // version_number
+ gb.BitRead(1); // current_next_indicator
+ gb.BitRead(8); // section_number
+ gb.BitRead(8); // last_section_number
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParseSDT(ULONG ulFreq)
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wONID;
- WORD wSectionLength;
-
- CheckNoLog(m_pData->GetSection(PID_SDT, SI_SDT, &m_Filter, 5000, &pSectionList));
- CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
-
- CGolombBuffer gb((BYTE*)data, dwLength);
-
- // service_description_section()
- CheckNoLog(ParseSIHeader(gb, SI_SDT, wSectionLength, wTSID));
-
- wONID = gb.BitRead(16); // original_network_id
- gb.BitRead(8); // reserved_future_use
-
- while(gb.GetSize() - gb.GetPos() > 4)
- {
- CDVBChannel Channel;
- Channel.SetFrequency(ulFreq);
- Channel.SetTSID(wTSID);
- Channel.SetONID(wONID);
- Channel.SetSID(gb.BitRead(16)); // service_id uimsbf
- gb.BitRead(6); // reserved_future_use bslbf
- gb.BitRead(1); // EIT_schedule_flag bslbf
- gb.BitRead(1); // EIT_present_following_flag bslbf
- gb.BitRead(3); // running_status uimsbf
- gb.BitRead(1); // free_CA_mode bslbf
-
- BeginEnumDescriptors(gb, nType, nLength)
- {
- switch(nType)
- {
- case DT_SERVICE :
- gb.BitRead(8); // service_type
- nLength = gb.BitRead(8); // service_provider_name_length
- gb.ReadBuffer(DescBuffer, nLength); // service_provider_name
-
- nLength = gb.BitRead(8); // service_name_length
- gb.ReadBuffer(DescBuffer, nLength); // service_name
- DescBuffer[nLength] = 0;
- Channel.SetName(ConvertString(DescBuffer, nLength));
- TRACE("%15S %d\n", Channel.GetName(), Channel.GetSID());
- break;
- default :
- SkipDescriptor(gb, nType, nLength); // descriptor()
- break;
- }
- }
- EndEnumDescriptors
-
-
- if(!Channels.Lookup(Channel.GetSID()))
- Channels [Channel.GetSID()] = Channel;
- }
-
- return S_OK;
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wONID;
+ WORD wSectionLength;
+
+ CheckNoLog (m_pData->GetSection (PID_SDT, SI_SDT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
+
+ CGolombBuffer gb ((BYTE*)data, dwLength);
+
+ // service_description_section()
+ CheckNoLog (ParseSIHeader (gb, SI_SDT, wSectionLength, wTSID));
+
+ wONID = gb.BitRead(16); // original_network_id
+ gb.BitRead(8); // reserved_future_use
+
+ while (gb.GetSize() - gb.GetPos() > 4)
+ {
+ CDVBChannel Channel;
+ Channel.SetFrequency (ulFreq);
+ Channel.SetTSID (wTSID);
+ Channel.SetONID (wONID);
+ Channel.SetSID (gb.BitRead(16)); // service_id uimsbf
+ gb.BitRead(6); // reserved_future_use bslbf
+ gb.BitRead(1); // EIT_schedule_flag bslbf
+ gb.BitRead(1); // EIT_present_following_flag bslbf
+ gb.BitRead(3); // running_status uimsbf
+ gb.BitRead(1); // free_CA_mode bslbf
+
+ BeginEnumDescriptors(gb, nType, nLength)
+ {
+ switch (nType)
+ {
+ case DT_SERVICE :
+ gb.BitRead(8); // service_type
+ nLength = gb.BitRead(8); // service_provider_name_length
+ gb.ReadBuffer (DescBuffer, nLength); // service_provider_name
+
+ nLength = gb.BitRead(8); // service_name_length
+ gb.ReadBuffer (DescBuffer, nLength); // service_name
+ DescBuffer[nLength] = 0;
+ Channel.SetName (ConvertString (DescBuffer, nLength));
+ TRACE ("%15S %d\n", Channel.GetName(), Channel.GetSID());
+ break;
+ default :
+ SkipDescriptor (gb, nType, nLength); // descriptor()
+ break;
+ }
+ }
+ EndEnumDescriptors
+
+
+ if (!Channels.Lookup(Channel.GetSID()))
+ Channels [Channel.GetSID()] = Channel;
+ }
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParsePAT()
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wSectionLength;
-
- CheckNoLog(m_pData->GetSection(PID_PAT, SI_PAT, &m_Filter, 5000, &pSectionList));
- CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
-
- CGolombBuffer gb((BYTE*)data, dwLength);
-
- // program_association_section()
- CheckNoLog(ParseSIHeader(gb, SI_PAT, wSectionLength, wTSID));
- while(gb.GetSize() - gb.GetPos() > 4)
- {
- WORD program_number;
- WORD program_map_PID = 0;
-
- program_number = gb.BitRead(16); // program_number
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wSectionLength;
+
+ CheckNoLog (m_pData->GetSection (PID_PAT, SI_PAT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
+
+ CGolombBuffer gb ((BYTE*)data, dwLength);
+
+ // program_association_section()
+ CheckNoLog (ParseSIHeader (gb, SI_PAT, wSectionLength, wTSID));
+ while (gb.GetSize() - gb.GetPos() > 4)
+ {
+ WORD program_number;
+ WORD program_map_PID = 0;
+
+ program_number = gb.BitRead(16); // program_number
gb.BitRead(3); // reserved
- if(program_number == 0)
- gb.BitRead(13); // network_PID
- else
- {
- program_map_PID = gb.BitRead(13); // program_map_PID
- if(Channels.Lookup(program_number))
- {
- Channels [program_number].SetPMT(program_map_PID);
- ParsePMT(Channels [program_number]);
- }
- }
- }
-
- return S_OK;
+ if (program_number==0)
+ gb.BitRead(13); // network_PID
+ else
+ {
+ program_map_PID = gb.BitRead(13); // program_map_PID
+ if (Channels.Lookup(program_number))
+ {
+ Channels [program_number].SetPMT (program_map_PID);
+ ParsePMT (Channels [program_number]);
+ }
+ }
+ }
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParsePMT(CDVBChannel& Channel)
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wSectionLength;
- int nLimit;
-
- CheckNoLog(m_pData->GetSection(Channel.GetPMT(), SI_PMT, &m_Filter, 5000, &pSectionList));
- CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
-
- CGolombBuffer gb((BYTE*)data, dwLength);
-
- // TS_program_map_section()
- CheckNoLog(ParseSIHeader(gb, SI_PMT, wSectionLength, wTSID));
-
- gb.BitRead(3); // reserved
- Channel.SetPCR(gb.BitRead(13)); // PCR_PID
- gb.BitRead(4); // reserved
- BeginEnumDescriptors(gb, nType, nLength) // for (i=0;i<N;i++) {
- {
- SkipDescriptor(gb, nType, nLength); // descriptor()
- }
- EndEnumDescriptors
-
-
- while(gb.GetSize() - gb.GetPos() > 4)
- {
- PES_STREAM_TYPE pes_stream_type;
- DVB_STREAM_TYPE dvb_stream_type;
- WORD wPID;
- CString strLanguage;
-
- pes_stream_type = (PES_STREAM_TYPE)gb.BitRead(8); // stream_type
- gb.BitRead(3); // reserved
- wPID = gb.BitRead(13); // elementary_PID
- gb.BitRead(4); // reserved
-
- BeginEnumDescriptors(gb, nType, nLength) // ES_info_length
- {
- switch(nType)
- {
- case DT_ISO_639_LANGUAGE :
- gb.ReadBuffer(DescBuffer, nLength);
- strLanguage = ConvertString(DescBuffer, 3);
- break;
- case DT_AC3_AUDIO :
- pes_stream_type = AUDIO_STREAM_AC3;
- SkipDescriptor(gb, nType, nLength);
- break;
- case DT_EXTENDED_AC3_AUDIO :
- pes_stream_type = AUDIO_STREAM_AC3_PLUS;
- SkipDescriptor(gb, nType, nLength);
- break;
- case DT_SUBTITLING :
- {
- gb.ReadBuffer(DescBuffer, nLength);
- strLanguage = ConvertString(DescBuffer, 3);
- pes_stream_type = SUBTITLE_STREAM;
- }
- break;
- default :
- SkipDescriptor(gb, nType, nLength);
- break;
- }
- }
- EndEnumDescriptors
- if((dvb_stream_type = ConvertToDVBType(pes_stream_type)) != DVB_UNKNOWN)
- Channel.AddStreamInfo(wPID, dvb_stream_type, pes_stream_type, strLanguage);
- }
-
- return S_OK;
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wSectionLength;
+ int nLimit;
+
+ CheckNoLog (m_pData->GetSection (Channel.GetPMT(), SI_PMT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
+
+ CGolombBuffer gb ((BYTE*)data, dwLength);
+
+ // TS_program_map_section()
+ CheckNoLog (ParseSIHeader (gb, SI_PMT, wSectionLength, wTSID));
+
+ gb.BitRead(3); // reserved
+ Channel.SetPCR (gb.BitRead(13)); // PCR_PID
+ gb.BitRead(4); // reserved
+ BeginEnumDescriptors(gb, nType, nLength) // for (i=0;i<N;i++) {
+ {
+ SkipDescriptor (gb, nType, nLength); // descriptor()
+ }
+ EndEnumDescriptors
+
+
+ while (gb.GetSize() - gb.GetPos() > 4)
+ {
+ PES_STREAM_TYPE pes_stream_type;
+ DVB_STREAM_TYPE dvb_stream_type;
+ WORD wPID;
+ CString strLanguage;
+
+ pes_stream_type = (PES_STREAM_TYPE)gb.BitRead(8); // stream_type
+ gb.BitRead(3); // reserved
+ wPID = gb.BitRead(13); // elementary_PID
+ gb.BitRead(4); // reserved
+
+ BeginEnumDescriptors(gb, nType, nLength) // ES_info_length
+ {
+ switch (nType)
+ {
+ case DT_ISO_639_LANGUAGE :
+ gb.ReadBuffer(DescBuffer, nLength);
+ strLanguage = ConvertString (DescBuffer, 3);
+ break;
+ case DT_AC3_AUDIO :
+ pes_stream_type = AUDIO_STREAM_AC3;
+ SkipDescriptor (gb, nType, nLength);
+ break;
+ case DT_EXTENDED_AC3_AUDIO :
+ pes_stream_type = AUDIO_STREAM_AC3_PLUS;
+ SkipDescriptor (gb, nType, nLength);
+ break;
+ case DT_SUBTITLING :
+ {
+ gb.ReadBuffer(DescBuffer, nLength);
+ strLanguage = ConvertString (DescBuffer, 3);
+ pes_stream_type = SUBTITLE_STREAM;
+ }
+ break;
+ default :
+ SkipDescriptor (gb, nType, nLength);
+ break;
+ }
+ }
+ EndEnumDescriptors
+ if ((dvb_stream_type = ConvertToDVBType(pes_stream_type)) != DVB_UNKNOWN)
+ Channel.AddStreamInfo (wPID, dvb_stream_type, pes_stream_type, strLanguage);
+ }
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParseNIT()
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wSectionLength;
- WORD transport_stream_loop_length;
-
- CheckNoLog(m_pData->GetSection(PID_NIT, SI_NIT, &m_Filter, 5000, &pSectionList));
- CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
-
- CGolombBuffer gb((BYTE*)data, dwLength);
-
- // network_information_section()
- CheckNoLog(ParseSIHeader(gb, SI_NIT, wSectionLength, wTSID));
-
- gb.BitRead(4); // reserved_future_use
- BeginEnumDescriptors(gb, nType, nLength) // for (i=0;i<N;i++) {
- {
- SkipDescriptor(gb, nType, nLength); // descriptor()
- }
- EndEnumDescriptors
-
- gb.BitRead(4); // reserved_future_use
- transport_stream_loop_length = gb.BitRead(12); // network_descriptors_length
- while(gb.GetSize() - gb.GetPos() > 4)
- {
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wSectionLength;
+ WORD transport_stream_loop_length;
+
+ CheckNoLog (m_pData->GetSection (PID_NIT, SI_NIT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
+
+ CGolombBuffer gb ((BYTE*)data, dwLength);
+
+ // network_information_section()
+ CheckNoLog (ParseSIHeader (gb, SI_NIT, wSectionLength, wTSID));
+
+ gb.BitRead(4); // reserved_future_use
+ BeginEnumDescriptors(gb, nType, nLength) // for (i=0;i<N;i++) {
+ {
+ SkipDescriptor (gb, nType, nLength); // descriptor()
+ }
+ EndEnumDescriptors
+
+ gb.BitRead(4); // reserved_future_use
+ transport_stream_loop_length = gb.BitRead(12); // network_descriptors_length
+ while (gb.GetSize() - gb.GetPos() > 4)
+ {
WORD transport_stream_id = gb.BitRead(16); // transport_stream_id
WORD original_network_id = gb.BitRead(16); // original_network_id
gb.BitRead(4); // reserved_future_use
- BeginEnumDescriptors(gb, nType, nLength)
- {
- switch(nType)
- {
- case DT_LOGICAL_CHANNEL :
- for(int i = 0; i < nLength / 4; i++)
- {
- WORD service_id = gb.BitRead(16);
- gb.BitRead(6);
- WORD logical_channel_number = gb.BitRead(10);
- if(Channels.Lookup(service_id))
- {
- Channels[service_id].SetOriginNumber(logical_channel_number);
- TRACE("NIT association : %d -> %S\n", logical_channel_number, Channels[service_id].ToString());
- }
- }
- break;
- default :
- SkipDescriptor(gb, nType, nLength);
- break;
- }
- }
- EndEnumDescriptors
- }
-
- return S_OK;
+ BeginEnumDescriptors (gb, nType, nLength)
+ {
+ switch (nType)
+ {
+ case DT_LOGICAL_CHANNEL :
+ for (int i=0; i<nLength/4; i++)
+ {
+ WORD service_id = gb.BitRead (16);
+ gb.BitRead(6);
+ WORD logical_channel_number = gb.BitRead(10);
+ if (Channels.Lookup(service_id))
+ {
+ Channels[service_id].SetOriginNumber (logical_channel_number);
+ TRACE ("NIT association : %d -> %S\n", logical_channel_number, Channels[service_id].ToString());
+ }
+ }
+ break;
+ default :
+ SkipDescriptor (gb, nType, nLength);
+ break;
+ }
+ }
+ EndEnumDescriptors
+ }
+
+ return S_OK;
} \ No newline at end of file
diff --git a/src/apps/mplayerc/Mpeg2SectionData.h b/src/apps/mplayerc/Mpeg2SectionData.h
index 59a3e3d19..4eb9cfa2e 100644
--- a/src/apps/mplayerc/Mpeg2SectionData.h
+++ b/src/apps/mplayerc/Mpeg2SectionData.h
@@ -6,16 +6,16 @@
#pragma pack(1)
typedef struct
{
- UINT8 TableID;
- WORD SectionSyntaxIndicator : 1;
- WORD Reserved1 : 3;
- WORD SectionLength : 12;
- WORD BouquetID;
- UINT8 Reserved2 : 1;
- UINT8 VersionNumber : 5;
- UINT8 CurrentNextIndicator : 1;
- UINT8 SectionNumber;
- UINT8 LastSectionNumber;
+ UINT8 TableID;
+ WORD SectionSyntaxIndicator : 1;
+ WORD Reserved1 : 3;
+ WORD SectionLength : 12;
+ WORD BouquetID;
+ UINT8 Reserved2 : 1;
+ UINT8 VersionNumber : 5;
+ UINT8 CurrentNextIndicator : 1;
+ UINT8 SectionNumber;
+ UINT8 LastSectionNumber;
} SI_HEADER;
@@ -24,23 +24,23 @@ class CMpeg2DataParser
{
public :
- CMpeg2DataParser(IBaseFilter* pFilter);
+ CMpeg2DataParser(IBaseFilter* pFilter);
- HRESULT ParseSDT(ULONG ulFreq);
- HRESULT ParsePAT();
- HRESULT ParseNIT();
+ HRESULT ParseSDT(ULONG ulFreq);
+ HRESULT ParsePAT();
+ HRESULT ParseNIT();
- static CString ConvertString(BYTE* pBuffer, int nLength);
+ static CString ConvertString (BYTE* pBuffer, int nLength);
- CAtlMap<int, CDVBChannel> Channels;
+ CAtlMap<int,CDVBChannel> Channels;
private :
- CComQIPtr<IMpeg2Data> m_pData;
- MPEG2_FILTER m_Filter;
+ CComQIPtr<IMpeg2Data> m_pData;
+ MPEG2_FILTER m_Filter;
- DVB_STREAM_TYPE ConvertToDVBType(PES_STREAM_TYPE nType);
- HRESULT ParseSIHeader(CGolombBuffer& gb, DVB_SI SIType, WORD& wSectionLength, WORD& wTSID);
- HRESULT ParsePMT(CDVBChannel& Channel);
+ DVB_STREAM_TYPE ConvertToDVBType(PES_STREAM_TYPE nType);
+ HRESULT ParseSIHeader(CGolombBuffer& gb, DVB_SI SIType, WORD& wSectionLength, WORD& wTSID);
+ HRESULT ParsePMT(CDVBChannel& Channel);
};
diff --git a/src/apps/mplayerc/MultiMonitor.cpp b/src/apps/mplayerc/MultiMonitor.cpp
index 5c27f5cf2..0196019b1 100644
--- a/src/apps/mplayerc/MultiMonitor.cpp
+++ b/src/apps/mplayerc/MultiMonitor.cpp
@@ -29,15 +29,15 @@
// CMonitor
// constucts a monitor class not attached to any handle
-CMonitor::CMonitor() : m_hMonitor(NULL)
-{
+CMonitor::CMonitor() : m_hMonitor( NULL )
+{
}
// copy constructor
-CMonitor::CMonitor(const CMonitor& monitor)
+CMonitor::CMonitor( const CMonitor& monitor )
{
- m_hMonitor = (HMONITOR)monitor;
+ m_hMonitor = (HMONITOR)monitor;
}
CMonitor::~CMonitor()
@@ -46,18 +46,18 @@ CMonitor::~CMonitor()
-void CMonitor::Attach(const HMONITOR hMonitor)
+void CMonitor::Attach( const HMONITOR hMonitor )
{
- ASSERT(CMonitors::IsMonitor(hMonitor));
+ ASSERT( CMonitors::IsMonitor( hMonitor ) );
- m_hMonitor = hMonitor;
+ m_hMonitor = hMonitor;
}
-HMONITOR CMonitor::Detach()
+HMONITOR CMonitor::Detach()
{
- HMONITOR hMonitor = m_hMonitor;
- m_hMonitor = NULL;
- return hMonitor;
+ HMONITOR hMonitor = m_hMonitor;
+ m_hMonitor = NULL;
+ return hMonitor;
}
// creates an HDC for the monitor
@@ -70,150 +70,150 @@ HMONITOR CMonitor::Detach()
// Only very exacting applications would need a DC for each monitor
HDC CMonitor::CreateDC() const
{
- ASSERT(IsMonitor());
+ ASSERT( IsMonitor() );
- CString name;
- GetName(name);
+ CString name;
+ GetName( name );
- //create a dc for this display
- HDC hdc = ::CreateDC(name, name, NULL, NULL);
- ASSERT(hdc != NULL);
+ //create a dc for this display
+ HDC hdc = ::CreateDC( name, name, NULL, NULL );
+ ASSERT( hdc != NULL );
- //set the viewport based on the monitor rect's relation to the primary monitor
- CRect rect;
- GetMonitorRect(&rect);
+ //set the viewport based on the monitor rect's relation to the primary monitor
+ CRect rect;
+ GetMonitorRect( &rect );
- ::SetViewportOrgEx(hdc, -rect.left, -rect.top, NULL);
- ::SetViewportExtEx(hdc, rect.Width(), rect.Height(), NULL);
+ ::SetViewportOrgEx( hdc, -rect.left, -rect.top, NULL );
+ ::SetViewportExtEx( hdc, rect.Width(), rect.Height(), NULL );
- return hdc;
+ return hdc;
}
int CMonitor::GetBitsPerPixel() const
{
- HDC hdc = CreateDC();
- int ret = ::GetDeviceCaps(hdc, BITSPIXEL) * ::GetDeviceCaps(hdc, PLANES);
- VERIFY(::DeleteDC(hdc));
+ HDC hdc = CreateDC();
+ int ret = ::GetDeviceCaps( hdc, BITSPIXEL ) * ::GetDeviceCaps( hdc, PLANES );
+ VERIFY( ::DeleteDC( hdc ) );
- return ret;
+ return ret;
}
-void CMonitor::GetName(CString& string) const
+void CMonitor::GetName( CString& string ) const
{
- ASSERT(IsMonitor());
+ ASSERT( IsMonitor() );
- MONITORINFOEX mi;
- mi.cbSize = sizeof(mi);
- ::GetMonitorInfo(m_hMonitor, &mi);
+ MONITORINFOEX mi;
+ mi.cbSize = sizeof( mi );
+ ::GetMonitorInfo( m_hMonitor, &mi );
- string = mi.szDevice;
+ string = mi.szDevice;
}
//
// these methods return true if any part of the item intersects the monitor rect
-BOOL CMonitor::IsOnMonitor(const POINT pt) const
+BOOL CMonitor::IsOnMonitor( const POINT pt ) const
{
- CRect rect;
- GetMonitorRect(rect);
+ CRect rect;
+ GetMonitorRect( rect );
- return rect.PtInRect(pt);
+ return rect.PtInRect( pt );
}
-BOOL CMonitor::IsOnMonitor(const CWnd* pWnd) const
+BOOL CMonitor::IsOnMonitor( const CWnd* pWnd ) const
{
- CRect rect;
- GetMonitorRect(rect);
+ CRect rect;
+ GetMonitorRect( rect );
- ASSERT(::IsWindow(pWnd->GetSafeHwnd()));
- CRect wndRect;
- pWnd->GetWindowRect(&wndRect);
+ ASSERT( ::IsWindow( pWnd->GetSafeHwnd() ) );
+ CRect wndRect;
+ pWnd->GetWindowRect( &wndRect );
- return rect.IntersectRect(rect, wndRect);
+ return rect.IntersectRect( rect, wndRect );
}
-BOOL CMonitor::IsOnMonitor(const LPRECT lprc) const
+BOOL CMonitor::IsOnMonitor( const LPRECT lprc ) const
{
- CRect rect;
- GetMonitorRect(rect);
+ CRect rect;
+ GetMonitorRect( rect );
- return rect.IntersectRect(rect, lprc);
+ return rect.IntersectRect( rect, lprc );
}
-void CMonitor::GetMonitorRect(LPRECT lprc) const
+void CMonitor::GetMonitorRect( LPRECT lprc ) const
{
- ASSERT(IsMonitor());
-
- MONITORINFO mi;
+ ASSERT( IsMonitor() );
+
+ MONITORINFO mi;
RECT rc;
- mi.cbSize = sizeof(mi);
- ::GetMonitorInfo(m_hMonitor, &mi);
- rc = mi.rcMonitor;
+ mi.cbSize = sizeof( mi );
+ ::GetMonitorInfo( m_hMonitor, &mi );
+ rc = mi.rcMonitor;
- ::SetRect(lprc, rc.left, rc.top, rc.right, rc.bottom);
+ ::SetRect( lprc, rc.left, rc.top, rc.right, rc.bottom );
}
//
// the work area does not include the start bar
-void CMonitor::GetWorkAreaRect(LPRECT lprc) const
+void CMonitor::GetWorkAreaRect( LPRECT lprc ) const
{
- ASSERT(IsMonitor());
+ ASSERT( IsMonitor() );
- MONITORINFO mi;
+ MONITORINFO mi;
RECT rc;
- mi.cbSize = sizeof(mi);
- ::GetMonitorInfo(m_hMonitor, &mi);
- rc = mi.rcWork;
+ mi.cbSize = sizeof( mi );
+ ::GetMonitorInfo( m_hMonitor, &mi );
+ rc = mi.rcWork;
- ::SetRect(lprc, rc.left, rc.top, rc.right, rc.bottom);
+ ::SetRect( lprc, rc.left, rc.top, rc.right, rc.bottom );
}
//these two center methods are adapted from David Campbell's
//MSJ article (see comment at the top of the header file)
-void CMonitor::CenterRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect) const
+void CMonitor::CenterRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) const
{
int w = lprc->right - lprc->left;
int h = lprc->bottom - lprc->top;
CRect rect;
- if(UseWorkAreaRect)
- GetWorkAreaRect(&rect);
+ if ( UseWorkAreaRect )
+ GetWorkAreaRect( &rect );
else
- GetMonitorRect(&rect);
+ GetMonitorRect( &rect );
- lprc->left = rect.left + (rect.Width() - w) / 2;
- lprc->top = rect.top + (rect.Height() - h) / 2;
+ lprc->left = rect.left + ( rect.Width() - w ) / 2;
+ lprc->top = rect.top + ( rect.Height() - h ) / 2;
lprc->right = lprc->left + w;
lprc->bottom = lprc->top + h;
}
-void CMonitor::CenterWindowToMonitor(CWnd* const pWnd, const BOOL UseWorkAreaRect) const
+void CMonitor::CenterWindowToMonitor( CWnd* const pWnd, const BOOL UseWorkAreaRect ) const
{
- ASSERT(IsMonitor());
- ASSERT(pWnd);
- ASSERT(::IsWindow(pWnd->m_hWnd));
+ ASSERT( IsMonitor() );
+ ASSERT( pWnd );
+ ASSERT( ::IsWindow( pWnd->m_hWnd ) );
- CRect rect;
- pWnd->GetWindowRect(&rect);
- CenterRectToMonitor(&rect, UseWorkAreaRect);
- pWnd->SetWindowPos(NULL, rect.left, rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+ CRect rect;
+ pWnd->GetWindowRect( &rect );
+ CenterRectToMonitor( &rect, UseWorkAreaRect );
+ pWnd->SetWindowPos( NULL, rect.left, rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
}
-void CMonitor::ClipRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect) const
+void CMonitor::ClipRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) const
{
int w = lprc->right - lprc->left;
int h = lprc->bottom - lprc->top;
CRect rect;
- if(UseWorkAreaRect)
- GetWorkAreaRect(&rect);
+ if ( UseWorkAreaRect )
+ GetWorkAreaRect( &rect );
else
- GetMonitorRect(&rect);
+ GetMonitorRect( &rect );
- lprc->left = max(rect.left, min(rect.right - w, lprc->left));
- lprc->top = max(rect.top, min(rect.bottom - h, lprc->top));
+ lprc->left = max( rect.left, min( rect.right - w, lprc->left ) );
+ lprc->top = max( rect.top, min( rect.bottom - h, lprc->top ) );
lprc->right = lprc->left + w;
lprc->bottom = lprc->top + h;
}
@@ -222,19 +222,19 @@ void CMonitor::ClipRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect) const
// is the instance the primary monitor
BOOL CMonitor::IsPrimaryMonitor() const
{
- ASSERT(IsMonitor());
-
- MONITORINFO mi;
+ ASSERT( IsMonitor() );
- mi.cbSize = sizeof(mi);
- ::GetMonitorInfo(m_hMonitor, &mi);
+ MONITORINFO mi;
- return mi.dwFlags == MONITORINFOF_PRIMARY;
+ mi.cbSize = sizeof( mi );
+ ::GetMonitorInfo( m_hMonitor, &mi );
+
+ return mi.dwFlags == MONITORINFOF_PRIMARY;
}
//
// is the instance currently attached to a valid monitor handle
-BOOL CMonitor::IsMonitor() const
+BOOL CMonitor::IsMonitor() const
{
- return CMonitors::IsMonitor(m_hMonitor);
+ return CMonitors::IsMonitor( m_hMonitor );
}
diff --git a/src/apps/mplayerc/MultiMonitor.h b/src/apps/mplayerc/MultiMonitor.h
index 38d4e7c1f..ef0a1871d 100644
--- a/src/apps/mplayerc/MultiMonitor.h
+++ b/src/apps/mplayerc/MultiMonitor.h
@@ -29,7 +29,7 @@
* http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0697/monitor/monitor.htm&nav=/msj/0697/newnav.htm
*/
-// CMonitor
+// CMonitor
#pragma once
@@ -37,59 +37,59 @@ class CMonitor : public CObject
{
public:
//construction destruction
- CMonitor();
- CMonitor(const CMonitor& monitor);
- virtual ~CMonitor();
+ CMonitor();
+ CMonitor( const CMonitor& monitor );
+ virtual ~CMonitor();
//operations
- void Attach(const HMONITOR hMonitor);
- HMONITOR Detach();
+ void Attach( const HMONITOR hMonitor );
+ HMONITOR Detach();
- void ClipRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect = FALSE) const;
- void CenterRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect = FALSE) const;
- void CenterWindowToMonitor(CWnd* const pWnd, const BOOL UseWorkAreaRect = FALSE) const;
+ void ClipRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect = FALSE ) const;
+ void CenterRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect = FALSE ) const;
+ void CenterWindowToMonitor( CWnd* const pWnd, const BOOL UseWorkAreaRect = FALSE ) const;
- HDC CreateDC() const;
+ HDC CreateDC() const;
//properties
- void GetMonitorRect(LPRECT lprc) const;
- void GetWorkAreaRect(LPRECT lprc) const;
+ void GetMonitorRect( LPRECT lprc ) const;
+ void GetWorkAreaRect( LPRECT lprc ) const;
- void GetName(CString& string) const;
+ void GetName( CString& string ) const;
- int GetBitsPerPixel() const;
+ int GetBitsPerPixel() const;
- BOOL IsOnMonitor(const POINT pt) const;
- BOOL IsOnMonitor(const CWnd* pWnd) const;
- BOOL IsOnMonitor(const LPRECT lprc) const;
+ BOOL IsOnMonitor( const POINT pt ) const;
+ BOOL IsOnMonitor( const CWnd* pWnd ) const;
+ BOOL IsOnMonitor( const LPRECT lprc ) const;
- BOOL IsPrimaryMonitor() const;
- BOOL IsMonitor() const;
+ BOOL IsPrimaryMonitor() const;
+ BOOL IsMonitor() const;
//operators
- operator HMONITOR() const
- {
- return this == NULL ? NULL : m_hMonitor;
- }
+ operator HMONITOR() const
+ {
+ return this == NULL ? NULL : m_hMonitor;
+ }
- BOOL operator ==(const CMonitor& monitor) const
- {
- return m_hMonitor == (HMONITOR)monitor;
- }
+ BOOL operator ==( const CMonitor& monitor ) const
+ {
+ return m_hMonitor == (HMONITOR)monitor;
+ }
- BOOL operator !=(const CMonitor& monitor) const
- {
- return !(*this == monitor);
- }
+ BOOL operator !=( const CMonitor& monitor ) const
+ {
+ return !( *this == monitor );
+ }
- void operator =(const CMonitor& monitor)
- {
- m_hMonitor = (HMONITOR)monitor;
- }
+ void operator =( const CMonitor& monitor )
+ {
+ m_hMonitor = (HMONITOR)monitor;
+ }
private:
- HMONITOR m_hMonitor;
+ HMONITOR m_hMonitor;
};
diff --git a/src/apps/mplayerc/OpenCapDeviceDlg.cpp b/src/apps/mplayerc/OpenCapDeviceDlg.cpp
index a4fe353ac..b65123c92 100644
--- a/src/apps/mplayerc/OpenCapDeviceDlg.cpp
+++ b/src/apps/mplayerc/OpenCapDeviceDlg.cpp
@@ -27,264 +27,259 @@
#include "../../DSUtil/DSUtil.h"
-static struct cc_t
+static struct cc_t {long code; AnalogVideoStandard standard; const TCHAR* str;} s_countrycodes[] =
{
- long code;
- AnalogVideoStandard standard;
- const TCHAR* str;
-} s_countrycodes[] =
-{
- {1, AnalogVideo_NTSC_M, _T("USA")},
- /* {1, AnalogVideo_NTSC_M, _T("Anguilla")},
- {1, AnalogVideo_NTSC_M, _T("Antigua")},
- {1, AnalogVideo_NTSC_M, _T("Bahamas")},
- {1, AnalogVideo_NTSC_M, _T("Barbados")},
- {1, AnalogVideo_NTSC_M, _T("Bermuda")},
- {1, AnalogVideo_NTSC_M, _T("British Virgin Islands")},
- {1, AnalogVideo_NTSC_M, _T("Canada")},
- {1, AnalogVideo_NTSC_M, _T("Cayman Islands")},
- {1, AnalogVideo_NTSC_M, _T("Dominica")},
- {1, AnalogVideo_NTSC_M, _T("Dominican Republic")},
- {1, AnalogVideo_NTSC_M, _T("Grenada")},
- {1, AnalogVideo_NTSC_M, _T("Jamaica")},
- {1, AnalogVideo_NTSC_M, _T("Montserrat")},
- {1, AnalogVideo_NTSC_M, _T("Nevis")},
- {1, AnalogVideo_NTSC_M, _T("St. Kitts")},
- {1, AnalogVideo_NTSC_M, _T("St. Vincent and the Grenadines")},
- {1, AnalogVideo_NTSC_M, _T("Trinidad and Tobago")},
- {1, AnalogVideo_NTSC_M, _T("Turks and Caicos Islands")},
- {1, AnalogVideo_NTSC_M, _T("Barbuda")},
- {1, AnalogVideo_NTSC_M, _T("Puerto Rico")},
- {1, AnalogVideo_NTSC_M, _T("Saint Lucia")},
- {1, AnalogVideo_NTSC_M, _T("United States Virgin Islands")},
- */ {2, AnalogVideo_NTSC_M, _T("Canada")},
- {7, AnalogVideo_SECAM_D, _T("Russia")},
- /* {7, AnalogVideo_SECAM_D, _T("Kazakhstan")},
- {7, AnalogVideo_SECAM_D, _T("Kyrgyzstan")},
- {7, AnalogVideo_SECAM_D, _T("Tajikistan")},
- {7, AnalogVideo_SECAM_D, _T("Turkmenistan")},
- {7, AnalogVideo_SECAM_D, _T("Uzbekistan")},
- */ {20, AnalogVideo_SECAM_B, _T("Egypt")},
- {27, AnalogVideo_PAL_I, _T("South Africa")},
- {30, AnalogVideo_SECAM_B, _T("Greece")},
- {31, AnalogVideo_PAL_B, _T("Netherlands")},
- {32, AnalogVideo_PAL_B, _T("Belgium")},
- {33, AnalogVideo_SECAM_L, _T("France")},
- {34, AnalogVideo_PAL_B, _T("Spain")},
- {36, AnalogVideo_SECAM_D, _T("Hungary")},
- {39, AnalogVideo_PAL_B, _T("Italy")},
- {39, AnalogVideo_PAL_B, _T("Vatican City")},
- {40, AnalogVideo_PAL_D, _T("Romania")},
- {41, AnalogVideo_PAL_B, _T("Switzerland")},
- {41, AnalogVideo_PAL_B, _T("Liechtenstein")},
- {43, AnalogVideo_PAL_B, _T("Austria")},
- {44, AnalogVideo_PAL_I, _T("United Kingdom")},
- {45, AnalogVideo_PAL_B, _T("Denmark")},
- {46, AnalogVideo_PAL_B, _T("Sweden")},
- {47, AnalogVideo_PAL_B, _T("Norway")},
- {48, AnalogVideo_PAL_B, _T("Poland")},
- {49, AnalogVideo_PAL_B, _T("Germany")},
- {51, AnalogVideo_NTSC_M, _T("Peru")},
- {52, AnalogVideo_NTSC_M, _T("Mexico")},
- {53, AnalogVideo_NTSC_M, _T("Cuba")},
- {53, AnalogVideo_NTSC_M, _T("Guantanamo Bay")},
- {54, AnalogVideo_PAL_N, _T("Argentina")},
- {55, AnalogVideo_PAL_M, _T("Brazil")},
- {56, AnalogVideo_NTSC_M, _T("Chile")},
- {57, AnalogVideo_NTSC_M, _T("Colombia")},
- {58, AnalogVideo_NTSC_M, _T("Bolivarian Republic of Venezuela")},
- {60, AnalogVideo_PAL_B, _T("Malaysia")},
- {61, AnalogVideo_PAL_B, _T("Australia")},
- // {61, AnalogVideo_NTSC_M, _T("Cocos-Keeling Islands")},
- {62, AnalogVideo_PAL_B, _T("Indonesia")},
- {63, AnalogVideo_NTSC_M, _T("Philippines")},
- {64, AnalogVideo_PAL_B, _T("New Zealand")},
- {65, AnalogVideo_PAL_B, _T("Singapore")},
- {66, AnalogVideo_PAL_B, _T("Thailand")},
- {81, AnalogVideo_NTSC_M_J, _T("Japan")},
- {82, AnalogVideo_NTSC_M, _T("Korea (South)")},
- {84, AnalogVideo_NTSC_M, _T("Vietnam")},
- {86, AnalogVideo_PAL_D, _T("China")},
- {90, AnalogVideo_PAL_B, _T("Turkey")},
- {91, AnalogVideo_PAL_B, _T("India")},
- {92, AnalogVideo_PAL_B, _T("Pakistan")},
- {93, AnalogVideo_PAL_B, _T("Afghanistan")},
- {94, AnalogVideo_PAL_B, _T("Sri Lanka")},
- {95, AnalogVideo_NTSC_M, _T("Myanmar")},
- {98, AnalogVideo_SECAM_B, _T("Iran")},
- {212, AnalogVideo_SECAM_B, _T("Morocco")},
- {213, AnalogVideo_PAL_B, _T("Algeria")},
- {216, AnalogVideo_SECAM_B, _T("Tunisia")},
- {218, AnalogVideo_SECAM_B, _T("Libya")},
- {220, AnalogVideo_SECAM_K, _T("Gambia")},
- {221, AnalogVideo_SECAM_K, _T("Senegal Republic")},
- {222, AnalogVideo_SECAM_B, _T("Mauritania")},
- {223, AnalogVideo_SECAM_K, _T("Mali")},
- {224, AnalogVideo_SECAM_K, _T("Guinea")},
- {225, AnalogVideo_SECAM_K, _T("Cote D'Ivoire")},
- {226, AnalogVideo_SECAM_K, _T("Burkina Faso")},
- {227, AnalogVideo_SECAM_K, _T("Niger")},
- {228, AnalogVideo_SECAM_K, _T("Togo")},
- {229, AnalogVideo_SECAM_K, _T("Benin")},
- {230, AnalogVideo_SECAM_B, _T("Mauritius")},
- {231, AnalogVideo_PAL_B, _T("Liberia")},
- {232, AnalogVideo_PAL_B, _T("Sierra Leone")},
- {233, AnalogVideo_PAL_B, _T("Ghana")},
- {234, AnalogVideo_PAL_B, _T("Nigeria")},
- {235, AnalogVideo_PAL_B, _T("Chad")},
- {236, AnalogVideo_PAL_B, _T("Central African Republic")},
- {237, AnalogVideo_PAL_B, _T("Cameroon")},
- {238, AnalogVideo_NTSC_M, _T("Cape Verde Islands")},
- {239, AnalogVideo_PAL_B, _T("Sao Tome and Principe")},
- {240, AnalogVideo_SECAM_B, _T("Equatorial Guinea")},
- {241, AnalogVideo_SECAM_K, _T("Gabon")},
- {242, AnalogVideo_SECAM_D, _T("Congo")},
- {243, AnalogVideo_SECAM_K, _T("Congo(DRC)")},
- {244, AnalogVideo_PAL_I, _T("Angola")},
- {245, AnalogVideo_NTSC_M, _T("Guinea-Bissau")},
- {246, AnalogVideo_NTSC_M, _T("Diego Garcia")},
- {247, AnalogVideo_NTSC_M, _T("Ascension Island")},
- {248, AnalogVideo_PAL_B, _T("Seychelle Islands")},
- {249, AnalogVideo_PAL_B, _T("Sudan")},
- {250, AnalogVideo_PAL_B, _T("Rwanda")},
- {251, AnalogVideo_PAL_B, _T("Ethiopia")},
- {252, AnalogVideo_PAL_B, _T("Somalia")},
- {253, AnalogVideo_SECAM_K, _T("Djibouti")},
- {254, AnalogVideo_PAL_B, _T("Kenya")},
- {255, AnalogVideo_PAL_B, _T("Tanzania")},
- {256, AnalogVideo_PAL_B, _T("Uganda")},
- {257, AnalogVideo_SECAM_K, _T("Burundi")},
- {258, AnalogVideo_PAL_B, _T("Mozambique")},
- {260, AnalogVideo_PAL_B, _T("Zambia")},
- {261, AnalogVideo_SECAM_K, _T("Madagascar")},
- {262, AnalogVideo_SECAM_K, _T("Reunion Island")},
- {263, AnalogVideo_PAL_B, _T("Zimbabwe")},
- {264, AnalogVideo_PAL_I, _T("Namibia")},
- {265, AnalogVideo_NTSC_M, _T("Malawi")},
- {266, AnalogVideo_PAL_I, _T("Lesotho")},
- {267, AnalogVideo_SECAM_K, _T("Botswana")},
- {268, AnalogVideo_PAL_B, _T("Swaziland")},
- {269, AnalogVideo_SECAM_K, _T("Mayotte Island")},
+ {1, AnalogVideo_NTSC_M, _T("USA")},
+/* {1, AnalogVideo_NTSC_M, _T("Anguilla")},
+ {1, AnalogVideo_NTSC_M, _T("Antigua")},
+ {1, AnalogVideo_NTSC_M, _T("Bahamas")},
+ {1, AnalogVideo_NTSC_M, _T("Barbados")},
+ {1, AnalogVideo_NTSC_M, _T("Bermuda")},
+ {1, AnalogVideo_NTSC_M, _T("British Virgin Islands")},
+ {1, AnalogVideo_NTSC_M, _T("Canada")},
+ {1, AnalogVideo_NTSC_M, _T("Cayman Islands")},
+ {1, AnalogVideo_NTSC_M, _T("Dominica")},
+ {1, AnalogVideo_NTSC_M, _T("Dominican Republic")},
+ {1, AnalogVideo_NTSC_M, _T("Grenada")},
+ {1, AnalogVideo_NTSC_M, _T("Jamaica")},
+ {1, AnalogVideo_NTSC_M, _T("Montserrat")},
+ {1, AnalogVideo_NTSC_M, _T("Nevis")},
+ {1, AnalogVideo_NTSC_M, _T("St. Kitts")},
+ {1, AnalogVideo_NTSC_M, _T("St. Vincent and the Grenadines")},
+ {1, AnalogVideo_NTSC_M, _T("Trinidad and Tobago")},
+ {1, AnalogVideo_NTSC_M, _T("Turks and Caicos Islands")},
+ {1, AnalogVideo_NTSC_M, _T("Barbuda")},
+ {1, AnalogVideo_NTSC_M, _T("Puerto Rico")},
+ {1, AnalogVideo_NTSC_M, _T("Saint Lucia")},
+ {1, AnalogVideo_NTSC_M, _T("United States Virgin Islands")},
+*/ {2, AnalogVideo_NTSC_M, _T("Canada")},
+ {7, AnalogVideo_SECAM_D, _T("Russia")},
+/* {7, AnalogVideo_SECAM_D, _T("Kazakhstan")},
+ {7, AnalogVideo_SECAM_D, _T("Kyrgyzstan")},
+ {7, AnalogVideo_SECAM_D, _T("Tajikistan")},
+ {7, AnalogVideo_SECAM_D, _T("Turkmenistan")},
+ {7, AnalogVideo_SECAM_D, _T("Uzbekistan")},
+*/ {20, AnalogVideo_SECAM_B, _T("Egypt")},
+ {27, AnalogVideo_PAL_I, _T("South Africa")},
+ {30, AnalogVideo_SECAM_B, _T("Greece")},
+ {31, AnalogVideo_PAL_B, _T("Netherlands")},
+ {32, AnalogVideo_PAL_B, _T("Belgium")},
+ {33, AnalogVideo_SECAM_L, _T("France")},
+ {34, AnalogVideo_PAL_B, _T("Spain")},
+ {36, AnalogVideo_SECAM_D, _T("Hungary")},
+ {39, AnalogVideo_PAL_B, _T("Italy")},
+ {39, AnalogVideo_PAL_B, _T("Vatican City")},
+ {40, AnalogVideo_PAL_D, _T("Romania")},
+ {41, AnalogVideo_PAL_B, _T("Switzerland")},
+ {41, AnalogVideo_PAL_B, _T("Liechtenstein")},
+ {43, AnalogVideo_PAL_B, _T("Austria")},
+ {44, AnalogVideo_PAL_I, _T("United Kingdom")},
+ {45, AnalogVideo_PAL_B, _T("Denmark")},
+ {46, AnalogVideo_PAL_B, _T("Sweden")},
+ {47, AnalogVideo_PAL_B, _T("Norway")},
+ {48, AnalogVideo_PAL_B, _T("Poland")},
+ {49, AnalogVideo_PAL_B, _T("Germany")},
+ {51, AnalogVideo_NTSC_M, _T("Peru")},
+ {52, AnalogVideo_NTSC_M, _T("Mexico")},
+ {53, AnalogVideo_NTSC_M, _T("Cuba")},
+ {53, AnalogVideo_NTSC_M, _T("Guantanamo Bay")},
+ {54, AnalogVideo_PAL_N, _T("Argentina")},
+ {55, AnalogVideo_PAL_M, _T("Brazil")},
+ {56, AnalogVideo_NTSC_M, _T("Chile")},
+ {57, AnalogVideo_NTSC_M, _T("Colombia")},
+ {58, AnalogVideo_NTSC_M, _T("Bolivarian Republic of Venezuela")},
+ {60, AnalogVideo_PAL_B, _T("Malaysia")},
+ {61, AnalogVideo_PAL_B, _T("Australia")},
+ // {61, AnalogVideo_NTSC_M, _T("Cocos-Keeling Islands")},
+ {62, AnalogVideo_PAL_B, _T("Indonesia")},
+ {63, AnalogVideo_NTSC_M, _T("Philippines")},
+ {64, AnalogVideo_PAL_B, _T("New Zealand")},
+ {65, AnalogVideo_PAL_B, _T("Singapore")},
+ {66, AnalogVideo_PAL_B, _T("Thailand")},
+ {81, AnalogVideo_NTSC_M_J, _T("Japan")},
+ {82, AnalogVideo_NTSC_M, _T("Korea (South)")},
+ {84, AnalogVideo_NTSC_M, _T("Vietnam")},
+ {86, AnalogVideo_PAL_D, _T("China")},
+ {90, AnalogVideo_PAL_B, _T("Turkey")},
+ {91, AnalogVideo_PAL_B, _T("India")},
+ {92, AnalogVideo_PAL_B, _T("Pakistan")},
+ {93, AnalogVideo_PAL_B, _T("Afghanistan")},
+ {94, AnalogVideo_PAL_B, _T("Sri Lanka")},
+ {95, AnalogVideo_NTSC_M, _T("Myanmar")},
+ {98, AnalogVideo_SECAM_B, _T("Iran")},
+ {212, AnalogVideo_SECAM_B, _T("Morocco")},
+ {213, AnalogVideo_PAL_B, _T("Algeria")},
+ {216, AnalogVideo_SECAM_B, _T("Tunisia")},
+ {218, AnalogVideo_SECAM_B, _T("Libya")},
+ {220, AnalogVideo_SECAM_K, _T("Gambia")},
+ {221, AnalogVideo_SECAM_K, _T("Senegal Republic")},
+ {222, AnalogVideo_SECAM_B, _T("Mauritania")},
+ {223, AnalogVideo_SECAM_K, _T("Mali")},
+ {224, AnalogVideo_SECAM_K, _T("Guinea")},
+ {225, AnalogVideo_SECAM_K, _T("Cote D'Ivoire")},
+ {226, AnalogVideo_SECAM_K, _T("Burkina Faso")},
+ {227, AnalogVideo_SECAM_K, _T("Niger")},
+ {228, AnalogVideo_SECAM_K, _T("Togo")},
+ {229, AnalogVideo_SECAM_K, _T("Benin")},
+ {230, AnalogVideo_SECAM_B, _T("Mauritius")},
+ {231, AnalogVideo_PAL_B, _T("Liberia")},
+ {232, AnalogVideo_PAL_B, _T("Sierra Leone")},
+ {233, AnalogVideo_PAL_B, _T("Ghana")},
+ {234, AnalogVideo_PAL_B, _T("Nigeria")},
+ {235, AnalogVideo_PAL_B, _T("Chad")},
+ {236, AnalogVideo_PAL_B, _T("Central African Republic")},
+ {237, AnalogVideo_PAL_B, _T("Cameroon")},
+ {238, AnalogVideo_NTSC_M, _T("Cape Verde Islands")},
+ {239, AnalogVideo_PAL_B, _T("Sao Tome and Principe")},
+ {240, AnalogVideo_SECAM_B, _T("Equatorial Guinea")},
+ {241, AnalogVideo_SECAM_K, _T("Gabon")},
+ {242, AnalogVideo_SECAM_D, _T("Congo")},
+ {243, AnalogVideo_SECAM_K, _T("Congo(DRC)")},
+ {244, AnalogVideo_PAL_I, _T("Angola")},
+ {245, AnalogVideo_NTSC_M, _T("Guinea-Bissau")},
+ {246, AnalogVideo_NTSC_M, _T("Diego Garcia")},
+ {247, AnalogVideo_NTSC_M, _T("Ascension Island")},
+ {248, AnalogVideo_PAL_B, _T("Seychelle Islands")},
+ {249, AnalogVideo_PAL_B, _T("Sudan")},
+ {250, AnalogVideo_PAL_B, _T("Rwanda")},
+ {251, AnalogVideo_PAL_B, _T("Ethiopia")},
+ {252, AnalogVideo_PAL_B, _T("Somalia")},
+ {253, AnalogVideo_SECAM_K, _T("Djibouti")},
+ {254, AnalogVideo_PAL_B, _T("Kenya")},
+ {255, AnalogVideo_PAL_B, _T("Tanzania")},
+ {256, AnalogVideo_PAL_B, _T("Uganda")},
+ {257, AnalogVideo_SECAM_K, _T("Burundi")},
+ {258, AnalogVideo_PAL_B, _T("Mozambique")},
+ {260, AnalogVideo_PAL_B, _T("Zambia")},
+ {261, AnalogVideo_SECAM_K, _T("Madagascar")},
+ {262, AnalogVideo_SECAM_K, _T("Reunion Island")},
+ {263, AnalogVideo_PAL_B, _T("Zimbabwe")},
+ {264, AnalogVideo_PAL_I, _T("Namibia")},
+ {265, AnalogVideo_NTSC_M, _T("Malawi")},
+ {266, AnalogVideo_PAL_I, _T("Lesotho")},
+ {267, AnalogVideo_SECAM_K, _T("Botswana")},
+ {268, AnalogVideo_PAL_B, _T("Swaziland")},
+ {269, AnalogVideo_SECAM_K, _T("Mayotte Island")},
// {269, AnalogVideo_NTSC_M, _T("Comoros")},
- {290, AnalogVideo_NTSC_M, _T("St. Helena")},
- {291, AnalogVideo_NTSC_M, _T("Eritrea")},
- {297, AnalogVideo_NTSC_M, _T("Aruba")},
- {298, AnalogVideo_PAL_B, _T("Faroe Islands")},
- {299, AnalogVideo_NTSC_M, _T("Greenland")},
- {350, AnalogVideo_PAL_B, _T("Gibraltar")},
- {351, AnalogVideo_PAL_B, _T("Portugal")},
- {352, AnalogVideo_PAL_B, _T("Luxembourg")},
- {353, AnalogVideo_PAL_I, _T("Ireland")},
- {354, AnalogVideo_PAL_B, _T("Iceland")},
- {355, AnalogVideo_PAL_B, _T("Albania")},
- {356, AnalogVideo_PAL_B, _T("Malta")},
- {357, AnalogVideo_PAL_B, _T("Cyprus")},
- {358, AnalogVideo_PAL_B, _T("Finland")},
- {359, AnalogVideo_SECAM_D, _T("Bulgaria")},
- {370, AnalogVideo_PAL_B, _T("Lithuania")},
- {371, AnalogVideo_SECAM_D, _T("Latvia")},
- {372, AnalogVideo_PAL_B, _T("Estonia")},
- {373, AnalogVideo_SECAM_D, _T("Moldova")},
- {374, AnalogVideo_SECAM_D, _T("Armenia")},
- {375, AnalogVideo_SECAM_D, _T("Belarus")},
- {376, AnalogVideo_NTSC_M, _T("Andorra")},
- {377, AnalogVideo_SECAM_G, _T("Monaco")},
- {378, AnalogVideo_PAL_B, _T("San Marino")},
- {380, AnalogVideo_SECAM_D, _T("Ukraine")},
- {381, AnalogVideo_PAL_B, _T("Serbia and Montenegro")},
- {385, AnalogVideo_PAL_B, _T("Croatia")},
- {386, AnalogVideo_PAL_B, _T("Slovenia")},
- {387, AnalogVideo_PAL_B, _T("Bosnia and Herzegovina")},
- {389, AnalogVideo_PAL_B, _T("F.Y.R.O.M. (Former Yugoslav Republic of Macedonia)")},
- {420, AnalogVideo_PAL_D, _T("Czech Republic")},
- {421, AnalogVideo_PAL_B, _T("Slovak Republic")},
- {500, AnalogVideo_PAL_I, _T("Falkland Islands (Islas Malvinas)")},
- {501, AnalogVideo_NTSC_M, _T("Belize")},
- {502, AnalogVideo_NTSC_M, _T("Guatemala")},
- {503, AnalogVideo_NTSC_M, _T("El Salvador")},
- {504, AnalogVideo_NTSC_M, _T("Honduras")},
- {505, AnalogVideo_NTSC_M, _T("Nicaragua")},
- {506, AnalogVideo_NTSC_M, _T("Costa Rica")},
- {507, AnalogVideo_NTSC_M, _T("Panama")},
- {508, AnalogVideo_SECAM_K, _T("St. Pierre and Miquelon")},
- {509, AnalogVideo_NTSC_M, _T("Haiti")},
- {590, AnalogVideo_SECAM_K, _T("Guadeloupe")},
+ {290, AnalogVideo_NTSC_M, _T("St. Helena")},
+ {291, AnalogVideo_NTSC_M, _T("Eritrea")},
+ {297, AnalogVideo_NTSC_M, _T("Aruba")},
+ {298, AnalogVideo_PAL_B, _T("Faroe Islands")},
+ {299, AnalogVideo_NTSC_M, _T("Greenland")},
+ {350, AnalogVideo_PAL_B, _T("Gibraltar")},
+ {351, AnalogVideo_PAL_B, _T("Portugal")},
+ {352, AnalogVideo_PAL_B, _T("Luxembourg")},
+ {353, AnalogVideo_PAL_I, _T("Ireland")},
+ {354, AnalogVideo_PAL_B, _T("Iceland")},
+ {355, AnalogVideo_PAL_B, _T("Albania")},
+ {356, AnalogVideo_PAL_B, _T("Malta")},
+ {357, AnalogVideo_PAL_B, _T("Cyprus")},
+ {358, AnalogVideo_PAL_B, _T("Finland")},
+ {359, AnalogVideo_SECAM_D, _T("Bulgaria")},
+ {370, AnalogVideo_PAL_B, _T("Lithuania")},
+ {371, AnalogVideo_SECAM_D, _T("Latvia")},
+ {372, AnalogVideo_PAL_B, _T("Estonia")},
+ {373, AnalogVideo_SECAM_D, _T("Moldova")},
+ {374, AnalogVideo_SECAM_D, _T("Armenia")},
+ {375, AnalogVideo_SECAM_D, _T("Belarus")},
+ {376, AnalogVideo_NTSC_M, _T("Andorra")},
+ {377, AnalogVideo_SECAM_G, _T("Monaco")},
+ {378, AnalogVideo_PAL_B, _T("San Marino")},
+ {380, AnalogVideo_SECAM_D, _T("Ukraine")},
+ {381, AnalogVideo_PAL_B, _T("Serbia and Montenegro")},
+ {385, AnalogVideo_PAL_B, _T("Croatia")},
+ {386, AnalogVideo_PAL_B, _T("Slovenia")},
+ {387, AnalogVideo_PAL_B, _T("Bosnia and Herzegovina")},
+ {389, AnalogVideo_PAL_B, _T("F.Y.R.O.M. (Former Yugoslav Republic of Macedonia)")},
+ {420, AnalogVideo_PAL_D, _T("Czech Republic")},
+ {421, AnalogVideo_PAL_B, _T("Slovak Republic")},
+ {500, AnalogVideo_PAL_I, _T("Falkland Islands (Islas Malvinas)")},
+ {501, AnalogVideo_NTSC_M, _T("Belize")},
+ {502, AnalogVideo_NTSC_M, _T("Guatemala")},
+ {503, AnalogVideo_NTSC_M, _T("El Salvador")},
+ {504, AnalogVideo_NTSC_M, _T("Honduras")},
+ {505, AnalogVideo_NTSC_M, _T("Nicaragua")},
+ {506, AnalogVideo_NTSC_M, _T("Costa Rica")},
+ {507, AnalogVideo_NTSC_M, _T("Panama")},
+ {508, AnalogVideo_SECAM_K, _T("St. Pierre and Miquelon")},
+ {509, AnalogVideo_NTSC_M, _T("Haiti")},
+ {590, AnalogVideo_SECAM_K, _T("Guadeloupe")},
// {590, AnalogVideo_NTSC_M, _T("French Antilles")},
- {591, AnalogVideo_PAL_N, _T("Bolivia")},
- {592, AnalogVideo_SECAM_K, _T("Guyana")},
- {593, AnalogVideo_NTSC_M, _T("Ecuador")},
- {594, AnalogVideo_SECAM_K, _T("French Guiana")},
- {595, AnalogVideo_PAL_N, _T("Paraguay")},
- {596, AnalogVideo_SECAM_K, _T("Martinique")},
- {597, AnalogVideo_NTSC_M, _T("Suriname")},
- {598, AnalogVideo_PAL_N, _T("Uruguay")},
- {599, AnalogVideo_NTSC_M, _T("Netherlands Antilles")},
- {670, AnalogVideo_NTSC_M, _T("Saipan Island")},
+ {591, AnalogVideo_PAL_N, _T("Bolivia")},
+ {592, AnalogVideo_SECAM_K, _T("Guyana")},
+ {593, AnalogVideo_NTSC_M, _T("Ecuador")},
+ {594, AnalogVideo_SECAM_K, _T("French Guiana")},
+ {595, AnalogVideo_PAL_N, _T("Paraguay")},
+ {596, AnalogVideo_SECAM_K, _T("Martinique")},
+ {597, AnalogVideo_NTSC_M, _T("Suriname")},
+ {598, AnalogVideo_PAL_N, _T("Uruguay")},
+ {599, AnalogVideo_NTSC_M, _T("Netherlands Antilles")},
+ {670, AnalogVideo_NTSC_M, _T("Saipan Island")},
// {670, AnalogVideo_NTSC_M, _T("Rota Island")},
// {670, AnalogVideo_NTSC_M, _T("Tinian Island")},
- {671, AnalogVideo_NTSC_M, _T("Guam")},
- {672, AnalogVideo_NTSC_M, _T("Christmas Island")},
- {672, AnalogVideo_NTSC_M, _T("Australian Antarctic Territory")},
- //{672, AnalogVideo_PAL_B, _T("Norfolk Island")},
- {673, AnalogVideo_PAL_B, _T("Brunei")},
- {674, AnalogVideo_NTSC_M, _T("Nauru")},
- {675, AnalogVideo_PAL_B, _T("Papua New Guinea")},
- {676, AnalogVideo_NTSC_M, _T("Tonga")},
- {677, AnalogVideo_NTSC_M, _T("Solomon Islands")},
- {678, AnalogVideo_NTSC_M, _T("Vanuatu")},
- {679, AnalogVideo_NTSC_M, _T("Fiji Islands")},
- {680, AnalogVideo_NTSC_M, _T("Palau")},
- {681, AnalogVideo_SECAM_K, _T("Wallis and Futuna Islands")},
- {682, AnalogVideo_PAL_B, _T("Cook Islands")},
- {683, AnalogVideo_NTSC_M, _T("Niue")},
- {684, AnalogVideo_NTSC_M, _T("Territory of American Samoa")},
- {685, AnalogVideo_PAL_B, _T("Samoa")},
- {686, AnalogVideo_PAL_B, _T("Kiribati Republic")},
- {687, AnalogVideo_SECAM_K, _T("New Caledonia")},
- {688, AnalogVideo_NTSC_M, _T("Tuvalu")},
- {689, AnalogVideo_SECAM_K, _T("French Polynesia")},
- {690, AnalogVideo_NTSC_M, _T("Tokelau")},
- {691, AnalogVideo_NTSC_M, _T("Micronesia")},
- {692, AnalogVideo_NTSC_M, _T("Marshall Islands")},
- {850, AnalogVideo_SECAM_D, _T("Korea (North)")},
- {852, AnalogVideo_PAL_I, _T("Hong Kong SAR")},
- {853, AnalogVideo_PAL_I, _T("Macao SAR")},
- {855, AnalogVideo_PAL_B, _T("Cambodia")},
- {856, AnalogVideo_PAL_B, _T("Laos")},
- {871, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-East)")},
- {872, AnalogVideo_NTSC_M, _T("INMARSAT (Pacific)")},
- {873, AnalogVideo_NTSC_M, _T("INMARSAT (Indian)")},
- {874, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-West)")},
- {880, AnalogVideo_PAL_B, _T("Bangladesh")},
- {886, AnalogVideo_NTSC_M, _T("Taiwan")},
- {960, AnalogVideo_PAL_B, _T("Maldives")},
- {961, AnalogVideo_SECAM_B, _T("Lebanon")},
- {962, AnalogVideo_PAL_B, _T("Jordan")},
- {963, AnalogVideo_SECAM_B, _T("Syria")},
- {964, AnalogVideo_SECAM_B, _T("Iraq")},
- {965, AnalogVideo_PAL_B, _T("Kuwait")},
- {966, AnalogVideo_SECAM_B, _T("Saudi Arabia")},
- {967, AnalogVideo_PAL_B, _T("Yemen")},
- {968, AnalogVideo_PAL_B, _T("Oman")},
- {971, AnalogVideo_PAL_B, _T("United Arab Emirates")},
- {972, AnalogVideo_PAL_B, _T("Israel")},
- {973, AnalogVideo_PAL_B, _T("Bahrain")},
- {974, AnalogVideo_PAL_B, _T("Qatar")},
- {975, AnalogVideo_NTSC_M, _T("Bhutan")},
- {976, AnalogVideo_SECAM_D, _T("Mongolia")},
- {977, AnalogVideo_PAL_B, _T("Nepal")},
- {994, AnalogVideo_SECAM_D, _T("Azerbaijan")},
- {995, AnalogVideo_SECAM_D, _T("Georgia")},
+ {671, AnalogVideo_NTSC_M, _T("Guam")},
+ {672, AnalogVideo_NTSC_M, _T("Christmas Island")},
+ {672, AnalogVideo_NTSC_M, _T("Australian Antarctic Territory")},
+ //{672, AnalogVideo_PAL_B, _T("Norfolk Island")},
+ {673, AnalogVideo_PAL_B, _T("Brunei")},
+ {674, AnalogVideo_NTSC_M, _T("Nauru")},
+ {675, AnalogVideo_PAL_B, _T("Papua New Guinea")},
+ {676, AnalogVideo_NTSC_M, _T("Tonga")},
+ {677, AnalogVideo_NTSC_M, _T("Solomon Islands")},
+ {678, AnalogVideo_NTSC_M, _T("Vanuatu")},
+ {679, AnalogVideo_NTSC_M, _T("Fiji Islands")},
+ {680, AnalogVideo_NTSC_M, _T("Palau")},
+ {681, AnalogVideo_SECAM_K, _T("Wallis and Futuna Islands")},
+ {682, AnalogVideo_PAL_B, _T("Cook Islands")},
+ {683, AnalogVideo_NTSC_M, _T("Niue")},
+ {684, AnalogVideo_NTSC_M, _T("Territory of American Samoa")},
+ {685, AnalogVideo_PAL_B, _T("Samoa")},
+ {686, AnalogVideo_PAL_B, _T("Kiribati Republic")},
+ {687, AnalogVideo_SECAM_K, _T("New Caledonia")},
+ {688, AnalogVideo_NTSC_M, _T("Tuvalu")},
+ {689, AnalogVideo_SECAM_K, _T("French Polynesia")},
+ {690, AnalogVideo_NTSC_M, _T("Tokelau")},
+ {691, AnalogVideo_NTSC_M, _T("Micronesia")},
+ {692, AnalogVideo_NTSC_M, _T("Marshall Islands")},
+ {850, AnalogVideo_SECAM_D, _T("Korea (North)")},
+ {852, AnalogVideo_PAL_I, _T("Hong Kong SAR")},
+ {853, AnalogVideo_PAL_I, _T("Macao SAR")},
+ {855, AnalogVideo_PAL_B, _T("Cambodia")},
+ {856, AnalogVideo_PAL_B, _T("Laos")},
+ {871, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-East)")},
+ {872, AnalogVideo_NTSC_M, _T("INMARSAT (Pacific)")},
+ {873, AnalogVideo_NTSC_M, _T("INMARSAT (Indian)")},
+ {874, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-West)")},
+ {880, AnalogVideo_PAL_B, _T("Bangladesh")},
+ {886, AnalogVideo_NTSC_M, _T("Taiwan")},
+ {960, AnalogVideo_PAL_B, _T("Maldives")},
+ {961, AnalogVideo_SECAM_B, _T("Lebanon")},
+ {962, AnalogVideo_PAL_B, _T("Jordan")},
+ {963, AnalogVideo_SECAM_B, _T("Syria")},
+ {964, AnalogVideo_SECAM_B, _T("Iraq")},
+ {965, AnalogVideo_PAL_B, _T("Kuwait")},
+ {966, AnalogVideo_SECAM_B, _T("Saudi Arabia")},
+ {967, AnalogVideo_PAL_B, _T("Yemen")},
+ {968, AnalogVideo_PAL_B, _T("Oman")},
+ {971, AnalogVideo_PAL_B, _T("United Arab Emirates")},
+ {972, AnalogVideo_PAL_B, _T("Israel")},
+ {973, AnalogVideo_PAL_B, _T("Bahrain")},
+ {974, AnalogVideo_PAL_B, _T("Qatar")},
+ {975, AnalogVideo_NTSC_M, _T("Bhutan")},
+ {976, AnalogVideo_SECAM_D, _T("Mongolia")},
+ {977, AnalogVideo_PAL_B, _T("Nepal")},
+ {994, AnalogVideo_SECAM_D, _T("Azerbaijan")},
+ {995, AnalogVideo_SECAM_D,_T("Georgia")},
};
// COpenCapDeviceDlg dialog
//IMPLEMENT_DYNAMIC(COpenCapDeviceDlg, CResizableDialog)
COpenCapDeviceDlg::COpenCapDeviceDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(COpenCapDeviceDlg::IDD, pParent)
- , m_vidstr(_T(""))
- , m_audstr(_T(""))
- , m_country(1)
+ : CResizableDialog(COpenCapDeviceDlg::IDD, pParent)
+ , m_vidstr(_T(""))
+ , m_audstr(_T(""))
+ , m_country(1)
{
}
@@ -294,14 +289,14 @@ COpenCapDeviceDlg::~COpenCapDeviceDlg()
void COpenCapDeviceDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_vidctrl);
- DDX_Control(pDX, IDC_COMBO2, m_audctrl);
- DDX_Control(pDX, IDC_COMBO9, m_countryctrl);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_vidctrl);
+ DDX_Control(pDX, IDC_COMBO2, m_audctrl);
+ DDX_Control(pDX, IDC_COMBO9, m_countryctrl);
}
BEGIN_MESSAGE_MAP(COpenCapDeviceDlg, CResizableDialog)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
@@ -309,185 +304,145 @@ END_MESSAGE_MAP()
BOOL COpenCapDeviceDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- AddAnchor(m_vidctrl, TOP_LEFT, TOP_RIGHT);
- AddAnchor(m_audctrl, TOP_LEFT, TOP_RIGHT);
- AddAnchor(m_countryctrl, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDOK, TOP_CENTER);
- AddAnchor(IDCANCEL, TOP_CENTER);
-
- CRect r;
- GetWindowRect(r);
- CSize s = r.Size();
- SetMinTrackSize(s);
- s.cx = 1000;
- SetMaxTrackSize(s);
-
- CString dummy = _T("dummy");
- CString vidstr = AfxGetApp()->GetProfileString(_T("Capture"), _T("VidDispName"), dummy);
- CString audstr = AfxGetApp()->GetProfileString(_T("Capture"), _T("AudDispName"), dummy);
- long country = AfxGetApp()->GetProfileInt(_T("Capture"), _T("Country"), 1);
-
- int iSel = vidstr == dummy ? 0 : -1;
-
- BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_vidctrl.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
- m_vidnames.Add(CString(strName));
- if(vidstr == CString(strName)) iSel = i;
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
-
- if(m_vidctrl.GetCount())
- m_vidctrl.SetCurSel(iSel);
-
- iSel = audstr == dummy ? 0 : -1;
-
- BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_audctrl.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
- m_audnames.Add(CString(strName));
- if(audstr == CString(strName)) iSel = i;
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
-
- {
- int i = m_audctrl.AddString(_T("<Video Capture Device>"));
- m_audnames.Add(_T(""));
- if(audstr.IsEmpty()) iSel = i;
- }
-
- if(m_audctrl.GetCount())
- m_audctrl.SetCurSel(iSel);
-
- iSel = 0;
-
- for(int j = 0; j < countof(s_countrycodes); j++)
- {
- CString standard;
- switch(s_countrycodes[j].standard)
- {
- case AnalogVideo_NTSC_M:
- standard = _T("NTSC M");
- break;
- case AnalogVideo_NTSC_M_J:
- standard = _T("NTSC M J");
- break;
- case AnalogVideo_NTSC_433:
- standard = _T("NTSC 433");
- break;
- case AnalogVideo_PAL_B:
- standard = _T("PAL B");
- break;
- case AnalogVideo_PAL_D:
- standard = _T("PAL D");
- break;
- case AnalogVideo_PAL_G:
- standard = _T("PAL G");
- break;
- case AnalogVideo_PAL_H:
- standard = _T("PAL H");
- break;
- case AnalogVideo_PAL_I:
- standard = _T("PAL I");
- break;
- case AnalogVideo_PAL_M:
- standard = _T("PAL M");
- break;
- case AnalogVideo_PAL_N:
- standard = _T("PAL N");
- break;
- case AnalogVideo_PAL_60:
- standard = _T("PAL 60");
- break;
- case AnalogVideo_SECAM_B:
- standard = _T("SECAM B");
- break;
- case AnalogVideo_SECAM_D:
- standard = _T("SECAM D");
- break;
- case AnalogVideo_SECAM_G:
- standard = _T("SECAM G");
- break;
- case AnalogVideo_SECAM_H:
- standard = _T("SECAM H");
- break;
- case AnalogVideo_SECAM_K:
- standard = _T("SECAM K");
- break;
- case AnalogVideo_SECAM_K1:
- standard = _T("SECAM K1");
- break;
- case AnalogVideo_SECAM_L:
- standard = _T("SECAM L");
- break;
- case AnalogVideo_SECAM_L1:
- standard = _T("SECAM L1");
- break;
- case AnalogVideo_PAL_N_COMBO:
- standard = _T("PAL N COMBO");
- break;
- }
-
- CString str;
- str.Format(_T("%d - %s - %s"), s_countrycodes[j].code, s_countrycodes[j].str, standard);
-
- int i = m_countryctrl.AddString(str);
- m_countryctrl.SetItemDataPtr(i, &s_countrycodes[j]);
- if(country == s_countrycodes[j].code) iSel = i;
- }
-
- if(m_countryctrl.GetCount())
- m_countryctrl.SetCurSel(iSel);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AddAnchor(m_vidctrl, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(m_audctrl, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(m_countryctrl, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDOK, TOP_CENTER);
+ AddAnchor(IDCANCEL, TOP_CENTER);
+
+ CRect r;
+ GetWindowRect(r);
+ CSize s = r.Size();
+ SetMinTrackSize(s);
+ s.cx = 1000;
+ SetMaxTrackSize(s);
+
+ CString dummy = _T("dummy");
+ CString vidstr = AfxGetApp()->GetProfileString(_T("Capture"), _T("VidDispName"), dummy);
+ CString audstr = AfxGetApp()->GetProfileString(_T("Capture"), _T("AudDispName"), dummy);
+ long country = AfxGetApp()->GetProfileInt(_T("Capture"), _T("Country"), 1);
+
+ int iSel = vidstr == dummy ? 0 : -1;
+
+ BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_vidctrl.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ {
+ m_vidnames.Add(CString(strName));
+ if(vidstr == CString(strName)) iSel = i;
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+
+ if(m_vidctrl.GetCount())
+ m_vidctrl.SetCurSel(iSel);
+
+ iSel = audstr == dummy ? 0 : -1;
+
+ BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_audctrl.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ {
+ m_audnames.Add(CString(strName));
+ if(audstr == CString(strName)) iSel = i;
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+
+ {
+ int i = m_audctrl.AddString(_T("<Video Capture Device>"));
+ m_audnames.Add(_T(""));
+ if(audstr.IsEmpty()) iSel = i;
+ }
+
+ if(m_audctrl.GetCount())
+ m_audctrl.SetCurSel(iSel);
+
+ iSel = 0;
+
+ for(int j = 0; j < countof(s_countrycodes); j++)
+ {
+ CString standard;
+ switch(s_countrycodes[j].standard)
+ {
+ case AnalogVideo_NTSC_M: standard = _T("NTSC M"); break;
+ case AnalogVideo_NTSC_M_J: standard = _T("NTSC M J"); break;
+ case AnalogVideo_NTSC_433: standard = _T("NTSC 433"); break;
+ case AnalogVideo_PAL_B: standard = _T("PAL B"); break;
+ case AnalogVideo_PAL_D: standard = _T("PAL D"); break;
+ case AnalogVideo_PAL_G: standard = _T("PAL G"); break;
+ case AnalogVideo_PAL_H: standard = _T("PAL H"); break;
+ case AnalogVideo_PAL_I: standard = _T("PAL I"); break;
+ case AnalogVideo_PAL_M: standard = _T("PAL M"); break;
+ case AnalogVideo_PAL_N: standard = _T("PAL N"); break;
+ case AnalogVideo_PAL_60: standard = _T("PAL 60"); break;
+ case AnalogVideo_SECAM_B: standard = _T("SECAM B"); break;
+ case AnalogVideo_SECAM_D: standard = _T("SECAM D"); break;
+ case AnalogVideo_SECAM_G: standard = _T("SECAM G"); break;
+ case AnalogVideo_SECAM_H: standard = _T("SECAM H"); break;
+ case AnalogVideo_SECAM_K: standard = _T("SECAM K"); break;
+ case AnalogVideo_SECAM_K1: standard = _T("SECAM K1"); break;
+ case AnalogVideo_SECAM_L: standard = _T("SECAM L"); break;
+ case AnalogVideo_SECAM_L1: standard = _T("SECAM L1"); break;
+ case AnalogVideo_PAL_N_COMBO: standard = _T("PAL N COMBO"); break;
+ }
+
+ CString str;
+ str.Format(_T("%d - %s - %s"), s_countrycodes[j].code, s_countrycodes[j].str, standard);
+
+ int i = m_countryctrl.AddString(str);
+ m_countryctrl.SetItemDataPtr(i, &s_countrycodes[j]);
+ if(country == s_countrycodes[j].code) iSel = i;
+ }
+
+ if(m_countryctrl.GetCount())
+ m_countryctrl.SetCurSel(iSel);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void COpenCapDeviceDlg::OnBnClickedOk()
{
- UpdateData();
-
- if(m_vidctrl.GetCurSel() >= 0)
- {
- m_vidstr = m_vidnames[m_vidctrl.GetCurSel()];
- AfxGetApp()->WriteProfileString(_T("Capture"), _T("VidDispName"), m_vidstr);
- }
-
- if(m_audctrl.GetCurSel() >= 0)
- {
- m_audstr = m_audnames[m_audctrl.GetCurSel()];
- AfxGetApp()->WriteProfileString(_T("Capture"), _T("AudDispName"), m_audstr);
- }
-
- if(m_countryctrl.GetCurSel() >= 0)
- {
- m_country = ((cc_t*)m_countryctrl.GetItemDataPtr(m_countryctrl.GetCurSel()))->code;
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("Country"), m_country);
- }
-
- OnOK();
+ UpdateData();
+
+ if(m_vidctrl.GetCurSel() >= 0)
+ {
+ m_vidstr = m_vidnames[m_vidctrl.GetCurSel()];
+ AfxGetApp()->WriteProfileString(_T("Capture"), _T("VidDispName"), m_vidstr);
+ }
+
+ if(m_audctrl.GetCurSel() >= 0)
+ {
+ m_audstr = m_audnames[m_audctrl.GetCurSel()];
+ AfxGetApp()->WriteProfileString(_T("Capture"), _T("AudDispName"), m_audstr);
+ }
+
+ if(m_countryctrl.GetCurSel() >= 0)
+ {
+ m_country = ((cc_t*)m_countryctrl.GetItemDataPtr(m_countryctrl.GetCurSel()))->code;
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("Country"), m_country);
+ }
+
+ OnOK();
}
diff --git a/src/apps/mplayerc/OpenCapDeviceDlg.h b/src/apps/mplayerc/OpenCapDeviceDlg.h
index 04c722255..449c82fd6 100644
--- a/src/apps/mplayerc/OpenCapDeviceDlg.h
+++ b/src/apps/mplayerc/OpenCapDeviceDlg.h
@@ -34,28 +34,28 @@ class COpenCapDeviceDlg : public CResizableDialog
// DECLARE_DYNAMIC(COpenCapDeviceDlg)
private:
- CAtlArray<CString> m_vidnames, m_audnames;
+ CAtlArray<CString> m_vidnames, m_audnames;
public:
- COpenCapDeviceDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~COpenCapDeviceDlg();
+ COpenCapDeviceDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~COpenCapDeviceDlg();
- CComboBox m_vidctrl;
- CComboBox m_audctrl;
- CComboBox m_countryctrl;
+ CComboBox m_vidctrl;
+ CComboBox m_audctrl;
+ CComboBox m_countryctrl;
- CString m_vidstr, m_audstr;
- long m_country;
+ CString m_vidstr, m_audstr;
+ long m_country;
// Dialog Data
- enum { IDD = IDD_OPENCAPDEVICE_DLG };
+ enum { IDD = IDD_OPENCAPDEVICE_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedOk();
+ afx_msg void OnBnClickedOk();
};
diff --git a/src/apps/mplayerc/OpenDlg.cpp b/src/apps/mplayerc/OpenDlg.cpp
index b5f375654..6a564130b 100644
--- a/src/apps/mplayerc/OpenDlg.cpp
+++ b/src/apps/mplayerc/OpenDlg.cpp
@@ -31,11 +31,11 @@
//IMPLEMENT_DYNAMIC(COpenDlg, CResizableDialog)
COpenDlg::COpenDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(COpenDlg::IDD, pParent)
- , m_path(_T(""))
- , m_path2(_T(""))
- , m_fMultipleFiles(false)
- , m_fAppendPlaylist(FALSE)
+ : CResizableDialog(COpenDlg::IDD, pParent)
+ , m_path(_T(""))
+ , m_path2(_T(""))
+ , m_fMultipleFiles(false)
+ , m_fAppendPlaylist(FALSE)
{
}
@@ -45,23 +45,23 @@ COpenDlg::~COpenDlg()
void COpenDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_mrucombo);
- DDX_CBString(pDX, IDC_COMBO1, m_path);
- DDX_Control(pDX, IDC_COMBO2, m_mrucombo2);
- DDX_CBString(pDX, IDC_COMBO2, m_path2);
- DDX_Control(pDX, IDC_STATIC1, m_label2);
- DDX_Check(pDX, IDC_CHECK1, m_fAppendPlaylist);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_mrucombo);
+ DDX_CBString(pDX, IDC_COMBO1, m_path);
+ DDX_Control(pDX, IDC_COMBO2, m_mrucombo2);
+ DDX_CBString(pDX, IDC_COMBO2, m_path2);
+ DDX_Control(pDX, IDC_STATIC1, m_label2);
+ DDX_Check(pDX, IDC_CHECK1, m_fAppendPlaylist);
}
BEGIN_MESSAGE_MAP(COpenDlg, CResizableDialog)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedBrowsebutton)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedBrowsebutton2)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateDub)
- ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateDub)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateDub)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedBrowsebutton)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedBrowsebutton2)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateDub)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateDub)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateDub)
END_MESSAGE_MAP()
@@ -69,127 +69,127 @@ END_MESSAGE_MAP()
BOOL COpenDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- CRecentFileList& MRU = AfxGetAppSettings().MRU;
- MRU.ReadList();
- m_mrucombo.ResetContent();
- for(int i = 0; i < MRU.GetSize(); i++)
- if(!MRU[i].IsEmpty())
- m_mrucombo.AddString(MRU[i]);
- CorrectComboListWidth(m_mrucombo, GetFont());
-
- CRecentFileList& MRUDub = AfxGetAppSettings().MRUDub;
- MRUDub.ReadList();
- m_mrucombo2.ResetContent();
- for(int i = 0; i < MRUDub.GetSize(); i++)
- if(!MRUDub[i].IsEmpty())
- m_mrucombo2.AddString(MRUDub[i]);
- CorrectComboListWidth(m_mrucombo2, GetFont());
-
- if(m_mrucombo.GetCount() > 0) m_mrucombo.SetCurSel(0);
-
- AddAnchor(m_mrucombo, TOP_LEFT, TOP_RIGHT);
- AddAnchor(m_mrucombo2, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
- AddAnchor(IDC_BUTTON2, TOP_RIGHT);
- AddAnchor(IDOK, TOP_RIGHT);
- AddAnchor(IDCANCEL, TOP_RIGHT);
- AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
-
- CRect r;
- GetWindowRect(r);
- CSize s = r.Size();
- SetMinTrackSize(s);
- s.cx = 1000;
- SetMaxTrackSize(s);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ CRecentFileList& MRU = AfxGetAppSettings().MRU;
+ MRU.ReadList();
+ m_mrucombo.ResetContent();
+ for(int i = 0; i < MRU.GetSize(); i++)
+ if(!MRU[i].IsEmpty())
+ m_mrucombo.AddString(MRU[i]);
+ CorrectComboListWidth(m_mrucombo, GetFont());
+
+ CRecentFileList& MRUDub = AfxGetAppSettings().MRUDub;
+ MRUDub.ReadList();
+ m_mrucombo2.ResetContent();
+ for(int i = 0; i < MRUDub.GetSize(); i++)
+ if(!MRUDub[i].IsEmpty())
+ m_mrucombo2.AddString(MRUDub[i]);
+ CorrectComboListWidth(m_mrucombo2, GetFont());
+
+ if(m_mrucombo.GetCount() > 0) m_mrucombo.SetCurSel(0);
+
+ AddAnchor(m_mrucombo, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(m_mrucombo2, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON2, TOP_RIGHT);
+ AddAnchor(IDOK, TOP_RIGHT);
+ AddAnchor(IDCANCEL, TOP_RIGHT);
+ AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
+
+ CRect r;
+ GetWindowRect(r);
+ CSize s = r.Size();
+ SetMinTrackSize(s);
+ s.cx = 1000;
+ SetMaxTrackSize(s);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
static CString GetFileName(CString str)
{
- CPath p = str;
- p.StripPath();
- return (LPCTSTR)p;
+ CPath p = str;
+ p.StripPath();
+ return (LPCTSTR)p;
}
void COpenDlg::OnBnClickedBrowsebutton()
{
- UpdateData();
-
- CString filter;
- CAtlArray<CString> mask;
- AfxGetAppSettings().Formats.GetFilter(filter, mask);
-
- COpenFileDlg fd(mask, true, NULL, m_path,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_ENABLEINCLUDENOTIFY,
- filter, this);
- if(fd.DoModal() != IDOK) return;
-
- m_fns.RemoveAll();
-
- POSITION pos = fd.GetStartPosition();
- while(pos)
- {
- /*
- CString str = fd.GetNextPathName(pos);
- POSITION insertpos = m_fns.GetTailPosition();
- while(insertpos && GetFileName(str).CompareNoCase(GetFileName(m_fns.GetAt(insertpos))) <= 0)
- m_fns.GetPrev(insertpos);
- if(!insertpos) m_fns.AddHead(str);
- else m_fns.InsertAfter(insertpos, str);
- */
- m_fns.AddTail(fd.GetNextPathName(pos));
- }
-
- if(m_fns.GetCount() > 1
- || m_fns.GetCount() == 1
- && (m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '\\'
- || m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '*'))
- {
- m_fMultipleFiles = true;
- EndDialog(IDOK);
- return;
- }
-
- m_mrucombo.SetWindowText(fd.GetPathName());
+ UpdateData();
+
+ CString filter;
+ CAtlArray<CString> mask;
+ AfxGetAppSettings().Formats.GetFilter(filter, mask);
+
+ COpenFileDlg fd(mask, true, NULL, m_path,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY,
+ filter, this);
+ if(fd.DoModal() != IDOK) return;
+
+ m_fns.RemoveAll();
+
+ POSITION pos = fd.GetStartPosition();
+ while(pos)
+ {
+/*
+ CString str = fd.GetNextPathName(pos);
+ POSITION insertpos = m_fns.GetTailPosition();
+ while(insertpos && GetFileName(str).CompareNoCase(GetFileName(m_fns.GetAt(insertpos))) <= 0)
+ m_fns.GetPrev(insertpos);
+ if(!insertpos) m_fns.AddHead(str);
+ else m_fns.InsertAfter(insertpos, str);
+*/
+ m_fns.AddTail(fd.GetNextPathName(pos));
+ }
+
+ if(m_fns.GetCount() > 1
+ || m_fns.GetCount() == 1
+ && (m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '\\'
+ || m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '*'))
+ {
+ m_fMultipleFiles = true;
+ EndDialog(IDOK);
+ return;
+ }
+
+ m_mrucombo.SetWindowText(fd.GetPathName());
}
void COpenDlg::OnBnClickedBrowsebutton2()
{
- UpdateData();
+ UpdateData();
- CString filter;
- CAtlArray<CString> mask;
- AfxGetAppSettings().Formats.GetAudioFilter(filter, mask);
+ CString filter;
+ CAtlArray<CString> mask;
+ AfxGetAppSettings().Formats.GetAudioFilter(filter, mask);
- COpenFileDlg fd(mask, false, NULL, m_path2,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ENABLEINCLUDENOTIFY,
- filter, this);
+ COpenFileDlg fd(mask, false, NULL, m_path2,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLEINCLUDENOTIFY,
+ filter, this);
- if(fd.DoModal() != IDOK) return;
+ if(fd.DoModal() != IDOK) return;
- m_mrucombo2.SetWindowText(fd.GetPathName());
+ m_mrucombo2.SetWindowText(fd.GetPathName());
}
void COpenDlg::OnBnClickedOk()
{
- UpdateData();
+ UpdateData();
- m_fns.RemoveAll();
- m_fns.AddTail(m_path);
- if(m_mrucombo2.IsWindowEnabled())
- m_fns.AddTail(m_path2);
+ m_fns.RemoveAll();
+ m_fns.AddTail(m_path);
+ if(m_mrucombo2.IsWindowEnabled())
+ m_fns.AddTail(m_path2);
- m_fMultipleFiles = false;
+ m_fMultipleFiles = false;
- OnOK();
+ OnOK();
}
void COpenDlg::OnUpdateDub(CCmdUI* pCmdUI)
{
- m_mrucombo.GetWindowText(m_path);
- pCmdUI->Enable(AfxGetAppSettings().Formats.GetEngine(m_path) == DirectShow);
+ m_mrucombo.GetWindowText(m_path);
+ pCmdUI->Enable(AfxGetAppSettings().Formats.GetEngine(m_path) == DirectShow);
}
diff --git a/src/apps/mplayerc/OpenDlg.h b/src/apps/mplayerc/OpenDlg.h
index f2989799e..b30e8cf4e 100644
--- a/src/apps/mplayerc/OpenDlg.h
+++ b/src/apps/mplayerc/OpenDlg.h
@@ -33,30 +33,30 @@ class COpenDlg : public CResizableDialog
// DECLARE_DYNAMIC(COpenDlg)
public:
- COpenDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~COpenDlg();
+ COpenDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~COpenDlg();
- bool m_fMultipleFiles;
- CAtlList<CString> m_fns;
+ bool m_fMultipleFiles;
+ CAtlList<CString> m_fns;
// Dialog Data
- enum { IDD = IDD_OPEN_DLG };
- CComboBox m_mrucombo;
- CString m_path;
- CComboBox m_mrucombo2;
- CString m_path2;
- CStatic m_label2;
- BOOL m_fAppendPlaylist;
+ enum { IDD = IDD_OPEN_DLG };
+ CComboBox m_mrucombo;
+ CString m_path;
+ CComboBox m_mrucombo2;
+ CString m_path2;
+ CStatic m_label2;
+ BOOL m_fAppendPlaylist;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedBrowsebutton();
- afx_msg void OnBnClickedBrowsebutton2();
- afx_msg void OnBnClickedOk();
- afx_msg void OnUpdateDub(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedBrowsebutton();
+ afx_msg void OnBnClickedBrowsebutton2();
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnUpdateDub(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/OpenFileDlg.cpp b/src/apps/mplayerc/OpenFileDlg.cpp
index f301c2220..8d4a59bc5 100644
--- a/src/apps/mplayerc/OpenFileDlg.cpp
+++ b/src/apps/mplayerc/OpenFileDlg.cpp
@@ -36,26 +36,26 @@ WNDPROC COpenFileDlg::m_wndProc = NULL;
IMPLEMENT_DYNAMIC(COpenFileDlg, CFileDialog)
COpenFileDlg::COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd)
- : CFileDialog(TRUE, lpszDefExt, lpszFileName, dwFlags | OFN_NOVALIDATE, lpszFilter, pParentWnd, 0)
- , m_mask(mask)
+ DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd)
+ : CFileDialog(TRUE, lpszDefExt, lpszFileName, dwFlags|OFN_NOVALIDATE, lpszFilter, pParentWnd, 0)
+ , m_mask(mask)
{
- m_fAllowDirSelection = fAllowDirSelection;
- m_pOFN->lpstrInitialDir = lpszFileName;
+ m_fAllowDirSelection = fAllowDirSelection;
+ m_pOFN->lpstrInitialDir = lpszFileName;
- m_buff = DNew TCHAR[10000];
- m_buff[0] = 0;
- m_pOFN->lpstrFile = m_buff;
- m_pOFN->nMaxFile = 10000;
+ m_buff = DNew TCHAR[10000];
+ m_buff[0] = 0;
+ m_pOFN->lpstrFile = m_buff;
+ m_pOFN->nMaxFile = 10000;
}
COpenFileDlg::~COpenFileDlg()
{
- delete [] m_buff;
+ delete [] m_buff;
}
BEGIN_MESSAGE_MAP(COpenFileDlg, CFileDialog)
- ON_WM_DESTROY()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
@@ -63,97 +63,91 @@ END_MESSAGE_MAP()
LRESULT CALLBACK COpenFileDlg::WindowProcNew(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK
- && m_fAllowDirSelection)
- {
- CAutoVectorPtr<TCHAR> path;
- path.Allocate(MAX_PATH + 1); // MAX_PATH should be bigger for multiple selection, but we are only interested if it's zero length
- // note: allocating MAX_PATH only will cause a buffer overrun for too long strings, and will result in a silent app disappearing crash, 100% reproducable
- if(::GetDlgItemText(hwnd, cmb13, (TCHAR*)path, MAX_PATH) == 0)
- ::SendMessage(hwnd, CDM_SETCONTROLTEXT, edt1, (LPARAM)__DUMMY__);
- }
-
- return CallWindowProc(COpenFileDlg::m_wndProc, hwnd, message, wParam, lParam);
+ if(message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK
+ && m_fAllowDirSelection)
+ {
+ CAutoVectorPtr<TCHAR> path;
+ path.Allocate(MAX_PATH+1); // MAX_PATH should be bigger for multiple selection, but we are only interested if it's zero length
+ // note: allocating MAX_PATH only will cause a buffer overrun for too long strings, and will result in a silent app disappearing crash, 100% reproducable
+ if(::GetDlgItemText(hwnd, cmb13, (TCHAR*)path, MAX_PATH) == 0)
+ ::SendMessage(hwnd, CDM_SETCONTROLTEXT, edt1, (LPARAM)__DUMMY__);
+ }
+
+ return CallWindowProc(COpenFileDlg::m_wndProc, hwnd, message, wParam, lParam);
}
BOOL COpenFileDlg::OnInitDialog()
{
- CFileDialog::OnInitDialog();
+ CFileDialog::OnInitDialog();
- m_wndProc = (WNDPROC)SetWindowLongPtr(GetParent()->m_hWnd, GWLP_WNDPROC , (LONG_PTR)WindowProcNew);
+ m_wndProc = (WNDPROC)SetWindowLongPtr(GetParent()->m_hWnd, GWLP_WNDPROC , (LONG_PTR)WindowProcNew);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void COpenFileDlg::OnDestroy()
{
- int i = GetPathName().Find(__DUMMY__);
- if(i >= 0) m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i+1] = 0;
+ int i = GetPathName().Find(__DUMMY__);
+ if(i >= 0) m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i+1] = 0;
- CFileDialog::OnDestroy();
+ CFileDialog::OnDestroy();
}
BOOL COpenFileDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
- ASSERT(pResult != NULL);
-
- OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
- // allow message map to override
- if(__super::OnNotify(wParam, lParam, pResult))
- {
- ASSERT(pNotify->hdr.code != CDN_INCLUDEITEM);
- return TRUE;
- }
-
- switch(pNotify->hdr.code)
- {
- case CDN_INCLUDEITEM:
- if(OnIncludeItem((OFNOTIFYEX*)lParam, pResult))
- return TRUE;
- break;
- }
-
- return FALSE; // not handled
+ ASSERT(pResult != NULL);
+
+ OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
+ // allow message map to override
+ if (__super::OnNotify(wParam, lParam, pResult))
+ {
+ ASSERT(pNotify->hdr.code != CDN_INCLUDEITEM);
+ return TRUE;
+ }
+
+ switch(pNotify->hdr.code)
+ {
+ case CDN_INCLUDEITEM:
+ if(OnIncludeItem((OFNOTIFYEX*)lParam, pResult))
+ return TRUE;
+ break;
+ }
+
+ return FALSE; // not handled
}
BOOL COpenFileDlg::OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult)
{
- TCHAR buff[_MAX_PATH];
- if(!SHGetPathFromIDList((LPCITEMIDLIST)pOFNEx->pidl, buff))
- {
- STRRET s;
- HRESULT hr = ((IShellFolder*)pOFNEx->psf)->GetDisplayNameOf((LPCITEMIDLIST)pOFNEx->pidl, SHGDN_NORMAL | SHGDN_FORPARSING, &s);
- if(S_OK != hr) return FALSE;
- switch(s.uType)
- {
- case STRRET_CSTR:
- _tcscpy(buff, CString(s.cStr));
- break;
- case STRRET_WSTR:
- _tcscpy(buff, CString(s.pOleStr));
- CoTaskMemFree(s.pOleStr);
- break;
- default:
- return FALSE;
- }
- }
-
- CString fn(buff);
- /*
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if(GetFileAttributesEx(fn, GetFileExInfoStandard, &fad)
- && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
- return FALSE;
- */
- int i = fn.ReverseFind('.'), j = fn.ReverseFind('\\');
- if(i < 0 || i < j)
- return FALSE;
-
- CString mask = m_mask[pOFNEx->lpOFN->nFilterIndex-1] + _T(";");
- CString ext = fn.Mid(i).MakeLower() + _T(";");
-
- *pResult = mask.Find(ext) >= 0 || mask.Find(_T("*.*")) >= 0;
-
- return TRUE;
+ TCHAR buff[_MAX_PATH];
+ if(!SHGetPathFromIDList((LPCITEMIDLIST)pOFNEx->pidl, buff))
+ {
+ STRRET s;
+ HRESULT hr = ((IShellFolder*)pOFNEx->psf)->GetDisplayNameOf((LPCITEMIDLIST)pOFNEx->pidl, SHGDN_NORMAL|SHGDN_FORPARSING, &s);
+ if(S_OK != hr) return FALSE;
+ switch(s.uType)
+ {
+ case STRRET_CSTR: _tcscpy(buff, CString(s.cStr)); break;
+ case STRRET_WSTR: _tcscpy(buff, CString(s.pOleStr)); CoTaskMemFree(s.pOleStr); break;
+ default: return FALSE;
+ }
+ }
+
+ CString fn(buff);
+/*
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if(GetFileAttributesEx(fn, GetFileExInfoStandard, &fad)
+ && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
+ return FALSE;
+*/
+ int i = fn.ReverseFind('.'), j = fn.ReverseFind('\\');
+ if(i < 0 || i < j)
+ return FALSE;
+
+ CString mask = m_mask[pOFNEx->lpOFN->nFilterIndex-1] + _T(";");
+ CString ext = fn.Mid(i).MakeLower() + _T(";");
+
+ *pResult = mask.Find(ext) >= 0 || mask.Find(_T("*.*")) >= 0;
+
+ return TRUE;
}
diff --git a/src/apps/mplayerc/OpenFileDlg.h b/src/apps/mplayerc/OpenFileDlg.h
index 0d4989815..2e02d9361 100644
--- a/src/apps/mplayerc/OpenFileDlg.h
+++ b/src/apps/mplayerc/OpenFileDlg.h
@@ -30,32 +30,32 @@
class COpenFileDlg : public CFileDialog
{
- DECLARE_DYNAMIC(COpenFileDlg)
+ DECLARE_DYNAMIC(COpenFileDlg)
private:
- TCHAR* m_buff;
- CAtlArray<CString>& m_mask;
+ TCHAR* m_buff;
+ CAtlArray<CString>& m_mask;
public:
- COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection,
- LPCTSTR lpszDefExt = NULL,
- LPCTSTR lpszFileName = NULL,
- DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- LPCTSTR lpszFilter = NULL,
- CWnd* pParentWnd = NULL);
- virtual ~COpenFileDlg();
+ COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection,
+ LPCTSTR lpszDefExt = NULL,
+ LPCTSTR lpszFileName = NULL,
+ DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ LPCTSTR lpszFilter = NULL,
+ CWnd* pParentWnd = NULL);
+ virtual ~COpenFileDlg();
- static bool m_fAllowDirSelection;
- static WNDPROC m_wndProc;
- static LRESULT CALLBACK WindowProcNew(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
+ static bool m_fAllowDirSelection;
+ static WNDPROC m_wndProc;
+ static LRESULT CALLBACK WindowProcNew(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam);
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
protected:
- DECLARE_MESSAGE_MAP()
- virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
- virtual BOOL OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult);
+ DECLARE_MESSAGE_MAP()
+ virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
+ virtual BOOL OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult);
public:
- afx_msg void OnDestroy();
+ afx_msg void OnDestroy();
};
diff --git a/src/apps/mplayerc/PPageAccelTbl.cpp b/src/apps/mplayerc/PPageAccelTbl.cpp
index 57b3d228a..c1f360300 100644
--- a/src/apps/mplayerc/PPageAccelTbl.cpp
+++ b/src/apps/mplayerc/PPageAccelTbl.cpp
@@ -28,102 +28,102 @@
struct APP_COMMAND
{
- UINT appcmd;
- LPCTSTR cmdname;
+ UINT appcmd;
+ LPCTSTR cmdname;
};
-APP_COMMAND g_CommandList[] =
+APP_COMMAND g_CommandList[] =
{
- {0, _T("")},
- {APPCOMMAND_BROWSER_BACKWARD, _T("BROWSER_BACKWARD")},
- {APPCOMMAND_BROWSER_FORWARD, _T("BROWSER_FORWARD")},
- {APPCOMMAND_BROWSER_REFRESH, _T("BROWSER_REFRESH")},
- {APPCOMMAND_BROWSER_STOP, _T("BROWSER_STOP")},
- {APPCOMMAND_BROWSER_SEARCH, _T("BROWSER_SEARCH")},
- {APPCOMMAND_BROWSER_FAVORITES, _T("BROWSER_FAVORITES")},
- {APPCOMMAND_BROWSER_HOME, _T("BROWSER_HOME")},
- {APPCOMMAND_VOLUME_MUTE, _T("VOLUME_MUTE")},
- {APPCOMMAND_VOLUME_DOWN, _T("VOLUME_DOWN")},
- {APPCOMMAND_VOLUME_UP, _T("VOLUME_UP")},
- {APPCOMMAND_MEDIA_NEXTTRACK, _T("MEDIA_NEXTTRACK")},
- {APPCOMMAND_MEDIA_PREVIOUSTRACK, _T("MEDIA_PREVIOUSTRACK")},
- {APPCOMMAND_MEDIA_STOP, _T("MEDIA_STOP")},
- {APPCOMMAND_MEDIA_PLAY_PAUSE, _T("MEDIA_PLAY_PAUSE")},
- {APPCOMMAND_LAUNCH_MAIL, _T("LAUNCH_MAIL")},
- {APPCOMMAND_LAUNCH_MEDIA_SELECT, _T("LAUNCH_MEDIA_SELECT")},
- {APPCOMMAND_LAUNCH_APP1, _T("LAUNCH_APP1")},
- {APPCOMMAND_LAUNCH_APP2, _T("LAUNCH_APP2")},
- {APPCOMMAND_BASS_DOWN, _T("BASS_DOWN")},
- {APPCOMMAND_BASS_BOOST, _T("BASS_BOOST")},
- {APPCOMMAND_BASS_UP, _T("BASS_UP")},
- {APPCOMMAND_TREBLE_DOWN, _T("TREBLE_DOWN")},
- {APPCOMMAND_TREBLE_UP, _T("TREBLE_UP")},
- {APPCOMMAND_MICROPHONE_VOLUME_MUTE, _T("MICROPHONE_VOLUME_MUTE")},
- {APPCOMMAND_MICROPHONE_VOLUME_DOWN, _T("MICROPHONE_VOLUME_DOWN")},
- {APPCOMMAND_MICROPHONE_VOLUME_UP, _T("MICROPHONE_VOLUME_UP")},
- {APPCOMMAND_HELP, _T("HELP")},
- {APPCOMMAND_FIND, _T("FIND")},
- {APPCOMMAND_NEW, _T("NEW")},
- {APPCOMMAND_OPEN, _T("OPEN")},
- {APPCOMMAND_CLOSE, _T("CLOSE")},
- {APPCOMMAND_SAVE, _T("SAVE")},
- {APPCOMMAND_PRINT, _T("PRINT")},
- {APPCOMMAND_UNDO, _T("UNDO")},
- {APPCOMMAND_REDO, _T("REDO")},
- {APPCOMMAND_COPY, _T("COPY")},
- {APPCOMMAND_CUT, _T("CUT")},
- {APPCOMMAND_PASTE, _T("PASTE")},
- {APPCOMMAND_REPLY_TO_MAIL, _T("REPLY_TO_MAIL")},
- {APPCOMMAND_FORWARD_MAIL, _T("FORWARD_MAIL")},
- {APPCOMMAND_SEND_MAIL, _T("SEND_MAIL")},
- {APPCOMMAND_SPELL_CHECK, _T("SPELL_CHECK")},
- {APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE, _T("DICTATE_OR_COMMAND_CONTROL_TOGGLE")},
- {APPCOMMAND_MIC_ON_OFF_TOGGLE, _T("MIC_ON_OFF_TOGGLE")},
- {APPCOMMAND_CORRECTION_LIST, _T("CORRECTION_LIST")},
- {APPCOMMAND_MEDIA_PLAY, _T("MEDIA_PLAY")},
- {APPCOMMAND_MEDIA_PAUSE, _T("MEDIA_PAUSE")},
- {APPCOMMAND_MEDIA_RECORD, _T("MEDIA_RECORD")},
- {APPCOMMAND_MEDIA_FAST_FORWARD, _T("MEDIA_FAST_FORWARD")},
- {APPCOMMAND_MEDIA_REWIND, _T("MEDIA_REWIND")},
- {APPCOMMAND_MEDIA_CHANNEL_UP, _T("MEDIA_CHANNEL_UP")},
- {APPCOMMAND_MEDIA_CHANNEL_DOWN, _T("MEDIA_CHANNEL_DOWN")},
- {APPCOMMAND_DELETE, _T("DELETE")},
- {APPCOMMAND_DWM_FLIP3D, _T("DWM_FLIP3D")},
- {MCE_DETAILS, _T("MCE_DETAILS")},
- {MCE_GUIDE, _T("MCE_GUIDE")},
- {MCE_TVJUMP, _T("MCE_TVJUMP")},
- {MCE_STANDBY, _T("MCE_STANDBY")},
- {MCE_OEM1, _T("MCE_OEM1")},
- {MCE_OEM2, _T("MCE_OEM2")},
- {MCE_MYTV, _T("MCE_MYTV")},
- {MCE_MYVIDEOS, _T("MCE_MYVIDEOS")},
- {MCE_MYPICTURES, _T("MCE_MYPICTURES")},
- {MCE_MYMUSIC, _T("MCE_MYMUSIC")},
- {MCE_RECORDEDTV, _T("MCE_RECORDEDTV")},
- {MCE_DVDANGLE, _T("MCE_DVDANGLE")},
- {MCE_DVDAUDIO, _T("MCE_DVDAUDIO")},
- {MCE_DVDMENU, _T("MCE_DVDMENU")},
- {MCE_DVDSUBTITLE, _T("MCE_DVDSUBTITLE")},
- {MCE_RED, _T("MCE_RED")},
- {MCE_GREEN, _T("MCE_GREEN")},
- {MCE_YELLOW, _T("MCE_YELLOW")},
- {MCE_BLUE, _T("MCE_BLUE")},
- {MCE_MEDIA_NEXTTRACK, _T("MCE_MEDIA_NEXTTRACK")},
- {MCE_MEDIA_PREVIOUSTRACK, _T("MCE_MEDIA_PREVIOUSTRACK")}
+ {0, _T("")},
+ {APPCOMMAND_BROWSER_BACKWARD, _T("BROWSER_BACKWARD")},
+ {APPCOMMAND_BROWSER_FORWARD, _T("BROWSER_FORWARD")},
+ {APPCOMMAND_BROWSER_REFRESH, _T("BROWSER_REFRESH")},
+ {APPCOMMAND_BROWSER_STOP, _T("BROWSER_STOP")},
+ {APPCOMMAND_BROWSER_SEARCH, _T("BROWSER_SEARCH")},
+ {APPCOMMAND_BROWSER_FAVORITES, _T("BROWSER_FAVORITES")},
+ {APPCOMMAND_BROWSER_HOME, _T("BROWSER_HOME")},
+ {APPCOMMAND_VOLUME_MUTE, _T("VOLUME_MUTE")},
+ {APPCOMMAND_VOLUME_DOWN, _T("VOLUME_DOWN")},
+ {APPCOMMAND_VOLUME_UP, _T("VOLUME_UP")},
+ {APPCOMMAND_MEDIA_NEXTTRACK, _T("MEDIA_NEXTTRACK")},
+ {APPCOMMAND_MEDIA_PREVIOUSTRACK, _T("MEDIA_PREVIOUSTRACK")},
+ {APPCOMMAND_MEDIA_STOP, _T("MEDIA_STOP")},
+ {APPCOMMAND_MEDIA_PLAY_PAUSE, _T("MEDIA_PLAY_PAUSE")},
+ {APPCOMMAND_LAUNCH_MAIL, _T("LAUNCH_MAIL")},
+ {APPCOMMAND_LAUNCH_MEDIA_SELECT, _T("LAUNCH_MEDIA_SELECT")},
+ {APPCOMMAND_LAUNCH_APP1, _T("LAUNCH_APP1")},
+ {APPCOMMAND_LAUNCH_APP2, _T("LAUNCH_APP2")},
+ {APPCOMMAND_BASS_DOWN, _T("BASS_DOWN")},
+ {APPCOMMAND_BASS_BOOST, _T("BASS_BOOST")},
+ {APPCOMMAND_BASS_UP, _T("BASS_UP")},
+ {APPCOMMAND_TREBLE_DOWN, _T("TREBLE_DOWN")},
+ {APPCOMMAND_TREBLE_UP, _T("TREBLE_UP")},
+ {APPCOMMAND_MICROPHONE_VOLUME_MUTE, _T("MICROPHONE_VOLUME_MUTE")},
+ {APPCOMMAND_MICROPHONE_VOLUME_DOWN, _T("MICROPHONE_VOLUME_DOWN")},
+ {APPCOMMAND_MICROPHONE_VOLUME_UP, _T("MICROPHONE_VOLUME_UP")},
+ {APPCOMMAND_HELP, _T("HELP")},
+ {APPCOMMAND_FIND, _T("FIND")},
+ {APPCOMMAND_NEW, _T("NEW")},
+ {APPCOMMAND_OPEN, _T("OPEN")},
+ {APPCOMMAND_CLOSE, _T("CLOSE")},
+ {APPCOMMAND_SAVE, _T("SAVE")},
+ {APPCOMMAND_PRINT, _T("PRINT")},
+ {APPCOMMAND_UNDO, _T("UNDO")},
+ {APPCOMMAND_REDO, _T("REDO")},
+ {APPCOMMAND_COPY, _T("COPY")},
+ {APPCOMMAND_CUT, _T("CUT")},
+ {APPCOMMAND_PASTE, _T("PASTE")},
+ {APPCOMMAND_REPLY_TO_MAIL, _T("REPLY_TO_MAIL")},
+ {APPCOMMAND_FORWARD_MAIL, _T("FORWARD_MAIL")},
+ {APPCOMMAND_SEND_MAIL, _T("SEND_MAIL")},
+ {APPCOMMAND_SPELL_CHECK, _T("SPELL_CHECK")},
+ {APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE, _T("DICTATE_OR_COMMAND_CONTROL_TOGGLE")},
+ {APPCOMMAND_MIC_ON_OFF_TOGGLE, _T("MIC_ON_OFF_TOGGLE")},
+ {APPCOMMAND_CORRECTION_LIST, _T("CORRECTION_LIST")},
+ {APPCOMMAND_MEDIA_PLAY, _T("MEDIA_PLAY")},
+ {APPCOMMAND_MEDIA_PAUSE, _T("MEDIA_PAUSE")},
+ {APPCOMMAND_MEDIA_RECORD, _T("MEDIA_RECORD")},
+ {APPCOMMAND_MEDIA_FAST_FORWARD, _T("MEDIA_FAST_FORWARD")},
+ {APPCOMMAND_MEDIA_REWIND, _T("MEDIA_REWIND")},
+ {APPCOMMAND_MEDIA_CHANNEL_UP, _T("MEDIA_CHANNEL_UP")},
+ {APPCOMMAND_MEDIA_CHANNEL_DOWN, _T("MEDIA_CHANNEL_DOWN")},
+ {APPCOMMAND_DELETE, _T("DELETE")},
+ {APPCOMMAND_DWM_FLIP3D, _T("DWM_FLIP3D")},
+ {MCE_DETAILS, _T("MCE_DETAILS")},
+ {MCE_GUIDE, _T("MCE_GUIDE")},
+ {MCE_TVJUMP, _T("MCE_TVJUMP")},
+ {MCE_STANDBY, _T("MCE_STANDBY")},
+ {MCE_OEM1, _T("MCE_OEM1")},
+ {MCE_OEM2, _T("MCE_OEM2")},
+ {MCE_MYTV, _T("MCE_MYTV")},
+ {MCE_MYVIDEOS, _T("MCE_MYVIDEOS")},
+ {MCE_MYPICTURES, _T("MCE_MYPICTURES")},
+ {MCE_MYMUSIC, _T("MCE_MYMUSIC")},
+ {MCE_RECORDEDTV, _T("MCE_RECORDEDTV")},
+ {MCE_DVDANGLE, _T("MCE_DVDANGLE")},
+ {MCE_DVDAUDIO, _T("MCE_DVDAUDIO")},
+ {MCE_DVDMENU, _T("MCE_DVDMENU")},
+ {MCE_DVDSUBTITLE, _T("MCE_DVDSUBTITLE")},
+ {MCE_RED, _T("MCE_RED")},
+ {MCE_GREEN, _T("MCE_GREEN")},
+ {MCE_YELLOW, _T("MCE_YELLOW")},
+ {MCE_BLUE, _T("MCE_BLUE")},
+ {MCE_MEDIA_NEXTTRACK, _T("MCE_MEDIA_NEXTTRACK")},
+ {MCE_MEDIA_PREVIOUSTRACK, _T("MCE_MEDIA_PREVIOUSTRACK")}
};
// CPPageAccelTbl dialog
IMPLEMENT_DYNAMIC(CPPageAccelTbl, CPPageBase)
CPPageAccelTbl::CPPageAccelTbl()
- : CPPageBase(CPPageAccelTbl::IDD, CPPageAccelTbl::IDD)
- , m_list(0)
- , m_counter(0)
- , m_fWinLirc(FALSE)
- , m_WinLircLink(_T("http://winlirc.sourceforge.net/"))
- , m_fUIce(FALSE)
- , m_UIceLink(_T("http://www.mediatexx.com/"))
- , m_fGlobalMedia(FALSE)
+ : CPPageBase(CPPageAccelTbl::IDD, CPPageAccelTbl::IDD)
+ , m_list(0)
+ , m_counter(0)
+ , m_fWinLirc(FALSE)
+ , m_WinLircLink(_T("http://winlirc.sourceforge.net/"))
+ , m_fUIce(FALSE)
+ , m_UIceLink(_T("http://www.mediatexx.com/"))
+ , m_fGlobalMedia(FALSE)
{
}
@@ -133,1539 +133,866 @@ CPPageAccelTbl::~CPPageAccelTbl()
BOOL CPPageAccelTbl::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
- && (pMsg->hwnd == m_WinLircEdit.m_hWnd || pMsg->hwnd == m_UIceEdit.m_hWnd))
- {
- OnApply();
- return TRUE;
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
+ && (pMsg->hwnd == m_WinLircEdit.m_hWnd || pMsg->hwnd == m_UIceEdit.m_hWnd))
+ {
+ OnApply();
+ return TRUE;
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
void CPPageAccelTbl::SetupList()
{
- for(int row = 0; row < m_list.GetItemCount(); row++)
- {
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(row));
+ for(int row = 0; row < m_list.GetItemCount(); row++)
+ {
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(row));
- CString mod = MakeAccelModLabel(wc.fVirt);
- m_list.SetItemText(row, COL_MOD, mod);
+ CString mod = MakeAccelModLabel(wc.fVirt);
+ m_list.SetItemText(row, COL_MOD, mod);
- CString key = MakeAccelVkeyLabel(wc.key, wc.fVirt & FVIRTKEY);
- m_list.SetItemText(row, COL_KEY, key);
+ CString key = MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY);
+ m_list.SetItemText(row, COL_KEY, key);
- CString type = (wc.fVirt & FVIRTKEY) ? _T("VIRTKEY") : _T("ASCII");
- m_list.SetItemText(row, COL_TYPE, type);
+ CString type = (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII");
+ m_list.SetItemText(row, COL_TYPE, type);
- CString id;
- id.Format(_T("%d"), wc.cmd);
- m_list.SetItemText(row, COL_ID, id);
+ CString id;
+ id.Format(_T("%d"), wc.cmd);
+ m_list.SetItemText(row, COL_ID, id);
- m_list.SetItemText(row, COL_MOUSE, MakeMouseButtonLabel(wc.mouse));
+ m_list.SetItemText(row, COL_MOUSE, MakeMouseButtonLabel(wc.mouse));
- m_list.SetItemText(row, COL_APPCMD, MakeAppCommandLabel(wc.appcmd));
+ m_list.SetItemText(row, COL_APPCMD, MakeAppCommandLabel(wc.appcmd));
- m_list.SetItemText(row, COL_RMCMD, CString(wc.rmcmd));
+ m_list.SetItemText(row, COL_RMCMD, CString(wc.rmcmd));
- CString repcnt;
- repcnt.Format(_T("%d"), wc.rmrepcnt);
- m_list.SetItemText(row, COL_RMREPCNT, repcnt);
- }
+ CString repcnt;
+ repcnt.Format(_T("%d"), wc.rmrepcnt);
+ m_list.SetItemText(row, COL_RMREPCNT, repcnt);
+ }
}
CString CPPageAccelTbl::MakeAccelModLabel(BYTE fVirt)
{
- CString str;
- if(fVirt & FCONTROL)
- {
- if(!str.IsEmpty()) str += _T(" + ");
- str += _T("Ctrl");
- }
- if(fVirt & FALT)
- {
- if(!str.IsEmpty()) str += _T(" + ");
- str += _T("Alt");
- }
- if(fVirt & FSHIFT)
- {
- if(!str.IsEmpty()) str += _T(" + ");
- str += _T("Shift");
- }
- if(str.IsEmpty()) str = ResStr(IDS_AG_NONE);
- return(str);
+ CString str;
+ if(fVirt&FCONTROL) {if(!str.IsEmpty()) str += _T(" + "); str += _T("Ctrl");}
+ if(fVirt&FALT) {if(!str.IsEmpty()) str += _T(" + "); str += _T("Alt");}
+ if(fVirt&FSHIFT) {if(!str.IsEmpty()) str += _T(" + "); str += _T("Shift");}
+ if(str.IsEmpty()) str = ResStr(IDS_AG_NONE);
+ return(str);
}
CString CPPageAccelTbl::MakeAccelVkeyLabel(WORD key, bool fVirtKey)
{
- CString str;
-
- if(fVirtKey)
- switch(key)
- {
- case VK_LBUTTON:
- str = _T("VK_LBUTTON");
- break;
- case VK_RBUTTON:
- str = _T("VK_RBUTTON");
- break;
- case VK_CANCEL:
- str = _T("VK_CANCEL");
- break;
- case VK_MBUTTON:
- str = _T("VK_MBUTTON");
- break;
- case VK_XBUTTON1:
- str = _T("VK_XBUTTON1");
- break;
- case VK_XBUTTON2:
- str = _T("VK_XBUTTON2");
- break;
- case VK_BACK:
- str = _T("VK_BACK");
- break;
- case VK_TAB:
- str = _T("VK_TAB");
- break;
- case VK_CLEAR:
- str = _T("VK_CLEAR");
- break;
- case VK_RETURN:
- str = _T("VK_RETURN");
- break;
- case VK_SHIFT:
- str = _T("VK_SHIFT");
- break;
- case VK_CONTROL:
- str = _T("VK_CONTROL");
- break;
- case VK_MENU:
- str = _T("VK_MENU");
- break;
- case VK_PAUSE:
- str = _T("VK_PAUSE");
- break;
- case VK_CAPITAL:
- str = _T("VK_CAPITAL");
- break;
+ CString str;
+
+ if(fVirtKey)
+ switch(key)
+ {
+ case VK_LBUTTON: str = _T("VK_LBUTTON"); break;
+ case VK_RBUTTON: str = _T("VK_RBUTTON"); break;
+ case VK_CANCEL: str = _T("VK_CANCEL"); break;
+ case VK_MBUTTON: str = _T("VK_MBUTTON"); break;
+ case VK_XBUTTON1: str = _T("VK_XBUTTON1"); break;
+ case VK_XBUTTON2: str = _T("VK_XBUTTON2"); break;
+ case VK_BACK: str = _T("VK_BACK"); break;
+ case VK_TAB: str = _T("VK_TAB"); break;
+ case VK_CLEAR: str = _T("VK_CLEAR"); break;
+ case VK_RETURN: str = _T("VK_RETURN"); break;
+ case VK_SHIFT: str = _T("VK_SHIFT"); break;
+ case VK_CONTROL: str = _T("VK_CONTROL"); break;
+ case VK_MENU: str = _T("VK_MENU"); break;
+ case VK_PAUSE: str = _T("VK_PAUSE"); break;
+ case VK_CAPITAL: str = _T("VK_CAPITAL"); break;
// case VK_KANA: str = _T("VK_KANA"); break;
// case VK_HANGEUL: str = _T("VK_HANGEUL"); break;
- case VK_HANGUL:
- str = _T("VK_HANGUL");
- break;
- case VK_JUNJA:
- str = _T("VK_JUNJA");
- break;
- case VK_FINAL:
- str = _T("VK_FINAL");
- break;
+ case VK_HANGUL: str = _T("VK_HANGUL"); break;
+ case VK_JUNJA: str = _T("VK_JUNJA"); break;
+ case VK_FINAL: str = _T("VK_FINAL"); break;
// case VK_HANJA: str = _T("VK_HANJA"); break;
- case VK_KANJI:
- str = _T("VK_KANJI");
- break;
- case VK_ESCAPE:
- str = _T("VK_ESCAPE");
- break;
- case VK_CONVERT:
- str = _T("VK_CONVERT");
- break;
- case VK_NONCONVERT:
- str = _T("VK_NONCONVERT");
- break;
- case VK_ACCEPT:
- str = _T("VK_ACCEPT");
- break;
- case VK_MODECHANGE:
- str = _T("VK_MODECHANGE");
- break;
- case VK_SPACE:
- str = _T("VK_SPACE");
- break;
- case VK_PRIOR:
- str = _T("VK_PRIOR");
- break;
- case VK_NEXT:
- str = _T("VK_NEXT");
- break;
- case VK_END:
- str = _T("VK_END");
- break;
- case VK_HOME:
- str = _T("VK_HOME");
- break;
- case VK_LEFT:
- str = _T("VK_LEFT");
- break;
- case VK_UP:
- str = _T("VK_UP");
- break;
- case VK_RIGHT:
- str = _T("VK_RIGHT");
- break;
- case VK_DOWN:
- str = _T("VK_DOWN");
- break;
- case VK_SELECT:
- str = _T("VK_SELECT");
- break;
- case VK_PRINT:
- str = _T("VK_PRINT");
- break;
- case VK_EXECUTE:
- str = _T("VK_EXECUTE");
- break;
- case VK_SNAPSHOT:
- str = _T("VK_SNAPSHOT");
- break;
- case VK_INSERT:
- str = _T("VK_INSERT");
- break;
- case VK_DELETE:
- str = _T("VK_DELETE");
- break;
- case VK_HELP:
- str = _T("VK_HELP");
- break;
- case VK_LWIN:
- str = _T("VK_LWIN");
- break;
- case VK_RWIN:
- str = _T("VK_RWIN");
- break;
- case VK_APPS:
- str = _T("VK_APPS");
- break;
- case VK_SLEEP:
- str = _T("VK_SLEEP");
- break;
- case VK_NUMPAD0:
- str = _T("VK_NUMPAD0");
- break;
- case VK_NUMPAD1:
- str = _T("VK_NUMPAD1");
- break;
- case VK_NUMPAD2:
- str = _T("VK_NUMPAD2");
- break;
- case VK_NUMPAD3:
- str = _T("VK_NUMPAD3");
- break;
- case VK_NUMPAD4:
- str = _T("VK_NUMPAD4");
- break;
- case VK_NUMPAD5:
- str = _T("VK_NUMPAD5");
- break;
- case VK_NUMPAD6:
- str = _T("VK_NUMPAD6");
- break;
- case VK_NUMPAD7:
- str = _T("VK_NUMPAD7");
- break;
- case VK_NUMPAD8:
- str = _T("VK_NUMPAD8");
- break;
- case VK_NUMPAD9:
- str = _T("VK_NUMPAD9");
- break;
- case VK_MULTIPLY:
- str = _T("VK_MULTIPLY");
- break;
- case VK_ADD:
- str = _T("VK_ADD");
- break;
- case VK_SEPARATOR:
- str = _T("VK_SEPARATOR");
- break;
- case VK_SUBTRACT:
- str = _T("VK_SUBTRACT");
- break;
- case VK_DECIMAL:
- str = _T("VK_DECIMAL");
- break;
- case VK_DIVIDE:
- str = _T("VK_DIVIDE");
- break;
- case VK_F1:
- str = _T("VK_F1");
- break;
- case VK_F2:
- str = _T("VK_F2");
- break;
- case VK_F3:
- str = _T("VK_F3");
- break;
- case VK_F4:
- str = _T("VK_F4");
- break;
- case VK_F5:
- str = _T("VK_F5");
- break;
- case VK_F6:
- str = _T("VK_F6");
- break;
- case VK_F7:
- str = _T("VK_F7");
- break;
- case VK_F8:
- str = _T("VK_F8");
- break;
- case VK_F9:
- str = _T("VK_F9");
- break;
- case VK_F10:
- str = _T("VK_F10");
- break;
- case VK_F11:
- str = _T("VK_F11");
- break;
- case VK_F12:
- str = _T("VK_F12");
- break;
- case VK_F13:
- str = _T("VK_F13");
- break;
- case VK_F14:
- str = _T("VK_F14");
- break;
- case VK_F15:
- str = _T("VK_F15");
- break;
- case VK_F16:
- str = _T("VK_F16");
- break;
- case VK_F17:
- str = _T("VK_F17");
- break;
- case VK_F18:
- str = _T("VK_F18");
- break;
- case VK_F19:
- str = _T("VK_F19");
- break;
- case VK_F20:
- str = _T("VK_F20");
- break;
- case VK_F21:
- str = _T("VK_F21");
- break;
- case VK_F22:
- str = _T("VK_F22");
- break;
- case VK_F23:
- str = _T("VK_F23");
- break;
- case VK_F24:
- str = _T("VK_F24");
- break;
- case VK_NUMLOCK:
- str = _T("VK_NUMLOCK");
- break;
- case VK_SCROLL:
- str = _T("VK_SCROLL");
- break;
+ case VK_KANJI: str = _T("VK_KANJI"); break;
+ case VK_ESCAPE: str = _T("VK_ESCAPE"); break;
+ case VK_CONVERT: str = _T("VK_CONVERT"); break;
+ case VK_NONCONVERT: str = _T("VK_NONCONVERT"); break;
+ case VK_ACCEPT: str = _T("VK_ACCEPT"); break;
+ case VK_MODECHANGE: str = _T("VK_MODECHANGE"); break;
+ case VK_SPACE: str = _T("VK_SPACE"); break;
+ case VK_PRIOR: str = _T("VK_PRIOR"); break;
+ case VK_NEXT: str = _T("VK_NEXT"); break;
+ case VK_END: str = _T("VK_END"); break;
+ case VK_HOME: str = _T("VK_HOME"); break;
+ case VK_LEFT: str = _T("VK_LEFT"); break;
+ case VK_UP: str = _T("VK_UP"); break;
+ case VK_RIGHT: str = _T("VK_RIGHT"); break;
+ case VK_DOWN: str = _T("VK_DOWN"); break;
+ case VK_SELECT: str = _T("VK_SELECT"); break;
+ case VK_PRINT: str = _T("VK_PRINT"); break;
+ case VK_EXECUTE: str = _T("VK_EXECUTE"); break;
+ case VK_SNAPSHOT: str = _T("VK_SNAPSHOT"); break;
+ case VK_INSERT: str = _T("VK_INSERT"); break;
+ case VK_DELETE: str = _T("VK_DELETE"); break;
+ case VK_HELP: str = _T("VK_HELP"); break;
+ case VK_LWIN: str = _T("VK_LWIN"); break;
+ case VK_RWIN: str = _T("VK_RWIN"); break;
+ case VK_APPS: str = _T("VK_APPS"); break;
+ case VK_SLEEP: str = _T("VK_SLEEP"); break;
+ case VK_NUMPAD0: str = _T("VK_NUMPAD0"); break;
+ case VK_NUMPAD1: str = _T("VK_NUMPAD1"); break;
+ case VK_NUMPAD2: str = _T("VK_NUMPAD2"); break;
+ case VK_NUMPAD3: str = _T("VK_NUMPAD3"); break;
+ case VK_NUMPAD4: str = _T("VK_NUMPAD4"); break;
+ case VK_NUMPAD5: str = _T("VK_NUMPAD5"); break;
+ case VK_NUMPAD6: str = _T("VK_NUMPAD6"); break;
+ case VK_NUMPAD7: str = _T("VK_NUMPAD7"); break;
+ case VK_NUMPAD8: str = _T("VK_NUMPAD8"); break;
+ case VK_NUMPAD9: str = _T("VK_NUMPAD9"); break;
+ case VK_MULTIPLY: str = _T("VK_MULTIPLY"); break;
+ case VK_ADD: str = _T("VK_ADD"); break;
+ case VK_SEPARATOR: str = _T("VK_SEPARATOR"); break;
+ case VK_SUBTRACT: str = _T("VK_SUBTRACT"); break;
+ case VK_DECIMAL: str = _T("VK_DECIMAL"); break;
+ case VK_DIVIDE: str = _T("VK_DIVIDE"); break;
+ case VK_F1: str = _T("VK_F1"); break;
+ case VK_F2: str = _T("VK_F2"); break;
+ case VK_F3: str = _T("VK_F3"); break;
+ case VK_F4: str = _T("VK_F4"); break;
+ case VK_F5: str = _T("VK_F5"); break;
+ case VK_F6: str = _T("VK_F6"); break;
+ case VK_F7: str = _T("VK_F7"); break;
+ case VK_F8: str = _T("VK_F8"); break;
+ case VK_F9: str = _T("VK_F9"); break;
+ case VK_F10: str = _T("VK_F10"); break;
+ case VK_F11: str = _T("VK_F11"); break;
+ case VK_F12: str = _T("VK_F12"); break;
+ case VK_F13: str = _T("VK_F13"); break;
+ case VK_F14: str = _T("VK_F14"); break;
+ case VK_F15: str = _T("VK_F15"); break;
+ case VK_F16: str = _T("VK_F16"); break;
+ case VK_F17: str = _T("VK_F17"); break;
+ case VK_F18: str = _T("VK_F18"); break;
+ case VK_F19: str = _T("VK_F19"); break;
+ case VK_F20: str = _T("VK_F20"); break;
+ case VK_F21: str = _T("VK_F21"); break;
+ case VK_F22: str = _T("VK_F22"); break;
+ case VK_F23: str = _T("VK_F23"); break;
+ case VK_F24: str = _T("VK_F24"); break;
+ case VK_NUMLOCK: str = _T("VK_NUMLOCK"); break;
+ case VK_SCROLL: str = _T("VK_SCROLL"); break;
// case VK_OEM_NEC_EQUAL: str = _T("VK_OEM_NEC_EQUAL"); break;
- case VK_OEM_FJ_JISHO:
- str = _T("VK_OEM_FJ_JISHO");
- break;
- case VK_OEM_FJ_MASSHOU:
- str = _T("VK_OEM_FJ_MASSHOU");
- break;
- case VK_OEM_FJ_TOUROKU:
- str = _T("VK_OEM_FJ_TOUROKU");
- break;
- case VK_OEM_FJ_LOYA:
- str = _T("VK_OEM_FJ_LOYA");
- break;
- case VK_OEM_FJ_ROYA:
- str = _T("VK_OEM_FJ_ROYA");
- break;
- case VK_LSHIFT:
- str = _T("VK_LSHIFT");
- break;
- case VK_RSHIFT:
- str = _T("VK_RSHIFT");
- break;
- case VK_LCONTROL:
- str = _T("VK_LCONTROL");
- break;
- case VK_RCONTROL:
- str = _T("VK_RCONTROL");
- break;
- case VK_LMENU:
- str = _T("VK_LMENU");
- break;
- case VK_RMENU:
- str = _T("VK_RMENU");
- break;
- case VK_BROWSER_BACK:
- str = _T("VK_BROWSER_BACK");
- break;
- case VK_BROWSER_FORWARD:
- str = _T("VK_BROWSER_FORWARD");
- break;
- case VK_BROWSER_REFRESH:
- str = _T("VK_BROWSER_REFRESH");
- break;
- case VK_BROWSER_STOP:
- str = _T("VK_BROWSER_STOP");
- break;
- case VK_BROWSER_SEARCH:
- str = _T("VK_BROWSER_SEARCH");
- break;
- case VK_BROWSER_FAVORITES:
- str = _T("VK_BROWSER_FAVORITES");
- break;
- case VK_BROWSER_HOME:
- str = _T("VK_BROWSER_HOME");
- break;
- case VK_VOLUME_MUTE:
- str = _T("VK_VOLUME_MUTE");
- break;
- case VK_VOLUME_DOWN:
- str = _T("VK_VOLUME_DOWN");
- break;
- case VK_VOLUME_UP:
- str = _T("VK_VOLUME_UP");
- break;
- case VK_MEDIA_NEXT_TRACK:
- str = _T("VK_MEDIA_NEXT_TRACK");
- break;
- case VK_MEDIA_PREV_TRACK:
- str = _T("VK_MEDIA_PREV_TRACK");
- break;
- case VK_MEDIA_STOP:
- str = _T("VK_MEDIA_STOP");
- break;
- case VK_MEDIA_PLAY_PAUSE:
- str = _T("VK_MEDIA_PLAY_PAUSE");
- break;
- case VK_LAUNCH_MAIL:
- str = _T("VK_LAUNCH_MAIL");
- break;
- case VK_LAUNCH_MEDIA_SELECT:
- str = _T("VK_LAUNCH_MEDIA_SELECT");
- break;
- case VK_LAUNCH_APP1:
- str = _T("VK_LAUNCH_APP1");
- break;
- case VK_LAUNCH_APP2:
- str = _T("VK_LAUNCH_APP2");
- break;
- case VK_OEM_1:
- str = _T("VK_OEM_1");
- break;
- case VK_OEM_PLUS:
- str = _T("VK_OEM_PLUS");
- break;
- case VK_OEM_COMMA:
- str = _T("VK_OEM_COMMA");
- break;
- case VK_OEM_MINUS:
- str = _T("VK_OEM_MINUS");
- break;
- case VK_OEM_PERIOD:
- str = _T("VK_OEM_PERIOD");
- break;
- case VK_OEM_2:
- str = _T("VK_OEM_2");
- break;
- case VK_OEM_3:
- str = _T("VK_OEM_3");
- break;
- case VK_OEM_4:
- str = _T("VK_OEM_4");
- break;
- case VK_OEM_5:
- str = _T("VK_OEM_5");
- break;
- case VK_OEM_6:
- str = _T("VK_OEM_6");
- break;
- case VK_OEM_7:
- str = _T("VK_OEM_7");
- break;
- case VK_OEM_8:
- str = _T("VK_OEM_8");
- break;
- case VK_OEM_AX:
- str = _T("VK_OEM_AX");
- break;
- case VK_OEM_102:
- str = _T("VK_OEM_102");
- break;
- case VK_ICO_HELP:
- str = _T("VK_ICO_HELP");
- break;
- case VK_ICO_00:
- str = _T("VK_ICO_00");
- break;
- case VK_PROCESSKEY:
- str = _T("VK_PROCESSKEY");
- break;
- case VK_ICO_CLEAR:
- str = _T("VK_ICO_CLEAR");
- break;
- case VK_PACKET:
- str = _T("VK_PACKET");
- break;
- case VK_OEM_RESET:
- str = _T("VK_OEM_RESET");
- break;
- case VK_OEM_JUMP:
- str = _T("VK_OEM_JUMP");
- break;
- case VK_OEM_PA1:
- str = _T("VK_OEM_PA1");
- break;
- case VK_OEM_PA2:
- str = _T("VK_OEM_PA2");
- break;
- case VK_OEM_PA3:
- str = _T("VK_OEM_PA3");
- break;
- case VK_OEM_WSCTRL:
- str = _T("VK_OEM_WSCTRL");
- break;
- case VK_OEM_CUSEL:
- str = _T("VK_OEM_CUSEL");
- break;
- case VK_OEM_ATTN:
- str = _T("VK_OEM_ATTN");
- break;
- case VK_OEM_FINISH:
- str = _T("VK_OEM_FINISH");
- break;
- case VK_OEM_COPY:
- str = _T("VK_OEM_COPY");
- break;
- case VK_OEM_AUTO:
- str = _T("VK_OEM_AUTO");
- break;
- case VK_OEM_ENLW:
- str = _T("VK_OEM_ENLW");
- break;
- case VK_OEM_BACKTAB:
- str = _T("VK_OEM_BACKTAB");
- break;
- case VK_ATTN:
- str = _T("VK_ATTN");
- break;
- case VK_CRSEL:
- str = _T("VK_CRSEL");
- break;
- case VK_EXSEL:
- str = _T("VK_EXSEL");
- break;
- case VK_EREOF:
- str = _T("VK_EREOF");
- break;
- case VK_PLAY:
- str = _T("VK_PLAY");
- break;
- case VK_ZOOM:
- str = _T("VK_ZOOM");
- break;
- case VK_NONAME:
- str = _T("VK_NONAME");
- break;
- case VK_PA1:
- str = _T("VK_PA1");
- break;
- case VK_OEM_CLEAR:
- str = _T("VK_OEM_CLEAR");
- break;
- default:
- if('0' <= key && key <= '9' || 'A' <= key && key <= 'Z')
- str.Format(_T("%c"), (TCHAR)key);
- break;
- }
-
- if(str.IsEmpty() || !fVirtKey)
- {
- str.Format(_T("%c, 0x%02x"), (TCHAR)key, key);
- return(str);
- }
-
- return(str);
+ case VK_OEM_FJ_JISHO: str = _T("VK_OEM_FJ_JISHO"); break;
+ case VK_OEM_FJ_MASSHOU: str = _T("VK_OEM_FJ_MASSHOU"); break;
+ case VK_OEM_FJ_TOUROKU: str = _T("VK_OEM_FJ_TOUROKU"); break;
+ case VK_OEM_FJ_LOYA: str = _T("VK_OEM_FJ_LOYA"); break;
+ case VK_OEM_FJ_ROYA: str = _T("VK_OEM_FJ_ROYA"); break;
+ case VK_LSHIFT: str = _T("VK_LSHIFT"); break;
+ case VK_RSHIFT: str = _T("VK_RSHIFT"); break;
+ case VK_LCONTROL: str = _T("VK_LCONTROL"); break;
+ case VK_RCONTROL: str = _T("VK_RCONTROL"); break;
+ case VK_LMENU: str = _T("VK_LMENU"); break;
+ case VK_RMENU: str = _T("VK_RMENU"); break;
+ case VK_BROWSER_BACK: str = _T("VK_BROWSER_BACK"); break;
+ case VK_BROWSER_FORWARD: str = _T("VK_BROWSER_FORWARD"); break;
+ case VK_BROWSER_REFRESH: str = _T("VK_BROWSER_REFRESH"); break;
+ case VK_BROWSER_STOP: str = _T("VK_BROWSER_STOP"); break;
+ case VK_BROWSER_SEARCH: str = _T("VK_BROWSER_SEARCH"); break;
+ case VK_BROWSER_FAVORITES: str = _T("VK_BROWSER_FAVORITES"); break;
+ case VK_BROWSER_HOME: str = _T("VK_BROWSER_HOME"); break;
+ case VK_VOLUME_MUTE: str = _T("VK_VOLUME_MUTE"); break;
+ case VK_VOLUME_DOWN: str = _T("VK_VOLUME_DOWN"); break;
+ case VK_VOLUME_UP: str = _T("VK_VOLUME_UP"); break;
+ case VK_MEDIA_NEXT_TRACK: str = _T("VK_MEDIA_NEXT_TRACK"); break;
+ case VK_MEDIA_PREV_TRACK: str = _T("VK_MEDIA_PREV_TRACK"); break;
+ case VK_MEDIA_STOP: str = _T("VK_MEDIA_STOP"); break;
+ case VK_MEDIA_PLAY_PAUSE: str = _T("VK_MEDIA_PLAY_PAUSE"); break;
+ case VK_LAUNCH_MAIL: str = _T("VK_LAUNCH_MAIL"); break;
+ case VK_LAUNCH_MEDIA_SELECT: str = _T("VK_LAUNCH_MEDIA_SELECT"); break;
+ case VK_LAUNCH_APP1: str = _T("VK_LAUNCH_APP1"); break;
+ case VK_LAUNCH_APP2: str = _T("VK_LAUNCH_APP2"); break;
+ case VK_OEM_1: str = _T("VK_OEM_1"); break;
+ case VK_OEM_PLUS: str = _T("VK_OEM_PLUS"); break;
+ case VK_OEM_COMMA: str = _T("VK_OEM_COMMA"); break;
+ case VK_OEM_MINUS: str = _T("VK_OEM_MINUS"); break;
+ case VK_OEM_PERIOD: str = _T("VK_OEM_PERIOD"); break;
+ case VK_OEM_2: str = _T("VK_OEM_2"); break;
+ case VK_OEM_3: str = _T("VK_OEM_3"); break;
+ case VK_OEM_4: str = _T("VK_OEM_4"); break;
+ case VK_OEM_5: str = _T("VK_OEM_5"); break;
+ case VK_OEM_6: str = _T("VK_OEM_6"); break;
+ case VK_OEM_7: str = _T("VK_OEM_7"); break;
+ case VK_OEM_8: str = _T("VK_OEM_8"); break;
+ case VK_OEM_AX: str = _T("VK_OEM_AX"); break;
+ case VK_OEM_102: str = _T("VK_OEM_102"); break;
+ case VK_ICO_HELP: str = _T("VK_ICO_HELP"); break;
+ case VK_ICO_00: str = _T("VK_ICO_00"); break;
+ case VK_PROCESSKEY: str = _T("VK_PROCESSKEY"); break;
+ case VK_ICO_CLEAR: str = _T("VK_ICO_CLEAR"); break;
+ case VK_PACKET: str = _T("VK_PACKET"); break;
+ case VK_OEM_RESET: str = _T("VK_OEM_RESET"); break;
+ case VK_OEM_JUMP: str = _T("VK_OEM_JUMP"); break;
+ case VK_OEM_PA1: str = _T("VK_OEM_PA1"); break;
+ case VK_OEM_PA2: str = _T("VK_OEM_PA2"); break;
+ case VK_OEM_PA3: str = _T("VK_OEM_PA3"); break;
+ case VK_OEM_WSCTRL: str = _T("VK_OEM_WSCTRL"); break;
+ case VK_OEM_CUSEL: str = _T("VK_OEM_CUSEL"); break;
+ case VK_OEM_ATTN: str = _T("VK_OEM_ATTN"); break;
+ case VK_OEM_FINISH: str = _T("VK_OEM_FINISH"); break;
+ case VK_OEM_COPY: str = _T("VK_OEM_COPY"); break;
+ case VK_OEM_AUTO: str = _T("VK_OEM_AUTO"); break;
+ case VK_OEM_ENLW: str = _T("VK_OEM_ENLW"); break;
+ case VK_OEM_BACKTAB: str = _T("VK_OEM_BACKTAB"); break;
+ case VK_ATTN: str = _T("VK_ATTN"); break;
+ case VK_CRSEL: str = _T("VK_CRSEL"); break;
+ case VK_EXSEL: str = _T("VK_EXSEL"); break;
+ case VK_EREOF: str = _T("VK_EREOF"); break;
+ case VK_PLAY: str = _T("VK_PLAY"); break;
+ case VK_ZOOM: str = _T("VK_ZOOM"); break;
+ case VK_NONAME: str = _T("VK_NONAME"); break;
+ case VK_PA1: str = _T("VK_PA1"); break;
+ case VK_OEM_CLEAR: str = _T("VK_OEM_CLEAR"); break;
+ default:
+ if('0' <= key && key <= '9' || 'A' <= key && key <= 'Z')
+ str.Format(_T("%c"), (TCHAR)key);
+ break;
+ }
+
+ if(str.IsEmpty() || !fVirtKey)
+ {
+ str.Format(_T("%c, 0x%02x"), (TCHAR)key, key);
+ return(str);
+ }
+
+ return(str);
}
CString CPPageAccelTbl::MakeAccelShortcutLabel(UINT id)
{
- CList<wmcmd>& wmcmds = AfxGetAppSettings().wmcmds;
- POSITION pos = wmcmds.GetHeadPosition();
- while(pos)
- {
- ACCEL& a = wmcmds.GetNext(pos);
- if(a.cmd == id)
- return(MakeAccelShortcutLabel(a));
- }
-
- return(_T(""));
+ CList<wmcmd>& wmcmds = AfxGetAppSettings().wmcmds;
+ POSITION pos = wmcmds.GetHeadPosition();
+ while(pos)
+ {
+ ACCEL& a = wmcmds.GetNext(pos);
+ if(a.cmd == id)
+ return(MakeAccelShortcutLabel(a));
+ }
+
+ return(_T(""));
}
CString CPPageAccelTbl::MakeAccelShortcutLabel(ACCEL& a)
{
- CString str;
-
- if(a.fVirt & 1)
- switch(a.key)
- {
- case VK_LBUTTON:
- str = _T("LBtn");
- break;
- case VK_RBUTTON:
- str = _T("RBtn");
- break;
- case VK_CANCEL:
- str = _T("Cancel");
- break;
- case VK_MBUTTON:
- str = _T("MBtn");
- break;
- case VK_XBUTTON1:
- str = _T("X1Btn");
- break;
- case VK_XBUTTON2:
- str = _T("X2Btn");
- break;
- case VK_BACK:
- str = _T("Back");
- break;
- case VK_TAB:
- str = _T("Tab");
- break;
- case VK_CLEAR:
- str = _T("Clear");
- break;
- case VK_RETURN:
- str = _T("Return");
- break;
- case VK_SHIFT:
- str = _T("Shift");
- break;
- case VK_CONTROL:
- str = _T("Ctrl");
- break;
- case VK_MENU:
- str = _T("Alt");
- break;
- case VK_PAUSE:
- str = _T("Pause");
- break;
- case VK_CAPITAL:
- str = _T("Capital");
- break;
+ CString str;
+
+ if(a.fVirt&1)
+ switch(a.key)
+ {
+ case VK_LBUTTON: str = _T("LBtn"); break;
+ case VK_RBUTTON: str = _T("RBtn"); break;
+ case VK_CANCEL: str = _T("Cancel"); break;
+ case VK_MBUTTON: str = _T("MBtn"); break;
+ case VK_XBUTTON1: str = _T("X1Btn"); break;
+ case VK_XBUTTON2: str = _T("X2Btn"); break;
+ case VK_BACK: str = _T("Back"); break;
+ case VK_TAB: str = _T("Tab"); break;
+ case VK_CLEAR: str = _T("Clear"); break;
+ case VK_RETURN: str = _T("Return"); break;
+ case VK_SHIFT: str = _T("Shift"); break;
+ case VK_CONTROL: str = _T("Ctrl"); break;
+ case VK_MENU: str = _T("Alt"); break;
+ case VK_PAUSE: str = _T("Pause"); break;
+ case VK_CAPITAL: str = _T("Capital"); break;
// case VK_KANA: str = _T("Kana"); break;
// case VK_HANGEUL: str = _T("Hangeul"); break;
- case VK_HANGUL:
- str = _T("Hangul");
- break;
- case VK_JUNJA:
- str = _T("Junja");
- break;
- case VK_FINAL:
- str = _T("Final");
- break;
+ case VK_HANGUL: str = _T("Hangul"); break;
+ case VK_JUNJA: str = _T("Junja"); break;
+ case VK_FINAL: str = _T("Final"); break;
// case VK_HANJA: str = _T("Hanja"); break;
- case VK_KANJI:
- str = _T("Kanji");
- break;
- case VK_ESCAPE:
- str = _T("Escape");
- break;
- case VK_CONVERT:
- str = _T("Convert");
- break;
- case VK_NONCONVERT:
- str = _T("Non Convert");
- break;
- case VK_ACCEPT:
- str = _T("Accept");
- break;
- case VK_MODECHANGE:
- str = _T("Mode Change");
- break;
- case VK_SPACE:
- str = _T("Space");
- break;
- case VK_PRIOR:
- str = _T("PgUp");
- break;
- case VK_NEXT:
- str = _T("PgDn");
- break;
- case VK_END:
- str = _T("End");
- break;
- case VK_HOME:
- str = _T("Home");
- break;
- case VK_LEFT:
- str = _T("Left");
- break;
- case VK_UP:
- str = _T("Up");
- break;
- case VK_RIGHT:
- str = _T("Right");
- break;
- case VK_DOWN:
- str = _T("Down");
- break;
- case VK_SELECT:
- str = _T("Select");
- break;
- case VK_PRINT:
- str = _T("Print");
- break;
- case VK_EXECUTE:
- str = _T("Execute");
- break;
- case VK_SNAPSHOT:
- str = _T("Snapshot");
- break;
- case VK_INSERT:
- str = _T("Insert");
- break;
- case VK_DELETE:
- str = _T("Delete");
- break;
- case VK_HELP:
- str = _T("Help");
- break;
- case VK_LWIN:
- str = _T("LWin");
- break;
- case VK_RWIN:
- str = _T("RWin");
- break;
- case VK_APPS:
- str = _T("Apps");
- break;
- case VK_SLEEP:
- str = _T("Sleep");
- break;
- case VK_NUMPAD0:
- str = _T("Numpad 0");
- break;
- case VK_NUMPAD1:
- str = _T("Numpad 1");
- break;
- case VK_NUMPAD2:
- str = _T("Numpad 2");
- break;
- case VK_NUMPAD3:
- str = _T("Numpad 3");
- break;
- case VK_NUMPAD4:
- str = _T("Numpad 4");
- break;
- case VK_NUMPAD5:
- str = _T("Numpad 5");
- break;
- case VK_NUMPAD6:
- str = _T("Numpad 6");
- break;
- case VK_NUMPAD7:
- str = _T("Numpad 7");
- break;
- case VK_NUMPAD8:
- str = _T("Numpad 8");
- break;
- case VK_NUMPAD9:
- str = _T("Numpad 9");
- break;
- case VK_MULTIPLY:
- str = _T("Multiply");
- break;
- case VK_ADD:
- str = _T("Add");
- break;
- case VK_SEPARATOR:
- str = _T("Separator");
- break;
- case VK_SUBTRACT:
- str = _T("Subtract");
- break;
- case VK_DECIMAL:
- str = _T("Decimal");
- break;
- case VK_DIVIDE:
- str = _T("Divide");
- break;
- case VK_F1:
- str = _T("F1");
- break;
- case VK_F2:
- str = _T("F2");
- break;
- case VK_F3:
- str = _T("F3");
- break;
- case VK_F4:
- str = _T("F4");
- break;
- case VK_F5:
- str = _T("F5");
- break;
- case VK_F6:
- str = _T("F6");
- break;
- case VK_F7:
- str = _T("F7");
- break;
- case VK_F8:
- str = _T("F8");
- break;
- case VK_F9:
- str = _T("F9");
- break;
- case VK_F10:
- str = _T("F10");
- break;
- case VK_F11:
- str = _T("F11");
- break;
- case VK_F12:
- str = _T("F12");
- break;
- case VK_F13:
- str = _T("F13");
- break;
- case VK_F14:
- str = _T("F14");
- break;
- case VK_F15:
- str = _T("F15");
- break;
- case VK_F16:
- str = _T("F16");
- break;
- case VK_F17:
- str = _T("F17");
- break;
- case VK_F18:
- str = _T("F18");
- break;
- case VK_F19:
- str = _T("F19");
- break;
- case VK_F20:
- str = _T("F20");
- break;
- case VK_F21:
- str = _T("F21");
- break;
- case VK_F22:
- str = _T("F22");
- break;
- case VK_F23:
- str = _T("F23");
- break;
- case VK_F24:
- str = _T("F24");
- break;
- case VK_NUMLOCK:
- str = _T("Numlock");
- break;
- case VK_SCROLL:
- str = _T("Scroll");
- break;
+ case VK_KANJI: str = _T("Kanji"); break;
+ case VK_ESCAPE: str = _T("Escape"); break;
+ case VK_CONVERT: str = _T("Convert"); break;
+ case VK_NONCONVERT: str = _T("Non Convert"); break;
+ case VK_ACCEPT: str = _T("Accept"); break;
+ case VK_MODECHANGE: str = _T("Mode Change"); break;
+ case VK_SPACE: str = _T("Space"); break;
+ case VK_PRIOR: str = _T("PgUp"); break;
+ case VK_NEXT: str = _T("PgDn"); break;
+ case VK_END: str = _T("End"); break;
+ case VK_HOME: str = _T("Home"); break;
+ case VK_LEFT: str = _T("Left"); break;
+ case VK_UP: str = _T("Up"); break;
+ case VK_RIGHT: str = _T("Right"); break;
+ case VK_DOWN: str = _T("Down"); break;
+ case VK_SELECT: str = _T("Select"); break;
+ case VK_PRINT: str = _T("Print"); break;
+ case VK_EXECUTE: str = _T("Execute"); break;
+ case VK_SNAPSHOT: str = _T("Snapshot"); break;
+ case VK_INSERT: str = _T("Insert"); break;
+ case VK_DELETE: str = _T("Delete"); break;
+ case VK_HELP: str = _T("Help"); break;
+ case VK_LWIN: str = _T("LWin"); break;
+ case VK_RWIN: str = _T("RWin"); break;
+ case VK_APPS: str = _T("Apps"); break;
+ case VK_SLEEP: str = _T("Sleep"); break;
+ case VK_NUMPAD0: str = _T("Numpad 0"); break;
+ case VK_NUMPAD1: str = _T("Numpad 1"); break;
+ case VK_NUMPAD2: str = _T("Numpad 2"); break;
+ case VK_NUMPAD3: str = _T("Numpad 3"); break;
+ case VK_NUMPAD4: str = _T("Numpad 4"); break;
+ case VK_NUMPAD5: str = _T("Numpad 5"); break;
+ case VK_NUMPAD6: str = _T("Numpad 6"); break;
+ case VK_NUMPAD7: str = _T("Numpad 7"); break;
+ case VK_NUMPAD8: str = _T("Numpad 8"); break;
+ case VK_NUMPAD9: str = _T("Numpad 9"); break;
+ case VK_MULTIPLY: str = _T("Multiply"); break;
+ case VK_ADD: str = _T("Add"); break;
+ case VK_SEPARATOR: str = _T("Separator"); break;
+ case VK_SUBTRACT: str = _T("Subtract"); break;
+ case VK_DECIMAL: str = _T("Decimal"); break;
+ case VK_DIVIDE: str = _T("Divide"); break;
+ case VK_F1: str = _T("F1"); break;
+ case VK_F2: str = _T("F2"); break;
+ case VK_F3: str = _T("F3"); break;
+ case VK_F4: str = _T("F4"); break;
+ case VK_F5: str = _T("F5"); break;
+ case VK_F6: str = _T("F6"); break;
+ case VK_F7: str = _T("F7"); break;
+ case VK_F8: str = _T("F8"); break;
+ case VK_F9: str = _T("F9"); break;
+ case VK_F10: str = _T("F10"); break;
+ case VK_F11: str = _T("F11"); break;
+ case VK_F12: str = _T("F12"); break;
+ case VK_F13: str = _T("F13"); break;
+ case VK_F14: str = _T("F14"); break;
+ case VK_F15: str = _T("F15"); break;
+ case VK_F16: str = _T("F16"); break;
+ case VK_F17: str = _T("F17"); break;
+ case VK_F18: str = _T("F18"); break;
+ case VK_F19: str = _T("F19"); break;
+ case VK_F20: str = _T("F20"); break;
+ case VK_F21: str = _T("F21"); break;
+ case VK_F22: str = _T("F22"); break;
+ case VK_F23: str = _T("F23"); break;
+ case VK_F24: str = _T("F24"); break;
+ case VK_NUMLOCK: str = _T("Numlock"); break;
+ case VK_SCROLL: str = _T("Scroll"); break;
// case VK_OEM_NEC_EQUAL: str = _T("OEM NEC Equal"); break;
- case VK_OEM_FJ_JISHO:
- str = _T("OEM FJ Jisho");
- break;
- case VK_OEM_FJ_MASSHOU:
- str = _T("OEM FJ Msshou");
- break;
- case VK_OEM_FJ_TOUROKU:
- str = _T("OEM FJ Touroku");
- break;
- case VK_OEM_FJ_LOYA:
- str = _T("OEM FJ Loya");
- break;
- case VK_OEM_FJ_ROYA:
- str = _T("OEM FJ Roya");
- break;
- case VK_LSHIFT:
- str = _T("LShift");
- break;
- case VK_RSHIFT:
- str = _T("RShift");
- break;
- case VK_LCONTROL:
- str = _T("LCtrl");
- break;
- case VK_RCONTROL:
- str = _T("RCtrl");
- break;
- case VK_LMENU:
- str = _T("LAlt");
- break;
- case VK_RMENU:
- str = _T("RAlt");
- break;
- case VK_BROWSER_BACK:
- str = _T("Browser Back");
- break;
- case VK_BROWSER_FORWARD:
- str = _T("Browser Forward");
- break;
- case VK_BROWSER_REFRESH:
- str = _T("Browser Refresh");
- break;
- case VK_BROWSER_STOP:
- str = _T("Browser Stop");
- break;
- case VK_BROWSER_SEARCH:
- str = _T("Browser Search");
- break;
- case VK_BROWSER_FAVORITES:
- str = _T("Browser Favorites");
- break;
- case VK_BROWSER_HOME:
- str = _T("Browser Home");
- break;
- case VK_VOLUME_MUTE:
- str = _T("Volume Mute");
- break;
- case VK_VOLUME_DOWN:
- str = _T("Volume Down");
- break;
- case VK_VOLUME_UP:
- str = _T("Volume Up");
- break;
- case VK_MEDIA_NEXT_TRACK:
- str = _T("Media Next Track");
- break;
- case VK_MEDIA_PREV_TRACK:
- str = _T("Media Prev Track");
- break;
- case VK_MEDIA_STOP:
- str = _T("Media Stop");
- break;
- case VK_MEDIA_PLAY_PAUSE:
- str = _T("Media Play/Pause");
- break;
- case VK_LAUNCH_MAIL:
- str = _T("Launch Mail");
- break;
- case VK_LAUNCH_MEDIA_SELECT:
- str = _T("Launch Media Select");
- break;
- case VK_LAUNCH_APP1:
- str = _T("Launch App1");
- break;
- case VK_LAUNCH_APP2:
- str = _T("Launch App2");
- break;
- case VK_OEM_1:
- str = _T("OEM 1");
- break;
- case VK_OEM_PLUS:
- str = _T("Plus");
- break;
- case VK_OEM_COMMA:
- str = _T("Comma");
- break;
- case VK_OEM_MINUS:
- str = _T("Minus");
- break;
- case VK_OEM_PERIOD:
- str = _T("Period");
- break;
- case VK_OEM_2:
- str = _T("OEM 2");
- break;
- case VK_OEM_3:
- str = _T("OEM 3");
- break;
- case VK_OEM_4:
- str = _T("OEM 4");
- break;
- case VK_OEM_5:
- str = _T("OEM 5");
- break;
- case VK_OEM_6:
- str = _T("OEM 6");
- break;
- case VK_OEM_7:
- str = _T("OEM 7");
- break;
- case VK_OEM_8:
- str = _T("OEM 8");
- break;
- case VK_OEM_AX:
- str = _T("OEM AX");
- break;
- case VK_OEM_102:
- str = _T("OEM 102");
- break;
- case VK_ICO_HELP:
- str = _T("ICO Help");
- break;
- case VK_ICO_00:
- str = _T("ICO 00");
- break;
- case VK_PROCESSKEY:
- str = _T("Process Key");
- break;
- case VK_ICO_CLEAR:
- str = _T("ICO Clear");
- break;
- case VK_PACKET:
- str = _T("Packet");
- break;
- case VK_OEM_RESET:
- str = _T("OEM Reset");
- break;
- case VK_OEM_JUMP:
- str = _T("OEM Jump");
- break;
- case VK_OEM_PA1:
- str = _T("OEM PA1");
- break;
- case VK_OEM_PA2:
- str = _T("OEM PA2");
- break;
- case VK_OEM_PA3:
- str = _T("OEM PA3");
- break;
- case VK_OEM_WSCTRL:
- str = _T("OEM WSCtrl");
- break;
- case VK_OEM_CUSEL:
- str = _T("OEM CUSEL");
- break;
- case VK_OEM_ATTN:
- str = _T("OEM ATTN");
- break;
- case VK_OEM_FINISH:
- str = _T("OEM Finish");
- break;
- case VK_OEM_COPY:
- str = _T("OEM Copy");
- break;
- case VK_OEM_AUTO:
- str = _T("OEM Auto");
- break;
- case VK_OEM_ENLW:
- str = _T("OEM ENLW");
- break;
- case VK_OEM_BACKTAB:
- str = _T("OEM Backtab");
- break;
- case VK_ATTN:
- str = _T("ATTN");
- break;
- case VK_CRSEL:
- str = _T("CRSEL");
- break;
- case VK_EXSEL:
- str = _T("EXSEL");
- break;
- case VK_EREOF:
- str = _T("EREOF");
- break;
- case VK_PLAY:
- str = _T("Play");
- break;
- case VK_ZOOM:
- str = _T("Zoom");
- break;
- case VK_NONAME:
- str = _T("Noname");
- break;
- case VK_PA1:
- str = _T("PA1");
- break;
- case VK_OEM_CLEAR:
- str = _T("OEM Clear");
- break;
- default:
- if('0' <= a.key && a.key <= '9' || 'A' <= a.key && a.key <= 'Z')
- str.Format(_T("%c"), (TCHAR)a.key);
- break;
- }
-
- if(str.IsEmpty() || !(a.fVirt & 1))
- str.Format(_T("%c"), (TCHAR)a.key);
-
- if(a.fVirt&(FCONTROL | FALT | FSHIFT))
- str = MakeAccelModLabel(a.fVirt) + _T(" + ") + str;
-
- str.Replace(_T(" + "), _T("+"));
-
- return(str);
+ case VK_OEM_FJ_JISHO: str = _T("OEM FJ Jisho"); break;
+ case VK_OEM_FJ_MASSHOU: str = _T("OEM FJ Msshou"); break;
+ case VK_OEM_FJ_TOUROKU: str = _T("OEM FJ Touroku"); break;
+ case VK_OEM_FJ_LOYA: str = _T("OEM FJ Loya"); break;
+ case VK_OEM_FJ_ROYA: str = _T("OEM FJ Roya"); break;
+ case VK_LSHIFT: str = _T("LShift"); break;
+ case VK_RSHIFT: str = _T("RShift"); break;
+ case VK_LCONTROL: str = _T("LCtrl"); break;
+ case VK_RCONTROL: str = _T("RCtrl"); break;
+ case VK_LMENU: str = _T("LAlt"); break;
+ case VK_RMENU: str = _T("RAlt"); break;
+ case VK_BROWSER_BACK: str = _T("Browser Back"); break;
+ case VK_BROWSER_FORWARD: str = _T("Browser Forward"); break;
+ case VK_BROWSER_REFRESH: str = _T("Browser Refresh"); break;
+ case VK_BROWSER_STOP: str = _T("Browser Stop"); break;
+ case VK_BROWSER_SEARCH: str = _T("Browser Search"); break;
+ case VK_BROWSER_FAVORITES: str = _T("Browser Favorites"); break;
+ case VK_BROWSER_HOME: str = _T("Browser Home"); break;
+ case VK_VOLUME_MUTE: str = _T("Volume Mute"); break;
+ case VK_VOLUME_DOWN: str = _T("Volume Down"); break;
+ case VK_VOLUME_UP: str = _T("Volume Up"); break;
+ case VK_MEDIA_NEXT_TRACK: str = _T("Media Next Track"); break;
+ case VK_MEDIA_PREV_TRACK: str = _T("Media Prev Track"); break;
+ case VK_MEDIA_STOP: str = _T("Media Stop"); break;
+ case VK_MEDIA_PLAY_PAUSE: str = _T("Media Play/Pause"); break;
+ case VK_LAUNCH_MAIL: str = _T("Launch Mail"); break;
+ case VK_LAUNCH_MEDIA_SELECT: str = _T("Launch Media Select"); break;
+ case VK_LAUNCH_APP1: str = _T("Launch App1"); break;
+ case VK_LAUNCH_APP2: str = _T("Launch App2"); break;
+ case VK_OEM_1: str = _T("OEM 1"); break;
+ case VK_OEM_PLUS: str = _T("Plus"); break;
+ case VK_OEM_COMMA: str = _T("Comma"); break;
+ case VK_OEM_MINUS: str = _T("Minus"); break;
+ case VK_OEM_PERIOD: str = _T("Period"); break;
+ case VK_OEM_2: str = _T("OEM 2"); break;
+ case VK_OEM_3: str = _T("OEM 3"); break;
+ case VK_OEM_4: str = _T("OEM 4"); break;
+ case VK_OEM_5: str = _T("OEM 5"); break;
+ case VK_OEM_6: str = _T("OEM 6"); break;
+ case VK_OEM_7: str = _T("OEM 7"); break;
+ case VK_OEM_8: str = _T("OEM 8"); break;
+ case VK_OEM_AX: str = _T("OEM AX"); break;
+ case VK_OEM_102: str = _T("OEM 102"); break;
+ case VK_ICO_HELP: str = _T("ICO Help"); break;
+ case VK_ICO_00: str = _T("ICO 00"); break;
+ case VK_PROCESSKEY: str = _T("Process Key"); break;
+ case VK_ICO_CLEAR: str = _T("ICO Clear"); break;
+ case VK_PACKET: str = _T("Packet"); break;
+ case VK_OEM_RESET: str = _T("OEM Reset"); break;
+ case VK_OEM_JUMP: str = _T("OEM Jump"); break;
+ case VK_OEM_PA1: str = _T("OEM PA1"); break;
+ case VK_OEM_PA2: str = _T("OEM PA2"); break;
+ case VK_OEM_PA3: str = _T("OEM PA3"); break;
+ case VK_OEM_WSCTRL: str = _T("OEM WSCtrl"); break;
+ case VK_OEM_CUSEL: str = _T("OEM CUSEL"); break;
+ case VK_OEM_ATTN: str = _T("OEM ATTN"); break;
+ case VK_OEM_FINISH: str = _T("OEM Finish"); break;
+ case VK_OEM_COPY: str = _T("OEM Copy"); break;
+ case VK_OEM_AUTO: str = _T("OEM Auto"); break;
+ case VK_OEM_ENLW: str = _T("OEM ENLW"); break;
+ case VK_OEM_BACKTAB: str = _T("OEM Backtab"); break;
+ case VK_ATTN: str = _T("ATTN"); break;
+ case VK_CRSEL: str = _T("CRSEL"); break;
+ case VK_EXSEL: str = _T("EXSEL"); break;
+ case VK_EREOF: str = _T("EREOF"); break;
+ case VK_PLAY: str = _T("Play"); break;
+ case VK_ZOOM: str = _T("Zoom"); break;
+ case VK_NONAME: str = _T("Noname"); break;
+ case VK_PA1: str = _T("PA1"); break;
+ case VK_OEM_CLEAR: str = _T("OEM Clear"); break;
+ default:
+ if('0' <= a.key && a.key <= '9' || 'A' <= a.key && a.key <= 'Z')
+ str.Format(_T("%c"), (TCHAR)a.key);
+ break;
+ }
+
+ if(str.IsEmpty() || !(a.fVirt&1))
+ str.Format(_T("%c"), (TCHAR)a.key);
+
+ if(a.fVirt&(FCONTROL|FALT|FSHIFT))
+ str = MakeAccelModLabel(a.fVirt) + _T(" + ") + str;
+
+ str.Replace(_T(" + "), _T("+"));
+
+ return(str);
}
CString CPPageAccelTbl::MakeMouseButtonLabel(UINT mouse)
{
- CString ret;
- switch(mouse)
- {
- case wmcmd::NONE:
- default:
- ret = ResStr(IDS_AG_NONE);
- break;
- case wmcmd::LDOWN:
- ret = _T("Left Down");
- break;
- case wmcmd::LUP:
- ret = _T("Left Up");
- break;
- case wmcmd::LDBLCLK:
- ret = _T("Left DblClk");
- break;
- case wmcmd::MDOWN:
- ret = _T("Middle Down");
- break;
- case wmcmd::MUP:
- ret = _T("Middle Up");
- break;
- case wmcmd::MDBLCLK:
- ret = _T("Middle DblClk");
- break;
- case wmcmd::RDOWN:
- ret = _T("Right Down");
- break;
- case wmcmd::RUP:
- ret = _T("Right Up");
- break;
- case wmcmd::RDBLCLK:
- ret = _T("Right DblClk");
- break;
- case wmcmd::X1DOWN:
- ret = _T("X1 Down");
- break;
- case wmcmd::X1UP:
- ret = _T("X1 Up");
- break;
- case wmcmd::X1DBLCLK:
- ret = _T("X1 DblClk");
- break;
- case wmcmd::X2DOWN:
- ret = _T("X2 Down");
- break;
- case wmcmd::X2UP:
- ret = _T("X2 Up");
- break;
- case wmcmd::X2DBLCLK:
- ret = _T("X2 DblClk");
- break;
- case wmcmd::WUP:
- ret = _T("Wheel Up");
- break;
- case wmcmd::WDOWN:
- ret = _T("Wheel Down");
- break;
- }
- return ret;
+ CString ret;
+ switch(mouse)
+ {
+ case wmcmd::NONE: default: ret = ResStr(IDS_AG_NONE); break;
+ case wmcmd::LDOWN: ret = _T("Left Down"); break;
+ case wmcmd::LUP: ret = _T("Left Up"); break;
+ case wmcmd::LDBLCLK: ret = _T("Left DblClk"); break;
+ case wmcmd::MDOWN: ret = _T("Middle Down"); break;
+ case wmcmd::MUP: ret = _T("Middle Up"); break;
+ case wmcmd::MDBLCLK: ret = _T("Middle DblClk"); break;
+ case wmcmd::RDOWN: ret = _T("Right Down"); break;
+ case wmcmd::RUP: ret = _T("Right Up"); break;
+ case wmcmd::RDBLCLK: ret = _T("Right DblClk"); break;
+ case wmcmd::X1DOWN: ret = _T("X1 Down"); break;
+ case wmcmd::X1UP: ret = _T("X1 Up"); break;
+ case wmcmd::X1DBLCLK: ret = _T("X1 DblClk"); break;
+ case wmcmd::X2DOWN: ret = _T("X2 Down"); break;
+ case wmcmd::X2UP: ret = _T("X2 Up"); break;
+ case wmcmd::X2DBLCLK: ret = _T("X2 DblClk"); break;
+ case wmcmd::WUP: ret = _T("Wheel Up"); break;
+ case wmcmd::WDOWN: ret = _T("Wheel Down"); break;
+ }
+ return ret;
}
CString CPPageAccelTbl::MakeAppCommandLabel(UINT id)
{
- for(int i = 0; i < countof(g_CommandList); i++)
- {
- if(g_CommandList[i].appcmd == id)
- return CString(g_CommandList[i].cmdname);
- }
- return CString("");
+ for (int i=0; i<countof(g_CommandList); i++)
+ {
+ if (g_CommandList[i].appcmd == id)
+ return CString(g_CommandList[i].cmdname);
+ }
+ return CString("");
}
void CPPageAccelTbl::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT1, m_WinLircAddr);
- DDX_Control(pDX, IDC_EDIT1, m_WinLircEdit);
- DDX_Control(pDX, IDC_STATICLINK, m_WinLircLink);
- DDX_Check(pDX, IDC_CHECK1, m_fWinLirc);
- DDX_Text(pDX, IDC_EDIT2, m_UIceAddr);
- DDX_Control(pDX, IDC_EDIT2, m_UIceEdit);
- DDX_Control(pDX, IDC_STATICLINK2, m_UIceLink);
- DDX_Check(pDX, IDC_CHECK9, m_fUIce);
- DDX_Check(pDX, IDC_CHECK2, m_fGlobalMedia);
+ __super::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT1, m_WinLircAddr);
+ DDX_Control(pDX, IDC_EDIT1, m_WinLircEdit);
+ DDX_Control(pDX, IDC_STATICLINK, m_WinLircLink);
+ DDX_Check(pDX, IDC_CHECK1, m_fWinLirc);
+ DDX_Text(pDX, IDC_EDIT2, m_UIceAddr);
+ DDX_Control(pDX, IDC_EDIT2, m_UIceEdit);
+ DDX_Control(pDX, IDC_STATICLINK2, m_UIceLink);
+ DDX_Check(pDX, IDC_CHECK9, m_fUIce);
+ DDX_Check(pDX, IDC_CHECK2, m_fGlobalMedia);
}
BEGIN_MESSAGE_MAP(CPPageAccelTbl, CPPageBase)
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_WM_TIMER()
- ON_WM_CTLCOLOR()
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_WM_TIMER()
+ ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
// CPPageAccelTbl message handlers
BOOL CPPageAccelTbl::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- m_wmcmds.RemoveAll();
- m_wmcmds.AddTail(&s.wmcmds);
- m_fWinLirc = s.fWinLirc;
- m_WinLircAddr = s.WinLircAddr;
- m_fUIce = s.fUIce;
- m_UIceAddr = s.UIceAddr;
- m_fGlobalMedia = s.fGlobalMedia;
-
- UpdateData(FALSE);
-
- CRect r;
- GetDlgItem(IDC_PLACEHOLDER)->GetWindowRect(r);
- ScreenToClient(r);
-
- m_list.CreateEx(
- WS_EX_CLIENTEDGE,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | LVS_REPORT | LVS_AUTOARRANGE | LVS_SHOWSELALWAYS,
- r, this, IDC_LIST1);
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
-
- for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
- m_list.InsertColumn(COL_CMD, ResStr(IDS_AG_COMMAND), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_MOD, _T("Modifier"), LVCFMT_LEFT, 40);
- m_list.InsertColumn(COL_KEY, ResStr(IDS_AG_KEY), LVCFMT_LEFT, 40);
- m_list.InsertColumn(COL_TYPE, ResStr(IDS_AG_TYPE), LVCFMT_LEFT, 40);
- m_list.InsertColumn(COL_ID, _T("ID"), LVCFMT_LEFT, 40);
- m_list.InsertColumn(COL_MOUSE, ResStr(IDS_AG_MOUSE), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_APPCMD, ResStr(IDS_AG_APP_COMMAND), LVCFMT_LEFT, 120);
- m_list.InsertColumn(COL_RMCMD, _T("RemoteCmd"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_RMREPCNT, _T("RepCnt"), LVCFMT_CENTER, 60);
-
- POSITION pos = m_wmcmds.GetHeadPosition();
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_wmcmds.RemoveAll();
+ m_wmcmds.AddTail(&s.wmcmds);
+ m_fWinLirc = s.fWinLirc;
+ m_WinLircAddr = s.WinLircAddr;
+ m_fUIce = s.fUIce;
+ m_UIceAddr = s.UIceAddr;
+ m_fGlobalMedia = s.fGlobalMedia;
+
+ UpdateData(FALSE);
+
+ CRect r;
+ GetDlgItem(IDC_PLACEHOLDER)->GetWindowRect(r);
+ ScreenToClient(r);
+
+ m_list.CreateEx(
+ WS_EX_CLIENTEDGE,
+ WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP|LVS_REPORT|LVS_AUTOARRANGE|LVS_SHOWSELALWAYS,
+ r, this, IDC_LIST1);
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
+
+ for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
+ m_list.InsertColumn(COL_CMD, ResStr(IDS_AG_COMMAND), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_MOD, _T("Modifier"), LVCFMT_LEFT, 40);
+ m_list.InsertColumn(COL_KEY, ResStr(IDS_AG_KEY), LVCFMT_LEFT, 40);
+ m_list.InsertColumn(COL_TYPE, ResStr(IDS_AG_TYPE), LVCFMT_LEFT, 40);
+ m_list.InsertColumn(COL_ID, _T("ID"), LVCFMT_LEFT, 40);
+ m_list.InsertColumn(COL_MOUSE, ResStr(IDS_AG_MOUSE), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_APPCMD, ResStr(IDS_AG_APP_COMMAND), LVCFMT_LEFT, 120);
+ m_list.InsertColumn(COL_RMCMD, _T("RemoteCmd"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_RMREPCNT, _T("RepCnt"), LVCFMT_CENTER, 60);
+
+ POSITION pos = m_wmcmds.GetHeadPosition();
for(int i = 0; pos; i++)
- {
- int row = m_list.InsertItem(m_list.GetItemCount(), m_wmcmds.GetAt(pos).GetName(), COL_CMD);
- m_list.SetItemData(row, (DWORD_PTR)pos);
- m_wmcmds.GetNext(pos);
- }
-
- SetupList();
-
- m_list.SetColumnWidth(COL_CMD, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_MOD, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_KEY, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_TYPE, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_ID, LVSCW_AUTOSIZE_USEHEADER);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ {
+ int row = m_list.InsertItem(m_list.GetItemCount(), m_wmcmds.GetAt(pos).GetName(), COL_CMD);
+ m_list.SetItemData(row, (DWORD_PTR)pos);
+ m_wmcmds.GetNext(pos);
+ }
+
+ SetupList();
+
+ m_list.SetColumnWidth(COL_CMD, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_MOD, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_KEY, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_TYPE, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_ID, LVSCW_AUTOSIZE_USEHEADER);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageAccelTbl::OnApply()
{
- AfxGetMyApp()->UnregisterHotkeys();
- UpdateData();
+ AfxGetMyApp()->UnregisterHotkeys();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.wmcmds.RemoveAll();
- s.wmcmds.AddTail(&m_wmcmds);
+ s.wmcmds.RemoveAll();
+ s.wmcmds.AddTail(&m_wmcmds);
- CAtlArray<ACCEL> pAccel;
- pAccel.SetCount(m_wmcmds.GetCount());
- POSITION pos = m_wmcmds.GetHeadPosition();
- for(int i = 0; pos; i++) pAccel[i] = m_wmcmds.GetNext(pos);
- if(s.hAccel) DestroyAcceleratorTable(s.hAccel);
- s.hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
+ CAtlArray<ACCEL> pAccel;
+ pAccel.SetCount(m_wmcmds.GetCount());
+ POSITION pos = m_wmcmds.GetHeadPosition();
+ for(int i = 0; pos; i++) pAccel[i] = m_wmcmds.GetNext(pos);
+ if(s.hAccel) DestroyAcceleratorTable(s.hAccel);
+ s.hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
- GetParentFrame()->m_hAccelTable = s.hAccel;
+ GetParentFrame()->m_hAccelTable = s.hAccel;
- s.fWinLirc = !!m_fWinLirc;
- s.WinLircAddr = m_WinLircAddr;
- if(s.fWinLirc) s.WinLircClient.Connect(m_WinLircAddr);
- s.fUIce = !!m_fUIce;
- s.UIceAddr = m_UIceAddr;
- if(s.fUIce) s.UIceClient.Connect(m_UIceAddr);
- s.fGlobalMedia = !!m_fGlobalMedia;
+ s.fWinLirc = !!m_fWinLirc;
+ s.WinLircAddr = m_WinLircAddr;
+ if(s.fWinLirc) s.WinLircClient.Connect(m_WinLircAddr);
+ s.fUIce = !!m_fUIce;
+ s.UIceAddr = m_UIceAddr;
+ if(s.fUIce) s.UIceClient.Connect(m_UIceAddr);
+ s.fGlobalMedia = !!m_fGlobalMedia;
- AfxGetMyApp()->RegisterHotkeys();
+ AfxGetMyApp()->RegisterHotkeys();
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageAccelTbl::OnBnClickedButton1()
{
- m_list.SetFocus();
+ m_list.SetFocus();
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
- m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- }
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
+ {
+ m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ }
}
void CPPageAccelTbl::OnBnClickedButton2()
{
- m_list.SetFocus();
+ m_list.SetFocus();
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- if(!pos) return;
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ if(!pos) return;
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- while(pos)
- {
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos)));
- wc.Restore();
- }
+ while(pos)
+ {
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos)));
+ wc.Restore();
+ }
- SetupList();
+ SetupList();
- SetModified();
+ SetModified();
}
-void CPPageAccelTbl::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPPageAccelTbl::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if(pItem->iItem < 0)
- return;
+ if(pItem->iItem < 0)
+ return;
- if(pItem->iSubItem == COL_MOD || pItem->iSubItem == COL_KEY || pItem->iSubItem == COL_TYPE
- || pItem->iSubItem == COL_MOUSE || pItem->iSubItem == COL_APPCMD
- || pItem->iSubItem == COL_RMCMD || pItem->iSubItem == COL_RMREPCNT)
- {
- *pResult = TRUE;
- }
+ if(pItem->iSubItem == COL_MOD || pItem->iSubItem == COL_KEY || pItem->iSubItem == COL_TYPE
+ || pItem->iSubItem == COL_MOUSE || pItem->iSubItem == COL_APPCMD
+ || pItem->iSubItem == COL_RMCMD || pItem->iSubItem == COL_RMREPCNT)
+ {
+ *pResult = TRUE;
+ }
}
-static BYTE s_mods[] = {0, FALT, FCONTROL, FSHIFT, FCONTROL | FALT, FCONTROL | FSHIFT, FALT | FSHIFT, FCONTROL | FALT | FSHIFT};
+static BYTE s_mods[] = {0,FALT,FCONTROL,FSHIFT,FCONTROL|FALT,FCONTROL|FSHIFT,FALT|FSHIFT,FCONTROL|FALT|FSHIFT};
-void CPPageAccelTbl::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPPageAccelTbl::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if(pItem->iItem < 0)
- return;
-
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
- ACCEL& a = wc;
-
- CAtlList<CString> sl;
- int nSel = -1;
-
- if(pItem->iSubItem == COL_MOD)
- {
- for(int i = 0; i < countof(s_mods); i++)
- {
- sl.AddTail(MakeAccelModLabel(s_mods[i]));
- if((a.fVirt&~3) == s_mods[i]) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_KEY)
- {
- for(int i = 0; i < 256; i++)
- {
- sl.AddTail(MakeAccelVkeyLabel(i, a.fVirt & FVIRTKEY));
- if(a.key == i) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_TYPE)
- {
- sl.AddTail(_T("VIRTKEY"));
- sl.AddTail(_T("ASCII"));
-
- nSel = !(a.fVirt & FVIRTKEY);
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_MOUSE)
- {
- for(UINT i = 0; i < wmcmd::LAST; i++)
- {
- sl.AddTail(MakeMouseButtonLabel(i));
- if(wc.mouse == i) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_APPCMD)
- {
- for(int i = 0; i < countof(g_CommandList); i++)
- {
- sl.AddTail(g_CommandList[i].cmdname);
- if(wc.appcmd == g_CommandList[i].appcmd) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_RMCMD)
- {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_RMREPCNT)
- {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
-
- *pResult = TRUE;
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if(pItem->iItem < 0)
+ return;
+
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
+ ACCEL& a = wc;
+
+ CAtlList<CString> sl;
+ int nSel = -1;
+
+ if(pItem->iSubItem == COL_MOD)
+ {
+ for(int i = 0; i < countof(s_mods); i++)
+ {
+ sl.AddTail(MakeAccelModLabel(s_mods[i]));
+ if((a.fVirt&~3) == s_mods[i]) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+
+ *pResult = TRUE;
+ }
+ else if(pItem->iSubItem == COL_KEY)
+ {
+ for(int i = 0; i < 256; i++)
+ {
+ sl.AddTail(MakeAccelVkeyLabel(i, a.fVirt&FVIRTKEY));
+ if(a.key == i) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+
+ *pResult = TRUE;
+ }
+ else if(pItem->iSubItem == COL_TYPE)
+ {
+ sl.AddTail(_T("VIRTKEY"));
+ sl.AddTail(_T("ASCII"));
+
+ nSel = !(a.fVirt&FVIRTKEY);
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+
+ *pResult = TRUE;
+ }
+ else if(pItem->iSubItem == COL_MOUSE)
+ {
+ for(UINT i = 0; i < wmcmd::LAST; i++)
+ {
+ sl.AddTail(MakeMouseButtonLabel(i));
+ if(wc.mouse == i) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+
+ *pResult = TRUE;
+ }
+ else if(pItem->iSubItem == COL_APPCMD)
+ {
+ for(int i = 0; i < countof(g_CommandList); i++)
+ {
+ sl.AddTail(g_CommandList[i].cmdname);
+ if(wc.appcmd == g_CommandList[i].appcmd) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+
+ *pResult = TRUE;
+ }
+ else if(pItem->iSubItem == COL_RMCMD)
+ {
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+
+ *pResult = TRUE;
+ }
+ else if(pItem->iSubItem == COL_RMREPCNT)
+ {
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+
+ *pResult = TRUE;
+ }
}
-void CPPageAccelTbl::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPPageAccelTbl::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if(!m_list.m_fInPlaceDirty)
- return;
-
- if(pItem->iItem < 0)
- return;
-
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
-
- if(pItem->iSubItem == COL_MOD)
- {
- if(pItem->lParam >= 0 && pItem->lParam < countof(s_mods))
- {
- wc.fVirt = (wc.fVirt & 3) | (s_mods[pItem->lParam]&~3);
- m_list.SetItemText(pItem->iItem, COL_MOD, pItem->pszText);
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_KEY)
- {
- int i = pItem->lParam;
- if(i >= 0 && i < 256)
- {
- wc.key = (WORD)i;
- m_list.SetItemText(pItem->iItem, COL_KEY, pItem->pszText);
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_TYPE)
- {
- int i = pItem->lParam;
- if(i >= 0 && i < 2)
- {
- wc.fVirt = (wc.fVirt&~FVIRTKEY) | (i == 0 ? FVIRTKEY : 0);
- m_list.SetItemText(pItem->iItem, COL_KEY, MakeAccelVkeyLabel(wc.key, wc.fVirt & FVIRTKEY));
- m_list.SetItemText(pItem->iItem, COL_TYPE, (wc.fVirt & FVIRTKEY) ? _T("VIRTKEY") : _T("ASCII"));
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_APPCMD)
- {
- int i = pItem->lParam;
- if(i >= 0 && i < countof(g_CommandList))
- {
- wc.appcmd = g_CommandList[i].appcmd;
- m_list.SetItemText(pItem->iItem, COL_APPCMD, pItem->pszText);
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_MOUSE)
- {
- wc.mouse = pItem->lParam;
- m_list.SetItemText(pItem->iItem, COL_MOUSE, pItem->pszText);
- }
- else if(pItem->iSubItem == COL_RMCMD)
- {
- wc.rmcmd = CStringA(CString(pItem->pszText)).Trim();
- wc.rmcmd.Replace(' ', '_');
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, CString(wc.rmcmd));
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_RMREPCNT)
- {
- CString str = CString(pItem->pszText).Trim();
- wc.rmrepcnt = _tcstol(str, NULL, 10);
- str.Format(_T("%d"), wc.rmrepcnt);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- *pResult = TRUE;
- }
-
- if(*pResult)
- SetModified();
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if(!m_list.m_fInPlaceDirty)
+ return;
+
+ if(pItem->iItem < 0)
+ return;
+
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
+
+ if(pItem->iSubItem == COL_MOD)
+ {
+ if(pItem->lParam >= 0 && pItem->lParam < countof(s_mods))
+ {
+ wc.fVirt = (wc.fVirt&3) | (s_mods[pItem->lParam]&~3);
+ m_list.SetItemText(pItem->iItem, COL_MOD, pItem->pszText);
+ *pResult = TRUE;
+ }
+ }
+ else if(pItem->iSubItem == COL_KEY)
+ {
+ int i = pItem->lParam;
+ if(i >= 0 && i < 256)
+ {
+ wc.key = (WORD)i;
+ m_list.SetItemText(pItem->iItem, COL_KEY, pItem->pszText);
+ *pResult = TRUE;
+ }
+ }
+ else if(pItem->iSubItem == COL_TYPE)
+ {
+ int i = pItem->lParam;
+ if(i >= 0 && i < 2)
+ {
+ wc.fVirt = (wc.fVirt&~FVIRTKEY) | (i == 0 ? FVIRTKEY : 0);
+ m_list.SetItemText(pItem->iItem, COL_KEY, MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY));
+ m_list.SetItemText(pItem->iItem, COL_TYPE, (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII"));
+ *pResult = TRUE;
+ }
+ }
+ else if(pItem->iSubItem == COL_APPCMD)
+ {
+ int i = pItem->lParam;
+ if(i >= 0 && i < countof(g_CommandList))
+ {
+ wc.appcmd = g_CommandList[i].appcmd;
+ m_list.SetItemText(pItem->iItem, COL_APPCMD, pItem->pszText);
+ *pResult = TRUE;
+ }
+ }
+ else if(pItem->iSubItem == COL_MOUSE)
+ {
+ wc.mouse = pItem->lParam;
+ m_list.SetItemText(pItem->iItem, COL_MOUSE, pItem->pszText);
+ }
+ else if(pItem->iSubItem == COL_RMCMD)
+ {
+ wc.rmcmd = CStringA(CString(pItem->pszText)).Trim();
+ wc.rmcmd.Replace(' ', '_');
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, CString(wc.rmcmd));
+ *pResult = TRUE;
+ }
+ else if(pItem->iSubItem == COL_RMREPCNT)
+ {
+ CString str = CString(pItem->pszText).Trim();
+ wc.rmrepcnt = _tcstol(str, NULL, 10);
+ str.Format(_T("%d"), wc.rmrepcnt);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ *pResult = TRUE;
+ }
+
+ if(*pResult)
+ SetModified();
}
void CPPageAccelTbl::OnTimer(UINT_PTR nIDEvent)
{
- UpdateData();
+ UpdateData();
- if(m_fWinLirc)
- {
- CString addr;
- m_WinLircEdit.GetWindowText(addr);
- AfxGetAppSettings().WinLircClient.Connect(addr);
- }
+ if(m_fWinLirc)
+ {
+ CString addr;
+ m_WinLircEdit.GetWindowText(addr);
+ AfxGetAppSettings().WinLircClient.Connect(addr);
+ }
- m_WinLircEdit.Invalidate();
+ m_WinLircEdit.Invalidate();
- if(m_fUIce)
- {
- CString addr;
- m_UIceEdit.GetWindowText(addr);
- AfxGetAppSettings().UIceClient.Connect(addr);
- }
+ if(m_fUIce)
+ {
+ CString addr;
+ m_UIceEdit.GetWindowText(addr);
+ AfxGetAppSettings().UIceClient.Connect(addr);
+ }
- m_UIceEdit.Invalidate();
+ m_UIceEdit.Invalidate();
- m_counter++;
+ m_counter++;
- __super::OnTimer(nIDEvent);
+ __super::OnTimer(nIDEvent);
}
HBRUSH CPPageAccelTbl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
- HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
+ HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
- int status = -1;
+ int status = -1;
- if(*pWnd == m_WinLircEdit)
- status = AfxGetAppSettings().WinLircClient.GetStatus();
- else if(*pWnd == m_UIceEdit)
- status = AfxGetAppSettings().UIceClient.GetStatus();
+ if(*pWnd == m_WinLircEdit)
+ status = AfxGetAppSettings().WinLircClient.GetStatus();
+ else if(*pWnd == m_UIceEdit)
+ status = AfxGetAppSettings().UIceClient.GetStatus();
- if(status == 0 || status == 2 && (m_counter & 1))
- pDC->SetTextColor(0x0000ff);
- else if(status == 1)
- pDC->SetTextColor(0x008000);
+ if(status == 0 || status == 2 && (m_counter&1))
+ pDC->SetTextColor(0x0000ff);
+ else if(status == 1)
+ pDC->SetTextColor(0x008000);
- return hbr;
+ return hbr;
}
BOOL CPPageAccelTbl::OnSetActive()
{
- SetTimer(1, 1000, NULL);
+ SetTimer(1, 1000, NULL);
- return CPPageBase::OnSetActive();
+ return CPPageBase::OnSetActive();
}
BOOL CPPageAccelTbl::OnKillActive()
{
- KillTimer(1);
+ KillTimer(1);
- return CPPageBase::OnKillActive();
+ return CPPageBase::OnKillActive();
}
diff --git a/src/apps/mplayerc/PPageAccelTbl.h b/src/apps/mplayerc/PPageAccelTbl.h
index a2aadcd03..8b1bbb4a5 100644
--- a/src/apps/mplayerc/PPageAccelTbl.h
+++ b/src/apps/mplayerc/PPageAccelTbl.h
@@ -32,58 +32,58 @@
class CPPageAccelTbl : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageAccelTbl)
+ DECLARE_DYNAMIC(CPPageAccelTbl)
private:
- enum {COL_CMD, COL_MOD, COL_KEY, COL_TYPE, COL_ID, COL_MOUSE, COL_APPCMD, COL_RMCMD, COL_RMREPCNT};
- CList<wmcmd> m_wmcmds;
+ enum {COL_CMD, COL_MOD, COL_KEY, COL_TYPE, COL_ID, COL_MOUSE, COL_APPCMD, COL_RMCMD, COL_RMREPCNT};
+ CList<wmcmd> m_wmcmds;
- void SetupList();
+ void SetupList();
- int m_counter;
+ int m_counter;
public:
- CPPageAccelTbl();
- virtual ~CPPageAccelTbl();
+ CPPageAccelTbl();
+ virtual ~CPPageAccelTbl();
- static CString MakeAccelModLabel(BYTE fVirt);
- static CString MakeAccelVkeyLabel(WORD key, bool fVirtKey);
- static CString MakeAccelShortcutLabel(UINT id);
- static CString MakeAccelShortcutLabel(ACCEL& a);
- static CString MakeMouseButtonLabel(UINT mouse);
- static CString MakeAppCommandLabel(UINT id);
+ static CString MakeAccelModLabel(BYTE fVirt);
+ static CString MakeAccelVkeyLabel(WORD key, bool fVirtKey);
+ static CString MakeAccelShortcutLabel(UINT id);
+ static CString MakeAccelShortcutLabel(ACCEL& a);
+ static CString MakeMouseButtonLabel(UINT mouse);
+ static CString MakeAppCommandLabel(UINT id);
- enum {APPCOMMAND_LAST = APPCOMMAND_DWM_FLIP3D};
+ enum {APPCOMMAND_LAST=APPCOMMAND_DWM_FLIP3D};
// Dialog Data
- enum { IDD = IDD_PPAGEACCELTBL };
- CPlayerListCtrl m_list;
- BOOL m_fWinLirc;
- CString m_WinLircAddr;
- CEdit m_WinLircEdit;
- CStaticLink m_WinLircLink;
- BOOL m_fUIce;
- CString m_UIceAddr;
- CEdit m_UIceEdit;
- CStaticLink m_UIceLink;
- BOOL m_fGlobalMedia;
+ enum { IDD = IDD_PPAGEACCELTBL };
+ CPlayerListCtrl m_list;
+ BOOL m_fWinLirc;
+ CString m_WinLircAddr;
+ CEdit m_WinLircEdit;
+ CStaticLink m_WinLircLink;
+ BOOL m_fUIce;
+ CString m_UIceAddr;
+ CEdit m_UIceEdit;
+ CStaticLink m_UIceLink;
+ BOOL m_fGlobalMedia;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnSetActive();
- virtual BOOL OnKillActive();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnSetActive();
+ virtual BOOL OnKillActive();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton2();
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
};
diff --git a/src/apps/mplayerc/PPageAudioSwitcher.cpp b/src/apps/mplayerc/PPageAudioSwitcher.cpp
index fe9a09cf8..9c89965d9 100644
--- a/src/apps/mplayerc/PPageAudioSwitcher.cpp
+++ b/src/apps/mplayerc/PPageAudioSwitcher.cpp
@@ -31,19 +31,19 @@
IMPLEMENT_DYNAMIC(CPPageAudioSwitcher, CPPageBase)
CPPageAudioSwitcher::CPPageAudioSwitcher(IFilterGraph* pFG)
- : CPPageBase(CPPageAudioSwitcher::IDD, CPPageAudioSwitcher::IDD)
- , m_fAudioNormalize(FALSE)
- , m_fAudioNormalizeRecover(FALSE)
- , m_fDownSampleTo441(FALSE)
- , m_fCustomChannelMapping(FALSE)
- , m_nChannels(0)
- , m_fEnableAudioSwitcher(FALSE)
- , m_dwChannelMask(0)
- , m_tAudioTimeShift(0)
- , m_fAudioTimeShift(FALSE)
- , m_AudioBoost(0)
+ : CPPageBase(CPPageAudioSwitcher::IDD, CPPageAudioSwitcher::IDD)
+ , m_fAudioNormalize(FALSE)
+ , m_fAudioNormalizeRecover(FALSE)
+ , m_fDownSampleTo441(FALSE)
+ , m_fCustomChannelMapping(FALSE)
+ , m_nChannels(0)
+ , m_fEnableAudioSwitcher(FALSE)
+ , m_dwChannelMask(0)
+ , m_tAudioTimeShift(0)
+ , m_fAudioTimeShift(FALSE)
+ , m_AudioBoost(0)
{
- m_pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pFG);
+ m_pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pFG);
}
CPPageAudioSwitcher::~CPPageAudioSwitcher()
@@ -52,46 +52,46 @@ CPPageAudioSwitcher::~CPPageAudioSwitcher()
void CPPageAudioSwitcher::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK5, m_fAudioNormalize);
- DDX_Check(pDX, IDC_CHECK6, m_fAudioNormalizeRecover);
- DDX_Slider(pDX, IDC_SLIDER1, m_AudioBoost);
- DDX_Control(pDX, IDC_SLIDER1, m_AudioBoostCtrl);
- DDX_Check(pDX, IDC_CHECK3, m_fDownSampleTo441);
- DDX_Check(pDX, IDC_CHECK1, m_fCustomChannelMapping);
- DDX_Control(pDX, IDC_EDIT1, m_nChannelsCtrl);
- DDX_Text(pDX, IDC_EDIT1, m_nChannels);
- DDX_Control(pDX, IDC_SPIN1, m_nChannelsSpinCtrl);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Check(pDX, IDC_CHECK2, m_fEnableAudioSwitcher);
- DDX_Control(pDX, IDC_CHECK3, m_fDownSampleTo441Ctrl);
- DDX_Control(pDX, IDC_CHECK1, m_fCustomChannelMappingCtrl);
- DDX_Control(pDX, IDC_EDIT2, m_tAudioTimeShiftCtrl);
- DDX_Control(pDX, IDC_SPIN2, m_tAudioTimeShiftSpin);
- DDX_Text(pDX, IDC_EDIT2, m_tAudioTimeShift);
- DDX_Check(pDX, IDC_CHECK4, m_fAudioTimeShift);
- DDX_Control(pDX, IDC_CHECK4, m_fAudioTimeShiftCtrl);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK5, m_fAudioNormalize);
+ DDX_Check(pDX, IDC_CHECK6, m_fAudioNormalizeRecover);
+ DDX_Slider(pDX, IDC_SLIDER1, m_AudioBoost);
+ DDX_Control(pDX, IDC_SLIDER1, m_AudioBoostCtrl);
+ DDX_Check(pDX, IDC_CHECK3, m_fDownSampleTo441);
+ DDX_Check(pDX, IDC_CHECK1, m_fCustomChannelMapping);
+ DDX_Control(pDX, IDC_EDIT1, m_nChannelsCtrl);
+ DDX_Text(pDX, IDC_EDIT1, m_nChannels);
+ DDX_Control(pDX, IDC_SPIN1, m_nChannelsSpinCtrl);
+ DDX_Control(pDX, IDC_LIST1, m_list);
+ DDX_Check(pDX, IDC_CHECK2, m_fEnableAudioSwitcher);
+ DDX_Control(pDX, IDC_CHECK3, m_fDownSampleTo441Ctrl);
+ DDX_Control(pDX, IDC_CHECK1, m_fCustomChannelMappingCtrl);
+ DDX_Control(pDX, IDC_EDIT2, m_tAudioTimeShiftCtrl);
+ DDX_Control(pDX, IDC_SPIN2, m_tAudioTimeShiftSpin);
+ DDX_Text(pDX, IDC_EDIT2, m_tAudioTimeShift);
+ DDX_Check(pDX, IDC_CHECK4, m_fAudioTimeShift);
+ DDX_Control(pDX, IDC_CHECK4, m_fAudioTimeShiftCtrl);
}
BEGIN_MESSAGE_MAP(CPPageAudioSwitcher, CPPageBase)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
- ON_WM_DRAWITEM()
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_UPDATE_COMMAND_UI(IDC_SLIDER1, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK5, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK6, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK4, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK1, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_LIST1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdateChannelMapping)
- ON_WM_HSCROLL()
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
+ ON_WM_DRAWITEM()
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_UPDATE_COMMAND_UI(IDC_SLIDER1, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK5, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK6, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK4, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK1, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_LIST1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdateChannelMapping)
+ ON_WM_HSCROLL()
END_MESSAGE_MAP()
@@ -99,243 +99,243 @@ END_MESSAGE_MAP()
BOOL CPPageAudioSwitcher::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- m_fEnableAudioSwitcher = s.fEnableAudioSwitcher;
- m_fAudioNormalize = s.fAudioNormalize;
- m_fAudioNormalizeRecover = s.fAudioNormalizeRecover;
- m_AudioBoost = (int)(50.0f * log10(s.AudioBoost));
- m_AudioBoostCtrl.SetRange(0, 100);
- m_fDownSampleTo441 = s.fDownSampleTo441;
- m_fAudioTimeShift = s.fAudioTimeShift;
- m_tAudioTimeShift = s.tAudioTimeShift;
- m_tAudioTimeShiftSpin.SetRange32(-1000 * 60 * 60 * 24, 1000 * 60 * 60 * 24);
- m_fCustomChannelMapping = s.fCustomChannelMapping;
- memcpy(m_pSpeakerToChannelMap, s.pSpeakerToChannelMap, sizeof(s.pSpeakerToChannelMap));
-
- if(m_pASF)
- m_pASF->GetInputSpeakerConfig(&m_dwChannelMask);
-
- m_nChannels = s.fnChannels;
- m_nChannelsSpinCtrl.SetRange(1, 18);
-
- if(m_pASF)
- m_nChannels = m_pASF->GetNumberOfInputChannels();
-
- m_list.InsertColumn(0, _T(""), LVCFMT_LEFT, 100);
- m_list.InsertItem(0, _T(""));
- m_list.InsertItem(1, ResStr(IDS_FRONT_LEFT));
- m_list.InsertItem(2, ResStr(IDS_FRONT_RIGHT));
- m_list.InsertItem(3, ResStr(IDS_FRONT_CENTER));
- m_list.InsertItem(4, ResStr(IDS_LOW_FREQUENCY));
- m_list.InsertItem(5, ResStr(IDS_BACK_LEFT));
- m_list.InsertItem(6, ResStr(IDS_BACK_RIGHT));
- m_list.InsertItem(7, ResStr(IDS_FRONT_LEFT_OF_CENTER));
- m_list.InsertItem(8, ResStr(IDS_FRONT_RIGHT_OF_CENTER));
- m_list.InsertItem(9, ResStr(IDS_BACK_CENTER));
- m_list.InsertItem(10, ResStr(IDS_SIDE_LEFT));
- m_list.InsertItem(11, ResStr(IDS_SIDE_RIGHT));
- m_list.InsertItem(12, ResStr(IDS_TOP_CENTER));
- m_list.InsertItem(13, ResStr(IDS_TOP_FRONT_LEFT));
- m_list.InsertItem(14, ResStr(IDS_TOP_FRONT_CENTER));
- m_list.InsertItem(15, ResStr(IDS_TOP_FRONT_RIGHT));
- m_list.InsertItem(16, ResStr(IDS_TOP_BACK_LEFT));
- m_list.InsertItem(17, ResStr(IDS_TOP_BACK_CENTER));
- m_list.InsertItem(18, ResStr(IDS_TOP_BACK_RIGHT));
- m_list.SetColumnWidth(0, LVSCW_AUTOSIZE);
-
- for(int i = 1; i <= 18; i++)
- {
- m_list.InsertColumn(i, _T(""), LVCFMT_CENTER, 16);
- CString n;
- n.Format(_T("%d"), i);
- m_list.SetItemText(0, i, n);
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_fEnableAudioSwitcher = s.fEnableAudioSwitcher;
+ m_fAudioNormalize = s.fAudioNormalize;
+ m_fAudioNormalizeRecover = s.fAudioNormalizeRecover;
+ m_AudioBoost = (int)(50.0f*log10(s.AudioBoost));
+ m_AudioBoostCtrl.SetRange(0, 100);
+ m_fDownSampleTo441 = s.fDownSampleTo441;
+ m_fAudioTimeShift = s.fAudioTimeShift;
+ m_tAudioTimeShift = s.tAudioTimeShift;
+ m_tAudioTimeShiftSpin.SetRange32(-1000*60*60*24, 1000*60*60*24);
+ m_fCustomChannelMapping = s.fCustomChannelMapping;
+ memcpy(m_pSpeakerToChannelMap, s.pSpeakerToChannelMap, sizeof(s.pSpeakerToChannelMap));
+
+ if(m_pASF)
+ m_pASF->GetInputSpeakerConfig(&m_dwChannelMask);
+
+ m_nChannels = s.fnChannels;
+ m_nChannelsSpinCtrl.SetRange(1, 18);
+
+ if(m_pASF)
+ m_nChannels = m_pASF->GetNumberOfInputChannels();
+
+ m_list.InsertColumn(0, _T(""), LVCFMT_LEFT, 100);
+ m_list.InsertItem(0, _T(""));
+ m_list.InsertItem(1, ResStr(IDS_FRONT_LEFT));
+ m_list.InsertItem(2, ResStr(IDS_FRONT_RIGHT));
+ m_list.InsertItem(3, ResStr(IDS_FRONT_CENTER));
+ m_list.InsertItem(4, ResStr(IDS_LOW_FREQUENCY));
+ m_list.InsertItem(5, ResStr(IDS_BACK_LEFT));
+ m_list.InsertItem(6, ResStr(IDS_BACK_RIGHT));
+ m_list.InsertItem(7, ResStr(IDS_FRONT_LEFT_OF_CENTER));
+ m_list.InsertItem(8, ResStr(IDS_FRONT_RIGHT_OF_CENTER));
+ m_list.InsertItem(9, ResStr(IDS_BACK_CENTER));
+ m_list.InsertItem(10, ResStr(IDS_SIDE_LEFT));
+ m_list.InsertItem(11, ResStr(IDS_SIDE_RIGHT));
+ m_list.InsertItem(12, ResStr(IDS_TOP_CENTER));
+ m_list.InsertItem(13, ResStr(IDS_TOP_FRONT_LEFT));
+ m_list.InsertItem(14, ResStr(IDS_TOP_FRONT_CENTER));
+ m_list.InsertItem(15, ResStr(IDS_TOP_FRONT_RIGHT));
+ m_list.InsertItem(16, ResStr(IDS_TOP_BACK_LEFT));
+ m_list.InsertItem(17, ResStr(IDS_TOP_BACK_CENTER));
+ m_list.InsertItem(18, ResStr(IDS_TOP_BACK_RIGHT));
+ m_list.SetColumnWidth(0, LVSCW_AUTOSIZE);
+
+ for(int i = 1; i <= 18; i++)
+ {
+ m_list.InsertColumn(i, _T(""), LVCFMT_CENTER, 16);
+ CString n;
+ n.Format(_T("%d"), i);
+ m_list.SetItemText(0, i, n);
// m_list.SetColumnWidth(i, LVSCW_AUTOSIZE);
// m_list.SetColumnWidth(i, m_list.GetColumnWidth(i)*8/10);
- }
+ }
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageAudioSwitcher::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.fEnableAudioSwitcher = !!m_fEnableAudioSwitcher;
- s.fAudioNormalize = !!m_fAudioNormalize;
- s.fAudioNormalizeRecover = !!m_fAudioNormalizeRecover;
- s.AudioBoost = (float)pow(10.0, (double)m_AudioBoost / 50);
- s.fDownSampleTo441 = !!m_fDownSampleTo441;
- s.fAudioTimeShift = !!m_fAudioTimeShift;
- s.tAudioTimeShift = m_tAudioTimeShift;
- s.fCustomChannelMapping = !!m_fCustomChannelMapping;
- memcpy(s.pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
-
- if(m_pASF)
- {
- m_pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
- m_pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
- m_pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64 * s.tAudioTimeShift : 0);
- m_pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.AudioBoost);
- }
-
- s.fnChannels = m_nChannels;
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.fEnableAudioSwitcher = !!m_fEnableAudioSwitcher;
+ s.fAudioNormalize = !!m_fAudioNormalize;
+ s.fAudioNormalizeRecover = !!m_fAudioNormalizeRecover;
+ s.AudioBoost = (float)pow(10.0, (double)m_AudioBoost/50);
+ s.fDownSampleTo441 = !!m_fDownSampleTo441;
+ s.fAudioTimeShift = !!m_fAudioTimeShift;
+ s.tAudioTimeShift = m_tAudioTimeShift;
+ s.fCustomChannelMapping = !!m_fCustomChannelMapping;
+ memcpy(s.pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
+
+ if(m_pASF)
+ {
+ m_pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
+ m_pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
+ m_pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64*s.tAudioTimeShift : 0);
+ m_pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.AudioBoost);
+ }
+
+ s.fnChannels = m_nChannels;
+
+ return __super::OnApply();
}
void CPPageAudioSwitcher::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
-
- if(lpnmlv->iItem > 0 && lpnmlv->iSubItem > 0 && lpnmlv->iSubItem <= m_nChannels)
- {
- UpdateData();
- m_pSpeakerToChannelMap[m_nChannels-1][lpnmlv->iItem-1] ^= 1 << (lpnmlv->iSubItem - 1);
- m_list.RedrawItems(lpnmlv->iItem, lpnmlv->iItem);
- SetModified();
-
- if(GetKeyState(VK_SHIFT) & 0x8000)
- {
- OnApply();
- }
- }
-
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+
+ if(lpnmlv->iItem > 0 && lpnmlv->iSubItem > 0 && lpnmlv->iSubItem <= m_nChannels)
+ {
+ UpdateData();
+ m_pSpeakerToChannelMap[m_nChannels-1][lpnmlv->iItem-1] ^= 1<<(lpnmlv->iSubItem-1);
+ m_list.RedrawItems(lpnmlv->iItem, lpnmlv->iItem);
+ SetModified();
+
+ if(GetKeyState(VK_SHIFT) & 0x8000)
+ {
+ OnApply();
+ }
+ }
+
+ *pResult = 0;
}
void CPPageAudioSwitcher::OnEnChangeEdit1()
{
- if(IsWindow(m_list.m_hWnd))
- {
- UpdateData();
- m_list.Invalidate();
- SetModified();
- }
+ if(IsWindow(m_list.m_hWnd))
+ {
+ UpdateData();
+ m_list.Invalidate();
+ SetModified();
+ }
}
#include <math.h>
void CPPageAudioSwitcher::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_LIST1) return;
+ if(nIDCtl != IDC_LIST1) return;
// if(lpDrawItemStruct->itemID == 0)
// UpdateData();
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- pDC->SetBkMode(TRANSPARENT);
-
- CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
- CPen* old = pDC->SelectObject(&p);
-
- pDC->MoveTo(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom - 1);
- pDC->LineTo(lpDrawItemStruct->rcItem.right, lpDrawItemStruct->rcItem.bottom - 1);
-
- CHeaderCtrl* pHeader = m_list.GetHeaderCtrl();
- int nColumnCount = pHeader->GetItemCount();
-
- for(int i = 0; i < nColumnCount; i++)
- {
- CRect r, rb;
- m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_BOUNDS, rb);
- m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_LABEL, r);
-
- pDC->MoveTo(r.right - 1, r.top);
- pDC->LineTo(r.right - 1, r.bottom - 1);
-
- CSize s = pDC->GetTextExtent(m_list.GetItemText(lpDrawItemStruct->itemID, i));
-
- if(i == 0)
- {
- r.left = rb.left;
-
- if(lpDrawItemStruct->itemID == 0)
- {
- pDC->MoveTo(0, 0);
- pDC->LineTo(r.right, r.bottom - 1);
- }
- else
- {
- pDC->SetTextColor(m_list.IsWindowEnabled() ? 0 : 0xb0b0b0);
- pDC->TextOut(r.left + 1, (r.top + r.bottom - s.cy) / 2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
- }
- }
- else
- {
- pDC->SetTextColor(i > m_nChannels ? 0xe0e0e0 : (!m_list.IsWindowEnabled() ? 0xb0b0b0 : 0));
-
- if(lpDrawItemStruct->itemID == 0)
- {
- pDC->TextOut((r.left + r.right - s.cx) / 2, (r.top + r.bottom - s.cy) / 2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
- }
- else
- {
- if(m_dwChannelMask & (1 << (lpDrawItemStruct->itemID - 1)))
- {
- int nBitsSet = 0;
-
- for(int j = 1; j <= (1 << (lpDrawItemStruct->itemID - 1)); j <<= 1)
- {
- if(m_dwChannelMask & j)
- nBitsSet++;
- }
-
- if(nBitsSet == i)
- {
- COLORREF tmp = pDC->GetTextColor();
-
- pDC->SetTextColor(0xe0e0e0);
- CFont f;
- f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
- CFont* old = pDC->SelectObject(&f);
- s = pDC->GetTextExtent(_T("g"));
- pDC->TextOut((r.left + r.right - s.cx) / 2, (r.top + r.bottom - s.cy) / 2, _T("g"));
-
- pDC->SetTextColor(tmp);
- }
- }
-
- if(m_pSpeakerToChannelMap[m_nChannels-1][lpDrawItemStruct->itemID-1] & (1 << (i - 1)))
- {
- CFont f;
- f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
- CFont* old = pDC->SelectObject(&f);
- s = pDC->GetTextExtent(_T("a"));
- pDC->TextOut((r.left + r.right - s.cx) / 2, (r.top + r.bottom - s.cy) / 2, _T("a"));
- pDC->SelectObject(old);
- }
- }
- }
- }
-
- pDC->SelectObject(old);
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ pDC->SetBkMode(TRANSPARENT);
+
+ CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
+ CPen* old = pDC->SelectObject(&p);
+
+ pDC->MoveTo(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom-1);
+ pDC->LineTo(lpDrawItemStruct->rcItem.right, lpDrawItemStruct->rcItem.bottom-1);
+
+ CHeaderCtrl* pHeader = m_list.GetHeaderCtrl();
+ int nColumnCount = pHeader->GetItemCount();
+
+ for(int i = 0; i < nColumnCount; i++)
+ {
+ CRect r, rb;
+ m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_BOUNDS, rb);
+ m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_LABEL, r);
+
+ pDC->MoveTo(r.right-1, r.top);
+ pDC->LineTo(r.right-1, r.bottom-1);
+
+ CSize s = pDC->GetTextExtent(m_list.GetItemText(lpDrawItemStruct->itemID, i));
+
+ if(i == 0)
+ {
+ r.left = rb.left;
+
+ if(lpDrawItemStruct->itemID == 0)
+ {
+ pDC->MoveTo(0, 0);
+ pDC->LineTo(r.right, r.bottom-1);
+ }
+ else
+ {
+ pDC->SetTextColor(m_list.IsWindowEnabled() ? 0 : 0xb0b0b0);
+ pDC->TextOut(r.left+1, (r.top+r.bottom-s.cy)/2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
+ }
+ }
+ else
+ {
+ pDC->SetTextColor(i > m_nChannels ? 0xe0e0e0 : (!m_list.IsWindowEnabled() ? 0xb0b0b0 : 0));
+
+ if(lpDrawItemStruct->itemID == 0)
+ {
+ pDC->TextOut((r.left+r.right-s.cx)/2, (r.top+r.bottom-s.cy)/2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
+ }
+ else
+ {
+ if(m_dwChannelMask & (1<<(lpDrawItemStruct->itemID-1)))
+ {
+ int nBitsSet = 0;
+
+ for(int j = 1; j <= (1<<(lpDrawItemStruct->itemID-1)); j <<= 1)
+ {
+ if(m_dwChannelMask & j)
+ nBitsSet++;
+ }
+
+ if(nBitsSet == i)
+ {
+ COLORREF tmp = pDC->GetTextColor();
+
+ pDC->SetTextColor(0xe0e0e0);
+ CFont f;
+ f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
+ CFont* old = pDC->SelectObject(&f);
+ s = pDC->GetTextExtent(_T("g"));
+ pDC->TextOut((r.left+r.right-s.cx)/2, (r.top+r.bottom-s.cy)/2, _T("g"));
+
+ pDC->SetTextColor(tmp);
+ }
+ }
+
+ if(m_pSpeakerToChannelMap[m_nChannels-1][lpDrawItemStruct->itemID-1] & (1<<(i-1)))
+ {
+ CFont f;
+ f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
+ CFont* old = pDC->SelectObject(&f);
+ s = pDC->GetTextExtent(_T("a"));
+ pDC->TextOut((r.left+r.right-s.cx)/2, (r.top+r.bottom-s.cy)/2, _T("a"));
+ pDC->SelectObject(old);
+ }
+ }
+ }
+ }
+
+ pDC->SelectObject(old);
}
void CPPageAudioSwitcher::OnUpdateAudioSwitcher(CCmdUI* pCmdUI)
{
// UpdateData();
- pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/);
+ pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/);
}
void CPPageAudioSwitcher::OnUpdateChannelMapping(CCmdUI* pCmdUI)
{
// UpdateData();
- pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/
- && IsDlgButtonChecked(IDC_CHECK1)/*m_fCustomChannelMapping*/);
+ pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/
+ && IsDlgButtonChecked(IDC_CHECK1)/*m_fCustomChannelMapping*/);
}
void CPPageAudioSwitcher::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- SetModified();
+ SetModified();
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
diff --git a/src/apps/mplayerc/PPageAudioSwitcher.h b/src/apps/mplayerc/PPageAudioSwitcher.h
index 8c68b786a..2254d52f5 100644
--- a/src/apps/mplayerc/PPageAudioSwitcher.h
+++ b/src/apps/mplayerc/PPageAudioSwitcher.h
@@ -32,52 +32,52 @@
class CPPageAudioSwitcher : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageAudioSwitcher)
+ DECLARE_DYNAMIC(CPPageAudioSwitcher)
private:
- CComQIPtr<IAudioSwitcherFilter> m_pASF;
- DWORD m_pSpeakerToChannelMap[18][18];
- DWORD m_dwChannelMask;
+ CComQIPtr<IAudioSwitcherFilter> m_pASF;
+ DWORD m_pSpeakerToChannelMap[18][18];
+ DWORD m_dwChannelMask;
public:
- CPPageAudioSwitcher(IFilterGraph* pFG);
- virtual ~CPPageAudioSwitcher();
+ CPPageAudioSwitcher(IFilterGraph* pFG);
+ virtual ~CPPageAudioSwitcher();
// Dialog Data
- enum { IDD = IDD_PPAGEAUDIOSWITCHER };
+ enum { IDD = IDD_PPAGEAUDIOSWITCHER };
- BOOL m_fEnableAudioSwitcher;
- BOOL m_fAudioNormalize;
- BOOL m_fAudioNormalizeRecover;
- int m_AudioBoost;
- CSliderCtrl m_AudioBoostCtrl;
- BOOL m_fDownSampleTo441;
- CButton m_fDownSampleTo441Ctrl;
- BOOL m_fCustomChannelMapping;
- CButton m_fCustomChannelMappingCtrl;
- CEdit m_nChannelsCtrl;
- int m_nChannels;
- CSpinButtonCtrl m_nChannelsSpinCtrl;
- CListCtrl m_list;
- int m_tAudioTimeShift;
- CButton m_fAudioTimeShiftCtrl;
- CIntEdit m_tAudioTimeShiftCtrl;
- CSpinButtonCtrl m_tAudioTimeShiftSpin;
- BOOL m_fAudioTimeShift;
+ BOOL m_fEnableAudioSwitcher;
+ BOOL m_fAudioNormalize;
+ BOOL m_fAudioNormalizeRecover;
+ int m_AudioBoost;
+ CSliderCtrl m_AudioBoostCtrl;
+ BOOL m_fDownSampleTo441;
+ CButton m_fDownSampleTo441Ctrl;
+ BOOL m_fCustomChannelMapping;
+ CButton m_fCustomChannelMappingCtrl;
+ CEdit m_nChannelsCtrl;
+ int m_nChannels;
+ CSpinButtonCtrl m_nChannelsSpinCtrl;
+ CListCtrl m_list;
+ int m_tAudioTimeShift;
+ CButton m_fAudioTimeShiftCtrl;
+ CIntEdit m_tAudioTimeShiftCtrl;
+ CSpinButtonCtrl m_tAudioTimeShiftSpin;
+ BOOL m_fAudioTimeShift;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnUpdateAudioSwitcher(CCmdUI* pCmdUI);
- afx_msg void OnUpdateChannelMapping(CCmdUI* pCmdUI);
+ afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnUpdateAudioSwitcher(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateChannelMapping(CCmdUI* pCmdUI);
public:
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
};
diff --git a/src/apps/mplayerc/PPageBase.cpp b/src/apps/mplayerc/PPageBase.cpp
index bb4ba3c92..561c7d57d 100644
--- a/src/apps/mplayerc/PPageBase.cpp
+++ b/src/apps/mplayerc/PPageBase.cpp
@@ -30,7 +30,7 @@
IMPLEMENT_DYNAMIC(CPPageBase, CCmdUIPropertyPage)
CPPageBase::CPPageBase(UINT nIDTemplate, UINT nIDCaption)
- : CCmdUIPropertyPage(nIDTemplate, nIDCaption)
+ : CCmdUIPropertyPage(nIDTemplate, nIDCaption)
{
}
@@ -40,48 +40,48 @@ CPPageBase::~CPPageBase()
void CPPageBase::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
+ __super::DoDataExchange(pDX);
}
void CPPageBase::CreateToolTip()
{
- m_wndToolTip.Create(this);
- m_wndToolTip.Activate(TRUE);
- m_wndToolTip.SetMaxTipWidth(300);
- m_wndToolTip.SetDelayTime(TTDT_AUTOPOP, 10000);
- for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetWindow(GW_HWNDNEXT))
- {
- CString strToolTip;
- if(strToolTip.LoadString(pChild->GetDlgCtrlID()))
- m_wndToolTip.AddTool(pChild, strToolTip);
- }
+ m_wndToolTip.Create(this);
+ m_wndToolTip.Activate(TRUE);
+ m_wndToolTip.SetMaxTipWidth(300);
+ m_wndToolTip.SetDelayTime(TTDT_AUTOPOP, 10000);
+ for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetWindow(GW_HWNDNEXT))
+ {
+ CString strToolTip;
+ if(strToolTip.LoadString(pChild->GetDlgCtrlID()))
+ m_wndToolTip.AddTool(pChild, strToolTip);
+ }
}
BOOL CPPageBase::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(m_wndToolTip))
- if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
- {
- MSG msg;
- memcpy(&msg, pMsg, sizeof(MSG));
- for(HWND hWndParent = ::GetParent(msg.hwnd);
- hWndParent && hWndParent != m_hWnd;
- hWndParent = ::GetParent(hWndParent))
- {
- msg.hwnd = hWndParent;
- }
-
- if(msg.hwnd)
- {
- m_wndToolTip.RelayEvent(&msg);
- }
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if(IsWindow(m_wndToolTip))
+ if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
+ {
+ MSG msg;
+ memcpy(&msg, pMsg, sizeof(MSG));
+ for(HWND hWndParent = ::GetParent(msg.hwnd);
+ hWndParent && hWndParent != m_hWnd;
+ hWndParent = ::GetParent(hWndParent))
+ {
+ msg.hwnd = hWndParent;
+ }
+
+ if(msg.hwnd)
+ {
+ m_wndToolTip.RelayEvent(&msg);
+ }
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPPageBase, CCmdUIPropertyPage)
- ON_WM_DESTROY()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
@@ -89,14 +89,14 @@ END_MESSAGE_MAP()
BOOL CPPageBase::OnSetActive()
{
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("LastUsedPage"), (UINT)m_pPSP->pszTemplate);
+ AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("LastUsedPage"), (UINT)m_pPSP->pszTemplate);
- return __super::OnSetActive();
+ return __super::OnSetActive();
}
void CPPageBase::OnDestroy()
{
- __super::OnDestroy();
+ __super::OnDestroy();
- m_wndToolTip.DestroyWindow();
+ m_wndToolTip.DestroyWindow();
}
diff --git a/src/apps/mplayerc/PPageBase.h b/src/apps/mplayerc/PPageBase.h
index 74c964f8e..3db4f17c3 100644
--- a/src/apps/mplayerc/PPageBase.h
+++ b/src/apps/mplayerc/PPageBase.h
@@ -27,25 +27,25 @@
class CPPageBase : public CCmdUIPropertyPage
{
- DECLARE_DYNAMIC(CPPageBase)
+ DECLARE_DYNAMIC(CPPageBase)
protected:
- CToolTipCtrl m_wndToolTip;
- void CreateToolTip();
+ CToolTipCtrl m_wndToolTip;
+ void CreateToolTip();
public:
- CPPageBase(UINT nIDTemplate, UINT nIDCaption = 0);
- virtual ~CPPageBase();
+ CPPageBase(UINT nIDTemplate, UINT nIDCaption = 0);
+ virtual ~CPPageBase();
// Dialog Data
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnSetActive();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnSetActive();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnDestroy();
+ afx_msg void OnDestroy();
};
diff --git a/src/apps/mplayerc/PPageCapture.cpp b/src/apps/mplayerc/PPageCapture.cpp
index f503be257..b1256a7ff 100644
--- a/src/apps/mplayerc/PPageCapture.cpp
+++ b/src/apps/mplayerc/PPageCapture.cpp
@@ -35,221 +35,216 @@
#include "../../DSUtil/DSUtil.h"
-static struct cc_t
+static struct cc_t {long code; AnalogVideoStandard standard; const TCHAR* str;} s_countrycodes[] =
{
- long code;
- AnalogVideoStandard standard;
- const TCHAR* str;
-} s_countrycodes[] =
-{
- {1, AnalogVideo_NTSC_M, _T("USA")},
- {2, AnalogVideo_NTSC_M, _T("Canada")},
- {7, AnalogVideo_SECAM_D, _T("Russia")},
- {20, AnalogVideo_SECAM_B, _T("Egypt")},
- {27, AnalogVideo_PAL_I, _T("South Africa")},
- {30, AnalogVideo_SECAM_B, _T("Greece")},
- {31, AnalogVideo_PAL_B, _T("Netherlands")},
- {32, AnalogVideo_PAL_B, _T("Belgium")},
- {33, AnalogVideo_SECAM_L, _T("France")},
- {34, AnalogVideo_PAL_B, _T("Spain")},
- {36, AnalogVideo_SECAM_D, _T("Hungary")},
- {39, AnalogVideo_PAL_B, _T("Italy")},
- {39, AnalogVideo_PAL_B, _T("Vatican City")},
- {40, AnalogVideo_PAL_D, _T("Romania")},
- {41, AnalogVideo_PAL_B, _T("Switzerland")},
- {41, AnalogVideo_PAL_B, _T("Liechtenstein")},
- {43, AnalogVideo_PAL_B, _T("Austria")},
- {44, AnalogVideo_PAL_I, _T("United Kingdom")},
- {45, AnalogVideo_PAL_B, _T("Denmark")},
- {46, AnalogVideo_PAL_B, _T("Sweden")},
- {47, AnalogVideo_PAL_B, _T("Norway")},
- {48, AnalogVideo_PAL_B, _T("Poland")},
- {49, AnalogVideo_PAL_B, _T("Germany")},
- {51, AnalogVideo_NTSC_M, _T("Peru")},
- {52, AnalogVideo_NTSC_M, _T("Mexico")},
- {53, AnalogVideo_NTSC_M, _T("Cuba")},
- {53, AnalogVideo_NTSC_M, _T("Guantanamo Bay")},
- {54, AnalogVideo_PAL_N, _T("Argentina")},
- {55, AnalogVideo_PAL_M, _T("Brazil")},
- {56, AnalogVideo_NTSC_M, _T("Chile")},
- {57, AnalogVideo_NTSC_M, _T("Colombia")},
- {58, AnalogVideo_NTSC_M, _T("Bolivarian Republic of Venezuela")},
- {60, AnalogVideo_PAL_B, _T("Malaysia")},
- {61, AnalogVideo_PAL_B, _T("Australia")},
- {62, AnalogVideo_PAL_B, _T("Indonesia")},
- {63, AnalogVideo_NTSC_M, _T("Philippines")},
- {64, AnalogVideo_PAL_B, _T("New Zealand")},
- {65, AnalogVideo_PAL_B, _T("Singapore")},
- {66, AnalogVideo_PAL_B, _T("Thailand")},
- {81, AnalogVideo_NTSC_M_J, _T("Japan")},
- {82, AnalogVideo_NTSC_M, _T("Korea (South)")},
- {84, AnalogVideo_NTSC_M, _T("Vietnam")},
- {86, AnalogVideo_PAL_D, _T("China")},
- {90, AnalogVideo_PAL_B, _T("Turkey")},
- {91, AnalogVideo_PAL_B, _T("India")},
- {92, AnalogVideo_PAL_B, _T("Pakistan")},
- {93, AnalogVideo_PAL_B, _T("Afghanistan")},
- {94, AnalogVideo_PAL_B, _T("Sri Lanka")},
- {95, AnalogVideo_NTSC_M, _T("Myanmar")},
- {98, AnalogVideo_SECAM_B, _T("Iran")},
- {212, AnalogVideo_SECAM_B, _T("Morocco")},
- {213, AnalogVideo_PAL_B, _T("Algeria")},
- {216, AnalogVideo_SECAM_B, _T("Tunisia")},
- {218, AnalogVideo_SECAM_B, _T("Libya")},
- {220, AnalogVideo_SECAM_K, _T("Gambia")},
- {221, AnalogVideo_SECAM_K, _T("Senegal Republic")},
- {222, AnalogVideo_SECAM_B, _T("Mauritania")},
- {223, AnalogVideo_SECAM_K, _T("Mali")},
- {224, AnalogVideo_SECAM_K, _T("Guinea")},
- {225, AnalogVideo_SECAM_K, _T("Cote D'Ivoire")},
- {226, AnalogVideo_SECAM_K, _T("Burkina Faso")},
- {227, AnalogVideo_SECAM_K, _T("Niger")},
- {228, AnalogVideo_SECAM_K, _T("Togo")},
- {229, AnalogVideo_SECAM_K, _T("Benin")},
- {230, AnalogVideo_SECAM_B, _T("Mauritius")},
- {231, AnalogVideo_PAL_B, _T("Liberia")},
- {232, AnalogVideo_PAL_B, _T("Sierra Leone")},
- {233, AnalogVideo_PAL_B, _T("Ghana")},
- {234, AnalogVideo_PAL_B, _T("Nigeria")},
- {235, AnalogVideo_PAL_B, _T("Chad")},
- {236, AnalogVideo_PAL_B, _T("Central African Republic")},
- {237, AnalogVideo_PAL_B, _T("Cameroon")},
- {238, AnalogVideo_NTSC_M, _T("Cape Verde Islands")},
- {239, AnalogVideo_PAL_B, _T("Sao Tome and Principe")},
- {240, AnalogVideo_SECAM_B, _T("Equatorial Guinea")},
- {241, AnalogVideo_SECAM_K, _T("Gabon")},
- {242, AnalogVideo_SECAM_D, _T("Congo")},
- {243, AnalogVideo_SECAM_K, _T("Congo(DRC)")},
- {244, AnalogVideo_PAL_I, _T("Angola")},
- {245, AnalogVideo_NTSC_M, _T("Guinea-Bissau")},
- {246, AnalogVideo_NTSC_M, _T("Diego Garcia")},
- {247, AnalogVideo_NTSC_M, _T("Ascension Island")},
- {248, AnalogVideo_PAL_B, _T("Seychelle Islands")},
- {249, AnalogVideo_PAL_B, _T("Sudan")},
- {250, AnalogVideo_PAL_B, _T("Rwanda")},
- {251, AnalogVideo_PAL_B, _T("Ethiopia")},
- {252, AnalogVideo_PAL_B, _T("Somalia")},
- {253, AnalogVideo_SECAM_K, _T("Djibouti")},
- {254, AnalogVideo_PAL_B, _T("Kenya")},
- {255, AnalogVideo_PAL_B, _T("Tanzania")},
- {256, AnalogVideo_PAL_B, _T("Uganda")},
- {257, AnalogVideo_SECAM_K, _T("Burundi")},
- {258, AnalogVideo_PAL_B, _T("Mozambique")},
- {260, AnalogVideo_PAL_B, _T("Zambia")},
- {261, AnalogVideo_SECAM_K, _T("Madagascar")},
- {262, AnalogVideo_SECAM_K, _T("Reunion Island")},
- {263, AnalogVideo_PAL_B, _T("Zimbabwe")},
- {264, AnalogVideo_PAL_I, _T("Namibia")},
- {265, AnalogVideo_NTSC_M, _T("Malawi")},
- {266, AnalogVideo_PAL_I, _T("Lesotho")},
- {267, AnalogVideo_SECAM_K, _T("Botswana")},
- {268, AnalogVideo_PAL_B, _T("Swaziland")},
- {269, AnalogVideo_SECAM_K, _T("Mayotte Island")},
- {290, AnalogVideo_NTSC_M, _T("St. Helena")},
- {291, AnalogVideo_NTSC_M, _T("Eritrea")},
- {297, AnalogVideo_NTSC_M, _T("Aruba")},
- {298, AnalogVideo_PAL_B, _T("Faroe Islands")},
- {299, AnalogVideo_NTSC_M, _T("Greenland")},
- {350, AnalogVideo_PAL_B, _T("Gibraltar")},
- {351, AnalogVideo_PAL_B, _T("Portugal")},
- {352, AnalogVideo_PAL_B, _T("Luxembourg")},
- {353, AnalogVideo_PAL_I, _T("Ireland")},
- {354, AnalogVideo_PAL_B, _T("Iceland")},
- {355, AnalogVideo_PAL_B, _T("Albania")},
- {356, AnalogVideo_PAL_B, _T("Malta")},
- {357, AnalogVideo_PAL_B, _T("Cyprus")},
- {358, AnalogVideo_PAL_B, _T("Finland")},
- {359, AnalogVideo_SECAM_D, _T("Bulgaria")},
- {370, AnalogVideo_PAL_B, _T("Lithuania")},
- {371, AnalogVideo_SECAM_D, _T("Latvia")},
- {372, AnalogVideo_PAL_B, _T("Estonia")},
- {373, AnalogVideo_SECAM_D, _T("Moldova")},
- {374, AnalogVideo_SECAM_D, _T("Armenia")},
- {375, AnalogVideo_SECAM_D, _T("Belarus")},
- {376, AnalogVideo_NTSC_M, _T("Andorra")},
- {377, AnalogVideo_SECAM_G, _T("Monaco")},
- {378, AnalogVideo_PAL_B, _T("San Marino")},
- {380, AnalogVideo_SECAM_D, _T("Ukraine")},
- {381, AnalogVideo_PAL_B, _T("Serbia and Montenegro")},
- {385, AnalogVideo_PAL_B, _T("Croatia")},
- {386, AnalogVideo_PAL_B, _T("Slovenia")},
- {387, AnalogVideo_PAL_B, _T("Bosnia and Herzegovina")},
- {389, AnalogVideo_PAL_B, _T("F.Y.R.O.M. (Former Yugoslav Republic of Macedonia)")},
- {420, AnalogVideo_PAL_D, _T("Czech Republic")},
- {421, AnalogVideo_PAL_B, _T("Slovak Republic")},
- {500, AnalogVideo_PAL_I, _T("Falkland Islands (Islas Malvinas)")},
- {501, AnalogVideo_NTSC_M, _T("Belize")},
- {502, AnalogVideo_NTSC_M, _T("Guatemala")},
- {503, AnalogVideo_NTSC_M, _T("El Salvador")},
- {504, AnalogVideo_NTSC_M, _T("Honduras")},
- {505, AnalogVideo_NTSC_M, _T("Nicaragua")},
- {506, AnalogVideo_NTSC_M, _T("Costa Rica")},
- {507, AnalogVideo_NTSC_M, _T("Panama")},
- {508, AnalogVideo_SECAM_K, _T("St. Pierre and Miquelon")},
- {509, AnalogVideo_NTSC_M, _T("Haiti")},
- {590, AnalogVideo_SECAM_K, _T("Guadeloupe")},
- {591, AnalogVideo_PAL_N, _T("Bolivia")},
- {592, AnalogVideo_SECAM_K, _T("Guyana")},
- {593, AnalogVideo_NTSC_M, _T("Ecuador")},
- {594, AnalogVideo_SECAM_K, _T("French Guiana")},
- {595, AnalogVideo_PAL_N, _T("Paraguay")},
- {596, AnalogVideo_SECAM_K, _T("Martinique")},
- {597, AnalogVideo_NTSC_M, _T("Suriname")},
- {598, AnalogVideo_PAL_N, _T("Uruguay")},
- {599, AnalogVideo_NTSC_M, _T("Netherlands Antilles")},
- {670, AnalogVideo_NTSC_M, _T("Saipan Island")},
- {671, AnalogVideo_NTSC_M, _T("Guam")},
- {672, AnalogVideo_NTSC_M, _T("Christmas Island")},
- {672, AnalogVideo_NTSC_M, _T("Australian Antarctic Territory")},
- {673, AnalogVideo_PAL_B, _T("Brunei")},
- {674, AnalogVideo_NTSC_M, _T("Nauru")},
- {675, AnalogVideo_PAL_B, _T("Papua New Guinea")},
- {676, AnalogVideo_NTSC_M, _T("Tonga")},
- {677, AnalogVideo_NTSC_M, _T("Solomon Islands")},
- {678, AnalogVideo_NTSC_M, _T("Vanuatu")},
- {679, AnalogVideo_NTSC_M, _T("Fiji Islands")},
- {680, AnalogVideo_NTSC_M, _T("Palau")},
- {681, AnalogVideo_SECAM_K, _T("Wallis and Futuna Islands")},
- {682, AnalogVideo_PAL_B, _T("Cook Islands")},
- {683, AnalogVideo_NTSC_M, _T("Niue")},
- {684, AnalogVideo_NTSC_M, _T("Territory of American Samoa")},
- {685, AnalogVideo_PAL_B, _T("Samoa")},
- {686, AnalogVideo_PAL_B, _T("Kiribati Republic")},
- {687, AnalogVideo_SECAM_K, _T("New Caledonia")},
- {688, AnalogVideo_NTSC_M, _T("Tuvalu")},
- {689, AnalogVideo_SECAM_K, _T("French Polynesia")},
- {690, AnalogVideo_NTSC_M, _T("Tokelau")},
- {691, AnalogVideo_NTSC_M, _T("Micronesia")},
- {692, AnalogVideo_NTSC_M, _T("Marshall Islands")},
- {850, AnalogVideo_SECAM_D, _T("Korea (North)")},
- {852, AnalogVideo_PAL_I, _T("Hong Kong SAR")},
- {853, AnalogVideo_PAL_I, _T("Macao SAR")},
- {855, AnalogVideo_PAL_B, _T("Cambodia")},
- {856, AnalogVideo_PAL_B, _T("Laos")},
- {871, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-East)")},
- {872, AnalogVideo_NTSC_M, _T("INMARSAT (Pacific)")},
- {873, AnalogVideo_NTSC_M, _T("INMARSAT (Indian)")},
- {874, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-West)")},
- {880, AnalogVideo_PAL_B, _T("Bangladesh")},
- {886, AnalogVideo_NTSC_M, _T("Taiwan")},
- {960, AnalogVideo_PAL_B, _T("Maldives")},
- {961, AnalogVideo_SECAM_B, _T("Lebanon")},
- {962, AnalogVideo_PAL_B, _T("Jordan")},
- {963, AnalogVideo_SECAM_B, _T("Syria")},
- {964, AnalogVideo_SECAM_B, _T("Iraq")},
- {965, AnalogVideo_PAL_B, _T("Kuwait")},
- {966, AnalogVideo_SECAM_B, _T("Saudi Arabia")},
- {967, AnalogVideo_PAL_B, _T("Yemen")},
- {968, AnalogVideo_PAL_B, _T("Oman")},
- {971, AnalogVideo_PAL_B, _T("United Arab Emirates")},
- {972, AnalogVideo_PAL_B, _T("Israel")},
- {973, AnalogVideo_PAL_B, _T("Bahrain")},
- {974, AnalogVideo_PAL_B, _T("Qatar")},
- {975, AnalogVideo_NTSC_M, _T("Bhutan")},
- {976, AnalogVideo_SECAM_D, _T("Mongolia")},
- {977, AnalogVideo_PAL_B, _T("Nepal")},
- {994, AnalogVideo_SECAM_D, _T("Azerbaijan")},
- {995, AnalogVideo_SECAM_D, _T("Georgia")},
+ {1, AnalogVideo_NTSC_M, _T("USA")},
+ {2, AnalogVideo_NTSC_M, _T("Canada")},
+ {7, AnalogVideo_SECAM_D, _T("Russia")},
+ {20, AnalogVideo_SECAM_B, _T("Egypt")},
+ {27, AnalogVideo_PAL_I, _T("South Africa")},
+ {30, AnalogVideo_SECAM_B, _T("Greece")},
+ {31, AnalogVideo_PAL_B, _T("Netherlands")},
+ {32, AnalogVideo_PAL_B, _T("Belgium")},
+ {33, AnalogVideo_SECAM_L, _T("France")},
+ {34, AnalogVideo_PAL_B, _T("Spain")},
+ {36, AnalogVideo_SECAM_D, _T("Hungary")},
+ {39, AnalogVideo_PAL_B, _T("Italy")},
+ {39, AnalogVideo_PAL_B, _T("Vatican City")},
+ {40, AnalogVideo_PAL_D, _T("Romania")},
+ {41, AnalogVideo_PAL_B, _T("Switzerland")},
+ {41, AnalogVideo_PAL_B, _T("Liechtenstein")},
+ {43, AnalogVideo_PAL_B, _T("Austria")},
+ {44, AnalogVideo_PAL_I, _T("United Kingdom")},
+ {45, AnalogVideo_PAL_B, _T("Denmark")},
+ {46, AnalogVideo_PAL_B, _T("Sweden")},
+ {47, AnalogVideo_PAL_B, _T("Norway")},
+ {48, AnalogVideo_PAL_B, _T("Poland")},
+ {49, AnalogVideo_PAL_B, _T("Germany")},
+ {51, AnalogVideo_NTSC_M, _T("Peru")},
+ {52, AnalogVideo_NTSC_M, _T("Mexico")},
+ {53, AnalogVideo_NTSC_M, _T("Cuba")},
+ {53, AnalogVideo_NTSC_M, _T("Guantanamo Bay")},
+ {54, AnalogVideo_PAL_N, _T("Argentina")},
+ {55, AnalogVideo_PAL_M, _T("Brazil")},
+ {56, AnalogVideo_NTSC_M, _T("Chile")},
+ {57, AnalogVideo_NTSC_M, _T("Colombia")},
+ {58, AnalogVideo_NTSC_M, _T("Bolivarian Republic of Venezuela")},
+ {60, AnalogVideo_PAL_B, _T("Malaysia")},
+ {61, AnalogVideo_PAL_B, _T("Australia")},
+ {62, AnalogVideo_PAL_B, _T("Indonesia")},
+ {63, AnalogVideo_NTSC_M, _T("Philippines")},
+ {64, AnalogVideo_PAL_B, _T("New Zealand")},
+ {65, AnalogVideo_PAL_B, _T("Singapore")},
+ {66, AnalogVideo_PAL_B, _T("Thailand")},
+ {81, AnalogVideo_NTSC_M_J, _T("Japan")},
+ {82, AnalogVideo_NTSC_M, _T("Korea (South)")},
+ {84, AnalogVideo_NTSC_M, _T("Vietnam")},
+ {86, AnalogVideo_PAL_D, _T("China")},
+ {90, AnalogVideo_PAL_B, _T("Turkey")},
+ {91, AnalogVideo_PAL_B, _T("India")},
+ {92, AnalogVideo_PAL_B, _T("Pakistan")},
+ {93, AnalogVideo_PAL_B, _T("Afghanistan")},
+ {94, AnalogVideo_PAL_B, _T("Sri Lanka")},
+ {95, AnalogVideo_NTSC_M, _T("Myanmar")},
+ {98, AnalogVideo_SECAM_B, _T("Iran")},
+ {212, AnalogVideo_SECAM_B, _T("Morocco")},
+ {213, AnalogVideo_PAL_B, _T("Algeria")},
+ {216, AnalogVideo_SECAM_B, _T("Tunisia")},
+ {218, AnalogVideo_SECAM_B, _T("Libya")},
+ {220, AnalogVideo_SECAM_K, _T("Gambia")},
+ {221, AnalogVideo_SECAM_K, _T("Senegal Republic")},
+ {222, AnalogVideo_SECAM_B, _T("Mauritania")},
+ {223, AnalogVideo_SECAM_K, _T("Mali")},
+ {224, AnalogVideo_SECAM_K, _T("Guinea")},
+ {225, AnalogVideo_SECAM_K, _T("Cote D'Ivoire")},
+ {226, AnalogVideo_SECAM_K, _T("Burkina Faso")},
+ {227, AnalogVideo_SECAM_K, _T("Niger")},
+ {228, AnalogVideo_SECAM_K, _T("Togo")},
+ {229, AnalogVideo_SECAM_K, _T("Benin")},
+ {230, AnalogVideo_SECAM_B, _T("Mauritius")},
+ {231, AnalogVideo_PAL_B, _T("Liberia")},
+ {232, AnalogVideo_PAL_B, _T("Sierra Leone")},
+ {233, AnalogVideo_PAL_B, _T("Ghana")},
+ {234, AnalogVideo_PAL_B, _T("Nigeria")},
+ {235, AnalogVideo_PAL_B, _T("Chad")},
+ {236, AnalogVideo_PAL_B, _T("Central African Republic")},
+ {237, AnalogVideo_PAL_B, _T("Cameroon")},
+ {238, AnalogVideo_NTSC_M, _T("Cape Verde Islands")},
+ {239, AnalogVideo_PAL_B, _T("Sao Tome and Principe")},
+ {240, AnalogVideo_SECAM_B, _T("Equatorial Guinea")},
+ {241, AnalogVideo_SECAM_K, _T("Gabon")},
+ {242, AnalogVideo_SECAM_D, _T("Congo")},
+ {243, AnalogVideo_SECAM_K, _T("Congo(DRC)")},
+ {244, AnalogVideo_PAL_I, _T("Angola")},
+ {245, AnalogVideo_NTSC_M, _T("Guinea-Bissau")},
+ {246, AnalogVideo_NTSC_M, _T("Diego Garcia")},
+ {247, AnalogVideo_NTSC_M, _T("Ascension Island")},
+ {248, AnalogVideo_PAL_B, _T("Seychelle Islands")},
+ {249, AnalogVideo_PAL_B, _T("Sudan")},
+ {250, AnalogVideo_PAL_B, _T("Rwanda")},
+ {251, AnalogVideo_PAL_B, _T("Ethiopia")},
+ {252, AnalogVideo_PAL_B, _T("Somalia")},
+ {253, AnalogVideo_SECAM_K, _T("Djibouti")},
+ {254, AnalogVideo_PAL_B, _T("Kenya")},
+ {255, AnalogVideo_PAL_B, _T("Tanzania")},
+ {256, AnalogVideo_PAL_B, _T("Uganda")},
+ {257, AnalogVideo_SECAM_K, _T("Burundi")},
+ {258, AnalogVideo_PAL_B, _T("Mozambique")},
+ {260, AnalogVideo_PAL_B, _T("Zambia")},
+ {261, AnalogVideo_SECAM_K, _T("Madagascar")},
+ {262, AnalogVideo_SECAM_K, _T("Reunion Island")},
+ {263, AnalogVideo_PAL_B, _T("Zimbabwe")},
+ {264, AnalogVideo_PAL_I, _T("Namibia")},
+ {265, AnalogVideo_NTSC_M, _T("Malawi")},
+ {266, AnalogVideo_PAL_I, _T("Lesotho")},
+ {267, AnalogVideo_SECAM_K, _T("Botswana")},
+ {268, AnalogVideo_PAL_B, _T("Swaziland")},
+ {269, AnalogVideo_SECAM_K, _T("Mayotte Island")},
+ {290, AnalogVideo_NTSC_M, _T("St. Helena")},
+ {291, AnalogVideo_NTSC_M, _T("Eritrea")},
+ {297, AnalogVideo_NTSC_M, _T("Aruba")},
+ {298, AnalogVideo_PAL_B, _T("Faroe Islands")},
+ {299, AnalogVideo_NTSC_M, _T("Greenland")},
+ {350, AnalogVideo_PAL_B, _T("Gibraltar")},
+ {351, AnalogVideo_PAL_B, _T("Portugal")},
+ {352, AnalogVideo_PAL_B, _T("Luxembourg")},
+ {353, AnalogVideo_PAL_I, _T("Ireland")},
+ {354, AnalogVideo_PAL_B, _T("Iceland")},
+ {355, AnalogVideo_PAL_B, _T("Albania")},
+ {356, AnalogVideo_PAL_B, _T("Malta")},
+ {357, AnalogVideo_PAL_B, _T("Cyprus")},
+ {358, AnalogVideo_PAL_B, _T("Finland")},
+ {359, AnalogVideo_SECAM_D, _T("Bulgaria")},
+ {370, AnalogVideo_PAL_B, _T("Lithuania")},
+ {371, AnalogVideo_SECAM_D, _T("Latvia")},
+ {372, AnalogVideo_PAL_B, _T("Estonia")},
+ {373, AnalogVideo_SECAM_D, _T("Moldova")},
+ {374, AnalogVideo_SECAM_D, _T("Armenia")},
+ {375, AnalogVideo_SECAM_D, _T("Belarus")},
+ {376, AnalogVideo_NTSC_M, _T("Andorra")},
+ {377, AnalogVideo_SECAM_G, _T("Monaco")},
+ {378, AnalogVideo_PAL_B, _T("San Marino")},
+ {380, AnalogVideo_SECAM_D, _T("Ukraine")},
+ {381, AnalogVideo_PAL_B, _T("Serbia and Montenegro")},
+ {385, AnalogVideo_PAL_B, _T("Croatia")},
+ {386, AnalogVideo_PAL_B, _T("Slovenia")},
+ {387, AnalogVideo_PAL_B, _T("Bosnia and Herzegovina")},
+ {389, AnalogVideo_PAL_B, _T("F.Y.R.O.M. (Former Yugoslav Republic of Macedonia)")},
+ {420, AnalogVideo_PAL_D, _T("Czech Republic")},
+ {421, AnalogVideo_PAL_B, _T("Slovak Republic")},
+ {500, AnalogVideo_PAL_I, _T("Falkland Islands (Islas Malvinas)")},
+ {501, AnalogVideo_NTSC_M, _T("Belize")},
+ {502, AnalogVideo_NTSC_M, _T("Guatemala")},
+ {503, AnalogVideo_NTSC_M, _T("El Salvador")},
+ {504, AnalogVideo_NTSC_M, _T("Honduras")},
+ {505, AnalogVideo_NTSC_M, _T("Nicaragua")},
+ {506, AnalogVideo_NTSC_M, _T("Costa Rica")},
+ {507, AnalogVideo_NTSC_M, _T("Panama")},
+ {508, AnalogVideo_SECAM_K, _T("St. Pierre and Miquelon")},
+ {509, AnalogVideo_NTSC_M, _T("Haiti")},
+ {590, AnalogVideo_SECAM_K, _T("Guadeloupe")},
+ {591, AnalogVideo_PAL_N, _T("Bolivia")},
+ {592, AnalogVideo_SECAM_K, _T("Guyana")},
+ {593, AnalogVideo_NTSC_M, _T("Ecuador")},
+ {594, AnalogVideo_SECAM_K, _T("French Guiana")},
+ {595, AnalogVideo_PAL_N, _T("Paraguay")},
+ {596, AnalogVideo_SECAM_K, _T("Martinique")},
+ {597, AnalogVideo_NTSC_M, _T("Suriname")},
+ {598, AnalogVideo_PAL_N, _T("Uruguay")},
+ {599, AnalogVideo_NTSC_M, _T("Netherlands Antilles")},
+ {670, AnalogVideo_NTSC_M, _T("Saipan Island")},
+ {671, AnalogVideo_NTSC_M, _T("Guam")},
+ {672, AnalogVideo_NTSC_M, _T("Christmas Island")},
+ {672, AnalogVideo_NTSC_M, _T("Australian Antarctic Territory")},
+ {673, AnalogVideo_PAL_B, _T("Brunei")},
+ {674, AnalogVideo_NTSC_M, _T("Nauru")},
+ {675, AnalogVideo_PAL_B, _T("Papua New Guinea")},
+ {676, AnalogVideo_NTSC_M, _T("Tonga")},
+ {677, AnalogVideo_NTSC_M, _T("Solomon Islands")},
+ {678, AnalogVideo_NTSC_M, _T("Vanuatu")},
+ {679, AnalogVideo_NTSC_M, _T("Fiji Islands")},
+ {680, AnalogVideo_NTSC_M, _T("Palau")},
+ {681, AnalogVideo_SECAM_K, _T("Wallis and Futuna Islands")},
+ {682, AnalogVideo_PAL_B, _T("Cook Islands")},
+ {683, AnalogVideo_NTSC_M, _T("Niue")},
+ {684, AnalogVideo_NTSC_M, _T("Territory of American Samoa")},
+ {685, AnalogVideo_PAL_B, _T("Samoa")},
+ {686, AnalogVideo_PAL_B, _T("Kiribati Republic")},
+ {687, AnalogVideo_SECAM_K, _T("New Caledonia")},
+ {688, AnalogVideo_NTSC_M, _T("Tuvalu")},
+ {689, AnalogVideo_SECAM_K, _T("French Polynesia")},
+ {690, AnalogVideo_NTSC_M, _T("Tokelau")},
+ {691, AnalogVideo_NTSC_M, _T("Micronesia")},
+ {692, AnalogVideo_NTSC_M, _T("Marshall Islands")},
+ {850, AnalogVideo_SECAM_D, _T("Korea (North)")},
+ {852, AnalogVideo_PAL_I, _T("Hong Kong SAR")},
+ {853, AnalogVideo_PAL_I, _T("Macao SAR")},
+ {855, AnalogVideo_PAL_B, _T("Cambodia")},
+ {856, AnalogVideo_PAL_B, _T("Laos")},
+ {871, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-East)")},
+ {872, AnalogVideo_NTSC_M, _T("INMARSAT (Pacific)")},
+ {873, AnalogVideo_NTSC_M, _T("INMARSAT (Indian)")},
+ {874, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-West)")},
+ {880, AnalogVideo_PAL_B, _T("Bangladesh")},
+ {886, AnalogVideo_NTSC_M, _T("Taiwan")},
+ {960, AnalogVideo_PAL_B, _T("Maldives")},
+ {961, AnalogVideo_SECAM_B, _T("Lebanon")},
+ {962, AnalogVideo_PAL_B, _T("Jordan")},
+ {963, AnalogVideo_SECAM_B, _T("Syria")},
+ {964, AnalogVideo_SECAM_B, _T("Iraq")},
+ {965, AnalogVideo_PAL_B, _T("Kuwait")},
+ {966, AnalogVideo_SECAM_B, _T("Saudi Arabia")},
+ {967, AnalogVideo_PAL_B, _T("Yemen")},
+ {968, AnalogVideo_PAL_B, _T("Oman")},
+ {971, AnalogVideo_PAL_B, _T("United Arab Emirates")},
+ {972, AnalogVideo_PAL_B, _T("Israel")},
+ {973, AnalogVideo_PAL_B, _T("Bahrain")},
+ {974, AnalogVideo_PAL_B, _T("Qatar")},
+ {975, AnalogVideo_NTSC_M, _T("Bhutan")},
+ {976, AnalogVideo_SECAM_D, _T("Mongolia")},
+ {977, AnalogVideo_PAL_B, _T("Nepal")},
+ {994, AnalogVideo_SECAM_D, _T("Azerbaijan")},
+ {995, AnalogVideo_SECAM_D,_T("Georgia")},
};
@@ -258,8 +253,8 @@ static struct cc_t
IMPLEMENT_DYNAMIC(CPPageCapture, CPPageBase)
CPPageCapture::CPPageCapture()
- : CPPageBase(CPPageCapture::IDD, CPPageCapture::IDD)
- , m_iDefaultDevice(0)
+ : CPPageBase(CPPageCapture::IDD, CPPageCapture::IDD)
+ , m_iDefaultDevice(0)
{
}
@@ -270,14 +265,14 @@ CPPageCapture::~CPPageCapture()
void CPPageCapture::DoDataExchange(CDataExchange* pDX)
{
- CPPageBase::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_cbAnalogVideo);
- DDX_Control(pDX, IDC_COMBO2, m_cbAnalogAudio);
- DDX_Control(pDX, IDC_COMBO9, m_cbAnalogCountry);
- DDX_Control(pDX, IDC_COMBO4, m_cbDigitalNetworkProvider);
- DDX_Control(pDX, IDC_COMBO5, m_cbDigitalTuner);
- DDX_Control(pDX, IDC_COMBO3, m_cbDigitalReceiver);
- DDX_Radio(pDX, IDC_RADIO1, m_iDefaultDevice);
+ CPPageBase::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_cbAnalogVideo);
+ DDX_Control(pDX, IDC_COMBO2, m_cbAnalogAudio);
+ DDX_Control(pDX, IDC_COMBO9, m_cbAnalogCountry);
+ DDX_Control(pDX, IDC_COMBO4, m_cbDigitalNetworkProvider);
+ DDX_Control(pDX, IDC_COMBO5, m_cbDigitalTuner);
+ DDX_Control(pDX, IDC_COMBO3, m_cbDigitalReceiver);
+ DDX_Radio(pDX, IDC_RADIO1, m_iDefaultDevice);
}
@@ -290,249 +285,209 @@ END_MESSAGE_MAP()
BOOL CPPageCapture::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- SetHandCursor(m_hWnd, IDC_COMBO1);
+ SetHandCursor(m_hWnd, IDC_COMBO1);
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- FindAnalogDevices();
- FindDigitalDevices();
+ FindAnalogDevices();
+ FindDigitalDevices();
- m_iDefaultDevice = s.iDefaultCaptureDevice;
+ m_iDefaultDevice = s.iDefaultCaptureDevice;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE;
+ return TRUE;
}
void CPPageCapture::FindAnalogDevices()
{
- AppSettings& s = AfxGetAppSettings();
- int iSel = 0;
-
- // List video deviced
- BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbAnalogVideo.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
- m_vidnames.Add(CString(strName));
- if(s.strAnalogVideo == CString(strName)) iSel = i;
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
-
- if(m_cbAnalogVideo.GetCount())
- {
- m_cbAnalogVideo.SetCurSel(iSel);
- }
-
- // List audio deviced
- iSel = 0;
- BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbAnalogAudio.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
- m_audnames.Add(CString(strName));
- if(s.strAnalogAudio == CString(strName)) iSel = i;
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if(m_cbAnalogAudio.GetCount())
- m_cbAnalogAudio.SetCurSel(iSel);
-
- // Fill country
- iSel = 0;
- for(int j = 0; j < countof(s_countrycodes); j++)
- {
- CString standard;
- switch(s_countrycodes[j].standard)
- {
- case AnalogVideo_NTSC_M:
- standard = _T("NTSC M");
- break;
- case AnalogVideo_NTSC_M_J:
- standard = _T("NTSC M J");
- break;
- case AnalogVideo_NTSC_433:
- standard = _T("NTSC 433");
- break;
- case AnalogVideo_PAL_B:
- standard = _T("PAL B");
- break;
- case AnalogVideo_PAL_D:
- standard = _T("PAL D");
- break;
- case AnalogVideo_PAL_G:
- standard = _T("PAL G");
- break;
- case AnalogVideo_PAL_H:
- standard = _T("PAL H");
- break;
- case AnalogVideo_PAL_I:
- standard = _T("PAL I");
- break;
- case AnalogVideo_PAL_M:
- standard = _T("PAL M");
- break;
- case AnalogVideo_PAL_N:
- standard = _T("PAL N");
- break;
- case AnalogVideo_PAL_60:
- standard = _T("PAL 60");
- break;
- case AnalogVideo_SECAM_B:
- standard = _T("SECAM B");
- break;
- case AnalogVideo_SECAM_D:
- standard = _T("SECAM D");
- break;
- case AnalogVideo_SECAM_G:
- standard = _T("SECAM G");
- break;
- case AnalogVideo_SECAM_H:
- standard = _T("SECAM H");
- break;
- case AnalogVideo_SECAM_K:
- standard = _T("SECAM K");
- break;
- case AnalogVideo_SECAM_K1:
- standard = _T("SECAM K1");
- break;
- case AnalogVideo_SECAM_L:
- standard = _T("SECAM L");
- break;
- case AnalogVideo_SECAM_L1:
- standard = _T("SECAM L1");
- break;
- case AnalogVideo_PAL_N_COMBO:
- standard = _T("PAL N COMBO");
- break;
- }
-
- CString str;
- str.Format(_T("%d - %s - %s"), s_countrycodes[j].code, s_countrycodes[j].str, standard);
-
- int i = m_cbAnalogCountry.AddString(str);
- m_cbAnalogCountry.SetItemDataPtr(i, &s_countrycodes[j]);
- if(s.iAnalogCountry == s_countrycodes[j].code) iSel = i;
- }
-
- if(m_cbAnalogCountry.GetCount())
- m_cbAnalogCountry.SetCurSel(iSel);
+ AppSettings& s = AfxGetAppSettings();
+ int iSel = 0;
+
+ // List video deviced
+ BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbAnalogVideo.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ {
+ m_vidnames.Add(CString(strName));
+ if(s.strAnalogVideo == CString(strName)) iSel = i;
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+
+ if(m_cbAnalogVideo.GetCount())
+ {
+ m_cbAnalogVideo.SetCurSel(iSel);
+ }
+
+ // List audio deviced
+ iSel = 0;
+ BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbAnalogAudio.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ {
+ m_audnames.Add(CString(strName));
+ if(s.strAnalogAudio == CString(strName)) iSel = i;
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if(m_cbAnalogAudio.GetCount())
+ m_cbAnalogAudio.SetCurSel(iSel);
+
+ // Fill country
+ iSel = 0;
+ for(int j = 0; j < countof(s_countrycodes); j++)
+ {
+ CString standard;
+ switch(s_countrycodes[j].standard)
+ {
+ case AnalogVideo_NTSC_M: standard = _T("NTSC M"); break;
+ case AnalogVideo_NTSC_M_J: standard = _T("NTSC M J"); break;
+ case AnalogVideo_NTSC_433: standard = _T("NTSC 433"); break;
+ case AnalogVideo_PAL_B: standard = _T("PAL B"); break;
+ case AnalogVideo_PAL_D: standard = _T("PAL D"); break;
+ case AnalogVideo_PAL_G: standard = _T("PAL G"); break;
+ case AnalogVideo_PAL_H: standard = _T("PAL H"); break;
+ case AnalogVideo_PAL_I: standard = _T("PAL I"); break;
+ case AnalogVideo_PAL_M: standard = _T("PAL M"); break;
+ case AnalogVideo_PAL_N: standard = _T("PAL N"); break;
+ case AnalogVideo_PAL_60: standard = _T("PAL 60"); break;
+ case AnalogVideo_SECAM_B: standard = _T("SECAM B"); break;
+ case AnalogVideo_SECAM_D: standard = _T("SECAM D"); break;
+ case AnalogVideo_SECAM_G: standard = _T("SECAM G"); break;
+ case AnalogVideo_SECAM_H: standard = _T("SECAM H"); break;
+ case AnalogVideo_SECAM_K: standard = _T("SECAM K"); break;
+ case AnalogVideo_SECAM_K1: standard = _T("SECAM K1"); break;
+ case AnalogVideo_SECAM_L: standard = _T("SECAM L"); break;
+ case AnalogVideo_SECAM_L1: standard = _T("SECAM L1"); break;
+ case AnalogVideo_PAL_N_COMBO: standard = _T("PAL N COMBO"); break;
+ }
+
+ CString str;
+ str.Format(_T("%d - %s - %s"), s_countrycodes[j].code, s_countrycodes[j].str, standard);
+
+ int i = m_cbAnalogCountry.AddString(str);
+ m_cbAnalogCountry.SetItemDataPtr(i, &s_countrycodes[j]);
+ if(s.iAnalogCountry == s_countrycodes[j].code) iSel = i;
+ }
+
+ if(m_cbAnalogCountry.GetCount())
+ m_cbAnalogCountry.SetCurSel(iSel);
}
void CPPageCapture::FindDigitalDevices()
{
- AppSettings& s = AfxGetAppSettings();
- int iSel = 0;
-
- BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_PROVIDER, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbDigitalNetworkProvider.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
- m_providernames.Add(CString(strName));
- if(s.BDANetworkProvider == CString(strName)) iSel = i;
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if(m_cbDigitalNetworkProvider.GetCount())
- m_cbDigitalNetworkProvider.SetCurSel(iSel);
-
-
- iSel = 0;
- BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_TUNER, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbDigitalTuner.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
- m_tunernames.Add(CString(strName));
- if(s.BDATuner == CString(strName)) iSel = i;
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if(m_cbDigitalTuner.GetCount())
- m_cbDigitalTuner.SetCurSel(iSel);
-
- iSel = 0;
- BeginEnumSysDev(KSCATEGORY_BDA_RECEIVER_COMPONENT, pMoniker)
- {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbDigitalReceiver.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
- m_receivernames.Add(CString(strName));
- if(s.BDAReceiver == CString(strName)) iSel = i;
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if(m_cbDigitalReceiver.GetCount())
- m_cbDigitalReceiver.SetCurSel(iSel);
+ AppSettings& s = AfxGetAppSettings();
+ int iSel = 0;
+
+ BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_PROVIDER, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbDigitalNetworkProvider.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ {
+ m_providernames.Add(CString(strName));
+ if (s.BDANetworkProvider == CString(strName)) iSel = i;
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if(m_cbDigitalNetworkProvider.GetCount())
+ m_cbDigitalNetworkProvider.SetCurSel(iSel);
+
+
+ iSel = 0;
+ BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_TUNER, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbDigitalTuner.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ {
+ m_tunernames.Add(CString(strName));
+ if (s.BDATuner == CString(strName)) iSel = i;
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if(m_cbDigitalTuner.GetCount())
+ m_cbDigitalTuner.SetCurSel(iSel);
+
+ iSel = 0;
+ BeginEnumSysDev(KSCATEGORY_BDA_RECEIVER_COMPONENT, pMoniker)
+ {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbDigitalReceiver.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ {
+ m_receivernames.Add(CString(strName));
+ if (s.BDAReceiver == CString(strName)) iSel = i;
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if(m_cbDigitalReceiver.GetCount())
+ m_cbDigitalReceiver.SetCurSel(iSel);
}
BOOL CPPageCapture::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.iDefaultCaptureDevice = m_iDefaultDevice;
+ s.iDefaultCaptureDevice = m_iDefaultDevice;
- if(m_cbAnalogVideo.GetCurSel() >= 0)
- s.strAnalogVideo = m_vidnames[m_cbAnalogVideo.GetCurSel()];
- if(m_cbAnalogAudio.GetCurSel() >= 0)
- s.strAnalogAudio = m_audnames[m_cbAnalogAudio.GetCurSel()];
- if(m_cbAnalogCountry.GetCurSel() >= 0)
- s.iAnalogCountry = ((cc_t*)m_cbAnalogCountry.GetItemDataPtr(m_cbAnalogCountry.GetCurSel()))->code;
+ if (m_cbAnalogVideo.GetCurSel()>=0)
+ s.strAnalogVideo = m_vidnames[m_cbAnalogVideo.GetCurSel()];
+ if (m_cbAnalogAudio.GetCurSel()>=0)
+ s.strAnalogAudio = m_audnames[m_cbAnalogAudio.GetCurSel()];
+ if (m_cbAnalogCountry.GetCurSel()>=0)
+ s.iAnalogCountry = ((cc_t*)m_cbAnalogCountry.GetItemDataPtr(m_cbAnalogCountry.GetCurSel()))->code;
- if(m_cbDigitalNetworkProvider.GetCurSel() >= 0)
- s.BDANetworkProvider = m_providernames[m_cbDigitalNetworkProvider.GetCurSel()];
- if(m_cbDigitalTuner.GetCurSel() >= 0)
- s.BDATuner = m_tunernames[m_cbDigitalTuner.GetCurSel()];
- if(m_cbDigitalReceiver.GetCurSel() >= 0)
- s.BDAReceiver = m_receivernames[m_cbDigitalReceiver.GetCurSel()];
+ if (m_cbDigitalNetworkProvider.GetCurSel()>=0)
+ s.BDANetworkProvider = m_providernames[m_cbDigitalNetworkProvider.GetCurSel()];
+ if (m_cbDigitalTuner.GetCurSel()>=0)
+ s.BDATuner = m_tunernames[m_cbDigitalTuner.GetCurSel()];
+ if (m_cbDigitalReceiver.GetCurSel()>=0)
+ s.BDAReceiver = m_receivernames[m_cbDigitalReceiver.GetCurSel()];
- return __super::OnApply();
+ return __super::OnApply();
}
diff --git a/src/apps/mplayerc/PPageCapture.h b/src/apps/mplayerc/PPageCapture.h
index 377f0e147..e78030b26 100644
--- a/src/apps/mplayerc/PPageCapture.h
+++ b/src/apps/mplayerc/PPageCapture.h
@@ -30,32 +30,32 @@
class CPPageCapture : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageCapture)
+ DECLARE_DYNAMIC(CPPageCapture)
- CAtlArray<CString> m_vidnames, m_audnames, m_providernames, m_tunernames, m_receivernames;
+ CAtlArray<CString> m_vidnames, m_audnames, m_providernames, m_tunernames, m_receivernames;
public:
- CPPageCapture(); // standard constructor
- virtual ~CPPageCapture();
+ CPPageCapture(); // standard constructor
+ virtual ~CPPageCapture();
// Dialog Data
- enum { IDD = IDD_PPAGECAPTURE };
+ enum { IDD = IDD_PPAGECAPTURE };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- void FindAnalogDevices();
- void FindDigitalDevices();
+ void FindAnalogDevices();
+ void FindDigitalDevices();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CComboBox m_cbAnalogVideo;
- CComboBox m_cbAnalogAudio;
- CComboBox m_cbAnalogCountry;
- CComboBox m_cbDigitalNetworkProvider;
- CComboBox m_cbDigitalTuner;
- CComboBox m_cbDigitalReceiver;
- int m_iDefaultDevice;
+ CComboBox m_cbAnalogVideo;
+ CComboBox m_cbAnalogAudio;
+ CComboBox m_cbAnalogCountry;
+ CComboBox m_cbDigitalNetworkProvider;
+ CComboBox m_cbDigitalTuner;
+ CComboBox m_cbDigitalReceiver;
+ int m_iDefaultDevice;
};
diff --git a/src/apps/mplayerc/PPageCasimir.cpp b/src/apps/mplayerc/PPageCasimir.cpp
index 81abe1916..67a00182c 100644
--- a/src/apps/mplayerc/PPageCasimir.cpp
+++ b/src/apps/mplayerc/PPageCasimir.cpp
@@ -33,7 +33,7 @@
IMPLEMENT_DYNAMIC(CPPageCasimir, CPPageBase)
CPPageCasimir::CPPageCasimir()
- : CPPageBase(CPPageCasimir::IDD, CPPageCasimir::IDD)
+ : CPPageBase(CPPageCasimir::IDD, CPPageCasimir::IDD)
{
}
@@ -43,17 +43,17 @@ CPPageCasimir::~CPPageCasimir()
void CPPageCasimir::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_SLI_CONTRAST, m_SliContrast);
- DDX_Control(pDX, IDC_SLI_BRIGHTNESS, m_SliBrightness);
- DDX_Control(pDX, IDC_SLI_HUE, m_SliHue);
- DDX_Control(pDX, IDC_SLI_SATURATION, m_SliSaturation);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_SLI_CONTRAST, m_SliContrast);
+ DDX_Control(pDX, IDC_SLI_BRIGHTNESS, m_SliBrightness);
+ DDX_Control(pDX, IDC_SLI_HUE, m_SliHue);
+ DDX_Control(pDX, IDC_SLI_SATURATION, m_SliSaturation);
}
BEGIN_MESSAGE_MAP(CPPageCasimir, CPPageBase)
- ON_WM_HSCROLL()
- ON_BN_CLICKED(IDC_RESET, OnBnClickedReset)
+ ON_WM_HSCROLL()
+ ON_BN_CLICKED(IDC_RESET, OnBnClickedReset)
END_MESSAGE_MAP()
@@ -61,126 +61,126 @@ END_MESSAGE_MAP()
BOOL CPPageCasimir::OnInitDialog()
{
- COLORPROPERTY_RANGE* ControlRange;
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- UpdateData(FALSE);
-
- CreateToolTip();
-
- ControlRange = AfxGetMyApp()->GetColorControl(Contrast);
- if(ControlRange)
- {
- m_dContrast = s.dContrast;
- m_SliContrast.EnableWindow(TRUE);
- m_SliContrast.SetRange((int)ControlRange->MinValue * 100, (int)ControlRange->MaxValue * 100);
- m_SliContrast.SetTicFreq((int)(ControlRange->MaxValue - ControlRange->MinValue) * 10);
- m_SliContrast.SetPos((int)(m_dContrast * 100));
- }
-
- ControlRange = AfxGetMyApp()->GetColorControl(Brightness);
- if(ControlRange)
- {
- m_dBrightness = s.dBrightness;
- m_SliBrightness.EnableWindow(TRUE);
- m_SliBrightness.SetRange((int)ControlRange->MinValue, (int)ControlRange->MaxValue);
- m_SliBrightness.SetTicFreq((int)(ControlRange->MaxValue - ControlRange->MinValue) / 10);
- m_SliBrightness.SetPos((int)m_dBrightness);
- }
-
- ControlRange = AfxGetMyApp()->GetColorControl(Hue);
- if(ControlRange)
- {
- m_dHue = s.dHue;
- m_SliHue.EnableWindow(TRUE);
- m_SliHue.SetRange((int)ControlRange->MinValue, (int)ControlRange->MaxValue);
- m_SliHue.SetTicFreq((int)(ControlRange->MaxValue - ControlRange->MinValue) / 10);
- m_SliHue.SetPos((int)m_dHue);
- }
-
- ControlRange = AfxGetMyApp()->GetColorControl(Saturation);
- if(ControlRange)
- {
- m_dSaturation = s.dSaturation;
- m_SliSaturation.EnableWindow(TRUE);
- m_SliSaturation.SetRange((int)ControlRange->MinValue * 100, (int)ControlRange->MaxValue * 100);
- m_SliSaturation.SetTicFreq((int)(ControlRange->MaxValue - ControlRange->MinValue) * 10);
- m_SliSaturation.SetPos((int)(m_dSaturation * 100));
- }
-
- return TRUE;
+ COLORPROPERTY_RANGE* ControlRange;
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ UpdateData(FALSE);
+
+ CreateToolTip();
+
+ ControlRange = AfxGetMyApp()->GetColorControl (Contrast);
+ if (ControlRange)
+ {
+ m_dContrast = s.dContrast;
+ m_SliContrast.EnableWindow (TRUE);
+ m_SliContrast.SetRange ((int)ControlRange->MinValue*100, (int)ControlRange->MaxValue*100);
+ m_SliContrast.SetTicFreq ((int)(ControlRange->MaxValue - ControlRange->MinValue) * 10);
+ m_SliContrast.SetPos ((int)(m_dContrast*100));
+ }
+
+ ControlRange = AfxGetMyApp()->GetColorControl (Brightness);
+ if (ControlRange)
+ {
+ m_dBrightness = s.dBrightness;
+ m_SliBrightness.EnableWindow (TRUE);
+ m_SliBrightness.SetRange ((int)ControlRange->MinValue, (int)ControlRange->MaxValue);
+ m_SliBrightness.SetTicFreq ((int)(ControlRange->MaxValue - ControlRange->MinValue) / 10);
+ m_SliBrightness.SetPos ((int)m_dBrightness);
+ }
+
+ ControlRange = AfxGetMyApp()->GetColorControl (Hue);
+ if (ControlRange)
+ {
+ m_dHue = s.dHue;
+ m_SliHue.EnableWindow (TRUE);
+ m_SliHue.SetRange ((int)ControlRange->MinValue, (int)ControlRange->MaxValue);
+ m_SliHue.SetTicFreq ((int)(ControlRange->MaxValue - ControlRange->MinValue) / 10);
+ m_SliHue.SetPos ((int)m_dHue);
+ }
+
+ ControlRange = AfxGetMyApp()->GetColorControl (Saturation);
+ if (ControlRange)
+ {
+ m_dSaturation = s.dSaturation;
+ m_SliSaturation.EnableWindow (TRUE);
+ m_SliSaturation.SetRange ((int)ControlRange->MinValue*100, (int)ControlRange->MaxValue*100);
+ m_SliSaturation.SetTicFreq ((int)(ControlRange->MaxValue - ControlRange->MinValue) * 10);
+ m_SliSaturation.SetPos ((int)(m_dSaturation*100));
+ }
+
+ return TRUE;
}
BOOL CPPageCasimir::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.dBrightness = m_dBrightness;
- s.dContrast = m_dContrast;
- s.dHue = m_dHue;
- s.dSaturation = m_dSaturation;
+ s.dBrightness = m_dBrightness;
+ s.dContrast = m_dContrast;
+ s.dHue = m_dHue;
+ s.dSaturation = m_dSaturation;
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageCasimir::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(*pScrollBar == m_SliContrast)
- {
- UpdateData();
- m_dContrast = (float)(m_SliContrast.GetPos() / 100.0);
- }
- else if(*pScrollBar == m_SliBrightness)
- {
- UpdateData();
- m_dBrightness = (float)m_SliBrightness.GetPos();
- }
- else if(*pScrollBar == m_SliHue)
- {
- UpdateData();
- m_dHue = (float)m_SliHue.GetPos();
- }
- else if(*pScrollBar == m_SliSaturation)
- {
- UpdateData();
- m_dSaturation = (float)(m_SliSaturation.GetPos() / 100.0);
- }
-
- SetModified();
-
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetVMR9ColorControl(m_dBrightness, m_dContrast, m_dHue, m_dSaturation);
-
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ if(*pScrollBar == m_SliContrast)
+ {
+ UpdateData();
+ m_dContrast = (float)(m_SliContrast.GetPos()/100.0);
+ }
+ else if(*pScrollBar == m_SliBrightness)
+ {
+ UpdateData();
+ m_dBrightness = (float)m_SliBrightness.GetPos();
+ }
+ else if(*pScrollBar == m_SliHue)
+ {
+ UpdateData();
+ m_dHue = (float)m_SliHue.GetPos();
+ }
+ else if(*pScrollBar == m_SliSaturation)
+ {
+ UpdateData();
+ m_dSaturation = (float)(m_SliSaturation.GetPos()/100.0);
+ }
+
+ SetModified();
+
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetVMR9ColorControl(m_dBrightness, m_dContrast, m_dHue, m_dSaturation);
+
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CPPageCasimir::OnBnClickedReset()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- UpdateData(FALSE);
+ UpdateData(FALSE);
- m_dContrast = AfxGetMyApp()->GetColorControl(Contrast)->DefaultValue;
- m_dBrightness = AfxGetMyApp()->GetColorControl(Brightness)->DefaultValue;
- m_dHue = AfxGetMyApp()->GetColorControl(Hue)->DefaultValue;
- m_dSaturation = AfxGetMyApp()->GetColorControl(Saturation)->DefaultValue;
+ m_dContrast = AfxGetMyApp()->GetColorControl (Contrast)->DefaultValue;
+ m_dBrightness = AfxGetMyApp()->GetColorControl (Brightness)->DefaultValue;
+ m_dHue = AfxGetMyApp()->GetColorControl (Hue)->DefaultValue;
+ m_dSaturation = AfxGetMyApp()->GetColorControl (Saturation)->DefaultValue;
- m_SliContrast.SetPos((int)m_dContrast * 100);
- m_SliBrightness.SetPos((int)m_dBrightness);
- m_SliHue.SetPos((int)m_dHue);
- m_SliSaturation.SetPos((int)m_dSaturation * 100);
+ m_SliContrast.SetPos ((int)m_dContrast*100);
+ m_SliBrightness.SetPos ((int)m_dBrightness);
+ m_SliHue.SetPos ((int)m_dHue);
+ m_SliSaturation.SetPos ((int)m_dSaturation*100);
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetVMR9ColorControl(m_dBrightness, m_dContrast, m_dHue, m_dSaturation);
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetVMR9ColorControl(m_dBrightness, m_dContrast, m_dHue, m_dSaturation);
}
void CPPageCasimir::OnCancel()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetVMR9ColorControl(s.dBrightness, s.dContrast, s.dHue, s.dSaturation);
- __super::OnCancel();
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetVMR9ColorControl(s.dBrightness, s.dContrast, s.dHue, s.dSaturation);
+ __super::OnCancel();
}
diff --git a/src/apps/mplayerc/PPageCasimir.h b/src/apps/mplayerc/PPageCasimir.h
index d2ea1cf62..d9420c91c 100644
--- a/src/apps/mplayerc/PPageCasimir.h
+++ b/src/apps/mplayerc/PPageCasimir.h
@@ -30,35 +30,35 @@
class CPPageCasimir : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageCasimir)
+ DECLARE_DYNAMIC(CPPageCasimir)
private:
- float m_dBrightness;
- float m_dContrast;
- float m_dHue;
- float m_dSaturation;
+ float m_dBrightness;
+ float m_dContrast;
+ float m_dHue;
+ float m_dSaturation;
public:
- CPPageCasimir();
- virtual ~CPPageCasimir();
+ CPPageCasimir();
+ virtual ~CPPageCasimir();
// Dialog Data
- enum { IDD = IDD_PPAGECASIMIR };
+ enum { IDD = IDD_PPAGECASIMIR };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- CSliderCtrl m_SliContrast;
- CSliderCtrl m_SliBrightness;
- CSliderCtrl m_SliHue;
- CSliderCtrl m_SliSaturation;
- afx_msg void OnBnClickedReset();
- virtual void OnCancel();
+ CSliderCtrl m_SliContrast;
+ CSliderCtrl m_SliBrightness;
+ CSliderCtrl m_SliHue;
+ CSliderCtrl m_SliSaturation;
+ afx_msg void OnBnClickedReset();
+ virtual void OnCancel();
};
diff --git a/src/apps/mplayerc/PPageDVD.cpp b/src/apps/mplayerc/PPageDVD.cpp
index 319f10575..cad95b671 100644
--- a/src/apps/mplayerc/PPageDVD.cpp
+++ b/src/apps/mplayerc/PPageDVD.cpp
@@ -28,151 +28,151 @@
struct
{
- LCID lcid;
- LPCSTR name;
-}
+ LCID lcid;
+ LPCSTR name;
+}
LCIDNameList[] =
{
- {0x0000, "Default"},
- {0x0436, "Afrikaans"},
- {0x041c, "Albanian"},
- {0x0401, "Arabic (Saudi Arabia)"},
- {0x0801, "Arabic (Iraq)"},
- {0x0c01, "Arabic (Egypt)"},
- {0x1001, "Arabic (Libya)"},
- {0x1401, "Arabic (Algeria)"},
- {0x1801, "Arabic (Morocco)"},
- {0x1c01, "Arabic (Tunisia)"},
- {0x2001, "Arabic (Oman)"},
- {0x2401, "Arabic (Yemen)"},
- {0x2801, "Arabic (Syria)"},
- {0x2c01, "Arabic (Jordan)"},
- {0x3001, "Arabic (Lebanon)"},
- {0x3401, "Arabic (Kuwait)"},
- {0x3801, "Arabic (U.A.E.)"},
- {0x3c01, "Arabic (Bahrain)"},
- {0x4001, "Arabic (Qatar)"},
- {0x042b, "Armenian"},
- {0x042c, "Azeri (Latin)"},
- {0x082c, "Azeri (Cyrillic)"},
- {0x042d, "Basque"},
- {0x0423, "Belarusian"},
- {0x0402, "Bulgarian"},
- {0x0455, "Burmese"},
- {0x0403, "Catalan"},
- {0x0404, "Chinese (Taiwan)"},
- {0x0804, "Chinese (PRC)"},
- {0x0c04, "Chinese (Hong Kong SAR, PRC)"},
- {0x1004, "Chinese (Singapore)"},
- {0x1404, "Chinese (Macau SAR)"},
- {0x041a, "Croatian"},
- {0x0405, "Czech"},
- {0x0406, "Danish"},
- {0x0465, "Divehi"},
- {0x0413, "Dutch (Netherlands)"},
- {0x0813, "Dutch (Belgium)"},
- {0x0409, "English (United States)"},
- {0x0809, "English (United Kingdom)"},
- {0x0c09, "English (Australian)"},
- {0x1009, "English (Canadian)"},
- {0x1409, "English (New Zealand)"},
- {0x1809, "English (Ireland)"},
- {0x1c09, "English (South Africa)"},
- {0x2009, "English (Jamaica)"},
- {0x2409, "English (Caribbean)"},
- {0x2809, "English (Belize)"},
- {0x2c09, "English (Trinidad)"},
- {0x3009, "English (Zimbabwe)"},
- {0x3409, "English (Philippines)"},
- {0x0425, "Estonian"},
- {0x0438, "Faeroese"},
- {0x0429, "Farsi"},
- {0x040b, "Finnish"},
- {0x040c, "French (Standard)"},
- {0x080c, "French (Belgian)"},
- {0x0c0c, "French (Canadian)"},
- {0x100c, "French (Switzerland)"},
- {0x140c, "French (Luxembourg)"},
- {0x180c, "French (Monaco)"},
- {0x0456, "Galician"},
- {0x0437, "Georgian"},
- {0x0407, "German (Standard)"},
- {0x0807, "German (Switzerland)"},
- {0x0c07, "German (Austria)"},
- {0x1007, "German (Luxembourg)"},
- {0x1407, "German (Liechtenstein)"},
- {0x0408, "Greek"},
- {0x0447, "Gujarati"},
- {0x040d, "Hebrew"},
- {0x0439, "Hindi"},
- {0x040e, "Hungarian"},
- {0x040f, "Icelandic"},
- {0x0421, "Indonesian"},
- {0x0410, "Italian (Standard)"},
- {0x0810, "Italian (Switzerland)"},
- {0x0411, "Japanese"},
- {0x044b, "Kannada"},
- {0x0457, "Konkani"},
- {0x0412, "Korean"},
- {0x0812, "Korean (Johab)"},
- {0x0440, "Kyrgyz"},
- {0x0426, "Latvian"},
- {0x0427, "Lithuanian"},
- {0x0827, "Lithuanian (Classic)"},
- {0x042f, "FYRO Macedonian"},
- {0x043e, "Malay (Malaysian)"},
- {0x083e, "Malay (Brunei Darussalam)"},
- {0x044e, "Marathi"},
- {0x0450, "Mongolian"},
- {0x0414, "Norwegian (Bokmal)"},
- {0x0814, "Norwegian (Nynorsk)"},
- {0x0415, "Polish"},
- {0x0416, "Portuguese (Brazil)"},
- {0x0816, "Portuguese (Portugal)"},
- {0x0446, "Punjabi"},
- {0x0418, "Romanian"},
- {0x0419, "Russian"},
- {0x044f, "Sanskrit"},
- {0x0c1a, "Serbian (Cyrillic)"},
- {0x081a, "Serbian (Latin)"},
- {0x041b, "Slovak"},
- {0x0424, "Slovenian"},
- {0x040a, "Spanish (Spain, Traditional Sort)"},
- {0x080a, "Spanish (Mexican)"},
- {0x0c0a, "Spanish (Spain, International Sort)"},
- {0x100a, "Spanish (Guatemala)"},
- {0x140a, "Spanish (Costa Rica)"},
- {0x180a, "Spanish (Panama)"},
- {0x1c0a, "Spanish (Dominican Republic)"},
- {0x200a, "Spanish (Venezuela)"},
- {0x240a, "Spanish (Colombia)"},
- {0x280a, "Spanish (Peru)"},
- {0x2c0a, "Spanish (Argentina)"},
- {0x300a, "Spanish (Ecuador)"},
- {0x340a, "Spanish (Chile)"},
- {0x380a, "Spanish (Uruguay)"},
- {0x3c0a, "Spanish (Paraguay)"},
- {0x400a, "Spanish (Bolivia)"},
- {0x440a, "Spanish (El Salvador)"},
- {0x480a, "Spanish (Honduras)"},
- {0x4c0a, "Spanish (Nicaragua)"},
- {0x500a, "Spanish (Puerto Rico)"},
- {0x0430, "Sutu"},
- {0x0441, "Swahili (Kenya)"},
- {0x041d, "Swedish"},
- {0x081d, "Swedish (Finland)"},
- {0x045a, "Syriac"},
- {0x0449, "Tamil"},
- {0x0444, "Tatar (Tatarstan)"},
- {0x044a, "Telugu"},
- {0x041e, "Thai"},
- {0x041f, "Turkish"},
- {0x0422, "Ukrainian"},
- {0x0420, "Urdu (Pakistan)"},
- {0x0820, "Urdu (India)"},
- {0x0443, "Uzbek (Latin)"},
- {0x0843, "Uzbek (Cyrillic)"},
- {0x042a, "Vietnamese"}
+ {0x0000, "Default"},
+ {0x0436, "Afrikaans"},
+ {0x041c, "Albanian"},
+ {0x0401, "Arabic (Saudi Arabia)"},
+ {0x0801, "Arabic (Iraq)"},
+ {0x0c01, "Arabic (Egypt)"},
+ {0x1001, "Arabic (Libya)"},
+ {0x1401, "Arabic (Algeria)"},
+ {0x1801, "Arabic (Morocco)"},
+ {0x1c01, "Arabic (Tunisia)"},
+ {0x2001, "Arabic (Oman)"},
+ {0x2401, "Arabic (Yemen)"},
+ {0x2801, "Arabic (Syria)"},
+ {0x2c01, "Arabic (Jordan)"},
+ {0x3001, "Arabic (Lebanon)"},
+ {0x3401, "Arabic (Kuwait)"},
+ {0x3801, "Arabic (U.A.E.)"},
+ {0x3c01, "Arabic (Bahrain)"},
+ {0x4001, "Arabic (Qatar)"},
+ {0x042b, "Armenian"},
+ {0x042c, "Azeri (Latin)"},
+ {0x082c, "Azeri (Cyrillic)"},
+ {0x042d, "Basque"},
+ {0x0423, "Belarusian"},
+ {0x0402, "Bulgarian"},
+ {0x0455, "Burmese"},
+ {0x0403, "Catalan"},
+ {0x0404, "Chinese (Taiwan)"},
+ {0x0804, "Chinese (PRC)"},
+ {0x0c04, "Chinese (Hong Kong SAR, PRC)"},
+ {0x1004, "Chinese (Singapore)"},
+ {0x1404, "Chinese (Macau SAR)"},
+ {0x041a, "Croatian"},
+ {0x0405, "Czech"},
+ {0x0406, "Danish"},
+ {0x0465, "Divehi"},
+ {0x0413, "Dutch (Netherlands)"},
+ {0x0813, "Dutch (Belgium)"},
+ {0x0409, "English (United States)"},
+ {0x0809, "English (United Kingdom)"},
+ {0x0c09, "English (Australian)"},
+ {0x1009, "English (Canadian)"},
+ {0x1409, "English (New Zealand)"},
+ {0x1809, "English (Ireland)"},
+ {0x1c09, "English (South Africa)"},
+ {0x2009, "English (Jamaica)"},
+ {0x2409, "English (Caribbean)"},
+ {0x2809, "English (Belize)"},
+ {0x2c09, "English (Trinidad)"},
+ {0x3009, "English (Zimbabwe)"},
+ {0x3409, "English (Philippines)"},
+ {0x0425, "Estonian"},
+ {0x0438, "Faeroese"},
+ {0x0429, "Farsi"},
+ {0x040b, "Finnish"},
+ {0x040c, "French (Standard)"},
+ {0x080c, "French (Belgian)"},
+ {0x0c0c, "French (Canadian)"},
+ {0x100c, "French (Switzerland)"},
+ {0x140c, "French (Luxembourg)"},
+ {0x180c, "French (Monaco)"},
+ {0x0456, "Galician"},
+ {0x0437, "Georgian"},
+ {0x0407, "German (Standard)"},
+ {0x0807, "German (Switzerland)"},
+ {0x0c07, "German (Austria)"},
+ {0x1007, "German (Luxembourg)"},
+ {0x1407, "German (Liechtenstein)"},
+ {0x0408, "Greek"},
+ {0x0447, "Gujarati"},
+ {0x040d, "Hebrew"},
+ {0x0439, "Hindi"},
+ {0x040e, "Hungarian"},
+ {0x040f, "Icelandic"},
+ {0x0421, "Indonesian"},
+ {0x0410, "Italian (Standard)"},
+ {0x0810, "Italian (Switzerland)"},
+ {0x0411, "Japanese"},
+ {0x044b, "Kannada"},
+ {0x0457, "Konkani"},
+ {0x0412, "Korean"},
+ {0x0812, "Korean (Johab)"},
+ {0x0440, "Kyrgyz"},
+ {0x0426, "Latvian"},
+ {0x0427, "Lithuanian"},
+ {0x0827, "Lithuanian (Classic)"},
+ {0x042f, "FYRO Macedonian"},
+ {0x043e, "Malay (Malaysian)"},
+ {0x083e, "Malay (Brunei Darussalam)"},
+ {0x044e, "Marathi"},
+ {0x0450, "Mongolian"},
+ {0x0414, "Norwegian (Bokmal)"},
+ {0x0814, "Norwegian (Nynorsk)"},
+ {0x0415, "Polish"},
+ {0x0416, "Portuguese (Brazil)"},
+ {0x0816, "Portuguese (Portugal)"},
+ {0x0446, "Punjabi"},
+ {0x0418, "Romanian"},
+ {0x0419, "Russian"},
+ {0x044f, "Sanskrit"},
+ {0x0c1a, "Serbian (Cyrillic)"},
+ {0x081a, "Serbian (Latin)"},
+ {0x041b, "Slovak"},
+ {0x0424, "Slovenian"},
+ {0x040a, "Spanish (Spain, Traditional Sort)"},
+ {0x080a, "Spanish (Mexican)"},
+ {0x0c0a, "Spanish (Spain, International Sort)"},
+ {0x100a, "Spanish (Guatemala)"},
+ {0x140a, "Spanish (Costa Rica)"},
+ {0x180a, "Spanish (Panama)"},
+ {0x1c0a, "Spanish (Dominican Republic)"},
+ {0x200a, "Spanish (Venezuela)"},
+ {0x240a, "Spanish (Colombia)"},
+ {0x280a, "Spanish (Peru)"},
+ {0x2c0a, "Spanish (Argentina)"},
+ {0x300a, "Spanish (Ecuador)"},
+ {0x340a, "Spanish (Chile)"},
+ {0x380a, "Spanish (Uruguay)"},
+ {0x3c0a, "Spanish (Paraguay)"},
+ {0x400a, "Spanish (Bolivia)"},
+ {0x440a, "Spanish (El Salvador)"},
+ {0x480a, "Spanish (Honduras)"},
+ {0x4c0a, "Spanish (Nicaragua)"},
+ {0x500a, "Spanish (Puerto Rico)"},
+ {0x0430, "Sutu"},
+ {0x0441, "Swahili (Kenya)"},
+ {0x041d, "Swedish"},
+ {0x081d, "Swedish (Finland)"},
+ {0x045a, "Syriac"},
+ {0x0449, "Tamil"},
+ {0x0444, "Tatar (Tatarstan)"},
+ {0x044a, "Telugu"},
+ {0x041e, "Thai"},
+ {0x041f, "Turkish"},
+ {0x0422, "Ukrainian"},
+ {0x0420, "Urdu (Pakistan)"},
+ {0x0820, "Urdu (India)"},
+ {0x0443, "Uzbek (Latin)"},
+ {0x0843, "Uzbek (Cyrillic)"},
+ {0x042a, "Vietnamese"}
};
@@ -180,11 +180,11 @@ LCIDNameList[] =
IMPLEMENT_DYNAMIC(CPPageDVD, CPPageBase)
CPPageDVD::CPPageDVD()
- : CPPageBase(CPPageDVD::IDD, CPPageDVD::IDD)
- , m_iDVDLocation(0)
- , m_iDVDLangType(0)
- , m_dvdpath(_T(""))
- , m_fAutoSpeakerConf(FALSE)
+ : CPPageBase(CPPageDVD::IDD, CPPageDVD::IDD)
+ , m_iDVDLocation(0)
+ , m_iDVDLangType(0)
+ , m_dvdpath(_T(""))
+ , m_fAutoSpeakerConf(FALSE)
{
}
@@ -194,41 +194,41 @@ CPPageDVD::~CPPageDVD()
void CPPageDVD::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_RADIO1, m_iDVDLocation);
- DDX_Radio(pDX, IDC_RADIO3, m_iDVDLangType);
- DDX_Control(pDX, IDC_LIST1, m_lcids);
- DDX_Text(pDX, IDC_DVDPATH, m_dvdpath);
- DDX_Control(pDX, IDC_DVDPATH, m_dvdpathctrl);
- DDX_Control(pDX, IDC_BUTTON1, m_dvdpathselctrl);
- DDX_Check(pDX, IDC_CHECK1, m_fAutoSpeakerConf);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_RADIO1, m_iDVDLocation);
+ DDX_Radio(pDX, IDC_RADIO3, m_iDVDLangType);
+ DDX_Control(pDX, IDC_LIST1, m_lcids);
+ DDX_Text(pDX, IDC_DVDPATH, m_dvdpath);
+ DDX_Control(pDX, IDC_DVDPATH, m_dvdpathctrl);
+ DDX_Control(pDX, IDC_BUTTON1, m_dvdpathselctrl);
+ DDX_Check(pDX, IDC_CHECK1, m_fAutoSpeakerConf);
}
void CPPageDVD::UpdateLCIDList()
{
- UpdateData();
-
- LCID lcid = m_iDVDLangType == 0 ? m_idMenuLang
- : m_iDVDLangType == 1 ? m_idAudioLang
- : m_idSubtitlesLang;
-
- for(int i = 0; i < m_lcids.GetCount(); i++)
- {
- if(m_lcids.GetItemData(i) == lcid)
- {
- m_lcids.SetCurSel(i);
- m_lcids.SetTopIndex(i);
- break;
- }
- }
+ UpdateData();
+
+ LCID lcid = m_iDVDLangType == 0 ? m_idMenuLang
+ : m_iDVDLangType == 1 ? m_idAudioLang
+ : m_idSubtitlesLang;
+
+ for(int i = 0; i < m_lcids.GetCount(); i++)
+ {
+ if(m_lcids.GetItemData(i) == lcid)
+ {
+ m_lcids.SetCurSel(i);
+ m_lcids.SetTopIndex(i);
+ break;
+ }
+ }
}
BEGIN_MESSAGE_MAP(CPPageDVD, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO3, IDC_RADIO5, OnBnClickedLangradio123)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_UPDATE_COMMAND_UI(IDC_DVDPATH, OnUpdateDVDPath)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateDVDPath)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO3, IDC_RADIO5, OnBnClickedLangradio123)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_UPDATE_COMMAND_UI(IDC_DVDPATH, OnUpdateDVDPath)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateDVDPath)
END_MESSAGE_MAP()
@@ -236,94 +236,94 @@ END_MESSAGE_MAP()
BOOL CPPageDVD::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_iDVDLocation = s.fUseDVDPath ? 1 : 0;
- m_dvdpath = s.sDVDPath;
- m_iDVDLangType = 0;
+ m_iDVDLocation = s.fUseDVDPath ? 1 : 0;
+ m_dvdpath = s.sDVDPath;
+ m_iDVDLangType = 0;
- m_idMenuLang = s.idMenuLang;
- m_idAudioLang = s.idAudioLang;
- m_idSubtitlesLang = s.idSubtitlesLang;
- m_fAutoSpeakerConf = s.fAutoSpeakerConf;
+ m_idMenuLang = s.idMenuLang;
+ m_idAudioLang = s.idAudioLang;
+ m_idSubtitlesLang = s.idSubtitlesLang;
+ m_fAutoSpeakerConf = s.fAutoSpeakerConf;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- for(int i = 0; i < countof(LCIDNameList); i++)
- {
- m_lcids.AddString(CString(LCIDNameList[i].name));
- m_lcids.SetItemData(i, LCIDNameList[i].lcid);
- }
+ for(int i = 0; i < countof(LCIDNameList); i++)
+ {
+ m_lcids.AddString(CString(LCIDNameList[i].name));
+ m_lcids.SetItemData(i, LCIDNameList[i].lcid);
+ }
- UpdateLCIDList();
+ UpdateLCIDList();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageDVD::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.sDVDPath = m_dvdpath;
- s.fUseDVDPath = (m_iDVDLocation == 1);
- s.idMenuLang = m_idMenuLang;
- s.idAudioLang = m_idAudioLang;
- s.idSubtitlesLang = m_idSubtitlesLang;
- s.fAutoSpeakerConf = !!m_fAutoSpeakerConf;
+ s.sDVDPath = m_dvdpath;
+ s.fUseDVDPath = (m_iDVDLocation == 1);
+ s.idMenuLang = m_idMenuLang;
+ s.idAudioLang = m_idAudioLang;
+ s.idSubtitlesLang = m_idSubtitlesLang;
+ s.fAutoSpeakerConf = !!m_fAutoSpeakerConf;
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageDVD::OnBnClickedButton1()
{
- TCHAR path[_MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = path;
- bi.lpszTitle = _T("Select the path for the DVD:");
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
- bi.lpfn = NULL;
- bi.lParam = 0;
- bi.iImage = 0;
-
- LPITEMIDLIST iil;
- if(iil = SHBrowseForFolder(&bi))
- {
- SHGetPathFromIDList(iil, path);
- m_dvdpath = path;
-
- UpdateData(FALSE);
-
- SetModified();
- }
+ TCHAR path[_MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = path;
+ bi.lpszTitle = _T("Select the path for the DVD:");
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ LPITEMIDLIST iil;
+ if(iil = SHBrowseForFolder(&bi))
+ {
+ SHGetPathFromIDList(iil, path);
+ m_dvdpath = path;
+
+ UpdateData(FALSE);
+
+ SetModified();
+ }
}
void CPPageDVD::OnBnClickedLangradio123(UINT nID)
{
- UpdateLCIDList();
+ UpdateLCIDList();
}
void CPPageDVD::OnLbnSelchangeList1()
{
- LCID& lcid = m_iDVDLangType == 0 ? m_idMenuLang
- : m_iDVDLangType == 1 ? m_idAudioLang
- : m_idSubtitlesLang;
+ LCID& lcid = m_iDVDLangType == 0 ? m_idMenuLang
+ : m_iDVDLangType == 1 ? m_idAudioLang
+ : m_idSubtitlesLang;
- lcid = m_lcids.GetItemData(m_lcids.GetCurSel());
+ lcid = m_lcids.GetItemData(m_lcids.GetCurSel());
- SetModified();
+ SetModified();
}
void CPPageDVD::OnUpdateDVDPath(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(m_iDVDLocation == 1);
+ pCmdUI->Enable(m_iDVDLocation == 1);
}
diff --git a/src/apps/mplayerc/PPageDVD.h b/src/apps/mplayerc/PPageDVD.h
index 8f007b365..6579611d5 100644
--- a/src/apps/mplayerc/PPageDVD.h
+++ b/src/apps/mplayerc/PPageDVD.h
@@ -30,41 +30,41 @@
class CPPageDVD : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageDVD)
+ DECLARE_DYNAMIC(CPPageDVD)
private:
- void UpdateLCIDList();
+ void UpdateLCIDList();
public:
- CPPageDVD();
- virtual ~CPPageDVD();
+ CPPageDVD();
+ virtual ~CPPageDVD();
- CListBox m_lcids;
- CString m_dvdpath;
- CEdit m_dvdpathctrl;
- CButton m_dvdpathselctrl;
- int m_iDVDLocation;
- int m_iDVDLangType;
+ CListBox m_lcids;
+ CString m_dvdpath;
+ CEdit m_dvdpathctrl;
+ CButton m_dvdpathselctrl;
+ int m_iDVDLocation;
+ int m_iDVDLangType;
- LCID m_idMenuLang;
- LCID m_idAudioLang;
- LCID m_idSubtitlesLang;
+ LCID m_idMenuLang;
+ LCID m_idAudioLang;
+ LCID m_idSubtitlesLang;
- BOOL m_fAutoSpeakerConf;
+ BOOL m_fAutoSpeakerConf;
// Dialog Data
- enum { IDD = IDD_PPAGEDVD};
+ enum { IDD = IDD_PPAGEDVD};
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedLangradio123(UINT nID);
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnUpdateDVDPath(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedLangradio123(UINT nID);
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnUpdateDVDPath(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/PPageExternalFilters.cpp b/src/apps/mplayerc/PPageExternalFilters.cpp
index 455f34a64..078b71a0c 100644
--- a/src/apps/mplayerc/PPageExternalFilters.cpp
+++ b/src/apps/mplayerc/PPageExternalFilters.cpp
@@ -38,9 +38,9 @@
IMPLEMENT_DYNAMIC(CPPageExternalFilters, CPPageBase)
CPPageExternalFilters::CPPageExternalFilters()
- : CPPageBase(CPPageExternalFilters::IDD, CPPageExternalFilters::IDD)
- , m_iLoadType(FilterOverride::PREFERRED)
- , m_pLastSelFilter(NULL)
+ : CPPageBase(CPPageExternalFilters::IDD, CPPageExternalFilters::IDD)
+ , m_iLoadType(FilterOverride::PREFERRED)
+ , m_pLastSelFilter(NULL)
{
}
@@ -50,227 +50,227 @@ CPPageExternalFilters::~CPPageExternalFilters()
void CPPageExternalFilters::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_filters);
- DDX_Radio(pDX, IDC_RADIO1, m_iLoadType);
- DDX_Control(pDX, IDC_EDIT1, m_dwMerit);
- DDX_Control(pDX, IDC_TREE2, m_tree);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_filters);
+ DDX_Radio(pDX, IDC_RADIO1, m_iLoadType);
+ DDX_Control(pDX, IDC_EDIT1, m_dwMerit);
+ DDX_Control(pDX, IDC_TREE2, m_tree);
}
void CPPageExternalFilters::StepUp(CCheckListBox& list)
{
- int i = list.GetCurSel();
- if(i < 1) return;
-
- CString str;
- list.GetText(i, str);
- DWORD_PTR dwItemData = list.GetItemData(i);
- int nCheck = list.GetCheck(i);
- list.DeleteString(i);
- i--;
- list.InsertString(i, str);
- list.SetItemData(i, dwItemData);
- list.SetCheck(i, nCheck);
- list.SetCurSel(i);
+ int i = list.GetCurSel();
+ if(i < 1) return;
+
+ CString str;
+ list.GetText(i, str);
+ DWORD_PTR dwItemData = list.GetItemData(i);
+ int nCheck = list.GetCheck(i);
+ list.DeleteString(i);
+ i--;
+ list.InsertString(i, str);
+ list.SetItemData(i, dwItemData);
+ list.SetCheck(i, nCheck);
+ list.SetCurSel(i);
}
void CPPageExternalFilters::StepDown(CCheckListBox& list)
{
- int i = list.GetCurSel();
- if(i < 0 || i >= list.GetCount() - 1) return;
-
- CString str;
- list.GetText(i, str);
- DWORD_PTR dwItemData = list.GetItemData(i);
- int nCheck = list.GetCheck(i);
- list.DeleteString(i);
- i++;
- list.InsertString(i, str);
- list.SetItemData(i, dwItemData);
- list.SetCheck(i, nCheck);
- list.SetCurSel(i);
+ int i = list.GetCurSel();
+ if(i < 0 || i >= list.GetCount()-1) return;
+
+ CString str;
+ list.GetText(i, str);
+ DWORD_PTR dwItemData = list.GetItemData(i);
+ int nCheck = list.GetCheck(i);
+ list.DeleteString(i);
+ i++;
+ list.InsertString(i, str);
+ list.SetItemData(i, dwItemData);
+ list.SetCheck(i, nCheck);
+ list.SetCurSel(i);
}
FilterOverride* CPPageExternalFilters::GetCurFilter()
{
- int i = m_filters.GetCurSel();
- return i >= 0 ? (FilterOverride*)m_pFilters.GetAt((POSITION)m_filters.GetItemDataPtr(i)) : (FilterOverride*)NULL;
+ int i = m_filters.GetCurSel();
+ return i >= 0 ? (FilterOverride*)m_pFilters.GetAt((POSITION)m_filters.GetItemDataPtr(i)) : (FilterOverride*)NULL;
}
void CPPageExternalFilters::SetupMajorTypes(CAtlArray<GUID>& guids)
{
- guids.RemoveAll();
- guids.Add(MEDIATYPE_NULL);
- guids.Add(MEDIATYPE_Video);
- guids.Add(MEDIATYPE_Audio);
- guids.Add(MEDIATYPE_Text);
- guids.Add(MEDIATYPE_Midi);
- guids.Add(MEDIATYPE_Stream);
- guids.Add(MEDIATYPE_Interleaved);
- guids.Add(MEDIATYPE_File);
- guids.Add(MEDIATYPE_ScriptCommand);
- guids.Add(MEDIATYPE_AUXLine21Data);
- guids.Add(MEDIATYPE_VBI);
- guids.Add(MEDIATYPE_Timecode);
- guids.Add(MEDIATYPE_LMRT);
- guids.Add(MEDIATYPE_URL_STREAM);
- guids.Add(MEDIATYPE_MPEG1SystemStream);
- guids.Add(MEDIATYPE_AnalogVideo);
- guids.Add(MEDIATYPE_AnalogAudio);
- guids.Add(MEDIATYPE_MPEG2_PACK);
- guids.Add(MEDIATYPE_MPEG2_PES);
- guids.Add(MEDIATYPE_MPEG2_SECTIONS);
- guids.Add(MEDIATYPE_DVD_ENCRYPTED_PACK);
- guids.Add(MEDIATYPE_DVD_NAVIGATION);
+ guids.RemoveAll();
+ guids.Add(MEDIATYPE_NULL);
+ guids.Add(MEDIATYPE_Video);
+ guids.Add(MEDIATYPE_Audio);
+ guids.Add(MEDIATYPE_Text);
+ guids.Add(MEDIATYPE_Midi);
+ guids.Add(MEDIATYPE_Stream);
+ guids.Add(MEDIATYPE_Interleaved);
+ guids.Add(MEDIATYPE_File);
+ guids.Add(MEDIATYPE_ScriptCommand);
+ guids.Add(MEDIATYPE_AUXLine21Data);
+ guids.Add(MEDIATYPE_VBI);
+ guids.Add(MEDIATYPE_Timecode);
+ guids.Add(MEDIATYPE_LMRT);
+ guids.Add(MEDIATYPE_URL_STREAM);
+ guids.Add(MEDIATYPE_MPEG1SystemStream);
+ guids.Add(MEDIATYPE_AnalogVideo);
+ guids.Add(MEDIATYPE_AnalogAudio);
+ guids.Add(MEDIATYPE_MPEG2_PACK);
+ guids.Add(MEDIATYPE_MPEG2_PES);
+ guids.Add(MEDIATYPE_MPEG2_SECTIONS);
+ guids.Add(MEDIATYPE_DVD_ENCRYPTED_PACK);
+ guids.Add(MEDIATYPE_DVD_NAVIGATION);
}
void CPPageExternalFilters::SetupSubTypes(CAtlArray<GUID>& guids)
{
- guids.RemoveAll();
- guids.Add(MEDIASUBTYPE_None);
- guids.Add(MEDIASUBTYPE_CLPL);
- guids.Add(MEDIASUBTYPE_YUYV);
- guids.Add(MEDIASUBTYPE_IYUV);
- guids.Add(MEDIASUBTYPE_YVU9);
- guids.Add(MEDIASUBTYPE_Y411);
- guids.Add(MEDIASUBTYPE_Y41P);
- guids.Add(MEDIASUBTYPE_YUY2);
- guids.Add(MEDIASUBTYPE_YVYU);
- guids.Add(MEDIASUBTYPE_UYVY);
- guids.Add(MEDIASUBTYPE_Y211);
- guids.Add(MEDIASUBTYPE_CLJR);
- guids.Add(MEDIASUBTYPE_IF09);
- guids.Add(MEDIASUBTYPE_CPLA);
- guids.Add(MEDIASUBTYPE_MJPG);
- guids.Add(MEDIASUBTYPE_TVMJ);
- guids.Add(MEDIASUBTYPE_WAKE);
- guids.Add(MEDIASUBTYPE_CFCC);
- guids.Add(MEDIASUBTYPE_IJPG);
- guids.Add(MEDIASUBTYPE_Plum);
- guids.Add(MEDIASUBTYPE_DVCS);
- guids.Add(MEDIASUBTYPE_DVSD);
- guids.Add(MEDIASUBTYPE_MDVF);
- guids.Add(MEDIASUBTYPE_RGB1);
- guids.Add(MEDIASUBTYPE_RGB4);
- guids.Add(MEDIASUBTYPE_RGB8);
- guids.Add(MEDIASUBTYPE_RGB565);
- guids.Add(MEDIASUBTYPE_RGB555);
- guids.Add(MEDIASUBTYPE_RGB24);
- guids.Add(MEDIASUBTYPE_RGB32);
- guids.Add(MEDIASUBTYPE_ARGB1555);
- guids.Add(MEDIASUBTYPE_ARGB4444);
- guids.Add(MEDIASUBTYPE_ARGB32);
- guids.Add(MEDIASUBTYPE_A2R10G10B10);
- guids.Add(MEDIASUBTYPE_A2B10G10R10);
- guids.Add(MEDIASUBTYPE_AYUV);
- guids.Add(MEDIASUBTYPE_AI44);
- guids.Add(MEDIASUBTYPE_IA44);
- guids.Add(MEDIASUBTYPE_RGB32_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_RGB16_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_RGB32_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_RGB16_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_YV12);
- guids.Add(MEDIASUBTYPE_NV12);
- guids.Add(MEDIASUBTYPE_IMC1);
- guids.Add(MEDIASUBTYPE_IMC2);
- guids.Add(MEDIASUBTYPE_IMC3);
- guids.Add(MEDIASUBTYPE_IMC4);
- guids.Add(MEDIASUBTYPE_S340);
- guids.Add(MEDIASUBTYPE_S342);
- guids.Add(MEDIASUBTYPE_Overlay);
- guids.Add(MEDIASUBTYPE_MPEG1Packet);
- guids.Add(MEDIASUBTYPE_MPEG1Payload);
- guids.Add(MEDIASUBTYPE_MPEG1AudioPayload);
- guids.Add(MEDIASUBTYPE_MPEG1System);
- guids.Add(MEDIASUBTYPE_MPEG1VideoCD);
- guids.Add(MEDIASUBTYPE_MPEG1Video);
- guids.Add(MEDIASUBTYPE_MPEG1Audio);
- guids.Add(MEDIASUBTYPE_Avi);
- guids.Add(MEDIASUBTYPE_Asf);
- guids.Add(MEDIASUBTYPE_QTMovie);
- guids.Add(MEDIASUBTYPE_QTRpza);
- guids.Add(MEDIASUBTYPE_QTSmc);
- guids.Add(MEDIASUBTYPE_QTRle);
- guids.Add(MEDIASUBTYPE_QTJpeg);
- guids.Add(MEDIASUBTYPE_PCMAudio_Obsolete);
- guids.Add(MEDIASUBTYPE_PCM);
- guids.Add(MEDIASUBTYPE_WAVE);
- guids.Add(MEDIASUBTYPE_AU);
- guids.Add(MEDIASUBTYPE_AIFF);
- guids.Add(MEDIASUBTYPE_dvsd);
- guids.Add(MEDIASUBTYPE_dvhd);
- guids.Add(MEDIASUBTYPE_dvsl);
- guids.Add(MEDIASUBTYPE_dv25);
- guids.Add(MEDIASUBTYPE_dv50);
- guids.Add(MEDIASUBTYPE_dvh1);
- guids.Add(MEDIASUBTYPE_Line21_BytePair);
- guids.Add(MEDIASUBTYPE_Line21_GOPPacket);
- guids.Add(MEDIASUBTYPE_Line21_VBIRawData);
- guids.Add(MEDIASUBTYPE_TELETEXT);
- guids.Add(MEDIASUBTYPE_DRM_Audio);
- guids.Add(MEDIASUBTYPE_IEEE_FLOAT);
- guids.Add(MEDIASUBTYPE_DOLBY_AC3_SPDIF);
- guids.Add(MEDIASUBTYPE_RAW_SPORT);
- guids.Add(MEDIASUBTYPE_SPDIF_TAG_241h);
- guids.Add(MEDIASUBTYPE_DssVideo);
- guids.Add(MEDIASUBTYPE_DssAudio);
- guids.Add(MEDIASUBTYPE_VPVideo);
- guids.Add(MEDIASUBTYPE_VPVBI);
- guids.Add(MEDIASUBTYPE_ATSC_SI);
- guids.Add(MEDIASUBTYPE_DVB_SI);
- guids.Add(MEDIASUBTYPE_MPEG2DATA);
- guids.Add(MEDIASUBTYPE_MPEG2_VIDEO);
- guids.Add(MEDIASUBTYPE_MPEG2_PROGRAM);
- guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT);
- guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT_STRIDE);
- guids.Add(MEDIASUBTYPE_MPEG2_AUDIO);
- guids.Add(MEDIASUBTYPE_DOLBY_AC3);
- guids.Add(MEDIASUBTYPE_DVD_SUBPICTURE);
- guids.Add(MEDIASUBTYPE_DVD_LPCM_AUDIO);
- guids.Add(MEDIASUBTYPE_DTS);
- guids.Add(MEDIASUBTYPE_SDDS);
- guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PCI);
- guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_DSI);
- guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER);
- guids.Add(MEDIASUBTYPE_I420);
- guids.Add(MEDIASUBTYPE_WAVE_DOLBY_AC3);
- guids.Add(MEDIASUBTYPE_WAVE_DTS);
+ guids.RemoveAll();
+ guids.Add(MEDIASUBTYPE_None);
+ guids.Add(MEDIASUBTYPE_CLPL);
+ guids.Add(MEDIASUBTYPE_YUYV);
+ guids.Add(MEDIASUBTYPE_IYUV);
+ guids.Add(MEDIASUBTYPE_YVU9);
+ guids.Add(MEDIASUBTYPE_Y411);
+ guids.Add(MEDIASUBTYPE_Y41P);
+ guids.Add(MEDIASUBTYPE_YUY2);
+ guids.Add(MEDIASUBTYPE_YVYU);
+ guids.Add(MEDIASUBTYPE_UYVY);
+ guids.Add(MEDIASUBTYPE_Y211);
+ guids.Add(MEDIASUBTYPE_CLJR);
+ guids.Add(MEDIASUBTYPE_IF09);
+ guids.Add(MEDIASUBTYPE_CPLA);
+ guids.Add(MEDIASUBTYPE_MJPG);
+ guids.Add(MEDIASUBTYPE_TVMJ);
+ guids.Add(MEDIASUBTYPE_WAKE);
+ guids.Add(MEDIASUBTYPE_CFCC);
+ guids.Add(MEDIASUBTYPE_IJPG);
+ guids.Add(MEDIASUBTYPE_Plum);
+ guids.Add(MEDIASUBTYPE_DVCS);
+ guids.Add(MEDIASUBTYPE_DVSD);
+ guids.Add(MEDIASUBTYPE_MDVF);
+ guids.Add(MEDIASUBTYPE_RGB1);
+ guids.Add(MEDIASUBTYPE_RGB4);
+ guids.Add(MEDIASUBTYPE_RGB8);
+ guids.Add(MEDIASUBTYPE_RGB565);
+ guids.Add(MEDIASUBTYPE_RGB555);
+ guids.Add(MEDIASUBTYPE_RGB24);
+ guids.Add(MEDIASUBTYPE_RGB32);
+ guids.Add(MEDIASUBTYPE_ARGB1555);
+ guids.Add(MEDIASUBTYPE_ARGB4444);
+ guids.Add(MEDIASUBTYPE_ARGB32);
+ guids.Add(MEDIASUBTYPE_A2R10G10B10);
+ guids.Add(MEDIASUBTYPE_A2B10G10R10);
+ guids.Add(MEDIASUBTYPE_AYUV);
+ guids.Add(MEDIASUBTYPE_AI44);
+ guids.Add(MEDIASUBTYPE_IA44);
+ guids.Add(MEDIASUBTYPE_RGB32_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_RGB16_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_RGB32_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_RGB16_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_YV12);
+ guids.Add(MEDIASUBTYPE_NV12);
+ guids.Add(MEDIASUBTYPE_IMC1);
+ guids.Add(MEDIASUBTYPE_IMC2);
+ guids.Add(MEDIASUBTYPE_IMC3);
+ guids.Add(MEDIASUBTYPE_IMC4);
+ guids.Add(MEDIASUBTYPE_S340);
+ guids.Add(MEDIASUBTYPE_S342);
+ guids.Add(MEDIASUBTYPE_Overlay);
+ guids.Add(MEDIASUBTYPE_MPEG1Packet);
+ guids.Add(MEDIASUBTYPE_MPEG1Payload);
+ guids.Add(MEDIASUBTYPE_MPEG1AudioPayload);
+ guids.Add(MEDIASUBTYPE_MPEG1System);
+ guids.Add(MEDIASUBTYPE_MPEG1VideoCD);
+ guids.Add(MEDIASUBTYPE_MPEG1Video);
+ guids.Add(MEDIASUBTYPE_MPEG1Audio);
+ guids.Add(MEDIASUBTYPE_Avi);
+ guids.Add(MEDIASUBTYPE_Asf);
+ guids.Add(MEDIASUBTYPE_QTMovie);
+ guids.Add(MEDIASUBTYPE_QTRpza);
+ guids.Add(MEDIASUBTYPE_QTSmc);
+ guids.Add(MEDIASUBTYPE_QTRle);
+ guids.Add(MEDIASUBTYPE_QTJpeg);
+ guids.Add(MEDIASUBTYPE_PCMAudio_Obsolete);
+ guids.Add(MEDIASUBTYPE_PCM);
+ guids.Add(MEDIASUBTYPE_WAVE);
+ guids.Add(MEDIASUBTYPE_AU);
+ guids.Add(MEDIASUBTYPE_AIFF);
+ guids.Add(MEDIASUBTYPE_dvsd);
+ guids.Add(MEDIASUBTYPE_dvhd);
+ guids.Add(MEDIASUBTYPE_dvsl);
+ guids.Add(MEDIASUBTYPE_dv25);
+ guids.Add(MEDIASUBTYPE_dv50);
+ guids.Add(MEDIASUBTYPE_dvh1);
+ guids.Add(MEDIASUBTYPE_Line21_BytePair);
+ guids.Add(MEDIASUBTYPE_Line21_GOPPacket);
+ guids.Add(MEDIASUBTYPE_Line21_VBIRawData);
+ guids.Add(MEDIASUBTYPE_TELETEXT);
+ guids.Add(MEDIASUBTYPE_DRM_Audio);
+ guids.Add(MEDIASUBTYPE_IEEE_FLOAT);
+ guids.Add(MEDIASUBTYPE_DOLBY_AC3_SPDIF);
+ guids.Add(MEDIASUBTYPE_RAW_SPORT);
+ guids.Add(MEDIASUBTYPE_SPDIF_TAG_241h);
+ guids.Add(MEDIASUBTYPE_DssVideo);
+ guids.Add(MEDIASUBTYPE_DssAudio);
+ guids.Add(MEDIASUBTYPE_VPVideo);
+ guids.Add(MEDIASUBTYPE_VPVBI);
+ guids.Add(MEDIASUBTYPE_ATSC_SI);
+ guids.Add(MEDIASUBTYPE_DVB_SI);
+ guids.Add(MEDIASUBTYPE_MPEG2DATA);
+ guids.Add(MEDIASUBTYPE_MPEG2_VIDEO);
+ guids.Add(MEDIASUBTYPE_MPEG2_PROGRAM);
+ guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT);
+ guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT_STRIDE);
+ guids.Add(MEDIASUBTYPE_MPEG2_AUDIO);
+ guids.Add(MEDIASUBTYPE_DOLBY_AC3);
+ guids.Add(MEDIASUBTYPE_DVD_SUBPICTURE);
+ guids.Add(MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ guids.Add(MEDIASUBTYPE_DTS);
+ guids.Add(MEDIASUBTYPE_SDDS);
+ guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PCI);
+ guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_DSI);
+ guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER);
+ guids.Add(MEDIASUBTYPE_I420);
+ guids.Add(MEDIASUBTYPE_WAVE_DOLBY_AC3);
+ guids.Add(MEDIASUBTYPE_WAVE_DTS);
}
BEGIN_MESSAGE_MAP(CPPageExternalFilters, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_RADIO1, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_RADIO2, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_RADIO3, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateFilterUp)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateFilterDown)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateFilterMerit)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON6, OnUpdateSubType)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON7, OnUpdateDeleteType)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON8, OnUpdateFilter)
- ON_BN_CLICKED(IDC_BUTTON1, OnAddRegistered)
- ON_BN_CLICKED(IDC_BUTTON2, OnRemoveFilter)
- ON_BN_CLICKED(IDC_BUTTON3, OnMoveFilterUp)
- ON_BN_CLICKED(IDC_BUTTON4, OnMoveFilterDown)
- ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkFilter)
- ON_BN_CLICKED(IDC_BUTTON5, OnAddMajorType)
- ON_BN_CLICKED(IDC_BUTTON6, OnAddSubType)
- ON_BN_CLICKED(IDC_BUTTON7, OnDeleteType)
- ON_BN_CLICKED(IDC_BUTTON8, OnResetTypes)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio)
- ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio)
- ON_BN_CLICKED(IDC_RADIO3, OnBnClickedRadio)
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_NOTIFY(NM_DBLCLK, IDC_TREE2, OnNMDblclkTree2)
- ON_WM_DROPFILES()
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_RADIO1, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_RADIO2, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_RADIO3, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateFilterUp)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateFilterDown)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateFilterMerit)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON6, OnUpdateSubType)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON7, OnUpdateDeleteType)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON8, OnUpdateFilter)
+ ON_BN_CLICKED(IDC_BUTTON1, OnAddRegistered)
+ ON_BN_CLICKED(IDC_BUTTON2, OnRemoveFilter)
+ ON_BN_CLICKED(IDC_BUTTON3, OnMoveFilterUp)
+ ON_BN_CLICKED(IDC_BUTTON4, OnMoveFilterDown)
+ ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkFilter)
+ ON_BN_CLICKED(IDC_BUTTON5, OnAddMajorType)
+ ON_BN_CLICKED(IDC_BUTTON6, OnAddSubType)
+ ON_BN_CLICKED(IDC_BUTTON7, OnDeleteType)
+ ON_BN_CLICKED(IDC_BUTTON8, OnResetTypes)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio)
+ ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio)
+ ON_BN_CLICKED(IDC_RADIO3, OnBnClickedRadio)
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_NOTIFY(NM_DBLCLK, IDC_TREE2, OnNMDblclkTree2)
+ ON_WM_DROPFILES()
END_MESSAGE_MAP()
@@ -278,462 +278,454 @@ END_MESSAGE_MAP()
BOOL CPPageExternalFilters::OnInitDialog()
{
- __super::OnInitDialog();
-
- DragAcceptFiles(TRUE);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_pFilters.RemoveAll();
-
- POSITION pos = s.filters.GetHeadPosition();
- while(pos)
- {
- CAutoPtr<FilterOverride> f(DNew FilterOverride(s.filters.GetNext(pos)));
-
- CString name(_T("<unknown>"));
-
- if(f->type == FilterOverride::REGISTERED)
- {
- name = CFGFilterRegistry(f->dispname).GetName();
- if(name.IsEmpty()) name = f->name + _T(" <not registered>");
- }
- else if(f->type == FilterOverride::EXTERNAL)
- {
- name = f->name;
- if(f->fTemporary) name += _T(" <temporary>");
- if(!CPath(MakeFullPath(f->path)).FileExists()) name += _T(" <not found!>");
- }
-
- int i = m_filters.AddString(name);
- m_filters.SetCheck(i, f->fDisabled ? 0 : 1);
- m_filters.SetItemDataPtr(i, m_pFilters.AddTail(f));
- }
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ DragAcceptFiles(TRUE);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_pFilters.RemoveAll();
+
+ POSITION pos = s.filters.GetHeadPosition();
+ while(pos)
+ {
+ CAutoPtr<FilterOverride> f(DNew FilterOverride(s.filters.GetNext(pos)));
+
+ CString name(_T("<unknown>"));
+
+ if(f->type == FilterOverride::REGISTERED)
+ {
+ name = CFGFilterRegistry(f->dispname).GetName();
+ if(name.IsEmpty()) name = f->name + _T(" <not registered>");
+ }
+ else if(f->type == FilterOverride::EXTERNAL)
+ {
+ name = f->name;
+ if(f->fTemporary) name += _T(" <temporary>");
+ if(!CPath(MakeFullPath(f->path)).FileExists()) name += _T(" <not found!>");
+ }
+
+ int i = m_filters.AddString(name);
+ m_filters.SetCheck(i, f->fDisabled ? 0 : 1);
+ m_filters.SetItemDataPtr(i, m_pFilters.AddTail(f));
+ }
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageExternalFilters::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.filters.RemoveAll();
+ s.filters.RemoveAll();
- for(int i = 0; i < m_filters.GetCount(); i++)
- {
- if(POSITION pos = (POSITION)m_filters.GetItemData(i))
- {
- CAutoPtr<FilterOverride> f(DNew FilterOverride(m_pFilters.GetAt(pos)));
- f->fDisabled = !m_filters.GetCheck(i);
- s.filters.AddTail(f);
- }
- }
+ for(int i = 0; i < m_filters.GetCount(); i++)
+ {
+ if(POSITION pos = (POSITION)m_filters.GetItemData(i))
+ {
+ CAutoPtr<FilterOverride> f(DNew FilterOverride(m_pFilters.GetAt(pos)));
+ f->fDisabled = !m_filters.GetCheck(i);
+ s.filters.AddTail(f);
+ }
+ }
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageExternalFilters::OnUpdateFilter(CCmdUI* pCmdUI)
{
- if(FilterOverride* f = GetCurFilter())
- {
- pCmdUI->Enable(!(pCmdUI->m_nID == IDC_RADIO2 && f->type == FilterOverride::EXTERNAL));
- }
- else
- {
- pCmdUI->Enable(FALSE);
- }
+ if(FilterOverride* f = GetCurFilter())
+ {
+ pCmdUI->Enable(!(pCmdUI->m_nID == IDC_RADIO2 && f->type == FilterOverride::EXTERNAL));
+ }
+ else
+ {
+ pCmdUI->Enable(FALSE);
+ }
}
void CPPageExternalFilters::OnUpdateFilterUp(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_filters.GetCurSel() > 0);
+ pCmdUI->Enable(m_filters.GetCurSel() > 0);
}
void CPPageExternalFilters::OnUpdateFilterDown(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_filters.GetCurSel() >= 0 && m_filters.GetCurSel() < m_filters.GetCount() - 1);
+ pCmdUI->Enable(m_filters.GetCurSel() >= 0 && m_filters.GetCurSel() < m_filters.GetCount()-1);
}
void CPPageExternalFilters::OnUpdateFilterMerit(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_iLoadType == FilterOverride::MERIT);
+ UpdateData();
+ pCmdUI->Enable(m_iLoadType == FilterOverride::MERIT);
}
void CPPageExternalFilters::OnUpdateSubType(CCmdUI* pCmdUI)
{
- HTREEITEM node = m_tree.GetSelectedItem();
- pCmdUI->Enable(node != NULL && m_tree.GetItemData(node) == NULL);
+ HTREEITEM node = m_tree.GetSelectedItem();
+ pCmdUI->Enable(node != NULL && m_tree.GetItemData(node) == NULL);
}
void CPPageExternalFilters::OnUpdateDeleteType(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!m_tree.GetSelectedItem());
+ pCmdUI->Enable(!!m_tree.GetSelectedItem());
}
void CPPageExternalFilters::OnAddRegistered()
{
- CRegFilterChooserDlg dlg(this);
- if(dlg.DoModal() == IDOK)
- {
- while(!dlg.m_filters.IsEmpty())
- {
- if(FilterOverride* f = dlg.m_filters.RemoveHead())
- {
- CAutoPtr<FilterOverride> p(f);
-
- CString name = f->name;
-
- if(f->type == FilterOverride::EXTERNAL)
- {
- if(!CPath(MakeFullPath(f->path)).FileExists()) name += _T(" <not found!>");
- }
-
- int i = m_filters.AddString(name);
- m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
- m_filters.SetCheck(i, 1);
-
- if(dlg.m_filters.IsEmpty())
- {
- m_filters.SetCurSel(i);
- OnLbnSelchangeList1();
- }
- }
- }
- }
+ CRegFilterChooserDlg dlg(this);
+ if(dlg.DoModal() == IDOK)
+ {
+ while(!dlg.m_filters.IsEmpty())
+ {
+ if(FilterOverride* f = dlg.m_filters.RemoveHead())
+ {
+ CAutoPtr<FilterOverride> p(f);
+
+ CString name = f->name;
+
+ if(f->type == FilterOverride::EXTERNAL)
+ {
+ if(!CPath(MakeFullPath(f->path)).FileExists()) name += _T(" <not found!>");
+ }
+
+ int i = m_filters.AddString(name);
+ m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
+ m_filters.SetCheck(i, 1);
+
+ if(dlg.m_filters.IsEmpty())
+ {
+ m_filters.SetCurSel(i);
+ OnLbnSelchangeList1();
+ }
+ }
+ }
+ }
}
void CPPageExternalFilters::OnRemoveFilter()
{
- int i = m_filters.GetCurSel();
- m_pFilters.RemoveAt((POSITION)m_filters.GetItemDataPtr(i));
- m_filters.DeleteString(i);
- if(i >= m_filters.GetCount()) i--;
- m_filters.SetCurSel(i);
- OnLbnSelchangeList1();
+ int i = m_filters.GetCurSel();
+ m_pFilters.RemoveAt((POSITION)m_filters.GetItemDataPtr(i));
+ m_filters.DeleteString(i);
+ if(i >= m_filters.GetCount()) i--;
+ m_filters.SetCurSel(i);
+ OnLbnSelchangeList1();
}
void CPPageExternalFilters::OnMoveFilterUp()
{
- StepUp(m_filters);
+ StepUp(m_filters);
}
void CPPageExternalFilters::OnMoveFilterDown()
{
- StepDown(m_filters);
+ StepDown(m_filters);
}
void CPPageExternalFilters::OnLbnDblclkFilter()
{
- if(FilterOverride* f = GetCurFilter())
- {
- CComPtr<IBaseFilter> pBF;
- CString name;
-
- if(f->type == FilterOverride::REGISTERED)
- {
- CStringW namew;
- if(CreateFilter(f->dispname, &pBF, namew))
- name = namew;
- }
- else if(f->type == FilterOverride::EXTERNAL)
- {
- if(SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF)))
- name = f->name;
- }
-
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = pBF)
- {
- CComPropertySheet ps(name, this);
- if(ps.AddPages(pSPP) > 0)
- {
- CComPtr<IFilterGraph> pFG;
- if(SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph)))
- pFG->AddFilter(pBF, L"");
-
- ps.DoModal();
- }
- }
- }
+ if(FilterOverride* f = GetCurFilter())
+ {
+ CComPtr<IBaseFilter> pBF;
+ CString name;
+
+ if(f->type == FilterOverride::REGISTERED)
+ {
+ CStringW namew;
+ if(CreateFilter(f->dispname, &pBF, namew))
+ name = namew;
+ }
+ else if(f->type == FilterOverride::EXTERNAL)
+ {
+ if(SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF)))
+ name = f->name;
+ }
+
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = pBF)
+ {
+ CComPropertySheet ps(name, this);
+ if(ps.AddPages(pSPP) > 0)
+ {
+ CComPtr<IFilterGraph> pFG;
+ if(SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph)))
+ pFG->AddFilter(pBF, L"");
+
+ ps.DoModal();
+ }
+ }
+ }
}
void CPPageExternalFilters::OnAddMajorType()
{
- FilterOverride* f = GetCurFilter();
- if(!f) return;
-
- CAtlArray<GUID> guids;
- SetupMajorTypes(guids);
-
- CSelectMediaType dlg(guids, MEDIATYPE_NULL, this);
- if(dlg.DoModal() == IDOK)
- {
- POSITION pos = f->guids.GetHeadPosition();
- while(pos)
- {
- if(f->guids.GetNext(pos) == dlg.m_guid)
- {
- AfxMessageBox(_T("Already on the list!"));
- return;
- }
- f->guids.GetNext(pos);
- }
-
- f->guids.AddTail(dlg.m_guid);
- pos = f->guids.GetTailPosition();
- f->guids.AddTail(GUID_NULL);
-
- CString major = GetMediaTypeName(dlg.m_guid);
- CString sub = GetMediaTypeName(GUID_NULL);
-
- HTREEITEM node = m_tree.InsertItem(major);
- m_tree.SetItemData(node, NULL);
-
- node = m_tree.InsertItem(sub, node);
- m_tree.SetItemData(node, (DWORD_PTR)pos);
- }
+ FilterOverride* f = GetCurFilter();
+ if(!f) return;
+
+ CAtlArray<GUID> guids;
+ SetupMajorTypes(guids);
+
+ CSelectMediaType dlg(guids, MEDIATYPE_NULL, this);
+ if(dlg.DoModal() == IDOK)
+ {
+ POSITION pos = f->guids.GetHeadPosition();
+ while(pos)
+ {
+ if(f->guids.GetNext(pos) == dlg.m_guid) {AfxMessageBox(_T("Already on the list!")); return;}
+ f->guids.GetNext(pos);
+ }
+
+ f->guids.AddTail(dlg.m_guid);
+ pos = f->guids.GetTailPosition();
+ f->guids.AddTail(GUID_NULL);
+
+ CString major = GetMediaTypeName(dlg.m_guid);
+ CString sub = GetMediaTypeName(GUID_NULL);
+
+ HTREEITEM node = m_tree.InsertItem(major);
+ m_tree.SetItemData(node, NULL);
+
+ node = m_tree.InsertItem(sub, node);
+ m_tree.SetItemData(node, (DWORD_PTR)pos);
+ }
}
void CPPageExternalFilters::OnAddSubType()
{
- FilterOverride* f = GetCurFilter();
- if(!f) return;
-
- HTREEITEM node = m_tree.GetSelectedItem();
- if(!node) return;
-
- HTREEITEM child = m_tree.GetChildItem(node);
- if(!child) return;
-
- POSITION pos = (POSITION)m_tree.GetItemData(child);
- GUID major = f->guids.GetAt(pos);
-
- CAtlArray<GUID> guids;
- SetupSubTypes(guids);
-
- CSelectMediaType dlg(guids, MEDIASUBTYPE_NULL, this);
- if(dlg.DoModal() == IDOK)
- {
- for(child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child))
- {
- pos = (POSITION)m_tree.GetItemData(child);
- f->guids.GetNext(pos);
- if(f->guids.GetAt(pos) == dlg.m_guid)
- {
- AfxMessageBox(_T("Already on the list!"));
- return;
- }
- }
-
- f->guids.AddTail(major);
- pos = f->guids.GetTailPosition();
- f->guids.AddTail(dlg.m_guid);
-
- CString sub = GetMediaTypeName(dlg.m_guid);
-
- node = m_tree.InsertItem(sub, node);
- m_tree.SetItemData(node, (DWORD_PTR)pos);
- }
+ FilterOverride* f = GetCurFilter();
+ if(!f) return;
+
+ HTREEITEM node = m_tree.GetSelectedItem();
+ if(!node) return;
+
+ HTREEITEM child = m_tree.GetChildItem(node);
+ if(!child) return;
+
+ POSITION pos = (POSITION)m_tree.GetItemData(child);
+ GUID major = f->guids.GetAt(pos);
+
+ CAtlArray<GUID> guids;
+ SetupSubTypes(guids);
+
+ CSelectMediaType dlg(guids, MEDIASUBTYPE_NULL, this);
+ if(dlg.DoModal() == IDOK)
+ {
+ for(child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child))
+ {
+ pos = (POSITION)m_tree.GetItemData(child);
+ f->guids.GetNext(pos);
+ if(f->guids.GetAt(pos) == dlg.m_guid) {AfxMessageBox(_T("Already on the list!")); return;}
+ }
+
+ f->guids.AddTail(major);
+ pos = f->guids.GetTailPosition();
+ f->guids.AddTail(dlg.m_guid);
+
+ CString sub = GetMediaTypeName(dlg.m_guid);
+
+ node = m_tree.InsertItem(sub, node);
+ m_tree.SetItemData(node, (DWORD_PTR)pos);
+ }
}
void CPPageExternalFilters::OnDeleteType()
{
- if(FilterOverride* f = GetCurFilter())
- {
- HTREEITEM node = m_tree.GetSelectedItem();
- if(!node) return;
-
- POSITION pos = (POSITION)m_tree.GetItemData(node);
-
- if(pos == NULL)
- {
- for(HTREEITEM child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child))
- {
- pos = (POSITION)m_tree.GetItemData(child);
-
- POSITION pos1 = pos;
- f->guids.GetNext(pos);
- POSITION pos2 = pos;
- f->guids.GetNext(pos);
-
- f->guids.RemoveAt(pos1);
- f->guids.RemoveAt(pos2);
- }
-
- m_tree.DeleteItem(node);
- }
- else
- {
- HTREEITEM parent = m_tree.GetParentItem(node);
-
- POSITION pos1 = pos;
- f->guids.GetNext(pos);
- POSITION pos2 = pos;
- f->guids.GetNext(pos);
-
- m_tree.DeleteItem(node);
-
- if(!m_tree.ItemHasChildren(parent))
- {
- f->guids.SetAt(pos2, GUID_NULL);
- node = m_tree.InsertItem(GetMediaTypeName(GUID_NULL), parent);
- m_tree.SetItemData(node, (DWORD_PTR)pos1);
- }
- else
- {
- f->guids.RemoveAt(pos1);
- f->guids.RemoveAt(pos2);
- }
- }
- }
+ if(FilterOverride* f = GetCurFilter())
+ {
+ HTREEITEM node = m_tree.GetSelectedItem();
+ if(!node) return;
+
+ POSITION pos = (POSITION)m_tree.GetItemData(node);
+
+ if(pos == NULL)
+ {
+ for(HTREEITEM child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child))
+ {
+ pos = (POSITION)m_tree.GetItemData(child);
+
+ POSITION pos1 = pos;
+ f->guids.GetNext(pos);
+ POSITION pos2 = pos;
+ f->guids.GetNext(pos);
+
+ f->guids.RemoveAt(pos1);
+ f->guids.RemoveAt(pos2);
+ }
+
+ m_tree.DeleteItem(node);
+ }
+ else
+ {
+ HTREEITEM parent = m_tree.GetParentItem(node);
+
+ POSITION pos1 = pos;
+ f->guids.GetNext(pos);
+ POSITION pos2 = pos;
+ f->guids.GetNext(pos);
+
+ m_tree.DeleteItem(node);
+
+ if(!m_tree.ItemHasChildren(parent))
+ {
+ f->guids.SetAt(pos2, GUID_NULL);
+ node = m_tree.InsertItem(GetMediaTypeName(GUID_NULL), parent);
+ m_tree.SetItemData(node, (DWORD_PTR)pos1);
+ }
+ else
+ {
+ f->guids.RemoveAt(pos1);
+ f->guids.RemoveAt(pos2);
+ }
+ }
+ }
}
void CPPageExternalFilters::OnResetTypes()
{
- if(FilterOverride* f = GetCurFilter())
- {
- f->guids.RemoveAll();
- f->guids.AddTailList(&f->backup);
-
- m_pLastSelFilter = NULL;
- OnLbnSelchangeList1();
- }
+ if(FilterOverride* f = GetCurFilter())
+ {
+ f->guids.RemoveAll();
+ f->guids.AddTailList(&f->backup);
+
+ m_pLastSelFilter = NULL;
+ OnLbnSelchangeList1();
+ }
}
void CPPageExternalFilters::OnLbnSelchangeList1()
{
- if(FilterOverride* f = GetCurFilter())
- {
- if(m_pLastSelFilter == f) return;
- m_pLastSelFilter = f;
+ if(FilterOverride* f = GetCurFilter())
+ {
+ if(m_pLastSelFilter == f) return;
+ m_pLastSelFilter = f;
- m_iLoadType = f->iLoadType;
- UpdateData(FALSE);
- m_dwMerit = f->dwMerit;
+ m_iLoadType = f->iLoadType;
+ UpdateData(FALSE);
+ m_dwMerit = f->dwMerit;
- HTREEITEM dummy_item = m_tree.InsertItem(_T(""), 0, 0, NULL, TVI_FIRST);
- if(dummy_item)
- for(HTREEITEM item = m_tree.GetNextVisibleItem(dummy_item); item; item = m_tree.GetNextVisibleItem(dummy_item))
- m_tree.DeleteItem(item);
+ HTREEITEM dummy_item = m_tree.InsertItem(_T(""), 0,0, NULL, TVI_FIRST);
+ if(dummy_item)
+ for(HTREEITEM item = m_tree.GetNextVisibleItem(dummy_item); item; item = m_tree.GetNextVisibleItem(dummy_item))
+ m_tree.DeleteItem(item);
- CMapStringToPtr map;
+ CMapStringToPtr map;
- POSITION pos = f->guids.GetHeadPosition();
- while(pos)
- {
- POSITION tmp = pos;
- CString major = GetMediaTypeName(f->guids.GetNext(pos));
- CString sub = GetMediaTypeName(f->guids.GetNext(pos));
+ POSITION pos = f->guids.GetHeadPosition();
+ while(pos)
+ {
+ POSITION tmp = pos;
+ CString major = GetMediaTypeName(f->guids.GetNext(pos));
+ CString sub = GetMediaTypeName(f->guids.GetNext(pos));
- HTREEITEM node = NULL;
+ HTREEITEM node = NULL;
- void* val = NULL;
- if(map.Lookup(major, val)) node = (HTREEITEM)val;
- else map[major] = node = m_tree.InsertItem(major);
- m_tree.SetItemData(node, NULL);
+ void* val = NULL;
+ if(map.Lookup(major, val)) node = (HTREEITEM)val;
+ else map[major] = node = m_tree.InsertItem(major);
+ m_tree.SetItemData(node, NULL);
- node = m_tree.InsertItem(sub, node);
- m_tree.SetItemData(node, (DWORD_PTR)tmp);
- }
+ node = m_tree.InsertItem(sub, node);
+ m_tree.SetItemData(node, (DWORD_PTR)tmp);
+ }
- m_tree.DeleteItem(dummy_item);
+ m_tree.DeleteItem(dummy_item);
- for(HTREEITEM item = m_tree.GetFirstVisibleItem(); item; item = m_tree.GetNextVisibleItem(item))
- m_tree.Expand(item, TVE_EXPAND);
+ for(HTREEITEM item = m_tree.GetFirstVisibleItem(); item; item = m_tree.GetNextVisibleItem(item))
+ m_tree.Expand(item, TVE_EXPAND);
- m_tree.EnsureVisible(m_tree.GetRootItem());
- }
- else
- {
- m_pLastSelFilter = NULL;
+ m_tree.EnsureVisible(m_tree.GetRootItem());
+ }
+ else
+ {
+ m_pLastSelFilter = NULL;
- m_iLoadType = FilterOverride::PREFERRED;
- UpdateData(FALSE);
- m_dwMerit = 0;
+ m_iLoadType = FilterOverride::PREFERRED;
+ UpdateData(FALSE);
+ m_dwMerit = 0;
- m_tree.DeleteAllItems();
- }
+ m_tree.DeleteAllItems();
+ }
}
void CPPageExternalFilters::OnBnClickedRadio()
{
- UpdateData();
- if(FilterOverride* f = GetCurFilter())
- f->iLoadType = m_iLoadType;
+ UpdateData();
+ if(FilterOverride* f = GetCurFilter())
+ f->iLoadType = m_iLoadType;
}
void CPPageExternalFilters::OnEnChangeEdit1()
{
- UpdateData();
- if(FilterOverride* f = GetCurFilter())
- {
- DWORD dw;
- if(m_dwMerit.GetDWORD(dw))
- f->dwMerit = dw;
- }
+ UpdateData();
+ if(FilterOverride* f = GetCurFilter())
+ {
+ DWORD dw;
+ if(m_dwMerit.GetDWORD(dw))
+ f->dwMerit = dw;
+ }
}
void CPPageExternalFilters::OnNMDblclkTree2(NMHDR *pNMHDR, LRESULT *pResult)
{
- *pResult = 0;
+ *pResult = 0;
- if(FilterOverride* f = GetCurFilter())
- {
- HTREEITEM node = m_tree.GetSelectedItem();
- if(!node) return;
+ if(FilterOverride* f = GetCurFilter())
+ {
+ HTREEITEM node = m_tree.GetSelectedItem();
+ if(!node) return;
- POSITION pos = (POSITION)m_tree.GetItemData(node);
- if(!pos) return;
+ POSITION pos = (POSITION)m_tree.GetItemData(node);
+ if(!pos) return;
- f->guids.GetNext(pos);
- if(!pos) return;
+ f->guids.GetNext(pos);
+ if(!pos) return;
- CAtlArray<GUID> guids;
- SetupSubTypes(guids);
+ CAtlArray<GUID> guids;
+ SetupSubTypes(guids);
- CSelectMediaType dlg(guids, f->guids.GetAt(pos), this);
- if(dlg.DoModal() == IDOK)
- {
- f->guids.SetAt(pos, dlg.m_guid);
- m_tree.SetItemText(node, GetMediaTypeName(dlg.m_guid));
- }
- }
+ CSelectMediaType dlg(guids, f->guids.GetAt(pos), this);
+ if(dlg.DoModal() == IDOK)
+ {
+ f->guids.SetAt(pos, dlg.m_guid);
+ m_tree.SetItemText(node, GetMediaTypeName(dlg.m_guid));
+ }
+ }
}
void CPPageExternalFilters::OnDropFiles(HDROP hDropInfo)
{
- SetActiveWindow();
-
- UINT nFiles = ::DragQueryFile(hDropInfo, (UINT) - 1, NULL, 0);
- for(UINT iFile = 0; iFile < nFiles; iFile++)
- {
- TCHAR szFileName[_MAX_PATH];
- ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
-
- CFilterMapper2 fm2(false);
- fm2.Register(szFileName);
-
- while(!fm2.m_filters.IsEmpty())
- {
- if(FilterOverride* f = fm2.m_filters.RemoveHead())
- {
- CAutoPtr<FilterOverride> p(f);
- int i = m_filters.AddString(f->name);
- m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
- m_filters.SetCheck(i, 1);
-
- if(fm2.m_filters.IsEmpty())
- {
- m_filters.SetCurSel(i);
- OnLbnSelchangeList1();
- }
- }
- }
- }
- ::DragFinish(hDropInfo);
+ SetActiveWindow();
+
+ UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
+ for(UINT iFile = 0; iFile < nFiles; iFile++)
+ {
+ TCHAR szFileName[_MAX_PATH];
+ ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
+
+ CFilterMapper2 fm2(false);
+ fm2.Register(szFileName);
+
+ while(!fm2.m_filters.IsEmpty())
+ {
+ if(FilterOverride* f = fm2.m_filters.RemoveHead())
+ {
+ CAutoPtr<FilterOverride> p(f);
+ int i = m_filters.AddString(f->name);
+ m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
+ m_filters.SetCheck(i, 1);
+
+ if(fm2.m_filters.IsEmpty())
+ {
+ m_filters.SetCurSel(i);
+ OnLbnSelchangeList1();
+ }
+ }
+ }
+ }
+ ::DragFinish(hDropInfo);
}
diff --git a/src/apps/mplayerc/PPageExternalFilters.h b/src/apps/mplayerc/PPageExternalFilters.h
index 65cf71923..a627e6111 100644
--- a/src/apps/mplayerc/PPageExternalFilters.h
+++ b/src/apps/mplayerc/PPageExternalFilters.h
@@ -32,57 +32,57 @@
class CPPageExternalFilters : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageExternalFilters)
+ DECLARE_DYNAMIC(CPPageExternalFilters)
private:
- void StepUp(CCheckListBox& list);
- void StepDown(CCheckListBox& list);
+ void StepUp(CCheckListBox& list);
+ void StepDown(CCheckListBox& list);
- CAutoPtrList<FilterOverride> m_pFilters;
- FilterOverride* m_pLastSelFilter;
- FilterOverride* GetCurFilter();
+ CAutoPtrList<FilterOverride> m_pFilters;
+ FilterOverride* m_pLastSelFilter;
+ FilterOverride* GetCurFilter();
- void SetupMajorTypes(CAtlArray<GUID>& guids);
- void SetupSubTypes(CAtlArray<GUID>& guids);
+ void SetupMajorTypes(CAtlArray<GUID>& guids);
+ void SetupSubTypes(CAtlArray<GUID>& guids);
public:
- CPPageExternalFilters();
- virtual ~CPPageExternalFilters();
+ CPPageExternalFilters();
+ virtual ~CPPageExternalFilters();
// Dialog Data
- enum { IDD = IDD_PPAGEEXTERNALFILTERS };
+ enum { IDD = IDD_PPAGEEXTERNALFILTERS };
- CCheckListBox m_filters;
- int m_iLoadType;
- CHexEdit m_dwMerit;
- CTreeCtrl m_tree;
+ CCheckListBox m_filters;
+ int m_iLoadType;
+ CHexEdit m_dwMerit;
+ CTreeCtrl m_tree;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateFilter(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFilterUp(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFilterDown(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFilterMerit(CCmdUI* pCmdUI);
- afx_msg void OnUpdateSubType(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDeleteType(CCmdUI* pCmdUI);
- afx_msg void OnAddRegistered();
- afx_msg void OnRemoveFilter();
- afx_msg void OnMoveFilterUp();
- afx_msg void OnMoveFilterDown();
- afx_msg void OnLbnDblclkFilter();
- afx_msg void OnAddMajorType();
- afx_msg void OnAddSubType();
- afx_msg void OnDeleteType();
- afx_msg void OnResetTypes();
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnBnClickedRadio();
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnNMDblclkTree2(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnDropFiles(HDROP hDropInfo);
+ afx_msg void OnUpdateFilter(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFilterUp(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFilterDown(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFilterMerit(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateSubType(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDeleteType(CCmdUI* pCmdUI);
+ afx_msg void OnAddRegistered();
+ afx_msg void OnRemoveFilter();
+ afx_msg void OnMoveFilterUp();
+ afx_msg void OnMoveFilterDown();
+ afx_msg void OnLbnDblclkFilter();
+ afx_msg void OnAddMajorType();
+ afx_msg void OnAddSubType();
+ afx_msg void OnDeleteType();
+ afx_msg void OnResetTypes();
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnBnClickedRadio();
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnNMDblclkTree2(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnDropFiles(HDROP hDropInfo);
};
diff --git a/src/apps/mplayerc/PPageFileInfoClip.cpp b/src/apps/mplayerc/PPageFileInfoClip.cpp
index ab6bbdcf3..e323c8552 100644
--- a/src/apps/mplayerc/PPageFileInfoClip.cpp
+++ b/src/apps/mplayerc/PPageFileInfoClip.cpp
@@ -33,34 +33,34 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoClip, CPropertyPage)
CPPageFileInfoClip::CPPageFileInfoClip(CString fn, IFilterGraph* pFG)
- : CPropertyPage(CPPageFileInfoClip::IDD, CPPageFileInfoClip::IDD)
- , m_fn(fn)
- , m_pFG(pFG)
- , m_clip(ResStr(IDS_AG_NONE))
- , m_author(ResStr(IDS_AG_NONE))
- , m_copyright(ResStr(IDS_AG_NONE))
- , m_rating(ResStr(IDS_AG_NONE))
- , m_location(ResStr(IDS_AG_NONE))
- , m_hIcon(NULL)
+ : CPropertyPage(CPPageFileInfoClip::IDD, CPPageFileInfoClip::IDD)
+ , m_fn(fn)
+ , m_pFG(pFG)
+ , m_clip(ResStr(IDS_AG_NONE))
+ , m_author(ResStr(IDS_AG_NONE))
+ , m_copyright(ResStr(IDS_AG_NONE))
+ , m_rating(ResStr(IDS_AG_NONE))
+ , m_location(ResStr(IDS_AG_NONE))
+ , m_hIcon(NULL)
{
}
CPPageFileInfoClip::~CPPageFileInfoClip()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) DestroyIcon(m_hIcon);
}
void CPPageFileInfoClip::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
- DDX_Text(pDX, IDC_EDIT1, m_fn);
- DDX_Text(pDX, IDC_EDIT4, m_clip);
- DDX_Text(pDX, IDC_EDIT3, m_author);
- DDX_Text(pDX, IDC_EDIT2, m_copyright);
- DDX_Text(pDX, IDC_EDIT5, m_rating);
- DDX_Text(pDX, IDC_EDIT6, m_location);
- DDX_Control(pDX, IDC_EDIT7, m_desc);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
+ DDX_Text(pDX, IDC_EDIT1, m_fn);
+ DDX_Text(pDX, IDC_EDIT4, m_clip);
+ DDX_Text(pDX, IDC_EDIT3, m_author);
+ DDX_Text(pDX, IDC_EDIT2, m_copyright);
+ DDX_Text(pDX, IDC_EDIT5, m_rating);
+ DDX_Text(pDX, IDC_EDIT6, m_location);
+ DDX_Control(pDX, IDC_EDIT7, m_desc);
}
BEGIN_MESSAGE_MAP(CPPageFileInfoClip, CPropertyPage)
@@ -71,60 +71,40 @@ END_MESSAGE_MAP()
BOOL CPPageFileInfoClip::OnInitDialog()
{
- __super::OnInitDialog();
-
- if(m_hIcon = LoadIcon(m_fn, false))
- m_icon.SetIcon(m_hIcon);
-
- m_fn.TrimRight('/');
- int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
- if(i >= 0 && i < m_fn.GetLength() - 1)
- {
- m_location = m_fn.Left(i);
- m_fn = m_fn.Mid(i + 1);
-
- if(m_location.GetLength() == 2 && m_location[1] == ':')
- m_location += '\\';
- }
-
- bool fEmpty = true;
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
- if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
- {
- CComBSTR bstr;
- if(SUCCEEDED(pAMMC->get_Title(&bstr)) && wcslen(bstr.m_str) > 0)
- {
- m_clip = bstr.m_str;
- fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_AuthorName(&bstr)) && wcslen(bstr.m_str) > 0)
- {
- m_author = bstr.m_str;
- fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_Copyright(&bstr)) && wcslen(bstr.m_str) > 0)
- {
- m_copyright = bstr.m_str;
- fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_Rating(&bstr)) && wcslen(bstr.m_str) > 0)
- {
- m_rating = bstr.m_str;
- fEmpty = false;
- }
- if(SUCCEEDED(pAMMC->get_Description(&bstr)) && wcslen(bstr.m_str) > 0)
- {
- m_desc.SetWindowText(CString(bstr.m_str));
- fEmpty = false;
- }
- if(!fEmpty) break;
- }
- }
- EndEnumFilters
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ if(m_hIcon = LoadIcon(m_fn, false))
+ m_icon.SetIcon(m_hIcon);
+
+ m_fn.TrimRight('/');
+ int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
+ if(i >= 0 && i < m_fn.GetLength()-1)
+ {
+ m_location = m_fn.Left(i);
+ m_fn = m_fn.Mid(i+1);
+
+ if(m_location.GetLength() == 2 && m_location[1] == ':')
+ m_location += '\\';
+ }
+
+ bool fEmpty = true;
+ BeginEnumFilters(m_pFG, pEF, pBF)
+ {
+ if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
+ {
+ CComBSTR bstr;
+ if(SUCCEEDED(pAMMC->get_Title(&bstr)) && wcslen(bstr.m_str) > 0) {m_clip = bstr.m_str; fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_AuthorName(&bstr)) && wcslen(bstr.m_str) > 0) {m_author = bstr.m_str; fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_Copyright(&bstr)) && wcslen(bstr.m_str) > 0) {m_copyright = bstr.m_str; fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_Rating(&bstr)) && wcslen(bstr.m_str) > 0) {m_rating = bstr.m_str; fEmpty = false;}
+ if(SUCCEEDED(pAMMC->get_Description(&bstr)) && wcslen(bstr.m_str) > 0) {m_desc.SetWindowText(CString(bstr.m_str)); fEmpty = false;}
+ if(!fEmpty) break;
+ }
+ }
+ EndEnumFilters
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
diff --git a/src/apps/mplayerc/PPageFileInfoClip.h b/src/apps/mplayerc/PPageFileInfoClip.h
index 94db6c18c..d28c5ff85 100644
--- a/src/apps/mplayerc/PPageFileInfoClip.h
+++ b/src/apps/mplayerc/PPageFileInfoClip.h
@@ -30,33 +30,33 @@
class CPPageFileInfoClip : public CPropertyPage
{
- DECLARE_DYNAMIC(CPPageFileInfoClip)
+ DECLARE_DYNAMIC(CPPageFileInfoClip)
private:
- CComPtr<IFilterGraph> m_pFG;
- HICON m_hIcon;
+ CComPtr<IFilterGraph> m_pFG;
+ HICON m_hIcon;
public:
- CPPageFileInfoClip(CString fn, IFilterGraph* pFG);
- virtual ~CPPageFileInfoClip();
+ CPPageFileInfoClip(CString fn, IFilterGraph* pFG);
+ virtual ~CPPageFileInfoClip();
// Dialog Data
- enum { IDD = IDD_FILEPROPCLIP };
+ enum { IDD = IDD_FILEPROPCLIP };
- CStatic m_icon;
- CString m_fn;
- CString m_clip;
- CString m_author;
- CString m_copyright;
- CString m_rating;
- CString m_location;
- CEdit m_desc;
+ CStatic m_icon;
+ CString m_fn;
+ CString m_clip;
+ CString m_author;
+ CString m_copyright;
+ CString m_rating;
+ CString m_location;
+ CEdit m_desc;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
};
diff --git a/src/apps/mplayerc/PPageFileInfoDetails.cpp b/src/apps/mplayerc/PPageFileInfoDetails.cpp
index 67b357f94..34f84556c 100644
--- a/src/apps/mplayerc/PPageFileInfoDetails.cpp
+++ b/src/apps/mplayerc/PPageFileInfoDetails.cpp
@@ -35,35 +35,35 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoDetails, CPropertyPage)
CPPageFileInfoDetails::CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISubPicAllocatorPresenter* pCAP)
- : CPropertyPage(CPPageFileInfoDetails::IDD, CPPageFileInfoDetails::IDD)
- , m_fn(fn)
- , m_pFG(pFG)
- , m_pCAP(pCAP)
- , m_hIcon(NULL)
- , m_type(ResStr(IDS_AG_NOT_KNOWN))
- , m_size(ResStr(IDS_AG_NOT_KNOWN))
- , m_time(ResStr(IDS_AG_NOT_KNOWN))
- , m_res(ResStr(IDS_AG_NOT_KNOWN))
- , m_created(ResStr(IDS_AG_NOT_KNOWN))
+ : CPropertyPage(CPPageFileInfoDetails::IDD, CPPageFileInfoDetails::IDD)
+ , m_fn(fn)
+ , m_pFG(pFG)
+ , m_pCAP(pCAP)
+ , m_hIcon(NULL)
+ , m_type(ResStr(IDS_AG_NOT_KNOWN))
+ , m_size(ResStr(IDS_AG_NOT_KNOWN))
+ , m_time(ResStr(IDS_AG_NOT_KNOWN))
+ , m_res(ResStr(IDS_AG_NOT_KNOWN))
+ , m_created(ResStr(IDS_AG_NOT_KNOWN))
{
}
CPPageFileInfoDetails::~CPPageFileInfoDetails()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) DestroyIcon(m_hIcon);
}
void CPPageFileInfoDetails::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
- DDX_Text(pDX, IDC_EDIT1, m_fn);
- DDX_Text(pDX, IDC_EDIT4, m_type);
- DDX_Text(pDX, IDC_EDIT3, m_size);
- DDX_Text(pDX, IDC_EDIT2, m_time);
- DDX_Text(pDX, IDC_EDIT5, m_res);
- DDX_Text(pDX, IDC_EDIT6, m_created);
- DDX_Control(pDX, IDC_EDIT7, m_encoding);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
+ DDX_Text(pDX, IDC_EDIT1, m_fn);
+ DDX_Text(pDX, IDC_EDIT4, m_type);
+ DDX_Text(pDX, IDC_EDIT3, m_size);
+ DDX_Text(pDX, IDC_EDIT2, m_time);
+ DDX_Text(pDX, IDC_EDIT5, m_res);
+ DDX_Text(pDX, IDC_EDIT6, m_created);
+ DDX_Control(pDX, IDC_EDIT7, m_encoding);
}
BEGIN_MESSAGE_MAP(CPPageFileInfoDetails, CPropertyPage)
@@ -71,239 +71,239 @@ END_MESSAGE_MAP()
inline int LNKO(int a, int b)
{
- if(a == 0 || b == 0)
- return(1);
+ if(a == 0 || b == 0)
+ return(1);
- while(a != b)
- {
- if(a < b) b -= a;
- else if(a > b) a -= b;
- }
+ while(a != b)
+ {
+ if(a < b) b -= a;
+ else if(a > b) a -= b;
+ }
- return(a);
+ return(a);
}
// CPPageFileInfoDetails message handlers
static bool GetProperty(IFilterGraph* pFG, LPCOLESTR propName, VARIANT* vt)
{
- BeginEnumFilters(pFG, pEF, pBF)
- {
- if(CComQIPtr<IPropertyBag> pPB = pBF)
- if(SUCCEEDED(pPB->Read(propName, vt, NULL)))
- return true;
- }
- EndEnumFilters
-
- return false;
+ BeginEnumFilters(pFG, pEF, pBF)
+ {
+ if(CComQIPtr<IPropertyBag> pPB = pBF)
+ if(SUCCEEDED(pPB->Read(propName, vt, NULL)))
+ return true;
+ }
+ EndEnumFilters
+
+ return false;
}
static CString FormatDateTime(FILETIME tm)
{
- SYSTEMTIME t;
- FileTimeToSystemTime(&tm, &t);
- TCHAR buff[256];
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &t, NULL, buff, 256);
- CString ret(buff);
- ret += _T(" ");
- GetTimeFormat(LOCALE_USER_DEFAULT, 0, &t, NULL, buff, 256);
- ret += buff;
- return ret;
+ SYSTEMTIME t;
+ FileTimeToSystemTime(&tm, &t);
+ TCHAR buff[256];
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &t, NULL, buff, 256);
+ CString ret(buff);
+ ret += _T(" ");
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, &t, NULL, buff, 256);
+ ret += buff;
+ return ret;
}
BOOL CPPageFileInfoDetails::OnInitDialog()
{
- __super::OnInitDialog();
-
- CString ext = m_fn.Left(m_fn.Find(_T("://")) + 1).TrimRight(':');
- if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
- ext = _T(".") + m_fn.Mid(m_fn.ReverseFind('.') + 1);
-
- if(m_hIcon = LoadIcon(m_fn, false))
- m_icon.SetIcon(m_hIcon);
-
- if(!LoadType(ext, m_type))
- m_type = ResStr(IDS_AG_NOT_KNOWN);
-
- CComVariant vt;
- if(::GetProperty(m_pFG, L"CurFile.TimeCreated", &vt))
- {
- if(V_VT(&vt) == VT_UI8)
- {
- ULARGE_INTEGER uli;
- uli.QuadPart = V_UI8(&vt);
-
- FILETIME ft;
- ft.dwLowDateTime = uli.LowPart;
- ft.dwHighDateTime = uli.HighPart;
-
- m_created = FormatDateTime(ft);
- }
- }
-
- WIN32_FIND_DATA wfd;
- HANDLE hFind = FindFirstFile(m_fn, &wfd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- FindClose(hFind);
-
- __int64 size = (__int64(wfd.nFileSizeHigh) << 32) | wfd.nFileSizeLow;
- __int64 shortsize = size;
- CString measure = _T("B");
- if(shortsize > 10240) shortsize /= 1024, measure = _T("KB");
- if(shortsize > 10240) shortsize /= 1024, measure = _T("MB");
- if(shortsize > 10240) shortsize /= 1024, measure = _T("GB");
- m_size.Format(_T("%I64d%s (%I64d bytes)"), shortsize, measure, size);
-
- if(m_created.IsEmpty())
- {
- m_created = FormatDateTime(wfd.ftCreationTime);
- }
- }
-
- REFERENCE_TIME rtDur = 0;
- CComQIPtr<IMediaSeeking> pMS = m_pFG;
- if(pMS && SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur > 0)
- {
- m_time.Format(_T("%02d:%02d:%02d"),
- int(rtDur / 10000000 / 60 / 60),
- int((rtDur / 10000000 / 60) % 60),
- int((rtDur / 10000000) % 60));
- }
-
- CSize wh(0, 0), arxy(0, 0);
- long fps = 0;
-
- if(m_pCAP)
- {
- wh = m_pCAP->GetVideoSize(false);
- arxy = m_pCAP->GetVideoSize(true);
- }
- else
- {
- if(CComQIPtr<IBasicVideo> pBV = m_pFG)
- {
- if(SUCCEEDED(pBV->GetVideoSize(&wh.cx, &wh.cy)))
- {
- if(CComQIPtr<IBasicVideo2> pBV2 = m_pFG)
- pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
- }
- else
- {
- wh.SetSize(0, 0);
- }
- }
-
- if(wh.cx == 0 && wh.cy == 0)
- {
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
- if(CComQIPtr<IBasicVideo> pBV = pBF)
- {
- pBV->GetVideoSize(&wh.cx, &wh.cy);
- if(CComQIPtr<IBasicVideo2> pBV2 = pBF)
- pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
- break;
- }
- else if(CComQIPtr<IVMRWindowlessControl> pWC = pBF)
- {
- pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
- break;
- }
- else if(CComQIPtr<IVMRWindowlessControl9> pWC = pBF)
- {
- pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
- break;
- }
- }
- EndEnumFilters
- }
- }
-
- if(wh.cx > 0 && wh.cy > 0)
- {
- m_res.Format(_T("%d x %d"), wh.cx, wh.cy);
-
- int lnko = 0;
- do
- {
- lnko = LNKO(arxy.cx, arxy.cy);
- if(lnko > 1) arxy.cx /= lnko, arxy.cy /= lnko;
- }
- while(lnko > 1);
-
- if(arxy.cx > 0 && arxy.cy > 0 && arxy.cx*wh.cy != arxy.cy * wh.cx)
- {
- CString ar;
- ar.Format(_T(" (AR %d:%d)"), arxy.cx, arxy.cy);
- m_res += ar;
- }
- }
-
- m_fn.TrimRight('/');
- m_fn.Replace('\\', '/');
- m_fn = m_fn.Mid(m_fn.ReverseFind('/') + 1);
-
- UpdateData(FALSE);
-
- InitEncoding();
-
- m_pFG = NULL;
- m_pCAP = NULL;
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ CString ext = m_fn.Left(m_fn.Find(_T("://"))+1).TrimRight(':');
+ if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
+ ext = _T(".") + m_fn.Mid(m_fn.ReverseFind('.')+1);
+
+ if(m_hIcon = LoadIcon(m_fn, false))
+ m_icon.SetIcon(m_hIcon);
+
+ if(!LoadType(ext, m_type))
+ m_type = ResStr(IDS_AG_NOT_KNOWN);
+
+ CComVariant vt;
+ if(::GetProperty(m_pFG, L"CurFile.TimeCreated", &vt))
+ {
+ if(V_VT(&vt) == VT_UI8)
+ {
+ ULARGE_INTEGER uli;
+ uli.QuadPart = V_UI8(&vt);
+
+ FILETIME ft;
+ ft.dwLowDateTime = uli.LowPart;
+ ft.dwHighDateTime = uli.HighPart;
+
+ m_created = FormatDateTime(ft);
+ }
+ }
+
+ WIN32_FIND_DATA wfd;
+ HANDLE hFind = FindFirstFile(m_fn, &wfd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ FindClose(hFind);
+
+ __int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
+ __int64 shortsize = size;
+ CString measure = _T("B");
+ if(shortsize > 10240) shortsize /= 1024, measure = _T("KB");
+ if(shortsize > 10240) shortsize /= 1024, measure = _T("MB");
+ if(shortsize > 10240) shortsize /= 1024, measure = _T("GB");
+ m_size.Format(_T("%I64d%s (%I64d bytes)"), shortsize, measure, size);
+
+ if(m_created.IsEmpty())
+ {
+ m_created = FormatDateTime(wfd.ftCreationTime);
+ }
+ }
+
+ REFERENCE_TIME rtDur = 0;
+ CComQIPtr<IMediaSeeking> pMS = m_pFG;
+ if(pMS && SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur > 0)
+ {
+ m_time.Format(_T("%02d:%02d:%02d"),
+ int(rtDur/10000000/60/60),
+ int((rtDur/10000000/60)%60),
+ int((rtDur/10000000)%60));
+ }
+
+ CSize wh(0, 0), arxy(0, 0);
+ long fps = 0;
+
+ if(m_pCAP)
+ {
+ wh = m_pCAP->GetVideoSize(false);
+ arxy = m_pCAP->GetVideoSize(true);
+ }
+ else
+ {
+ if(CComQIPtr<IBasicVideo> pBV = m_pFG)
+ {
+ if(SUCCEEDED(pBV->GetVideoSize(&wh.cx, &wh.cy)))
+ {
+ if(CComQIPtr<IBasicVideo2> pBV2 = m_pFG)
+ pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
+ }
+ else
+ {
+ wh.SetSize(0, 0);
+ }
+ }
+
+ if(wh.cx == 0 && wh.cy == 0)
+ {
+ BeginEnumFilters(m_pFG, pEF, pBF)
+ {
+ if(CComQIPtr<IBasicVideo> pBV = pBF)
+ {
+ pBV->GetVideoSize(&wh.cx, &wh.cy);
+ if(CComQIPtr<IBasicVideo2> pBV2 = pBF)
+ pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
+ break;
+ }
+ else if(CComQIPtr<IVMRWindowlessControl> pWC = pBF)
+ {
+ pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
+ break;
+ }
+ else if(CComQIPtr<IVMRWindowlessControl9> pWC = pBF)
+ {
+ pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+ }
+
+ if(wh.cx > 0 && wh.cy > 0)
+ {
+ m_res.Format(_T("%d x %d"), wh.cx, wh.cy);
+
+ int lnko = 0;
+ do
+ {
+ lnko = LNKO(arxy.cx, arxy.cy);
+ if(lnko > 1) arxy.cx /= lnko, arxy.cy /= lnko;
+ }
+ while(lnko > 1);
+
+ if(arxy.cx > 0 && arxy.cy > 0 && arxy.cx*wh.cy != arxy.cy*wh.cx)
+ {
+ CString ar;
+ ar.Format(_T(" (AR %d:%d)"), arxy.cx, arxy.cy);
+ m_res += ar;
+ }
+ }
+
+ m_fn.TrimRight('/');
+ m_fn.Replace('\\', '/');
+ m_fn = m_fn.Mid(m_fn.ReverseFind('/')+1);
+
+ UpdateData(FALSE);
+
+ InitEncoding();
+
+ m_pFG = NULL;
+ m_pCAP = NULL;
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPPageFileInfoDetails::InitEncoding()
{
- CAtlList<CString> sl;
-
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
- CComPtr<IBaseFilter> pUSBF = GetUpStreamFilter(pBF);
-
- if(GetCLSID(pBF) == CLSID_NetShowSource)
- {
- continue;
- }
- else if(GetCLSID(pUSBF) != CLSID_NetShowSource)
- {
- if(IPin* pPin = GetFirstPin(pBF, PINDIR_INPUT))
- {
- CMediaType mt;
- if(FAILED(pPin->ConnectionMediaType(&mt)) || mt.majortype != MEDIATYPE_Stream)
- continue;
- }
-
- if(IPin* pPin = GetFirstPin(pBF, PINDIR_OUTPUT))
- {
- CMediaType mt;
- if(SUCCEEDED(pPin->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream)
- continue;
- }
- }
-
- BeginEnumPins(pBF, pEP, pPin)
- {
- CMediaTypeEx mt;
- PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
- || FAILED(pPin->ConnectionMediaType(&mt)))
- continue;
-
- CString str = mt.ToString();
-
- if(!str.IsEmpty())
- {
- sl.AddTail(mt.ToString() + CString(L" [" + GetPinName(pPin) + L"]"));
- }
- }
- EndEnumPins
- }
- EndEnumFilters
-
- CString text = Implode(sl, '\n');
- text.Replace(_T("\n"), _T("\r\n"));
- m_encoding.SetWindowText(text);
+ CAtlList<CString> sl;
+
+ BeginEnumFilters(m_pFG, pEF, pBF)
+ {
+ CComPtr<IBaseFilter> pUSBF = GetUpStreamFilter(pBF);
+
+ if(GetCLSID(pBF) == CLSID_NetShowSource)
+ {
+ continue;
+ }
+ else if(GetCLSID(pUSBF) != CLSID_NetShowSource)
+ {
+ if(IPin* pPin = GetFirstPin(pBF, PINDIR_INPUT))
+ {
+ CMediaType mt;
+ if(FAILED(pPin->ConnectionMediaType(&mt)) || mt.majortype != MEDIATYPE_Stream)
+ continue;
+ }
+
+ if(IPin* pPin = GetFirstPin(pBF, PINDIR_OUTPUT))
+ {
+ CMediaType mt;
+ if(SUCCEEDED(pPin->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream)
+ continue;
+ }
+ }
+
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ CMediaTypeEx mt;
+ PIN_DIRECTION dir;
+ if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
+ || FAILED(pPin->ConnectionMediaType(&mt)))
+ continue;
+
+ CString str = mt.ToString();
+
+ if(!str.IsEmpty())
+ {
+ sl.AddTail(mt.ToString() + CString(L" [" + GetPinName(pPin) + L"]"));
+ }
+ }
+ EndEnumPins
+ }
+ EndEnumFilters
+
+ CString text = Implode(sl, '\n');
+ text.Replace(_T("\n"), _T("\r\n"));
+ m_encoding.SetWindowText(text);
}
diff --git a/src/apps/mplayerc/PPageFileInfoDetails.h b/src/apps/mplayerc/PPageFileInfoDetails.h
index 37bc4c30e..046746956 100644
--- a/src/apps/mplayerc/PPageFileInfoDetails.h
+++ b/src/apps/mplayerc/PPageFileInfoDetails.h
@@ -31,37 +31,37 @@
class CPPageFileInfoDetails : public CPropertyPage
{
- DECLARE_DYNAMIC(CPPageFileInfoDetails)
+ DECLARE_DYNAMIC(CPPageFileInfoDetails)
private:
- CComPtr<IFilterGraph> m_pFG;
- CComPtr<ISubPicAllocatorPresenter> m_pCAP;
+ CComPtr<IFilterGraph> m_pFG;
+ CComPtr<ISubPicAllocatorPresenter> m_pCAP;
- HICON m_hIcon;
-
- void InitEncoding();
+ HICON m_hIcon;
+
+ void InitEncoding();
public:
- CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISubPicAllocatorPresenter* pCAP);
- virtual ~CPPageFileInfoDetails();
+ CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISubPicAllocatorPresenter* pCAP);
+ virtual ~CPPageFileInfoDetails();
// Dialog Data
- enum { IDD = IDD_FILEPROPDETAILS };
+ enum { IDD = IDD_FILEPROPDETAILS };
- CStatic m_icon;
- CString m_fn;
- CString m_type;
- CString m_size;
- CString m_time;
- CString m_res;
- CString m_created;
- CEdit m_encoding;
+ CStatic m_icon;
+ CString m_fn;
+ CString m_type;
+ CString m_size;
+ CString m_time;
+ CString m_res;
+ CString m_created;
+ CEdit m_encoding;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
};
diff --git a/src/apps/mplayerc/PPageFileInfoRes.cpp b/src/apps/mplayerc/PPageFileInfoRes.cpp
index 71cded342..c96550570 100644
--- a/src/apps/mplayerc/PPageFileInfoRes.cpp
+++ b/src/apps/mplayerc/PPageFileInfoRes.cpp
@@ -30,121 +30,121 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoRes, CPPageBase)
CPPageFileInfoRes::CPPageFileInfoRes(CString fn, IFilterGraph* pFG)
- : CPPageBase(CPPageFileInfoRes::IDD, CPPageFileInfoRes::IDD)
- , m_fn(fn)
- , m_hIcon(NULL)
- , m_pFG(pFG)
+ : CPPageBase(CPPageFileInfoRes::IDD, CPPageFileInfoRes::IDD)
+ , m_fn(fn)
+ , m_hIcon(NULL)
+ , m_pFG(pFG)
{
}
CPPageFileInfoRes::~CPPageFileInfoRes()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) DestroyIcon(m_hIcon);
}
void CPPageFileInfoRes::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
- DDX_Text(pDX, IDC_EDIT1, m_fn);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
+ DDX_Text(pDX, IDC_EDIT1, m_fn);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BEGIN_MESSAGE_MAP(CPPageFileInfoRes, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnSaveAs)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateSaveAs)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnNMDblclkList1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnSaveAs)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateSaveAs)
+ ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnNMDblclkList1)
END_MESSAGE_MAP()
// CPPageFileInfoRes message handlers
BOOL CPPageFileInfoRes::OnInitDialog()
{
- __super::OnInitDialog();
-
- if(m_hIcon = LoadIcon(m_fn, false))
- m_icon.SetIcon(m_hIcon);
-
- m_fn.TrimRight('/');
- int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
- if(i >= 0 && i < m_fn.GetLength() - 1)
- m_fn = m_fn.Mid(i + 1);
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
-
- m_list.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 187);
- m_list.InsertColumn(1, _T("Mime Type"), LVCFMT_LEFT, 127);
-
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
- if(CComQIPtr<IDSMResourceBag> pRB = pBF)
- if(pRB && pRB->ResGetCount() > 0)
- {
- for(DWORD i = 0; i < pRB->ResGetCount(); i++)
- {
- CComBSTR name, desc, mime;
- BYTE* pData = NULL;
- DWORD len = 0;
- if(SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL)))
- {
- CDSMResource r;
- r.name = name;
- r.desc = desc;
- r.mime = mime;
- r.data.SetCount(len);
- memcpy(r.data.GetData(), pData, r.data.GetCount());
- CoTaskMemFree(pData);
- POSITION pos = m_res.AddTail(r);
- int iItem = m_list.InsertItem(m_list.GetItemCount(), CString(name));
- m_list.SetItemText(iItem, 1, CString(mime));
- m_list.SetItemData(iItem, (DWORD_PTR)pos);
- }
- }
- }
- }
- EndEnumFilters
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ if(m_hIcon = LoadIcon(m_fn, false))
+ m_icon.SetIcon(m_hIcon);
+
+ m_fn.TrimRight('/');
+ int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
+ if(i >= 0 && i < m_fn.GetLength()-1)
+ m_fn = m_fn.Mid(i+1);
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
+
+ m_list.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 187);
+ m_list.InsertColumn(1, _T("Mime Type"), LVCFMT_LEFT, 127);
+
+ BeginEnumFilters(m_pFG, pEF, pBF)
+ {
+ if(CComQIPtr<IDSMResourceBag> pRB = pBF)
+ if(pRB && pRB->ResGetCount() > 0)
+ {
+ for(DWORD i = 0; i < pRB->ResGetCount(); i++)
+ {
+ CComBSTR name, desc, mime;
+ BYTE* pData = NULL;
+ DWORD len = 0;
+ if(SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL)))
+ {
+ CDSMResource r;
+ r.name = name;
+ r.desc = desc;
+ r.mime = mime;
+ r.data.SetCount(len);
+ memcpy(r.data.GetData(), pData, r.data.GetCount());
+ CoTaskMemFree(pData);
+ POSITION pos = m_res.AddTail(r);
+ int iItem = m_list.InsertItem(m_list.GetItemCount(), CString(name));
+ m_list.SetItemText(iItem, 1, CString(mime));
+ m_list.SetItemData(iItem, (DWORD_PTR)pos);
+ }
+ }
+ }
+ }
+ EndEnumFilters
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPPageFileInfoRes::OnSaveAs()
{
- int i = m_list.GetSelectionMark();
- if(i < 0) return;
-
- CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
-
- CFileDialog fd(FALSE, NULL, CString(r.name),
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- _T("All files|*.*||"), this, 0);
- if(fd.DoModal() == IDOK)
- {
- if(FILE* f = _tfopen(fd.GetPathName(), _T("wb")))
- {
- fwrite(r.data.GetData(), 1, r.data.GetCount(), f);
- fclose(f);
- }
- }
+ int i = m_list.GetSelectionMark();
+ if(i < 0) return;
+
+ CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
+
+ CFileDialog fd(FALSE, NULL, CString(r.name),
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
+ _T("All files|*.*||"), this, 0);
+ if(fd.DoModal() == IDOK)
+ {
+ if(FILE* f = _tfopen(fd.GetPathName(), _T("wb")))
+ {
+ fwrite(r.data.GetData(), 1, r.data.GetCount(), f);
+ fclose(f);
+ }
+ }
}
void CPPageFileInfoRes::OnUpdateSaveAs(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetSelectedCount());
+ pCmdUI->Enable(m_list.GetSelectedCount());
}
void CPPageFileInfoRes::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
{
- int i = m_list.GetSelectionMark();
- if(i < 0) return;
+ int i = m_list.GetSelectionMark();
+ if(i < 0) return;
- CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
+ CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
- CString url;
- url.Format(_T("http://localhost:%d/convres.html?id=%x"), AfxGetAppSettings().nWebServerPort, (DWORD)&r);
- ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
+ CString url;
+ url.Format(_T("http://localhost:%d/convres.html?id=%x"), AfxGetAppSettings().nWebServerPort, (DWORD)&r);
+ ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
- *pResult = 0;
+ *pResult = 0;
}
diff --git a/src/apps/mplayerc/PPageFileInfoRes.h b/src/apps/mplayerc/PPageFileInfoRes.h
index b6793c01b..5882ff16d 100644
--- a/src/apps/mplayerc/PPageFileInfoRes.h
+++ b/src/apps/mplayerc/PPageFileInfoRes.h
@@ -33,32 +33,32 @@
class CPPageFileInfoRes : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageFileInfoRes)
+ DECLARE_DYNAMIC(CPPageFileInfoRes)
private:
- CComPtr<IFilterGraph> m_pFG;
- HICON m_hIcon;
- CAtlList<CDSMResource> m_res;
+ CComPtr<IFilterGraph> m_pFG;
+ HICON m_hIcon;
+ CAtlList<CDSMResource> m_res;
public:
- CPPageFileInfoRes(CString fn, IFilterGraph* pFG); // standard constructor
- virtual ~CPPageFileInfoRes();
+ CPPageFileInfoRes(CString fn, IFilterGraph* pFG); // standard constructor
+ virtual ~CPPageFileInfoRes();
// Dialog Data
- enum { IDD = IDD_FILEPROPRES };
+ enum { IDD = IDD_FILEPROPRES };
- CStatic m_icon;
- CString m_fn;
- CListCtrl m_list;
+ CStatic m_icon;
+ CString m_fn;
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSaveAs();
- afx_msg void OnUpdateSaveAs(CCmdUI* pCmdUI);
- afx_msg void OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnSaveAs();
+ afx_msg void OnUpdateSaveAs(CCmdUI* pCmdUI);
+ afx_msg void OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult);
};
diff --git a/src/apps/mplayerc/PPageFileInfoSheet.cpp b/src/apps/mplayerc/PPageFileInfoSheet.cpp
index 0b6513021..b866948e0 100644
--- a/src/apps/mplayerc/PPageFileInfoSheet.cpp
+++ b/src/apps/mplayerc/PPageFileInfoSheet.cpp
@@ -30,29 +30,29 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoSheet, CPropertySheet)
CPPageFileInfoSheet::CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd)
- : CPropertySheet(ResStr(IDS_PROPSHEET_PROPERTIES), pParentWnd, 0)
- , m_clip(fn, pMainFrame->pGB)
- , m_details(fn, pMainFrame->pGB, pMainFrame->m_pCAP)
- , m_res(fn, pMainFrame->pGB)
- , m_mi(fn)
- , m_fn(fn)
+ : CPropertySheet(ResStr(IDS_PROPSHEET_PROPERTIES), pParentWnd, 0)
+ , m_clip(fn, pMainFrame->pGB)
+ , m_details(fn, pMainFrame->pGB, pMainFrame->m_pCAP)
+ , m_res(fn, pMainFrame->pGB)
+ , m_mi(fn)
+ , m_fn(fn)
{
- AddPage(&m_clip);
- AddPage(&m_details);
-
- BeginEnumFilters(pMainFrame->pGB, pEF, pBF)
- {
- if(CComQIPtr<IDSMResourceBag> pRB = pBF)
- if(pRB && pRB->ResGetCount() > 0)
- {
- AddPage(&m_res);
- break;
- }
- }
- EndEnumFilters
-
- if(CPPageFileMediaInfo::HasMediaInfo())
- AddPage(&m_mi);
+ AddPage(&m_clip);
+ AddPage(&m_details);
+
+ BeginEnumFilters(pMainFrame->pGB, pEF, pBF)
+ {
+ if(CComQIPtr<IDSMResourceBag> pRB = pBF)
+ if(pRB && pRB->ResGetCount() > 0)
+ {
+ AddPage(&m_res);
+ break;
+ }
+ }
+ EndEnumFilters
+
+ if (CPPageFileMediaInfo::HasMediaInfo())
+ AddPage(&m_mi);
}
CPPageFileInfoSheet::~CPPageFileInfoSheet()
@@ -61,55 +61,55 @@ CPPageFileInfoSheet::~CPPageFileInfoSheet()
BEGIN_MESSAGE_MAP(CPPageFileInfoSheet, CPropertySheet)
- ON_BN_CLICKED(IDC_BUTTON_MI, OnSaveAs)
+ ON_BN_CLICKED(IDC_BUTTON_MI, OnSaveAs)
END_MESSAGE_MAP()
// CPPageFileInfoSheet message handlers
BOOL CPPageFileInfoSheet::OnInitDialog()
{
- BOOL fRet = __super::OnInitDialog();
-
- m_fn.TrimRight('/');
- int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
- if(i >= 0 && i < m_fn.GetLength() - 1)
- m_fn = m_fn.Mid(i + 1);
- m_fn = m_fn + _T(".MediaInfo.txt");
-
- GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
- GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE);
- GetDlgItem(IDOK)->SetWindowText(ResStr(IDS_AG_CLOSE));
-
- CRect r;
- GetDlgItem(ID_APPLY_NOW)->GetWindowRect(&r);
- ScreenToClient(r);
- GetDlgItem(IDOK)->MoveWindow(r);
-
- r.MoveToX(5);
- r.right += 10;
- m_Button_MI.Create(ResStr(IDS_AG_SAVE_AS), WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, r, this, IDC_BUTTON_MI);
- m_Button_MI.SetFont(GetFont());
- m_Button_MI.ShowWindow(SW_HIDE);
-
- return fRet;
+ BOOL fRet = __super::OnInitDialog();
+
+ m_fn.TrimRight('/');
+ int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
+ if(i >= 0 && i < m_fn.GetLength()-1)
+ m_fn = m_fn.Mid(i+1);
+ m_fn = m_fn+_T(".MediaInfo.txt");
+
+ GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
+ GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE);
+ GetDlgItem(IDOK)->SetWindowText(ResStr(IDS_AG_CLOSE));
+
+ CRect r;
+ GetDlgItem(ID_APPLY_NOW)->GetWindowRect(&r);
+ ScreenToClient(r);
+ GetDlgItem(IDOK)->MoveWindow(r);
+
+ r.MoveToX(5);
+ r.right += 10;
+ m_Button_MI.Create(ResStr(IDS_AG_SAVE_AS), WS_CHILD|BS_PUSHBUTTON|WS_VISIBLE, r, this, IDC_BUTTON_MI);
+ m_Button_MI.SetFont(GetFont());
+ m_Button_MI.ShowWindow(SW_HIDE);
+
+ return fRet;
}
void CPPageFileInfoSheet::OnSaveAs()
{
- CFileDialog filedlg(FALSE, _T("*.txt"), m_fn,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
- _T("Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
-
- if(filedlg.DoModal() == IDOK) // user has chosen a file, so
- {
- _TCHAR bom = (_TCHAR)0xFEFF;
- CFile mFile;
- if(mFile.Open(filedlg.GetPathName(), CFile::modeCreate | CFile::modeWrite))
- {
- mFile.Write(&bom, sizeof(_TCHAR));
- mFile.Write(LPCTSTR(m_mi.MI_Text), m_mi.MI_Text.GetLength()*sizeof(_TCHAR));
- mFile.Close();
- }
- }
+ CFileDialog filedlg (FALSE, _T("*.txt"), m_fn,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
+ _T("Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
+
+ if (filedlg.DoModal() == IDOK) // user has chosen a file, so
+ {
+ _TCHAR bom = (_TCHAR)0xFEFF;
+ CFile mFile;
+ if(mFile.Open(filedlg.GetPathName(), CFile::modeCreate | CFile::modeWrite))
+ {
+ mFile.Write(&bom, sizeof(_TCHAR));
+ mFile.Write(LPCTSTR(m_mi.MI_Text), m_mi.MI_Text.GetLength()*sizeof(_TCHAR));
+ mFile.Close();
+ }
+ }
}
diff --git a/src/apps/mplayerc/PPageFileInfoSheet.h b/src/apps/mplayerc/PPageFileInfoSheet.h
index 812422b09..6697ef5ba 100644
--- a/src/apps/mplayerc/PPageFileInfoSheet.h
+++ b/src/apps/mplayerc/PPageFileInfoSheet.h
@@ -34,25 +34,25 @@ class CMainFrame;
class CPPageFileInfoSheet : public CPropertySheet
{
- DECLARE_DYNAMIC(CPPageFileInfoSheet)
+ DECLARE_DYNAMIC(CPPageFileInfoSheet)
private:
- CPPageFileInfoClip m_clip;
- CPPageFileInfoDetails m_details;
- CPPageFileInfoRes m_res;
- CPPageFileMediaInfo m_mi;
+ CPPageFileInfoClip m_clip;
+ CPPageFileInfoDetails m_details;
+ CPPageFileInfoRes m_res;
+ CPPageFileMediaInfo m_mi;
- CButton m_Button_MI;
+ CButton m_Button_MI;
public:
- CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd);
- virtual ~CPPageFileInfoSheet();
+ CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd);
+ virtual ~CPPageFileInfoSheet();
- afx_msg void OnSaveAs();
+ afx_msg void OnSaveAs();
- CString m_fn;
+ CString m_fn;
protected:
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/apps/mplayerc/PPageFileMediaInfo.cpp b/src/apps/mplayerc/PPageFileMediaInfo.cpp
index 1d724fa4e..4ec69f65f 100644
--- a/src/apps/mplayerc/PPageFileMediaInfo.cpp
+++ b/src/apps/mplayerc/PPageFileMediaInfo.cpp
@@ -34,69 +34,69 @@ using namespace MediaInfoDLL;
IMPLEMENT_DYNAMIC(CPPageFileMediaInfo, CPropertyPage)
CPPageFileMediaInfo::CPPageFileMediaInfo(CString fn)
- : CPropertyPage(CPPageFileMediaInfo::IDD, CPPageFileMediaInfo::IDD)
- , m_fn(fn)
- , m_pCFont(NULL)
+ : CPropertyPage(CPPageFileMediaInfo::IDD, CPPageFileMediaInfo::IDD)
+ , m_fn(fn)
+ , m_pCFont(NULL)
{
}
CPPageFileMediaInfo::~CPPageFileMediaInfo()
{
- if(m_pCFont) delete m_pCFont;
+ if(m_pCFont) delete m_pCFont;
}
void CPPageFileMediaInfo::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_MIEDIT, m_mediainfo);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_MIEDIT, m_mediainfo);
}
BEGIN_MESSAGE_MAP(CPPageFileMediaInfo, CPropertyPage)
- ON_WM_SHOWWINDOW()
+ ON_WM_SHOWWINDOW()
END_MESSAGE_MAP()
// CPPageFileMediaInfo message handlers
BOOL CPPageFileMediaInfo::OnInitDialog()
{
- __super::OnInitDialog();
-
- if(!m_pCFont) m_pCFont = DNew CFont;
- if(!m_pCFont) return TRUE;
-
- MediaInfoDLL::String f_name = m_fn;
- MediaInfo MI;
- MI.Open(f_name);
- MI.Option(_T("Complete"));
- MI_Text = MI.Inform().c_str();
- MI.Close();
- if(!MI_Text.Find(_T("Unable to load"))) MI_Text = _T("");
-
- LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- lf.lfHeight = 10;
- lf.lfPitchAndFamily = DEFAULT_PITCH | FF_ROMAN;
- lstrcpy(lf.lfFaceName, _T("Lucida Console"));
- m_pCFont->CreateFontIndirect(&lf);
- m_mediainfo.SetFont(m_pCFont);
- m_mediainfo.SetWindowText(MI_Text);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ if(!m_pCFont) m_pCFont = DNew CFont;
+ if(!m_pCFont) return TRUE;
+
+ MediaInfoDLL::String f_name = m_fn;
+ MediaInfo MI;
+ MI.Open(f_name);
+ MI.Option(_T("Complete"));
+ MI_Text = MI.Inform().c_str();
+ MI.Close();
+ if(!MI_Text.Find(_T("Unable to load"))) MI_Text = _T("");
+
+ LOGFONT lf;
+ memset( &lf, 0, sizeof(lf) );
+ lf.lfHeight = 10;
+ lf.lfPitchAndFamily = DEFAULT_PITCH | FF_ROMAN;
+ lstrcpy( lf.lfFaceName, _T("Lucida Console") );
+ m_pCFont->CreateFontIndirect( &lf );
+ m_mediainfo.SetFont( m_pCFont );
+ m_mediainfo.SetWindowText(MI_Text);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPPageFileMediaInfo::OnShowWindow(BOOL bShow, UINT nStatus)
{
- __super::OnShowWindow(bShow, nStatus);
- if(bShow)
- GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_SHOW);
- else
- GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_HIDE);
+ __super::OnShowWindow(bShow, nStatus);
+ if(bShow)
+ GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_SHOW);
+ else
+ GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_HIDE);
}
bool CPPageFileMediaInfo::HasMediaInfo()
{
- MediaInfo MI;
- return MI.IsReady();
+ MediaInfo MI;
+ return MI.IsReady();
}
diff --git a/src/apps/mplayerc/PPageFileMediaInfo.h b/src/apps/mplayerc/PPageFileMediaInfo.h
index 466a59838..864e578e5 100644
--- a/src/apps/mplayerc/PPageFileMediaInfo.h
+++ b/src/apps/mplayerc/PPageFileMediaInfo.h
@@ -27,28 +27,28 @@
class CPPageFileMediaInfo : public CPropertyPage
{
- DECLARE_DYNAMIC(CPPageFileMediaInfo)
+ DECLARE_DYNAMIC(CPPageFileMediaInfo)
public:
- CPPageFileMediaInfo(CString fn); // standard constructor
- virtual ~CPPageFileMediaInfo();
+ CPPageFileMediaInfo(CString fn); // standard constructor
+ virtual ~CPPageFileMediaInfo();
// Dialog Data
- enum { IDD = IDD_FILEMEDIAINFO };
+ enum { IDD = IDD_FILEMEDIAINFO };
- CEdit m_mediainfo;
- CString m_fn;
- CFont* m_pCFont;
+ CEdit m_mediainfo;
+ CString m_fn;
+ CFont* m_pCFont;
- CString MI_Text;
+ CString MI_Text;
- static bool HasMediaInfo();
+ static bool HasMediaInfo();
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+ afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
};
diff --git a/src/apps/mplayerc/PPageFormats.cpp b/src/apps/mplayerc/PPageFormats.cpp
index 449922f5d..703bf6272 100644
--- a/src/apps/mplayerc/PPageFormats.cpp
+++ b/src/apps/mplayerc/PPageFormats.cpp
@@ -44,22 +44,22 @@ int f_setAssociatedWithIcon = 0;
IMPLEMENT_DYNAMIC(CPPageFormats, CPPageBase)
CPPageFormats::CPPageFormats()
- : CPPageBase(CPPageFormats::IDD, CPPageFormats::IDD)
- , m_list(0)
- , m_exts(_T(""))
- , m_iRtspHandler(0)
- , m_fRtspFileExtFirst(FALSE)
- , m_bInsufficientPrivileges(false)
+ : CPPageBase(CPPageFormats::IDD, CPPageFormats::IDD)
+ , m_list(0)
+ , m_exts(_T(""))
+ , m_iRtspHandler(0)
+ , m_fRtspFileExtFirst(FALSE)
+ , m_bInsufficientPrivileges(false)
{
- if(m_pAAR == NULL)
- {
- // Default manager (requiered at least Vista)
- HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
- NULL,
- CLSCTX_INPROC,
- __uuidof(IApplicationAssociationRegistration),
- (void**)&m_pAAR);
- }
+ if (m_pAAR == NULL)
+ {
+ // Default manager (requiered at least Vista)
+ HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
+ NULL,
+ CLSCTX_INPROC,
+ __uuidof(IApplicationAssociationRegistration),
+ (void**)&m_pAAR);
+ }
}
CPPageFormats::~CPPageFormats()
@@ -68,142 +68,142 @@ CPPageFormats::~CPPageFormats()
void CPPageFormats::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Text(pDX, IDC_EDIT1, m_exts);
- DDX_Control(pDX, IDC_STATIC1, m_autoplay);
- DDX_Control(pDX, IDC_CHECK1, m_apvideo);
- DDX_Control(pDX, IDC_CHECK2, m_apmusic);
- DDX_Control(pDX, IDC_CHECK3, m_apaudiocd);
- DDX_Control(pDX, IDC_CHECK4, m_apdvd);
- DDX_Radio(pDX, IDC_RADIO1, m_iRtspHandler);
- DDX_Check(pDX, IDC_CHECK5, m_fRtspFileExtFirst);
- DDX_Control(pDX, IDC_CHECK6, m_fContextDir);
- DDX_Control(pDX, IDC_CHECK7, m_fContextFiles);
- DDX_Control(pDX, IDC_CHECK8, m_fAssociatedWithIcons);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list);
+ DDX_Text(pDX, IDC_EDIT1, m_exts);
+ DDX_Control(pDX, IDC_STATIC1, m_autoplay);
+ DDX_Control(pDX, IDC_CHECK1, m_apvideo);
+ DDX_Control(pDX, IDC_CHECK2, m_apmusic);
+ DDX_Control(pDX, IDC_CHECK3, m_apaudiocd);
+ DDX_Control(pDX, IDC_CHECK4, m_apdvd);
+ DDX_Radio(pDX, IDC_RADIO1, m_iRtspHandler);
+ DDX_Check(pDX, IDC_CHECK5, m_fRtspFileExtFirst);
+ DDX_Control(pDX, IDC_CHECK6, m_fContextDir);
+ DDX_Control(pDX, IDC_CHECK7, m_fContextFiles);
+ DDX_Control(pDX, IDC_CHECK8, m_fAssociatedWithIcons);
}
int CPPageFormats::GetChecked(int iItem)
{
- LVITEM lvi;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_IMAGE;
- m_list.GetItem(&lvi);
- return(lvi.iImage);
+ LVITEM lvi;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_IMAGE;
+ m_list.GetItem(&lvi);
+ return(lvi.iImage);
}
void CPPageFormats::SetChecked(int iItem, int iChecked)
{
- LVITEM lvi;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_IMAGE;
- lvi.iImage = iChecked;
- m_list.SetItem(&lvi);
+ LVITEM lvi;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_IMAGE;
+ lvi.iImage = iChecked;
+ m_list.SetItem(&lvi);
}
CString CPPageFormats::GetEnqueueCommand()
{
- CString path;
+ CString path;
- TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0)
- return _T("");
+ TCHAR buff[_MAX_PATH];
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0)
+ return _T("");
- path = buff;
- return _T("\"") + path + _T("\" /add \"%1\"");
+ path = buff;
+ return _T("\"") + path + _T("\" /add \"%1\"");
}
CString CPPageFormats::GetOpenCommand()
{
- CString path;
- TCHAR buff[_MAX_PATH];
+ CString path;
+ TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0)
- return _T("");
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0)
+ return _T("");
- path = buff;
- return _T("\"") + path + _T("\" \"%1\"");
+ path = buff;
+ return _T("\"") + path + _T("\" \"%1\"");
}
bool CPPageFormats::IsRegistered(CString ext)
{
- BOOL bIsDefault = FALSE;
- CString strProgID = _T("mplayerc") + ext;
-
- if(m_pAAR == NULL)
- {
- // Default manager (requires at least Vista)
- HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
- NULL,
- CLSCTX_INPROC,
- __uuidof(IApplicationAssociationRegistration),
- (void**)&m_pAAR);
- }
-
- if(m_pAAR)
- {
- // The Vista way
- HRESULT hr;
- hr = m_pAAR->QueryAppIsDefault(ext, AT_FILEEXTENSION, AL_EFFECTIVE, g_strRegisteredAppName, &bIsDefault);
- }
- else
- {
- // The 2000/XP way
- CRegKey key;
- TCHAR buff[256];
- ULONG len = sizeof(buff);
- memset(buff, 0, len);
-
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext))
- return false;
-
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
- return false;
-
- bIsDefault = (buff == strProgID);
- }
- if(!f_setContextFiles)
- {
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = sizeof(buff);
-
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"), KEY_READ))
- {
- CString strCommand = ResStr(IDS_OPEN_WITH_MPC);
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len))
- f_setContextFiles = (strCommand.CompareNoCase(CString(buff)) == 0);
- }
- }
-
- // Check if association is for this instance of MPC
- if(bIsDefault)
- {
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = sizeof(buff);
-
- bIsDefault = FALSE;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ))
- {
- CString strCommand = GetOpenCommand();
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len))
- bIsDefault = (strCommand.CompareNoCase(CString(buff)) == 0);
- }
-
- }
-
- return !!bIsDefault;
+ BOOL bIsDefault = FALSE;
+ CString strProgID = _T("mplayerc") + ext;
+
+ if (m_pAAR == NULL)
+ {
+ // Default manager (requires at least Vista)
+ HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
+ NULL,
+ CLSCTX_INPROC,
+ __uuidof(IApplicationAssociationRegistration),
+ (void**)&m_pAAR);
+ }
+
+ if (m_pAAR)
+ {
+ // The Vista way
+ HRESULT hr;
+ hr = m_pAAR->QueryAppIsDefault(ext, AT_FILEEXTENSION, AL_EFFECTIVE, g_strRegisteredAppName, &bIsDefault);
+ }
+ else
+ {
+ // The 2000/XP way
+ CRegKey key;
+ TCHAR buff[256];
+ ULONG len = sizeof(buff);
+ memset(buff, 0, len);
+
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext))
+ return false;
+
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ return false;
+
+ bIsDefault = (buff == strProgID);
+ }
+ if(!f_setContextFiles)
+ {
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = sizeof(buff);
+
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"), KEY_READ))
+ {
+ CString strCommand = ResStr(IDS_OPEN_WITH_MPC);
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len))
+ f_setContextFiles = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
+ }
+
+ // Check if association is for this instance of MPC
+ if (bIsDefault)
+ {
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = sizeof(buff);
+
+ bIsDefault = FALSE;
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ))
+ {
+ CString strCommand = GetOpenCommand();
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len))
+ bIsDefault = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
+
+ }
+
+ return !!bIsDefault;
}
CString GetProgramDir()
{
CString RtnVal;
TCHAR FileName[_MAX_PATH];
- ::GetModuleFileName(AfxGetInstanceHandle(), FileName, MAX_PATH);
+ ::GetModuleFileName(AfxGetInstanceHandle(), FileName, MAX_PATH);
RtnVal = FileName;
RtnVal = RtnVal.Left(RtnVal.ReverseFind('\\'));
return RtnVal;
@@ -211,851 +211,835 @@ CString GetProgramDir()
int FileExists(const TCHAR *fileName)
{
- DWORD fileAttr;
- fileAttr = ::GetFileAttributes(fileName);
- if(0xFFFFFFFF == fileAttr)
- return false;
- return true;
+ DWORD fileAttr;
+ fileAttr = ::GetFileAttributes(fileName);
+ if (0xFFFFFFFF == fileAttr)
+ return false;
+ return true;
}
typedef int (*GetIconIndexFunc)(CString);
int GetIconIndex(CString ext)
-{
- int iconindex = -1;
- GetIconIndexFunc _getIconIndexFunc;
- HINSTANCE mpciconlib = LoadLibrary(_T("mpciconlib.dll"));
- if(mpciconlib)
- {
- _getIconIndexFunc = (GetIconIndexFunc) GetProcAddress(mpciconlib, "get_icon_index");
- if(_getIconIndexFunc)
- {
- iconindex = _getIconIndexFunc(ext);
- }
- FreeLibrary(mpciconlib);
- }
-
- return iconindex;
+{
+ int iconindex = -1;
+ GetIconIndexFunc _getIconIndexFunc;
+ HINSTANCE mpciconlib = LoadLibrary(_T("mpciconlib.dll"));
+ if(mpciconlib)
+ {
+ _getIconIndexFunc = (GetIconIndexFunc) GetProcAddress(mpciconlib, "get_icon_index");
+ if(_getIconIndexFunc)
+ {
+ iconindex = _getIconIndexFunc(ext);
+ }
+ FreeLibrary(mpciconlib);
+ }
+
+ return iconindex;
}
bool CPPageFormats::RegisterExt(CString ext, CString strLabel, bool fRegister)
{
- CRegKey key;
- bool bSetValue;
- CString strProgID = _T("mplayerc") + ext;
-
- if(!fRegister)
- {
- if(fRegister != IsRegistered(ext))
- SetFileAssociation(ext, strProgID, fRegister);
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(strProgID);
- return(true);
- }
-
- bSetValue = fRegister || (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ));
-
- // Create ProgID for this file type
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) return(false);
- if(ERROR_SUCCESS != key.SetStringValue(NULL, strLabel)) return(false);
-
- // Add to playlist option
- if(f_setContextFiles)
- {
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue"))) return(false);
- if(ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST))) return(false);
-
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue\\command"))) return(false);
- if(bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetEnqueueCommand()))) return(false);
- }
- else
- {
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(strProgID + _T("\\shell\\enqueue"));
- }
-
- // Play option
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"))) return(false);
- if(f_setContextFiles)
- {
- if(ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC))) return(false);
- }
- else
- {
- if(ERROR_SUCCESS != key.SetStringValue(NULL, _T(""))) return(false);
- }
-
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"))) return(false);
- if(bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetOpenCommand()))) return(false);
-
- if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey + _T("\\FileAssociations"))) return(false);
- if(ERROR_SUCCESS != key.SetStringValue(ext, strProgID)) return(false);
-
- if(f_setAssociatedWithIcon)
- {
- CString AppIcon = _T("");
- TCHAR buff[_MAX_PATH];
-
- CString mpciconlib = GetProgramDir() + _T("\\mpciconlib.dll");
-
- if(FileExists(mpciconlib))
- {
- int icon_index = GetIconIndex(ext);
- CString m_typeicon = mpciconlib;
-
- /* icon_index value -1 means no icon was found in the iconlib for the file extension */
- if((icon_index >= 0) && ExtractIcon(AfxGetApp()->m_hInstance, (LPCWSTR)m_typeicon, icon_index))
- {
- m_typeicon = "\"" + mpciconlib + "\"";
- AppIcon.Format(_T("%s,%d"), m_typeicon, icon_index);
- }
- }
-
- /* no icon was found for the file extension, so use MPC's icon */
- if((AppIcon.IsEmpty()) && (::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH)))
- {
- AppIcon = buff;
- AppIcon = "\"" + AppIcon + "\"";
- AppIcon += _T(",0");
- }
-
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))) return(false);
- if(bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, AppIcon))) return(false);
- }
- else
- {
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(strProgID + _T("\\DefaultIcon"));
- }
-
- if(fRegister != IsRegistered(ext))
- SetFileAssociation(ext, strProgID, fRegister);
-
- return(true);
+ CRegKey key;
+ bool bSetValue;
+ CString strProgID = _T("mplayerc") + ext;
+
+ if(!fRegister)
+ {
+ if(fRegister != IsRegistered(ext))
+ SetFileAssociation (ext, strProgID, fRegister);
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(strProgID);
+ return(true);
+ }
+
+ bSetValue = fRegister || (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ));
+
+ // Create ProgID for this file type
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) return(false);
+ if(ERROR_SUCCESS != key.SetStringValue(NULL, strLabel)) return(false);
+
+ // Add to playlist option
+ if(f_setContextFiles)
+ {
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue"))) return(false);
+ if(ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST))) return(false);
+
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue\\command"))) return(false);
+ if(bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetEnqueueCommand()))) return(false);
+ }
+ else
+ {
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(strProgID + _T("\\shell\\enqueue"));
+ }
+
+ // Play option
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"))) return(false);
+ if(f_setContextFiles)
+ {
+ if(ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC))) return(false);
+ }
+ else
+ {
+ if(ERROR_SUCCESS != key.SetStringValue(NULL, _T(""))) return(false);
+ }
+
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"))) return(false);
+ if(bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetOpenCommand()))) return(false);
+
+ if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey + _T("\\FileAssociations"))) return(false);
+ if(ERROR_SUCCESS != key.SetStringValue(ext, strProgID)) return(false);
+
+ if(f_setAssociatedWithIcon)
+ {
+ CString AppIcon = _T("");
+ TCHAR buff[_MAX_PATH];
+
+ CString mpciconlib = GetProgramDir() + _T("\\mpciconlib.dll");
+
+ if(FileExists(mpciconlib))
+ {
+ int icon_index = GetIconIndex(ext);
+ CString m_typeicon = mpciconlib;
+
+ /* icon_index value -1 means no icon was found in the iconlib for the file extension */
+ if((icon_index >= 0) && ExtractIcon(AfxGetApp()->m_hInstance,(LPCWSTR)m_typeicon, icon_index))
+ {
+ m_typeicon = "\""+mpciconlib+"\"";
+ AppIcon.Format(_T("%s,%d"), m_typeicon, icon_index);
+ }
+ }
+
+ /* no icon was found for the file extension, so use MPC's icon */
+ if((AppIcon.IsEmpty()) && (::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH)))
+ {
+ AppIcon = buff;
+ AppIcon = "\""+AppIcon+"\"";
+ AppIcon += _T(",0");
+ }
+
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))) return(false);
+ if(bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, AppIcon))) return(false);
+ }
+ else
+ {
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(strProgID + _T("\\DefaultIcon"));
+ }
+
+ if(fRegister != IsRegistered(ext))
+ SetFileAssociation (ext, strProgID, fRegister);
+
+ return(true);
}
-static struct
-{
- LPCSTR verb, cmd;
- UINT action;
-} handlers[] =
+static struct {LPCSTR verb, cmd; UINT action;} handlers[] =
{
- {"VideoFiles", " %1", IDS_AUTOPLAY_PLAYVIDEO},
- {"MusicFiles", " %1", IDS_AUTOPLAY_PLAYMUSIC},
- {"CDAudio", " %1 /cd", IDS_AUTOPLAY_PLAYAUDIOCD},
- {"DVDMovie", " %1 /dvd", IDS_AUTOPLAY_PLAYDVDMOVIE},
+ {"VideoFiles", " %1", IDS_AUTOPLAY_PLAYVIDEO},
+ {"MusicFiles", " %1", IDS_AUTOPLAY_PLAYMUSIC},
+ {"CDAudio", " %1 /cd", IDS_AUTOPLAY_PLAYAUDIOCD},
+ {"DVDMovie", " %1 /dvd", IDS_AUTOPLAY_PLAYDVDMOVIE},
};
void CPPageFormats::AddAutoPlayToRegistry(autoplay_t ap, bool fRegister)
{
- if(!AfxGetAppSettings().fXpOrBetter) return;
-
- TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0) return;
- CString exe = buff;
-
- int i = (int)ap;
- if(i < 0 || i >= countof(handlers)) return;
-
- CRegKey key;
-
- if(fRegister)
- {
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, _T("MediaPlayerClassic.Autorun"))) return;
- key.Close();
-
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT,
- CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"))) return;
- key.SetStringValue(NULL, _T("\"") + exe + _T("\"") + handlers[i].cmd);
- key.Close();
-
- if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\Handlers\\MPCPlay") + handlers[i].verb + "OnArrival"))) return;
- key.SetStringValue(_T("Action"), ResStr(handlers[i].action));
- key.SetStringValue(_T("Provider"), _T("Media Player Classic"));
- key.SetStringValue(_T("InvokeProgID"), _T("MediaPlayerClassic.Autorun"));
- key.SetStringValue(_T("InvokeVerb"), CString(CStringA("Play") + handlers[i].verb));
- key.SetStringValue(_T("DefaultIcon"), exe + _T(",0"));
- key.Close();
-
- if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) return;
- key.SetStringValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"), _T(""));
- key.Close();
- }
- else
- {
- if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) return;
- key.DeleteValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"));
- key.Close();
- }
+ if(!AfxGetAppSettings().fXpOrBetter) return;
+
+ TCHAR buff[_MAX_PATH];
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0) return;
+ CString exe = buff;
+
+ int i = (int)ap;
+ if(i < 0 || i >= countof(handlers)) return;
+
+ CRegKey key;
+
+ if(fRegister)
+ {
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, _T("MediaPlayerClassic.Autorun"))) return;
+ key.Close();
+
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT,
+ CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"))) return;
+ key.SetStringValue(NULL, _T("\"") + exe + _T("\"") + handlers[i].cmd);
+ key.Close();
+
+ if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\Handlers\\MPCPlay") + handlers[i].verb + "OnArrival"))) return;
+ key.SetStringValue(_T("Action"), ResStr(handlers[i].action));
+ key.SetStringValue(_T("Provider"), _T("Media Player Classic"));
+ key.SetStringValue(_T("InvokeProgID"), _T("MediaPlayerClassic.Autorun"));
+ key.SetStringValue(_T("InvokeVerb"), CString(CStringA("Play") + handlers[i].verb));
+ key.SetStringValue(_T("DefaultIcon"), exe + _T(",0"));
+ key.Close();
+
+ if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) return;
+ key.SetStringValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"), _T(""));
+ key.Close();
+ }
+ else
+ {
+ if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) return;
+ key.DeleteValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"));
+ key.Close();
+ }
}
bool CPPageFormats::IsAutoPlayRegistered(autoplay_t ap)
{
- ULONG len;
- TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0) return(false);
- CString exe = buff;
-
- int i = (int)ap;
- if(i < 0 || i >= countof(handlers)) return(false);
-
- CRegKey key;
-
- if(ERROR_SUCCESS != key.Open(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"),
- KEY_READ)) return(false);
- len = countof(buff);
- if(ERROR_SUCCESS != key.QueryStringValue(
- CString(_T("MPCPlay")) + handlers[i].verb + _T("OnArrival"),
- buff, &len)) return(false);
- key.Close();
-
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT,
- CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"),
- KEY_READ)) return(false);
- len = countof(buff);
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
- return(false);
- if(_tcsnicmp(_T("\"") + exe, buff, exe.GetLength() + 1))
- return(false);
- key.Close();
-
- return(true);
+ ULONG len;
+ TCHAR buff[_MAX_PATH];
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH) == 0) return(false);
+ CString exe = buff;
+
+ int i = (int)ap;
+ if(i < 0 || i >= countof(handlers)) return(false);
+
+ CRegKey key;
+
+ if(ERROR_SUCCESS != key.Open(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"),
+ KEY_READ)) return(false);
+ len = countof(buff);
+ if(ERROR_SUCCESS != key.QueryStringValue(
+ CString(_T("MPCPlay")) + handlers[i].verb + _T("OnArrival"),
+ buff, &len)) return(false);
+ key.Close();
+
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT,
+ CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"),
+ KEY_READ)) return(false);
+ len = countof(buff);
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
+ return(false);
+ if(_tcsnicmp(_T("\"") + exe, buff, exe.GetLength() + 1))
+ return(false);
+ key.Close();
+
+ return(true);
}
void CPPageFormats::SetListItemState(int nItem)
{
- if(nItem < 0) return;
+ if(nItem < 0) return;
- CString str = AfxGetAppSettings().Formats[(int)m_list.GetItemData(nItem)].GetExtsWithPeriod();
+ CString str = AfxGetAppSettings().Formats[(int)m_list.GetItemData(nItem)].GetExtsWithPeriod();
- CAtlList<CString> exts;
- ExplodeMin(str, exts, ' ');
+ CAtlList<CString> exts;
+ ExplodeMin(str, exts, ' ');
- int cnt = 0;
+ int cnt = 0;
- POSITION pos = exts.GetHeadPosition();
- while(pos) if(IsRegistered(exts.GetNext(pos))) cnt++;
+ POSITION pos = exts.GetHeadPosition();
+ while(pos) if(IsRegistered(exts.GetNext(pos))) cnt++;
- SetChecked(nItem, cnt == 0 ? 0 : cnt == exts.GetCount() ? 1 : 2);
+ SetChecked(nItem, cnt == 0 ? 0 : cnt == exts.GetCount() ? 1 : 2);
}
BEGIN_MESSAGE_MAP(CPPageFormats, CPPageBase)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
- ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnLvnItemchangedList1)
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton12)
- ON_BN_CLICKED(IDC_BUTTON_EXT_SET, OnBnClickedButton11)
- ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton14)
- ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton13)
- ON_BN_CLICKED(IDC_BUTTON5, OnBnVistaModify)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButtonDefault)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON_EXT_SET, OnUpdateButtonSet)
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
+ ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnLvnItemchangedList1)
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton12)
+ ON_BN_CLICKED(IDC_BUTTON_EXT_SET, OnBnClickedButton11)
+ ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton14)
+ ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton13)
+ ON_BN_CLICKED(IDC_BUTTON5, OnBnVistaModify)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButtonDefault)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON_EXT_SET, OnUpdateButtonSet)
END_MESSAGE_MAP()
// CPPageFormats message handlers
BOOL CPPageFormats::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
- m_list.InsertColumn(COL_CATEGORY, _T("Category"), LVCFMT_LEFT, 300);
- m_list.InsertColumn(COL_ENGINE, _T("Engine"), LVCFMT_RIGHT, 60);
+ m_list.InsertColumn(COL_CATEGORY, _T("Category"), LVCFMT_LEFT, 300);
+ m_list.InsertColumn(COL_ENGINE, _T("Engine"), LVCFMT_RIGHT, 60);
- m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff);
- m_list.SetImageList(&m_onoff, LVSIL_SMALL);
+ m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff);
+ m_list.SetImageList(&m_onoff, LVSIL_SMALL);
- CMediaFormats& mf = AfxGetAppSettings().Formats;
- mf.UpdateData(FALSE);
- for(int i = 0; i < (int)mf.GetCount(); i++)
- {
- CString label;
- label.Format(_T("%s (%s)"), mf[i].GetLabel(), mf[i].GetExts());
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+ mf.UpdateData(FALSE);
+ for(int i = 0; i < (int)mf.GetCount(); i++)
+ {
+ CString label;
+ label.Format (_T("%s (%s)"), mf[i].GetLabel(), mf[i].GetExts());
- int iItem = m_list.InsertItem(i, label);
- m_list.SetItemData(iItem, i);
- engine_t e = mf[i].GetEngineType();
- m_list.SetItemText(iItem, COL_ENGINE,
- e == DirectShow ? _T("DirectShow") :
- e == RealMedia ? _T("RealMedia") :
- e == QuickTime ? _T("QuickTime") :
- e == ShockWave ? _T("ShockWave") : _T("-"));
- }
+ int iItem = m_list.InsertItem(i, label);
+ m_list.SetItemData(iItem, i);
+ engine_t e = mf[i].GetEngineType();
+ m_list.SetItemText(iItem, COL_ENGINE,
+ e == DirectShow ? _T("DirectShow") :
+ e == RealMedia ? _T("RealMedia") :
+ e == QuickTime ? _T("QuickTime") :
+ e == ShockWave ? _T("ShockWave") : _T("-"));
+ }
// m_list.SetColumnWidth(COL_CATEGORY, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_ENGINE, LVSCW_AUTOSIZE_USEHEADER);
-
- m_list.SetSelectionMark(0);
- m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
- m_exts = mf[(int)m_list.GetItemData(0)].GetExtsWithPeriod();
-
- AppSettings& s = AfxGetAppSettings();
- bool fRtspFileExtFirst;
- engine_t e = s.Formats.GetRtspHandler(fRtspFileExtFirst);
- m_iRtspHandler = (e == RealMedia ? 0 : e == QuickTime ? 1 : 2);
- m_fRtspFileExtFirst = fRtspFileExtFirst;
-
- UpdateData(FALSE);
-
- f_setContextFiles = 0;
-
- for(int i = 0; i < m_list.GetItemCount(); i++)
- {
- SetListItemState(i);
- }
- m_fContextFiles.SetCheck(f_setContextFiles);
-
- if(AfxGetAppSettings().fXpOrBetter)
- {
- m_apvideo.SetCheck(IsAutoPlayRegistered(AP_VIDEO));
- m_apmusic.SetCheck(IsAutoPlayRegistered(AP_MUSIC));
- m_apaudiocd.SetCheck(IsAutoPlayRegistered(AP_AUDIOCD));
- m_apdvd.SetCheck(IsAutoPlayRegistered(AP_DVDMOVIE));
- }
- else
- {
- m_autoplay.ShowWindow(SW_HIDE);
- m_apvideo.ShowWindow(SW_HIDE);
- m_apmusic.ShowWindow(SW_HIDE);
- m_apaudiocd.ShowWindow(SW_HIDE);
- m_apdvd.ShowWindow(SW_HIDE);
- }
-
- CreateToolTip();
-
-
- if(AfxGetMyApp()->IsVistaOrAbove() && !IsUserAnAdmin())
- {
- GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_BUTTON3)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_BUTTON4)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
- GetDlgItem(IDC_CHECK2)->EnableWindow(FALSE);
- GetDlgItem(IDC_CHECK3)->EnableWindow(FALSE);
- GetDlgItem(IDC_CHECK4)->EnableWindow(FALSE);
- GetDlgItem(IDC_CHECK5)->EnableWindow(FALSE);
-
- GetDlgItem(IDC_RADIO1)->EnableWindow(FALSE);
- GetDlgItem(IDC_RADIO2)->EnableWindow(FALSE);
- GetDlgItem(IDC_RADIO3)->EnableWindow(FALSE);
-
- GetDlgItem(IDC_BUTTON5)->ShowWindow(SW_SHOW);
- GetDlgItem(IDC_BUTTON5)->SendMessage(BCM_SETSHIELD, 0, 1);
-
- m_bInsufficientPrivileges = true;
- }
- else
- GetDlgItem(IDC_BUTTON5)->ShowWindow(SW_HIDE);
-
-
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = sizeof(buff);
-
- int fContextDir = 0;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"), KEY_READ))
- {
- CString strCommand = GetOpenCommand();
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len))
- fContextDir = (strCommand.CompareNoCase(CString(buff)) == 0);
- }
- m_fContextDir.SetCheck(fContextDir);
- m_fAssociatedWithIcons.SetCheck(s.fAssociatedWithIcons);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ m_list.SetColumnWidth(COL_ENGINE, LVSCW_AUTOSIZE_USEHEADER);
+
+ m_list.SetSelectionMark(0);
+ m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
+ m_exts = mf[(int)m_list.GetItemData(0)].GetExtsWithPeriod();
+
+ AppSettings& s = AfxGetAppSettings();
+ bool fRtspFileExtFirst;
+ engine_t e = s.Formats.GetRtspHandler(fRtspFileExtFirst);
+ m_iRtspHandler = (e==RealMedia?0:e==QuickTime?1:2);
+ m_fRtspFileExtFirst = fRtspFileExtFirst;
+
+ UpdateData(FALSE);
+
+ f_setContextFiles = 0;
+
+ for(int i = 0; i < m_list.GetItemCount(); i++)
+ {
+ SetListItemState(i);
+ }
+ m_fContextFiles.SetCheck(f_setContextFiles);
+
+ if(AfxGetAppSettings().fXpOrBetter)
+ {
+ m_apvideo.SetCheck(IsAutoPlayRegistered(AP_VIDEO));
+ m_apmusic.SetCheck(IsAutoPlayRegistered(AP_MUSIC));
+ m_apaudiocd.SetCheck(IsAutoPlayRegistered(AP_AUDIOCD));
+ m_apdvd.SetCheck(IsAutoPlayRegistered(AP_DVDMOVIE));
+ }
+ else
+ {
+ m_autoplay.ShowWindow(SW_HIDE);
+ m_apvideo.ShowWindow(SW_HIDE);
+ m_apmusic.ShowWindow(SW_HIDE);
+ m_apaudiocd.ShowWindow(SW_HIDE);
+ m_apdvd.ShowWindow(SW_HIDE);
+ }
+
+ CreateToolTip();
+
+
+ if (AfxGetMyApp()->IsVistaOrAbove() && !IsUserAnAdmin())
+ {
+ GetDlgItem(IDC_BUTTON1)->ShowWindow (SW_HIDE);
+ GetDlgItem(IDC_BUTTON3)->ShowWindow (SW_HIDE);
+ GetDlgItem(IDC_BUTTON4)->ShowWindow (SW_HIDE);
+ GetDlgItem(IDC_CHECK1)->EnableWindow (FALSE);
+ GetDlgItem(IDC_CHECK2)->EnableWindow (FALSE);
+ GetDlgItem(IDC_CHECK3)->EnableWindow (FALSE);
+ GetDlgItem(IDC_CHECK4)->EnableWindow (FALSE);
+ GetDlgItem(IDC_CHECK5)->EnableWindow (FALSE);
+
+ GetDlgItem(IDC_RADIO1)->EnableWindow (FALSE);
+ GetDlgItem(IDC_RADIO2)->EnableWindow (FALSE);
+ GetDlgItem(IDC_RADIO3)->EnableWindow (FALSE);
+
+ GetDlgItem(IDC_BUTTON5)->ShowWindow (SW_SHOW);
+ GetDlgItem(IDC_BUTTON5)->SendMessage (BCM_SETSHIELD, 0, 1);
+
+ m_bInsufficientPrivileges = true;
+ }
+ else
+ GetDlgItem(IDC_BUTTON5)->ShowWindow (SW_HIDE);
+
+
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = sizeof(buff);
+
+ int fContextDir = 0;
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"), KEY_READ))
+ {
+ CString strCommand = GetOpenCommand();
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len))
+ fContextDir = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
+ m_fContextDir.SetCheck(fContextDir);
+ m_fAssociatedWithIcons.SetCheck(s.fAssociatedWithIcons);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageFormats::SetFileAssociation(CString strExt, CString strProgID, bool fRegister)
{
- CString extoldreg, extOldIcon;
- CRegKey key;
- HRESULT hr = S_OK;
- TCHAR buff[256];
- ULONG len = sizeof(buff);
- memset(buff, 0, len);
-
- if(m_pAAR == NULL)
- {
- // Default manager (requiered at least Vista)
- HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
- NULL,
- CLSCTX_INPROC,
- __uuidof(IApplicationAssociationRegistration),
- (void**)&m_pAAR);
- }
-
- if(m_pAAR)
- {
- // The Vista way
- CString strNewApp;
- if(fRegister)
- {
- // Create non existing file type
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) return(false);
-
- WCHAR* pszCurrentAssociation;
- // Save current application associated
- if(SUCCEEDED(m_pAAR->QueryCurrentDefault(strExt, AT_FILEEXTENSION, AL_EFFECTIVE, &pszCurrentAssociation)))
- {
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
- return(false);
-
- key.SetStringValue(g_strOldAssoc, pszCurrentAssociation);
-
- // Get current icon for file type
- /*
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(pszCurrentAssociation) + _T("\\DefaultIcon")))
- {
- len = sizeof(buff);
- memset(buff, 0, len);
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
- {
- if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon")))
- key.SetStringValue (NULL, buff);
- }
- }
- */
- CoTaskMemFree(pszCurrentAssociation);
- }
- strNewApp = g_strRegisteredAppName;
- }
- else
- {
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID))
- return(false);
-
- if(ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len))
- strNewApp = buff;
-
- // TODO : retrieve registered app name from previous association (or find Bill function for that...)
- }
-
- hr = m_pAAR->SetAppAsDefault(strNewApp, strExt, AT_FILEEXTENSION);
- }
- else
- {
- // The 2000/XP way
- if(fRegister)
- {
- // Set new association
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt))
- return(false);
-
- len = sizeof(buff);
- memset(buff, 0, len);
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
- extoldreg = buff;
- if(ERROR_SUCCESS != key.SetStringValue(NULL, strProgID)) return(false);
-
- // Get current icon for file type
- /*
- if (!extoldreg.IsEmpty())
- {
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, extoldreg + _T("\\DefaultIcon")))
- {
- len = sizeof(buff);
- memset(buff, 0, len);
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
- extOldIcon = buff;
- }
- }
- */
-
- // Save old association
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
- return(false);
- key.SetStringValue(g_strOldAssoc, extoldreg);
-
- /*
- if (!extOldIcon.IsEmpty() && (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))))
- key.SetStringValue (NULL, extOldIcon);
- */
- }
- else
- {
- // Get previous association
- len = sizeof(buff);
- memset(buff, 0, len);
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
- return(false);
- if(ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len) && !CString(buff).Trim().IsEmpty())
- extoldreg = buff;
-
- // Set previous association
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt))
- return(false);
- key.SetStringValue(NULL, extoldreg);
- }
-
- }
-
- return SUCCEEDED(hr);
+ CString extoldreg, extOldIcon;
+ CRegKey key;
+ HRESULT hr = S_OK;
+ TCHAR buff[256];
+ ULONG len = sizeof(buff);
+ memset(buff, 0, len);
+
+ if (m_pAAR == NULL)
+ {
+ // Default manager (requiered at least Vista)
+ HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
+ NULL,
+ CLSCTX_INPROC,
+ __uuidof(IApplicationAssociationRegistration),
+ (void**)&m_pAAR);
+ }
+
+ if (m_pAAR)
+ {
+ // The Vista way
+ CString strNewApp;
+ if (fRegister)
+ {
+ // Create non existing file type
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) return(false);
+
+ WCHAR* pszCurrentAssociation;
+ // Save current application associated
+ if (SUCCEEDED (m_pAAR->QueryCurrentDefault (strExt, AT_FILEEXTENSION, AL_EFFECTIVE, &pszCurrentAssociation)))
+ {
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
+ return(false);
+
+ key.SetStringValue(g_strOldAssoc, pszCurrentAssociation);
+
+ // Get current icon for file type
+ /*
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(pszCurrentAssociation) + _T("\\DefaultIcon")))
+ {
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ {
+ if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon")))
+ key.SetStringValue (NULL, buff);
+ }
+ }
+ */
+ CoTaskMemFree (pszCurrentAssociation);
+ }
+ strNewApp = g_strRegisteredAppName;
+ }
+ else
+ {
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID))
+ return(false);
+
+ if(ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len))
+ strNewApp = buff;
+
+ // TODO : retrieve registered app name from previous association (or find Bill function for that...)
+ }
+
+ hr = m_pAAR->SetAppAsDefault(strNewApp, strExt, AT_FILEEXTENSION);
+ }
+ else
+ {
+ // The 2000/XP way
+ if (fRegister)
+ {
+ // Set new association
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt))
+ return(false);
+
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ extoldreg = buff;
+ if(ERROR_SUCCESS != key.SetStringValue(NULL, strProgID)) return(false);
+
+ // Get current icon for file type
+ /*
+ if (!extoldreg.IsEmpty())
+ {
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, extoldreg + _T("\\DefaultIcon")))
+ {
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ extOldIcon = buff;
+ }
+ }
+ */
+
+ // Save old association
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
+ return(false);
+ key.SetStringValue(g_strOldAssoc, extoldreg);
+
+ /*
+ if (!extOldIcon.IsEmpty() && (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))))
+ key.SetStringValue (NULL, extOldIcon);
+ */
+ }
+ else
+ {
+ // Get previous association
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
+ return(false);
+ if(ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len) && !CString(buff).Trim().IsEmpty())
+ extoldreg = buff;
+
+ // Set previous association
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt))
+ return(false);
+ key.SetStringValue(NULL, extoldreg);
+ }
+
+ }
+
+ return SUCCEEDED (hr);
}
BOOL CPPageFormats::OnApply()
{
- UpdateData();
-
- {
- int i = m_list.GetSelectionMark();
- if(i >= 0) i = (int)m_list.GetItemData(i);
- if(i >= 0)
- {
- CMediaFormats& mf = AfxGetAppSettings().Formats;
- mf[i].SetExts(m_exts);
- m_exts = mf[i].GetExtsWithPeriod();
- UpdateData(FALSE);
- }
- }
-
- CMediaFormats& mf = AfxGetAppSettings().Formats;
-
- CString AppIcon = _T("");
- TCHAR buff[_MAX_PATH];
-
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH))
- {
- AppIcon = buff;
- AppIcon = "\"" + AppIcon + "\"";
- AppIcon += _T(",0");
- }
-
- if(m_pAAR)
- {
- // Register MPC for the windows "Default application" manager
- CRegKey key;
-
- if(ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\RegisteredApplications")))
- {
- key.SetStringValue(_T("Media Player Classic"), g_strRegisteredKey);
-
- if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey))
- return(false);
-
- // ==>> TODO icon !!!
- key.SetStringValue(_T("ApplicationDescription"), ResStr(IDS_APP_DESCRIPTION), REG_EXPAND_SZ);
- key.SetStringValue(_T("ApplicationIcon"), AppIcon, REG_EXPAND_SZ);
- key.SetStringValue(_T("ApplicationName"), ResStr(IDR_MAINFRAME), REG_EXPAND_SZ);
- }
- }
-
- f_setContextFiles = m_fContextFiles.GetCheck();
- f_setAssociatedWithIcon = m_fAssociatedWithIcons.GetCheck();
-
- for(int i = 0; i < m_list.GetItemCount(); i++)
- {
- int iChecked = GetChecked(i);
- if(iChecked == 2) continue;
-
- CAtlList<CString> exts;
- Explode(mf[(int)m_list.GetItemData(i)].GetExtsWithPeriod(), exts, ' ');
-
- POSITION pos = exts.GetHeadPosition();
- while(pos)
- RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetLabel(), !!iChecked);
- }
-
- CRegKey key;
- if(m_fContextDir.GetCheck())
- {
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue")))
- {
- key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST));
- }
-
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue\\command")))
- {
- key.SetStringValue(NULL, GetEnqueueCommand());
- }
-
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play")))
- {
- key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC));
- }
-
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command")))
- {
- key.SetStringValue(NULL, GetOpenCommand());
- }
- }
- else
- {
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.enqueue"));
- key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.play"));
- }
-
- {
- SetListItemState(m_list.GetSelectionMark());
- }
-
- AddAutoPlayToRegistry(AP_VIDEO, !!m_apvideo.GetCheck());
- AddAutoPlayToRegistry(AP_MUSIC, !!m_apmusic.GetCheck());
- AddAutoPlayToRegistry(AP_AUDIOCD, !!m_apaudiocd.GetCheck());
- AddAutoPlayToRegistry(AP_DVDMOVIE, !!m_apdvd.GetCheck());
-
- AppSettings& s = AfxGetAppSettings();
- s.Formats.SetRtspHandler(m_iRtspHandler == 0 ? RealMedia : m_iRtspHandler == 1 ? QuickTime : DirectShow, !!m_fRtspFileExtFirst);
- s.fAssociatedWithIcons = !!m_fAssociatedWithIcons.GetCheck();
-
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-
- return __super::OnApply();
+ UpdateData();
+
+ {
+ int i = m_list.GetSelectionMark();
+ if(i >= 0) i = (int)m_list.GetItemData(i);
+ if(i >= 0)
+ {
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+ mf[i].SetExts(m_exts);
+ m_exts = mf[i].GetExtsWithPeriod();
+ UpdateData(FALSE);
+ }
+ }
+
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+
+ CString AppIcon = _T("");
+ TCHAR buff[_MAX_PATH];
+
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH))
+ {
+ AppIcon = buff;
+ AppIcon = "\""+AppIcon+"\"";
+ AppIcon += _T(",0");
+ }
+
+ if (m_pAAR)
+ {
+ // Register MPC for the windows "Default application" manager
+ CRegKey key;
+
+ if(ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\RegisteredApplications")))
+ {
+ key.SetStringValue(_T("Media Player Classic"), g_strRegisteredKey);
+
+ if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey))
+ return(false);
+
+ // ==>> TODO icon !!!
+ key.SetStringValue(_T("ApplicationDescription"), ResStr(IDS_APP_DESCRIPTION), REG_EXPAND_SZ);
+ key.SetStringValue(_T("ApplicationIcon"), AppIcon, REG_EXPAND_SZ);
+ key.SetStringValue(_T("ApplicationName"), ResStr(IDR_MAINFRAME), REG_EXPAND_SZ);
+ }
+ }
+
+ f_setContextFiles = m_fContextFiles.GetCheck();
+ f_setAssociatedWithIcon = m_fAssociatedWithIcons.GetCheck();
+
+ for(int i = 0; i < m_list.GetItemCount(); i++)
+ {
+ int iChecked = GetChecked(i);
+ if(iChecked == 2) continue;
+
+ CAtlList<CString> exts;
+ Explode(mf[(int)m_list.GetItemData(i)].GetExtsWithPeriod(), exts, ' ');
+
+ POSITION pos = exts.GetHeadPosition();
+ while(pos)
+ RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetLabel(), !!iChecked);
+ }
+
+ CRegKey key;
+ if(m_fContextDir.GetCheck())
+ {
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue"))){
+ key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST));
+ }
+
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue\\command"))){
+ key.SetStringValue(NULL, GetEnqueueCommand());
+ }
+
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play"))){
+ key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC));
+ }
+
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"))){
+ key.SetStringValue(NULL, GetOpenCommand());
+ }
+ }
+ else
+ {
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.enqueue"));
+ key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.play"));
+ }
+
+ {
+ SetListItemState(m_list.GetSelectionMark());
+ }
+
+ AddAutoPlayToRegistry(AP_VIDEO, !!m_apvideo.GetCheck());
+ AddAutoPlayToRegistry(AP_MUSIC, !!m_apmusic.GetCheck());
+ AddAutoPlayToRegistry(AP_AUDIOCD, !!m_apaudiocd.GetCheck());
+ AddAutoPlayToRegistry(AP_DVDMOVIE, !!m_apdvd.GetCheck());
+
+ AppSettings& s = AfxGetAppSettings();
+ s.Formats.SetRtspHandler(m_iRtspHandler==0?RealMedia:m_iRtspHandler==1?QuickTime:DirectShow, !!m_fRtspFileExtFirst);
+ s.fAssociatedWithIcons = !!m_fAssociatedWithIcons.GetCheck();
+
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+
+ return __super::OnApply();
}
void CPPageFormats::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
-
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem == COL_CATEGORY)
- {
- CRect r;
- m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
- if(r.PtInRect(lpnmlv->ptAction))
- {
- if(m_bInsufficientPrivileges)
- MessageBox(ResStr(IDS_CANNOT_CHANGE_FORMAT));
- else
- {
- SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem) & 1) == 0 ? 1 : 0);
- SetModified();
- }
- }
- }
-
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+
+ if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem == COL_CATEGORY)
+ {
+ CRect r;
+ m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
+ if(r.PtInRect(lpnmlv->ptAction))
+ {
+ if (m_bInsufficientPrivileges)
+ MessageBox (ResStr (IDS_CANNOT_CHANGE_FORMAT));
+ else
+ {
+ SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem)&1) == 0 ? 1 : 0);
+ SetModified();
+ }
+ }
+ }
+
+ *pResult = 0;
}
void CPPageFormats::OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- if(pNMLV->iItem >= 0 && pNMLV->iSubItem == COL_CATEGORY
- && (pNMLV->uChanged & LVIF_STATE) && (pNMLV->uNewState & LVIS_SELECTED))
- {
- m_exts = AfxGetAppSettings().Formats[(int)m_list.GetItemData(pNMLV->iItem)].GetExtsWithPeriod();
- UpdateData(FALSE);
- }
+ if(pNMLV->iItem >= 0 && pNMLV->iSubItem == COL_CATEGORY
+ && (pNMLV->uChanged&LVIF_STATE) && (pNMLV->uNewState&LVIS_SELECTED))
+ {
+ m_exts = AfxGetAppSettings().Formats[(int)m_list.GetItemData(pNMLV->iItem)].GetExtsWithPeriod();
+ UpdateData(FALSE);
+ }
- *pResult = 0;
+ *pResult = 0;
}
-void CPPageFormats::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPPageFormats::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if(pItem->iItem < 0)
- return;
+ if(pItem->iItem < 0)
+ return;
- if(pItem->iSubItem == COL_ENGINE)
- {
- *pResult = TRUE;
- }
+ if(pItem->iSubItem == COL_ENGINE)
+ {
+ *pResult = TRUE;
+ }
}
-void CPPageFormats::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPPageFormats::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if(pItem->iItem < 0)
- return;
+ if(pItem->iItem < 0)
+ return;
- CMediaFormatCategory& mfc = AfxGetAppSettings().Formats[m_list.GetItemData(pItem->iItem)];
+ CMediaFormatCategory& mfc = AfxGetAppSettings().Formats[m_list.GetItemData(pItem->iItem)];
- CAtlList<CString> sl;
- int nSel = -1;
+ CAtlList<CString> sl;
+ int nSel = -1;
- if(pItem->iSubItem == COL_ENGINE)
- {
- sl.AddTail(_T("DirectShow"));
- sl.AddTail(_T("RealMedia"));
- sl.AddTail(_T("QuickTime"));
- sl.AddTail(_T("ShockWave"));
+ if(pItem->iSubItem == COL_ENGINE)
+ {
+ sl.AddTail(_T("DirectShow"));
+ sl.AddTail(_T("RealMedia"));
+ sl.AddTail(_T("QuickTime"));
+ sl.AddTail(_T("ShockWave"));
- nSel = (int)mfc.GetEngineType();
+ nSel = (int)mfc.GetEngineType();
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
-void CPPageFormats::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPPageFormats::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if(!m_list.m_fInPlaceDirty)
- return;
+ if(!m_list.m_fInPlaceDirty)
+ return;
- if(pItem->iItem < 0)
- return;
+ if(pItem->iItem < 0)
+ return;
- CMediaFormatCategory& mfc = AfxGetAppSettings().Formats[m_list.GetItemData(pItem->iItem)];
+ CMediaFormatCategory& mfc = AfxGetAppSettings().Formats[m_list.GetItemData(pItem->iItem)];
- if(pItem->iSubItem == COL_ENGINE && pItem->lParam >= 0)
- {
- mfc.SetEngineType((engine_t)pItem->lParam);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
- *pResult = TRUE;
- }
+ if(pItem->iSubItem == COL_ENGINE && pItem->lParam >= 0)
+ {
+ mfc.SetEngineType((engine_t)pItem->lParam);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
+ *pResult = TRUE;
+ }
- if(*pResult)
- SetModified();
+ if(*pResult)
+ SetModified();
}
void CPPageFormats::OnBnClickedButton1()
{
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
- SetChecked(i, 1);
- }
-
- m_apvideo.SetCheck(1);
- m_apmusic.SetCheck(1);
- m_apaudiocd.SetCheck(1);
- m_apdvd.SetCheck(1);
-
- SetModified();
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
+ {
+ SetChecked(i, 1);
+ }
+
+ m_apvideo.SetCheck(1);
+ m_apmusic.SetCheck(1);
+ m_apaudiocd.SetCheck(1);
+ m_apdvd.SetCheck(1);
+
+ SetModified();
}
void CPPageFormats::OnBnClickedButton14()
{
- CMediaFormats& mf = AfxGetAppSettings().Formats;
-
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
- if(!mf[m_list.GetItemData(i)].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE)))
- {
- SetChecked(i, 0);
- continue;
- }
- SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly() ? 0 : 1);
- }
-
- m_apvideo.SetCheck(1);
- m_apmusic.SetCheck(0);
- m_apaudiocd.SetCheck(0);
- m_apdvd.SetCheck(1);
-
- SetModified();
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
+ {
+ if(!mf[m_list.GetItemData(i)].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE)))
+ {
+ SetChecked(i, 0);
+ continue;
+ }
+ SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly()?0:1);
+ }
+
+ m_apvideo.SetCheck(1);
+ m_apmusic.SetCheck(0);
+ m_apaudiocd.SetCheck(0);
+ m_apdvd.SetCheck(1);
+
+ SetModified();
}
void CPPageFormats::OnBnClickedButton13()
{
- CMediaFormats& mf = AfxGetAppSettings().Formats;
-
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
- SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly() ? 1 : 0);
- }
-
- m_apvideo.SetCheck(0);
- m_apmusic.SetCheck(1);
- m_apaudiocd.SetCheck(1);
- m_apdvd.SetCheck(0);
-
- SetModified();
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
+ {
+ SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly()?1:0);
+ }
+
+ m_apvideo.SetCheck(0);
+ m_apmusic.SetCheck(1);
+ m_apaudiocd.SetCheck(1);
+ m_apdvd.SetCheck(0);
+
+ SetModified();
}
void CPPageFormats::OnBnVistaModify()
{
- CString strCmd;
- TCHAR strApp [_MAX_PATH];
+ CString strCmd;
+ TCHAR strApp [_MAX_PATH];
- strCmd.Format(_T("/adminoption %d"), IDD);
- GetModuleFileNameEx(GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, MAX_PATH);
+ strCmd.Format (_T("/adminoption %d"), IDD);
+ GetModuleFileNameEx (GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, MAX_PATH);
- AfxGetMyApp()->RunAsAdministrator(strApp, strCmd, true);
+ AfxGetMyApp()->RunAsAdministrator (strApp, strCmd, true);
- CMediaFormats& mf = AfxGetAppSettings().Formats;
- for(int i = 0; i < m_list.GetItemCount(); i++)
- {
- SetListItemState(i);
- }
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+ for(int i = 0; i < m_list.GetItemCount(); i++)
+ {
+ SetListItemState(i);
+ }
}
void CPPageFormats::OnBnClickedButton12()
{
- int i = m_list.GetSelectionMark();
- if(i < 0) return;
- i = (int)m_list.GetItemData(i);
- CMediaFormats& mf = AfxGetAppSettings().Formats;
- mf[i].RestoreDefaultExts();
- m_exts = mf[i].GetExtsWithPeriod();
- SetListItemState(m_list.GetSelectionMark());
- UpdateData(FALSE);
-
- SetModified();
+ int i = m_list.GetSelectionMark();
+ if(i < 0) return;
+ i = (int)m_list.GetItemData(i);
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+ mf[i].RestoreDefaultExts();
+ m_exts = mf[i].GetExtsWithPeriod();
+ SetListItemState(m_list.GetSelectionMark());
+ UpdateData(FALSE);
+
+ SetModified();
}
void CPPageFormats::OnBnClickedButton11()
{
- UpdateData();
- int i = m_list.GetSelectionMark();
- if(i < 0) return;
- i = (int)m_list.GetItemData(i);
- CMediaFormats& mf = AfxGetAppSettings().Formats;
- mf[i].SetExts(m_exts);
- m_exts = mf[i].GetExtsWithPeriod();
- SetListItemState(m_list.GetSelectionMark());
- UpdateData(FALSE);
-
- SetModified();
+ UpdateData();
+ int i = m_list.GetSelectionMark();
+ if(i < 0) return;
+ i = (int)m_list.GetItemData(i);
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+ mf[i].SetExts(m_exts);
+ m_exts = mf[i].GetExtsWithPeriod();
+ SetListItemState(m_list.GetSelectionMark());
+ UpdateData(FALSE);
+
+ SetModified();
}
void CPPageFormats::OnUpdateButtonDefault(CCmdUI* pCmdUI)
{
- int i = m_list.GetSelectionMark();
- if(i < 0)
- {
- pCmdUI->Enable(FALSE);
- return;
- }
- i = (int)m_list.GetItemData(i);
-
- CString orgexts, newexts;
- GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
- newexts.Trim();
- orgexts = AfxGetAppSettings().Formats[i].GetBackupExtsWithPeriod();
-
- pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
+ int i = m_list.GetSelectionMark();
+ if(i < 0) {pCmdUI->Enable(FALSE); return;}
+ i = (int)m_list.GetItemData(i);
+
+ CString orgexts, newexts;
+ GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
+ newexts.Trim();
+ orgexts = AfxGetAppSettings().Formats[i].GetBackupExtsWithPeriod();
+
+ pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
}
void CPPageFormats::OnUpdateButtonSet(CCmdUI* pCmdUI)
{
- int i = m_list.GetSelectionMark();
- if(i < 0)
- {
- pCmdUI->Enable(FALSE);
- return;
- }
- i = (int)m_list.GetItemData(i);
-
- CString orgexts, newexts;
- GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
- newexts.Trim();
- orgexts = AfxGetAppSettings().Formats[i].GetExtsWithPeriod();
-
- pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
+ int i = m_list.GetSelectionMark();
+ if(i < 0) {pCmdUI->Enable(FALSE); return;}
+ i = (int)m_list.GetItemData(i);
+
+ CString orgexts, newexts;
+ GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
+ newexts.Trim();
+ orgexts = AfxGetAppSettings().Formats[i].GetExtsWithPeriod();
+
+ pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
}
diff --git a/src/apps/mplayerc/PPageFormats.h b/src/apps/mplayerc/PPageFormats.h
index f8e2cc1d3..2e51b1302 100644
--- a/src/apps/mplayerc/PPageFormats.h
+++ b/src/apps/mplayerc/PPageFormats.h
@@ -32,68 +32,68 @@
class CPPageFormats : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageFormats)
+ DECLARE_DYNAMIC(CPPageFormats)
private:
- CImageList m_onoff;
- bool m_bInsufficientPrivileges;
+ CImageList m_onoff;
+ bool m_bInsufficientPrivileges;
- int GetChecked(int iItem);
- void SetChecked(int iItem, int fChecked);
+ int GetChecked(int iItem);
+ void SetChecked(int iItem, int fChecked);
- typedef enum {AP_VIDEO = 0, AP_MUSIC, AP_AUDIOCD, AP_DVDMOVIE} autoplay_t;
- void AddAutoPlayToRegistry(autoplay_t ap, bool fRegister);
- bool IsAutoPlayRegistered(autoplay_t ap);
+ typedef enum {AP_VIDEO=0,AP_MUSIC,AP_AUDIOCD,AP_DVDMOVIE} autoplay_t;
+ void AddAutoPlayToRegistry(autoplay_t ap, bool fRegister);
+ bool IsAutoPlayRegistered(autoplay_t ap);
- void SetListItemState(int nItem);
- static CComPtr<IApplicationAssociationRegistration> m_pAAR;
- static BOOL SetFileAssociation(CString strExt, CString extfile, bool fRegister);
- static CString GetOpenCommand();
- static CString GetEnqueueCommand();
+ void SetListItemState(int nItem);
+ static CComPtr<IApplicationAssociationRegistration> m_pAAR;
+ static BOOL SetFileAssociation(CString strExt, CString extfile, bool fRegister);
+ static CString GetOpenCommand();
+ static CString GetEnqueueCommand();
public:
- CPPageFormats();
- virtual ~CPPageFormats();
-
- static bool IsRegistered(CString ext);
- static bool RegisterExt(CString ext, CString strLabel, bool fRegister);
-
- enum {COL_CATEGORY, COL_ENGINE};
- CPlayerListCtrl m_list;
- CString m_exts;
- CStatic m_autoplay;
- CButton m_apvideo;
- CButton m_apmusic;
- CButton m_apaudiocd;
- CButton m_apdvd;
- int m_iRtspHandler;
- BOOL m_fRtspFileExtFirst;
+ CPPageFormats();
+ virtual ~CPPageFormats();
+
+ static bool IsRegistered(CString ext);
+ static bool RegisterExt(CString ext, CString strLabel, bool fRegister);
+
+ enum {COL_CATEGORY, COL_ENGINE};
+ CPlayerListCtrl m_list;
+ CString m_exts;
+ CStatic m_autoplay;
+ CButton m_apvideo;
+ CButton m_apmusic;
+ CButton m_apaudiocd;
+ CButton m_apdvd;
+ int m_iRtspHandler;
+ BOOL m_fRtspFileExtFirst;
// Dialog Data
- enum { IDD = IDD_PPAGEFORMATS };
+ enum { IDD = IDD_PPAGEFORMATS };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton14();
- afx_msg void OnBnClickedButton13();
- afx_msg void OnBnClickedButton12();
- afx_msg void OnBnClickedButton11();
- afx_msg void OnBnVistaModify();
- afx_msg void OnUpdateButtonDefault(CCmdUI* pCmdUI);
- afx_msg void OnUpdateButtonSet(CCmdUI* pCmdUI);
- CButton m_fContextDir;
- CButton m_fContextFiles;
- CButton m_fAssociatedWithIcons;
+ afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton14();
+ afx_msg void OnBnClickedButton13();
+ afx_msg void OnBnClickedButton12();
+ afx_msg void OnBnClickedButton11();
+ afx_msg void OnBnVistaModify();
+ afx_msg void OnUpdateButtonDefault(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateButtonSet(CCmdUI* pCmdUI);
+ CButton m_fContextDir;
+ CButton m_fContextFiles;
+ CButton m_fAssociatedWithIcons;
};
diff --git a/src/apps/mplayerc/PPageFullscreen.cpp b/src/apps/mplayerc/PPageFullscreen.cpp
index e8fe5b92d..7e8c60238 100644
--- a/src/apps/mplayerc/PPageFullscreen.cpp
+++ b/src/apps/mplayerc/PPageFullscreen.cpp
@@ -30,293 +30,293 @@
#include "MultiMonitor.h"
// CPPagePlayer dialog
-
+
IMPLEMENT_DYNAMIC(CPPageFullscreen, CPPageBase)
CPPageFullscreen::CPPageFullscreen()
- : CPPageBase(CPPageFullscreen::IDD, CPPageFullscreen::IDD)
- , m_launchfullscreen(FALSE)
- , m_fSetFullscreenRes(FALSE)
- , m_fSetDefault(FALSE)
- , m_iShowBarsWhenFullScreen(FALSE)
- , m_nShowBarsWhenFullScreenTimeOut(0)
- , m_fExitFullScreenAtTheEnd(FALSE)
- , m_fRestoreResAfterExit(TRUE)
+ : CPPageBase(CPPageFullscreen::IDD, CPPageFullscreen::IDD)
+ , m_launchfullscreen(FALSE)
+ , m_fSetFullscreenRes(FALSE)
+ , m_fSetDefault(FALSE)
+ , m_iShowBarsWhenFullScreen(FALSE)
+ , m_nShowBarsWhenFullScreenTimeOut(0)
+ , m_fExitFullScreenAtTheEnd(FALSE)
+ , m_fRestoreResAfterExit(TRUE)
{
}
-
+
CPPageFullscreen::~CPPageFullscreen()
{
}
void CPPageFullscreen::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK1, m_launchfullscreen);
- DDX_Check(pDX, IDC_CHECK2, m_fSetFullscreenRes);
- DDX_Check(pDX, IDC_CHECK3, m_fSetDefault);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iMonitorType);
- DDX_Control(pDX, IDC_COMBO1, m_iMonitorTypeCtrl);
- DDX_Control(pDX, IDC_COMBO2, m_dispmode24combo);
- DDX_Control(pDX, IDC_COMBO3, m_dispmode25combo);
- DDX_Control(pDX, IDC_COMBO4, m_dispmode30combo);
- DDX_Control(pDX, IDC_COMBO5, m_dispmodeOthercombo);
- DDX_Control(pDX, IDC_COMBO6, m_dispmode23d976combo);
- DDX_Control(pDX, IDC_COMBO7, m_dispmode29d97combo);
- DDX_Check(pDX, IDC_CHECK4, m_iShowBarsWhenFullScreen);
- DDX_Text(pDX, IDC_EDIT1, m_nShowBarsWhenFullScreenTimeOut);
- DDX_Check(pDX, IDC_CHECK5, m_fExitFullScreenAtTheEnd);
- DDX_Control(pDX, IDC_SPIN1, m_nTimeOutCtrl);
- DDX_Check(pDX, IDC_RESTORERESCHECK, m_fRestoreResAfterExit);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK1, m_launchfullscreen);
+ DDX_Check(pDX, IDC_CHECK2, m_fSetFullscreenRes);
+ DDX_Check(pDX, IDC_CHECK3, m_fSetDefault);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iMonitorType);
+ DDX_Control(pDX, IDC_COMBO1, m_iMonitorTypeCtrl);
+ DDX_Control(pDX, IDC_COMBO2, m_dispmode24combo);
+ DDX_Control(pDX, IDC_COMBO3, m_dispmode25combo);
+ DDX_Control(pDX, IDC_COMBO4, m_dispmode30combo);
+ DDX_Control(pDX, IDC_COMBO5, m_dispmodeOthercombo);
+ DDX_Control(pDX, IDC_COMBO6, m_dispmode23d976combo);
+ DDX_Control(pDX, IDC_COMBO7, m_dispmode29d97combo);
+ DDX_Check(pDX, IDC_CHECK4, m_iShowBarsWhenFullScreen);
+ DDX_Text(pDX, IDC_EDIT1, m_nShowBarsWhenFullScreenTimeOut);
+ DDX_Check(pDX, IDC_CHECK5, m_fExitFullScreenAtTheEnd);
+ DDX_Control(pDX, IDC_SPIN1, m_nTimeOutCtrl);
+ DDX_Check(pDX, IDC_RESTORERESCHECK, m_fRestoreResAfterExit);
}
BEGIN_MESSAGE_MAP(CPPageFullscreen, CPPageBase)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnUpdateFullScrCombo)
- ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateDispMode24Combo)
- ON_UPDATE_COMMAND_UI(IDC_COMBO3, OnUpdateDispMode25Combo)
- ON_UPDATE_COMMAND_UI(IDC_COMBO4, OnUpdateDispMode30Combo)
- ON_UPDATE_COMMAND_UI(IDC_COMBO5, OnUpdateDispModeOtherCombo)
- ON_UPDATE_COMMAND_UI(IDC_COMBO6, OnUpdateDispMode23d976Combo)
- ON_UPDATE_COMMAND_UI(IDC_COMBO7, OnUpdateDispMode29d97Combo)
- ON_UPDATE_COMMAND_UI(IDC_CHECK3 , OnUpdateApplyDefault)
- ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateTimeout)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateTimeout)
- ON_UPDATE_COMMAND_UI(IDC_RESTORERESCHECK, OnUpdateRestoreRes)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnUpdateFullScrCombo)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateDispMode24Combo)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO3, OnUpdateDispMode25Combo)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO4, OnUpdateDispMode30Combo)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO5, OnUpdateDispModeOtherCombo)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO6, OnUpdateDispMode23d976Combo)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO7, OnUpdateDispMode29d97Combo)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK3 ,OnUpdateApplyDefault)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateTimeout)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateTimeout)
+ ON_UPDATE_COMMAND_UI(IDC_RESTORERESCHECK, OnUpdateRestoreRes)
END_MESSAGE_MAP()
-
+
// CPPagePlayer message handlers
BOOL CPPageFullscreen::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_launchfullscreen = s.launchfullscreen;
- m_AutoChangeFullscrRes = s.AutoChangeFullscrRes;
- m_fSetDefault = s.AutoChangeFullscrRes.bApplyDefault;
- m_f_hmonitor = s.f_hmonitor;
- m_iShowBarsWhenFullScreen = s.fShowBarsWhenFullScreen;
- m_nShowBarsWhenFullScreenTimeOut = s.nShowBarsWhenFullScreenTimeOut;
- m_nTimeOutCtrl.SetRange(-1, 10);
- m_fExitFullScreenAtTheEnd = s.fExitFullScreenAtTheEnd;
- m_fRestoreResAfterExit = s.fRestoreResAfterExit;
-
- CString str;
- m_iMonitorType = 0;
- CMonitor monitor;
- CMonitors monitors;
-
- m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
- m_MonitorDisplayNames.Add(_T("Current"));
- if(m_f_hmonitor == _T("Current"))
- {
- m_iMonitorType = m_iMonitorTypeCtrl.GetCount() - 1;
- }
-
- for(int i = 0; i < monitors.GetCount(); i++)
- {
- monitor = monitors.GetMonitor(i);
- monitor.GetName(str);
-
- if(monitor.IsMonitor())
- {
- DISPLAY_DEVICE displayDevice;
- ZeroMemory(&displayDevice, sizeof(displayDevice));
- displayDevice.cb = sizeof(displayDevice);
- VERIFY(EnumDisplayDevices(str, 0, &displayDevice, 0));
-
- m_iMonitorTypeCtrl.AddString(str + _T(" - ") + displayDevice.DeviceString);
- m_MonitorDisplayNames.Add(str);
-
- if(m_f_hmonitor == str && m_iMonitorType == 0)
- {
- m_iMonitorType = m_iMonitorTypeCtrl.GetCount() - 1;
- }
- }
- }
-
- if(m_iMonitorTypeCtrl.GetCount() > 2)
- {
- GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
- }
- else
- {
- m_iMonitorType = 0;
- GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
- }
- ModesUpdate();
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_launchfullscreen = s.launchfullscreen;
+ m_AutoChangeFullscrRes = s.AutoChangeFullscrRes;
+ m_fSetDefault = s.AutoChangeFullscrRes.bApplyDefault;
+ m_f_hmonitor = s.f_hmonitor;
+ m_iShowBarsWhenFullScreen = s.fShowBarsWhenFullScreen;
+ m_nShowBarsWhenFullScreenTimeOut = s.nShowBarsWhenFullScreenTimeOut;
+ m_nTimeOutCtrl.SetRange(-1, 10);
+ m_fExitFullScreenAtTheEnd = s.fExitFullScreenAtTheEnd;
+ m_fRestoreResAfterExit = s.fRestoreResAfterExit;
+
+ CString str;
+ m_iMonitorType = 0;
+ CMonitor monitor;
+ CMonitors monitors;
+
+ m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
+ m_MonitorDisplayNames.Add(_T("Current"));
+ if(m_f_hmonitor == _T("Current"))
+ {
+ m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
+ }
+
+ for ( int i = 0; i < monitors.GetCount(); i++ )
+ {
+ monitor = monitors.GetMonitor( i );
+ monitor.GetName(str);
+
+ if(monitor.IsMonitor())
+ {
+ DISPLAY_DEVICE displayDevice;
+ ZeroMemory(&displayDevice, sizeof(displayDevice));
+ displayDevice.cb = sizeof(displayDevice);
+ VERIFY(EnumDisplayDevices(str, 0, &displayDevice, 0));
+
+ m_iMonitorTypeCtrl.AddString(str+_T(" - ")+displayDevice.DeviceString);
+ m_MonitorDisplayNames.Add(str);
+
+ if(m_f_hmonitor == str && m_iMonitorType == 0)
+ {
+ m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
+ }
+ }
+ }
+
+ if(m_iMonitorTypeCtrl.GetCount() > 2)
+ {
+ GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
+ }
+ else
+ {
+ m_iMonitorType = 0;
+ GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
+ }
+ ModesUpdate();
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageFullscreen::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- int iSel_24 = m_dispmode24combo.GetCurSel();
- int iSel_25 = m_dispmode25combo.GetCurSel();
- int iSel_30 = m_dispmode30combo.GetCurSel();
- int iSel_Other = m_dispmodeOthercombo.GetCurSel();
- int iSel_23 = m_dispmode23d976combo.GetCurSel();
- int iSel_29 = m_dispmode29d97combo.GetCurSel();
-
- if(m_AutoChangeFullscrRes.bEnabled = !!m_fSetFullscreenRes)
- {
- if(iSel_24 >= 0 && iSel_24 < m_dms.GetCount())
- m_AutoChangeFullscrRes.dmFullscreenRes24Hz = m_dms[m_dispmode24combo.GetCurSel()];
- if(iSel_25 >= 0 && iSel_25 < m_dms.GetCount())
- m_AutoChangeFullscrRes.dmFullscreenRes25Hz = m_dms[m_dispmode25combo.GetCurSel()];
- if(iSel_30 >= 0 && iSel_30 < m_dms.GetCount())
- m_AutoChangeFullscrRes.dmFullscreenRes30Hz = m_dms[m_dispmode30combo.GetCurSel()];
- if(iSel_Other >= 0 && iSel_Other < m_dms.GetCount())
- m_AutoChangeFullscrRes.dmFullscreenResOther = m_dms[m_dispmodeOthercombo.GetCurSel()];
- if(iSel_23 >= 0 && iSel_23 < m_dms.GetCount())
- m_AutoChangeFullscrRes.dmFullscreenRes23d976Hz = m_dms[m_dispmode23d976combo.GetCurSel()];
- if(iSel_29 >= 0 && iSel_29 < m_dms.GetCount())
- m_AutoChangeFullscrRes.dmFullscreenRes29d97Hz = m_dms[m_dispmode29d97combo.GetCurSel()];
- }
- m_AutoChangeFullscrRes.bApplyDefault = m_fSetDefault;
- s.AutoChangeFullscrRes = m_AutoChangeFullscrRes;
- s.launchfullscreen = !!m_launchfullscreen;
- s.f_hmonitor = m_f_hmonitor;
- s.fShowBarsWhenFullScreen = !!m_iShowBarsWhenFullScreen;
- s.nShowBarsWhenFullScreenTimeOut = m_nShowBarsWhenFullScreenTimeOut;
- s.fExitFullScreenAtTheEnd = !!m_fExitFullScreenAtTheEnd;
- s.fRestoreResAfterExit = !!m_fRestoreResAfterExit;
-
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ int iSel_24 = m_dispmode24combo.GetCurSel();
+ int iSel_25 = m_dispmode25combo.GetCurSel();
+ int iSel_30 = m_dispmode30combo.GetCurSel();
+ int iSel_Other = m_dispmodeOthercombo.GetCurSel();
+ int iSel_23 = m_dispmode23d976combo.GetCurSel();
+ int iSel_29 = m_dispmode29d97combo.GetCurSel();
+
+ if (m_AutoChangeFullscrRes.bEnabled = !!m_fSetFullscreenRes)
+ {
+ if(iSel_24 >= 0 && iSel_24 < m_dms.GetCount())
+ m_AutoChangeFullscrRes.dmFullscreenRes24Hz = m_dms[m_dispmode24combo.GetCurSel()];
+ if(iSel_25 >= 0 && iSel_25 < m_dms.GetCount())
+ m_AutoChangeFullscrRes.dmFullscreenRes25Hz = m_dms[m_dispmode25combo.GetCurSel()];
+ if(iSel_30 >= 0 && iSel_30 < m_dms.GetCount())
+ m_AutoChangeFullscrRes.dmFullscreenRes30Hz = m_dms[m_dispmode30combo.GetCurSel()];
+ if(iSel_Other >= 0 && iSel_Other < m_dms.GetCount())
+ m_AutoChangeFullscrRes.dmFullscreenResOther = m_dms[m_dispmodeOthercombo.GetCurSel()];
+ if(iSel_23 >= 0 && iSel_23 < m_dms.GetCount())
+ m_AutoChangeFullscrRes.dmFullscreenRes23d976Hz = m_dms[m_dispmode23d976combo.GetCurSel()];
+ if(iSel_29 >= 0 && iSel_29 < m_dms.GetCount())
+ m_AutoChangeFullscrRes.dmFullscreenRes29d97Hz = m_dms[m_dispmode29d97combo.GetCurSel()];
+ }
+ m_AutoChangeFullscrRes.bApplyDefault = m_fSetDefault;
+ s.AutoChangeFullscrRes = m_AutoChangeFullscrRes;
+ s.launchfullscreen = !!m_launchfullscreen;
+ s.f_hmonitor = m_f_hmonitor;
+ s.fShowBarsWhenFullScreen = !!m_iShowBarsWhenFullScreen;
+ s.nShowBarsWhenFullScreenTimeOut = m_nShowBarsWhenFullScreenTimeOut;
+ s.fExitFullScreenAtTheEnd = !!m_fExitFullScreenAtTheEnd;
+ s.fRestoreResAfterExit = !!m_fRestoreResAfterExit;
+
+
+ return __super::OnApply();
}
void CPPageFullscreen::OnUpdateDispMode24Combo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateDispMode25Combo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateDispMode30Combo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateDispModeOtherCombo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateDispMode23d976Combo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && CMPlayerCApp::IsVistaOrAbove());
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && CMPlayerCApp::IsVistaOrAbove());
}
void CPPageFullscreen::OnUpdateDispMode29d97Combo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && CMPlayerCApp::IsVistaOrAbove());
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && CMPlayerCApp::IsVistaOrAbove());
}
void CPPageFullscreen::OnUpdateApplyDefault(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateRestoreRes(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateFullScrCombo()
{
- CMonitors monitors;
- m_f_hmonitor = m_MonitorDisplayNames[m_iMonitorTypeCtrl.GetCurSel()];
- if(AfxGetAppSettings().f_hmonitor != m_f_hmonitor) m_AutoChangeFullscrRes.bEnabled = false;
- ModesUpdate();
- SetModified();
+ CMonitors monitors;
+ m_f_hmonitor = m_MonitorDisplayNames[m_iMonitorTypeCtrl.GetCurSel()];
+ if(AfxGetAppSettings().f_hmonitor != m_f_hmonitor) m_AutoChangeFullscrRes.bEnabled = false;
+ ModesUpdate();
+ SetModified();
}
void CPPageFullscreen::OnUpdateTimeout(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_iShowBarsWhenFullScreen);
+ UpdateData();
+ pCmdUI->Enable(m_iShowBarsWhenFullScreen);
}
void CPPageFullscreen::ModesUpdate()
{
- CMonitors monitors;
- m_fSetFullscreenRes = m_AutoChangeFullscrRes.bEnabled;
- int iSel_24, iSel_25, iSel_30, iSel_Other, iSel_23, iSel_29;
- iSel_24 = iSel_25 = iSel_30 = iSel_Other = iSel_23 = iSel_29 = -1;
- dispmode dm,
- dmtoset24 = m_AutoChangeFullscrRes.dmFullscreenRes24Hz,
- dmtoset25 = m_AutoChangeFullscrRes.dmFullscreenRes25Hz,
- dmtoset30 = m_AutoChangeFullscrRes.dmFullscreenRes30Hz,
- dmtosetOther = m_AutoChangeFullscrRes.dmFullscreenResOther,
- dmtoset23 = m_AutoChangeFullscrRes.dmFullscreenRes23d976Hz,
- dmtoset29 = m_AutoChangeFullscrRes.dmFullscreenRes29d97Hz;
-
- if(!m_AutoChangeFullscrRes.bEnabled)
- {
- GetCurDispMode(dmtoset24, m_f_hmonitor);
- dmtoset29 = dmtoset23 = dmtosetOther = dmtoset30 = dmtoset25 = dmtoset24;
- }
- CString str;
-
- ComboBox_ResetContent(m_dispmode24combo);
- ComboBox_ResetContent(m_dispmode25combo);
- ComboBox_ResetContent(m_dispmode30combo);
- ComboBox_ResetContent(m_dispmodeOthercombo);
- ComboBox_ResetContent(m_dispmode23d976combo);
- ComboBox_ResetContent(m_dispmode29d97combo);
- m_dms.RemoveAll();
-
- for(int i = 0, j = 0, ModeExist = true; ; i++)
- {
- ModeExist = GetDispMode(i, dm, m_f_hmonitor);
- if(!ModeExist) break;
- if(dm.bpp <= 8) continue;
- //skip doubles (check previous only)
- if(j > 0 && (dm.bpp == m_dms[j-1].bpp && dm.dmDisplayFlags == m_dms[j-1].dmDisplayFlags
- && dm.freq == m_dms[j-1].freq && dm.fValid == m_dms[j-1].fValid
- && dm.size == m_dms[j-1].size)) continue;
- m_dms.Add(dm);
- str.Format(_T("%dx%d %dbpp %d") + ResStr(IDS_HZ), dm.size.cx, dm.size.cy, dm.bpp, dm.freq);
- if(dm.dmDisplayFlags == DM_INTERLACED) str += _T(" ") + ResStr(IDS_INTERLACED);
- if(dm.freq == 23) str += _T(" (23.976)");
- if(dm.freq == 59) str += _T(" (NTSC)");
-
- m_dispmode24combo.AddString(str);
- m_dispmode25combo.AddString(str);
- m_dispmode30combo.AddString(str);
- m_dispmodeOthercombo.AddString(str);
- m_dispmode23d976combo.AddString(str);
- m_dispmode29d97combo.AddString(str);
-
- if(iSel_24 < 0 && dmtoset24.fValid && dm.size == dmtoset24.size
- && dm.bpp == dmtoset24.bpp && dm.freq == dmtoset24.freq) iSel_24 = j;
- if(iSel_25 < 0 && dmtoset25.fValid && dm.size == dmtoset25.size
- && dm.bpp == dmtoset25.bpp && dm.freq == dmtoset25.freq) iSel_25 = j;
- if(iSel_30 < 0 && dmtoset30.fValid && dm.size == dmtoset30.size
- && dm.bpp == dmtoset30.bpp && dm.freq == dmtoset30.freq) iSel_30 = j;
- if(iSel_Other < 0 && dmtosetOther.fValid && dm.size == dmtosetOther.size
- && dm.bpp == dmtosetOther.bpp && dm.freq == dmtosetOther.freq) iSel_Other = j;
- if(iSel_23 < 0 && dmtoset23.fValid && dm.size == dmtoset23.size
- && dm.bpp == dmtoset23.bpp && dm.freq == dmtoset23.freq) iSel_23 = j;
- if(iSel_29 < 0 && dmtoset29.fValid && dm.size == dmtoset29.size
- && dm.bpp == dmtoset29.bpp && dm.freq == dmtoset29.freq) iSel_29 = j;
- j++;
- }
- m_dispmode24combo.SetCurSel(iSel_24);
- m_dispmode25combo.SetCurSel(iSel_25);
- m_dispmode30combo.SetCurSel(iSel_30);
- m_dispmodeOthercombo.SetCurSel(iSel_Other);
- m_dispmode23d976combo.SetCurSel(iSel_23);
- m_dispmode29d97combo.SetCurSel(iSel_29);
+ CMonitors monitors;
+ m_fSetFullscreenRes = m_AutoChangeFullscrRes.bEnabled;
+ int iSel_24, iSel_25, iSel_30, iSel_Other, iSel_23, iSel_29;
+ iSel_24 = iSel_25 = iSel_30 = iSel_Other = iSel_23 = iSel_29 = -1;
+ dispmode dm,
+ dmtoset24 = m_AutoChangeFullscrRes.dmFullscreenRes24Hz,
+ dmtoset25 = m_AutoChangeFullscrRes.dmFullscreenRes25Hz,
+ dmtoset30 = m_AutoChangeFullscrRes.dmFullscreenRes30Hz,
+ dmtosetOther = m_AutoChangeFullscrRes.dmFullscreenResOther,
+ dmtoset23 = m_AutoChangeFullscrRes.dmFullscreenRes23d976Hz,
+ dmtoset29 = m_AutoChangeFullscrRes.dmFullscreenRes29d97Hz;
+
+ if(!m_AutoChangeFullscrRes.bEnabled)
+ {
+ GetCurDispMode(dmtoset24, m_f_hmonitor);
+ dmtoset29 = dmtoset23 = dmtosetOther = dmtoset30 = dmtoset25 = dmtoset24;
+ }
+ CString str;
+
+ ComboBox_ResetContent(m_dispmode24combo);
+ ComboBox_ResetContent(m_dispmode25combo);
+ ComboBox_ResetContent(m_dispmode30combo);
+ ComboBox_ResetContent(m_dispmodeOthercombo);
+ ComboBox_ResetContent(m_dispmode23d976combo);
+ ComboBox_ResetContent(m_dispmode29d97combo);
+ m_dms.RemoveAll();
+
+ for(int i = 0, j = 0, ModeExist = true; ; i++)
+ {
+ ModeExist = GetDispMode(i, dm, m_f_hmonitor);
+ if (!ModeExist) break;
+ if(dm.bpp <= 8) continue;
+ //skip doubles (check previous only)
+ if (j>0 && (dm.bpp == m_dms[j-1].bpp && dm.dmDisplayFlags == m_dms[j-1].dmDisplayFlags
+ && dm.freq == m_dms[j-1].freq && dm.fValid == m_dms[j-1].fValid
+ && dm.size == m_dms[j-1].size)) continue;
+ m_dms.Add(dm);
+ str.Format(_T("%dx%d %dbpp %d") + ResStr(IDS_HZ), dm.size.cx, dm.size.cy, dm.bpp, dm.freq);
+ if (dm.dmDisplayFlags == DM_INTERLACED) str+=_T(" ")+ ResStr(IDS_INTERLACED);
+ if (dm.freq == 23) str+=_T(" (23.976)");
+ if (dm.freq == 59) str+=_T(" (NTSC)");
+
+ m_dispmode24combo.AddString(str);
+ m_dispmode25combo.AddString(str);
+ m_dispmode30combo.AddString(str);
+ m_dispmodeOthercombo.AddString(str);
+ m_dispmode23d976combo.AddString(str);
+ m_dispmode29d97combo.AddString(str);
+
+ if(iSel_24 < 0 && dmtoset24.fValid && dm.size == dmtoset24.size
+ && dm.bpp == dmtoset24.bpp && dm.freq == dmtoset24.freq) iSel_24 = j;
+ if(iSel_25 < 0 && dmtoset25.fValid && dm.size == dmtoset25.size
+ && dm.bpp == dmtoset25.bpp && dm.freq == dmtoset25.freq) iSel_25 = j;
+ if(iSel_30 < 0 && dmtoset30.fValid && dm.size == dmtoset30.size
+ && dm.bpp == dmtoset30.bpp && dm.freq == dmtoset30.freq) iSel_30 = j;
+ if(iSel_Other < 0 && dmtosetOther.fValid && dm.size == dmtosetOther.size
+ && dm.bpp == dmtosetOther.bpp && dm.freq == dmtosetOther.freq) iSel_Other = j;
+ if(iSel_23 < 0 && dmtoset23.fValid && dm.size == dmtoset23.size
+ && dm.bpp == dmtoset23.bpp && dm.freq == dmtoset23.freq) iSel_23 = j;
+ if(iSel_29 < 0 && dmtoset29.fValid && dm.size == dmtoset29.size
+ && dm.bpp == dmtoset29.bpp && dm.freq == dmtoset29.freq) iSel_29 = j;
+ j++;
+ }
+ m_dispmode24combo.SetCurSel(iSel_24);
+ m_dispmode25combo.SetCurSel(iSel_25);
+ m_dispmode30combo.SetCurSel(iSel_30);
+ m_dispmodeOthercombo.SetCurSel(iSel_Other);
+ m_dispmode23d976combo.SetCurSel(iSel_23);
+ m_dispmode29d97combo.SetCurSel(iSel_29);
}
diff --git a/src/apps/mplayerc/PPageFullscreen.h b/src/apps/mplayerc/PPageFullscreen.h
index fa8d47156..5bb83e4e4 100644
--- a/src/apps/mplayerc/PPageFullscreen.h
+++ b/src/apps/mplayerc/PPageFullscreen.h
@@ -24,62 +24,62 @@
#pragma once
#include "PPageBase.h"
-
+
// CPPageFullscreen dialog
-
+
class CPPageFullscreen : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageFullscreen)
+ DECLARE_DYNAMIC(CPPageFullscreen)
// private:
- CAtlArray<dispmode> m_dms;
- CStringArray m_MonitorDisplayNames;
-
-public:
- CPPageFullscreen();
- virtual ~CPPageFullscreen();
+ CAtlArray<dispmode> m_dms;
+ CStringArray m_MonitorDisplayNames;
- BOOL m_launchfullscreen;
- BOOL m_fSetFullscreenRes;
- BOOL m_fSetDefault;
- CComboBox m_dispmode24combo;
- CComboBox m_dispmode25combo;
- CComboBox m_dispmode30combo;
- CComboBox m_dispmodeOthercombo;
- CComboBox m_dispmode23d976combo;
- CComboBox m_dispmode29d97combo;
+ public:
+ CPPageFullscreen();
+ virtual ~CPPageFullscreen();
- AChFR m_AutoChangeFullscrRes;
- CStringW m_f_hmonitor;
- int m_iMonitorType;
- CComboBox m_iMonitorTypeCtrl;
+ BOOL m_launchfullscreen;
+ BOOL m_fSetFullscreenRes;
+ BOOL m_fSetDefault;
+ CComboBox m_dispmode24combo;
+ CComboBox m_dispmode25combo;
+ CComboBox m_dispmode30combo;
+ CComboBox m_dispmodeOthercombo;
+ CComboBox m_dispmode23d976combo;
+ CComboBox m_dispmode29d97combo;
+
+ AChFR m_AutoChangeFullscrRes;
+ CStringW m_f_hmonitor;
+ int m_iMonitorType;
+ CComboBox m_iMonitorTypeCtrl;
- BOOL m_iShowBarsWhenFullScreen;
- int m_nShowBarsWhenFullScreenTimeOut;
- BOOL m_fExitFullScreenAtTheEnd;
- CSpinButtonCtrl m_nTimeOutCtrl;
- BOOL m_fRestoreResAfterExit;
+ BOOL m_iShowBarsWhenFullScreen;
+ int m_nShowBarsWhenFullScreenTimeOut;
+ BOOL m_fExitFullScreenAtTheEnd;
+ CSpinButtonCtrl m_nTimeOutCtrl;
+ BOOL m_fRestoreResAfterExit;
// Dialog Data
- enum { IDD = IDD_PPAGEFULLSCREEN };
-
-protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
-
- DECLARE_MESSAGE_MAP()
-
-public:
- afx_msg void OnUpdateDispMode24Combo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDispMode25Combo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDispMode30Combo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDispModeOtherCombo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDispMode23d976Combo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDispMode29d97Combo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateApplyDefault(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFullScrCombo();
- afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
- afx_msg void OnUpdateRestoreRes(CCmdUI* pCmdUI);
- void ModesUpdate();
-};
+ enum { IDD = IDD_PPAGEFULLSCREEN };
+
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+
+ DECLARE_MESSAGE_MAP()
+
+ public:
+ afx_msg void OnUpdateDispMode24Combo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDispMode25Combo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDispMode30Combo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDispModeOtherCombo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDispMode23d976Combo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDispMode29d97Combo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateApplyDefault(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFullScrCombo();
+ afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateRestoreRes(CCmdUI* pCmdUI);
+ void ModesUpdate();
+ };
diff --git a/src/apps/mplayerc/PPageInternalFilters.cpp b/src/apps/mplayerc/PPageInternalFilters.cpp
index 67109038b..0afeb47eb 100644
--- a/src/apps/mplayerc/PPageInternalFilters.cpp
+++ b/src/apps/mplayerc/PPageInternalFilters.cpp
@@ -31,267 +31,267 @@
static struct filter_t
{
- LPCTSTR label;
- int type;
- int flag;
- UINT nHintID;
- CUnknown*(WINAPI * CreateInstance)(LPUNKNOWN lpunk, HRESULT* phr);
+ LPCTSTR label;
+ int type;
+ int flag;
+ UINT nHintID;
+ CUnknown* (WINAPI * CreateInstance)(LPUNKNOWN lpunk, HRESULT* phr);
}
-s_filters[] =
+s_filters[] =
{
#if INTERNAL_SOURCEFILTER_AVI
- {_T("AVI"), 0, SRC_AVI, IDS_SRC_AVI, NULL},
+ {_T("AVI"), 0, SRC_AVI, IDS_SRC_AVI, NULL},
#endif
#if INTERNAL_SOURCEFILTER_CDDA
- {_T("CDDA (Audio CD)"), 0, SRC_CDDA, IDS_SRC_CDDA, NULL},
+ {_T("CDDA (Audio CD)"), 0, SRC_CDDA, IDS_SRC_CDDA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- {_T("CDXA (VCD/SVCD/XCD)"), 0, SRC_CDXA, IDS_SRC_CDXA, NULL},
+ {_T("CDXA (VCD/SVCD/XCD)"), 0, SRC_CDXA, IDS_SRC_CDXA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_DIRAC
- {_T("Dirac"), 0, SRC_DIRAC, IDS_SRC_DIRAC, NULL},
+ {_T("Dirac"), 0, SRC_DIRAC, IDS_SRC_DIRAC, NULL},
#endif
#if INTERNAL_SOURCEFILTER_DSM
- {_T("DirectShow Media"), 0, SRC_DSM, IDS_SRC_DSM, NULL},
+ {_T("DirectShow Media"), 0, SRC_DSM, IDS_SRC_DSM, NULL},
#endif
#if INTERNAL_SOURCEFILTER_DTSAC3
- {_T("DTS/AC3"), 0, SRC_DTSAC3, IDS_SRC_DTSAC3, NULL},
+ {_T("DTS/AC3"), 0, SRC_DTSAC3, IDS_SRC_DTSAC3, NULL},
#endif
#if INTERNAL_SOURCEFILTER_VTS
- {_T("DVD Video Title Set"), 0, SRC_VTS, IDS_SRC_VTS, NULL},
+ {_T("DVD Video Title Set"), 0, SRC_VTS, IDS_SRC_VTS, NULL},
#endif
#if INTERNAL_SOURCEFILTER_DVSOURCE
- {_T("DVD2AVI Project File"), 0, SRC_D2V, IDS_SRC_D2V, NULL},
+ {_T("DVD2AVI Project File"), 0, SRC_D2V, IDS_SRC_D2V, NULL},
#endif
#if INTERNAL_SOURCEFILTER_FLIC
- {_T("FLI/FLC"), 0, SRC_FLIC, IDS_SRC_FLIC, NULL},
+ {_T("FLI/FLC"), 0, SRC_FLIC, IDS_SRC_FLIC, NULL},
#endif
#if INTERNAL_SOURCEFILTER_FLAC
- {_T("Flac"), 0, SRC_FLAC, IDS_SRC_FLAC, NULL},
+ {_T("Flac"), 0, SRC_FLAC, IDS_SRC_FLAC, NULL},
#endif
#if INTERNAL_SOURCEFILTER_FLV
- {_T("FLV"), 0, SRC_FLV, IDS_SRC_FLV, NULL},
+ {_T("FLV"), 0, SRC_FLV, IDS_SRC_FLV, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- {_T("Matroska"), 0, SRC_MATROSKA, IDS_SRC_MATROSKA, NULL},
+ {_T("Matroska"), 0, SRC_MATROSKA, IDS_SRC_MATROSKA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MP4
- {_T("MP4/MOV"), 0, SRC_MP4, IDS_SRC_MP4, NULL},
+ {_T("MP4/MOV"), 0, SRC_MP4, IDS_SRC_MP4, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- {_T("MPEG Audio"), 0, SRC_MPA, IDS_SRC_MPA, NULL},
+ {_T("MPEG Audio"), 0, SRC_MPA, IDS_SRC_MPA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- {_T("MPEG PS/TS/PVA"), 0, SRC_MPEG, 0, NULL},
+ {_T("MPEG PS/TS/PVA"), 0, SRC_MPEG, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_NUT
- {_T("Nut"), 0, SRC_NUT, IDS_SRC_NUT, NULL},
+ {_T("Nut"), 0, SRC_NUT, IDS_SRC_NUT, NULL},
#endif
#if INTERNAL_SOURCEFILTER_OGG
- {_T("Ogg"), 0, SRC_OGG, IDS_SRC_OGG, NULL},
+ {_T("Ogg"), 0, SRC_OGG, IDS_SRC_OGG, NULL},
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- {_T("RealMedia"), 0, SRC_REALMEDIA, IDS_SRC_REALMEDIA, NULL},
+ {_T("RealMedia"), 0, SRC_REALMEDIA, IDS_SRC_REALMEDIA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_ROQ
- {_T("RoQ"), 0, SRC_ROQ, IDS_SRC_ROQ, NULL},
+ {_T("RoQ"), 0, SRC_ROQ, IDS_SRC_ROQ, NULL},
#endif
#if INTERNAL_SOURCEFILTER_SHOUTCAST
- {_T("SHOUTcast"), 0, SRC_SHOUTCAST, IDS_SRC_SHOUTCAST, NULL},
+ {_T("SHOUTcast"), 0, SRC_SHOUTCAST, IDS_SRC_SHOUTCAST, NULL},
#endif
#if INTERNAL_SOURCEFILTER_RADGT
- {_T("Smacker/Bink"), 0, SRC_RADGT, IDS_SRC_RADGT, NULL},
+ {_T("Smacker/Bink"), 0, SRC_RADGT, IDS_SRC_RADGT, NULL},
#endif
#if INTERNAL_DECODER_AAC
- {_T("AAC"), 1, TRA_AAC, IDS_TRA_AAC, CreateInstance<CMpaDecFilter>},
+ {_T("AAC"), 1, TRA_AAC, IDS_TRA_AAC, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_AC3
- {_T("AC3"), 1, TRA_AC3, IDS_TRA_AC3, CreateInstance<CMpaDecFilter>},
+ {_T("AC3"), 1, TRA_AC3, IDS_TRA_AC3, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_DTS
- {_T("DTS"), 1, TRA_DTS, IDS_TRA_DTS, CreateInstance<CMpaDecFilter>},
- {_T("LPCM"), 1, TRA_LPCM, IDS_TRA_LPCM, CreateInstance<CMpaDecFilter>},
+ {_T("DTS"), 1, TRA_DTS, IDS_TRA_DTS, CreateInstance<CMpaDecFilter>},
+ {_T("LPCM"), 1, TRA_LPCM, IDS_TRA_LPCM, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_MPEGAUDIO
- {_T("MPEG Audio"), 1, TRA_MPA, IDS_TRA_MPA, CreateInstance<CMpaDecFilter>},
+ {_T("MPEG Audio"), 1, TRA_MPA, IDS_TRA_MPA, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_VORBIS
- {_T("Vorbis"), 1, TRA_VORBIS, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
+ {_T("Vorbis"), 1, TRA_VORBIS, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
#endif
#if INTERNAL_DECODER_FLAC
- {_T("FLAC"), 1, TRA_FLAC, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
+ {_T("FLAC"), 1, TRA_FLAC, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
#endif
#if INTERNAL_DECODER_NELLYMOSER
- {_T("Nellymoser"), 1, TRA_NELLY, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
+ {_T("Nellymoser"), 1, TRA_NELLY, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
#endif
#if INTERNAL_DECODER_AMR
- {_T("AMR"), 1, TRA_AMR, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
+ {_T("AMR"), 1, TRA_AMR, 0, NULL /* TODO: CreateInstance<CMpaDecFilter>*/},
#endif
#if INTERNAL_DECODER_REALAUDIO
- {_T("RealAudio"), 1, TRA_RA, IDS_TRA_RA, NULL},
+ {_T("RealAudio"), 1, TRA_RA, IDS_TRA_RA, NULL},
#endif
#if INTERNAL_DECODER_PS2AUDIO
- {_T("PS2 Audio (PCM/ADPCM)"), 1, TRA_PS2AUD, IDS_TRA_PS2AUD, CreateInstance<CMpaDecFilter>},
+ {_T("PS2 Audio (PCM/ADPCM)"), 1, TRA_PS2AUD, IDS_TRA_PS2AUD, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_MPEG1
- {_T("MPEG-1 Video"), 1, TRA_MPEG1, IDS_TRA_MPEG1, CreateInstance<CMpeg2DecFilter>},
+ {_T("MPEG-1 Video"), 1, TRA_MPEG1, IDS_TRA_MPEG1, CreateInstance<CMpeg2DecFilter>},
#endif
#if INTERNAL_DECODER_MPEG2
- {_T("MPEG-2 Video"), 1, TRA_MPEG2, IDS_TRA_MPEG2, CreateInstance<CMpeg2DecFilter>},
+ {_T("MPEG-2 Video"), 1, TRA_MPEG2, IDS_TRA_MPEG2, CreateInstance<CMpeg2DecFilter>},
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- {_T("MPEG-2 Video (DXVA)"), 2, DXVA_MPEG2, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("MPEG-2 Video (DXVA)"), 2, DXVA_MPEG2, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_DIRAC
- {_T("Dirac"), 1, TRA_DIRAC, IDS_TRA_DIRAC, NULL},
+ {_T("Dirac"), 1, TRA_DIRAC, IDS_TRA_DIRAC, NULL},
#endif
#if INTERNAL_DECODER_REALVIDEO
- {_T("RealVideo"), 1, TRA_RV, IDS_TRA_RV, NULL},
+ {_T("RealVideo"), 1, TRA_RV, IDS_TRA_RV, NULL},
#endif
#if INTERNAL_DECODER_H264_DXVA
- {_T("H264/AVC (DXVA)"), 2, DXVA_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("H264/AVC (DXVA)"), 2, DXVA_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_H264
- {_T("H264/AVC (FFmpeg)"), 3, FFM_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("H264/AVC (FFmpeg)"), 3, FFM_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_VC1_DXVA
- {_T("VC1 (DXVA)"), 2, DXVA_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("VC1 (DXVA)"), 2, DXVA_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_VC1
- {_T("VC1 (FFmpeg)"), 3, FFM_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("VC1 (FFmpeg)"), 3, FFM_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_XVID
- {_T("Xvid/MPEG-4"), 3, FFM_XVID, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("Xvid/MPEG-4"), 3, FFM_XVID, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_DIVX
- {_T("DivX"), 3, FFM_DIVX, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("DivX"), 3, FFM_DIVX, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_MSMPEG4
- {_T("MS MPEG-4"), 3, FFM_MSMPEG4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("MS MPEG-4"), 3, FFM_MSMPEG4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_FLV
- {_T("FLV1/4"), 3, FFM_FLV4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("FLV1/4"), 3, FFM_FLV4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_VP6
- {_T("VP5/6"), 3, FFM_VP62, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("VP5/6"), 3, FFM_VP62, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_WMV
- {_T("WMV1/2/3"), 3, FFM_WMV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("WMV1/2/3"), 3, FFM_WMV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_SVQ
- {_T("SVQ1/3"), 3, FFM_SVQ3, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("SVQ1/3"), 3, FFM_SVQ3, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_H263
- {_T("H263"), 3, FFM_H263, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("H263"), 3, FFM_H263, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_AMVV
- {_T("AMV video"), 3, FFM_AMVV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("AMV video"), 3, FFM_AMVV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_THEORA
- {_T("Theora"), 3, FFM_THEORA, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("Theora"), 3, FFM_THEORA, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
- {NULL, 0, 0, 0, NULL}
+ {NULL, 0, 0, 0, NULL}
};
IMPLEMENT_DYNAMIC(CPPageInternalFiltersListBox, CCheckListBox)
CPPageInternalFiltersListBox::CPPageInternalFiltersListBox()
- : CCheckListBox()
+ : CCheckListBox()
{
}
void CPPageInternalFiltersListBox::PreSubclassWindow()
{
- __super::PreSubclassWindow();
- EnableToolTips(TRUE);
+ __super::PreSubclassWindow();
+ EnableToolTips(TRUE);
}
INT_PTR CPPageInternalFiltersListBox::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
- BOOL b = FALSE;
- int row = ItemFromPoint(point, b);
- if(row < 0) return -1;
-
- CRect r;
- GetItemRect(row, r);
- pTI->rect = r;
- pTI->hwnd = m_hWnd;
- pTI->uId = (UINT)row;
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- pTI->uFlags |= TTF_ALWAYSTIP;
-
- return pTI->uId;
+ BOOL b = FALSE;
+ int row = ItemFromPoint(point, b);
+ if(row < 0) return -1;
+
+ CRect r;
+ GetItemRect(row, r);
+ pTI->rect = r;
+ pTI->hwnd = m_hWnd;
+ pTI->uId = (UINT)row;
+ pTI->lpszText = LPSTR_TEXTCALLBACK;
+ pTI->uFlags |= TTF_ALWAYSTIP;
+
+ return pTI->uId;
}
BEGIN_MESSAGE_MAP(CPPageInternalFiltersListBox, CCheckListBox)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
BOOL CPPageInternalFiltersListBox::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
- TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
+ TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
+ TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
- filter_t* f = (filter_t*)GetItemDataPtr(pNMHDR->idFrom);
- if(f->nHintID == 0) return FALSE;
+ filter_t* f = (filter_t*)GetItemDataPtr(pNMHDR->idFrom);
+ if(f->nHintID == 0) return FALSE;
- ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
+ ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
- static CStringA m_strTipTextA;
- static CStringW m_strTipTextW;
+ static CStringA m_strTipTextA;
+ static CStringW m_strTipTextW;
+
+ m_strTipTextA = CString(MAKEINTRESOURCE(f->nHintID));
+ m_strTipTextW = CString(MAKEINTRESOURCE(f->nHintID));
- m_strTipTextA = CString(MAKEINTRESOURCE(f->nHintID));
- m_strTipTextW = CString(MAKEINTRESOURCE(f->nHintID));
+ if(pNMHDR->code == TTN_NEEDTEXTA) pTTTA->lpszText = (LPSTR)(LPCSTR)m_strTipTextA;
+ else pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
- if(pNMHDR->code == TTN_NEEDTEXTA) pTTTA->lpszText = (LPSTR)(LPCSTR)m_strTipTextA;
- else pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
+ *pResult = 0;
- *pResult = 0;
-
- return TRUE; // message was handled
+ return TRUE; // message was handled
}
void CPPageInternalFiltersListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- CFont* pOldFont = NULL;
-
- if((lpDrawItemStruct->itemData != 0) && ((filter_t*)lpDrawItemStruct->itemData)->CreateInstance)
- {
- if(!(HFONT)m_bold)
- {
- CFont* pFont = pDC->GetCurrentFont();
-
- LOGFONT lf;
- pFont->GetLogFont(&lf);
- lf.lfWeight = FW_BOLD;
-
- m_bold.CreateFontIndirect(&lf);
- }
-
- if((HFONT)m_bold)
- {
- pOldFont = pDC->SelectObject(&m_bold);
- }
- }
-
- __super::DrawItem(lpDrawItemStruct);
-
- if(pOldFont)
- {
- pDC->SelectObject(pOldFont);
- }
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ CFont* pOldFont = NULL;
+
+ if((lpDrawItemStruct->itemData != 0) && ((filter_t*)lpDrawItemStruct->itemData)->CreateInstance)
+ {
+ if(!(HFONT)m_bold)
+ {
+ CFont* pFont = pDC->GetCurrentFont();
+
+ LOGFONT lf;
+ pFont->GetLogFont(&lf);
+ lf.lfWeight = FW_BOLD;
+
+ m_bold.CreateFontIndirect(&lf);
+ }
+
+ if((HFONT)m_bold)
+ {
+ pOldFont = pDC->SelectObject(&m_bold);
+ }
+ }
+
+ __super::DrawItem(lpDrawItemStruct);
+
+ if(pOldFont)
+ {
+ pDC->SelectObject(pOldFont);
+ }
}
// CPPageInternalFilters dialog
IMPLEMENT_DYNAMIC(CPPageInternalFilters, CPPageBase)
CPPageInternalFilters::CPPageInternalFilters()
- : CPPageBase(CPPageInternalFilters::IDD, CPPageInternalFilters::IDD)
+ : CPPageBase(CPPageInternalFilters::IDD, CPPageInternalFilters::IDD)
{
}
@@ -302,138 +302,138 @@ CPPageInternalFilters::~CPPageInternalFilters()
void CPPageInternalFilters::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_listSrc);
- DDX_Control(pDX, IDC_LIST2, m_listTra);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_listSrc);
+ DDX_Control(pDX, IDC_LIST2, m_listTra);
}
BEGIN_MESSAGE_MAP(CPPageInternalFilters, CPPageBase)
- ON_LBN_DBLCLK(IDC_LIST1, &CPPageInternalFilters::OnLbnDblclkList1)
- ON_LBN_DBLCLK(IDC_LIST2, &CPPageInternalFilters::OnLbnDblclkList2)
+ ON_LBN_DBLCLK(IDC_LIST1, &CPPageInternalFilters::OnLbnDblclkList1)
+ ON_LBN_DBLCLK(IDC_LIST2, &CPPageInternalFilters::OnLbnDblclkList2)
END_MESSAGE_MAP()
// CPPageInternalFilters message handlers
BOOL CPPageInternalFilters::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- for(int i = 0; i < countof(s_filters); i++)
- {
- CCheckListBox* l;
- UINT* pflags;
-
- switch(s_filters[i].type)
- {
- case 0: // source filter
- l = &m_listSrc;
- pflags = &s.SrcFilters;
- break;
- case 1: // decoder
- l = &m_listTra;
- pflags = &s.TraFilters;
- break;
- case 2: // dxva decoder
- l = &m_listTra;
- pflags = &s.DXVAFilters;
- break;
- case 3: // ffmpeg decoder
- l = &m_listTra;
- pflags = &s.FFmpegFilters;
- break;
- default:
- l = NULL;
- pflags = NULL;
- }
-
- if(l && pflags)
- {
- int Index = l->AddString(s_filters[i].label);
- l->SetCheck(Index, !!(*pflags & s_filters[i].flag));
- l->SetItemDataPtr(Index, &s_filters[i]);
- }
- }
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ for(int i = 0; i < countof(s_filters); i++)
+ {
+ CCheckListBox* l;
+ UINT* pflags;
+
+ switch(s_filters[i].type)
+ {
+ case 0: // source filter
+ l = &m_listSrc;
+ pflags = &s.SrcFilters;
+ break;
+ case 1: // decoder
+ l = &m_listTra;
+ pflags = &s.TraFilters;
+ break;
+ case 2: // dxva decoder
+ l = &m_listTra;
+ pflags = &s.DXVAFilters;
+ break;
+ case 3: // ffmpeg decoder
+ l = &m_listTra;
+ pflags = &s.FFmpegFilters;
+ break;
+ default:
+ l = NULL;
+ pflags = NULL;
+ }
+
+ if(l && pflags)
+ {
+ int Index = l->AddString(s_filters[i].label);
+ l->SetCheck(Index, !!(*pflags & s_filters[i].flag));
+ l->SetItemDataPtr(Index, &s_filters[i]);
+ }
+ }
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageInternalFilters::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.SrcFilters = s.TraFilters = s.DXVAFilters = s.FFmpegFilters = 0;
-
- CList<filter_t*> fl;
- for(int i = 0; i < m_listSrc.GetCount(); i++)
- if(m_listSrc.GetCheck(i))
- fl.AddTail((filter_t*)m_listSrc.GetItemDataPtr(i));
- for(int i = 0; i < m_listTra.GetCount(); i++)
- if(m_listTra.GetCheck(i))
- fl.AddTail((filter_t*)m_listTra.GetItemDataPtr(i));
-
- POSITION pos = fl.GetHeadPosition();
- while(pos)
- {
- filter_t* f = fl.GetNext(pos);
-
- switch(f->type)
- {
- case 0:
- s.SrcFilters |= f->flag;
- break;
- case 1:
- s.TraFilters |= f->flag;
- break;
- case 2:
- s.DXVAFilters |= f->flag;
- break;
- case 3:
- s.FFmpegFilters |= f->flag;
- break;
- }
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.SrcFilters = s.TraFilters = s.DXVAFilters = s.FFmpegFilters = 0;
+
+ CList<filter_t*> fl;
+ for(int i = 0; i < m_listSrc.GetCount(); i++)
+ if(m_listSrc.GetCheck(i))
+ fl.AddTail((filter_t*)m_listSrc.GetItemDataPtr(i));
+ for(int i = 0; i < m_listTra.GetCount(); i++)
+ if(m_listTra.GetCheck(i))
+ fl.AddTail((filter_t*)m_listTra.GetItemDataPtr(i));
+
+ POSITION pos = fl.GetHeadPosition();
+ while(pos)
+ {
+ filter_t* f = fl.GetNext(pos);
+
+ switch(f->type)
+ {
+ case 0:
+ s.SrcFilters |= f->flag;
+ break;
+ case 1:
+ s.TraFilters |= f->flag;
+ break;
+ case 2:
+ s.DXVAFilters |= f->flag;
+ break;
+ case 3:
+ s.FFmpegFilters |= f->flag;
+ break;
+ }
+ }
+
+ return __super::OnApply();
}
void CPPageInternalFilters::ShowPPage(CPPageInternalFiltersListBox& l)
{
- int i = l.GetCurSel();
- if(i < 0) return;
-
- filter_t* f = (filter_t*)l.GetItemDataPtr(i);
- if(!f || !f->CreateInstance) return;
-
- HRESULT hr;
- CUnknown* pObj = f->CreateInstance(NULL, &hr);
- if(!pObj) return;
-
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pObj;
-
- if(SUCCEEDED(hr))
- {
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk)
- {
- CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), this);
- ps.AddPages(pSPP);
- ps.DoModal();
- }
- }
+ int i = l.GetCurSel();
+ if(i < 0) return;
+
+ filter_t* f = (filter_t*)l.GetItemDataPtr(i);
+ if(!f || !f->CreateInstance) return;
+
+ HRESULT hr;
+ CUnknown* pObj = f->CreateInstance(NULL, &hr);
+ if(!pObj) return;
+
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pObj;
+
+ if(SUCCEEDED(hr))
+ {
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk)
+ {
+ CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), this);
+ ps.AddPages(pSPP);
+ ps.DoModal();
+ }
+ }
}
void CPPageInternalFilters::OnLbnDblclkList1()
{
- ShowPPage(m_listSrc);
+ ShowPPage(m_listSrc);
}
void CPPageInternalFilters::OnLbnDblclkList2()
{
- ShowPPage(m_listTra);
+ ShowPPage(m_listTra);
}
diff --git a/src/apps/mplayerc/PPageInternalFilters.h b/src/apps/mplayerc/PPageInternalFilters.h
index d38771bd6..8da851e40 100644
--- a/src/apps/mplayerc/PPageInternalFilters.h
+++ b/src/apps/mplayerc/PPageInternalFilters.h
@@ -29,49 +29,49 @@
class CPPageInternalFiltersListBox : public CCheckListBox
{
- DECLARE_DYNAMIC(CPPageInternalFiltersListBox)
+ DECLARE_DYNAMIC(CPPageInternalFiltersListBox)
public:
- CPPageInternalFiltersListBox();
+ CPPageInternalFiltersListBox();
- CFont m_bold;
+ CFont m_bold;
protected:
- virtual void PreSubclassWindow();
- virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
+ virtual void PreSubclassWindow();
+ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
- DECLARE_MESSAGE_MAP()
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ DECLARE_MESSAGE_MAP()
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
public:
- virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
+ virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
};
// CPPageInternalFilters dialog
class CPPageInternalFilters : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageInternalFilters)
+ DECLARE_DYNAMIC(CPPageInternalFilters)
public:
- CPPageInternalFilters();
- virtual ~CPPageInternalFilters();
+ CPPageInternalFilters();
+ virtual ~CPPageInternalFilters();
// Dialog Data
- enum { IDD = IDD_PPAGEINTERNALFILTERS };
- CPPageInternalFiltersListBox m_listSrc;
- CPPageInternalFiltersListBox m_listTra;
+ enum { IDD = IDD_PPAGEINTERNALFILTERS };
+ CPPageInternalFiltersListBox m_listSrc;
+ CPPageInternalFiltersListBox m_listTra;
- void ShowPPage(CPPageInternalFiltersListBox& l);
+ void ShowPPage(CPPageInternalFiltersListBox& l);
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnLbnDblclkList1();
- afx_msg void OnLbnDblclkList2();
+ afx_msg void OnLbnDblclkList1();
+ afx_msg void OnLbnDblclkList2();
};
diff --git a/src/apps/mplayerc/PPageLogo.cpp b/src/apps/mplayerc/PPageLogo.cpp
index 17f115067..7c8811bdf 100644
--- a/src/apps/mplayerc/PPageLogo.cpp
+++ b/src/apps/mplayerc/PPageLogo.cpp
@@ -31,19 +31,19 @@
IMPLEMENT_DYNAMIC(CPPageLogo, CPPageBase)
CPPageLogo::CPPageLogo()
- : CPPageBase(CPPageLogo::IDD, CPPageLogo::IDD)
- , m_intext(0)
- , m_logofn(_T(""))
- , m_author(_T(""))
+ : CPPageBase(CPPageLogo::IDD, CPPageLogo::IDD)
+ , m_intext(0)
+ , m_logofn(_T(""))
+ , m_author(_T(""))
{
- m_logoids.AddTail(IDF_LOGO0);
- m_logoids.AddTail(IDF_LOGO1);
- m_logoids.AddTail(IDF_LOGO2);
- m_logoids.AddTail(IDF_LOGO3);
- m_logoids.AddTail(IDF_LOGO4);
- m_logoids.AddTail(IDF_LOGO5);
- m_logoids.AddTail(IDF_LOGO6);
- m_logoids.AddTail(IDF_LOGO7);
+ m_logoids.AddTail(IDF_LOGO0);
+ m_logoids.AddTail(IDF_LOGO1);
+ m_logoids.AddTail(IDF_LOGO2);
+ m_logoids.AddTail(IDF_LOGO3);
+ m_logoids.AddTail(IDF_LOGO4);
+ m_logoids.AddTail(IDF_LOGO5);
+ m_logoids.AddTail(IDF_LOGO6);
+ m_logoids.AddTail(IDF_LOGO7);
}
CPPageLogo::~CPPageLogo()
@@ -52,19 +52,19 @@ CPPageLogo::~CPPageLogo()
void CPPageLogo::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_RADIO1, m_intext);
- DDX_Text(pDX, IDC_LOGOFILENAME, m_logofn);
- DDX_Control(pDX, IDC_LOGOPREVIEW, m_logopreview);
- DDX_Text(pDX, IDC_AUTHOR, m_author);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_RADIO1, m_intext);
+ DDX_Text(pDX, IDC_LOGOFILENAME, m_logofn);
+ DDX_Control(pDX, IDC_LOGOPREVIEW, m_logopreview);
+ DDX_Text(pDX, IDC_AUTHOR, m_author);
}
BEGIN_MESSAGE_MAP(CPPageLogo, CPPageBase)
- ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio1)
- ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2)
- ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio1)
+ ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2)
+ ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
END_MESSAGE_MAP()
@@ -72,125 +72,125 @@ END_MESSAGE_MAP()
BOOL CPPageLogo::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_intext = s.logoext ? 1 : 0;
- m_logofn = s.logofn;
- m_logoidpos = NULL;
+ m_intext = s.logoext?1:0;
+ m_logofn = s.logofn;
+ m_logoidpos = NULL;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- for(POSITION pos = m_logoids.GetHeadPosition(); pos; m_logoids.GetNext(pos))
- {
- if(m_logoids.GetAt(pos) == s.logoid)
- {
- m_logoidpos = pos;
- break;
- }
- }
+ for(POSITION pos = m_logoids.GetHeadPosition(); pos; m_logoids.GetNext(pos))
+ {
+ if(m_logoids.GetAt(pos) == s.logoid)
+ {
+ m_logoidpos = pos;
+ break;
+ }
+ }
- if(!m_intext) OnBnClickedRadio1();
- else OnBnClickedRadio2();
+ if(!m_intext) OnBnClickedRadio1();
+ else OnBnClickedRadio2();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageLogo::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.logoext = !!m_intext;
- s.logofn = m_logofn;
- s.logoid = m_logoids.GetAt(m_logoidpos);
+ s.logoext = !!m_intext;
+ s.logofn = m_logofn;
+ s.logoid = m_logoids.GetAt(m_logoidpos);
- ((CMainFrame*)AfxGetMainWnd())->m_wndView.LoadLogo();
+ ((CMainFrame*)AfxGetMainWnd())->m_wndView.LoadLogo();
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageLogo::OnBnClickedRadio1()
{
- ASSERT(m_logoidpos);
+ ASSERT(m_logoidpos);
- m_author.Empty();
+ m_author.Empty();
- m_logobm.Destroy();
- UINT id = m_logoids.GetAt(m_logoidpos);
- if(IDF_LOGO0 != id)
- {
- m_logobm.LoadFromResource(id);
- // m_logobm.LoadFromResource(::AfxGetInstanceHandle(), id);
- if(!m_author.LoadString(id)) m_author = ResStr(IDS_LOGO_AUTOR);
- }
- m_logopreview.SetBitmap(m_logobm);
- Invalidate();
+ m_logobm.Destroy();
+ UINT id = m_logoids.GetAt(m_logoidpos);
+ if(IDF_LOGO0 != id)
+ {
+ m_logobm.LoadFromResource(id);
+ // m_logobm.LoadFromResource(::AfxGetInstanceHandle(), id);
+ if(!m_author.LoadString(id)) m_author = ResStr(IDS_LOGO_AUTOR);
+ }
+ m_logopreview.SetBitmap(m_logobm);
+ Invalidate();
- m_intext = 0;
- UpdateData(FALSE);
+ m_intext = 0;
+ UpdateData(FALSE);
- SetModified();
+ SetModified();
}
void CPPageLogo::OnBnClickedRadio2()
{
- UpdateData();
+ UpdateData();
- m_author.Empty();
+ m_author.Empty();
- m_logobm.Destroy();
- if(AfxGetAppSettings().fXpOrBetter)
- m_logobm.Load(m_logofn);
- else if(HANDLE h = LoadImage(NULL, m_logofn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE))
- m_logobm.Attach((HBITMAP)h);
- m_logopreview.SetBitmap(m_logobm);
- Invalidate();
+ m_logobm.Destroy();
+ if(AfxGetAppSettings().fXpOrBetter)
+ m_logobm.Load(m_logofn);
+ else if(HANDLE h = LoadImage(NULL, m_logofn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE))
+ m_logobm.Attach((HBITMAP)h);
+ m_logopreview.SetBitmap(m_logobm);
+ Invalidate();
- m_intext = 1;
- UpdateData(FALSE);
+ m_intext = 1;
+ UpdateData(FALSE);
- SetModified();
+ SetModified();
}
void CPPageLogo::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
{
- LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
-
- if(pNMUpDown->iDelta < 0)
- {
- m_logoids.GetNext(m_logoidpos);
- if(!m_logoidpos) m_logoidpos = m_logoids.GetHeadPosition();
- }
- else
- {
- m_logoids.GetPrev(m_logoidpos);
- if(!m_logoidpos) m_logoidpos = m_logoids.GetTailPosition();
- }
-
- OnBnClickedRadio1();
-
- *pResult = 0;
+ LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
+
+ if(pNMUpDown->iDelta < 0)
+ {
+ m_logoids.GetNext(m_logoidpos);
+ if(!m_logoidpos) m_logoidpos = m_logoids.GetHeadPosition();
+ }
+ else
+ {
+ m_logoids.GetPrev(m_logoidpos);
+ if(!m_logoidpos) m_logoidpos = m_logoids.GetTailPosition();
+ }
+
+ OnBnClickedRadio1();
+
+ *pResult = 0;
}
void CPPageLogo::OnBnClickedButton2()
{
- CFileDialog dlg(TRUE, NULL, m_logofn,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
- AfxGetAppSettings().fXpOrBetter
- ? _T("Images (*.bmp;*.jpg;*.gif;*.png)|*.bmp;*.jpg;*.gif;*.png|All files (*.*)|*.*||")
- : _T("Images (*.bmp)|*.bmp|All files (*.*)|*.*||")
- , this, 0);
-
- if(dlg.DoModal() == IDOK)
- {
- m_logofn = dlg.GetPathName();
- UpdateData(FALSE);
- OnBnClickedRadio2();
- }
+ CFileDialog dlg(TRUE, NULL, m_logofn,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ AfxGetAppSettings().fXpOrBetter
+ ? _T("Images (*.bmp;*.jpg;*.gif;*.png)|*.bmp;*.jpg;*.gif;*.png|All files (*.*)|*.*||")
+ : _T("Images (*.bmp)|*.bmp|All files (*.*)|*.*||")
+ , this, 0);
+
+ if(dlg.DoModal() == IDOK)
+ {
+ m_logofn = dlg.GetPathName();
+ UpdateData(FALSE);
+ OnBnClickedRadio2();
+ }
}
diff --git a/src/apps/mplayerc/PPageLogo.h b/src/apps/mplayerc/PPageLogo.h
index 6c7c0263c..54cb17716 100644
--- a/src/apps/mplayerc/PPageLogo.h
+++ b/src/apps/mplayerc/PPageLogo.h
@@ -30,34 +30,34 @@
class CPPageLogo : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageLogo)
+ DECLARE_DYNAMIC(CPPageLogo)
private:
- CList<UINT> m_logoids;
- POSITION m_logoidpos;
- CPngImage m_logobm;
+ CList<UINT> m_logoids;
+ POSITION m_logoidpos;
+ CPngImage m_logobm;
public:
- CPPageLogo();
- virtual ~CPPageLogo();
+ CPPageLogo();
+ virtual ~CPPageLogo();
// Dialog Data
- enum { IDD = IDD_PPAGELOGO };
- int m_intext;
- CString m_logofn;
- CStatic m_logopreview;
+ enum { IDD = IDD_PPAGELOGO };
+ int m_intext;
+ CString m_logofn;
+ CStatic m_logopreview;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedRadio1();
- afx_msg void OnBnClickedRadio2();
- afx_msg void OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBnClickedButton2();
- CString m_author;
+ afx_msg void OnBnClickedRadio1();
+ afx_msg void OnBnClickedRadio2();
+ afx_msg void OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnBnClickedButton2();
+ CString m_author;
};
diff --git a/src/apps/mplayerc/PPageOutput.cpp b/src/apps/mplayerc/PPageOutput.cpp
index d3977b079..24a26a085 100644
--- a/src/apps/mplayerc/PPageOutput.cpp
+++ b/src/apps/mplayerc/PPageOutput.cpp
@@ -33,22 +33,22 @@
IMPLEMENT_DYNAMIC(CPPageOutput, CPPageBase)
CPPageOutput::CPPageOutput()
- : CPPageBase(CPPageOutput::IDD, CPPageOutput::IDD)
- , m_iDSVideoRendererType(0)
- , m_iRMVideoRendererType(0)
- , m_iQTVideoRendererType(0)
- , m_iAPSurfaceUsage(0)
- , m_iAudioRendererType(0)
+ : CPPageBase(CPPageOutput::IDD, CPPageOutput::IDD)
+ , m_iDSVideoRendererType(0)
+ , m_iRMVideoRendererType(0)
+ , m_iQTVideoRendererType(0)
+ , m_iAPSurfaceUsage(0)
+ , m_iAudioRendererType(0)
// , m_fVMRSyncFix(FALSE)
- , m_iDX9Resizer(0)
- , m_fVMR9MixerMode(FALSE)
- , m_fVMR9MixerYUV(FALSE)
- , m_fVMR9AlterativeVSync(FALSE)
- , m_fResetDevice(FALSE)
- , m_iEvrBuffers(L"5")
- , m_fD3DFullscreen(FALSE)
- , m_fD3D9RenderDevice(FALSE)
- , m_iD3D9RenderDevice(-1)
+ , m_iDX9Resizer(0)
+ , m_fVMR9MixerMode(FALSE)
+ , m_fVMR9MixerYUV(FALSE)
+ , m_fVMR9AlterativeVSync(FALSE)
+ , m_fResetDevice(FALSE)
+ , m_iEvrBuffers(L"5")
+ , m_fD3DFullscreen(FALSE)
+ , m_fD3D9RenderDevice(FALSE)
+ , m_iD3D9RenderDevice(-1)
{
}
@@ -58,385 +58,385 @@ CPPageOutput::~CPPageOutput()
void CPPageOutput::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_DSSYSDEF, m_iDSVideoRendererType);
- DDX_Radio(pDX, IDC_RMSYSDEF, m_iRMVideoRendererType);
- DDX_Radio(pDX, IDC_QTSYSDEF, m_iQTVideoRendererType);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_DSSYSDEF, m_iDSVideoRendererType);
+ DDX_Radio(pDX, IDC_RMSYSDEF, m_iRMVideoRendererType);
+ DDX_Radio(pDX, IDC_QTSYSDEF, m_iQTVideoRendererType);
// DDX_Radio(pDX, IDC_REGULARSURF, m_iAPSurfaceUsage);
- DDX_CBIndex(pDX, IDC_DX_SURFACE, m_iAPSurfaceUsage);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iAudioRendererType);
- DDX_Control(pDX, IDC_COMBO1, m_iAudioRendererTypeCtrl);
+ DDX_CBIndex(pDX, IDC_DX_SURFACE, m_iAPSurfaceUsage);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iAudioRendererType);
+ DDX_Control(pDX, IDC_COMBO1, m_iAudioRendererTypeCtrl);
// DDX_Check(pDX, IDC_CHECK1, m_fVMRSyncFix);
- DDX_CBIndex(pDX, IDC_DX9RESIZER_COMBO, m_iDX9Resizer);
- DDX_Check(pDX, IDC_DSVMR9LOADMIXER, m_fVMR9MixerMode);
- DDX_Check(pDX, IDC_DSVMR9YUVMIXER, m_fVMR9MixerYUV);
- DDX_Check(pDX, IDC_DSVMR9ALTERNATIVEVSYNC, m_fVMR9AlterativeVSync);
- DDX_Check(pDX, IDC_RESETDEVICE, m_fResetDevice);
- DDX_Check(pDX, IDC_FULLSCREEN_MONITOR_CHECK, m_fD3DFullscreen);
-
- DDX_CBString(pDX, IDC_EVR_BUFFERS, m_iEvrBuffers);
-
- DDX_Check(pDX, IDC_D3D9DEVICE, m_fD3D9RenderDevice);
- DDX_CBIndex(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDevice);
- DDX_Control(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDeviceCtrl);
+ DDX_CBIndex(pDX, IDC_DX9RESIZER_COMBO, m_iDX9Resizer);
+ DDX_Check(pDX, IDC_DSVMR9LOADMIXER, m_fVMR9MixerMode);
+ DDX_Check(pDX, IDC_DSVMR9YUVMIXER, m_fVMR9MixerYUV);
+ DDX_Check(pDX, IDC_DSVMR9ALTERNATIVEVSYNC, m_fVMR9AlterativeVSync);
+ DDX_Check(pDX, IDC_RESETDEVICE, m_fResetDevice);
+ DDX_Check(pDX, IDC_FULLSCREEN_MONITOR_CHECK, m_fD3DFullscreen);
+
+ DDX_CBString(pDX, IDC_EVR_BUFFERS, m_iEvrBuffers);
+
+ DDX_Check(pDX, IDC_D3D9DEVICE, m_fD3D9RenderDevice);
+ DDX_CBIndex(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDevice);
+ DDX_Control(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDeviceCtrl);
}
BEGIN_MESSAGE_MAP(CPPageOutput, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_DSVMR9YUVMIXER, OnUpdateMixerYUV)
- ON_CBN_SELCHANGE(IDC_DX_SURFACE, &CPPageOutput::OnSurfaceChange)
- ON_CONTROL_RANGE(BN_CLICKED, IDC_DSSYSDEF, IDC_DSSYNC, &CPPageOutput::OnDSRendererChange)
- ON_BN_CLICKED(IDC_FULLSCREEN_MONITOR_CHECK, OnFullscreenCheck)
- ON_BN_CLICKED(IDC_D3D9DEVICE, OnD3D9DeviceCheck)
+ ON_UPDATE_COMMAND_UI(IDC_DSVMR9YUVMIXER, OnUpdateMixerYUV)
+ ON_CBN_SELCHANGE(IDC_DX_SURFACE, &CPPageOutput::OnSurfaceChange)
+ ON_CONTROL_RANGE(BN_CLICKED, IDC_DSSYSDEF, IDC_DSSYNC, &CPPageOutput::OnDSRendererChange)
+ ON_BN_CLICKED(IDC_FULLSCREEN_MONITOR_CHECK, OnFullscreenCheck)
+ ON_BN_CLICKED(IDC_D3D9DEVICE, OnD3D9DeviceCheck)
END_MESSAGE_MAP()
void CPPageOutput::DisableRadioButton(UINT nID, UINT nDefID)
{
- if(IsDlgButtonChecked(nID))
- {
- CheckDlgButton(nID, BST_UNCHECKED);
- CheckDlgButton(nDefID, BST_CHECKED);
- }
+ if(IsDlgButtonChecked(nID))
+ {
+ CheckDlgButton(nID, BST_UNCHECKED);
+ CheckDlgButton(nDefID, BST_CHECKED);
+ }
- GetDlgItem(nID)->EnableWindow(FALSE);
+ GetDlgItem(nID)->EnableWindow(FALSE);
}
// CPPageOutput message handlers
BOOL CPPageOutput::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- SetHandCursor(m_hWnd, IDC_COMBO1);
+ SetHandCursor(m_hWnd, IDC_COMBO1);
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_iDSVideoRendererType = s.iDSVideoRendererType;
- m_iRMVideoRendererType = s.iRMVideoRendererType;
- m_iQTVideoRendererType = s.iQTVideoRendererType;
- m_iAPSurfaceUsage = s.iAPSurfaceUsage;
+ m_iDSVideoRendererType = s.iDSVideoRendererType;
+ m_iRMVideoRendererType = s.iRMVideoRendererType;
+ m_iQTVideoRendererType = s.iQTVideoRendererType;
+ m_iAPSurfaceUsage = s.iAPSurfaceUsage;
// m_fVMRSyncFix = s.fVMRSyncFix;
- m_iDX9Resizer = s.iDX9Resizer;
- m_fVMR9MixerMode = s.fVMR9MixerMode;
- m_fVMR9MixerYUV = s.fVMR9MixerYUV;
- m_fVMR9AlterativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
- m_fD3DFullscreen = s.fD3DFullscreen;
- m_iEvrBuffers.Format(L"%d", s.iEvrBuffers);
-
- m_fResetDevice = s.fResetDevice;
- m_AudioRendererDisplayNames.Add(_T(""));
- m_iAudioRendererTypeCtrl.AddString(_T("1: System Default"));
- m_iAudioRendererType = 0;
-
- int i = 2;
- CString Cbstr;
-
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
- {
- LPOLESTR olestr = NULL;
- if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr)))
- continue;
-
- CStringW str(olestr);
- CoTaskMemFree(olestr);
-
- m_AudioRendererDisplayNames.Add(CString(str));
-
- CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
- {
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
-
- CString fstr(var.bstrVal);
-
- var.Clear();
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL)))
- {
- BSTR* pbstr;
- if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pbstr)))
- {
- fstr.Format(_T("%s (%08x)"), CString(fstr), *((DWORD*)pbstr + 1));
- SafeArrayUnaccessData(var.parray);
- }
- }
- Cbstr.Format(_T("%d: %s"), i, fstr);
- }
- else
- {
- Cbstr.Format(_T("%d: %s"), i, CString(str));
- }
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
-
- if(s.AudioRendererDisplayName == str && m_iAudioRendererType == 0)
- {
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
- }
- i++;
- }
- EndEnumSysDev
-
- Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_COMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
- if(s.AudioRendererDisplayName == AUDRNDT_NULL_COMP && m_iAudioRendererType == 0)
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
-
- Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_UNCOMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
- if(s.AudioRendererDisplayName == AUDRNDT_NULL_UNCOMP && m_iAudioRendererType == 0)
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
-
- Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_MPC);
- m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
- if(s.AudioRendererDisplayName == AUDRNDT_MPC && m_iAudioRendererType == 0)
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
-
-
- CorrectComboListWidth(m_iAudioRendererTypeCtrl, GetFont());
-
- //
- IDirect3D9* pD3D;
- if(pD3D = Direct3DCreate9(D3D_SDK_VERSION))
- {
- TCHAR strGUID[50];
- CString cstrGUID;
- CString d3ddevice_str = _T("");
- CStringArray adapterList;
-
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
-
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
- if(pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
- {
- d3ddevice_str = adapterIdentifier.Description;
- d3ddevice_str += _T(" - ");
- d3ddevice_str += adapterIdentifier.DeviceName;
- cstrGUID = _T("");
- if(::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0)
- {
- cstrGUID = strGUID;
- }
- if((cstrGUID != _T("")))
- {
- boolean m_find = false;
- for(i = 0; !m_find, i < m_D3D9GUIDNames.GetCount(); i++)
- {
- if(m_D3D9GUIDNames.GetAt(i) == cstrGUID) m_find = true;
- }
- if(!m_find)
- {
- m_iD3D9RenderDeviceCtrl.AddString(d3ddevice_str);
- m_D3D9GUIDNames.Add(cstrGUID);
- if(s.D3D9RenderDevice == cstrGUID)
- m_iD3D9RenderDevice = m_iD3D9RenderDeviceCtrl.GetCount() - 1;
- }
- }
- }
- }
- pD3D->Release();
- }
-
- CorrectComboListWidth(m_iD3D9RenderDeviceCtrl, GetFont());
-
- UpdateData(FALSE);
-
- if(!IsCLSIDRegistered(CLSID_VideoMixingRenderer))
- {
- DisableRadioButton(IDC_DSVMR7WIN, IDC_DSSYSDEF);
- DisableRadioButton(IDC_DSVMR7REN, IDC_DSSYSDEF);
- }
-
- if(!IsCLSIDRegistered(CLSID_VideoMixingRenderer9))
- {
- DisableRadioButton(IDC_DSVMR9WIN, IDC_DSSYSDEF);
- DisableRadioButton(IDC_DSVMR9REN, IDC_DSSYSDEF);
- DisableRadioButton(IDC_RMDX9, IDC_RMSYSDEF);
- DisableRadioButton(IDC_QTDX9, IDC_QTSYSDEF);
- }
-
- if(!IsCLSIDRegistered(CLSID_EnhancedVideoRenderer))
- {
- DisableRadioButton(IDC_EVR, IDC_DSSYSDEF);
- DisableRadioButton(IDC_EVR_CUSTOM, IDC_DSSYSDEF);
- }
-
- if(!IsCLSIDRegistered(CLSID_DXR))
- {
- DisableRadioButton(IDC_DSDXR, IDC_DSSYSDEF);
- }
-
- if(!IsCLSIDRegistered(CLSID_madVR))
- {
- DisableRadioButton(IDC_DSMADVR, IDC_DSSYSDEF);
- }
-
- // YUV mixing is not compatible with Vista
- if(AfxGetMyApp()->IsVistaOrAbove())
- {
- GetDlgItem(IDC_DSVMR9YUVMIXER)->ShowWindow(SW_HIDE);
- }
-
- OnDSRendererChange(m_iDSVideoRendererType + IDC_DSSYSDEF);
-
- CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
-
- if((m_iDSVideoRendererType == 6 || m_iDSVideoRendererType == 11) && (m_iD3D9RenderDeviceCtrl.GetCount() > 1))
- {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
- CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
- if(m_iD3D9RenderDevice != -1)
- {
- CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
- }
- }
- else
- {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
- if(m_iD3D9RenderDevice == -1)
- CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
- }
- UpdateData(TRUE);
-
- CreateToolTip();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ m_iDX9Resizer = s.iDX9Resizer;
+ m_fVMR9MixerMode = s.fVMR9MixerMode;
+ m_fVMR9MixerYUV = s.fVMR9MixerYUV;
+ m_fVMR9AlterativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
+ m_fD3DFullscreen = s.fD3DFullscreen;
+ m_iEvrBuffers.Format(L"%d", s.iEvrBuffers);
+
+ m_fResetDevice = s.fResetDevice;
+ m_AudioRendererDisplayNames.Add(_T(""));
+ m_iAudioRendererTypeCtrl.AddString(_T("1: System Default"));
+ m_iAudioRendererType = 0;
+
+ int i=2;
+ CString Cbstr;
+
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
+ {
+ LPOLESTR olestr = NULL;
+ if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr)))
+ continue;
+
+ CStringW str(olestr);
+ CoTaskMemFree(olestr);
+
+ m_AudioRendererDisplayNames.Add(CString(str));
+
+ CComPtr<IPropertyBag> pPB;
+ if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
+ {
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+
+ CString fstr(var.bstrVal);
+
+ var.Clear();
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL)))
+ {
+ BSTR* pbstr;
+ if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pbstr)))
+ {
+ fstr.Format(_T("%s (%08x)"), CString(fstr), *((DWORD*)pbstr + 1));
+ SafeArrayUnaccessData(var.parray);
+ }
+ }
+ Cbstr.Format(_T("%d: %s"), i, fstr);
+ }
+ else
+ {
+ Cbstr.Format(_T("%d: %s"), i, CString(str));
+ }
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+
+ if(s.AudioRendererDisplayName == str && m_iAudioRendererType == 0)
+ {
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
+ }
+ i++;
+ }
+ EndEnumSysDev
+
+ Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_COMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+ if(s.AudioRendererDisplayName == AUDRNDT_NULL_COMP && m_iAudioRendererType == 0)
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
+
+ Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_UNCOMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+ if(s.AudioRendererDisplayName == AUDRNDT_NULL_UNCOMP && m_iAudioRendererType == 0)
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
+
+ Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_MPC);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+ if(s.AudioRendererDisplayName == AUDRNDT_MPC && m_iAudioRendererType == 0)
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
+
+
+ CorrectComboListWidth(m_iAudioRendererTypeCtrl, GetFont());
+
+ //
+ IDirect3D9* pD3D;
+ if (pD3D = Direct3DCreate9(D3D_SDK_VERSION))
+ {
+ TCHAR strGUID[50];
+ CString cstrGUID;
+ CString d3ddevice_str = _T("");
+ CStringArray adapterList;
+
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
+ {
+ if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
+ {
+ d3ddevice_str = adapterIdentifier.Description;
+ d3ddevice_str += _T(" - ");
+ d3ddevice_str += adapterIdentifier.DeviceName;
+ cstrGUID = _T("");
+ if (::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0)
+ {
+ cstrGUID = strGUID;
+ }
+ if((cstrGUID != _T("")))
+ {
+ boolean m_find = false;
+ for(i = 0; !m_find, i < m_D3D9GUIDNames.GetCount(); i++)
+ {
+ if(m_D3D9GUIDNames.GetAt(i) == cstrGUID) m_find = true;
+ }
+ if(!m_find)
+ {
+ m_iD3D9RenderDeviceCtrl.AddString(d3ddevice_str);
+ m_D3D9GUIDNames.Add(cstrGUID);
+ if (s.D3D9RenderDevice == cstrGUID)
+ m_iD3D9RenderDevice = m_iD3D9RenderDeviceCtrl.GetCount()-1;
+ }
+ }
+ }
+ }
+ pD3D->Release();
+ }
+
+ CorrectComboListWidth(m_iD3D9RenderDeviceCtrl, GetFont());
+
+ UpdateData(FALSE);
+
+ if(!IsCLSIDRegistered(CLSID_VideoMixingRenderer))
+ {
+ DisableRadioButton(IDC_DSVMR7WIN, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_DSVMR7REN, IDC_DSSYSDEF);
+ }
+
+ if(!IsCLSIDRegistered(CLSID_VideoMixingRenderer9))
+ {
+ DisableRadioButton(IDC_DSVMR9WIN, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_DSVMR9REN, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_RMDX9, IDC_RMSYSDEF);
+ DisableRadioButton(IDC_QTDX9, IDC_QTSYSDEF);
+ }
+
+ if(!IsCLSIDRegistered(CLSID_EnhancedVideoRenderer))
+ {
+ DisableRadioButton(IDC_EVR, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_EVR_CUSTOM, IDC_DSSYSDEF);
+ }
+
+ if(!IsCLSIDRegistered(CLSID_DXR))
+ {
+ DisableRadioButton(IDC_DSDXR, IDC_DSSYSDEF);
+ }
+
+ if(!IsCLSIDRegistered(CLSID_madVR))
+ {
+ DisableRadioButton(IDC_DSMADVR, IDC_DSSYSDEF);
+ }
+
+ // YUV mixing is not compatible with Vista
+ if (AfxGetMyApp()->IsVistaOrAbove())
+ {
+ GetDlgItem(IDC_DSVMR9YUVMIXER)->ShowWindow (SW_HIDE);
+ }
+
+ OnDSRendererChange (m_iDSVideoRendererType + IDC_DSSYSDEF);
+
+ CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
+
+ if((m_iDSVideoRendererType == 6 || m_iDSVideoRendererType == 11) && (m_iD3D9RenderDeviceCtrl.GetCount() > 1))
+ {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
+ CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
+ if(m_iD3D9RenderDevice != -1)
+ {
+ CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
+ }
+ }
+ else
+ {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
+ if(m_iD3D9RenderDevice == -1)
+ CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
+ }
+ UpdateData(TRUE);
+
+ CreateToolTip();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageOutput::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.iDSVideoRendererType = m_iDSVideoRendererType;
- s.iRMVideoRendererType = m_iRMVideoRendererType;
- s.iQTVideoRendererType = m_iQTVideoRendererType;
- s.iAPSurfaceUsage = m_iAPSurfaceUsage;
+ s.iDSVideoRendererType = m_iDSVideoRendererType;
+ s.iRMVideoRendererType = m_iRMVideoRendererType;
+ s.iQTVideoRendererType = m_iQTVideoRendererType;
+ s.iAPSurfaceUsage = m_iAPSurfaceUsage;
// s.fVMRSyncFix = !!m_fVMRSyncFix;
- s.AudioRendererDisplayName = m_AudioRendererDisplayNames[m_iAudioRendererType];
- s.iDX9Resizer = m_iDX9Resizer;
- s.fVMR9MixerMode = !!m_fVMR9MixerMode;
- s.fVMR9MixerYUV = !!m_fVMR9MixerYUV;
- s.m_RenderSettings.fVMR9AlterativeVSync = m_fVMR9AlterativeVSync != 0;
- s.fD3DFullscreen = m_fD3DFullscreen ? true : false;
-
- s.fResetDevice = !!m_fResetDevice;
-
- if(!m_iEvrBuffers.IsEmpty())
- {
- int Temp = 5;
- swscanf(m_iEvrBuffers.GetBuffer(), L"%d", &Temp);
- s.iEvrBuffers = Temp;
- }
- else
- s.iEvrBuffers = 5;
-
- s.D3D9RenderDevice = m_fD3D9RenderDevice ? m_D3D9GUIDNames[m_iD3D9RenderDevice] : _T("");
-
- return __super::OnApply();
+ s.AudioRendererDisplayName = m_AudioRendererDisplayNames[m_iAudioRendererType];
+ s.iDX9Resizer = m_iDX9Resizer;
+ s.fVMR9MixerMode = !!m_fVMR9MixerMode;
+ s.fVMR9MixerYUV = !!m_fVMR9MixerYUV;
+ s.m_RenderSettings.fVMR9AlterativeVSync = m_fVMR9AlterativeVSync != 0;
+ s.fD3DFullscreen = m_fD3DFullscreen ? true : false;
+
+ s.fResetDevice = !!m_fResetDevice;
+
+ if (!m_iEvrBuffers.IsEmpty())
+ {
+ int Temp = 5;
+ swscanf(m_iEvrBuffers.GetBuffer(), L"%d", &Temp);
+ s.iEvrBuffers = Temp;
+ }
+ else
+ s.iEvrBuffers = 5;
+
+ s.D3D9RenderDevice = m_fD3D9RenderDevice ? m_D3D9GUIDNames[m_iD3D9RenderDevice] : _T("");
+
+ return __super::OnApply();
}
void CPPageOutput::OnUpdateMixerYUV(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_DSVMR9LOADMIXER) && IsDlgButtonChecked(IDC_DSVMR9REN));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_DSVMR9LOADMIXER) && IsDlgButtonChecked(IDC_DSVMR9REN));
}
void CPPageOutput::OnSurfaceChange()
{
- SetModified();
+ SetModified();
}
void CPPageOutput::OnDSRendererChange(UINT nIDbutton)
{
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
- GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(FALSE);
- GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(FALSE);
- GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(FALSE);
- GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(FALSE);
- GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(FALSE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(FALSE);
+ GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(FALSE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(FALSE);
// GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
- GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
- GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
-
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
-
- switch(nIDbutton - IDC_DSSYSDEF)
- {
- case 6 : // VMR9 renderless
- if(m_iD3D9RenderDeviceCtrl.GetCount() > 1)
- {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
- }
-
- GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(TRUE);
- GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(TRUE);
- GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
- case 11 : // EVR custom presenter
- if(m_iD3D9RenderDeviceCtrl.GetCount() > 1)
- {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
- }
-
- GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
- GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
+ GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
+ GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
+
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
+
+ switch (nIDbutton - IDC_DSSYSDEF)
+ {
+ case 6 : // VMR9 renderless
+ if(m_iD3D9RenderDeviceCtrl.GetCount()>1)
+ {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
+ }
+
+ GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
+ case 11 : // EVR custom presenter
+ if(m_iD3D9RenderDeviceCtrl.GetCount()>1)
+ {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
+ }
+
+ GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
+ GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
// GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE); // Lock back buffer
- GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
-
- // Force 3D surface with EVR Custom
- if(nIDbutton - IDC_DSSYSDEF == 11)
- {
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
- ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
- }
- else
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
- break;
- case 13 : // Sync Renderer
- GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow(TRUE);
- GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow(TRUE);
- GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
- GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
- ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
- break;
- case 5 : // VMR7 renderless
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
- break;
- }
-
- SetModified();
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
+
+ // Force 3D surface with EVR Custom
+ if (nIDbutton - IDC_DSSYSDEF == 11)
+ {
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
+ ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
+ }
+ else
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
+ break;
+ case 13 : // Sync Renderer
+ GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow(TRUE);
+ GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
+ GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
+ ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
+ break;
+ case 5 : // VMR7 renderless
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
+ break;
+ }
+
+ SetModified();
}
void CPPageOutput::OnFullscreenCheck()
{
- UpdateData();
- if(m_fD3DFullscreen &&
- (MessageBox(ResStr(IDS_D3DFS_WARNING), NULL, MB_YESNO) == IDNO))
- {
- m_fD3DFullscreen = false;
- UpdateData(FALSE);
- }
- SetModified();
+ UpdateData();
+ if (m_fD3DFullscreen &&
+ (MessageBox(ResStr(IDS_D3DFS_WARNING), NULL, MB_YESNO) == IDNO))
+ {
+ m_fD3DFullscreen = false;
+ UpdateData(FALSE);
+ }
+ SetModified();
}
void CPPageOutput::OnD3D9DeviceCheck()
{
- UpdateData();
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(m_fD3D9RenderDevice);
- SetModified();
+ UpdateData();
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(m_fD3D9RenderDevice);
+ SetModified();
} \ No newline at end of file
diff --git a/src/apps/mplayerc/PPageOutput.h b/src/apps/mplayerc/PPageOutput.h
index 6dd59a5c9..635450e2c 100644
--- a/src/apps/mplayerc/PPageOutput.h
+++ b/src/apps/mplayerc/PPageOutput.h
@@ -32,50 +32,50 @@
class CPPageOutput : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageOutput)
+ DECLARE_DYNAMIC(CPPageOutput)
private:
- CStringArray m_AudioRendererDisplayNames;
- CStringArray m_D3D9GUIDNames;
+ CStringArray m_AudioRendererDisplayNames;
+ CStringArray m_D3D9GUIDNames;
- void DisableRadioButton(UINT nID, UINT nDefID);
+ void DisableRadioButton(UINT nID, UINT nDefID);
public:
- CPPageOutput();
- virtual ~CPPageOutput();
+ CPPageOutput();
+ virtual ~CPPageOutput();
// Dialog Data
- enum { IDD = IDD_PPAGEOUTPUT };
- int m_iDSVideoRendererType;
- int m_iRMVideoRendererType;
- int m_iQTVideoRendererType;
- int m_iAPSurfaceUsage;
- int m_iAudioRendererType;
- CComboBox m_iAudioRendererTypeCtrl;
+ enum { IDD = IDD_PPAGEOUTPUT };
+ int m_iDSVideoRendererType;
+ int m_iRMVideoRendererType;
+ int m_iQTVideoRendererType;
+ int m_iAPSurfaceUsage;
+ int m_iAudioRendererType;
+ CComboBox m_iAudioRendererTypeCtrl;
// BOOL m_fVMRSyncFix;
- int m_iDX9Resizer;
- BOOL m_fVMR9MixerMode;
- BOOL m_fVMR9MixerYUV;
- BOOL m_fD3DFullscreen;
- BOOL m_fVMR9AlterativeVSync;
- BOOL m_fResetDevice;
- CString m_iEvrBuffers;
- //
- BOOL m_fD3D9RenderDevice;
- int m_iD3D9RenderDevice;
- CComboBox m_iD3D9RenderDeviceCtrl;
+ int m_iDX9Resizer;
+ BOOL m_fVMR9MixerMode;
+ BOOL m_fVMR9MixerYUV;
+ BOOL m_fD3DFullscreen;
+ BOOL m_fVMR9AlterativeVSync;
+ BOOL m_fResetDevice;
+ CString m_iEvrBuffers;
+ //
+ BOOL m_fD3D9RenderDevice;
+ int m_iD3D9RenderDevice;
+ CComboBox m_iD3D9RenderDeviceCtrl;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateMixerYUV(CCmdUI* pCmdUI);
- afx_msg void OnSurfaceChange();
- afx_msg void OnDSRendererChange(UINT nIDbutton);
- afx_msg void OnFullscreenCheck();
- afx_msg void OnD3D9DeviceCheck();
+ afx_msg void OnUpdateMixerYUV(CCmdUI* pCmdUI);
+ afx_msg void OnSurfaceChange();
+ afx_msg void OnDSRendererChange(UINT nIDbutton);
+ afx_msg void OnFullscreenCheck();
+ afx_msg void OnD3D9DeviceCheck();
};
diff --git a/src/apps/mplayerc/PPagePlayback.cpp b/src/apps/mplayerc/PPagePlayback.cpp
index 6a012c56c..cdacd0a2b 100644
--- a/src/apps/mplayerc/PPagePlayback.cpp
+++ b/src/apps/mplayerc/PPagePlayback.cpp
@@ -34,20 +34,20 @@
IMPLEMENT_DYNAMIC(CPPagePlayback, CPPageBase)
CPPagePlayback::CPPagePlayback()
- : CPPageBase(CPPagePlayback::IDD, CPPagePlayback::IDD)
- , m_iLoopForever(0)
- , m_nLoops(0)
- , m_fRewind(FALSE)
- , m_iZoomLevel(0)
- , m_iRememberZoomLevel(FALSE)
- , m_nVolume(0)
- , m_nBalance(0)
- , m_fAutoloadAudio(FALSE)
- , m_fAutoloadSubtitles(FALSE)
- , m_fEnableWorkerThreadForOpening(FALSE)
- , m_fReportFailedPins(FALSE)
- , m_subtitlesLanguageOrder(_T(""))
- , m_audiosLanguageOrder(_T(""))
+ : CPPageBase(CPPagePlayback::IDD, CPPagePlayback::IDD)
+ , m_iLoopForever(0)
+ , m_nLoops(0)
+ , m_fRewind(FALSE)
+ , m_iZoomLevel(0)
+ , m_iRememberZoomLevel(FALSE)
+ , m_nVolume(0)
+ , m_nBalance(0)
+ , m_fAutoloadAudio(FALSE)
+ , m_fAutoloadSubtitles(FALSE)
+ , m_fEnableWorkerThreadForOpening(FALSE)
+ , m_fReportFailedPins(FALSE)
+ , m_subtitlesLanguageOrder(_T(""))
+ , m_audiosLanguageOrder(_T(""))
{
}
@@ -57,31 +57,31 @@ CPPagePlayback::~CPPagePlayback()
void CPPagePlayback::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_SLIDER1, m_volumectrl);
- DDX_Control(pDX, IDC_SLIDER2, m_balancectrl);
- DDX_Slider(pDX, IDC_SLIDER1, m_nVolume);
- DDX_Slider(pDX, IDC_SLIDER2, m_nBalance);
- DDX_Radio(pDX, IDC_RADIO1, m_iLoopForever);
- DDX_Control(pDX, IDC_EDIT1, m_loopnumctrl);
- DDX_Text(pDX, IDC_EDIT1, m_nLoops);
- DDX_Check(pDX, IDC_CHECK1, m_fRewind);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iZoomLevel);
- DDX_Check(pDX, IDC_CHECK5, m_iRememberZoomLevel);
- DDX_Check(pDX, IDC_CHECK2, m_fAutoloadAudio);
- DDX_Check(pDX, IDC_CHECK3, m_fAutoloadSubtitles);
- DDX_Check(pDX, IDC_CHECK7, m_fEnableWorkerThreadForOpening);
- DDX_Check(pDX, IDC_CHECK6, m_fReportFailedPins);
- DDX_Text(pDX, IDC_EDIT2, m_subtitlesLanguageOrder);
- DDX_Text(pDX, IDC_EDIT3, m_audiosLanguageOrder);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_SLIDER1, m_volumectrl);
+ DDX_Control(pDX, IDC_SLIDER2, m_balancectrl);
+ DDX_Slider(pDX, IDC_SLIDER1, m_nVolume);
+ DDX_Slider(pDX, IDC_SLIDER2, m_nBalance);
+ DDX_Radio(pDX, IDC_RADIO1, m_iLoopForever);
+ DDX_Control(pDX, IDC_EDIT1, m_loopnumctrl);
+ DDX_Text(pDX, IDC_EDIT1, m_nLoops);
+ DDX_Check(pDX, IDC_CHECK1, m_fRewind);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iZoomLevel);
+ DDX_Check(pDX, IDC_CHECK5, m_iRememberZoomLevel);
+ DDX_Check(pDX, IDC_CHECK2, m_fAutoloadAudio);
+ DDX_Check(pDX, IDC_CHECK3, m_fAutoloadSubtitles);
+ DDX_Check(pDX, IDC_CHECK7, m_fEnableWorkerThreadForOpening);
+ DDX_Check(pDX, IDC_CHECK6, m_fReportFailedPins);
+ DDX_Text(pDX, IDC_EDIT2, m_subtitlesLanguageOrder);
+ DDX_Text(pDX, IDC_EDIT3, m_audiosLanguageOrder);
}
BEGIN_MESSAGE_MAP(CPPagePlayback, CPPageBase)
- ON_WM_HSCROLL()
- ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO1, IDC_RADIO2, OnBnClickedRadio12)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateLoopNum)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateLoopNum)
- ON_UPDATE_COMMAND_UI(IDC_COMBO1, OnUpdateAutoZoomCombo)
+ ON_WM_HSCROLL()
+ ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO1, IDC_RADIO2, OnBnClickedRadio12)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateLoopNum)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateLoopNum)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO1, OnUpdateAutoZoomCombo)
END_MESSAGE_MAP()
@@ -89,98 +89,98 @@ END_MESSAGE_MAP()
BOOL CPPagePlayback::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_volumectrl.SetRange(1, 100);
- m_volumectrl.SetTicFreq(10);
- m_balancectrl.SetRange(0, 200);
- m_balancectrl.SetTicFreq(20);
- m_nVolume = s.nVolume;
- m_nBalance = s.nBalance + 100;
- m_iLoopForever = s.fLoopForever ? 1 : 0;
- m_nLoops = s.nLoops;
- m_fRewind = s.fRewind;
- m_iZoomLevel = s.iZoomLevel;
- m_iRememberZoomLevel = s.fRememberZoomLevel;
- m_fAutoloadAudio = s.fAutoloadAudio;
- m_fAutoloadSubtitles = s.fAutoloadSubtitles;
- m_fEnableWorkerThreadForOpening = s.fEnableWorkerThreadForOpening;
- m_fReportFailedPins = s.fReportFailedPins;
- m_subtitlesLanguageOrder = s.m_subtitlesLanguageOrder;
- m_audiosLanguageOrder = s.m_audiosLanguageOrder;
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_volumectrl.SetRange(1, 100);
+ m_volumectrl.SetTicFreq(10);
+ m_balancectrl.SetRange(0, 200);
+ m_balancectrl.SetTicFreq(20);
+ m_nVolume = s.nVolume;
+ m_nBalance = s.nBalance+100;
+ m_iLoopForever = s.fLoopForever?1:0;
+ m_nLoops = s.nLoops;
+ m_fRewind = s.fRewind;
+ m_iZoomLevel = s.iZoomLevel;
+ m_iRememberZoomLevel = s.fRememberZoomLevel;
+ m_fAutoloadAudio = s.fAutoloadAudio;
+ m_fAutoloadSubtitles = s.fAutoloadSubtitles;
+ m_fEnableWorkerThreadForOpening = s.fEnableWorkerThreadForOpening;
+ m_fReportFailedPins = s.fReportFailedPins;
+ m_subtitlesLanguageOrder = s.m_subtitlesLanguageOrder;
+ m_audiosLanguageOrder = s.m_audiosLanguageOrder;
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPagePlayback::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.nVolume = m_nVolume;
- s.nBalance = m_nBalance - 100;
- s.fLoopForever = !!m_iLoopForever;
- s.nLoops = m_nLoops;
- s.fRewind = !!m_fRewind;
- s.iZoomLevel = m_iZoomLevel;
- s.fRememberZoomLevel = !!m_iRememberZoomLevel;
- s.fAutoloadAudio = !!m_fAutoloadAudio;
- s.fAutoloadSubtitles = !!m_fAutoloadSubtitles;
- s.fEnableWorkerThreadForOpening = !!m_fEnableWorkerThreadForOpening;
- s.fReportFailedPins = !!m_fReportFailedPins;
- s.m_subtitlesLanguageOrder = m_subtitlesLanguageOrder;
- s.m_audiosLanguageOrder = m_audiosLanguageOrder;
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.nVolume = m_nVolume;
+ s.nBalance = m_nBalance-100;
+ s.fLoopForever = !!m_iLoopForever;
+ s.nLoops = m_nLoops;
+ s.fRewind = !!m_fRewind;
+ s.iZoomLevel = m_iZoomLevel;
+ s.fRememberZoomLevel = !!m_iRememberZoomLevel;
+ s.fAutoloadAudio = !!m_fAutoloadAudio;
+ s.fAutoloadSubtitles = !!m_fAutoloadSubtitles;
+ s.fEnableWorkerThreadForOpening = !!m_fEnableWorkerThreadForOpening;
+ s.fReportFailedPins = !!m_fReportFailedPins;
+ s.m_subtitlesLanguageOrder = m_subtitlesLanguageOrder;
+ s.m_audiosLanguageOrder = m_audiosLanguageOrder;
+
+ return __super::OnApply();
}
LRESULT CPPagePlayback::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_HSCROLL || message == WM_VSCROLL)
- {
- SetModified();
- }
+ if(message == WM_HSCROLL || message == WM_VSCROLL)
+ {
+ SetModified();
+ }
- return __super::DefWindowProc(message, wParam, lParam);
+ return __super::DefWindowProc(message, wParam, lParam);
}
void CPPagePlayback::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(*pScrollBar == m_volumectrl)
- {
- UpdateData();
- ((CMainFrame*)GetParentFrame())->m_wndToolBar.Volume = m_nVolume; // nice shortcut...
- }
- else if(*pScrollBar == m_balancectrl)
- {
- UpdateData();
- ((CMainFrame*)GetParentFrame())->SetBalance(m_nBalance - 100); // see prev note...
- }
-
- SetModified();
-
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ if(*pScrollBar == m_volumectrl)
+ {
+ UpdateData();
+ ((CMainFrame*)GetParentFrame())->m_wndToolBar.Volume = m_nVolume; // nice shortcut...
+ }
+ else if(*pScrollBar == m_balancectrl)
+ {
+ UpdateData();
+ ((CMainFrame*)GetParentFrame())->SetBalance(m_nBalance-100); // see prev note...
+ }
+
+ SetModified();
+
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CPPagePlayback::OnBnClickedRadio12(UINT nID)
{
- SetModified();
+ SetModified();
}
void CPPagePlayback::OnUpdateLoopNum(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_RADIO1));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_RADIO1));
}
void CPPagePlayback::OnUpdateAutoZoomCombo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK5));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK5));
}
diff --git a/src/apps/mplayerc/PPagePlayback.h b/src/apps/mplayerc/PPagePlayback.h
index ed63a11d7..4bb147491 100644
--- a/src/apps/mplayerc/PPagePlayback.h
+++ b/src/apps/mplayerc/PPagePlayback.h
@@ -30,46 +30,46 @@
class CPPagePlayback : public CPPageBase
{
- DECLARE_DYNAMIC(CPPagePlayback)
+ DECLARE_DYNAMIC(CPPagePlayback)
private:
- CAtlArray<dispmode> m_dms;
- CStringArray m_MonitorDisplayNames;
+ CAtlArray<dispmode> m_dms;
+ CStringArray m_MonitorDisplayNames;
public:
- CPPagePlayback();
- virtual ~CPPagePlayback();
+ CPPagePlayback();
+ virtual ~CPPagePlayback();
- CSliderCtrl m_volumectrl;
- CSliderCtrl m_balancectrl;
- int m_nVolume;
- int m_nBalance;
- int m_iLoopForever;
- CEdit m_loopnumctrl;
- int m_nLoops;
- BOOL m_fRewind;
- int m_iZoomLevel;
- BOOL m_iRememberZoomLevel;
- BOOL m_fAutoloadAudio;
- BOOL m_fAutoloadSubtitles;
- BOOL m_fEnableWorkerThreadForOpening;
- BOOL m_fReportFailedPins;
- CString m_subtitlesLanguageOrder;
- CString m_audiosLanguageOrder;
+ CSliderCtrl m_volumectrl;
+ CSliderCtrl m_balancectrl;
+ int m_nVolume;
+ int m_nBalance;
+ int m_iLoopForever;
+ CEdit m_loopnumctrl;
+ int m_nLoops;
+ BOOL m_fRewind;
+ int m_iZoomLevel;
+ BOOL m_iRememberZoomLevel;
+ BOOL m_fAutoloadAudio;
+ BOOL m_fAutoloadSubtitles;
+ BOOL m_fEnableWorkerThreadForOpening;
+ BOOL m_fReportFailedPins;
+ CString m_subtitlesLanguageOrder;
+ CString m_audiosLanguageOrder;
// Dialog Data
- enum { IDD = IDD_PPAGEPLAYBACK };
+ enum { IDD = IDD_PPAGEPLAYBACK };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
- virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+ virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnBnClickedRadio12(UINT nID);
- afx_msg void OnUpdateLoopNum(CCmdUI* pCmdUI);
- afx_msg void OnUpdateAutoZoomCombo(CCmdUI* pCmdUI);
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnBnClickedRadio12(UINT nID);
+ afx_msg void OnUpdateLoopNum(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateAutoZoomCombo(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/PPagePlayer.cpp b/src/apps/mplayerc/PPagePlayer.cpp
index 7de7b331a..85a8e5d06 100644
--- a/src/apps/mplayerc/PPagePlayer.cpp
+++ b/src/apps/mplayerc/PPagePlayer.cpp
@@ -31,23 +31,23 @@
IMPLEMENT_DYNAMIC(CPPagePlayer, CPPageBase)
CPPagePlayer::CPPagePlayer()
- : CPPageBase(CPPagePlayer::IDD, CPPagePlayer::IDD)
- , m_iAllowMultipleInst(0)
- , m_iAlwaysOnTop(FALSE)
- , m_fTrayIcon(FALSE)
- , m_iTitleBarTextStyle(0)
- , m_bTitleBarTextTitle(0)
- , m_fRememberWindowPos(FALSE)
- , m_fRememberWindowSize(FALSE)
- , m_fSnapToDesktopEdges(FALSE)
- , m_fUseIni(FALSE)
- , m_fKeepHistory(FALSE)
- , m_fHideCDROMsSubMenu(FALSE)
- , m_priority(FALSE)
- , m_fShowOSD(FALSE)
- , m_fLimitWindowProportions(TRUE)
- , m_fRememberDVDPos(FALSE)
- , m_fRememberFilePos(FALSE)
+ : CPPageBase(CPPagePlayer::IDD, CPPagePlayer::IDD)
+ , m_iAllowMultipleInst(0)
+ , m_iAlwaysOnTop(FALSE)
+ , m_fTrayIcon(FALSE)
+ , m_iTitleBarTextStyle(0)
+ , m_bTitleBarTextTitle(0)
+ , m_fRememberWindowPos(FALSE)
+ , m_fRememberWindowSize(FALSE)
+ , m_fSnapToDesktopEdges(FALSE)
+ , m_fUseIni(FALSE)
+ , m_fKeepHistory(FALSE)
+ , m_fHideCDROMsSubMenu(FALSE)
+ , m_priority(FALSE)
+ , m_fShowOSD(FALSE)
+ , m_fLimitWindowProportions(TRUE)
+ , m_fRememberDVDPos(FALSE)
+ , m_fRememberFilePos(FALSE)
{
}
@@ -57,126 +57,126 @@ CPPagePlayer::~CPPagePlayer()
void CPPagePlayer::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_RADIO1, m_iAllowMultipleInst);
- DDX_Radio(pDX, IDC_RADIO3, m_iTitleBarTextStyle);
- DDX_Check(pDX, IDC_CHECK13, m_bTitleBarTextTitle);
- DDX_Check(pDX, IDC_CHECK2, m_iAlwaysOnTop);
- DDX_Check(pDX, IDC_CHECK3, m_fTrayIcon);
- DDX_Check(pDX, IDC_CHECK6, m_fRememberWindowPos);
- DDX_Check(pDX, IDC_CHECK7, m_fRememberWindowSize);
- DDX_Check(pDX, IDC_CHECK12, m_fSnapToDesktopEdges);
- DDX_Check(pDX, IDC_CHECK8, m_fUseIni);
- DDX_Check(pDX, IDC_CHECK1, m_fKeepHistory);
- DDX_Check(pDX, IDC_CHECK10, m_fHideCDROMsSubMenu);
- DDX_Check(pDX, IDC_CHECK9, m_priority);
- DDX_Check(pDX, IDC_SHOW_OSD, m_fShowOSD);
- DDX_Check(pDX, IDC_CHECK4, m_fLimitWindowProportions);
- DDX_Check(pDX, IDC_DVD_POS, m_fRememberDVDPos);
- DDX_Check(pDX, IDC_FILE_POS, m_fRememberFilePos);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_RADIO1, m_iAllowMultipleInst);
+ DDX_Radio(pDX, IDC_RADIO3, m_iTitleBarTextStyle);
+ DDX_Check(pDX, IDC_CHECK13, m_bTitleBarTextTitle);
+ DDX_Check(pDX, IDC_CHECK2, m_iAlwaysOnTop);
+ DDX_Check(pDX, IDC_CHECK3, m_fTrayIcon);
+ DDX_Check(pDX, IDC_CHECK6, m_fRememberWindowPos);
+ DDX_Check(pDX, IDC_CHECK7, m_fRememberWindowSize);
+ DDX_Check(pDX, IDC_CHECK12, m_fSnapToDesktopEdges);
+ DDX_Check(pDX, IDC_CHECK8, m_fUseIni);
+ DDX_Check(pDX, IDC_CHECK1, m_fKeepHistory);
+ DDX_Check(pDX, IDC_CHECK10, m_fHideCDROMsSubMenu);
+ DDX_Check(pDX, IDC_CHECK9, m_priority);
+ DDX_Check(pDX, IDC_SHOW_OSD, m_fShowOSD);
+ DDX_Check(pDX, IDC_CHECK4, m_fLimitWindowProportions);
+ DDX_Check(pDX, IDC_DVD_POS, m_fRememberDVDPos);
+ DDX_Check(pDX, IDC_FILE_POS, m_fRememberFilePos);
}
BEGIN_MESSAGE_MAP(CPPagePlayer, CPPageBase)
- ON_BN_CLICKED(IDC_CHECK8, OnBnClickedCheck8)
- ON_UPDATE_COMMAND_UI(IDC_CHECK13, OnUpdateCheck13)
- ON_UPDATE_COMMAND_UI(IDC_DVD_POS, OnUpdatePos)
- ON_UPDATE_COMMAND_UI(IDC_FILE_POS, OnUpdatePos)
+ ON_BN_CLICKED(IDC_CHECK8, OnBnClickedCheck8)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK13, OnUpdateCheck13)
+ ON_UPDATE_COMMAND_UI(IDC_DVD_POS, OnUpdatePos)
+ ON_UPDATE_COMMAND_UI(IDC_FILE_POS, OnUpdatePos)
END_MESSAGE_MAP()
// CPPagePlayer message handlers
BOOL CPPagePlayer::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- m_iAllowMultipleInst = s.fAllowMultipleInst;
- m_iTitleBarTextStyle = s.iTitleBarTextStyle;
- m_bTitleBarTextTitle = s.fTitleBarTextTitle;
- m_iAlwaysOnTop = s.iOnTop;
- m_fTrayIcon = s.fTrayIcon;
- m_fRememberWindowPos = s.fRememberWindowPos;
- m_fRememberWindowSize = s.fRememberWindowSize;
- m_fSnapToDesktopEdges = s.fSnapToDesktopEdges;
- m_fUseIni = ((CMPlayerCApp*)AfxGetApp())->IsIniValid();
- m_fKeepHistory = s.fKeepHistory;
- m_fHideCDROMsSubMenu = s.fHideCDROMsSubMenu;
- m_priority = s.priority != NORMAL_PRIORITY_CLASS;
- m_fShowOSD = s.fShowOSD;
- m_fRememberDVDPos = s.fRememberDVDPos;
- m_fRememberFilePos = s.fRememberFilePos;
- m_fLimitWindowProportions = s.fLimitWindowProportions;
-
- UpdateData(FALSE);
-
- GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
- GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_iAllowMultipleInst = s.fAllowMultipleInst;
+ m_iTitleBarTextStyle = s.iTitleBarTextStyle;
+ m_bTitleBarTextTitle = s.fTitleBarTextTitle;
+ m_iAlwaysOnTop = s.iOnTop;
+ m_fTrayIcon = s.fTrayIcon;
+ m_fRememberWindowPos = s.fRememberWindowPos;
+ m_fRememberWindowSize = s.fRememberWindowSize;
+ m_fSnapToDesktopEdges = s.fSnapToDesktopEdges;
+ m_fUseIni = ((CMPlayerCApp*)AfxGetApp())->IsIniValid();
+ m_fKeepHistory = s.fKeepHistory;
+ m_fHideCDROMsSubMenu = s.fHideCDROMsSubMenu;
+ m_priority = s.priority != NORMAL_PRIORITY_CLASS;
+ m_fShowOSD = s.fShowOSD;
+ m_fRememberDVDPos = s.fRememberDVDPos;
+ m_fRememberFilePos = s.fRememberFilePos;
+ m_fLimitWindowProportions = s.fLimitWindowProportions;
+
+ UpdateData(FALSE);
+
+ GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
+ GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPagePlayer::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.fAllowMultipleInst = !!m_iAllowMultipleInst;
- s.iTitleBarTextStyle = m_iTitleBarTextStyle;
- s.fTitleBarTextTitle = !!m_bTitleBarTextTitle;
- s.iOnTop = m_iAlwaysOnTop;
- s.fTrayIcon = !!m_fTrayIcon;
- s.fRememberWindowPos = !!m_fRememberWindowPos;
- s.fRememberWindowSize = !!m_fRememberWindowSize;
- s.fSnapToDesktopEdges = !!m_fSnapToDesktopEdges;
- s.fKeepHistory = !!m_fKeepHistory;
- s.fHideCDROMsSubMenu = !!m_fHideCDROMsSubMenu;
- s.priority = !m_priority ? NORMAL_PRIORITY_CLASS : GetVersion() < 0 ? HIGH_PRIORITY_CLASS : ABOVE_NORMAL_PRIORITY_CLASS;
- s.fShowOSD = !!m_fShowOSD;
- s.fLimitWindowProportions = !!m_fLimitWindowProportions;
- s.fRememberDVDPos = m_fRememberDVDPos ? true : false;
- s.fRememberFilePos = m_fRememberFilePos ? true : false;
-
- if(!m_fKeepHistory)
- {
- for(int i = 0; i < s.MRU.GetSize(); i++) s.MRU.Remove(i);
- for(int i = 0; i < s.MRUDub.GetSize(); i++) s.MRUDub.Remove(i);
- s.MRU.WriteList();
- s.MRUDub.WriteList();
- }
-
- ((CMainFrame*)AfxGetMainWnd())->ShowTrayIcon(s.fTrayIcon);
-
- ::SetPriorityClass(::GetCurrentProcess(), s.priority);
-
- GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
- GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.fAllowMultipleInst = !!m_iAllowMultipleInst;
+ s.iTitleBarTextStyle = m_iTitleBarTextStyle;
+ s.fTitleBarTextTitle = !!m_bTitleBarTextTitle;
+ s.iOnTop = m_iAlwaysOnTop;
+ s.fTrayIcon = !!m_fTrayIcon;
+ s.fRememberWindowPos = !!m_fRememberWindowPos;
+ s.fRememberWindowSize = !!m_fRememberWindowSize;
+ s.fSnapToDesktopEdges = !!m_fSnapToDesktopEdges;
+ s.fKeepHistory = !!m_fKeepHistory;
+ s.fHideCDROMsSubMenu = !!m_fHideCDROMsSubMenu;
+ s.priority = !m_priority ? NORMAL_PRIORITY_CLASS : GetVersion() < 0 ? HIGH_PRIORITY_CLASS : ABOVE_NORMAL_PRIORITY_CLASS;
+ s.fShowOSD = !!m_fShowOSD;
+ s.fLimitWindowProportions = !!m_fLimitWindowProportions;
+ s.fRememberDVDPos = m_fRememberDVDPos ? true : false;
+ s.fRememberFilePos = m_fRememberFilePos ? true : false;
+
+ if(!m_fKeepHistory)
+ {
+ for(int i = 0; i < s.MRU.GetSize(); i++) s.MRU.Remove(i);
+ for(int i = 0; i < s.MRUDub.GetSize(); i++) s.MRUDub.Remove(i);
+ s.MRU.WriteList();
+ s.MRUDub.WriteList();
+ }
+
+ ((CMainFrame*)AfxGetMainWnd())->ShowTrayIcon(s.fTrayIcon);
+
+ ::SetPriorityClass(::GetCurrentProcess(), s.priority);
+
+ GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
+ GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
+
+ return __super::OnApply();
}
void CPPagePlayer::OnBnClickedCheck8()
{
- UpdateData();
+ UpdateData();
- if(m_fUseIni)((CMPlayerCApp*)AfxGetApp())->StoreSettingsToIni();
- else((CMPlayerCApp*)AfxGetApp())->StoreSettingsToRegistry();
+ if(m_fUseIni) ((CMPlayerCApp*)AfxGetApp())->StoreSettingsToIni();
+ else ((CMPlayerCApp*)AfxGetApp())->StoreSettingsToRegistry();
- SetModified();
+ SetModified();
}
void CPPagePlayer::OnUpdateCheck13(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(m_iTitleBarTextStyle == 1);
+ pCmdUI->Enable(m_iTitleBarTextStyle == 1);
}
void CPPagePlayer::OnUpdatePos(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(!!m_fKeepHistory);
+ pCmdUI->Enable( !!m_fKeepHistory );
}
diff --git a/src/apps/mplayerc/PPagePlayer.h b/src/apps/mplayerc/PPagePlayer.h
index 44b7a7e52..dd1f77ee0 100644
--- a/src/apps/mplayerc/PPagePlayer.h
+++ b/src/apps/mplayerc/PPagePlayer.h
@@ -30,42 +30,42 @@
class CPPagePlayer : public CPPageBase
{
- DECLARE_DYNAMIC(CPPagePlayer)
+ DECLARE_DYNAMIC(CPPagePlayer)
public:
- CPPagePlayer();
- virtual ~CPPagePlayer();
+ CPPagePlayer();
+ virtual ~CPPagePlayer();
- int m_iAllowMultipleInst;
- int m_iTitleBarTextStyle;
- BOOL m_bTitleBarTextTitle;
- BOOL m_iAlwaysOnTop;
- BOOL m_fRememberWindowPos;
- BOOL m_fRememberWindowSize;
- BOOL m_fSnapToDesktopEdges;
- BOOL m_fUseIni;
- BOOL m_fTrayIcon;
- BOOL m_fKeepHistory;
- BOOL m_fHideCDROMsSubMenu;
- BOOL m_priority;
- BOOL m_fShowOSD;
- BOOL m_fLimitWindowProportions;
- BOOL m_fRememberDVDPos;
- BOOL m_fRememberFilePos;
+ int m_iAllowMultipleInst;
+ int m_iTitleBarTextStyle;
+ BOOL m_bTitleBarTextTitle;
+ BOOL m_iAlwaysOnTop;
+ BOOL m_fRememberWindowPos;
+ BOOL m_fRememberWindowSize;
+ BOOL m_fSnapToDesktopEdges;
+ BOOL m_fUseIni;
+ BOOL m_fTrayIcon;
+ BOOL m_fKeepHistory;
+ BOOL m_fHideCDROMsSubMenu;
+ BOOL m_priority;
+ BOOL m_fShowOSD;
+ BOOL m_fLimitWindowProportions;
+ BOOL m_fRememberDVDPos;
+ BOOL m_fRememberFilePos;
// Dialog Data
- enum { IDD = IDD_PPAGEPLAYER };
+ enum { IDD = IDD_PPAGEPLAYER };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedCheck8();
- afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
- afx_msg void OnUpdateCheck13(CCmdUI* pCmdUI);
- afx_msg void OnUpdatePos(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedCheck8();
+ afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateCheck13(CCmdUI* pCmdUI);
+ afx_msg void OnUpdatePos(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/PPageSheet.cpp b/src/apps/mplayerc/PPageSheet.cpp
index bbca4b769..2a6cc3b8b 100644
--- a/src/apps/mplayerc/PPageSheet.cpp
+++ b/src/apps/mplayerc/PPageSheet.cpp
@@ -31,46 +31,46 @@
IMPLEMENT_DYNAMIC(CPPageSheet, CTreePropSheet)
CPPageSheet::CPPageSheet(LPCTSTR pszCaption, IFilterGraph* pFG, CWnd* pParentWnd, UINT idPage)
- : CTreePropSheet(pszCaption, pParentWnd, 0)
- , m_audioswitcher(pFG)
- , m_bLockPage(false)
+ : CTreePropSheet(pszCaption, pParentWnd, 0)
+ , m_audioswitcher(pFG)
+ , m_bLockPage(false)
{
- SetTreeWidth(180);
- AddPage(&m_player);
- AddPage(&m_formats);
- AddPage(&m_acceltbl);
- AddPage(&m_logo);
- AddPage(&m_playback);
- AddPage(&m_dvd);
- AddPage(&m_output);
- AddPage(&m_fullscreen);
- AddPage(&m_sync);
- AddPage(&m_tuner);
- AddPage(&m_webserver);
- AddPage(&m_internalfilters);
- AddPage(&m_audioswitcher);
- AddPage(&m_externalfilters);
- AddPage(&m_subtitles);
- AddPage(&m_substyle);
- AddPage(&m_subdb);
- AddPage(&m_tweaks);
- AddPage(&m_casimir);
-
- EnableStackedTabs(FALSE);
-
- SetTreeViewMode(TRUE, TRUE, FALSE);
-
- if(idPage || (idPage = AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("LastUsedPage"), 0)))
- {
- for(int i = 0; i < GetPageCount(); i++)
- {
- if(GetPage(i)->m_pPSP->pszTemplate == MAKEINTRESOURCE(idPage))
- {
- SetActivePage(i);
- break;
- }
- }
- }
+ SetTreeWidth(180);
+ AddPage(&m_player);
+ AddPage(&m_formats);
+ AddPage(&m_acceltbl);
+ AddPage(&m_logo);
+ AddPage(&m_playback);
+ AddPage(&m_dvd);
+ AddPage(&m_output);
+ AddPage(&m_fullscreen);
+ AddPage(&m_sync);
+ AddPage(&m_tuner);
+ AddPage(&m_webserver);
+ AddPage(&m_internalfilters);
+ AddPage(&m_audioswitcher);
+ AddPage(&m_externalfilters);
+ AddPage(&m_subtitles);
+ AddPage(&m_substyle);
+ AddPage(&m_subdb);
+ AddPage(&m_tweaks);
+ AddPage(&m_casimir);
+
+ EnableStackedTabs(FALSE);
+
+ SetTreeViewMode(TRUE, TRUE, FALSE);
+
+ if(idPage || (idPage = AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("LastUsedPage"), 0)))
+ {
+ for(int i = 0; i < GetPageCount(); i++)
+ {
+ if(GetPage(i)->m_pPSP->pszTemplate == MAKEINTRESOURCE(idPage))
+ {
+ SetActivePage(i);
+ break;
+ }
+ }
+ }
}
CPPageSheet::~CPPageSheet()
@@ -79,32 +79,32 @@ CPPageSheet::~CPPageSheet()
CTreeCtrl* CPPageSheet::CreatePageTreeObject()
{
- return DNew CTreePropSheetTreeCtrl();
+ return DNew CTreePropSheetTreeCtrl();
}
BEGIN_MESSAGE_MAP(CPPageSheet, CTreePropSheet)
- ON_WM_CONTEXTMENU()
+ ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()
BOOL CPPageSheet::OnInitDialog()
{
- BOOL bResult = __super::OnInitDialog();
+ BOOL bResult = __super::OnInitDialog();
- if(CTreeCtrl* pTree = GetPageTreeControl())
- {
- for(HTREEITEM node = pTree->GetRootItem(); node; node = pTree->GetNextSiblingItem(node))
- pTree->Expand(node, TVE_EXPAND);
- }
+ if(CTreeCtrl* pTree = GetPageTreeControl())
+ {
+ for(HTREEITEM node = pTree->GetRootItem(); node; node = pTree->GetNextSiblingItem(node))
+ pTree->Expand(node, TVE_EXPAND);
+ }
- if(m_bLockPage)
- GetPageTreeControl()->EnableWindow(FALSE);
+ if (m_bLockPage)
+ GetPageTreeControl()->EnableWindow (FALSE);
- return bResult;
+ return bResult;
}
void CPPageSheet::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
{
- // display your own context menu handler or do nothing
+ // display your own context menu handler or do nothing
}
// CTreePropSheetTreeCtrl
@@ -127,8 +127,8 @@ END_MESSAGE_MAP()
BOOL CTreePropSheetTreeCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
- cs.dwExStyle |= WS_EX_CLIENTEDGE;
+ cs.dwExStyle |= WS_EX_CLIENTEDGE;
// cs.style &= ~TVS_LINESATROOT;
- return __super::PreCreateWindow(cs);
+ return __super::PreCreateWindow(cs);
}
diff --git a/src/apps/mplayerc/PPageSheet.h b/src/apps/mplayerc/PPageSheet.h
index 690e7e123..d54798256 100644
--- a/src/apps/mplayerc/PPageSheet.h
+++ b/src/apps/mplayerc/PPageSheet.h
@@ -49,59 +49,56 @@ using namespace TreePropSheet;
class CTreePropSheetTreeCtrl : public CTreeCtrl
{
- DECLARE_DYNAMIC(CTreePropSheetTreeCtrl)
+ DECLARE_DYNAMIC(CTreePropSheetTreeCtrl)
public:
- CTreePropSheetTreeCtrl();
- virtual ~CTreePropSheetTreeCtrl();
+ CTreePropSheetTreeCtrl();
+ virtual ~CTreePropSheetTreeCtrl();
protected:
- DECLARE_MESSAGE_MAP()
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ DECLARE_MESSAGE_MAP()
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
};
// CPPageSheet
class CPPageSheet : public CTreePropSheet
{
- DECLARE_DYNAMIC(CPPageSheet)
+ DECLARE_DYNAMIC(CPPageSheet)
private:
- bool m_bLockPage;
+ bool m_bLockPage;
- CPPagePlayer m_player;
- CPPageFormats m_formats;
- CPPageAccelTbl m_acceltbl;
- CPPageLogo m_logo;
- CPPagePlayback m_playback;
- CPPageDVD m_dvd;
- CPPageOutput m_output;
- CPPageFullscreen m_fullscreen;
- CPPageSync m_sync;
- CPPageWebServer m_webserver;
- CPPageSubtitles m_subtitles;
- CPPageSubStyle m_substyle;
- CPPageSubDB m_subdb;
- CPPageInternalFilters m_internalfilters;
- CPPageAudioSwitcher m_audioswitcher;
- CPPageExternalFilters m_externalfilters;
- CPPageTweaks m_tweaks;
- CPPageCasimir m_casimir;
- CPPageCapture m_tuner;
+ CPPagePlayer m_player;
+ CPPageFormats m_formats;
+ CPPageAccelTbl m_acceltbl;
+ CPPageLogo m_logo;
+ CPPagePlayback m_playback;
+ CPPageDVD m_dvd;
+ CPPageOutput m_output;
+ CPPageFullscreen m_fullscreen;
+ CPPageSync m_sync;
+ CPPageWebServer m_webserver;
+ CPPageSubtitles m_subtitles;
+ CPPageSubStyle m_substyle;
+ CPPageSubDB m_subdb;
+ CPPageInternalFilters m_internalfilters;
+ CPPageAudioSwitcher m_audioswitcher;
+ CPPageExternalFilters m_externalfilters;
+ CPPageTweaks m_tweaks;
+ CPPageCasimir m_casimir;
+ CPPageCapture m_tuner;
- CTreeCtrl* CreatePageTreeObject();
+ CTreeCtrl* CreatePageTreeObject();
public:
- CPPageSheet(LPCTSTR pszCaption, IFilterGraph* pFG, CWnd* pParentWnd, UINT idPage = 0);
- virtual ~CPPageSheet();
- afx_msg void OnContextMenu(CWnd *pWnd, CPoint point);
+ CPPageSheet(LPCTSTR pszCaption, IFilterGraph* pFG, CWnd* pParentWnd, UINT idPage = 0);
+ virtual ~CPPageSheet();
+ afx_msg void OnContextMenu(CWnd *pWnd, CPoint point);
- void LockPage()
- {
- m_bLockPage = true;
- };
+ void LockPage() { m_bLockPage = true; };
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
};
diff --git a/src/apps/mplayerc/PPageSubDB.cpp b/src/apps/mplayerc/PPageSubDB.cpp
index b65d57658..b9723aba2 100644
--- a/src/apps/mplayerc/PPageSubDB.cpp
+++ b/src/apps/mplayerc/PPageSubDB.cpp
@@ -32,8 +32,8 @@
IMPLEMENT_DYNAMIC(CPPageSubDB, CPPageBase)
CPPageSubDB::CPPageSubDB()
- : CPPageBase(CPPageSubDB::IDD, CPPageSubDB::IDD)
- , m_ISDb(_T(""))
+ : CPPageBase(CPPageSubDB::IDD, CPPageSubDB::IDD)
+ , m_ISDb(_T(""))
{
}
@@ -43,14 +43,14 @@ CPPageSubDB::~CPPageSubDB()
void CPPageSubDB::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_ISDbCombo);
- DDX_CBString(pDX, IDC_COMBO1, m_ISDb);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_ISDbCombo);
+ DDX_CBString(pDX, IDC_COMBO1, m_ISDb);
}
BEGIN_MESSAGE_MAP(CPPageSubDB, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
END_MESSAGE_MAP()
@@ -58,60 +58,60 @@ END_MESSAGE_MAP()
BOOL CPPageSubDB::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_ISDb = s.ISDb;
- m_ISDbCombo.AddString(m_ISDb);
- if(m_ISDb.CompareNoCase(_T("www.opensubtitles.org/isdb")))
- m_ISDbCombo.AddString(_T("www.opensubtitles.org/isdb"));
+ m_ISDb = s.ISDb;
+ m_ISDbCombo.AddString(m_ISDb);
+ if(m_ISDb.CompareNoCase(_T("www.opensubtitles.org/isdb")))
+ m_ISDbCombo.AddString(_T("www.opensubtitles.org/isdb"));
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageSubDB::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.ISDb = m_ISDb;
- s.ISDb.TrimRight('/');
+ s.ISDb = m_ISDb;
+ s.ISDb.TrimRight('/');
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageSubDB::OnBnClickedButton1()
{
- CString ISDb, ver, msg, str;
-
- m_ISDbCombo.GetWindowText(ISDb);
- ISDb.TrimRight('/');
-
- ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);
-
- CWebTextFile wtf;
- if(wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver)
- {
- msg = ResStr(IDS_PPSDB_URLCORRECT);
- }
- else if(str.Find(_T("ISDb v")) == 0)
- {
- msg = ResStr(IDS_PPSDB_PROTOCOLERR);
- }
- else
- {
- msg = ResStr(IDS_PPSDB_BADURL);
- }
-
- AfxMessageBox(msg, MB_OK);
+ CString ISDb, ver, msg, str;
+
+ m_ISDbCombo.GetWindowText(ISDb);
+ ISDb.TrimRight('/');
+
+ ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);
+
+ CWebTextFile wtf;
+ if(wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver)
+ {
+ msg = ResStr(IDS_PPSDB_URLCORRECT);
+ }
+ else if(str.Find(_T("ISDb v")) == 0)
+ {
+ msg = ResStr(IDS_PPSDB_PROTOCOLERR);
+ }
+ else
+ {
+ msg = ResStr(IDS_PPSDB_BADURL);
+ }
+
+ AfxMessageBox(msg, MB_OK);
}
void CPPageSubDB::OnUpdateButton1(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_ISDbCombo.GetWindowTextLength() > 0);
+ pCmdUI->Enable(m_ISDbCombo.GetWindowTextLength() > 0);
}
diff --git a/src/apps/mplayerc/PPageSubDB.h b/src/apps/mplayerc/PPageSubDB.h
index 007e10500..a2c65ec43 100644
--- a/src/apps/mplayerc/PPageSubDB.h
+++ b/src/apps/mplayerc/PPageSubDB.h
@@ -30,25 +30,25 @@
class CPPageSubDB : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSubDB)
+ DECLARE_DYNAMIC(CPPageSubDB)
public:
- CPPageSubDB();
- virtual ~CPPageSubDB();
+ CPPageSubDB();
+ virtual ~CPPageSubDB();
// Dialog Data
- enum { IDD = IDD_PPAGESUBDB };
- CComboBox m_ISDbCombo;
- CString m_ISDb;
+ enum { IDD = IDD_PPAGESUBDB };
+ CComboBox m_ISDbCombo;
+ CString m_ISDb;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/PPageSubStyle.cpp b/src/apps/mplayerc/PPageSubStyle.cpp
index eb1098924..c1fa58efd 100644
--- a/src/apps/mplayerc/PPageSubStyle.cpp
+++ b/src/apps/mplayerc/PPageSubStyle.cpp
@@ -39,22 +39,22 @@
IMPLEMENT_DYNAMIC(CPPageSubStyle, CPPageBase)
CPPageSubStyle::CPPageSubStyle()
- : CPPageBase(CPPageSubStyle::IDD, CPPageSubStyle::IDD)
- , m_iCharset(0)
- , m_spacing(0)
- , m_angle(0)
- , m_scalex(0)
- , m_scaley(0)
- , m_borderstyle(0)
- , m_borderwidth(0)
- , m_shadowdepth(0)
- , m_screenalignment(0)
- , m_margin(0, 0, 0, 0)
- , m_linkalphasliders(FALSE)
- , m_relativeTo(FALSE)
+ : CPPageBase(CPPageSubStyle::IDD, CPPageSubStyle::IDD)
+ , m_iCharset(0)
+ , m_spacing(0)
+ , m_angle(0)
+ , m_scalex(0)
+ , m_scaley(0)
+ , m_borderstyle(0)
+ , m_borderwidth(0)
+ , m_shadowdepth(0)
+ , m_screenalignment(0)
+ , m_margin(0,0,0,0)
+ , m_linkalphasliders(FALSE)
+ , m_relativeTo(FALSE)
{
- m_stss = AfxGetAppSettings().subdefstyle;
- m_fUseDefaultStyle = true;
+ m_stss = AfxGetAppSettings().subdefstyle;
+ m_fUseDefaultStyle = true;
}
CPPageSubStyle::~CPPageSubStyle()
@@ -63,77 +63,77 @@ CPPageSubStyle::~CPPageSubStyle()
void CPPageSubStyle::InitStyle(CString title, STSStyle& stss)
{
- m_pPSP->pszTitle = (m_title = title);
- m_psp.dwFlags |= PSP_USETITLE;
+ m_pPSP->pszTitle = (m_title = title);
+ m_psp.dwFlags |= PSP_USETITLE;
- m_stss = stss;
- m_fUseDefaultStyle = false;
+ m_stss = stss;
+ m_fUseDefaultStyle = false;
}
void CPPageSubStyle::AskColor(int i)
{
- CColorDialog dlg(m_stss.colors[i]);
- dlg.m_cc.Flags |= CC_FULLOPEN;
- if(dlg.DoModal() == IDOK)
- {
- m_stss.colors[i] = dlg.m_cc.rgbResult;
- m_color[i].Invalidate();
- }
+ CColorDialog dlg(m_stss.colors[i]);
+ dlg.m_cc.Flags |= CC_FULLOPEN;
+ if(dlg.DoModal() == IDOK)
+ {
+ m_stss.colors[i] = dlg.m_cc.rgbResult;
+ m_color[i].Invalidate();
+ }
}
void CPPageSubStyle::DoDataExchange(CDataExchange* pDX)
{
- CPPageBase::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_BUTTON1, m_font);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iCharset);
- DDX_Control(pDX, IDC_COMBO1, m_charset);
- DDX_Text(pDX, IDC_EDIT3, m_spacing);
- DDX_Control(pDX, IDC_SPIN3, m_spacingspin);
- DDX_Text(pDX, IDC_EDIT4, m_angle);
- DDX_Control(pDX, IDC_SPIN10, m_anglespin);
- DDX_Text(pDX, IDC_EDIT5, m_scalex);
- DDX_Control(pDX, IDC_SPIN4, m_scalexspin);
- DDX_Text(pDX, IDC_EDIT6, m_scaley);
- DDX_Control(pDX, IDC_SPIN5, m_scaleyspin);
- DDX_Radio(pDX, IDC_RADIO1, m_borderstyle);
- DDX_Text(pDX, IDC_EDIT1, m_borderwidth);
- DDX_Control(pDX, IDC_SPIN1, m_borderwidthspin);
- DDX_Text(pDX, IDC_EDIT2, m_shadowdepth);
- DDX_Control(pDX, IDC_SPIN2, m_shadowdepthspin);
- DDX_Radio(pDX, IDC_RADIO3, m_screenalignment);
- DDX_Text(pDX, IDC_EDIT7, m_margin.left);
- DDX_Control(pDX, IDC_SPIN6, m_marginleftspin);
- DDX_Text(pDX, IDC_EDIT8, m_margin.right);
- DDX_Control(pDX, IDC_SPIN7, m_marginrightspin);
- DDX_Text(pDX, IDC_EDIT9, m_margin.top);
- DDX_Control(pDX, IDC_SPIN8, m_margintopspin);
- DDX_Text(pDX, IDC_EDIT10, m_margin.bottom);
- DDX_Control(pDX, IDC_SPIN9, m_marginbottomspin);
- DDX_Control(pDX, IDC_COLORPRI, m_color[0]);
- DDX_Control(pDX, IDC_COLORSEC, m_color[1]);
- DDX_Control(pDX, IDC_COLOROUTL, m_color[2]);
- DDX_Control(pDX, IDC_COLORSHAD, m_color[3]);
- DDX_Slider(pDX, IDC_SLIDER1, m_alpha[0]);
- DDX_Slider(pDX, IDC_SLIDER2, m_alpha[1]);
- DDX_Slider(pDX, IDC_SLIDER3, m_alpha[2]);
- DDX_Slider(pDX, IDC_SLIDER4, m_alpha[3]);
- DDX_Control(pDX, IDC_SLIDER1, m_alphasliders[0]);
- DDX_Control(pDX, IDC_SLIDER2, m_alphasliders[1]);
- DDX_Control(pDX, IDC_SLIDER3, m_alphasliders[2]);
- DDX_Control(pDX, IDC_SLIDER4, m_alphasliders[3]);
- DDX_Check(pDX, IDC_CHECK1, m_linkalphasliders);
- DDX_Check(pDX, IDC_CHECK_RELATIVETO, m_relativeTo);
+ CPPageBase::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_BUTTON1, m_font);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iCharset);
+ DDX_Control(pDX, IDC_COMBO1, m_charset);
+ DDX_Text(pDX, IDC_EDIT3, m_spacing);
+ DDX_Control(pDX, IDC_SPIN3, m_spacingspin);
+ DDX_Text(pDX, IDC_EDIT4, m_angle);
+ DDX_Control(pDX, IDC_SPIN10, m_anglespin);
+ DDX_Text(pDX, IDC_EDIT5, m_scalex);
+ DDX_Control(pDX, IDC_SPIN4, m_scalexspin);
+ DDX_Text(pDX, IDC_EDIT6, m_scaley);
+ DDX_Control(pDX, IDC_SPIN5, m_scaleyspin);
+ DDX_Radio(pDX, IDC_RADIO1, m_borderstyle);
+ DDX_Text(pDX, IDC_EDIT1, m_borderwidth);
+ DDX_Control(pDX, IDC_SPIN1, m_borderwidthspin);
+ DDX_Text(pDX, IDC_EDIT2, m_shadowdepth);
+ DDX_Control(pDX, IDC_SPIN2, m_shadowdepthspin);
+ DDX_Radio(pDX, IDC_RADIO3, m_screenalignment);
+ DDX_Text(pDX, IDC_EDIT7, m_margin.left);
+ DDX_Control(pDX, IDC_SPIN6, m_marginleftspin);
+ DDX_Text(pDX, IDC_EDIT8, m_margin.right);
+ DDX_Control(pDX, IDC_SPIN7, m_marginrightspin);
+ DDX_Text(pDX, IDC_EDIT9, m_margin.top);
+ DDX_Control(pDX, IDC_SPIN8, m_margintopspin);
+ DDX_Text(pDX, IDC_EDIT10, m_margin.bottom);
+ DDX_Control(pDX, IDC_SPIN9, m_marginbottomspin);
+ DDX_Control(pDX, IDC_COLORPRI, m_color[0]);
+ DDX_Control(pDX, IDC_COLORSEC, m_color[1]);
+ DDX_Control(pDX, IDC_COLOROUTL, m_color[2]);
+ DDX_Control(pDX, IDC_COLORSHAD, m_color[3]);
+ DDX_Slider(pDX, IDC_SLIDER1, m_alpha[0]);
+ DDX_Slider(pDX, IDC_SLIDER2, m_alpha[1]);
+ DDX_Slider(pDX, IDC_SLIDER3, m_alpha[2]);
+ DDX_Slider(pDX, IDC_SLIDER4, m_alpha[3]);
+ DDX_Control(pDX, IDC_SLIDER1, m_alphasliders[0]);
+ DDX_Control(pDX, IDC_SLIDER2, m_alphasliders[1]);
+ DDX_Control(pDX, IDC_SLIDER3, m_alphasliders[2]);
+ DDX_Control(pDX, IDC_SLIDER4, m_alphasliders[3]);
+ DDX_Check(pDX, IDC_CHECK1, m_linkalphasliders);
+ DDX_Check(pDX, IDC_CHECK_RELATIVETO, m_relativeTo);
}
BEGIN_MESSAGE_MAP(CPPageSubStyle, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_STN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
- ON_STN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
- ON_STN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
- ON_STN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
- ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
- ON_WM_HSCROLL()
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_STN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
+ ON_STN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
+ ON_STN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
+ ON_STN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
+ ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
+ ON_WM_HSCROLL()
END_MESSAGE_MAP()
@@ -141,165 +141,165 @@ END_MESSAGE_MAP()
BOOL CPPageSubStyle::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- m_font.SetWindowText(m_stss.fontName);
- m_iCharset = -1;
- for(int i = 0; i < CharSetLen; i++)
- {
- CString str;
- str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
- m_charset.AddString(str);
- m_charset.SetItemData(i, CharSetList[i]);
- if(m_stss.charSet == CharSetList[i]) m_iCharset = i;
- }
-
- // TODO: allow floats in these edit boxes
- m_spacing = (int)m_stss.fontSpacing;
- m_spacingspin.SetRange32(-10000, 10000);
- while(m_stss.fontAngleZ < 0) m_stss.fontAngleZ += 360;
- m_angle = (int)fmod(m_stss.fontAngleZ, 360);
- m_anglespin.SetRange32(0, 359);
- m_scalex = (int)m_stss.fontScaleX;
- m_scalexspin.SetRange32(-10000, 10000);
- m_scaley = (int)m_stss.fontScaleY;
- m_scaleyspin.SetRange32(-10000, 10000);
-
- m_borderstyle = m_stss.borderStyle;
- m_borderwidth = min(m_stss.outlineWidthX, m_stss.outlineWidthY);
- m_borderwidthspin.SetRange32(0, 10000);
- m_shadowdepth = min(m_stss.shadowDepthX, m_stss.shadowDepthY);
- m_shadowdepthspin.SetRange32(0, 10000);
-
- m_screenalignment = m_stss.scrAlignment - 1;
- m_margin = m_stss.marginRect;
- m_marginleftspin.SetRange32(-10000, 10000);
- m_marginrightspin.SetRange32(-10000, 10000);
- m_margintopspin.SetRange32(-10000, 10000);
- m_marginbottomspin.SetRange32(-10000, 10000);
- m_relativeTo = m_stss.relativeTo;
-
- for(int i = 0; i < 4; i++)
- {
- m_color[i].SetColorPtr(&m_stss.colors[i]);
- m_alpha[i] = 255 - m_stss.alpha[i];
- m_alphasliders[i].SetRange(0, 255);
- }
-
- m_linkalphasliders = FALSE;
-
- UpdateData(FALSE);
-
- CreateToolTip();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ m_font.SetWindowText(m_stss.fontName);
+ m_iCharset = -1;
+ for(int i = 0; i < CharSetLen; i++)
+ {
+ CString str;
+ str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
+ m_charset.AddString(str);
+ m_charset.SetItemData(i, CharSetList[i]);
+ if(m_stss.charSet == CharSetList[i]) m_iCharset = i;
+ }
+
+ // TODO: allow floats in these edit boxes
+ m_spacing = (int)m_stss.fontSpacing;
+ m_spacingspin.SetRange32(-10000, 10000);
+ while(m_stss.fontAngleZ < 0) m_stss.fontAngleZ += 360;
+ m_angle = (int)fmod(m_stss.fontAngleZ, 360);
+ m_anglespin.SetRange32(0, 359);
+ m_scalex = (int)m_stss.fontScaleX;
+ m_scalexspin.SetRange32(-10000, 10000);
+ m_scaley = (int)m_stss.fontScaleY;
+ m_scaleyspin.SetRange32(-10000, 10000);
+
+ m_borderstyle = m_stss.borderStyle;
+ m_borderwidth = min(m_stss.outlineWidthX, m_stss.outlineWidthY);
+ m_borderwidthspin.SetRange32(0, 10000);
+ m_shadowdepth = min(m_stss.shadowDepthX, m_stss.shadowDepthY);
+ m_shadowdepthspin.SetRange32(0, 10000);
+
+ m_screenalignment = m_stss.scrAlignment-1;
+ m_margin = m_stss.marginRect;
+ m_marginleftspin.SetRange32(-10000, 10000);
+ m_marginrightspin.SetRange32(-10000, 10000);
+ m_margintopspin.SetRange32(-10000, 10000);
+ m_marginbottomspin.SetRange32(-10000, 10000);
+ m_relativeTo = m_stss.relativeTo;
+
+ for(int i = 0; i < 4; i++)
+ {
+ m_color[i].SetColorPtr(&m_stss.colors[i]);
+ m_alpha[i] = 255-m_stss.alpha[i];
+ m_alphasliders[i].SetRange(0, 255);
+ }
+
+ m_linkalphasliders = FALSE;
+
+ UpdateData(FALSE);
+
+ CreateToolTip();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageSubStyle::OnApply()
{
- UpdateData();
-
- if(m_iCharset >= 0) m_stss.charSet = m_charset.GetItemData(m_iCharset);
- m_stss.fontSpacing = m_spacing;
- m_stss.fontAngleZ = m_angle;
- m_stss.fontScaleX = m_scalex;
- m_stss.fontScaleY = m_scaley;
-
- m_stss.borderStyle = m_borderstyle;
- m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
- m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
-
- m_stss.scrAlignment = m_screenalignment + 1;
- m_stss.marginRect = m_margin;
- m_stss.relativeTo = m_relativeTo;
-
- for(int i = 0; i < 4; i++) m_stss.alpha[i] = 255 - m_alpha[i];
-
- if(m_fUseDefaultStyle)
- {
- STSStyle& stss = AfxGetAppSettings().subdefstyle;
- if(!(stss == m_stss))
- {
- stss = m_stss;
- if(CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd()))
- pFrame->UpdateSubtitle(true);
- }
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ if(m_iCharset >= 0) m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ m_stss.fontSpacing = m_spacing;
+ m_stss.fontAngleZ = m_angle;
+ m_stss.fontScaleX = m_scalex;
+ m_stss.fontScaleY = m_scaley;
+
+ m_stss.borderStyle = m_borderstyle;
+ m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
+ m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
+
+ m_stss.scrAlignment = m_screenalignment+1;
+ m_stss.marginRect = m_margin;
+ m_stss.relativeTo = m_relativeTo;
+
+ for(int i = 0; i < 4; i++) m_stss.alpha[i] = 255-m_alpha[i];
+
+ if(m_fUseDefaultStyle)
+ {
+ STSStyle& stss = AfxGetAppSettings().subdefstyle;
+ if(!(stss == m_stss))
+ {
+ stss = m_stss;
+ if(CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd()))
+ pFrame->UpdateSubtitle(true);
+ }
+ }
+
+ return __super::OnApply();
}
void CPPageSubStyle::OnBnClickedButton1()
{
- LOGFONT lf;
- lf <<= m_stss;
-
- CFontDialog dlg(&lf, CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_FORCEFONTEXIST | CF_SCALABLEONLY | CF_EFFECTS);
- if(dlg.DoModal() == IDOK)
- {
- CString str(lf.lfFaceName);
- if(str.GetLength() > 16) str = str.Left(14) + _T("...");
- m_font.SetWindowText(str);
-
- for(int i = 0, j = m_charset.GetCount(); i < j; i++)
- {
- if(m_charset.GetItemData(i) == lf.lfCharSet)
- {
- m_charset.SetCurSel(i);
- break;
- }
- }
-
- m_stss = lf;
-
- SetModified();
- }
+ LOGFONT lf;
+ lf <<= m_stss;
+
+ CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCALABLEONLY|CF_EFFECTS);
+ if(dlg.DoModal() == IDOK)
+ {
+ CString str(lf.lfFaceName);
+ if(str.GetLength() > 16) str = str.Left(14) + _T("...");
+ m_font.SetWindowText(str);
+
+ for(int i = 0, j = m_charset.GetCount(); i < j; i++)
+ {
+ if(m_charset.GetItemData(i) == lf.lfCharSet)
+ {
+ m_charset.SetCurSel(i);
+ break;
+ }
+ }
+
+ m_stss = lf;
+
+ SetModified();
+ }
}
void CPPageSubStyle::OnStnClickedColorpri()
{
- AskColor(0);
+ AskColor(0);
}
void CPPageSubStyle::OnStnClickedColorsec()
{
- AskColor(1);
+ AskColor(1);
}
void CPPageSubStyle::OnStnClickedColoroutl()
{
- AskColor(2);
+ AskColor(2);
}
void CPPageSubStyle::OnStnClickedColorshad()
{
- AskColor(3);
+ AskColor(3);
}
void CPPageSubStyle::OnBnClickedCheck1()
{
- UpdateData();
+ UpdateData();
- int avg = 0;
- for(int i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
- avg /= 4;
- for(int i = 0; i < 4; i++) m_alphasliders[i].SetPos(avg);
+ int avg = 0;
+ for(int i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
+ avg /= 4;
+ for(int i = 0; i < 4; i++) m_alphasliders[i].SetPos(avg);
- SetModified();
+ SetModified();
}
void CPPageSubStyle::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(m_linkalphasliders && pScrollBar)
- {
- int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for(int i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
- }
-
- SetModified();
-
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ if(m_linkalphasliders && pScrollBar)
+ {
+ int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
+ for(int i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
+ }
+
+ SetModified();
+
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
diff --git a/src/apps/mplayerc/PPageSubStyle.h b/src/apps/mplayerc/PPageSubStyle.h
index b1e43f251..955d9b010 100644
--- a/src/apps/mplayerc/PPageSubStyle.h
+++ b/src/apps/mplayerc/PPageSubStyle.h
@@ -31,93 +31,87 @@ class CColorStatic : public CStatic
{
// DECLARE_DYNAMIC(CColorStatic)
- COLORREF* m_pColor;
+ COLORREF* m_pColor;
public:
- CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {}
- virtual ~CColorStatic() {}
+ CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {}
+ virtual ~CColorStatic() {}
- void SetColorPtr(COLORREF* pColor)
- {
- m_pColor = pColor;
- }
+ void SetColorPtr(COLORREF* pColor) {m_pColor = pColor;}
// DECLARE_MESSAGE_MAP()
protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
- CRect r;
- GetClientRect(r);
- CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
- }
+ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
+ {
+ CRect r;
+ GetClientRect(r);
+ CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
+ }
};
// CPPageSubStyle dialog
class CPPageSubStyle : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSubStyle)
+ DECLARE_DYNAMIC(CPPageSubStyle)
private:
- CString m_title;
- STSStyle m_stss;
- bool m_fUseDefaultStyle;
+ CString m_title;
+ STSStyle m_stss;
+ bool m_fUseDefaultStyle;
- void AskColor(int i);
+ void AskColor(int i);
public:
- CPPageSubStyle();
- virtual ~CPPageSubStyle();
+ CPPageSubStyle();
+ virtual ~CPPageSubStyle();
- void InitStyle(CString title, STSStyle& stss);
- void GetStyle(STSStyle& stss)
- {
- stss = m_stss;
- }
+ void InitStyle(CString title, STSStyle& stss);
+ void GetStyle(STSStyle& stss) {stss = m_stss;}
// Dialog Data
- enum { IDD = IDD_PPAGESUBSTYLE };
- CButton m_font;
- int m_iCharset;
- CComboBox m_charset;
- int m_spacing;
- CSpinButtonCtrl m_spacingspin;
- int m_angle;
- CSpinButtonCtrl m_anglespin;
- int m_scalex;
- CSpinButtonCtrl m_scalexspin;
- int m_scaley;
- CSpinButtonCtrl m_scaleyspin;
- int m_borderstyle;
- int m_borderwidth;
- CSpinButtonCtrl m_borderwidthspin;
- int m_shadowdepth;
- CSpinButtonCtrl m_shadowdepthspin;
- int m_screenalignment;
- CRect m_margin;
- CSpinButtonCtrl m_marginleftspin;
- CSpinButtonCtrl m_marginrightspin;
- CSpinButtonCtrl m_margintopspin;
- CSpinButtonCtrl m_marginbottomspin;
- CColorStatic m_color[4];
- int m_alpha[4];
- CSliderCtrl m_alphasliders[4];
- BOOL m_linkalphasliders;
- BOOL m_relativeTo;
+ enum { IDD = IDD_PPAGESUBSTYLE };
+ CButton m_font;
+ int m_iCharset;
+ CComboBox m_charset;
+ int m_spacing;
+ CSpinButtonCtrl m_spacingspin;
+ int m_angle;
+ CSpinButtonCtrl m_anglespin;
+ int m_scalex;
+ CSpinButtonCtrl m_scalexspin;
+ int m_scaley;
+ CSpinButtonCtrl m_scaleyspin;
+ int m_borderstyle;
+ int m_borderwidth;
+ CSpinButtonCtrl m_borderwidthspin;
+ int m_shadowdepth;
+ CSpinButtonCtrl m_shadowdepthspin;
+ int m_screenalignment;
+ CRect m_margin;
+ CSpinButtonCtrl m_marginleftspin;
+ CSpinButtonCtrl m_marginrightspin;
+ CSpinButtonCtrl m_margintopspin;
+ CSpinButtonCtrl m_marginbottomspin;
+ CColorStatic m_color[4];
+ int m_alpha[4];
+ CSliderCtrl m_alphasliders[4];
+ BOOL m_linkalphasliders;
+ BOOL m_relativeTo;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
-
- DECLARE_MESSAGE_MAP()
- afx_msg void OnBnClickedButton1();
- afx_msg void OnStnClickedColorpri();
- afx_msg void OnStnClickedColorsec();
- afx_msg void OnStnClickedColoroutl();
- afx_msg void OnStnClickedColorshad();
- afx_msg void OnBnClickedCheck1();
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnStnClickedColorpri();
+ afx_msg void OnStnClickedColorsec();
+ afx_msg void OnStnClickedColoroutl();
+ afx_msg void OnStnClickedColorshad();
+ afx_msg void OnBnClickedCheck1();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
public:
};
diff --git a/src/apps/mplayerc/PPageSubtitles.cpp b/src/apps/mplayerc/PPageSubtitles.cpp
index ca45c07a5..fe079f2a8 100644
--- a/src/apps/mplayerc/PPageSubtitles.cpp
+++ b/src/apps/mplayerc/PPageSubtitles.cpp
@@ -31,14 +31,14 @@
IMPLEMENT_DYNAMIC(CPPageSubtitles, CPPageBase)
CPPageSubtitles::CPPageSubtitles()
- : CPPageBase(CPPageSubtitles::IDD, CPPageSubtitles::IDD)
- , m_fOverridePlacement(FALSE)
- , m_nHorPos(0)
- , m_nVerPos(0)
- , m_nSPCSize(0)
- , m_fSPCPow2Tex(FALSE)
- , m_fSPCAllowAnimationWhenBuffering(TRUE)
- , m_nSubDelayInterval(0)
+ : CPPageBase(CPPageSubtitles::IDD, CPPageSubtitles::IDD)
+ , m_fOverridePlacement(FALSE)
+ , m_nHorPos(0)
+ , m_nVerPos(0)
+ , m_nSPCSize(0)
+ , m_fSPCPow2Tex(FALSE)
+ , m_fSPCAllowAnimationWhenBuffering(TRUE)
+ , m_nSubDelayInterval(0)
{
}
@@ -48,33 +48,33 @@ CPPageSubtitles::~CPPageSubtitles()
void CPPageSubtitles::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK3, m_fOverridePlacement);
- DDX_Text(pDX, IDC_EDIT2, m_nHorPos);
- DDX_Control(pDX, IDC_SPIN2, m_nHorPosCtrl);
- DDX_Text(pDX, IDC_EDIT3, m_nVerPos);
- DDX_Control(pDX, IDC_SPIN3, m_nVerPosCtrl);
- DDX_Text(pDX, IDC_EDIT1, m_nSPCSize);
- DDX_Control(pDX, IDC_SPIN1, m_nSPCSizeCtrl);
- DDX_Control(pDX, IDC_COMBO1, m_spmaxres);
- DDX_Control(pDX, IDC_EDIT2, m_nHorPosEdit);
- DDX_Control(pDX, IDC_EDIT3, m_nVerPosEdit);
- DDX_Check(pDX, IDC_CHECK_SPCPOW2TEX, m_fSPCPow2Tex);
- DDX_Check(pDX, IDC_CHECK_SPCANIMWITHBUFFER, m_fSPCAllowAnimationWhenBuffering);
- DDX_Text(pDX, IDC_EDIT4, m_nSubDelayInterval);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK3, m_fOverridePlacement);
+ DDX_Text(pDX, IDC_EDIT2, m_nHorPos);
+ DDX_Control(pDX, IDC_SPIN2, m_nHorPosCtrl);
+ DDX_Text(pDX, IDC_EDIT3, m_nVerPos);
+ DDX_Control(pDX, IDC_SPIN3, m_nVerPosCtrl);
+ DDX_Text(pDX, IDC_EDIT1, m_nSPCSize);
+ DDX_Control(pDX, IDC_SPIN1, m_nSPCSizeCtrl);
+ DDX_Control(pDX, IDC_COMBO1, m_spmaxres);
+ DDX_Control(pDX, IDC_EDIT2, m_nHorPosEdit);
+ DDX_Control(pDX, IDC_EDIT3, m_nVerPosEdit);
+ DDX_Check(pDX, IDC_CHECK_SPCPOW2TEX, m_fSPCPow2Tex);
+ DDX_Check(pDX, IDC_CHECK_SPCANIMWITHBUFFER, m_fSPCAllowAnimationWhenBuffering);
+ DDX_Text(pDX, IDC_EDIT4, m_nSubDelayInterval);
}
BEGIN_MESSAGE_MAP(CPPageSubtitles, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_EDIT3, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_SPIN3, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC4, OnUpdatePosOverride)
- ON_EN_CHANGE(IDC_EDIT4, OnSubDelayInterval)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT3, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN3, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC4, OnUpdatePosOverride)
+ ON_EN_CHANGE(IDC_EDIT4, OnSubDelayInterval)
END_MESSAGE_MAP()
@@ -82,127 +82,127 @@ END_MESSAGE_MAP()
int TranslateResIn(int _In)
{
- switch(_In)
- {
- case 0:
- return 0;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- return _In + 4;
- case 6:
- case 7:
- case 8:
- case 9:
- return _In - 5;
- }
- return _In;
+ switch (_In)
+ {
+ case 0:
+ return 0;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ return _In + 4;
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return _In - 5;
+ }
+ return _In;
}
int TranslateResOut(int _In)
{
- switch(_In)
- {
- case 0:
- return 0;
- case 1:
- case 2:
- case 3:
- case 4:
- return _In + 5;
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- return _In - 4;
- }
- return _In;
+ switch (_In)
+ {
+ case 0:
+ return 0;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return _In + 5;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return _In - 4;
+ }
+ return _In;
}
BOOL CPPageSubtitles::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_fOverridePlacement = s.fOverridePlacement;
- m_nHorPos = s.nHorPos;
- m_nHorPosCtrl.SetRange(-10, 110);
- m_nVerPos = s.nVerPos;
- m_nVerPosCtrl.SetRange(110, -10);
- m_nSPCSize = s.nSPCSize;
- m_nSPCSizeCtrl.SetRange(0, 60);
- m_spmaxres.AddString(_T("Desktop"));
- m_spmaxres.AddString(_T("2560x1600"));
- m_spmaxres.AddString(_T("1920x1080"));
- m_spmaxres.AddString(_T("1320x900"));
- m_spmaxres.AddString(_T("1280x720"));
- m_spmaxres.AddString(_T("1024x768"));
- m_spmaxres.AddString(_T("800x600"));
- m_spmaxres.AddString(_T("640x480"));
- m_spmaxres.AddString(_T("512x384"));
- m_spmaxres.AddString(_T("384x288"));
- m_spmaxres.SetCurSel(TranslateResIn(s.nSPCMaxRes));
- m_fSPCPow2Tex = s.fSPCPow2Tex;
- m_fSPCAllowAnimationWhenBuffering = s.fSPCAllowAnimationWhenBuffering;
- m_nSubDelayInterval = s.nSubDelayInterval;
-
- UpdateData(FALSE);
-
- CreateToolTip();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_fOverridePlacement = s.fOverridePlacement;
+ m_nHorPos = s.nHorPos;
+ m_nHorPosCtrl.SetRange(-10,110);
+ m_nVerPos = s.nVerPos;
+ m_nVerPosCtrl.SetRange(110,-10);
+ m_nSPCSize = s.nSPCSize;
+ m_nSPCSizeCtrl.SetRange(0, 60);
+ m_spmaxres.AddString(_T("Desktop"));
+ m_spmaxres.AddString(_T("2560x1600"));
+ m_spmaxres.AddString(_T("1920x1080"));
+ m_spmaxres.AddString(_T("1320x900"));
+ m_spmaxres.AddString(_T("1280x720"));
+ m_spmaxres.AddString(_T("1024x768"));
+ m_spmaxres.AddString(_T("800x600"));
+ m_spmaxres.AddString(_T("640x480"));
+ m_spmaxres.AddString(_T("512x384"));
+ m_spmaxres.AddString(_T("384x288"));
+ m_spmaxres.SetCurSel(TranslateResIn(s.nSPCMaxRes));
+ m_fSPCPow2Tex = s.fSPCPow2Tex;
+ m_fSPCAllowAnimationWhenBuffering = s.fSPCAllowAnimationWhenBuffering;
+ m_nSubDelayInterval = s.nSubDelayInterval;
+
+ UpdateData(FALSE);
+
+ CreateToolTip();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageSubtitles::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- if(s.fOverridePlacement != !!m_fOverridePlacement
- || s.nHorPos != m_nHorPos
- || s.nVerPos != m_nVerPos
- || s.nSPCSize != m_nSPCSize
- || s.nSubDelayInterval != m_nSubDelayInterval
- || s.nSPCMaxRes != TranslateResOut(m_spmaxres.GetCurSel())
- || s.fSPCPow2Tex != !!m_fSPCPow2Tex
- || s.fSPCAllowAnimationWhenBuffering != !!m_fSPCAllowAnimationWhenBuffering)
- {
- s.fOverridePlacement = !!m_fOverridePlacement;
- s.nHorPos = m_nHorPos;
- s.nVerPos = m_nVerPos;
- s.nSPCSize = m_nSPCSize;
- s.nSubDelayInterval = m_nSubDelayInterval;
- s.nSPCMaxRes = TranslateResOut(m_spmaxres.GetCurSel());
- s.fSPCPow2Tex = !!m_fSPCPow2Tex;
- s.fSPCAllowAnimationWhenBuffering = !!m_fSPCAllowAnimationWhenBuffering;
-
- if(CMainFrame* pFrame = (CMainFrame*)GetParentFrame())
- pFrame->UpdateSubtitle(true);
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if(s.fOverridePlacement != !!m_fOverridePlacement
+ || s.nHorPos != m_nHorPos
+ || s.nVerPos != m_nVerPos
+ || s.nSPCSize != m_nSPCSize
+ || s.nSubDelayInterval != m_nSubDelayInterval
+ || s.nSPCMaxRes != TranslateResOut(m_spmaxres.GetCurSel())
+ || s.fSPCPow2Tex != !!m_fSPCPow2Tex
+ || s.fSPCAllowAnimationWhenBuffering != !!m_fSPCAllowAnimationWhenBuffering)
+ {
+ s.fOverridePlacement = !!m_fOverridePlacement;
+ s.nHorPos = m_nHorPos;
+ s.nVerPos = m_nVerPos;
+ s.nSPCSize = m_nSPCSize;
+ s.nSubDelayInterval = m_nSubDelayInterval;
+ s.nSPCMaxRes = TranslateResOut(m_spmaxres.GetCurSel());
+ s.fSPCPow2Tex = !!m_fSPCPow2Tex;
+ s.fSPCAllowAnimationWhenBuffering = !!m_fSPCAllowAnimationWhenBuffering;
+
+ if(CMainFrame* pFrame = (CMainFrame*)GetParentFrame())
+ pFrame->UpdateSubtitle(true);
+ }
+
+ return __super::OnApply();
}
void CPPageSubtitles::OnUpdatePosOverride(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_fOverridePlacement);
+ UpdateData();
+ pCmdUI->Enable(m_fOverridePlacement);
}
void CPPageSubtitles::OnSubDelayInterval()
{
- // If incorrect number, revert modifications
- if(!UpdateData())
- UpdateData(FALSE);
+ // If incorrect number, revert modifications
+ if (!UpdateData())
+ UpdateData(FALSE);
- SetModified();
+ SetModified();
}
diff --git a/src/apps/mplayerc/PPageSubtitles.h b/src/apps/mplayerc/PPageSubtitles.h
index 9b8852c64..2ebb6c442 100644
--- a/src/apps/mplayerc/PPageSubtitles.h
+++ b/src/apps/mplayerc/PPageSubtitles.h
@@ -30,38 +30,38 @@
class CPPageSubtitles : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSubtitles)
+ DECLARE_DYNAMIC(CPPageSubtitles)
public:
- CPPageSubtitles();
- virtual ~CPPageSubtitles();
+ CPPageSubtitles();
+ virtual ~CPPageSubtitles();
- BOOL m_fOverridePlacement;
- int m_nHorPos;
- CEdit m_nHorPosEdit;
- CSpinButtonCtrl m_nHorPosCtrl;
- int m_nVerPos;
- CEdit m_nVerPosEdit;
- CSpinButtonCtrl m_nVerPosCtrl;
- int m_nSPCSize;
- CSpinButtonCtrl m_nSPCSizeCtrl;
- CComboBox m_spmaxres;
- BOOL m_fSPCPow2Tex;
- BOOL m_fSPCAllowAnimationWhenBuffering;
- int m_nSubDelayInterval;
+ BOOL m_fOverridePlacement;
+ int m_nHorPos;
+ CEdit m_nHorPosEdit;
+ CSpinButtonCtrl m_nHorPosCtrl;
+ int m_nVerPos;
+ CEdit m_nVerPosEdit;
+ CSpinButtonCtrl m_nVerPosCtrl;
+ int m_nSPCSize;
+ CSpinButtonCtrl m_nSPCSizeCtrl;
+ CComboBox m_spmaxres;
+ BOOL m_fSPCPow2Tex;
+ BOOL m_fSPCAllowAnimationWhenBuffering;
+ int m_nSubDelayInterval;
// Dialog Data
- enum { IDD = IDD_PPAGESUBTITLES };
+ enum { IDD = IDD_PPAGESUBTITLES };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
- void OnSubDelayInterval();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+ void OnSubDelayInterval();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUpdatePosOverride(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUpdatePosOverride(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/PPageSync.cpp b/src/apps/mplayerc/PPageSync.cpp
index 357d293a5..21fbf5204 100644
--- a/src/apps/mplayerc/PPageSync.cpp
+++ b/src/apps/mplayerc/PPageSync.cpp
@@ -26,15 +26,15 @@
IMPLEMENT_DYNAMIC(CPPageSync, CPPageBase)
CPPageSync::CPPageSync()
- : CPPageBase(CPPageSync::IDD, CPPageSync::IDD)
- , m_bSynchronizeVideo(0)
- , m_bSynchronizeDisplay(0)
- , m_bSynchronizeNearest(0)
- , m_iLineDelta(0)
- , m_iColumnDelta(0)
- , m_fCycleDelta(0.0012)
- , m_fTargetSyncOffset(10.0)
- , m_fControlLimit(2.0)
+ : CPPageBase(CPPageSync::IDD, CPPageSync::IDD)
+ , m_bSynchronizeVideo(0)
+ , m_bSynchronizeDisplay(0)
+ , m_bSynchronizeNearest(0)
+ , m_iLineDelta(0)
+ , m_iColumnDelta(0)
+ , m_fCycleDelta(0.0012)
+ , m_fTargetSyncOffset(10.0)
+ , m_fControlLimit(2.0)
{
}
@@ -44,136 +44,136 @@ CPPageSync::~CPPageSync()
void CPPageSync::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_SYNCVIDEO, m_bSynchronizeVideo);
- DDX_Check(pDX, IDC_SYNCDISPLAY, m_bSynchronizeDisplay);
- DDX_Check(pDX, IDC_SYNCNEAREST, m_bSynchronizeNearest);
- DDX_Text(pDX, IDC_CYCLEDELTA, m_fCycleDelta);
- DDX_Text(pDX, IDC_LINEDELTA, m_iLineDelta);
- DDX_Text(pDX, IDC_COLUMNDELTA, m_iColumnDelta);
- DDX_Text(pDX, IDC_TARGETSYNCOFFSET, m_fTargetSyncOffset);
- DDX_Text(pDX, IDC_CONTROLLIMIT, m_fControlLimit);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_SYNCVIDEO, m_bSynchronizeVideo);
+ DDX_Check(pDX, IDC_SYNCDISPLAY, m_bSynchronizeDisplay);
+ DDX_Check(pDX, IDC_SYNCNEAREST, m_bSynchronizeNearest);
+ DDX_Text(pDX, IDC_CYCLEDELTA, m_fCycleDelta);
+ DDX_Text(pDX, IDC_LINEDELTA, m_iLineDelta);
+ DDX_Text(pDX, IDC_COLUMNDELTA, m_iColumnDelta);
+ DDX_Text(pDX, IDC_TARGETSYNCOFFSET, m_fTargetSyncOffset);
+ DDX_Text(pDX, IDC_CONTROLLIMIT, m_fControlLimit);
}
BOOL CPPageSync::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
- CMainFrame * pFrame;
- pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
- if((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->m_iPlaybackMode == PM_NONE))
- {
- GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(TRUE);
- GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(TRUE);
- GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(TRUE);
- }
- else
- {
- GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
- GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
- GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
- }
-
- m_bSynchronizeVideo = s.m_RenderSettings.bSynchronizeVideo;
- m_bSynchronizeDisplay = s.m_RenderSettings.bSynchronizeDisplay;
- m_bSynchronizeNearest = s.m_RenderSettings.bSynchronizeNearest;
- m_iLineDelta = s.m_RenderSettings.iLineDelta;
- m_iColumnDelta = s.m_RenderSettings.iColumnDelta;
- m_fCycleDelta = s.m_RenderSettings.fCycleDelta;
- m_fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
- m_fControlLimit = s.m_RenderSettings.fControlLimit;
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+ CMainFrame * pFrame;
+ pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
+ if ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->m_iPlaybackMode == PM_NONE))
+ {
+ GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(TRUE);
+ GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(TRUE);
+ GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(TRUE);
+ }
+ else
+ {
+ GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
+ GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
+ GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
+ }
+
+ m_bSynchronizeVideo = s.m_RenderSettings.bSynchronizeVideo;
+ m_bSynchronizeDisplay = s.m_RenderSettings.bSynchronizeDisplay;
+ m_bSynchronizeNearest = s.m_RenderSettings.bSynchronizeNearest;
+ m_iLineDelta = s.m_RenderSettings.iLineDelta;
+ m_iColumnDelta = s.m_RenderSettings.iColumnDelta;
+ m_fCycleDelta = s.m_RenderSettings.fCycleDelta;
+ m_fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+ m_fControlLimit = s.m_RenderSettings.fControlLimit;
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
-BOOL CPPageSync::OnSetActive()
+BOOL CPPageSync::OnSetActive()
{
- AppSettings& s = AfxGetAppSettings();
- CMainFrame * pFrame;
- pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
- if((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->m_iPlaybackMode == PM_NONE))
- {
- GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(TRUE);
- GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(TRUE);
- GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(TRUE);
- }
- else
- {
- GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
- GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
- GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
- }
-
- m_bSynchronizeVideo = s.m_RenderSettings.bSynchronizeVideo;
- m_bSynchronizeDisplay = s.m_RenderSettings.bSynchronizeDisplay;
- m_bSynchronizeNearest = s.m_RenderSettings.bSynchronizeNearest;
- m_iLineDelta = s.m_RenderSettings.iLineDelta;
- m_iColumnDelta = s.m_RenderSettings.iColumnDelta;
- m_fCycleDelta = s.m_RenderSettings.fCycleDelta;
- m_fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
- m_fControlLimit = s.m_RenderSettings.fControlLimit;
-
- UpdateData(FALSE);
-
- return CPropertyPage::OnSetActive();
+ AppSettings& s = AfxGetAppSettings();
+ CMainFrame * pFrame;
+ pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
+ if ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->m_iPlaybackMode == PM_NONE))
+ {
+ GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(TRUE);
+ GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(TRUE);
+ GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(TRUE);
+ }
+ else
+ {
+ GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
+ GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
+ GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
+ }
+
+ m_bSynchronizeVideo = s.m_RenderSettings.bSynchronizeVideo;
+ m_bSynchronizeDisplay = s.m_RenderSettings.bSynchronizeDisplay;
+ m_bSynchronizeNearest = s.m_RenderSettings.bSynchronizeNearest;
+ m_iLineDelta = s.m_RenderSettings.iLineDelta;
+ m_iColumnDelta = s.m_RenderSettings.iColumnDelta;
+ m_fCycleDelta = s.m_RenderSettings.fCycleDelta;
+ m_fTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+ m_fControlLimit = s.m_RenderSettings.fControlLimit;
+
+ UpdateData(FALSE);
+
+ return CPropertyPage::OnSetActive();
}
BOOL CPPageSync::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.m_RenderSettings.bSynchronizeVideo = !!m_bSynchronizeVideo;
- s.m_RenderSettings.bSynchronizeDisplay = !!m_bSynchronizeDisplay;
- s.m_RenderSettings.bSynchronizeNearest = !!m_bSynchronizeNearest;
- s.m_RenderSettings.iLineDelta = m_iLineDelta;
- s.m_RenderSettings.iColumnDelta = m_iColumnDelta;
- s.m_RenderSettings.fCycleDelta = m_fCycleDelta;
- s.m_RenderSettings.fTargetSyncOffset = m_fTargetSyncOffset;
- s.m_RenderSettings.fControlLimit = m_fControlLimit;
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.m_RenderSettings.bSynchronizeVideo = !!m_bSynchronizeVideo;
+ s.m_RenderSettings.bSynchronizeDisplay = !!m_bSynchronizeDisplay;
+ s.m_RenderSettings.bSynchronizeNearest = !!m_bSynchronizeNearest;
+ s.m_RenderSettings.iLineDelta = m_iLineDelta;
+ s.m_RenderSettings.iColumnDelta = m_iColumnDelta;
+ s.m_RenderSettings.fCycleDelta = m_fCycleDelta;
+ s.m_RenderSettings.fTargetSyncOffset = m_fTargetSyncOffset;
+ s.m_RenderSettings.fControlLimit = m_fControlLimit;
+ return __super::OnApply();
}
BEGIN_MESSAGE_MAP(CPPageSync, CPPageBase)
- ON_BN_CLICKED(IDC_SYNCVIDEO, OnBnClickedSyncVideo)
- ON_BN_CLICKED(IDC_SYNCDISPLAY, OnBnClickedSyncDisplay)
- ON_BN_CLICKED(IDC_SYNCNEAREST, OnBnClickedSyncNearest)
+ ON_BN_CLICKED(IDC_SYNCVIDEO, OnBnClickedSyncVideo)
+ ON_BN_CLICKED(IDC_SYNCDISPLAY, OnBnClickedSyncDisplay)
+ ON_BN_CLICKED(IDC_SYNCNEAREST, OnBnClickedSyncNearest)
END_MESSAGE_MAP()
void CPPageSync::OnBnClickedSyncVideo()
{
- m_bSynchronizeVideo = !m_bSynchronizeVideo;
- if(m_bSynchronizeVideo)
- {
- m_bSynchronizeDisplay = FALSE;
- m_bSynchronizeNearest = FALSE;
- }
- UpdateData(FALSE);
+ m_bSynchronizeVideo = !m_bSynchronizeVideo;
+ if (m_bSynchronizeVideo)
+ {
+ m_bSynchronizeDisplay = FALSE;
+ m_bSynchronizeNearest = FALSE;
+ }
+ UpdateData(FALSE);
}
void CPPageSync::OnBnClickedSyncDisplay()
{
- m_bSynchronizeDisplay = !m_bSynchronizeDisplay;
- if(m_bSynchronizeDisplay)
- {
- m_bSynchronizeVideo = FALSE;
- m_bSynchronizeNearest = FALSE;
- }
- UpdateData(FALSE);
+ m_bSynchronizeDisplay = !m_bSynchronizeDisplay;
+ if (m_bSynchronizeDisplay)
+ {
+ m_bSynchronizeVideo = FALSE;
+ m_bSynchronizeNearest = FALSE;
+ }
+ UpdateData(FALSE);
}
void CPPageSync::OnBnClickedSyncNearest()
{
- m_bSynchronizeNearest = !m_bSynchronizeNearest;
- if(m_bSynchronizeNearest)
- {
- m_bSynchronizeVideo = FALSE;
- m_bSynchronizeDisplay = FALSE;
- }
- UpdateData(FALSE);
+ m_bSynchronizeNearest = !m_bSynchronizeNearest;
+ if (m_bSynchronizeNearest)
+ {
+ m_bSynchronizeVideo = FALSE;
+ m_bSynchronizeDisplay = FALSE;
+ }
+ UpdateData(FALSE);
}
diff --git a/src/apps/mplayerc/PPageSync.h b/src/apps/mplayerc/PPageSync.h
index 9df13f476..410882bd0 100644
--- a/src/apps/mplayerc/PPageSync.h
+++ b/src/apps/mplayerc/PPageSync.h
@@ -25,34 +25,34 @@
class CPPageSync: public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSync)
+ DECLARE_DYNAMIC(CPPageSync)
public:
- CPPageSync();
- virtual ~CPPageSync();
+ CPPageSync();
+ virtual ~CPPageSync();
- enum {IDD = IDD_PPAGESYNC};
- BOOL m_bSynchronizeVideo;
- BOOL m_bSynchronizeDisplay;
- BOOL m_bSynchronizeNearest;
+ enum {IDD = IDD_PPAGESYNC};
+ BOOL m_bSynchronizeVideo;
+ BOOL m_bSynchronizeDisplay;
+ BOOL m_bSynchronizeNearest;
- int m_iLineDelta;
- int m_iColumnDelta;
- double m_fCycleDelta;
+ int m_iLineDelta;
+ int m_iColumnDelta;
+ double m_fCycleDelta;
- double m_fTargetSyncOffset;
- double m_fControlLimit;
+ double m_fTargetSyncOffset;
+ double m_fControlLimit;
protected:
- virtual void DoDataExchange(CDataExchange* pDX);
- virtual BOOL OnInitDialog();
- virtual BOOL OnSetActive();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX);
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnSetActive();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedSyncVideo();
- afx_msg void OnBnClickedSyncDisplay();
- afx_msg void OnBnClickedSyncNearest();
+ afx_msg void OnBnClickedSyncVideo();
+ afx_msg void OnBnClickedSyncDisplay();
+ afx_msg void OnBnClickedSyncNearest();
};
diff --git a/src/apps/mplayerc/PPageTweaks.cpp b/src/apps/mplayerc/PPageTweaks.cpp
index 49b463ace..164b7a6fa 100644
--- a/src/apps/mplayerc/PPageTweaks.cpp
+++ b/src/apps/mplayerc/PPageTweaks.cpp
@@ -31,22 +31,22 @@
IMPLEMENT_DYNAMIC(CPPageTweaks, CPPageBase)
CPPageTweaks::CPPageTweaks()
- : CPPageBase(CPPageTweaks::IDD, CPPageTweaks::IDD)
- , m_fDisableXPToolbars(FALSE)
- , m_fUseWMASFReader(FALSE)
- , m_nJumpDistS(0)
- , m_nJumpDistM(0)
- , m_nJumpDistL(0)
- , m_OSD_Size(0)
- , m_fNotifyMSN(TRUE)
- , m_fNotifyGTSdll(FALSE)
- , m_GTSdllLink(_T("https://sourceforge.net/project/showfiles.php?group_id=82303&package_id=169521&release_id=371114"))
- , m_fPreventMinimize(FALSE)
- , m_fUseWin7TaskBar(TRUE)
- , m_fDontUseSearchInFolder(FALSE)
+ : CPPageBase(CPPageTweaks::IDD, CPPageTweaks::IDD)
+ , m_fDisableXPToolbars(FALSE)
+ , m_fUseWMASFReader(FALSE)
+ , m_nJumpDistS(0)
+ , m_nJumpDistM(0)
+ , m_nJumpDistL(0)
+ , m_OSD_Size(0)
+ , m_fNotifyMSN(TRUE)
+ , m_fNotifyGTSdll(FALSE)
+ , m_GTSdllLink(_T("https://sourceforge.net/project/showfiles.php?group_id=82303&package_id=169521&release_id=371114"))
+ , m_fPreventMinimize(FALSE)
+ , m_fUseWin7TaskBar(TRUE)
+ , m_fDontUseSearchInFolder(FALSE)
{
- m_fWMASFReader = SUCCEEDED(CComPtr<IBaseFilter>().CoCreateInstance(
- GUIDFromCString(_T("{187463A0-5BB7-11D3-ACBE-0080C75E246E}")))); // WM ASF Reader
+ m_fWMASFReader = SUCCEEDED(CComPtr<IBaseFilter>().CoCreateInstance(
+ GUIDFromCString(_T("{187463A0-5BB7-11D3-ACBE-0080C75E246E}")))); // WM ASF Reader
}
CPPageTweaks::~CPPageTweaks()
@@ -55,121 +55,121 @@ CPPageTweaks::~CPPageTweaks()
void CPPageTweaks::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK3, m_fDisableXPToolbars);
- DDX_Control(pDX, IDC_CHECK3, m_fDisableXPToolbarsCtrl);
- DDX_Check(pDX, IDC_CHECK2, m_fUseWMASFReader);
- DDX_Control(pDX, IDC_CHECK2, m_fUseWMASFReaderCtrl);
- DDX_Text(pDX, IDC_EDIT1, m_nJumpDistS);
- DDX_Text(pDX, IDC_EDIT2, m_nJumpDistM);
- DDX_Text(pDX, IDC_EDIT3, m_nJumpDistL);
- DDX_Check(pDX, IDC_CHECK4, m_fNotifyMSN);
- DDX_Check(pDX, IDC_CHECK5, m_fNotifyGTSdll);
- DDX_Control(pDX, IDC_STATICLINKGTS, m_GTSdllLink);
- DDX_Check(pDX, IDC_CHECK6, m_fPreventMinimize);
- DDX_Check(pDX, IDC_CHECK_WIN7, m_fUseWin7TaskBar);
- DDX_Check(pDX, IDC_CHECK7, m_fDontUseSearchInFolder);
- DDX_Control(pDX, IDC_COMBO1, m_FontType);
- DDX_Control(pDX, IDC_COMBO2, m_FontSize);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK3, m_fDisableXPToolbars);
+ DDX_Control(pDX, IDC_CHECK3, m_fDisableXPToolbarsCtrl);
+ DDX_Check(pDX, IDC_CHECK2, m_fUseWMASFReader);
+ DDX_Control(pDX, IDC_CHECK2, m_fUseWMASFReaderCtrl);
+ DDX_Text(pDX, IDC_EDIT1, m_nJumpDistS);
+ DDX_Text(pDX, IDC_EDIT2, m_nJumpDistM);
+ DDX_Text(pDX, IDC_EDIT3, m_nJumpDistL);
+ DDX_Check(pDX, IDC_CHECK4, m_fNotifyMSN);
+ DDX_Check(pDX, IDC_CHECK5, m_fNotifyGTSdll);
+ DDX_Control(pDX, IDC_STATICLINKGTS, m_GTSdllLink);
+ DDX_Check(pDX, IDC_CHECK6, m_fPreventMinimize);
+ DDX_Check(pDX, IDC_CHECK_WIN7, m_fUseWin7TaskBar);
+ DDX_Check(pDX, IDC_CHECK7, m_fDontUseSearchInFolder);
+ DDX_Control(pDX, IDC_COMBO1, m_FontType);
+ DDX_Control(pDX, IDC_COMBO2, m_FontSize);
}
-
+
int CALLBACK EnumFontProc(ENUMLOGFONT FAR* lf, NEWTEXTMETRIC FAR* tm, int FontType, LPARAM dwData)
{
- CAtlArray<CString>* fntl = (CAtlArray<CString>*)dwData;
- if(FontType == TRUETYPE_FONTTYPE) fntl->Add(lf->elfFullName);
- return true;
+ CAtlArray<CString>* fntl = (CAtlArray<CString>*)dwData;
+ if(FontType == TRUETYPE_FONTTYPE) fntl->Add(lf->elfFullName);
+ return true;
}
BOOL CPPageTweaks::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_fDisableXPToolbars = s.fDisableXPToolbars;
- m_fUseWMASFReader = s.fUseWMASFReader;
- m_nJumpDistS = s.nJumpDistS;
- m_nJumpDistM = s.nJumpDistM;
- m_nJumpDistL = s.nJumpDistL;
- m_fNotifyMSN = s.fNotifyMSN;
- m_fNotifyGTSdll = s.fNotifyGTSdll;
-
- m_fPreventMinimize = s.m_fPreventMinimize;
- m_fUseWin7TaskBar = s.m_fUseWin7TaskBar;
- m_fDontUseSearchInFolder = s.m_fDontUseSearchInFolder;
-
- m_OSD_Size = s.nOSD_Size;
- m_OSD_Font = s.m_OSD_Font;
-
- CString str;
- int iSel = 0;
- m_FontType.Clear();
- m_FontSize.Clear();
- HDC dc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
- CAtlArray<CString> fntl;
- EnumFontFamilies(dc, NULL, (FONTENUMPROC)EnumFontProc, (LPARAM)&fntl);
- DeleteDC(dc);
- for(int i = 0; i < fntl.GetCount(); i++)
- {
- if(i > 0 && fntl[i-1] == fntl[i]) continue;
- m_FontType.AddString(fntl[i]);
- }
- for(int i = 0; i < m_FontType.GetCount(); i++)
- {
- m_FontType.GetLBText(i, str);
- if(m_OSD_Font == str) iSel = i;
- }
- m_FontType.SetCurSel(iSel);
-
- for(int i = 10; i < 26; i++)
- {
- str.Format(_T("%d"), i);
- m_FontSize.AddString(str);
- if(m_OSD_Size == i) iSel = i;
- }
- m_FontSize.SetCurSel(iSel - 10);
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_fDisableXPToolbars = s.fDisableXPToolbars;
+ m_fUseWMASFReader = s.fUseWMASFReader;
+ m_nJumpDistS = s.nJumpDistS;
+ m_nJumpDistM = s.nJumpDistM;
+ m_nJumpDistL = s.nJumpDistL;
+ m_fNotifyMSN = s.fNotifyMSN;
+ m_fNotifyGTSdll = s.fNotifyGTSdll;
+
+ m_fPreventMinimize = s.m_fPreventMinimize;
+ m_fUseWin7TaskBar = s.m_fUseWin7TaskBar;
+ m_fDontUseSearchInFolder =s.m_fDontUseSearchInFolder;
+
+ m_OSD_Size = s.nOSD_Size;
+ m_OSD_Font = s.m_OSD_Font;
+
+ CString str;
+ int iSel = 0;
+ m_FontType.Clear();
+ m_FontSize.Clear();
+ HDC dc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
+ CAtlArray<CString> fntl;
+ EnumFontFamilies(dc, NULL,(FONTENUMPROC)EnumFontProc, (LPARAM)&fntl);
+ DeleteDC(dc);
+ for (int i=0; i< fntl.GetCount(); i++)
+ {
+ if (i>0 && fntl[i-1] == fntl[i]) continue;
+ m_FontType.AddString(fntl[i]);
+ }
+ for (int i=0; i< m_FontType.GetCount(); i++)
+ {
+ m_FontType.GetLBText(i,str);
+ if (m_OSD_Font == str) iSel=i;
+ }
+ m_FontType.SetCurSel(iSel);
+
+ for (int i=10; i<26; i++)
+ {
+ str.Format(_T("%d"), i);
+ m_FontSize.AddString(str);
+ if (m_OSD_Size == i) iSel=i;
+ }
+ m_FontSize.SetCurSel(iSel-10);
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageTweaks::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.fDisableXPToolbars = !!m_fDisableXPToolbars;
- s.fUseWMASFReader = !!m_fUseWMASFReader;
- s.nJumpDistS = m_nJumpDistS;
- s.nJumpDistM = m_nJumpDistM;
- s.nJumpDistL = m_nJumpDistL;
- s.fNotifyMSN = !!m_fNotifyMSN;
- s.fNotifyGTSdll = !!m_fNotifyGTSdll;
+ s.fDisableXPToolbars = !!m_fDisableXPToolbars;
+ s.fUseWMASFReader = !!m_fUseWMASFReader;
+ s.nJumpDistS = m_nJumpDistS;
+ s.nJumpDistM = m_nJumpDistM;
+ s.nJumpDistL = m_nJumpDistL;
+ s.fNotifyMSN = !!m_fNotifyMSN;
+ s.fNotifyGTSdll = !!m_fNotifyGTSdll;
- s.m_fPreventMinimize = m_fPreventMinimize;
- s.m_fUseWin7TaskBar = m_fUseWin7TaskBar;
- s.m_fDontUseSearchInFolder = m_fDontUseSearchInFolder;
- s.nOSD_Size = m_OSD_Size;
- m_FontType.GetLBText(m_FontType.GetCurSel(), s.m_OSD_Font);
+ s.m_fPreventMinimize = m_fPreventMinimize;
+ s.m_fUseWin7TaskBar = m_fUseWin7TaskBar;
+ s.m_fDontUseSearchInFolder = m_fDontUseSearchInFolder;
+ s.nOSD_Size = m_OSD_Size;
+ m_FontType.GetLBText(m_FontType.GetCurSel(),s.m_OSD_Font);
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if(m_fUseWin7TaskBar) pFrame->CreateThumbnailToolbar();
- pFrame->UpdateThumbarButton();
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if(m_fUseWin7TaskBar) pFrame->CreateThumbnailToolbar();
+ pFrame->UpdateThumbarButton();
- return __super::OnApply();
+ return __super::OnApply();
}
BEGIN_MESSAGE_MAP(CPPageTweaks, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateCheck3)
- ON_UPDATE_COMMAND_UI(IDC_CHECK2, OnUpdateCheck2)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnChngOSDCombo)
- ON_CBN_SELCHANGE(IDC_COMBO2, OnChngOSDCombo)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateCheck3)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK2, OnUpdateCheck2)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnChngOSDCombo)
+ ON_CBN_SELCHANGE(IDC_COMBO2, OnChngOSDCombo)
END_MESSAGE_MAP()
@@ -177,32 +177,32 @@ END_MESSAGE_MAP()
void CPPageTweaks::OnUpdateCheck3(CCmdUI* pCmdUI)
{
- if(!AfxGetAppSettings().fXpOrBetter)
- {
- pCmdUI->Enable(FALSE);
- pCmdUI->SetCheck(TRUE);
- }
+ if(!AfxGetAppSettings().fXpOrBetter)
+ {
+ pCmdUI->Enable(FALSE);
+ pCmdUI->SetCheck(TRUE);
+ }
}
void CPPageTweaks::OnUpdateCheck2(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_fWMASFReader);
+ pCmdUI->Enable(m_fWMASFReader);
}
void CPPageTweaks::OnBnClickedButton1()
{
- m_nJumpDistS = 1000;
- m_nJumpDistM = 5000;
- m_nJumpDistL = 20000;
+ m_nJumpDistS = 1000;
+ m_nJumpDistM = 5000;
+ m_nJumpDistL = 20000;
- UpdateData(FALSE);
+ UpdateData(FALSE);
}
void CPPageTweaks::OnChngOSDCombo()
-{
- CString str;
- m_OSD_Size = m_FontSize.GetCurSel() + 10;
- m_FontType.GetLBText(m_FontType.GetCurSel(), str);
- ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, _T("Test"), 2000, m_OSD_Size, str);
- SetModified();
+{
+ CString str;
+ m_OSD_Size = m_FontSize.GetCurSel()+10;
+ m_FontType.GetLBText(m_FontType.GetCurSel(),str);
+ ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, _T("Test"), 2000, m_OSD_Size, str);
+ SetModified();
}
diff --git a/src/apps/mplayerc/PPageTweaks.h b/src/apps/mplayerc/PPageTweaks.h
index 6a2d02b9b..239f234ca 100644
--- a/src/apps/mplayerc/PPageTweaks.h
+++ b/src/apps/mplayerc/PPageTweaks.h
@@ -30,47 +30,47 @@
class CPPageTweaks : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageTweaks)
+ DECLARE_DYNAMIC(CPPageTweaks)
private:
- bool m_fWMASFReader;
+ bool m_fWMASFReader;
public:
- CPPageTweaks();
- virtual ~CPPageTweaks();
+ CPPageTweaks();
+ virtual ~CPPageTweaks();
- BOOL m_fDisableXPToolbars;
- CButton m_fDisableXPToolbarsCtrl;
- BOOL m_fUseWMASFReader;
- CButton m_fUseWMASFReaderCtrl;
+ BOOL m_fDisableXPToolbars;
+ CButton m_fDisableXPToolbarsCtrl;
+ BOOL m_fUseWMASFReader;
+ CButton m_fUseWMASFReaderCtrl;
// Dialog Data
- enum { IDD = IDD_PPAGETWEAKS };
- int m_nJumpDistS;
- int m_nJumpDistM;
- int m_nJumpDistL;
- BOOL m_fNotifyMSN;
- BOOL m_fNotifyGTSdll;
- CStaticLink m_GTSdllLink;
+ enum { IDD = IDD_PPAGETWEAKS };
+ int m_nJumpDistS;
+ int m_nJumpDistM;
+ int m_nJumpDistL;
+ BOOL m_fNotifyMSN;
+ BOOL m_fNotifyGTSdll;
+ CStaticLink m_GTSdllLink;
- BOOL m_fPreventMinimize;
- BOOL m_fUseWin7TaskBar;
- BOOL m_fDontUseSearchInFolder;
- CComboBox m_FontSize;
- CComboBox m_FontType;
- int m_OSD_Size;
- CString m_OSD_Font;
+ BOOL m_fPreventMinimize;
+ BOOL m_fUseWin7TaskBar;
+ BOOL m_fDontUseSearchInFolder;
+ CComboBox m_FontSize;
+ CComboBox m_FontType;
+ int m_OSD_Size;
+ CString m_OSD_Font;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateCheck3(CCmdUI* pCmdUI);
- afx_msg void OnUpdateCheck2(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnChngOSDCombo();
+ afx_msg void OnUpdateCheck3(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateCheck2(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnChngOSDCombo();
};
diff --git a/src/apps/mplayerc/PPageWebServer.cpp b/src/apps/mplayerc/PPageWebServer.cpp
index 8ace1a99a..75db49fd8 100644
--- a/src/apps/mplayerc/PPageWebServer.cpp
+++ b/src/apps/mplayerc/PPageWebServer.cpp
@@ -31,17 +31,17 @@
IMPLEMENT_DYNAMIC(CPPageWebServer, CPPageBase)
CPPageWebServer::CPPageWebServer()
- : CPPageBase(CPPageWebServer::IDD, CPPageWebServer::IDD)
- , m_fEnableWebServer(FALSE)
- , m_nWebServerPort(0)
- , m_launch(_T("http://localhost:13579/"))
- , m_fWebServerPrintDebugInfo(FALSE)
- , m_fWebServerUseCompression(FALSE)
- , m_fWebRoot(FALSE)
- , m_WebRoot(_T(""))
- , m_fWebServerLocalhostOnly(FALSE)
- , m_WebServerCGI(_T(""))
- , m_WebDefIndex(_T(""))
+ : CPPageBase(CPPageWebServer::IDD, CPPageWebServer::IDD)
+ , m_fEnableWebServer(FALSE)
+ , m_nWebServerPort(0)
+ , m_launch(_T("http://localhost:13579/"))
+ , m_fWebServerPrintDebugInfo(FALSE)
+ , m_fWebServerUseCompression(FALSE)
+ , m_fWebRoot(FALSE)
+ , m_WebRoot(_T(""))
+ , m_fWebServerLocalhostOnly(FALSE)
+ , m_WebServerCGI(_T(""))
+ , m_WebDefIndex(_T(""))
{
}
@@ -51,164 +51,164 @@ CPPageWebServer::~CPPageWebServer()
void CPPageWebServer::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK1, m_fEnableWebServer);
- DDX_Text(pDX, IDC_EDIT1, m_nWebServerPort);
- DDX_Control(pDX, IDC_EDIT1, m_nWebServerPortCtrl);
- DDX_Control(pDX, IDC_STATIC1, m_launch);
- DDX_Check(pDX, IDC_CHECK2, m_fWebServerPrintDebugInfo);
- DDX_Check(pDX, IDC_CHECK3, m_fWebServerUseCompression);
- DDX_Check(pDX, IDC_CHECK4, m_fWebRoot);
- DDX_Text(pDX, IDC_EDIT2, m_WebRoot);
- DDX_Check(pDX, IDC_CHECK5, m_fWebServerLocalhostOnly);
- DDX_Text(pDX, IDC_EDIT3, m_WebServerCGI);
- DDX_Text(pDX, IDC_EDIT9, m_WebDefIndex);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK1, m_fEnableWebServer);
+ DDX_Text(pDX, IDC_EDIT1, m_nWebServerPort);
+ DDX_Control(pDX, IDC_EDIT1, m_nWebServerPortCtrl);
+ DDX_Control(pDX, IDC_STATIC1, m_launch);
+ DDX_Check(pDX, IDC_CHECK2, m_fWebServerPrintDebugInfo);
+ DDX_Check(pDX, IDC_CHECK3, m_fWebServerUseCompression);
+ DDX_Check(pDX, IDC_CHECK4, m_fWebRoot);
+ DDX_Text(pDX, IDC_EDIT2, m_WebRoot);
+ DDX_Check(pDX, IDC_CHECK5, m_fWebServerLocalhostOnly);
+ DDX_Text(pDX, IDC_EDIT3, m_WebServerCGI);
+ DDX_Text(pDX, IDC_EDIT9, m_WebDefIndex);
}
BOOL CPPageWebServer::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_launch.m_hWnd)
- {
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- if(CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd())
- {
- if(m_fEnableWebServer)
- {
- if(s.nWebServerPort != m_nWebServerPort)
- {
- AfxMessageBox(_T("Press apply first, before testing the new settings!"), MB_OK);
- return TRUE;
- }
- }
- }
- }
-
- return CPPageBase::PreTranslateMessage(pMsg);
+ if(pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_launch.m_hWnd)
+ {
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if(CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd())
+ {
+ if(m_fEnableWebServer)
+ {
+ if(s.nWebServerPort != m_nWebServerPort)
+ {
+ AfxMessageBox(_T("Press apply first, before testing the new settings!"), MB_OK);
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return CPPageBase::PreTranslateMessage(pMsg);
}
BOOL CPPageWebServer::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_fEnableWebServer = s.fEnableWebServer;
- m_nWebServerPort = s.nWebServerPort;
- m_fWebServerPrintDebugInfo = s.fWebServerPrintDebugInfo;
- m_fWebServerLocalhostOnly = s.fWebServerLocalhostOnly;
- m_fWebServerUseCompression = s.fWebServerUseCompression;
- m_fWebRoot = s.WebRoot.Find('*') < 0;
- m_WebRoot = s.WebRoot;
- m_WebRoot.TrimLeft(_T("*"));
- m_WebDefIndex = s.WebDefIndex;
- m_WebServerCGI = s.WebServerCGI;
+ m_fEnableWebServer = s.fEnableWebServer;
+ m_nWebServerPort = s.nWebServerPort;
+ m_fWebServerPrintDebugInfo = s.fWebServerPrintDebugInfo;
+ m_fWebServerLocalhostOnly = s.fWebServerLocalhostOnly;
+ m_fWebServerUseCompression = s.fWebServerUseCompression;
+ m_fWebRoot = s.WebRoot.Find('*') < 0;
+ m_WebRoot = s.WebRoot;
+ m_WebRoot.TrimLeft(_T("*"));
+ m_WebDefIndex = s.WebDefIndex;
+ m_WebServerCGI = s.WebServerCGI;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- OnEnChangeEdit1();
+ OnEnChangeEdit1();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageWebServer::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- CString NewWebRoot = m_WebRoot;
- if(!m_fWebRoot) NewWebRoot = _T("*") + NewWebRoot;
-
- bool fRestart = s.nWebServerPort != m_nWebServerPort
- || s.WebRoot != NewWebRoot || s.WebServerCGI != m_WebServerCGI;
-
- s.fEnableWebServer = !!m_fEnableWebServer;
- s.nWebServerPort = m_nWebServerPort;
- s.fWebServerPrintDebugInfo = !!m_fWebServerPrintDebugInfo;
- s.fWebServerLocalhostOnly = !!m_fWebServerLocalhostOnly;
- s.fWebServerUseCompression = !!m_fWebServerUseCompression;
- s.WebRoot = NewWebRoot;
- s.WebDefIndex = m_WebDefIndex;
- s.WebServerCGI = m_WebServerCGI;
-
- if(CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd())
- {
- if(m_fEnableWebServer)
- {
- if(fRestart) pWnd->StopWebServer();
- pWnd->StartWebServer(m_nWebServerPort);
- }
- else
- {
- pWnd->StopWebServer();
- }
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CString NewWebRoot = m_WebRoot;
+ if(!m_fWebRoot) NewWebRoot = _T("*") + NewWebRoot;
+
+ bool fRestart = s.nWebServerPort != m_nWebServerPort
+ || s.WebRoot != NewWebRoot || s.WebServerCGI != m_WebServerCGI;
+
+ s.fEnableWebServer = !!m_fEnableWebServer;
+ s.nWebServerPort = m_nWebServerPort;
+ s.fWebServerPrintDebugInfo = !!m_fWebServerPrintDebugInfo;
+ s.fWebServerLocalhostOnly = !!m_fWebServerLocalhostOnly;
+ s.fWebServerUseCompression = !!m_fWebServerUseCompression;
+ s.WebRoot = NewWebRoot;
+ s.WebDefIndex = m_WebDefIndex;
+ s.WebServerCGI = m_WebServerCGI;
+
+ if(CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd())
+ {
+ if(m_fEnableWebServer)
+ {
+ if(fRestart) pWnd->StopWebServer();
+ pWnd->StartWebServer(m_nWebServerPort);
+ }
+ else
+ {
+ pWnd->StopWebServer();
+ }
+ }
+
+ return __super::OnApply();
}
CString CPPageWebServer::GetMPCDir()
{
- CString dir;
- GetModuleFileName(AfxGetInstanceHandle(), dir.GetBuffer(MAX_PATH), MAX_PATH);
- dir.ReleaseBuffer();
- CPath path(dir);
- path.RemoveFileSpec();
- return (LPCTSTR)path;
+ CString dir;
+ GetModuleFileName(AfxGetInstanceHandle(), dir.GetBuffer(MAX_PATH), MAX_PATH);
+ dir.ReleaseBuffer();
+ CPath path(dir);
+ path.RemoveFileSpec();
+ return (LPCTSTR)path;
}
CString CPPageWebServer::GetCurWebRoot()
{
- CString WebRoot;
- GetDlgItem(IDC_EDIT2)->GetWindowText(WebRoot);
- WebRoot.Replace('/', '\\');
+ CString WebRoot;
+ GetDlgItem(IDC_EDIT2)->GetWindowText(WebRoot);
+ WebRoot.Replace('/', '\\');
- CPath path;
- path.Combine(GetMPCDir(), WebRoot);
- return path.IsDirectory() ? (LPCTSTR)path : _T("");
+ CPath path;
+ path.Combine(GetMPCDir(), WebRoot);
+ return path.IsDirectory() ? (LPCTSTR)path : _T("");
}
static int __stdcall BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
- if(uMsg == BFFM_INITIALIZED && lpData)
- ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
- return 0;
+ if(uMsg == BFFM_INITIALIZED && lpData)
+ ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
+ return 0;
}
bool CPPageWebServer::PickDir(CString& dir)
{
- TCHAR buff[_MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = buff;
- bi.lpszTitle = ResStr(IDS_PPAGEWEBSERVER_0);
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI;
- bi.lpfn = BrowseCtrlCallback;
- bi.lParam = (LPARAM)(LPCTSTR)dir;
- bi.iImage = 0;
-
- LPITEMIDLIST iil;
- if(iil = SHBrowseForFolder(&bi))
- {
- SHGetPathFromIDList(iil, buff);
- dir = buff;
- return true;
- }
-
- return false;
+ TCHAR buff[_MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = buff;
+ bi.lpszTitle = ResStr(IDS_PPAGEWEBSERVER_0);
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI;
+ bi.lpfn = BrowseCtrlCallback;
+ bi.lParam = (LPARAM)(LPCTSTR)dir;
+ bi.iImage = 0;
+
+ LPITEMIDLIST iil;
+ if(iil = SHBrowseForFolder(&bi))
+ {
+ SHGetPathFromIDList(iil, buff);
+ dir = buff;
+ return true;
+ }
+
+ return false;
}
BEGIN_MESSAGE_MAP(CPPageWebServer, CPPageBase)
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton2)
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton2)
END_MESSAGE_MAP()
@@ -217,39 +217,39 @@ END_MESSAGE_MAP()
void CPPageWebServer::OnEnChangeEdit1()
{
- UpdateData();
+ UpdateData();
- CString link;
- link.Format(_T("http://localhost:%d/"), m_nWebServerPort);
- m_launch.m_link = link;
+ CString link;
+ link.Format(_T("http://localhost:%d/"), m_nWebServerPort);
+ m_launch.m_link = link;
- SetModified();
+ SetModified();
}
void CPPageWebServer::OnBnClickedButton1()
{
- CString dir = GetCurWebRoot();
- if(PickDir(dir))
- {
- CPath path;
- if(path.RelativePathTo(GetMPCDir(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY))
- dir = (LPCTSTR)path;
- m_WebRoot = dir;
- UpdateData(FALSE);
- }
+ CString dir = GetCurWebRoot();
+ if(PickDir(dir))
+ {
+ CPath path;
+ if(path.RelativePathTo(GetMPCDir(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY))
+ dir = (LPCTSTR)path;
+ m_WebRoot = dir;
+ UpdateData(FALSE);
+ }
}
void CPPageWebServer::OnBnClickedButton2()
{
- CString dir;
- if(PickDir(dir))
- {
- dir += _T("\\");
- CWebServer::Deploy(dir);
- }
+ CString dir;
+ if(PickDir(dir))
+ {
+ dir += _T("\\");
+ CWebServer::Deploy(dir);
+ }
}
void CPPageWebServer::OnUpdateButton2(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(GetDlgItem(IDC_EDIT2)->GetWindowTextLength() > 0);
+ pCmdUI->Enable(GetDlgItem(IDC_EDIT2)->GetWindowTextLength() > 0);
}
diff --git a/src/apps/mplayerc/PPageWebServer.h b/src/apps/mplayerc/PPageWebServer.h
index bdfd6cfa9..80271add5 100644
--- a/src/apps/mplayerc/PPageWebServer.h
+++ b/src/apps/mplayerc/PPageWebServer.h
@@ -32,42 +32,42 @@
class CPPageWebServer : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageWebServer)
+ DECLARE_DYNAMIC(CPPageWebServer)
private:
- CString GetMPCDir();
- CString GetCurWebRoot();
- bool PickDir(CString& dir);
+ CString GetMPCDir();
+ CString GetCurWebRoot();
+ bool PickDir(CString& dir);
public:
- CPPageWebServer();
- virtual ~CPPageWebServer();
+ CPPageWebServer();
+ virtual ~CPPageWebServer();
// Dialog Data
- enum { IDD = IDD_PPAGEWEBSERVER };
- BOOL m_fEnableWebServer;
- int m_nWebServerPort;
- CIntEdit m_nWebServerPortCtrl;
- CStaticLink m_launch;
- BOOL m_fWebServerPrintDebugInfo;
- BOOL m_fWebServerUseCompression;
- BOOL m_fWebServerLocalhostOnly;
- BOOL m_fWebRoot;
- CString m_WebRoot;
- CString m_WebServerCGI;
- CString m_WebDefIndex;
+ enum { IDD = IDD_PPAGEWEBSERVER };
+ BOOL m_fEnableWebServer;
+ int m_nWebServerPort;
+ CIntEdit m_nWebServerPortCtrl;
+ CStaticLink m_launch;
+ BOOL m_fWebServerPrintDebugInfo;
+ BOOL m_fWebServerUseCompression;
+ BOOL m_fWebServerLocalhostOnly;
+ BOOL m_fWebRoot;
+ CString m_WebRoot;
+ CString m_WebServerCGI;
+ CString m_WebDefIndex;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/PixelShaderCompiler.cpp b/src/apps/mplayerc/PixelShaderCompiler.cpp
index f91c9a82c..43e96a812 100644
--- a/src/apps/mplayerc/PixelShaderCompiler.cpp
+++ b/src/apps/mplayerc/PixelShaderCompiler.cpp
@@ -27,30 +27,30 @@
CPixelShaderCompiler::CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStaySilent)
- : m_pD3DDev(pD3DDev)
- , m_pD3DXCompileShader(NULL)
- , m_pD3DXDisassembleShader(NULL)
+ : m_pD3DDev(pD3DDev)
+ , m_pD3DXCompileShader(NULL)
+ , m_pD3DXDisassembleShader(NULL)
{
- HINSTANCE hDll;
- hDll = AfxGetMyApp()->GetD3X9Dll();
-
- if(hDll)
- {
- m_pD3DXCompileShader = (D3DXCompileShaderPtr)GetProcAddress(hDll, "D3DXCompileShader");
- m_pD3DXDisassembleShader = (D3DXDisassembleShaderPtr)GetProcAddress(hDll, "D3DXDisassembleShader");
- }
-
- if(!fStaySilent)
- {
- if(!hDll)
- {
- AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_0), MB_OK);
- }
- else if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader)
- {
- AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_1), MB_OK);
- }
- }
+ HINSTANCE hDll;
+ hDll = AfxGetMyApp()->GetD3X9Dll();
+
+ if(hDll)
+ {
+ m_pD3DXCompileShader = (D3DXCompileShaderPtr)GetProcAddress(hDll, "D3DXCompileShader");
+ m_pD3DXDisassembleShader = (D3DXDisassembleShaderPtr)GetProcAddress(hDll, "D3DXDisassembleShader");
+ }
+
+ if(!fStaySilent)
+ {
+ if(!hDll)
+ {
+ AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_0), MB_OK);
+ }
+ else if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader)
+ {
+ AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_1), MB_OK);
+ }
+ }
}
CPixelShaderCompiler::~CPixelShaderCompiler()
@@ -63,47 +63,47 @@ HRESULT CPixelShaderCompiler::CompileShader(
LPCSTR pProfile,
DWORD Flags,
IDirect3DPixelShader9** ppPixelShader,
- CString* disasm,
- CString* errmsg)
+ CString* disasm,
+ CString* errmsg)
{
- if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader)
- return E_FAIL;
-
- HRESULT hr;
-
- CComPtr<ID3DXBuffer> pShader, pDisAsm, pErrorMsgs;
- hr = m_pD3DXCompileShader(pSrcData, strlen(pSrcData), NULL, NULL, pFunctionName, pProfile, Flags, &pShader, &pErrorMsgs, NULL);
-
- if(FAILED(hr))
- {
- if(errmsg)
- {
- CStringA msg = "Unexpected compiler error";
-
- if(pErrorMsgs)
- {
- int len = pErrorMsgs->GetBufferSize();
- memcpy(msg.GetBufferSetLength(len), pErrorMsgs->GetBufferPointer(), len);
- }
-
- *errmsg = msg;
- }
-
- return hr;
- }
-
- if(ppPixelShader)
- {
- if(!m_pD3DDev) return E_FAIL;
- hr = m_pD3DDev->CreatePixelShader((DWORD*)pShader->GetBufferPointer(), ppPixelShader);
- if(FAILED(hr)) return hr;
- }
-
- if(disasm)
- {
- hr = m_pD3DXDisassembleShader((DWORD*)pShader->GetBufferPointer(), FALSE, NULL, &pDisAsm);
- if(SUCCEEDED(hr) && pDisAsm) *disasm = CStringA((const char*)pDisAsm->GetBufferPointer());
- }
-
- return S_OK;
+ if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader)
+ return E_FAIL;
+
+ HRESULT hr;
+
+ CComPtr<ID3DXBuffer> pShader, pDisAsm, pErrorMsgs;
+ hr = m_pD3DXCompileShader(pSrcData, strlen(pSrcData), NULL, NULL, pFunctionName, pProfile, Flags, &pShader, &pErrorMsgs, NULL);
+
+ if(FAILED(hr))
+ {
+ if(errmsg)
+ {
+ CStringA msg = "Unexpected compiler error";
+
+ if(pErrorMsgs)
+ {
+ int len = pErrorMsgs->GetBufferSize();
+ memcpy(msg.GetBufferSetLength(len), pErrorMsgs->GetBufferPointer(), len);
+ }
+
+ *errmsg = msg;
+ }
+
+ return hr;
+ }
+
+ if(ppPixelShader)
+ {
+ if(!m_pD3DDev) return E_FAIL;
+ hr = m_pD3DDev->CreatePixelShader((DWORD*)pShader->GetBufferPointer(), ppPixelShader);
+ if(FAILED(hr)) return hr;
+ }
+
+ if(disasm)
+ {
+ hr = m_pD3DXDisassembleShader((DWORD*)pShader->GetBufferPointer(), FALSE, NULL, &pDisAsm);
+ if(SUCCEEDED(hr) && pDisAsm) *disasm = CStringA((const char*)pDisAsm->GetBufferPointer());
+ }
+
+ return S_OK;
}
diff --git a/src/apps/mplayerc/PixelShaderCompiler.h b/src/apps/mplayerc/PixelShaderCompiler.h
index 29be88c85..c5e90a991 100644
--- a/src/apps/mplayerc/PixelShaderCompiler.h
+++ b/src/apps/mplayerc/PixelShaderCompiler.h
@@ -28,7 +28,7 @@
class CPixelShaderCompiler
{
- typedef HRESULT(WINAPI * D3DXCompileShaderPtr)(
+ typedef HRESULT (WINAPI * D3DXCompileShaderPtr) (
LPCSTR pSrcData,
UINT SrcDataLen,
CONST D3DXMACRO* pDefines,
@@ -40,27 +40,27 @@ class CPixelShaderCompiler
LPD3DXBUFFER* ppErrorMsgs,
LPD3DXCONSTANTTABLE* ppConstantTable);
- typedef HRESULT(WINAPI * D3DXDisassembleShaderPtr)(
- CONST DWORD* pShader,
- bool EnableColorCode,
- LPCSTR pComments,
+ typedef HRESULT (WINAPI * D3DXDisassembleShaderPtr) (
+ CONST DWORD* pShader,
+ bool EnableColorCode,
+ LPCSTR pComments,
LPD3DXBUFFER* ppDisassembly);
+
+ D3DXCompileShaderPtr m_pD3DXCompileShader;
+ D3DXDisassembleShaderPtr m_pD3DXDisassembleShader;
- D3DXCompileShaderPtr m_pD3DXCompileShader;
- D3DXDisassembleShaderPtr m_pD3DXDisassembleShader;
-
- CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
public:
- CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStaySilent = false);
- virtual ~CPixelShaderCompiler();
+ CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStaySilent = false);
+ virtual ~CPixelShaderCompiler();
- HRESULT CompileShader(
+ HRESULT CompileShader(
LPCSTR pSrcData,
LPCSTR pFunctionName,
LPCSTR pProfile,
DWORD Flags,
IDirect3DPixelShader9** ppPixelShader,
- CString* disasm = NULL,
- CString* errmsg = NULL);
+ CString* disasm = NULL,
+ CString* errmsg = NULL);
};
diff --git a/src/apps/mplayerc/PlayerCaptureBar.cpp b/src/apps/mplayerc/PlayerCaptureBar.cpp
index 1b802d84b..b4520c432 100644
--- a/src/apps/mplayerc/PlayerCaptureBar.cpp
+++ b/src/apps/mplayerc/PlayerCaptureBar.cpp
@@ -40,32 +40,32 @@ CPlayerCaptureBar::~CPlayerCaptureBar()
BOOL CPlayerCaptureBar::Create(CWnd* pParentWnd)
{
- if(!baseCPlayerCaptureBar::Create(_T("Capture Settings"), pParentWnd, 0))
- return FALSE;
+ if(!baseCPlayerCaptureBar::Create(_T("Capture Settings"), pParentWnd, 0))
+ return FALSE;
- m_capdlg.Create(this);
- m_capdlg.ShowWindow(SW_SHOWNORMAL);
+ m_capdlg.Create(this);
+ m_capdlg.ShowWindow(SW_SHOWNORMAL);
- CRect r;
- m_capdlg.GetWindowRect(r);
- m_szMinVert = m_szVert = r.Size();
- m_szMinHorz = m_szHorz = r.Size();
- m_szMinFloat = m_szFloat = r.Size();
- m_bFixedFloat = true;
- m_szFixedFloat = r.Size();
+ CRect r;
+ m_capdlg.GetWindowRect(r);
+ m_szMinVert = m_szVert = r.Size();
+ m_szMinHorz = m_szHorz = r.Size();
+ m_szMinFloat = m_szFloat = r.Size();
+ m_bFixedFloat = true;
+ m_szFixedFloat = r.Size();
- return TRUE;
+ return TRUE;
}
BOOL CPlayerCaptureBar::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
- {
- if(IsDialogMessage(pMsg))
- return TRUE;
- }
+ if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
+ {
+ if(IsDialogMessage(pMsg))
+ return TRUE;
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerCaptureBar, baseCPlayerCaptureBar)
diff --git a/src/apps/mplayerc/PlayerCaptureBar.h b/src/apps/mplayerc/PlayerCaptureBar.h
index 8960edc8f..43c4da461 100644
--- a/src/apps/mplayerc/PlayerCaptureBar.h
+++ b/src/apps/mplayerc/PlayerCaptureBar.h
@@ -34,19 +34,19 @@
class CPlayerCaptureBar : public baseCPlayerCaptureBar
{
- DECLARE_DYNAMIC(CPlayerCaptureBar)
+ DECLARE_DYNAMIC(CPlayerCaptureBar)
public:
- CPlayerCaptureBar();
- virtual ~CPlayerCaptureBar();
+ CPlayerCaptureBar();
+ virtual ~CPlayerCaptureBar();
- BOOL Create(CWnd* pParentWnd);
+ BOOL Create(CWnd* pParentWnd);
public:
- CPlayerCaptureDialog m_capdlg;
+ CPlayerCaptureDialog m_capdlg;
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/apps/mplayerc/PlayerCaptureDialog.cpp b/src/apps/mplayerc/PlayerCaptureDialog.cpp
index 9e9534bef..f6efa78c7 100644
--- a/src/apps/mplayerc/PlayerCaptureDialog.cpp
+++ b/src/apps/mplayerc/PlayerCaptureDialog.cpp
@@ -34,126 +34,126 @@
static bool LoadMediaType(CStringW DisplayName, AM_MEDIA_TYPE** ppmt)
{
- bool fRet = false;
-
- if(!ppmt) return(fRet);
-
- *ppmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- if(!*ppmt) return(fRet);
-
- memset(*ppmt, 0, sizeof(AM_MEDIA_TYPE));
-
- BYTE* pData;
- UINT len;
- if(AfxGetApp()->GetProfileBinary(_T("Capture\\") + CString(DisplayName), _T("MediaType"), &pData, &len))
- {
- if(len != sizeof(AM_MEDIA_TYPE))
- {
- delete [] pData;
- return(fRet);
- }
- memcpy(*ppmt, pData, len);
- delete [] pData;
-
- (*ppmt)->cbFormat = 0;
- (*ppmt)->pbFormat = NULL;
-
- fRet = true;
-
- if(AfxGetApp()->GetProfileBinary(_T("Capture\\") + CString(DisplayName), _T("Format"), &pData, &len))
- {
- if(!len)
- {
- delete [] pData;
- return(fRet);
- }
- (*ppmt)->cbFormat = len;
- (*ppmt)->pbFormat = (BYTE*)CoTaskMemAlloc(len);
- memcpy((*ppmt)->pbFormat, pData, len);
- delete [] pData;
-
- }
- }
-
- return(fRet);
+ bool fRet = false;
+
+ if(!ppmt) return(fRet);
+
+ *ppmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ if(!*ppmt) return(fRet);
+
+ memset(*ppmt, 0, sizeof(AM_MEDIA_TYPE));
+
+ BYTE* pData;
+ UINT len;
+ if(AfxGetApp()->GetProfileBinary(_T("Capture\\") + CString(DisplayName), _T("MediaType"), &pData, &len))
+ {
+ if ( len != sizeof(AM_MEDIA_TYPE) )
+ {
+ delete [] pData;
+ return(fRet);
+ }
+ memcpy(*ppmt, pData, len);
+ delete [] pData;
+
+ (*ppmt)->cbFormat = 0;
+ (*ppmt)->pbFormat = NULL;
+
+ fRet = true;
+
+ if(AfxGetApp()->GetProfileBinary(_T("Capture\\") + CString(DisplayName), _T("Format"), &pData, &len))
+ {
+ if ( !len )
+ {
+ delete [] pData;
+ return(fRet);
+ }
+ (*ppmt)->cbFormat = len;
+ (*ppmt)->pbFormat = (BYTE*)CoTaskMemAlloc(len);
+ memcpy((*ppmt)->pbFormat, pData, len);
+ delete [] pData;
+
+ }
+ }
+
+ return(fRet);
}
static void SaveMediaType(CStringW DisplayName, AM_MEDIA_TYPE* pmt)
{
- if(DisplayName.IsEmpty() || !pmt) return;
+ if(DisplayName.IsEmpty() || !pmt) return;
- AfxGetApp()->WriteProfileBinary(_T("Capture\\") + CString(DisplayName), _T("MediaType"), (BYTE*)pmt, sizeof(AM_MEDIA_TYPE));
- AfxGetApp()->WriteProfileBinary(_T("Capture\\") + CString(DisplayName), _T("Format"), pmt->pbFormat, pmt->cbFormat);
+ AfxGetApp()->WriteProfileBinary(_T("Capture\\") + CString(DisplayName), _T("MediaType"), (BYTE*)pmt, sizeof(AM_MEDIA_TYPE));
+ AfxGetApp()->WriteProfileBinary(_T("Capture\\") + CString(DisplayName), _T("Format"), pmt->pbFormat, pmt->cbFormat);
}
static void LoadDefaultCodec(CAtlArray<Codec>& codecs, CComboBox& box, const GUID& cat)
{
- int len = box.GetCount();
- if(len >= 0) box.SetCurSel(0);
-
- if(cat == GUID_NULL) return;
-
- CString DisplayName = AfxGetApp()->GetProfileString(_T("Capture\\") + CStringFromGUID(cat), _T("DisplayName"));
-
- for(int i = 0; i < len; i++)
- {
- int iSel = box.GetItemData(i);
- if(iSel < 0) continue;
-
- Codec& c = codecs[iSel];
- if(DisplayName == c.DisplayName)
- {
- box.SetCurSel(i);
- if(!c.pBF)
- c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
- break;
- }
- }
+ int len = box.GetCount();
+ if(len >= 0) box.SetCurSel(0);
+
+ if(cat == GUID_NULL) return;
+
+ CString DisplayName = AfxGetApp()->GetProfileString(_T("Capture\\") + CStringFromGUID(cat), _T("DisplayName"));
+
+ for(int i = 0; i < len; i++)
+ {
+ int iSel = box.GetItemData(i);
+ if(iSel < 0) continue;
+
+ Codec& c = codecs[iSel];
+ if(DisplayName == c.DisplayName)
+ {
+ box.SetCurSel(i);
+ if(!c.pBF)
+ c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
+ break;
+ }
+ }
}
static void SaveDefaultCodec(CAtlArray<Codec>& codecs, CComboBox& box, const GUID& cat)
{
- if(cat == GUID_NULL) return;
+ if(cat == GUID_NULL) return;
- CString guid = CStringFromGUID(cat);
+ CString guid = CStringFromGUID(cat);
- AfxGetApp()->WriteProfileString(_T("Capture\\") + guid, NULL, NULL);
+ AfxGetApp()->WriteProfileString(_T("Capture\\") + guid, NULL, NULL);
- int iSel = box.GetCurSel();
- if(iSel < 0) return;
- iSel = box.GetItemData(iSel);
- if(iSel < 0) return;
+ int iSel = box.GetCurSel();
+ if(iSel < 0) return;
+ iSel = box.GetItemData(iSel);
+ if(iSel < 0) return;
- Codec& codec = codecs[iSel];
+ Codec& codec = codecs[iSel];
- AfxGetApp()->WriteProfileString(_T("Capture\\") + guid, _T("DisplayName"), CString(codec.DisplayName));
+ AfxGetApp()->WriteProfileString(_T("Capture\\") + guid, _T("DisplayName"), CString(codec.DisplayName));
}
static void SetupDefaultCaps(AM_MEDIA_TYPE* pmt, VIDEO_STREAM_CONFIG_CAPS& caps)
{
- memset(&caps, 0, sizeof(caps));
+ memset(&caps, 0, sizeof(caps));
- if(!pmt) return;
+ if(!pmt) return;
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
caps.guid = GUID_NULL;
caps.VideoStandard = 0;
- caps.InputSize.cx = bih->biWidth;
- caps.InputSize.cy = abs(bih->biHeight);
+ caps.InputSize.cx = bih->biWidth;
+ caps.InputSize.cy = abs(bih->biHeight);
caps.MinCroppingSize = caps.MaxCroppingSize = caps.InputSize;
caps.CropGranularityX = caps.CropGranularityY = 1;
caps.CropAlignX = caps.CropAlignY = 1;
caps.MinOutputSize = CSize(64, 64);
caps.MaxOutputSize = CSize(768, 576);
caps.OutputGranularityX = 16;
- caps.OutputGranularityY = 1;
+ caps.OutputGranularityY = 1;
caps.StretchTapsX = caps.StretchTapsY = 0;
caps.ShrinkTapsX = caps.ShrinkTapsY = 0;
caps.MinFrameInterval = 100000i64;
@@ -163,1116 +163,1086 @@ static void SetupDefaultCaps(AM_MEDIA_TYPE* pmt, VIDEO_STREAM_CONFIG_CAPS& caps)
static void SetupDefaultCaps(AM_MEDIA_TYPE* pmt, AUDIO_STREAM_CONFIG_CAPS& caps)
{
- memset(&caps, 0, sizeof(caps));
+ memset(&caps, 0, sizeof(caps));
- if(!pmt) return;
+ if(!pmt) return;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->pbFormat;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->pbFormat;
caps.guid = GUID_NULL;
- caps.MinimumChannels = caps.MaximumChannels = wfe->nChannels;
+ caps.MinimumChannels = caps.MaximumChannels = wfe->nChannels;
caps.ChannelsGranularity = 1;
- caps.MinimumBitsPerSample = caps.MaximumBitsPerSample = wfe->wBitsPerSample;
+ caps.MinimumBitsPerSample = caps.MaximumBitsPerSample = wfe->wBitsPerSample;
caps.BitsPerSampleGranularity = 1;
- caps.MinimumSampleFrequency = caps.MaximumSampleFrequency = wfe->nSamplesPerSec;
+ caps.MinimumSampleFrequency = caps.MaximumSampleFrequency = wfe->nSamplesPerSec;
caps.SampleFrequencyGranularity = 1;
}
template<class T>
static void SetupMediaTypes(CComPtr<IAMStreamConfig> pAMSC, CFormatArray<T>& tfa, CComboBox& type, CComboBox& dim, CMediaType& mt)
{
- tfa.RemoveAll();
- type.ResetContent();
- dim.ResetContent();
- type.EnableWindow(FALSE);
- dim.EnableWindow(FALSE);
-
- if(!pAMSC) return;
-
- AM_MEDIA_TYPE* pcurmt = NULL;
- pAMSC->GetFormat(&pcurmt);
-
- int iCount = 0, iSize;
- if(SUCCEEDED(pAMSC->GetNumberOfCapabilities(&iCount, &iSize))
- && iSize == sizeof(T) && iCount > 0)
- {
- for(int i = 0; i < iCount; i++)
- {
- T caps;
- AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED(pAMSC->GetStreamCaps(i, &pmt, (BYTE*)&caps)))
- {
- tfa.AddFormat(pmt, caps);
- }
- }
-
- if(iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
- {
- for(int i = 0, cnt = tfa.GetCount(); i < cnt; i++)
- {
- if(tfa[i]->GetCount() != 1) continue;
-
- CFormatElem<T>* pfe = tfa[i]->GetAt(0);
-
- if(pfe->mt.formattype != FORMAT_VideoInfo
- && pfe->mt.formattype != FORMAT_VideoInfo2)
- continue;
-
- static SIZE presets[] =
- {
- {160, 120}, {192, 144},
- {320, 240}, {384, 288},
- {480, 240}, {512, 288},
- {480, 360}, {512, 384},
- {640, 240}, {768, 288},
- {640, 480}, {768, 576},
- {704, 240}, {704, 288},
- {704, 480}, {704, 576},
- {720, 240}, {720, 288},
- {720, 480}, {720, 576},
- {768, 240}, {768, 288},
- {768, 480}, {768, 576},
- };
-
- VIDEO_STREAM_CONFIG_CAPS* pcaps = (VIDEO_STREAM_CONFIG_CAPS*)&pfe->caps;
- BITMAPINFOHEADER bihCur;
- ExtractBIH(&pfe->mt, &bihCur);
-
- for(int j = 0; j < countof(presets); j++)
- {
- if(presets[j].cx == bihCur.biWidth
- && presets[j].cy == abs(bihCur.biHeight)
- || presets[j].cx < pcaps->MinOutputSize.cx
- || presets[j].cx > pcaps->MaxOutputSize.cx
- || presets[j].cy < pcaps->MinOutputSize.cy
- || presets[j].cy > pcaps->MaxOutputSize.cy
- || presets[j].cx % pcaps->OutputGranularityX
- || presets[j].cy % pcaps->OutputGranularityY)
- continue;
-
- CMediaType mt = pfe->mt;
-
- if(mt.formattype == FORMAT_VideoInfo)
- {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- if(!vih->bmiHeader.biHeight) vih->bmiHeader.biHeight = 1;
- vih->bmiHeader.biWidth = presets[j].cx;
- vih->bmiHeader.biHeight = presets[j].cy * (vih->bmiHeader.biHeight / vih->bmiHeader.biHeight);
- vih->bmiHeader.biSizeImage = presets[j].cx * presets[j].cy * vih->bmiHeader.biBitCount >> 3;
-
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &mt);
- tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
-
- if(presets[j].cx * 3 != presets[j].cy * 4)
- {
- int extra = mt.cbFormat - sizeof(VIDEOINFOHEADER);
- int bmiHeaderSize = sizeof(vih->bmiHeader) + extra;
- BYTE* pbmiHeader = DNew BYTE[bmiHeaderSize];
- memcpy(pbmiHeader, &vih->bmiHeader, bmiHeaderSize);
- mt.ReallocFormatBuffer(FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader) + bmiHeaderSize);
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- memcpy(&vih2->bmiHeader, pbmiHeader, bmiHeaderSize);
- delete [] pbmiHeader;
- vih2->dwInterlaceFlags = vih2->dwCopyProtectFlags = 0;
- vih2->dwReserved1 = vih2->dwReserved2 = 0;
- vih2->dwPictAspectRatioX = 4;
- vih2->dwPictAspectRatioY = 3;
-
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &mt);
- tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
- }
- }
- else if(mt.formattype == FORMAT_VideoInfo2)
- {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- if(!vih2->bmiHeader.biHeight) vih2->bmiHeader.biHeight = 1;
- vih2->bmiHeader.biWidth = presets[j].cx;
- vih2->bmiHeader.biHeight = presets[j].cy * (vih2->bmiHeader.biHeight / vih2->bmiHeader.biHeight);
- vih2->bmiHeader.biSizeImage = presets[j].cx * presets[j].cy * vih2->bmiHeader.biBitCount >> 3;
- vih2->dwPictAspectRatioX = 4;
- vih2->dwPictAspectRatioY = 3;
-
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &mt);
- tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
- }
- }
- }
- }
- }
-
- if(tfa.GetCount() == 0)
- {
- if(pcurmt && (pcurmt->majortype == MEDIATYPE_Video || pcurmt->majortype == MEDIATYPE_Audio))
- {
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, pcurmt);
- T caps;
- SetupDefaultCaps(pmt, caps);
+ tfa.RemoveAll();
+ type.ResetContent();
+ dim.ResetContent();
+ type.EnableWindow(FALSE);
+ dim.EnableWindow(FALSE);
+
+ if(!pAMSC) return;
+
+ AM_MEDIA_TYPE* pcurmt = NULL;
+ pAMSC->GetFormat(&pcurmt);
+
+ int iCount = 0, iSize;
+ if(SUCCEEDED(pAMSC->GetNumberOfCapabilities(&iCount, &iSize))
+ && iSize == sizeof(T) && iCount > 0)
+ {
+ for(int i = 0; i < iCount; i++)
+ {
+ T caps;
+ AM_MEDIA_TYPE* pmt = NULL;
+ if(SUCCEEDED(pAMSC->GetStreamCaps(i, &pmt, (BYTE*)&caps)))
+ {
+ tfa.AddFormat(pmt, caps);
+ }
+ }
+
+ if(iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
+ {
+ for(int i = 0, cnt = tfa.GetCount(); i < cnt; i++)
+ {
+ if(tfa[i]->GetCount() != 1) continue;
+
+ CFormatElem<T>* pfe = tfa[i]->GetAt(0);
+
+ if(pfe->mt.formattype != FORMAT_VideoInfo
+ && pfe->mt.formattype != FORMAT_VideoInfo2)
+ continue;
+
+ static SIZE presets[] =
+ {
+ {160, 120}, {192, 144},
+ {320, 240}, {384, 288},
+ {480, 240}, {512, 288},
+ {480, 360}, {512, 384},
+ {640, 240}, {768, 288},
+ {640, 480}, {768, 576},
+ {704, 240}, {704, 288},
+ {704, 480}, {704, 576},
+ {720, 240}, {720, 288},
+ {720, 480}, {720, 576},
+ {768, 240}, {768, 288},
+ {768, 480}, {768, 576},
+ };
+
+ VIDEO_STREAM_CONFIG_CAPS* pcaps = (VIDEO_STREAM_CONFIG_CAPS*)&pfe->caps;
+ BITMAPINFOHEADER bihCur;
+ ExtractBIH(&pfe->mt, &bihCur);
+
+ for(int j = 0; j < countof(presets); j++)
+ {
+ if(presets[j].cx == bihCur.biWidth
+ && presets[j].cy == abs(bihCur.biHeight)
+ || presets[j].cx < pcaps->MinOutputSize.cx
+ || presets[j].cx > pcaps->MaxOutputSize.cx
+ || presets[j].cy < pcaps->MinOutputSize.cy
+ || presets[j].cy > pcaps->MaxOutputSize.cy
+ || presets[j].cx % pcaps->OutputGranularityX
+ || presets[j].cy % pcaps->OutputGranularityY)
+ continue;
+
+ CMediaType mt = pfe->mt;
+
+ if(mt.formattype == FORMAT_VideoInfo)
+ {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
+ if(!vih->bmiHeader.biHeight) vih->bmiHeader.biHeight = 1;
+ vih->bmiHeader.biWidth = presets[j].cx;
+ vih->bmiHeader.biHeight = presets[j].cy*(vih->bmiHeader.biHeight/vih->bmiHeader.biHeight);
+ vih->bmiHeader.biSizeImage = presets[j].cx*presets[j].cy*vih->bmiHeader.biBitCount>>3;
+
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &mt);
+ tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
+
+ if(presets[j].cx*3 != presets[j].cy*4)
+ {
+ int extra = mt.cbFormat - sizeof(VIDEOINFOHEADER);
+ int bmiHeaderSize = sizeof(vih->bmiHeader) + extra;
+ BYTE* pbmiHeader = DNew BYTE[bmiHeaderSize];
+ memcpy(pbmiHeader, &vih->bmiHeader, bmiHeaderSize);
+ mt.ReallocFormatBuffer(FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader) + bmiHeaderSize);
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
+ memcpy(&vih2->bmiHeader, pbmiHeader, bmiHeaderSize);
+ delete [] pbmiHeader;
+ vih2->dwInterlaceFlags = vih2->dwCopyProtectFlags = 0;
+ vih2->dwReserved1 = vih2->dwReserved2 = 0;
+ vih2->dwPictAspectRatioX = 4;
+ vih2->dwPictAspectRatioY = 3;
+
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &mt);
+ tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
+ }
+ }
+ else if(mt.formattype == FORMAT_VideoInfo2)
+ {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
+ if(!vih2->bmiHeader.biHeight) vih2->bmiHeader.biHeight = 1;
+ vih2->bmiHeader.biWidth = presets[j].cx;
+ vih2->bmiHeader.biHeight = presets[j].cy*(vih2->bmiHeader.biHeight/vih2->bmiHeader.biHeight);
+ vih2->bmiHeader.biSizeImage = presets[j].cx*presets[j].cy*vih2->bmiHeader.biBitCount>>3;
+ vih2->dwPictAspectRatioX = 4;
+ vih2->dwPictAspectRatioY = 3;
+
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &mt);
+ tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
+ }
+ }
+ }
+ }
+ }
+
+ if(tfa.GetCount() == 0)
+ {
+ if(pcurmt && (pcurmt->majortype == MEDIATYPE_Video || pcurmt->majortype == MEDIATYPE_Audio))
+ {
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, pcurmt);
+ T caps;
+ SetupDefaultCaps(pmt, caps);
tfa.AddFormat(pmt, caps);
- }
- else
- {
- mt.majortype = GUID_NULL;
- if(pcurmt) DeleteMediaType(pcurmt);
- return;
- }
- }
-
- for(int i = 0; i < (int)tfa.GetCount(); i++)
- {
- CFormat<T>* pf = tfa[i];
- int j = type.AddString(pf->name);
- type.SetItemData(j, (DWORD_PTR)pf);
- }
-
- CFormat<T>* pf = NULL;
- CFormatElem<T>* pfe = NULL;
-
- if(!pcurmt)
- {
- pf = tfa[0];
- pfe = pf->GetAt(0);
- }
- else if(!tfa.FindFormat(pcurmt, NULL, &pf, &pfe) && !tfa.FindFormat(pcurmt, &pf))
- {
- if(pcurmt) DeleteMediaType(pcurmt);
- return;
- }
-
- for(int i = 0; i < (int)pf->GetCount(); i++)
- {
- CFormatElem<T>* pfe = pf->GetAt(i);
- int j = dim.AddString(tfa.MakeDimensionName(pfe));
- dim.SetItemData(j, (DWORD_PTR)pfe);
- }
-
- int iType = type.SetCurSel(type.FindStringExact(0, pf->name));
- if(iType < 0 && type.GetCount()) type.SetCurSel(0);
- int iDim = dim.SetCurSel(dim.FindStringExact(0, tfa.MakeDimensionName(pfe)));
+ }
+ else
+ {
+ mt.majortype = GUID_NULL;
+ if(pcurmt) DeleteMediaType(pcurmt);
+ return;
+ }
+ }
+
+ for(int i = 0; i < (int)tfa.GetCount(); i++)
+ {
+ CFormat<T>* pf = tfa[i];
+ int j = type.AddString(pf->name);
+ type.SetItemData(j, (DWORD_PTR)pf);
+ }
+
+ CFormat<T>* pf = NULL;
+ CFormatElem<T>* pfe = NULL;
+
+ if(!pcurmt)
+ {
+ pf = tfa[0];
+ pfe = pf->GetAt(0);
+ }
+ else if(!tfa.FindFormat(pcurmt, NULL, &pf, &pfe) && !tfa.FindFormat(pcurmt, &pf))
+ {
+ if(pcurmt) DeleteMediaType(pcurmt);
+ return;
+ }
+
+ for(int i = 0; i < (int)pf->GetCount(); i++)
+ {
+ CFormatElem<T>* pfe = pf->GetAt(i);
+ int j = dim.AddString(tfa.MakeDimensionName(pfe));
+ dim.SetItemData(j, (DWORD_PTR)pfe);
+ }
+
+ int iType = type.SetCurSel(type.FindStringExact(0, pf->name));
+ if(iType < 0 && type.GetCount()) type.SetCurSel(0);
+ int iDim = dim.SetCurSel(dim.FindStringExact(0, tfa.MakeDimensionName(pfe)));
// if(iDim < 0 && dim.GetCount()) dim.SetCurSel(iDim = 0);
- CorrectComboListWidth(type, type.GetParent()->GetFont());
- CorrectComboListWidth(dim, dim.GetParent()->GetFont());
+ CorrectComboListWidth(type, type.GetParent()->GetFont());
+ CorrectComboListWidth(dim, dim.GetParent()->GetFont());
- if(iDim >= 0) mt = ((CFormatElem<T>*)dim.GetItemData(iDim))->mt;
- else if(pcurmt) mt = *pcurmt;
+ if(iDim >= 0) mt = ((CFormatElem<T>*)dim.GetItemData(iDim))->mt;
+ else if(pcurmt) mt = *pcurmt;
- type.EnableWindow(type.GetCount() > 0);
- dim.EnableWindow(dim.GetCount() > 0);
+ type.EnableWindow(type.GetCount() > 0);
+ dim.EnableWindow(dim.GetCount() > 0);
- if(pcurmt) DeleteMediaType(pcurmt);
+ if(pcurmt) DeleteMediaType(pcurmt);
}
template<class T>
static bool SetupDimension(CFormatArray<T>& tfa, CComboBox& type, CComboBox& dim)
{
- CString str;
- dim.GetWindowText(str);
+ CString str;
+ dim.GetWindowText(str);
- dim.ResetContent();
- dim.EnableWindow(FALSE);
+ dim.ResetContent();
+ dim.EnableWindow(FALSE);
- int iSel = type.GetCurSel();
- if(iSel < 0) return(false);
+ int iSel = type.GetCurSel();
+ if(iSel < 0) return(false);
- CFormat<T>* pf = (CFormat<T>*)type.GetItemData(iSel);
+ CFormat<T>* pf = (CFormat<T>*)type.GetItemData(iSel);
- for(int i = 0; i < (int)pf->GetCount(); i++)
- {
- CFormatElem<T>* pfe = pf->GetAt(i);
- dim.SetItemData(dim.AddString(tfa.MakeDimensionName(pfe)), (DWORD_PTR)pfe);
- }
+ for(int i = 0; i < (int)pf->GetCount(); i++)
+ {
+ CFormatElem<T>* pfe = pf->GetAt(i);
+ dim.SetItemData(dim.AddString(tfa.MakeDimensionName(pfe)), (DWORD_PTR)pfe);
+ }
- CorrectComboListWidth(dim, dim.GetParent()->GetFont());
+ CorrectComboListWidth(dim, dim.GetParent()->GetFont());
- dim.SetCurSel(dim.FindStringExact(0, str));
- dim.EnableWindow(dim.GetCount() > 0);
+ dim.SetCurSel(dim.FindStringExact(0, str));
+ dim.EnableWindow(dim.GetCount() > 0);
- return(dim.GetCurSel() >= 0);
+ return(dim.GetCurSel() >= 0);
}
static void InitCodecList(CAtlArray<Codec>& codecs, CComboBox& box, const GUID& cat)
{
- codecs.RemoveAll();
- box.ResetContent();
- box.EnableWindow(FALSE);
+ codecs.RemoveAll();
+ box.ResetContent();
+ box.EnableWindow(FALSE);
- box.SetItemData(box.AddString(_T("Uncompressed")), (DWORD_PTR) - 1);
+ box.SetItemData(box.AddString(_T("Uncompressed")), (DWORD_PTR)-1);
- BeginEnumSysDev(cat, pMoniker)
- {
- Codec c;
+ BeginEnumSysDev(cat, pMoniker)
+ {
+ Codec c;
- c.pMoniker = pMoniker;
- /*
- CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
- continue;
-
- c.pBF = pBF;
- */
- LPOLESTR strName = NULL;
- if(FAILED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- continue;
-
- c.DisplayName = strName;
- CoTaskMemFree(strName);
-
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- continue;
-
- c.FriendlyName = var.bstrVal;
-
- CStringW str = CStringW(c.DisplayName).MakeLower();
- if(str.Find(L"@device:dmo:") == 0)
- c.FriendlyName = _T("(DMO) ") + c.FriendlyName;
- else if(str.Find(L"@device:sw:") == 0)
- c.FriendlyName = _T("(DS) ") + c.FriendlyName;
- else if(str.Find(L"@device:cm:") == 0)
- c.FriendlyName = _T("(VfW) ") + c.FriendlyName;
-
- box.SetItemData(
- box.AddString(c.FriendlyName),
- (DWORD_PTR)codecs.Add(c));
- }
- EndEnumSysDev
-
- box.EnableWindow(box.GetCount() > 1);
-
- CorrectComboListWidth(box, box.GetParent()->GetFont());
-
- LoadDefaultCodec(codecs, box, cat);
+ c.pMoniker = pMoniker;
+/*
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ continue;
+
+ c.pBF = pBF;
+*/
+ LPOLESTR strName = NULL;
+ if(FAILED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ continue;
+
+ c.DisplayName = strName;
+ CoTaskMemFree(strName);
+
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ continue;
+
+ c.FriendlyName = var.bstrVal;
+
+ CStringW str = CStringW(c.DisplayName).MakeLower();
+ if(str.Find(L"@device:dmo:") == 0)
+ c.FriendlyName = _T("(DMO) ") + c.FriendlyName;
+ else if(str.Find(L"@device:sw:") == 0)
+ c.FriendlyName = _T("(DS) ") + c.FriendlyName;
+ else if(str.Find(L"@device:cm:") == 0)
+ c.FriendlyName = _T("(VfW) ") + c.FriendlyName;
+
+ box.SetItemData(
+ box.AddString(c.FriendlyName),
+ (DWORD_PTR)codecs.Add(c));
+ }
+ EndEnumSysDev
+
+ box.EnableWindow(box.GetCount() > 1);
+
+ CorrectComboListWidth(box, box.GetParent()->GetFont());
+
+ LoadDefaultCodec(codecs, box, cat);
}
static int ShowPPage(CAtlArray<Codec>& codecs, CComboBox& box, HWND hWnd = NULL)
{
- int iSel = box.GetCurSel();
- if(iSel < 0) return(-1);
-
- iSel = box.GetItemData(iSel);
- if(iSel < 0) return(-1);
-
- Codec& c = codecs[iSel];
-
- if(!c.pBF)
- {
- c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
- }
-
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = c.pBF)
- {
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID)))
- {
- IUnknown* lpUnk = NULL;
- pSPP.QueryInterface(&lpUnk);
- OleCreatePropertyFrame(
- hWnd, 0, 0, CStringW(c.FriendlyName),
- 1, (IUnknown**)&lpUnk,
- caGUID.cElems, caGUID.pElems,
- 0, 0, NULL);
- lpUnk->Release();
-
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- }
- }
- else if(CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.pBF)
- {
- if(pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK)
- pAMVfWCD->ShowDialog(VfwCompressDialog_Config, hWnd);
- }
-
- return(iSel);
+ int iSel = box.GetCurSel();
+ if(iSel < 0) return(-1);
+
+ iSel = box.GetItemData(iSel);
+ if(iSel < 0) return(-1);
+
+ Codec& c = codecs[iSel];
+
+ if(!c.pBF)
+ {
+ c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
+ }
+
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = c.pBF)
+ {
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if(SUCCEEDED(pSPP->GetPages(&caGUID)))
+ {
+ IUnknown* lpUnk = NULL;
+ pSPP.QueryInterface(&lpUnk);
+ OleCreatePropertyFrame(
+ hWnd, 0, 0, CStringW(c.FriendlyName),
+ 1, (IUnknown**)&lpUnk,
+ caGUID.cElems, caGUID.pElems,
+ 0, 0, NULL);
+ lpUnk->Release();
+
+ if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+ }
+ }
+ else if(CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.pBF)
+ {
+ if(pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK)
+ pAMVfWCD->ShowDialog(VfwCompressDialog_Config, hWnd);
+ }
+
+ return(iSel);
}
// CPlayerCaptureDialog dialog
//IMPLEMENT_DYNAMIC(CPlayerCaptureDialog, CResizableDialog)
CPlayerCaptureDialog::CPlayerCaptureDialog()
- : CResizableDialog(CPlayerCaptureDialog::IDD, NULL)
- , m_vidfps(0)
- , m_file(_T(""))
- , m_fVidOutput(TRUE)
- , m_fAudOutput(TRUE)
- , m_fVidPreview(FALSE)
- , m_fAudPreview(FALSE)
- , m_nVidBuffers(0)
- , m_nAudBuffers(0)
- , m_pVidBuffer(NULL)
- , m_pAudBuffer(NULL)
- , m_fSepAudio(FALSE)
- , m_muxtype(0)
+ : CResizableDialog(CPlayerCaptureDialog::IDD, NULL)
+ , m_vidfps(0)
+ , m_file(_T(""))
+ , m_fVidOutput(TRUE)
+ , m_fAudOutput(TRUE)
+ , m_fVidPreview(FALSE)
+ , m_fAudPreview(FALSE)
+ , m_nVidBuffers(0)
+ , m_nAudBuffers(0)
+ , m_pVidBuffer(NULL)
+ , m_pAudBuffer(NULL)
+ , m_fSepAudio(FALSE)
+ , m_muxtype(0)
{
}
CPlayerCaptureDialog::~CPlayerCaptureDialog()
{
- EmptyVideo();
- EmptyAudio();
+ EmptyVideo();
+ EmptyAudio();
}
BOOL CPlayerCaptureDialog::Create(CWnd* pParent)
{
- if(!__super::Create(IDD, pParent))
- return FALSE;
+ if(!__super::Create(IDD, pParent))
+ return FALSE;
- EmptyVideo();
- EmptyAudio();
+ EmptyVideo();
+ EmptyAudio();
- return TRUE;
+ return TRUE;
}
void CPlayerCaptureDialog::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO4, m_vidinput);
- DDX_Control(pDX, IDC_COMBO1, m_vidtype);
- DDX_Control(pDX, IDC_COMBO5, m_viddimension);
- DDX_Control(pDX, IDC_SPIN1, m_vidhor);
- DDX_Control(pDX, IDC_SPIN2, m_vidver);
- DDX_Control(pDX, IDC_EDIT1, m_vidhoredit);
- DDX_Control(pDX, IDC_EDIT2, m_vidveredit);
- DDX_Control(pDX, IDC_EDIT3, m_vidfpsedit);
- DDX_Control(pDX, IDC_BUTTON1, m_vidsetres);
- DDX_Control(pDX, IDC_COMBO3, m_audinput);
- DDX_Control(pDX, IDC_COMBO2, m_audtype);
- DDX_Control(pDX, IDC_COMBO6, m_auddimension);
- DDX_Control(pDX, IDC_COMBO7, m_vidcodec);
- DDX_Control(pDX, IDC_COMBO9, m_vidcodectype);
- DDX_Control(pDX, IDC_COMBO10, m_vidcodecdimension);
- DDX_Check(pDX, IDC_CHECK1, m_fVidOutput);
- DDX_Control(pDX, IDC_CHECK1, m_vidoutput);
- DDX_Check(pDX, IDC_CHECK2, m_fVidPreview);
- DDX_Control(pDX, IDC_CHECK2, m_vidpreview);
- DDX_Control(pDX, IDC_COMBO8, m_audcodec);
- DDX_Control(pDX, IDC_COMBO12, m_audcodectype);
- DDX_Control(pDX, IDC_COMBO11, m_audcodecdimension);
- DDX_Check(pDX, IDC_CHECK3, m_fAudOutput);
- DDX_Control(pDX, IDC_CHECK3, m_audoutput);
- DDX_Check(pDX, IDC_CHECK4, m_fAudPreview);
- DDX_Control(pDX, IDC_CHECK4, m_audpreview);
- DDX_Text(pDX, IDC_EDIT4, m_file);
- DDX_Control(pDX, IDC_BUTTON2, m_recordbtn);
- DDX_Text(pDX, IDC_EDIT5, m_nVidBuffers);
- DDX_Text(pDX, IDC_EDIT6, m_nAudBuffers);
- DDX_Check(pDX, IDC_CHECK5, m_fSepAudio);
- DDX_CBIndex(pDX, IDC_COMBO14, m_muxtype);
- DDX_Control(pDX, IDC_COMBO14, m_muxctrl);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO4, m_vidinput);
+ DDX_Control(pDX, IDC_COMBO1, m_vidtype);
+ DDX_Control(pDX, IDC_COMBO5, m_viddimension);
+ DDX_Control(pDX, IDC_SPIN1, m_vidhor);
+ DDX_Control(pDX, IDC_SPIN2, m_vidver);
+ DDX_Control(pDX, IDC_EDIT1, m_vidhoredit);
+ DDX_Control(pDX, IDC_EDIT2, m_vidveredit);
+ DDX_Control(pDX, IDC_EDIT3, m_vidfpsedit);
+ DDX_Control(pDX, IDC_BUTTON1, m_vidsetres);
+ DDX_Control(pDX, IDC_COMBO3, m_audinput);
+ DDX_Control(pDX, IDC_COMBO2, m_audtype);
+ DDX_Control(pDX, IDC_COMBO6, m_auddimension);
+ DDX_Control(pDX, IDC_COMBO7, m_vidcodec);
+ DDX_Control(pDX, IDC_COMBO9, m_vidcodectype);
+ DDX_Control(pDX, IDC_COMBO10, m_vidcodecdimension);
+ DDX_Check(pDX, IDC_CHECK1, m_fVidOutput);
+ DDX_Control(pDX, IDC_CHECK1, m_vidoutput);
+ DDX_Check(pDX, IDC_CHECK2, m_fVidPreview);
+ DDX_Control(pDX, IDC_CHECK2, m_vidpreview);
+ DDX_Control(pDX, IDC_COMBO8, m_audcodec);
+ DDX_Control(pDX, IDC_COMBO12, m_audcodectype);
+ DDX_Control(pDX, IDC_COMBO11, m_audcodecdimension);
+ DDX_Check(pDX, IDC_CHECK3, m_fAudOutput);
+ DDX_Control(pDX, IDC_CHECK3, m_audoutput);
+ DDX_Check(pDX, IDC_CHECK4, m_fAudPreview);
+ DDX_Control(pDX, IDC_CHECK4, m_audpreview);
+ DDX_Text(pDX, IDC_EDIT4, m_file);
+ DDX_Control(pDX, IDC_BUTTON2, m_recordbtn);
+ DDX_Text(pDX, IDC_EDIT5, m_nVidBuffers);
+ DDX_Text(pDX, IDC_EDIT6, m_nAudBuffers);
+ DDX_Check(pDX, IDC_CHECK5, m_fSepAudio);
+ DDX_CBIndex(pDX, IDC_COMBO14, m_muxtype);
+ DDX_Control(pDX, IDC_COMBO14, m_muxctrl);
}
BOOL CPlayerCaptureDialog::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- if(pMsg->wParam == VK_RETURN)
- {
- CWnd* pFocused = GetFocus();
- if(pFocused && pFocused->m_hWnd == m_vidfpsedit.m_hWnd)
- {
- UpdateGraph();
- }
- }
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if(pMsg->message == WM_KEYDOWN)
+ {
+ if(pMsg->wParam == VK_RETURN)
+ {
+ CWnd* pFocused = GetFocus();
+ if(pFocused && pFocused->m_hWnd == m_vidfpsedit.m_hWnd)
+ {
+ UpdateGraph();
+ }
+ }
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
void CPlayerCaptureDialog::EmptyVideo()
{
- // first save channel from previous session
-
- if(m_pAMTuner && !m_VidDisplayName.IsEmpty())
- {
- long lChannel = 0, lVivSub = 0, lAudSub = 0;
- m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
- AfxGetApp()->WriteProfileInt(_T("Capture\\") + CString(m_VidDisplayName), _T("Channel"), lChannel);
- }
-
- //
-
- m_vfa.RemoveAll();
-
- m_pAMXB = NULL;
- m_pAMTuner = NULL;
- m_pAMVSC = NULL;
-
- if(IsWindow(m_hWnd))
- {
- m_vidinput.ResetContent();
- m_vidinput.EnableWindow(FALSE);
- m_vidtype.ResetContent();
- m_vidtype.EnableWindow(FALSE);
- m_viddimension.ResetContent();
- m_viddimension.EnableWindow(FALSE);
- m_vidhor.EnableWindow(FALSE);
- m_vidver.EnableWindow(FALSE);
- m_vidhoredit.EnableWindow(FALSE);
- m_vidveredit.EnableWindow(FALSE);
- m_vidfpsedit.EnableWindow(FALSE);
- m_vidfps = 0;
- m_vidsetres.EnableWindow(FALSE);
- UpdateData(FALSE);
- }
+ // first save channel from previous session
+
+ if(m_pAMTuner && !m_VidDisplayName.IsEmpty())
+ {
+ long lChannel = 0, lVivSub = 0, lAudSub = 0;
+ m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
+ AfxGetApp()->WriteProfileInt(_T("Capture\\") + CString(m_VidDisplayName), _T("Channel"), lChannel);
+ }
+
+ //
+
+ m_vfa.RemoveAll();
+
+ m_pAMXB = NULL;
+ m_pAMTuner = NULL;
+ m_pAMVSC = NULL;
+
+ if(IsWindow(m_hWnd))
+ {
+ m_vidinput.ResetContent();
+ m_vidinput.EnableWindow(FALSE);
+ m_vidtype.ResetContent();
+ m_vidtype.EnableWindow(FALSE);
+ m_viddimension.ResetContent();
+ m_viddimension.EnableWindow(FALSE);
+ m_vidhor.EnableWindow(FALSE);
+ m_vidver.EnableWindow(FALSE);
+ m_vidhoredit.EnableWindow(FALSE);
+ m_vidveredit.EnableWindow(FALSE);
+ m_vidfpsedit.EnableWindow(FALSE);
+ m_vidfps = 0;
+ m_vidsetres.EnableWindow(FALSE);
+ UpdateData(FALSE);
+ }
}
void CPlayerCaptureDialog::EmptyAudio()
{
- m_afa.RemoveAll();
-
- m_pAMASC = NULL;
- m_pAMAIM.RemoveAll();
-
- if(IsWindow(m_hWnd))
- {
- m_audinput.ResetContent();
- m_audinput.EnableWindow(FALSE);
- m_audtype.ResetContent();
- m_audtype.EnableWindow(FALSE);
- m_auddimension.ResetContent();
- m_auddimension.EnableWindow(FALSE);
- UpdateData(FALSE);
- }
+ m_afa.RemoveAll();
+
+ m_pAMASC = NULL;
+ m_pAMAIM.RemoveAll();
+
+ if(IsWindow(m_hWnd))
+ {
+ m_audinput.ResetContent();
+ m_audinput.EnableWindow(FALSE);
+ m_audtype.ResetContent();
+ m_audtype.EnableWindow(FALSE);
+ m_auddimension.ResetContent();
+ m_auddimension.EnableWindow(FALSE);
+ UpdateData(FALSE);
+ }
}
void CPlayerCaptureDialog::UpdateMediaTypes()
{
- UpdateData();
-
- // fps
-
- CString fps;
- m_vidfpsedit.GetWindowText(fps);
- if(!fps.IsEmpty())
- {
- float ffps;
- _stscanf_s(fps, _T("%f"), &ffps);
- if(ffps > 0) m_vidfps = ffps;
- }
-
- // video
-
- {
- AM_MEDIA_TYPE* pmt = NULL;
- VIDEO_STREAM_CONFIG_CAPS* pcaps = NULL;
-
- int i = m_viddimension.GetCurSel();
- if(i >= 0)
- {
- pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &((CVidFormatElem*)m_viddimension.GetItemData(i))->mt);
- pcaps = &((CVidFormatElem*)m_viddimension.GetItemData(i))->caps;
- }
- else if(m_pAMVSC)
- {
- m_pAMVSC->GetFormat(&pmt);
- }
-
- if(pmt)
- {
- if(m_vidfps > 0)
- {
- REFERENCE_TIME atpf = (REFERENCE_TIME)(10000000.0 / m_vidfps);
-
- if(pcaps)
- {
- // FIXME: some drivers do not set the interval right and they still accept the preferable but unfortunately out-of-range fps
+ UpdateData();
+
+ // fps
+
+ CString fps;
+ m_vidfpsedit.GetWindowText(fps);
+ if(!fps.IsEmpty())
+ {
+ float ffps;
+ _stscanf_s(fps, _T("%f"), &ffps);
+ if(ffps > 0) m_vidfps = ffps;
+ }
+
+ // video
+
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+ VIDEO_STREAM_CONFIG_CAPS* pcaps = NULL;
+
+ int i = m_viddimension.GetCurSel();
+ if(i >= 0)
+ {
+ pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &((CVidFormatElem*)m_viddimension.GetItemData(i))->mt);
+ pcaps = &((CVidFormatElem*)m_viddimension.GetItemData(i))->caps;
+ }
+ else if(m_pAMVSC)
+ {
+ m_pAMVSC->GetFormat(&pmt);
+ }
+
+ if(pmt)
+ {
+ if(m_vidfps > 0)
+ {
+ REFERENCE_TIME atpf = (REFERENCE_TIME)(10000000.0 / m_vidfps);
+
+ if(pcaps)
+ {
+ // FIXME: some drivers do not set the interval right and they still accept the preferable but unfortunately out-of-range fps
// atpf = min(max(atpf, pcaps->MinFrameInterval), pcaps->MaxFrameInterval);
- }
-
- if(pmt->formattype == FORMAT_VideoInfo)
- ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame = atpf;
- else if(pmt->formattype == FORMAT_VideoInfo2)
- ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame = atpf;
- }
-
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
-
- bih->biWidth = m_vidhor.GetPos();
- bih->biHeight = m_vidver.GetPos();
- bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
-
- SaveMediaType(m_VidDisplayName, pmt);
-
- m_mtv = *pmt;
- DeleteMediaType(pmt);
- }
- }
-
- // audio
-
- {
- AM_MEDIA_TYPE* pmt = NULL;
-
- int i = m_auddimension.GetCurSel();
- if(i >= 0)
- {
- pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &((CAudFormatElem*)m_auddimension.GetItemData(i))->mt);
- }
- else if(m_pAMASC)
- {
- m_pAMASC->GetFormat(&pmt);
- }
-
- if(pmt)
- {
- SaveMediaType(m_AudDisplayName, pmt);
-
- m_mta = *pmt;
- DeleteMediaType(pmt);
- }
- }
+ }
+
+ if(pmt->formattype == FORMAT_VideoInfo)
+ ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame = atpf;
+ else if(pmt->formattype == FORMAT_VideoInfo2)
+ ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame = atpf;
+ }
+
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
+
+ bih->biWidth = m_vidhor.GetPos();
+ bih->biHeight = m_vidver.GetPos();
+ bih->biSizeImage = bih->biWidth*bih->biHeight*bih->biBitCount>>3;
+
+ SaveMediaType(m_VidDisplayName, pmt);
+
+ m_mtv = *pmt;
+ DeleteMediaType(pmt);
+ }
+ }
+
+ // audio
+
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+
+ int i = m_auddimension.GetCurSel();
+ if(i >= 0)
+ {
+ pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &((CAudFormatElem*)m_auddimension.GetItemData(i))->mt);
+ }
+ else if(m_pAMASC)
+ {
+ m_pAMASC->GetFormat(&pmt);
+ }
+
+ if(pmt)
+ {
+ SaveMediaType(m_AudDisplayName, pmt);
+
+ m_mta = *pmt;
+ DeleteMediaType(pmt);
+ }
+ }
}
void CPlayerCaptureDialog::UpdateUserDefinableControls()
{
- int iSel = m_viddimension.GetCurSel();
- if(iSel < 0) return;
+ int iSel = m_viddimension.GetCurSel();
+ if(iSel < 0) return;
- CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
- if(!pvfe) return;
+ CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
+ if(!pvfe) return;
- if(!m_pAMVSC) return;
+ if(!m_pAMVSC) return;
- AM_MEDIA_TYPE* pmt = NULL;
- m_pAMVSC->GetFormat(&pmt);
- if(!pmt) return;
+ AM_MEDIA_TYPE* pmt = NULL;
+ m_pAMVSC->GetFormat(&pmt);
+ if(!pmt) return;
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
- if(!bih) return;
+ if(!bih) return;
- UDACCEL ua[3] = {{0, 0}, {2, 0}, {4, 0}};
+ UDACCEL ua[3] = {{0,0},{2,0},{4,0}};
- int w = m_vidhor.GetPos(), h = m_vidver.GetPos();
+ int w = m_vidhor.GetPos(), h = m_vidver.GetPos();
- m_vidhor.SetRange((short)pvfe->caps.MinOutputSize.cx, (short)pvfe->caps.MaxOutputSize.cx);
- /* if(bih->biCompression == mmioFOURCC('Y','U','Y','2')) // FIXME: bt8x8 drivers seem to crop the right side in yuv2 mode if the width is not divisable by 64
- pvfe->caps.OutputGranularityX = 64;
- */
- ua[0].nInc = pvfe->caps.OutputGranularityX;
- ua[1].nInc = pvfe->caps.OutputGranularityX * 2;
- ua[2].nInc = pvfe->caps.OutputGranularityX * 4;
- m_vidhor.SetAccel(3, ua);
+ m_vidhor.SetRange((short)pvfe->caps.MinOutputSize.cx, (short)pvfe->caps.MaxOutputSize.cx);
+/* if(bih->biCompression == mmioFOURCC('Y','U','Y','2')) // FIXME: bt8x8 drivers seem to crop the right side in yuv2 mode if the width is not divisable by 64
+ pvfe->caps.OutputGranularityX = 64;
+*/
+ ua[0].nInc = pvfe->caps.OutputGranularityX;
+ ua[1].nInc = pvfe->caps.OutputGranularityX*2;
+ ua[2].nInc = pvfe->caps.OutputGranularityX*4;
+ m_vidhor.SetAccel(3, ua);
- m_vidver.SetRange((short)pvfe->caps.MinOutputSize.cy, (short)pvfe->caps.MaxOutputSize.cy);
- ua[0].nInc = pvfe->caps.OutputGranularityY;
- ua[1].nInc = pvfe->caps.OutputGranularityY * 2;
- ua[2].nInc = pvfe->caps.OutputGranularityY * 4;
- m_vidver.SetAccel(3, ua);
+ m_vidver.SetRange((short)pvfe->caps.MinOutputSize.cy, (short)pvfe->caps.MaxOutputSize.cy);
+ ua[0].nInc = pvfe->caps.OutputGranularityY;
+ ua[1].nInc = pvfe->caps.OutputGranularityY*2;
+ ua[2].nInc = pvfe->caps.OutputGranularityY*4;
+ m_vidver.SetAccel(3, ua);
- m_vidhor.SetPos(bih->biWidth);
- m_vidver.SetPos(abs(bih->biHeight));
+ m_vidhor.SetPos(bih->biWidth);
+ m_vidver.SetPos(abs(bih->biHeight));
- CString fps;
- fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame));
- m_vidfpsedit.SetWindowText(fps);
+ CString fps;
+ fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame));
+ m_vidfpsedit.SetWindowText(fps);
- DeleteMediaType(pmt);
+ DeleteMediaType(pmt);
}
void CPlayerCaptureDialog::UpdateVideoCodec()
{
- int iSel = m_vidcodec.GetCurSel();
- if(iSel >= 0) iSel = m_vidcodec.GetItemData(iSel);
+ int iSel = m_vidcodec.GetCurSel();
+ if(iSel >= 0) iSel = m_vidcodec.GetItemData(iSel);
- m_pVidEnc = iSel < 0 ? NULL : m_pVidEncArray[iSel].pBF;
- m_pVidEncMoniker = iSel < 0 ? NULL : m_pVidEncArray[iSel].pMoniker;
+ m_pVidEnc = iSel < 0 ? NULL : m_pVidEncArray[iSel].pBF;
+ m_pVidEncMoniker = iSel < 0 ? NULL : m_pVidEncArray[iSel].pMoniker;
// CString DisplayName = iSel < 0 ? _T("") : CString(m_pVidEncArray[iSel].DisplayName.m_str);
- CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pVidEnc, PINDIR_OUTPUT);
+ CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pVidEnc, PINDIR_OUTPUT);
- SetupMediaTypes(pAMSC, m_vcfa, m_vidcodectype, m_vidcodecdimension, m_mtcv);
+ SetupMediaTypes(pAMSC, m_vcfa, m_vidcodectype, m_vidcodecdimension, m_mtcv);
- SaveDefaultCodec(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
+ SaveDefaultCodec(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
// SaveMediaType(DisplayName, &m_mtcv);
}
void CPlayerCaptureDialog::UpdateAudioCodec()
{
- int iSel = m_audcodec.GetCurSel();
- if(iSel >= 0) iSel = m_audcodec.GetItemData(iSel);
+ int iSel = m_audcodec.GetCurSel();
+ if(iSel >= 0) iSel = m_audcodec.GetItemData(iSel);
- m_pAudEnc = iSel < 0 ? NULL : m_pAudEncArray[iSel].pBF;
- m_pAudEncMoniker = iSel < 0 ? NULL : m_pAudEncArray[iSel].pMoniker;
+ m_pAudEnc = iSel < 0 ? NULL : m_pAudEncArray[iSel].pBF;
+ m_pAudEncMoniker = iSel < 0 ? NULL : m_pAudEncArray[iSel].pMoniker;
// CString DisplayName = iSel < 0 ? _T("") : CString(m_pAudEncArray[iSel].DisplayName.m_str);
- CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pAudEnc, PINDIR_OUTPUT);
+ CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pAudEnc, PINDIR_OUTPUT);
- SetupMediaTypes(pAMSC, m_acfa, m_audcodectype, m_audcodecdimension, m_mtca);
+ SetupMediaTypes(pAMSC, m_acfa, m_audcodectype, m_audcodecdimension, m_mtca);
- SaveDefaultCodec(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
+ SaveDefaultCodec(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
// SaveMediaType(DisplayName, &m_mtca);
}
void CPlayerCaptureDialog::UpdateMuxer()
{
- m_pMux = NULL;
- m_pAudMux = NULL;
+ m_pMux = NULL;
+ m_pAudMux = NULL;
- UpdateData();
+ UpdateData();
- HRESULT hr;
+ HRESULT hr;
- if(m_muxtype == 0) m_pMux.CoCreateInstance(CLSID_AviDest);
- else if(m_muxtype == 1) m_pMux.CoCreateInstance(CLSID_OggMux);
- else if(m_muxtype == 2) m_pMux = DNew CMatroskaMuxerFilter(NULL, &hr);
- else if(m_muxtype == 3) m_pMux = DNew CDSMMuxerFilter(NULL, &hr);
- else return;
+ if(m_muxtype == 0) m_pMux.CoCreateInstance(CLSID_AviDest);
+ else if(m_muxtype == 1) m_pMux.CoCreateInstance(CLSID_OggMux);
+ else if(m_muxtype == 2) m_pMux = DNew CMatroskaMuxerFilter(NULL, &hr);
+ else if(m_muxtype == 3) m_pMux = DNew CDSMMuxerFilter(NULL, &hr);
+ else return;
- if(m_fSepAudio) m_pAudMux = DNew CWavDestFilter(NULL, &hr);
+ if(m_fSepAudio) m_pAudMux = DNew CWavDestFilter(NULL, &hr);
}
void CPlayerCaptureDialog::UpdateOutputControls()
{
- UpdateData();
+ UpdateData();
- m_recordbtn.EnableWindow(!m_file.IsEmpty() && (m_pAMVSC && m_fVidOutput || m_pAMASC && m_fAudOutput));
- m_vidcodec.EnableWindow(TRUE);
- m_audcodec.EnableWindow(TRUE);
+ m_recordbtn.EnableWindow(!m_file.IsEmpty() && (m_pAMVSC && m_fVidOutput || m_pAMASC && m_fAudOutput));
+ m_vidcodec.EnableWindow(TRUE);
+ m_audcodec.EnableWindow(TRUE);
}
void CPlayerCaptureDialog::UpdateGraph()
{
- UpdateMediaTypes();
+ UpdateMediaTypes();
// UpdateMuxer();
- ((CMainFrame*)AfxGetMainWnd())->BuildGraphVideoAudio(m_fVidPreview, false, m_fAudPreview, false);
+ ((CMainFrame*)AfxGetMainWnd())->BuildGraphVideoAudio(m_fVidPreview, false, m_fAudPreview, false);
- UpdateUserDefinableControls();
+ UpdateUserDefinableControls();
}
void CPlayerCaptureDialog::EnableControls(CWnd* pWnd, bool fEnable)
{
- if(fEnable)
- {
- for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
- BOOL fEnabled;
- if(m_wndenabledmap.Lookup(pChild->m_hWnd, fEnabled))
- pChild->EnableWindow(fEnabled);
- EnableControls(pChild, fEnable);
- }
-
- if(pWnd->m_hWnd == m_hWnd)
- m_wndenabledmap.RemoveAll();
-
- m_recordbtn.SetWindowText(_T("Record"));
- }
- else
- {
- if(pWnd->m_hWnd == m_hWnd)
- m_wndenabledmap.RemoveAll();
-
- for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
- m_wndenabledmap[pChild->m_hWnd] = pChild->IsWindowEnabled();
- pChild->EnableWindow(FALSE);
- EnableControls(pChild, fEnable);
- }
-
- m_recordbtn.EnableWindow(TRUE);
- m_recordbtn.SetWindowText(_T("Stop"));
- }
+ if(fEnable)
+ {
+ for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
+ {
+ BOOL fEnabled;
+ if(m_wndenabledmap.Lookup(pChild->m_hWnd, fEnabled))
+ pChild->EnableWindow(fEnabled);
+ EnableControls(pChild, fEnable);
+ }
+
+ if(pWnd->m_hWnd == m_hWnd)
+ m_wndenabledmap.RemoveAll();
+
+ m_recordbtn.SetWindowText(_T("Record"));
+ }
+ else
+ {
+ if(pWnd->m_hWnd == m_hWnd)
+ m_wndenabledmap.RemoveAll();
+
+ for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
+ {
+ m_wndenabledmap[pChild->m_hWnd] = pChild->IsWindowEnabled();
+ pChild->EnableWindow(FALSE);
+ EnableControls(pChild, fEnable);
+ }
+
+ m_recordbtn.EnableWindow(TRUE);
+ m_recordbtn.SetWindowText(_T("Stop"));
+ }
}
void CPlayerCaptureDialog::SetupVideoControls(
- CStringW DisplayName,
- CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMCrossbar> pAMXB, CComPtr<IAMTVTuner> pAMTuner)
+ CStringW DisplayName,
+ CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMCrossbar> pAMXB, CComPtr<IAMTVTuner> pAMTuner)
{
- EmptyVideo();
-
- // crossbar
-
- if(m_pAMXB = pAMXB)
- {
- long OutputPinCount, InputPinCount;
- if(SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount)))
- {
- for(int i = 0; i < InputPinCount; i++)
- {
- long PinIndexRelated, PhysicalType;
- if(FAILED(pAMXB->get_CrossbarPinInfo(TRUE, i, &PinIndexRelated, &PhysicalType)))
- continue;
-
- if(PhysicalType >= PhysConn_Audio_Tuner)
- continue;
-
- CString str;
- switch(PhysicalType)
- {
- case PhysConn_Video_Tuner:
- str = _T("Tuner");
- break;
- case PhysConn_Video_Composite:
- str = _T("Composite");
- break;
- case PhysConn_Video_SVideo:
- str = _T("SVideo");
- break;
- case PhysConn_Video_RGB:
- str = _T("RGB");
- break;
- case PhysConn_Video_YRYBY:
- str = _T("YRYBY");
- break;
- case PhysConn_Video_SerialDigital:
- str = _T("SerialDigital");
- break;
- case PhysConn_Video_ParallelDigital:
- str = _T("ParallelDigital");
- break;
- case PhysConn_Video_SCSI:
- str = _T("SCSI");
- break;
- case PhysConn_Video_AUX:
- str = _T("AUX");
- break;
- case PhysConn_Video_1394:
- str = _T("1394");
- break;
- case PhysConn_Video_USB:
- str = _T("USB");
- break;
- case PhysConn_Video_VideoDecoder:
- str = _T("VideoDecoder");
- break;
- case PhysConn_Video_VideoEncoder:
- str = _T("VideoEncoder");
- break;
- case PhysConn_Video_SCART:
- str = _T("SCART");
- break;
- default:
- str.Format(_T("PhysicalType %d"), PhysicalType);
- break;
- }
-
- m_vidinput.SetItemData(m_vidinput.AddString(str), i);
- }
- }
- }
-
- if(m_vidinput.GetCount() > 0)
- {
- m_vidinput.EnableWindow(TRUE);
-
- long OutputPinCount, InputPinCount;
- if(SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount)))
- {
- for(int i = 0; i < OutputPinCount; i++)
- {
- long InputPinIndex;
- if(S_OK == pAMXB->get_IsRoutedTo(i, &InputPinIndex))
- {
- for(int j = 0; j < m_vidinput.GetCount(); j++)
- {
- if(m_vidinput.GetItemData(j) == InputPinIndex)
- {
- m_vidinput.SetCurSel(j);
- i = OutputPinCount;
- break;
- }
- }
- }
- }
- }
- OnVideoInput();
- }
-
- // tuner
-
- if(m_pAMTuner = pAMTuner)
- {
- // TODO:...
- }
-
- // streamconfig
-
- if(m_pAMVSC = pAMSC)
- {
- m_VidDisplayName = DisplayName;
-
- AM_MEDIA_TYPE* pmt;
- if(LoadMediaType(DisplayName, &pmt))
- {
- pAMSC->SetFormat(pmt);
- DeleteMediaType(pmt);
- }
-
- SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
- }
-
- if(m_vidtype.GetCount() > 0)
- {
- m_vidfpsedit.EnableWindow(TRUE);
- m_vidhor.EnableWindow(TRUE);
- m_vidver.EnableWindow(TRUE);
- m_vidhoredit.EnableWindow(TRUE);
- m_vidveredit.EnableWindow(TRUE);
- m_vidsetres.EnableWindow(TRUE);
- }
-
- {
- m_vidoutput.EnableWindow(TRUE);
- m_vidpreview.EnableWindow(TRUE);
- }
-
- UpdateMediaTypes();
-
- UpdateUserDefinableControls();
-
- UpdateOutputControls();
+ EmptyVideo();
+
+ // crossbar
+
+ if(m_pAMXB = pAMXB)
+ {
+ long OutputPinCount, InputPinCount;
+ if(SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount)))
+ {
+ for(int i = 0; i < InputPinCount; i++)
+ {
+ long PinIndexRelated, PhysicalType;
+ if(FAILED(pAMXB->get_CrossbarPinInfo(TRUE, i, &PinIndexRelated, &PhysicalType)))
+ continue;
+
+ if(PhysicalType >= PhysConn_Audio_Tuner)
+ continue;
+
+ CString str;
+ switch(PhysicalType)
+ {
+ case PhysConn_Video_Tuner: str = _T("Tuner"); break;
+ case PhysConn_Video_Composite: str = _T("Composite"); break;
+ case PhysConn_Video_SVideo: str = _T("SVideo"); break;
+ case PhysConn_Video_RGB: str = _T("RGB"); break;
+ case PhysConn_Video_YRYBY: str = _T("YRYBY"); break;
+ case PhysConn_Video_SerialDigital: str = _T("SerialDigital"); break;
+ case PhysConn_Video_ParallelDigital: str = _T("ParallelDigital"); break;
+ case PhysConn_Video_SCSI: str = _T("SCSI"); break;
+ case PhysConn_Video_AUX: str = _T("AUX"); break;
+ case PhysConn_Video_1394: str = _T("1394"); break;
+ case PhysConn_Video_USB: str = _T("USB"); break;
+ case PhysConn_Video_VideoDecoder: str = _T("VideoDecoder"); break;
+ case PhysConn_Video_VideoEncoder: str = _T("VideoEncoder"); break;
+ case PhysConn_Video_SCART: str = _T("SCART"); break;
+ default: str.Format(_T("PhysicalType %d"), PhysicalType); break;
+ }
+
+ m_vidinput.SetItemData(m_vidinput.AddString(str), i);
+ }
+ }
+ }
+
+ if(m_vidinput.GetCount() > 0)
+ {
+ m_vidinput.EnableWindow(TRUE);
+
+ long OutputPinCount, InputPinCount;
+ if(SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount)))
+ {
+ for(int i = 0; i < OutputPinCount; i++)
+ {
+ long InputPinIndex;
+ if(S_OK == pAMXB->get_IsRoutedTo(i, &InputPinIndex))
+ {
+ for(int j = 0; j < m_vidinput.GetCount(); j++)
+ {
+ if(m_vidinput.GetItemData(j) == InputPinIndex)
+ {
+ m_vidinput.SetCurSel(j);
+ i = OutputPinCount;
+ break;
+ }
+ }
+ }
+ }
+ }
+ OnVideoInput();
+ }
+
+ // tuner
+
+ if(m_pAMTuner = pAMTuner)
+ {
+ // TODO:...
+ }
+
+ // streamconfig
+
+ if(m_pAMVSC = pAMSC)
+ {
+ m_VidDisplayName = DisplayName;
+
+ AM_MEDIA_TYPE* pmt;
+ if(LoadMediaType(DisplayName, &pmt))
+ {
+ pAMSC->SetFormat(pmt);
+ DeleteMediaType(pmt);
+ }
+
+ SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
+ }
+
+ if(m_vidtype.GetCount() > 0)
+ {
+ m_vidfpsedit.EnableWindow(TRUE);
+ m_vidhor.EnableWindow(TRUE);
+ m_vidver.EnableWindow(TRUE);
+ m_vidhoredit.EnableWindow(TRUE);
+ m_vidveredit.EnableWindow(TRUE);
+ m_vidsetres.EnableWindow(TRUE);
+ }
+
+ {
+ m_vidoutput.EnableWindow(TRUE);
+ m_vidpreview.EnableWindow(TRUE);
+ }
+
+ UpdateMediaTypes();
+
+ UpdateUserDefinableControls();
+
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::SetupVideoControls(
- CStringW DisplayName,
- CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMVfwCaptureDialogs> pAMVfwCD)
+ CStringW DisplayName,
+ CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMVfwCaptureDialogs> pAMVfwCD)
{
- EmptyVideo();
-
- if(m_pAMVfwCD = pAMVfwCD)
- {
- if(S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Source))
- m_vidinput.SetItemData(m_vidinput.AddString(_T("Source")), (DWORD_PTR)VfwCaptureDialog_Source);
- if(S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Format))
- m_vidinput.SetItemData(m_vidinput.AddString(_T("Format")), (DWORD_PTR)VfwCaptureDialog_Format);
- if(S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Display))
- m_vidinput.SetItemData(m_vidinput.AddString(_T("Display")), (DWORD_PTR)VfwCaptureDialog_Display);
-
- if(m_vidinput.GetCount() > 0)
- {
- m_vidinput.EnableWindow(TRUE);
- m_vidinput.SetCurSel(0);
- }
- }
-
- // streamconfig
-
- if(m_pAMVSC = pAMSC)
- {
- m_VidDisplayName = DisplayName;
-
- AM_MEDIA_TYPE* pmt;
- if(LoadMediaType(DisplayName, &pmt))
- {
- pAMSC->SetFormat(pmt);
- DeleteMediaType(pmt);
- }
-
- SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
- }
-
- if(m_vidtype.GetCount() > 0)
- {
- m_vidfpsedit.EnableWindow(TRUE);
- m_vidhor.EnableWindow(TRUE);
- m_vidver.EnableWindow(TRUE);
- m_vidhoredit.EnableWindow(TRUE);
- m_vidveredit.EnableWindow(TRUE);
- m_vidsetres.EnableWindow(TRUE);
- }
-
- {
- m_vidoutput.EnableWindow(TRUE);
- m_vidpreview.EnableWindow(TRUE);
- }
-
- UpdateMediaTypes();
-
- UpdateUserDefinableControls();
-
- UpdateOutputControls();
+ EmptyVideo();
+
+ if(m_pAMVfwCD = pAMVfwCD)
+ {
+ if(S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Source))
+ m_vidinput.SetItemData(m_vidinput.AddString(_T("Source")), (DWORD_PTR)VfwCaptureDialog_Source);
+ if(S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Format))
+ m_vidinput.SetItemData(m_vidinput.AddString(_T("Format")), (DWORD_PTR)VfwCaptureDialog_Format);
+ if(S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Display))
+ m_vidinput.SetItemData(m_vidinput.AddString(_T("Display")), (DWORD_PTR)VfwCaptureDialog_Display);
+
+ if(m_vidinput.GetCount() > 0)
+ {
+ m_vidinput.EnableWindow(TRUE);
+ m_vidinput.SetCurSel(0);
+ }
+ }
+
+ // streamconfig
+
+ if(m_pAMVSC = pAMSC)
+ {
+ m_VidDisplayName = DisplayName;
+
+ AM_MEDIA_TYPE* pmt;
+ if(LoadMediaType(DisplayName, &pmt))
+ {
+ pAMSC->SetFormat(pmt);
+ DeleteMediaType(pmt);
+ }
+
+ SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
+ }
+
+ if(m_vidtype.GetCount() > 0)
+ {
+ m_vidfpsedit.EnableWindow(TRUE);
+ m_vidhor.EnableWindow(TRUE);
+ m_vidver.EnableWindow(TRUE);
+ m_vidhoredit.EnableWindow(TRUE);
+ m_vidveredit.EnableWindow(TRUE);
+ m_vidsetres.EnableWindow(TRUE);
+ }
+
+ {
+ m_vidoutput.EnableWindow(TRUE);
+ m_vidpreview.EnableWindow(TRUE);
+ }
+
+ UpdateMediaTypes();
+
+ UpdateUserDefinableControls();
+
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::SetupAudioControls(
- CStringW DisplayName,
- CComPtr<IAMStreamConfig> pAMSC, CInterfaceArray<IAMAudioInputMixer>& pAMAIM)
+ CStringW DisplayName,
+ CComPtr<IAMStreamConfig> pAMSC, CInterfaceArray<IAMAudioInputMixer>& pAMAIM)
{
- EmptyAudio();
+ EmptyAudio();
- // input selection
+ // input selection
- if(pAMAIM.GetCount() > 0)
- {
- m_pAMAIM.Copy(pAMAIM);
+ if(pAMAIM.GetCount() > 0)
+ {
+ m_pAMAIM.Copy(pAMAIM);
- int iSel = -1;
+ int iSel = -1;
- for(int i = 0; i < (int)m_pAMAIM.GetCount(); i++)
- {
- CComQIPtr<IPin> pPin = m_pAMAIM[i];
- m_audinput.SetItemData(m_audinput.AddString(CString(GetPinName(pPin))), (DWORD_PTR)i);
+ for(int i = 0; i < (int)m_pAMAIM.GetCount(); i++)
+ {
+ CComQIPtr<IPin> pPin = m_pAMAIM[i];
+ m_audinput.SetItemData(m_audinput.AddString(CString(GetPinName(pPin))), (DWORD_PTR)i);
- BOOL fEnable;
- if(SUCCEEDED(m_pAMAIM[i]->get_Enable(&fEnable)) && fEnable)
- iSel = i;
- }
+ BOOL fEnable;
+ if(SUCCEEDED(m_pAMAIM[i]->get_Enable(&fEnable)) && fEnable)
+ iSel = i;
+ }
- if(m_audinput.GetCount() > 0)
- {
- for(int i = 0; i < m_audinput.GetCount(); i++)
- {
- if(m_audinput.GetItemData(i) == iSel)
- {
- m_audinput.SetCurSel(i);
- break;
- }
- }
+ if(m_audinput.GetCount() > 0)
+ {
+ for(int i = 0; i < m_audinput.GetCount(); i++)
+ {
+ if(m_audinput.GetItemData(i) == iSel)
+ {
+ m_audinput.SetCurSel(i);
+ break;
+ }
+ }
- m_audinput.EnableWindow(TRUE);
- }
- }
+ m_audinput.EnableWindow(TRUE);
+ }
+ }
- // stream config
+ // stream config
- if(m_pAMASC = pAMSC)
- {
- m_AudDisplayName = DisplayName;
+ if(m_pAMASC = pAMSC)
+ {
+ m_AudDisplayName = DisplayName;
- AM_MEDIA_TYPE* pmt;
- if(LoadMediaType(DisplayName, &pmt))
- {
- pAMSC->SetFormat(pmt);
- DeleteMediaType(pmt);
- }
+ AM_MEDIA_TYPE* pmt;
+ if(LoadMediaType(DisplayName, &pmt))
+ {
+ pAMSC->SetFormat(pmt);
+ DeleteMediaType(pmt);
+ }
- SetupMediaTypes(pAMSC, m_afa, m_audtype, m_auddimension, m_mta);
- }
+ SetupMediaTypes(pAMSC, m_afa, m_audtype, m_auddimension, m_mta);
+ }
// if(m_audtype.GetCount() > 0)
- {
- m_audoutput.EnableWindow(TRUE);
- m_audpreview.EnableWindow(TRUE);
- }
+ {
+ m_audoutput.EnableWindow(TRUE);
+ m_audpreview.EnableWindow(TRUE);
+ }
- UpdateMediaTypes();
+ UpdateMediaTypes();
- UpdateUserDefinableControls();
+ UpdateUserDefinableControls();
- UpdateOutputControls();
+ UpdateOutputControls();
}
bool CPlayerCaptureDialog::IsTunerActive()
{
- int iSel = m_vidinput.GetCurSel();
- if(iSel < 0) return(false);
- iSel = m_vidinput.GetItemData(iSel);
- if(iSel < 0) return(false);
-
- long PinIndexRelated, PhysicalType;
- return(m_pAMXB
- && SUCCEEDED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType))
- && PhysicalType == PhysConn_Video_Tuner);
+ int iSel = m_vidinput.GetCurSel();
+ if(iSel < 0) return(false);
+ iSel = m_vidinput.GetItemData(iSel);
+ if(iSel < 0) return(false);
+
+ long PinIndexRelated, PhysicalType;
+ return(m_pAMXB
+ && SUCCEEDED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType))
+ && PhysicalType == PhysConn_Video_Tuner);
}
bool CPlayerCaptureDialog::SetVideoInput(int input)
{
- if(!m_pAMXB || input < 0) return false;
-
- for(int i = 0; i < m_vidinput.GetCount(); i++)
- {
- if(m_vidinput.GetItemData(i) == input)
- {
- m_vidinput.SetCurSel(i);
- OnVideoInput();
- return true;
- }
- }
-
- return false;
+ if(!m_pAMXB || input < 0) return false;
+
+ for(int i = 0; i < m_vidinput.GetCount(); i++)
+ {
+ if(m_vidinput.GetItemData(i) == input)
+ {
+ m_vidinput.SetCurSel(i);
+ OnVideoInput();
+ return true;
+ }
+ }
+
+ return false;
}
bool CPlayerCaptureDialog::SetVideoChannel(int channel)
{
- if(!m_pAMTuner || channel < 0) return false;
+ if(!m_pAMTuner || channel < 0) return false;
- return SUCCEEDED(m_pAMTuner->put_Channel(channel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT));
+ return SUCCEEDED(m_pAMTuner->put_Channel(channel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT));
}
bool CPlayerCaptureDialog::SetAudioInput(int input)
{
- if(input < 0) return false;
-
- for(int i = 0; i < m_audinput.GetCount(); i++)
- {
- if(m_audinput.GetItemData(i) == input)
- {
- m_audinput.SetCurSel(i);
- OnAudioInput();
- return true;
- }
- }
-
- return false;
+ if(input < 0) return false;
+
+ for(int i = 0; i < m_audinput.GetCount(); i++)
+ {
+ if(m_audinput.GetItemData(i) == input)
+ {
+ m_audinput.SetCurSel(i);
+ OnAudioInput();
+ return true;
+ }
+ }
+
+ return false;
}
int CPlayerCaptureDialog::GetVideoInput()
{
- int i = m_vidinput.GetCurSel();
- if(i < 0) return -1;
- return m_vidinput.GetItemData(i);
+ int i = m_vidinput.GetCurSel();
+ if(i < 0) return -1;
+ return m_vidinput.GetItemData(i);
}
int CPlayerCaptureDialog::GetVideoChannel()
{
- long lChannel, lVivSub, lAudSub;
- return m_pAMTuner && SUCCEEDED(m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub)) ? lChannel : -1;
+ long lChannel, lVivSub, lAudSub;
+ return m_pAMTuner && SUCCEEDED(m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub)) ? lChannel : -1;
}
int CPlayerCaptureDialog::GetAudioInput()
{
- int i = m_audinput.GetCurSel();
- if(i < 0) return -1;
- return m_audinput.GetItemData(i);
+ int i = m_audinput.GetCurSel();
+ if(i < 0) return -1;
+ return m_audinput.GetItemData(i);
}
BEGIN_MESSAGE_MAP(CPlayerCaptureDialog, CResizableDialog)
- ON_WM_DESTROY()
- ON_CBN_SELCHANGE(IDC_COMBO4, OnVideoInput)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnVideoType)
- ON_CBN_SELCHANGE(IDC_COMBO5, OnVideoDimension)
- ON_BN_CLICKED(IDC_BUTTON1, OnOverrideVideoDimension)
- ON_CBN_SELCHANGE(IDC_COMBO3, OnAudioInput)
- ON_CBN_SELCHANGE(IDC_COMBO2, OnAudioType)
- ON_CBN_SELCHANGE(IDC_COMBO6, OnAudioDimension)
- ON_BN_CLICKED(IDC_CHECK1, OnRecordVideo)
- ON_CBN_SELCHANGE(IDC_COMBO7, OnVideoCodec)
- ON_CBN_SELCHANGE(IDC_COMBO9, OnVideoCodecType)
- ON_CBN_SELCHANGE(IDC_COMBO10, OnVideoCodecDimension)
- ON_BN_CLICKED(IDC_CHECK3, OnRecordAudio)
- ON_CBN_SELCHANGE(IDC_COMBO8, OnAudioCodec)
- ON_CBN_SELCHANGE(IDC_COMBO12, OnAudioCodecType)
- ON_CBN_SELCHANGE(IDC_COMBO11, OnAudioCodecDimension)
- ON_BN_CLICKED(IDC_BUTTON3, OnOpenFile)
- ON_BN_CLICKED(IDC_BUTTON2, OnRecord)
- ON_EN_CHANGE(IDC_EDIT5, OnEnChangeEdit9)
- ON_EN_CHANGE(IDC_EDIT6, OnEnChangeEdit12)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_CHECK2, OnBnClickedVidAudPreview)
- ON_BN_CLICKED(IDC_CHECK4, OnBnClickedVidAudPreview)
- ON_BN_CLICKED(IDC_CHECK5, OnBnClickedCheck7)
- ON_CBN_SELCHANGE(IDC_COMBO14, OnCbnSelchangeCombo14)
+ ON_WM_DESTROY()
+ ON_CBN_SELCHANGE(IDC_COMBO4, OnVideoInput)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnVideoType)
+ ON_CBN_SELCHANGE(IDC_COMBO5, OnVideoDimension)
+ ON_BN_CLICKED(IDC_BUTTON1, OnOverrideVideoDimension)
+ ON_CBN_SELCHANGE(IDC_COMBO3, OnAudioInput)
+ ON_CBN_SELCHANGE(IDC_COMBO2, OnAudioType)
+ ON_CBN_SELCHANGE(IDC_COMBO6, OnAudioDimension)
+ ON_BN_CLICKED(IDC_CHECK1, OnRecordVideo)
+ ON_CBN_SELCHANGE(IDC_COMBO7, OnVideoCodec)
+ ON_CBN_SELCHANGE(IDC_COMBO9, OnVideoCodecType)
+ ON_CBN_SELCHANGE(IDC_COMBO10, OnVideoCodecDimension)
+ ON_BN_CLICKED(IDC_CHECK3, OnRecordAudio)
+ ON_CBN_SELCHANGE(IDC_COMBO8, OnAudioCodec)
+ ON_CBN_SELCHANGE(IDC_COMBO12, OnAudioCodecType)
+ ON_CBN_SELCHANGE(IDC_COMBO11, OnAudioCodecDimension)
+ ON_BN_CLICKED(IDC_BUTTON3, OnOpenFile)
+ ON_BN_CLICKED(IDC_BUTTON2, OnRecord)
+ ON_EN_CHANGE(IDC_EDIT5, OnEnChangeEdit9)
+ ON_EN_CHANGE(IDC_EDIT6, OnEnChangeEdit12)
+ ON_WM_TIMER()
+ ON_BN_CLICKED(IDC_CHECK2, OnBnClickedVidAudPreview)
+ ON_BN_CLICKED(IDC_CHECK4, OnBnClickedVidAudPreview)
+ ON_BN_CLICKED(IDC_CHECK5, OnBnClickedCheck7)
+ ON_CBN_SELCHANGE(IDC_COMBO14, OnCbnSelchangeCombo14)
END_MESSAGE_MAP()
@@ -1280,400 +1250,393 @@ END_MESSAGE_MAP()
BOOL CPlayerCaptureDialog::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- InitCodecList(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
- UpdateVideoCodec();
+ InitCodecList(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
+ UpdateVideoCodec();
- InitCodecList(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
- UpdateAudioCodec();
+ InitCodecList(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
+ UpdateAudioCodec();
- m_fEnableOgm = IsCLSIDRegistered(_T("{8cae96b7-85b1-4605-b23c-17ff5262b296}"));
+ m_fEnableOgm = IsCLSIDRegistered(_T("{8cae96b7-85b1-4605-b23c-17ff5262b296}"));
- m_nVidBuffers = AfxGetApp()->GetProfileInt(_T("Capture"), _T("VidBuffers"), 50);
- m_nAudBuffers = AfxGetApp()->GetProfileInt(_T("Capture"), _T("AudBuffers"), 50);
- m_fVidOutput = !!AfxGetApp()->GetProfileInt(_T("Capture"), _T("VidOutput"), TRUE);
- m_fAudOutput = !!AfxGetApp()->GetProfileInt(_T("Capture"), _T("AudOutput"), TRUE);
- m_fVidPreview = AfxGetApp()->GetProfileInt(_T("Capture"), _T("VidPreview"), TRUE);
- m_fAudPreview = AfxGetApp()->GetProfileInt(_T("Capture"), _T("AudPreview"), TRUE);
- m_muxtype = AfxGetApp()->GetProfileInt(_T("Capture"), _T("FileFormat"), 0);
- m_file = AfxGetApp()->GetProfileString(_T("Capture"), _T("FileName"), _T(""));
- m_fSepAudio = AfxGetApp()->GetProfileInt(_T("Capture"), _T("SepAudio"), TRUE);
+ m_nVidBuffers = AfxGetApp()->GetProfileInt(_T("Capture"), _T("VidBuffers"), 50);
+ m_nAudBuffers = AfxGetApp()->GetProfileInt(_T("Capture"), _T("AudBuffers"), 50);
+ m_fVidOutput = !!AfxGetApp()->GetProfileInt(_T("Capture"), _T("VidOutput"), TRUE);
+ m_fAudOutput = !!AfxGetApp()->GetProfileInt(_T("Capture"), _T("AudOutput"), TRUE);
+ m_fVidPreview = AfxGetApp()->GetProfileInt(_T("Capture"), _T("VidPreview"), TRUE);
+ m_fAudPreview = AfxGetApp()->GetProfileInt(_T("Capture"), _T("AudPreview"), TRUE);
+ m_muxtype = AfxGetApp()->GetProfileInt(_T("Capture"), _T("FileFormat"), 0);
+ m_file = AfxGetApp()->GetProfileString(_T("Capture"), _T("FileName"), _T(""));
+ m_fSepAudio = AfxGetApp()->GetProfileInt(_T("Capture"), _T("SepAudio"), TRUE);
- m_muxctrl.AddString(_T("AVI"));
- m_muxctrl.AddString(_T("Ogg Media"));
- m_muxctrl.AddString(_T("Matroska"));
- m_muxctrl.AddString(_T("DirectShow Media"));
+ m_muxctrl.AddString(_T("AVI"));
+ m_muxctrl.AddString(_T("Ogg Media"));
+ m_muxctrl.AddString(_T("Matroska"));
+ m_muxctrl.AddString(_T("DirectShow Media"));
// UpdateMuxer();
- UpdateData(FALSE);
+ UpdateData(FALSE);
- OnCbnSelchangeCombo14();
+ OnCbnSelchangeCombo14();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPlayerCaptureDialog::OnDestroy()
{
- UpdateData();
+ UpdateData();
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("VidOutput"), m_fVidOutput);
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("AudOutput"), m_fAudOutput);
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("VidPreview"), m_fVidPreview);
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("AudPreview"), m_fAudPreview);
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("FileFormat"), m_muxtype);
- AfxGetApp()->WriteProfileString(_T("Capture"), _T("FileName"), m_file);
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("SepAudio"), m_fSepAudio);
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("VidOutput"), m_fVidOutput);
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("AudOutput"), m_fAudOutput);
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("VidPreview"), m_fVidPreview);
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("AudPreview"), m_fAudPreview);
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("FileFormat"), m_muxtype);
+ AfxGetApp()->WriteProfileString(_T("Capture"), _T("FileName"), m_file);
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("SepAudio"), m_fSepAudio);
- __super::OnDestroy();
+ __super::OnDestroy();
}
void CPlayerCaptureDialog::OnVideoInput()
{
- int iSel = m_vidinput.GetCurSel();
- if(iSel < 0) return;
- iSel = m_vidinput.GetItemData(iSel);
- if(iSel < 0) return;
-
- if(m_pAMXB)
- {
- long PinIndexRelated, PhysicalType;
- if(FAILED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType)))
- return;
-
- long OutputPinCount, InputPinCount;
- if(FAILED(m_pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount)))
- return;
-
- for(int i = 0; i < OutputPinCount; i++)
- {
- if(S_OK == m_pAMXB->CanRoute(i, iSel))
- {
- m_pAMXB->Route(i, iSel);
- break;
- }
- }
-
- if(PinIndexRelated >= 0)
- {
- for(int i = 0; i < OutputPinCount; i++)
- {
- if(S_OK == m_pAMXB->CanRoute(i, PinIndexRelated))
- {
- m_pAMXB->Route(i, PinIndexRelated);
- break;
- }
- }
- }
- }
- else if(m_pAMVfwCD)
- {
- if(S_OK == m_pAMVfwCD->HasDialog(iSel))
- {
- HRESULT hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
-
- if(VFW_E_NOT_STOPPED == hr)
- {
- ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_STOP);
- hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
- ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
-
- if(VFW_E_CANNOT_CONNECT == hr)
- UpdateGraph();
- }
- }
+ int iSel = m_vidinput.GetCurSel();
+ if(iSel < 0) return;
+ iSel = m_vidinput.GetItemData(iSel);
+ if(iSel < 0) return;
+
+ if(m_pAMXB)
+ {
+ long PinIndexRelated, PhysicalType;
+ if(FAILED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType)))
+ return;
+
+ long OutputPinCount, InputPinCount;
+ if(FAILED(m_pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount)))
+ return;
+
+ for(int i = 0; i < OutputPinCount; i++)
+ {
+ if(S_OK == m_pAMXB->CanRoute(i, iSel))
+ {
+ m_pAMXB->Route(i, iSel);
+ break;
+ }
+ }
+
+ if(PinIndexRelated >= 0)
+ {
+ for(int i = 0; i < OutputPinCount; i++)
+ {
+ if(S_OK == m_pAMXB->CanRoute(i, PinIndexRelated))
+ {
+ m_pAMXB->Route(i, PinIndexRelated);
+ break;
+ }
+ }
+ }
+ }
+ else if(m_pAMVfwCD)
+ {
+ if(S_OK == m_pAMVfwCD->HasDialog(iSel))
+ {
+ HRESULT hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
+
+ if(VFW_E_NOT_STOPPED == hr)
+ {
+ ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
+ ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+
+ if(VFW_E_CANNOT_CONNECT == hr)
+ UpdateGraph();
+ }
+ }
}
void CPlayerCaptureDialog::OnVideoType()
{
- if(SetupDimension(m_vfa, m_vidtype, m_viddimension))
- OnVideoDimension();
+ if(SetupDimension(m_vfa, m_vidtype, m_viddimension))
+ OnVideoDimension();
}
void CPlayerCaptureDialog::OnVideoDimension()
{
- int iSel = m_viddimension.GetCurSel();
- if(iSel < 0) return;
-
- CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
- if(!pvfe) return;
-
- BITMAPINFOHEADER* bih = (pvfe->mt.formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->bmiHeader
- : (pvfe->mt.formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pvfe->mt.pbFormat)->bmiHeader
- : NULL;
-
- m_vidhor.SetRange(0, 32767);
- m_vidver.SetRange(0, 32767);
- m_vidhor.SetPos(bih->biWidth);
- m_vidver.SetPos(abs(bih->biHeight));
- CString fps;
- fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->AvgTimePerFrame));
- m_vidfpsedit.SetWindowText(fps);
-
- UpdateGraph();
+ int iSel = m_viddimension.GetCurSel();
+ if(iSel < 0) return;
+
+ CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
+ if(!pvfe) return;
+
+ BITMAPINFOHEADER* bih = (pvfe->mt.formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->bmiHeader
+ : (pvfe->mt.formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pvfe->mt.pbFormat)->bmiHeader
+ : NULL;
+
+ m_vidhor.SetRange(0, 32767);
+ m_vidver.SetRange(0, 32767);
+ m_vidhor.SetPos(bih->biWidth);
+ m_vidver.SetPos(abs(bih->biHeight));
+ CString fps;
+ fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->AvgTimePerFrame));
+ m_vidfpsedit.SetWindowText(fps);
+
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnOverrideVideoDimension()
{
- UpdateGraph();
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnAudioInput()
{
- int iSel = m_audinput.GetCurSel();
+ int iSel = m_audinput.GetCurSel();
- for(int i = 0; i < (int)m_pAMAIM.GetCount(); i++)
- {
- m_pAMAIM[m_audinput.GetItemData(i)]->put_Enable(i == iSel ? TRUE : FALSE);
- }
+ for(int i = 0; i < (int)m_pAMAIM.GetCount(); i++)
+ {
+ m_pAMAIM[m_audinput.GetItemData(i)]->put_Enable(i == iSel ? TRUE : FALSE);
+ }
}
void CPlayerCaptureDialog::OnAudioType()
{
- if(SetupDimension(m_afa, m_audtype, m_auddimension))
- OnAudioDimension();
+ if(SetupDimension(m_afa, m_audtype, m_auddimension))
+ OnAudioDimension();
}
void CPlayerCaptureDialog::OnAudioDimension()
{
- UpdateGraph();
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnRecordVideo()
{
- UpdateOutputControls();
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::OnVideoCodec()
{
- ShowPPage(m_pVidEncArray, m_vidcodec, m_hWnd);
- UpdateVideoCodec();
+ ShowPPage(m_pVidEncArray, m_vidcodec, m_hWnd);
+ UpdateVideoCodec();
}
void CPlayerCaptureDialog::OnVideoCodecType()
{
- if(SetupDimension(m_vcfa, m_vidcodectype, m_vidcodecdimension))
- OnVideoCodecDimension();
+ if(SetupDimension(m_vcfa, m_vidcodectype, m_vidcodecdimension))
+ OnVideoCodecDimension();
}
void CPlayerCaptureDialog::OnVideoCodecDimension()
{
- int i = m_vidcodecdimension.GetCurSel();
- if(i >= 0)
- {
- m_mtcv = ((CVidFormatElem*)m_vidcodecdimension.GetItemData(i))->mt;
-
- // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
- m_pVidEnc = NULL;
- m_pVidEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pVidEnc);
- }
+ int i = m_vidcodecdimension.GetCurSel();
+ if(i >= 0)
+ {
+ m_mtcv = ((CVidFormatElem*)m_vidcodecdimension.GetItemData(i))->mt;
+
+ // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
+ m_pVidEnc = NULL;
+ m_pVidEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pVidEnc);
+ }
}
void CPlayerCaptureDialog::OnRecordAudio()
{
- UpdateOutputControls();
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::OnAudioCodec()
{
- ShowPPage(m_pAudEncArray, m_audcodec, m_hWnd);
- UpdateAudioCodec();
+ ShowPPage(m_pAudEncArray, m_audcodec, m_hWnd);
+ UpdateAudioCodec();
}
void CPlayerCaptureDialog::OnAudioCodecType()
{
- if(SetupDimension(m_acfa, m_audcodectype, m_audcodecdimension))
- OnAudioCodecDimension();
+ if(SetupDimension(m_acfa, m_audcodectype, m_audcodecdimension))
+ OnAudioCodecDimension();
}
void CPlayerCaptureDialog::OnAudioCodecDimension()
{
- int i = m_audcodecdimension.GetCurSel();
- if(i >= 0)
- {
- m_mtca = ((CAudFormatElem*)m_audcodecdimension.GetItemData(i))->mt;
-
- // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
- m_pAudEnc = NULL;
- m_pAudEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pAudEnc);
- /*
- SaveMediaType(
- CString(m_pAudEncArray[m_audcodec.GetItemData(m_audcodec.GetCurSel())].DisplayName.m_str),
- &m_mtca);
- */
- }
+ int i = m_audcodecdimension.GetCurSel();
+ if(i >= 0)
+ {
+ m_mtca = ((CAudFormatElem*)m_audcodecdimension.GetItemData(i))->mt;
+
+ // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
+ m_pAudEnc = NULL;
+ m_pAudEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pAudEnc);
+/*
+ SaveMediaType(
+ CString(m_pAudEncArray[m_audcodec.GetItemData(m_audcodec.GetCurSel())].DisplayName.m_str),
+ &m_mtca);
+*/ }
}
void CPlayerCaptureDialog::OnOpenFile()
{
- CFileDialog fd(FALSE, NULL, NULL,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- _T("Media files (*.avi,*.ogm,*.mkv,*.dsm)|*.avi;*.ogm;*.mkv;*.dsm|"), this, 0);
-
- if(fd.DoModal() == IDOK)
- {
- CString str = fd.GetPathName();
-
- CString ext = str.Mid(str.ReverseFind('.') + 1).MakeLower();
- if(ext == _T("avi")) m_muxtype = 0;
- else if(ext == _T("ogm")) m_muxtype = 1;
- else if(ext == _T("mkv")) m_muxtype = 2;
- else if(ext == _T("dsm")) m_muxtype = 3;
- else
- {
- if(m_muxtype == 0) str += _T(".avi");
- else if(m_muxtype == 1) str += _T(".ogm");
- else if(m_muxtype == 2) str += _T(".mkv");
- else if(m_muxtype == 3) str += _T(".dsm");
- }
-
- m_file = str;
-
- UpdateData(FALSE);
- }
-
- UpdateOutputControls();
+ CFileDialog fd(FALSE, NULL, NULL,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
+ _T("Media files (*.avi,*.ogm,*.mkv,*.dsm)|*.avi;*.ogm;*.mkv;*.dsm|"), this, 0);
+
+ if(fd.DoModal() == IDOK)
+ {
+ CString str = fd.GetPathName();
+
+ CString ext = str.Mid(str.ReverseFind('.')+1).MakeLower();
+ if(ext == _T("avi")) m_muxtype = 0;
+ else if(ext == _T("ogm")) m_muxtype = 1;
+ else if(ext == _T("mkv")) m_muxtype = 2;
+ else if(ext == _T("dsm")) m_muxtype = 3;
+ else
+ {
+ if(m_muxtype == 0) str += _T(".avi");
+ else if(m_muxtype == 1) str += _T(".ogm");
+ else if(m_muxtype == 2) str += _T(".mkv");
+ else if(m_muxtype == 3) str += _T(".dsm");
+ }
+
+ m_file = str;
+
+ UpdateData(FALSE);
+ }
+
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::OnRecord()
{
- UpdateData();
-
- CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
- if(!pFrame) return;
-
- if(!pFrame->m_fCapturing)
- {
- UpdateMuxer();
-
- CComQIPtr<IFileSinkFilter2> pFSF = m_pMux;
- if(pFSF)
- {
- m_pDst = m_pMux;
- }
- else
- {
- m_pDst = NULL;
- m_pDst.CoCreateInstance(CLSID_FileWriter);
- pFSF = m_pDst;
- }
-
- if(!pFSF
- || FAILED(pFSF->SetFileName(CStringW(m_file), NULL))
- || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE)))
- {
- AfxMessageBox(_T("Error initializing the output file"));
- return;
- }
-
- CString audfn = m_file.Left(m_file.ReverseFind('.') + 1);
- if(m_fSepAudio && m_fAudOutput && m_pAudMux && !audfn.IsEmpty())
- {
- audfn += _T("wav");
-
- CComQIPtr<IFileSinkFilter2> pFSF = m_pAudMux;
- if(pFSF)
- {
- m_pAudDst = m_pAudMux;
- }
- else
- {
- m_pAudDst = NULL;
- m_pAudDst.CoCreateInstance(CLSID_FileWriter);
- pFSF = m_pAudDst;
- }
-
- if(!pFSF
- || FAILED(pFSF->SetFileName(CStringW(audfn), NULL))
- || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE)))
- {
- AfxMessageBox(_T("Error initializing the audio output file"));
- return;
- }
- }
-
- m_pVidBuffer = m_fVidOutput && m_nVidBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
- if(CComQIPtr<IBufferFilter> pVB = m_pVidBuffer)
- {
- pVB->SetBuffers(m_nVidBuffers);
- pVB->SetPriority(THREAD_PRIORITY_NORMAL);
- }
-
- m_pAudBuffer = m_fAudOutput && m_nAudBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
- if(CComQIPtr<IBufferFilter> pAB = m_pAudBuffer)
- {
- pAB->SetBuffers(m_nAudBuffers);
- pAB->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL);
- }
-
- EnableControls(this, false);
-
- pFrame->StartCapture();
-
- SetTimer(1, 100, NULL);
- }
- else
- {
- KillTimer(1);
-
- pFrame->StopCapture();
- /*
- {
- if(FILE* f = _tfopen(m_file, _T("rb+")))
- {
- fseek(f, 0x20, SEEK_SET);
- unsigned short mspf = (unsigned short)(((VIDEOINFOHEADER*)m_mtv.pbFormat)->AvgTimePerFrame / 10);
- fwrite(&mspf, 1, 2, f);
- fclose(f);
- }
- }
- */
- EnableControls(this, true);
-
- m_pVidBuffer = NULL;
- m_pAudBuffer = NULL;
- }
+ UpdateData();
+
+ CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
+ if(!pFrame) return;
+
+ if(!pFrame->m_fCapturing)
+ {
+ UpdateMuxer();
+
+ CComQIPtr<IFileSinkFilter2> pFSF = m_pMux;
+ if(pFSF)
+ {
+ m_pDst = m_pMux;
+ }
+ else
+ {
+ m_pDst = NULL;
+ m_pDst.CoCreateInstance(CLSID_FileWriter);
+ pFSF = m_pDst;
+ }
+
+ if(!pFSF
+ || FAILED(pFSF->SetFileName(CStringW(m_file), NULL))
+ || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE)))
+ {
+ AfxMessageBox(_T("Error initializing the output file"));
+ return;
+ }
+
+ CString audfn = m_file.Left(m_file.ReverseFind('.')+1);
+ if(m_fSepAudio && m_fAudOutput && m_pAudMux && !audfn.IsEmpty())
+ {
+ audfn += _T("wav");
+
+ CComQIPtr<IFileSinkFilter2> pFSF = m_pAudMux;
+ if(pFSF)
+ {
+ m_pAudDst = m_pAudMux;
+ }
+ else
+ {
+ m_pAudDst = NULL;
+ m_pAudDst.CoCreateInstance(CLSID_FileWriter);
+ pFSF = m_pAudDst;
+ }
+
+ if(!pFSF
+ || FAILED(pFSF->SetFileName(CStringW(audfn), NULL))
+ || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE)))
+ {
+ AfxMessageBox(_T("Error initializing the audio output file"));
+ return;
+ }
+ }
+
+ m_pVidBuffer = m_fVidOutput && m_nVidBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
+ if(CComQIPtr<IBufferFilter> pVB = m_pVidBuffer)
+ {pVB->SetBuffers(m_nVidBuffers); pVB->SetPriority(THREAD_PRIORITY_NORMAL);}
+
+ m_pAudBuffer = m_fAudOutput && m_nAudBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
+ if(CComQIPtr<IBufferFilter> pAB = m_pAudBuffer)
+ {pAB->SetBuffers(m_nAudBuffers); pAB->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL);}
+
+ EnableControls(this, false);
+
+ pFrame->StartCapture();
+
+ SetTimer(1, 100, NULL);
+ }
+ else
+ {
+ KillTimer(1);
+
+ pFrame->StopCapture();
+/*
+ {
+ if(FILE* f = _tfopen(m_file, _T("rb+")))
+ {
+ fseek(f, 0x20, SEEK_SET);
+ unsigned short mspf = (unsigned short)(((VIDEOINFOHEADER*)m_mtv.pbFormat)->AvgTimePerFrame / 10);
+ fwrite(&mspf, 1, 2, f);
+ fclose(f);
+ }
+ }
+*/
+ EnableControls(this, true);
+
+ m_pVidBuffer = NULL;
+ m_pAudBuffer = NULL;
+ }
}
void CPlayerCaptureDialog::OnEnChangeEdit9()
{
- UpdateData();
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("VidBuffers"), max(m_nVidBuffers, 0));
+ UpdateData();
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("VidBuffers"), max(m_nVidBuffers, 0));
}
void CPlayerCaptureDialog::OnEnChangeEdit12()
{
- UpdateData();
- AfxGetApp()->WriteProfileInt(_T("Capture"), _T("AudBuffers"), max(m_nAudBuffers, 0));
+ UpdateData();
+ AfxGetApp()->WriteProfileInt(_T("Capture"), _T("AudBuffers"), max(m_nAudBuffers, 0));
}
void CPlayerCaptureDialog::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
- if(((CMainFrame*)AfxGetMainWnd())->m_fCapturing)
- {
- ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
- if(GetDiskFreeSpaceEx(m_file.Left(m_file.ReverseFind('\\') + 1), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)
- && FreeBytesAvailable.QuadPart < 1024i64 * 1024 * 10)
- {
- OnRecord();
- }
- }
- }
-
- __super::OnTimer(nIDEvent);
+ if(nIDEvent == 1)
+ {
+ if(((CMainFrame*)AfxGetMainWnd())->m_fCapturing)
+ {
+ ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
+ if(GetDiskFreeSpaceEx(m_file.Left(m_file.ReverseFind('\\')+1), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)
+ && FreeBytesAvailable.QuadPart < 1024i64*1024*10)
+ {
+ OnRecord();
+ }
+ }
+ }
+
+ __super::OnTimer(nIDEvent);
}
void CPlayerCaptureDialog::OnBnClickedVidAudPreview()
{
- UpdateData();
- UpdateGraph();
+ UpdateData();
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnBnClickedCheck7()
@@ -1683,23 +1646,23 @@ void CPlayerCaptureDialog::OnBnClickedCheck7()
void CPlayerCaptureDialog::OnCbnSelchangeCombo14()
{
- UpdateData();
+ UpdateData();
- CString ext = m_file.Mid(m_file.ReverseFind('.') + 1).MakeLower();
+ CString ext = m_file.Mid(m_file.ReverseFind('.')+1).MakeLower();
- if(m_muxtype == 0 && ext != _T("avi"))
- m_file = m_file.Left(m_file.GetLength() - 4) + _T(".avi");
- else if(m_muxtype == 1 && ext != _T("ogm"))
- m_file = m_file.Left(m_file.GetLength() - 4) + _T(".ogm");
- else if(m_muxtype == 2 && ext != _T("mkv"))
- m_file = m_file.Left(m_file.GetLength() - 4) + _T(".mkv");
- else if(m_muxtype == 3 && ext != _T("dsm"))
- m_file = m_file.Left(m_file.GetLength() - 4) + _T(".dsm");
+ if(m_muxtype == 0 && ext != _T("avi"))
+ m_file = m_file.Left(m_file.GetLength()-4) + _T(".avi");
+ else if(m_muxtype == 1 && ext != _T("ogm"))
+ m_file = m_file.Left(m_file.GetLength()-4) + _T(".ogm");
+ else if(m_muxtype == 2 && ext != _T("mkv"))
+ m_file = m_file.Left(m_file.GetLength()-4) + _T(".mkv");
+ else if(m_muxtype == 3 && ext != _T("dsm"))
+ m_file = m_file.Left(m_file.GetLength()-4) + _T(".dsm");
- UpdateData(FALSE);
+ UpdateData(FALSE);
- GetDlgItem(IDC_EDIT5)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
- GetDlgItem(IDC_EDIT6)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
+ GetDlgItem(IDC_EDIT5)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
+ GetDlgItem(IDC_EDIT6)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
- m_recordbtn.EnableWindow(m_muxtype != 1 || m_fEnableOgm);
+ m_recordbtn.EnableWindow(m_muxtype != 1 || m_fEnableOgm);
}
diff --git a/src/apps/mplayerc/PlayerCaptureDialog.h b/src/apps/mplayerc/PlayerCaptureDialog.h
index 520c457e9..d29f3389e 100644
--- a/src/apps/mplayerc/PlayerCaptureDialog.h
+++ b/src/apps/mplayerc/PlayerCaptureDialog.h
@@ -35,125 +35,114 @@ template<class T>
class CFormatElem
{
public:
- CMediaType mt;
- T caps;
+ CMediaType mt;
+ T caps;
};
template<class T>
class CFormat : public CAutoPtrArray<CFormatElem<T> >
{
public:
- CString name;
- CFormat(CString name = _T(""))
- {
- this->name = name;
- }
- virtual ~CFormat() {}
+ CString name;
+ CFormat(CString name = _T("")) {this->name = name;}
+ virtual ~CFormat() {}
};
template<class T>
class CFormatArray : public CAutoPtrArray<CFormat<T> >
{
public:
- virtual ~CFormatArray() {}
-
- CFormat<T>* Find(CString name, bool fCreate = false)
- {
- for(int i = 0; i < (int)GetCount(); i++)
- {
- if(GetAt(i)->name == name)
- return(GetAt(i));
- }
-
- if(fCreate)
- {
- CAutoPtr<CFormat<T> > pf(DNew CFormat<T>(name));
- CFormat<T>* tmp = pf;
- Add(pf);
- return(tmp);
- }
-
- return(NULL);
- }
-
- bool FindFormat(AM_MEDIA_TYPE* pmt, CFormat<T>** ppf)
- {
- if(!pmt) return(false);
-
- for(int i = 0; i < (int)GetCount(); i++)
- {
- CFormat<T>* pf = GetAt(i);
- for(int j = 0; j < (int)pf->GetCount(); j++)
- {
- CFormatElem<T>* pfe = pf->GetAt(j);
- if(!pmt || (pfe->mt.majortype == pmt->majortype && pfe->mt.subtype == pmt->subtype))
- {
- if(ppf) *ppf = pf;
- return(true);
- }
- }
- }
-
- return(false);
- }
-
- bool FindFormat(AM_MEDIA_TYPE* pmt, T* pcaps, CFormat<T>** ppf, CFormatElem<T>** ppfe)
- {
- if(!pmt && !pcaps) return(false);
-
- for(int i = 0; i < (int)GetCount(); i++)
- {
- CFormat<T>* pf = GetAt(i);
- for(int j = 0; j < (int)pf->GetCount(); j++)
- {
- CFormatElem<T>* pfe = pf->GetAt(j);
- if((!pmt || pfe->mt == *pmt) && (!pcaps || !memcmp(pcaps, &pfe->caps, sizeof(T))))
- {
- if(ppf) *ppf = pf;
- if(ppfe) *ppfe = pfe;
- return(true);
- }
- }
- }
-
- return(false);
- }
-
- bool AddFormat(AM_MEDIA_TYPE* pmt, T caps)
- {
- if(!pmt) return(false);
-
- if(FindFormat(pmt, NULL, NULL, NULL))
- {
- DeleteMediaType(pmt);
- return(false);
- }
+ virtual ~CFormatArray() {}
+
+ CFormat<T>* Find(CString name, bool fCreate = false)
+ {
+ for(int i = 0; i < (int)GetCount(); i++)
+ {
+ if(GetAt(i)->name == name)
+ return(GetAt(i));
+ }
+
+ if(fCreate)
+ {
+ CAutoPtr<CFormat<T> > pf(DNew CFormat<T>(name));
+ CFormat<T>* tmp = pf;
+ Add(pf);
+ return(tmp);
+ }
+
+ return(NULL);
+ }
+
+ bool FindFormat(AM_MEDIA_TYPE* pmt, CFormat<T>** ppf)
+ {
+ if(!pmt) return(false);
+
+ for(int i = 0; i < (int)GetCount(); i++)
+ {
+ CFormat<T>* pf = GetAt(i);
+ for(int j = 0; j < (int)pf->GetCount(); j++)
+ {
+ CFormatElem<T>* pfe = pf->GetAt(j);
+ if(!pmt || (pfe->mt.majortype == pmt->majortype && pfe->mt.subtype == pmt->subtype))
+ {
+ if(ppf) *ppf = pf;
+ return(true);
+ }
+ }
+ }
+
+ return(false);
+ }
+
+ bool FindFormat(AM_MEDIA_TYPE* pmt, T* pcaps, CFormat<T>** ppf, CFormatElem<T>** ppfe)
+ {
+ if(!pmt && !pcaps) return(false);
+
+ for(int i = 0; i < (int)GetCount(); i++)
+ {
+ CFormat<T>* pf = GetAt(i);
+ for(int j = 0; j < (int)pf->GetCount(); j++)
+ {
+ CFormatElem<T>* pfe = pf->GetAt(j);
+ if((!pmt || pfe->mt == *pmt) && (!pcaps || !memcmp(pcaps, &pfe->caps, sizeof(T))))
+ {
+ if(ppf) *ppf = pf;
+ if(ppfe) *ppfe = pfe;
+ return(true);
+ }
+ }
+ }
+
+ return(false);
+ }
+
+ bool AddFormat(AM_MEDIA_TYPE* pmt, T caps)
+ {
+ if(!pmt) return(false);
+
+ if(FindFormat(pmt, NULL, NULL, NULL)) {DeleteMediaType(pmt); return(false);}
// if(pmt->formattype == FORMAT_VideoInfo2) {DeleteMediaType(pmt); return(false);} // TODO
- CFormat<T>* pf = Find(MakeFormatName(pmt), true);
- if(!pf)
- {
- DeleteMediaType(pmt);
- return(false);
- }
-
- CAutoPtr<CFormatElem<T> > pfe(DNew CFormatElem<T>());
- pfe->mt = *pmt;
- pfe->caps = caps;
- pf->Add(pfe);
-
- return(true);
- }
-
- bool AddFormat(AM_MEDIA_TYPE* pmt, void* pcaps, int size)
- {
- if(!pcaps) return false;
- ASSERT(size == sizeof(T));
- return AddFormat(pmt, *(T*)pcaps);
- }
-
- virtual CString MakeFormatName(AM_MEDIA_TYPE* pmt) = 0;
- virtual CString MakeDimensionName(CFormatElem<T>* pfe) = 0;
+ CFormat<T>* pf = Find(MakeFormatName(pmt), true);
+ if(!pf) {DeleteMediaType(pmt); return(false);}
+
+ CAutoPtr<CFormatElem<T> > pfe(DNew CFormatElem<T>());
+ pfe->mt = *pmt;
+ pfe->caps = caps;
+ pf->Add(pfe);
+
+ return(true);
+ }
+
+ bool AddFormat(AM_MEDIA_TYPE* pmt, void* pcaps, int size)
+ {
+ if(!pcaps) return false;
+ ASSERT(size == sizeof(T));
+ return AddFormat(pmt, *(T*)pcaps);
+ }
+
+ virtual CString MakeFormatName(AM_MEDIA_TYPE* pmt) = 0;
+ virtual CString MakeDimensionName(CFormatElem<T>* pfe) = 0;
};
typedef CFormatElem<VIDEO_STREAM_CONFIG_CAPS> CVidFormatElem;
@@ -162,92 +151,80 @@ typedef CFormat<VIDEO_STREAM_CONFIG_CAPS> CVidFormat;
class CVidFormatArray : public CFormatArray<VIDEO_STREAM_CONFIG_CAPS>
{
public:
- CString MakeFormatName(AM_MEDIA_TYPE* pmt)
- {
- CString str(_T("Default"));
-
- if(!pmt) return(str);
-
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
-
- if(!bih)
- {
- // it may have a fourcc in the mediasubtype, let's check that
-
- WCHAR guid[100];
- memset(guid, 0, 100 * sizeof(WCHAR));
- StringFromGUID2(pmt->subtype, guid, 100);
-
- if(CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0)
- {
- str.Format(_T("%c%c%c%c"),
- (TCHAR)((pmt->subtype.Data1 >> 0) & 0xff), (TCHAR)((pmt->subtype.Data1 >> 8) & 0xff),
- (TCHAR)((pmt->subtype.Data1 >> 16) & 0xff), (TCHAR)((pmt->subtype.Data1 >> 24) & 0xff));
- }
-
- return(str);
- }
-
- switch(bih->biCompression)
- {
- case BI_RGB:
- str.Format(_T("RGB%d"), bih->biBitCount);
- break;
- case BI_RLE8:
- str = _T("RLE8");
- break;
- case BI_RLE4:
- str = _T("RLE4");
- break;
- case BI_BITFIELDS:
- str.Format(_T("BITF%d"), bih->biBitCount);
- break;
- case BI_JPEG:
- str = _T("JPEG");
- break;
- case BI_PNG:
- str = _T("PNG");
- break;
- default:
- str.Format(_T("%c%c%c%c"),
- (TCHAR)((bih->biCompression >> 0) & 0xff), (TCHAR)((bih->biCompression >> 8) & 0xff),
- (TCHAR)((bih->biCompression >> 16) & 0xff), (TCHAR)((bih->biCompression >> 24) & 0xff));
- break;
- }
-
- return(str);
- }
-
- CString MakeDimensionName(CVidFormatElem* pfe)
- {
- CString str(_T("Default"));
-
- if(!pfe) return(str);
-
- BITMAPINFOHEADER* bih = (pfe->mt.formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pfe->mt.pbFormat)->bmiHeader
- : (pfe->mt.formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pfe->mt.pbFormat)->bmiHeader
- : NULL;
-
- if(bih == NULL) return(str);
-
- str.Format(_T("%dx%d %.2f"), bih->biWidth, bih->biHeight, (float)10000000 / ((VIDEOINFOHEADER*)pfe->mt.pbFormat)->AvgTimePerFrame);
-
- if(pfe->mt.formattype == FORMAT_VideoInfo2)
- {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pfe->mt.pbFormat;
- CString str2;
- str2.Format(_T(" i%02x %d:%d"), vih2->dwInterlaceFlags, vih2->dwPictAspectRatioX, vih2->dwPictAspectRatioY);
- str += str2;
- }
-
- return(str);
- }
+ CString MakeFormatName(AM_MEDIA_TYPE* pmt)
+ {
+ CString str(_T("Default"));
+
+ if(!pmt) return(str);
+
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
+
+ if(!bih)
+ {
+ // it may have a fourcc in the mediasubtype, let's check that
+
+ WCHAR guid[100];
+ memset(guid, 0, 100*sizeof(WCHAR));
+ StringFromGUID2(pmt->subtype, guid, 100);
+
+ if(CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0)
+ {
+ str.Format(_T("%c%c%c%c"),
+ (TCHAR)((pmt->subtype.Data1>>0)&0xff), (TCHAR)((pmt->subtype.Data1>>8)&0xff),
+ (TCHAR)((pmt->subtype.Data1>>16)&0xff), (TCHAR)((pmt->subtype.Data1>>24)&0xff));
+ }
+
+ return(str);
+ }
+
+ switch(bih->biCompression)
+ {
+ case BI_RGB: str.Format(_T("RGB%d"), bih->biBitCount); break;
+ case BI_RLE8: str = _T("RLE8"); break;
+ case BI_RLE4: str = _T("RLE4"); break;
+ case BI_BITFIELDS: str.Format(_T("BITF%d"), bih->biBitCount); break;
+ case BI_JPEG: str = _T("JPEG"); break;
+ case BI_PNG: str = _T("PNG"); break;
+ default:
+ str.Format(_T("%c%c%c%c"),
+ (TCHAR)((bih->biCompression>>0)&0xff), (TCHAR)((bih->biCompression>>8)&0xff),
+ (TCHAR)((bih->biCompression>>16)&0xff), (TCHAR)((bih->biCompression>>24)&0xff));
+ break;
+ }
+
+ return(str);
+ }
+
+ CString MakeDimensionName(CVidFormatElem* pfe)
+ {
+ CString str(_T("Default"));
+
+ if(!pfe) return(str);
+
+ BITMAPINFOHEADER* bih = (pfe->mt.formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pfe->mt.pbFormat)->bmiHeader
+ : (pfe->mt.formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pfe->mt.pbFormat)->bmiHeader
+ : NULL;
+
+ if(bih == NULL) return(str);
+
+ str.Format(_T("%dx%d %.2f"), bih->biWidth, bih->biHeight, (float)10000000/((VIDEOINFOHEADER*)pfe->mt.pbFormat)->AvgTimePerFrame);
+
+ if(pfe->mt.formattype == FORMAT_VideoInfo2)
+ {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pfe->mt.pbFormat;
+ CString str2;
+ str2.Format(_T(" i%02x %d:%d"), vih2->dwInterlaceFlags, vih2->dwPictAspectRatioX, vih2->dwPictAspectRatioY);
+ str += str2;
+ }
+
+ return(str);
+ }
};
typedef CFormatElem<AUDIO_STREAM_CONFIG_CAPS> CAudFormatElem;
@@ -256,93 +233,79 @@ typedef CFormat<AUDIO_STREAM_CONFIG_CAPS> CAudFormat;
class CAudFormatArray : public CFormatArray<AUDIO_STREAM_CONFIG_CAPS>
{
public:
- CString MakeFormatName(AM_MEDIA_TYPE* pmt)
- {
- CString str(_T("Unknown"));
-
- if(!pmt) return(str);
-
- WAVEFORMATEX* wfe = (pmt->formattype == FORMAT_WaveFormatEx)
- ? (WAVEFORMATEX*)pmt->pbFormat
- : NULL;
-
- if(!wfe)
- {
- WCHAR guid[100];
- memset(guid, 0, 100 * sizeof(WCHAR));
- StringFromGUID2(pmt->subtype, guid, 100);
-
- if(CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0)
- {
- str.Format(_T("0x%04x"), pmt->subtype.Data1);
- }
-
- return(str);
- }
-
- switch(wfe->wFormatTag)
- {
- case 1:
- str = _T("PCM ");
- break;
- default:
- str.Format(_T("0x%03x "), wfe->wFormatTag);
- break;
- }
-
- return(str);
- }
-
- CString MakeDimensionName(CAudFormatElem* pfe)
- {
- CString str(_T("Unknown"));
-
- if(!pfe) return(str);
-
- WAVEFORMATEX* wfe = (pfe->mt.formattype == FORMAT_WaveFormatEx)
- ? (WAVEFORMATEX*)pfe->mt.pbFormat
- : NULL;
-
- if(!wfe) return(str);
-
- str.Empty();
- CString str2;
-
- str2.Format(_T("%6dKHz "), wfe->nSamplesPerSec);
- str += str2;
-
- str2.Format(_T("%dbps "), wfe->wBitsPerSample);
- str += str2;
-
- switch(wfe->nChannels)
- {
- case 1:
- str += _T("mono ");
- break;
- case 2:
- str += _T("stereo ");
- break;
- default:
- str2.Format(_T("%d channels "), wfe->nChannels);
- str += str2;
- break;
- }
-
- str2.Format(_T("%3dkbps "), wfe->nAvgBytesPerSec * 8 / 1000);
- str += str2;
-
- return(str);
- }
+ CString MakeFormatName(AM_MEDIA_TYPE* pmt)
+ {
+ CString str(_T("Unknown"));
+
+ if(!pmt) return(str);
+
+ WAVEFORMATEX* wfe = (pmt->formattype == FORMAT_WaveFormatEx)
+ ? (WAVEFORMATEX*)pmt->pbFormat
+ : NULL;
+
+ if(!wfe)
+ {
+ WCHAR guid[100];
+ memset(guid, 0, 100*sizeof(WCHAR));
+ StringFromGUID2(pmt->subtype, guid, 100);
+
+ if(CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0)
+ {
+ str.Format(_T("0x%04x"), pmt->subtype.Data1);
+ }
+
+ return(str);
+ }
+
+ switch(wfe->wFormatTag)
+ {
+ case 1: str = _T("PCM "); break;
+ default: str.Format(_T("0x%03x "), wfe->wFormatTag); break;
+ }
+
+ return(str);
+ }
+
+ CString MakeDimensionName(CAudFormatElem* pfe)
+ {
+ CString str(_T("Unknown"));
+
+ if(!pfe) return(str);
+
+ WAVEFORMATEX* wfe = (pfe->mt.formattype == FORMAT_WaveFormatEx)
+ ? (WAVEFORMATEX*)pfe->mt.pbFormat
+ : NULL;
+
+ if(!wfe) return(str);
+
+ str.Empty();
+ CString str2;
+
+ str2.Format(_T("%6dKHz "), wfe->nSamplesPerSec); str += str2;
+
+ str2.Format(_T("%dbps "), wfe->wBitsPerSample); str += str2;
+
+ switch(wfe->nChannels)
+ {
+ case 1: str += _T("mono "); break;
+ case 2: str += _T("stereo "); break;
+ default: str2.Format(_T("%d channels "), wfe->nChannels); str += str2; break;
+ }
+
+ str2.Format(_T("%3dkbps "), wfe->nAvgBytesPerSec*8/1000); str += str2;
+
+ return(str);
+ }
};
//
typedef struct
{
- CComPtr<IMoniker> pMoniker;
- CComPtr<IBaseFilter> pBF;
- CString FriendlyName;
- CComBSTR DisplayName;
+ CComPtr<IMoniker> pMoniker;
+ CComPtr<IBaseFilter> pBF;
+ CString FriendlyName;
+ CComBSTR DisplayName;
} Codec;
typedef CAtlArray<Codec> CCodecArray;
@@ -351,143 +314,143 @@ typedef CAtlArray<Codec> CCodecArray;
class CPlayerCaptureDialog : public CResizableDialog //CDialog
{
- //DECLARE_DYNAMIC(CPlayerCaptureDialog)
+ //DECLARE_DYNAMIC(CPlayerCaptureDialog)
- // video input
- CStringW m_VidDisplayName;
- CComPtr<IAMStreamConfig> m_pAMVSC;
- CComPtr<IAMCrossbar> m_pAMXB;
- CComPtr<IAMTVTuner> m_pAMTuner;
- CComPtr<IAMVfwCaptureDialogs> m_pAMVfwCD;
- CVidFormatArray m_vfa;
+ // video input
+ CStringW m_VidDisplayName;
+ CComPtr<IAMStreamConfig> m_pAMVSC;
+ CComPtr<IAMCrossbar> m_pAMXB;
+ CComPtr<IAMTVTuner> m_pAMTuner;
+ CComPtr<IAMVfwCaptureDialogs> m_pAMVfwCD;
+ CVidFormatArray m_vfa;
- // audio input
- CStringW m_AudDisplayName;
- CComPtr<IAMStreamConfig> m_pAMASC;
- CInterfaceArray<IAMAudioInputMixer> m_pAMAIM;
- CAudFormatArray m_afa;
+ // audio input
+ CStringW m_AudDisplayName;
+ CComPtr<IAMStreamConfig> m_pAMASC;
+ CInterfaceArray<IAMAudioInputMixer> m_pAMAIM;
+ CAudFormatArray m_afa;
- // video codec
- CCodecArray m_pVidEncArray;
- CVidFormatArray m_vcfa;
+ // video codec
+ CCodecArray m_pVidEncArray;
+ CVidFormatArray m_vcfa;
- // audio codec
- CCodecArray m_pAudEncArray;
- CAudFormatArray m_acfa;
+ // audio codec
+ CCodecArray m_pAudEncArray;
+ CAudFormatArray m_acfa;
- void EmptyVideo();
- void EmptyAudio();
+ void EmptyVideo();
+ void EmptyAudio();
- void UpdateMediaTypes();
- void UpdateUserDefinableControls();
- void UpdateVideoCodec();
- void UpdateAudioCodec();
- void UpdateMuxer();
- void UpdateOutputControls();
+ void UpdateMediaTypes();
+ void UpdateUserDefinableControls();
+ void UpdateVideoCodec();
+ void UpdateAudioCodec();
+ void UpdateMuxer();
+ void UpdateOutputControls();
- void UpdateGraph();
+ void UpdateGraph();
- CMap<HWND, HWND&, BOOL, BOOL&> m_wndenabledmap;
- void EnableControls(CWnd* pWnd, bool fEnable);
+ CMap<HWND, HWND&, BOOL, BOOL&> m_wndenabledmap;
+ void EnableControls(CWnd* pWnd, bool fEnable);
- bool m_fEnableOgm;
+ bool m_fEnableOgm;
public:
- CPlayerCaptureDialog(); // standard constructor
- virtual ~CPlayerCaptureDialog();
+ CPlayerCaptureDialog(); // standard constructor
+ virtual ~CPlayerCaptureDialog();
- BOOL Create(CWnd* pParent = NULL);
+ BOOL Create(CWnd* pParent = NULL);
// Dialog Data
- enum { IDD = IDD_CAPTURE_DLG };
-
- CComboBox m_vidinput;
- CComboBox m_vidtype;
- CComboBox m_viddimension;
- CSpinButtonCtrl m_vidhor;
- CSpinButtonCtrl m_vidver;
- CEdit m_vidhoredit;
- CEdit m_vidveredit;
- CFloatEdit m_vidfpsedit;
- float m_vidfps;
- CButton m_vidsetres;
- CComboBox m_audinput;
- CComboBox m_audtype;
- CComboBox m_auddimension;
- CComboBox m_vidcodec;
- CComboBox m_vidcodectype;
- CComboBox m_vidcodecdimension;
- BOOL m_fVidOutput;
- CButton m_vidoutput;
- int m_fVidPreview;
- CButton m_vidpreview;
- CComboBox m_audcodec;
- CComboBox m_audcodectype;
- CComboBox m_audcodecdimension;
- BOOL m_fAudOutput;
- CButton m_audoutput;
- int m_fAudPreview;
- CButton m_audpreview;
- int m_nVidBuffers;
- int m_nAudBuffers;
- CString m_file;
- CButton m_recordbtn;
- BOOL m_fSepAudio;
- int m_muxtype;
- CComboBox m_muxctrl;
-
- CMediaType m_mtv, m_mta, m_mtcv, m_mtca;
- CComPtr<IBaseFilter> m_pVidEnc, m_pAudEnc, m_pMux, m_pDst, m_pAudMux, m_pAudDst;
- CComPtr<IMoniker> m_pVidEncMoniker, m_pAudEncMoniker;
- CComPtr<IBaseFilter> m_pVidBuffer, m_pAudBuffer;
+ enum { IDD = IDD_CAPTURE_DLG };
+
+ CComboBox m_vidinput;
+ CComboBox m_vidtype;
+ CComboBox m_viddimension;
+ CSpinButtonCtrl m_vidhor;
+ CSpinButtonCtrl m_vidver;
+ CEdit m_vidhoredit;
+ CEdit m_vidveredit;
+ CFloatEdit m_vidfpsedit;
+ float m_vidfps;
+ CButton m_vidsetres;
+ CComboBox m_audinput;
+ CComboBox m_audtype;
+ CComboBox m_auddimension;
+ CComboBox m_vidcodec;
+ CComboBox m_vidcodectype;
+ CComboBox m_vidcodecdimension;
+ BOOL m_fVidOutput;
+ CButton m_vidoutput;
+ int m_fVidPreview;
+ CButton m_vidpreview;
+ CComboBox m_audcodec;
+ CComboBox m_audcodectype;
+ CComboBox m_audcodecdimension;
+ BOOL m_fAudOutput;
+ CButton m_audoutput;
+ int m_fAudPreview;
+ CButton m_audpreview;
+ int m_nVidBuffers;
+ int m_nAudBuffers;
+ CString m_file;
+ CButton m_recordbtn;
+ BOOL m_fSepAudio;
+ int m_muxtype;
+ CComboBox m_muxctrl;
+
+ CMediaType m_mtv, m_mta, m_mtcv, m_mtca;
+ CComPtr<IBaseFilter> m_pVidEnc, m_pAudEnc, m_pMux, m_pDst, m_pAudMux, m_pAudDst;
+ CComPtr<IMoniker> m_pVidEncMoniker, m_pAudEncMoniker;
+ CComPtr<IBaseFilter> m_pVidBuffer, m_pAudBuffer;
public:
- void SetupVideoControls(CStringW DisplayName, CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMCrossbar> pAMXB, CComPtr<IAMTVTuner> pAMTuner);
- void SetupVideoControls(CStringW DisplayName, CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMVfwCaptureDialogs> pAMVfwCD);
- void SetupAudioControls(CStringW DisplayName, CComPtr<IAMStreamConfig> pAMSC, CInterfaceArray<IAMAudioInputMixer>& pAMAIM);
+ void SetupVideoControls(CStringW DisplayName, CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMCrossbar> pAMXB, CComPtr<IAMTVTuner> pAMTuner);
+ void SetupVideoControls(CStringW DisplayName, CComPtr<IAMStreamConfig> pAMSC, CComPtr<IAMVfwCaptureDialogs> pAMVfwCD);
+ void SetupAudioControls(CStringW DisplayName, CComPtr<IAMStreamConfig> pAMSC, CInterfaceArray<IAMAudioInputMixer>& pAMAIM);
- bool IsTunerActive();
+ bool IsTunerActive();
- bool SetVideoInput(int input);
- bool SetVideoChannel(int channel);
- bool SetAudioInput(int input);
+ bool SetVideoInput(int input);
+ bool SetVideoChannel(int channel);
+ bool SetAudioInput(int input);
- int GetVideoInput();
- int GetVideoChannel();
- int GetAudioInput();
+ int GetVideoInput();
+ int GetVideoChannel();
+ int GetAudioInput();
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnInitDialog();
- virtual void OnOK() {}
- virtual void OnCancel() {}
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnInitDialog();
+ virtual void OnOK() {}
+ virtual void OnCancel() {}
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnDestroy();
- afx_msg void OnVideoInput();
- afx_msg void OnVideoType();
- afx_msg void OnVideoDimension();
- afx_msg void OnOverrideVideoDimension();
- afx_msg void OnAudioInput();
- afx_msg void OnAudioType();
- afx_msg void OnAudioDimension();
- afx_msg void OnRecordVideo();
- afx_msg void OnVideoCodec();
- afx_msg void OnVideoCodecType();
- afx_msg void OnVideoCodecDimension();
- afx_msg void OnRecordAudio();
- afx_msg void OnAudioCodec();
- afx_msg void OnAudioCodecType();
- afx_msg void OnAudioCodecDimension();
- afx_msg void OnOpenFile();
- afx_msg void OnRecord();
- afx_msg void OnEnChangeEdit9();
- afx_msg void OnEnChangeEdit12();
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnBnClickedVidAudPreview();
- afx_msg void OnBnClickedCheck7();
- afx_msg void OnCbnSelchangeCombo14();
+ afx_msg void OnDestroy();
+ afx_msg void OnVideoInput();
+ afx_msg void OnVideoType();
+ afx_msg void OnVideoDimension();
+ afx_msg void OnOverrideVideoDimension();
+ afx_msg void OnAudioInput();
+ afx_msg void OnAudioType();
+ afx_msg void OnAudioDimension();
+ afx_msg void OnRecordVideo();
+ afx_msg void OnVideoCodec();
+ afx_msg void OnVideoCodecType();
+ afx_msg void OnVideoCodecDimension();
+ afx_msg void OnRecordAudio();
+ afx_msg void OnAudioCodec();
+ afx_msg void OnAudioCodecType();
+ afx_msg void OnAudioCodecDimension();
+ afx_msg void OnOpenFile();
+ afx_msg void OnRecord();
+ afx_msg void OnEnChangeEdit9();
+ afx_msg void OnEnChangeEdit12();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnBnClickedVidAudPreview();
+ afx_msg void OnBnClickedCheck7();
+ afx_msg void OnCbnSelchangeCombo14();
};
diff --git a/src/apps/mplayerc/PlayerInfoBar.cpp b/src/apps/mplayerc/PlayerInfoBar.cpp
index 95743a97e..6f2908da6 100644
--- a/src/apps/mplayerc/PlayerInfoBar.cpp
+++ b/src/apps/mplayerc/PlayerInfoBar.cpp
@@ -40,128 +40,128 @@ CPlayerInfoBar::~CPlayerInfoBar()
void CPlayerInfoBar::SetLine(CString label, CString info)
{
- if(info.IsEmpty())
- {
- RemoveLine(label);
- return;
- }
-
- for(size_t idx = 0; idx < m_label.GetCount(); idx++)
- {
- CString tmp;
- m_label[idx]->GetWindowText(tmp);
- if(label == tmp)
- {
- m_info[idx]->GetWindowText(tmp);
- if(info != tmp) m_info[idx]->SetWindowText(info);
- return;
- }
- }
-
- CAutoPtr<CStatusLabel> l(DNew CStatusLabel(true, false));
- l->Create(label, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SS_OWNERDRAW, CRect(0, 0, 0, 0), this);
- m_label.Add(l);
-
- CAutoPtr<CStatusLabel> i(DNew CStatusLabel(false, true));
- i->Create(info, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SS_OWNERDRAW, CRect(0, 0, 0, 0), this);
- m_info.Add(i);
-
- Relayout();
+ if(info.IsEmpty())
+ {
+ RemoveLine(label);
+ return;
+ }
+
+ for(size_t idx = 0; idx < m_label.GetCount(); idx++)
+ {
+ CString tmp;
+ m_label[idx]->GetWindowText(tmp);
+ if(label == tmp)
+ {
+ m_info[idx]->GetWindowText(tmp);
+ if(info != tmp) m_info[idx]->SetWindowText(info);
+ return;
+ }
+ }
+
+ CAutoPtr<CStatusLabel> l(DNew CStatusLabel(true, false));
+ l->Create(label, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SS_OWNERDRAW, CRect(0,0,0,0), this);
+ m_label.Add(l);
+
+ CAutoPtr<CStatusLabel> i(DNew CStatusLabel(false, true));
+ i->Create(info, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SS_OWNERDRAW, CRect(0,0,0,0), this);
+ m_info.Add(i);
+
+ Relayout();
}
void CPlayerInfoBar::GetLine(CString label, CString& info)
{
- info.Empty();
-
- for(size_t idx = 0; idx < m_label.GetCount(); idx++)
- {
- CString tmp;
- m_label[idx]->GetWindowText(tmp);
- if(label == tmp)
- {
- m_info[idx]->GetWindowText(tmp);
- info = tmp;
- return;
- }
- }
+ info.Empty();
+
+ for(size_t idx = 0; idx < m_label.GetCount(); idx++)
+ {
+ CString tmp;
+ m_label[idx]->GetWindowText(tmp);
+ if(label == tmp)
+ {
+ m_info[idx]->GetWindowText(tmp);
+ info = tmp;
+ return;
+ }
+ }
}
void CPlayerInfoBar::RemoveLine(CString label)
{
- for(size_t i = 0; i < m_label.GetCount(); i++)
- {
- CString tmp;
- m_label[i]->GetWindowText(tmp);
- if(label == tmp)
- {
- m_label.RemoveAt(i);
- m_info.RemoveAt(i);
- break;
- }
- }
-
- Relayout();
+ for(size_t i = 0; i < m_label.GetCount(); i++)
+ {
+ CString tmp;
+ m_label[i]->GetWindowText(tmp);
+ if(label == tmp)
+ {
+ m_label.RemoveAt(i);
+ m_info.RemoveAt(i);
+ break;
+ }
+ }
+
+ Relayout();
}
void CPlayerInfoBar::RemoveAllLines()
{
- m_label.RemoveAll();
- m_info.RemoveAll();
+ m_label.RemoveAll();
+ m_info.RemoveAll();
- Relayout();
+ Relayout();
}
BOOL CPlayerInfoBar::Create(CWnd* pParentWnd)
{
- return CDialogBar::Create(pParentWnd, IDD_PLAYERINFOBAR, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM, IDD_PLAYERINFOBAR);
+ return CDialogBar::Create(pParentWnd, IDD_PLAYERINFOBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERINFOBAR);
}
BOOL CPlayerInfoBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CDialogBar::PreCreateWindow(cs))
- return FALSE;
+ if(!CDialogBar::PreCreateWindow(cs))
+ return FALSE;
- m_dwStyle &= ~CBRS_BORDER_TOP;
- m_dwStyle &= ~CBRS_BORDER_BOTTOM;
+ m_dwStyle &= ~CBRS_BORDER_TOP;
+ m_dwStyle &= ~CBRS_BORDER_BOTTOM;
- return TRUE;
+ return TRUE;
}
CSize CPlayerInfoBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
- CRect r;
- GetParent()->GetClientRect(&r);
- r.bottom = r.top + m_label.GetCount() * 17 + (m_label.GetCount() ? 4 : 0);
- return r.Size();
+ CRect r;
+ GetParent()->GetClientRect(&r);
+ r.bottom = r.top + m_label.GetCount() * 17 + (m_label.GetCount() ? 4 : 0);
+ return r.Size();
}
void CPlayerInfoBar::Relayout()
{
- CRect r;
- GetParent()->GetClientRect(&r);
-
- int w = m_nFirstColWidth, h = 17, y = 2;
-
- for(size_t i = 0; i < m_label.GetCount(); i++)
- {
- CDC* pDC = m_label[i]->GetDC();
- CString str;
- m_label[i]->GetWindowText(str);
- w = max(w, pDC->GetTextExtent(str).cx);
- m_label[i]->ReleaseDC(pDC);
- }
-
- for(size_t i = 0; i < m_label.GetCount(); i++, y += h)
- {
- m_label[i]->MoveWindow(1, y, w - 10, h);
- m_info[i]->MoveWindow(w + 10, y, r.Width() - (w + 10) - 1, h);
- }
+ CRect r;
+ GetParent()->GetClientRect(&r);
+
+ int w = m_nFirstColWidth, h = 17, y = 2;
+
+ for(size_t i = 0; i < m_label.GetCount(); i++)
+ {
+ CDC* pDC = m_label[i]->GetDC();
+ CString str;
+ m_label[i]->GetWindowText(str);
+ w = max(w, pDC->GetTextExtent(str).cx);
+ m_label[i]->ReleaseDC(pDC);
+ }
+
+ for(size_t i = 0; i < m_label.GetCount(); i++, y += h)
+ {
+ m_label[i]->MoveWindow(1, y, w - 10, h);
+ m_info[i]->MoveWindow(w + 10, y, r.Width()-(w+10)-1, h);
+ }
}
BEGIN_MESSAGE_MAP(CPlayerInfoBar, CDialogBar)
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_WM_LBUTTONDOWN()
+ ON_WM_ERASEBKGND()
+ ON_WM_SIZE()
+ ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
@@ -170,49 +170,49 @@ END_MESSAGE_MAP()
BOOL CPlayerInfoBar::OnEraseBkgnd(CDC* pDC)
{
- for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
- CRect r;
- pChild->GetClientRect(&r);
- pChild->MapWindowPoints(this, &r);
- pDC->ExcludeClipRect(&r);
- }
+ for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
+ {
+ CRect r;
+ pChild->GetClientRect(&r);
+ pChild->MapWindowPoints(this, &r);
+ pDC->ExcludeClipRect(&r);
+ }
- CRect r;
- GetClientRect(&r);
+ CRect r;
+ GetClientRect(&r);
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+
+ if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen)
+ r.InflateRect(0, 0, 0, 1);
- if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen)
- r.InflateRect(0, 0, 0, 1);
+ if(pFrame->m_fFullScreen)
+ r.InflateRect(1, 0, 1, 0);
- if(pFrame->m_fFullScreen)
- r.InflateRect(1, 0, 1, 0);
+ pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
- pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
+ r.DeflateRect(1, 1);
- r.DeflateRect(1, 1);
+ pDC->FillSolidRect(&r, 0);
- pDC->FillSolidRect(&r, 0);
-
- return TRUE;
+ return TRUE;
}
void CPlayerInfoBar::OnSize(UINT nType, int cx, int cy)
{
- CDialogBar::OnSize(nType, cx, cy);
+ CDialogBar::OnSize(nType, cx, cy);
- Relayout();
+ Relayout();
- Invalidate();
+ Invalidate();
}
void CPlayerInfoBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if(!pFrame->m_fFullScreen)
- {
- MapWindowPoints(pFrame, &point, 1);
- pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- }
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if(!pFrame->m_fFullScreen)
+ {
+ MapWindowPoints(pFrame, &point, 1);
+ pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
+ }
}
diff --git a/src/apps/mplayerc/PlayerInfoBar.h b/src/apps/mplayerc/PlayerInfoBar.h
index a0481985a..e1645b422 100644
--- a/src/apps/mplayerc/PlayerInfoBar.h
+++ b/src/apps/mplayerc/PlayerInfoBar.h
@@ -31,35 +31,35 @@
class CPlayerInfoBar : public CDialogBar
{
- DECLARE_DYNAMIC(CPlayerInfoBar)
+ DECLARE_DYNAMIC(CPlayerInfoBar)
private:
- CAutoPtrArray<CStatusLabel> m_label;
- CAutoPtrArray<CStatusLabel> m_info;
+ CAutoPtrArray<CStatusLabel> m_label;
+ CAutoPtrArray<CStatusLabel> m_info;
- int m_nFirstColWidth;
+ int m_nFirstColWidth;
- void Relayout();
+ void Relayout();
public:
- CPlayerInfoBar(int nFirstColWidth = 100);
- virtual ~CPlayerInfoBar();
+ CPlayerInfoBar(int nFirstColWidth = 100);
+ virtual ~CPlayerInfoBar();
- BOOL Create(CWnd* pParentWnd);
+ BOOL Create(CWnd* pParentWnd);
- void SetLine(CString label, CString info);
- void GetLine(CString label, CString& info);
- void RemoveLine(CString label);
- void RemoveAllLines();
+ void SetLine(CString label, CString info);
+ void GetLine(CString label, CString& info);
+ void RemoveLine(CString label);
+ void RemoveAllLines();
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
public:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
- DECLARE_MESSAGE_MAP()
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
diff --git a/src/apps/mplayerc/PlayerListCtrl.cpp b/src/apps/mplayerc/PlayerListCtrl.cpp
index f1514ba72..b0d221d8c 100644
--- a/src/apps/mplayerc/PlayerListCtrl.cpp
+++ b/src/apps/mplayerc/PlayerListCtrl.cpp
@@ -29,11 +29,11 @@
// CInPlaceEdit
CInPlaceEdit::CInPlaceEdit(int iItem, int iSubItem, CString sInitText)
- : m_sInitText(sInitText)
+ : m_sInitText( sInitText )
{
- m_iItem = iItem;
- m_iSubItem = iSubItem;
- m_bESC = FALSE;
+ m_iItem = iItem;
+ m_iSubItem = iSubItem;
+ m_bESC = FALSE;
}
CInPlaceEdit::~CInPlaceEdit()
@@ -41,12 +41,12 @@ CInPlaceEdit::~CInPlaceEdit()
}
BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit)
- //{{AFX_MSG_MAP(CInPlaceEdit)
- ON_WM_KILLFOCUS()
- ON_WM_NCDESTROY()
- ON_WM_CHAR()
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CInPlaceEdit)
+ ON_WM_KILLFOCUS()
+ ON_WM_NCDESTROY()
+ ON_WM_CHAR()
+ ON_WM_CREATE()
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -54,88 +54,88 @@ END_MESSAGE_MAP()
BOOL CInPlaceEdit::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- if(pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_DELETE
- || pMsg->wParam == VK_ESCAPE
- || GetKeyState(VK_CONTROL))
- {
- ::TranslateMessage(pMsg);
- ::DispatchMessage(pMsg);
- return TRUE; // DO NOT process further
- }
- }
+ if(pMsg->message == WM_KEYDOWN)
+ {
+ if(pMsg->wParam == VK_RETURN
+ || pMsg->wParam == VK_DELETE
+ || pMsg->wParam == VK_ESCAPE
+ || GetKeyState(VK_CONTROL))
+ {
+ ::TranslateMessage(pMsg);
+ ::DispatchMessage(pMsg);
+ return TRUE; // DO NOT process further
+ }
+ }
- return CEdit::PreTranslateMessage(pMsg);
+ return CEdit::PreTranslateMessage(pMsg);
}
void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
{
- CEdit::OnKillFocus(pNewWnd);
+ CEdit::OnKillFocus(pNewWnd);
- CString str;
- GetWindowText(str);
+ CString str;
+ GetWindowText(str);
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_ENDLABELEDIT;
- dispinfo.item.mask = LVIF_TEXT;
- dispinfo.item.iItem = m_iItem;
- dispinfo.item.iSubItem = m_iSubItem;
- dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
- dispinfo.item.cchTextMax = str.GetLength();
- GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_ENDLABELEDIT;
+ dispinfo.item.mask = LVIF_TEXT;
+ dispinfo.item.iItem = m_iItem;
+ dispinfo.item.iSubItem = m_iSubItem;
+ dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
+ dispinfo.item.cchTextMax = str.GetLength();
+ GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
- DestroyWindow();
+ DestroyWindow();
}
void CInPlaceEdit::OnNcDestroy()
{
- CEdit::OnNcDestroy();
+ CEdit::OnNcDestroy();
- delete this;
+ delete this;
}
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(nChar == VK_ESCAPE || nChar == VK_RETURN)
- {
- if(nChar == VK_ESCAPE) m_bESC = TRUE;
- GetParent()->SetFocus();
- return;
- }
+ if(nChar == VK_ESCAPE || nChar == VK_RETURN)
+ {
+ if(nChar == VK_ESCAPE) m_bESC = TRUE;
+ GetParent()->SetFocus();
+ return;
+ }
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
int CInPlaceEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CEdit::OnCreate(lpCreateStruct) == -1)
- return -1;
+ if(CEdit::OnCreate(lpCreateStruct) == -1)
+ return -1;
- // Set the proper font
- CFont* font = GetParent()->GetFont();
- SetFont(font);
+ // Set the proper font
+ CFont* font = GetParent()->GetFont();
+ SetFont(font);
- SetWindowText(m_sInitText);
- SetFocus();
- SetSel(0, -1);
- return 0;
+ SetWindowText(m_sInitText);
+ SetFocus();
+ SetSel(0, -1);
+ return 0;
}
// CInPlaceComboBox
CInPlaceComboBox::CInPlaceComboBox(int iItem, int iSubItem, CAtlList<CString>& lstItems, int nSel)
{
- m_iItem = iItem;
- m_iSubItem = iSubItem;
+ m_iItem = iItem;
+ m_iSubItem = iSubItem;
- m_lstItems.AddTailList(&lstItems);
- m_nSel = nSel;
- m_bESC = FALSE;
+ m_lstItems.AddTailList(&lstItems);
+ m_nSel = nSel;
+ m_bESC = FALSE;
}
CInPlaceComboBox::~CInPlaceComboBox()
@@ -143,107 +143,107 @@ CInPlaceComboBox::~CInPlaceComboBox()
}
BEGIN_MESSAGE_MAP(CInPlaceComboBox, CComboBox)
- //{{AFX_MSG_MAP(CInPlaceComboBox)
- ON_WM_CREATE()
- ON_WM_KILLFOCUS()
- ON_WM_CHAR()
- ON_WM_NCDESTROY()
- ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CInPlaceComboBox)
+ ON_WM_CREATE()
+ ON_WM_KILLFOCUS()
+ ON_WM_CHAR()
+ ON_WM_NCDESTROY()
+ ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInPlaceComboBox message handlers
-int CInPlaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
+int CInPlaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CComboBox::OnCreate(lpCreateStruct) == -1)
- return -1;
+ if (CComboBox::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ // Set the proper font
+ CFont* font = GetParent()->GetFont();
+ SetFont(font);
- // Set the proper font
- CFont* font = GetParent()->GetFont();
- SetFont(font);
+ for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;)
+ AddString((LPCTSTR)(m_lstItems.GetNext(pos)));
- for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;)
- AddString((LPCTSTR)(m_lstItems.GetNext(pos)));
-
- SetFocus();
- SetCurSel(m_nSel);
- return 0;
+ SetFocus();
+ SetCurSel(m_nSel);
+ return 0;
}
-BOOL CInPlaceComboBox::PreTranslateMessage(MSG* pMsg)
+BOOL CInPlaceComboBox::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- if(pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_ESCAPE)
- {
- ::TranslateMessage(pMsg);
- ::DispatchMessage(pMsg);
- return TRUE; // DO NOT process further
- }
- }
+ if(pMsg->message == WM_KEYDOWN)
+ {
+ if(pMsg->wParam == VK_RETURN
+ || pMsg->wParam == VK_ESCAPE)
+ {
+ ::TranslateMessage(pMsg);
+ ::DispatchMessage(pMsg);
+ return TRUE; // DO NOT process further
+ }
+ }
- return CComboBox::PreTranslateMessage(pMsg);
+ return CComboBox::PreTranslateMessage(pMsg);
}
-void CInPlaceComboBox::OnKillFocus(CWnd* pNewWnd)
+void CInPlaceComboBox::OnKillFocus(CWnd* pNewWnd)
{
- CComboBox::OnKillFocus(pNewWnd);
-
- CString str;
- GetWindowText(str);
+ CComboBox::OnKillFocus(pNewWnd);
+
+ CString str;
+ GetWindowText(str);
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_ENDLABELEDIT;
- dispinfo.item.mask = LVIF_TEXT | LVIF_PARAM;
- dispinfo.item.iItem = m_iItem;
- dispinfo.item.iSubItem = m_iSubItem;
- dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
- dispinfo.item.cchTextMax = str.GetLength();
- dispinfo.item.lParam = GetCurSel();
- GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_ENDLABELEDIT;
+ dispinfo.item.mask = LVIF_TEXT|LVIF_PARAM;
+ dispinfo.item.iItem = m_iItem;
+ dispinfo.item.iSubItem = m_iSubItem;
+ dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
+ dispinfo.item.cchTextMax = str.GetLength();
+ dispinfo.item.lParam = GetCurSel();
+ GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
- PostMessage(WM_CLOSE);
+ PostMessage(WM_CLOSE);
}
-void CInPlaceComboBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
+void CInPlaceComboBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(nChar == VK_ESCAPE || nChar == VK_RETURN)
- {
- if(nChar == VK_ESCAPE) m_bESC = TRUE;
- GetParent()->SetFocus();
- return;
- }
+ if(nChar == VK_ESCAPE || nChar == VK_RETURN)
+ {
+ if(nChar == VK_ESCAPE) m_bESC = TRUE;
+ GetParent()->SetFocus();
+ return;
+ }
- CComboBox::OnChar(nChar, nRepCnt, nFlags);
+ CComboBox::OnChar(nChar, nRepCnt, nFlags);
}
-void CInPlaceComboBox::OnNcDestroy()
+void CInPlaceComboBox::OnNcDestroy()
{
- CComboBox::OnNcDestroy();
-
- delete this;
+ CComboBox::OnNcDestroy();
+
+ delete this;
}
-void CInPlaceComboBox::OnCloseup()
+void CInPlaceComboBox::OnCloseup()
{
- GetParent()->SetFocus();
+ GetParent()->SetFocus();
}
// CInPlaceListBox
CInPlaceListBox::CInPlaceListBox(int iItem, int iSubItem, CAtlList<CString>& lstItems, int nSel)
{
- m_iItem = iItem;
- m_iSubItem = iSubItem;
+ m_iItem = iItem;
+ m_iSubItem = iSubItem;
- m_lstItems.AddTailList(&lstItems);
- m_nSel = nSel;
- m_bESC = FALSE;
+ m_lstItems.AddTailList(&lstItems);
+ m_nSel = nSel;
+ m_bESC = FALSE;
}
CInPlaceListBox::~CInPlaceListBox()
@@ -251,90 +251,90 @@ CInPlaceListBox::~CInPlaceListBox()
}
BEGIN_MESSAGE_MAP(CInPlaceListBox, CListBox)
- //{{AFX_MSG_MAP(CInPlaceListBox)
- ON_WM_CREATE()
- ON_WM_KILLFOCUS()
- ON_WM_CHAR()
- ON_WM_NCDESTROY()
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CInPlaceListBox)
+ ON_WM_CREATE()
+ ON_WM_KILLFOCUS()
+ ON_WM_CHAR()
+ ON_WM_NCDESTROY()
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInPlaceListBox message handlers
-int CInPlaceListBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
+int CInPlaceListBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CListBox::OnCreate(lpCreateStruct) == -1)
- return -1;
+ if(CListBox::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ // Set the proper font
+ CFont* font = GetParent()->GetFont();
+ SetFont(font);
- // Set the proper font
- CFont* font = GetParent()->GetFont();
- SetFont(font);
-
- for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;)
- {
- AddString((LPCTSTR)(m_lstItems.GetNext(pos)));
- }
- SetCurSel(m_nSel);
- SetFocus();
- return 0;
+ for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;)
+ {
+ AddString( (LPCTSTR) (m_lstItems.GetNext( pos )) );
+ }
+ SetCurSel( m_nSel );
+ SetFocus();
+ return 0;
}
-BOOL CInPlaceListBox::PreTranslateMessage(MSG* pMsg)
+BOOL CInPlaceListBox::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- if(pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_ESCAPE)
- {
- ::TranslateMessage(pMsg);
- ::DispatchMessage(pMsg);
- return TRUE; // DO NOT process further
- }
- }
-
- return CListBox::PreTranslateMessage(pMsg);
+ if(pMsg->message == WM_KEYDOWN)
+ {
+ if(pMsg->wParam == VK_RETURN
+ || pMsg->wParam == VK_ESCAPE)
+ {
+ ::TranslateMessage(pMsg);
+ ::DispatchMessage(pMsg);
+ return TRUE; // DO NOT process further
+ }
+ }
+
+ return CListBox::PreTranslateMessage(pMsg);
}
-void CInPlaceListBox::OnKillFocus(CWnd* pNewWnd)
+void CInPlaceListBox::OnKillFocus(CWnd* pNewWnd)
{
- CListBox::OnKillFocus(pNewWnd);
-
- CString str;
- GetWindowText(str);
+ CListBox::OnKillFocus(pNewWnd);
+
+ CString str;
+ GetWindowText(str);
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_ENDLABELEDIT;
- dispinfo.item.mask = LVIF_TEXT | LVIF_PARAM;
- dispinfo.item.iItem = m_iItem;
- dispinfo.item.iSubItem = m_iSubItem;
- dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
- dispinfo.item.cchTextMax = str.GetLength();
- dispinfo.item.lParam = GetCurSel();
- GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_ENDLABELEDIT;
+ dispinfo.item.mask = LVIF_TEXT|LVIF_PARAM;
+ dispinfo.item.iItem = m_iItem;
+ dispinfo.item.iSubItem = m_iSubItem;
+ dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
+ dispinfo.item.cchTextMax = str.GetLength();
+ dispinfo.item.lParam = GetCurSel();
+ GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
- PostMessage(WM_CLOSE);
+ PostMessage(WM_CLOSE);
}
-void CInPlaceListBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
+void CInPlaceListBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(nChar == VK_ESCAPE || nChar == VK_RETURN)
- {
- if(nChar == VK_ESCAPE) m_bESC = TRUE;
- GetParent()->SetFocus();
- return;
- }
+ if(nChar == VK_ESCAPE || nChar == VK_RETURN)
+ {
+ if(nChar == VK_ESCAPE) m_bESC = TRUE;
+ GetParent()->SetFocus();
+ return;
+ }
- CListBox::OnChar(nChar, nRepCnt, nFlags);
+ CListBox::OnChar(nChar, nRepCnt, nFlags);
}
-void CInPlaceListBox::OnNcDestroy()
+void CInPlaceListBox::OnNcDestroy()
{
- CListBox::OnNcDestroy();
-
- delete this;
+ CListBox::OnNcDestroy();
+
+ delete this;
}
@@ -343,8 +343,8 @@ void CInPlaceListBox::OnNcDestroy()
IMPLEMENT_DYNAMIC(CPlayerListCtrl, CListCtrl)
CPlayerListCtrl::CPlayerListCtrl(int tStartEditingDelay)
- : m_tStartEditingDelay(tStartEditingDelay)
- , m_nItemClicked(-1)
+ : m_tStartEditingDelay(tStartEditingDelay)
+ , m_nItemClicked(-1)
{
}
@@ -354,519 +354,518 @@ CPlayerListCtrl::~CPlayerListCtrl()
void CPlayerListCtrl::PreSubclassWindow()
{
- EnableToolTips(TRUE);
+ EnableToolTips(TRUE);
- CListCtrl::PreSubclassWindow();
+ CListCtrl::PreSubclassWindow();
}
int CPlayerListCtrl::HitTestEx(CPoint& point, int* col) const
{
- if(col) *col = 0;
+ if(col) *col = 0;
- int row = HitTest(CPoint(0, point.y), NULL);
+ int row = HitTest(CPoint(0, point.y), NULL);
- if((GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT)
- return row;
+ if((GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT)
+ return row;
- int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
+ int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
- for(int top = GetTopIndex(), bottom = GetBottomIndex(); top <= bottom; top++)
- {
- CRect r;
- GetItemRect(top, &r, LVIR_BOUNDS);
+ for(int top = GetTopIndex(), bottom = GetBottomIndex(); top <= bottom; top++)
+ {
+ CRect r;
+ GetItemRect(top, &r, LVIR_BOUNDS);
- if(r.top <= point.y && point.y < r.bottom)
- {
- for(int colnum = 0; colnum < nColumnCount; colnum++)
- {
- int colwidth = GetColumnWidth(colnum);
+ if(r.top <= point.y && point.y < r.bottom)
+ {
+ for(int colnum = 0; colnum < nColumnCount; colnum++)
+ {
+ int colwidth = GetColumnWidth(colnum);
- if(point.x >= r.left && point.x <= (r.left + colwidth))
- {
- if(col) *col = colnum;
- return top;
- }
+ if(point.x >= r.left && point.x <= (r.left + colwidth))
+ {
+ if(col) *col = colnum;
+ return top;
+ }
- r.left += colwidth;
- }
- }
- }
+ r.left += colwidth;
+ }
+ }
+ }
- return -1;
+ return -1;
}
int CPlayerListCtrl::GetBottomIndex() const
{
- CRect r;
- GetClientRect(r);
+ CRect r;
+ GetClientRect(r);
- int nBottomIndex = GetTopIndex() + GetCountPerPage() - 1;
+ int nBottomIndex = GetTopIndex() + GetCountPerPage() - 1;
- if(nBottomIndex >= GetItemCount())
- {
- nBottomIndex = GetItemCount() - 1;
- }
- else if(nBottomIndex < GetItemCount())
- {
- CRect br;
- GetItemRect(nBottomIndex, br, LVIR_BOUNDS);
+ if(nBottomIndex >= GetItemCount())
+ {
+ nBottomIndex = GetItemCount() - 1;
+ }
+ else if(nBottomIndex < GetItemCount())
+ {
+ CRect br;
+ GetItemRect(nBottomIndex, br, LVIR_BOUNDS);
- if(br.bottom < r.bottom)
- nBottomIndex++;
- }
+ if(br.bottom < r.bottom)
+ nBottomIndex++;
+ }
- return(nBottomIndex);
+ return(nBottomIndex);
}
CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
{
- if(GetSelectedCount() <= 0)
- return NULL;
-
- CRect cSingleRect, cCompleteRect(0, 0, 0, 0);
- GetClientRect(cSingleRect);
- int nWidth = cSingleRect.Width();
-
- // Start and Stop index in view area
- int nIndex = GetTopIndex() - 1;
- int nBottomIndex = GetBottomIndex();
-
- // Determine the size of the drag image (limite for
- // rows visibled and Client width)
- while((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex)
- {
- GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
- /*
- CRect r;
- GetItemRect(nIndex, r, LVIR_LABEL);
- cSingleRect.left = r.left;
- */
- if(cSingleRect.left < 0) cSingleRect.left = 0;
- if(cSingleRect.right > nWidth) cSingleRect.right = nWidth;
-
- cCompleteRect |= cSingleRect;
- }
-
- //
- // Create bitmap in memory DC
- //
- CClientDC cDc(this);
- CDC cMemDC;
- CBitmap cBitmap;
-
- if(!cMemDC.CreateCompatibleDC(&cDc))
- return NULL;
-
- if(!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height()))
- return NULL;
-
- CBitmap* pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap);
- // Here green is used as mask color
- cMemDC.FillSolidRect(0, 0, cCompleteRect.Width(), cCompleteRect.Height(), RGB(0, 255, 0));
-
- // Paint each DragImage in the DC
- nIndex = GetTopIndex() - 1;
- while((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex)
- {
- CPoint pt;
- CImageList* pSingleImageList = CreateDragImage(nIndex, &pt);
-
- if(pSingleImageList)
- {
- GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
-
- pSingleImageList->Draw(&cMemDC,
- 0,
- CPoint(cSingleRect.left - cCompleteRect.left, cSingleRect.top - cCompleteRect.top),
- ILD_MASK);
-
- pSingleImageList->DeleteImageList();
- delete pSingleImageList;
- }
- }
-
- cMemDC.SelectObject(pOldMemDCBitmap);
-
- //
- // Create the imagelist with the merged drag images
- //
- CImageList* pCompleteImageList = DNew CImageList;
-
- pCompleteImageList->Create(cCompleteRect.Width(),
- cCompleteRect.Height(),
- ILC_COLOR | ILC_MASK, 0, 1);
-
- // Here green is used as mask color
- pCompleteImageList->Add(&cBitmap, RGB(0, 255, 0));
-
- //
- // as an optional service:
- // Find the offset of the current mouse cursor to the imagelist
- // this we can use in BeginDrag()
- //
- if(lpPoint)
- {
- lpPoint->x = cCompleteRect.left;
- lpPoint->y = cCompleteRect.top;
- }
-
- return(pCompleteImageList);
+ if(GetSelectedCount() <= 0)
+ return NULL;
+
+ CRect cSingleRect, cCompleteRect(0, 0, 0, 0);
+ GetClientRect(cSingleRect);
+ int nWidth = cSingleRect.Width();
+
+ // Start and Stop index in view area
+ int nIndex = GetTopIndex() - 1;
+ int nBottomIndex = GetBottomIndex();
+
+ // Determine the size of the drag image (limite for
+ // rows visibled and Client width)
+ while((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex)
+ {
+ GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
+/*
+ CRect r;
+ GetItemRect(nIndex, r, LVIR_LABEL);
+ cSingleRect.left = r.left;
+*/
+ if(cSingleRect.left < 0) cSingleRect.left = 0;
+ if(cSingleRect.right > nWidth) cSingleRect.right = nWidth;
+
+ cCompleteRect |= cSingleRect;
+ }
+
+ //
+ // Create bitmap in memory DC
+ //
+ CClientDC cDc(this);
+ CDC cMemDC;
+ CBitmap cBitmap;
+
+ if(!cMemDC.CreateCompatibleDC(&cDc))
+ return NULL;
+
+ if(!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height()))
+ return NULL;
+
+ CBitmap* pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap);
+ // Here green is used as mask color
+ cMemDC.FillSolidRect(0, 0, cCompleteRect.Width(), cCompleteRect.Height(), RGB(0, 255, 0));
+
+ // Paint each DragImage in the DC
+ nIndex = GetTopIndex() - 1;
+ while((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex)
+ {
+ CPoint pt;
+ CImageList* pSingleImageList = CreateDragImage(nIndex, &pt);
+
+ if(pSingleImageList)
+ {
+ GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
+
+ pSingleImageList->Draw(&cMemDC,
+ 0,
+ CPoint(cSingleRect.left - cCompleteRect.left, cSingleRect.top - cCompleteRect.top),
+ ILD_MASK);
+
+ pSingleImageList->DeleteImageList();
+ delete pSingleImageList;
+ }
+ }
+
+ cMemDC.SelectObject(pOldMemDCBitmap);
+
+ //
+ // Create the imagelist with the merged drag images
+ //
+ CImageList* pCompleteImageList = DNew CImageList;
+
+ pCompleteImageList->Create(cCompleteRect.Width(),
+ cCompleteRect.Height(),
+ ILC_COLOR | ILC_MASK, 0, 1);
+
+ // Here green is used as mask color
+ pCompleteImageList->Add(&cBitmap, RGB(0, 255, 0));
+
+ //
+ // as an optional service:
+ // Find the offset of the current mouse cursor to the imagelist
+ // this we can use in BeginDrag()
+ //
+ if(lpPoint)
+ {
+ lpPoint->x = cCompleteRect.left;
+ lpPoint->y = cCompleteRect.top;
+ }
+
+ return(pCompleteImageList);
}
bool CPlayerListCtrl::PrepareInPlaceControl(int nRow, int nCol, CRect& rect)
{
- if(!EnsureVisible(nRow, TRUE)) return(false);
+ if(!EnsureVisible(nRow, TRUE)) return(false);
- int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
- if(nCol >= nColumnCount || GetColumnWidth(nCol) < 5) return(false);
+ int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
+ if(nCol >= nColumnCount || GetColumnWidth(nCol) < 5) return(false);
- int offset = 0;
- for(int i = 0; i < nCol; i++) offset += GetColumnWidth(i);
+ int offset = 0;
+ for(int i = 0; i < nCol; i++) offset += GetColumnWidth(i);
- GetItemRect(nRow, &rect, LVIR_BOUNDS);
+ GetItemRect(nRow, &rect, LVIR_BOUNDS);
- CRect rcClient;
- GetClientRect(&rcClient);
- if(offset + rect.left < 0 || offset + rect.left > rcClient.right)
- {
- CSize size(offset + rect.left, 0);
- Scroll(size);
- rect.left -= size.cx;
- }
+ CRect rcClient;
+ GetClientRect(&rcClient);
+ if(offset + rect.left < 0 || offset + rect.left > rcClient.right)
+ {
+ CSize size(offset + rect.left, 0);
+ Scroll(size);
+ rect.left -= size.cx;
+ }
- rect.left += offset;
- rect.right = rect.left + GetColumnWidth(nCol);
- if(rect.right > rcClient.right) rect.right = rcClient.right;
+ rect.left += offset;
+ rect.right = rect.left + GetColumnWidth(nCol);
+ if(rect.right > rcClient.right) rect.right = rcClient.right;
- rect.DeflateRect(1, 0, 0, 1);
+ rect.DeflateRect(1, 0, 0, 1);
- if(nCol == 0)
- {
- CRect r;
- GetItemRect(nRow, r, LVIR_LABEL);
- rect.left = r.left - 1;
- }
+ if(nCol == 0)
+ {
+ CRect r;
+ GetItemRect(nRow, r, LVIR_LABEL);
+ rect.left = r.left-1;
+ }
- return(true);
+ return(true);
}
CEdit* CPlayerListCtrl::ShowInPlaceEdit(int nItem, int nCol)
{
- CRect rect;
- if(!PrepareInPlaceControl(nItem, nCol, rect))
- return(NULL);
+ CRect rect;
+ if(!PrepareInPlaceControl(nItem, nCol, rect))
+ return(NULL);
- DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;
+ DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
- LV_COLUMN lvcol;
- lvcol.mask = LVCF_FMT;
- GetColumn(nCol, &lvcol);
- dwStyle |= (lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT ? ES_LEFT
- : (lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT ? ES_RIGHT
- : ES_CENTER;
+ LV_COLUMN lvcol;
+ lvcol.mask = LVCF_FMT;
+ GetColumn(nCol, &lvcol);
+ dwStyle |= (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT ? ES_LEFT
+ : (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT ? ES_RIGHT
+ : ES_CENTER;
- CEdit* pEdit = DNew CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
- pEdit->Create(dwStyle, rect, this, IDC_EDIT1);
+ CEdit* pEdit = DNew CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
+ pEdit->Create(dwStyle, rect, this, IDC_EDIT1);
- m_fInPlaceDirty = false;
+ m_fInPlaceDirty = false;
- return pEdit;
+ return pEdit;
}
CComboBox* CPlayerListCtrl::ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown)
{
- CRect rect;
- if(!PrepareInPlaceControl(nItem, nCol, rect))
- return(NULL);
+ CRect rect;
+ if(!PrepareInPlaceControl(nItem, nCol, rect))
+ return(NULL);
- DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | WS_VSCROLL /*|WS_HSCROLL*/
- | CBS_DROPDOWNLIST | CBS_DISABLENOSCROLL/*|CBS_NOINTEGRALHEIGHT*/;
- CComboBox* pComboBox = DNew CInPlaceComboBox(nItem, nCol, lstItems, nSel);
- pComboBox->Create(dwStyle, rect, this, IDC_COMBO1);
+ DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|WS_VSCROLL/*|WS_HSCROLL*/
+ |CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL/*|CBS_NOINTEGRALHEIGHT*/;
+ CComboBox* pComboBox = DNew CInPlaceComboBox(nItem, nCol, lstItems, nSel);
+ pComboBox->Create(dwStyle, rect, this, IDC_COMBO1);
- CorrectComboListWidth(*pComboBox, GetFont());
+ CorrectComboListWidth(*pComboBox, GetFont());
- int width = GetColumnWidth(nCol);
- if(pComboBox->GetDroppedWidth() < width)
- pComboBox->SetDroppedWidth(width);
+ int width = GetColumnWidth(nCol);
+ if(pComboBox->GetDroppedWidth() < width)
+ pComboBox->SetDroppedWidth(width);
- if(bShowDropDown) pComboBox->ShowDropDown();
+ if (bShowDropDown) pComboBox->ShowDropDown();
- m_fInPlaceDirty = false;
+ m_fInPlaceDirty = false;
- return pComboBox;
+ return pComboBox;
}
CListBox* CPlayerListCtrl::ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel)
{
- CRect rect;
- if(!PrepareInPlaceControl(nItem, nCol, rect))
- return(NULL);
+ CRect rect;
+ if(!PrepareInPlaceControl(nItem, nCol, rect))
+ return(NULL);
- DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL/*|WS_HSCROLL*/ | LBS_NOTIFY;
- CListBox* pListBox = DNew CInPlaceListBox(nItem, nCol, lstItems, nSel);
- pListBox->Create(dwStyle, rect, this, IDC_LIST1);
+ DWORD dwStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL/*|WS_HSCROLL*/|LBS_NOTIFY;
+ CListBox* pListBox = DNew CInPlaceListBox(nItem, nCol, lstItems, nSel);
+ pListBox->Create(dwStyle, rect, this, IDC_LIST1);
- CRect ir;
- GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
+ CRect ir;
+ GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
- pListBox->SetItemHeight(-1, ir.Height());
+ pListBox->SetItemHeight(-1, ir.Height());
- CDC* pDC = pListBox->GetDC();
- CFont* pWndFont = GetFont();
- pDC->SelectObject(pWndFont);
- int width = GetColumnWidth(nCol);
- POSITION pos = lstItems.GetHeadPosition();
- while(pos)
- {
- int w = pDC->GetTextExtent(lstItems.GetNext(pos)).cx + 16;
- if(width < w) width = w;
- }
- ReleaseDC(pDC);
+ CDC* pDC = pListBox->GetDC();
+ CFont* pWndFont = GetFont();
+ pDC->SelectObject(pWndFont);
+ int width = GetColumnWidth(nCol);
+ POSITION pos = lstItems.GetHeadPosition();
+ while(pos)
+ {
+ int w = pDC->GetTextExtent(lstItems.GetNext(pos)).cx + 16;
+ if(width < w) width = w;
+ }
+ ReleaseDC(pDC);
- CRect r;
- pListBox->GetWindowRect(r);
- ScreenToClient(r);
- r.top = ir.bottom;
- r.bottom = r.top + pListBox->GetItemHeight(0) * (pListBox->GetCount() + 1);
- r.right = r.left + width;
- pListBox->MoveWindow(r);
+ CRect r;
+ pListBox->GetWindowRect(r);
+ ScreenToClient(r);
+ r.top = ir.bottom;
+ r.bottom = r.top + pListBox->GetItemHeight(0) * (pListBox->GetCount() + 1);
+ r.right = r.left + width;
+ pListBox->MoveWindow(r);
- m_fInPlaceDirty = false;
+ m_fInPlaceDirty = false;
- return pListBox;
+ return pListBox;
}
BEGIN_MESSAGE_MAP(CPlayerListCtrl, CListCtrl)
- ON_WM_VSCROLL()
- ON_WM_HSCROLL()
- ON_WM_MOUSEWHEEL()
- ON_WM_LBUTTONDOWN()
- ON_WM_TIMER()
- ON_WM_LBUTTONDBLCLK()
- ON_NOTIFY_REFLECT(LVN_MARQUEEBEGIN, OnLvnMarqueeBegin)
- ON_NOTIFY_REFLECT(LVN_INSERTITEM, OnLvnInsertitem)
- ON_NOTIFY_REFLECT(LVN_DELETEITEM, OnLvnDeleteitem)
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_CBN_DROPDOWN(IDC_COMBO1, OnCbnDropdownCombo1)
- ON_CBN_SELENDOK(IDC_COMBO1, OnCbnSelendokCombo1)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelChangeList1)
- ON_NOTIFY_EX(HDN_ITEMCHANGINGA, 0, OnHdnItemchanging)
- ON_NOTIFY_EX(HDN_ITEMCHANGINGW, 0, OnHdnItemchanging)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
+ ON_WM_VSCROLL()
+ ON_WM_HSCROLL()
+ ON_WM_MOUSEWHEEL()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_TIMER()
+ ON_WM_LBUTTONDBLCLK()
+ ON_NOTIFY_REFLECT(LVN_MARQUEEBEGIN, OnLvnMarqueeBegin)
+ ON_NOTIFY_REFLECT(LVN_INSERTITEM, OnLvnInsertitem)
+ ON_NOTIFY_REFLECT(LVN_DELETEITEM, OnLvnDeleteitem)
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_CBN_DROPDOWN(IDC_COMBO1, OnCbnDropdownCombo1)
+ ON_CBN_SELENDOK(IDC_COMBO1, OnCbnSelendokCombo1)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelChangeList1)
+ ON_NOTIFY_EX(HDN_ITEMCHANGINGA, 0, OnHdnItemchanging)
+ ON_NOTIFY_EX(HDN_ITEMCHANGINGW, 0, OnHdnItemchanging)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
// CPlayerListCtrl message handlers
void CPlayerListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(GetFocus() != this) SetFocus();
- CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
+ if(GetFocus() != this) SetFocus();
+ CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}
void CPlayerListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(GetFocus() != this) SetFocus();
- CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
+ if(GetFocus() != this) SetFocus();
+ CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
}
BOOL CPlayerListCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
- if(GetFocus() != this) SetFocus();
- return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
+ if(GetFocus() != this) SetFocus();
+ return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
}
void CPlayerListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
- CListCtrl::OnLButtonDown(nFlags, point);
-
- if(GetFocus() != this) SetFocus();
-
- KillTimer(1);
-
- int m_nItemClickedNow, m_nSubItemClickedNow;
-
- if((m_nItemClickedNow = HitTestEx(point, &m_nSubItemClickedNow)) < 0)
- {
- m_nItemClicked = -1;
- }
- else if(m_nItemClicked == m_nItemClickedNow /*&& m_nSubItemClicked == m_nSubItemClickedNow*/)
- {
- m_nSubItemClicked = m_nSubItemClickedNow;
-
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_BEGINLABELEDIT;
- dispinfo.item.mask = 0;
- dispinfo.item.iItem = m_nItemClicked;
- dispinfo.item.iSubItem = m_nSubItemClicked;
- if(GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo))
- {
- if(m_tStartEditingDelay > 0)
- {
- SetTimer(1, m_tStartEditingDelay, NULL);
- }
- else
- {
- dispinfo.hdr.code = LVN_DOLABELEDIT;
- GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
- }
- }
- }
- else
- {
- m_nItemClicked = m_nItemClickedNow;
- m_nSubItemClicked = m_nSubItemClickedNow;
-
- SetItemState(m_nItemClicked, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- }
+ CListCtrl::OnLButtonDown(nFlags, point);
+
+ if(GetFocus() != this) SetFocus();
+
+ KillTimer(1);
+
+ int m_nItemClickedNow, m_nSubItemClickedNow;
+
+ if((m_nItemClickedNow = HitTestEx(point, &m_nSubItemClickedNow)) < 0)
+ {
+ m_nItemClicked = -1;
+ }
+ else if(m_nItemClicked == m_nItemClickedNow /*&& m_nSubItemClicked == m_nSubItemClickedNow*/)
+ {
+ m_nSubItemClicked = m_nSubItemClickedNow;
+
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_BEGINLABELEDIT;
+ dispinfo.item.mask = 0;
+ dispinfo.item.iItem = m_nItemClicked;
+ dispinfo.item.iSubItem = m_nSubItemClicked;
+ if(GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo))
+ {
+ if(m_tStartEditingDelay > 0)
+ {
+ SetTimer(1, m_tStartEditingDelay, NULL);
+ }
+ else
+ {
+ dispinfo.hdr.code = LVN_DOLABELEDIT;
+ GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
+ }
+ }
+ }
+ else
+ {
+ m_nItemClicked = m_nItemClickedNow;
+ m_nSubItemClicked = m_nSubItemClickedNow;
+
+ SetItemState(m_nItemClicked, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
+ }
}
void CPlayerListCtrl::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
- KillTimer(1);
+ if(nIDEvent == 1)
+ {
+ KillTimer(1);
- UINT flag = LVIS_FOCUSED;
- if((GetItemState(m_nItemClicked, flag) & flag) == flag && m_nSubItemClicked >= 0)
- {
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_DOLABELEDIT;
- dispinfo.item.mask = 0;
- dispinfo.item.iItem = m_nItemClicked;
- dispinfo.item.iSubItem = m_nSubItemClicked;
- GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
- }
- }
+ UINT flag = LVIS_FOCUSED;
+ if((GetItemState(m_nItemClicked, flag) & flag) == flag && m_nSubItemClicked >= 0)
+ {
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_DOLABELEDIT;
+ dispinfo.item.mask = 0;
+ dispinfo.item.iItem = m_nItemClicked;
+ dispinfo.item.iSubItem = m_nSubItemClicked;
+ GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
+ }
+ }
- CListCtrl::OnTimer(nIDEvent);
+ CListCtrl::OnTimer(nIDEvent);
}
void CPlayerListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
- KillTimer(1);
+ KillTimer(1);
- CListCtrl::OnLButtonDblClk(nFlags, point);
+ CListCtrl::OnLButtonDblClk(nFlags, point);
}
void CPlayerListCtrl::OnLvnMarqueeBegin(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- *pResult = 1;
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ *pResult = 1;
}
void CPlayerListCtrl::OnLvnInsertitem(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- m_nItemClicked = -1;
- *pResult = 0;
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ m_nItemClicked = -1;
+ *pResult = 0;
}
void CPlayerListCtrl::OnLvnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- m_nItemClicked = -1;
- *pResult = 0;
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ m_nItemClicked = -1;
+ *pResult = 0;
}
void CPlayerListCtrl::OnEnChangeEdit1()
{
- m_fInPlaceDirty = true;
+ m_fInPlaceDirty = true;
}
void CPlayerListCtrl::OnCbnDropdownCombo1()
{
- CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO1);
+ CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO1);
- CRect ir;
- GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
+ CRect ir;
+ GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
- CRect r;
- pCombo->GetWindowRect(r);
- ScreenToClient(r);
- r.bottom = r.top + ir.Height() + pCombo->GetItemHeight(0) * 10;
- pCombo->MoveWindow(r);
+ CRect r;
+ pCombo->GetWindowRect(r);
+ ScreenToClient(r);
+ r.bottom = r.top + ir.Height() + pCombo->GetItemHeight(0)*10;
+ pCombo->MoveWindow(r);
}
void CPlayerListCtrl::OnCbnSelendokCombo1()
{
- m_fInPlaceDirty = true;
+ m_fInPlaceDirty = true;
}
void CPlayerListCtrl::OnLbnSelChangeList1()
{
- m_fInPlaceDirty = true;
- SetFocus();
+ m_fInPlaceDirty = true;
+ SetFocus();
}
BOOL CPlayerListCtrl::OnHdnItemchanging(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
+ LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
// SetFocus();
- *pResult = 0;
- return FALSE;
+ *pResult = 0;
+ return FALSE;
}
INT_PTR CPlayerListCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
- int col;
- int row = HitTestEx(point, &col);
- if(row == -1)
- return -1;
+ int col;
+ int row = HitTestEx(point, &col);
+ if(row == -1)
+ return -1;
- CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
- CRect rect;
- GetItemRect(row, &rect, LVIR_BOUNDS);
+ CRect rect;
+ GetItemRect(row, &rect, LVIR_BOUNDS);
- for(int colnum = 0; colnum < nColumnCount; colnum++)
- {
- int colwidth = GetColumnWidth(colnum);
+ for(int colnum = 0; colnum < nColumnCount; colnum++)
+ {
+ int colwidth = GetColumnWidth(colnum);
- if(colnum == col)
- {
- rect.right = rect.left + colwidth;
- break;
- }
+ if(colnum == col)
+ {
+ rect.right = rect.left + colwidth; break;
+ }
- rect.left += colwidth;
- }
+ rect.left += colwidth;
+ }
- pTI->hwnd = m_hWnd;
- pTI->uId = (UINT)((row << 10) + (col & 0x3ff) + 1);
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- pTI->rect = rect;
+ pTI->hwnd = m_hWnd;
+ pTI->uId = (UINT)((row<<10)+(col&0x3ff)+1);
+ pTI->lpszText = LPSTR_TEXTCALLBACK;
+ pTI->rect = rect;
- return pTI->uId;
+ return pTI->uId;
}
BOOL CPlayerListCtrl::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
- TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
+ TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
+ TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
- UINT nID = pNMHDR->idFrom;
+ UINT nID = pNMHDR->idFrom;
- if(pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND)
- || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
- {
- // idFrom is actually the HWND of the tool
- nID = ::GetDlgCtrlID((HWND)nID);
- }
+ if(pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND)
+ || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
+ {
+ // idFrom is actually the HWND of the tool
+ nID = ::GetDlgCtrlID((HWND)nID);
+ }
- if(nID == 0) // Notification in NT from automatically
- return FALSE; // created tooltip
+ if(nID == 0) // Notification in NT from automatically
+ return FALSE; // created tooltip
- if(pNMHDR->code == TTN_NEEDTEXTA) pTTTA->lParam = (LPARAM)m_hWnd;
- else if(pNMHDR->code == TTN_NEEDTEXTW) pTTTW->lParam = (LPARAM)m_hWnd;
+ if(pNMHDR->code == TTN_NEEDTEXTA) pTTTA->lParam = (LPARAM)m_hWnd;
+ else if(pNMHDR->code == TTN_NEEDTEXTW) pTTTW->lParam = (LPARAM)m_hWnd;
- *pResult = 0;
+ *pResult = 0;
- return GetParent()->SendMessage(WM_NOTIFY, id, (LPARAM)pNMHDR);
+ return GetParent()->SendMessage(WM_NOTIFY, id, (LPARAM)pNMHDR);
}
diff --git a/src/apps/mplayerc/PlayerListCtrl.h b/src/apps/mplayerc/PlayerListCtrl.h
index b7b3a178a..7dadc6e79 100644
--- a/src/apps/mplayerc/PlayerListCtrl.h
+++ b/src/apps/mplayerc/PlayerListCtrl.h
@@ -29,125 +29,125 @@
class CInPlaceEdit : public CEdit
{
private:
- int m_iItem;
- int m_iSubItem;
- CString m_sInitText;
- BOOL m_bESC; // To indicate whether ESC key was pressed
+ int m_iItem;
+ int m_iSubItem;
+ CString m_sInitText;
+ BOOL m_bESC; // To indicate whether ESC key was pressed
public:
- CInPlaceEdit(int iItem, int iSubItem, CString sInitText);
- virtual ~CInPlaceEdit();
+ CInPlaceEdit(int iItem, int iSubItem, CString sInitText);
+ virtual ~CInPlaceEdit();
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnNcDestroy();
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnNcDestroy();
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
class CInPlaceComboBox : public CComboBox
{
private:
- int m_iItem;
- int m_iSubItem;
- CAtlList<CString> m_lstItems;
- int m_nSel;
- BOOL m_bESC; // To indicate whether ESC key was pressed
+ int m_iItem;
+ int m_iSubItem;
+ CAtlList<CString> m_lstItems;
+ int m_nSel;
+ BOOL m_bESC; // To indicate whether ESC key was pressed
public:
- CInPlaceComboBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
- virtual ~CInPlaceComboBox();
+ CInPlaceComboBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
+ virtual ~CInPlaceComboBox();
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnNcDestroy();
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnCloseup();
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnNcDestroy();
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnCloseup();
};
class CInPlaceListBox : public CListBox
{
private:
- int m_iItem;
- int m_iSubItem;
- CAtlList<CString> m_lstItems;
- int m_nSel;
- BOOL m_bESC; // To indicate whether ESC key was pressed
+ int m_iItem;
+ int m_iSubItem;
+ CAtlList<CString> m_lstItems;
+ int m_nSel;
+ BOOL m_bESC; // To indicate whether ESC key was pressed
public:
- CInPlaceListBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
- virtual ~CInPlaceListBox();
+ CInPlaceListBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
+ virtual ~CInPlaceListBox();
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnNcDestroy();
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnNcDestroy();
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
// CPlayerListCtrl
class CPlayerListCtrl : public CListCtrl
{
- DECLARE_DYNAMIC(CPlayerListCtrl)
+ DECLARE_DYNAMIC(CPlayerListCtrl)
private:
- int m_nItemClicked, m_nSubItemClicked;
- int m_tStartEditingDelay;
+ int m_nItemClicked, m_nSubItemClicked;
+ int m_tStartEditingDelay;
- bool PrepareInPlaceControl(int nRow, int nCol, CRect& rect);
+ bool PrepareInPlaceControl(int nRow, int nCol, CRect& rect);
public:
- CPlayerListCtrl(int tStartEditingDelay = 500);
- virtual ~CPlayerListCtrl();
+ CPlayerListCtrl(int tStartEditingDelay = 500);
+ virtual ~CPlayerListCtrl();
- int HitTestEx(CPoint& point, int* col) const;
- CImageList* CreateDragImageEx(LPPOINT lpPoint);
+ int HitTestEx(CPoint& point, int* col) const;
+ CImageList* CreateDragImageEx(LPPOINT lpPoint);
- int GetBottomIndex() const;
+ int GetBottomIndex() const;
- CEdit* ShowInPlaceEdit(int nItem, int nCol);
- CComboBox* ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown = false);
- CListBox* ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel);
+ CEdit* ShowInPlaceEdit(int nItem, int nCol);
+ CComboBox* ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown=false);
+ CListBox* ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel);
- bool m_fInPlaceDirty;
+ bool m_fInPlaceDirty;
protected:
- virtual void PreSubclassWindow();
- virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
+ virtual void PreSubclassWindow();
+ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnLvnMarqueeBegin(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnInsertitem(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnCbnDropdownCombo1();
- afx_msg void OnCbnSelendokCombo1();
- afx_msg void OnLbnSelChangeList1();
- afx_msg BOOL OnHdnItemchanging(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg void OnLvnMarqueeBegin(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnInsertitem(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnCbnDropdownCombo1();
+ afx_msg void OnCbnSelendokCombo1();
+ afx_msg void OnLbnSelChangeList1();
+ afx_msg BOOL OnHdnItemchanging(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/apps/mplayerc/PlayerNavigationBar.cpp b/src/apps/mplayerc/PlayerNavigationBar.cpp
index d2cdd192b..14c6e362b 100644
--- a/src/apps/mplayerc/PlayerNavigationBar.cpp
+++ b/src/apps/mplayerc/PlayerNavigationBar.cpp
@@ -39,69 +39,69 @@ CPlayerNavigationBar::~CPlayerNavigationBar()
BOOL CPlayerNavigationBar::Create(CWnd* pParentWnd)
{
- if(!baseCPlayerNavigationBar::Create(_T("Navigation bar"), pParentWnd, 0))
- return FALSE;
-
- m_pParent = pParentWnd;
- m_navdlg.Create(this);
- m_navdlg.ShowWindow(SW_SHOWNORMAL);
-
- CRect r;
- m_navdlg.GetWindowRect(r);
- m_szMinVert = m_szVert = r.Size();
- m_szMinHorz = m_szHorz = r.Size();
- m_szMinFloat = m_szFloat = r.Size();
- m_bFixedFloat = true;
- m_szFixedFloat = r.Size();
-
- return TRUE;
+ if(!baseCPlayerNavigationBar::Create(_T("Navigation bar"), pParentWnd, 0))
+ return FALSE;
+
+ m_pParent = pParentWnd;
+ m_navdlg.Create(this);
+ m_navdlg.ShowWindow(SW_SHOWNORMAL);
+
+ CRect r;
+ m_navdlg.GetWindowRect(r);
+ m_szMinVert = m_szVert = r.Size();
+ m_szMinHorz = m_szHorz = r.Size();
+ m_szMinFloat = m_szFloat = r.Size();
+ m_bFixedFloat = true;
+ m_szFixedFloat = r.Size();
+
+ return TRUE;
}
BOOL CPlayerNavigationBar::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
- {
- if(IsDialogMessage(pMsg))
- return TRUE;
- }
+ if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
+ {
+ if(IsDialogMessage(pMsg))
+ return TRUE;
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerNavigationBar, baseCPlayerNavigationBar)
- ON_WM_SIZE()
+ ON_WM_SIZE()
END_MESSAGE_MAP()
// CPlayerShaderEditorBar message handlers
void CPlayerNavigationBar::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
-
- if(::IsWindow(m_navdlg.m_hWnd))
- {
- CRect r;
- GetClientRect(r);
- m_navdlg.MoveWindow(r);
- r.DeflateRect(8, 8, 8, 40);
- m_navdlg.m_ChannelList.MoveWindow(r);
-
- m_navdlg.m_ComboAudio.SetWindowPos(NULL, r.left, r.bottom + 5, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
- m_navdlg.m_ButtonInfo.SetWindowPos(NULL, r.left + 90, r.bottom + 5, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
- m_navdlg.m_ButtonScan.SetWindowPos(NULL, r.left + 145, r.bottom + 5, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
- }
-
-
- /*
- if (cy > 300)
- m_navdlg.m_ChannelList.Size = System::Drawing::Size( cx - 20, cy - 85 );
-
-
- if(::IsWindow(m_dlg.m_hWnd))
- {
- CRect r;
- GetClientRect(r);
- m_dlg.MoveWindow(r);
- }
- */
+ __super::OnSize(nType, cx, cy);
+
+ if(::IsWindow(m_navdlg.m_hWnd))
+ {
+ CRect r;
+ GetClientRect(r);
+ m_navdlg.MoveWindow(r);
+ r.DeflateRect(8,8,8,40);
+ m_navdlg.m_ChannelList.MoveWindow(r);
+
+ m_navdlg.m_ComboAudio.SetWindowPos(NULL, r.left,r.bottom +5, 0,0, SWP_NOSIZE | SWP_NOZORDER);
+ m_navdlg.m_ButtonInfo.SetWindowPos(NULL, r.left+90,r.bottom +5, 0,0, SWP_NOSIZE | SWP_NOZORDER);
+ m_navdlg.m_ButtonScan.SetWindowPos(NULL, r.left+145,r.bottom +5, 0,0, SWP_NOSIZE | SWP_NOZORDER);
+ }
+
+
+/*
+ if (cy > 300)
+ m_navdlg.m_ChannelList.Size = System::Drawing::Size( cx - 20, cy - 85 );
+
+
+ if(::IsWindow(m_dlg.m_hWnd))
+ {
+ CRect r;
+ GetClientRect(r);
+ m_dlg.MoveWindow(r);
+ }
+*/
}
diff --git a/src/apps/mplayerc/PlayerNavigationBar.h b/src/apps/mplayerc/PlayerNavigationBar.h
index 560567bc8..b13ca7ecf 100644
--- a/src/apps/mplayerc/PlayerNavigationBar.h
+++ b/src/apps/mplayerc/PlayerNavigationBar.h
@@ -33,22 +33,22 @@
class CPlayerNavigationBar : public baseCPlayerNavigationBar
{
- DECLARE_DYNAMIC(CPlayerNavigationBar)
+ DECLARE_DYNAMIC(CPlayerNavigationBar)
public:
- CWnd* m_pParent;
- CPlayerNavigationBar();
- virtual ~CPlayerNavigationBar();
- BOOL Create(CWnd* pParentWnd);
+ CWnd* m_pParent;
+ CPlayerNavigationBar();
+ virtual ~CPlayerNavigationBar();
+ BOOL Create(CWnd* pParentWnd);
public:
- CPlayerNavigationDialog m_navdlg;
+ CPlayerNavigationDialog m_navdlg;
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
};
diff --git a/src/apps/mplayerc/PlayerNavigationDialog.cpp b/src/apps/mplayerc/PlayerNavigationDialog.cpp
index 756d759a9..4d5a642eb 100644
--- a/src/apps/mplayerc/PlayerNavigationDialog.cpp
+++ b/src/apps/mplayerc/PlayerNavigationDialog.cpp
@@ -32,7 +32,7 @@
// IMPLEMENT_DYNAMIC(CPlayerNavigationDialog, CResizableDialog)
CPlayerNavigationDialog::CPlayerNavigationDialog()
- : CResizableDialog(CPlayerNavigationDialog::IDD, NULL)
+ : CResizableDialog(CPlayerNavigationDialog::IDD, NULL)
{
}
@@ -43,40 +43,40 @@ CPlayerNavigationDialog::~CPlayerNavigationDialog()
BOOL CPlayerNavigationDialog::Create(CWnd* pParent)
{
- if(!__super::Create(IDD, pParent))
- return FALSE;
- m_pParent = pParent;
- return TRUE;
+ if(!__super::Create(IDD, pParent))
+ return FALSE;
+ m_pParent = pParent;
+ return TRUE;
}
void CPlayerNavigationDialog::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LISTCHANNELS, m_ChannelList);
- DDX_Control(pDX, IDC_NAVIGATION_AUDIO, m_ComboAudio);
- DDX_Control(pDX, IDC_NAVIGATION_INFO, m_ButtonInfo);
- DDX_Control(pDX, IDC_NAVIGATION_SCAN, m_ButtonScan);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LISTCHANNELS, m_ChannelList);
+ DDX_Control(pDX, IDC_NAVIGATION_AUDIO, m_ComboAudio);
+ DDX_Control(pDX, IDC_NAVIGATION_INFO, m_ButtonInfo);
+ DDX_Control(pDX, IDC_NAVIGATION_SCAN, m_ButtonScan);
}
BOOL CPlayerNavigationDialog::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- if(pMsg->wParam == VK_RETURN)
- {
- CWnd* pFocused = GetFocus();
- }
- }
- return __super::PreTranslateMessage(pMsg);
+ if(pMsg->message == WM_KEYDOWN)
+ {
+ if(pMsg->wParam == VK_RETURN)
+ {
+ CWnd* pFocused = GetFocus();
+ }
+ }
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerNavigationDialog, CResizableDialog)
- ON_WM_DESTROY()
- ON_LBN_SELCHANGE(IDC_LISTCHANNELS, OnChangeChannel)
- ON_CBN_SELCHANGE(IDC_NAVIGATION_AUDIO, OnSelChangeComboAudio)
- ON_BN_CLICKED(IDC_NAVIGATION_INFO, OnButtonInfo)
- ON_BN_CLICKED(IDC_NAVIGATION_SCAN, OnTunerScan)
+ ON_WM_DESTROY()
+ ON_LBN_SELCHANGE(IDC_LISTCHANNELS, OnChangeChannel)
+ ON_CBN_SELCHANGE(IDC_NAVIGATION_AUDIO, OnSelChangeComboAudio)
+ ON_BN_CLICKED (IDC_NAVIGATION_INFO, OnButtonInfo)
+ ON_BN_CLICKED(IDC_NAVIGATION_SCAN, OnTunerScan)
END_MESSAGE_MAP()
@@ -85,127 +85,127 @@ END_MESSAGE_MAP()
BOOL CPlayerNavigationDialog::OnInitDialog()
{
- __super::OnInitDialog();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPlayerNavigationDialog::OnDestroy()
{
- m_ChannelList.ResetContent();
- __super::OnDestroy();
+ m_ChannelList.ResetContent();
+ __super::OnDestroy();
}
void CPlayerNavigationDialog::OnChangeChannel()
{
- CWnd* TempWnd;
+ CWnd* TempWnd;
int nItem;
- TempWnd = static_cast<CPlayerNavigationBar*>(m_pParent) -> m_pParent;
- nItem = p_nItems[m_ChannelList.GetCurSel()] + ID_NAVIGATE_CHAP_SUBITEM_START;
- static_cast<CMainFrame*>(TempWnd) -> OnNavigateChapters(nItem);
- SetupAudioSwitcherSubMenu();
+ TempWnd = static_cast<CPlayerNavigationBar*> (m_pParent) -> m_pParent;
+ nItem = p_nItems[m_ChannelList.GetCurSel()] + ID_NAVIGATE_CHAP_SUBITEM_START;
+ static_cast<CMainFrame*> (TempWnd) -> OnNavigateChapters(nItem);
+ SetupAudioSwitcherSubMenu();
}
void CPlayerNavigationDialog::SetupAudioSwitcherSubMenu(CDVBChannel* pChannel)
{
- bool bFound = FALSE;
- int nCurrentChannel;
- AppSettings& s = AfxGetAppSettings();
-
- if(!pChannel)
- {
- nCurrentChannel = s.DVBLastChannel;
- POSITION pos = s.DVBChannels.GetHeadPosition();
- while(pos && !bFound)
- {
- pChannel = &s.DVBChannels.GetNext(pos);
- if(nCurrentChannel == pChannel->GetPrefNumber())
- {
- bFound = TRUE;
- break;
- }
- }
- }
-
- m_ComboAudio.ResetContent();
- for(int i = 0; i < pChannel->GetAudioCount(); i++)
- {
- m_ComboAudio.AddString(pChannel->GetAudio(i)->Language);
- m_audios[i].PID = pChannel->GetAudio(i)-> PID;
- m_audios[i].Type = pChannel->GetAudio(i)->Type;
- m_audios[i].PesType = pChannel->GetAudio(i) -> PesType;
- m_audios[i].Language = pChannel->GetAudio(i) -> Language;
- }
-
- m_ComboAudio.SetCurSel(0); // TODO: managing default languages
-
+ bool bFound = FALSE;
+ int nCurrentChannel;
+ AppSettings& s = AfxGetAppSettings();
+
+ if (!pChannel)
+ {
+ nCurrentChannel = s.DVBLastChannel;
+ POSITION pos = s.DVBChannels.GetHeadPosition();
+ while (pos && !bFound)
+ {
+ pChannel = &s.DVBChannels.GetNext(pos);
+ if (nCurrentChannel == pChannel->GetPrefNumber())
+ {
+ bFound = TRUE;
+ break;
+ }
+ }
+ }
+
+ m_ComboAudio.ResetContent();
+ for (int i=0; i < pChannel->GetAudioCount(); i++)
+ {
+ m_ComboAudio.AddString(pChannel->GetAudio(i)->Language);
+ m_audios[i].PID = pChannel->GetAudio(i)-> PID;
+ m_audios[i].Type = pChannel->GetAudio(i)->Type;
+ m_audios[i].PesType = pChannel->GetAudio(i) -> PesType;
+ m_audios[i].Language = pChannel->GetAudio(i) -> Language;
+ }
+
+ m_ComboAudio.SetCurSel(0); // TODO: managing default languages
+
}
void CPlayerNavigationDialog::UpdateElementList()
{
- int nItem;
- int nCurrentChannel;
- AppSettings& s = AfxGetAppSettings();
-
- if(s.iDefaultCaptureDevice = 1)
- {
- m_ChannelList.ResetContent();
-
- nCurrentChannel = s.DVBLastChannel;
-
- POSITION pos = s.DVBChannels.GetHeadPosition();
- while(pos)
- {
- CDVBChannel& Channel = s.DVBChannels.GetNext(pos);
-
- nItem = m_ChannelList.AddString(Channel.GetName());
- if(nItem < MAX_CHANNELS_ALLOWED)
- p_nItems [nItem] = Channel.GetPrefNumber();
- if(nCurrentChannel == Channel.GetPrefNumber())
- {
- m_ChannelList.SetCurSel(nItem);
- SetupAudioSwitcherSubMenu(&Channel);
- }
- }
- }
+ int nItem;
+ int nCurrentChannel;
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.iDefaultCaptureDevice = 1)
+ {
+ m_ChannelList.ResetContent();
+
+ nCurrentChannel = s.DVBLastChannel;
+
+ POSITION pos = s.DVBChannels.GetHeadPosition();
+ while (pos)
+ {
+ CDVBChannel& Channel = s.DVBChannels.GetNext(pos);
+
+ nItem = m_ChannelList.AddString (Channel.GetName());
+ if (nItem < MAX_CHANNELS_ALLOWED)
+ p_nItems [nItem] = Channel.GetPrefNumber();
+ if (nCurrentChannel == Channel.GetPrefNumber())
+ {
+ m_ChannelList.SetCurSel(nItem);
+ SetupAudioSwitcherSubMenu(&Channel);
+ }
+ }
+ }
}
void CPlayerNavigationDialog::UpdatePos(int nID)
{
- for(int i = 0; i < MAX_CHANNELS_ALLOWED; i++)
- {
- if(p_nItems [i] == nID)
- {
- m_ChannelList.SetCurSel(i);
- break;
- }
-
- }
+ for (int i=0; i < MAX_CHANNELS_ALLOWED; i++)
+ {
+ if (p_nItems [i] == nID)
+ {
+ m_ChannelList.SetCurSel(i);
+ break;
+ }
+
+ }
}
void CPlayerNavigationDialog::OnTunerScan()
{
- CWnd* TempWnd;
+ CWnd* TempWnd;
- TempWnd = static_cast<CPlayerNavigationBar*>(m_pParent) -> m_pParent;
- static_cast<CMainFrame*>(TempWnd) -> OnTunerScan();
+ TempWnd = static_cast<CPlayerNavigationBar*> (m_pParent) -> m_pParent;
+ static_cast<CMainFrame*> (TempWnd) -> OnTunerScan();
}
void CPlayerNavigationDialog::OnSelChangeComboAudio()
{
- UINT nID;
- CWnd* TempWnd;
+ UINT nID;
+ CWnd* TempWnd;
- nID = m_ComboAudio.GetCurSel() + ID_NAVIGATE_AUDIO_SUBITEM_START;
+ nID = m_ComboAudio.GetCurSel() + ID_NAVIGATE_AUDIO_SUBITEM_START;
- TempWnd = static_cast<CPlayerNavigationBar*>(m_pParent) -> m_pParent;
- static_cast<CMainFrame*>(TempWnd) -> OnNavigateAudio(nID);
+ TempWnd = static_cast<CPlayerNavigationBar*> (m_pParent) -> m_pParent;
+ static_cast<CMainFrame*> (TempWnd) -> OnNavigateAudio(nID);
}
void CPlayerNavigationDialog::OnButtonInfo()
{
- // TODO: Retrieve and show channel info
+ // TODO: Retrieve and show channel info
}
diff --git a/src/apps/mplayerc/PlayerNavigationDialog.h b/src/apps/mplayerc/PlayerNavigationDialog.h
index 64c981012..2a108a3f0 100644
--- a/src/apps/mplayerc/PlayerNavigationDialog.h
+++ b/src/apps/mplayerc/PlayerNavigationDialog.h
@@ -36,38 +36,38 @@ class CPlayerNavigationDialog : public CResizableDialog //CDialog
{
public:
- CPlayerNavigationDialog(); // standard constructor
- virtual ~CPlayerNavigationDialog();
-
- BOOL Create(CWnd* pParent = NULL);
- void UpdateElementList();
- void UpdatePos(int nID);
- void SetupAudioSwitcherSubMenu(CDVBChannel* Channel = NULL);
- int p_nItems[MAX_CHANNELS_ALLOWED];
- DVBStreamInfo m_audios[DVB_MAX_AUDIO];
+ CPlayerNavigationDialog(); // standard constructor
+ virtual ~CPlayerNavigationDialog();
+ BOOL Create(CWnd* pParent = NULL);
+ void UpdateElementList();
+ void UpdatePos(int nID);
+ void SetupAudioSwitcherSubMenu(CDVBChannel* Channel = NULL);
+ int p_nItems[MAX_CHANNELS_ALLOWED];
+ DVBStreamInfo m_audios[DVB_MAX_AUDIO];
+
// Dialog Data
- enum { IDD = IDD_NAVIGATION_DLG };
+ enum { IDD = IDD_NAVIGATION_DLG };
- CListBox m_ChannelList;
- CComboBox m_ComboAudio;
- CButton m_ButtonInfo;
- CButton m_ButtonScan;
- CWnd* m_pParent;
+ CListBox m_ChannelList;
+ CComboBox m_ComboAudio;
+ CButton m_ButtonInfo;
+ CButton m_ButtonScan;
+ CWnd* m_pParent;
// CMenu m_subtitles, m_audios;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnInitDialog();
-
- DECLARE_MESSAGE_MAP()
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnInitDialog();
+
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnDestroy();
- afx_msg void OnChangeChannel();
- afx_msg void OnTunerScan();
- afx_msg void OnSelChangeComboAudio();
- afx_msg void OnButtonInfo();
+ afx_msg void OnDestroy();
+ afx_msg void OnChangeChannel();
+ afx_msg void OnTunerScan();
+ afx_msg void OnSelChangeComboAudio();
+ afx_msg void OnButtonInfo();
};
diff --git a/src/apps/mplayerc/PlayerPlaylistBar.cpp b/src/apps/mplayerc/PlayerPlaylistBar.cpp
index 431efec9f..473f833d9 100644
--- a/src/apps/mplayerc/PlayerPlaylistBar.cpp
+++ b/src/apps/mplayerc/PlayerPlaylistBar.cpp
@@ -35,10 +35,10 @@
IMPLEMENT_DYNAMIC(CPlayerPlaylistBar, CSizingControlBarG)
CPlayerPlaylistBar::CPlayerPlaylistBar()
- : m_list(0)
- , m_nTimeColWidth(0)
+ : m_list(0)
+ , m_nTimeColWidth(0)
{
- m_bDragging = FALSE;
+ m_bDragging = FALSE;
}
CPlayerPlaylistBar::~CPlayerPlaylistBar()
@@ -47,808 +47,775 @@ CPlayerPlaylistBar::~CPlayerPlaylistBar()
BOOL CPlayerPlaylistBar::Create(CWnd* pParentWnd)
{
- if(!CSizingControlBarG::Create(_T("Playlist"), pParentWnd, 0))
- return FALSE;
+ if(!CSizingControlBarG::Create(_T("Playlist"), pParentWnd, 0))
+ return FALSE;
- m_list.CreateEx(
- WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP
- | LVS_OWNERDRAWFIXED
- | LVS_NOCOLUMNHEADER
- | LVS_EDITLABELS
- | LVS_REPORT | LVS_SINGLESEL | LVS_AUTOARRANGE | LVS_NOSORTHEADER, // TODO: remove LVS_SINGLESEL and implement multiple item repositioning (dragging is ready)
- CRect(0, 0, 100, 100), this, IDC_PLAYLIST);
+ m_list.CreateEx(
+ WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
+ WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP
+ |LVS_OWNERDRAWFIXED
+ |LVS_NOCOLUMNHEADER
+ |LVS_EDITLABELS
+ |LVS_REPORT|LVS_SINGLESEL|LVS_AUTOARRANGE|LVS_NOSORTHEADER, // TODO: remove LVS_SINGLESEL and implement multiple item repositioning (dragging is ready)
+ CRect(0,0,100,100), this, IDC_PLAYLIST);
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
- m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 380);
+ m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 380);
- CDC* pDC = m_list.GetDC();
- CFont* old = pDC->SelectObject(GetFont());
- m_nTimeColWidth = pDC->GetTextExtent(_T("000:00:00")).cx + 5;
- pDC->SelectObject(old);
- m_list.ReleaseDC(pDC);
- m_list.InsertColumn(COL_TIME, _T("Time"), LVCFMT_RIGHT, m_nTimeColWidth);
+ CDC* pDC = m_list.GetDC();
+ CFont* old = pDC->SelectObject(GetFont());
+ m_nTimeColWidth = pDC->GetTextExtent(_T("000:00:00")).cx + 5;
+ pDC->SelectObject(old);
+ m_list.ReleaseDC(pDC);
+ m_list.InsertColumn(COL_TIME, _T("Time"), LVCFMT_RIGHT, m_nTimeColWidth);
m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10);
- m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
+ m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
- return TRUE;
+ return TRUE;
}
BOOL CPlayerPlaylistBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CSizingControlBarG::PreCreateWindow(cs))
- return FALSE;
+ if(!CSizingControlBarG::PreCreateWindow(cs))
+ return FALSE;
- cs.dwExStyle |= WS_EX_ACCEPTFILES;
+ cs.dwExStyle |= WS_EX_ACCEPTFILES;
- return TRUE;
+ return TRUE;
}
BOOL CPlayerPlaylistBar::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
- {
- if(IsDialogMessage(pMsg))
- return TRUE;
- }
+ if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
+ {
+ if(IsDialogMessage(pMsg))
+ return TRUE;
+ }
- return CSizingControlBarG::PreTranslateMessage(pMsg);
+ return CSizingControlBarG::PreTranslateMessage(pMsg);
}
bool FindFileInList(CAtlList<CString>& sl, CString fn)
{
- bool fFound = false;
- POSITION pos = sl.GetHeadPosition();
- while(pos && !fFound)
- {
- if(!sl.GetNext(pos).CompareNoCase(fn)) fFound = true;
- }
- return(fFound);
+ bool fFound = false;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos && !fFound) {if(!sl.GetNext(pos).CompareNoCase(fn)) fFound = true;}
+ return(fFound);
}
void CPlayerPlaylistBar::AddItem(CString fn, CAtlList<CString>* subs)
{
- CAtlList<CString> sl;
- sl.AddTail(fn);
- AddItem(sl, subs);
+ CAtlList<CString> sl;
+ sl.AddTail(fn);
+ AddItem(sl, subs);
}
void CPlayerPlaylistBar::AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs)
{
- CPlaylistItem pli;
-
- POSITION pos = fns.GetHeadPosition();
- while(pos)
- {
- CString fn = fns.GetNext(pos);
- if(!fn.Trim().IsEmpty()) pli.m_fns.AddTail(fn);
- }
-
- if(subs)
- {
- POSITION pos = subs->GetHeadPosition();
- while(pos)
- {
- CString fn = subs->GetNext(pos);
- if(!fn.Trim().IsEmpty()) pli.m_subs.AddTail(fn);
- }
- }
-
- if(pli.m_fns.IsEmpty()) return;
-
- CString fn = pli.m_fns.GetHead();
-
- if(AfxGetAppSettings().fAutoloadAudio && fn.Find(_T("://")) < 0)
- {
- int i = fn.ReverseFind('.');
- if(i > 0)
- {
- CMediaFormats& mf = AfxGetAppSettings().Formats;
-
- CString ext = fn.Mid(i + 1).MakeLower();
-
- if(!mf.FindExt(ext, true))
- {
- CString path = fn;
- path.Replace('/', '\\');
- path = path.Left(path.ReverseFind('\\') + 1);
-
- WIN32_FIND_DATA fd = {0};
- HANDLE hFind = FindFirstFile(fn.Left(i) + _T("*.*"), &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
-
- CString fullpath = path + fd.cFileName;
- CString ext2 = fullpath.Mid(fullpath.ReverseFind('.') + 1).MakeLower();
- if(!FindFileInList(pli.m_fns, fullpath) && ext != ext2
- && mf.FindExt(ext2, true) && mf.IsUsingEngine(fullpath, DirectShow))
- {
- pli.m_fns.AddTail(fullpath);
- }
- }
- while(FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
- }
- }
- }
-
- if(AfxGetAppSettings().fAutoloadSubtitles)
- {
- CAtlArray<CString> paths;
- paths.Add(_T("."));
- paths.Add(_T(".\\subtitles"));
- paths.Add(_T("c:\\subtitles"));
-
- CAtlArray<SubFile> ret;
- GetSubFileNames(fn, paths, ret);
-
- for(int i = 0; i < ret.GetCount(); i++)
- {
- if(!FindFileInList(pli.m_subs, ret[i].fn))
- pli.m_subs.AddTail(ret[i].fn);
- }
- }
-
- m_pl.AddTail(pli);
+ CPlaylistItem pli;
+
+ POSITION pos = fns.GetHeadPosition();
+ while(pos)
+ {
+ CString fn = fns.GetNext(pos);
+ if(!fn.Trim().IsEmpty()) pli.m_fns.AddTail(fn);
+ }
+
+ if(subs)
+ {
+ POSITION pos = subs->GetHeadPosition();
+ while(pos)
+ {
+ CString fn = subs->GetNext(pos);
+ if(!fn.Trim().IsEmpty()) pli.m_subs.AddTail(fn);
+ }
+ }
+
+ if(pli.m_fns.IsEmpty()) return;
+
+ CString fn = pli.m_fns.GetHead();
+
+ if(AfxGetAppSettings().fAutoloadAudio && fn.Find(_T("://")) < 0)
+ {
+ int i = fn.ReverseFind('.');
+ if(i > 0)
+ {
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+
+ CString ext = fn.Mid(i+1).MakeLower();
+
+ if(!mf.FindExt(ext, true))
+ {
+ CString path = fn;
+ path.Replace('/', '\\');
+ path = path.Left(path.ReverseFind('\\')+1);
+
+ WIN32_FIND_DATA fd = {0};
+ HANDLE hFind = FindFirstFile(fn.Left(i) + _T("*.*"), &fd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
+
+ CString fullpath = path + fd.cFileName;
+ CString ext2 = fullpath.Mid(fullpath.ReverseFind('.')+1).MakeLower();
+ if(!FindFileInList(pli.m_fns, fullpath) && ext != ext2
+ && mf.FindExt(ext2, true) && mf.IsUsingEngine(fullpath, DirectShow))
+ {
+ pli.m_fns.AddTail(fullpath);
+ }
+ }
+ while(FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+ }
+ }
+ }
+
+ if(AfxGetAppSettings().fAutoloadSubtitles)
+ {
+ CAtlArray<CString> paths;
+ paths.Add(_T("."));
+ paths.Add(_T(".\\subtitles"));
+ paths.Add(_T("c:\\subtitles"));
+
+ CAtlArray<SubFile> ret;
+ GetSubFileNames(fn, paths, ret);
+
+ for(int i = 0; i < ret.GetCount(); i++)
+ {
+ if(!FindFileInList(pli.m_subs, ret[i].fn))
+ pli.m_subs.AddTail(ret[i].fn);
+ }
+ }
+
+ m_pl.AddTail(pli);
}
static bool SearchFiles(CString mask, CAtlList<CString>& sl)
{
- if(mask.Find(_T("://")) >= 0)
- return(false);
-
- mask.Trim();
- sl.RemoveAll();
-
- CMediaFormats& mf = AfxGetAppSettings().Formats;
-
- bool fFilterKnownExts;
- WIN32_FILE_ATTRIBUTE_DATA fad;
- mask = (fFilterKnownExts = (GetFileAttributesEx(mask, GetFileExInfoStandard, &fad)
- && (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)))
- ? CString(mask).TrimRight(_T("\\/")) + _T("\\*.*")
- : mask;
-
- {
- CString dir = mask.Left(max(mask.ReverseFind('\\'), mask.ReverseFind('/')) + 1);
-
- WIN32_FIND_DATA fd;
- HANDLE h = FindFirstFile(mask, &fd);
- if(h != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
-
- CString fn = fd.cFileName;
- //CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
- CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
- CString path = dir + fd.cFileName;
-
- if(!fFilterKnownExts || mf.FindExt(ext))
- {
- for(int i = 0; i < mf.GetCount(); i++)
- {
- CMediaFormatCategory& mfc = mf.GetAt(i);
- /* playlist files are skipped when playing the contents of an entire directory */
- if((mfc.FindExt(ext)) && (mf[i].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE)) != 0))
- {
- sl.AddTail(path);
- break;
- }
- }
- }
-
- }
- while(FindNextFile(h, &fd));
-
- FindClose(h);
-
- if(sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1)
- {
- GetCDROMType(mask[0], sl);
- }
- }
- }
-
- return(sl.GetCount() > 1
- || sl.GetCount() == 1 && sl.GetHead().CompareNoCase(mask)
- || sl.GetCount() == 0 && mask.FindOneOf(_T("?*")) >= 0);
+ if(mask.Find(_T("://")) >= 0)
+ return(false);
+
+ mask.Trim();
+ sl.RemoveAll();
+
+ CMediaFormats& mf = AfxGetAppSettings().Formats;
+
+ bool fFilterKnownExts;
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ mask = (fFilterKnownExts = (GetFileAttributesEx(mask, GetFileExInfoStandard, &fad)
+ && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)))
+ ? CString(mask).TrimRight(_T("\\/")) + _T("\\*.*")
+ : mask;
+
+ {
+ CString dir = mask.Left(max(mask.ReverseFind('\\'), mask.ReverseFind('/'))+1);
+
+ WIN32_FIND_DATA fd;
+ HANDLE h = FindFirstFile(mask, &fd);
+ if(h != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
+
+ CString fn = fd.cFileName;
+ //CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
+ CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
+ CString path = dir + fd.cFileName;
+
+ if(!fFilterKnownExts || mf.FindExt(ext))
+ {
+ for(int i = 0; i < mf.GetCount(); i++)
+ {
+ CMediaFormatCategory& mfc = mf.GetAt(i);
+ /* playlist files are skipped when playing the contents of an entire directory */
+ if((mfc.FindExt(ext)) && (mf[i].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE)) != 0))
+ {
+ sl.AddTail(path);
+ break;
+ }
+ }
+ }
+
+ }
+ while(FindNextFile(h, &fd));
+
+ FindClose(h);
+
+ if(sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1)
+ {
+ GetCDROMType(mask[0], sl);
+ }
+ }
+ }
+
+ return(sl.GetCount() > 1
+ || sl.GetCount() == 1 && sl.GetHead().CompareNoCase(mask)
+ || sl.GetCount() == 0 && mask.FindOneOf(_T("?*")) >= 0);
}
void CPlayerPlaylistBar::ParsePlayList(CString fn, CAtlList<CString>* subs)
{
- CAtlList<CString> sl;
- sl.AddTail(fn);
- ParsePlayList(sl, subs);
+ CAtlList<CString> sl;
+ sl.AddTail(fn);
+ ParsePlayList(sl, subs);
}
-void CPlayerPlaylistBar::ResolveLinkFiles(CAtlList<CString> &fns)
+void CPlayerPlaylistBar::ResolveLinkFiles( CAtlList<CString> &fns )
{
- // resolve .lnk files
-
- CComPtr<IShellLink> pSL;
- pSL.CoCreateInstance(CLSID_ShellLink);
- CComQIPtr<IPersistFile> pPF = pSL;
-
- POSITION pos = fns.GetHeadPosition();
- while(pSL && pPF && pos)
- {
- CString& fn = fns.GetNext(pos);
- TCHAR buff[_MAX_PATH];
- if(CPath(fn).GetExtension().MakeLower() != _T(".lnk")
- || FAILED(pPF->Load(CStringW(fn), STGM_READ))
- || FAILED(pSL->Resolve(NULL, SLR_ANY_MATCH | SLR_NO_UI))
- || FAILED(pSL->GetPath(buff, countof(buff), NULL, 0)))
- continue;
-
- fn = buff;
- }
+ // resolve .lnk files
+
+ CComPtr<IShellLink> pSL;
+ pSL.CoCreateInstance(CLSID_ShellLink);
+ CComQIPtr<IPersistFile> pPF = pSL;
+
+ POSITION pos = fns.GetHeadPosition();
+ while(pSL && pPF && pos)
+ {
+ CString& fn = fns.GetNext(pos);
+ TCHAR buff[_MAX_PATH];
+ if(CPath(fn).GetExtension().MakeLower() != _T(".lnk")
+ || FAILED(pPF->Load(CStringW(fn), STGM_READ))
+ || FAILED(pSL->Resolve(NULL, SLR_ANY_MATCH|SLR_NO_UI))
+ || FAILED(pSL->GetPath(buff, countof(buff), NULL, 0)))
+ continue;
+
+ fn = buff;
+ }
}
void CPlayerPlaylistBar::ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs)
{
- if(fns.IsEmpty()) return;
-
- ResolveLinkFiles(fns);
-
- CAtlList<CString> sl;
- if(SearchFiles(fns.GetHead(), sl))
- {
- if(sl.GetCount() > 1) subs = NULL;
- POSITION pos = sl.GetHeadPosition();
- while(pos) ParsePlayList(sl.GetNext(pos), subs);
- return;
- }
-
- CAtlList<CString> redir;
- CStringA ct = GetContentType(fns.GetHead(), &redir);
- if(!redir.IsEmpty())
- {
- POSITION pos = redir.GetHeadPosition();
- while(pos) ParsePlayList(sl.GetNext(pos), subs);
- return;
- }
-
- if(ct == "application/x-mpc-playlist")
- {
- ParseMPCPlayList(fns.GetHead());
- return;
- }
- else if(ct == "application/x-bdmv-playlist")
- {
- ParseBDMVPlayList(fns.GetHead());
- return;
- }
-
- AddItem(fns, subs);
+ if(fns.IsEmpty()) return;
+
+ ResolveLinkFiles(fns);
+
+ CAtlList<CString> sl;
+ if(SearchFiles(fns.GetHead(), sl))
+ {
+ if(sl.GetCount() > 1) subs = NULL;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos) ParsePlayList(sl.GetNext(pos), subs);
+ return;
+ }
+
+ CAtlList<CString> redir;
+ CStringA ct = GetContentType(fns.GetHead(), &redir);
+ if(!redir.IsEmpty())
+ {
+ POSITION pos = redir.GetHeadPosition();
+ while(pos) ParsePlayList(sl.GetNext(pos), subs);
+ return;
+ }
+
+ if(ct == "application/x-mpc-playlist")
+ {
+ ParseMPCPlayList(fns.GetHead());
+ return;
+ }
+ else if(ct == "application/x-bdmv-playlist")
+ {
+ ParseBDMVPlayList(fns.GetHead());
+ return;
+ }
+
+ AddItem(fns, subs);
}
static int s_int_comp(const void* i1, const void* i2)
{
- return (int)i1 - (int)i2;
+ return (int)i1 - (int)i2;
}
static CString CombinePath(CPath p, CString fn)
{
- if(fn.Find(':') >= 0 || fn.Find(_T("\\")) == 0) return fn;
- p.Append(CPath(fn));
- return (LPCTSTR)p;
+ if(fn.Find(':') >= 0 || fn.Find(_T("\\")) == 0) return fn;
+ p.Append(CPath(fn));
+ return (LPCTSTR)p;
}
bool CPlayerPlaylistBar::ParseBDMVPlayList(CString fn)
{
- CHdmvClipInfo ClipInfo;
- CString strPlaylistFile;
- CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
-
- CPath Path(fn);
- Path.RemoveFileSpec();
- Path.RemoveFileSpec();
-
- if(SUCCEEDED(ClipInfo.FindMainMovie(Path + L"\\", strPlaylistFile, MainPlaylist)))
- {
- CAtlList<CString> strFiles;
- strFiles.AddHead(strPlaylistFile);
- Append(strFiles, MainPlaylist.GetCount() > 1, NULL);
- }
-
- return m_pl.GetCount() > 0;
+ CHdmvClipInfo ClipInfo;
+ CString strPlaylistFile;
+ CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
+
+ CPath Path(fn);
+ Path.RemoveFileSpec();
+ Path.RemoveFileSpec();
+
+ if (SUCCEEDED (ClipInfo.FindMainMovie (Path + L"\\", strPlaylistFile, MainPlaylist)))
+ {
+ CAtlList<CString> strFiles;
+ strFiles.AddHead (strPlaylistFile);
+ Append(strFiles, MainPlaylist.GetCount()>1, NULL);
+ }
+
+ return m_pl.GetCount() > 0;
}
bool CPlayerPlaylistBar::ParseMPCPlayList(CString fn)
{
- CString str;
- CAtlMap<int, CPlaylistItem> pli;
- CAtlArray<int> idx;
-
- CWebTextFile f;
- if(!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST"))
- return false;
-
- if(f.GetEncoding() == CTextFile::ASCII)
- f.SetEncoding(CTextFile::ANSI);
-
- CPath base(fn);
- base.RemoveFileSpec();
-
- while(f.ReadString(str))
- {
- CAtlList<CString> sl;
- Explode(str, sl, ',', 3);
- if(sl.GetCount() != 3) continue;
-
- if(int i = _ttoi(sl.RemoveHead()))
- {
- CString key = sl.RemoveHead();
- CString value = sl.RemoveHead();
-
- if(key == _T("type"))
- {
- pli[i].m_type = (CPlaylistItem::type_t)_ttol(value);
- idx.Add(i);
- }
- else if(key == _T("label")) pli[i].m_label = value;
- else if(key == _T("filename"))
- {
- value = CombinePath(base, value);
- pli[i].m_fns.AddTail(value);
- }
- else if(key == _T("subtitle"))
- {
- value = CombinePath(base, value);
- pli[i].m_subs.AddTail(value);
- }
- else if(key == _T("video"))
- {
- while(pli[i].m_fns.GetCount() < 2) pli[i].m_fns.AddTail(_T(""));
- pli[i].m_fns.GetHead() = value;
- }
- else if(key == _T("audio"))
- {
- while(pli[i].m_fns.GetCount() < 2) pli[i].m_fns.AddTail(_T(""));
- pli[i].m_fns.GetTail() = value;
- }
- else if(key == _T("vinput")) pli[i].m_vinput = _ttol(value);
- else if(key == _T("vchannel")) pli[i].m_vchannel = _ttol(value);
- else if(key == _T("ainput")) pli[i].m_ainput = _ttol(value);
- else if(key == _T("country")) pli[i].m_country = _ttol(value);
- }
- }
-
- qsort(idx.GetData(), idx.GetCount(), sizeof(int), s_int_comp);
- for(int i = 0; i < idx.GetCount(); i++)
- m_pl.AddTail(pli[idx[i]]);
-
- return pli.GetCount() > 0;
+ CString str;
+ CAtlMap<int, CPlaylistItem> pli;
+ CAtlArray<int> idx;
+
+ CWebTextFile f;
+ if(!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST"))
+ return false;
+
+ if(f.GetEncoding() == CTextFile::ASCII)
+ f.SetEncoding(CTextFile::ANSI);
+
+ CPath base(fn);
+ base.RemoveFileSpec();
+
+ while(f.ReadString(str))
+ {
+ CAtlList<CString> sl;
+ Explode(str, sl, ',', 3);
+ if(sl.GetCount() != 3) continue;
+
+ if(int i = _ttoi(sl.RemoveHead()))
+ {
+ CString key = sl.RemoveHead();
+ CString value = sl.RemoveHead();
+
+ if(key == _T("type")) {pli[i].m_type = (CPlaylistItem::type_t)_ttol(value); idx.Add(i);}
+ else if(key == _T("label")) pli[i].m_label = value;
+ else if(key == _T("filename")) {value = CombinePath(base, value); pli[i].m_fns.AddTail(value);}
+ else if(key == _T("subtitle")) {value = CombinePath(base, value); pli[i].m_subs.AddTail(value);}
+ else if(key == _T("video")) {while(pli[i].m_fns.GetCount() < 2) pli[i].m_fns.AddTail(_T("")); pli[i].m_fns.GetHead() = value;}
+ else if(key == _T("audio")) {while(pli[i].m_fns.GetCount() < 2) pli[i].m_fns.AddTail(_T("")); pli[i].m_fns.GetTail() = value;}
+ else if(key == _T("vinput")) pli[i].m_vinput = _ttol(value);
+ else if(key == _T("vchannel")) pli[i].m_vchannel = _ttol(value);
+ else if(key == _T("ainput")) pli[i].m_ainput = _ttol(value);
+ else if(key == _T("country")) pli[i].m_country = _ttol(value);
+ }
+ }
+
+ qsort(idx.GetData(), idx.GetCount(), sizeof(int), s_int_comp);
+ for(int i = 0; i < idx.GetCount(); i++)
+ m_pl.AddTail(pli[idx[i]]);
+
+ return pli.GetCount() > 0;
}
bool CPlayerPlaylistBar::SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath)
{
- CTextFile f;
- if(!f.Save(fn, e))
- return false;
-
- f.WriteString(_T("MPCPLAYLIST\n"));
-
- POSITION pos = m_pl.GetHeadPosition(), pos2;
- for(int i = 1; pos; i++)
- {
- CPlaylistItem& pli = m_pl.GetNext(pos);
-
- CString idx;
- idx.Format(_T("%d"), i);
-
- CString str;
- str.Format(_T("%d,type,%d"), i, pli.m_type);
- f.WriteString(str + _T("\n"));
-
- if(!pli.m_label.IsEmpty())
- f.WriteString(idx + _T(",label,") + pli.m_label + _T("\n"));
-
- if(pli.m_type == CPlaylistItem::file)
- {
- pos2 = pli.m_fns.GetHeadPosition();
- while(pos2)
- {
- CString fn = pli.m_fns.GetNext(pos2);
- if(fRemovePath)
- {
- CPath p(fn);
- p.StripPath();
- fn = (LPCTSTR)p;
- }
- f.WriteString(idx + _T(",filename,") + fn + _T("\n"));
- }
-
- pos2 = pli.m_subs.GetHeadPosition();
- while(pos2)
- {
- CString fn = pli.m_subs.GetNext(pos2);
- if(fRemovePath)
- {
- CPath p(fn);
- p.StripPath();
- fn = (LPCTSTR)p;
- }
- f.WriteString(idx + _T(",subtitle,") + fn + _T("\n"));
- }
- }
- else if(pli.m_type == CPlaylistItem::device && pli.m_fns.GetCount() == 2)
- {
- f.WriteString(idx + _T(",video,") + pli.m_fns.GetHead() + _T("\n"));
- f.WriteString(idx + _T(",audio,") + pli.m_fns.GetTail() + _T("\n"));
- str.Format(_T("%d,vinput,%d"), i, pli.m_vinput);
- f.WriteString(str + _T("\n"));
- str.Format(_T("%d,vchannel,%d"), i, pli.m_vchannel);
- f.WriteString(str + _T("\n"));
- str.Format(_T("%d,ainput,%d"), i, pli.m_ainput);
- f.WriteString(str + _T("\n"));
- str.Format(_T("%d,country,%d"), i, pli.m_country);
- f.WriteString(str + _T("\n"));
- }
- }
-
- return true;
+ CTextFile f;
+ if(!f.Save(fn, e))
+ return false;
+
+ f.WriteString(_T("MPCPLAYLIST\n"));
+
+ POSITION pos = m_pl.GetHeadPosition(), pos2;
+ for(int i = 1; pos; i++)
+ {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
+
+ CString idx;
+ idx.Format(_T("%d"), i);
+
+ CString str;
+ str.Format(_T("%d,type,%d"), i, pli.m_type);
+ f.WriteString(str + _T("\n"));
+
+ if(!pli.m_label.IsEmpty())
+ f.WriteString(idx + _T(",label,") + pli.m_label + _T("\n"));
+
+ if(pli.m_type == CPlaylistItem::file)
+ {
+ pos2 = pli.m_fns.GetHeadPosition();
+ while(pos2)
+ {
+ CString fn = pli.m_fns.GetNext(pos2);
+ if(fRemovePath) {CPath p(fn); p.StripPath(); fn = (LPCTSTR)p;}
+ f.WriteString(idx + _T(",filename,") + fn + _T("\n"));
+ }
+
+ pos2 = pli.m_subs.GetHeadPosition();
+ while(pos2)
+ {
+ CString fn = pli.m_subs.GetNext(pos2);
+ if(fRemovePath) {CPath p(fn); p.StripPath(); fn = (LPCTSTR)p;}
+ f.WriteString(idx + _T(",subtitle,") + fn + _T("\n"));
+ }
+ }
+ else if(pli.m_type == CPlaylistItem::device && pli.m_fns.GetCount() == 2)
+ {
+ f.WriteString(idx + _T(",video,") + pli.m_fns.GetHead() + _T("\n"));
+ f.WriteString(idx + _T(",audio,") + pli.m_fns.GetTail() + _T("\n"));
+ str.Format(_T("%d,vinput,%d"), i, pli.m_vinput);
+ f.WriteString(str + _T("\n"));
+ str.Format(_T("%d,vchannel,%d"), i, pli.m_vchannel);
+ f.WriteString(str + _T("\n"));
+ str.Format(_T("%d,ainput,%d"), i, pli.m_ainput);
+ f.WriteString(str + _T("\n"));
+ str.Format(_T("%d,country,%d"), i, pli.m_country);
+ f.WriteString(str + _T("\n"));
+ }
+ }
+
+ return true;
}
void CPlayerPlaylistBar::Refresh()
{
- SetupList();
- ResizeListColumn();
+ SetupList();
+ ResizeListColumn();
}
-
+
void CPlayerPlaylistBar::Empty()
{
- m_pl.RemoveAll();
- m_list.DeleteAllItems();
- SavePlaylist();
+ m_pl.RemoveAll();
+ m_list.DeleteAllItems();
+ SavePlaylist();
}
void CPlayerPlaylistBar::Open(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs)
{
- if(!fMulti)
- {
- ASSERT(fns.GetCount() == 1);
- ResolveLinkFiles(fns);
- if(SelectFileInPlaylist(fns.GetHead().GetString()))
- return;
- }
-
- Empty();
- Append(fns, fMulti, subs);
+ if (!fMulti)
+ {
+ ASSERT(fns.GetCount() == 1);
+ ResolveLinkFiles(fns);
+ if (SelectFileInPlaylist(fns.GetHead().GetString()))
+ return;
+ }
+
+ Empty();
+ Append(fns, fMulti, subs);
}
void CPlayerPlaylistBar::Append(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs)
{
- if(fMulti)
- {
- ASSERT(subs == NULL || subs->GetCount() == 0);
- POSITION pos = fns.GetHeadPosition();
- while(pos) ParsePlayList(fns.GetNext(pos), NULL);
- }
- else
- {
- ParsePlayList(fns, subs);
- }
-
- Refresh();
- SavePlaylist();
+ if(fMulti)
+ {
+ ASSERT(subs == NULL || subs->GetCount() == 0);
+ POSITION pos = fns.GetHeadPosition();
+ while(pos) ParsePlayList(fns.GetNext(pos), NULL);
+ }
+ else
+ {
+ ParsePlayList(fns, subs);
+ }
+
+ Refresh();
+ SavePlaylist();
}
void CPlayerPlaylistBar::Open(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput)
{
- Empty();
- Append(vdn, adn, vinput, vchannel, ainput);
+ Empty();
+ Append(vdn, adn, vinput, vchannel, ainput);
}
void CPlayerPlaylistBar::Append(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput)
{
- CPlaylistItem pli;
- pli.m_type = CPlaylistItem::device;
- pli.m_fns.AddTail(CString(vdn));
- pli.m_fns.AddTail(CString(adn));
- pli.m_vinput = vinput;
- pli.m_vchannel = vchannel;
- pli.m_ainput = ainput;
- CAtlList<CStringW> sl;
- CStringW vfn = GetFriendlyName(vdn);
- CStringW afn = GetFriendlyName(adn);
- if(!vfn.IsEmpty()) sl.AddTail(vfn);
- if(!afn.IsEmpty()) sl.AddTail(afn);
- CStringW label = Implode(sl, '|');
- label.Replace(L"|", L" - ");
- pli.m_label = CString(label);
- m_pl.AddTail(pli);
-
- Refresh();
- SavePlaylist();
+ CPlaylistItem pli;
+ pli.m_type = CPlaylistItem::device;
+ pli.m_fns.AddTail(CString(vdn));
+ pli.m_fns.AddTail(CString(adn));
+ pli.m_vinput = vinput;
+ pli.m_vchannel = vchannel;
+ pli.m_ainput = ainput;
+ CAtlList<CStringW> sl;
+ CStringW vfn = GetFriendlyName(vdn);
+ CStringW afn = GetFriendlyName(adn);
+ if(!vfn.IsEmpty()) sl.AddTail(vfn);
+ if(!afn.IsEmpty()) sl.AddTail(afn);
+ CStringW label = Implode(sl, '|');
+ label.Replace(L"|", L" - ");
+ pli.m_label = CString(label);
+ m_pl.AddTail(pli);
+
+ Refresh();
+ SavePlaylist();
}
void CPlayerPlaylistBar::SetupList()
{
- m_list.DeleteAllItems();
-
- POSITION pos = m_pl.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- m_list.SetItemData(m_list.InsertItem(i, pli.GetLabel()), (DWORD_PTR)pos);
- m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
- m_pl.GetNext(pos);
- }
+ m_list.DeleteAllItems();
+
+ POSITION pos = m_pl.GetHeadPosition();
+ for(int i = 0; pos; i++)
+ {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ m_list.SetItemData(m_list.InsertItem(i, pli.GetLabel()), (DWORD_PTR)pos);
+ m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
+ m_pl.GetNext(pos);
+ }
}
void CPlayerPlaylistBar::UpdateList()
{
- POSITION pos = m_pl.GetHeadPosition();
- for(int i = 0, j = m_list.GetItemCount(); pos && i < j; i++)
- {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- m_list.SetItemData(i, (DWORD_PTR)pos);
- m_list.SetItemText(i, COL_NAME, pli.GetLabel(0));
- m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
- m_pl.GetNext(pos);
- }
+ POSITION pos = m_pl.GetHeadPosition();
+ for(int i = 0, j = m_list.GetItemCount(); pos && i < j; i++)
+ {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ m_list.SetItemData(i, (DWORD_PTR)pos);
+ m_list.SetItemText(i, COL_NAME, pli.GetLabel(0));
+ m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
+ m_pl.GetNext(pos);
+ }
}
void CPlayerPlaylistBar::EnsureVisible(POSITION pos)
{
- int i = FindItem(m_pl.GetPos());
- if(i < 0) return;
- m_list.EnsureVisible(i, TRUE);
- m_list.Invalidate();
+ int i = FindItem(m_pl.GetPos());
+ if(i < 0) return;
+ m_list.EnsureVisible(i, TRUE);
+ m_list.Invalidate();
}
int CPlayerPlaylistBar::FindItem(POSITION pos)
{
- for(int i = 0; i < m_list.GetItemCount(); i++)
- if((POSITION)m_list.GetItemData(i) == pos)
- return(i);
- return(-1);
+ for(int i = 0; i < m_list.GetItemCount(); i++)
+ if((POSITION)m_list.GetItemData(i) == pos)
+ return(i);
+ return(-1);
}
POSITION CPlayerPlaylistBar::FindPos(int i)
{
- if(i < 0) return(NULL);
- return((POSITION)m_list.GetItemData(i));
+ if(i < 0) return(NULL);
+ return((POSITION)m_list.GetItemData(i));
}
int CPlayerPlaylistBar::GetCount()
{
- return(m_pl.GetCount()); // TODO: n - .fInvalid
+ return(m_pl.GetCount()); // TODO: n - .fInvalid
}
int CPlayerPlaylistBar::GetSelIdx()
{
- return(FindItem(m_pl.GetPos()));
+ return(FindItem(m_pl.GetPos()));
}
void CPlayerPlaylistBar::SetSelIdx(int i)
{
- m_pl.SetPos(FindPos(i));
+ m_pl.SetPos(FindPos(i));
}
bool CPlayerPlaylistBar::IsAtEnd()
{
- return(m_pl.GetPos() && m_pl.GetPos() == m_pl.GetTailPosition());
+ return(m_pl.GetPos() && m_pl.GetPos() == m_pl.GetTailPosition());
}
bool CPlayerPlaylistBar::GetCur(CPlaylistItem& pli)
{
- if(!m_pl.GetPos()) return(false);
- pli = m_pl.GetAt(m_pl.GetPos());
- return(true);
+ if(!m_pl.GetPos()) return(false);
+ pli = m_pl.GetAt(m_pl.GetPos());
+ return(true);
}
CString CPlayerPlaylistBar::GetCur()
{
- CString fn;
- CPlaylistItem pli;
- if(GetCur(pli) && !pli.m_fns.IsEmpty()) fn = pli.m_fns.GetHead();
- return(fn);
+ CString fn;
+ CPlaylistItem pli;
+ if(GetCur(pli) && !pli.m_fns.IsEmpty()) fn = pli.m_fns.GetHead();
+ return(fn);
}
void CPlayerPlaylistBar::SetNext()
{
- POSITION pos = m_pl.GetPos(), org = pos;
- while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
- UpdateList();
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetPos(), org = pos;
+ while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
+ UpdateList();
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetPrev()
{
- POSITION pos = m_pl.GetPos(), org = pos;
- while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org);
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetPos(), org = pos;
+ while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org);
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetFirstSelected()
{
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- if(pos)
- pos = FindPos(m_list.GetNextSelectedItem(pos));
- else
- {
- pos = m_pl.GetTailPosition();
- POSITION org = pos;
- while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
- }
- UpdateList();
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ if(pos)
+ pos = FindPos(m_list.GetNextSelectedItem(pos));
+ else
+ {
+ pos = m_pl.GetTailPosition();
+ POSITION org = pos;
+ while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
+ }
+ UpdateList();
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetFirst()
{
- POSITION pos = m_pl.GetTailPosition(), org = pos;
- while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
- UpdateList();
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetTailPosition(), org = pos;
+ while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
+ UpdateList();
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetLast()
{
- POSITION pos = m_pl.GetHeadPosition(), org = pos;
- while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org);
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetHeadPosition(), org = pos;
+ while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org);
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetCurValid(bool fValid)
{
- if(POSITION pos = m_pl.GetPos())
- {
- if(m_pl.GetAt(pos).m_fInvalid = !fValid)
- {
- int i = FindItem(pos);
- m_list.RedrawItems(i, i);
- }
- }
+ if(POSITION pos = m_pl.GetPos())
+ {
+ if(m_pl.GetAt(pos).m_fInvalid = !fValid)
+ {
+ int i = FindItem(pos);
+ m_list.RedrawItems(i, i);
+ }
+ }
}
void CPlayerPlaylistBar::SetCurTime(REFERENCE_TIME rt)
{
- if(POSITION pos = m_pl.GetPos())
- {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- pli.m_duration = rt;
- m_list.SetItemText(FindItem(pos), COL_TIME, pli.GetLabel(1));
- }
+ if(POSITION pos = m_pl.GetPos())
+ {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ pli.m_duration = rt;
+ m_list.SetItemText(FindItem(pos), COL_TIME, pli.GetLabel(1));
+ }
}
OpenMediaData* CPlayerPlaylistBar::GetCurOMD(REFERENCE_TIME rtStart)
{
- CPlaylistItem pli;
- if(!GetCur(pli)) return NULL;
-
- CString fn = CString(pli.m_fns.GetHead()).MakeLower();
-
- if(fn.Find(_T("video_ts.ifo")) >= 0
- || fn.Find(_T(".ratdvd")) >= 0)
- {
- if(OpenDVDData* p = DNew OpenDVDData())
- {
- p->path = pli.m_fns.GetHead();
- p->subs.AddTailList(&pli.m_subs);
- return p;
- }
- }
-
- if(pli.m_type == CPlaylistItem::device)
- {
- if(OpenDeviceData* p = DNew OpenDeviceData())
- {
- POSITION pos = pli.m_fns.GetHeadPosition();
- for(int i = 0; i < countof(p->DisplayName) && pos; i++)
- p->DisplayName[i] = pli.m_fns.GetNext(pos);
- p->vinput = pli.m_vinput;
- p->vchannel = pli.m_vchannel;
- p->ainput = pli.m_ainput;
- return p;
- }
- }
- else
- {
- if(OpenFileData* p = DNew OpenFileData())
- {
- p->fns.AddTailList(&pli.m_fns);
- p->subs.AddTailList(&pli.m_subs);
- p->rtStart = rtStart;
- return p;
- }
- }
-
- return NULL;
+ CPlaylistItem pli;
+ if(!GetCur(pli)) return NULL;
+
+ CString fn = CString(pli.m_fns.GetHead()).MakeLower();
+
+ if(fn.Find(_T("video_ts.ifo")) >= 0
+ || fn.Find(_T(".ratdvd")) >= 0)
+ {
+ if(OpenDVDData* p = DNew OpenDVDData())
+ {
+ p->path = pli.m_fns.GetHead();
+ p->subs.AddTailList(&pli.m_subs);
+ return p;
+ }
+ }
+
+ if(pli.m_type == CPlaylistItem::device)
+ {
+ if(OpenDeviceData* p = DNew OpenDeviceData())
+ {
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ for(int i = 0; i < countof(p->DisplayName) && pos; i++)
+ p->DisplayName[i] = pli.m_fns.GetNext(pos);
+ p->vinput = pli.m_vinput;
+ p->vchannel = pli.m_vchannel;
+ p->ainput = pli.m_ainput;
+ return p;
+ }
+ }
+ else
+ {
+ if(OpenFileData* p = DNew OpenFileData())
+ {
+ p->fns.AddTailList(&pli.m_fns);
+ p->subs.AddTailList(&pli.m_subs);
+ p->rtStart = rtStart;
+ return p;
+ }
+ }
+
+ return NULL;
}
bool CPlayerPlaylistBar::SelectFileInPlaylist(LPCTSTR filename)
{
- if(!filename)
- return false;
- POSITION pos = m_pl.GetHeadPosition();
- while(pos)
- {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- if(pli.FindFile(filename))
- {
- m_pl.SetPos(pos);
- EnsureVisible(pos);
- return true;
- }
- m_pl.GetNext(pos);
- }
- return false;
+ if (!filename)
+ return false;
+ POSITION pos = m_pl.GetHeadPosition();
+ while(pos)
+ {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ if (pli.FindFile(filename))
+ {
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
+ return true;
+ }
+ m_pl.GetNext(pos);
+ }
+ return false;
}
void CPlayerPlaylistBar::LoadPlaylist(LPCTSTR filename)
{
- CString base;
- if(AfxGetMyApp()->GetAppSavePath(base))
- {
- CPath p;
- p.Combine(base, _T("default.mpcpl"));
-
- if(!AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE))
- {
- DeleteFile(p);
- }
- else
- {
- ParseMPCPlayList(p);
- Refresh();
- SelectFileInPlaylist(filename);
- }
- }
+ CString base;
+ if(AfxGetMyApp()->GetAppSavePath(base))
+ {
+ CPath p;
+ p.Combine(base, _T("default.mpcpl"));
+
+ if(!AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE))
+ {
+ DeleteFile(p);
+ }
+ else
+ {
+ ParseMPCPlayList(p);
+ Refresh();
+ SelectFileInPlaylist(filename);
+ }
+ }
}
void CPlayerPlaylistBar::SavePlaylist()
{
- CString base;
- if(AfxGetMyApp()->GetAppSavePath(base))
- {
- CPath p;
- p.Combine(base, _T("default.mpcpl"));
-
- if(!AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE))
- {
- DeleteFile(p);
- }
- else
- {
- SaveMPCPlayList(p, CTextFile::UTF8, false);
- }
- }
+ CString base;
+ if(AfxGetMyApp()->GetAppSavePath(base))
+ {
+ CPath p;
+ p.Combine(base, _T("default.mpcpl"));
+
+ if(!AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE))
+ {
+ DeleteFile(p);
+ }
+ else
+ {
+ SaveMPCPlayList(p, CTextFile::UTF8, false);
+ }
+ }
}
BEGIN_MESSAGE_MAP(CPlayerPlaylistBar, CSizingControlBarG)
- ON_WM_SIZE()
- ON_NOTIFY(LVN_KEYDOWN, IDC_PLAYLIST, OnLvnKeyDown)
- ON_NOTIFY(NM_DBLCLK, IDC_PLAYLIST, OnNMDblclkList)
+ ON_WM_SIZE()
+ ON_NOTIFY(LVN_KEYDOWN, IDC_PLAYLIST, OnLvnKeyDown)
+ ON_NOTIFY(NM_DBLCLK, IDC_PLAYLIST, OnNMDblclkList)
// ON_NOTIFY(NM_CUSTOMDRAW, IDC_PLAYLIST, OnCustomdrawList)
- ON_WM_DRAWITEM()
- ON_COMMAND_EX(ID_FILE_CLOSEPLAYLIST, OnFileClosePlaylist)
- ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlay)
- ON_WM_DROPFILES()
- ON_NOTIFY(LVN_BEGINDRAG, IDC_PLAYLIST, OnBeginDrag)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONUP()
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
- ON_WM_TIMER()
- ON_WM_CONTEXTMENU()
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_PLAYLIST, OnLvnEndlabeleditList)
+ ON_WM_DRAWITEM()
+ ON_COMMAND_EX(ID_FILE_CLOSEPLAYLIST, OnFileClosePlaylist)
+ ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlay)
+ ON_WM_DROPFILES()
+ ON_NOTIFY(LVN_BEGINDRAG, IDC_PLAYLIST, OnBeginDrag)
+ ON_WM_MOUSEMOVE()
+ ON_WM_LBUTTONUP()
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
+ ON_WM_TIMER()
+ ON_WM_CONTEXTMENU()
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_PLAYLIST, OnLvnEndlabeleditList)
END_MESSAGE_MAP()
@@ -856,80 +823,80 @@ END_MESSAGE_MAP()
void CPlayerPlaylistBar::ResizeListColumn()
{
- if(::IsWindow(m_list.m_hWnd))
- {
- CRect r;
- GetClientRect(r);
- r.DeflateRect(2, 2);
- m_list.SetRedraw(FALSE);
- m_list.MoveWindow(r);
- m_list.GetClientRect(r);
- m_list.SetColumnWidth(COL_NAME, r.Width() - m_nTimeColWidth); //LVSCW_AUTOSIZE_USEHEADER
- m_list.SetRedraw(TRUE);
- }
+ if(::IsWindow(m_list.m_hWnd))
+ {
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(2, 2);
+ m_list.SetRedraw(FALSE);
+ m_list.MoveWindow(r);
+ m_list.GetClientRect(r);
+ m_list.SetColumnWidth(COL_NAME, r.Width()-m_nTimeColWidth); //LVSCW_AUTOSIZE_USEHEADER
+ m_list.SetRedraw(TRUE);
+ }
}
void CPlayerPlaylistBar::OnSize(UINT nType, int cx, int cy)
{
- CSizingControlBarG::OnSize(nType, cx, cy);
+ CSizingControlBarG::OnSize(nType, cx, cy);
- ResizeListColumn();
+ ResizeListColumn();
}
-void CPlayerPlaylistBar::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
+void CPlayerPlaylistBar::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
+ LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
- *pResult = FALSE;
+ *pResult = FALSE;
- CList<int> items;
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- while(pos) items.AddHead(m_list.GetNextSelectedItem(pos));
+ CList<int> items;
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ while(pos) items.AddHead(m_list.GetNextSelectedItem(pos));
- if(pLVKeyDown->wVKey == VK_DELETE && items.GetCount() > 0)
- {
- pos = items.GetHeadPosition();
- while(pos)
- {
- int i = items.GetNext(pos);
- if(m_pl.RemoveAt(FindPos(i)))((CMainFrame*)AfxGetMainWnd())->CloseMedia();
- m_list.DeleteItem(i);
- }
+ if(pLVKeyDown->wVKey == VK_DELETE && items.GetCount() > 0)
+ {
+ pos = items.GetHeadPosition();
+ while(pos)
+ {
+ int i = items.GetNext(pos);
+ if(m_pl.RemoveAt(FindPos(i))) ((CMainFrame*)AfxGetMainWnd())->CloseMedia();
+ m_list.DeleteItem(i);
+ }
- m_list.SetItemState(-1, 0, LVIS_SELECTED);
- m_list.SetItemState(
- max(min(items.GetTail(), m_list.GetItemCount() - 1), 0),
- LVIS_SELECTED, LVIS_SELECTED);
+ m_list.SetItemState(-1, 0, LVIS_SELECTED);
+ m_list.SetItemState(
+ max(min(items.GetTail(), m_list.GetItemCount()-1), 0),
+ LVIS_SELECTED, LVIS_SELECTED);
- ResizeListColumn();
+ ResizeListColumn();
- *pResult = TRUE;
- }
- else if(pLVKeyDown->wVKey == VK_SPACE && items.GetCount() == 1)
- {
- m_pl.SetPos(FindPos(items.GetHead()));
+ *pResult = TRUE;
+ }
+ else if(pLVKeyDown->wVKey == VK_SPACE && items.GetCount() == 1)
+ {
+ m_pl.SetPos(FindPos(items.GetHead()));
- ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
+ ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
void CPlayerPlaylistBar::OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0)
- {
- FILE_POSITION* FilePosition = AfxGetAppSettings().CurrentFilePosition();
- if(FilePosition) FilePosition->llPosition = 0;
+ if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0)
+ {
+ FILE_POSITION* FilePosition = AfxGetAppSettings().CurrentFilePosition();
+ if (FilePosition) FilePosition->llPosition = 0;
- m_pl.SetPos(FindPos(lpnmlv->iItem));
- m_list.Invalidate();
- ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
- }
+ m_pl.SetPos(FindPos(lpnmlv->iItem));
+ m_list.Invalidate();
+ ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
+ }
- *pResult = 0;
+ *pResult = 0;
}
/*
void CPlayerPlaylistBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
@@ -975,591 +942,575 @@ void CPlayerPlaylistBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
void CPlayerPlaylistBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_PLAYLIST) return;
-
- int nItem = lpDrawItemStruct->itemID;
- CRect rcItem = lpDrawItemStruct->rcItem;
- POSITION pos = FindPos(nItem);
- bool fSelected = pos == m_pl.GetPos();
- CPlaylistItem& pli = m_pl.GetAt(pos);
-
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
- {
- FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
- FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- }
- else
- {
- FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
- }
-
- COLORREF textcolor = fSelected ? 0xff : 0;
- if(pli.m_fInvalid) textcolor |= 0xA0A0A0;
-
- CString time = !pli.m_fInvalid ? m_list.GetItemText(nItem, COL_TIME) : _T("Invalid");
- CSize timesize(0, 0);
- CPoint timept(rcItem.right, 0);
- if(time.GetLength() > 0)
- {
- timesize = pDC->GetTextExtent(time);
- if((3 + timesize.cx + 3) < rcItem.Width() / 2)
- {
- timept = CPoint(rcItem.right - (3 + timesize.cx + 3), (rcItem.top + rcItem.bottom - timesize.cy) / 2);
-
- pDC->SetTextColor(textcolor);
- pDC->TextOut(timept.x, timept.y, time);
- }
- }
-
- CString fmt, file;
- fmt.Format(_T("%%0%dd. %%s"), (int)log10(0.1 + m_pl.GetCount()) + 1);
- file.Format(fmt, nItem + 1, m_list.GetItemText(nItem, COL_NAME));
- CSize filesize = pDC->GetTextExtent(file);
- while(3 + filesize.cx + 6 > timept.x && file.GetLength() > 3)
- {
- file = file.Left(file.GetLength() - 4) + _T("...");
- filesize = pDC->GetTextExtent(file);
- }
-
- if(file.GetLength() > 3)
- {
- pDC->SetTextColor(textcolor);
- pDC->TextOut(rcItem.left + 3, (rcItem.top + rcItem.bottom - filesize.cy) / 2, file);
- }
+ if(nIDCtl != IDC_PLAYLIST) return;
+
+ int nItem = lpDrawItemStruct->itemID;
+ CRect rcItem = lpDrawItemStruct->rcItem;
+ POSITION pos = FindPos(nItem);
+ bool fSelected = pos == m_pl.GetPos();
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
+ {
+ FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
+ FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
+ }
+ else
+ {
+ FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
+ }
+
+ COLORREF textcolor = fSelected?0xff:0;
+ if(pli.m_fInvalid) textcolor |= 0xA0A0A0;
+
+ CString time = !pli.m_fInvalid ? m_list.GetItemText(nItem, COL_TIME) : _T("Invalid");
+ CSize timesize(0, 0);
+ CPoint timept(rcItem.right, 0);
+ if(time.GetLength() > 0)
+ {
+ timesize = pDC->GetTextExtent(time);
+ if((3+timesize.cx+3) < rcItem.Width()/2)
+ {
+ timept = CPoint(rcItem.right-(3+timesize.cx+3), (rcItem.top+rcItem.bottom-timesize.cy)/2);
+
+ pDC->SetTextColor(textcolor);
+ pDC->TextOut(timept.x, timept.y, time);
+ }
+ }
+
+ CString fmt, file;
+ fmt.Format(_T("%%0%dd. %%s"), (int)log10(0.1+m_pl.GetCount())+1);
+ file.Format(fmt, nItem+1, m_list.GetItemText(nItem, COL_NAME));
+ CSize filesize = pDC->GetTextExtent(file);
+ while(3+filesize.cx+6 > timept.x && file.GetLength() > 3)
+ {
+ file = file.Left(file.GetLength()-4) + _T("...");
+ filesize = pDC->GetTextExtent(file);
+ }
+
+ if(file.GetLength() > 3)
+ {
+ pDC->SetTextColor(textcolor);
+ pDC->TextOut(rcItem.left+3, (rcItem.top+rcItem.bottom-filesize.cy)/2, file);
+ }
}
BOOL CPlayerPlaylistBar::OnFileClosePlaylist(UINT nID)
{
- Empty();
- return FALSE;
+ Empty();
+ return FALSE;
}
BOOL CPlayerPlaylistBar::OnPlayPlay(UINT nID)
{
- m_list.Invalidate();
- return FALSE;
+ m_list.Invalidate();
+ return FALSE;
}
void CPlayerPlaylistBar::OnDropFiles(HDROP hDropInfo)
{
- SetActiveWindow();
+ SetActiveWindow();
- CAtlList<CString> sl;
+ CAtlList<CString> sl;
- UINT nFiles = ::DragQueryFile(hDropInfo, (UINT) - 1, NULL, 0);
- for(UINT iFile = 0; iFile < nFiles; iFile++)
- {
- TCHAR szFileName[_MAX_PATH];
- ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
- sl.AddTail(szFileName);
- }
- ::DragFinish(hDropInfo);
+ UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
+ for(UINT iFile = 0; iFile < nFiles; iFile++)
+ {
+ TCHAR szFileName[_MAX_PATH];
+ ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
+ sl.AddTail(szFileName);
+ }
+ ::DragFinish(hDropInfo);
- Append(sl, true);
+ Append(sl, true);
}
void CPlayerPlaylistBar::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
{
- ModifyStyle(WS_EX_ACCEPTFILES, 0);
+ ModifyStyle(WS_EX_ACCEPTFILES, 0);
- m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
+ m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
- CPoint p(0, 0);
- m_pDragImage = m_list.CreateDragImageEx(&p);
+ CPoint p(0, 0);
+ m_pDragImage = m_list.CreateDragImageEx(&p);
- CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
+ CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
- m_pDragImage->BeginDrag(0, p2 - p);
- m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
+ m_pDragImage->BeginDrag(0, p2 - p);
+ m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
- m_bDragging = TRUE;
- m_nDropIndex = -1;
+ m_bDragging = TRUE;
+ m_nDropIndex = -1;
- SetCapture();
+ SetCapture();
}
void CPlayerPlaylistBar::OnMouseMove(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
- m_ptDropPoint = point;
- ClientToScreen(&m_ptDropPoint);
+ if(m_bDragging)
+ {
+ m_ptDropPoint = point;
+ ClientToScreen(&m_ptDropPoint);
+
+ m_pDragImage->DragMove(m_ptDropPoint);
+ m_pDragImage->DragShowNolock(FALSE);
- m_pDragImage->DragMove(m_ptDropPoint);
- m_pDragImage->DragShowNolock(FALSE);
+ WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
+
+ m_pDragImage->DragShowNolock(TRUE);
- WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
+ {
+ int iOverItem = m_list.HitTest(m_ptDropPoint);
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = m_list.GetBottomIndex();
+
+ if(iOverItem == iTopItem && iTopItem != 0) // top of list
+ SetTimer(1, 100, NULL);
+ else
+ KillTimer(1);
+
+ if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) // bottom of list
+ SetTimer(2, 100, NULL);
+ else
+ KillTimer(2);
+ }
+ }
- m_pDragImage->DragShowNolock(TRUE);
+ __super::OnMouseMove(nFlags, point);
+}
- {
- int iOverItem = m_list.HitTest(m_ptDropPoint);
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = m_list.GetBottomIndex();
+void CPlayerPlaylistBar::OnTimer(UINT_PTR nIDEvent)
+{
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
- if(iOverItem == iTopItem && iTopItem != 0) // top of list
- SetTimer(1, 100, NULL);
- else
- KillTimer(1);
+ if(m_bDragging)
+ {
+ m_pDragImage->DragShowNolock(FALSE);
- if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) // bottom of list
- SetTimer(2, 100, NULL);
- else
- KillTimer(2);
- }
- }
+ if(nIDEvent == 1)
+ {
+ m_list.EnsureVisible(iTopItem - 1, false);
+ m_list.UpdateWindow();
+ if(m_list.GetTopIndex() == 0) KillTimer(1);
+ }
+ else if(nIDEvent == 2)
+ {
+ m_list.EnsureVisible(iBottomItem + 1, false);
+ m_list.UpdateWindow();
+ if(m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) KillTimer(2);
+ }
- __super::OnMouseMove(nFlags, point);
-}
+ m_pDragImage->DragShowNolock(TRUE);
+ }
-void CPlayerPlaylistBar::OnTimer(UINT_PTR nIDEvent)
-{
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
-
- if(m_bDragging)
- {
- m_pDragImage->DragShowNolock(FALSE);
-
- if(nIDEvent == 1)
- {
- m_list.EnsureVisible(iTopItem - 1, false);
- m_list.UpdateWindow();
- if(m_list.GetTopIndex() == 0) KillTimer(1);
- }
- else if(nIDEvent == 2)
- {
- m_list.EnsureVisible(iBottomItem + 1, false);
- m_list.UpdateWindow();
- if(m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) KillTimer(2);
- }
-
- m_pDragImage->DragShowNolock(TRUE);
- }
-
- __super::OnTimer(nIDEvent);
+ __super::OnTimer(nIDEvent);
}
void CPlayerPlaylistBar::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
- ::ReleaseCapture();
+ if(m_bDragging)
+ {
+ ::ReleaseCapture();
- m_bDragging = FALSE;
- m_pDragImage->DragLeave(GetDesktopWindow());
- m_pDragImage->EndDrag();
+ m_bDragging = FALSE;
+ m_pDragImage->DragLeave(GetDesktopWindow());
+ m_pDragImage->EndDrag();
- delete m_pDragImage;
- m_pDragImage = NULL;
+ delete m_pDragImage;
+ m_pDragImage = NULL;
- KillTimer(1);
- KillTimer(2);
+ KillTimer(1);
+ KillTimer(2);
- CPoint pt(point);
- ClientToScreen(&pt);
+ CPoint pt(point);
+ ClientToScreen(&pt);
- if(WindowFromPoint(pt) == &m_list)
- DropItemOnList();
- }
+ if(WindowFromPoint(pt) == &m_list)
+ DropItemOnList();
+ }
- ModifyStyle(0, WS_EX_ACCEPTFILES);
+ ModifyStyle(0, WS_EX_ACCEPTFILES);
- __super::OnLButtonUp(nFlags, point);
+ __super::OnLButtonUp(nFlags, point);
}
void CPlayerPlaylistBar::DropItemOnList()
{
- m_ptDropPoint.y += 10; //
- m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
-
- TCHAR szLabel[_MAX_PATH];
- LV_ITEM lvi;
- ZeroMemory(&lvi, sizeof(LV_ITEM));
- lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
- lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
- lvi.pszText = szLabel;
- lvi.iItem = m_nDragIndex;
- lvi.cchTextMax = MAX_PATH;
- m_list.GetItem(&lvi);
-
- if(m_nDropIndex < 0) m_nDropIndex = m_list.GetItemCount();
- lvi.iItem = m_nDropIndex;
- m_list.InsertItem(&lvi);
-
- CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
- lvi.mask = LVIF_TEXT;
- lvi.iItem = m_nDropIndex;
- //INDEX OF DRAGGED ITEM WILL CHANGE IF ITEM IS DROPPED ABOVE ITSELF
- if(m_nDropIndex < m_nDragIndex) m_nDragIndex++;
- for(int col = 1; col < nColumnCount; col++)
- {
- _tcscpy(lvi.pszText, (LPCTSTR)(m_list.GetItemText(m_nDragIndex, col)));
- lvi.iSubItem = col;
- m_list.SetItem(&lvi);
- }
-
- m_list.DeleteItem(m_nDragIndex);
-
- CList<CPlaylistItem> tmp;
- UINT id = -1;
- for(int i = 0; i < m_list.GetItemCount(); i++)
- {
- POSITION pos = (POSITION)m_list.GetItemData(i);
- CPlaylistItem& pli = m_pl.GetAt(pos);
- tmp.AddTail(pli);
- if(pos == m_pl.GetPos()) id = pli.m_id;
- }
- m_pl.RemoveAll();
- POSITION pos = tmp.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
- CPlaylistItem& pli = tmp.GetNext(pos);
- m_pl.AddTail(pli);
- if(pli.m_id == id) m_pl.SetPos(m_pl.GetTailPosition());
- m_list.SetItemData(i, (DWORD_PTR)m_pl.GetTailPosition());
- }
-
- ResizeListColumn();
+ m_ptDropPoint.y += 10; //
+ m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
+
+ TCHAR szLabel[_MAX_PATH];
+ LV_ITEM lvi;
+ ZeroMemory(&lvi, sizeof(LV_ITEM));
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
+ lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
+ lvi.pszText = szLabel;
+ lvi.iItem = m_nDragIndex;
+ lvi.cchTextMax = MAX_PATH;
+ m_list.GetItem(&lvi);
+
+ if(m_nDropIndex < 0) m_nDropIndex = m_list.GetItemCount();
+ lvi.iItem = m_nDropIndex;
+ m_list.InsertItem(&lvi);
+
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
+ lvi.mask = LVIF_TEXT;
+ lvi.iItem = m_nDropIndex;
+ //INDEX OF DRAGGED ITEM WILL CHANGE IF ITEM IS DROPPED ABOVE ITSELF
+ if(m_nDropIndex < m_nDragIndex) m_nDragIndex++;
+ for(int col=1; col < nColumnCount; col++)
+ {
+ _tcscpy(lvi.pszText, (LPCTSTR)(m_list.GetItemText(m_nDragIndex, col)));
+ lvi.iSubItem = col;
+ m_list.SetItem(&lvi);
+ }
+
+ m_list.DeleteItem(m_nDragIndex);
+
+ CList<CPlaylistItem> tmp;
+ UINT id = -1;
+ for(int i = 0; i < m_list.GetItemCount(); i++)
+ {
+ POSITION pos = (POSITION)m_list.GetItemData(i);
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ tmp.AddTail(pli);
+ if(pos == m_pl.GetPos()) id = pli.m_id;
+ }
+ m_pl.RemoveAll();
+ POSITION pos = tmp.GetHeadPosition();
+ for(int i = 0; pos; i++)
+ {
+ CPlaylistItem& pli = tmp.GetNext(pos);
+ m_pl.AddTail(pli);
+ if(pli.m_id == id) m_pl.SetPos(m_pl.GetTailPosition());
+ m_list.SetItemData(i, (DWORD_PTR)m_pl.GetTailPosition());
+ }
+
+ ResizeListColumn();
}
BOOL CPlayerPlaylistBar::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
- TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
-
- if((pNMHDR->code == TTN_NEEDTEXTA && (HWND)pTTTA->lParam != m_list.m_hWnd)
- || (pNMHDR->code == TTN_NEEDTEXTW && (HWND)pTTTW->lParam != m_list.m_hWnd))
- return FALSE;
-
- int row = ((pNMHDR->idFrom - 1) >> 10) & 0x3fffff;
- int col = (pNMHDR->idFrom - 1) & 0x3ff;
-
- if(row < 0 || row >= m_pl.GetCount())
- return FALSE;
-
- CPlaylistItem& pli = m_pl.GetAt(FindPos(row));
-
- CString strTipText;
-
- if(col == COL_NAME)
- {
- POSITION pos = pli.m_fns.GetHeadPosition();
- while(pos) strTipText += _T("\n") + pli.m_fns.GetNext(pos);
- strTipText.Trim();
-
- if(pli.m_type == CPlaylistItem::device)
- {
- CString str;
- str.Format(_T("Video Input %d"), pli.m_vinput);
- if(pli.m_vinput >= 0) strTipText += _T("\n") + str;
- str.Format(_T("Video Channel %d"), pli.m_vchannel);
- if(pli.m_vchannel >= 0) strTipText += _T("\n") + str;
- str.Format(_T("Audio Input %d"), pli.m_ainput);
- if(pli.m_ainput >= 0) strTipText += _T("\n") + str;
- }
-
- ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
- }
- else if(col == COL_TIME)
- {
- return FALSE;
- }
-
- static CStringA m_strTipTextA;
- static CStringW m_strTipTextW;
-
- if(pNMHDR->code == TTN_NEEDTEXTA)
- {
- m_strTipTextA = strTipText;
- pTTTA->lpszText = (LPSTR)(LPCSTR)m_strTipTextA;
- }
- else
- {
- m_strTipTextW = strTipText;
- pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
- }
-
- *pResult = 0;
-
- return TRUE; // message was handled
+ TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
+ TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
+
+ if((pNMHDR->code == TTN_NEEDTEXTA && (HWND)pTTTA->lParam != m_list.m_hWnd)
+ || (pNMHDR->code == TTN_NEEDTEXTW && (HWND)pTTTW->lParam != m_list.m_hWnd))
+ return FALSE;
+
+ int row = ((pNMHDR->idFrom-1) >> 10) & 0x3fffff;
+ int col = (pNMHDR->idFrom-1) & 0x3ff;
+
+ if(row < 0 || row >= m_pl.GetCount())
+ return FALSE;
+
+ CPlaylistItem& pli = m_pl.GetAt(FindPos(row));
+
+ CString strTipText;
+
+ if(col == COL_NAME)
+ {
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while(pos) strTipText += _T("\n") + pli.m_fns.GetNext(pos);
+ strTipText.Trim();
+
+ if(pli.m_type == CPlaylistItem::device)
+ {
+ CString str;
+ str.Format(_T("Video Input %d"), pli.m_vinput);
+ if(pli.m_vinput >= 0) strTipText += _T("\n") + str;
+ str.Format(_T("Video Channel %d"), pli.m_vchannel);
+ if(pli.m_vchannel >= 0) strTipText += _T("\n") + str;
+ str.Format(_T("Audio Input %d"), pli.m_ainput);
+ if(pli.m_ainput >= 0) strTipText += _T("\n") + str;
+ }
+
+ ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
+ }
+ else if(col == COL_TIME)
+ {
+ return FALSE;
+ }
+
+ static CStringA m_strTipTextA;
+ static CStringW m_strTipTextW;
+
+ if(pNMHDR->code == TTN_NEEDTEXTA)
+ {
+ m_strTipTextA = strTipText;
+ pTTTA->lpszText = (LPSTR)(LPCSTR)m_strTipTextA;
+ }
+ else
+ {
+ m_strTipTextW = strTipText;
+ pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
+ }
+
+ *pResult = 0;
+
+ return TRUE; // message was handled
}
void CPlayerPlaylistBar::OnContextMenu(CWnd* /*pWnd*/, CPoint p)
{
- LVHITTESTINFO lvhti;
- lvhti.pt = p;
- m_list.ScreenToClient(&lvhti.pt);
- m_list.SubItemHitTest(&lvhti);
+ LVHITTESTINFO lvhti;
+ lvhti.pt = p;
+ m_list.ScreenToClient(&lvhti.pt);
+ m_list.SubItemHitTest(&lvhti);
- POSITION pos = FindPos(lvhti.iItem);
+ POSITION pos = FindPos(lvhti.iItem);
// bool fSelected = (pos == m_pl.GetPos());
- bool fOnItem = !!(lvhti.flags & LVHT_ONITEM);
-
- CMenu m;
- m.CreatePopupMenu();
-
- enum
- {
- M_OPEN = 1, M_ADD, M_REMOVE, M_CLIPBOARD, M_SAVEAS,
- M_SORTBYNAME, M_SORTBYPATH, M_RANDOMIZE, M_SORTBYID,
- M_REMEMBERPLAYLIST, M_SHUFFLE, M_HIDEFULLSCREEN
- };
-
- m.AppendMenu(MF_STRING | (!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_OPEN, ResStr(IDS_PLAYLIST_OPEN));
- if(((CMainFrame*)AfxGetMainWnd())->m_iPlaybackMode == PM_CAPTURE) m.AppendMenu(MF_STRING | MF_ENABLED, M_ADD, ResStr(IDS_PLAYLIST_ADD));
- m.AppendMenu(MF_STRING | (/*fSelected||*/!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_REMOVE, ResStr(IDS_PLAYLIST_REMOVE));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | (!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_CLIPBOARD, ResStr(IDS_PLAYLIST_COPYTOCLIPBOARD));
- m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SAVEAS, ResStr(IDS_PLAYLIST_SAVEAS));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYNAME, ResStr(IDS_PLAYLIST_SORTBYLABEL));
- m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYPATH, ResStr(IDS_PLAYLIST_SORTBYPATH));
- m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_RANDOMIZE, ResStr(IDS_PLAYLIST_RANDOMIZE));
- m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYID, ResStr(IDS_PLAYLIST_RESTORE));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | MF_ENABLED | (AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE) ? MF_CHECKED : 0), M_SHUFFLE, ResStr(IDS_PLAYLIST_SHUFFLE));
- m.AppendMenu(MF_STRING | MF_ENABLED | (AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE) ? MF_CHECKED : 0), M_REMEMBERPLAYLIST, ResStr(IDS_PLAYLIST_REMEBERITEMS));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | MF_ENABLED | (AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE) ? MF_CHECKED : 0), M_HIDEFULLSCREEN, ResStr(IDS_PLAYLIST_HIDEFS));
-
- CMainFrame* pMainFrm = (CMainFrame*)AfxGetMainWnd();
-
- int nID = (int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this);
- switch(nID)
- {
- case M_OPEN:
- m_pl.SetPos(pos);
- m_list.Invalidate();
- pMainFrm->OpenCurPlaylistItem();
- break;
- case M_ADD:
- pMainFrm->AddCurDevToPlaylist();
- m_pl.SetPos(m_pl.GetTailPosition());
- break;
- case M_REMOVE:
- if(m_pl.RemoveAt(pos)) pMainFrm->CloseMedia();
- m_list.DeleteItem(lvhti.iItem);
- SavePlaylist();
- break;
- case M_SORTBYID:
- m_pl.SortById();
- SetupList();
- SavePlaylist();
- break;
- case M_SORTBYNAME:
- m_pl.SortByName();
- SetupList();
- SavePlaylist();
- break;
- case M_SORTBYPATH:
- m_pl.SortByPath();
- SetupList();
- SavePlaylist();
- break;
- case M_RANDOMIZE:
- m_pl.Randomize();
- SetupList();
- SavePlaylist();
- break;
- case M_CLIPBOARD:
- if(OpenClipboard() && EmptyClipboard())
- {
- CString str;
-
- CPlaylistItem& pli = m_pl.GetAt(pos);
- POSITION pos = pli.m_fns.GetHeadPosition();
- while(pos) str += _T("\r\n") + pli.m_fns.GetNext(pos);
- str.Trim();
-
- if(HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (str.GetLength() + 1) * sizeof(TCHAR)))
- {
- if(TCHAR* s = (TCHAR*)GlobalLock(h))
- {
- _tcscpy(s, str);
- GlobalUnlock(h);
+ bool fOnItem = !!(lvhti.flags&LVHT_ONITEM);
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ enum
+ {
+ M_OPEN=1, M_ADD, M_REMOVE, M_CLIPBOARD, M_SAVEAS,
+ M_SORTBYNAME, M_SORTBYPATH, M_RANDOMIZE, M_SORTBYID,
+ M_REMEMBERPLAYLIST, M_SHUFFLE, M_HIDEFULLSCREEN
+ };
+
+ m.AppendMenu(MF_STRING|(!fOnItem?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_OPEN, ResStr(IDS_PLAYLIST_OPEN));
+ if(((CMainFrame*)AfxGetMainWnd())->m_iPlaybackMode == PM_CAPTURE) m.AppendMenu(MF_STRING|MF_ENABLED, M_ADD, ResStr(IDS_PLAYLIST_ADD));
+ m.AppendMenu(MF_STRING|(/*fSelected||*/!fOnItem?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_REMOVE, ResStr(IDS_PLAYLIST_REMOVE));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|(!fOnItem?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_CLIPBOARD, ResStr(IDS_PLAYLIST_COPYTOCLIPBOARD));
+ m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SAVEAS, ResStr(IDS_PLAYLIST_SAVEAS));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SORTBYNAME, ResStr(IDS_PLAYLIST_SORTBYLABEL));
+ m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SORTBYPATH, ResStr(IDS_PLAYLIST_SORTBYPATH));
+ m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_RANDOMIZE, ResStr(IDS_PLAYLIST_RANDOMIZE));
+ m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SORTBYID, ResStr(IDS_PLAYLIST_RESTORE));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|MF_ENABLED|(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE)?MF_CHECKED:0), M_SHUFFLE, ResStr(IDS_PLAYLIST_SHUFFLE));
+ m.AppendMenu(MF_STRING|MF_ENABLED|(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE)?MF_CHECKED:0), M_REMEMBERPLAYLIST, ResStr(IDS_PLAYLIST_REMEBERITEMS));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|MF_ENABLED|(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)?MF_CHECKED:0), M_HIDEFULLSCREEN, ResStr(IDS_PLAYLIST_HIDEFS));
+
+ CMainFrame* pMainFrm = (CMainFrame*)AfxGetMainWnd();
+
+ int nID = (int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this);
+ switch(nID)
+ {
+ case M_OPEN:
+ m_pl.SetPos(pos);
+ m_list.Invalidate();
+ pMainFrm->OpenCurPlaylistItem();
+ break;
+ case M_ADD:
+ pMainFrm->AddCurDevToPlaylist();
+ m_pl.SetPos(m_pl.GetTailPosition());
+ break;
+ case M_REMOVE:
+ if(m_pl.RemoveAt(pos)) pMainFrm->CloseMedia();
+ m_list.DeleteItem(lvhti.iItem);
+ SavePlaylist();
+ break;
+ case M_SORTBYID:
+ m_pl.SortById();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_SORTBYNAME:
+ m_pl.SortByName();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_SORTBYPATH:
+ m_pl.SortByPath();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_RANDOMIZE:
+ m_pl.Randomize();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_CLIPBOARD:
+ if(OpenClipboard() && EmptyClipboard())
+ {
+ CString str;
+
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while(pos) str += _T("\r\n") + pli.m_fns.GetNext(pos);
+ str.Trim();
+
+ if(HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (str.GetLength()+1)*sizeof(TCHAR)))
+ {
+ if(TCHAR* s = (TCHAR*)GlobalLock(h))
+ {
+ _tcscpy(s, str);
+ GlobalUnlock(h);
#ifdef UNICODE
- SetClipboardData(CF_UNICODETEXT, h);
+ SetClipboardData(CF_UNICODETEXT, h);
#else
- SetClipboardData(CF_TEXT, h);
+ SetClipboardData(CF_TEXT, h);
#endif
- }
- }
- CloseClipboard();
- }
- break;
- case M_SAVEAS:
- {
- CSaveTextFileDialog fd(
- CTextFile::ASCII, NULL, NULL,
- _T("Media Player Classic playlist (*.mpcpl)|*.mpcpl|Playlist (*.pls)|*.pls|Winamp playlist (*.m3u)|*.m3u|Windows Media playlist (*.asx)|*.asx||"),
- this);
-
- if(fd.DoModal() != IDOK)
- break;
-
- CTextFile::enc encoding = (CTextFile::enc)fd.GetEncoding();
- if(encoding == CTextFile::ASCII) encoding = CTextFile::ANSI;
-
- int idx = fd.m_pOFN->nFilterIndex;
-
- CPath path(fd.GetPathName());
-
- switch(idx)
- {
- case 1:
- path.AddExtension(_T(".mpcpl"));
- break;
- case 2:
- path.AddExtension(_T(".pls"));
- break;
- case 3:
- path.AddExtension(_T(".m3u"));
- break;
- case 4:
- path.AddExtension(_T(".asx"));
- break;
- default:
- break;
- }
-
- bool fRemovePath = true;
-
- CPath p(path);
- p.RemoveFileSpec();
- CString base = (LPCTSTR)p;
-
- pos = m_pl.GetHeadPosition();
- while(pos && fRemovePath)
- {
- CPlaylistItem& pli = m_pl.GetNext(pos);
-
- if(pli.m_type != CPlaylistItem::file) fRemovePath = false;
- else
- {
- POSITION pos;
-
- pos = pli.m_fns.GetHeadPosition();
- while(pos && fRemovePath)
- {
- CString fn = pli.m_fns.GetNext(pos);
-
- CPath p(fn);
- p.RemoveFileSpec();
- if(base != (LPCTSTR)p) fRemovePath = false;
- }
-
- pos = pli.m_subs.GetHeadPosition();
- while(pos && fRemovePath)
- {
- CString fn = pli.m_subs.GetNext(pos);
-
- CPath p(fn);
- p.RemoveFileSpec();
- if(base != (LPCTSTR)p) fRemovePath = false;
- }
- }
- }
-
- if(idx == 1)
- {
- SaveMPCPlayList(path, encoding, fRemovePath);
- break;
- }
-
- CTextFile f;
- if(!f.Save(path, encoding))
- break;
-
- if(idx == 2)
- {
- f.WriteString(_T("[playlist]\n"));
- }
- else if(idx == 4)
- {
- f.WriteString(_T("<ASX version = \"3.0\">\n"));
- }
-
- pos = m_pl.GetHeadPosition();
- CString str;
- int i;
- for(i = 0; pos; i++)
- {
- CPlaylistItem& pli = m_pl.GetNext(pos);
-
- if(pli.m_type != CPlaylistItem::file)
- continue;
-
- CString fn = pli.m_fns.GetHead();
-
- /*
- if(fRemovePath)
- {
- CPath p(path);
- p.StripPath();
- fn = (LPCTSTR)p;
- }
- */
-
- switch(idx)
- {
- case 2:
- str.Format(_T("File%d=%s\n"), i + 1, fn);
- break;
- case 3:
- str.Format(_T("%s\n"), fn);
- break;
- case 4:
- str.Format(_T("<Entry><Ref href = \"%s\"/></Entry>\n"), fn);
- break;
- default:
- break;
- }
- f.WriteString(str);
- }
-
- if(idx == 2)
- {
- str.Format(_T("NumberOfEntries=%d\n"), i);
- f.WriteString(str);
- f.WriteString(_T("Version=2\n"));
- }
- else if(idx == 4)
- {
- f.WriteString(_T("</ASX>\n"));
- }
- }
- break;
- case M_REMEMBERPLAYLIST:
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"),
- !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE));
- break;
- case M_SHUFFLE:
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"),
- !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE));
- break;
- case M_HIDEFULLSCREEN:
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"),
- !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE));
- break;
- default:
- break;
- }
+ }
+ }
+ CloseClipboard();
+ }
+ break;
+ case M_SAVEAS:
+ {
+ CSaveTextFileDialog fd(
+ CTextFile::ASCII, NULL, NULL,
+ _T("Media Player Classic playlist (*.mpcpl)|*.mpcpl|Playlist (*.pls)|*.pls|Winamp playlist (*.m3u)|*.m3u|Windows Media playlist (*.asx)|*.asx||"),
+ this);
+
+ if(fd.DoModal() != IDOK)
+ break;
+
+ CTextFile::enc encoding = (CTextFile::enc)fd.GetEncoding();
+ if(encoding == CTextFile::ASCII) encoding = CTextFile::ANSI;
+
+ int idx = fd.m_pOFN->nFilterIndex;
+
+ CPath path(fd.GetPathName());
+
+ switch(idx)
+ {
+ case 1: path.AddExtension(_T(".mpcpl")); break;
+ case 2: path.AddExtension(_T(".pls")); break;
+ case 3: path.AddExtension(_T(".m3u")); break;
+ case 4: path.AddExtension(_T(".asx")); break;
+ default: break;
+ }
+
+ bool fRemovePath = true;
+
+ CPath p(path);
+ p.RemoveFileSpec();
+ CString base = (LPCTSTR)p;
+
+ pos = m_pl.GetHeadPosition();
+ while(pos && fRemovePath)
+ {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
+
+ if(pli.m_type != CPlaylistItem::file) fRemovePath = false;
+ else
+ {
+ POSITION pos;
+
+ pos = pli.m_fns.GetHeadPosition();
+ while(pos && fRemovePath)
+ {
+ CString fn = pli.m_fns.GetNext(pos);
+
+ CPath p(fn);
+ p.RemoveFileSpec();
+ if(base != (LPCTSTR)p) fRemovePath = false;
+ }
+
+ pos = pli.m_subs.GetHeadPosition();
+ while(pos && fRemovePath)
+ {
+ CString fn = pli.m_subs.GetNext(pos);
+
+ CPath p(fn);
+ p.RemoveFileSpec();
+ if(base != (LPCTSTR)p) fRemovePath = false;
+ }
+ }
+ }
+
+ if(idx == 1)
+ {
+ SaveMPCPlayList(path, encoding, fRemovePath);
+ break;
+ }
+
+ CTextFile f;
+ if(!f.Save(path, encoding))
+ break;
+
+ if (idx == 2)
+ {
+ f.WriteString(_T("[playlist]\n"));
+ }
+ else if (idx == 4)
+ {
+ f.WriteString(_T("<ASX version = \"3.0\">\n"));
+ }
+
+ pos = m_pl.GetHeadPosition();
+ CString str;
+ int i;
+ for(i = 0; pos; i++)
+ {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
+
+ if(pli.m_type != CPlaylistItem::file)
+ continue;
+
+ CString fn = pli.m_fns.GetHead();
+
+ /*
+ if(fRemovePath)
+ {
+ CPath p(path);
+ p.StripPath();
+ fn = (LPCTSTR)p;
+ }
+ */
+
+ switch(idx)
+ {
+ case 2: str.Format(_T("File%d=%s\n"), i+1, fn); break;
+ case 3: str.Format(_T("%s\n"), fn); break;
+ case 4: str.Format(_T("<Entry><Ref href = \"%s\"/></Entry>\n"), fn); break;
+ default: break;
+ }
+ f.WriteString(str);
+ }
+
+ if (idx == 2)
+ {
+ str.Format(_T("NumberOfEntries=%d\n"), i);
+ f.WriteString(str);
+ f.WriteString(_T("Version=2\n"));
+ }
+ else if (idx == 4)
+ {
+ f.WriteString(_T("</ASX>\n"));
+ }
+ }
+ break;
+ case M_REMEMBERPLAYLIST:
+ AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"),
+ !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE));
+ break;
+ case M_SHUFFLE:
+ AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"),
+ !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE));
+ break;
+ case M_HIDEFULLSCREEN:
+ AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"),
+ !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE));
+ break;
+ default:
+ break;
+ }
}
void CPlayerPlaylistBar::OnLvnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
+ NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
- if(pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText)
- {
- CPlaylistItem& pli = m_pl.GetAt((POSITION)m_list.GetItemData(pDispInfo->item.iItem));
- pli.m_label = pDispInfo->item.pszText;
- m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
- }
+ if(pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText)
+ {
+ CPlaylistItem& pli = m_pl.GetAt((POSITION)m_list.GetItemData(pDispInfo->item.iItem));
+ pli.m_label = pDispInfo->item.pszText;
+ m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
+ }
- *pResult = 0;
+ *pResult = 0;
} \ No newline at end of file
diff --git a/src/apps/mplayerc/PlayerPlaylistBar.h b/src/apps/mplayerc/PlayerPlaylistBar.h
index 578fd0d8e..147ed1207 100644
--- a/src/apps/mplayerc/PlayerPlaylistBar.h
+++ b/src/apps/mplayerc/PlayerPlaylistBar.h
@@ -32,100 +32,100 @@ class OpenMediaData;
class CPlayerPlaylistBar : public CSizingControlBarG
{
- DECLARE_DYNAMIC(CPlayerPlaylistBar)
+ DECLARE_DYNAMIC(CPlayerPlaylistBar)
private:
- enum {COL_NAME, COL_TIME};
+ enum {COL_NAME, COL_TIME};
- CImageList m_fakeImageList;
- CPlayerListCtrl m_list;
+ CImageList m_fakeImageList;
+ CPlayerListCtrl m_list;
- int m_nTimeColWidth;
- void ResizeListColumn();
+ int m_nTimeColWidth;
+ void ResizeListColumn();
- void AddItem(CString fn, CAtlList<CString>* subs);
- void AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs);
- void ParsePlayList(CString fn, CAtlList<CString>* subs);
- void ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs);
- void ResolveLinkFiles(CAtlList<CString> &fns);
+ void AddItem(CString fn, CAtlList<CString>* subs);
+ void AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs);
+ void ParsePlayList(CString fn, CAtlList<CString>* subs);
+ void ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs);
+ void ResolveLinkFiles( CAtlList<CString> &fns );
- bool ParseBDMVPlayList(CString fn);
+ bool ParseBDMVPlayList(CString fn);
- bool ParseMPCPlayList(CString fn);
- bool SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath);
+ bool ParseMPCPlayList(CString fn);
+ bool SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath);
- void SetupList();
- void UpdateList();
- void EnsureVisible(POSITION pos);
- int FindItem(POSITION pos);
- POSITION FindPos(int i);
+ void SetupList();
+ void UpdateList();
+ void EnsureVisible(POSITION pos);
+ int FindItem(POSITION pos);
+ POSITION FindPos(int i);
- CImageList* m_pDragImage;
- BOOL m_bDragging;
- int m_nDragIndex, m_nDropIndex;
- CPoint m_ptDropPoint;
+ CImageList* m_pDragImage;
+ BOOL m_bDragging;
+ int m_nDragIndex, m_nDropIndex;
+ CPoint m_ptDropPoint;
- void DropItemOnList();
+ void DropItemOnList();
public:
- CPlayerPlaylistBar();
- virtual ~CPlayerPlaylistBar();
+ CPlayerPlaylistBar();
+ virtual ~CPlayerPlaylistBar();
- BOOL Create(CWnd* pParentWnd);
+ BOOL Create(CWnd* pParentWnd);
- CPlaylist m_pl;
+ CPlaylist m_pl;
- int GetCount();
- int GetSelIdx();
- void SetSelIdx(int i);
- bool IsAtEnd();
- bool GetCur(CPlaylistItem& pli);
- CString GetCur();
- void SetNext();
- void SetPrev();
- void SetFirstSelected();
- void SetFirst();
- void SetLast();
- void SetCurValid(bool fValid);
- void SetCurTime(REFERENCE_TIME rt);
+ int GetCount();
+ int GetSelIdx();
+ void SetSelIdx(int i);
+ bool IsAtEnd();
+ bool GetCur(CPlaylistItem& pli);
+ CString GetCur();
+ void SetNext();
+ void SetPrev();
+ void SetFirstSelected();
+ void SetFirst();
+ void SetLast();
+ void SetCurValid(bool fValid);
+ void SetCurTime(REFERENCE_TIME rt);
- void Refresh();
- void Empty();
+ void Refresh();
+ void Empty();
- void Open(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
- void Append(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
+ void Open(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
+ void Append(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
- void Open(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
- void Append(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
+ void Open(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
+ void Append(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
- OpenMediaData* GetCurOMD(REFERENCE_TIME rtStart = 0);
+ OpenMediaData* GetCurOMD(REFERENCE_TIME rtStart = 0);
- void LoadPlaylist(LPCTSTR filename);
- void SavePlaylist();
+ void LoadPlaylist(LPCTSTR filename);
+ void SavePlaylist();
- bool SelectFileInPlaylist(LPCTSTR filename);
+ bool SelectFileInPlaylist(LPCTSTR filename);
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
// afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg BOOL OnFileClosePlaylist(UINT nID);
- afx_msg BOOL OnPlayPlay(UINT nID);
- afx_msg void OnDropFiles(HDROP hDropInfo);
- afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
- afx_msg void OnLvnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg BOOL OnFileClosePlaylist(UINT nID);
+ afx_msg BOOL OnPlayPlay(UINT nID);
+ afx_msg void OnDropFiles(HDROP hDropInfo);
+ afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
+ afx_msg void OnLvnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/apps/mplayerc/PlayerSeekBar.cpp b/src/apps/mplayerc/PlayerSeekBar.cpp
index b30b97614..e6ad3d347 100644
--- a/src/apps/mplayerc/PlayerSeekBar.cpp
+++ b/src/apps/mplayerc/PlayerSeekBar.cpp
@@ -31,9 +31,9 @@
IMPLEMENT_DYNAMIC(CPlayerSeekBar, CDialogBar)
-CPlayerSeekBar::CPlayerSeekBar() :
- m_start(0), m_stop(100), m_pos(0), m_posreal(0),
- m_fEnabled(false)
+CPlayerSeekBar::CPlayerSeekBar() :
+ m_start(0), m_stop(100), m_pos(0), m_posreal(0),
+ m_fEnabled(false)
{
}
@@ -43,141 +43,141 @@ CPlayerSeekBar::~CPlayerSeekBar()
BOOL CPlayerSeekBar::Create(CWnd* pParentWnd)
{
- if(!CDialogBar::Create(pParentWnd, IDD_PLAYERSEEKBAR, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM, IDD_PLAYERSEEKBAR))
- return FALSE;
+ if(!CDialogBar::Create(pParentWnd, IDD_PLAYERSEEKBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERSEEKBAR))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSeekBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CDialogBar::PreCreateWindow(cs))
- return FALSE;
+ if(!CDialogBar::PreCreateWindow(cs))
+ return FALSE;
- m_dwStyle &= ~CBRS_BORDER_TOP;
- m_dwStyle &= ~CBRS_BORDER_BOTTOM;
- m_dwStyle |= CBRS_SIZE_FIXED;
+ m_dwStyle &= ~CBRS_BORDER_TOP;
+ m_dwStyle &= ~CBRS_BORDER_BOTTOM;
+ m_dwStyle |= CBRS_SIZE_FIXED;
- return TRUE;
+ return TRUE;
}
void CPlayerSeekBar::Enable(bool fEnable)
{
- m_fEnabled = fEnable;
- Invalidate();
+ m_fEnabled = fEnable;
+ Invalidate();
}
void CPlayerSeekBar::GetRange(__int64& start, __int64& stop)
{
- start = m_start;
- stop = m_stop;
+ start = m_start;
+ stop = m_stop;
}
-void CPlayerSeekBar::SetRange(__int64 start, __int64 stop)
+void CPlayerSeekBar::SetRange(__int64 start, __int64 stop)
{
- if(start > stop) start ^= stop, stop ^= start, start ^= stop;
- m_start = start;
- m_stop = stop;
- if(m_pos < m_start || m_pos >= m_stop) SetPos(m_start);
+ if(start > stop) start ^= stop, stop ^= start, start ^= stop;
+ m_start = start;
+ m_stop = stop;
+ if(m_pos < m_start || m_pos >= m_stop) SetPos(m_start);
}
__int64 CPlayerSeekBar::GetPos()
{
- return(m_pos);
+ return(m_pos);
}
__int64 CPlayerSeekBar::GetPosReal()
{
- return(m_posreal);
+ return(m_posreal);
}
void CPlayerSeekBar::SetPos(__int64 pos)
{
- CWnd* w = GetCapture();
- if(w && w->m_hWnd == m_hWnd) return;
+ CWnd* w = GetCapture();
+ if(w && w->m_hWnd == m_hWnd) return;
- SetPosInternal(pos);
+ SetPosInternal(pos);
}
void CPlayerSeekBar::SetPosInternal(__int64 pos)
{
- if(m_pos == pos) return;
-
- CRect before = GetThumbRect();
- m_pos = min(max(pos, m_start), m_stop);
- m_posreal = pos;
- CRect after = GetThumbRect();
-
- if(before != after)
- {
- InvalidateRect(before | after);
-
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if((AfxGetAppSettings().m_fUseWin7TaskBar) && (pFrame->m_pTaskbarList))
- pFrame->m_pTaskbarList->SetProgressValue(pFrame->m_hWnd, pos, m_stop);
- }
+ if(m_pos == pos) return;
+
+ CRect before = GetThumbRect();
+ m_pos = min(max(pos, m_start), m_stop);
+ m_posreal = pos;
+ CRect after = GetThumbRect();
+
+ if(before != after)
+ {
+ InvalidateRect(before | after);
+
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if((AfxGetAppSettings().m_fUseWin7TaskBar)&&(pFrame->m_pTaskbarList))
+ pFrame->m_pTaskbarList->SetProgressValue ( pFrame->m_hWnd, pos, m_stop );
+ }
}
CRect CPlayerSeekBar::GetChannelRect()
{
- CRect r;
- GetClientRect(&r);
- r.DeflateRect(8, 9, 9, 0);
- r.bottom = r.top + 5;
- return(r);
+ CRect r;
+ GetClientRect(&r);
+ r.DeflateRect(8, 9, 9, 0);
+ r.bottom = r.top + 5;
+ return(r);
}
CRect CPlayerSeekBar::GetThumbRect()
{
// bool fEnabled = m_fEnabled || m_start >= m_stop;
- CRect r = GetChannelRect();
+ CRect r = GetChannelRect();
- int x = r.left + (int)((m_start < m_stop /*&& fEnabled*/) ? (__int64)r.Width() * (m_pos - m_start) / (m_stop - m_start) : 0);
- int y = r.CenterPoint().y;
+ int x = r.left + (int)((m_start < m_stop /*&& fEnabled*/) ? (__int64)r.Width() * (m_pos - m_start) / (m_stop - m_start) : 0);
+ int y = r.CenterPoint().y;
- r.SetRect(x, y, x, y);
- r.InflateRect(6, 7, 7, 8);
+ r.SetRect(x, y, x, y);
+ r.InflateRect(6, 7, 7, 8);
- return(r);
+ return(r);
}
CRect CPlayerSeekBar::GetInnerThumbRect()
{
- CRect r = GetThumbRect();
+ CRect r = GetThumbRect();
- bool fEnabled = m_fEnabled && m_start < m_stop;
- r.DeflateRect(3, fEnabled ? 5 : 4, 3, fEnabled ? 5 : 4);
+ bool fEnabled = m_fEnabled && m_start < m_stop;
+ r.DeflateRect(3, fEnabled ? 5 : 4, 3, fEnabled ? 5 : 4);
- return(r);
+ return(r);
}
void CPlayerSeekBar::MoveThumb(CPoint point)
{
- CRect r = GetChannelRect();
-
- if(r.left >= r.right) return;
-
- if(point.x < r.left) SetPos(m_start);
- else if(point.x >= r.right) SetPos(m_stop);
- else
- {
- __int64 w = r.right - r.left;
- if(m_start < m_stop)
- SetPosInternal(m_start + ((m_stop - m_start) *(point.x - r.left) + (w / 2)) / w);
- }
+ CRect r = GetChannelRect();
+
+ if(r.left >= r.right) return;
+
+ if(point.x < r.left) SetPos(m_start);
+ else if(point.x >= r.right) SetPos(m_stop);
+ else
+ {
+ __int64 w = r.right - r.left;
+ if(m_start < m_stop)
+ SetPosInternal(m_start + ((m_stop - m_start) * (point.x - r.left) + (w/2)) / w);
+ }
}
BEGIN_MESSAGE_MAP(CPlayerSeekBar, CDialogBar)
- //{{AFX_MSG_MAP(CPlayerSeekBar)
- ON_WM_PAINT()
- ON_WM_SIZE()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_MOUSEMOVE()
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- ON_COMMAND_EX(ID_PLAY_STOP, OnPlayStop)
+ //{{AFX_MSG_MAP(CPlayerSeekBar)
+ ON_WM_PAINT()
+ ON_WM_SIZE()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_LBUTTONUP()
+ ON_WM_MOUSEMOVE()
+ ON_WM_ERASEBKGND()
+ //}}AFX_MSG_MAP
+ ON_COMMAND_EX(ID_PLAY_STOP, OnPlayStop)
END_MESSAGE_MAP()
@@ -185,128 +185,128 @@ END_MESSAGE_MAP()
void CPlayerSeekBar::OnPaint()
{
- CPaintDC dc(this); // device context for painting
-
- bool fEnabled = m_fEnabled && m_start < m_stop;
-
- COLORREF
- white = GetSysColor(COLOR_WINDOW),
- shadow = GetSysColor(COLOR_3DSHADOW),
- light = GetSysColor(COLOR_3DHILIGHT),
- bkg = GetSysColor(COLOR_BTNFACE);
-
- // thumb
- {
- CRect r = GetThumbRect(), r2 = GetInnerThumbRect();
- CRect rt = r, rit = r2;
-
- dc.Draw3dRect(&r, light, 0);
- r.DeflateRect(0, 0, 1, 1);
- dc.Draw3dRect(&r, light, shadow);
- r.DeflateRect(1, 1, 1, 1);
-
- CBrush b(bkg);
-
- dc.FrameRect(&r, &b);
- r.DeflateRect(0, 1, 0, 1);
- dc.FrameRect(&r, &b);
-
- r.DeflateRect(1, 1, 0, 0);
- dc.Draw3dRect(&r, shadow, bkg);
-
- if(fEnabled)
- {
- r.DeflateRect(1, 1, 1, 2);
- CPen white(PS_INSIDEFRAME, 1, white);
- CPen* old = dc.SelectObject(&white);
- dc.MoveTo(r.left, r.top);
- dc.LineTo(r.right, r.top);
- dc.MoveTo(r.left, r.bottom);
- dc.LineTo(r.right, r.bottom);
- dc.SelectObject(old);
- dc.SetPixel(r.CenterPoint().x, r.top, 0);
- dc.SetPixel(r.CenterPoint().x, r.bottom, 0);
- }
-
- dc.SetPixel(r.CenterPoint().x + 5, r.top - 4, bkg);
-
- {
- CRgn rgn1, rgn2;
- rgn1.CreateRectRgnIndirect(&rt);
- rgn2.CreateRectRgnIndirect(&rit);
- ExtSelectClipRgn(dc, rgn1, RGN_DIFF);
- ExtSelectClipRgn(dc, rgn2, RGN_OR);
- }
- }
-
- // channel
- {
- CRect r = GetChannelRect();
-
- dc.FillSolidRect(&r, fEnabled ? white : bkg);
- r.InflateRect(1, 1);
- dc.Draw3dRect(&r, shadow, light);
- dc.ExcludeClipRect(&r);
- }
-
- // background
- {
- CRect r;
- GetClientRect(&r);
- CBrush b(bkg);
- dc.FillRect(&r, &b);
- }
-
-
- // Do not call CDialogBar::OnPaint() for painting messages
+ CPaintDC dc(this); // device context for painting
+
+ bool fEnabled = m_fEnabled && m_start < m_stop;
+
+ COLORREF
+ white = GetSysColor(COLOR_WINDOW),
+ shadow = GetSysColor(COLOR_3DSHADOW),
+ light = GetSysColor(COLOR_3DHILIGHT),
+ bkg = GetSysColor(COLOR_BTNFACE);
+
+ // thumb
+ {
+ CRect r = GetThumbRect(), r2 = GetInnerThumbRect();
+ CRect rt = r, rit = r2;
+
+ dc.Draw3dRect(&r, light, 0);
+ r.DeflateRect(0, 0, 1, 1);
+ dc.Draw3dRect(&r, light, shadow);
+ r.DeflateRect(1, 1, 1, 1);
+
+ CBrush b(bkg);
+
+ dc.FrameRect(&r, &b);
+ r.DeflateRect(0, 1, 0, 1);
+ dc.FrameRect(&r, &b);
+
+ r.DeflateRect(1, 1, 0, 0);
+ dc.Draw3dRect(&r, shadow, bkg);
+
+ if(fEnabled)
+ {
+ r.DeflateRect(1, 1, 1, 2);
+ CPen white(PS_INSIDEFRAME, 1, white);
+ CPen* old = dc.SelectObject(&white);
+ dc.MoveTo(r.left, r.top);
+ dc.LineTo(r.right, r.top);
+ dc.MoveTo(r.left, r.bottom);
+ dc.LineTo(r.right, r.bottom);
+ dc.SelectObject(old);
+ dc.SetPixel(r.CenterPoint().x, r.top, 0);
+ dc.SetPixel(r.CenterPoint().x, r.bottom, 0);
+ }
+
+ dc.SetPixel(r.CenterPoint().x+5, r.top-4, bkg);
+
+ {
+ CRgn rgn1, rgn2;
+ rgn1.CreateRectRgnIndirect(&rt);
+ rgn2.CreateRectRgnIndirect(&rit);
+ ExtSelectClipRgn(dc, rgn1, RGN_DIFF);
+ ExtSelectClipRgn(dc, rgn2, RGN_OR);
+ }
+ }
+
+ // channel
+ {
+ CRect r = GetChannelRect();
+
+ dc.FillSolidRect(&r, fEnabled ? white : bkg);
+ r.InflateRect(1, 1);
+ dc.Draw3dRect(&r, shadow, light);
+ dc.ExcludeClipRect(&r);
+ }
+
+ // background
+ {
+ CRect r;
+ GetClientRect(&r);
+ CBrush b(bkg);
+ dc.FillRect(&r, &b);
+ }
+
+
+ // Do not call CDialogBar::OnPaint() for painting messages
}
void CPlayerSeekBar::OnSize(UINT nType, int cx, int cy)
{
- CDialogBar::OnSize(nType, cx, cy);
+ CDialogBar::OnSize(nType, cx, cy);
- Invalidate();
+ Invalidate();
}
void CPlayerSeekBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- if(m_fEnabled && (GetChannelRect() | GetThumbRect()).PtInRect(point))
- {
- SetCapture();
- MoveThumb(point);
- GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBPOSITION), (LPARAM)m_hWnd);
- }
-
- CDialogBar::OnLButtonDown(nFlags, point);
+ if(m_fEnabled && (GetChannelRect() | GetThumbRect()).PtInRect(point))
+ {
+ SetCapture();
+ MoveThumb(point);
+ GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBPOSITION), (LPARAM)m_hWnd);
+ }
+
+ CDialogBar::OnLButtonDown(nFlags, point);
}
void CPlayerSeekBar::OnLButtonUp(UINT nFlags, CPoint point)
{
- ReleaseCapture();
+ ReleaseCapture();
- CDialogBar::OnLButtonUp(nFlags, point);
+ CDialogBar::OnLButtonUp(nFlags, point);
}
void CPlayerSeekBar::OnMouseMove(UINT nFlags, CPoint point)
{
- CWnd* w = GetCapture();
- if(w && w->m_hWnd == m_hWnd && (nFlags & MK_LBUTTON))
- {
- MoveThumb(point);
- GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBTRACK), (LPARAM)m_hWnd);
- }
-
- CDialogBar::OnMouseMove(nFlags, point);
+ CWnd* w = GetCapture();
+ if(w && w->m_hWnd == m_hWnd && (nFlags & MK_LBUTTON))
+ {
+ MoveThumb(point);
+ GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBTRACK), (LPARAM)m_hWnd);
+ }
+
+ CDialogBar::OnMouseMove(nFlags, point);
}
BOOL CPlayerSeekBar::OnEraseBkgnd(CDC* pDC)
{
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSeekBar::OnPlayStop(UINT nID)
{
- SetPos(0);
- return FALSE;
+ SetPos(0);
+ return FALSE;
}
diff --git a/src/apps/mplayerc/PlayerSeekBar.h b/src/apps/mplayerc/PlayerSeekBar.h
index 896ebd04c..a19fb72ca 100644
--- a/src/apps/mplayerc/PlayerSeekBar.h
+++ b/src/apps/mplayerc/PlayerSeekBar.h
@@ -27,49 +27,49 @@
class CPlayerSeekBar : public CDialogBar
{
- DECLARE_DYNAMIC(CPlayerSeekBar)
+ DECLARE_DYNAMIC(CPlayerSeekBar)
private:
- __int64 m_start, m_stop, m_pos, m_posreal;
- bool m_fEnabled;
+ __int64 m_start, m_stop, m_pos, m_posreal;
+ bool m_fEnabled;
+
+ void MoveThumb(CPoint point);
+ void SetPosInternal(__int64 pos);
- void MoveThumb(CPoint point);
- void SetPosInternal(__int64 pos);
-
- CRect GetChannelRect();
- CRect GetThumbRect();
- CRect GetInnerThumbRect();
+ CRect GetChannelRect();
+ CRect GetThumbRect();
+ CRect GetInnerThumbRect();
public:
- CPlayerSeekBar();
- virtual ~CPlayerSeekBar();
+ CPlayerSeekBar();
+ virtual ~CPlayerSeekBar();
- void Enable(bool fEnable);
+ void Enable(bool fEnable);
- void GetRange(__int64& start, __int64& stop);
- void SetRange(__int64 start, __int64 stop);
- __int64 GetPos(), GetPosReal();
- void SetPos(__int64 pos);
+ void GetRange(__int64& start, __int64& stop);
+ void SetRange(__int64 start, __int64 stop);
+ __int64 GetPos(), GetPosReal();
+ void SetPos(__int64 pos);
// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CPlayerSeekBar)
- virtual BOOL Create(CWnd* pParentWnd);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- //}}AFX_VIRTUAL
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CPlayerSeekBar)
+ virtual BOOL Create(CWnd* pParentWnd);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ //}}AFX_VIRTUAL
// Generated message map functions
protected:
- //{{AFX_MSG(CPlayerSeekBar)
- afx_msg void OnPaint();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CPlayerSeekBar)
+ afx_msg void OnPaint();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg BOOL OnPlayStop(UINT nID);
+ afx_msg BOOL OnPlayStop(UINT nID);
};
diff --git a/src/apps/mplayerc/PlayerShaderEditorBar.cpp b/src/apps/mplayerc/PlayerShaderEditorBar.cpp
index a456c3539..84b6742e4 100644
--- a/src/apps/mplayerc/PlayerShaderEditorBar.cpp
+++ b/src/apps/mplayerc/PlayerShaderEditorBar.cpp
@@ -38,47 +38,47 @@ CPlayerShaderEditorBar::~CPlayerShaderEditorBar()
BOOL CPlayerShaderEditorBar::Create(CWnd* pParentWnd)
{
- if(!__super::Create(ResStr(IDS_AG_SHADER_EDITOR), pParentWnd, 0))
- return FALSE;
+ if(!__super::Create(ResStr(IDS_AG_SHADER_EDITOR), pParentWnd, 0))
+ return FALSE;
- m_dlg.Create(this);
- m_dlg.ShowWindow(SW_SHOWNORMAL);
+ m_dlg.Create(this);
+ m_dlg.ShowWindow(SW_SHOWNORMAL);
- CRect r;
- m_dlg.GetWindowRect(r);
- m_szMinVert = m_szVert = r.Size();
- m_szMinHorz = m_szHorz = r.Size();
- m_szMinFloat = m_szFloat = r.Size();
- m_bFixedFloat = false;
+ CRect r;
+ m_dlg.GetWindowRect(r);
+ m_szMinVert = m_szVert = r.Size();
+ m_szMinHorz = m_szHorz = r.Size();
+ m_szMinFloat = m_szFloat = r.Size();
+ m_bFixedFloat = false;
- return TRUE;
+ return TRUE;
}
BOOL CPlayerShaderEditorBar::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
- {
- if(IsDialogMessage(pMsg))
- return TRUE;
- }
+ if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
+ {
+ if(IsDialogMessage(pMsg))
+ return TRUE;
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerShaderEditorBar, baseCPlayerShaderEditorBar)
- ON_WM_SIZE()
+ ON_WM_SIZE()
END_MESSAGE_MAP()
// CPlayerShaderEditorBar message handlers
void CPlayerShaderEditorBar::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- if(::IsWindow(m_dlg.m_hWnd))
- {
- CRect r;
- GetClientRect(r);
- m_dlg.MoveWindow(r);
- }
+ if(::IsWindow(m_dlg.m_hWnd))
+ {
+ CRect r;
+ GetClientRect(r);
+ m_dlg.MoveWindow(r);
+ }
}
diff --git a/src/apps/mplayerc/PlayerShaderEditorBar.h b/src/apps/mplayerc/PlayerShaderEditorBar.h
index 5afecc9ed..e68d467d5 100644
--- a/src/apps/mplayerc/PlayerShaderEditorBar.h
+++ b/src/apps/mplayerc/PlayerShaderEditorBar.h
@@ -34,22 +34,22 @@
class CPlayerShaderEditorBar : public baseCPlayerShaderEditorBar
{
- DECLARE_DYNAMIC(CPlayerShaderEditorBar)
+ DECLARE_DYNAMIC(CPlayerShaderEditorBar)
public:
- CPlayerShaderEditorBar();
- virtual ~CPlayerShaderEditorBar();
+ CPlayerShaderEditorBar();
+ virtual ~CPlayerShaderEditorBar();
- BOOL Create(CWnd* pParentWnd);
+ BOOL Create(CWnd* pParentWnd);
public:
- CShaderEditorDlg m_dlg;
+ CShaderEditorDlg m_dlg;
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
};
diff --git a/src/apps/mplayerc/PlayerStatusBar.cpp b/src/apps/mplayerc/PlayerStatusBar.cpp
index e83ecffa0..1e984bfd9 100644
--- a/src/apps/mplayerc/PlayerStatusBar.cpp
+++ b/src/apps/mplayerc/PlayerStatusBar.cpp
@@ -32,211 +32,211 @@
IMPLEMENT_DYNAMIC(CPlayerStatusBar, CDialogBar)
-CPlayerStatusBar::CPlayerStatusBar()
- : m_status(false, false)
- , m_time(true, false)
- , m_bmid(0)
- , m_hIcon(0)
+CPlayerStatusBar::CPlayerStatusBar()
+ : m_status(false, false)
+ , m_time(true, false)
+ , m_bmid(0)
+ , m_hIcon(0)
{
}
CPlayerStatusBar::~CPlayerStatusBar()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) DestroyIcon(m_hIcon);
}
BOOL CPlayerStatusBar::Create(CWnd* pParentWnd)
{
- return CDialogBar::Create(pParentWnd, IDD_PLAYERSTATUSBAR, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM, IDD_PLAYERSTATUSBAR);
+ return CDialogBar::Create(pParentWnd, IDD_PLAYERSTATUSBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERSTATUSBAR);
}
BOOL CPlayerStatusBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CDialogBar::PreCreateWindow(cs))
- return FALSE;
+ if(!CDialogBar::PreCreateWindow(cs))
+ return FALSE;
- m_dwStyle &= ~CBRS_BORDER_TOP;
- m_dwStyle &= ~CBRS_BORDER_BOTTOM;
+ m_dwStyle &= ~CBRS_BORDER_TOP;
+ m_dwStyle &= ~CBRS_BORDER_BOTTOM;
- return TRUE;
+ return TRUE;
}
int CPlayerStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CDialogBar::OnCreate(lpCreateStruct) == -1)
- return -1;
+ if(CDialogBar::OnCreate(lpCreateStruct) == -1)
+ return -1;
- CRect r;
- r.SetRectEmpty();
+ CRect r;
+ r.SetRectEmpty();
- m_type.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_ICON,
- r, this, IDC_STATIC1);
+ m_type.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_ICON,
+ r, this, IDC_STATIC1);
- m_status.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_OWNERDRAW,
- r, this, IDC_PLAYERSTATUS);
+ m_status.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
+ r, this, IDC_PLAYERSTATUS);
- m_time.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_OWNERDRAW,
- r, this, IDC_PLAYERTIME);
+ m_time.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
+ r, this, IDC_PLAYERTIME);
- m_status.SetWindowPos(&m_time, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ m_status.SetWindowPos(&m_time, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
- Relayout();
+ Relayout();
- return 0;
+ return 0;
}
void CPlayerStatusBar::Relayout()
{
- BITMAP bm;
- memset(&bm, 0, sizeof(bm));
- if(m_bm.m_hObject) m_bm.GetBitmap(&bm);
-
- CRect r, r2;
- GetClientRect(r);
-
- r.DeflateRect(27, 5, bm.bmWidth + 8, 4);
- int div = r.right - (m_time.IsWindowVisible() ? 140 : 0);
-
- CString str;
- m_time.GetWindowText(str);
- if(CDC* pDC = m_time.GetDC())
- {
- CFont* pOld = pDC->SelectObject(&m_time.GetFont());
- div = r.right - pDC->GetTextExtent(str).cx;
- pDC->SelectObject(pOld);
- m_time.ReleaseDC(pDC);
- }
-
- r2 = r;
- r2.right = div - 2;
- m_status.MoveWindow(&r2);
-
- r2 = r;
- r2.left = div;
- m_time.MoveWindow(&r2);
-
- GetClientRect(r);
- r.SetRect(6, r.top + 4, 22, r.bottom - 4);
- m_type.MoveWindow(r);
-
- Invalidate();
+ BITMAP bm;
+ memset(&bm, 0, sizeof(bm));
+ if(m_bm.m_hObject) m_bm.GetBitmap(&bm);
+
+ CRect r, r2;
+ GetClientRect(r);
+
+ r.DeflateRect(27, 5, bm.bmWidth + 8, 4);
+ int div = r.right - (m_time.IsWindowVisible() ? 140 : 0);
+
+ CString str;
+ m_time.GetWindowText(str);
+ if(CDC* pDC = m_time.GetDC())
+ {
+ CFont* pOld = pDC->SelectObject(&m_time.GetFont());
+ div = r.right - pDC->GetTextExtent(str).cx;
+ pDC->SelectObject(pOld);
+ m_time.ReleaseDC(pDC);
+ }
+
+ r2 = r;
+ r2.right = div - 2;
+ m_status.MoveWindow(&r2);
+
+ r2 = r;
+ r2.left = div;
+ m_time.MoveWindow(&r2);
+
+ GetClientRect(r);
+ r.SetRect(6, r.top+4, 22, r.bottom-4);
+ m_type.MoveWindow(r);
+
+ Invalidate();
}
void CPlayerStatusBar::Clear()
{
- m_status.SetWindowText(_T(""));
- m_time.SetWindowText(_T(""));
- SetStatusBitmap(0);
- SetStatusTypeIcon(0);
+ m_status.SetWindowText(_T(""));
+ m_time.SetWindowText(_T(""));
+ SetStatusBitmap(0);
+ SetStatusTypeIcon(0);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::SetStatusBitmap(UINT id)
{
- if(m_bmid == id) return;
+ if(m_bmid == id) return;
- if(m_bm.m_hObject) m_bm.DeleteObject();
- if(id) m_bm.LoadBitmap(id);
- m_bmid = id;
+ if(m_bm.m_hObject) m_bm.DeleteObject();
+ if(id) m_bm.LoadBitmap(id);
+ m_bmid = id;
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::SetStatusTypeIcon(HICON hIcon)
{
- if(m_hIcon == hIcon) return;
+ if(m_hIcon == hIcon) return;
- if(m_hIcon) DestroyIcon(m_hIcon);
- m_type.SetIcon(m_hIcon = hIcon);
+ if(m_hIcon) DestroyIcon(m_hIcon);
+ m_type.SetIcon(m_hIcon = hIcon);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::SetStatusMessage(CString str)
{
- str.Trim();
- m_status.SetWindowText(str);
+ str.Trim();
+ m_status.SetWindowText(str);
}
CString CPlayerStatusBar::GetStatusTimer()
{
- CString strResult;
+ CString strResult;
- m_time.GetWindowText(strResult);
+ m_time.GetWindowText(strResult);
- return strResult;
+ return strResult;
}
void CPlayerStatusBar::SetStatusTimer(CString str)
{
- CString tmp;
- m_time.GetWindowText(tmp);
- if(tmp == str) return;
+ CString tmp;
+ m_time.GetWindowText(tmp);
+ if(tmp == str) return;
- str.Trim();
- m_time.SetWindowText(str);
+ str.Trim();
+ m_time.SetWindowText(str);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat)
{
- ASSERT(pTimeFormat);
-
- CString str;
- CString posstr, durstr;
-
- if(*pTimeFormat == TIME_FORMAT_MEDIA_TIME)
- {
- DVD_HMSF_TIMECODE tcNow = RT2HMSF(rtNow);
- DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
-
- if(tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0))
- posstr.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
- else
- posstr.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);
-
- if(tcDur.bHours > 0)
- durstr.Format(_T("%02d:%02d:%02d"), tcDur.bHours, tcDur.bMinutes, tcDur.bSeconds);
- else
- durstr.Format(_T("%02d:%02d"), tcDur.bMinutes, tcDur.bSeconds);
-
- if(fHighPrecision)
- {
- str.Format(_T("%s.%03d"), posstr, (rtNow / 10000) % 1000);
- posstr = str;
- str.Format(_T("%s.%03d"), durstr, (rtDur / 10000) % 1000);
- durstr = str;
- str.Empty();
- }
- }
- else if(*pTimeFormat == TIME_FORMAT_FRAME)
- {
- posstr.Format(_T("%I64d"), rtNow);
- durstr.Format(_T("%I64d"), rtDur);
- }
-
- str = (/*start <= 0 &&*/ rtDur <= 0) ? posstr : posstr + _T(" / ") + durstr;
-
- SetStatusTimer(str);
+ ASSERT(pTimeFormat);
+
+ CString str;
+ CString posstr, durstr;
+
+ if(*pTimeFormat == TIME_FORMAT_MEDIA_TIME)
+ {
+ DVD_HMSF_TIMECODE tcNow = RT2HMSF(rtNow);
+ DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
+
+ if(tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0))
+ posstr.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
+ else
+ posstr.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);
+
+ if(tcDur.bHours > 0)
+ durstr.Format(_T("%02d:%02d:%02d"), tcDur.bHours, tcDur.bMinutes, tcDur.bSeconds);
+ else
+ durstr.Format(_T("%02d:%02d"), tcDur.bMinutes, tcDur.bSeconds);
+
+ if(fHighPrecision)
+ {
+ str.Format(_T("%s.%03d"), posstr, (rtNow/10000)%1000);
+ posstr = str;
+ str.Format(_T("%s.%03d"), durstr, (rtDur/10000)%1000);
+ durstr = str;
+ str.Empty();
+ }
+ }
+ else if(*pTimeFormat == TIME_FORMAT_FRAME)
+ {
+ posstr.Format(_T("%I64d"), rtNow);
+ durstr.Format(_T("%I64d"), rtDur);
+ }
+
+ str = (/*start <= 0 &&*/ rtDur <= 0) ? posstr : posstr + _T(" / ") + durstr;
+
+ SetStatusTimer(str);
}
void CPlayerStatusBar::ShowTimer(bool fShow)
{
- m_time.ShowWindow(fShow ? SW_SHOW : SW_HIDE);
+ m_time.ShowWindow(fShow ? SW_SHOW : SW_HIDE);
- Relayout();
+ Relayout();
}
BEGIN_MESSAGE_MAP(CPlayerStatusBar, CDialogBar)
- ON_WM_ERASEBKGND()
- ON_WM_PAINT()
- ON_WM_SIZE()
- ON_WM_CREATE()
- ON_WM_LBUTTONDOWN()
- ON_WM_SETCURSOR()
- ON_WM_CTLCOLOR()
+ ON_WM_ERASEBKGND()
+ ON_WM_PAINT()
+ ON_WM_SIZE()
+ ON_WM_CREATE()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_SETCURSOR()
+ ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
@@ -245,130 +245,130 @@ END_MESSAGE_MAP()
BOOL CPlayerStatusBar::OnEraseBkgnd(CDC* pDC)
{
- for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
- if(!pChild->IsWindowVisible()) continue;
+ for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
+ {
+ if(!pChild->IsWindowVisible()) continue;
- CRect r;
- pChild->GetClientRect(&r);
- pChild->MapWindowPoints(this, &r);
- pDC->ExcludeClipRect(&r);
- }
+ CRect r;
+ pChild->GetClientRect(&r);
+ pChild->MapWindowPoints(this, &r);
+ pDC->ExcludeClipRect(&r);
+ }
- CRect r;
- GetClientRect(&r);
+ CRect r;
+ GetClientRect(&r);
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+
+ if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen)
+ r.InflateRect(0, 0, 0, 1);
- if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen)
- r.InflateRect(0, 0, 0, 1);
+ if(pFrame->m_fFullScreen)
+ r.InflateRect(1, 0, 1, 0);
- if(pFrame->m_fFullScreen)
- r.InflateRect(1, 0, 1, 0);
+ pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
- pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
+ r.DeflateRect(1, 1);
- r.DeflateRect(1, 1);
+ pDC->FillSolidRect(&r, 0);
- pDC->FillSolidRect(&r, 0);
-
- return TRUE;
+ return TRUE;
}
void CPlayerStatusBar::OnPaint()
{
- CPaintDC dc(this); // device context for painting
-
- CRect r;
-
- if(m_bm.m_hObject)
- {
- BITMAP bm;
- m_bm.GetBitmap(&bm);
- CDC memdc;
- memdc.CreateCompatibleDC(&dc);
- memdc.SelectObject(&m_bm);
- GetClientRect(&r);
- dc.BitBlt(r.right - bm.bmWidth - 1, (r.Height() - bm.bmHeight) / 2, bm.bmWidth, bm.bmHeight, &memdc, 0, 0, SRCCOPY);
-
- //
- }
- /*
- if(m_hIcon)
- {
- GetClientRect(&r);
- r.SetRect(6, r.top+4, 22-1, r.bottom-4-1);
- DrawIconEx(dc, r.left, r.top, m_hIcon, r.Width(), r.Height(), 0, NULL, DI_NORMAL|DI_COMPAT);
- }
- */
- // Do not call CDialogBar::OnPaint() for painting messages
+ CPaintDC dc(this); // device context for painting
+
+ CRect r;
+
+ if(m_bm.m_hObject)
+ {
+ BITMAP bm;
+ m_bm.GetBitmap(&bm);
+ CDC memdc;
+ memdc.CreateCompatibleDC(&dc);
+ memdc.SelectObject(&m_bm);
+ GetClientRect(&r);
+ dc.BitBlt(r.right-bm.bmWidth-1, (r.Height() - bm.bmHeight)/2, bm.bmWidth, bm.bmHeight, &memdc, 0, 0, SRCCOPY);
+
+ //
+ }
+/*
+ if(m_hIcon)
+ {
+ GetClientRect(&r);
+ r.SetRect(6, r.top+4, 22-1, r.bottom-4-1);
+ DrawIconEx(dc, r.left, r.top, m_hIcon, r.Width(), r.Height(), 0, NULL, DI_NORMAL|DI_COMPAT);
+ }
+*/
+ // Do not call CDialogBar::OnPaint() for painting messages
}
void CPlayerStatusBar::OnSize(UINT nType, int cx, int cy)
{
- CDialogBar::OnSize(nType, cx, cy);
+ CDialogBar::OnSize(nType, cx, cy);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
-
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- pFrame->GetWindowPlacement(&wp);
-
- if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED)
- {
- CRect r;
- GetClientRect(r);
- CPoint p = point;
-
- MapWindowPoints(pFrame, &point, 1);
- pFrame->PostMessage(WM_NCLBUTTONDOWN,
-// (p.x+p.y >= r.Width()) ? HTBOTTOMRIGHT : HTCAPTION,
- (p.x >= r.Width() - r.Height() && !pFrame->IsCaptionMenuHidden()) ? HTBOTTOMRIGHT :
- HTCAPTION,
- MAKELPARAM(point.x, point.y));
- }
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ pFrame->GetWindowPlacement(&wp);
+
+ if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED)
+ {
+ CRect r;
+ GetClientRect(r);
+ CPoint p = point;
+
+ MapWindowPoints(pFrame, &point, 1);
+ pFrame->PostMessage(WM_NCLBUTTONDOWN,
+// (p.x+p.y >= r.Width()) ? HTBOTTOMRIGHT : HTCAPTION,
+ (p.x >= r.Width()-r.Height() && !pFrame->IsCaptionMenuHidden()) ? HTBOTTOMRIGHT :
+ HTCAPTION,
+ MAKELPARAM(point.x, point.y));
+ }
}
BOOL CPlayerStatusBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
-
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- pFrame->GetWindowPlacement(&wp);
-
- if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED)
- {
- CRect r;
- GetClientRect(r);
- CPoint p;
- GetCursorPos(&p);
- ScreenToClient(&p);
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ pFrame->GetWindowPlacement(&wp);
+
+ if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED)
+ {
+ CRect r;
+ GetClientRect(r);
+ CPoint p;
+ GetCursorPos(&p);
+ ScreenToClient(&p);
// if(p.x+p.y >= r.Width())
- if(p.x >= r.Width() - r.Height() && !pFrame->IsCaptionMenuHidden())
- {
- SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
- return TRUE;
- }
- }
-
- return CDialogBar::OnSetCursor(pWnd, nHitTest, message);
+ if(p.x >= r.Width()-r.Height() && !pFrame->IsCaptionMenuHidden())
+ {
+ SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
+ return TRUE;
+ }
+ }
+
+ return CDialogBar::OnSetCursor(pWnd, nHitTest, message);
}
HBRUSH CPlayerStatusBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
- HBRUSH hbr = CDialogBar::OnCtlColor(pDC, pWnd, nCtlColor);
+ HBRUSH hbr = CDialogBar::OnCtlColor(pDC, pWnd, nCtlColor);
- if(*pWnd == m_type)
- {
- hbr = GetStockBrush(BLACK_BRUSH);
- }
+ if(*pWnd == m_type)
+ {
+ hbr = GetStockBrush(BLACK_BRUSH);
+ }
- // TODO: Return a different brush if the default is not desired
- return hbr;
+ // TODO: Return a different brush if the default is not desired
+ return hbr;
}
diff --git a/src/apps/mplayerc/PlayerStatusBar.h b/src/apps/mplayerc/PlayerStatusBar.h
index 5cb63b6df..c4fa89a34 100644
--- a/src/apps/mplayerc/PlayerStatusBar.h
+++ b/src/apps/mplayerc/PlayerStatusBar.h
@@ -30,44 +30,44 @@
class CPlayerStatusBar : public CDialogBar
{
- DECLARE_DYNAMIC(CPlayerStatusBar)
+ DECLARE_DYNAMIC(CPlayerStatusBar)
- CStatic m_type;
- CStatusLabel m_status, m_time;
- CBitmap m_bm;
- UINT m_bmid;
- HICON m_hIcon;
+ CStatic m_type;
+ CStatusLabel m_status, m_time;
+ CBitmap m_bm;
+ UINT m_bmid;
+ HICON m_hIcon;
- void Relayout();
+ void Relayout();
public:
- CPlayerStatusBar();
- virtual ~CPlayerStatusBar();
+ CPlayerStatusBar();
+ virtual ~CPlayerStatusBar();
- void Clear();
+ void Clear();
- void SetStatusBitmap(UINT id);
- void SetStatusTypeIcon(HICON hIcon);
- void SetStatusMessage(CString str);
- void SetStatusTimer(CString str);
- void SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat = &TIME_FORMAT_MEDIA_TIME);
+ void SetStatusBitmap(UINT id);
+ void SetStatusTypeIcon(HICON hIcon);
+ void SetStatusMessage(CString str);
+ void SetStatusTimer(CString str);
+ void SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat = &TIME_FORMAT_MEDIA_TIME);
- CString GetStatusTimer();
- void ShowTimer(bool fShow);
+ CString GetStatusTimer();
+ void ShowTimer(bool fShow);
// Overrides
- virtual BOOL Create(CWnd* pParentWnd);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL Create(CWnd* pParentWnd);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
protected:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnPaint();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnPaint();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
public:
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
};
diff --git a/src/apps/mplayerc/PlayerSubresyncBar.cpp b/src/apps/mplayerc/PlayerSubresyncBar.cpp
index 87380c6f1..763efe93c 100644
--- a/src/apps/mplayerc/PlayerSubresyncBar.cpp
+++ b/src/apps/mplayerc/PlayerSubresyncBar.cpp
@@ -32,9 +32,9 @@
IMPLEMENT_DYNAMIC(CPlayerSubresyncBar, CSizingControlBarG)
CPlayerSubresyncBar::CPlayerSubresyncBar()
{
- m_rt = 0;
- m_fUnlink = false;
- m_lastSegment = -1;
+ m_rt = 0;
+ m_fUnlink = false;
+ m_lastSegment = -1;
}
CPlayerSubresyncBar::~CPlayerSubresyncBar()
@@ -43,514 +43,514 @@ CPlayerSubresyncBar::~CPlayerSubresyncBar()
BOOL CPlayerSubresyncBar::Create(CWnd* pParentWnd, CCritSec* pSubLock)
{
- if(!CSizingControlBarG::Create(_T("Subresync"), pParentWnd, 0))
- return FALSE;
+ if(!CSizingControlBarG::Create(_T("Subresync"), pParentWnd, 0))
+ return FALSE;
- m_pSubLock = pSubLock;
+ m_pSubLock = pSubLock;
- m_list.CreateEx(
- WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | LVS_REPORT/*|LVS_SHOWSELALWAYS*/ | LVS_AUTOARRANGE | LVS_NOSORTHEADER,
- CRect(0, 0, 100, 100), this, IDC_SUBRESYNCLIST);
+ m_list.CreateEx(
+ WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
+ WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP|LVS_REPORT/*|LVS_SHOWSELALWAYS*/|LVS_AUTOARRANGE|LVS_NOSORTHEADER,
+ CRect(0,0,100,100), this, IDC_SUBRESYNCLIST);
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSubresyncBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CSizingControlBarG::PreCreateWindow(cs))
- return FALSE;
+ if(!CSizingControlBarG::PreCreateWindow(cs))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSubresyncBar::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
- {
- if(IsShortCut(pMsg) || IsDialogMessage(pMsg))
- return TRUE;
- }
+ if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
+ {
+ if(IsShortCut(pMsg) || IsDialogMessage(pMsg))
+ return TRUE;
+ }
- return CSizingControlBarG::PreTranslateMessage(pMsg);
+ return CSizingControlBarG::PreTranslateMessage(pMsg);
}
void CPlayerSubresyncBar::SetTime(__int64 rt)
{
- m_rt = rt;
+ m_rt = rt;
- int curSegment;
+ int curSegment;
+
+ if(!m_sts.SearchSubs((int)(rt/10000), 25, &curSegment))
+ {
+ curSegment = -1;
+ }
- if(!m_sts.SearchSubs((int)(rt / 10000), 25, &curSegment))
- {
- curSegment = -1;
- }
-
- if(m_lastSegment != curSegment) m_list.Invalidate();
- m_lastSegment = curSegment;
+ if(m_lastSegment != curSegment) m_list.Invalidate();
+ m_lastSegment = curSegment;
}
void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
{
- m_pSubStream = pSubStream;
+ m_pSubStream = pSubStream;
- m_mode = NONE;
- m_lastSegment = -1;
- m_sts.Empty();
+ m_mode = NONE;
+ m_lastSegment = -1;
+ m_sts.Empty();
- ResetSubtitle();
+ ResetSubtitle();
- if(!m_pSubStream) return;
+ if(!m_pSubStream) return;
- CLSID clsid;
- m_pSubStream->GetClassID(&clsid);
+ CLSID clsid;
+ m_pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile))
- {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
+ if(clsid == __uuidof(CVobSubFile))
+ {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
- m_mode = VOBSUB;
+ m_mode = VOBSUB;
- CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
+ CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
- for(int i = 0, j = sp.GetCount(); i < j; i++)
- {
- CString str;
- str.Format(_T("%d,%d,%d,%d"), sp[i].vobid, sp[i].cellid, sp[i].fForced, i);
- m_sts.Add(TToW(str), false, (int)sp[i].start, (int)sp[i].stop);
- }
+ for(int i = 0, j = sp.GetCount(); i < j; i++)
+ {
+ CString str;
+ str.Format(_T("%d,%d,%d,%d"), sp[i].vobid, sp[i].cellid, sp[i].fForced, i);
+ m_sts.Add(TToW(str), false, (int)sp[i].start, (int)sp[i].stop);
+ }
- m_sts.CreateDefaultStyle(DEFAULT_CHARSET);
+ m_sts.CreateDefaultStyle(DEFAULT_CHARSET);
- pVSF->m_fOnlyShowForcedSubs = false;
+ pVSF->m_fOnlyShowForcedSubs = false;
- for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
- m_list.InsertColumn(COL_START, _T("Time"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_END, _T("End"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_PREVSTART, _T("Preview"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_PREVEND, _T("End"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_VOBID, _T("Vob ID"), LVCFMT_CENTER, 60);
- m_list.InsertColumn(COL_CELLID, _T("Cell ID"), LVCFMT_CENTER, 60);
- m_list.InsertColumn(COL_FORCED, _T("Forced"), LVCFMT_CENTER, 60);
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+ for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
+ m_list.InsertColumn(COL_START, _T("Time"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_END, _T("End"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_PREVSTART, _T("Preview"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_PREVEND, _T("End"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_VOBID, _T("Vob ID"), LVCFMT_CENTER, 60);
+ m_list.InsertColumn(COL_CELLID, _T("Cell ID"), LVCFMT_CENTER, 60);
+ m_list.InsertColumn(COL_FORCED, _T("Forced"), LVCFMT_CENTER, 60);
+ }
+ else if(clsid == __uuidof(CRenderedTextSubtitle))
+ {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
- m_mode = TEXTSUB;
+ m_mode = TEXTSUB;
- m_sts.Copy(*pRTS);
- m_sts.ConvertToTimeBased(fps);
- m_sts.Sort(true); /*!!m_fUnlink*/
+ m_sts.Copy(*pRTS);
+ m_sts.ConvertToTimeBased(fps);
+ m_sts.Sort(true); /*!!m_fUnlink*/
#ifndef UNICODE
- if(!m_sts.IsEntryUnicode(0))
- {
- CFont* f = m_list.GetFont();
- LOGFONT lf;
- f->GetLogFont(&lf);
- lf.lfCharSet = m_sts.GetCharSet(0);
- m_font.DeleteObject();
- m_font.CreateFontIndirect(&lf);
- m_list.SetFont(&m_font);
- }
+ if(!m_sts.IsEntryUnicode(0))
+ {
+ CFont* f = m_list.GetFont();
+ LOGFONT lf;
+ f->GetLogFont(&lf);
+ lf.lfCharSet = m_sts.GetCharSet(0);
+ m_font.DeleteObject();
+ m_font.CreateFontIndirect(&lf);
+ m_list.SetFont(&m_font);
+ }
#endif
- for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
- m_list.InsertColumn(COL_START, _T("Time"), LVCFMT_LEFT, 90);
- m_list.InsertColumn(COL_END, _T("End"), LVCFMT_LEFT, 4);
- m_list.InsertColumn(COL_PREVSTART, _T("Preview"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_PREVEND, _T("End"), LVCFMT_LEFT, 4);
- m_list.InsertColumn(COL_TEXT, _T("Text"), LVCFMT_LEFT, 275);
- m_list.InsertColumn(COL_STYLE, _T("Style"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_FONT, _T("Font"), LVCFMT_LEFT, 60);
- m_list.InsertColumn(COL_CHARSET, _T("CharSet"), LVCFMT_CENTER, 20);
- m_list.InsertColumn(COL_UNICODE, _T("Unicode"), LVCFMT_CENTER, 40);
- m_list.InsertColumn(COL_LAYER, _T("Layer"), LVCFMT_CENTER, 50);
- m_list.InsertColumn(COL_ACTOR, _T("Actor"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_EFFECT, _T("Effect"), LVCFMT_LEFT, 80);
- }
-
- m_subtimes.SetCount(m_sts.GetCount());
-
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
- m_subtimes[i].orgstart = m_sts[i].start;
- m_subtimes[i].orgend = m_sts[i].end;
- }
-
- ResetSubtitle();
+ for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
+ m_list.InsertColumn(COL_START, _T("Time"), LVCFMT_LEFT, 90);
+ m_list.InsertColumn(COL_END, _T("End"), LVCFMT_LEFT, 4);
+ m_list.InsertColumn(COL_PREVSTART, _T("Preview"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_PREVEND, _T("End"), LVCFMT_LEFT, 4);
+ m_list.InsertColumn(COL_TEXT, _T("Text"), LVCFMT_LEFT, 275);
+ m_list.InsertColumn(COL_STYLE, _T("Style"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_FONT, _T("Font"), LVCFMT_LEFT, 60);
+ m_list.InsertColumn(COL_CHARSET, _T("CharSet"), LVCFMT_CENTER, 20);
+ m_list.InsertColumn(COL_UNICODE, _T("Unicode"), LVCFMT_CENTER, 40);
+ m_list.InsertColumn(COL_LAYER, _T("Layer"), LVCFMT_CENTER, 50);
+ m_list.InsertColumn(COL_ACTOR, _T("Actor"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_EFFECT, _T("Effect"), LVCFMT_LEFT, 80);
+ }
+
+ m_subtimes.SetCount(m_sts.GetCount());
+
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ {
+ m_subtimes[i].orgstart = m_sts[i].start;
+ m_subtimes[i].orgend = m_sts[i].end;
+ }
+
+ ResetSubtitle();
}
void CPlayerSubresyncBar::ResetSubtitle()
{
- m_list.DeleteAllItems();
+ m_list.DeleteAllItems();
- if(m_mode == VOBSUB || m_mode == TEXTSUB)
- {
- TCHAR buff[32];
+ if(m_mode == VOBSUB || m_mode == TEXTSUB)
+ {
+ TCHAR buff[32];
- int prevstart = INT_MIN;
+ int prevstart = INT_MIN;
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
- m_subtimes[i].newstart = m_subtimes[i].orgstart;
- m_subtimes[i].newend = m_subtimes[i].orgend;
- FormatTime(i, buff, 0, false);
- m_list.InsertItem(i, buff, COL_START);
- FormatTime(i, buff, 0, true);
- m_list.SetItemText(i, COL_END, buff);
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ {
+ m_subtimes[i].newstart = m_subtimes[i].orgstart;
+ m_subtimes[i].newend = m_subtimes[i].orgend;
+ FormatTime(i, buff, 0, false);
+ m_list.InsertItem(i, buff, COL_START);
+ FormatTime(i, buff, 0, true);
+ m_list.SetItemText(i, COL_END, buff);
- if(prevstart > m_subtimes[i].orgstart) m_list.SetItemData(i, TSEP);
- prevstart = m_subtimes[i].orgstart;
+ if(prevstart > m_subtimes[i].orgstart) m_list.SetItemData(i, TSEP);
+ prevstart = m_subtimes[i].orgstart;
- SetCheck(i, false, false);
- }
+ SetCheck(i, false, false);
+ }
- UpdatePreview();
+ UpdatePreview();
- m_list.SetColumnWidth(COL_START, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_PREVSTART, LVSCW_AUTOSIZE);
- }
+ m_list.SetColumnWidth(COL_START, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_PREVSTART, LVSCW_AUTOSIZE);
+ }
- UpdateStrings();
+ UpdateStrings();
}
void CPlayerSubresyncBar::SaveSubtitle()
{
- CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd());
- if(!pFrame) return;
+ CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd());
+ if(!pFrame) return;
- CLSID clsid;
- m_pSubStream->GetClassID(&clsid);
+ CLSID clsid;
+ m_pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile) && m_mode == VOBSUB)
- {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
+ if(clsid == __uuidof(CVobSubFile) && m_mode == VOBSUB)
+ {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
- CAutoLock cAutoLock(m_pSubLock);
+ CAutoLock cAutoLock(m_pSubLock);
- CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
+ CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
- for(int i = 0, j = sp.GetCount(); i < j; i++)
- {
- sp[i].fValid = false;
- }
+ for(int i = 0, j = sp.GetCount(); i < j; i++)
+ {
+ sp[i].fValid = false;
+ }
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
- int vobid, cellid, forced, spnum, c;
- if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d%c%d"), &vobid, &c, &cellid, &c, &forced, &c, &spnum) != 7) continue;
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ {
+ int vobid, cellid, forced, spnum, c;
+ if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d%c%d"), &vobid, &c, &cellid, &c, &forced, &c, &spnum) != 7) continue;
sp[spnum].start = m_sts[i].start;
- sp[spnum].stop = m_sts[i].end;
- sp[spnum].fValid = true;
- }
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle) && m_mode == TEXTSUB)
- {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
-
- CAutoLock cAutoLock(m_pSubLock);
-
- pRTS->Copy(m_sts);
- }
- else
- {
- return;
- }
-
- pFrame->InvalidateSubtitle();
+ sp[spnum].stop = m_sts[i].end;
+ sp[spnum].fValid = true;
+ }
+ }
+ else if(clsid == __uuidof(CRenderedTextSubtitle) && m_mode == TEXTSUB)
+ {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+
+ CAutoLock cAutoLock(m_pSubLock);
+
+ pRTS->Copy(m_sts);
+ }
+ else
+ {
+ return;
+ }
+
+ pFrame->InvalidateSubtitle();
}
void CPlayerSubresyncBar::UpdatePreview()
{
- if(m_mode == VOBSUB || m_mode == TEXTSUB)
- {
- if(0/*m_fUnlink*/)
- {
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
- bool fStartMod, fEndMod, fStartAdj, fEndAdj;
- GetCheck(i, fStartMod, fEndMod, fStartAdj, fEndAdj);
- m_sts[i].start = (fStartMod || fStartAdj) ? m_subtimes[i].newstart : m_subtimes[i].orgstart;
- m_sts[i].end = (fEndMod || fEndAdj) ? m_subtimes[i].newend : m_subtimes[i].orgend;
- }
- }
- else
- {
- CAtlArray<int> schk;
-
- for(int i = 0, j = m_sts.GetCount(); i < j;)
- {
- schk.RemoveAll();
-
- int start = i, end;
-
- for(end = i; end < j; end++)
- {
- int data = (int)m_list.GetItemData(end);
- if((data & TSEP) && end > i) break;
- if(data&(TSMOD | TSADJ))
- schk.Add(end);
- }
-
- if(schk.GetCount() == 0)
- {
- for(; start < end; start++)
- {
- m_sts[start].start = m_subtimes[start].orgstart;
- m_sts[start].end = m_subtimes[start].orgend;
- }
- }
- else if(schk.GetCount() == 1)
- {
- int k = schk[0];
- int dt = m_subtimes[k].newstart - m_subtimes[k].orgstart;
- for(; start < end; start++)
- {
- m_sts[start].start = m_subtimes[start].orgstart + dt;
- m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
- ? m_subtimes[start].newend
- : (m_subtimes[start].orgend + dt);
- }
- }
- else if(schk.GetCount() >= 2)
- {
- int i0, i1, ti0, ds;
- double m = 0;
-
- for(int k = 0, l = schk.GetCount() - 1; k < l; k++)
- {
- i0 = schk[k];
- i1 = schk[k+1];
-
- ti0 = m_subtimes[i0].orgstart;
- ds = m_subtimes[i1].orgstart - ti0;
-
- if(ds == 0)
- {
- for(; start < i1; start++)
- {
- m_sts[start].start = ti0;
- m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
- ? m_subtimes[start].newend
- : (ti0 + m_subtimes[start].orgend - m_subtimes[start].orgstart);
- }
- }
- else
- {
- m = double(m_subtimes[i1].newstart - m_subtimes[i0].newstart) / ds;
-
- for(; start < i1; start++)
- {
- m_sts[start].start = int((m_subtimes[start].orgstart - ti0) * m + m_subtimes[i0].newstart);
- m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
- ? m_subtimes[start].newend
- : m_mode == VOBSUB
- ? (m_sts[start].start + m_subtimes[start].orgend - m_subtimes[start].orgstart)
- : (m_sts[start].start + int((m_subtimes[start].orgend - m_subtimes[start].orgstart) * m));
- }
- }
- }
-
- if(ds == 0)
- {
- for(; start < end; start++)
- {
- m_sts[start].start = ti0;
- m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
- ? m_subtimes[start].newend
- : (ti0 + (m_subtimes[start].orgend - m_subtimes[start].orgstart));
- }
- }
- else
- {
- for(; start < end; start++)
- {
- m_sts[start].start = int((m_subtimes[start].orgstart - ti0) * m + m_subtimes[i0].newstart);
- m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
- ? m_subtimes[start].newend
- : m_mode == VOBSUB
- ? (m_sts[start].start + m_subtimes[start].orgend - m_subtimes[start].orgstart)
- : (m_sts[start].start + int((m_subtimes[start].orgend - m_subtimes[start].orgstart) * m));
- }
- }
- }
-
- i = end;
- }
- }
-
- m_sts.CreateSegments();
-
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
- TCHAR buff[32];
- FormatTime(i, buff, 2, false);
- m_list.SetItemText(i, COL_PREVSTART, buff);
- FormatTime(i, buff, 2, true);
- m_list.SetItemText(i, COL_PREVEND, buff);
- }
-
- if(IsWindowVisible())
- {
- SaveSubtitle();
- }
- }
+ if(m_mode == VOBSUB || m_mode == TEXTSUB)
+ {
+ if(0/*m_fUnlink*/)
+ {
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ {
+ bool fStartMod, fEndMod, fStartAdj, fEndAdj;
+ GetCheck(i, fStartMod, fEndMod, fStartAdj, fEndAdj);
+ m_sts[i].start = (fStartMod||fStartAdj) ? m_subtimes[i].newstart : m_subtimes[i].orgstart;
+ m_sts[i].end = (fEndMod||fEndAdj) ? m_subtimes[i].newend : m_subtimes[i].orgend;
+ }
+ }
+ else
+ {
+ CAtlArray<int> schk;
+
+ for(int i = 0, j = m_sts.GetCount(); i < j;)
+ {
+ schk.RemoveAll();
+
+ int start = i, end;
+
+ for(end = i; end < j; end++)
+ {
+ int data = (int)m_list.GetItemData(end);
+ if((data&TSEP) && end > i) break;
+ if(data&(TSMOD|TSADJ))
+ schk.Add(end);
+ }
+
+ if(schk.GetCount() == 0)
+ {
+ for(; start < end; start++)
+ {
+ m_sts[start].start = m_subtimes[start].orgstart;
+ m_sts[start].end = m_subtimes[start].orgend;
+ }
+ }
+ else if(schk.GetCount() == 1)
+ {
+ int k = schk[0];
+ int dt = m_subtimes[k].newstart - m_subtimes[k].orgstart;
+ for(; start < end; start++)
+ {
+ m_sts[start].start = m_subtimes[start].orgstart + dt;
+ m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
+ ? m_subtimes[start].newend
+ : (m_subtimes[start].orgend + dt);
+ }
+ }
+ else if(schk.GetCount() >= 2)
+ {
+ int i0, i1, ti0, ds;
+ double m = 0;
+
+ for(int k = 0, l = schk.GetCount()-1; k < l; k++)
+ {
+ i0 = schk[k];
+ i1 = schk[k+1];
+
+ ti0 = m_subtimes[i0].orgstart;
+ ds = m_subtimes[i1].orgstart - ti0;
+
+ if(ds == 0)
+ {
+ for(; start < i1; start++)
+ {
+ m_sts[start].start = ti0;
+ m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
+ ? m_subtimes[start].newend
+ : (ti0 + m_subtimes[start].orgend - m_subtimes[start].orgstart);
+ }
+ }
+ else
+ {
+ m = double(m_subtimes[i1].newstart - m_subtimes[i0].newstart) / ds;
+
+ for(; start < i1; start++)
+ {
+ m_sts[start].start = int((m_subtimes[start].orgstart - ti0)*m + m_subtimes[i0].newstart);
+ m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
+ ? m_subtimes[start].newend
+ : m_mode == VOBSUB
+ ? (m_sts[start].start + m_subtimes[start].orgend - m_subtimes[start].orgstart)
+ : (m_sts[start].start + int((m_subtimes[start].orgend - m_subtimes[start].orgstart)*m));
+ }
+ }
+ }
+
+ if(ds == 0)
+ {
+ for(; start < end; start++)
+ {
+ m_sts[start].start = ti0;
+ m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
+ ? m_subtimes[start].newend
+ : (ti0 + (m_subtimes[start].orgend - m_subtimes[start].orgstart));
+ }
+ }
+ else
+ {
+ for(; start < end; start++)
+ {
+ m_sts[start].start = int((m_subtimes[start].orgstart - ti0)*m + m_subtimes[i0].newstart);
+ m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
+ ? m_subtimes[start].newend
+ : m_mode == VOBSUB
+ ? (m_sts[start].start + m_subtimes[start].orgend - m_subtimes[start].orgstart)
+ : (m_sts[start].start + int((m_subtimes[start].orgend - m_subtimes[start].orgstart)*m));
+ }
+ }
+ }
+
+ i = end;
+ }
+ }
+
+ m_sts.CreateSegments();
+
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ {
+ TCHAR buff[32];
+ FormatTime(i, buff, 2, false);
+ m_list.SetItemText(i, COL_PREVSTART, buff);
+ FormatTime(i, buff, 2, true);
+ m_list.SetItemText(i, COL_PREVEND, buff);
+ }
+
+ if(IsWindowVisible())
+ {
+ SaveSubtitle();
+ }
+ }
}
void CPlayerSubresyncBar::UpdateStrings()
{
- CString str;
-
- if(m_mode == TEXTSUB)
- {
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
- STSStyle stss;
- m_sts.GetStyle(i, stss);
-
- m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
- m_list.SetItemText(i, COL_STYLE, m_sts[i].style);
- m_list.SetItemText(i, COL_FONT, stss.fontName);
- str.Format(_T("%d"), stss.charSet);
- m_list.SetItemText(i, COL_CHARSET, str);
- m_list.SetItemText(i, COL_UNICODE, m_sts.IsEntryUnicode(i) ? _T("yes") : _T("no"));
- str.Format(_T("%d"), m_sts[i].layer);
- m_list.SetItemText(i, COL_LAYER, str);
- m_list.SetItemText(i, COL_ACTOR, m_sts[i].actor);
- m_list.SetItemText(i, COL_EFFECT, m_sts[i].effect);
- }
- }
- else if(m_mode == VOBSUB)
- {
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
- int vobid, cellid, forced, c;
- if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d"), &vobid, &c, &cellid, &c, &forced) != 5) continue;
- if(vobid < 0) str = _T("-");
- else str.Format(_T("%d"), vobid);
- m_list.SetItemText(i, COL_VOBID, str);
- if(cellid < 0) str = _T("-");
- else str.Format(_T("%d"), cellid);
- m_list.SetItemText(i, COL_CELLID, str);
- str = forced ? _T("Yes") : _T("");
- m_list.SetItemText(i, COL_FORCED, str);
- }
- }
+ CString str;
+
+ if(m_mode == TEXTSUB)
+ {
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ {
+ STSStyle stss;
+ m_sts.GetStyle(i, stss);
+
+ m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
+ m_list.SetItemText(i, COL_STYLE, m_sts[i].style);
+ m_list.SetItemText(i, COL_FONT, stss.fontName);
+ str.Format(_T("%d"), stss.charSet);
+ m_list.SetItemText(i, COL_CHARSET, str);
+ m_list.SetItemText(i, COL_UNICODE, m_sts.IsEntryUnicode(i) ? _T("yes") : _T("no"));
+ str.Format(_T("%d"), m_sts[i].layer);
+ m_list.SetItemText(i, COL_LAYER, str);
+ m_list.SetItemText(i, COL_ACTOR, m_sts[i].actor);
+ m_list.SetItemText(i, COL_EFFECT, m_sts[i].effect);
+ }
+ }
+ else if(m_mode == VOBSUB)
+ {
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ {
+ int vobid, cellid, forced, c;
+ if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d"), &vobid, &c, &cellid, &c, &forced) != 5) continue;
+ if(vobid < 0) str = _T("-");
+ else str.Format(_T("%d"), vobid);
+ m_list.SetItemText(i, COL_VOBID, str);
+ if(cellid < 0) str = _T("-");
+ else str.Format(_T("%d"), cellid);
+ m_list.SetItemText(i, COL_CELLID, str);
+ str = forced?_T("Yes"):_T("");
+ m_list.SetItemText(i, COL_FORCED, str);
+ }
+ }
}
void CPlayerSubresyncBar::GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bool& fStartAdj, bool& fEndAdj)
{
- if(0 <= iItem && iItem < m_sts.GetCount())
- {
+ if(0 <= iItem && iItem < m_sts.GetCount())
+ {
int nCheck = (int)m_list.GetItemData(iItem);
- fStartMod = !!(nCheck & TSMOD);
- fEndMod = !!(nCheck & TEMOD);
- fStartAdj = !!(nCheck & TSADJ);
- fEndAdj = !!(nCheck & TEADJ);
- }
+ fStartMod = !!(nCheck&TSMOD);
+ fEndMod = !!(nCheck&TEMOD);
+ fStartAdj = !!(nCheck&TSADJ);
+ fEndAdj = !!(nCheck&TEADJ);
+ }
}
void CPlayerSubresyncBar::SetCheck(int iItem, bool fStart, bool fEnd)
{
- if(0 <= iItem && iItem < m_sts.GetCount())
- {
- SubTime& st = m_subtimes[iItem];
+ if(0 <= iItem && iItem < m_sts.GetCount())
+ {
+ SubTime& st = m_subtimes[iItem];
int nCheck = (int)m_list.GetItemData(iItem) & TSEP;
- if(fStart) nCheck |= TSMOD;
- else if(abs(st.orgstart - st.newstart)) nCheck |= TSADJ;
- if(fEnd) nCheck |= TEMOD;
- else if(abs(st.orgend - st.newend)) nCheck |= TEADJ;
+ if(fStart) nCheck |= TSMOD;
+ else if(abs(st.orgstart-st.newstart)) nCheck |= TSADJ;
+ if(fEnd) nCheck |= TEMOD;
+ else if(abs(st.orgend-st.newend)) nCheck |= TEADJ;
- m_list.SetItemData(iItem, (DWORD)nCheck);
+ m_list.SetItemData(iItem, (DWORD)nCheck);
- TCHAR buff[32];
- FormatTime(iItem, buff, fStart, false);
- m_list.SetItemText(iItem, COL_START, buff);
- FormatTime(iItem, buff, fEnd, true);
- m_list.SetItemText(iItem, COL_END, buff);
- }
+ TCHAR buff[32];
+ FormatTime(iItem, buff, fStart, false);
+ m_list.SetItemText(iItem, COL_START, buff);
+ FormatTime(iItem, buff, fEnd, true);
+ m_list.SetItemText(iItem, COL_END, buff);
+ }
}
bool CPlayerSubresyncBar::ModStart(int iItem, int t, bool fReset)
{
- bool fRet = false;
+ bool fRet = false;
- bool fStartMod, fEndMod, fStartAdj, fEndAdj;
- GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
+ bool fStartMod, fEndMod, fStartAdj, fEndAdj;
+ GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
- SubTime& st = m_subtimes[iItem];
+ SubTime& st = m_subtimes[iItem];
// if(fStartMod || fStartAdj || st.orgstart != t || fReset)
- {
- fRet = (st.newstart != t);
+ {
+ fRet = (st.newstart != t);
- st.newstart = t;
- if(!fEndMod) st.newend = st.newstart + (st.orgend - st.orgstart);
- else if(fReset) st.newstart = st.newend - (st.orgend - st.orgstart);
+ st.newstart = t;
+ if(!fEndMod) st.newend = st.newstart + (st.orgend - st.orgstart);
+ else if(fReset) st.newstart = st.newend - (st.orgend - st.orgstart);
- SetCheck(iItem, !fReset, fEndMod);
- }
+ SetCheck(iItem, !fReset, fEndMod);
+ }
- return(fRet);
+ return(fRet);
}
bool CPlayerSubresyncBar::ModEnd(int iItem, int t, bool fReset)
{
- bool fRet = false;
+ bool fRet = false;
- bool fStartMod, fEndMod, fStartAdj, fEndAdj;
- GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
+ bool fStartMod, fEndMod, fStartAdj, fEndAdj;
+ GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
- SubTime& st = m_subtimes[iItem];
+ SubTime& st = m_subtimes[iItem];
// if(fEndMod || fEndAdj || st.orgend != t || fReset)
- {
- fRet = (st.newend != t);
+ {
+ fRet = (st.newend != t);
- st.newend = t;
- if(!fStartMod) st.newstart = st.newend - (st.orgend - st.orgstart);
- else if(fReset) st.newend = st.newstart + (st.orgend - st.orgstart);
+ st.newend = t;
+ if(!fStartMod) st.newstart = st.newend - (st.orgend - st.orgstart);
+ else if(fReset) st.newend = st.newstart + (st.orgend - st.orgstart);
- SetCheck(iItem, fStartMod, !fReset);
- }
+ SetCheck(iItem, fStartMod, !fReset);
+ }
- return(fRet);
+ return(fRet);
}
void CPlayerSubresyncBar::FormatTime(int iItem, TCHAR* buff, int time, bool fEnd)
{
- int t = !fEnd
- ? (time == 2 ? m_sts[iItem].start
- : time == 1 ? m_subtimes[iItem].newstart
- : m_subtimes[iItem].orgstart)
- : (time == 2 ? m_sts[iItem].end
- : time == 1 ? m_subtimes[iItem].newend
- : m_subtimes[iItem].orgend);
-
- _stprintf(buff, t >= 0
- ? _T("%02d:%02d:%02d.%03d")
- : _T("-%02d:%02d:%02d.%03d"),
- abs(t) / 60 / 60 / 1000,
- (abs(t) / 60 / 1000) % 60,
- (abs(t) / 1000) % 60,
- abs(t) % 1000);
+ int t = !fEnd
+ ?(time == 2 ? m_sts[iItem].start
+ : time == 1 ? m_subtimes[iItem].newstart
+ : m_subtimes[iItem].orgstart)
+ : (time == 2 ? m_sts[iItem].end
+ : time == 1 ? m_subtimes[iItem].newend
+ : m_subtimes[iItem].orgend);
+
+ _stprintf(buff, t >= 0
+ ? _T("%02d:%02d:%02d.%03d")
+ : _T("-%02d:%02d:%02d.%03d"),
+ abs(t)/60/60/1000,
+ (abs(t)/60/1000)%60,
+ (abs(t)/1000)%60,
+ abs(t)%1000);
}
BEGIN_MESSAGE_MAP(CPlayerSubresyncBar, CSizingControlBarG)
- ON_WM_SIZE()
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_SUBRESYNCLIST, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_SUBRESYNCLIST, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SUBRESYNCLIST, OnEndlabeleditList)
- ON_NOTIFY(NM_RCLICK, IDC_SUBRESYNCLIST, OnRclickList)
- ON_NOTIFY(NM_DBLCLK, IDC_SUBRESYNCLIST, OnNMDblclkList)
- ON_NOTIFY(LVN_KEYDOWN, IDC_SUBRESYNCLIST, OnLvnKeydownList)
- ON_NOTIFY(NM_CUSTOMDRAW, IDC_SUBRESYNCLIST, OnCustomdrawList)
+ ON_WM_SIZE()
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_SUBRESYNCLIST, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_SUBRESYNCLIST, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SUBRESYNCLIST, OnEndlabeleditList)
+ ON_NOTIFY(NM_RCLICK, IDC_SUBRESYNCLIST, OnRclickList)
+ ON_NOTIFY(NM_DBLCLK, IDC_SUBRESYNCLIST, OnNMDblclkList)
+ ON_NOTIFY(LVN_KEYDOWN, IDC_SUBRESYNCLIST, OnLvnKeydownList)
+ ON_NOTIFY(NM_CUSTOMDRAW, IDC_SUBRESYNCLIST, OnCustomdrawList)
END_MESSAGE_MAP()
@@ -558,577 +558,559 @@ END_MESSAGE_MAP()
void CPlayerSubresyncBar::OnSize(UINT nType, int cx, int cy)
{
- CSizingControlBarG::OnSize(nType, cx, cy);
-
- if(::IsWindow(m_list.m_hWnd))
- {
- CRect r;
- GetClientRect(r);
- r.DeflateRect(2, 2);
- m_list.MoveWindow(r);
- }
+ CSizingControlBarG::OnSize(nType, cx, cy);
+
+ if(::IsWindow(m_list.m_hWnd))
+ {
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(2, 2);
+ m_list.MoveWindow(r);
+ }
}
static bool ParseTime(CString str, int& ret, bool fWarn = true)
{
- int sign = 1, h, m, s, ms;
- TCHAR c;
+ int sign = 1, h, m, s, ms;
+ TCHAR c;
- str.Trim();
- if(str.GetLength() > 0 && str[0] == '-') sign = -1;
+ str.Trim();
+ if(str.GetLength() > 0 && str[0] == '-') sign = -1;
- int n = _stscanf(str, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms);
+ int n = _stscanf(str, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms);
- h = abs(h);
+ h = abs(h);
- if(n == 7
- && 0 <= h && h < 24
- && 0 <= m && m < 60
- && 0 <= s && s < 60
- && 0 <= ms && ms < 1000)
- {
- ret = sign * (h * 60 * 60 * 1000 + m * 60 * 1000 + s * 1000 + ms);
- return(true);
- }
+ if(n == 7
+ && 0 <= h && h < 24
+ && 0 <= m && m < 60
+ && 0 <= s && s < 60
+ && 0 <= ms && ms < 1000)
+ {
+ ret = sign*(h*60*60*1000+m*60*1000+s*1000+ms);
+ return(true);
+ }
- if(fWarn) AfxMessageBox(_T("The correct time format is [-]hh:mm:ss.ms\n(e.g. 01:23:45.678)"));
- return(false);
+ if(fWarn) AfxMessageBox(_T("The correct time format is [-]hh:mm:ss.ms\n(e.g. 01:23:45.678)"));
+ return(false);
}
-void CPlayerSubresyncBar::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPlayerSubresyncBar::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if(pItem->iItem >= 0)
- {
- if((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
- || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
- || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
- && m_mode == TEXTSUB)
- {
- *pResult = TRUE;
- }
- else if((pItem->iSubItem == COL_START)
- && m_mode == VOBSUB)
- {
- *pResult = TRUE;
- }
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if(pItem->iItem >= 0)
+ {
+ if((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
+ || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
+ || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
+ && m_mode == TEXTSUB)
+ {
+ *pResult = TRUE;
+ }
+ else if((pItem->iSubItem == COL_START)
+ && m_mode == VOBSUB)
+ {
+ *pResult = TRUE;
+ }
+ }
}
-void CPlayerSubresyncBar::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPlayerSubresyncBar::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if(pItem->iItem >= 0)
- {
- if((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
- || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
- || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
- && m_mode == TEXTSUB)
- {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
- *pResult = TRUE;
- }
- else if((pItem->iSubItem == COL_START)
- && m_mode == VOBSUB)
- {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
- *pResult = TRUE;
- }
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if(pItem->iItem >= 0)
+ {
+ if((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
+ || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
+ || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
+ && m_mode == TEXTSUB)
+ {
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ *pResult = TRUE;
+ }
+ else if((pItem->iSubItem == COL_START)
+ && m_mode == VOBSUB)
+ {
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ *pResult = TRUE;
+ }
+ }
}
-void CPlayerSubresyncBar::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPlayerSubresyncBar::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if(!m_list.m_fInPlaceDirty)
- return;
-
- bool fNeedsUpdate = false;
-
- if(pItem->iItem >= 0 && pItem->pszText && (m_mode == VOBSUB || m_mode == TEXTSUB))
- {
- if(pItem->iSubItem == COL_START)
- {
- int t;
- if(ParseTime(pItem->pszText, t))
- {
- fNeedsUpdate = ModStart(pItem->iItem, t);
-
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_END && m_mode == TEXTSUB)
- {
- int t;
- if(ParseTime(pItem->pszText, t))
- {
- fNeedsUpdate = ModEnd(pItem->iItem, t);
-
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_TEXT && m_mode == TEXTSUB)
- {
- CString str = m_sts.GetStr(pItem->iItem, true);
-
- if(str != pItem->pszText)
- {
- fNeedsUpdate = true;
- m_sts.SetStr(pItem->iItem, CString(pItem->pszText), true);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, m_sts.GetStr(pItem->iItem, true));
- }
- }
- else if(pItem->iSubItem == COL_STYLE && m_mode == TEXTSUB)
- {
- CString str(pItem->pszText);
- str.Trim();
-
- if(!str.IsEmpty() && m_sts[pItem->iItem].style != str)
- {
- fNeedsUpdate = true;
-
- if(!m_sts.m_styles.Lookup(str))
- m_sts.AddStyle(str, DNew STSStyle());
-
- m_sts[pItem->iItem].style = str;
-
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
- }
- }
- else if(pItem->iSubItem == COL_LAYER && m_mode == TEXTSUB)
- {
- int l;
- if(_stscanf_s(pItem->pszText, _T("%d"), &l) == 1)
- {
- fNeedsUpdate = true;
- m_sts[pItem->iItem].layer = l;
- CString str;
- str.Format(_T("%d"), l);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- }
- }
- else if(pItem->iSubItem == COL_ACTOR && m_mode == TEXTSUB)
- {
- CString str(pItem->pszText);
- str.Trim();
- if(!str.IsEmpty())
- {
- fNeedsUpdate = true;
- m_sts[pItem->iItem].actor = str;
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- }
- }
- else if(pItem->iSubItem == COL_EFFECT && m_mode == TEXTSUB)
- {
- CString str(pItem->pszText);
- str.Trim();
- if(!str.IsEmpty())
- {
- fNeedsUpdate = true;
- m_sts[pItem->iItem].effect = str;
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- }
- }
- }
-
- if(fNeedsUpdate)
- {
- UpdatePreview();
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if(!m_list.m_fInPlaceDirty)
+ return;
+
+ bool fNeedsUpdate = false;
+
+ if(pItem->iItem >= 0 && pItem->pszText && (m_mode == VOBSUB || m_mode == TEXTSUB))
+ {
+ if(pItem->iSubItem == COL_START)
+ {
+ int t;
+ if(ParseTime(pItem->pszText, t))
+ {
+ fNeedsUpdate = ModStart(pItem->iItem, t);
+
+ *pResult = TRUE;
+ }
+ }
+ else if(pItem->iSubItem == COL_END && m_mode == TEXTSUB)
+ {
+ int t;
+ if(ParseTime(pItem->pszText, t))
+ {
+ fNeedsUpdate = ModEnd(pItem->iItem, t);
+
+ *pResult = TRUE;
+ }
+ }
+ else if(pItem->iSubItem == COL_TEXT && m_mode == TEXTSUB)
+ {
+ CString str = m_sts.GetStr(pItem->iItem, true);
+
+ if(str != pItem->pszText)
+ {
+ fNeedsUpdate = true;
+ m_sts.SetStr(pItem->iItem, CString(pItem->pszText), true);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, m_sts.GetStr(pItem->iItem, true));
+ }
+ }
+ else if(pItem->iSubItem == COL_STYLE && m_mode == TEXTSUB)
+ {
+ CString str(pItem->pszText);
+ str.Trim();
+
+ if(!str.IsEmpty() && m_sts[pItem->iItem].style != str)
+ {
+ fNeedsUpdate = true;
+
+ if(!m_sts.m_styles.Lookup(str))
+ m_sts.AddStyle(str, DNew STSStyle());
+
+ m_sts[pItem->iItem].style = str;
+
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
+ }
+ }
+ else if(pItem->iSubItem == COL_LAYER && m_mode == TEXTSUB)
+ {
+ int l;
+ if(_stscanf_s(pItem->pszText, _T("%d"), &l) == 1)
+ {
+ fNeedsUpdate = true;
+ m_sts[pItem->iItem].layer = l;
+ CString str;
+ str.Format(_T("%d"), l);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ }
+ }
+ else if(pItem->iSubItem == COL_ACTOR && m_mode == TEXTSUB)
+ {
+ CString str(pItem->pszText);
+ str.Trim();
+ if(!str.IsEmpty())
+ {
+ fNeedsUpdate = true;
+ m_sts[pItem->iItem].actor = str;
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ }
+ }
+ else if(pItem->iSubItem == COL_EFFECT && m_mode == TEXTSUB)
+ {
+ CString str(pItem->pszText);
+ str.Trim();
+ if(!str.IsEmpty())
+ {
+ fNeedsUpdate = true;
+ m_sts[pItem->iItem].effect = str;
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ }
+ }
+ }
+
+ if(fNeedsUpdate)
+ {
+ UpdatePreview();
+ }
}
static int uintcomp(const void* i1, const void* i2)
{
- return(*((UINT*)i2) - *((UINT*)i1));
+ return(*((UINT*)i2) - *((UINT*)i1));
}
-void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
+void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
-
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0)
- {
- enum
- {
- TOGSEP = 1,
- DUPITEM, DELITEM,
- RESETS, SETOS, SETCS, RESETE, SETOE, SETCE,
- STYLEFIRST, STYLELAST = STYLEFIRST + 1000, STYLEEDIT,
- UNICODEYES, UNICODENO,
- LAYERDEC, LAYERINC,
- ACTORFIRST, ACTORLAST = ACTORFIRST + 1000,
- EFFECTFIRST, EFFECTLAST = EFFECTFIRST + 1000
- };
-
- CStringArray styles;
- CStringArray actors;
- CStringArray effects;
-
- CMenu m;
- m.CreatePopupMenu();
-
- if(m_mode == VOBSUB || m_mode == TEXTSUB)
- {
- m.AppendMenu(MF_STRING | MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR));
- m.AppendMenu(MF_SEPARATOR);
- if(m_mode == TEXTSUB) m.AppendMenu(MF_STRING | MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE));
- m.AppendMenu(MF_STRING | MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE));
- }
-
- if(lpnmlv->iSubItem == COL_START && (m_mode == VOBSUB || m_mode == TEXTSUB))
- {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1"));
- m.AppendMenu(MF_STRING | MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3"));
- m.AppendMenu(MF_STRING | MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5"));
- }
- else if(lpnmlv->iSubItem == COL_END && m_mode == TEXTSUB)
- {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2"));
- m.AppendMenu(MF_STRING | MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4"));
- m.AppendMenu(MF_STRING | MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6"));
- }
- else if(lpnmlv->iSubItem == COL_STYLE && m_mode == TEXTSUB)
- {
- m.AppendMenu(MF_SEPARATOR);
-
- int id = STYLEFIRST;
-
- POSITION pos = m_sts.m_styles.GetStartPosition();
- while(pos && id <= STYLELAST)
- {
- CString key;
- STSStyle* val;
- m_sts.m_styles.GetNextAssoc(pos, key, val);
- styles.Add(key);
- m.AppendMenu(MF_STRING | MF_ENABLED, id++, key);
- }
-
- if(id > STYLEFIRST && m_list.GetSelectedCount() == 1)
- {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT));
- }
- }
- else if(lpnmlv->iSubItem == COL_UNICODE && m_mode == TEXTSUB)
- {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | MF_ENABLED, UNICODEYES, ResStr(IDS_SUBRESYNC_YES));
- m.AppendMenu(MF_STRING | MF_ENABLED, UNICODENO, ResStr(IDS_SUBRESYNC_NO));
- }
- else if(lpnmlv->iSubItem == COL_LAYER && m_mode == TEXTSUB)
- {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING | MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE));
- m.AppendMenu(MF_STRING | MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE));
- }
- else if(lpnmlv->iSubItem == COL_ACTOR && m_mode == TEXTSUB)
- {
- CMapStringToPtr actormap;
-
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- actormap[m_sts[i].actor] = NULL;
-
- actormap.RemoveKey(_T(""));
-
- if(actormap.GetCount() > 0)
- {
- m.AppendMenu(MF_SEPARATOR);
-
- int id = ACTORFIRST;
-
- POSITION pos = actormap.GetStartPosition();
- while(pos && id <= ACTORLAST)
- {
- CString key;
- void* val;
- actormap.GetNextAssoc(pos, key, val);
-
- actors.Add(key);
-
- m.AppendMenu(MF_STRING | MF_ENABLED, id++, key);
- }
- }
- }
- else if(lpnmlv->iSubItem == COL_EFFECT && m_mode == TEXTSUB)
- {
- CMapStringToPtr effectmap;
-
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- effectmap[m_sts[i].effect] = NULL;
-
- effectmap.RemoveKey(_T(""));
-
- if(effectmap.GetCount() > 0)
- {
- m.AppendMenu(MF_SEPARATOR);
-
- int id = EFFECTFIRST;
-
- POSITION pos = effectmap.GetStartPosition();
- while(pos && id <= EFFECTLAST)
- {
- CString key;
- void* val;
- effectmap.GetNextAssoc(pos, key, val);
-
- effects.Add(key);
-
- m.AppendMenu(MF_STRING | MF_ENABLED, id++, key);
- }
- }
- }
-
- CPoint p = lpnmlv->ptAction;
- ::MapWindowPoints(pNMHDR->hwndFrom, HWND_DESKTOP, &p, 1);
-
- UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this);
-
- bool fNeedsUpdate = false;
-
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- while(pos)
- {
- int iItem = m_list.GetNextSelectedItem(pos);
-
- SubTime& st = m_subtimes[iItem];
-
- switch(id)
- {
- case TOGSEP:
- m_list.SetItemData(iItem, m_list.GetItemData(iItem) ^ TSEP);
- m_list.Invalidate();
- fNeedsUpdate = true;
- break;
- case DUPITEM:
- {
- CUIntArray items;
- pos = m_list.GetFirstSelectedItemPosition();
- while(pos) items.Add(m_list.GetNextSelectedItem(pos));
-
- qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
-
- for(int i = 0; i < items.GetCount(); i++)
- {
- iItem = items[i];
-
- STSEntry stse = m_sts[iItem];
- m_sts.InsertAt(iItem + 1, stse);
-
- SubTime st = m_subtimes[iItem];
- m_subtimes.InsertAt(iItem + 1, st);
-
- CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
-
- CStringArray sa;
- sa.SetSize(nColumnCount);
- for(int col = 0; col < nColumnCount; col++)
- sa[col] = m_list.GetItemText(iItem, col);
-
- DWORD data = m_list.GetItemData(iItem);
- m_list.InsertItem(iItem + 1, sa[0]);
- m_list.SetItemData(iItem + 1, data);
- for(int col = 1; col < nColumnCount; col++)
- m_list.SetItemText(iItem + 1, col, sa[col]);
- }
- }
-
- fNeedsUpdate = true;
- break;
- case DELITEM:
- {
- CUIntArray items;
- pos = m_list.GetFirstSelectedItemPosition();
- while(pos) items.Add(m_list.GetNextSelectedItem(pos));
-
- qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
-
- for(int i = 0; i < items.GetCount(); i++)
- {
- iItem = items[i];
- m_sts.RemoveAt(iItem);
- m_subtimes.RemoveAt(iItem);
- m_list.DeleteItem(iItem);
- }
-
- iItem = items[items.GetCount()-1];
- if(iItem >= m_list.GetItemCount()) iItem = m_list.GetItemCount() - 1;
-
- m_list.SetSelectionMark(iItem);
- }
- fNeedsUpdate = true;
- break;
- case RESETS: /*if(*/
- ModStart(iItem, st.orgstart, true);/*)*/
- fNeedsUpdate = true;
- break;
- case SETOS: /*if(*/
- ModStart(iItem, st.orgstart);/*)*/
- fNeedsUpdate = true;
- break;
- case SETCS: /*if(*/
- ModStart(iItem, (int)(m_rt / 10000));/*)*/
- fNeedsUpdate = true;
- break;
- case RESETE: /*if(*/
- ModEnd(iItem, st.orgend, true);/*)*/
- fNeedsUpdate = true;
- break;
- case SETOE: /*if(*/
- ModEnd(iItem, st.orgend);/*)*/
- fNeedsUpdate = true;
- break;
- case SETCE: /*if(*/
- ModEnd(iItem, (int)(m_rt / 10000));/*)*/
- fNeedsUpdate = true;
- break;
- default:
- if(STYLEFIRST <= id && id <= STYLELAST)
- {
- CString s = styles[id - STYLEFIRST];
- if(m_sts[iItem].style != s) fNeedsUpdate = true;
- m_sts[iItem].style = s;
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- }
- else if(id == STYLEEDIT)
- {
- CAutoPtrArray<CPPageSubStyle> pages;
- CAtlArray<STSStyle*> styles;
-
- STSStyle* stss = m_sts.GetStyle(iItem);
- int iSelPage = 0;
-
- POSITION pos = m_sts.m_styles.GetStartPosition();
- for(int i = 0; pos; i++)
- {
- CString key;
- STSStyle* val;
- m_sts.m_styles.GetNextAssoc(pos, key, val);
-
- CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
- page->InitStyle(key, *val);
- pages.Add(page);
- styles.Add(val);
-
- if(stss == val)
- iSelPage = i;
- }
-
- CPropertySheet dlg(_T("Styles..."), this, iSelPage);
- for(int i = 0; i < (int)pages.GetCount(); i++) dlg.AddPage(pages[i]);
-
- if(dlg.DoModal() == IDOK)
- {
- for(int j = 0; j < (int)pages.GetCount(); j++)
- {
- stss = styles[j];
- pages[j]->GetStyle(*stss);
-
- for(int i = 0; i < m_sts.GetCount(); i++)
- {
- if(m_sts.GetStyle(i) == stss)
- {
- CString str;
- m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
- m_list.SetItemText(i, COL_FONT, stss->fontName);
- str.Format(_T("%d"), stss->charSet);
- m_list.SetItemText(i, COL_CHARSET, str);
- str.Format(_T("%d"), m_sts[i].layer);
- }
- }
- }
-
- fNeedsUpdate = true;
- }
- }
- else if(id == UNICODEYES || id == UNICODENO)
- {
- m_sts.ConvertUnicode(iItem, id == UNICODEYES);
- m_list.SetItemText(iItem, COL_TEXT, m_sts.GetStr(iItem, true));
- m_list.SetItemText(iItem, COL_UNICODE, m_sts.IsEntryUnicode(iItem) ? _T("yes") : _T("no"));
- fNeedsUpdate = true;
- }
- else if(id == LAYERDEC || id == LAYERINC)
- {
- int d = (id == LAYERDEC) ? -1 : (id == LAYERINC) ? +1 : 0;
- if(d != 0) fNeedsUpdate = true;
- m_sts[iItem].layer += d;
- CString s;
- s.Format(_T("%d"), m_sts[iItem].layer);
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- }
- else if(ACTORFIRST <= id && id <= ACTORLAST)
- {
- CString s = actors[id - ACTORFIRST];
- if(m_sts[iItem].actor != s) fNeedsUpdate = true;
- m_sts[iItem].actor = s;
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- }
- else if(EFFECTFIRST <= id && id <= EFFECTLAST)
- {
- CString s = effects[id - EFFECTFIRST];
- if(m_sts[iItem].effect != s) fNeedsUpdate = true;
- m_sts[iItem].effect = s;
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- }
- break;
- }
- }
-
- if(fNeedsUpdate)
- {
- UpdatePreview();
- }
- }
-
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+
+ if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0)
+ {
+ enum
+ {
+ TOGSEP=1,
+ DUPITEM, DELITEM,
+ RESETS, SETOS, SETCS, RESETE, SETOE, SETCE,
+ STYLEFIRST, STYLELAST=STYLEFIRST+1000, STYLEEDIT,
+ UNICODEYES, UNICODENO,
+ LAYERDEC, LAYERINC,
+ ACTORFIRST, ACTORLAST=ACTORFIRST+1000,
+ EFFECTFIRST, EFFECTLAST=EFFECTFIRST+1000
+ };
+
+ CStringArray styles;
+ CStringArray actors;
+ CStringArray effects;
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ if(m_mode == VOBSUB || m_mode == TEXTSUB)
+ {
+ m.AppendMenu(MF_STRING|MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR));
+ m.AppendMenu(MF_SEPARATOR);
+ if(m_mode == TEXTSUB) m.AppendMenu(MF_STRING|MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE));
+ m.AppendMenu(MF_STRING|MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE));
+ }
+
+ if(lpnmlv->iSubItem == COL_START && (m_mode == VOBSUB || m_mode == TEXTSUB))
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1"));
+ m.AppendMenu(MF_STRING|MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3"));
+ m.AppendMenu(MF_STRING|MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5"));
+ }
+ else if(lpnmlv->iSubItem == COL_END && m_mode == TEXTSUB)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2"));
+ m.AppendMenu(MF_STRING|MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4"));
+ m.AppendMenu(MF_STRING|MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6"));
+ }
+ else if(lpnmlv->iSubItem == COL_STYLE && m_mode == TEXTSUB)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+
+ int id = STYLEFIRST;
+
+ POSITION pos = m_sts.m_styles.GetStartPosition();
+ while(pos && id <= STYLELAST)
+ {
+ CString key;
+ STSStyle* val;
+ m_sts.m_styles.GetNextAssoc(pos, key, val);
+ styles.Add(key);
+ m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
+ }
+
+ if(id > STYLEFIRST && m_list.GetSelectedCount() == 1)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT));
+ }
+ }
+ else if(lpnmlv->iSubItem == COL_UNICODE && m_mode == TEXTSUB)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|MF_ENABLED, UNICODEYES, ResStr(IDS_SUBRESYNC_YES));
+ m.AppendMenu(MF_STRING|MF_ENABLED, UNICODENO, ResStr(IDS_SUBRESYNC_NO));
+ }
+ else if(lpnmlv->iSubItem == COL_LAYER && m_mode == TEXTSUB)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING|MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE));
+ m.AppendMenu(MF_STRING|MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE));
+ }
+ else if(lpnmlv->iSubItem == COL_ACTOR && m_mode == TEXTSUB)
+ {
+ CMapStringToPtr actormap;
+
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ actormap[m_sts[i].actor] = NULL;
+
+ actormap.RemoveKey(_T(""));
+
+ if(actormap.GetCount() > 0)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+
+ int id = ACTORFIRST;
+
+ POSITION pos = actormap.GetStartPosition();
+ while(pos && id <= ACTORLAST)
+ {
+ CString key;
+ void* val;
+ actormap.GetNextAssoc(pos, key, val);
+
+ actors.Add(key);
+
+ m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
+ }
+ }
+ }
+ else if(lpnmlv->iSubItem == COL_EFFECT && m_mode == TEXTSUB)
+ {
+ CMapStringToPtr effectmap;
+
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++)
+ effectmap[m_sts[i].effect] = NULL;
+
+ effectmap.RemoveKey(_T(""));
+
+ if(effectmap.GetCount() > 0)
+ {
+ m.AppendMenu(MF_SEPARATOR);
+
+ int id = EFFECTFIRST;
+
+ POSITION pos = effectmap.GetStartPosition();
+ while(pos && id <= EFFECTLAST)
+ {
+ CString key;
+ void* val;
+ effectmap.GetNextAssoc(pos, key, val);
+
+ effects.Add(key);
+
+ m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
+ }
+ }
+ }
+
+ CPoint p = lpnmlv->ptAction;
+ ::MapWindowPoints(pNMHDR->hwndFrom, HWND_DESKTOP, &p, 1);
+
+ UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this);
+
+ bool fNeedsUpdate = false;
+
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ while(pos)
+ {
+ int iItem = m_list.GetNextSelectedItem(pos);
+
+ SubTime& st = m_subtimes[iItem];
+
+ switch(id)
+ {
+ case TOGSEP:
+ m_list.SetItemData(iItem, m_list.GetItemData(iItem)^TSEP);
+ m_list.Invalidate();
+ fNeedsUpdate = true;
+ break;
+ case DUPITEM:
+ {
+ CUIntArray items;
+ pos = m_list.GetFirstSelectedItemPosition();
+ while(pos) items.Add(m_list.GetNextSelectedItem(pos));
+
+ qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
+
+ for(int i = 0; i < items.GetCount(); i++)
+ {
+ iItem = items[i];
+
+ STSEntry stse = m_sts[iItem];
+ m_sts.InsertAt(iItem+1, stse);
+
+ SubTime st = m_subtimes[iItem];
+ m_subtimes.InsertAt(iItem+1, st);
+
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
+
+ CStringArray sa;
+ sa.SetSize(nColumnCount);
+ for(int col = 0; col < nColumnCount; col++)
+ sa[col] = m_list.GetItemText(iItem, col);
+
+ DWORD data = m_list.GetItemData(iItem);
+ m_list.InsertItem(iItem+1, sa[0]);
+ m_list.SetItemData(iItem+1, data);
+ for(int col = 1; col < nColumnCount; col++)
+ m_list.SetItemText(iItem+1, col, sa[col]);
+ }
+ }
+
+ fNeedsUpdate = true;
+ break;
+ case DELITEM:
+ {
+ CUIntArray items;
+ pos = m_list.GetFirstSelectedItemPosition();
+ while(pos) items.Add(m_list.GetNextSelectedItem(pos));
+
+ qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
+
+ for(int i = 0; i < items.GetCount(); i++)
+ {
+ iItem = items[i];
+ m_sts.RemoveAt(iItem);
+ m_subtimes.RemoveAt(iItem);
+ m_list.DeleteItem(iItem);
+ }
+
+ iItem = items[items.GetCount()-1];
+ if(iItem >= m_list.GetItemCount()) iItem = m_list.GetItemCount()-1;
+
+ m_list.SetSelectionMark(iItem);
+ }
+ fNeedsUpdate = true;
+ break;
+ case RESETS: /*if(*/ModStart(iItem, st.orgstart, true);/*)*/ fNeedsUpdate = true; break;
+ case SETOS: /*if(*/ModStart(iItem, st.orgstart);/*)*/ fNeedsUpdate = true; break;
+ case SETCS: /*if(*/ModStart(iItem, (int)(m_rt/10000));/*)*/ fNeedsUpdate = true; break;
+ case RESETE: /*if(*/ModEnd(iItem, st.orgend, true);/*)*/ fNeedsUpdate = true; break;
+ case SETOE: /*if(*/ModEnd(iItem, st.orgend);/*)*/ fNeedsUpdate = true; break;
+ case SETCE: /*if(*/ModEnd(iItem, (int)(m_rt/10000));/*)*/ fNeedsUpdate = true; break;
+ default:
+ if(STYLEFIRST <= id && id <= STYLELAST)
+ {
+ CString s = styles[id - STYLEFIRST];
+ if(m_sts[iItem].style != s) fNeedsUpdate = true;
+ m_sts[iItem].style = s;
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ }
+ else if(id == STYLEEDIT)
+ {
+ CAutoPtrArray<CPPageSubStyle> pages;
+ CAtlArray<STSStyle*> styles;
+
+ STSStyle* stss = m_sts.GetStyle(iItem);
+ int iSelPage = 0;
+
+ POSITION pos = m_sts.m_styles.GetStartPosition();
+ for(int i = 0; pos; i++)
+ {
+ CString key;
+ STSStyle* val;
+ m_sts.m_styles.GetNextAssoc(pos, key, val);
+
+ CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
+ page->InitStyle(key, *val);
+ pages.Add(page);
+ styles.Add(val);
+
+ if(stss == val)
+ iSelPage = i;
+ }
+
+ CPropertySheet dlg(_T("Styles..."), this, iSelPage);
+ for(int i = 0; i < (int)pages.GetCount(); i++) dlg.AddPage(pages[i]);
+
+ if(dlg.DoModal() == IDOK)
+ {
+ for(int j = 0; j < (int)pages.GetCount(); j++)
+ {
+ stss = styles[j];
+ pages[j]->GetStyle(*stss);
+
+ for(int i = 0; i < m_sts.GetCount(); i++)
+ {
+ if(m_sts.GetStyle(i) == stss)
+ {
+ CString str;
+ m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
+ m_list.SetItemText(i, COL_FONT, stss->fontName);
+ str.Format(_T("%d"), stss->charSet);
+ m_list.SetItemText(i, COL_CHARSET, str);
+ str.Format(_T("%d"), m_sts[i].layer);
+ }
+ }
+ }
+
+ fNeedsUpdate = true;
+ }
+ }
+ else if(id == UNICODEYES || id == UNICODENO)
+ {
+ m_sts.ConvertUnicode(iItem, id == UNICODEYES);
+ m_list.SetItemText(iItem, COL_TEXT, m_sts.GetStr(iItem, true));
+ m_list.SetItemText(iItem, COL_UNICODE, m_sts.IsEntryUnicode(iItem) ? _T("yes") : _T("no"));
+ fNeedsUpdate = true;
+ }
+ else if(id == LAYERDEC || id == LAYERINC)
+ {
+ int d = (id == LAYERDEC) ? -1 : (id == LAYERINC) ? +1 : 0;
+ if(d != 0) fNeedsUpdate = true;
+ m_sts[iItem].layer += d;
+ CString s;
+ s.Format(_T("%d"), m_sts[iItem].layer);
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ }
+ else if(ACTORFIRST <= id && id <= ACTORLAST)
+ {
+ CString s = actors[id - ACTORFIRST];
+ if(m_sts[iItem].actor != s) fNeedsUpdate = true;
+ m_sts[iItem].actor = s;
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ }
+ else if(EFFECTFIRST <= id && id <= EFFECTLAST)
+ {
+ CString s = effects[id - EFFECTFIRST];
+ if(m_sts[iItem].effect != s) fNeedsUpdate = true;
+ m_sts[iItem].effect = s;
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ }
+ break;
+ }
+ }
+
+ if(fNeedsUpdate)
+ {
+ UpdatePreview();
+ }
+ }
+
+ *pResult = 0;
}
void CPlayerSubresyncBar::OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
-
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0 && (m_mode == VOBSUB || m_mode == TEXTSUB))
- {
- if(CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd())
- {
- int t = 0;
- if(!ParseTime(m_list.GetItemText(lpnmlv->iItem, lpnmlv->iSubItem), t, false))
- t = m_sts[lpnmlv->iItem].start;
-
- REFERENCE_TIME rt =
- lpnmlv->iSubItem == COL_START ? ((REFERENCE_TIME)t * 10000) :
- lpnmlv->iSubItem == COL_END ? ((REFERENCE_TIME)t * 10000) :
- lpnmlv->iSubItem == COL_PREVSTART ? ((REFERENCE_TIME)t * 10000) :
- lpnmlv->iSubItem == COL_PREVEND ? ((REFERENCE_TIME)t * 10000) :
- ((REFERENCE_TIME)t * 10000);
-
- pFrame->SeekTo(rt);
- }
- }
-
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+
+ if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0 && (m_mode == VOBSUB || m_mode == TEXTSUB))
+ {
+ if(CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd())
+ {
+ int t = 0;
+ if(!ParseTime(m_list.GetItemText(lpnmlv->iItem, lpnmlv->iSubItem), t, false))
+ t = m_sts[lpnmlv->iItem].start;
+
+ REFERENCE_TIME rt =
+ lpnmlv->iSubItem == COL_START ? ((REFERENCE_TIME)t*10000) :
+ lpnmlv->iSubItem == COL_END ? ((REFERENCE_TIME)t*10000) :
+ lpnmlv->iSubItem == COL_PREVSTART ? ((REFERENCE_TIME)t*10000) :
+ lpnmlv->iSubItem == COL_PREVEND ? ((REFERENCE_TIME)t*10000) :
+ ((REFERENCE_TIME)t*10000);
+
+ pFrame->SeekTo(rt);
+ }
+ }
+
+ *pResult = 0;
}
void CPlayerSubresyncBar::OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
+ LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
- *pResult = 0;
+ *pResult = 0;
}
static CUIntArray m_itemGroups;
@@ -1136,257 +1118,239 @@ static int m_totalGroups;
void CPlayerSubresyncBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
-
- *pResult = CDRF_DODEFAULT;
-
- if(CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
- {
- m_itemGroups.SetSize(m_list.GetItemCount());
- m_totalGroups = 0;
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
- if(m_list.GetItemData(i)&TSEP) m_totalGroups++;
- m_itemGroups[i] = m_totalGroups;
- }
-
- *pResult = CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW;
- }
- else if(CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
- {
- pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
-
- *pResult = CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYSUBITEMDRAW;
- }
- else if((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage)
- {
- COLORREF clrText;
- COLORREF clrTextBk;
-
- if((pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_TEXT || pLVCD->iSubItem == COL_STYLE
- || pLVCD->iSubItem == COL_LAYER || pLVCD->iSubItem == COL_ACTOR || pLVCD->iSubItem == COL_EFFECT)
- && m_mode == TEXTSUB)
- {
- clrText = 0;
- }
- else if((pLVCD->iSubItem == COL_START)
- && m_mode == VOBSUB)
- {
- clrText = 0;
- }
- else
- {
- clrText = 0x606060;
- }
-
- clrTextBk = 0xffffff;
+ NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
+
+ *pResult = CDRF_DODEFAULT;
+
+ if(CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
+ {
+ m_itemGroups.SetSize(m_list.GetItemCount());
+ m_totalGroups = 0;
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
+ {
+ if(m_list.GetItemData(i)&TSEP) m_totalGroups++;
+ m_itemGroups[i] = m_totalGroups;
+ }
+
+ *pResult = CDRF_NOTIFYPOSTPAINT|CDRF_NOTIFYITEMDRAW;
+ }
+ else if(CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
+ {
+ pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
+
+ *pResult = CDRF_NOTIFYPOSTPAINT|CDRF_NOTIFYSUBITEMDRAW;
+ }
+ else if((CDDS_ITEMPREPAINT|CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage)
+ {
+ COLORREF clrText;
+ COLORREF clrTextBk;
+
+ if((pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_TEXT || pLVCD->iSubItem == COL_STYLE
+ || pLVCD->iSubItem == COL_LAYER || pLVCD->iSubItem == COL_ACTOR || pLVCD->iSubItem == COL_EFFECT)
+ && m_mode == TEXTSUB)
+ {
+ clrText = 0;
+ }
+ else if((pLVCD->iSubItem == COL_START)
+ && m_mode == VOBSUB)
+ {
+ clrText = 0;
+ }
+ else
+ {
+ clrText = 0x606060;
+ }
+
+ clrTextBk = 0xffffff;
// if(m_totalGroups > 0)
- clrTextBk -= ((m_itemGroups[pLVCD->nmcd.dwItemSpec] & 1) ? 0x100010 : 0x200020);
-
- if(m_sts[pLVCD->nmcd.dwItemSpec].start <= m_rt / 10000 && m_rt / 10000 < m_sts[pLVCD->nmcd.dwItemSpec].end)
- {
- clrText |= 0xFF;
- }
-
- int nCheck = (int)m_list.GetItemData(pLVCD->nmcd.dwItemSpec);
-
- if((nCheck & 1) && (pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_PREVSTART))
- {
- clrTextBk = 0xffddbb;
- }
- else if((nCheck & 4) && (/*pLVCD->iSubItem == COL_START ||*/ pLVCD->iSubItem == COL_PREVSTART))
- {
- clrTextBk = 0xffeedd;
- }
-
- if((nCheck & 2) && (pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_PREVEND))
- {
- clrTextBk = 0xffddbb;
- }
- else if((nCheck & 8) && (/*pLVCD->iSubItem == COL_END ||*/ pLVCD->iSubItem == COL_PREVEND))
- {
- clrTextBk = 0xffeedd;
- }
-
- pLVCD->clrText = clrText;
- pLVCD->clrTextBk = clrTextBk;
-
- *pResult = CDRF_NOTIFYPOSTPAINT;
- }
- else if((CDDS_ITEMPOSTPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage)
- {
+ clrTextBk -= ((m_itemGroups[pLVCD->nmcd.dwItemSpec]&1) ? 0x100010 : 0x200020);
+
+ if(m_sts[pLVCD->nmcd.dwItemSpec].start <= m_rt/10000 && m_rt/10000 < m_sts[pLVCD->nmcd.dwItemSpec].end)
+ {
+ clrText |= 0xFF;
+ }
+
+ int nCheck = (int)m_list.GetItemData(pLVCD->nmcd.dwItemSpec);
+
+ if((nCheck&1) && (pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_PREVSTART))
+ {
+ clrTextBk = 0xffddbb;
+ }
+ else if((nCheck&4) && (/*pLVCD->iSubItem == COL_START ||*/ pLVCD->iSubItem == COL_PREVSTART))
+ {
+ clrTextBk = 0xffeedd;
+ }
+
+ if((nCheck&2) && (pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_PREVEND))
+ {
+ clrTextBk = 0xffddbb;
+ }
+ else if((nCheck&8) && (/*pLVCD->iSubItem == COL_END ||*/ pLVCD->iSubItem == COL_PREVEND))
+ {
+ clrTextBk = 0xffeedd;
+ }
+
+ pLVCD->clrText = clrText;
+ pLVCD->clrTextBk = clrTextBk;
+
+ *pResult = CDRF_NOTIFYPOSTPAINT;
+ }
+ else if((CDDS_ITEMPOSTPAINT|CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage)
+ {
// *pResult = CDRF_DODEFAULT;
- }
- else if(CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage)
- {
+ }
+ else if(CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage)
+ {
int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec);
- LVITEM rItem;
+ LVITEM rItem;
ZeroMemory(&rItem, sizeof(LVITEM));
rItem.mask = LVIF_IMAGE | LVIF_STATE;
rItem.iItem = nItem;
rItem.stateMask = LVIS_SELECTED;
m_list.GetItem(&rItem);
- {
+ {
CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
- CRect rcItem;
+ CRect rcItem;
m_list.GetItemRect(nItem, &rcItem, LVIR_BOUNDS);
- {
- bool fSeparator = nItem < m_list.GetItemCount() - 1 && (m_list.GetItemData(nItem + 1)&TSEP);
- CPen p(PS_INSIDEFRAME, 1, fSeparator ? 0x404040 : 0xe0e0e0);
- CPen* old = pDC->SelectObject(&p);
- pDC->MoveTo(CPoint(rcItem.left, rcItem.bottom - 1));
- pDC->LineTo(CPoint(rcItem.right, rcItem.bottom - 1));
- pDC->SelectObject(old);
- }
-
- {
- CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
- CPen* old = pDC->SelectObject(&p);
-
- CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
-
- // Get the column offset
- int offset = rcItem.left;
- for(int i = 0; i < nColumnCount; i++)
- {
- offset += m_list.GetColumnWidth(i);
- pDC->MoveTo(CPoint(offset, rcItem.top));
- pDC->LineTo(CPoint(offset, rcItem.bottom));
- }
-
- pDC->SelectObject(old);
- }
+ {
+ bool fSeparator = nItem < m_list.GetItemCount()-1 && (m_list.GetItemData(nItem+1)&TSEP);
+ CPen p(PS_INSIDEFRAME, 1, fSeparator ? 0x404040 : 0xe0e0e0);
+ CPen* old = pDC->SelectObject(&p);
+ pDC->MoveTo(CPoint(rcItem.left, rcItem.bottom-1));
+ pDC->LineTo(CPoint(rcItem.right, rcItem.bottom-1));
+ pDC->SelectObject(old);
+ }
+
+ {
+ CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
+ CPen* old = pDC->SelectObject(&p);
+
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
+
+ // Get the column offset
+ int offset = rcItem.left;
+ for(int i = 0; i < nColumnCount; i++)
+ {
+ offset += m_list.GetColumnWidth(i);
+ pDC->MoveTo(CPoint(offset, rcItem.top));
+ pDC->LineTo(CPoint(offset, rcItem.bottom));
+ }
+
+ pDC->SelectObject(old);
+ }
*pResult = CDRF_SKIPDEFAULT;
}
- }
- else if(CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage)
- {
- }
+ }
+ else if(CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage)
+ {
+ }
}
bool CPlayerSubresyncBar::IsShortCut(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN && VK_F1 <= pMsg->wParam && pMsg->wParam <= VK_F6)
- {
- int iItem = -1;
-
- bool fNeedsUpdate = false;
- bool fStep = false;
-
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- while(pos)
- {
- iItem = m_list.GetNextSelectedItem(pos);
-
- SubTime& st = m_subtimes[iItem];
-
- switch(pMsg->wParam)
- {
- case VK_F1: /*if(*/
- ModStart(iItem, st.orgstart, true);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F3: /*if(*/
- ModStart(iItem, st.orgstart);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F5: /*if(*/
- ModStart(iItem, (int)(m_rt / 10000));/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F2: /*if(*/
- ModEnd(iItem, st.orgend, true);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F4: /*if(*/
- ModEnd(iItem, st.orgend);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F6: /*if(*/
- ModEnd(iItem, (int)(m_rt / 10000));/*)*/
- fNeedsUpdate = fStep = true;
- break;
- }
- }
-
- if(fNeedsUpdate)
- {
- if(fStep && m_list.GetSelectedCount() == 1 && iItem < m_list.GetItemCount() - 1)
- {
- m_list.SetItemState(iItem, 0, LVIS_SELECTED);
- m_list.SetItemState(iItem + 1, LVIS_SELECTED, LVIS_SELECTED);
- m_list.SetSelectionMark(iItem + 1);
- m_list.EnsureVisible(iItem + 1, false);
- }
-
- UpdatePreview();
-
- return true;
- }
- }
-
- return false;
+ if(pMsg->message == WM_KEYDOWN && VK_F1 <= pMsg->wParam && pMsg->wParam <= VK_F6)
+ {
+ int iItem = -1;
+
+ bool fNeedsUpdate = false;
+ bool fStep = false;
+
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ while(pos)
+ {
+ iItem = m_list.GetNextSelectedItem(pos);
+
+ SubTime& st = m_subtimes[iItem];
+
+ switch(pMsg->wParam)
+ {
+ case VK_F1: /*if(*/ModStart(iItem, st.orgstart, true);/*)*/ fNeedsUpdate = true; break;
+ case VK_F3: /*if(*/ModStart(iItem, st.orgstart);/*)*/ fNeedsUpdate = true; break;
+ case VK_F5: /*if(*/ModStart(iItem, (int)(m_rt/10000));/*)*/ fNeedsUpdate = true; break;
+ case VK_F2: /*if(*/ModEnd(iItem, st.orgend, true);/*)*/ fNeedsUpdate = true; break;
+ case VK_F4: /*if(*/ModEnd(iItem, st.orgend);/*)*/ fNeedsUpdate = true; break;
+ case VK_F6: /*if(*/ModEnd(iItem, (int)(m_rt/10000));/*)*/ fNeedsUpdate = fStep = true; break;
+ }
+ }
+
+ if(fNeedsUpdate)
+ {
+ if(fStep && m_list.GetSelectedCount() == 1 && iItem < m_list.GetItemCount()-1)
+ {
+ m_list.SetItemState(iItem, 0, LVIS_SELECTED);
+ m_list.SetItemState(iItem+1, LVIS_SELECTED, LVIS_SELECTED);
+ m_list.SetSelectionMark(iItem+1);
+ m_list.EnsureVisible(iItem+1, false);
+ }
+
+ UpdatePreview();
+
+ return true;
+ }
+ }
+
+ return false;
}
int CPlayerSubresyncBar::FindNearestSub(__int64& rtPos, bool bForward)
{
- long lCurTime = rtPos / 10000 + (bForward ? 1 : -1);
-
- if(m_subtimes.GetCount() == 0)
- {
- rtPos = max(0, rtPos + (bForward ? 1 : -1) * 50000000);
- return -2;
- }
-
- if(lCurTime < m_subtimes[0].newstart)
- {
- rtPos = m_subtimes[0].newstart * 10000;
- return 0;
- }
-
- for(int i = 1, j = m_sts.GetCount(); i < j; i++)
- {
- if((lCurTime >= m_subtimes[i-1].newstart) && (lCurTime < m_subtimes[i].newstart))
- {
- rtPos = bForward ? (__int64)m_subtimes[i].newstart * 10000 : (__int64)m_subtimes[i-1].newstart * 10000;
- return bForward ? i : i - 1;
- }
- }
-
- return -1;
+ long lCurTime = rtPos / 10000 + (bForward ? 1 : -1);
+
+ if (m_subtimes.GetCount() == 0)
+ {
+ rtPos = max (0, rtPos + (bForward ? 1 : -1) * 50000000);
+ return -2;
+ }
+
+ if (lCurTime < m_subtimes[0].newstart)
+ {
+ rtPos = m_subtimes[0].newstart * 10000;
+ return 0;
+ }
+
+ for(int i = 1, j = m_sts.GetCount(); i < j; i++)
+ {
+ if ((lCurTime >= m_subtimes[i-1].newstart) && (lCurTime < m_subtimes[i].newstart))
+ {
+ rtPos = bForward ? (__int64)m_subtimes[i].newstart * 10000 : (__int64)m_subtimes[i-1].newstart * 10000;
+ return bForward ? i : i-1;
+ }
+ }
+
+ return -1;
}
bool CPlayerSubresyncBar::ShiftSubtitle(int nItem, long lValue, __int64& rtPos)
{
- bool bRet = false;
-
- if((nItem == 0) || (m_subtimes[nItem-1].newend < m_subtimes[nItem].newstart + lValue))
- {
- for(int i = nItem; i < m_sts.GetCount(); i++)
- {
- m_subtimes[i].newstart += lValue;
- m_subtimes[i].newend += lValue;
- m_subtimes[i].orgstart += lValue;
- m_subtimes[i].orgend += lValue;
- }
- UpdatePreview();
- SaveSubtitle();
- bRet = true;
- rtPos = (__int64)m_subtimes[nItem].newstart * 10000;
- }
- return bRet;
+ bool bRet = false;
+
+ if ((nItem == 0) || (m_subtimes[nItem-1].newend < m_subtimes[nItem].newstart + lValue))
+ {
+ for (int i= nItem; i<m_sts.GetCount(); i++)
+ {
+ m_subtimes[i].newstart += lValue;
+ m_subtimes[i].newend += lValue;
+ m_subtimes[i].orgstart += lValue;
+ m_subtimes[i].orgend += lValue;
+ }
+ UpdatePreview();
+ SaveSubtitle();
+ bRet = true;
+ rtPos = (__int64)m_subtimes[nItem].newstart * 10000;
+ }
+ return bRet;
}
bool CPlayerSubresyncBar::SaveToDisk()
{
- return m_sts.SaveAs(m_sts.m_path, m_sts.m_exttype);
+ return m_sts.SaveAs (m_sts.m_path, m_sts.m_exttype);
}
diff --git a/src/apps/mplayerc/PlayerSubresyncBar.h b/src/apps/mplayerc/PlayerSubresyncBar.h
index fd1fb7a2e..e9ecdaba7 100644
--- a/src/apps/mplayerc/PlayerSubresyncBar.h
+++ b/src/apps/mplayerc/PlayerSubresyncBar.h
@@ -33,86 +33,83 @@
class CPlayerSubresyncBar : public CSizingControlBarG
{
- DECLARE_DYNAMIC(CPlayerSubresyncBar)
+ DECLARE_DYNAMIC(CPlayerSubresyncBar)
private:
- CPlayerListCtrl m_list;
+ CPlayerListCtrl m_list;
- CFont m_font;
+ CFont m_font;
CCritSec* m_pSubLock;
- CComPtr<ISubStream> m_pSubStream;
+ CComPtr<ISubStream> m_pSubStream;
- int m_lastSegment;
- __int64 m_rt;
+ int m_lastSegment;
+ __int64 m_rt;
- enum
- {
- // TEXTSUB
- COL_START = 0, COL_END, COL_PREVSTART, COL_PREVEND, COL_TEXT, COL_STYLE, COL_FONT, COL_CHARSET, COL_UNICODE, COL_LAYER, COL_ACTOR, COL_EFFECT,
- // VOBSUB
- /* ........... same as TEXTSUB ............. */ COL_VOBID = COL_TEXT, COL_CELLID, COL_FORCED,
- };
+ enum
+ {
+ // TEXTSUB
+ COL_START=0, COL_END, COL_PREVSTART, COL_PREVEND, COL_TEXT, COL_STYLE, COL_FONT, COL_CHARSET, COL_UNICODE, COL_LAYER, COL_ACTOR, COL_EFFECT,
+ // VOBSUB
+ /* ........... same as TEXTSUB ............. */ COL_VOBID=COL_TEXT, COL_CELLID, COL_FORCED,
+ };
- enum {NONE = 0, VOBSUB, TEXTSUB};
- int m_mode;
+ enum {NONE = 0, VOBSUB, TEXTSUB};
+ int m_mode;
- bool m_fUnlink;
+ bool m_fUnlink;
- typedef struct
- {
- int orgstart, newstart, orgend, newend;
- } SubTime;
- CAtlArray<SubTime> m_subtimes;
+ typedef struct {int orgstart, newstart, orgend, newend;} SubTime;
+ CAtlArray<SubTime> m_subtimes;
// CRenderedTextSubtitle m_sts;
- CSimpleTextSubtitle m_sts;
+ CSimpleTextSubtitle m_sts;
- int GetStartTime(int iItem), GetEndTime(int iItem);
- void FormatTime(int iItem, TCHAR* buff, int time /* 0:start, 1:newstart, 2:preview */, bool fEnd);
+ int GetStartTime(int iItem), GetEndTime(int iItem);
+ void FormatTime(int iItem, TCHAR* buff, int time /* 0:start, 1:newstart, 2:preview */, bool fEnd);
- void UpdatePreview(), UpdateStrings();
+ void UpdatePreview(), UpdateStrings();
- enum {TSMOD = 1, TEMOD = 2, TSADJ = 4, TEADJ = 8, TSEP = 0x80000000};
+ enum {TSMOD=1, TEMOD=2, TSADJ=4, TEADJ=8, TSEP=0x80000000};
- void GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bool& fStartAdj, bool& fEndAdj);
- void SetCheck(int iItem, bool fStart, bool fEnd);
+ void GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bool& fStartAdj, bool& fEndAdj);
+ void SetCheck(int iItem, bool fStart, bool fEnd);
- bool ModStart(int iItem, int t, bool fReset = false);
- bool ModEnd(int iItem, int t, bool fReset = false);
+ bool ModStart(int iItem, int t, bool fReset = false);
+ bool ModEnd(int iItem, int t, bool fReset = false);
public:
- CPlayerSubresyncBar();
- virtual ~CPlayerSubresyncBar();
+ CPlayerSubresyncBar();
+ virtual ~CPlayerSubresyncBar();
- BOOL Create(CWnd* pParentWnd, CCritSec* pSubLock);
+ BOOL Create(CWnd* pParentWnd, CCritSec* pSubLock);
- void SetTime(__int64 rt);
+ void SetTime(__int64 rt);
- void SetSubtitle(ISubStream* pSubStream, double fps);
- void ResetSubtitle();
- void SaveSubtitle();
+ void SetSubtitle(ISubStream* pSubStream, double fps);
+ void ResetSubtitle();
+ void SaveSubtitle();
- int FindNearestSub(__int64& rtPos, bool bForward);
- bool ShiftSubtitle(int nItem, long lValue, __int64& rtPos);
- bool SaveToDisk();
+ int FindNearestSub(__int64& rtPos, bool bForward);
+ bool ShiftSubtitle(int nItem, long lValue, __int64& rtPos);
+ bool SaveToDisk();
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+
+ bool IsShortCut(MSG* pMsg);
- bool IsShortCut(MSG* pMsg);
-
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnRclickList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnRclickList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/apps/mplayerc/PlayerToolBar.cpp b/src/apps/mplayerc/PlayerToolBar.cpp
index 7703ceef5..a8701a979 100644
--- a/src/apps/mplayerc/PlayerToolBar.cpp
+++ b/src/apps/mplayerc/PlayerToolBar.cpp
@@ -29,7 +29,7 @@
#include "PlayerToolBar.h"
#include "MainFrm.h"
-typedef HRESULT(__stdcall * SetWindowThemeFunct)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
+typedef HRESULT (__stdcall * SetWindowThemeFunct)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
// CPlayerToolBar
@@ -45,276 +45,276 @@ CPlayerToolBar::~CPlayerToolBar()
BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
{
- if(!__super::CreateEx(pParentWnd,
- TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_AUTOSIZE,
- WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM | CBRS_TOOLTIPS, CRect(2, 2, 0, 3))
- || !LoadToolBar(IDB_PLAYERTOOLBAR))
- return FALSE;
-
- GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
-
- CToolBarCtrl& tb = GetToolBarCtrl();
- tb.DeleteButton(tb.GetButtonCount() - 1);
- tb.DeleteButton(tb.GetButtonCount() - 1);
-
- SetMute(AfxGetAppSettings().fMute);
-
- UINT styles[] =
- {
- TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP,
- TBBS_SEPARATOR,
- TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
- TBBS_SEPARATOR,
- TBBS_BUTTON/*|TBSTYLE_DROPDOWN*/,
- TBBS_SEPARATOR,
- TBBS_SEPARATOR,
- TBBS_CHECKBOX,
- /*TBBS_SEPARATOR,*/
- };
-
- for(int i = 0; i < countof(styles); i++)
- SetButtonStyle(i, styles[i] | TBBS_DISABLED);
-
- m_volctrl.Create(this);
-
- if(AfxGetAppSettings().fDisableXPToolbars)
- {
- if(HMODULE h = LoadLibrary(_T("uxtheme.dll")))
- {
- SetWindowThemeFunct f = (SetWindowThemeFunct)GetProcAddress(h, "SetWindowTheme");
- if(f) f(m_hWnd, L" ", L" ");
- FreeLibrary(h);
- }
- }
-
- // quick and dirty code from foxx1337; will leak, but don't care yet
- m_nButtonHeight = 16; // hardcoded from MainFrm.cpp - DEFCLIENTW; min width should be 9 * button width + 60 + 91
- HBITMAP hBmp = static_cast<HBITMAP>(::LoadImage(NULL, _T("toolbar.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION));
- if(NULL != hBmp)
- {
- CBitmap *bmp = new CBitmap();
- bmp->Attach(hBmp);
- BITMAP bitmapBmp;
- bmp->GetBitmap(&bitmapBmp);
- if(bitmapBmp.bmWidth == bitmapBmp.bmHeight * 15)
- {
- // the manual specifies that sizeButton should be sizeImage inflated by (7, 6)
- SetSizes(CSize(bitmapBmp.bmHeight + 7, bitmapBmp.bmHeight + 6), CSize(bitmapBmp.bmHeight, bitmapBmp.bmHeight));
-
- CDC dc;
- dc.CreateCompatibleDC(NULL);
-
- BITMAPINFOHEADER bih;
- bih.biSize = sizeof(BITMAPINFOHEADER);
- GetDIBits(dc, hBmp, 0, 0, NULL, reinterpret_cast<BITMAPINFO*>(&bih), DIB_RGB_COLORS);
- int fileDepth = bih.biBitCount;
- CImageList *imageList = new CImageList();
- if(32 == fileDepth)
- {
- imageList->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
- imageList->Add(bmp, static_cast<CBitmap*>(0)); // alpha is the mask
- }
- else
- {
- imageList->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR24 | ILC_MASK, 1, 0);
- imageList->Add(bmp, RGB(255, 0, 255));
- }
- m_nButtonHeight = bitmapBmp.bmHeight;
- GetToolBarCtrl().SetImageList(imageList);
- }
- delete bmp;
- DeleteObject(hBmp);
- }
-
- return TRUE;
+ if(!__super::CreateEx(pParentWnd,
+ TBSTYLE_FLAT|TBSTYLE_TRANSPARENT|TBSTYLE_AUTOSIZE,
+ WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM|CBRS_TOOLTIPS, CRect(2,2,0,3))
+ || !LoadToolBar(IDB_PLAYERTOOLBAR))
+ return FALSE;
+
+ GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
+
+ CToolBarCtrl& tb = GetToolBarCtrl();
+ tb.DeleteButton(tb.GetButtonCount()-1);
+ tb.DeleteButton(tb.GetButtonCount()-1);
+
+ SetMute(AfxGetAppSettings().fMute);
+
+ UINT styles[] =
+ {
+ TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP,
+ TBBS_SEPARATOR,
+ TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
+ TBBS_SEPARATOR,
+ TBBS_BUTTON/*|TBSTYLE_DROPDOWN*/,
+ TBBS_SEPARATOR,
+ TBBS_SEPARATOR,
+ TBBS_CHECKBOX,
+ /*TBBS_SEPARATOR,*/
+ };
+
+ for(int i = 0; i < countof(styles); i++)
+ SetButtonStyle(i, styles[i]|TBBS_DISABLED);
+
+ m_volctrl.Create(this);
+
+ if(AfxGetAppSettings().fDisableXPToolbars)
+ {
+ if(HMODULE h = LoadLibrary(_T("uxtheme.dll")))
+ {
+ SetWindowThemeFunct f = (SetWindowThemeFunct)GetProcAddress(h, "SetWindowTheme");
+ if(f) f(m_hWnd, L" ", L" ");
+ FreeLibrary(h);
+ }
+ }
+
+ // quick and dirty code from foxx1337; will leak, but don't care yet
+ m_nButtonHeight = 16; // hardcoded from MainFrm.cpp - DEFCLIENTW; min width should be 9 * button width + 60 + 91
+ HBITMAP hBmp = static_cast<HBITMAP>(::LoadImage(NULL, _T("toolbar.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION));
+ if(NULL != hBmp)
+ {
+ CBitmap *bmp = new CBitmap();
+ bmp->Attach(hBmp);
+ BITMAP bitmapBmp;
+ bmp->GetBitmap(&bitmapBmp);
+ if(bitmapBmp.bmWidth == bitmapBmp.bmHeight * 15)
+ {
+ // the manual specifies that sizeButton should be sizeImage inflated by (7, 6)
+ SetSizes(CSize(bitmapBmp.bmHeight + 7, bitmapBmp.bmHeight + 6), CSize(bitmapBmp.bmHeight, bitmapBmp.bmHeight));
+
+ CDC dc;
+ dc.CreateCompatibleDC(NULL);
+
+ BITMAPINFOHEADER bih;
+ bih.biSize = sizeof(BITMAPINFOHEADER);
+ GetDIBits(dc, hBmp, 0, 0, NULL, reinterpret_cast<BITMAPINFO*>(&bih), DIB_RGB_COLORS);
+ int fileDepth = bih.biBitCount;
+ CImageList *imageList = new CImageList();
+ if(32 == fileDepth)
+ {
+ imageList->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
+ imageList->Add(bmp, static_cast<CBitmap*>(0)); // alpha is the mask
+ }
+ else
+ {
+ imageList->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR24 | ILC_MASK, 1, 0);
+ imageList->Add(bmp, RGB(255, 0, 255));
+ }
+ m_nButtonHeight = bitmapBmp.bmHeight;
+ GetToolBarCtrl().SetImageList(imageList);
+ }
+ delete bmp;
+ DeleteObject(hBmp);
+ }
+
+ return TRUE;
}
BOOL CPlayerToolBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!__super::PreCreateWindow(cs))
- return FALSE;
+ if(!__super::PreCreateWindow(cs))
+ return FALSE;
- m_dwStyle &= ~CBRS_BORDER_TOP;
- m_dwStyle &= ~CBRS_BORDER_BOTTOM;
+ m_dwStyle &= ~CBRS_BORDER_TOP;
+ m_dwStyle &= ~CBRS_BORDER_BOTTOM;
// m_dwStyle |= CBRS_SIZE_FIXED;
- return TRUE;
+ return TRUE;
}
void CPlayerToolBar::ArrangeControls()
{
- if(!::IsWindow(m_volctrl.m_hWnd)) return;
+ if(!::IsWindow(m_volctrl.m_hWnd)) return;
- CRect r;
- GetClientRect(&r);
+ CRect r;
+ GetClientRect(&r);
- CRect br = GetBorders();
+ CRect br = GetBorders();
- CRect r10;
- GetItemRect(10, &r10);
+ CRect r10;
+ GetItemRect(10, &r10);
- CRect vr;
- m_volctrl.GetClientRect(&vr);
- CRect vr2(r.right + br.right - 60, r.bottom - 25, r.right + br.right + 6, r.bottom);
- m_volctrl.MoveWindow(vr2);
+ CRect vr;
+ m_volctrl.GetClientRect(&vr);
+ CRect vr2(r.right + br.right - 60, r.bottom - 25, r.right +br.right + 6, r.bottom);
+ m_volctrl.MoveWindow(vr2);
- UINT nID;
- UINT nStyle;
- int iImage;
- GetButtonInfo(12, nID, nStyle, iImage);
- SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr2.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
+ UINT nID;
+ UINT nStyle;
+ int iImage;
+ GetButtonInfo(12, nID, nStyle, iImage);
+ SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr2.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
}
void CPlayerToolBar::SetMute(bool fMute)
{
- CToolBarCtrl& tb = GetToolBarCtrl();
- TBBUTTONINFO bi;
- bi.cbSize = sizeof(bi);
- bi.dwMask = TBIF_IMAGE;
- bi.iImage = fMute ? 13 : 12;
- tb.SetButtonInfo(ID_VOLUME_MUTE, &bi);
-
- AfxGetAppSettings().fMute = fMute;
+ CToolBarCtrl& tb = GetToolBarCtrl();
+ TBBUTTONINFO bi;
+ bi.cbSize = sizeof(bi);
+ bi.dwMask = TBIF_IMAGE;
+ bi.iImage = fMute?13:12;
+ tb.SetButtonInfo(ID_VOLUME_MUTE, &bi);
+
+ AfxGetAppSettings().fMute = fMute;
}
bool CPlayerToolBar::IsMuted()
{
- CToolBarCtrl& tb = GetToolBarCtrl();
- TBBUTTONINFO bi;
- bi.cbSize = sizeof(bi);
- bi.dwMask = TBIF_IMAGE;
- tb.GetButtonInfo(ID_VOLUME_MUTE, &bi);
- return(bi.iImage == 13);
+ CToolBarCtrl& tb = GetToolBarCtrl();
+ TBBUTTONINFO bi;
+ bi.cbSize = sizeof(bi);
+ bi.dwMask = TBIF_IMAGE;
+ tb.GetButtonInfo(ID_VOLUME_MUTE, &bi);
+ return(bi.iImage==13);
}
int CPlayerToolBar::GetVolume()
{
- int volume = m_volctrl.GetPos();
- volume = (int)((log10(1.0 * volume) - 2) * 5000);
- volume = max(min(volume, 0), -10000);
- return(IsMuted() ? -10000 : volume);
+ int volume = m_volctrl.GetPos();
+ volume = (int)((log10(1.0*volume)-2)*5000);
+ volume = max(min(volume, 0), -10000);
+ return(IsMuted() ? -10000 : volume);
}
int CPlayerToolBar::GetMinWidth()
{
- return m_nButtonHeight * 9 + 151;
+ return m_nButtonHeight * 9 + 151;
}
void CPlayerToolBar::SetVolume(int volume)
{
- /*
- volume = (int)pow(10, ((double)volume)/5000+2);
- volume = max(min(volume, 100), 1);
- */
- m_volctrl.SetPosInternal(volume);
+/*
+ volume = (int)pow(10, ((double)volume)/5000+2);
+ volume = max(min(volume, 100), 1);
+*/
+ m_volctrl.SetPosInternal(volume);
}
BEGIN_MESSAGE_MAP(CPlayerToolBar, CToolBar)
- ON_WM_PAINT()
- ON_WM_SIZE()
- ON_MESSAGE_VOID(WM_INITIALUPDATE, OnInitialUpdate)
- ON_COMMAND_EX(ID_VOLUME_MUTE, OnVolumeMute)
- ON_UPDATE_COMMAND_UI(ID_VOLUME_MUTE, OnUpdateVolumeMute)
- ON_COMMAND_EX(ID_VOLUME_UP, OnVolumeUp)
- ON_COMMAND_EX(ID_VOLUME_DOWN, OnVolumeDown)
- ON_WM_NCPAINT()
- ON_WM_LBUTTONDOWN()
+ ON_WM_PAINT()
+ ON_WM_SIZE()
+ ON_MESSAGE_VOID(WM_INITIALUPDATE, OnInitialUpdate)
+ ON_COMMAND_EX(ID_VOLUME_MUTE, OnVolumeMute)
+ ON_UPDATE_COMMAND_UI(ID_VOLUME_MUTE, OnUpdateVolumeMute)
+ ON_COMMAND_EX(ID_VOLUME_UP, OnVolumeUp)
+ ON_COMMAND_EX(ID_VOLUME_DOWN, OnVolumeDown)
+ ON_WM_NCPAINT()
+ ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CPlayerToolBar message handlers
void CPlayerToolBar::OnPaint()
{
- if(m_bDelayedButtonLayout)
- Layout();
-
- CPaintDC dc(this); // device context for painting
-
- DefWindowProc(WM_PAINT, WPARAM(dc.m_hDC), 0);
-
- {
- UINT nID;
- UINT nStyle = 0;
- int iImage = 0;
- GetButtonInfo(11, nID, nStyle, iImage);
- CRect ItemRect;
- GetItemRect(11, ItemRect);
- dc.FillSolidRect(ItemRect, GetSysColor(COLOR_BTNFACE));
- }
+ if(m_bDelayedButtonLayout)
+ Layout();
+
+ CPaintDC dc(this); // device context for painting
+
+ DefWindowProc(WM_PAINT, WPARAM(dc.m_hDC), 0);
+
+ {
+ UINT nID;
+ UINT nStyle = 0;
+ int iImage = 0;
+ GetButtonInfo(11, nID, nStyle, iImage);
+ CRect ItemRect;
+ GetItemRect(11, ItemRect);
+ dc.FillSolidRect(ItemRect, GetSysColor(COLOR_BTNFACE));
+ }
}
void CPlayerToolBar::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- ArrangeControls();
+ ArrangeControls();
}
void CPlayerToolBar::OnInitialUpdate()
{
- ArrangeControls();
+ ArrangeControls();
}
BOOL CPlayerToolBar::OnVolumeMute(UINT nID)
{
- SetMute(!IsMuted());
- return FALSE;
+ SetMute(!IsMuted());
+ return FALSE;
}
void CPlayerToolBar::OnUpdateVolumeMute(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(true);
- pCmdUI->SetCheck(IsMuted());
+ pCmdUI->Enable(true);
+ pCmdUI->SetCheck(IsMuted());
}
BOOL CPlayerToolBar::OnVolumeUp(UINT nID)
{
- m_volctrl.IncreaseVolume();
- return FALSE;
+ m_volctrl.IncreaseVolume();
+ return FALSE;
}
BOOL CPlayerToolBar::OnVolumeDown(UINT nID)
{
- m_volctrl.DecreaseVolume();
- return FALSE;
+ m_volctrl.DecreaseVolume();
+ return FALSE;
}
void CPlayerToolBar::OnNcPaint() // when using XP styles the NC area isn't drawn for our toolbar...
{
- CRect wr, cr;
-
- CWindowDC dc(this);
- GetClientRect(&cr);
- ClientToScreen(&cr);
- GetWindowRect(&wr);
- cr.OffsetRect(-wr.left, -wr.top);
- wr.OffsetRect(-wr.left, -wr.top);
- dc.ExcludeClipRect(&cr);
- dc.FillSolidRect(wr, GetSysColor(COLOR_BTNFACE));
-
- // Do not call CToolBar::OnNcPaint() for painting messages
+ CRect wr, cr;
+
+ CWindowDC dc(this);
+ GetClientRect(&cr);
+ ClientToScreen(&cr);
+ GetWindowRect(&wr);
+ cr.OffsetRect(-wr.left, -wr.top);
+ wr.OffsetRect(-wr.left, -wr.top);
+ dc.ExcludeClipRect(&cr);
+ dc.FillSolidRect(wr, GetSysColor(COLOR_BTNFACE));
+
+ // Do not call CToolBar::OnNcPaint() for painting messages
}
void CPlayerToolBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- for(int i = 0, j = GetToolBarCtrl().GetButtonCount(); i < j; i++)
- {
- if(GetButtonStyle(i)&(TBBS_SEPARATOR | TBBS_DISABLED))
- continue;
-
- CRect r;
- GetItemRect(i, r);
- if(r.PtInRect(point))
- {
- __super::OnLButtonDown(nFlags, point);
- return;
- }
- }
-
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if(!pFrame->m_fFullScreen)
- {
- MapWindowPoints(pFrame, &point, 1);
- pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- }
+ for(int i = 0, j = GetToolBarCtrl().GetButtonCount(); i < j; i++)
+ {
+ if(GetButtonStyle(i)&(TBBS_SEPARATOR|TBBS_DISABLED))
+ continue;
+
+ CRect r;
+ GetItemRect(i, r);
+ if(r.PtInRect(point))
+ {
+ __super::OnLButtonDown(nFlags, point);
+ return;
+ }
+ }
+
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if(!pFrame->m_fFullScreen)
+ {
+ MapWindowPoints(pFrame, &point, 1);
+ pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
+ }
}
diff --git a/src/apps/mplayerc/PlayerToolBar.h b/src/apps/mplayerc/PlayerToolBar.h
index 3b64bda2a..54063bbf1 100644
--- a/src/apps/mplayerc/PlayerToolBar.h
+++ b/src/apps/mplayerc/PlayerToolBar.h
@@ -30,45 +30,45 @@
class CPlayerToolBar : public CToolBar
{
- DECLARE_DYNAMIC(CPlayerToolBar)
+ DECLARE_DYNAMIC(CPlayerToolBar)
private:
- bool IsMuted();
- void SetMute(bool fMute = true);
- int m_nButtonHeight;
+ bool IsMuted();
+ void SetMute(bool fMute = true);
+ int m_nButtonHeight;
public:
- CPlayerToolBar();
- virtual ~CPlayerToolBar();
+ CPlayerToolBar();
+ virtual ~CPlayerToolBar();
- int GetVolume();
- int GetMinWidth();
- void SetVolume(int volume);
- __declspec(property(get = GetVolume, put = SetVolume)) int Volume;
+ int GetVolume();
+ int GetMinWidth();
+ void SetVolume(int volume);
+ __declspec(property(get=GetVolume, put=SetVolume)) int Volume;
- void ArrangeControls();
+ void ArrangeControls();
- CVolumeCtrl m_volctrl;
+ CVolumeCtrl m_volctrl;
// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CPlayerToolBar)
- virtual BOOL Create(CWnd* pParentWnd);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- //}}AFX_VIRTUAL
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CPlayerToolBar)
+ virtual BOOL Create(CWnd* pParentWnd);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ //}}AFX_VIRTUAL
// Generated message map functions
protected:
- //{{AFX_MSG(CPlayerToolBar)
- afx_msg void OnPaint();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnInitialUpdate();
- afx_msg BOOL OnVolumeMute(UINT nID);
- afx_msg void OnUpdateVolumeMute(CCmdUI* pCmdUI);
- afx_msg BOOL OnVolumeUp(UINT nID);
- afx_msg BOOL OnVolumeDown(UINT nID);
- afx_msg void OnNcPaint();
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CPlayerToolBar)
+ afx_msg void OnPaint();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnInitialUpdate();
+ afx_msg BOOL OnVolumeMute(UINT nID);
+ afx_msg void OnUpdateVolumeMute(CCmdUI* pCmdUI);
+ afx_msg BOOL OnVolumeUp(UINT nID);
+ afx_msg BOOL OnVolumeDown(UINT nID);
+ afx_msg void OnNcPaint();
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/apps/mplayerc/Playlist.cpp b/src/apps/mplayerc/Playlist.cpp
index e966eafc8..b0e8bc006 100644
--- a/src/apps/mplayerc/Playlist.cpp
+++ b/src/apps/mplayerc/Playlist.cpp
@@ -33,14 +33,14 @@
UINT CPlaylistItem::m_globalid = 0;
CPlaylistItem::CPlaylistItem()
- : m_type(file)
- , m_fInvalid(false)
- , m_duration(0)
- , m_vinput(-1)
- , m_vchannel(-1)
- , m_ainput(-1)
+ : m_type(file)
+ , m_fInvalid(false)
+ , m_duration(0)
+ , m_vinput(-1)
+ , m_vchannel(-1)
+ , m_ainput(-1)
{
- m_id = m_globalid++;
+ m_id = m_globalid++;
}
CPlaylistItem::~CPlaylistItem()
@@ -49,83 +49,83 @@ CPlaylistItem::~CPlaylistItem()
CPlaylistItem::CPlaylistItem(const CPlaylistItem& pli)
{
- *this = pli;
+ *this = pli;
}
CPlaylistItem& CPlaylistItem::operator = (const CPlaylistItem& pli)
{
- m_id = pli.m_id;
- m_label = pli.m_label;
- m_fns.RemoveAll();
- m_fns.AddTailList(&pli.m_fns);
- m_subs.RemoveAll();
- m_subs.AddTailList(&pli.m_subs);
- m_type = pli.m_type;
- m_fInvalid = pli.m_fInvalid;
- m_duration = pli.m_duration;
- m_vinput = pli.m_vinput;
- m_vchannel = pli.m_vchannel;
- m_ainput = pli.m_ainput;
- return(*this);
+ m_id = pli.m_id;
+ m_label = pli.m_label;
+ m_fns.RemoveAll();
+ m_fns.AddTailList(&pli.m_fns);
+ m_subs.RemoveAll();
+ m_subs.AddTailList(&pli.m_subs);
+ m_type = pli.m_type;
+ m_fInvalid = pli.m_fInvalid;
+ m_duration = pli.m_duration;
+ m_vinput = pli.m_vinput;
+ m_vchannel = pli.m_vchannel;
+ m_ainput = pli.m_ainput;
+ return(*this);
}
POSITION CPlaylistItem::FindFile(LPCTSTR path)
{
- POSITION pos = m_fns.GetHeadPosition();
- while(pos)
- {
- if(m_fns.GetAt(pos).CompareNoCase(path) == 0)
- return pos;
- m_fns.GetNext(pos);
- }
- return(NULL);
+ POSITION pos = m_fns.GetHeadPosition();
+ while(pos)
+ {
+ if (m_fns.GetAt(pos).CompareNoCase(path) == 0)
+ return pos;
+ m_fns.GetNext(pos);
+ }
+ return(NULL);
}
static CString StripPath(CString path)
{
- CString p = path;
- p.Replace('\\', '/');
- p = p.Mid(p.ReverseFind('/') + 1);
- return(p.IsEmpty() ? path : p);
+ CString p = path;
+ p.Replace('\\', '/');
+ p = p.Mid(p.ReverseFind('/')+1);
+ return(p.IsEmpty() ? path : p);
}
CString CPlaylistItem::GetLabel(int i)
{
- CString str;
-
- if(i == 0)
- {
- if(!m_label.IsEmpty()) str = m_label;
- else if(!m_fns.IsEmpty()) str = StripPath(m_fns.GetHead());
- }
- else if(i == 1)
- {
- if(m_fInvalid) return _T("Invalid");
-
- if(m_type == file)
- {
- REFERENCE_TIME rt = m_duration;
-
- if(rt > 0)
- {
- rt /= 10000000;
- int ss = int(rt % 60);
- rt /= 60;
- int mm = int(rt % 60);
- rt /= 60;
- int hh = int(rt);
-
- str.Format(_T("%02d:%02d:%02d"), hh, mm, ss);
- }
- }
- else if(m_type == device)
- {
- // TODO
- }
-
- }
-
- return str;
+ CString str;
+
+ if(i == 0)
+ {
+ if(!m_label.IsEmpty()) str = m_label;
+ else if(!m_fns.IsEmpty()) str = StripPath(m_fns.GetHead());
+ }
+ else if(i == 1)
+ {
+ if(m_fInvalid) return _T("Invalid");
+
+ if(m_type == file)
+ {
+ REFERENCE_TIME rt = m_duration;
+
+ if(rt > 0)
+ {
+ rt /= 10000000;
+ int ss = int(rt%60);
+ rt /= 60;
+ int mm = int(rt%60);
+ rt /= 60;
+ int hh = int(rt);
+
+ str.Format(_T("%02d:%02d:%02d"), hh, mm, ss);
+ }
+ }
+ else if(m_type == device)
+ {
+ // TODO
+ }
+
+ }
+
+ return str;
}
//
@@ -133,7 +133,7 @@ CString CPlaylistItem::GetLabel(int i)
//
CPlaylist::CPlaylist()
- : m_pos(NULL)
+ : m_pos(NULL)
{
}
@@ -143,166 +143,154 @@ CPlaylist::~CPlaylist()
void CPlaylist::RemoveAll()
{
- __super::RemoveAll();
- m_pos = NULL;
+ __super::RemoveAll();
+ m_pos = NULL;
}
bool CPlaylist::RemoveAt(POSITION pos)
{
- if(pos)
- {
- __super::RemoveAt(pos);
- if(m_pos == pos)
- {
- m_pos = NULL;
- return(true);
- }
- }
-
- return(false);
+ if(pos)
+ {
+ __super::RemoveAt(pos);
+ if(m_pos == pos) {m_pos = NULL; return(true);}
+ }
+
+ return(false);
}
-typedef struct
-{
- UINT n;
- POSITION pos;
-} plsort_t;
+typedef struct {UINT n; POSITION pos;} plsort_t;
static int compare(const void* arg1, const void* arg2)
{
- UINT a1 = ((plsort_t*)arg1)->n;
- UINT a2 = ((plsort_t*)arg2)->n;
- return a1 > a2 ? 1 : a1 < a2 ? -1 : 0;
+ UINT a1 = ((plsort_t*)arg1)->n;
+ UINT a2 = ((plsort_t*)arg2)->n;
+ return a1 > a2 ? 1 : a1 < a2 ? -1 : 0;
}
-typedef struct
-{
- LPCTSTR str;
- POSITION pos;
-} plsort2_t;
+typedef struct {LPCTSTR str; POSITION pos;} plsort2_t;
int compare2(const void* arg1, const void* arg2)
{
- return _tcsicmp(((plsort2_t*)arg1)->str, ((plsort2_t*)arg2)->str);
+ return _tcsicmp(((plsort2_t*)arg1)->str, ((plsort2_t*)arg2)->str);
}
void CPlaylist::SortById()
{
- CAtlArray<plsort_t> a;
- a.SetCount(GetCount());
- POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
- a[i].n = GetAt(pos).m_id, a[i].pos = pos;
- qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
- for(int i = 0; i < a.GetCount(); i++)
- {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if(m_pos == a[i].pos) m_pos = GetTailPosition();
- }
+ CAtlArray<plsort_t> a;
+ a.SetCount(GetCount());
+ POSITION pos = GetHeadPosition();
+ for(int i = 0; pos; i++, GetNext(pos))
+ a[i].n = GetAt(pos).m_id, a[i].pos = pos;
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
+ for(int i = 0; i < a.GetCount(); i++)
+ {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if(m_pos == a[i].pos) m_pos = GetTailPosition();
+ }
}
void CPlaylist::SortByName()
{
- CAtlArray<plsort2_t> a;
- a.SetCount(GetCount());
- POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
- {
- CString& fn = GetAt(pos).m_fns.GetHead();
- a[i].str = (LPCTSTR)fn + max(fn.ReverseFind('/'), fn.ReverseFind('\\')) + 1;
- a[i].pos = pos;
- }
- qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
- for(int i = 0; i < a.GetCount(); i++)
- {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if(m_pos == a[i].pos) m_pos = GetTailPosition();
- }
+ CAtlArray<plsort2_t> a;
+ a.SetCount(GetCount());
+ POSITION pos = GetHeadPosition();
+ for(int i = 0; pos; i++, GetNext(pos))
+ {
+ CString& fn = GetAt(pos).m_fns.GetHead();
+ a[i].str = (LPCTSTR)fn + max(fn.ReverseFind('/'), fn.ReverseFind('\\')) + 1;
+ a[i].pos = pos;
+ }
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
+ for(int i = 0; i < a.GetCount(); i++)
+ {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if(m_pos == a[i].pos) m_pos = GetTailPosition();
+ }
}
void CPlaylist::SortByPath()
{
- CAtlArray<plsort2_t> a;
- a.SetCount(GetCount());
- POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
- a[i].str = GetAt(pos).m_fns.GetHead(), a[i].pos = pos;
- qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
- for(int i = 0; i < a.GetCount(); i++)
- {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if(m_pos == a[i].pos) m_pos = GetTailPosition();
- }
+ CAtlArray<plsort2_t> a;
+ a.SetCount(GetCount());
+ POSITION pos = GetHeadPosition();
+ for(int i = 0; pos; i++, GetNext(pos))
+ a[i].str = GetAt(pos).m_fns.GetHead(), a[i].pos = pos;
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
+ for(int i = 0; i < a.GetCount(); i++)
+ {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if(m_pos == a[i].pos) m_pos = GetTailPosition();
+ }
}
void CPlaylist::Randomize()
{
- CAtlArray<plsort_t> a;
- a.SetCount(GetCount());
- srand((unsigned int)time(NULL));
- POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
- a[i].n = rand(), a[i].pos = pos;
- qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
- CList<CPlaylistItem> pl;
- for(int i = 0; i < a.GetCount(); i++)
- {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if(m_pos == a[i].pos)
- m_pos = GetTailPosition();
- }
+ CAtlArray<plsort_t> a;
+ a.SetCount(GetCount());
+ srand((unsigned int)time(NULL));
+ POSITION pos = GetHeadPosition();
+ for(int i = 0; pos; i++, GetNext(pos))
+ a[i].n = rand(), a[i].pos = pos;
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
+ CList<CPlaylistItem> pl;
+ for(int i = 0; i < a.GetCount(); i++)
+ {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if(m_pos == a[i].pos)
+ m_pos = GetTailPosition();
+ }
}
POSITION CPlaylist::GetPos()
{
- return(m_pos);
+ return(m_pos);
}
void CPlaylist::SetPos(POSITION pos)
{
- m_pos = pos;
+ m_pos = pos;
}
#define Rand(a, b) rand()%(b-a+1)+a
POSITION CPlaylist::Shuffle()
{
- CAtlArray<plsort2_t> a;
- a.SetCount(GetCount());
- srand((unsigned)time(NULL));
- POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
- a[i].pos = pos;
-
- pos = GetPos();
- int rnd = Rand(0, a.GetCount() - 1);
- while(pos == a[rnd].pos) rnd = Rand(0, a.GetCount() - 1);
-
- return a[rnd].pos;
+ CAtlArray<plsort2_t> a;
+ a.SetCount(GetCount());
+ srand((unsigned)time(NULL));
+ POSITION pos = GetHeadPosition();
+ for(int i = 0; pos; i++, GetNext(pos))
+ a[i].pos = pos;
+
+ pos = GetPos();
+ int rnd = Rand(0, a.GetCount()-1);
+ while(pos == a[rnd].pos) rnd = Rand(0, a.GetCount()-1);
+
+ return a[rnd].pos;
}
CPlaylistItem& CPlaylist::GetNextWrap(POSITION& pos)
{
- if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE) && GetCount() > 2)
- {
- pos = Shuffle();
- }
- else
- {
- GetNext(pos);
- if(!pos) pos = GetHeadPosition();
- }
-
- return(GetAt(pos));
+ if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE) && GetCount() > 2)
+ {
+ pos = Shuffle();
+ }
+ else
+ {
+ GetNext(pos);
+ if(!pos) pos = GetHeadPosition();
+ }
+
+ return(GetAt(pos));
}
CPlaylistItem& CPlaylist::GetPrevWrap(POSITION& pos)
{
- GetPrev(pos);
- if(!pos) pos = GetTailPosition();
- return(GetAt(pos));
+ GetPrev(pos);
+ if(!pos) pos = GetTailPosition();
+ return(GetAt(pos));
}
diff --git a/src/apps/mplayerc/Playlist.h b/src/apps/mplayerc/Playlist.h
index cbe9a0b6d..31265a4e2 100644
--- a/src/apps/mplayerc/Playlist.h
+++ b/src/apps/mplayerc/Playlist.h
@@ -28,51 +28,51 @@
class CPlaylistItem
{
- static UINT m_globalid;
+ static UINT m_globalid;
public:
- UINT m_id;
- CString m_label;
- CAtlList<CString> m_fns;
- CAtlList<CString> m_subs;
- enum type_t {file, device} m_type;
- REFERENCE_TIME m_duration;
- int m_vinput, m_vchannel;
- int m_ainput;
- long m_country;
-
- bool m_fInvalid;
+ UINT m_id;
+ CString m_label;
+ CAtlList<CString> m_fns;
+ CAtlList<CString> m_subs;
+ enum type_t {file, device} m_type;
+ REFERENCE_TIME m_duration;
+ int m_vinput, m_vchannel;
+ int m_ainput;
+ long m_country;
+
+ bool m_fInvalid;
public:
- CPlaylistItem();
- virtual ~CPlaylistItem();
+ CPlaylistItem();
+ virtual ~CPlaylistItem();
- CPlaylistItem(const CPlaylistItem& pli);
- CPlaylistItem& operator = (const CPlaylistItem& pli);
+ CPlaylistItem(const CPlaylistItem& pli);
+ CPlaylistItem& operator = (const CPlaylistItem& pli);
- POSITION FindFile(LPCTSTR path);
+ POSITION FindFile(LPCTSTR path);
- CString GetLabel(int i = 0);
+ CString GetLabel(int i = 0);
};
class CPlaylist : public CList<CPlaylistItem>
{
protected:
- POSITION m_pos;
+ POSITION m_pos;
public:
- CPlaylist();
- virtual ~CPlaylist();
+ CPlaylist();
+ virtual ~CPlaylist();
- void RemoveAll();
- bool RemoveAt(POSITION pos);
+ void RemoveAll();
+ bool RemoveAt(POSITION pos);
- void SortById(), SortByName(), SortByPath(), Randomize();
+ void SortById(), SortByName(), SortByPath(), Randomize();
- POSITION GetPos();
- void SetPos(POSITION pos);
- CPlaylistItem& GetNextWrap(POSITION& pos);
- CPlaylistItem& GetPrevWrap(POSITION& pos);
+ POSITION GetPos();
+ void SetPos(POSITION pos);
+ CPlaylistItem& GetNextWrap(POSITION& pos);
+ CPlaylistItem& GetPrevWrap(POSITION& pos);
- POSITION Shuffle();
+ POSITION Shuffle();
};
diff --git a/src/apps/mplayerc/PnSPresetsDlg.cpp b/src/apps/mplayerc/PnSPresetsDlg.cpp
index 03f8d56a4..8c51c579c 100644
--- a/src/apps/mplayerc/PnSPresetsDlg.cpp
+++ b/src/apps/mplayerc/PnSPresetsDlg.cpp
@@ -30,8 +30,8 @@
IMPLEMENT_DYNAMIC(CPnSPresetsDlg, CCmdUIDialog)
CPnSPresetsDlg::CPnSPresetsDlg(CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CPnSPresetsDlg::IDD, pParent)
- , m_label(_T(""))
+ : CCmdUIDialog(CPnSPresetsDlg::IDD, pParent)
+ , m_label(_T(""))
{
}
@@ -41,218 +41,207 @@ CPnSPresetsDlg::~CPnSPresetsDlg()
void CPnSPresetsDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_EDIT2, m_PosX);
- DDX_Control(pDX, IDC_EDIT3, m_PosY);
- DDX_Control(pDX, IDC_EDIT4, m_ZoomX);
- DDX_Control(pDX, IDC_EDIT5, m_ZoomY);
- DDX_Text(pDX, IDC_EDIT1, m_label);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_EDIT2, m_PosX);
+ DDX_Control(pDX, IDC_EDIT3, m_PosY);
+ DDX_Control(pDX, IDC_EDIT4, m_ZoomX);
+ DDX_Control(pDX, IDC_EDIT5, m_ZoomY);
+ DDX_Text(pDX, IDC_EDIT1, m_label);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BOOL CPnSPresetsDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++)
- {
- CString label;
- double PosX, PosY, ZoomX, ZoomY;
- StringToParams(m_pnspresets[i], label, PosX, PosY, ZoomX, ZoomY);
+ for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++)
+ {
+ CString label;
+ double PosX, PosY, ZoomX, ZoomY;
+ StringToParams(m_pnspresets[i], label, PosX, PosY, ZoomX, ZoomY);
- m_list.AddString(label);
+ m_list.AddString(label);
- if(i == 0)
- {
- m_list.SetCurSel(0);
- OnLbnSelchangeList1();
- }
- }
+ if(i == 0)
+ {
+ m_list.SetCurSel(0);
+ OnLbnSelchangeList1();
+ }
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPnSPresetsDlg::StringToParams(CString str, CString& label, double& PosX, double& PosY, double& ZoomX, double& ZoomY)
{
- int i = 0, j = 0;
-
- for(CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++)
- {
- if(j == 0)
- {
- label = token;
- }
- else
- {
- float f = 0;
- if(_stscanf_s(token, _T("%f"), &f) != 1) continue;
-
- switch(j)
- {
- case 1:
- PosX = f;
- break;
- case 2:
- PosY = f;
- break;
- case 3:
- ZoomX = f;
- break;
- case 4:
- ZoomY = f;
- break;
- default:
- break;
- }
- }
- }
+ int i = 0, j = 0;
+
+ for(CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++)
+ {
+ if(j == 0)
+ {
+ label = token;
+ }
+ else
+ {
+ float f = 0;
+ if(_stscanf_s(token, _T("%f"), &f) != 1) continue;
+
+ switch(j)
+ {
+ case 1: PosX = f; break;
+ case 2: PosY = f; break;
+ case 3: ZoomX = f; break;
+ case 4: ZoomY = f; break;
+ default: break;
+ }
+ }
+ }
}
CString CPnSPresetsDlg::ParamsToString(CString label, double PosX, double PosY, double ZoomX, double ZoomY)
{
- CString str;
- str.Format(_T("%s,%.3f,%.3f,%.3f,%.3f"), label, PosX, PosY, ZoomX, ZoomY);
- return(str);
+ CString str;
+ str.Format(_T("%s,%.3f,%.3f,%.3f,%.3f"), label, PosX, PosY, ZoomX, ZoomY);
+ return(str);
}
BEGIN_MESSAGE_MAP(CPnSPresetsDlg, CCmdUIDialog)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton6)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateButton6)
- ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton9)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateButton9)
- ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton10)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateButton10)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
+ ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton6)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateButton6)
+ ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton9)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateButton9)
+ ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton10)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateButton10)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
END_MESSAGE_MAP()
// CPnSPresetsDlg message handlers
void CPnSPresetsDlg::OnLbnSelchangeList1()
{
- int i = m_list.GetCurSel();
- if(i >= 0 && i < m_pnspresets.GetCount())
- {
- double PosX, PosY, ZoomX, ZoomY;
- StringToParams(m_pnspresets[i], m_label, PosX, PosY, ZoomX, ZoomY);
- m_PosX = PosX;
- m_PosY = PosY;
- m_ZoomX = ZoomX;
- m_ZoomY = ZoomY;
- }
- else
- {
- m_label.Empty();
- m_PosX.SetWindowText(_T(""));
- m_PosY.SetWindowText(_T(""));
- m_ZoomX.SetWindowText(_T(""));
- m_ZoomY.SetWindowText(_T(""));
- }
-
- UpdateData(FALSE);
+ int i = m_list.GetCurSel();
+ if(i >= 0 && i < m_pnspresets.GetCount())
+ {
+ double PosX, PosY, ZoomX, ZoomY;
+ StringToParams(m_pnspresets[i], m_label, PosX, PosY, ZoomX, ZoomY);
+ m_PosX = PosX; m_PosY = PosY;
+ m_ZoomX = ZoomX; m_ZoomY = ZoomY;
+ }
+ else
+ {
+ m_label.Empty();
+ m_PosX.SetWindowText(_T(""));
+ m_PosY.SetWindowText(_T(""));
+ m_ZoomX.SetWindowText(_T(""));
+ m_ZoomY.SetWindowText(_T(""));
+ }
+
+ UpdateData(FALSE);
}
void CPnSPresetsDlg::OnBnClickedButton2() // new
{
- m_pnspresets.Add(_T("New,0.5,0.5,1.0,1.0"));
- m_list.SetCurSel(m_list.AddString(_T("New")));
- OnLbnSelchangeList1();
+ m_pnspresets.Add(_T("New,0.5,0.5,1.0,1.0"));
+ m_list.SetCurSel(m_list.AddString(_T("New")));
+ OnLbnSelchangeList1();
}
void CPnSPresetsDlg::OnUpdateButton2(CCmdUI* pCmdUI)
{
- CString str;
- int len = m_list.GetCount();
- if(len > 0) m_list.GetText(len - 1, str);
- pCmdUI->Enable(str != _T("New"));
+ CString str;
+ int len = m_list.GetCount();
+ if(len > 0) m_list.GetText(len-1, str);
+ pCmdUI->Enable(str != _T("New"));
}
void CPnSPresetsDlg::OnBnClickedButton6() // del
{
- int i = m_list.GetCurSel();
- m_list.DeleteString(i);
- m_pnspresets.RemoveAt(i);
- if(i == m_list.GetCount()) i--;
- m_list.SetCurSel(i);
- OnLbnSelchangeList1();
+ int i = m_list.GetCurSel();
+ m_list.DeleteString(i);
+ m_pnspresets.RemoveAt(i);
+ if(i == m_list.GetCount()) i--;
+ m_list.SetCurSel(i);
+ OnLbnSelchangeList1();
}
void CPnSPresetsDlg::OnUpdateButton6(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetCurSel() >= 0);
+ pCmdUI->Enable(m_list.GetCurSel() >= 0);
}
void CPnSPresetsDlg::OnBnClickedButton9() // up
{
- int i = m_list.GetCurSel();
- CString str, str2;
- m_list.GetText(i, str);
- str2 = m_pnspresets.GetAt(i);
- m_list.DeleteString(i);
- m_pnspresets.RemoveAt(i);
- i--;
- m_list.InsertString(i, str);
- m_pnspresets.InsertAt(i, str2);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ CString str, str2;
+ m_list.GetText(i, str);
+ str2 = m_pnspresets.GetAt(i);
+ m_list.DeleteString(i);
+ m_pnspresets.RemoveAt(i);
+ i--;
+ m_list.InsertString(i, str);
+ m_pnspresets.InsertAt(i, str2);
+ m_list.SetCurSel(i);
}
void CPnSPresetsDlg::OnUpdateButton9(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetCurSel() > 0 && m_list.GetCurSel() < m_list.GetCount());
+ pCmdUI->Enable(m_list.GetCurSel() > 0 && m_list.GetCurSel() < m_list.GetCount());
}
void CPnSPresetsDlg::OnBnClickedButton10() // down
{
- int i = m_list.GetCurSel();
- CString str, str2;
- m_list.GetText(i, str);
- str2 = m_pnspresets.GetAt(i);
- m_list.DeleteString(i);
- m_pnspresets.RemoveAt(i);
- i++;
- m_list.InsertString(i, str);
- m_pnspresets.InsertAt(i, str2);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ CString str, str2;
+ m_list.GetText(i, str);
+ str2 = m_pnspresets.GetAt(i);
+ m_list.DeleteString(i);
+ m_pnspresets.RemoveAt(i);
+ i++;
+ m_list.InsertString(i, str);
+ m_pnspresets.InsertAt(i, str2);
+ m_list.SetCurSel(i);
}
void CPnSPresetsDlg::OnUpdateButton10(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetCurSel() >= 0 && m_list.GetCurSel() < m_list.GetCount() - 1);
+ pCmdUI->Enable(m_list.GetCurSel() >= 0 && m_list.GetCurSel() < m_list.GetCount()-1);
}
void CPnSPresetsDlg::OnBnClickedButton1() // set
{
- int i = m_list.GetCurSel();
- UpdateData();
- /*if(m_label.Remove(',') > 0)
- UpdateData(FALSE);*/
- m_label.Replace(',', '.'); // Replace any ',' with '.' as ',' is used as tokeniser
- m_pnspresets[i] = ParamsToString(m_label, m_PosX, m_PosY, m_ZoomX, m_ZoomY);
- m_list.DeleteString(i);
- m_list.InsertString(i, m_label);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ UpdateData();
+ /*if(m_label.Remove(',') > 0)
+ UpdateData(FALSE);*/
+ m_label.Replace(',', '.'); // Replace any ',' with '.' as ',' is used as tokeniser
+ m_pnspresets[i] = ParamsToString(m_label, m_PosX, m_PosY, m_ZoomX, m_ZoomY);
+ m_list.DeleteString(i);
+ m_list.InsertString(i, m_label);
+ m_list.SetCurSel(i);
}
void CPnSPresetsDlg::OnUpdateButton1(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_list.GetCurSel() >= 0
- && !m_label.IsEmpty() // && m_label.Find(',') < 0
- && m_PosX >= 0 && m_PosX <= 1
- && m_PosY >= 0 && m_PosY <= 1
- && m_ZoomX >= 0.2 && m_ZoomX <= 3.0
- && m_ZoomY >= 0.2 && m_ZoomY <= 3.0);
+ UpdateData();
+ pCmdUI->Enable(m_list.GetCurSel() >= 0
+ && !m_label.IsEmpty() // && m_label.Find(',') < 0
+ && m_PosX >= 0 && m_PosX <= 1
+ && m_PosY >= 0 && m_PosY <= 1
+ && m_ZoomX >= 0.2 && m_ZoomX <= 3.0
+ && m_ZoomY >= 0.2 && m_ZoomY <= 3.0);
}
void CPnSPresetsDlg::OnOK()
{
- if(m_list.GetCurSel() >= 0)
- OnBnClickedButton1();
+ if(m_list.GetCurSel() >= 0)
+ OnBnClickedButton1();
- __super::OnOK();
+ __super::OnOK();
}
diff --git a/src/apps/mplayerc/PnSPresetsDlg.h b/src/apps/mplayerc/PnSPresetsDlg.h
index 7e9fd10e5..f4308b09c 100644
--- a/src/apps/mplayerc/PnSPresetsDlg.h
+++ b/src/apps/mplayerc/PnSPresetsDlg.h
@@ -30,43 +30,43 @@
class CPnSPresetsDlg : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CPnSPresetsDlg)
+ DECLARE_DYNAMIC(CPnSPresetsDlg)
private:
- void StringToParams(CString str, CString& label, double& PosX, double& PosY, double& ZoomX, double& ZoomY);
- CString ParamsToString(CString label, double PosX, double PosY, double ZoomX, double ZoomY);
+ void StringToParams(CString str, CString& label, double& PosX, double& PosY, double& ZoomX, double& ZoomY);
+ CString ParamsToString(CString label, double PosX, double PosY, double ZoomX, double ZoomY);
public:
- CPnSPresetsDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CPnSPresetsDlg();
+ CPnSPresetsDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CPnSPresetsDlg();
- CStringArray m_pnspresets;
+ CStringArray m_pnspresets;
// Dialog Data
- enum { IDD = IDD_PNSPRESET_DLG };
- CFloatEdit m_PosX;
- CFloatEdit m_PosY;
- CFloatEdit m_ZoomX;
- CFloatEdit m_ZoomY;
- CString m_label;
- CListBox m_list;
+ enum { IDD = IDD_PNSPRESET_DLG };
+ CFloatEdit m_PosX;
+ CFloatEdit m_PosY;
+ CFloatEdit m_ZoomX;
+ CFloatEdit m_ZoomY;
+ CString m_label;
+ CListBox m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton6();
- afx_msg void OnUpdateButton6(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton9();
- afx_msg void OnUpdateButton9(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton10();
- afx_msg void OnUpdateButton10(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton6();
+ afx_msg void OnUpdateButton6(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton9();
+ afx_msg void OnUpdateButton9(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton10();
+ afx_msg void OnUpdateButton10(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/QT9AllocatorPresenter.cpp b/src/apps/mplayerc/QT9AllocatorPresenter.cpp
index 3ea6d46f1..b9fb971ce 100644
--- a/src/apps/mplayerc/QT9AllocatorPresenter.cpp
+++ b/src/apps/mplayerc/QT9AllocatorPresenter.cpp
@@ -31,107 +31,107 @@ using namespace DSObjects;
// CQT9AllocatorPresenter
//
-CQT9AllocatorPresenter::CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
+CQT9AllocatorPresenter::CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+: CDX9AllocatorPresenter(hWnd, hr, false, _Error)
{
}
STDMETHODIMP CQT9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IQTVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IQTVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CQT9AllocatorPresenter::AllocSurfaces()
{
- HRESULT hr;
+ HRESULT hr;
- m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceOff = NULL;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL)))
- return hr;
+ if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL)))
+ return hr;
- return __super::AllocSurfaces();
+ return __super::AllocSurfaces();
}
void CQT9AllocatorPresenter::DeleteSurfaces()
{
- m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceOff = NULL;
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// IQTVideoSurface
STDMETHODIMP CQT9AllocatorPresenter::BeginBlt(const BITMAP& bm)
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
- DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
- if(FAILED(AllocSurfaces())) return E_FAIL;
- return S_OK;
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+ DeleteSurfaces();
+ m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
+ if(FAILED(AllocSurfaces())) return E_FAIL;
+ return S_OK;
}
STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
- return E_FAIL;
-
- bool fOk = false;
-
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd)))
- return E_FAIL;
-
- int w = bm.bmWidth;
- int h = abs(bm.bmHeight);
- int bpp = bm.bmBitsPixel;
- int dbpp =
- d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
- d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
-
- if((bpp == 16 || bpp == 24 || bpp == 32) && w == d3dsd.Width && h == d3dsd.Height)
- {
- D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0)))
- {
- BitBltFromRGBToRGB(
- w, h,
- (BYTE*)r.pBits, r.Pitch, dbpp,
- (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
- m_pVideoSurfaceOff->UnlockRect();
- fOk = true;
- }
- }
-
- if(!fOk)
- {
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
-
- HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
- CString str;
- str.Format(_T("Sorry, this color format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
- }
- }
-
- m_pD3DDev->StretchRect(m_pVideoSurfaceOff, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
-
- Paint(true);
-
- return S_OK;
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ return E_FAIL;
+
+ bool fOk = false;
+
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd)))
+ return E_FAIL;
+
+ int w = bm.bmWidth;
+ int h = abs(bm.bmHeight);
+ int bpp = bm.bmBitsPixel;
+ int dbpp =
+ d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
+ d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
+
+ if((bpp == 16 || bpp == 24 || bpp == 32) && w == d3dsd.Width && h == d3dsd.Height)
+ {
+ D3DLOCKED_RECT r;
+ if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0)))
+ {
+ BitBltFromRGBToRGB(
+ w, h,
+ (BYTE*)r.pBits, r.Pitch, dbpp,
+ (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
+ m_pVideoSurfaceOff->UnlockRect();
+ fOk = true;
+ }
+ }
+
+ if(!fOk)
+ {
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
+
+ HDC hDC;
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
+ {
+ CString str;
+ str.Format(_T("Sorry, this color format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+ }
+ }
+
+ m_pD3DDev->StretchRect(m_pVideoSurfaceOff, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
+
+ Paint(true);
+
+ return S_OK;
}
diff --git a/src/apps/mplayerc/QT9AllocatorPresenter.h b/src/apps/mplayerc/QT9AllocatorPresenter.h
index c10cd3e3c..b5e79bc53 100644
--- a/src/apps/mplayerc/QT9AllocatorPresenter.h
+++ b/src/apps/mplayerc/QT9AllocatorPresenter.h
@@ -27,24 +27,24 @@
namespace DSObjects
{
-class CQT9AllocatorPresenter
- : public CDX9AllocatorPresenter
- , public IQTVideoSurface
-{
- CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
+ class CQT9AllocatorPresenter
+ : public CDX9AllocatorPresenter
+ , public IQTVideoSurface
+ {
+ CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
-protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
-public:
- CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
+ public:
+ CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IQTVideoSurface
- STDMETHODIMP BeginBlt(const BITMAP& bm);
- STDMETHODIMP DoBlt(const BITMAP& bm);
-};
+ // IQTVideoSurface
+ STDMETHODIMP BeginBlt(const BITMAP& bm);
+ STDMETHODIMP DoBlt(const BITMAP& bm);
+ };
}
diff --git a/src/apps/mplayerc/QuicktimeGraph.cpp b/src/apps/mplayerc/QuicktimeGraph.cpp
index 4eb86e1d2..8a959594d 100644
--- a/src/apps/mplayerc/QuicktimeGraph.cpp
+++ b/src/apps/mplayerc/QuicktimeGraph.cpp
@@ -38,630 +38,618 @@
using namespace QT;
CQuicktimeGraph::CQuicktimeGraph(HWND hWndParent, HRESULT& hr)
- : CBaseGraph()
- , m_wndDestFrame(this)
- , m_fQtInitialized(false)
+ : CBaseGraph()
+ , m_wndDestFrame(this)
+ , m_fQtInitialized(false)
{
- hr = S_OK;
+ hr = S_OK;
- DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
+ DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if(s.iQTVideoRendererType == VIDRNDT_QT_DX7)
- {
- if(SUCCEEDED(CreateAP7(CLSID_QT7AllocatorPresenter, hWndParent, &m_pQTAP)))
+ if(s.iQTVideoRendererType == VIDRNDT_QT_DX7)
+ {
+ if(SUCCEEDED(CreateAP7(CLSID_QT7AllocatorPresenter, hWndParent, &m_pQTAP)))
+ dwStyle &= ~WS_VISIBLE;
+ }
+ else if(s.iQTVideoRendererType == VIDRNDT_QT_DX9)
+ {
+ if(SUCCEEDED(CreateAP9(CLSID_QT9AllocatorPresenter, hWndParent, &m_pQTAP)))
dwStyle &= ~WS_VISIBLE;
- }
- else if(s.iQTVideoRendererType == VIDRNDT_QT_DX9)
- {
- if(SUCCEEDED(CreateAP9(CLSID_QT9AllocatorPresenter, hWndParent, &m_pQTAP)))
- dwStyle &= ~WS_VISIBLE;
- }
-
- m_fQtInitialized = false;
- if(InitializeQTML(0) != 0)
- {
- hr = E_FAIL;
- return;
- }
- if(EnterMovies() != 0)
- {
- TerminateQTML();
- hr = E_FAIL;
- return;
- }
- m_fQtInitialized = true;
-
- if(!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, dwStyle, CRect(0, 0, 0, 0), CWnd::FromHandle(hWndParent), 0))
- {
- hr = E_FAIL;
- return;
- }
-
- if(!m_wndDestFrame.Create(NULL, NULL, dwStyle, CRect(0, 0, 0, 0), &m_wndWindowFrame, 0))
- {
- hr = E_FAIL;
- return;
- }
+ }
+
+ m_fQtInitialized = false;
+ if(InitializeQTML(0) != 0) {hr = E_FAIL; return;}
+ if(EnterMovies() != 0) {TerminateQTML(); hr = E_FAIL; return;}
+ m_fQtInitialized = true;
+
+ if(!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, dwStyle, CRect(0, 0, 0, 0), CWnd::FromHandle(hWndParent), 0))
+ {
+ hr = E_FAIL;
+ return;
+ }
+
+ if(!m_wndDestFrame.Create(NULL, NULL, dwStyle, CRect(0, 0, 0, 0), &m_wndWindowFrame, 0))
+ {
+ hr = E_FAIL;
+ return;
+ }
}
CQuicktimeGraph::~CQuicktimeGraph()
{
- m_wndDestFrame.DestroyWindow();
- m_wndWindowFrame.DestroyWindow();
+ m_wndDestFrame.DestroyWindow();
+ m_wndWindowFrame.DestroyWindow();
- if(m_fQtInitialized)
- {
- ExitMovies();
- TerminateQTML();
- }
+ if(m_fQtInitialized)
+ {
+ ExitMovies();
+ TerminateQTML();
+ }
}
STDMETHODIMP CQuicktimeGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IVideoFrameStep)
- (m_pQTAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(IQTVideoSurface))) ? m_pQTAP->QueryInterface(riid, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IVideoFrameStep)
+ (m_pQTAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(IQTVideoSurface))) ? m_pQTAP->QueryInterface(riid, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IGraphBuilder
STDMETHODIMP CQuicktimeGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- bool fRet = m_wndDestFrame.OpenMovie(CString(lpcwstrFile));
-
- if(fRet)
- {
- for(int i = 1, cnt = GetMovieTrackCount(m_wndDestFrame.theMovie); i <= cnt; i++)
- {
- Track aTrack = GetMovieIndTrack(m_wndDestFrame.theMovie, i);
- Media aMedia = GetTrackMedia(aTrack);
-
- OSType aTrackType;
- GetMediaHandlerDescription(aMedia, &aTrackType, 0, 0);
- if(aTrackType == SoundMediaType)
- {
- SampleDescriptionHandle aDesc = (SampleDescriptionHandle)NewHandle(sizeof(aDesc));
- GetMediaSampleDescription(aMedia, 1, aDesc);
- if(GetMoviesError() == noErr)
- {
- SoundDescription& desc = **(SoundDescriptionHandle)aDesc;
- NotifyEvent(EC_BG_AUDIO_CHANGED, desc.numChannels, 0);
- i = cnt;
- }
- DisposeHandle((Handle)aDesc);
- }
- }
- }
-
- return fRet ? S_OK : E_FAIL;
+ bool fRet = m_wndDestFrame.OpenMovie(CString(lpcwstrFile));
+
+ if(fRet)
+ {
+ for(int i = 1, cnt = GetMovieTrackCount(m_wndDestFrame.theMovie); i <= cnt; i++)
+ {
+ Track aTrack = GetMovieIndTrack(m_wndDestFrame.theMovie, i);
+ Media aMedia = GetTrackMedia(aTrack);
+
+ OSType aTrackType;
+ GetMediaHandlerDescription(aMedia, &aTrackType, 0, 0);
+ if(aTrackType == SoundMediaType)
+ {
+ SampleDescriptionHandle aDesc = (SampleDescriptionHandle)NewHandle(sizeof(aDesc));
+ GetMediaSampleDescription(aMedia, 1, aDesc);
+ if(GetMoviesError() == noErr)
+ {
+ SoundDescription& desc = **(SoundDescriptionHandle)aDesc;
+ NotifyEvent(EC_BG_AUDIO_CHANGED, desc.numChannels, 0);
+ i = cnt;
+ }
+ DisposeHandle((Handle)aDesc);
+ }
+ }
+ }
+
+ return fRet ? S_OK : E_FAIL;
}
// IMediaControl
STDMETHODIMP CQuicktimeGraph::Run()
{
- m_wndDestFrame.Run();
- return S_OK;
+ m_wndDestFrame.Run();
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::Pause()
-{
- m_wndDestFrame.Pause();
- return S_OK;
+{
+ m_wndDestFrame.Pause();
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::Stop()
{
- m_wndDestFrame.Stop();
- return S_OK;
+ m_wndDestFrame.Stop();
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::GetState(LONG msTimeout, OAFilterState* pfs)
{
- // TODO: this seems to deadlock when opening from the net
- return pfs ? *pfs = m_wndDestFrame.GetState(), S_OK : E_POINTER;
+ // TODO: this seems to deadlock when opening from the net
+ return pfs ? *pfs = m_wndDestFrame.GetState(), S_OK : E_POINTER;
}
// IMediaSeeking
STDMETHODIMP CQuicktimeGraph::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
+ CheckPointer(pDuration, E_POINTER);
- *pDuration = 0;
+ *pDuration = 0;
- if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
+ if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
- TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
- if(ts == 0) return E_FAIL;
+ TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
+ if(ts == 0) return E_FAIL;
- *pDuration = 10000i64 * GetMovieDuration(m_wndDestFrame.theMovie) / ts * 1000;
+ *pDuration = 10000i64*GetMovieDuration(m_wndDestFrame.theMovie)/ts*1000;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::GetCurrentPosition(LONGLONG* pCurrent)
{
- CheckPointer(pCurrent, E_POINTER);
+ CheckPointer(pCurrent, E_POINTER);
- *pCurrent = 0;
+ *pCurrent = 0;
- if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
+ if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
- TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
- if(ts == 0) return E_FAIL;
+ TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
+ if(ts == 0) return E_FAIL;
- TimeRecord tr;
- *pCurrent = 10000i64 * GetMovieTime(m_wndDestFrame.theMovie, &tr) / ts * 1000;
+ TimeRecord tr;
+ *pCurrent = 10000i64*GetMovieTime(m_wndDestFrame.theMovie, &tr)/ts*1000;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- CheckPointer(pCurrent, E_POINTER);
+ CheckPointer(pCurrent, E_POINTER);
- if(!(dwCurrentFlags & AM_SEEKING_AbsolutePositioning)) return E_INVALIDARG;
+ if(!(dwCurrentFlags&AM_SEEKING_AbsolutePositioning)) return E_INVALIDARG;
- if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
+ if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
- TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
- if(ts == 0) return E_FAIL;
+ TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
+ if(ts == 0) return E_FAIL;
- SetMovieTimeValue(m_wndDestFrame.theMovie, (TimeValue)(*pCurrent * ts / 1000 / 10000i64));
+ SetMovieTimeValue(m_wndDestFrame.theMovie, (TimeValue)(*pCurrent*ts/1000/10000i64));
- if(!m_wndDestFrame.theMC)
- {
- UpdateMovie(m_wndDestFrame.theMovie);
- MoviesTask(m_wndDestFrame.theMovie, 0L);
- }
+ if(!m_wndDestFrame.theMC)
+ {
+ UpdateMovie(m_wndDestFrame.theMovie);
+ MoviesTask(m_wndDestFrame.theMovie, 0L);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::SetRate(double dRate)
{
- return m_wndDestFrame.theMovie ? SetMovieRate(m_wndDestFrame.theMovie, (Fixed)(dRate * 0x10000)), S_OK : E_UNEXPECTED;
+ return m_wndDestFrame.theMovie ? SetMovieRate(m_wndDestFrame.theMovie, (Fixed)(dRate * 0x10000)), S_OK : E_UNEXPECTED;
}
STDMETHODIMP CQuicktimeGraph::GetRate(double* pdRate)
{
- CheckPointer(pdRate, E_POINTER);
- *pdRate = 1.0;
- return m_wndDestFrame.theMovie ? *pdRate = (double)GetMovieRate(m_wndDestFrame.theMovie) / 0x10000, S_OK : E_UNEXPECTED;
+ CheckPointer(pdRate, E_POINTER);
+ *pdRate = 1.0;
+ return m_wndDestFrame.theMovie ? *pdRate = (double)GetMovieRate(m_wndDestFrame.theMovie) / 0x10000, S_OK : E_UNEXPECTED;
}
// IVideoWindow
STDMETHODIMP CQuicktimeGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if(IsWindow(m_wndWindowFrame.m_hWnd))
- m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
+ if(IsWindow(m_wndWindowFrame.m_hWnd))
+ m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
- return S_OK;
+ return S_OK;
}
// IBasicVideo
STDMETHODIMP CQuicktimeGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- if(!m_pQTAP && IsWindow(m_wndDestFrame.m_hWnd))
- {
- m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
+ if(!m_pQTAP && IsWindow(m_wndDestFrame.m_hWnd))
+ {
+ m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
- if(m_wndDestFrame.theMC)
- {
- Rect bounds = {0, 0, (short)Height, (short)Width};
- MCPositionController(m_wndDestFrame.theMC, &bounds, NULL, mcTopLeftMovie | mcScaleMovieToFit);
- }
- }
+ if(m_wndDestFrame.theMC)
+ {
+ Rect bounds = {0,0,(short)Height,(short)Width};
+ MCPositionController(m_wndDestFrame.theMC, &bounds, NULL, mcTopLeftMovie|mcScaleMovieToFit);
+ }
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if(!pWidth || !pHeight) return E_POINTER;
+ if(!pWidth || !pHeight) return E_POINTER;
- *pWidth = m_wndDestFrame.m_size.cx;
- *pHeight = m_wndDestFrame.m_size.cy;
+ *pWidth = m_wndDestFrame.m_size.cx;
+ *pHeight = m_wndDestFrame.m_size.cy;
- return S_OK;
+ return S_OK;
}
// IBasicAudio
STDMETHODIMP CQuicktimeGraph::put_Volume(long lVolume)
{
- if(m_wndDestFrame.theMovie)
- {
- lVolume = (lVolume == -10000) ? 0 : (int)pow(10.0, (double)lVolume / 4152.41 + 2.41);
- SetMovieVolume(m_wndDestFrame.theMovie, (short)max(min(lVolume, 256), 0));
- return S_OK;
- }
+ if(m_wndDestFrame.theMovie)
+ {
+ lVolume = (lVolume == -10000) ? 0 : (int)pow(10.0, (double)lVolume/4152.41 + 2.41);
+ SetMovieVolume(m_wndDestFrame.theMovie, (short)max(min(lVolume, 256), 0));
+ return S_OK;
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CQuicktimeGraph::get_Volume(long* plVolume)
{
- CheckPointer(plVolume, E_POINTER);
+ CheckPointer(plVolume, E_POINTER);
- if(m_wndDestFrame.theMovie)
- {
- long lVolume = (long)GetMovieVolume(m_wndDestFrame.theMovie);
- *plVolume = (int)((log10(1.0 * lVolume) - 2.41) * 4152.41);
- *plVolume = max(min(*plVolume, 0), -10000);
- return S_OK;
- }
+ if(m_wndDestFrame.theMovie)
+ {
+ long lVolume = (long)GetMovieVolume(m_wndDestFrame.theMovie);
+ *plVolume = (int)((log10(1.0*lVolume)-2.41)*4152.41);
+ *plVolume = max(min(*plVolume, 0), -10000);
+ return S_OK;
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
// IVideoFrameStep
STDMETHODIMP CQuicktimeGraph::Step(DWORD dwFrames, IUnknown* pStepObject)
{
- if(pStepObject) return E_INVALIDARG;
- if(dwFrames == 0) return S_OK;
- if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
+ if(pStepObject) return E_INVALIDARG;
+ if(dwFrames == 0) return S_OK;
+ if(!m_wndDestFrame.theMovie) return E_UNEXPECTED;
- // w/o m_wndDestFrame.theMC
+ // w/o m_wndDestFrame.theMC
- OSType myTypes[] = {VisualMediaCharacteristic};
- TimeValue myCurrTime = GetMovieTime(m_wndDestFrame.theMovie, NULL);
- Fixed theRate = (int)dwFrames > 0 ? 0x00010000 : 0xffff0000;
+ OSType myTypes[] = {VisualMediaCharacteristic};
+ TimeValue myCurrTime = GetMovieTime(m_wndDestFrame.theMovie, NULL);
+ Fixed theRate = (int)dwFrames > 0 ? 0x00010000 : 0xffff0000;
- for(int nSteps = abs((int)dwFrames); nSteps > 0; nSteps--)
- {
- TimeValue myNextTime;
- GetMovieNextInterestingTime(m_wndDestFrame.theMovie, nextTimeStep, 1, myTypes, myCurrTime, theRate, &myNextTime, NULL);
- if(GetMoviesError() != noErr) return E_FAIL;
- myCurrTime = myNextTime;
- }
+ for(int nSteps = abs((int)dwFrames); nSteps > 0; nSteps--)
+ {
+ TimeValue myNextTime;
+ GetMovieNextInterestingTime(m_wndDestFrame.theMovie, nextTimeStep, 1, myTypes, myCurrTime, theRate, &myNextTime, NULL);
+ if(GetMoviesError() != noErr) return E_FAIL;
+ myCurrTime = myNextTime;
+ }
- if(myCurrTime >= 0 && myCurrTime < GetMovieDuration(m_wndDestFrame.theMovie))
- {
+ if(myCurrTime >= 0 && myCurrTime < GetMovieDuration(m_wndDestFrame.theMovie))
+ {
SetMovieTimeValue(m_wndDestFrame.theMovie, myCurrTime);
- if(GetMoviesError() != noErr) return E_FAIL;
- // the rest is not needed when we also have m_wndDestFrame.theMC:
- UpdateMovie(m_wndDestFrame.theMovie);
- if(GetMoviesError() != noErr) return E_FAIL;
- MoviesTask(m_wndDestFrame.theMovie, 0L);
- }
+ if(GetMoviesError() != noErr) return E_FAIL;
+ // the rest is not needed when we also have m_wndDestFrame.theMC:
+ UpdateMovie(m_wndDestFrame.theMovie);
+ if(GetMoviesError() != noErr) return E_FAIL;
+ MoviesTask(m_wndDestFrame.theMovie, 0L);
+ }
- NotifyEvent(EC_STEP_COMPLETE);
+ NotifyEvent(EC_STEP_COMPLETE);
- return S_OK;
+ return S_OK;
- /*
- // w/ m_wndDestFrame.theMC
+/*
+ // w/ m_wndDestFrame.theMC
- short myStep = (short)(long)dwFrames;
- return noErr == MCDoAction(m_wndDestFrame.theMC, mcActionStep, (Ptr)myStep)
- ? NotifyEvent(EC_STEP_COMPLETE), S_OK : E_FAIL;
- */
+ short myStep = (short)(long)dwFrames;
+ return noErr == MCDoAction(m_wndDestFrame.theMC, mcActionStep, (Ptr)myStep)
+ ? NotifyEvent(EC_STEP_COMPLETE), S_OK : E_FAIL;
+*/
}
STDMETHODIMP CQuicktimeGraph::CanStep(long bMultiple, IUnknown* pStepObject)
{
- return m_wndDestFrame.theMovie ? S_OK : S_FALSE;
+ return m_wndDestFrame.theMovie ? S_OK : S_FALSE;
}
STDMETHODIMP CQuicktimeGraph::CancelStep()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IGraphEngine
-STDMETHODIMP_(engine_t) CQuicktimeGraph::GetEngine()
-{
- return QuickTime;
-}
+STDMETHODIMP_(engine_t) CQuicktimeGraph::GetEngine() {return QuickTime;}
//
// CQuicktimeWindow
//
CQuicktimeWindow::CQuicktimeWindow(CQuicktimeGraph* pGraph)
- : m_pGraph(pGraph)
- , theMovie(NULL)
- , theMC(NULL)
- , m_size(0, 0)
- , m_idEndPoller(0)
- , m_fs(State_Stopped)
- , m_offscreenGWorld(NULL)
+ : m_pGraph(pGraph)
+ , theMovie(NULL)
+ , theMC(NULL)
+ , m_size(0, 0)
+ , m_idEndPoller(0)
+ , m_fs(State_Stopped)
+ , m_offscreenGWorld(NULL)
{
}
-void CQuicktimeWindow::ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam)
-{
- if(message >= WM_MOUSEFIRST && message <= WM_MOUSELAST
- || message >= WM_KEYFIRST && message <= WM_KEYLAST)
- return;
+void CQuicktimeWindow::ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam)
+{
+ if(message >= WM_MOUSEFIRST && message <= WM_MOUSELAST
+ || message >= WM_KEYFIRST && message <= WM_KEYLAST)
+ return;
- // Convert the Windows event to a QTML event
- MSG theMsg;
- EventRecord macEvent;
- LONG thePoints = GetMessagePos();
+ // Convert the Windows event to a QTML event
+ MSG theMsg;
+ EventRecord macEvent;
+ LONG thePoints = GetMessagePos();
- theMsg.hwnd = m_hWnd;
- theMsg.message = message;
- theMsg.wParam = wParam;
- theMsg.lParam = lParam;
- theMsg.time = GetMessageTime();
- theMsg.pt.x = LOWORD(thePoints);
- theMsg.pt.y = HIWORD(thePoints);
+ theMsg.hwnd = m_hWnd;
+ theMsg.message = message;
+ theMsg.wParam = wParam;
+ theMsg.lParam = lParam;
+ theMsg.time = GetMessageTime();
+ theMsg.pt.x = LOWORD(thePoints);
+ theMsg.pt.y = HIWORD(thePoints);
- // tranlate a windows event to a mac event
- WinEventToMacEvent(&theMsg, &macEvent);
+ // tranlate a windows event to a mac event
+ WinEventToMacEvent(&theMsg, &macEvent);
- // Pump messages as mac event
- MCIsPlayerEvent(theMC, (const EventRecord*)&macEvent);
+ // Pump messages as mac event
+ MCIsPlayerEvent(theMC, (const EventRecord*)&macEvent);
}
LRESULT CQuicktimeWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_ERASEBKGND)
- {
- LRESULT theResult = __super::WindowProc(message, wParam, lParam);
- ProcessMovieEvent(message, wParam, lParam);
- return theResult;
- }
- else
- {
- ProcessMovieEvent(message, wParam, lParam);
- return __super::WindowProc(message, wParam, lParam);
- }
+ if(message == WM_ERASEBKGND)
+ {
+ LRESULT theResult = __super::WindowProc(message, wParam, lParam);
+ ProcessMovieEvent(message, wParam, lParam);
+ return theResult;
+ }
+ else
+ {
+ ProcessMovieEvent(message, wParam, lParam);
+ return __super::WindowProc(message, wParam, lParam);
+ }
}
OSErr CQuicktimeWindow::MyMovieDrawingCompleteProc(Movie theMovie, long refCon)
{
- CQuicktimeWindow* pQW = (CQuicktimeWindow*)refCon;
- if(!pQW) return noErr;
+ CQuicktimeWindow* pQW = (CQuicktimeWindow*)refCon;
+ if(!pQW) return noErr;
- CQuicktimeGraph* pGraph = pQW->m_pGraph;
- if(!pGraph) return noErr;
+ CQuicktimeGraph* pGraph = pQW->m_pGraph;
+ if(!pGraph) return noErr;
- if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)pGraph)
- {
- BITMAP bm;
- pQW->m_bm.GetObject(sizeof(bm), &bm);
- pQTVS->DoBlt(bm);
- }
- /*
- else
- {
- pQW->Invalidate();
- }*/
+ if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)pGraph)
+ {
+ BITMAP bm;
+ pQW->m_bm.GetObject(sizeof(bm), &bm);
+ pQTVS->DoBlt(bm);
+ }
+ /*
+ else
+ {
+ pQW->Invalidate();
+ }*/
- return(noErr);
+ return(noErr);
}
bool CQuicktimeWindow::OpenMovie(CString fn)
{
- CloseMovie();
+ CloseMovie();
- CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
+ CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if(!pQTVS)
- {
- // Set the port
- SetGWorld((CGrafPtr)GetHWNDPort(m_hWnd), NULL);
- }
+ if(!pQTVS)
+ {
+ // Set the port
+ SetGWorld((CGrafPtr)GetHWNDPort(m_hWnd), NULL);
+ }
- if(fn.Find(_T("://")) > 0)
- {
- Handle myHandle = NULL;
- Size mySize = fn.GetLength() + 1;
+ if(fn.Find(_T("://")) > 0)
+ {
+ Handle myHandle = NULL;
+ Size mySize = fn.GetLength()+1;
- if(!(myHandle = NewHandleClear(mySize)))
- return(false);
+ if(!(myHandle = NewHandleClear(mySize)))
+ return(false);
- BlockMove((LPSTR)(LPCSTR)CStringA(fn), *myHandle, mySize);
+ BlockMove((LPSTR)(LPCSTR)CStringA(fn), *myHandle, mySize);
OSErr err = NewMovieFromDataRef(&theMovie, newMovieActive, NULL, myHandle, URLDataHandlerSubType);
- DisposeHandle(myHandle);
+ DisposeHandle(myHandle);
- if(err != noErr) return(false);
- }
- else
- {
- if(!(fn.GetLength() > 0 && fn.GetLength() < 255))
- return(false);
+ if(err != noErr) return(false);
+ }
+ else
+ {
+ if(!(fn.GetLength() > 0 && fn.GetLength() < 255))
+ return(false);
- CHAR buff[_MAX_PATH] = {0, 0};
+ CHAR buff[_MAX_PATH] = {0, 0};
#ifdef UNICODE
- WideCharToMultiByte(GetACP(), 0, fn, -1, buff + 1, MAX_PATH - 1, 0, 0);
+ WideCharToMultiByte(GetACP(), 0, fn, -1, buff+1, MAX_PATH-1, 0, 0);
#else
- strcpy(buff + 1, fn);
+ strcpy(buff+1, fn);
#endif
- buff[0] = strlen(buff + 1);
-
- // Make a FSSpec with a pascal string filename
- FSSpec sfFile;
- FSMakeFSSpec(0, 0L, (BYTE*)buff, &sfFile);
-
- // Open the movie file
- short movieResFile;
- OSErr err = OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
- if(err == noErr)
- {
- err = NewMovieFromFile(&theMovie, movieResFile, 0, 0, newMovieActive, 0);
- CloseMovieFile(movieResFile);
- }
- if(err != noErr) return(false);
- }
-
- Rect rect;
- GetMovieBox(theMovie, &rect);
- MacOffsetRect(&rect, -rect.left, -rect.top);
- SetMovieBox(theMovie, &rect);
- m_size.SetSize(rect.right - rect.left, rect.bottom - rect.top);
-
- Rect nrect;
- GetMovieNaturalBoundsRect(theMovie, &nrect);
-
- if(!pQTVS)
- {
- theMC = NewMovieController(theMovie, &rect, mcTopLeftMovie | mcNotVisible);
- }
- else if(m_size.cx > 0 && m_size.cy > 0)
- {
- SetMovieDrawingCompleteProc(theMovie,
- movieDrawingCallWhenChanged,//|movieDrawingCallAlways,
- MyMovieDrawingCompleteProc, (long)this);
-
- if(CDC* pDC = GetDC())
- {
- m_dc.CreateCompatibleDC(pDC);
- ReleaseDC(pDC);
-
- struct
- {
- BITMAPINFOHEADER bmiHeader;
- long bmiColors[256];
- } bmi;
-
- memset(&bmi, 0, sizeof(bmi));
-
- int bpp = m_dc.GetDeviceCaps(BITSPIXEL);
-
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biCompression = BI_BITFIELDS/*BI_RGB*/;
- bmi.bmiHeader.biWidth = m_size.cx;
- bmi.bmiHeader.biHeight = -m_size.cy;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32/*bpp*/;
-
- bmi.bmiColors[0] = /*bpp == 16 ? 0xf800 :*/ 0xff0000;
- bmi.bmiColors[1] = /*bpp == 16 ? 0x07e0 :*/ 0x00ff00;
- bmi.bmiColors[2] = /*bpp == 16 ? 0x001f :*/ 0x0000ff;
-
- void* bits;
- m_bm.Attach(CreateDIBSection(m_dc, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, &bits, NULL, 0));
-
- QDErr err = NewGWorldFromHBITMAP(&m_offscreenGWorld, NULL, NULL, 0, m_bm.m_hObject, m_dc.m_hDC);
-
- SetMovieGWorld(theMovie, m_offscreenGWorld, GetGWorldDevice(m_offscreenGWorld));
-
- BITMAP bm;
- m_bm.GetObject(sizeof(bm), &bm);
- pQTVS->BeginBlt(bm);
- }
- }
-
- return(theMovie != NULL);
+ buff[0] = strlen(buff+1);
+
+ // Make a FSSpec with a pascal string filename
+ FSSpec sfFile;
+ FSMakeFSSpec(0, 0L, (BYTE*)buff, &sfFile);
+
+ // Open the movie file
+ short movieResFile;
+ OSErr err = OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
+ if(err == noErr)
+ {
+ err = NewMovieFromFile(&theMovie, movieResFile, 0, 0, newMovieActive, 0);
+ CloseMovieFile(movieResFile);
+ }
+ if(err != noErr) return(false);
+ }
+
+ Rect rect;
+ GetMovieBox(theMovie, &rect);
+ MacOffsetRect(&rect, -rect.left, -rect.top);
+ SetMovieBox(theMovie, &rect);
+ m_size.SetSize(rect.right - rect.left, rect.bottom - rect.top);
+
+ Rect nrect;
+ GetMovieNaturalBoundsRect(theMovie, &nrect);
+
+ if(!pQTVS)
+ {
+ theMC = NewMovieController(theMovie, &rect, mcTopLeftMovie|mcNotVisible);
+ }
+ else if(m_size.cx > 0 && m_size.cy > 0)
+ {
+ SetMovieDrawingCompleteProc(theMovie,
+ movieDrawingCallWhenChanged,//|movieDrawingCallAlways,
+ MyMovieDrawingCompleteProc, (long)this);
+
+ if(CDC* pDC = GetDC())
+ {
+ m_dc.CreateCompatibleDC(pDC);
+ ReleaseDC(pDC);
+
+ struct
+ {
+ BITMAPINFOHEADER bmiHeader;
+ long bmiColors[256];
+ } bmi;
+
+ memset(&bmi, 0, sizeof(bmi));
+
+ int bpp = m_dc.GetDeviceCaps(BITSPIXEL);
+
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biCompression = BI_BITFIELDS/*BI_RGB*/;
+ bmi.bmiHeader.biWidth = m_size.cx;
+ bmi.bmiHeader.biHeight = -m_size.cy;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32/*bpp*/;
+
+ bmi.bmiColors[0] = /*bpp == 16 ? 0xf800 :*/ 0xff0000;
+ bmi.bmiColors[1] = /*bpp == 16 ? 0x07e0 :*/ 0x00ff00;
+ bmi.bmiColors[2] = /*bpp == 16 ? 0x001f :*/ 0x0000ff;
+
+ void* bits;
+ m_bm.Attach(CreateDIBSection(m_dc, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, &bits, NULL, 0));
+
+ QDErr err = NewGWorldFromHBITMAP(&m_offscreenGWorld, NULL, NULL, 0, m_bm.m_hObject, m_dc.m_hDC);
+
+ SetMovieGWorld(theMovie, m_offscreenGWorld, GetGWorldDevice(m_offscreenGWorld));
+
+ BITMAP bm;
+ m_bm.GetObject(sizeof(bm), &bm);
+ pQTVS->BeginBlt(bm);
+ }
+ }
+
+ return(theMovie != NULL);
}
void CQuicktimeWindow::CloseMovie()
{
- if(theMC) DisposeMovieController(theMC), theMC = NULL;
- if(theMovie) DisposeMovie(theMovie), theMovie = NULL;
- m_size.SetSize(0, 0);
- m_fs = State_Stopped;
+ if(theMC) DisposeMovieController(theMC), theMC = NULL;
+ if(theMovie) DisposeMovie(theMovie), theMovie = NULL;
+ m_size.SetSize(0, 0);
+ m_fs = State_Stopped;
- if(m_offscreenGWorld) DisposeGWorld(m_offscreenGWorld), m_offscreenGWorld = NULL;
- m_dc.DeleteDC();
- m_bm.DeleteObject();
+ if(m_offscreenGWorld) DisposeGWorld(m_offscreenGWorld), m_offscreenGWorld = NULL;
+ m_dc.DeleteDC();
+ m_bm.DeleteObject();
}
void CQuicktimeWindow::Run()
{
- if(theMovie)
- {
- StartMovie(theMovie);
- if(!m_idEndPoller) m_idEndPoller = SetTimer(1, 10, NULL); // 10ms -> 100fps max
- }
+ if(theMovie)
+ {
+ StartMovie(theMovie);
+ if(!m_idEndPoller) m_idEndPoller = SetTimer(1, 10, NULL); // 10ms -> 100fps max
+ }
- m_fs = State_Running;
+ m_fs = State_Running;
}
void CQuicktimeWindow::Pause()
{
- if(theMovie)
- {
- StopMovie(theMovie);
- if(m_idEndPoller) KillTimer(m_idEndPoller), m_idEndPoller = 0;
- }
+ if(theMovie)
+ {
+ StopMovie(theMovie);
+ if(m_idEndPoller) KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ }
- m_fs = State_Paused;
+ m_fs = State_Paused;
}
void CQuicktimeWindow::Stop()
{
- if(theMovie)
- {
- StopMovie(theMovie);
- GoToBeginningOfMovie(theMovie);
- if(m_idEndPoller) KillTimer(m_idEndPoller), m_idEndPoller = 0;
- }
+ if(theMovie)
+ {
+ StopMovie(theMovie);
+ GoToBeginningOfMovie(theMovie);
+ if(m_idEndPoller) KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ }
- m_fs = State_Stopped;
+ m_fs = State_Stopped;
}
FILTER_STATE CQuicktimeWindow::GetState()
{
- return m_fs;
+ return m_fs;
}
BEGIN_MESSAGE_MAP(CQuicktimeWindow, CPlayerWindow)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_ERASEBKGND()
- ON_WM_TIMER()
+ ON_WM_CREATE()
+ ON_WM_DESTROY()
+ ON_WM_ERASEBKGND()
+ ON_WM_TIMER()
END_MESSAGE_MAP()
int CQuicktimeWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(__super::OnCreate(lpCreateStruct) == -1)
- return -1;
+ if(__super::OnCreate(lpCreateStruct) == -1)
+ return -1;
- CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
+ CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if(!pQTVS)
- {
- // Create GrafPort <-> HWND association
- CreatePortAssociation(m_hWnd, NULL, 0);
- }
+ if(!pQTVS)
+ {
+ // Create GrafPort <-> HWND association
+ CreatePortAssociation(m_hWnd, NULL, 0);
+ }
- return 0;
+ return 0;
}
void CQuicktimeWindow::OnDestroy()
{
- CPlayerWindow::OnDestroy();
+ CPlayerWindow::OnDestroy();
- // close any movies before destroying PortAssocation
- CloseMovie();
+ // close any movies before destroying PortAssocation
+ CloseMovie();
- CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
+ CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if(!pQTVS)
- {
- // Destroy the view's GrafPort <-> HWND association
- if(m_hWnd)
- if(CGrafPtr windowPort = (CGrafPtr)GetHWNDPort(m_hWnd))
- DestroyPortAssociation(windowPort);
- }
+ if(!pQTVS)
+ {
+ // Destroy the view's GrafPort <-> HWND association
+ if(m_hWnd)
+ if(CGrafPtr windowPort = (CGrafPtr)GetHWNDPort(m_hWnd))
+ DestroyPortAssociation(windowPort);
+ }
}
BOOL CQuicktimeWindow::OnEraseBkgnd(CDC* pDC)
{
- return m_fs != State_Stopped && theMovie ? TRUE : __super::OnEraseBkgnd(pDC);
+ return m_fs != State_Stopped && theMovie ? TRUE : __super::OnEraseBkgnd(pDC);
}
void CQuicktimeWindow::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == m_idEndPoller && theMovie)
- {
- if(IsMovieDone(theMovie))
- {
- Pause();
- m_pGraph->NotifyEvent(EC_COMPLETE);
- }
- else if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph)
- {
+ if(nIDEvent == m_idEndPoller && theMovie)
+ {
+ if(IsMovieDone(theMovie))
+ {
+ Pause();
+ m_pGraph->NotifyEvent(EC_COMPLETE);
+ }
+ else if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph)
+ {
MoviesTask(theMovie, 0);
- /*
- long duration = 0, scale = 1000;
- OSErr err = QTGetTimeUntilNextTask(&duration, scale);
-
- // err is 0 but still doesn't seem to work... returns duration=0 always
- TRACE(_T("%d\n"), duration);
- KillTimer(m_idEndPoller);
- m_idEndPoller = SetTimer(m_idEndPoller, duration, NULL);
- */
- }
- }
-
- __super::OnTimer(nIDEvent);
+/*
+ long duration = 0, scale = 1000;
+ OSErr err = QTGetTimeUntilNextTask(&duration, scale);
+
+ // err is 0 but still doesn't seem to work... returns duration=0 always
+ TRACE(_T("%d\n"), duration);
+ KillTimer(m_idEndPoller);
+ m_idEndPoller = SetTimer(m_idEndPoller, duration, NULL);
+*/
+ }
+ }
+
+ __super::OnTimer(nIDEvent);
}
diff --git a/src/apps/mplayerc/QuicktimeGraph.h b/src/apps/mplayerc/QuicktimeGraph.h
index b88d48f1e..a64be3b83 100644
--- a/src/apps/mplayerc/QuicktimeGraph.h
+++ b/src/apps/mplayerc/QuicktimeGraph.h
@@ -30,99 +30,99 @@
namespace DSObjects
{
-class CQuicktimeGraph;
+ class CQuicktimeGraph;
-class CQuicktimeWindow : public CPlayerWindow
-{
- CDC m_dc;
- CBitmap m_bm;
- QT::GWorldPtr m_offscreenGWorld;
+ class CQuicktimeWindow : public CPlayerWindow
+ {
+ CDC m_dc;
+ CBitmap m_bm;
+ QT::GWorldPtr m_offscreenGWorld;
- CQuicktimeGraph* m_pGraph;
- FILTER_STATE m_fs;
- UINT m_idEndPoller;
+ CQuicktimeGraph* m_pGraph;
+ FILTER_STATE m_fs;
+ UINT m_idEndPoller;
- static QT::OSErr MyMovieDrawingCompleteProc(QT::Movie theMovie, long refCon);
+ static QT::OSErr MyMovieDrawingCompleteProc(QT::Movie theMovie, long refCon);
- void ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam);
+ void ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam);
-protected:
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ protected:
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
-public:
- CQuicktimeWindow(CQuicktimeGraph* pGraph);
+ public:
+ CQuicktimeWindow(CQuicktimeGraph* pGraph);
- bool OpenMovie(CString fn);
- void CloseMovie();
+ bool OpenMovie(CString fn);
+ void CloseMovie();
- void Run(), Pause(), Stop();
- FILTER_STATE GetState();
+ void Run(), Pause(), Stop();
+ FILTER_STATE GetState();
- QT::Movie theMovie;
- QT::MovieController theMC;
- CSize m_size;
+ QT::Movie theMovie;
+ QT::MovieController theMC;
+ CSize m_size;
-public:
- DECLARE_MESSAGE_MAP()
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnDestroy();
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
-};
+ public:
+ DECLARE_MESSAGE_MAP()
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnDestroy();
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ };
-class CQuicktimeGraph : public CBaseGraph, public IVideoFrameStep
-{
-protected:
- bool m_fQtInitialized;
+ class CQuicktimeGraph : public CBaseGraph, public IVideoFrameStep
+ {
+ protected:
+ bool m_fQtInitialized;
- CPlayerWindow m_wndWindowFrame;
- CQuicktimeWindow m_wndDestFrame;
+ CPlayerWindow m_wndWindowFrame;
+ CQuicktimeWindow m_wndDestFrame;
- CComPtr<ISubPicAllocatorPresenter> m_pQTAP;
+ CComPtr<ISubPicAllocatorPresenter> m_pQTAP;
-public:
- CQuicktimeGraph(HWND hParent, HRESULT& hr);
- virtual ~CQuicktimeGraph();
+ public:
+ CQuicktimeGraph(HWND hParent, HRESULT& hr);
+ virtual ~CQuicktimeGraph();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-protected:
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ protected:
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
- // IMediaSeeking
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
+ // IMediaSeeking
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
- // IVideoWindow
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+ // IVideoWindow
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
- // IBasicVideo
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+ // IBasicVideo
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
- // IVideoFrameStep
- STDMETHODIMP Step(DWORD dwFrames, IUnknown* pStepObject);
- STDMETHODIMP CanStep(long bMultiple, IUnknown* pStepObject);
- STDMETHODIMP CancelStep();
+ // IVideoFrameStep
+ STDMETHODIMP Step(DWORD dwFrames, IUnknown* pStepObject);
+ STDMETHODIMP CanStep(long bMultiple, IUnknown* pStepObject);
+ STDMETHODIMP CancelStep();
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
-};
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
+ };
}
using namespace DSObjects;
diff --git a/src/apps/mplayerc/RM9AllocatorPresenter.cpp b/src/apps/mplayerc/RM9AllocatorPresenter.cpp
index cc2d8f254..fb1b12111 100644
--- a/src/apps/mplayerc/RM9AllocatorPresenter.cpp
+++ b/src/apps/mplayerc/RM9AllocatorPresenter.cpp
@@ -31,8 +31,8 @@ using namespace DSObjects;
// CRM9AllocatorPresenter
//
-CRM9AllocatorPresenter::CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
+CRM9AllocatorPresenter::CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+ : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
{
}
@@ -40,215 +40,211 @@ STDMETHODIMP CRM9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, vo
{
CheckPointer(ppv, E_POINTER);
- return
- QI2(IRMAVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMAVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CRM9AllocatorPresenter::AllocSurfaces()
{
CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cRenderLock(&m_RenderLock);
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
- HRESULT hr;
+ HRESULT hr;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL)))
- return hr;
+ if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL)))
+ return hr;
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_YUY2,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceYUY2, NULL)))
- m_pVideoSurfaceYUY2 = NULL;
+ if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_YUY2,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceYUY2, NULL)))
+ m_pVideoSurfaceYUY2 = NULL;
- if(m_pVideoSurfaceYUY2)
- {
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0x80108010);
- }
+ if(m_pVideoSurfaceYUY2)
+ {
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0x80108010);
+ }
- return __super::AllocSurfaces();
+ return __super::AllocSurfaces();
}
void CRM9AllocatorPresenter::DeleteSurfaces()
{
CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
- __super::DeleteSurfaces();
+ CAutoLock cRenderLock(&m_RenderLock);
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
+ __super::DeleteSurfaces();
}
// IRMAVideoSurface
STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
- return E_FAIL;
-
- bool fRGB = false;
- bool fYUY2 = false;
-
- CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0, 0), src.Size());
- if(src.Width() > dst.Width() || src.Height() > dst.Height())
- return E_FAIL;
-
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd)))
- return E_FAIL;
-
- int dbpp =
- d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
- d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
-
- if(pBitmapInfo->biCompression == '024I')
- {
- DWORD pitch = pBitmapInfo->biWidth;
- DWORD size = pitch * abs(pBitmapInfo->biHeight);
-
- BYTE* y = pImageData + src.top * pitch + src.left;
- BYTE* u = pImageData + size + src.top * (pitch / 2) + src.left / 2;
- BYTE* v = pImageData + size + size / 4 + src.top * (pitch / 2) + src.left / 2;
-
- if(m_pVideoSurfaceYUY2)
- {
- D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0)))
- {
- BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, y, u, v, pitch);
- m_pVideoSurfaceYUY2->UnlockRect();
- fYUY2 = true;
- }
- }
- else
- {
- D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
- {
- BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, y, u, v, pitch);
- m_pVideoSurfaceOff->UnlockRect();
- fRGB = true;
- }
- }
- }
- else if(pBitmapInfo->biCompression == '2YUY')
- {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth * 2;
-
- BYTE* yvyu = pImageData + src.top * pitch + src.left * 2;
-
- if(m_pVideoSurfaceYUY2)
- {
- D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0)))
- {
- BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, yvyu, pitch);
- m_pVideoSurfaceYUY2->UnlockRect();
- fYUY2 = true;
- }
- }
- else
- {
- D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
- {
- BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, yvyu, pitch);
- m_pVideoSurfaceOff->UnlockRect();
- fRGB = true;
- }
- }
- }
- else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
- || pBitmapInfo->biCompression == 'BGRA')
- {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth * pBitmapInfo->biBitCount >> 3;
-
- BYTE* rgb = pImageData + src.top * pitch + src.left * (pBitmapInfo->biBitCount >> 3);
-
- D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
- {
- BYTE* pBits = (BYTE*)r.pBits;
- if(pBitmapInfo->biHeight > 0)
- {
- pBits += r.Pitch * (src.Height() - 1);
- r.Pitch = -r.Pitch;
- }
- BitBltFromRGBToRGB(src.Width(), src.Height(), pBits, r.Pitch, dbpp, rgb, pitch, pBitmapInfo->biBitCount);
- m_pVideoSurfaceOff->UnlockRect();
- fRGB = true;
- }
- }
-
- if(!fRGB && !fYUY2)
- {
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
-
- HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
-
- fRGB = true;
- }
- }
-
- HRESULT hr;
-
- if(fRGB)
- hr = m_pD3DDev->StretchRect(m_pVideoSurfaceOff, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
- if(fYUY2)
- hr = m_pD3DDev->StretchRect(m_pVideoSurfaceYUY2, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
-
- Paint(true);
-
- return PNR_OK;
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ return E_FAIL;
+
+ bool fRGB = false;
+ bool fYUY2 = false;
+
+ CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
+ if(src.Width() > dst.Width() || src.Height() > dst.Height())
+ return E_FAIL;
+
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd)))
+ return E_FAIL;
+
+ int dbpp =
+ d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
+ d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
+
+ if(pBitmapInfo->biCompression == '024I')
+ {
+ DWORD pitch = pBitmapInfo->biWidth;
+ DWORD size = pitch*abs(pBitmapInfo->biHeight);
+
+ BYTE* y = pImageData + src.top*pitch + src.left;
+ BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
+ BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ D3DLOCKED_RECT r;
+ if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0)))
+ {
+ BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, y, u, v, pitch);
+ m_pVideoSurfaceYUY2->UnlockRect();
+ fYUY2 = true;
+ }
+ }
+ else
+ {
+ D3DLOCKED_RECT r;
+ if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
+ {
+ BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, y, u, v, pitch);
+ m_pVideoSurfaceOff->UnlockRect();
+ fRGB = true;
+ }
+ }
+ }
+ else if(pBitmapInfo->biCompression == '2YUY')
+ {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth*2;
+
+ BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ D3DLOCKED_RECT r;
+ if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0)))
+ {
+ BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, yvyu, pitch);
+ m_pVideoSurfaceYUY2->UnlockRect();
+ fYUY2 = true;
+ }
+ }
+ else
+ {
+ D3DLOCKED_RECT r;
+ if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
+ {
+ BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, yvyu, pitch);
+ m_pVideoSurfaceOff->UnlockRect();
+ fRGB = true;
+ }
+ }
+ }
+ else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
+ || pBitmapInfo->biCompression == 'BGRA')
+ {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
+
+ BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
+
+ D3DLOCKED_RECT r;
+ if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
+ {
+ BYTE* pBits = (BYTE*)r.pBits;
+ if(pBitmapInfo->biHeight > 0) {pBits += r.Pitch*(src.Height()-1); r.Pitch = -r.Pitch;}
+ BitBltFromRGBToRGB(src.Width(), src.Height(), pBits, r.Pitch, dbpp, rgb, pitch, pBitmapInfo->biBitCount);
+ m_pVideoSurfaceOff->UnlockRect();
+ fRGB = true;
+ }
+ }
+
+ if(!fRGB && !fYUY2)
+ {
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
+
+ HDC hDC;
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
+ {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+
+ fRGB = true;
+ }
+ }
+
+ HRESULT hr;
+
+ if(fRGB)
+ hr = m_pD3DDev->StretchRect(m_pVideoSurfaceOff, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
+ if(fYUY2)
+ hr = m_pD3DDev->StretchRect(m_pVideoSurfaceYUY2, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
+
+ Paint(true);
+
+ return PNR_OK;
}
STDMETHODIMP CRM9AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo)
{
CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
- DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if(FAILED(AllocSurfaces())) return E_FAIL;
- return PNR_NOTIMPL;
+ CAutoLock cRenderLock(&m_RenderLock);
+ DeleteSurfaces();
+ m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
+ if(FAILED(AllocSurfaces())) return E_FAIL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::EndOptimizedBlt()
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- ulType = RMA_I420;
- return PNR_OK;
+ ulType = RMA_I420;
+ return PNR_OK;
}
diff --git a/src/apps/mplayerc/RM9AllocatorPresenter.h b/src/apps/mplayerc/RM9AllocatorPresenter.h
index 183bb1c01..fd7673a42 100644
--- a/src/apps/mplayerc/RM9AllocatorPresenter.h
+++ b/src/apps/mplayerc/RM9AllocatorPresenter.h
@@ -31,32 +31,32 @@
namespace DSObjects
{
-class CRM9AllocatorPresenter
- : public CDX9AllocatorPresenter
- , public IRMAVideoSurface
-{
- CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
- CComPtr<IDirect3DSurface9> m_pVideoSurfaceYUY2;
-
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
-
-protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
-
-public:
- CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IRMAVideoSurface
- STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
-};
+ class CRM9AllocatorPresenter
+ : public CDX9AllocatorPresenter
+ , public IRMAVideoSurface
+ {
+ CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
+ CComPtr<IDirect3DSurface9> m_pVideoSurfaceYUY2;
+
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
+
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
+
+ public:
+ CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IRMAVideoSurface
+ STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ };
}
diff --git a/src/apps/mplayerc/RealMediaGraph.cpp b/src/apps/mplayerc/RealMediaGraph.cpp
index 35bd77d6b..b549acba5 100644
--- a/src/apps/mplayerc/RealMediaGraph.cpp
+++ b/src/apps/mplayerc/RealMediaGraph.cpp
@@ -38,287 +38,275 @@
// CRealMediaPlayer
-CRealMediaPlayer::CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG)
- : CUnknown(NAME("CRealMediaPlayer"), NULL)
- , m_pRMG(pRMG)
- , m_hWndParent(hWndParent)
- , m_fpCreateEngine(NULL), m_fpCloseEngine(NULL), m_hRealMediaCore(NULL)
- , m_State(State_Stopped), m_UserState(State_Stopped), m_nCurrent(0), m_nDuration(0)
- , m_VideoSize(0, 0)
- , m_fVideoSizeChanged(true)
+CRealMediaPlayer::CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG)
+ : CUnknown(NAME("CRealMediaPlayer"), NULL)
+ , m_pRMG(pRMG)
+ , m_hWndParent(hWndParent)
+ , m_fpCreateEngine(NULL), m_fpCloseEngine(NULL), m_hRealMediaCore(NULL)
+ , m_State(State_Stopped), m_UserState(State_Stopped), m_nCurrent(0), m_nDuration(0)
+ , m_VideoSize(0, 0)
+ , m_fVideoSizeChanged(true)
{
}
CRealMediaPlayer::~CRealMediaPlayer()
{
- Deinit();
+ Deinit();
}
bool CRealMediaPlayer::Init()
{
- CString prefs(_T("Software\\RealNetworks\\Preferences"));
+ CString prefs(_T("Software\\RealNetworks\\Preferences"));
- CRegKey key;
+ CRegKey key;
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, prefs + _T("\\DT_Common"), KEY_READ))
- return(false);
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, prefs + _T("\\DT_Common"), KEY_READ))
+ return(false);
- TCHAR buff[_MAX_PATH];
- ULONG len = sizeof(buff);
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
- return(false);
+ TCHAR buff[_MAX_PATH];
+ ULONG len = sizeof(buff);
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
+ return(false);
- key.Close();
+ key.Close();
- if(!(m_hRealMediaCore = LoadLibrary(CString(buff) + _T("pnen3260.dll"))))
- return(false);
+ if(!(m_hRealMediaCore = LoadLibrary(CString(buff) + _T("pnen3260.dll"))))
+ return(false);
- m_fpCreateEngine = (FPRMCREATEENGINE)GetProcAddress(m_hRealMediaCore, "CreateEngine");
- m_fpCloseEngine = (FPRMCLOSEENGINE)GetProcAddress(m_hRealMediaCore, "CloseEngine");
- m_fpSetDLLAccessPath = (FPRMSETDLLACCESSPATH)GetProcAddress(m_hRealMediaCore, "SetDLLAccessPath");
+ m_fpCreateEngine = (FPRMCREATEENGINE)GetProcAddress(m_hRealMediaCore, "CreateEngine");
+ m_fpCloseEngine = (FPRMCLOSEENGINE)GetProcAddress(m_hRealMediaCore, "CloseEngine");
+ m_fpSetDLLAccessPath = (FPRMSETDLLACCESSPATH)GetProcAddress(m_hRealMediaCore, "SetDLLAccessPath");
+
+ if(!m_fpCreateEngine || !m_fpCloseEngine || !m_fpSetDLLAccessPath)
+ return(false);
- if(!m_fpCreateEngine || !m_fpCloseEngine || !m_fpSetDLLAccessPath)
- return(false);
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, prefs, KEY_READ))
+ {
+ CString dllpaths;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, prefs, KEY_READ))
- {
- CString dllpaths;
-
- len = sizeof(buff);
- for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = sizeof(buff))
- {
- CRegKey key2;
- TCHAR buff2[_MAX_PATH];
- ULONG len2 = sizeof(buff2);
- if(ERROR_SUCCESS != key2.Open(HKEY_CLASSES_ROOT, prefs + _T("\\") + buff, KEY_READ)
- || ERROR_SUCCESS != key2.QueryStringValue(NULL, buff2, &len2))
- continue;
-
- dllpaths += CString(buff) + '=' + buff2 + '|';
- }
-
- key.Close();
-
- if(!dllpaths.IsEmpty())
- {
- char* s = DNew char[dllpaths.GetLength()+1];
- strcpy(s, CStringA(dllpaths));
- for(int i = 0, j = strlen(s); i < j; i++)
- {
- if(s[i] == '|') s[i] = '\0';
- }
- m_fpSetDLLAccessPath(s);
- delete [] s;
- }
- }
+ len = sizeof(buff);
+ for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = sizeof(buff))
+ {
+ CRegKey key2;
+ TCHAR buff2[_MAX_PATH];
+ ULONG len2 = sizeof(buff2);
+ if(ERROR_SUCCESS != key2.Open(HKEY_CLASSES_ROOT, prefs + _T("\\") + buff, KEY_READ)
+ || ERROR_SUCCESS != key2.QueryStringValue(NULL, buff2, &len2))
+ continue;
+
+ dllpaths += CString(buff) + '=' + buff2 + '|';
+ }
+
+ key.Close();
- if(PNR_OK != m_fpCreateEngine(&m_pEngine))
- return(false);
+ if(!dllpaths.IsEmpty())
+ {
+ char* s = DNew char[dllpaths.GetLength()+1];
+ strcpy(s, CStringA(dllpaths));
+ for(int i = 0, j = strlen(s); i < j; i++) {if(s[i] == '|') s[i] = '\0';}
+ m_fpSetDLLAccessPath(s);
+ delete [] s;
+ }
+ }
- if(PNR_OK != m_pEngine->CreatePlayer(*&m_pPlayer))
- return(false);
+ if(PNR_OK != m_fpCreateEngine(&m_pEngine))
+ return(false);
- if(!(m_pSiteManager = m_pPlayer) || !(m_pCommonClassFactory = m_pPlayer))
- return(false);
+ if(PNR_OK != m_pEngine->CreatePlayer(*&m_pPlayer))
+ return(false);
- m_pAudioPlayer = m_pPlayer;
- m_pAudioPlayer->AddPostMixHook(static_cast<IRMAAudioHook*>(this), FALSE, FALSE);
+ if(!(m_pSiteManager = m_pPlayer) || !(m_pCommonClassFactory = m_pPlayer))
+ return(false);
+
+ m_pAudioPlayer = m_pPlayer;
+ m_pAudioPlayer->AddPostMixHook(static_cast<IRMAAudioHook*>(this), FALSE, FALSE);
// m_pVolume = m_pAudioPlayer->GetDeviceVolume();
- m_pVolume = m_pAudioPlayer->GetAudioVolume();
+ m_pVolume = m_pAudioPlayer->GetAudioVolume();
- // IRMAVolume::SetVolume has a huge latency when used via GetAudioVolume,
- // but by lowering this audio pushdown thing it can get better
- CComQIPtr<IRMAAudioPushdown, &IID_IRMAAudioPushdown> pAP = m_pAudioPlayer;
- if(pAP) pAP->SetAudioPushdown(300); // 100ms makes the playback sound choppy, 200ms looks ok, but for safety we set this to 300ms... :P
+ // IRMAVolume::SetVolume has a huge latency when used via GetAudioVolume,
+ // but by lowering this audio pushdown thing it can get better
+ CComQIPtr<IRMAAudioPushdown, &IID_IRMAAudioPushdown> pAP = m_pAudioPlayer;
+ if(pAP) pAP->SetAudioPushdown(300); // 100ms makes the playback sound choppy, 200ms looks ok, but for safety we set this to 300ms... :P
- CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
- if(pErrorSinkControl) pErrorSinkControl->AddErrorSink(static_cast<IRMAErrorSink*>(this), PNLOG_EMERG, PNLOG_INFO);
+ CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
+ if(pErrorSinkControl) pErrorSinkControl->AddErrorSink(static_cast<IRMAErrorSink*>(this), PNLOG_EMERG, PNLOG_INFO);
- if(PNR_OK != m_pPlayer->AddAdviseSink(static_cast<IRMAClientAdviseSink*>(this)))
- return(false);
+ if(PNR_OK != m_pPlayer->AddAdviseSink(static_cast<IRMAClientAdviseSink*>(this)))
+ return(false);
- if(PNR_OK != m_pPlayer->SetClientContext((IUnknown*)(INonDelegatingUnknown*)(this)))
- return(false);
+ if(PNR_OK != m_pPlayer->SetClientContext((IUnknown*)(INonDelegatingUnknown*)(this)))
+ return(false);
- // TODO
- /*
- if(CComQIPtr<IRMAPreferences, &IID_IRMAPreferences> pPrefs = m_pPlayer)
- {
- CComPtr<IRMABuffer> pBuffer;
- HRESULT hr = pPrefs->ReadPref("HTTPProxyHost", *&pBuffer);
+ // TODO
+/*
+ if(CComQIPtr<IRMAPreferences, &IID_IRMAPreferences> pPrefs = m_pPlayer)
+ {
+ CComPtr<IRMABuffer> pBuffer;
+ HRESULT hr = pPrefs->ReadPref("HTTPProxyHost", *&pBuffer);
- UCHAR* pData = NULL;
- ULONG32 ulLength = 0;
- hr = pBuffer->Get(pData, ulLength);
+ UCHAR* pData = NULL;
+ ULONG32 ulLength = 0;
+ hr = pBuffer->Get(pData, ulLength);
- pBuffer = NULL;
- hr = m_pCommonClassFactory->CreateInstance(CLSID_IRMABuffer, (void**)&pBuffer);
- hr = pBuffer->SetSize(strlen("localhost")+1);
- pData = pBuffer->GetBuffer();
- strcpy((char*)pData, "localhost");
- hr = pBuffer->Set(pData, strlen("localhost")+1);
+ pBuffer = NULL;
+ hr = m_pCommonClassFactory->CreateInstance(CLSID_IRMABuffer, (void**)&pBuffer);
+ hr = pBuffer->SetSize(strlen("localhost")+1);
+ pData = pBuffer->GetBuffer();
+ strcpy((char*)pData, "localhost");
+ hr = pBuffer->Set(pData, strlen("localhost")+1);
- pData = NULL;
- ulLength = 0;
- hr = pBuffer->Get(pData, ulLength);
+ pData = NULL;
+ ulLength = 0;
+ hr = pBuffer->Get(pData, ulLength);
- hr = pPrefs->WritePref("HTTPProxyHost", pBuffer);
+ hr = pPrefs->WritePref("HTTPProxyHost", pBuffer);
- hr = hr;
- }
- */
- return(true);
+ hr = hr;
+ }
+*/
+ return(true);
}
void CRealMediaPlayer::Deinit()
{
- if(m_pPlayer)
- {
- m_pPlayer->Stop();
+ if(m_pPlayer)
+ {
+ m_pPlayer->Stop();
- CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
- if(pErrorSinkControl) pErrorSinkControl->RemoveErrorSink(static_cast<IRMAErrorSink*>(this));
+ CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
+ if(pErrorSinkControl) pErrorSinkControl->RemoveErrorSink(static_cast<IRMAErrorSink*>(this));
- m_pPlayer->RemoveAdviseSink(static_cast<IRMAClientAdviseSink*>(this));
+ m_pPlayer->RemoveAdviseSink(static_cast<IRMAClientAdviseSink*>(this));
- m_pVolume = NULL;
- m_pAudioPlayer->RemovePostMixHook(static_cast<IRMAAudioHook*>(this));
- m_pAudioPlayer.Release();
+ m_pVolume = NULL;
+ m_pAudioPlayer->RemovePostMixHook(static_cast<IRMAAudioHook*>(this));
+ m_pAudioPlayer.Release();
- m_pEngine->ClosePlayer(m_pPlayer);
+ m_pEngine->ClosePlayer(m_pPlayer);
- m_pSiteManager.Release();
- m_pCommonClassFactory.Release();
+ m_pSiteManager.Release();
+ m_pCommonClassFactory.Release();
- m_pPlayer = NULL;
- }
+ m_pPlayer = NULL;
+ }
- if(m_pEngine)
- {
- m_fpCloseEngine(m_pEngine);
- m_pEngine = NULL;
- }
+ if(m_pEngine)
+ {
+ m_fpCloseEngine(m_pEngine);
+ m_pEngine = NULL;
+ }
- if(m_hRealMediaCore)
- {
- FreeLibrary(m_hRealMediaCore);
- m_hRealMediaCore = NULL;
- }
+ if(m_hRealMediaCore)
+ {
+ FreeLibrary(m_hRealMediaCore);
+ m_hRealMediaCore = NULL;
+ }
}
STDMETHODIMP CRealMediaPlayer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- QI2(IRMAErrorSink)
- QI2(IRMAClientAdviseSink)
- QI2(IRMAAuthenticationManager)
- QI2(IRMASiteSupplier)
- QI2(IRMAPassiveSiteWatcher)
- QI2(IRMAAudioHook)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMAErrorSink)
+ QI2(IRMAClientAdviseSink)
+ QI2(IRMAAuthenticationManager)
+ QI2(IRMASiteSupplier)
+ QI2(IRMAPassiveSiteWatcher)
+ QI2(IRMAAudioHook)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IRMAErrorSink
STDMETHODIMP CRealMediaPlayer::ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL)
{
- char* errmsg = NULL;
+ char* errmsg = NULL;
- if(unSeverity < 5)
- {
- if(CComQIPtr<IRMAErrorMessages, &IID_IRMAErrorMessages> pErrorMessages = m_pPlayer)
- {
- CComPtr<IRMABuffer> pBuffer = pErrorMessages->GetErrorText(ulRMACode);
- if(pBuffer)
- {
- char* buff = (char*)pBuffer->GetBuffer();
- int len = strlen(buff);
- if(len > 0 && (errmsg = (char*)CoTaskMemAlloc(len + 1)))
- strcpy(errmsg, buff);
- }
- }
-
- if(!errmsg && (errmsg = (char*)CoTaskMemAlloc(strlen("RealMedia error") + 1)))
- strcpy(errmsg, "RealMedia error");
-
- m_pRMG->NotifyEvent(EC_BG_ERROR, (LONG_PTR)errmsg, 0);
- }
+ if(unSeverity < 5)
+ {
+ if(CComQIPtr<IRMAErrorMessages, &IID_IRMAErrorMessages> pErrorMessages = m_pPlayer)
+ {
+ CComPtr<IRMABuffer> pBuffer = pErrorMessages->GetErrorText(ulRMACode);
+ if(pBuffer)
+ {
+ char* buff = (char*)pBuffer->GetBuffer();
+ int len = strlen(buff);
+ if(len > 0 && (errmsg = (char*)CoTaskMemAlloc(len+1)))
+ strcpy(errmsg, buff);
+ }
+ }
- return PNR_OK;
+ if(!errmsg && (errmsg = (char*)CoTaskMemAlloc(strlen("RealMedia error")+1)))
+ strcpy(errmsg, "RealMedia error");
+
+ m_pRMG->NotifyEvent(EC_BG_ERROR, (LONG_PTR)errmsg, 0);
+ }
+
+ return PNR_OK;
}
// IRMAClientAdviseSink
STDMETHODIMP CRealMediaPlayer::OnPosLength(UINT32 ulPosition, UINT32 ulLength)
{
- m_nCurrent = (REFERENCE_TIME)ulPosition * 10000;
- m_nDuration = (REFERENCE_TIME)ulLength * 10000;
- return PNR_OK;
-}
-STDMETHODIMP CRealMediaPlayer::OnPresentationOpened()
-{
- return PNR_OK;
-}
-STDMETHODIMP CRealMediaPlayer::OnPresentationClosed()
-{
- return PNR_OK;
+ m_nCurrent = (REFERENCE_TIME)ulPosition*10000;
+ m_nDuration = (REFERENCE_TIME)ulLength*10000;
+ return PNR_OK;
}
-STDMETHODIMP CRealMediaPlayer::OnStatisticsChanged()
+STDMETHODIMP CRealMediaPlayer::OnPresentationOpened() {return PNR_OK;}
+STDMETHODIMP CRealMediaPlayer::OnPresentationClosed() {return PNR_OK;}
+STDMETHODIMP CRealMediaPlayer::OnStatisticsChanged()
{
- m_pRMG->NotifyEvent(EC_LENGTH_CHANGED);
- return PNR_OK;
+ m_pRMG->NotifyEvent(EC_LENGTH_CHANGED);
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime)
{
- m_nCurrent = (REFERENCE_TIME)ulNewTime * 10000;
- return PNR_OK;
+ m_nCurrent = (REFERENCE_TIME)ulNewTime*10000;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime)
{
- m_nCurrent = (REFERENCE_TIME)ulNewTime * 10000;
- return PNR_OK;
+ m_nCurrent = (REFERENCE_TIME)ulNewTime*10000;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnStop()
{
- m_nCurrent = 0;
- m_State = State_Stopped;
- if(m_UserState != State_Stopped)
- m_pRMG->NotifyEvent(EC_COMPLETE);
- return PNR_OK;
+ m_nCurrent = 0;
+ m_State = State_Stopped;
+ if(m_UserState != State_Stopped)
+ m_pRMG->NotifyEvent(EC_COMPLETE);
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPause(UINT32 ulTime)
{
- m_State = State_Paused;
- return PNR_OK;
+ m_State = State_Paused;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnBegin(UINT32 ulTime)
{
- m_State = State_Running;
- return PNR_OK;
+ m_State = State_Running;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete)
{
- m_unPercentComplete = unPercentComplete;
- return PNR_OK;
-}
-STDMETHODIMP CRealMediaPlayer::OnContacting(const char* pHostName)
-{
- return PNR_OK;
+ m_unPercentComplete = unPercentComplete;
+ return PNR_OK;
}
+STDMETHODIMP CRealMediaPlayer::OnContacting(const char* pHostName) {return PNR_OK;}
// IRMAAuthenticationManager
STDMETHODIMP CRealMediaPlayer::HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse)
{
- CAuthDlg dlg;
+ CAuthDlg dlg;
- if(dlg.DoModal() == IDOK)
- {
- pResponse->AuthenticationRequestDone(
- PNR_OK, CStringA(dlg.m_username), CStringA(dlg.m_password));
- return PNR_OK;
- }
+ if(dlg.DoModal() == IDOK)
+ {
+ pResponse->AuthenticationRequestDone(
+ PNR_OK, CStringA(dlg.m_username), CStringA(dlg.m_password));
+ return PNR_OK;
+ }
- return pResponse->AuthenticationRequestDone(PNR_NOT_AUTHORIZED, NULL, NULL);
+ return pResponse->AuthenticationRequestDone(PNR_NOT_AUTHORIZED, NULL, NULL);
}
// IRMASiteSupplier
@@ -326,47 +314,47 @@ STDMETHODIMP CRealMediaPlayer::SitesNeeded(UINT32 uRequestID, IRMAValues* pProps
{
if(!pProps) return PNR_INVALID_PARAMETER;
- if(m_pTheSite || m_pTheSite2 || !m_hWndParent) return PNR_UNEXPECTED;
+ if(m_pTheSite || m_pTheSite2 || !m_hWndParent) return PNR_UNEXPECTED;
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if(!CreateSite(&m_pTheSite))
- return E_FAIL;
+ if(!CreateSite(&m_pTheSite))
+ return E_FAIL;
- ULONG refc = ((IRMASite*)m_pTheSite)->AddRef();
- refc = ((IRMASite*)m_pTheSite)->Release();
+ ULONG refc = ((IRMASite*)m_pTheSite)->AddRef();
+ refc = ((IRMASite*)m_pTheSite)->Release();
- if(!(m_pTheSite2 = m_pTheSite))
- return E_NOINTERFACE;
+ if(!(m_pTheSite2 = m_pTheSite))
+ return E_NOINTERFACE;
- CComQIPtr<IRMAValues, &IID_IRMAValues> pSiteProps = m_pTheSite;
+ CComQIPtr<IRMAValues, &IID_IRMAValues> pSiteProps = m_pTheSite;
if(!pSiteProps)
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
IRMABuffer* pValue;
- // no idea what these supposed to do... but they were in the example
+ // no idea what these supposed to do... but they were in the example
hr = pProps->GetPropertyCString("playto", pValue);
if(PNR_OK == hr)
{
- pSiteProps->SetPropertyCString("channel", pValue);
- pValue->Release();
+ pSiteProps->SetPropertyCString("channel", pValue);
+ pValue->Release();
}
else
{
- hr = pProps->GetPropertyCString("name", pValue);
- if(PNR_OK == hr)
- {
- pSiteProps->SetPropertyCString("LayoutGroup", pValue);
- pValue->Release();
- }
+ hr = pProps->GetPropertyCString("name", pValue);
+ if(PNR_OK == hr)
+ {
+ pSiteProps->SetPropertyCString("LayoutGroup", pValue);
+ pValue->Release();
+ }
}
m_pTheSite2->AddPassiveSiteWatcher(static_cast<IRMAPassiveSiteWatcher*>(this));
hr = m_pSiteManager->AddSite(m_pTheSite);
if(PNR_OK != hr)
- return hr;
+ return hr;
m_CreatedSites[uRequestID] = m_pTheSite;
@@ -376,147 +364,138 @@ STDMETHODIMP CRealMediaPlayer::SitesNeeded(UINT32 uRequestID, IRMAValues* pProps
STDMETHODIMP CRealMediaPlayer::SitesNotNeeded(UINT32 uRequestID)
{
IRMASite* pSite;
- if(!m_CreatedSites.Lookup(uRequestID, pSite))
- return PNR_INVALID_PARAMETER;
+ if(!m_CreatedSites.Lookup(uRequestID, pSite))
+ return PNR_INVALID_PARAMETER;
- m_CreatedSites.RemoveKey(uRequestID);
+ m_CreatedSites.RemoveKey(uRequestID);
m_pSiteManager->RemoveSite(pSite);
m_pTheSite2->RemovePassiveSiteWatcher(static_cast<IRMAPassiveSiteWatcher*>(this));
- m_pTheSite.Release();
- m_pTheSite2.Release();
+ m_pTheSite.Release();
+ m_pTheSite2.Release();
- DestroySite(pSite);
+ DestroySite(pSite);
return PNR_OK;
}
-STDMETHODIMP CRealMediaPlayer::BeginChangeLayout()
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CRealMediaPlayer::BeginChangeLayout() {return E_NOTIMPL;}
STDMETHODIMP CRealMediaPlayer::DoneChangeLayout()
{
- if(m_fVideoSizeChanged)
- {
+ if(m_fVideoSizeChanged)
+ {
m_pRMG->NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_VideoSize.cx, m_VideoSize.cy), 0);
- m_fVideoSizeChanged = false;
- }
+ m_fVideoSizeChanged = false;
+ }
- return PNR_OK;
+ return PNR_OK;
}
// IRMAPassiveSiteWatcher
-STDMETHODIMP CRealMediaPlayer::PositionChanged(PNxPoint* pos)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CRealMediaPlayer::PositionChanged(PNxPoint* pos) {return E_NOTIMPL;}
STDMETHODIMP CRealMediaPlayer::SizeChanged(PNxSize* size)
{
- if(m_VideoSize.cx == 0 || m_VideoSize.cy == 0)
- {
- m_fVideoSizeChanged = true;
- m_VideoSize.cx = size->cx;
- m_VideoSize.cy = size->cy;
- }
- return PNR_OK;
+ if(m_VideoSize.cx == 0 || m_VideoSize.cy == 0)
+ {
+ m_fVideoSizeChanged = true;
+ m_VideoSize.cx = size->cx;
+ m_VideoSize.cy = size->cy;
+ }
+ return PNR_OK;
}
// IRMAAudioHook
-STDMETHODIMP CRealMediaPlayer::OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData)
-{
- return E_NOTIMPL;
-}
+STDMETHODIMP CRealMediaPlayer::OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData) {return E_NOTIMPL;}
STDMETHODIMP CRealMediaPlayer::OnInit(RMAAudioFormat* pFormat)
{
- m_pRMG->NotifyEvent(EC_BG_AUDIO_CHANGED, pFormat->uChannels, 0);
- return PNR_OK;
+ m_pRMG->NotifyEvent(EC_BG_AUDIO_CHANGED, pFormat->uChannels, 0);
+ return PNR_OK;
}
//
// CRealMediaPlayerWindowed
//
-CRealMediaPlayerWindowed::CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG)
- : CRealMediaPlayer(hWndParent, pRMG)
+CRealMediaPlayerWindowed::CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG)
+ : CRealMediaPlayer(hWndParent, pRMG)
{
- if(!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE,
- CRect(0, 0, 0, 0), CWnd::FromHandle(m_hWndParent), 0, NULL))
- return;
+ if(!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE,
+ CRect(0, 0, 0, 0), CWnd::FromHandle(m_hWndParent), 0, NULL))
+ return;
- if(!m_wndDestFrame.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- CRect(0, 0, 0, 0), &m_wndWindowFrame, 0, NULL))
- return;
+ if(!m_wndDestFrame.Create(NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
+ CRect(0, 0, 0, 0), &m_wndWindowFrame, 0, NULL))
+ return;
}
CRealMediaPlayerWindowed::~CRealMediaPlayerWindowed()
{
- m_wndDestFrame.DestroyWindow();
- m_wndWindowFrame.DestroyWindow();
+ m_wndDestFrame.DestroyWindow();
+ m_wndWindowFrame.DestroyWindow();
}
void CRealMediaPlayerWindowed::SetWindowRect(CRect r)
{
- if(IsWindow(m_wndWindowFrame.m_hWnd))
- m_wndWindowFrame.MoveWindow(r);
+ if(IsWindow(m_wndWindowFrame.m_hWnd))
+ m_wndWindowFrame.MoveWindow(r);
}
void CRealMediaPlayerWindowed::SetDestRect(CRect r)
{
- if(IsWindow(m_wndDestFrame.m_hWnd))
- m_wndDestFrame.MoveWindow(r);
+ if(IsWindow(m_wndDestFrame.m_hWnd))
+ m_wndDestFrame.MoveWindow(r);
- if(m_pTheSite)
- {
- PNxSize s = {r.Width(), r.Height()};
- m_pTheSite->SetSize(s);
- }
+ if(m_pTheSite)
+ {
+ PNxSize s = {r.Width(), r.Height()};
+ m_pTheSite->SetSize(s);
+ }
}
bool CRealMediaPlayerWindowed::CreateSite(IRMASite** ppSite)
{
- if(!ppSite)
- return(false);
+ if(!ppSite)
+ return(false);
CComPtr<IRMASiteWindowed> pSiteWindowed;
if(PNR_OK != m_pCommonClassFactory->CreateInstance(CLSID_IRMASiteWindowed, (void**)&pSiteWindowed))
- return(false);
+ return(false);
- DWORD style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
- if(!AfxGetAppSettings().fIntRealMedia) style |= WS_DISABLED;
+ DWORD style = WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
+ if(!AfxGetAppSettings().fIntRealMedia) style |= WS_DISABLED;
if(PNR_OK != pSiteWindowed->Create(m_wndDestFrame.m_hWnd, style))
- return(false);
+ return(false);
- return !!(*ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowed).Detach());
+ return !!(*ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowed).Detach());
}
void CRealMediaPlayerWindowed::DestroySite(IRMASite* pSite)
{
- if(CComQIPtr<IRMASiteWindowed, &IID_IRMASiteWindowed> pRMASiteWindowed = pSite)
- pRMASiteWindowed->Destroy();
+ if(CComQIPtr<IRMASiteWindowed, &IID_IRMASiteWindowed> pRMASiteWindowed = pSite)
+ pRMASiteWindowed->Destroy();
}
//
// CRealMediaPlayerWindowless
//
-CRealMediaPlayerWindowless::CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG)
- : CRealMediaPlayer(hWndParent, pRMG)
+CRealMediaPlayerWindowless::CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG)
+ : CRealMediaPlayer(hWndParent, pRMG)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- switch(s.iRMVideoRendererType)
- {
- default:
- case VIDRNDT_RM_DX7:
- if(FAILED(CreateAP7(CLSID_RM7AllocatorPresenter, hWndParent, &m_pRMAP)))
- return;
- break;
- case VIDRNDT_RM_DX9:
- if(FAILED(CreateAP9(CLSID_RM9AllocatorPresenter, hWndParent, &m_pRMAP)))
- return;
- break;
- }
+ switch(s.iRMVideoRendererType)
+ {
+ default:
+ case VIDRNDT_RM_DX7:
+ if(FAILED(CreateAP7(CLSID_RM7AllocatorPresenter, hWndParent, &m_pRMAP)))
+ return;
+ break;
+ case VIDRNDT_RM_DX9:
+ if(FAILED(CreateAP9(CLSID_RM9AllocatorPresenter, hWndParent, &m_pRMAP)))
+ return;
+ break;
+ }
}
CRealMediaPlayerWindowless::~CRealMediaPlayerWindowless()
@@ -527,28 +506,28 @@ STDMETHODIMP CRealMediaPlayerWindowless::NonDelegatingQueryInterface(REFIID riid
{
CheckPointer(ppv, E_POINTER);
- return
- (m_pRMAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == IID_IRMAVideoSurface)) ? m_pRMAP->QueryInterface(riid, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (m_pRMAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == IID_IRMAVideoSurface)) ? m_pRMAP->QueryInterface(riid, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
bool CRealMediaPlayerWindowless::CreateSite(IRMASite** ppSite)
{
- if(!ppSite || !m_pRMAP)
- return(false);
+ if(!ppSite || !m_pRMAP)
+ return(false);
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- CRealMediaWindowlessSite* pWMWlS;
+ CRealMediaWindowlessSite* pWMWlS;
CComPtr<IRMASiteWindowless> pSiteWindowless;
- pSiteWindowless = (IRMASiteWindowless*)(pWMWlS = DNew CRealMediaWindowlessSite(hr, m_pPlayer, NULL, NULL));
+ pSiteWindowless = (IRMASiteWindowless*)(pWMWlS = DNew CRealMediaWindowlessSite(hr, m_pPlayer, NULL, NULL));
if(FAILED(hr))
- return(false);
+ return(false);
- pWMWlS->SetBltService(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface>(m_pRMAP));
+ pWMWlS->SetBltService(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface>(m_pRMAP));
- return !!(*ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowless).Detach());
+ return !!(*ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowless).Detach());
}
void CRealMediaPlayerWindowless::DestroySite(IRMASite* pSite)
@@ -557,185 +536,182 @@ void CRealMediaPlayerWindowless::DestroySite(IRMASite* pSite)
STDMETHODIMP CRealMediaPlayerWindowless::SizeChanged(PNxSize* size)
{
- if(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface> pRMAVS = m_pRMAP)
- {
- RMABitmapInfoHeader BitmapInfo;
- memset(&BitmapInfo, 0, sizeof(BitmapInfo));
- BitmapInfo.biWidth = size->cx;
- BitmapInfo.biHeight = size->cy;
- pRMAVS->BeginOptimizedBlt(&BitmapInfo);
- }
+ if(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface> pRMAVS = m_pRMAP)
+ {
+ RMABitmapInfoHeader BitmapInfo;
+ memset(&BitmapInfo, 0, sizeof(BitmapInfo));
+ BitmapInfo.biWidth = size->cx;
+ BitmapInfo.biHeight = size->cy;
+ pRMAVS->BeginOptimizedBlt(&BitmapInfo);
+ }
- return __super::SizeChanged(size);
+ return __super::SizeChanged(size);
}
////////////////
CRealMediaGraph::CRealMediaGraph(HWND hWndParent, HRESULT& hr)
- : CBaseGraph()
+ : CBaseGraph()
{
- hr = S_OK;
+ hr = S_OK;
- m_pRMP = AfxGetAppSettings().iRMVideoRendererType == VIDRNDT_RM_DEFAULT
- ? (CRealMediaPlayer*)DNew CRealMediaPlayerWindowed(hWndParent, this)
- : (CRealMediaPlayer*)DNew CRealMediaPlayerWindowless(hWndParent, this);
+ m_pRMP = AfxGetAppSettings().iRMVideoRendererType == VIDRNDT_RM_DEFAULT
+ ? (CRealMediaPlayer*)DNew CRealMediaPlayerWindowed(hWndParent, this)
+ : (CRealMediaPlayer*)DNew CRealMediaPlayerWindowless(hWndParent, this);
- if(!m_pRMP)
- {
- hr = E_OUTOFMEMORY;
- return;
- }
+ if(!m_pRMP)
+ {
+ hr = E_OUTOFMEMORY;
+ return;
+ }
- if(!m_pRMP->Init())
- {
- delete m_pRMP, m_pRMP = NULL;
- hr = E_FAIL;
- return;
- }
+ if(!m_pRMP->Init())
+ {
+ delete m_pRMP, m_pRMP = NULL;
+ hr = E_FAIL;
+ return;
+ }
- m_pRMP->AddRef();
+ m_pRMP->AddRef();
}
CRealMediaGraph::~CRealMediaGraph()
{
- if(m_pRMP)
- {
- m_pRMP->Deinit();
- m_pRMP->Release();
- m_pRMP = NULL;
- }
+ if(m_pRMP)
+ {
+ m_pRMP->Deinit();
+ m_pRMP->Release();
+ m_pRMP = NULL;
+ }
}
STDMETHODIMP CRealMediaGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- (m_pRMP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(ISubPicAllocatorPresenter))) ? m_pRMP->QueryInterface(riid, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (m_pRMP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(ISubPicAllocatorPresenter))) ? m_pRMP->QueryInterface(riid, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IGraphBuilder
STDMETHODIMP CRealMediaGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- m_fn = lpcwstrFile;
+ m_fn = lpcwstrFile;
- CHAR buff[_MAX_PATH] = {0};
- WideCharToMultiByte(GetACP(), 0, lpcwstrFile, -1, buff, MAX_PATH, 0, 0);
+ CHAR buff[_MAX_PATH] = {0};
+ WideCharToMultiByte(GetACP(), 0, lpcwstrFile, -1, buff, MAX_PATH, 0, 0);
- CStringA fn(buff);
- if(fn.Find("://") < 0) fn = "file://" + fn;
+ CStringA fn(buff);
+ if(fn.Find("://") < 0) fn = "file://" + fn;
- m_pRMP->m_unPercentComplete = 100;
+ m_pRMP->m_unPercentComplete = 100;
- ClearMessageQueue();
+ ClearMessageQueue();
- if(PNR_OK != m_pRMP->m_pPlayer->OpenURL(fn))
- return E_FAIL;
+ if(PNR_OK != m_pRMP->m_pPlayer->OpenURL(fn))
+ return E_FAIL;
- m_pRMP->m_pPlayer->Pause()/*Stop()*/; // please, don't start just yet
+ m_pRMP->m_pPlayer->Pause()/*Stop()*/; // please, don't start just yet
- return S_OK;
+ return S_OK;
}
// IMediaControl
STDMETHODIMP CRealMediaGraph::Run()
{
- if(m_pRMP->m_pPlayer->IsDone())
- RenderFile(m_fn, NULL);
+ if(m_pRMP->m_pPlayer->IsDone())
+ RenderFile(m_fn, NULL);
- m_pRMP->m_UserState = State_Running;
- return (PNR_OK == m_pRMP->m_pPlayer->Begin()) ? S_OK : E_FAIL;
+ m_pRMP->m_UserState = State_Running;
+ return (PNR_OK == m_pRMP->m_pPlayer->Begin()) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::Pause()
{
- m_pRMP->m_UserState = State_Paused;
- return (PNR_OK == m_pRMP->m_pPlayer->Pause()) ? S_OK : E_FAIL;
+ m_pRMP->m_UserState = State_Paused;
+ return (PNR_OK == m_pRMP->m_pPlayer->Pause()) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::Stop()
{
- m_pRMP->m_UserState = State_Stopped;
- return (PNR_OK == m_pRMP->m_pPlayer->Stop()) ? S_OK : E_FAIL;
+ m_pRMP->m_UserState = State_Stopped;
+ return (PNR_OK == m_pRMP->m_pPlayer->Stop()) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::GetState(LONG msTimeout, OAFilterState* pfs)
{
- return pfs ? *pfs = m_pRMP->m_State, S_OK : E_POINTER;
+ return pfs ? *pfs = m_pRMP->m_State, S_OK : E_POINTER;
}
// IMediaSeeking
STDMETHODIMP CRealMediaGraph::GetDuration(LONGLONG* pDuration)
{
- return pDuration ? *pDuration = m_pRMP->m_nDuration, S_OK : E_POINTER;
+ return pDuration ? *pDuration = m_pRMP->m_nDuration, S_OK : E_POINTER;
}
STDMETHODIMP CRealMediaGraph::GetCurrentPosition(LONGLONG* pCurrent)
{
- return pCurrent ? *pCurrent = m_pRMP->m_nCurrent, S_OK : E_POINTER;
+ return pCurrent ? *pCurrent = m_pRMP->m_nCurrent, S_OK : E_POINTER;
}
STDMETHODIMP CRealMediaGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- return (dwCurrentFlags & AM_SEEKING_AbsolutePositioning)
- && (PNR_OK == m_pRMP->m_pPlayer->Seek((ULONG)(*pCurrent / 10000))) ? S_OK : E_FAIL;
+ return (dwCurrentFlags&AM_SEEKING_AbsolutePositioning)
+ && (PNR_OK == m_pRMP->m_pPlayer->Seek((ULONG)(*pCurrent / 10000))) ? S_OK : E_FAIL;
}
// IVideoWindow
STDMETHODIMP CRealMediaGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if(m_pRMP)
- m_pRMP->SetWindowRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
+ if(m_pRMP)
+ m_pRMP->SetWindowRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
- return S_OK;
+ return S_OK;
}
// IBasicVideo
STDMETHODIMP CRealMediaGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- m_pRMP->SetDestRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
- return S_OK;
+ m_pRMP->SetDestRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
+ return S_OK;
}
STDMETHODIMP CRealMediaGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if(!pWidth || !pHeight) return E_POINTER;
- *pWidth = m_pRMP->GetVideoSize().cx;
- *pHeight = m_pRMP->GetVideoSize().cy;
- return S_OK;
+ if(!pWidth || !pHeight) return E_POINTER;
+ *pWidth = m_pRMP->GetVideoSize().cx;
+ *pHeight = m_pRMP->GetVideoSize().cy;
+ return S_OK;
}
// IBasicAudio
STDMETHODIMP CRealMediaGraph::put_Volume(long lVolume)
{
- if(!m_pRMP->m_pVolume) return E_UNEXPECTED;
+ if(!m_pRMP->m_pVolume) return E_UNEXPECTED;
- UINT16 volume = (lVolume == -10000) ? 0 : (int)pow(10.0, ((double)lVolume) / 5000 + 2);
- volume = max(min(volume, 100), 0);
+ UINT16 volume = (lVolume == -10000) ? 0 : (int)pow(10.0, ((double)lVolume)/5000+2);
+ volume = max(min(volume, 100), 0);
- return PNR_OK == m_pRMP->m_pVolume->SetVolume(volume) ? S_OK : E_FAIL;
+ return PNR_OK == m_pRMP->m_pVolume->SetVolume(volume) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::get_Volume(long* plVolume)
{
- if(!m_pRMP->m_pVolume) return E_UNEXPECTED;
+ if(!m_pRMP->m_pVolume) return E_UNEXPECTED;
- CheckPointer(plVolume, E_POINTER);
+ CheckPointer(plVolume, E_POINTER);
- UINT16 volume = m_pRMP->m_pVolume->GetVolume();
- volume = (int)((log10(1.0 * volume) - 2) * 5000);
- volume = max(min(volume, 0), -10000);
+ UINT16 volume = m_pRMP->m_pVolume->GetVolume();
+ volume = (int)((log10(1.0*volume)-2)*5000);
+ volume = max(min(volume, 0), -10000);
- *plVolume = volume;
+ *plVolume = volume;
- return S_OK;
+ return S_OK;
}
// IAMOpenProgress
STDMETHODIMP CRealMediaGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- *pllTotal = 100;
- *pllCurrent = m_pRMP->m_unPercentComplete > 0 ? m_pRMP->m_unPercentComplete : 100; // after seeking it drops to 0 and would show annoying "Buffering... (0%)" messages on the status line
- return S_OK;
+ *pllTotal = 100;
+ *pllCurrent = m_pRMP->m_unPercentComplete > 0 ? m_pRMP->m_unPercentComplete : 100; // after seeking it drops to 0 and would show annoying "Buffering... (0%)" messages on the status line
+ return S_OK;
}
// IGraphEngine
-STDMETHODIMP_(engine_t) CRealMediaGraph::GetEngine()
-{
- return RealMedia;
-}
+STDMETHODIMP_(engine_t) CRealMediaGraph::GetEngine() {return RealMedia;}
diff --git a/src/apps/mplayerc/RealMediaGraph.h b/src/apps/mplayerc/RealMediaGraph.h
index 8b3d0ad49..706eec4cd 100644
--- a/src/apps/mplayerc/RealMediaGraph.h
+++ b/src/apps/mplayerc/RealMediaGraph.h
@@ -49,187 +49,184 @@
namespace DSObjects
{
-class CRealMediaGraph;
+ class CRealMediaGraph;
+
+ class CRealMediaPlayer
+ : public CUnknown
+ , public IRMAErrorSink
+ , public IRMAClientAdviseSink
+ , public IRMAAuthenticationManager
+ , public IRMASiteSupplier
+ , public IRMAPassiveSiteWatcher
+ , public IRMAAudioHook
+
+ {
+ protected:
+ friend class CRealMediaGraph;
+ CRealMediaGraph* m_pRMG; // IMPORTANT: do not ever AddRef on this from here
+
+ HWND m_hWndParent;
+ CSize m_VideoSize;
+ bool m_fVideoSizeChanged;
+
+ //
+
+ DWORD m_wndStyle;
+ CPlayerWindow m_wndWindowFrame, m_wndDestFrame;
+
+ //
+
+ FPRMCREATEENGINE m_fpCreateEngine;
+ FPRMCLOSEENGINE m_fpCloseEngine;
+ FPRMSETDLLACCESSPATH m_fpSetDLLAccessPath;
+ HMODULE m_hRealMediaCore;
+
+ CComPtr<IRMAClientEngine> m_pEngine;
+ CComPtr<IRMAPlayer> m_pPlayer;
+ CComQIPtr<IRMAAudioPlayer, &IID_IRMAAudioPlayer> m_pAudioPlayer;
+ CComPtr<IRMAVolume> m_pVolume;
+ CComQIPtr<IRMASiteManager, &IID_IRMASiteManager> m_pSiteManager;
+ CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCommonClassFactory;
-class CRealMediaPlayer
- : public CUnknown
- , public IRMAErrorSink
- , public IRMAClientAdviseSink
- , public IRMAAuthenticationManager
- , public IRMASiteSupplier
- , public IRMAPassiveSiteWatcher
- , public IRMAAudioHook
+ CComQIPtr<IRMASite, &IID_IRMASite> m_pTheSite;
+ CComQIPtr<IRMASite2, &IID_IRMASite2> m_pTheSite2;
+ CMap<UINT32, UINT32&, IRMASite*, IRMASite*&> m_CreatedSites;
-{
-protected:
- friend class CRealMediaGraph;
- CRealMediaGraph* m_pRMG; // IMPORTANT: do not ever AddRef on this from here
-
- HWND m_hWndParent;
- CSize m_VideoSize;
- bool m_fVideoSizeChanged;
-
- //
-
- DWORD m_wndStyle;
- CPlayerWindow m_wndWindowFrame, m_wndDestFrame;
-
- //
-
- FPRMCREATEENGINE m_fpCreateEngine;
- FPRMCLOSEENGINE m_fpCloseEngine;
- FPRMSETDLLACCESSPATH m_fpSetDLLAccessPath;
- HMODULE m_hRealMediaCore;
-
- CComPtr<IRMAClientEngine> m_pEngine;
- CComPtr<IRMAPlayer> m_pPlayer;
- CComQIPtr<IRMAAudioPlayer, &IID_IRMAAudioPlayer> m_pAudioPlayer;
- CComPtr<IRMAVolume> m_pVolume;
- CComQIPtr<IRMASiteManager, &IID_IRMASiteManager> m_pSiteManager;
- CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCommonClassFactory;
-
- CComQIPtr<IRMASite, &IID_IRMASite> m_pTheSite;
- CComQIPtr<IRMASite2, &IID_IRMASite2> m_pTheSite2;
- CMap<UINT32, UINT32&, IRMASite*, IRMASite*&> m_CreatedSites;
-
- //
-
- OAFilterState m_State, m_UserState;
- REFERENCE_TIME m_nCurrent, m_nDuration;
-
- UINT16 m_unPercentComplete;
-
- //
-
-public:
- CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG);
- virtual ~CRealMediaPlayer();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- bool Init();
- void Deinit();
-
- virtual CSize GetVideoSize()
- {
- return(m_VideoSize);
- }
- virtual void SetWindowRect(CRect r) {}
- virtual void SetDestRect(CRect r) {}
- virtual bool CreateSite(IRMASite** pSite) = 0;
- virtual void DestroySite(IRMASite* pSite) = 0;
-
- // IRMAErrorSink
- STDMETHODIMP ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL);
-
- // IRMAClientAdviseSink
- STDMETHODIMP OnPosLength(UINT32 ulPosition, UINT32 ulLength);
- STDMETHODIMP OnPresentationOpened();
- STDMETHODIMP OnPresentationClosed();
- STDMETHODIMP OnStatisticsChanged();
- STDMETHODIMP OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime);
- STDMETHODIMP OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime);
- STDMETHODIMP OnStop();
- STDMETHODIMP OnPause(UINT32 ulTime);
- STDMETHODIMP OnBegin(UINT32 ulTime);
- STDMETHODIMP OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete);
- STDMETHODIMP OnContacting(const char* pHostName);
-
- // IRMAAuthenticationManager
- STDMETHODIMP HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse);
-
- // IRMASiteSupplier
- STDMETHODIMP SitesNeeded(UINT32 uRequestID, IRMAValues* pSiteProps);
- STDMETHODIMP SitesNotNeeded(UINT32 uRequestID);
- STDMETHODIMP BeginChangeLayout();
- STDMETHODIMP DoneChangeLayout();
-
- // IRMAPassiveSiteWatcher
- STDMETHODIMP PositionChanged(PNxPoint* pos);
- STDMETHODIMP SizeChanged(PNxSize* size);
-
- // IRMAAudioHook
- STDMETHODIMP OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData);
- STDMETHODIMP OnInit(RMAAudioFormat* pFormat);
-};
-
-class CRealMediaPlayerWindowed
- : public CRealMediaPlayer
-{
-public:
- CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG);
- virtual ~CRealMediaPlayerWindowed();
-
- void SetWindowRect(CRect r);
- void SetDestRect(CRect r);
-
- bool CreateSite(IRMASite** pSite);
- void DestroySite(IRMASite* pSite);
-};
-
-class CRealMediaPlayerWindowless
- : public CRealMediaPlayer
-{
- CComPtr<ISubPicAllocatorPresenter> m_pRMAP;
-
-public:
- CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
- virtual ~CRealMediaPlayerWindowless();
-
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- bool CreateSite(IRMASite** pSite);
- void DestroySite(IRMASite* pSite);
-
- STDMETHODIMP SizeChanged(PNxSize* size);
-};
-
-class CRealMediaGraph : public CBaseGraph
-{
- CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface
-
- CStringW m_fn;
-
-public:
- CRealMediaGraph(HWND hWndParent, HRESULT& hr); // in windowless mode IVideoWindow::* will return E_NOTIMPL, use ISubPicAllocatorPresenter instead
- virtual ~CRealMediaGraph();
+ //
+
+ OAFilterState m_State, m_UserState;
+ REFERENCE_TIME m_nCurrent, m_nDuration;
+
+ UINT16 m_unPercentComplete;
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ //
+
+ public:
+ CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG);
+ virtual ~CRealMediaPlayer();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ bool Init();
+ void Deinit();
+
+ virtual CSize GetVideoSize() {return(m_VideoSize);}
+ virtual void SetWindowRect(CRect r) {}
+ virtual void SetDestRect(CRect r) {}
+ virtual bool CreateSite(IRMASite** pSite) = 0;
+ virtual void DestroySite(IRMASite* pSite) = 0;
+
+ // IRMAErrorSink
+ STDMETHODIMP ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL);
+
+ // IRMAClientAdviseSink
+ STDMETHODIMP OnPosLength(UINT32 ulPosition, UINT32 ulLength);
+ STDMETHODIMP OnPresentationOpened();
+ STDMETHODIMP OnPresentationClosed();
+ STDMETHODIMP OnStatisticsChanged();
+ STDMETHODIMP OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime);
+ STDMETHODIMP OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime);
+ STDMETHODIMP OnStop();
+ STDMETHODIMP OnPause(UINT32 ulTime);
+ STDMETHODIMP OnBegin(UINT32 ulTime);
+ STDMETHODIMP OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete);
+ STDMETHODIMP OnContacting(const char* pHostName);
+
+ // IRMAAuthenticationManager
+ STDMETHODIMP HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse);
+
+ // IRMASiteSupplier
+ STDMETHODIMP SitesNeeded(UINT32 uRequestID, IRMAValues* pSiteProps);
+ STDMETHODIMP SitesNotNeeded(UINT32 uRequestID);
+ STDMETHODIMP BeginChangeLayout();
+ STDMETHODIMP DoneChangeLayout();
+
+ // IRMAPassiveSiteWatcher
+ STDMETHODIMP PositionChanged(PNxPoint* pos);
+ STDMETHODIMP SizeChanged(PNxSize* size);
+
+ // IRMAAudioHook
+ STDMETHODIMP OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData);
+ STDMETHODIMP OnInit(RMAAudioFormat* pFormat);
+ };
+
+ class CRealMediaPlayerWindowed
+ : public CRealMediaPlayer
+ {
+ public:
+ CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG);
+ virtual ~CRealMediaPlayerWindowed();
-protected:
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ void SetWindowRect(CRect r);
+ void SetDestRect(CRect r);
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+ bool CreateSite(IRMASite** pSite);
+ void DestroySite(IRMASite* pSite);
+ };
- // IMediaSeeking
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ class CRealMediaPlayerWindowless
+ : public CRealMediaPlayer
+ {
+ CComPtr<ISubPicAllocatorPresenter> m_pRMAP;
- // IVideoWindow
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+ public:
+ CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
+ virtual ~CRealMediaPlayerWindowless();
- // IBasicVideo
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ bool CreateSite(IRMASite** pSite);
+ void DestroySite(IRMASite* pSite);
+
+ STDMETHODIMP SizeChanged(PNxSize* size);
+ };
+
+ class CRealMediaGraph : public CBaseGraph
+ {
+ CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
+ CStringW m_fn;
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+ public:
+ CRealMediaGraph(HWND hWndParent, HRESULT& hr); // in windowless mode IVideoWindow::* will return E_NOTIMPL, use ISubPicAllocatorPresenter instead
+ virtual ~CRealMediaGraph();
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
-};
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ protected:
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+
+ // IMediaSeeking
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+
+ // IVideoWindow
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+
+ // IBasicVideo
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
+
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
+ };
}
using namespace DSObjects;
diff --git a/src/apps/mplayerc/RealMediaWindowlessSite.cpp b/src/apps/mplayerc/RealMediaWindowlessSite.cpp
index 84299a241..e15750e11 100644
--- a/src/apps/mplayerc/RealMediaWindowlessSite.cpp
+++ b/src/apps/mplayerc/RealMediaWindowlessSite.cpp
@@ -32,75 +32,75 @@
void DSObjects::ExtractRects(REGION* pRegion)
{
- LPRGNDATA lpRgnData;
+ LPRGNDATA lpRgnData;
- DWORD sizeNeeed = GetRegionData((HRGN)pRegion->pOSRegion, 0, NULL);
+ DWORD sizeNeeed = GetRegionData((HRGN)pRegion->pOSRegion, 0, NULL);
- lpRgnData = (LPRGNDATA)DNew char[sizeNeeed];
- DWORD returnValue = GetRegionData((HRGN)pRegion->pOSRegion, sizeNeeed, lpRgnData);
+ lpRgnData = (LPRGNDATA)DNew char[sizeNeeed];
+ DWORD returnValue = GetRegionData((HRGN)pRegion->pOSRegion, sizeNeeed, lpRgnData);
- PN_VECTOR_DELETE(pRegion->rects);
+ PN_VECTOR_DELETE(pRegion->rects);
- pRegion->numRects = lpRgnData->rdh.nCount;
- pRegion->extents.left = lpRgnData->rdh.rcBound.left;
- pRegion->extents.top = lpRgnData->rdh.rcBound.top;
- pRegion->extents.right = lpRgnData->rdh.rcBound.right;
- pRegion->extents.bottom = lpRgnData->rdh.rcBound.bottom;
+ pRegion->numRects = lpRgnData->rdh.nCount;
+ pRegion->extents.left = lpRgnData->rdh.rcBound.left;
+ pRegion->extents.top = lpRgnData->rdh.rcBound.top;
+ pRegion->extents.right = lpRgnData->rdh.rcBound.right;
+ pRegion->extents.bottom = lpRgnData->rdh.rcBound.bottom;
+
+ if(lpRgnData->rdh.nCount)
+ {
+ pRegion->rects = DNew PNxRect[lpRgnData->rdh.nCount];
- if(lpRgnData->rdh.nCount)
- {
- pRegion->rects = DNew PNxRect[lpRgnData->rdh.nCount];
+ // now extract the information.
- // now extract the information.
+ for(int j = 0; j < (int) lpRgnData->rdh.nCount;j++)
+ {
+ RECT* pRect = (RECT*)lpRgnData->Buffer;
+ pRegion->rects[j].left = pRect[j].left;
+ pRegion->rects[j].top = pRect[j].top;
+ pRegion->rects[j].right = pRect[j].right;
+ pRegion->rects[j].bottom = pRect[j].bottom;
+ }
+ }
- for(int j = 0; j < (int) lpRgnData->rdh.nCount; j++)
- {
- RECT* pRect = (RECT*)lpRgnData->Buffer;
- pRegion->rects[j].left = pRect[j].left;
- pRegion->rects[j].top = pRect[j].top;
- pRegion->rects[j].right = pRect[j].right;
- pRegion->rects[j].bottom = pRect[j].bottom;
- }
- }
-
- PN_VECTOR_DELETE(lpRgnData);
+ PN_VECTOR_DELETE(lpRgnData);
}
REGION* DSObjects::RMACreateRectRegion(int left, int top, int right, int bottom)
{
- REGION* retVal = DNew REGION;
- retVal->pOSRegion = (void*)CreateRectRgn(left, top, right, bottom);
- ExtractRects(retVal);
- return retVal;
+ REGION* retVal = DNew REGION;
+ retVal->pOSRegion = (void*)CreateRectRgn(left, top, right, bottom);
+ ExtractRects(retVal);
+ return retVal;
}
void DSObjects::RMASubtractRegion(REGION* regM, REGION* regS, REGION* regD)
{
- CombineRgn((HRGN)regD->pOSRegion, (HRGN)regM->pOSRegion, (HRGN)regS->pOSRegion, RGN_DIFF);
- ExtractRects(regD);
+ CombineRgn((HRGN)regD->pOSRegion, (HRGN)regM->pOSRegion, (HRGN)regS->pOSRegion, RGN_DIFF);
+ ExtractRects(regD);
}
void DSObjects::RMAUnionRegion(REGION* reg1, REGION* reg2, REGION* regD)
{
- CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_OR);
- ExtractRects(regD);
+ CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_OR);
+ ExtractRects(regD);
}
void DSObjects::RMAIntersectRegion(REGION* reg1, REGION* reg2, REGION* regD)
{
- CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_AND);
- ExtractRects(regD);
+ CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_AND);
+ ExtractRects(regD);
}
BOOL DSObjects::RMAEqualRegion(REGION* reg1, REGION* reg2)
{
- return EqualRgn((HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion)
- && !memcmp(&reg1->extents, &reg2->extents, sizeof(PNxRect)) ? TRUE : FALSE;
+ return EqualRgn((HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion)
+ && !memcmp(&reg1->extents, &reg2->extents, sizeof(PNxRect)) ? TRUE : FALSE;
}
void DSObjects::RMADestroyRegion(REGION* reg)
{
- if(reg) DeleteObject((HRGN)reg->pOSRegion),
- PN_VECTOR_DELETE(reg->rects);
- PN_DELETE(reg);
+ if(reg) DeleteObject((HRGN)reg->pOSRegion),
+ PN_VECTOR_DELETE(reg->rects);
+ PN_DELETE(reg);
}
REGION* DSObjects::RMACreateRegion()
{
- return RMACreateRectRegion(0, 0, 0, 0);
+ return RMACreateRectRegion(0,0,0,0);
}
//
@@ -108,606 +108,606 @@ REGION* DSObjects::RMACreateRegion()
//
CRealMediaWindowlessSite::CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pContext, CRealMediaWindowlessSite* pParentSite, IUnknown* pUnkOuter)
- : CUnknown(NAME("CRealMediaWindowlessSite"), pUnkOuter, &hr)
- , m_pContext(pContext)
- , m_pParentSite(pParentSite)
- , m_pCCF(pContext)
- , m_fDamaged(false), m_fInRedraw(false), m_fIsVisible(true)
- , m_lZOrder(0)
- , m_pRegion(NULL), m_pRegionWithoutChildren(NULL)
+ : CUnknown(NAME("CRealMediaWindowlessSite"), pUnkOuter, &hr)
+ , m_pContext(pContext)
+ , m_pParentSite(pParentSite)
+ , m_pCCF(pContext)
+ , m_fDamaged(false), m_fInRedraw(false), m_fIsVisible(true)
+ , m_lZOrder(0)
+ , m_pRegion(NULL), m_pRegionWithoutChildren(NULL)
{
- m_size.cx = m_size.cy = 0;
- m_position.x = m_position.y = 0;
+ m_size.cx = m_size.cy = 0;
+ m_position.x = m_position.y = 0;
- memset(&m_lastBitmapInfo, 0, sizeof(m_lastBitmapInfo));
+ memset(&m_lastBitmapInfo, 0, sizeof(m_lastBitmapInfo));
- hr = S_OK;
+ hr = S_OK;
- if(!m_pContext || !m_pCCF)
- {
- hr = E_POINTER;
- return;
- }
+ if(!m_pContext || !m_pCCF)
+ {
+ hr = E_POINTER;
+ return;
+ }
- m_pCCF->CreateInstance(CLSID_IRMAValues, (void**)&m_pValues);
+ m_pCCF->CreateInstance(CLSID_IRMAValues, (void**)&m_pValues);
}
CRealMediaWindowlessSite::~CRealMediaWindowlessSite()
{
- POSITION pos = m_pChildren.GetHeadPosition();
- while(pos) DestroyChild(m_pChildren.GetNext(pos));
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while(pos) DestroyChild(m_pChildren.GetNext(pos));
- RMADestroyRegion(m_pRegion);
- RMADestroyRegion(m_pRegionWithoutChildren);
+ RMADestroyRegion(m_pRegion);
+ RMADestroyRegion(m_pRegionWithoutChildren);
}
STDMETHODIMP CRealMediaWindowlessSite::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI2(IRMASite)
- QI2(IRMASite2)
- QI2(IRMASiteWindowless)
- QI2(IRMAVideoSurface)
- (m_pValues && m_pValues->QueryInterface(riid, ppv) == PNR_OK) ? PNR_OK :
- CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMASite)
+ QI2(IRMASite2)
+ QI2(IRMASiteWindowless)
+ QI2(IRMAVideoSurface)
+ (m_pValues && m_pValues->QueryInterface(riid, ppv) == PNR_OK) ? PNR_OK :
+ CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
// public
void CRealMediaWindowlessSite::GetTopLeft(PNxPoint* pPoint)
{
- pPoint->x += m_position.x;
- pPoint->y += m_position.y;
+ pPoint->x += m_position.x;
+ pPoint->y += m_position.y;
- if(m_pParentSite)
- m_pParentSite->GetTopLeft(pPoint);
+ if(m_pParentSite)
+ m_pParentSite->GetTopLeft(pPoint);
}
REGION* CRealMediaWindowlessSite::GetRegion()
{
- return m_pRegion;
+ return m_pRegion;
}
// private
void CRealMediaWindowlessSite::RecomputeRegion()
{
- if(m_pParentSite) m_pParentSite->RecomputeRegion();
- else InternalRecomputeRegion();
+ if(m_pParentSite) m_pParentSite->RecomputeRegion();
+ else InternalRecomputeRegion();
}
void CRealMediaWindowlessSite::InternalRecomputeRegion()
{
- ComputeRegion();
+ ComputeRegion();
- POSITION pos = m_pChildren.GetHeadPosition();
- while(pos)
- {
- CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
- if(pSite) pSite->InternalRecomputeRegion();
- }
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while(pos)
+ {
+ CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
+ if(pSite) pSite->InternalRecomputeRegion();
+ }
}
void CRealMediaWindowlessSite::ComputeRegion()
{
- REGION* pTempRegion = NULL;
+ REGION* pTempRegion = NULL;
- if(m_pRegion)
- {
- pTempRegion = RMACreateRegion();
- RMAUnionRegion(pTempRegion, m_pRegion, pTempRegion);
- RMADestroyRegion(m_pRegion);
- }
+ if(m_pRegion)
+ {
+ pTempRegion = RMACreateRegion();
+ RMAUnionRegion(pTempRegion, m_pRegion, pTempRegion);
+ RMADestroyRegion(m_pRegion);
+ }
- if(m_pRegionWithoutChildren)
- {
- RMADestroyRegion(m_pRegionWithoutChildren);
- }
+ if(m_pRegionWithoutChildren)
+ {
+ RMADestroyRegion(m_pRegionWithoutChildren);
+ }
- PNxPoint topleft = {0, 0};
- GetTopLeft(&topleft);
+ PNxPoint topleft = {0,0};
+ GetTopLeft(&topleft);
- if(IsSiteVisible())
- {
- m_pRegionWithoutChildren = RMACreateRectRegion(topleft.x, topleft.y, topleft.x + m_size.cx, topleft.y + m_size.cy);
+ if(IsSiteVisible())
+ {
+ m_pRegionWithoutChildren = RMACreateRectRegion(topleft.x, topleft.y, topleft.x + m_size.cx, topleft.y + m_size.cy);
- if(m_pParentSite)
- {
- RMAIntersectRegion(m_pRegionWithoutChildren, m_pParentSite->m_pRegionWithoutChildren, m_pRegionWithoutChildren);
+ if(m_pParentSite)
+ {
+ RMAIntersectRegion(m_pRegionWithoutChildren, m_pParentSite->m_pRegionWithoutChildren, m_pRegionWithoutChildren);
- POSITION pos = m_pParentSite->m_pChildren.GetHeadPosition();
+ POSITION pos = m_pParentSite->m_pChildren.GetHeadPosition();
while(pos)
- {
- CRealMediaWindowlessSite* pSiblingSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pParentSite->m_pChildren.GetNext(pos);
- if(pSiblingSite != this)
- {
- INT32 zOrder;
- pSiblingSite->GetZOrder(zOrder);
-
- if(zOrder > m_lZOrder && pSiblingSite->IsSiteVisible())
- {
- pSiblingSite->SubtractSite(m_pRegionWithoutChildren);
- }
- }
- }
- }
-
- m_pRegion = RMACreateRegion();
- RMAUnionRegion(m_pRegion, m_pRegionWithoutChildren, m_pRegion);
-
- POSITION pos = m_pChildren.GetHeadPosition();
- while(pos)
- {
- CRealMediaWindowlessSite* pChildSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
- if(pChildSite->IsSiteVisible()) pChildSite->SubtractSite(m_pRegion);
- }
- }
- else
- {
- m_pRegionWithoutChildren = RMACreateRectRegion(0, 0, 0, 0);
- m_pRegion = RMACreateRectRegion(0, 0, 0, 0);
- }
-
- if(pTempRegion && !RMAEqualRegion(m_pRegion, pTempRegion))
- {
- ForceRedraw();
- }
-
- RMADestroyRegion(pTempRegion);
+ {
+ CRealMediaWindowlessSite* pSiblingSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pParentSite->m_pChildren.GetNext(pos);
+ if(pSiblingSite != this)
+ {
+ INT32 zOrder;
+ pSiblingSite->GetZOrder(zOrder);
+
+ if(zOrder > m_lZOrder && pSiblingSite->IsSiteVisible())
+ {
+ pSiblingSite->SubtractSite(m_pRegionWithoutChildren);
+ }
+ }
+ }
+ }
+
+ m_pRegion = RMACreateRegion();
+ RMAUnionRegion(m_pRegion, m_pRegionWithoutChildren, m_pRegion);
+
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while(pos)
+ {
+ CRealMediaWindowlessSite* pChildSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
+ if(pChildSite->IsSiteVisible()) pChildSite->SubtractSite(m_pRegion);
+ }
+ }
+ else
+ {
+ m_pRegionWithoutChildren = RMACreateRectRegion(0,0,0,0);
+ m_pRegion = RMACreateRectRegion(0,0,0,0);
+ }
+
+ if(pTempRegion && !RMAEqualRegion(m_pRegion, pTempRegion))
+ {
+ ForceRedraw();
+ }
+
+ RMADestroyRegion(pTempRegion);
}
void CRealMediaWindowlessSite::SubtractSite(REGION* pRegion)
{
- PNxPoint topLeft;
- memset(&topLeft, 0, sizeof(PNxPoint));
- GetTopLeft(&topLeft);
-
- REGION* pTempRegion = RMACreateRectRegion(topLeft.x, topLeft.y, topLeft.x + m_size.cx, topLeft.y + m_size.cy);
+ PNxPoint topLeft;
+ memset(&topLeft, 0, sizeof(PNxPoint));
+ GetTopLeft(&topLeft);
+
+ REGION* pTempRegion = RMACreateRectRegion(topLeft.x, topLeft.y, topLeft.x + m_size.cx, topLeft.y + m_size.cy);
- RMASubtractRegion(pRegion, pTempRegion, pRegion);
- RMADestroyRegion(pTempRegion);
+ RMASubtractRegion(pRegion, pTempRegion, pRegion);
+ RMADestroyRegion(pTempRegion);
}
void CRealMediaWindowlessSite::UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder)
{
- POSITION pos = m_pChildren.GetHeadPosition();
- while(pos)
- {
- CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
-
- INT32 lItsOldZOrder;
- pSite->GetZOrder(lItsOldZOrder);
-
- if(pSite != pUpdatedChildSite)
- {
- if(lOldZOrder < lNewZOrder)
- {
- if(lItsOldZOrder >= lOldZOrder && lItsOldZOrder < lNewZOrder)
- {
- pSite->SetInternalZOrder(lItsOldZOrder - 1);
- }
- }
- else
- {
- if(lItsOldZOrder >= lNewZOrder && lItsOldZOrder < lOldZOrder)
- {
- pSite->SetInternalZOrder(lItsOldZOrder + 1);
- }
- }
- }
- else
- {
- pSite->SetInternalZOrder(lNewZOrder);
- }
- }
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while(pos)
+ {
+ CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
+
+ INT32 lItsOldZOrder;
+ pSite->GetZOrder(lItsOldZOrder);
+
+ if(pSite != pUpdatedChildSite)
+ {
+ if(lOldZOrder < lNewZOrder)
+ {
+ if(lItsOldZOrder >= lOldZOrder && lItsOldZOrder < lNewZOrder)
+ {
+ pSite->SetInternalZOrder(lItsOldZOrder-1);
+ }
+ }
+ else
+ {
+ if(lItsOldZOrder >= lNewZOrder && lItsOldZOrder < lOldZOrder)
+ {
+ pSite->SetInternalZOrder(lItsOldZOrder+1);
+ }
+ }
+ }
+ else
+ {
+ pSite->SetInternalZOrder(lNewZOrder);
+ }
+ }
}
void CRealMediaWindowlessSite::SetInternalZOrder(INT32 lZOrder)
{
- m_lZOrder = lZOrder;
+ m_lZOrder = lZOrder;
}
// IRMASiteWindowless
STDMETHODIMP CRealMediaWindowlessSite::EventOccurred(PNxEvent* /*IN*/ pEvent)
{
- return PNR_NOTIMPL; /* not necessary within our implementation */
+ return PNR_NOTIMPL; /* not necessary within our implementation */
}
STDMETHODIMP_(PNxWindow*) CRealMediaWindowlessSite::GetParentWindow()
{
- return NULL;
+ return NULL;
}
// IRMASite
STDMETHODIMP CRealMediaWindowlessSite::AttachUser(IRMASiteUser* /*IN*/ pUser)
{
- HRESULT hr = PNR_FAIL;
-
- if(m_pUser) return PNR_UNEXPECTED;
+ HRESULT hr = PNR_FAIL;
- if(CComQIPtr<IRMASite, &IID_IRMASite> pOuterSite = GetOwner())
- hr = pUser->AttachSite(pOuterSite);
+ if(m_pUser) return PNR_UNEXPECTED;
- if(PNR_OK == hr)
- m_pUser = pUser;
+ if(CComQIPtr<IRMASite, &IID_IRMASite> pOuterSite = GetOwner())
+ hr = pUser->AttachSite(pOuterSite);
+
+ if(PNR_OK == hr)
+ m_pUser = pUser;
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::DetachUser()
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if(!m_pUser) return PNR_UNEXPECTED;
+ if(!m_pUser) return PNR_UNEXPECTED;
- hr = m_pUser->DetachSite();
+ hr = m_pUser->DetachSite();
- if(PNR_OK == hr)
- m_pUser = NULL;
+ if(PNR_OK == hr)
+ m_pUser = NULL;
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::GetUser(REF(IRMASiteUser*) /*OUT*/ pUser)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if(!m_pUser) return PNR_UNEXPECTED;
+ if(!m_pUser) return PNR_UNEXPECTED;
- (pUser = m_pUser)->AddRef();
+ (pUser = m_pUser)->AddRef();
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::CreateChild(REF(IRMASite*) /*OUT*/ pChildSite)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- CComPtr<IRMASite> pSite =
- (IRMASite*)DNew CRealMediaWindowlessSite(hr, m_pContext, this);
+ CComPtr<IRMASite> pSite =
+ (IRMASite*)DNew CRealMediaWindowlessSite(hr, m_pContext, this);
- if(FAILED(hr) || !pSite)
- return E_FAIL;
+ if(FAILED(hr) || !pSite)
+ return E_FAIL;
- pChildSite = pSite.Detach();
+ pChildSite = pSite.Detach();
- m_pChildren.AddTail(pChildSite);
+ m_pChildren.AddTail(pChildSite);
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::DestroyChild(IRMASite* /*IN*/ pChildSite)
{
- if(POSITION pos = m_pChildren.Find(pChildSite))
- {
- m_pChildren.RemoveAt(pos);
- return PNR_OK;
- }
+ if(POSITION pos = m_pChildren.Find(pChildSite))
+ {
+ m_pChildren.RemoveAt(pos);
+ return PNR_OK;
+ }
- return PNR_UNEXPECTED;
+ return PNR_UNEXPECTED;
}
STDMETHODIMP CRealMediaWindowlessSite::AttachWatcher(IRMASiteWatcher* /*IN*/ pWatcher)
{
- if(m_pWatcher) return PNR_UNEXPECTED;
+ if(m_pWatcher) return PNR_UNEXPECTED;
- if(m_pWatcher = pWatcher)
- m_pWatcher->AttachSite((IRMASite*)this);
+ if(m_pWatcher = pWatcher)
+ m_pWatcher->AttachSite((IRMASite*)this);
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::DetachWatcher()
{
- if(!m_pWatcher) return PNR_UNEXPECTED;
+ if(!m_pWatcher) return PNR_UNEXPECTED;
- m_pWatcher->DetachSite();
- m_pWatcher = NULL;
+ m_pWatcher->DetachSite();
+ m_pWatcher = NULL;
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::SetPosition(PNxPoint position)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if(m_pWatcher)
- {
- hr = m_pWatcher->ChangingPosition(m_position, position);
- }
+ if(m_pWatcher)
+ {
+ hr = m_pWatcher->ChangingPosition(m_position, position);
+ }
- if(PNR_OK == hr)
- {
- m_position = position;
+ if(PNR_OK == hr)
+ {
+ m_position = position;
- POSITION pos = m_pPassiveWatchers.GetHeadPosition();
- while(pos) m_pPassiveWatchers.GetNext(pos)->PositionChanged(&position);
+ POSITION pos = m_pPassiveWatchers.GetHeadPosition();
+ while(pos) m_pPassiveWatchers.GetNext(pos)->PositionChanged(&position);
- RecomputeRegion();
- }
+ RecomputeRegion();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::GetPosition(REF(PNxPoint) position)
{
- position = m_position;
- return PNR_OK;
+ position = m_position;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::SetSize(PNxSize size)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if(m_pWatcher)
- {
- hr = m_pWatcher->ChangingSize(m_size, size);
- }
+ if(m_pWatcher)
+ {
+ hr = m_pWatcher->ChangingSize(m_size, size);
+ }
- if(PNR_OK == hr && size.cx != 0 && size.cy != 0)
- {
- m_size = size;
+ if(PNR_OK == hr && size.cx != 0 && size.cy != 0)
+ {
+ m_size = size;
- POSITION pos = m_pPassiveWatchers.GetHeadPosition();
- while(pos) m_pPassiveWatchers.GetNext(pos)->SizeChanged(&size);
+ POSITION pos = m_pPassiveWatchers.GetHeadPosition();
+ while(pos) m_pPassiveWatchers.GetNext(pos)->SizeChanged(&size);
- RecomputeRegion();
- }
+ RecomputeRegion();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::GetSize(REF(PNxSize) size)
{
- size = m_size;
- return PNR_OK;
+ size = m_size;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::DamageRect(PNxRect rect)
{
- m_fDamaged = TRUE;
- return PNR_OK;
+ m_fDamaged = TRUE;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::DamageRegion(PNxRegion region)
{
- m_fDamaged = TRUE;
- return PNR_OK;
+ m_fDamaged = TRUE;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::ForceRedraw()
{
- // make sure we have a visible window and are not re-enterering and we have damage
- if(!m_fInRedraw && m_fDamaged && m_fIsVisible)
- {
- m_fInRedraw = TRUE;
-
- PNxEvent event = {RMA_SURFACE_UPDATE, NULL, (IRMAVideoSurface*)this, NULL, 0, 0};
- m_pUser->HandleEvent(&event);
-
- m_fInRedraw = FALSE;
- m_fDamaged = FALSE;
- }
-
- return PNR_OK;
+ // make sure we have a visible window and are not re-enterering and we have damage
+ if(!m_fInRedraw && m_fDamaged && m_fIsVisible)
+ {
+ m_fInRedraw = TRUE;
+
+ PNxEvent event = {RMA_SURFACE_UPDATE, NULL, (IRMAVideoSurface*)this, NULL, 0, 0};
+ m_pUser->HandleEvent(&event);
+
+ m_fInRedraw = FALSE;
+ m_fDamaged = FALSE;
+ }
+
+ return PNR_OK;
}
// IRMASite2
STDMETHODIMP CRealMediaWindowlessSite::UpdateSiteWindow(PNxWindow* /*IN*/ pWindow)
{
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::ShowSite(BOOL bShow)
{
- m_fIsVisible = !!bShow;
- RecomputeRegion();
- return PNR_OK;
+ m_fIsVisible = !!bShow;
+ RecomputeRegion();
+ return PNR_OK;
}
STDMETHODIMP_(BOOL) CRealMediaWindowlessSite::IsSiteVisible()
{
- BOOL fIsVisible = m_fIsVisible;
- if(m_pParentSite) fIsVisible = fIsVisible && m_pParentSite->IsSiteVisible();
- return fIsVisible;
+ BOOL fIsVisible = m_fIsVisible;
+ if(m_pParentSite) fIsVisible = fIsVisible && m_pParentSite->IsSiteVisible();
+ return fIsVisible;
}
STDMETHODIMP CRealMediaWindowlessSite::SetZOrder(INT32 lZOrder)
{
- if(!m_pParentSite) return PNR_UNEXPECTED;
-
- if(lZOrder == -1 || lZOrder >= (INT32)m_pParentSite->GetNumberOfChildSites())
- lZOrder = m_pParentSite->GetNumberOfChildSites() - 1;
+ if(!m_pParentSite) return PNR_UNEXPECTED;
- if(m_lZOrder != lZOrder)
- m_pParentSite->UpdateZOrder(this, m_lZOrder, lZOrder);
+ if(lZOrder == -1 || lZOrder >= (INT32)m_pParentSite->GetNumberOfChildSites())
+ lZOrder = m_pParentSite->GetNumberOfChildSites() - 1;
+
+ if(m_lZOrder != lZOrder)
+ m_pParentSite->UpdateZOrder(this, m_lZOrder, lZOrder);
- m_lZOrder = lZOrder;
+ m_lZOrder = lZOrder;
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::GetZOrder(REF(INT32) lZOrder)
{
- if(!m_pParentSite) return PNR_UNEXPECTED;
- lZOrder = m_lZOrder;
- return PNR_OK;
+ if(!m_pParentSite) return PNR_UNEXPECTED;
+ lZOrder = m_lZOrder;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::MoveSiteToTop()
{
- if(!m_pParentSite) return PNR_UNEXPECTED;
- return PNR_NOTIMPL;
+ if(!m_pParentSite) return PNR_UNEXPECTED;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRealMediaWindowlessSite::GetVideoSurface(REF(IRMAVideoSurface*) pSurface)
{
- (pSurface = (IRMAVideoSurface*)this)->AddRef();
- return PNR_OK;
+ (pSurface = (IRMAVideoSurface*)this)->AddRef();
+ return PNR_OK;
}
STDMETHODIMP_(UINT32) CRealMediaWindowlessSite::GetNumberOfChildSites()
{
- return (UINT32)m_pChildren.GetCount();
+ return (UINT32)m_pChildren.GetCount();
}
STDMETHODIMP CRealMediaWindowlessSite::AddPassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher)
{
- m_pPassiveWatchers.AddTail(pWatcher);
- return PNR_OK;
+ m_pPassiveWatchers.AddTail(pWatcher);
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::RemovePassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher)
{
- if(POSITION pos = m_pPassiveWatchers.Find(pWatcher))
- {
- m_pPassiveWatchers.RemoveAt(pos);
- return PNR_OK;
- }
+ if(POSITION pos = m_pPassiveWatchers.Find(pWatcher))
+ {
+ m_pPassiveWatchers.RemoveAt(pos);
+ return PNR_OK;
+ }
- return PNR_UNEXPECTED;
+ return PNR_UNEXPECTED;
}
STDMETHODIMP CRealMediaWindowlessSite::SetCursor(PNxCursor cursor, REF(PNxCursor) oldCursor)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
// private
void CRealMediaWindowlessSite::IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal)
{
- pRetVal->left = max(pRect->left, pBox->left);
- pRetVal->top = max(pRect->top, pBox->top);
- pRetVal->right = min(pRect->right, pBox->right);
- pRetVal->bottom = min(pRect->bottom, pBox->bottom);
+ pRetVal->left = max(pRect->left, pBox->left);
+ pRetVal->top = max(pRect->top, pBox->top);
+ pRetVal->right = min(pRect->right, pBox->right);
+ pRetVal->bottom = min(pRect->bottom, pBox->bottom);
}
// protected
bool CRealMediaWindowlessSite::GetBltService(IRMAVideoSurface** ppBltService)
{
- bool fRet = false;
-
- if(ppBltService)
- {
- if(m_pParentSite)
- {
- fRet = m_pParentSite->GetBltService(ppBltService);
- }
- else if(m_pBltService)
- {
- (*ppBltService = m_pBltService)->AddRef();
- fRet = true;
- }
- }
+ bool fRet = false;
- return(fRet);
+ if(ppBltService)
+ {
+ if(m_pParentSite)
+ {
+ fRet = m_pParentSite->GetBltService(ppBltService);
+ }
+ else if(m_pBltService)
+ {
+ (*ppBltService = m_pBltService)->AddRef();
+ fRet = true;
+ }
+ }
+
+ return(fRet);
}
void CRealMediaWindowlessSite::SetBltService(IRMAVideoSurface* pBltService)
{
- m_pBltService = pBltService;
+ m_pBltService = pBltService;
}
// IRMAVideoSurface
STDMETHODIMP CRealMediaWindowlessSite::Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect)
{
- BeginOptimizedBlt(pBitmapInfo);
- return OptimizedBlt(pImageData, inDestRect, inSrcRect);
+ BeginOptimizedBlt(pBitmapInfo);
+ return OptimizedBlt(pImageData, inDestRect, inSrcRect);
}
STDMETHODIMP CRealMediaWindowlessSite::BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo)
{
- if(memcmp(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader)))
- {
- memcpy(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader));
+ if(memcmp(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader)))
+ {
+ memcpy(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader));
// format of image has changed somehow.
- // do something here if this affects you.
- }
+ // do something here if this affects you.
+ }
- /*
- CComPtr<IRMAVideoSurface> pBltService;
- GetBltService(&pBltService);
- if(!pBltService)
- return PNR_UNEXPECTED;
+/*
+ CComPtr<IRMAVideoSurface> pBltService;
+ GetBltService(&pBltService);
+ if(!pBltService)
+ return PNR_UNEXPECTED;
- RMA_COMPRESSION_TYPE ulType = (RMA_COMPRESSION_TYPE)-1;
- pBltService->GetPreferredFormat(ulType);
+ RMA_COMPRESSION_TYPE ulType = (RMA_COMPRESSION_TYPE)-1;
+ pBltService->GetPreferredFormat(ulType);
- if(pBitmapInfo->biCompression != ulType)
- return PNR_UNEXPECTED;
- */
- return PNR_OK;
+ if(pBitmapInfo->biCompression != ulType)
+ return PNR_UNEXPECTED;
+*/
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect)
{
- CComPtr<IRMAVideoSurface> pBltService;
- GetBltService(&pBltService);
-
- REGION* pRegion = GetRegion();
+ CComPtr<IRMAVideoSurface> pBltService;
+ GetBltService(&pBltService);
- if(!pBltService || !pRegion)
- return PNR_UNEXPECTED;
+ REGION* pRegion = GetRegion();
- PNxPoint origin;
- memset(&origin, 0, sizeof(PNxPoint));
- GetTopLeft(&origin);
- PNxRect adjustedDestRect;
- adjustedDestRect.left = rDestRect.left + origin.x;
- adjustedDestRect.top = rDestRect.top + origin.y;
- adjustedDestRect.right = rDestRect.right + origin.x;
- adjustedDestRect.bottom = rDestRect.bottom + origin.y;
+ if(!pBltService || !pRegion)
+ return PNR_UNEXPECTED;
- for(int i = 0; i < pRegion->numRects; i++)
- {
- PNxRect* pRect = pRegion->rects + i;
+ PNxPoint origin;
+ memset(&origin, 0, sizeof(PNxPoint));
+ GetTopLeft(&origin);
+ PNxRect adjustedDestRect;
+ adjustedDestRect.left = rDestRect.left + origin.x;
+ adjustedDestRect.top = rDestRect.top + origin.y;
+ adjustedDestRect.right = rDestRect.right + origin.x;
+ adjustedDestRect.bottom = rDestRect.bottom + origin.y;
- // intersect the dest rect with the rect from the
- // region to get the final dest rect.
- PNxRect finalDestRect;
- IntersectRect(&adjustedDestRect, pRect, &finalDestRect);
+ for(int i = 0; i < pRegion->numRects; i++)
+ {
+ PNxRect* pRect = pRegion->rects+i;
+
+ // intersect the dest rect with the rect from the
+ // region to get the final dest rect.
+ PNxRect finalDestRect;
+ IntersectRect(&adjustedDestRect, pRect, &finalDestRect);
// now compute the src rect for this blt.
- double xStretch = (double)(rDestRect.right - rDestRect.left) / (double)(rSrcRect.right - rSrcRect.left);
- double yStretch = (double)(rDestRect.bottom - rDestRect.top) / (double)(rSrcRect.bottom - rSrcRect.top);
+ double xStretch = (double) (rDestRect.right - rDestRect.left) / (double) (rSrcRect.right - rSrcRect.left);
+ double yStretch = (double) (rDestRect.bottom - rDestRect.top) / (double) (rSrcRect.bottom - rSrcRect.top);
- PNxRect finalSrcRect;
- finalSrcRect.left = (INT32)((double)(finalDestRect.left - origin.x) / xStretch + 0.5);
- finalSrcRect.top = (INT32)((double)(finalDestRect.top - origin.y) / yStretch + 0.5);
- finalSrcRect.right = (INT32)((double)(finalDestRect.right - origin.x) / xStretch + 0.5);
- finalSrcRect.bottom = (INT32)((double)(finalDestRect.bottom - origin.y) / yStretch + 0.5);
+ PNxRect finalSrcRect;
+ finalSrcRect.left = (INT32)((double)(finalDestRect.left-origin.x) / xStretch + 0.5);
+ finalSrcRect.top = (INT32)((double)(finalDestRect.top-origin.y) / yStretch + 0.5);
+ finalSrcRect.right = (INT32)((double)(finalDestRect.right-origin.x) / xStretch + 0.5);
+ finalSrcRect.bottom = (INT32)((double)(finalDestRect.bottom-origin.y) / yStretch + 0.5);
- pBltService->Blt(pImageBits, &m_bitmapInfo, finalDestRect, finalSrcRect);
- }
+ pBltService->Blt(pImageBits, &m_bitmapInfo, finalDestRect, finalSrcRect);
+ }
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::EndOptimizedBlt()
{
- memset(&m_bitmapInfo, 0, sizeof(m_bitmapInfo));
- return PNR_OK;
+ memset(&m_bitmapInfo, 0, sizeof(m_bitmapInfo));
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType)
{
- ulType = m_bitmapInfo.biCompression;
- return PNR_OK;
+ ulType = m_bitmapInfo.biCompression;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType)
{
- CComPtr<IRMAVideoSurface> pBltService;
- GetBltService(&pBltService);
- if(!pBltService)
- return PNR_UNEXPECTED;
+ CComPtr<IRMAVideoSurface> pBltService;
+ GetBltService(&pBltService);
+ if(!pBltService)
+ return PNR_UNEXPECTED;
- return pBltService->GetPreferredFormat(ulType);
+ return pBltService->GetPreferredFormat(ulType);
}
diff --git a/src/apps/mplayerc/RealMediaWindowlessSite.h b/src/apps/mplayerc/RealMediaWindowlessSite.h
index 4ddc44f21..0551b5bb9 100644
--- a/src/apps/mplayerc/RealMediaWindowlessSite.h
+++ b/src/apps/mplayerc/RealMediaWindowlessSite.h
@@ -45,177 +45,177 @@
namespace DSObjects
{
-struct REGION
-{
- REGION() : rects(0), pOSRegion(0) {}
- long size;
- long numRects;
- PNxRect* rects;
- PNxRect extents;
- void* pOSRegion;
-};
-
-void ExtractRects(REGION* pRegion);
-REGION* RMACreateRectRegion(int left, int top, int right, int bottom);
-void RMASubtractRegion(REGION* regM, REGION* regS, REGION* regD);
-void RMAUnionRegion(REGION* reg1, REGION* reg2, REGION* regD);
-void RMAIntersectRegion(REGION* reg1, REGION* reg2, REGION* regD);
-BOOL RMAEqualRegion(REGION* reg1, REGION* reg2);
-void RMADestroyRegion(REGION* reg);
-REGION* RMACreateRegion();
-
-class CRealMediaWindowlessSite;
-
-//
-// CRealMediaVideoSurface
-//
-
-class CRealMediaWindowlessSite;
-
-class CRealMediaVideoSurface
- : public CUnknown
- , public IRMAVideoSurface
-{
- void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
-
-protected:
- CComPtr<IUnknown> m_pContext;
- CRealMediaWindowlessSite* m_pSiteWindowless;
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
-
-public:
- CRealMediaVideoSurface(IUnknown* pContext, CRealMediaWindowlessSite* pSiteWindowless);
- virtual ~CRealMediaVideoSurface();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IRMAVideoSurface
-
- STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
-};
-
-//
-// CRealMediaWindowlessSite
-//
-
-class CRealMediaWindowlessSite
- : public CUnknown
- , public IRMASite
- , public IRMASite2
- , public IRMASiteWindowless
- , public IRMAVideoSurface
-{
- CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCCF;
- CComPtr<IUnknown> m_pContext;
- CComPtr<IRMAValues> m_pValues;
-
- CComPtr<IRMASiteUser> m_pUser;
-
- CRealMediaWindowlessSite* m_pParentSite;
- CInterfaceList<IRMASite, &IID_IRMASite> m_pChildren;
-
- CComPtr<IRMASiteWatcher> m_pWatcher;
- CInterfaceList<IRMAPassiveSiteWatcher, &IID_IRMAPassiveSiteWatcher> m_pPassiveWatchers;
-
- PNxSize m_size;
- PNxPoint m_position;
- bool m_fDamaged, m_fInRedraw, m_fIsVisible;
- INT32 m_lZOrder;
-
- //
-
- REGION* m_pRegion;
- REGION* m_pRegionWithoutChildren;
-
- void RecomputeRegion();
- void InternalRecomputeRegion();
- void ComputeRegion();
- void SubtractSite(REGION* pRegion);
-
- void UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder);
- void SetInternalZOrder(INT32 lZOrder);
-
-public:
- CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pContext, CRealMediaWindowlessSite* pParentSite = NULL, IUnknown* pUnkOuter = NULL);
- virtual ~CRealMediaWindowlessSite();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- void GetTopLeft(PNxPoint* pPoint);
- REGION* GetRegion();
+ struct REGION
+ {
+ REGION() : rects(0), pOSRegion(0) {}
+ long size;
+ long numRects;
+ PNxRect* rects;
+ PNxRect extents;
+ void* pOSRegion;
+ };
+
+ void ExtractRects(REGION* pRegion);
+ REGION* RMACreateRectRegion(int left, int top, int right, int bottom);
+ void RMASubtractRegion(REGION* regM, REGION* regS, REGION* regD);
+ void RMAUnionRegion(REGION* reg1, REGION* reg2, REGION* regD);
+ void RMAIntersectRegion(REGION* reg1, REGION* reg2, REGION* regD);
+ BOOL RMAEqualRegion(REGION* reg1, REGION* reg2);
+ void RMADestroyRegion(REGION* reg);
+ REGION* RMACreateRegion();
+
+ class CRealMediaWindowlessSite;
+
+ //
+ // CRealMediaVideoSurface
+ //
+
+ class CRealMediaWindowlessSite;
+
+ class CRealMediaVideoSurface
+ : public CUnknown
+ , public IRMAVideoSurface
+ {
+ void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
+
+ protected:
+ CComPtr<IUnknown> m_pContext;
+ CRealMediaWindowlessSite* m_pSiteWindowless;
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
+
+ public:
+ CRealMediaVideoSurface(IUnknown* pContext, CRealMediaWindowlessSite* pSiteWindowless);
+ virtual ~CRealMediaVideoSurface();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IRMAVideoSurface
+
+ STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ };
+
+ //
+ // CRealMediaWindowlessSite
+ //
+
+ class CRealMediaWindowlessSite
+ : public CUnknown
+ , public IRMASite
+ , public IRMASite2
+ , public IRMASiteWindowless
+ , public IRMAVideoSurface
+ {
+ CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCCF;
+ CComPtr<IUnknown> m_pContext;
+ CComPtr<IRMAValues> m_pValues;
+
+ CComPtr<IRMASiteUser> m_pUser;
+
+ CRealMediaWindowlessSite* m_pParentSite;
+ CInterfaceList<IRMASite, &IID_IRMASite> m_pChildren;
+
+ CComPtr<IRMASiteWatcher> m_pWatcher;
+ CInterfaceList<IRMAPassiveSiteWatcher, &IID_IRMAPassiveSiteWatcher> m_pPassiveWatchers;
+
+ PNxSize m_size;
+ PNxPoint m_position;
+ bool m_fDamaged, m_fInRedraw, m_fIsVisible;
+ INT32 m_lZOrder;
+
+ //
+
+ REGION* m_pRegion;
+ REGION* m_pRegionWithoutChildren;
+
+ void RecomputeRegion();
+ void InternalRecomputeRegion();
+ void ComputeRegion();
+ void SubtractSite(REGION* pRegion);
+
+ void UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder);
+ void SetInternalZOrder(INT32 lZOrder);
+
+ public:
+ CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pContext, CRealMediaWindowlessSite* pParentSite = NULL, IUnknown* pUnkOuter = NULL);
+ virtual ~CRealMediaWindowlessSite();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ void GetTopLeft(PNxPoint* pPoint);
+ REGION* GetRegion();
- // IRMASiteWindowless
+ // IRMASiteWindowless
- STDMETHODIMP EventOccurred(PNxEvent* /*IN*/ pEvent);
- STDMETHODIMP_(PNxWindow*) GetParentWindow();
+ STDMETHODIMP EventOccurred(PNxEvent* /*IN*/ pEvent);
+ STDMETHODIMP_(PNxWindow*) GetParentWindow();
- // IRMASite
+ // IRMASite
- STDMETHODIMP AttachUser(IRMASiteUser* /*IN*/ pUser);
- STDMETHODIMP DetachUser();
- STDMETHODIMP GetUser(REF(IRMASiteUser*) /*OUT*/ pUser);
+ STDMETHODIMP AttachUser(IRMASiteUser* /*IN*/ pUser);
+ STDMETHODIMP DetachUser();
+ STDMETHODIMP GetUser(REF(IRMASiteUser*) /*OUT*/ pUser);
- STDMETHODIMP CreateChild(REF(IRMASite*) /*OUT*/ pChildSite);
- STDMETHODIMP DestroyChild(IRMASite* /*IN*/ pChildSite);
+ STDMETHODIMP CreateChild(REF(IRMASite*) /*OUT*/ pChildSite);
+ STDMETHODIMP DestroyChild(IRMASite* /*IN*/ pChildSite);
- STDMETHODIMP AttachWatcher(IRMASiteWatcher* /*IN*/ pWatcher);
- STDMETHODIMP DetachWatcher();
+ STDMETHODIMP AttachWatcher(IRMASiteWatcher* /*IN*/ pWatcher);
+ STDMETHODIMP DetachWatcher();
- STDMETHODIMP SetPosition(PNxPoint position);
- STDMETHODIMP GetPosition(REF(PNxPoint) position);
- STDMETHODIMP SetSize(PNxSize size);
- STDMETHODIMP GetSize(REF(PNxSize) size);
+ STDMETHODIMP SetPosition(PNxPoint position);
+ STDMETHODIMP GetPosition(REF(PNxPoint) position);
+ STDMETHODIMP SetSize(PNxSize size);
+ STDMETHODIMP GetSize(REF(PNxSize) size);
- STDMETHODIMP DamageRect(PNxRect rect);
- STDMETHODIMP DamageRegion(PNxRegion region);
- STDMETHODIMP ForceRedraw();
+ STDMETHODIMP DamageRect(PNxRect rect);
+ STDMETHODIMP DamageRegion(PNxRegion region);
+ STDMETHODIMP ForceRedraw();
- // IRMASite2
+ // IRMASite2
- STDMETHODIMP UpdateSiteWindow(PNxWindow* /*IN*/ pWindow);
- STDMETHODIMP ShowSite(BOOL bShow);
- STDMETHODIMP_(BOOL) IsSiteVisible();
- STDMETHODIMP SetZOrder(INT32 lZOrder);
- STDMETHODIMP GetZOrder(REF(INT32) lZOrder);
- STDMETHODIMP MoveSiteToTop();
- STDMETHODIMP GetVideoSurface(REF(IRMAVideoSurface*) pSurface);
- STDMETHODIMP_(UINT32) GetNumberOfChildSites();
+ STDMETHODIMP UpdateSiteWindow(PNxWindow* /*IN*/ pWindow);
+ STDMETHODIMP ShowSite(BOOL bShow);
+ STDMETHODIMP_(BOOL) IsSiteVisible();
+ STDMETHODIMP SetZOrder(INT32 lZOrder);
+ STDMETHODIMP GetZOrder(REF(INT32) lZOrder);
+ STDMETHODIMP MoveSiteToTop();
+ STDMETHODIMP GetVideoSurface(REF(IRMAVideoSurface*) pSurface);
+ STDMETHODIMP_(UINT32) GetNumberOfChildSites();
- STDMETHODIMP AddPassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
- STDMETHODIMP RemovePassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
+ STDMETHODIMP AddPassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
+ STDMETHODIMP RemovePassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
- STDMETHODIMP SetCursor(PNxCursor cursor, REF(PNxCursor) oldCursor);
+ STDMETHODIMP SetCursor(PNxCursor cursor, REF(PNxCursor) oldCursor);
-private:
- void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
+ private:
+ void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
-protected:
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
+ protected:
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
- CComPtr<IRMAVideoSurface> m_pBltService;
+ CComPtr<IRMAVideoSurface> m_pBltService;
-public:
- bool GetBltService(IRMAVideoSurface** ppBltService);
- void SetBltService(IRMAVideoSurface* ppBltService);
+ public:
+ bool GetBltService(IRMAVideoSurface** ppBltService);
+ void SetBltService(IRMAVideoSurface* ppBltService);
- // IRMAVideoSurface
+ // IRMAVideoSurface
- STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
-};
+ STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ };
}
using namespace DSObjects;
diff --git a/src/apps/mplayerc/RegFilterChooserDlg.cpp b/src/apps/mplayerc/RegFilterChooserDlg.cpp
index 3d98af373..ad17a2fbb 100644
--- a/src/apps/mplayerc/RegFilterChooserDlg.cpp
+++ b/src/apps/mplayerc/RegFilterChooserDlg.cpp
@@ -33,45 +33,45 @@
//IMPLEMENT_DYNAMIC(CRegFilterChooserDlg, CResizableDialog)
CRegFilterChooserDlg::CRegFilterChooserDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CRegFilterChooserDlg::IDD, pParent)
+ : CResizableDialog(CRegFilterChooserDlg::IDD, pParent)
{
}
CRegFilterChooserDlg::~CRegFilterChooserDlg()
{
- POSITION pos = m_filters.GetHeadPosition();
- while(pos) delete m_filters.GetNext(pos);
+ POSITION pos = m_filters.GetHeadPosition();
+ while(pos) delete m_filters.GetNext(pos);
}
void CRegFilterChooserDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST2, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST2, m_list);
}
void CRegFilterChooserDlg::AddToList(IMoniker* pMoniker)
{
- CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
- {
- CComVariant var;
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- {
- m_list.SetItemData(
- m_list.InsertItem(-1, CString(CStringW(var.bstrVal))),
- (DWORD_PTR)m_monikers.AddTail(pMoniker));
- }
- }
+ CComPtr<IPropertyBag> pPB;
+ if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
+ {
+ CComVariant var;
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ {
+ m_list.SetItemData(
+ m_list.InsertItem(-1, CString(CStringW(var.bstrVal))),
+ (DWORD_PTR)m_monikers.AddTail(pMoniker));
+ }
+ }
}
BEGIN_MESSAGE_MAP(CRegFilterChooserDlg, CResizableDialog)
- ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnNMDblclkList2)
+ ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnNMDblclkList2)
END_MESSAGE_MAP()
@@ -79,95 +79,95 @@ END_MESSAGE_MAP()
BOOL CRegFilterChooserDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker)
- {
- AddToList(pMoniker);
- }
- EndEnumSysDev
-
- BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker)
- {
- AddToList(pMoniker);
- }
- EndEnumSysDev
-
- BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker)
- {
- AddToList(pMoniker);
- }
- EndEnumSysDev
-
- AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, BOTTOM_LEFT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
- AddAnchor(IDCANCEL, BOTTOM_RIGHT);
-
- SetMinTrackSize(CSize(300, 100));
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker)
+ {
+ AddToList(pMoniker);
+ }
+ EndEnumSysDev
+
+ BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker)
+ {
+ AddToList(pMoniker);
+ }
+ EndEnumSysDev
+
+ BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker)
+ {
+ AddToList(pMoniker);
+ }
+ EndEnumSysDev
+
+ AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, BOTTOM_LEFT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
+ AddAnchor(IDCANCEL, BOTTOM_RIGHT);
+
+ SetMinTrackSize(CSize(300,100));
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CRegFilterChooserDlg::OnLbnDblclkList1()
{
- SendMessage(WM_COMMAND, IDOK);
+ SendMessage(WM_COMMAND, IDOK);
}
void CRegFilterChooserDlg::OnUpdateOK(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!m_list.GetFirstSelectedItemPosition());
+ pCmdUI->Enable(!!m_list.GetFirstSelectedItemPosition());
}
void CRegFilterChooserDlg::OnBnClickedOk()
{
- CComPtr<IMoniker> pMoniker;
-
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- if(pos) pos = (POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos));
- if(pos) pMoniker = m_monikers.GetAt(pos);
- if(pMoniker)
- {
- CFGFilterRegistry fgf(pMoniker);
- FilterOverride* f = DNew FilterOverride;
- f->fDisabled = false;
- f->type = FilterOverride::REGISTERED;
- f->name = fgf.GetName();
- f->dispname = fgf.GetDisplayName();
- f->guids.AddTailList(&fgf.GetTypes());
- f->backup.AddTailList(&fgf.GetTypes());
- f->dwMerit = fgf.GetMeritForDirectShow();
- f->iLoadType = FilterOverride::MERIT;
- m_filters.AddTail(f);
- }
-
- __super::OnOK();
+ CComPtr<IMoniker> pMoniker;
+
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ if(pos) pos = (POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos));
+ if(pos) pMoniker = m_monikers.GetAt(pos);
+ if(pMoniker)
+ {
+ CFGFilterRegistry fgf(pMoniker);
+ FilterOverride* f = DNew FilterOverride;
+ f->fDisabled = false;
+ f->type = FilterOverride::REGISTERED;
+ f->name = fgf.GetName();
+ f->dispname = fgf.GetDisplayName();
+ f->guids.AddTailList(&fgf.GetTypes());
+ f->backup.AddTailList(&fgf.GetTypes());
+ f->dwMerit = fgf.GetMeritForDirectShow();
+ f->iLoadType = FilterOverride::MERIT;
+ m_filters.AddTail(f);
+ }
+
+ __super::OnOK();
}
void CRegFilterChooserDlg::OnBnClickedButton1()
{
- CFileDialog dlg(TRUE, NULL, NULL,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
- _T("DirectShow Filters (*.dll,*.ax)|*.dll;*.ax|"), this, 0);
-
- if(dlg.DoModal() == IDOK)
- {
- CFilterMapper2 fm2(false);
- fm2.Register(dlg.GetPathName());
- m_filters.AddTail(&fm2.m_filters);
- fm2.m_filters.RemoveAll();
-
- __super::OnOK();
- }
+ CFileDialog dlg(TRUE, NULL, NULL,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ _T("DirectShow Filters (*.dll,*.ax)|*.dll;*.ax|"), this, 0);
+
+ if(dlg.DoModal() == IDOK)
+ {
+ CFilterMapper2 fm2(false);
+ fm2.Register(dlg.GetPathName());
+ m_filters.AddTail(&fm2.m_filters);
+ fm2.m_filters.RemoveAll();
+
+ __super::OnOK();
+ }
}
void CRegFilterChooserDlg::OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult)
{
- if(m_list.GetFirstSelectedItemPosition())
- {
- OnBnClickedOk();
- }
+ if(m_list.GetFirstSelectedItemPosition())
+ {
+ OnBnClickedOk();
+ }
- *pResult = 0;
+ *pResult = 0;
}
diff --git a/src/apps/mplayerc/RegFilterChooserDlg.h b/src/apps/mplayerc/RegFilterChooserDlg.h
index 706d6901a..6128c8a16 100644
--- a/src/apps/mplayerc/RegFilterChooserDlg.h
+++ b/src/apps/mplayerc/RegFilterChooserDlg.h
@@ -32,29 +32,29 @@ class CRegFilterChooserDlg : public CResizableDialog
{
// DECLARE_DYNAMIC(CRegFilterChooserDlg)
- CInterfaceList<IMoniker> m_monikers;
- void AddToList(IMoniker* pMoniker);
+ CInterfaceList<IMoniker> m_monikers;
+ void AddToList(IMoniker* pMoniker);
public:
- CRegFilterChooserDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CRegFilterChooserDlg();
+ CRegFilterChooserDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CRegFilterChooserDlg();
- CList<FilterOverride*> m_filters;
+ CList<FilterOverride*> m_filters;
// Dialog Data
- enum { IDD = IDD_ADDREGFILTER };
- CListCtrl m_list;
+ enum { IDD = IDD_ADDREGFILTER };
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnLbnDblclkList1();
- afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedOk();
- afx_msg void OnBnClickedButton1();
- afx_msg void OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnLbnDblclkList1();
+ afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult);
};
diff --git a/src/apps/mplayerc/SaveDlg.cpp b/src/apps/mplayerc/SaveDlg.cpp
index 32e0ced36..9fd53afcb 100644
--- a/src/apps/mplayerc/SaveDlg.cpp
+++ b/src/apps/mplayerc/SaveDlg.cpp
@@ -32,9 +32,9 @@
IMPLEMENT_DYNAMIC(CSaveDlg, CCmdUIDialog)
CSaveDlg::CSaveDlg(CString in, CString out, CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CSaveDlg::IDD, pParent)
- , m_in(in), m_out(out)
- , m_nIDTimerEvent(-1)
+ : CCmdUIDialog(CSaveDlg::IDD, pParent)
+ , m_in(in), m_out(out)
+ , m_nIDTimerEvent(-1)
{
}
@@ -44,18 +44,18 @@ CSaveDlg::~CSaveDlg()
void CSaveDlg::DoDataExchange(CDataExchange* pDX)
{
- CCmdUIDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_ANIMATE1, m_anim);
- DDX_Control(pDX, IDC_PROGRESS1, m_progress);
- DDX_Control(pDX, IDC_REPORT, m_report);
- DDX_Control(pDX, IDC_FROMTO, m_fromto);
+ CCmdUIDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_ANIMATE1, m_anim);
+ DDX_Control(pDX, IDC_PROGRESS1, m_progress);
+ DDX_Control(pDX, IDC_REPORT, m_report);
+ DDX_Control(pDX, IDC_FROMTO, m_fromto);
}
BEGIN_MESSAGE_MAP(CSaveDlg, CCmdUIDialog)
- ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
- ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
- ON_WM_TIMER()
+ ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
+ ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
+ ON_WM_TIMER()
END_MESSAGE_MAP()
@@ -63,183 +63,183 @@ END_MESSAGE_MAP()
BOOL CSaveDlg::OnInitDialog()
{
- CCmdUIDialog::OnInitDialog();
+ CCmdUIDialog::OnInitDialog();
- m_anim.Open(IDR_AVI_FILECOPY);
- m_anim.Play(0, -1, -1);
+ m_anim.Open(IDR_AVI_FILECOPY);
+ m_anim.Play(0, -1, -1);
- CString str, in = m_in, out = m_out;
- if(in.GetLength() > 60) in = in.Left(17) + _T("..") + in.Right(43);
- if(out.GetLength() > 60) out = out.Left(17) + _T("..") + out.Right(43);
- str.Format(_T("%s\r\n%s"), in, out);
- m_fromto.SetWindowText(str);
+ CString str, in = m_in, out = m_out;
+ if(in.GetLength() > 60) in = in.Left(17) + _T("..") + in.Right(43);
+ if(out.GetLength() > 60) out = out.Left(17) + _T("..") + out.Right(43);
+ str.Format(_T("%s\r\n%s"), in, out);
+ m_fromto.SetWindowText(str);
- m_progress.SetRange(0, 100);
+ m_progress.SetRange(0, 100);
- if(FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
- || FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
- {
- m_report.SetWindowText(_T("Error"));
- return FALSE;
- }
+ if(FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
+ || FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
+ {
+ m_report.SetWindowText(_T("Error"));
+ return FALSE;
+ }
- HRESULT hr;
+ HRESULT hr;
- CStringW fnw = m_in;
- CComPtr<IFileSourceFilter> pReader;
+ CStringW fnw = m_in;
+ CComPtr<IFileSourceFilter> pReader;
#if INTERNAL_SOURCEFILTER_CDDA
- if(!pReader && m_in.Mid(m_in.ReverseFind('.') + 1).MakeLower() == _T("cda"))
- {
- hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);
- if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
- pReader.Release();
- }
+ if(!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda"))
+ {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
+ pReader.Release();
+ }
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- if(!pReader)
- {
- hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
- if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
- pReader.Release();
- }
+ if(!pReader)
+ {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
+ pReader.Release();
+ }
#endif
#if INTERNAL_SOURCEFILTER_VTS
- if(!pReader /*&& ext == _T("ifo")*/)
- {
- hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);
- if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
- pReader.Release();
- else
- {
- CPath pout(m_out);
- pout.RenameExtension(_T(".ifo"));
- CopyFile(m_in, pout, FALSE);
- }
- }
+ if(!pReader /*&& ext == _T("ifo")*/)
+ {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
+ pReader.Release();
+ else
+ {
+ CPath pout(m_out);
+ pout.RenameExtension(_T(".ifo"));
+ CopyFile(m_in, pout, FALSE);
+ }
+ }
#endif
- if(!pReader)
- {
- hr = S_OK;
- CComPtr<IUnknown> pUnk;
- pUnk.CoCreateInstance(CLSID_AsyncReader);
- if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
- pReader.Release();
- }
-
- if(!pReader)
- {
- hr = S_OK;
- CComPtr<IUnknown> pUnk;
- pUnk.CoCreateInstance(CLSID_URLReader);
- if(CComQIPtr<IBaseFilter> pSrc = pUnk) // url reader has to be in the graph to load the file
- {
- pGB->AddFilter(pSrc, fnw);
- if(FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL)))
- {
- pReader.Release();
- pGB->RemoveFilter(pSrc);
- }
- }
- }
-
- CComQIPtr<IBaseFilter> pSrc = pReader;
- if(FAILED(pGB->AddFilter(pSrc, fnw)))
- {
- m_report.SetWindowText(_T("Sorry, can't save this file, press cancel"));
- return FALSE;
- }
-
- CComQIPtr<IBaseFilter> pMid = DNew CStreamDriveThruFilter(NULL, &hr);
- if(FAILED(pGB->AddFilter(pMid, L"StreamDriveThru")))
- {
- m_report.SetWindowText(_T("Error"));
- return FALSE;
- }
-
- CComQIPtr<IBaseFilter> pDst;
- pDst.CoCreateInstance(CLSID_FileWriter);
- CComQIPtr<IFileSinkFilter2> pFSF = pDst;
- pFSF->SetFileName(CStringW(m_out), NULL);
- pFSF->SetMode(AM_FILE_OVERWRITE);
- if(FAILED(pGB->AddFilter(pDst, L"File Writer")))
- {
- m_report.SetWindowText(_T("Error"));
- return FALSE;
- }
-
- hr = pGB->Connect(
- GetFirstPin((pSrc), PINDIR_OUTPUT),
- GetFirstPin((pMid), PINDIR_INPUT));
-
- hr = pGB->Connect(
- GetFirstPin((pMid), PINDIR_OUTPUT),
- GetFirstPin((pDst), PINDIR_INPUT));
-
- pMS = pMid;
-
- pMC->Run();
-
- m_nIDTimerEvent = SetTimer(1, 1000, NULL);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ if(!pReader)
+ {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk;
+ pUnk.CoCreateInstance(CLSID_AsyncReader);
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
+ pReader.Release();
+ }
+
+ if(!pReader)
+ {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk;
+ pUnk.CoCreateInstance(CLSID_URLReader);
+ if(CComQIPtr<IBaseFilter> pSrc = pUnk) // url reader has to be in the graph to load the file
+ {
+ pGB->AddFilter(pSrc, fnw);
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL)))
+ {
+ pReader.Release();
+ pGB->RemoveFilter(pSrc);
+ }
+ }
+ }
+
+ CComQIPtr<IBaseFilter> pSrc = pReader;
+ if(FAILED(pGB->AddFilter(pSrc, fnw)))
+ {
+ m_report.SetWindowText(_T("Sorry, can't save this file, press cancel"));
+ return FALSE;
+ }
+
+ CComQIPtr<IBaseFilter> pMid = DNew CStreamDriveThruFilter(NULL, &hr);
+ if(FAILED(pGB->AddFilter(pMid, L"StreamDriveThru")))
+ {
+ m_report.SetWindowText(_T("Error"));
+ return FALSE;
+ }
+
+ CComQIPtr<IBaseFilter> pDst;
+ pDst.CoCreateInstance(CLSID_FileWriter);
+ CComQIPtr<IFileSinkFilter2> pFSF = pDst;
+ pFSF->SetFileName(CStringW(m_out), NULL);
+ pFSF->SetMode(AM_FILE_OVERWRITE);
+ if(FAILED(pGB->AddFilter(pDst, L"File Writer")))
+ {
+ m_report.SetWindowText(_T("Error"));
+ return FALSE;
+ }
+
+ hr = pGB->Connect(
+ GetFirstPin((pSrc), PINDIR_OUTPUT),
+ GetFirstPin((pMid), PINDIR_INPUT));
+
+ hr = pGB->Connect(
+ GetFirstPin((pMid), PINDIR_OUTPUT),
+ GetFirstPin((pDst), PINDIR_INPUT));
+
+pMS = pMid;
+
+ pMC->Run();
+
+ m_nIDTimerEvent = SetTimer(1, 1000, NULL);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CSaveDlg::OnBnClickedCancel()
{
- if(pMC) pMC->Stop();
+ if(pMC) pMC->Stop();
- OnCancel();
+ OnCancel();
}
LRESULT CSaveDlg::OnGraphNotify(WPARAM wParam, LPARAM lParam)
{
- LONG evCode, evParam1, evParam2;
+ LONG evCode, evParam1, evParam2;
while(pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0)))
{
- HRESULT hr = pME->FreeEventParams(evCode, evParam1, evParam2);
+ HRESULT hr = pME->FreeEventParams(evCode, evParam1, evParam2);
if(EC_COMPLETE == evCode)
{
- EndDialog(IDOK);
- }
- else if(EC_ERRORABORT == evCode)
- {
- TRACE(_T("CSaveDlg::OnGraphNotify / EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
- m_report.SetWindowText(_T("Copying unexpectedly terminated!"));
- }
- }
-
- return 0;
+ EndDialog(IDOK);
+ }
+ else if(EC_ERRORABORT == evCode)
+ {
+ TRACE(_T("CSaveDlg::OnGraphNotify / EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
+ m_report.SetWindowText(_T("Copying unexpectedly terminated!"));
+ }
+ }
+
+ return 0;
}
void CSaveDlg::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == m_nIDTimerEvent && pGB)
- {
- if(pMS)
- {
- CString str;
- REFERENCE_TIME pos = 0, dur = 0;
- pMS->GetCurrentPosition(&pos);
- pMS->GetDuration(&dur);
- REFERENCE_TIME time = 0;
- CComQIPtr<IMediaSeeking>(pGB)->GetCurrentPosition(&time);
- REFERENCE_TIME speed = time > 0 ? pos * 10000000 / time / 1024 : 0i64;
- str.Format(_T("%I64d/%I64d KB, %I64d KB/s, %I64d s"),
- pos / 1024, dur / 1024, speed, speed > 0 ? (dur - pos) / 1024 / speed : 0);
- m_report.SetWindowText(str);
-
- m_progress.SetPos(dur > 0 ? (int)(100 * pos / dur) : 0);
- }
- }
-
- CCmdUIDialog::OnTimer(nIDEvent);
+ if(nIDEvent == m_nIDTimerEvent && pGB)
+ {
+ if(pMS)
+ {
+ CString str;
+ REFERENCE_TIME pos = 0, dur = 0;
+ pMS->GetCurrentPosition(&pos);
+ pMS->GetDuration(&dur);
+ REFERENCE_TIME time = 0;
+ CComQIPtr<IMediaSeeking>(pGB)->GetCurrentPosition(&time);
+ REFERENCE_TIME speed = time > 0 ? pos*10000000/time / 1024 : 0i64;
+ str.Format(_T("%I64d/%I64d KB, %I64d KB/s, %I64d s"),
+ pos/1024, dur/1024, speed, speed > 0 ? (dur-pos)/1024 / speed : 0);
+ m_report.SetWindowText(str);
+
+ m_progress.SetPos(dur > 0 ? (int)(100*pos/dur) : 0);
+ }
+ }
+
+ CCmdUIDialog::OnTimer(nIDEvent);
}
diff --git a/src/apps/mplayerc/SaveDlg.h b/src/apps/mplayerc/SaveDlg.h
index 97fedaa97..a27536ae0 100644
--- a/src/apps/mplayerc/SaveDlg.h
+++ b/src/apps/mplayerc/SaveDlg.h
@@ -31,34 +31,34 @@
class CSaveDlg : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CSaveDlg)
+ DECLARE_DYNAMIC(CSaveDlg)
private:
- CString m_in, m_out;
- CComPtr<IGraphBuilder> pGB;
- CComQIPtr<IMediaControl> pMC;
- CComQIPtr<IMediaEventEx> pME;
- CComQIPtr<IMediaSeeking> pMS;
- UINT_PTR m_nIDTimerEvent;
+ CString m_in, m_out;
+ CComPtr<IGraphBuilder> pGB;
+ CComQIPtr<IMediaControl> pMC;
+ CComQIPtr<IMediaEventEx> pME;
+ CComQIPtr<IMediaSeeking> pMS;
+ UINT_PTR m_nIDTimerEvent;
public:
- CSaveDlg(CString in, CString out, CWnd* pParent = NULL); // standard constructor
- virtual ~CSaveDlg();
+ CSaveDlg(CString in, CString out, CWnd* pParent = NULL); // standard constructor
+ virtual ~CSaveDlg();
// Dialog Data
- enum { IDD = IDD_SAVE_DLG };
- CAnimateCtrl m_anim;
- CProgressCtrl m_progress;
- CStatic m_report;
- CStatic m_fromto;
+ enum { IDD = IDD_SAVE_DLG };
+ CAnimateCtrl m_anim;
+ CProgressCtrl m_progress;
+ CStatic m_report;
+ CStatic m_fromto;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedCancel();
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnBnClickedCancel();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
};
diff --git a/src/apps/mplayerc/SaveTextFileDialog.cpp b/src/apps/mplayerc/SaveTextFileDialog.cpp
index 551de0eb0..a5438e168 100644
--- a/src/apps/mplayerc/SaveTextFileDialog.cpp
+++ b/src/apps/mplayerc/SaveTextFileDialog.cpp
@@ -30,26 +30,26 @@
IMPLEMENT_DYNAMIC(CSaveTextFileDialog, CFileDialog)
CSaveTextFileDialog::CSaveTextFileDialog(
- CTextFile::enc e,
- LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- LPCTSTR lpszFilter, CWnd* pParentWnd) :
- CFileDialog(FALSE, lpszDefExt, lpszFileName,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
- lpszFilter, pParentWnd, 0
+ CTextFile::enc e,
+ LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
+ LPCTSTR lpszFilter, CWnd* pParentWnd) :
+ CFileDialog(FALSE, lpszDefExt, lpszFileName,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
+ lpszFilter, pParentWnd, 0
#if (_MSC_VER >= 1500) // <= Parameter added after Visual Studio 2008!
- , FALSE
+ , FALSE
#endif
- ),
- m_e(e)
+ ),
+ m_e(e)
{
- if(m_ofn.lStructSize == sizeof(OPENFILENAME))
- {
- SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL);
- }
- else /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
- {
- SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL_400);
- }
+ if(m_ofn.lStructSize == sizeof(OPENFILENAME))
+ {
+ SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL);
+ }
+ else /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
+ {
+ SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL_400);
+ }
}
CSaveTextFileDialog::~CSaveTextFileDialog()
@@ -58,38 +58,30 @@ CSaveTextFileDialog::~CSaveTextFileDialog()
void CSaveTextFileDialog::DoDataExchange(CDataExchange* pDX)
{
- DDX_Control(pDX, IDC_COMBO1, m_encoding);
- __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_encoding);
+ __super::DoDataExchange(pDX);
}
BOOL CSaveTextFileDialog::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_encoding.SetItemData(m_encoding.AddString(_T("ANSI")), CTextFile::ASCII);
- m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-LE")), CTextFile::LE16);
- m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-BE")), CTextFile::BE16);
- m_encoding.SetItemData(m_encoding.AddString(_T("UTF-8")), CTextFile::UTF8);
+ m_encoding.SetItemData(m_encoding.AddString(_T("ANSI")), CTextFile::ASCII);
+ m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-LE")), CTextFile::LE16);
+ m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-BE")), CTextFile::BE16);
+ m_encoding.SetItemData(m_encoding.AddString(_T("UTF-8")), CTextFile::UTF8);
- switch(m_e)
- {
- default:
- case CTextFile::ASCII:
- m_encoding.SetCurSel(0);
- break;
- case CTextFile::LE16:
- m_encoding.SetCurSel(1);
- break;
- case CTextFile::BE16:
- m_encoding.SetCurSel(2);
- break;
- case CTextFile::UTF8:
- m_encoding.SetCurSel(3);
- break;
- }
+ switch(m_e)
+ {
+ default:
+ case CTextFile::ASCII: m_encoding.SetCurSel(0); break;
+ case CTextFile::LE16: m_encoding.SetCurSel(1); break;
+ case CTextFile::BE16: m_encoding.SetCurSel(2); break;
+ case CTextFile::UTF8: m_encoding.SetCurSel(3); break;
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CSaveTextFileDialog, CFileDialog)
@@ -99,6 +91,6 @@ END_MESSAGE_MAP()
BOOL CSaveTextFileDialog::OnFileNameOK()
{
- m_e = (CTextFile::enc)m_encoding.GetItemData(m_encoding.GetCurSel());
- return __super::OnFileNameOK();
+ m_e = (CTextFile::enc)m_encoding.GetItemData(m_encoding.GetCurSel());
+ return __super::OnFileNameOK();
}
diff --git a/src/apps/mplayerc/SaveTextFileDialog.h b/src/apps/mplayerc/SaveTextFileDialog.h
index ec39f3f65..0f62bb134 100644
--- a/src/apps/mplayerc/SaveTextFileDialog.h
+++ b/src/apps/mplayerc/SaveTextFileDialog.h
@@ -30,31 +30,28 @@
class CSaveTextFileDialog : public CFileDialog
{
- DECLARE_DYNAMIC(CSaveTextFileDialog)
+ DECLARE_DYNAMIC(CSaveTextFileDialog)
private:
- CTextFile::enc m_e;
+ CTextFile::enc m_e;
public:
- CSaveTextFileDialog(
- CTextFile::enc e,
- LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
- LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
- virtual ~CSaveTextFileDialog();
+ CSaveTextFileDialog(
+ CTextFile::enc e,
+ LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
+ LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
+ virtual ~CSaveTextFileDialog();
- CComboBox m_encoding;
+ CComboBox m_encoding;
- CTextFile::enc GetEncoding()
- {
- return(m_e);
- }
+ CTextFile::enc GetEncoding() {return(m_e);}
protected:
- DECLARE_MESSAGE_MAP()
- virtual void DoDataExchange(CDataExchange* pDX);
- virtual BOOL OnInitDialog();
- virtual BOOL OnFileNameOK();
+ DECLARE_MESSAGE_MAP()
+ virtual void DoDataExchange(CDataExchange* pDX);
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnFileNameOK();
public:
- afx_msg void OnEncodingChange();
+ afx_msg void OnEncodingChange();
};
diff --git a/src/apps/mplayerc/SaveThumbnailsDialog.cpp b/src/apps/mplayerc/SaveThumbnailsDialog.cpp
index 45080b876..11e057483 100644
--- a/src/apps/mplayerc/SaveThumbnailsDialog.cpp
+++ b/src/apps/mplayerc/SaveThumbnailsDialog.cpp
@@ -30,26 +30,26 @@
IMPLEMENT_DYNAMIC(CSaveThumbnailsDialog, CFileDialog)
CSaveThumbnailsDialog::CSaveThumbnailsDialog(
- int rows, int cols, int width,
- LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- LPCTSTR lpszFilter, CWnd* pParentWnd) :
- CFileDialog(FALSE, lpszDefExt, lpszFileName,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
- lpszFilter, pParentWnd, 0
+ int rows, int cols, int width,
+ LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
+ LPCTSTR lpszFilter, CWnd* pParentWnd) :
+ CFileDialog(FALSE, lpszDefExt, lpszFileName,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
+ lpszFilter, pParentWnd, 0
#if (_MSC_VER >= 1500) // <= Parameter added after Visual Studio 2008!
- , FALSE
+ , FALSE
#endif
- ),
- m_rows(rows), m_cols(cols), m_width(width)
+ ),
+ m_rows(rows), m_cols(cols), m_width(width)
{
- if(m_ofn.lStructSize == sizeof(OPENFILENAME))
- {
- SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL);
- }
- else /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
- {
- SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL_400);
- }
+ if(m_ofn.lStructSize == sizeof(OPENFILENAME))
+ {
+ SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL);
+ }
+ else /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
+ {
+ SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL_400);
+ }
}
CSaveThumbnailsDialog::~CSaveThumbnailsDialog()
@@ -58,25 +58,25 @@ CSaveThumbnailsDialog::~CSaveThumbnailsDialog()
void CSaveThumbnailsDialog::DoDataExchange(CDataExchange* pDX)
{
- DDX_Control(pDX, IDC_SPIN1, m_rowsctrl);
- DDX_Control(pDX, IDC_SPIN2, m_colsctrl);
- DDX_Control(pDX, IDC_SPIN3, m_widthctrl);
- __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_SPIN1, m_rowsctrl);
+ DDX_Control(pDX, IDC_SPIN2, m_colsctrl);
+ DDX_Control(pDX, IDC_SPIN3, m_widthctrl);
+ __super::DoDataExchange(pDX);
}
BOOL CSaveThumbnailsDialog::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_rowsctrl.SetRange(1, 8);
- m_colsctrl.SetRange(1, 8);
- m_widthctrl.SetRange(256, 2048);
- m_rowsctrl.SetPos(m_rows);
- m_colsctrl.SetPos(m_cols);
- m_widthctrl.SetPos(m_width);
+ m_rowsctrl.SetRange(1, 8);
+ m_colsctrl.SetRange(1, 8);
+ m_widthctrl.SetRange(256, 2048);
+ m_rowsctrl.SetPos(m_rows);
+ m_colsctrl.SetPos(m_cols);
+ m_widthctrl.SetPos(m_width);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CSaveThumbnailsDialog, CFileDialog)
@@ -86,9 +86,9 @@ END_MESSAGE_MAP()
BOOL CSaveThumbnailsDialog::OnFileNameOK()
{
- m_rows = m_rowsctrl.GetPos();
- m_cols = m_colsctrl.GetPos();
- m_width = m_widthctrl.GetPos();
+ m_rows = m_rowsctrl.GetPos();
+ m_cols = m_colsctrl.GetPos();
+ m_width = m_widthctrl.GetPos();
- return __super::OnFileNameOK();
+ return __super::OnFileNameOK();
}
diff --git a/src/apps/mplayerc/SaveThumbnailsDialog.h b/src/apps/mplayerc/SaveThumbnailsDialog.h
index e82552dd6..d8e12fcd4 100644
--- a/src/apps/mplayerc/SaveThumbnailsDialog.h
+++ b/src/apps/mplayerc/SaveThumbnailsDialog.h
@@ -28,24 +28,24 @@
class CSaveThumbnailsDialog : public CFileDialog
{
- DECLARE_DYNAMIC(CSaveThumbnailsDialog)
+ DECLARE_DYNAMIC(CSaveThumbnailsDialog)
public:
- CSaveThumbnailsDialog(
- int rows, int cols, int width,
- LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
- LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
- virtual ~CSaveThumbnailsDialog();
+ CSaveThumbnailsDialog(
+ int rows, int cols, int width,
+ LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
+ LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
+ virtual ~CSaveThumbnailsDialog();
protected:
- DECLARE_MESSAGE_MAP()
- virtual void DoDataExchange(CDataExchange* pDX);
- virtual BOOL OnInitDialog();
- virtual BOOL OnFileNameOK();
+ DECLARE_MESSAGE_MAP()
+ virtual void DoDataExchange(CDataExchange* pDX);
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnFileNameOK();
public:
- int m_rows, m_cols, m_width;
- CSpinButtonCtrl m_rowsctrl;
- CSpinButtonCtrl m_colsctrl;
- CSpinButtonCtrl m_widthctrl;
+ int m_rows, m_cols, m_width;
+ CSpinButtonCtrl m_rowsctrl;
+ CSpinButtonCtrl m_colsctrl;
+ CSpinButtonCtrl m_widthctrl;
};
diff --git a/src/apps/mplayerc/SelectMediaType.cpp b/src/apps/mplayerc/SelectMediaType.cpp
index 850ccb4cd..192dc1d1f 100644
--- a/src/apps/mplayerc/SelectMediaType.cpp
+++ b/src/apps/mplayerc/SelectMediaType.cpp
@@ -31,10 +31,10 @@
IMPLEMENT_DYNAMIC(CSelectMediaType, CCmdUIDialog)
CSelectMediaType::CSelectMediaType(CAtlArray<GUID>& guids, GUID guid, CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CSelectMediaType::IDD, pParent)
- , m_guids(guids), m_guid(guid)
+ : CCmdUIDialog(CSelectMediaType::IDD, pParent)
+ , m_guids(guids), m_guid(guid)
{
- m_guidstr = CStringFromGUID(guid);
+ m_guidstr = CStringFromGUID(guid);
}
CSelectMediaType::~CSelectMediaType()
@@ -43,15 +43,15 @@ CSelectMediaType::~CSelectMediaType()
void CSelectMediaType::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_CBString(pDX, IDC_COMBO1, m_guidstr);
- DDX_Control(pDX, IDC_COMBO1, m_guidsctrl);
+ __super::DoDataExchange(pDX);
+ DDX_CBString(pDX, IDC_COMBO1, m_guidstr);
+ DDX_Control(pDX, IDC_COMBO1, m_guidsctrl);
}
BEGIN_MESSAGE_MAP(CSelectMediaType, CCmdUIDialog)
- ON_CBN_EDITCHANGE(IDC_COMBO1, OnCbnEditchangeCombo1)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
+ ON_CBN_EDITCHANGE(IDC_COMBO1, OnCbnEditchangeCombo1)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
END_MESSAGE_MAP()
@@ -59,42 +59,42 @@ END_MESSAGE_MAP()
BOOL CSelectMediaType::OnInitDialog()
{
- CCmdUIDialog::OnInitDialog();
+ CCmdUIDialog::OnInitDialog();
- for(int i = 0; i < m_guids.GetCount(); i++)
- {
- m_guidsctrl.AddString(GetMediaTypeName(m_guids[i]));
- }
+ for(int i = 0; i < m_guids.GetCount(); i++)
+ {
+ m_guidsctrl.AddString(GetMediaTypeName(m_guids[i]));
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CSelectMediaType::OnCbnEditchangeCombo1()
{
- UpdateData();
- int i = m_guidsctrl.FindStringExact(0, m_guidstr);
- if(i >= 0)
- {
- DWORD sel = m_guidsctrl.GetEditSel();
- m_guidsctrl.SetCurSel(i);
- m_guidsctrl.SetEditSel(sel, sel);
- }
+ UpdateData();
+ int i = m_guidsctrl.FindStringExact(0, m_guidstr);
+ if(i >= 0)
+ {
+ DWORD sel = m_guidsctrl.GetEditSel();
+ m_guidsctrl.SetCurSel(i);
+ m_guidsctrl.SetEditSel(sel,sel);
+ }
}
void CSelectMediaType::OnUpdateOK(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(!m_guidstr.IsEmpty() && (m_guidsctrl.GetCurSel() >= 0 || GUIDFromCString(m_guidstr) != GUID_NULL));
+ pCmdUI->Enable(!m_guidstr.IsEmpty() && (m_guidsctrl.GetCurSel() >= 0 || GUIDFromCString(m_guidstr) != GUID_NULL));
}
void CSelectMediaType::OnOK()
{
- UpdateData();
+ UpdateData();
- int i = m_guidsctrl.GetCurSel();
- m_guid = i >= 0 ? m_guids[i] : GUIDFromCString(m_guidstr);
+ int i = m_guidsctrl.GetCurSel();
+ m_guid = i >= 0 ? m_guids[i] : GUIDFromCString(m_guidstr);
- CCmdUIDialog::OnOK();
+ CCmdUIDialog::OnOK();
}
diff --git a/src/apps/mplayerc/SelectMediaType.h b/src/apps/mplayerc/SelectMediaType.h
index e9a1f61d0..f87e38e6e 100644
--- a/src/apps/mplayerc/SelectMediaType.h
+++ b/src/apps/mplayerc/SelectMediaType.h
@@ -30,29 +30,29 @@
class CSelectMediaType : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CSelectMediaType)
+ DECLARE_DYNAMIC(CSelectMediaType)
private:
- CAtlArray<GUID>& m_guids;
+ CAtlArray<GUID>& m_guids;
public:
- CSelectMediaType(CAtlArray<GUID>& guids, GUID guid, CWnd* pParent = NULL); // standard constructor
- virtual ~CSelectMediaType();
+ CSelectMediaType(CAtlArray<GUID>& guids, GUID guid, CWnd* pParent = NULL); // standard constructor
+ virtual ~CSelectMediaType();
- GUID m_guid;
+ GUID m_guid;
// Dialog Data
- enum { IDD = IDD_SELECTMEDIATYPE };
- CString m_guidstr;
- CComboBox m_guidsctrl;
+ enum { IDD = IDD_SELECTMEDIATYPE };
+ CString m_guidstr;
+ CComboBox m_guidsctrl;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnCbnEditchangeCombo1();
- afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
+ afx_msg void OnCbnEditchangeCombo1();
+ afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp b/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
index 741e02b0e..7dc6f0a70 100644
--- a/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
+++ b/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
@@ -29,89 +29,89 @@
// CShaderAutoCompleteDlg dialog
CShaderAutoCompleteDlg::CShaderAutoCompleteDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CShaderAutoCompleteDlg::IDD, pParent)
+ : CResizableDialog(CShaderAutoCompleteDlg::IDD, pParent)
{
- m_text[0] = 0;
-
- m_inst[_T("abs")] = _T("abs(value a)|Absolute value (per component). ");
- m_inst[_T("acos")] = _T("acos(x)|Returns the arccosine of each component of x. Each component should be in the range [-1, 1]. ");
- m_inst[_T("all")] = _T("all(x)|Test if all components of x are nonzero. ");
- m_inst[_T("any")] = _T("any(x)|Test is any component of x is nonzero. ");
- m_inst[_T("asin")] = _T("asin(x)|Returns the arcsine of each component of x. Each component should be in the range [-pi/2, pi/2]. ");
- m_inst[_T("atan")] = _T("atan(x)|Returns the arctangent of x. The return values are in the range [-pi/2, pi/2]. ");
- m_inst[_T("atan2")] = _T("atan2(y, x)|Returns the arctangent of y/x. The signs of y and x are used to determine the quadrant of the return values in the range [-pi, pi]. atan2 is well-defined for every point other than the origin, even if x equals 0 and y does not equal 0. ");
- m_inst[_T("ceil")] = _T("ceil(x)|Returns the smallest integer which is greater than or equal to x. ");
- m_inst[_T("clamp")] = _T("clamp(x, min, max)|Clamps x to the range [min, max]. ");
- m_inst[_T("clip")] = _T("clip(x)|Discards the current pixel, if any component of x is less than zero. This can be used to simulate clip planes, if each component of x represents the distance from a plane. ");
- m_inst[_T("cos")] = _T("cos(x)|Returns the cosine of x. ");
- m_inst[_T("cosh")] = _T("cosh(x)|Returns the hyperbolic cosine of x. ");
- m_inst[_T("cross")] = _T("cross(a, b)|Returns the cross product of two 3-D vectors a and b. ");
- m_inst[_T("d3dcolortoubyte4")] = _T("D3DCOLORtoUBYTE4(x)|Swizzles and scales components of the 4-D vector x to compensate for the lack of UBYTE4 support in some hardware. ");
- m_inst[_T("ddx")] = _T("ddx(x)|Returns the partial derivative of x with respect to the screen-space x-coordinate. ");
- m_inst[_T("ddy")] = _T("ddy(x)|Returns the partial derivative of x with respect to the screen-space y-coordinate. ");
- m_inst[_T("degrees")] = _T("degrees(x)|Converts x from radians to degrees. ");
- m_inst[_T("determinant")] = _T("determinant(m)|Returns the determinant of the square matrix m. ");
- m_inst[_T("distance")] = _T("distance(a, b)|Returns the distance between two points a and b. ");
- m_inst[_T("dot")] = _T("dot(a, b)|Returns the dot product of two vectors a and b. ");
- m_inst[_T("exp")] = _T("exp(x)|Returns the base-e exponent ex. ");
- m_inst[_T("exp2")] = _T("exp2(value a)|Base 2 Exp (per component). ");
- m_inst[_T("faceforward")] = _T("faceforward(n, i, ng)|Returns -n * sign(dot(i, ng)). ");
- m_inst[_T("floor")] = _T("floor(x)|Returns the greatest integer which is less than or equal to x. ");
- m_inst[_T("fmod")] = _T("fmod(a, b)|Returns the floating point remainder f of a / b such that a = i * b + f, where i is an integer, f has the same sign as x, and the absolute value of f is less than the absolute value of b. ");
- m_inst[_T("frac")] = _T("frac(x)|Returns the fractional part f of x, such that f is a value greater than or equal to 0, and less than 1. ");
- m_inst[_T("frc")] = _T("frc(value a)|Fractional part (per component). ");
- m_inst[_T("frexp")] = _T("frexp(x, out exp)|Returns the mantissa and exponent of x. frexp returns the mantissa, and the exponent is stored in the output parameter exp. If x is 0, the function returns 0 for both the mantissa and the exponent. ");
- m_inst[_T("fwidth")] = _T("fwidth(x)|Returns abs(ddx(x))+abs(ddy(x)). ");
- m_inst[_T("isfinite")] = _T("isfinite(x)|Returns true if x is finite, false otherwise. ");
- m_inst[_T("isinf")] = _T("isinf(x)|Returns true if x is +INF or -INF, false otherwise. ");
- m_inst[_T("isnan")] = _T("isnan(x)|Returns true if x is NAN or QNAN, false otherwise. ");
- m_inst[_T("ldexp")] = _T("ldexp(x, exp)|Returns x * 2exp. ");
- m_inst[_T("len")] = _T("len(value a)|Vector length. ");
- m_inst[_T("length")] = _T("length(v)|Returns the length of the vector v. ");
- m_inst[_T("lerp")] = _T("lerp(a, b, s)|Returns a + s(b - a). This linearly interpolates between a and b, such that the return value is a when s is 0, and b when s is 1. ");
- m_inst[_T("lit")] = _T("lit(ndotl, ndoth, m)|Returns a lighting vector (ambient, diffuse, specular, 1): ambient = 1; diffuse = (ndotl < 0) ? 0 : ndotl; specular = (ndotl < 0) || (ndoth < 0) ? 0 : (ndoth * m); ");
- m_inst[_T("log")] = _T("log(x)|Returns the base-e logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
- m_inst[_T("log10")] = _T("log10(x)|Returns the base-10 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
- m_inst[_T("log2")] = _T("log2(x)|Returns the base-2 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
- m_inst[_T("max")] = _T("max(a, b)|Selects the greater of a and b. ");
- m_inst[_T("min")] = _T("min(a, b)|Selects the lesser of a and b. ");
- m_inst[_T("modf")] = _T("modf(x, out ip)|Splits the value x into fractional and integer parts, each of which has the same sign and x. The signed fractional portion of x is returned. The integer portion is stored in the output parameter ip. ");
- m_inst[_T("mul")] = _T("mul(a, b)|Performs matrix multiplication between a and b. If a is a vector, it treated as a row vector. If b is a vector, it is treated as a column vector. The inner dimension acolumns and brows must be equal. The result has the dimension arows x bcolumns. ");
- m_inst[_T("noise")] = _T("noise(x)|Not yet implemented. ");
- m_inst[_T("normalize")] = _T("normalize(v)|Returns the normalized vector v / length(v). If the length of v is 0, the result is indefinite. ");
- m_inst[_T("pow")] = _T("pow(x, y)|Returns xy. ");
- m_inst[_T("radians")] = _T("radians(x)|Converts x from degrees to radians. ");
- m_inst[_T("reflect")] = _T("reflect(i, n)|Returns the reflection vector v, given the entering ray direction i, and the surface normal n. Such that v = i - 2 * dot(i, n) * n ");
- m_inst[_T("refract")] = _T("refract(i, n, eta)|Returns the refraction vector v, given the entering ray direction i, the surface normal n, and the relative index of refraction eta. If the angle between i and n is too great for a given eta, refract returns (0,0,0). ");
- m_inst[_T("round")] = _T("round(x)|Rounds x to the nearest integer. ");
- m_inst[_T("rsqrt")] = _T("rsqrt(x)|Returns 1 / sqrt(x). ");
- m_inst[_T("saturate")] = _T("saturate(x)|Clamps x to the range [0, 1]. ");
- m_inst[_T("sign")] = _T("sign(x)|Computes the sign of x. Returns -1 if x is less than 0, 0 if x equals 0, and 1 if x is greater than zero. ");
- m_inst[_T("sin")] = _T("sin(x)|Returns the sine of x. ");
- m_inst[_T("sincos")] = _T("sincos(x, out s, out c)|Returns the sine and cosine of x. sin(x) is stored in the output parameter s. cos(x) is stored in the output parameter c. ");
- m_inst[_T("sinh")] = _T("sinh(x)|Returns the hyperbolic sine of x. ");
- m_inst[_T("smoothstep")] = _T("smoothstep(min, max, x)|Returns 0 if x < min. Returns 1 if x > max. Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [min, max]. ");
- m_inst[_T("sqrt")] = _T("sqrt(value a)|Square root (per component). ");
- m_inst[_T("step")] = _T("step(a, x)|Returns (x >= a) ? 1 : 0. ");
- m_inst[_T("tan")] = _T("tan(x)|Returns the tangent of x. ");
- m_inst[_T("tanh")] = _T("tanh(x)|Returns the hyperbolic tangent of x. ");
- m_inst[_T("tex1d")] = _T("tex1D(s, t)|1-D texture lookup. s is a sampler or a sampler1D object. t is a scalar. ");
- m_inst[_T("tex1d(")] = _T("tex1D(s, t, ddx, ddy)|1-D texture lookup, with derivatives. s is a sampler or sampler1D object. t, ddx, and ddy are scalars. ");
- m_inst[_T("tex1dproj")] = _T("tex1Dproj(s, t)|1-D projective texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("tex1dbias")] = _T("tex1Dbias(s, t)|1-D biased texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("tex2d")] = _T("tex2D(s, t)|2-D texture lookup. s is a sampler or a sampler2D object. t is a 2-D texture coordinate. ");
- m_inst[_T("tex2d(")] = _T("tex2D(s, t, ddx, ddy)|2-D texture lookup, with derivatives. s is a sampler or sampler2D object. t, ddx, and ddy are 2-D vectors. ");
- m_inst[_T("tex2dproj")] = _T("tex2Dproj(s, t)|2-D projective texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("tex2dbias")] = _T("tex2Dbias(s, t)|2-D biased texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("tex3d")] = _T("tex3D(s, t)|3-D volume texture lookup. s is a sampler or a sampler3D object. t is a 3-D texture coordinate. ");
- m_inst[_T("tex3d(")] = _T("tex3D(s, t, ddx, ddy)|3-D volume texture lookup, with derivatives. s is a sampler or sampler3D object. t, ddx, and ddy are 3-D vectors. ");
- m_inst[_T("tex3dproj")] = _T("tex3Dproj(s, t)|3-D projective volume texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("tex3dbias")] = _T("tex3Dbias(s, t)|3-D biased texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("texcube")] = _T("texCUBE(s, t)|3-D cube texture lookup. s is a sampler or a samplerCUBE object. t is a 3-D texture coordinate. ");
- m_inst[_T("texcube(")] = _T("texCUBE(s, t, ddx, ddy)|3-D cube texture lookup, with derivatives. s is a sampler or samplerCUBE object. t, ddx, and ddy are 3-D vectors. ");
- m_inst[_T("texcubeproj")] = _T("texCUBEproj(s, t)|3-D projective cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("texcubebias")] = _T("texCUBEbias(s, t)|3-D biased cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-dimensional vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("transpose")] = _T("transpose(m)|Returns the transpose of the matrix m. If the source is dimension mrows x mcolumns, the result is dimension mcolumns x mrows. ");
+ m_text[0] = 0;
+
+ m_inst[_T("abs")] = _T("abs(value a)|Absolute value (per component). ");
+ m_inst[_T("acos")] = _T("acos(x)|Returns the arccosine of each component of x. Each component should be in the range [-1, 1]. ");
+ m_inst[_T("all")] = _T("all(x)|Test if all components of x are nonzero. ");
+ m_inst[_T("any")] = _T("any(x)|Test is any component of x is nonzero. ");
+ m_inst[_T("asin")] = _T("asin(x)|Returns the arcsine of each component of x. Each component should be in the range [-pi/2, pi/2]. ");
+ m_inst[_T("atan")] = _T("atan(x)|Returns the arctangent of x. The return values are in the range [-pi/2, pi/2]. ");
+ m_inst[_T("atan2")] = _T("atan2(y, x)|Returns the arctangent of y/x. The signs of y and x are used to determine the quadrant of the return values in the range [-pi, pi]. atan2 is well-defined for every point other than the origin, even if x equals 0 and y does not equal 0. ");
+ m_inst[_T("ceil")] = _T("ceil(x)|Returns the smallest integer which is greater than or equal to x. ");
+ m_inst[_T("clamp")] = _T("clamp(x, min, max)|Clamps x to the range [min, max]. ");
+ m_inst[_T("clip")] = _T("clip(x)|Discards the current pixel, if any component of x is less than zero. This can be used to simulate clip planes, if each component of x represents the distance from a plane. ");
+ m_inst[_T("cos")] = _T("cos(x)|Returns the cosine of x. ");
+ m_inst[_T("cosh")] = _T("cosh(x)|Returns the hyperbolic cosine of x. ");
+ m_inst[_T("cross")] = _T("cross(a, b)|Returns the cross product of two 3-D vectors a and b. ");
+ m_inst[_T("d3dcolortoubyte4")] = _T("D3DCOLORtoUBYTE4(x)|Swizzles and scales components of the 4-D vector x to compensate for the lack of UBYTE4 support in some hardware. ");
+ m_inst[_T("ddx")] = _T("ddx(x)|Returns the partial derivative of x with respect to the screen-space x-coordinate. ");
+ m_inst[_T("ddy")] = _T("ddy(x)|Returns the partial derivative of x with respect to the screen-space y-coordinate. ");
+ m_inst[_T("degrees")] = _T("degrees(x)|Converts x from radians to degrees. ");
+ m_inst[_T("determinant")] = _T("determinant(m)|Returns the determinant of the square matrix m. ");
+ m_inst[_T("distance")] = _T("distance(a, b)|Returns the distance between two points a and b. ");
+ m_inst[_T("dot")] = _T("dot(a, b)|Returns the dot product of two vectors a and b. ");
+ m_inst[_T("exp")] = _T("exp(x)|Returns the base-e exponent ex. ");
+ m_inst[_T("exp2")] = _T("exp2(value a)|Base 2 Exp (per component). ");
+ m_inst[_T("faceforward")] = _T("faceforward(n, i, ng)|Returns -n * sign(dot(i, ng)). ");
+ m_inst[_T("floor")] = _T("floor(x)|Returns the greatest integer which is less than or equal to x. ");
+ m_inst[_T("fmod")] = _T("fmod(a, b)|Returns the floating point remainder f of a / b such that a = i * b + f, where i is an integer, f has the same sign as x, and the absolute value of f is less than the absolute value of b. ");
+ m_inst[_T("frac")] = _T("frac(x)|Returns the fractional part f of x, such that f is a value greater than or equal to 0, and less than 1. ");
+ m_inst[_T("frc")] = _T("frc(value a)|Fractional part (per component). ");
+ m_inst[_T("frexp")] = _T("frexp(x, out exp)|Returns the mantissa and exponent of x. frexp returns the mantissa, and the exponent is stored in the output parameter exp. If x is 0, the function returns 0 for both the mantissa and the exponent. ");
+ m_inst[_T("fwidth")] = _T("fwidth(x)|Returns abs(ddx(x))+abs(ddy(x)). ");
+ m_inst[_T("isfinite")] = _T("isfinite(x)|Returns true if x is finite, false otherwise. ");
+ m_inst[_T("isinf")] = _T("isinf(x)|Returns true if x is +INF or -INF, false otherwise. ");
+ m_inst[_T("isnan")] = _T("isnan(x)|Returns true if x is NAN or QNAN, false otherwise. ");
+ m_inst[_T("ldexp")] = _T("ldexp(x, exp)|Returns x * 2exp. ");
+ m_inst[_T("len")] = _T("len(value a)|Vector length. ");
+ m_inst[_T("length")] = _T("length(v)|Returns the length of the vector v. ");
+ m_inst[_T("lerp")] = _T("lerp(a, b, s)|Returns a + s(b - a). This linearly interpolates between a and b, such that the return value is a when s is 0, and b when s is 1. ");
+ m_inst[_T("lit")] = _T("lit(ndotl, ndoth, m)|Returns a lighting vector (ambient, diffuse, specular, 1): ambient = 1; diffuse = (ndotl < 0) ? 0 : ndotl; specular = (ndotl < 0) || (ndoth < 0) ? 0 : (ndoth * m); ");
+ m_inst[_T("log")] = _T("log(x)|Returns the base-e logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
+ m_inst[_T("log10")] = _T("log10(x)|Returns the base-10 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
+ m_inst[_T("log2")] = _T("log2(x)|Returns the base-2 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
+ m_inst[_T("max")] = _T("max(a, b)|Selects the greater of a and b. ");
+ m_inst[_T("min")] = _T("min(a, b)|Selects the lesser of a and b. ");
+ m_inst[_T("modf")] = _T("modf(x, out ip)|Splits the value x into fractional and integer parts, each of which has the same sign and x. The signed fractional portion of x is returned. The integer portion is stored in the output parameter ip. ");
+ m_inst[_T("mul")] = _T("mul(a, b)|Performs matrix multiplication between a and b. If a is a vector, it treated as a row vector. If b is a vector, it is treated as a column vector. The inner dimension acolumns and brows must be equal. The result has the dimension arows x bcolumns. ");
+ m_inst[_T("noise")] = _T("noise(x)|Not yet implemented. ");
+ m_inst[_T("normalize")] = _T("normalize(v)|Returns the normalized vector v / length(v). If the length of v is 0, the result is indefinite. ");
+ m_inst[_T("pow")] = _T("pow(x, y)|Returns xy. ");
+ m_inst[_T("radians")] = _T("radians(x)|Converts x from degrees to radians. ");
+ m_inst[_T("reflect")] = _T("reflect(i, n)|Returns the reflection vector v, given the entering ray direction i, and the surface normal n. Such that v = i - 2 * dot(i, n) * n ");
+ m_inst[_T("refract")] = _T("refract(i, n, eta)|Returns the refraction vector v, given the entering ray direction i, the surface normal n, and the relative index of refraction eta. If the angle between i and n is too great for a given eta, refract returns (0,0,0). ");
+ m_inst[_T("round")] = _T("round(x)|Rounds x to the nearest integer. ");
+ m_inst[_T("rsqrt")] = _T("rsqrt(x)|Returns 1 / sqrt(x). ");
+ m_inst[_T("saturate")] = _T("saturate(x)|Clamps x to the range [0, 1]. ");
+ m_inst[_T("sign")] = _T("sign(x)|Computes the sign of x. Returns -1 if x is less than 0, 0 if x equals 0, and 1 if x is greater than zero. ");
+ m_inst[_T("sin")] = _T("sin(x)|Returns the sine of x. ");
+ m_inst[_T("sincos")] = _T("sincos(x, out s, out c)|Returns the sine and cosine of x. sin(x) is stored in the output parameter s. cos(x) is stored in the output parameter c. ");
+ m_inst[_T("sinh")] = _T("sinh(x)|Returns the hyperbolic sine of x. ");
+ m_inst[_T("smoothstep")] = _T("smoothstep(min, max, x)|Returns 0 if x < min. Returns 1 if x > max. Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [min, max]. ");
+ m_inst[_T("sqrt")] = _T("sqrt(value a)|Square root (per component). ");
+ m_inst[_T("step")] = _T("step(a, x)|Returns (x >= a) ? 1 : 0. ");
+ m_inst[_T("tan")] = _T("tan(x)|Returns the tangent of x. ");
+ m_inst[_T("tanh")] = _T("tanh(x)|Returns the hyperbolic tangent of x. ");
+ m_inst[_T("tex1d")] = _T("tex1D(s, t)|1-D texture lookup. s is a sampler or a sampler1D object. t is a scalar. ");
+ m_inst[_T("tex1d(")] = _T("tex1D(s, t, ddx, ddy)|1-D texture lookup, with derivatives. s is a sampler or sampler1D object. t, ddx, and ddy are scalars. ");
+ m_inst[_T("tex1dproj")] = _T("tex1Dproj(s, t)|1-D projective texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("tex1dbias")] = _T("tex1Dbias(s, t)|1-D biased texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("tex2d")] = _T("tex2D(s, t)|2-D texture lookup. s is a sampler or a sampler2D object. t is a 2-D texture coordinate. ");
+ m_inst[_T("tex2d(")] = _T("tex2D(s, t, ddx, ddy)|2-D texture lookup, with derivatives. s is a sampler or sampler2D object. t, ddx, and ddy are 2-D vectors. ");
+ m_inst[_T("tex2dproj")] = _T("tex2Dproj(s, t)|2-D projective texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("tex2dbias")] = _T("tex2Dbias(s, t)|2-D biased texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("tex3d")] = _T("tex3D(s, t)|3-D volume texture lookup. s is a sampler or a sampler3D object. t is a 3-D texture coordinate. ");
+ m_inst[_T("tex3d(")] = _T("tex3D(s, t, ddx, ddy)|3-D volume texture lookup, with derivatives. s is a sampler or sampler3D object. t, ddx, and ddy are 3-D vectors. ");
+ m_inst[_T("tex3dproj")] = _T("tex3Dproj(s, t)|3-D projective volume texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("tex3dbias")] = _T("tex3Dbias(s, t)|3-D biased texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("texcube")] = _T("texCUBE(s, t)|3-D cube texture lookup. s is a sampler or a samplerCUBE object. t is a 3-D texture coordinate. ");
+ m_inst[_T("texcube(")] = _T("texCUBE(s, t, ddx, ddy)|3-D cube texture lookup, with derivatives. s is a sampler or samplerCUBE object. t, ddx, and ddy are 3-D vectors. ");
+ m_inst[_T("texcubeproj")] = _T("texCUBEproj(s, t)|3-D projective cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("texcubebias")] = _T("texCUBEbias(s, t)|3-D biased cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-dimensional vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("transpose")] = _T("transpose(m)|Returns the transpose of the matrix m. If the source is dimension mrows x mcolumns, the result is dimension mcolumns x mrows. ");
}
CShaderAutoCompleteDlg::~CShaderAutoCompleteDlg()
@@ -120,15 +120,15 @@ CShaderAutoCompleteDlg::~CShaderAutoCompleteDlg()
void CShaderAutoCompleteDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BEGIN_MESSAGE_MAP(CShaderAutoCompleteDlg, CResizableDialog)
- ON_WM_SETFOCUS()
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_WM_SHOWWINDOW()
+ ON_WM_SETFOCUS()
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_WM_SHOWWINDOW()
END_MESSAGE_MAP()
@@ -136,64 +136,64 @@ END_MESSAGE_MAP()
BOOL CShaderAutoCompleteDlg::OnInitDialog()
{
- CResizableDialog::OnInitDialog();
+ CResizableDialog::OnInitDialog();
- AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
- m_hToolTipWnd = CreateWindowEx(
- WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- NULL, NULL, NULL, NULL);
+ m_hToolTipWnd = CreateWindowEx(
+ WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL, NULL, NULL, NULL);
- memset(&m_ti, 0, sizeof(m_ti));
- m_ti.cbSize = sizeof(TOOLINFO);
- m_ti.uFlags = TTF_ABSOLUTE | TTF_TRACK;
- m_ti.hwnd = m_hWnd;
- m_ti.lpszText = m_text;
+ memset(&m_ti, 0, sizeof(m_ti));
+ m_ti.cbSize = sizeof(TOOLINFO);
+ m_ti.uFlags = TTF_ABSOLUTE|TTF_TRACK;
+ m_ti.hwnd = m_hWnd;
+ m_ti.lpszText = m_text;
- ::SendMessage(m_hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&m_ti);
- ::SendMessage(m_hToolTipWnd, TTM_SETMAXTIPWIDTH, 0, (LPARAM)400);
+ ::SendMessage(m_hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&m_ti);
+ ::SendMessage(m_hToolTipWnd, TTM_SETMAXTIPWIDTH, 0, (LPARAM)400);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CShaderAutoCompleteDlg::OnSetFocus(CWnd* pOldWnd)
{
- __super::OnSetFocus(pOldWnd);
+ __super::OnSetFocus(pOldWnd);
- GetParent()->SetFocus();
+ GetParent()->SetFocus();
}
void CShaderAutoCompleteDlg::OnLbnSelchangeList1()
{
- ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
-
- int i = m_list.GetCurSel();
- if(i < 0) return;
-
- if(POSITION pos = (POSITION)m_list.GetItemData(i))
- {
- CString str, desc;
- m_inst.GetNextAssoc(pos, str, desc);
- CAtlList<CString> sl;
- Explode(desc, sl, '|', 2);
- if(sl.GetCount() != 2) return;
- _tcscpy(m_ti.lpszText, sl.RemoveTail());
- CRect r;
- GetWindowRect(r);
- ::SendMessage(m_hToolTipWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)&m_ti);
- ::SendMessage(m_hToolTipWnd, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(r.left, r.bottom + 1));
- ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, TRUE, (LPARAM)&m_ti);
- }
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
+
+ int i = m_list.GetCurSel();
+ if(i < 0) return;
+
+ if(POSITION pos = (POSITION)m_list.GetItemData(i))
+ {
+ CString str, desc;
+ m_inst.GetNextAssoc(pos, str, desc);
+ CAtlList<CString> sl;
+ Explode(desc, sl, '|', 2);
+ if(sl.GetCount() != 2) return;
+ _tcscpy(m_ti.lpszText, sl.RemoveTail());
+ CRect r;
+ GetWindowRect(r);
+ ::SendMessage(m_hToolTipWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)&m_ti);
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(r.left, r.bottom+1));
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, TRUE, (LPARAM)&m_ti);
+ }
}
void CShaderAutoCompleteDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
- CResizableDialog::OnShowWindow(bShow, nStatus);
+ CResizableDialog::OnShowWindow(bShow, nStatus);
- if(!bShow)
- {
- ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
- }
+ if(!bShow)
+ {
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
+ }
}
diff --git a/src/apps/mplayerc/ShaderAutoCompleteDlg.h b/src/apps/mplayerc/ShaderAutoCompleteDlg.h
index 36d392612..14eda44e1 100644
--- a/src/apps/mplayerc/ShaderAutoCompleteDlg.h
+++ b/src/apps/mplayerc/ShaderAutoCompleteDlg.h
@@ -30,28 +30,28 @@
class CShaderAutoCompleteDlg : public CResizableDialog
{
- TOOLINFO m_ti;
- HWND m_hToolTipWnd;
- TCHAR m_text[1024];
+ TOOLINFO m_ti;
+ HWND m_hToolTipWnd;
+ TCHAR m_text[1024];
public:
- CShaderAutoCompleteDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CShaderAutoCompleteDlg();
+ CShaderAutoCompleteDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CShaderAutoCompleteDlg();
- CMap<CString, LPCTSTR, CString, CString> m_inst;
+ CMap<CString, LPCTSTR, CString, CString> m_inst;
// Dialog Data
- enum { IDD = IDD_SHADERAUTOCOMPLETE_DLG };
+ enum { IDD = IDD_SHADERAUTOCOMPLETE_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CListBox m_list;
- virtual BOOL OnInitDialog();
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+ CListBox m_list;
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
};
diff --git a/src/apps/mplayerc/ShaderCombineDlg.cpp b/src/apps/mplayerc/ShaderCombineDlg.cpp
index 7eda83cf0..2af886ba7 100644
--- a/src/apps/mplayerc/ShaderCombineDlg.cpp
+++ b/src/apps/mplayerc/ShaderCombineDlg.cpp
@@ -28,9 +28,9 @@
// CShaderCombineDlg dialog
CShaderCombineDlg::CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent , bool bScreenSpace)
- : CResizableDialog(CShaderCombineDlg::IDD, pParent)
- , m_labels(labels)
- , m_bScreenSpace(bScreenSpace)
+ : CResizableDialog(CShaderCombineDlg::IDD, pParent)
+ , m_labels(labels)
+ , m_bScreenSpace(bScreenSpace)
{
}
@@ -40,120 +40,120 @@ CShaderCombineDlg::~CShaderCombineDlg()
void CShaderCombineDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Control(pDX, IDC_COMBO1, m_combo);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list);
+ DDX_Control(pDX, IDC_COMBO1, m_combo);
}
BEGIN_MESSAGE_MAP(CShaderCombineDlg, CResizableDialog)
- ON_BN_CLICKED(IDC_BUTTON2, &CShaderCombineDlg::OnBnClickedButton12)
- ON_BN_CLICKED(IDC_BUTTON3, &CShaderCombineDlg::OnBnClickedButton13)
- ON_BN_CLICKED(IDC_BUTTON1, &CShaderCombineDlg::OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON4, &CShaderCombineDlg::OnBnClickedButton11)
+ ON_BN_CLICKED(IDC_BUTTON2, &CShaderCombineDlg::OnBnClickedButton12)
+ ON_BN_CLICKED(IDC_BUTTON3, &CShaderCombineDlg::OnBnClickedButton13)
+ ON_BN_CLICKED(IDC_BUTTON1, &CShaderCombineDlg::OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON4, &CShaderCombineDlg::OnBnClickedButton11)
END_MESSAGE_MAP()
// CShaderCombineDlg message handlers
BOOL CShaderCombineDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_COMBO1, BOTTOM_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_STATIC1, BOTTOM_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON2, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON3, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
- AddAnchor(IDC_BUTTON4, TOP_RIGHT);
- AddAnchor(IDOK, TOP_RIGHT);
- AddAnchor(IDCANCEL, TOP_RIGHT);
-
- AppSettings& s = AfxGetAppSettings();
-
- CString str;
- if(m_bScreenSpace)
- str = s.m_shadercombineScreenSpace.Trim();
- else
- str = s.m_shadercombine.Trim();
-
- CAtlList<CString> sl;
- if(!str.IsEmpty()) Explode(str, sl, '|');
-
- POSITION pos = sl.GetHeadPosition();
- while(pos) m_list.AddString(sl.GetNext(pos));
-
- pos = s.m_shaders.GetHeadPosition();
- while(pos) m_combo.AddString(s.m_shaders.GetNext(pos).label);
- if(m_combo.GetCount()) m_combo.SetCurSel(0);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_COMBO1, BOTTOM_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_STATIC1, BOTTOM_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON2, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON3, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON4, TOP_RIGHT);
+ AddAnchor(IDOK, TOP_RIGHT);
+ AddAnchor(IDCANCEL, TOP_RIGHT);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CString str;
+ if (m_bScreenSpace)
+ str = s.m_shadercombineScreenSpace.Trim();
+ else
+ str = s.m_shadercombine.Trim();
+
+ CAtlList<CString> sl;
+ if(!str.IsEmpty()) Explode(str, sl, '|');
+
+ POSITION pos = sl.GetHeadPosition();
+ while(pos) m_list.AddString(sl.GetNext(pos));
+
+ pos = s.m_shaders.GetHeadPosition();
+ while(pos) m_combo.AddString(s.m_shaders.GetNext(pos).label);
+ if(m_combo.GetCount()) m_combo.SetCurSel(0);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CShaderCombineDlg::OnOK()
{
- m_labels.RemoveAll();
+ m_labels.RemoveAll();
- CAtlList<CString> sl;
+ CAtlList<CString> sl;
- for(int i = 0, j = m_list.GetCount(); i < j; i++)
- {
- CString label;
- m_list.GetText(i, label);
- sl.AddTail(label);
- m_labels.AddTail(label);
- }
+ for(int i = 0, j = m_list.GetCount(); i < j; i++)
+ {
+ CString label;
+ m_list.GetText(i, label);
+ sl.AddTail(label);
+ m_labels.AddTail(label);
+ }
- if(m_bScreenSpace)
- AfxGetAppSettings().m_shadercombineScreenSpace = Implode(sl, '|');
- else
- AfxGetAppSettings().m_shadercombine = Implode(sl, '|');
+ if (m_bScreenSpace)
+ AfxGetAppSettings().m_shadercombineScreenSpace = Implode(sl, '|');
+ else
+ AfxGetAppSettings().m_shadercombine = Implode(sl, '|');
- __super::OnOK();
+ __super::OnOK();
}
void CShaderCombineDlg::OnBnClickedButton12()
{
- int i = m_combo.GetCurSel();
- if(i < 0) return;
+ int i = m_combo.GetCurSel();
+ if(i < 0) return;
- CString label;
- m_combo.GetLBText(i, label);
- m_list.SetCurSel(m_list.AddString(label));
+ CString label;
+ m_combo.GetLBText(i, label);
+ m_list.SetCurSel(m_list.AddString(label));
}
void CShaderCombineDlg::OnBnClickedButton13()
{
- int i = m_list.GetCurSel();
- if(i < 0) return;
+ int i = m_list.GetCurSel();
+ if(i < 0) return;
- m_list.DeleteString(i);
- if(i == m_list.GetCount()) i--;
- if(i >= 0) m_list.SetCurSel(i);
+ m_list.DeleteString(i);
+ if(i == m_list.GetCount()) i--;
+ if(i >= 0) m_list.SetCurSel(i);
}
void CShaderCombineDlg::OnBnClickedButton1()
{
- int i = m_list.GetCurSel();
- if(i < 1) return;
-
- CString label;
- m_list.GetText(i, label);
- m_list.DeleteString(i);
- i--;
- m_list.InsertString(i, label);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ if(i < 1) return;
+
+ CString label;
+ m_list.GetText(i, label);
+ m_list.DeleteString(i);
+ i--;
+ m_list.InsertString(i, label);
+ m_list.SetCurSel(i);
}
void CShaderCombineDlg::OnBnClickedButton11()
{
- int i = m_list.GetCurSel();
- if(i < 0 || i >= m_list.GetCount() - 1) return;
-
- CString label;
- m_list.GetText(i, label);
- m_list.DeleteString(i);
- if(++i == m_list.GetCount()) m_list.AddString(label);
- else m_list.InsertString(i, label);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ if(i < 0 || i >= m_list.GetCount()-1) return;
+
+ CString label;
+ m_list.GetText(i, label);
+ m_list.DeleteString(i);
+ if(++i == m_list.GetCount()) m_list.AddString(label);
+ else m_list.InsertString(i, label);
+ m_list.SetCurSel(i);
}
diff --git a/src/apps/mplayerc/ShaderCombineDlg.h b/src/apps/mplayerc/ShaderCombineDlg.h
index 3146385e2..c91c985de 100644
--- a/src/apps/mplayerc/ShaderCombineDlg.h
+++ b/src/apps/mplayerc/ShaderCombineDlg.h
@@ -30,29 +30,29 @@
class CShaderCombineDlg : public CResizableDialog
{
- CAtlList<CString>& m_labels;
- bool m_bScreenSpace;
+ CAtlList<CString>& m_labels;
+ bool m_bScreenSpace;
public:
- CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent, bool bScreenSpace); // standard constructor
- virtual ~CShaderCombineDlg();
+ CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent, bool bScreenSpace); // standard constructor
+ virtual ~CShaderCombineDlg();
// Dialog Data
- enum { IDD = IDD_SHADERCOMBINE_DLG };
+ enum { IDD = IDD_SHADERCOMBINE_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
protected:
- virtual void OnOK();
+ virtual void OnOK();
public:
- CListBox m_list;
- CComboBox m_combo;
- afx_msg void OnBnClickedButton12();
- afx_msg void OnBnClickedButton13();
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton11();
+ CListBox m_list;
+ CComboBox m_combo;
+ afx_msg void OnBnClickedButton12();
+ afx_msg void OnBnClickedButton13();
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton11();
};
diff --git a/src/apps/mplayerc/ShaderEditorDlg.cpp b/src/apps/mplayerc/ShaderEditorDlg.cpp
index db06960c2..904d9d2fc 100644
--- a/src/apps/mplayerc/ShaderEditorDlg.cpp
+++ b/src/apps/mplayerc/ShaderEditorDlg.cpp
@@ -33,470 +33,470 @@
// CShaderLabelComboBox
BEGIN_MESSAGE_MAP(CShaderLabelComboBox, CComboBox)
- ON_WM_CTLCOLOR()
- ON_WM_DESTROY()
+ ON_WM_CTLCOLOR()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
HBRUSH CShaderLabelComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
- if(nCtlColor == CTLCOLOR_EDIT)
- {
- if(m_edit.GetSafeHwnd() == NULL)
+ if(nCtlColor == CTLCOLOR_EDIT)
+ {
+ if(m_edit.GetSafeHwnd() == NULL)
m_edit.SubclassWindow(pWnd->GetSafeHwnd());
- }
+ }
- return __super::OnCtlColor(pDC, pWnd, nCtlColor);
+ return __super::OnCtlColor(pDC, pWnd, nCtlColor);
}
void CShaderLabelComboBox::OnDestroy()
{
- if(m_edit.GetSafeHwnd() != NULL)
- m_edit.UnsubclassWindow();
+ if(m_edit.GetSafeHwnd() != NULL)
+ m_edit.UnsubclassWindow();
- __super::OnDestroy();
+ __super::OnDestroy();
}
// CShaderEdit
CShaderEdit::CShaderEdit()
{
- m_acdlg.Create(CShaderAutoCompleteDlg::IDD, NULL);
+ m_acdlg.Create(CShaderAutoCompleteDlg::IDD, NULL);
- m_nEndChar = -1;
- m_nIDEvent = -1;
+ m_nEndChar = -1;
+ m_nIDEvent = -1;
}
CShaderEdit::~CShaderEdit()
{
- m_acdlg.DestroyWindow();
+ m_acdlg.DestroyWindow();
}
BOOL CShaderEdit::PreTranslateMessage(MSG* pMsg)
{
- if(m_acdlg.IsWindowVisible()
- && pMsg->message == WM_KEYDOWN
- && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN
- || pMsg->wParam == VK_PRIOR || pMsg->wParam == VK_NEXT
- || pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE))
- {
- int i = m_acdlg.m_list.GetCurSel();
-
- if(pMsg->wParam == VK_RETURN && i >= 0)
- {
- CString str;
- m_acdlg.m_list.GetText(i, str);
- i = str.Find('(') + 1;
- if(i > 0) str = str.Left(i);
-
- int nStartChar = 0, nEndChar = -1;
- GetSel(nStartChar, nEndChar);
-
- CString text;
- GetWindowText(text);
- while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar - 1)))
- nStartChar--;
-
- SetSel(nStartChar, nEndChar);
- ReplaceSel(str, TRUE);
- }
- else if(pMsg->wParam == VK_ESCAPE)
- {
- m_acdlg.ShowWindow(SW_HIDE);
- }
- else
- {
- m_acdlg.m_list.SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
- }
-
- return TRUE;
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if(m_acdlg.IsWindowVisible()
+ && pMsg->message == WM_KEYDOWN
+ && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN
+ || pMsg->wParam == VK_PRIOR || pMsg->wParam == VK_NEXT
+ || pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE))
+ {
+ int i = m_acdlg.m_list.GetCurSel();
+
+ if(pMsg->wParam == VK_RETURN && i >= 0)
+ {
+ CString str;
+ m_acdlg.m_list.GetText(i, str);
+ i = str.Find('(')+1;
+ if(i > 0) str = str.Left(i);
+
+ int nStartChar = 0, nEndChar = -1;
+ GetSel(nStartChar, nEndChar);
+
+ CString text;
+ GetWindowText(text);
+ while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1)))
+ nStartChar--;
+
+ SetSel(nStartChar, nEndChar);
+ ReplaceSel(str, TRUE);
+ }
+ else if(pMsg->wParam == VK_ESCAPE)
+ {
+ m_acdlg.ShowWindow(SW_HIDE);
+ }
+ else
+ {
+ m_acdlg.m_list.SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
+ }
+
+ return TRUE;
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CShaderEdit, CLineNumberEdit)
- ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
- ON_WM_KILLFOCUS()
- ON_WM_TIMER()
+ ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
+ ON_WM_KILLFOCUS()
+ ON_WM_TIMER()
END_MESSAGE_MAP()
void CShaderEdit::OnUpdate()
{
- if(m_nIDEvent == -1)
- {
- m_nIDEvent = SetTimer(1, 100, NULL);
- }
-
- CString text;
- int nStartChar = 0, nEndChar = -1;
- GetSel(nStartChar, nEndChar);
-
- if(nStartChar == nEndChar)
- {
- GetWindowText(text);
- while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar - 1)))
- nStartChar--;
- }
-
- if(nStartChar < nEndChar)
- {
- text = text.Mid(nStartChar, nEndChar - nStartChar);
- text.TrimRight('(');
- text.MakeLower();
-
- m_acdlg.m_list.ResetContent();
-
- CString key, value;
- POSITION pos = m_acdlg.m_inst.GetStartPosition();
- while(pos)
- {
- POSITION cur = pos;
- m_acdlg.m_inst.GetNextAssoc(pos, key, value);
-
- if(key.Find(text) == 0)
- {
- CAtlList<CString> sl;
- Explode(value, sl, '|', 2);
- if(sl.GetCount() != 2) continue;
- CString name = sl.RemoveHead();
- CString description = sl.RemoveHead();
- int i = m_acdlg.m_list.AddString(name);
- m_acdlg.m_list.SetItemDataPtr(i, cur);
- }
- }
-
- if(m_acdlg.m_list.GetCount() > 0)
- {
- int lineheight = GetLineHeight();
-
- CPoint p = PosFromChar(nStartChar);
- p.y += lineheight;
- ClientToScreen(&p);
- CRect r(p, CSize(100, 100));
-
- m_acdlg.MoveWindow(r);
- m_acdlg.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- m_acdlg.ShowWindow(SW_SHOWNOACTIVATE);
-
- m_nEndChar = nEndChar;
-
- return;
- }
- }
-
- m_acdlg.ShowWindow(SW_HIDE);
+ if(m_nIDEvent == -1)
+ {
+ m_nIDEvent = SetTimer(1, 100, NULL);
+ }
+
+ CString text;
+ int nStartChar = 0, nEndChar = -1;
+ GetSel(nStartChar, nEndChar);
+
+ if(nStartChar == nEndChar)
+ {
+ GetWindowText(text);
+ while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1)))
+ nStartChar--;
+ }
+
+ if(nStartChar < nEndChar)
+ {
+ text = text.Mid(nStartChar, nEndChar - nStartChar);
+ text.TrimRight('(');
+ text.MakeLower();
+
+ m_acdlg.m_list.ResetContent();
+
+ CString key, value;
+ POSITION pos = m_acdlg.m_inst.GetStartPosition();
+ while(pos)
+ {
+ POSITION cur = pos;
+ m_acdlg.m_inst.GetNextAssoc(pos, key, value);
+
+ if(key.Find(text) == 0)
+ {
+ CAtlList<CString> sl;
+ Explode(value, sl, '|', 2);
+ if(sl.GetCount() != 2) continue;
+ CString name = sl.RemoveHead();
+ CString description = sl.RemoveHead();
+ int i = m_acdlg.m_list.AddString(name);
+ m_acdlg.m_list.SetItemDataPtr(i, cur);
+ }
+ }
+
+ if(m_acdlg.m_list.GetCount() > 0)
+ {
+ int lineheight = GetLineHeight();
+
+ CPoint p = PosFromChar(nStartChar);
+ p.y += lineheight;
+ ClientToScreen(&p);
+ CRect r(p, CSize(100, 100));
+
+ m_acdlg.MoveWindow(r);
+ m_acdlg.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ m_acdlg.ShowWindow(SW_SHOWNOACTIVATE);
+
+ m_nEndChar = nEndChar;
+
+ return;
+ }
+ }
+
+ m_acdlg.ShowWindow(SW_HIDE);
}
void CShaderEdit::OnKillFocus(CWnd* pNewWnd)
{
- CString text;
- GetWindowText(text);
- __super::OnKillFocus(pNewWnd);
- GetWindowText(text);
+ CString text;
+ GetWindowText(text);
+ __super::OnKillFocus(pNewWnd);
+ GetWindowText(text);
- m_acdlg.ShowWindow(SW_HIDE);
+ m_acdlg.ShowWindow(SW_HIDE);
}
void CShaderEdit::OnTimer(UINT_PTR nIDEvent)
{
- if(m_nIDEvent == nIDEvent)
- {
- int nStartChar = 0, nEndChar = -1;
- GetSel(nStartChar, nEndChar);
- if(nStartChar != nEndChar || m_nEndChar != nEndChar)
- m_acdlg.ShowWindow(SW_HIDE);
- }
-
- __super::OnTimer(nIDEvent);
+ if(m_nIDEvent == nIDEvent)
+ {
+ int nStartChar = 0, nEndChar = -1;
+ GetSel(nStartChar, nEndChar);
+ if(nStartChar != nEndChar || m_nEndChar != nEndChar)
+ m_acdlg.ShowWindow(SW_HIDE);
+ }
+
+ __super::OnTimer(nIDEvent);
}
// CShaderEditorDlg dialog
CShaderEditorDlg::CShaderEditorDlg()
- : CResizableDialog(CShaderEditorDlg::IDD, NULL)
- , m_fSplitterGrabbed(false)
- , m_pPSC(NULL)
- , m_pShader(NULL)
+ : CResizableDialog(CShaderEditorDlg::IDD, NULL)
+ , m_fSplitterGrabbed(false)
+ , m_pPSC(NULL)
+ , m_pShader(NULL)
{
}
CShaderEditorDlg::~CShaderEditorDlg()
{
- delete m_pPSC;
+ delete m_pPSC;
}
BOOL CShaderEditorDlg::Create(CWnd* pParent)
{
- if(!__super::Create(IDD, pParent))
- return FALSE;
-
- AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_COMBO2, TOP_RIGHT);
- AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_EDIT2, BOTTOM_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
-
- m_srcdata.SetTabStops(16);
-
- SetMinTrackSize(CSize(250, 40));
-
- m_targets.AddString(_T("ps_1_1"));
- m_targets.AddString(_T("ps_1_2"));
- m_targets.AddString(_T("ps_1_3"));
- m_targets.AddString(_T("ps_1_4"));
- m_targets.AddString(_T("ps_2_0"));
- m_targets.AddString(_T("ps_2_a"));
- m_targets.AddString(_T("ps_2_sw"));
- m_targets.AddString(_T("ps_3_0"));
- m_targets.AddString(_T("ps_3_sw"));
-
- POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition();
- while(pos)
- {
- const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
- m_labels.SetItemDataPtr(m_labels.AddString(s.label), (void*)&s);
- }
-
- m_nIDEventShader = SetTimer(1, 1000, NULL);
-
- return TRUE;
+ if(!__super::Create(IDD, pParent))
+ return FALSE;
+
+ AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_COMBO2, TOP_RIGHT);
+ AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_EDIT2, BOTTOM_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+
+ m_srcdata.SetTabStops(16);
+
+ SetMinTrackSize(CSize(250, 40));
+
+ m_targets.AddString(_T("ps_1_1"));
+ m_targets.AddString(_T("ps_1_2"));
+ m_targets.AddString(_T("ps_1_3"));
+ m_targets.AddString(_T("ps_1_4"));
+ m_targets.AddString(_T("ps_2_0"));
+ m_targets.AddString(_T("ps_2_a"));
+ m_targets.AddString(_T("ps_2_sw"));
+ m_targets.AddString(_T("ps_3_0"));
+ m_targets.AddString(_T("ps_3_sw"));
+
+ POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition();
+ while(pos)
+ {
+ const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
+ m_labels.SetItemDataPtr(m_labels.AddString(s.label), (void*)&s);
+ }
+
+ m_nIDEventShader = SetTimer(1, 1000, NULL);
+
+ return TRUE;
}
void CShaderEditorDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_labels);
- DDX_Control(pDX, IDC_COMBO2, m_targets);
- DDX_Control(pDX, IDC_EDIT1, m_srcdata);
- DDX_Control(pDX, IDC_EDIT2, m_output);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_labels);
+ DDX_Control(pDX, IDC_COMBO2, m_targets);
+ DDX_Control(pDX, IDC_EDIT1, m_srcdata);
+ DDX_Control(pDX, IDC_EDIT2, m_output);
}
bool CShaderEditorDlg::HitTestSplitter(CPoint p)
{
- CRect r, rs, ro;
- m_srcdata.GetWindowRect(&rs);
- m_output.GetWindowRect(&ro);
- ScreenToClient(&rs);
- ScreenToClient(&ro);
- GetClientRect(&r);
- r.left = ro.left;
- r.right = ro.right;
- r.top = rs.bottom;
- r.bottom = ro.top;
- return !!r.PtInRect(p);
+ CRect r, rs, ro;
+ m_srcdata.GetWindowRect(&rs);
+ m_output.GetWindowRect(&ro);
+ ScreenToClient(&rs);
+ ScreenToClient(&ro);
+ GetClientRect(&r);
+ r.left = ro.left;
+ r.right = ro.right;
+ r.top = rs.bottom;
+ r.bottom = ro.top;
+ return !!r.PtInRect(p);
}
BEGIN_MESSAGE_MAP(CShaderEditorDlg, CResizableDialog)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton2)
- ON_WM_TIMER()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_MOUSEMOVE()
- ON_WM_SETCURSOR()
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton2)
+ ON_WM_TIMER()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_LBUTTONUP()
+ ON_WM_MOUSEMOVE()
+ ON_WM_SETCURSOR()
END_MESSAGE_MAP()
// CShaderEditorDlg message handlers
BOOL CShaderEditorDlg::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
- && pMsg->hwnd == m_labels.m_edit.GetSafeHwnd())
- {
- OnCbnSelchangeCombo1();
-
- return TRUE;
- }
- else if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB
- && pMsg->hwnd == m_srcdata.GetSafeHwnd())
- {
- int nStartChar, nEndChar;
- m_srcdata.GetSel(nStartChar, nEndChar);
- if(nStartChar == nEndChar) m_srcdata.ReplaceSel(_T("\t"));
- return TRUE;
- }
- else if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
- {
- return TRUE;
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
+ && pMsg->hwnd == m_labels.m_edit.GetSafeHwnd())
+ {
+ OnCbnSelchangeCombo1();
+
+ return TRUE;
+ }
+ else if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB
+ && pMsg->hwnd == m_srcdata.GetSafeHwnd())
+ {
+ int nStartChar, nEndChar;
+ m_srcdata.GetSel(nStartChar, nEndChar);
+ if(nStartChar == nEndChar) m_srcdata.ReplaceSel(_T("\t"));
+ return TRUE;
+ }
+ else if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
+ {
+ return TRUE;
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
void CShaderEditorDlg::OnCbnSelchangeCombo1()
{
- int i = m_labels.GetCurSel();
+ int i = m_labels.GetCurSel();
- if(i < 0)
- {
- CString label;
- m_labels.GetWindowText(label);
- label.Trim();
+ if(i < 0)
+ {
+ CString label;
+ m_labels.GetWindowText(label);
+ label.Trim();
- if(label.IsEmpty()) return;
+ if(label.IsEmpty()) return;
- CStringA srcdata;
- LoadResource(IDF_SHADER_EMPTY, srcdata, _T("FILE"));
+ CStringA srcdata;
+ LoadResource(IDF_SHADER_EMPTY, srcdata, _T("FILE"));
- AppSettings::Shader s;
- s.label = label;
- s.target = _T("ps_2_0");
- s.srcdata = CString(srcdata);
+ AppSettings::Shader s;
+ s.label = label;
+ s.target = _T("ps_2_0");
+ s.srcdata = CString(srcdata);
- POSITION pos = AfxGetAppSettings().m_shaders.AddTail(s);
+ POSITION pos = AfxGetAppSettings().m_shaders.AddTail(s);
- i = m_labels.AddString(s.label);
- m_labels.SetCurSel(i);
- m_labels.SetItemDataPtr(i, (void*)&AfxGetAppSettings().m_shaders.GetAt(pos));
- }
+ i = m_labels.AddString(s.label);
+ m_labels.SetCurSel(i);
+ m_labels.SetItemDataPtr(i, (void*)&AfxGetAppSettings().m_shaders.GetAt(pos));
+ }
- m_pShader = (AppSettings::Shader*)m_labels.GetItemDataPtr(i);
+ m_pShader = (AppSettings::Shader*)m_labels.GetItemDataPtr(i);
- m_targets.SetWindowText(m_pShader->target);
+ m_targets.SetWindowText(m_pShader->target);
- CString srcdata = m_pShader->srcdata;
- srcdata.Replace(_T("\n"), _T("\r\n"));
- m_srcdata.SetWindowText(srcdata);
+ CString srcdata = m_pShader->srcdata;
+ srcdata.Replace(_T("\n"), _T("\r\n"));
+ m_srcdata.SetWindowText(srcdata);
- ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
+ ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
}
void CShaderEditorDlg::OnBnClickedButton2()
{
- if(!m_pShader) return;
-
- if(IDYES != AfxMessageBox(ResStr(IDS_SHADEREDITORDLG_0), MB_YESNO))
- return;
-
- AppSettings& s = AfxGetAppSettings();
-
- for(POSITION pos = s.m_shaders.GetHeadPosition(); pos; s.m_shaders.GetNext(pos))
- {
- if(m_pShader == &s.m_shaders.GetAt(pos))
- {
- m_pShader = NULL;
- s.m_shaders.RemoveAt(pos);
- int i = m_labels.GetCurSel();
- if(i >= 0) m_labels.DeleteString(i);
- m_labels.SetWindowText(_T(""));
- m_targets.SetWindowText(_T(""));
- m_srcdata.SetWindowText(_T(""));
- m_output.SetWindowText(_T(""));
- ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(_T(""));
- break;
- }
- }
+ if(!m_pShader) return;
+
+ if(IDYES != AfxMessageBox(ResStr(IDS_SHADEREDITORDLG_0), MB_YESNO))
+ return;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ for(POSITION pos = s.m_shaders.GetHeadPosition(); pos; s.m_shaders.GetNext(pos))
+ {
+ if(m_pShader == &s.m_shaders.GetAt(pos))
+ {
+ m_pShader = NULL;
+ s.m_shaders.RemoveAt(pos);
+ int i = m_labels.GetCurSel();
+ if(i >= 0) m_labels.DeleteString(i);
+ m_labels.SetWindowText(_T(""));
+ m_targets.SetWindowText(_T(""));
+ m_srcdata.SetWindowText(_T(""));
+ m_output.SetWindowText(_T(""));
+ ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(_T(""));
+ break;
+ }
+ }
}
void CShaderEditorDlg::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == m_nIDEventShader && IsWindowVisible() && m_pShader)
- {
- CString srcdata;
- m_srcdata.GetWindowText(srcdata);
- srcdata.Replace(_T("\r"), _T(""));
- srcdata.Trim();
+ if(nIDEvent == m_nIDEventShader && IsWindowVisible() && m_pShader)
+ {
+ CString srcdata;
+ m_srcdata.GetWindowText(srcdata);
+ srcdata.Replace(_T("\r"), _T(""));
+ srcdata.Trim();
- CString target;
- m_targets.GetWindowText(target);
- target.Trim();
+ CString target;
+ m_targets.GetWindowText(target);
+ target.Trim();
- if(!srcdata.IsEmpty() && !target.IsEmpty() && (m_pShader->srcdata != srcdata || m_pShader->target != target))
- {
- KillTimer(m_nIDEventShader);
+ if(!srcdata.IsEmpty() && !target.IsEmpty() && (m_pShader->srcdata != srcdata || m_pShader->target != target))
+ {
+ KillTimer(m_nIDEventShader);
- m_pShader->srcdata = srcdata;
- m_pShader->target = target;
+ m_pShader->srcdata = srcdata;
+ m_pShader->target = target;
- if(!m_pPSC) m_pPSC = DNew CPixelShaderCompiler(NULL);
+ if(!m_pPSC) m_pPSC = DNew CPixelShaderCompiler(NULL);
- CString disasm, errmsg;
- HRESULT hr = m_pPSC->CompileShader(CStringA(srcdata), "main", CStringA(target), D3DXSHADER_DEBUG, NULL, &disasm, &errmsg);
+ CString disasm, errmsg;
+ HRESULT hr = m_pPSC->CompileShader(CStringA(srcdata), "main", CStringA(target), D3DXSHADER_DEBUG, NULL, &disasm, &errmsg);
- if(SUCCEEDED(hr))
- {
- errmsg = _T("D3DXCompileShader succeeded\n");
- errmsg += _T("\n");
- errmsg += disasm;
+ if(SUCCEEDED(hr))
+ {
+ errmsg = _T("D3DXCompileShader succeeded\n");
+ errmsg += _T("\n");
+ errmsg += disasm;
- ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
- }
+ ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
+ }
- errmsg.Replace(_T("\n"), _T("\r\n"));
+ errmsg.Replace(_T("\n"), _T("\r\n"));
- m_output.SetWindowText(errmsg);
+ m_output.SetWindowText(errmsg);
- // TODO: autosave
+ // TODO: autosave
- m_nIDEventShader = SetTimer(1, 1000, NULL);
- }
- }
+ m_nIDEventShader = SetTimer(1, 1000, NULL);
+ }
+ }
- __super::OnTimer(nIDEvent);
+ __super::OnTimer(nIDEvent);
}
void CShaderEditorDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
- if(HitTestSplitter(point))
- {
- m_fSplitterGrabbed = true;
- SetCapture();
- }
-
- __super::OnLButtonDown(nFlags, point);
+ if(HitTestSplitter(point))
+ {
+ m_fSplitterGrabbed = true;
+ SetCapture();
+ }
+
+ __super::OnLButtonDown(nFlags, point);
}
void CShaderEditorDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(m_fSplitterGrabbed)
- {
- ReleaseCapture();
- m_fSplitterGrabbed = false;
- }
+ if(m_fSplitterGrabbed)
+ {
+ ReleaseCapture();
+ m_fSplitterGrabbed = false;
+ }
- __super::OnLButtonUp(nFlags, point);
+ __super::OnLButtonUp(nFlags, point);
}
void CShaderEditorDlg::OnMouseMove(UINT nFlags, CPoint point)
{
- if(m_fSplitterGrabbed)
- {
- CRect r, rs, ro;
- GetClientRect(&r);
- m_srcdata.GetWindowRect(&rs);
- m_output.GetWindowRect(&ro);
- ScreenToClient(&rs);
- ScreenToClient(&ro);
-
- int dist = ro.top - rs.bottom;
- int avgdist = dist / 2;
-
- rs.bottom = min(max(point.y, rs.top + 40), ro.bottom - 40) - avgdist;
- ro.top = rs.bottom + dist;
- m_srcdata.MoveWindow(&rs);
- m_output.MoveWindow(&ro);
-
- int div = 100 * ((rs.bottom + ro.top) / 2) / (ro.bottom - rs.top);
-
- RemoveAnchor(IDC_EDIT1);
- RemoveAnchor(IDC_EDIT2);
- AddAnchor(IDC_EDIT1, TOP_LEFT, CSize(100, div)/*BOTTOM_RIGHT*/);
- AddAnchor(IDC_EDIT2, CSize(0, div)/*BOTTOM_LEFT*/, BOTTOM_RIGHT);
- }
-
- __super::OnMouseMove(nFlags, point);
+ if(m_fSplitterGrabbed)
+ {
+ CRect r, rs, ro;
+ GetClientRect(&r);
+ m_srcdata.GetWindowRect(&rs);
+ m_output.GetWindowRect(&ro);
+ ScreenToClient(&rs);
+ ScreenToClient(&ro);
+
+ int dist = ro.top - rs.bottom;
+ int avgdist = dist / 2;
+
+ rs.bottom = min(max(point.y, rs.top + 40), ro.bottom - 40) - avgdist;
+ ro.top = rs.bottom + dist;
+ m_srcdata.MoveWindow(&rs);
+ m_output.MoveWindow(&ro);
+
+ int div = 100 * ((rs.bottom + ro.top) / 2) / (ro.bottom - rs.top);
+
+ RemoveAnchor(IDC_EDIT1);
+ RemoveAnchor(IDC_EDIT2);
+ AddAnchor(IDC_EDIT1, TOP_LEFT, CSize(100, div)/*BOTTOM_RIGHT*/);
+ AddAnchor(IDC_EDIT2, CSize(0, div)/*BOTTOM_LEFT*/, BOTTOM_RIGHT);
+ }
+
+ __super::OnMouseMove(nFlags, point);
}
BOOL CShaderEditorDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- CPoint p;
- GetCursorPos(&p);
- ScreenToClient(&p);
- if(HitTestSplitter(p))
- {
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS));
- return TRUE;
- }
-
- return __super::OnSetCursor(pWnd, nHitTest, message);
+ CPoint p;
+ GetCursorPos(&p);
+ ScreenToClient(&p);
+ if(HitTestSplitter(p))
+ {
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS));
+ return TRUE;
+ }
+
+ return __super::OnSetCursor(pWnd, nHitTest, message);
}
diff --git a/src/apps/mplayerc/ShaderEditorDlg.h b/src/apps/mplayerc/ShaderEditorDlg.h
index 535ac8f88..3a6a34457 100644
--- a/src/apps/mplayerc/ShaderEditorDlg.h
+++ b/src/apps/mplayerc/ShaderEditorDlg.h
@@ -34,29 +34,29 @@
class CShaderLabelComboBox : public CComboBox
{
public:
- CEdit m_edit;
+ CEdit m_edit;
- DECLARE_MESSAGE_MAP()
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnDestroy();
+ DECLARE_MESSAGE_MAP()
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnDestroy();
};
class CShaderEdit : public CLineNumberEdit
{
- int m_nEndChar;
- UINT m_nIDEvent;
+ int m_nEndChar;
+ UINT m_nIDEvent;
public:
- CShaderEdit();
- ~CShaderEdit();
+ CShaderEdit();
+ ~CShaderEdit();
- CShaderAutoCompleteDlg m_acdlg;
+ CShaderAutoCompleteDlg m_acdlg;
- DECLARE_MESSAGE_MAP()
- afx_msg void OnUpdate();
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnUpdate();
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
};
// CShaderEditorDlg dialog
@@ -66,42 +66,42 @@ class CPixelShaderCompiler;
class CShaderEditorDlg : public CResizableDialog
{
private:
- UINT m_nIDEventShader;
+ UINT m_nIDEventShader;
- bool m_fSplitterGrabbed;
- bool HitTestSplitter(CPoint p);
+ bool m_fSplitterGrabbed;
+ bool HitTestSplitter(CPoint p);
- CPixelShaderCompiler* m_pPSC;
- AppSettings::Shader* m_pShader;
+ CPixelShaderCompiler* m_pPSC;
+ AppSettings::Shader* m_pShader;
public:
- CShaderEditorDlg(); // standard constructor
- virtual ~CShaderEditorDlg();
+ CShaderEditorDlg(); // standard constructor
+ virtual ~CShaderEditorDlg();
- BOOL Create(CWnd* pParent = NULL);
+ BOOL Create(CWnd* pParent = NULL);
// Dialog Data
- enum { IDD = IDD_SHADEREDITOR_DLG };
- CShaderLabelComboBox m_labels;
- CComboBox m_targets;
- CShaderEdit m_srcdata;
- CEdit m_output;
+ enum { IDD = IDD_SHADEREDITOR_DLG };
+ CShaderLabelComboBox m_labels;
+ CComboBox m_targets;
+ CShaderEdit m_srcdata;
+ CEdit m_output;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual void OnOK() {}
- virtual void OnCancel() {}
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual void OnOK() {}
+ virtual void OnCancel() {}
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnCbnSelchangeCombo1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnCbnSelchangeCombo1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
};
diff --git a/src/apps/mplayerc/ShockwaveGraph.cpp b/src/apps/mplayerc/ShockwaveGraph.cpp
index 1f15ef45f..bbab27286 100644
--- a/src/apps/mplayerc/ShockwaveGraph.cpp
+++ b/src/apps/mplayerc/ShockwaveGraph.cpp
@@ -27,216 +27,174 @@
#include "../../DSUtil/DSUtil.h"
CShockwaveGraph::CShockwaveGraph(HWND hParent, HRESULT& hr)
- : m_fs(State_Stopped)
+ : m_fs(State_Stopped)
{
- hr = S_OK;
+ hr = S_OK;
- if(!m_wndWindowFrame.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- CRect(0, 0, 0, 0), CWnd::FromHandle(hParent), 0, NULL))
- {
- hr = E_FAIL;
- return;
- }
+ if(!m_wndWindowFrame.Create(NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
+ CRect(0, 0, 0, 0), CWnd::FromHandle(hParent), 0, NULL))
+ {
+ hr = E_FAIL;
+ return;
+ }
- if(!m_wndDestFrame.Create(NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
- CRect(0, 0, 0, 0), &m_wndWindowFrame, 0))
- {
- hr = E_FAIL;
- return;
- }
+ if(!m_wndDestFrame.Create(NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
+ CRect(0, 0, 0, 0), &m_wndWindowFrame, 0))
+ {
+ hr = E_FAIL;
+ return;
+ }
}
CShockwaveGraph::~CShockwaveGraph()
{
- m_wndDestFrame.DestroyWindow();
- m_wndWindowFrame.DestroyWindow();
+ m_wndDestFrame.DestroyWindow();
+ m_wndWindowFrame.DestroyWindow();
}
// IGraphBuilder
STDMETHODIMP CShockwaveGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- try
- {
- m_wndDestFrame.LoadMovie(0, CString(lpcwstrFile));
- }
- catch(CException* e)
- {
- e->Delete();
- return E_FAIL;
- }
- return S_OK;
+ try {m_wndDestFrame.LoadMovie(0, CString(lpcwstrFile));}
+ catch(CException* e) {e->Delete(); return E_FAIL;}
+ return S_OK;
}
// IMediaControl
STDMETHODIMP CShockwaveGraph::Run()
{
- try
- {
- if(m_fs != State_Running) m_wndDestFrame.Play();
- }
- catch(CException* e)
- {
- e->Delete();
- return E_FAIL;
- }
- m_fs = State_Running;
- m_wndWindowFrame.EnableWindow();
+ try {if(m_fs != State_Running) m_wndDestFrame.Play();}
+ catch(CException* e) {e->Delete(); return E_FAIL;}
+ m_fs = State_Running;
+ m_wndWindowFrame.EnableWindow();
// m_wndDestFrame.EnableWindow();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::Pause()
{
- try
- {
- if(m_fs == State_Running) m_wndDestFrame.Stop();
- }
- catch(CException* e)
- {
- e->Delete();
- return E_FAIL;
- }
- m_fs = State_Paused;
- return S_OK;
+ try {if(m_fs == State_Running) m_wndDestFrame.Stop();}
+ catch(CException* e) {e->Delete(); return E_FAIL;}
+ m_fs = State_Paused;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::Stop()
{
- try
- {
- m_wndDestFrame.Stop();
- }
- catch(CException* e)
- {
- e->Delete();
- return E_FAIL;
- }
- m_fs = State_Stopped;
- return S_OK;
+ try {m_wndDestFrame.Stop();}
+ catch(CException* e) {e->Delete(); return E_FAIL;}
+ m_fs = State_Stopped;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::GetState(LONG msTimeout, OAFilterState* pfs)
{
- OAFilterState fs = m_fs;
+ OAFilterState fs = m_fs;
- try
- {
- if(m_wndDestFrame.IsPlaying() && m_fs == State_Stopped) m_fs = State_Running;
- else if(!m_wndDestFrame.IsPlaying() && m_fs == State_Running) m_fs = State_Stopped;
- fs = m_fs;
- }
- catch(CException* e)
- {
- e->Delete();
- return E_FAIL;
- }
+ try
+ {
+ if(m_wndDestFrame.IsPlaying() && m_fs == State_Stopped) m_fs = State_Running;
+ else if(!m_wndDestFrame.IsPlaying() && m_fs == State_Running) m_fs = State_Stopped;
+ fs = m_fs;
+ }
+ catch(CException* e)
+ {
+ e->Delete();
+ return E_FAIL;
+ }
- return pfs ? *pfs = fs, S_OK : E_POINTER;
+ return pfs ? *pfs = fs, S_OK : E_POINTER;
}
// IMediaSeeking
STDMETHODIMP CShockwaveGraph::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
}
STDMETHODIMP CShockwaveGraph::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_FRAME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_FRAME, S_OK : E_POINTER;
}
STDMETHODIMP CShockwaveGraph::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- *pDuration = 0;
- try
- {
- if(m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) *pDuration = m_wndDestFrame.get_TotalFrames();
- }
- catch(CException* e)
- {
- e->Delete();
- return E_FAIL;
- }
- return S_OK;
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = 0;
+ try {if(m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) *pDuration = m_wndDestFrame.get_TotalFrames();}
+ catch(CException* e) {e->Delete(); return E_FAIL;}
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::GetCurrentPosition(LONGLONG* pCurrent)
{
- CheckPointer(pCurrent, E_POINTER);
- *pCurrent = 0;
- try
- {
- if(m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) *pCurrent = m_wndDestFrame.get_FrameNum();
- }
- catch(CException* e)
- {
- e->Delete();
- return E_FAIL;
- }
- return S_OK;
+ CheckPointer(pCurrent, E_POINTER);
+ *pCurrent = 0;
+ try {if(m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) *pCurrent = m_wndDestFrame.get_FrameNum();}
+ catch(CException* e) {e->Delete(); return E_FAIL;}
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- if(dwCurrentFlags & AM_SEEKING_AbsolutePositioning)
- {
- m_wndDestFrame.put_FrameNum(*pCurrent);
+ if(dwCurrentFlags&AM_SEEKING_AbsolutePositioning)
+ {
+ m_wndDestFrame.put_FrameNum(*pCurrent);
- if(m_fs == State_Running && !m_wndDestFrame.IsPlaying())
- m_wndDestFrame.Play();
- else if((m_fs == State_Paused || m_fs == State_Stopped) && m_wndDestFrame.IsPlaying())
- m_wndDestFrame.Stop();
+ if(m_fs == State_Running && !m_wndDestFrame.IsPlaying())
+ m_wndDestFrame.Play();
+ else if((m_fs == State_Paused || m_fs == State_Stopped) && m_wndDestFrame.IsPlaying())
+ m_wndDestFrame.Stop();
- m_wndDestFrame.put_Quality(1); // 0=Low, 1=High, 2=AutoLow, 3=AutoHigh
+ m_wndDestFrame.put_Quality(1); // 0=Low, 1=High, 2=AutoLow, 3=AutoHigh
- return S_OK;
- }
+ return S_OK;
+ }
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
// IVideoWindow
STDMETHODIMP CShockwaveGraph::put_Visible(long Visible)
{
- if(IsWindow(m_wndDestFrame.m_hWnd))
- m_wndDestFrame.ShowWindow(Visible == OATRUE ? SW_SHOWNORMAL : SW_HIDE);
- return S_OK;
+ if(IsWindow(m_wndDestFrame.m_hWnd))
+ m_wndDestFrame.ShowWindow(Visible == OATRUE ? SW_SHOWNORMAL : SW_HIDE);
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::get_Visible(long* pVisible)
{
-return pVisible ? *pVisible = (m_wndDestFrame.IsWindowVisible() ? OATRUE : OAFALSE), S_OK : E_POINTER;
+ return pVisible ? *pVisible = (m_wndDestFrame.IsWindowVisible() ? OATRUE : OAFALSE), S_OK : E_POINTER;
}
STDMETHODIMP CShockwaveGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if(IsWindow(m_wndWindowFrame.m_hWnd))
- m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
+ if(IsWindow(m_wndWindowFrame.m_hWnd))
+ m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
- return S_OK;
+ return S_OK;
}
// IBasicVideo
STDMETHODIMP CShockwaveGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- if(IsWindow(m_wndDestFrame.m_hWnd))
- m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
+ if(IsWindow(m_wndDestFrame.m_hWnd))
+ m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if(!pWidth || !pHeight) return E_POINTER;
+ if(!pWidth || !pHeight) return E_POINTER;
- CRect r;
- m_wndWindowFrame.GetWindowRect(r);
- if(!r.IsRectEmpty())
- {
- *pWidth = r.Width();
- *pHeight = r.Height();
- }
- else
- {
- // no call exists to determine these...
- *pWidth = 384;//m_wndDestFrame.get_;
- *pHeight = 288;
+ CRect r;
+ m_wndWindowFrame.GetWindowRect(r);
+ if(!r.IsRectEmpty())
+ {
+ *pWidth = r.Width();
+ *pHeight = r.Height();
+ }
+ else
+ {
+ // no call exists to determine these...
+ *pWidth = 384;//m_wndDestFrame.get_;
+ *pHeight = 288;
- NotifyEvent(EC_BG_AUDIO_CHANGED, 2, 0);
- }
+ NotifyEvent(EC_BG_AUDIO_CHANGED, 2, 0);
+ }
- return S_OK;
+ return S_OK;
}
#include <math.h>
@@ -244,36 +202,33 @@ STDMETHODIMP CShockwaveGraph::GetVideoSize(long* pWidth, long* pHeight)
// IBasicAudio
STDMETHODIMP CShockwaveGraph::put_Volume(long lVolume)
{
- lVolume = (lVolume == -10000) ? 0 : (int)pow(10.0, ((double)lVolume) / 5000 + 2);
- lVolume = lVolume * 0x10000 / 100;
- lVolume = max(min(lVolume, 0xffff), 0);
- waveOutSetVolume(0, (lVolume << 16) | lVolume);
+ lVolume = (lVolume == -10000) ? 0 : (int)pow(10.0, ((double)lVolume)/5000+2);
+ lVolume = lVolume*0x10000/100;
+ lVolume = max(min(lVolume, 0xffff), 0);
+ waveOutSetVolume(0, (lVolume<<16)|lVolume);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::get_Volume(long* plVolume)
{
- CheckPointer(plVolume, E_POINTER);
+ CheckPointer(plVolume, E_POINTER);
- waveOutGetVolume(0, (DWORD*)plVolume);
- *plVolume = (*plVolume & 0xffff + ((*plVolume >> 16) & 0xffff)) / 2;
- *plVolume = *plVolume * 100 / 0x10000;
- *plVolume = (int)((log10(1.0 * (*plVolume)) - 2) * 5000);
- *plVolume = max(min(*plVolume, 0), -10000);
+ waveOutGetVolume(0, (DWORD*)plVolume);
+ *plVolume = (*plVolume&0xffff + ((*plVolume>>16)&0xffff)) / 2;
+ *plVolume = *plVolume*100/0x10000;
+ *plVolume = (int)((log10(1.0*(*plVolume))-2)*5000);
+ *plVolume = max(min(*plVolume, 0), -10000);
- return S_OK;
+ return S_OK;
}
// IAMOpenProgress
STDMETHODIMP CShockwaveGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- *pllTotal = 100;
- *pllCurrent = m_wndDestFrame.PercentLoaded();
- return S_OK;
+ *pllTotal = 100;
+ *pllCurrent = m_wndDestFrame.PercentLoaded();
+ return S_OK;
}
// IGraphEngine
-STDMETHODIMP_(engine_t) CShockwaveGraph::GetEngine()
-{
- return ShockWave;
-}
+STDMETHODIMP_(engine_t) CShockwaveGraph::GetEngine() {return ShockWave;}
diff --git a/src/apps/mplayerc/ShockwaveGraph.h b/src/apps/mplayerc/ShockwaveGraph.h
index 011ffe4e6..8049409ac 100644
--- a/src/apps/mplayerc/ShockwaveGraph.h
+++ b/src/apps/mplayerc/ShockwaveGraph.h
@@ -30,53 +30,53 @@
namespace DSObjects
{
-class CShockwaveGraph : public CBaseGraph
-{
- CPlayerWindow m_wndWindowFrame;
- CShockwaveFlash m_wndDestFrame;
-
- FILTER_STATE m_fs;
-
-public:
- CShockwaveGraph(HWND hParent, HRESULT& hr);
- virtual ~CShockwaveGraph();
-
-protected:
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
-
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
-
- // IMediaSeeking
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
-
- // IVideoWindow
- STDMETHODIMP put_Visible(long Visible);
- STDMETHODIMP get_Visible(long* pVisible);
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
-
- // IBasicVideo
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
-
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
-
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
-
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
-};
+ class CShockwaveGraph : public CBaseGraph
+ {
+ CPlayerWindow m_wndWindowFrame;
+ CShockwaveFlash m_wndDestFrame;
+
+ FILTER_STATE m_fs;
+
+ public:
+ CShockwaveGraph(HWND hParent, HRESULT& hr);
+ virtual ~CShockwaveGraph();
+
+ protected:
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+
+ // IMediaSeeking
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+
+ // IVideoWindow
+ STDMETHODIMP put_Visible(long Visible);
+ STDMETHODIMP get_Visible(long* pVisible);
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+
+ // IBasicVideo
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
+
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
+ };
}
using namespace DSObjects;
diff --git a/src/apps/mplayerc/StaticLink.cpp b/src/apps/mplayerc/StaticLink.cpp
index a92bfcbeb..1cef8503c 100644
--- a/src/apps/mplayerc/StaticLink.cpp
+++ b/src/apps/mplayerc/StaticLink.cpp
@@ -28,152 +28,142 @@
// CStaticLink
-COLORREF CStaticLink::g_colorUnvisited = RGB(0, 0, 255); // blue
-COLORREF CStaticLink::g_colorVisited = RGB(128, 0, 128); // purple
-
-HCURSOR CStaticLink::g_hCursorLink = NULL;
-
-IMPLEMENT_DYNAMIC(CStaticLink, CStatic)
-
-BEGIN_MESSAGE_MAP(CStaticLink, CStatic)
- ON_WM_NCHITTEST()
- ON_WM_CTLCOLOR_REFLECT()
- ON_WM_LBUTTONDOWN()
- ON_WM_SETCURSOR()
-END_MESSAGE_MAP()
-
-///////////////////
-// Constructor sets default colors = blue/purple.
-// bDeleteOnDestroy is used internally by PixieLib in CPixieDlg.
-//
-CStaticLink::CStaticLink(LPCTSTR lpText, BOOL bDeleteOnDestroy)
-{
- m_link = lpText; // link text (NULL ==> window text)
- m_color = g_colorUnvisited; // not visited yet
- m_bDeleteOnDestroy = bDeleteOnDestroy; // delete object with window?
-}
-
-//////////////////
-// Normally, a static control does not get mouse events unless it has
-// SS_NOTIFY. This achieves the same effect as SS_NOTIFY, but it's fewer
-// lines of code and more reliable than turning on SS_NOTIFY in OnCtlColor
-// because Windows doesn't send WM_CTLCOLOR to bitmap static controls.
-//
-LRESULT CStaticLink::OnNcHitTest(CPoint point)
-{
- return HTCLIENT;
-}
-
-//////////////////
-// Handle reflected WM_CTLCOLOR to set custom control color.
-// For a text control, use visited/unvisited colors and underline font.
-// For non-text controls, do nothing. Also ensures SS_NOTIFY is on.
-//
-HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT nCtlColor)
-{
- ASSERT(nCtlColor == CTLCOLOR_STATIC);
- DWORD dwStyle = GetStyle();
-
- HBRUSH hbr = NULL;
- if((dwStyle & 0xFF) <= SS_RIGHT)
- {
-
- // this is a text control: set up font and colors
- if(!(HFONT)m_font)
- {
- // first time init: create font
- LOGFONT lf;
- GetFont()->GetObject(sizeof(lf), &lf);
- lf.lfUnderline = TRUE;
- m_font.CreateFontIndirect(&lf);
- }
-
- // use underline font and visited/unvisited colors
- pDC->SelectObject(&m_font);
- pDC->SetTextColor(m_color);
- pDC->SetBkMode(TRANSPARENT);
-
- // return hollow brush to preserve parent background color
- hbr = (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
- }
- return hbr;
-}
-
-/////////////////
-// Handle mouse click: navigate link
-//
-void CStaticLink::OnLButtonDown(UINT nFlags, CPoint point)
-{
- if(m_link.IsEmpty())
- {
- // no link: try to load from resource string or window text
- m_link.LoadString(GetDlgCtrlID()) || (GetWindowText(m_link), 1);
- if(m_link.IsEmpty())
- return;
- }
-
- // Call ShellExecute to run the file.
- // For an URL, this means opening it in the browser.
- //
- HINSTANCE h = m_link.Navigate();
- if((UINT)h > 32) // success!
- {
- m_color = g_colorVisited; // change color
- Invalidate(); // repaint
- }
- else
- {
- MessageBeep(0); // unable to execute file!
- TRACE(_T("*** WARNING: CStaticLink: unable to navigate link %s\n"),
- (LPCTSTR)m_link);
- }
-}
-
-//////////////////
-// Set "hand" cursor to cue user that this is a link. If app has not set
-// g_hCursorLink, then try to get the cursor from winhlp32.exe,
-// resource 106, which is a pointing finger. This is a bit of a kludge,
-// but it works.
-//
-BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
-{
- if(g_hCursorLink == NULL)
- {
- static BOOL bTriedOnce = FALSE;
- if(!bTriedOnce)
- {
- CString windir;
- GetWindowsDirectory(windir.GetBuffer(MAX_PATH), MAX_PATH);
- windir.ReleaseBuffer();
- windir += _T("\\winhlp32.exe");
- HMODULE hModule = LoadLibrary(windir);
- if(hModule)
- {
- g_hCursorLink =
- CopyCursor(::LoadCursor(hModule, MAKEINTRESOURCE(106)));
- }
- FreeLibrary(hModule);
- bTriedOnce = TRUE;
- }
- }
- if(g_hCursorLink)
- {
- ::SetCursor(g_hCursorLink);
- return TRUE;
- }
- return FALSE;
-}
-
-//////////////////
-// Normally, a control class is not destoyed when the window is;
-// however, CPixieDlg creates static controls with "new" instead of
-// as class members, so it's convenient to allow the option of destroying
-// object with window. In applications where you want the object to be
-// destoyed along with the window, you can call constructor with
-// bDeleteOnDestroy=TRUE.
-//
-void CStaticLink::PostNcDestroy()
-{
- if(m_bDeleteOnDestroy)
- delete this;
-}
+COLORREF CStaticLink::g_colorUnvisited = RGB(0,0,255); // blue
+COLORREF CStaticLink::g_colorVisited = RGB(128,0,128); // purple
+
+HCURSOR CStaticLink::g_hCursorLink = NULL;
+
+IMPLEMENT_DYNAMIC(CStaticLink, CStatic)
+
+BEGIN_MESSAGE_MAP(CStaticLink, CStatic)
+ ON_WM_NCHITTEST()
+ ON_WM_CTLCOLOR_REFLECT()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_SETCURSOR()
+END_MESSAGE_MAP()
+
+///////////////////
+// Constructor sets default colors = blue/purple.
+// bDeleteOnDestroy is used internally by PixieLib in CPixieDlg.
+//
+CStaticLink::CStaticLink(LPCTSTR lpText, BOOL bDeleteOnDestroy)
+{
+ m_link = lpText; // link text (NULL ==> window text)
+ m_color = g_colorUnvisited; // not visited yet
+ m_bDeleteOnDestroy = bDeleteOnDestroy; // delete object with window?
+}
+
+//////////////////
+// Normally, a static control does not get mouse events unless it has
+// SS_NOTIFY. This achieves the same effect as SS_NOTIFY, but it's fewer
+// lines of code and more reliable than turning on SS_NOTIFY in OnCtlColor
+// because Windows doesn't send WM_CTLCOLOR to bitmap static controls.
+//
+LRESULT CStaticLink::OnNcHitTest(CPoint point)
+{
+ return HTCLIENT;
+}
+
+//////////////////
+// Handle reflected WM_CTLCOLOR to set custom control color.
+// For a text control, use visited/unvisited colors and underline font.
+// For non-text controls, do nothing. Also ensures SS_NOTIFY is on.
+//
+HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT nCtlColor)
+{
+ ASSERT(nCtlColor == CTLCOLOR_STATIC);
+ DWORD dwStyle = GetStyle();
+
+ HBRUSH hbr = NULL;
+ if ((dwStyle & 0xFF) <= SS_RIGHT) {
+
+ // this is a text control: set up font and colors
+ if (!(HFONT)m_font) {
+ // first time init: create font
+ LOGFONT lf;
+ GetFont()->GetObject(sizeof(lf), &lf);
+ lf.lfUnderline = TRUE;
+ m_font.CreateFontIndirect(&lf);
+ }
+
+ // use underline font and visited/unvisited colors
+ pDC->SelectObject(&m_font);
+ pDC->SetTextColor(m_color);
+ pDC->SetBkMode(TRANSPARENT);
+
+ // return hollow brush to preserve parent background color
+ hbr = (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
+ }
+ return hbr;
+}
+
+/////////////////
+// Handle mouse click: navigate link
+//
+void CStaticLink::OnLButtonDown(UINT nFlags, CPoint point)
+{
+ if (m_link.IsEmpty()) {
+ // no link: try to load from resource string or window text
+ m_link.LoadString(GetDlgCtrlID()) || (GetWindowText(m_link),1);
+ if (m_link.IsEmpty())
+ return;
+ }
+
+ // Call ShellExecute to run the file.
+ // For an URL, this means opening it in the browser.
+ //
+ HINSTANCE h = m_link.Navigate();
+ if ((UINT)h > 32) { // success!
+ m_color = g_colorVisited; // change color
+ Invalidate(); // repaint
+ } else {
+ MessageBeep(0); // unable to execute file!
+ TRACE(_T("*** WARNING: CStaticLink: unable to navigate link %s\n"),
+ (LPCTSTR)m_link);
+ }
+}
+
+//////////////////
+// Set "hand" cursor to cue user that this is a link. If app has not set
+// g_hCursorLink, then try to get the cursor from winhlp32.exe,
+// resource 106, which is a pointing finger. This is a bit of a kludge,
+// but it works.
+//
+BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
+{
+ if (g_hCursorLink == NULL) {
+ static BOOL bTriedOnce = FALSE;
+ if (!bTriedOnce) {
+ CString windir;
+ GetWindowsDirectory(windir.GetBuffer(MAX_PATH), MAX_PATH);
+ windir.ReleaseBuffer();
+ windir += _T("\\winhlp32.exe");
+ HMODULE hModule = LoadLibrary(windir);
+ if (hModule) {
+ g_hCursorLink =
+ CopyCursor(::LoadCursor(hModule, MAKEINTRESOURCE(106)));
+ }
+ FreeLibrary(hModule);
+ bTriedOnce = TRUE;
+ }
+ }
+ if (g_hCursorLink) {
+ ::SetCursor(g_hCursorLink);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//////////////////
+// Normally, a control class is not destoyed when the window is;
+// however, CPixieDlg creates static controls with "new" instead of
+// as class members, so it's convenient to allow the option of destroying
+// object with window. In applications where you want the object to be
+// destoyed along with the window, you can call constructor with
+// bDeleteOnDestroy=TRUE.
+//
+void CStaticLink::PostNcDestroy()
+{
+ if (m_bDeleteOnDestroy)
+ delete this;
+}
diff --git a/src/apps/mplayerc/StaticLink.h b/src/apps/mplayerc/StaticLink.h
index a08a93e65..f185fda73 100644
--- a/src/apps/mplayerc/StaticLink.h
+++ b/src/apps/mplayerc/StaticLink.h
@@ -25,61 +25,57 @@
// CHyperlink
-class CHyperlink : public CString
-{
-public:
- CHyperlink(LPCTSTR lpLink = NULL) : CString(lpLink) { }
- ~CHyperlink() { }
- const CHyperlink& operator=(LPCTSTR lpsz)
- {
- CString::operator=(lpsz);
- return *this;
- }
- operator LPCTSTR()
- {
- return CString::operator LPCTSTR();
- }
- virtual HINSTANCE Navigate()
- {
- return IsEmpty() ? NULL :
- ShellExecute(0, _T("open"), *this, 0, 0, SW_SHOWNORMAL);
- }
+class CHyperlink : public CString {
+public:
+ CHyperlink(LPCTSTR lpLink = NULL) : CString(lpLink) { }
+ ~CHyperlink() { }
+ const CHyperlink& operator=(LPCTSTR lpsz) {
+ CString::operator=(lpsz);
+ return *this;
+ }
+ operator LPCTSTR() {
+ return CString::operator LPCTSTR();
+ }
+ virtual HINSTANCE Navigate() {
+ return IsEmpty() ? NULL :
+ ShellExecute(0, _T("open"), *this, 0, 0, SW_SHOWNORMAL);
+ }
};
// CStaticLink
class CStaticLink : public CStatic
{
-public:
- DECLARE_DYNAMIC(CStaticLink)
- CStaticLink(LPCTSTR lpText = NULL, BOOL bDeleteOnDestroy = FALSE);
- ~CStaticLink() { }
+public:
+ DECLARE_DYNAMIC(CStaticLink)
+ CStaticLink(LPCTSTR lpText = NULL, BOOL bDeleteOnDestroy=FALSE);
+ ~CStaticLink() { }
- // Hyperlink contains URL/filename. If NULL, I will use the window text.
- // (GetWindowText) to get the target.
- CHyperlink m_link;
- COLORREF m_color;
+ // Hyperlink contains URL/filename. If NULL, I will use the window text.
+ // (GetWindowText) to get the target.
+ CHyperlink m_link;
+ COLORREF m_color;
- // Default colors you can change
- // These are global, so they're the same for all links.
- static COLORREF g_colorUnvisited;
- static COLORREF g_colorVisited;
+ // Default colors you can change
+ // These are global, so they're the same for all links.
+ static COLORREF g_colorUnvisited;
+ static COLORREF g_colorVisited;
- // Cursor used when mouse is on a link--you can set, or
- // it will default to the standard hand with pointing finger.
- // This is global, so it's the same for all links.
- static HCURSOR g_hCursorLink;
+ // Cursor used when mouse is on a link--you can set, or
+ // it will default to the standard hand with pointing finger.
+ // This is global, so it's the same for all links.
+ static HCURSOR g_hCursorLink;
-protected:
- CFont m_font; // underline font for text control
- bool m_bDeleteOnDestroy; // delete object when window destroyed?
+protected:
+ CFont m_font; // underline font for text control
+ bool m_bDeleteOnDestroy; // delete object when window destroyed?
- virtual void PostNcDestroy();
+ virtual void PostNcDestroy();
- // message handlers
- DECLARE_MESSAGE_MAP()
- afx_msg LRESULT OnNcHitTest(CPoint point);
- afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ // message handlers
+ DECLARE_MESSAGE_MAP()
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+ afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
};
diff --git a/src/apps/mplayerc/StatusLabel.cpp b/src/apps/mplayerc/StatusLabel.cpp
index 1e29bfe9c..8bece1a79 100644
--- a/src/apps/mplayerc/StatusLabel.cpp
+++ b/src/apps/mplayerc/StatusLabel.cpp
@@ -29,24 +29,24 @@
// CStatusLabel
IMPLEMENT_DYNAMIC(CStatusLabel, CStatic)
-CStatusLabel::CStatusLabel(bool fRightAlign, bool fAddEllipses)
- : m_fRightAlign(fRightAlign)
- , m_fAddEllipses(fAddEllipses)
+CStatusLabel::CStatusLabel(bool fRightAlign, bool fAddEllipses)
+ : m_fRightAlign(fRightAlign)
+ , m_fAddEllipses(fAddEllipses)
{
- HDC hdc = ::GetDC(NULL);
- double scale = 1.0 * GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;
- ::ReleaseDC(0, hdc);
+ HDC hdc = ::GetDC(NULL);
+ double scale = 1.0*GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;
+ ::ReleaseDC(0, hdc);
- m_font.m_hObject = NULL;
+ m_font.m_hObject = NULL;
- if(!(::GetVersion() & 0x80000000))
- m_font.CreateFont(int(14.0 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
- _T("Microsoft Sans Serif"));
- if(!m_font.m_hObject)
- m_font.CreateFont(int(14.0 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
- _T("MS Sans Serif"));
+ if(!(::GetVersion()&0x80000000))
+ m_font.CreateFont(int(14.0 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
+ _T("Microsoft Sans Serif"));
+ if(!m_font.m_hObject)
+ m_font.CreateFont(int(14.0 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
+ _T("MS Sans Serif"));
}
CStatusLabel::~CStatusLabel()
@@ -54,43 +54,43 @@ CStatusLabel::~CStatusLabel()
}
BEGIN_MESSAGE_MAP(CStatusLabel, CStatic)
- ON_WM_ERASEBKGND()
+ ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
// CStatusLabel message handlers
void CStatusLabel::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- CDC dc;
- dc.Attach(lpDrawItemStruct->hDC);
- CString str;
- GetWindowText(str);
- CRect r;
- GetClientRect(&r);
- CFont* old = dc.SelectObject(&m_font);
- dc.SetTextColor(0xffffff);
- dc.SetBkColor(0);
- CSize size = dc.GetTextExtent(str);
- CPoint p = CPoint(m_fRightAlign ? r.Width() - size.cx : 0, (r.Height() - size.cy) / 2);
+ CDC dc;
+ dc.Attach(lpDrawItemStruct->hDC);
+ CString str;
+ GetWindowText(str);
+ CRect r;
+ GetClientRect(&r);
+ CFont* old = dc.SelectObject(&m_font);
+ dc.SetTextColor(0xffffff);
+ dc.SetBkColor(0);
+ CSize size = dc.GetTextExtent(str);
+ CPoint p = CPoint(m_fRightAlign ? r.Width() - size.cx : 0, (r.Height()-size.cy)/2);
- if(m_fAddEllipses)
- while(size.cx > r.Width() - 3 && str.GetLength() > 3)
- {
- str = str.Left(str.GetLength() - 4) + _T("...");
- size = dc.GetTextExtent(str);
- }
+ if(m_fAddEllipses)
+ while(size.cx > r.Width()-3 && str.GetLength() > 3)
+ {
+ str = str.Left(str.GetLength()-4) + _T("...");
+ size = dc.GetTextExtent(str);
+ }
- dc.TextOut(p.x, p.y, str);
- dc.ExcludeClipRect(CRect(p, size));
- dc.SelectObject(&old);
- dc.FillSolidRect(&r, 0);
- dc.Detach();
+ dc.TextOut(p.x, p.y, str);
+ dc.ExcludeClipRect(CRect(p, size));
+ dc.SelectObject(&old);
+ dc.FillSolidRect(&r, 0);
+ dc.Detach();
}
BOOL CStatusLabel::OnEraseBkgnd(CDC* pDC)
{
- CRect r;
- GetClientRect(&r);
- pDC->FillSolidRect(&r, 0);
- return TRUE;
+ CRect r;
+ GetClientRect(&r);
+ pDC->FillSolidRect(&r, 0);
+ return TRUE;
}
diff --git a/src/apps/mplayerc/StatusLabel.h b/src/apps/mplayerc/StatusLabel.h
index 1cec2b5d4..42fd6d50f 100644
--- a/src/apps/mplayerc/StatusLabel.h
+++ b/src/apps/mplayerc/StatusLabel.h
@@ -27,26 +27,23 @@
class CStatusLabel : public CStatic
{
- DECLARE_DYNAMIC(CStatusLabel)
+ DECLARE_DYNAMIC(CStatusLabel)
private:
- bool m_fRightAlign, m_fAddEllipses;
- CFont m_font;
+ bool m_fRightAlign, m_fAddEllipses;
+ CFont m_font;
public:
- CStatusLabel(bool fRightAlign, bool fAddEllipses);
- virtual ~CStatusLabel();
+ CStatusLabel(bool fRightAlign, bool fAddEllipses);
+ virtual ~CStatusLabel();
- CFont& GetFont()
- {
- return m_font;
- }
+ CFont& GetFont() {return m_font;}
- void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
+ void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};
diff --git a/src/apps/mplayerc/Struct.h b/src/apps/mplayerc/Struct.h
index 83e45e992..cffe115c7 100644
--- a/src/apps/mplayerc/Struct.h
+++ b/src/apps/mplayerc/Struct.h
@@ -9,11 +9,11 @@
#include <winternl.h>
#ifdef _WIN64
-typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
-typedef ULONG_PTR KAFFINITY, *PKAFFINITY;
+ typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
+ typedef ULONG_PTR KAFFINITY, *PKAFFINITY;
#else
-typedef unsigned long ULONG_PTR, *PULONG_PTR;
-typedef ULONG KAFFINITY, *PKAFFINITY;
+ typedef unsigned long ULONG_PTR, *PULONG_PTR;
+ typedef ULONG KAFFINITY, *PKAFFINITY;
#endif
typedef LONG NTSTATUS, *PNTSTATUS;
@@ -25,10 +25,9 @@ typedef LONG KPRIORITY;
typedef void (CALLBACK *PKNORMAL_ROUTINE)(PVOID, PVOID, PVOID);
-typedef struct _CLIENT_ID
-{
- HANDLE UniqueProcess;
- HANDLE UniqueThread;
+typedef struct _CLIENT_ID {
+ HANDLE UniqueProcess;
+ HANDLE UniqueThread;
} CLIENT_ID, *PCLIENT_ID;
#define InitializeObjectAttributes( p, n, a, r, s ) { \
@@ -49,16 +48,14 @@ typedef struct _CLIENT_ID
#define OBJ_KERNEL_HANDLE 0x00000200L
-typedef struct RTL_DRIVE_LETTER_CURDIR // Size = 0x10
-{
+typedef struct RTL_DRIVE_LETTER_CURDIR { // Size = 0x10
USHORT Flags;
USHORT Length;
ULONG TimeStamp;
UNICODE_STRING DosPath;
} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
-typedef struct _RTL_USER_PROCESS_PARAMETERS_MPC // Size = 0x290
-{
+typedef struct _RTL_USER_PROCESS_PARAMETERS_MPC { // Size = 0x290
ULONG AllocationSize;
ULONG Size;
ULONG Flags;
@@ -90,25 +87,23 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS_MPC // Size = 0x290
RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
} RTL_USER_PROCESS_PARAMETERS_MPC, *PRTL_USER_PROCESS_PARAMETERS_MPC;
-typedef struct _LDR_MODULE
-{
- LIST_ENTRY InLoadOrderModuleList;
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
- PVOID BaseAddress;
- PVOID EntryPoint;
- ULONG SizeOfImage;
- UNICODE_STRING FullDllName;
- UNICODE_STRING BaseDllName;
- ULONG Flags;
- SHORT LoadCount;
- SHORT TlsIndex;
- LIST_ENTRY HashTableEntry;
- ULONG TimeDateStamp;
+typedef struct _LDR_MODULE {
+ LIST_ENTRY InLoadOrderModuleList;
+ LIST_ENTRY InMemoryOrderModuleList;
+ LIST_ENTRY InInitializationOrderModuleList;
+ PVOID BaseAddress;
+ PVOID EntryPoint;
+ ULONG SizeOfImage;
+ UNICODE_STRING FullDllName;
+ UNICODE_STRING BaseDllName;
+ ULONG Flags;
+ SHORT LoadCount;
+ SHORT TlsIndex;
+ LIST_ENTRY HashTableEntry;
+ ULONG TimeDateStamp;
} LDR_MODULE, *PLDR_MODULE;
-typedef struct _PEB_LDR_DATA_MPC // Size = 0x24
-{
+typedef struct _PEB_LDR_DATA_MPC { // Size = 0x24
ULONG Length; // 00
BOOLEAN Initialized; // 04
PVOID SsHandle; // 08
@@ -118,15 +113,13 @@ typedef struct _PEB_LDR_DATA_MPC // Size = 0x24
// void * EntryInProgress; // 24
} PEB_LDR_DATA_MPC, *PPEB_LDR_DATA_MPC;
-typedef struct _PEB_FREE_BLOCK // Size = 8
-{
- struct _PEB_FREE_BLOCK *Next;
- ULONG Size;
+typedef struct _PEB_FREE_BLOCK { // Size = 8
+struct _PEB_FREE_BLOCK *Next;
+ULONG Size;
} PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
// Structured Exception Handler
-typedef struct _SEH
-{
+typedef struct _SEH {
struct _SEH *pNext;
FARPROC pfnHandler;
} SEH, *PSEH;
@@ -134,14 +127,12 @@ typedef struct _SEH
#pragma pack(1)
// Thread Information Block (FS:[0])
-typedef struct _TIB_NT
-{
+typedef struct _TIB_NT {
PSEH pvExcept; // 00 Head of exception record list
PVOID pvStackBase; // 04
PVOID pvStackLimit; // 08
PVOID SubSystemTib; // 0C
- union
- {
+ union {
PVOID FiberData; // 10
DWORD Version;
};
@@ -153,126 +144,124 @@ typedef void (*PPEBLOCKROUTINE)(PVOID);
// PEB (Process Environment Block) data structure (FS:[0x30])
// Located at addr. 0x7FFDF000
-typedef struct _PEB_NT // Size = 0x1E8
-{
- BOOLEAN InheritedAddressSpace; //000
- BOOLEAN ReadImageFileExecOptions; //001
- BOOLEAN BeingDebugged; //002
- BOOLEAN SpareBool; //003 Allocation size
- HANDLE Mutant; //004
- HINSTANCE ImageBaseAddress; //008 Instance
- PPEB_LDR_DATA_MPC LdrData; //00C
- PRTL_USER_PROCESS_PARAMETERS_MPC ProcessParameters; //010
- ULONG SubSystemData; //014
- HANDLE ProcessHeap; //018
- KSPIN_LOCK FastPebLock; //01C
- PPEBLOCKROUTINE FastPebLockRoutine; //020
- PPEBLOCKROUTINE FastPebUnlockRoutine; //024
- ULONG EnvironmentUpdateCount; //028
- PVOID * KernelCallbackTable; //02C
- PVOID EventLogSection; //030
- PVOID EventLog; //034
- PPEB_FREE_BLOCK FreeList; //038
- ULONG TlsExpansionCounter; //03C
- ULONG TlsBitmap; //040
- LARGE_INTEGER TlsBitmapBits; //044
- PVOID ReadOnlySharedMemoryBase; //04C
- PVOID ReadOnlySharedMemoryHeap; //050
- PVOID * ReadOnlyStaticServerData; //054
- PVOID AnsiCodePageData; //058
- PVOID OemCodePageData; //05C
- PVOID UnicodeCaseTableData; //060
- ULONG NumberOfProcessors; //064
- LARGE_INTEGER NtGlobalFlag; //068 Address of a local copy
- LARGE_INTEGER CriticalSectionTimeout; //070
- ULONG HeapSegmentReserve; //078
- ULONG HeapSegmentCommit; //07C
- ULONG HeapDeCommitTotalFreeThreshold; //080
- ULONG HeapDeCommitFreeBlockThreshold; //084
- ULONG NumberOfHeaps; //088
- ULONG MaximumNumberOfHeaps; //08C
- PVOID ** ProcessHeaps; //090
- PVOID GdiSharedHandleTable; //094
- PVOID ProcessStarterHelper; //098
- PVOID GdiDCAttributeList; //09C
- KSPIN_LOCK LoaderLock; //0A0
- ULONG OSMajorVersion; //0A4
- ULONG OSMinorVersion; //0A8
- USHORT OSBuildNumber; //0AC
- USHORT OSCSDVersion; //0AE
- ULONG OSPlatformId; //0B0
- ULONG ImageSubsystem; //0B4
- ULONG ImageSubsystemMajorVersion; //0B8
- ULONG ImageSubsystemMinorVersion; //0BC
- ULONG ImageProcessAffinityMask; //0C0
- ULONG GdiHandleBuffer[0x22]; //0C4
- ULONG PostProcessInitRoutine; //14C
- ULONG TlsExpansionBitmap; //150
- UCHAR TlsExpansionBitmapBits[0x80]; //154
- ULONG SessionId; //1D4
- void * AppCompatInfo; //1D8
- UNICODE_STRING CSDVersion; //1DC
+typedef struct _PEB_NT { // Size = 0x1E8
+ BOOLEAN InheritedAddressSpace; //000
+ BOOLEAN ReadImageFileExecOptions; //001
+ BOOLEAN BeingDebugged; //002
+ BOOLEAN SpareBool; //003 Allocation size
+ HANDLE Mutant; //004
+ HINSTANCE ImageBaseAddress; //008 Instance
+ PPEB_LDR_DATA_MPC LdrData; //00C
+ PRTL_USER_PROCESS_PARAMETERS_MPC ProcessParameters; //010
+ ULONG SubSystemData; //014
+ HANDLE ProcessHeap; //018
+ KSPIN_LOCK FastPebLock; //01C
+ PPEBLOCKROUTINE FastPebLockRoutine; //020
+ PPEBLOCKROUTINE FastPebUnlockRoutine; //024
+ ULONG EnvironmentUpdateCount; //028
+ PVOID * KernelCallbackTable; //02C
+ PVOID EventLogSection; //030
+ PVOID EventLog; //034
+ PPEB_FREE_BLOCK FreeList; //038
+ ULONG TlsExpansionCounter; //03C
+ ULONG TlsBitmap; //040
+ LARGE_INTEGER TlsBitmapBits; //044
+ PVOID ReadOnlySharedMemoryBase; //04C
+ PVOID ReadOnlySharedMemoryHeap; //050
+ PVOID * ReadOnlyStaticServerData; //054
+ PVOID AnsiCodePageData; //058
+ PVOID OemCodePageData; //05C
+ PVOID UnicodeCaseTableData; //060
+ ULONG NumberOfProcessors; //064
+ LARGE_INTEGER NtGlobalFlag; //068 Address of a local copy
+ LARGE_INTEGER CriticalSectionTimeout; //070
+ ULONG HeapSegmentReserve; //078
+ ULONG HeapSegmentCommit; //07C
+ ULONG HeapDeCommitTotalFreeThreshold; //080
+ ULONG HeapDeCommitFreeBlockThreshold; //084
+ ULONG NumberOfHeaps; //088
+ ULONG MaximumNumberOfHeaps; //08C
+ PVOID ** ProcessHeaps; //090
+ PVOID GdiSharedHandleTable; //094
+ PVOID ProcessStarterHelper; //098
+ PVOID GdiDCAttributeList; //09C
+ KSPIN_LOCK LoaderLock; //0A0
+ ULONG OSMajorVersion; //0A4
+ ULONG OSMinorVersion; //0A8
+ USHORT OSBuildNumber; //0AC
+ USHORT OSCSDVersion; //0AE
+ ULONG OSPlatformId; //0B0
+ ULONG ImageSubsystem; //0B4
+ ULONG ImageSubsystemMajorVersion; //0B8
+ ULONG ImageSubsystemMinorVersion; //0BC
+ ULONG ImageProcessAffinityMask; //0C0
+ ULONG GdiHandleBuffer[0x22]; //0C4
+ ULONG PostProcessInitRoutine; //14C
+ ULONG TlsExpansionBitmap; //150
+ UCHAR TlsExpansionBitmapBits[0x80]; //154
+ ULONG SessionId; //1D4
+ void * AppCompatInfo; //1D8
+ UNICODE_STRING CSDVersion; //1DC
} PEB_NT, *PPEB_NT;
// TEB (Thread Environment Block) data structure (FS:[0x18])
// Located at 0x7FFDE000, 0x7FFDD000, ...
-typedef struct _TEB_NT // Size = 0xF88
-{
- NT_TIB Tib; //000
- PVOID EnvironmentPointer; //01C
- CLIENT_ID ClientId; //020
- HANDLE ActiveRpcHandle; //028
- PVOID ThreadLocalStoragePointer; //02C
- PPEB_NT ProcessEnvironmentBlock; //030 PEB
- ULONG LastErrorValue; //034
- ULONG CountOfOwnedCriticalSections; //038
- ULONG CsrClientThread; //03C
- ULONG Win32ThreadInfo; //040
- UCHAR Win32ClientInfo[0x7C]; //044
- ULONG WOW32Reserved; //0C0
- ULONG CurrentLocale; //0C4
- ULONG FpSoftwareStatusRegister; //0C8
- UCHAR SystemReserved1[0xD8]; //0CC
- ULONG Spare1; //1A4
- ULONG ExceptionCode; //1A8
- UCHAR SpareBytes1[0x28]; //1AC
- UCHAR SystemReserved2[0x28]; //1D4
- UCHAR GdiTebBatch[0x4E0]; //1FC
- ULONG GdiRgn; //6DC
- ULONG GdiPen; //6E0
- ULONG GdiBrush; //6E4
- CLIENT_ID RealClientId; //6E8
- ULONG GdiCachedProcessHandle; //6F0
- ULONG GdiClientPID; //6F4
- ULONG GdiClientTID; //6F8
- ULONG GdiThreadLocalInfo; //6FC
- UCHAR UserReserved[0x14]; //700
- UCHAR glDispatchTable[0x460]; //714
- UCHAR glReserved1[0x68]; //B74
- ULONG glReserved2; //BDC
- ULONG glSectionInfo; //BE0
- ULONG glSection; //BE4
- ULONG glTable; //BE8
- ULONG glCurrentRC; //BEC
- ULONG glContext; //BF0
- ULONG LastStatusValue; //BF4
- LARGE_INTEGER StaticUnicodeString; //BF8
- UCHAR StaticUnicodeBuffer[0x20C]; //C00
- ULONG DeallocationStack; //E0C
- UCHAR TlsSlots[0x100]; //E10
- LARGE_INTEGER TlsLinks; //F10
- ULONG Vdm; //F18
- ULONG ReservedForNtRpc; //F1C
- LARGE_INTEGER DbgSsReserved; //F20
- ULONG HardErrorsAreDisabled; //F28
- UCHAR Instrumentation[0x40]; //F2C
- ULONG WinSockData; //F6C
- ULONG GdiBatchCount; //F70
- ULONG Spare2; //F74
- ULONG Spare3; //F78
- ULONG Spare4; //F7C
- ULONG ReservedForOle; //F80
- ULONG WaitingOnLoaderLock; //F84
+typedef struct _TEB_NT { // Size = 0xF88
+ NT_TIB Tib; //000
+ PVOID EnvironmentPointer; //01C
+ CLIENT_ID ClientId; //020
+ HANDLE ActiveRpcHandle; //028
+ PVOID ThreadLocalStoragePointer; //02C
+ PPEB_NT ProcessEnvironmentBlock; //030 PEB
+ ULONG LastErrorValue; //034
+ ULONG CountOfOwnedCriticalSections; //038
+ ULONG CsrClientThread; //03C
+ ULONG Win32ThreadInfo; //040
+ UCHAR Win32ClientInfo[0x7C]; //044
+ ULONG WOW32Reserved; //0C0
+ ULONG CurrentLocale; //0C4
+ ULONG FpSoftwareStatusRegister; //0C8
+ UCHAR SystemReserved1[0xD8]; //0CC
+ ULONG Spare1; //1A4
+ ULONG ExceptionCode; //1A8
+ UCHAR SpareBytes1[0x28]; //1AC
+ UCHAR SystemReserved2[0x28]; //1D4
+ UCHAR GdiTebBatch[0x4E0]; //1FC
+ ULONG GdiRgn; //6DC
+ ULONG GdiPen; //6E0
+ ULONG GdiBrush; //6E4
+ CLIENT_ID RealClientId; //6E8
+ ULONG GdiCachedProcessHandle; //6F0
+ ULONG GdiClientPID; //6F4
+ ULONG GdiClientTID; //6F8
+ ULONG GdiThreadLocalInfo; //6FC
+ UCHAR UserReserved[0x14]; //700
+ UCHAR glDispatchTable[0x460]; //714
+ UCHAR glReserved1[0x68]; //B74
+ ULONG glReserved2; //BDC
+ ULONG glSectionInfo; //BE0
+ ULONG glSection; //BE4
+ ULONG glTable; //BE8
+ ULONG glCurrentRC; //BEC
+ ULONG glContext; //BF0
+ ULONG LastStatusValue; //BF4
+ LARGE_INTEGER StaticUnicodeString; //BF8
+ UCHAR StaticUnicodeBuffer[0x20C]; //C00
+ ULONG DeallocationStack; //E0C
+ UCHAR TlsSlots[0x100]; //E10
+ LARGE_INTEGER TlsLinks; //F10
+ ULONG Vdm; //F18
+ ULONG ReservedForNtRpc; //F1C
+ LARGE_INTEGER DbgSsReserved; //F20
+ ULONG HardErrorsAreDisabled; //F28
+ UCHAR Instrumentation[0x40]; //F2C
+ ULONG WinSockData; //F6C
+ ULONG GdiBatchCount; //F70
+ ULONG Spare2; //F74
+ ULONG Spare3; //F78
+ ULONG Spare4; //F7C
+ ULONG ReservedForOle; //F80
+ ULONG WaitingOnLoaderLock; //F84
// PVOID StackCommit;
// PVOID StackCommitMax;
// PVOID StackReserved;
@@ -283,14 +272,13 @@ typedef struct _TEB_NT // Size = 0xF88
-typedef struct _THREAD_BASIC_INFORMATION
-{
- NTSTATUS ExitStatus;
- PTIB_NT TebBaseAddress;
- CLIENT_ID ClientId;
- KAFFINITY AffinityMask;
- KPRIORITY Priority;
- KPRIORITY BasePriority;
+typedef struct _THREAD_BASIC_INFORMATION {
+ NTSTATUS ExitStatus;
+ PTIB_NT TebBaseAddress;
+ CLIENT_ID ClientId;
+ KAFFINITY AffinityMask;
+ KPRIORITY Priority;
+ KPRIORITY BasePriority;
} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
@@ -298,8 +286,7 @@ typedef struct _THREAD_BASIC_INFORMATION
#define SystemProcessesAndThreadsInformation 5
-typedef struct _VM_COUNTERS
-{
+typedef struct _VM_COUNTERS {
SIZE_T PeakVirtualSize;
SIZE_T VirtualSize;
ULONG PageFaultCount;
@@ -313,8 +300,7 @@ typedef struct _VM_COUNTERS
SIZE_T PeakPagefileUsage;
} VM_COUNTERS;
-typedef struct _SYSTEM_THREAD_INFORMATION
-{
+typedef struct _SYSTEM_THREAD_INFORMATION {
LARGE_INTEGER KernelTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER CreateTime;
@@ -331,8 +317,7 @@ typedef struct _SYSTEM_THREAD_INFORMATION
// The size of the SYSTEM_PROCESS_INFORMATION structure is
// different on NT 4 and Win2K.
-typedef struct _SYSTEM_PROCESS_INFORMATION_NT4
-{
+typedef struct _SYSTEM_PROCESS_INFORMATION_NT4 {
ULONG NextEntryDelta;
ULONG ThreadCount;
ULONG Reserved1[6];
@@ -431,8 +416,7 @@ typedef struct _SYSTEM_PROCESS_INFORMATION_NT4
#define BLOCK_TERMINATE_APC 0x00040000
// Environment Database
-typedef struct _ENVIRONMENT_DATABASE
-{
+typedef struct _ENVIRONMENT_DATABASE {
PSTR pszEnvironment; //00 Pointer to Process Environment
DWORD un1; //04 (always 0)
PSTR pszCmdLine; //08 Pointer to command line
@@ -451,15 +435,13 @@ typedef struct _ENVIRONMENT_DATABASE
} EDB, *PEDB;
// Handle Table Entry
-typedef struct _HANDLE_TABLE_ENTRY
-{
+typedef struct _HANDLE_TABLE_ENTRY {
DWORD flags; // Valid flags depend on what type of object this is
PVOID pObject; // Pointer to the object that the handle refers to
} HANDLE_TABLE_ENTRY, *PHANDLE_TABLE_ENTRY;
// Handle Table
-typedef struct _HANDLE_TABLE
-{
+typedef struct _HANDLE_TABLE {
DWORD cEntries; // Max number of handles in table
HANDLE_TABLE_ENTRY array[1]; // An array (number is given by cEntries)
} HANDLE_TABLE, *PHANDLE_TABLE;
@@ -488,8 +470,7 @@ typedef struct _IMTE
} IMTE, *PIMTE;
// Thread Information Block (FS:[0x18])
-typedef struct _TIB95 // Size = 0x34
-{
+typedef struct _TIB95 { // Size = 0x34
PSEH pvExcept; // 00 Pointer to head of structured exception handling chain
PVOID pvStackUserTop; // 04 Max. address for stack
PVOID pvStackUserBase; // 08 Lowest page aligned addr. of stack
@@ -509,8 +490,7 @@ typedef struct _TIB95 // Size = 0x34
// Thread Database Extension
-typedef struct _TDBX95
-{
+typedef struct _TDBX95 {
DWORD ptdb; // 00 TDB
DWORD ppdb; // 04 PDB
DWORD ContextHandle; // 08 R0 memory context
@@ -566,8 +546,7 @@ typedef struct _TDBX98 TDBX98;
typedef struct _PDB98 PDB98;
// Thread Information Block (FS:[0x18])
-typedef struct _TIB98 // Size = 0x38
-{
+typedef struct _TIB98 { // Size = 0x38
PSEH pvExcept; // 00 Head of exception record list
PVOID pvStackUserTop; // 04 Top of user stack
PVOID pvStackUserBase; // 08 Base of user stack
@@ -587,8 +566,7 @@ typedef struct _TIB98 // Size = 0x38
} TIB98, *PTIB98;
// Thread database (FS:[0x18] - 0x8)
-typedef struct _TDB98 // Size = 0x228 (from Kernel32)
-{
+typedef struct _TDB98 { // Size = 0x228 (from Kernel32)
WORD Type; // 00 K32 object type
WORD cReference; // 02 Reference count
DWORD pSomeEvent; // 04 K32 event object used when someone waits on the thread object
@@ -606,8 +584,7 @@ typedef struct _TDB98 // Size = 0x228 (from Kernel32)
} TDB98, *PTDB98;
// Thread database extension
-typedef struct _TDBX98
-{
+typedef struct _TDBX98 {
DWORD un0; // 00
TDB98 *ptdb; // 04 R3 thread database
PDB98 *ppdb; // 08 R3 process database
@@ -638,8 +615,7 @@ typedef struct _TDBX98
typedef TIB98 TIBME;
typedef TIBME *PTIBME;
-typedef struct _TDBME // Size = 0x228 (from Kernel32)
-{
+typedef struct _TDBME { // Size = 0x228 (from Kernel32)
WORD Type; // 00 K32 object type
WORD cReference; // 02 Reference count
DWORD pSomeEvent; // 04 K32 event object used when someone waits on the thread object
diff --git a/src/apps/mplayerc/SubtitleDlDlg.cpp b/src/apps/mplayerc/SubtitleDlDlg.cpp
index 2c9f88bc8..52c23d369 100644
--- a/src/apps/mplayerc/SubtitleDlDlg.cpp
+++ b/src/apps/mplayerc/SubtitleDlDlg.cpp
@@ -30,9 +30,9 @@
//IMPLEMENT_DYNAMIC(CSubtitleDlDlg, CResizableDialog)
CSubtitleDlDlg::CSubtitleDlDlg(CList<isdb_movie>& movies, CWnd* pParent /*=NULL*/)
- : CResizableDialog(CSubtitleDlDlg::IDD, pParent)
+ : CResizableDialog(CSubtitleDlDlg::IDD, pParent)
{
- m_movies.AddTail(&movies);
+ m_movies.AddTail(&movies);
}
CSubtitleDlDlg::~CSubtitleDlDlg()
@@ -41,133 +41,133 @@ CSubtitleDlDlg::~CSubtitleDlDlg()
int CSubtitleDlDlg::GetChecked(int iItem)
{
- LVITEM lvi;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_IMAGE;
- m_list.GetItem(&lvi);
- return(lvi.iImage);
+ LVITEM lvi;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_IMAGE;
+ m_list.GetItem(&lvi);
+ return(lvi.iImage);
}
void CSubtitleDlDlg::SetChecked(int iItem, int iChecked)
{
- LVITEM lvi;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_IMAGE;
- lvi.iImage = iChecked;
- m_list.SetItem(&lvi);
+ LVITEM lvi;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_IMAGE;
+ lvi.iImage = iChecked;
+ m_list.SetItem(&lvi);
}
void CSubtitleDlDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BEGIN_MESSAGE_MAP(CSubtitleDlDlg, CResizableDialog)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
END_MESSAGE_MAP()
// CSubtitleDlDlg message handlers
BOOL CSubtitleDlDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_CHECK1, BOTTOM_LEFT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
+ AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_CHECK1, BOTTOM_LEFT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
- CSize s(200, 150);
- SetMinTrackSize(s);
+ CSize s(200, 150);
+ SetMinTrackSize(s);
- m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
- m_list.InsertColumn(COL_FILENAME, _T("File"), LVCFMT_LEFT, 160);
- m_list.InsertColumn(COL_LANGUAGE, _T("Language"), LVCFMT_CENTER, 80);
- m_list.InsertColumn(COL_FORMAT, _T("Format"), LVCFMT_CENTER, 50);
- m_list.InsertColumn(COL_DISC, _T("Disc"), LVCFMT_CENTER, 50);
- m_list.InsertColumn(COL_TITLES, _T("Title(s)"), LVCFMT_LEFT, 300);
+ m_list.InsertColumn(COL_FILENAME, _T("File"), LVCFMT_LEFT, 160);
+ m_list.InsertColumn(COL_LANGUAGE, _T("Language"), LVCFMT_CENTER, 80);
+ m_list.InsertColumn(COL_FORMAT, _T("Format"), LVCFMT_CENTER, 50);
+ m_list.InsertColumn(COL_DISC, _T("Disc"), LVCFMT_CENTER, 50);
+ m_list.InsertColumn(COL_TITLES, _T("Title(s)"), LVCFMT_LEFT, 300);
- m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff);
- m_list.SetImageList(&m_onoff, LVSIL_SMALL);
+ m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff);
+ m_list.SetImageList(&m_onoff, LVSIL_SMALL);
- int i = 0;
+ int i = 0;
- POSITION pos = m_movies.GetHeadPosition();
- while(pos)
- {
- isdb_movie& m = m_movies.GetNext(pos);
+ POSITION pos = m_movies.GetHeadPosition();
+ while(pos)
+ {
+ isdb_movie& m = m_movies.GetNext(pos);
- CStringA titlesA = Implode(m.titles, '|');
- titlesA.Replace("|", ", ");
- CString titles = UTF8To16(titlesA);
+ CStringA titlesA = Implode(m.titles, '|');
+ titlesA.Replace("|", ", ");
+ CString titles = UTF8To16(titlesA);
- POSITION pos2 = m.subs.GetHeadPosition();
- while(pos2)
- {
- isdb_subtitle& s = m.subs.GetNext(pos2);
- CString name = UTF8To16(s.name);
- CString language = s.language;
- CString format = s.format;
- CString disc;
- disc.Format(_T("%d/%d"), s.disc_no, s.discs);
+ POSITION pos2 = m.subs.GetHeadPosition();
+ while(pos2)
+ {
+ isdb_subtitle& s = m.subs.GetNext(pos2);
+ CString name = UTF8To16(s.name);
+ CString language = s.language;
+ CString format = s.format;
+ CString disc;
+ disc.Format(_T("%d/%d"), s.disc_no, s.discs);
- int iItem = m_list.InsertItem(i++, _T(""));
- m_list.SetItemData(iItem, (DWORD_PTR)&s);
- m_list.SetItemText(iItem, COL_FILENAME, name);
- m_list.SetItemText(iItem, COL_LANGUAGE, language);
- m_list.SetItemText(iItem, COL_FORMAT, format);
- m_list.SetItemText(iItem, COL_DISC, disc);
- m_list.SetItemText(iItem, COL_TITLES, titles);
- }
- }
+ int iItem = m_list.InsertItem(i++, _T(""));
+ m_list.SetItemData(iItem, (DWORD_PTR)&s);
+ m_list.SetItemText(iItem, COL_FILENAME, name);
+ m_list.SetItemText(iItem, COL_LANGUAGE, language);
+ m_list.SetItemText(iItem, COL_FORMAT, format);
+ m_list.SetItemText(iItem, COL_DISC, disc);
+ m_list.SetItemText(iItem, COL_TITLES, titles);
+ }
+ }
- m_selsubs.RemoveAll();
+ m_selsubs.RemoveAll();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CSubtitleDlDlg::OnOK()
{
- for(int i = 0; i < m_list.GetItemCount(); i++)
- if(GetChecked(i))
- m_selsubs.AddTail(*(isdb_subtitle*)m_list.GetItemData(i));
+ for(int i = 0; i < m_list.GetItemCount(); i++)
+ if(GetChecked(i))
+ m_selsubs.AddTail(*(isdb_subtitle*)m_list.GetItemData(i));
- m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;
+ m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;
- __super::OnOK();
+ __super::OnOK();
}
void CSubtitleDlDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
-
- if(lpnmlv->iItem >= 0)
- {
- CRect r;
- m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
- if(r.PtInRect(lpnmlv->ptAction))
- {
- SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem) & 1) == 0 ? 1 : 0);
- }
- }
-
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+
+ if(lpnmlv->iItem >= 0)
+ {
+ CRect r;
+ m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
+ if(r.PtInRect(lpnmlv->ptAction))
+ {
+ SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem)&1) == 0 ? 1 : 0);
+ }
+ }
+
+ *pResult = 0;
}
void CSubtitleDlDlg::OnUpdateOk(CCmdUI* pCmdUI)
{
- bool fEnable = false;
- for(int i = 0; !fEnable && i < m_list.GetItemCount(); i++)
- fEnable = !!GetChecked(i);
+ bool fEnable = false;
+ for(int i = 0; !fEnable && i < m_list.GetItemCount(); i++)
+ fEnable = !!GetChecked(i);
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
diff --git a/src/apps/mplayerc/SubtitleDlDlg.h b/src/apps/mplayerc/SubtitleDlDlg.h
index 1ebf74764..606111d52 100644
--- a/src/apps/mplayerc/SubtitleDlDlg.h
+++ b/src/apps/mplayerc/SubtitleDlDlg.h
@@ -34,33 +34,33 @@ class CSubtitleDlDlg : public CResizableDialog
// DECLARE_DYNAMIC(CSubtitleDlDlg)
private:
- CList<isdb_movie> m_movies;
+ CList<isdb_movie> m_movies;
- enum {COL_FILENAME, COL_LANGUAGE, COL_FORMAT, COL_DISC, COL_TITLES};
+ enum {COL_FILENAME, COL_LANGUAGE, COL_FORMAT, COL_DISC, COL_TITLES};
- CImageList m_onoff;
- int GetChecked(int iItem);
- void SetChecked(int iItem, int iChecked);
+ CImageList m_onoff;
+ int GetChecked(int iItem);
+ void SetChecked(int iItem, int iChecked);
public:
- CSubtitleDlDlg(CList<isdb_movie>& movies, CWnd* pParent = NULL); // standard constructor
- virtual ~CSubtitleDlDlg();
+ CSubtitleDlDlg(CList<isdb_movie>& movies, CWnd* pParent = NULL); // standard constructor
+ virtual ~CSubtitleDlDlg();
- bool m_fReplaceSubs;
- CList<isdb_subtitle> m_selsubs;
+ bool m_fReplaceSubs;
+ CList<isdb_subtitle> m_selsubs;
// Dialog Data
- enum { IDD = IDD_SUBTITLEDL_DLG };
- CListCtrl m_list;
+ enum { IDD = IDD_SUBTITLEDL_DLG };
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
+ afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
};
diff --git a/src/apps/mplayerc/SyncRenderer.cpp b/src/apps/mplayerc/SyncRenderer.cpp
index b0c20ae36..1debdd637 100644
--- a/src/apps/mplayerc/SyncRenderer.cpp
+++ b/src/apps/mplayerc/SyncRenderer.cpp
@@ -34,7 +34,7 @@
#include <d3dx9.h>
#include <Vmr9.h>
#include <evr.h>
-#include <mfapi.h>
+#include <mfapi.h>
#include <Mferror.h>
#include "../../SubPic/DX9SubPic.h"
#include <moreuuids.h>
@@ -49,3977 +49,3837 @@ using namespace GothSync;
CString GothSyncErrorMessage(HRESULT _Error, HMODULE _Module)
{
- switch(_Error)
- {
- case D3DERR_WRONGTEXTUREFORMAT :
- return _T("D3DERR_WRONGTEXTUREFORMAT");
- case D3DERR_UNSUPPORTEDCOLOROPERATION :
- return _T("D3DERR_UNSUPPORTEDCOLOROPERATION");
- case D3DERR_UNSUPPORTEDCOLORARG :
- return _T("D3DERR_UNSUPPORTEDCOLORARG");
- case D3DERR_UNSUPPORTEDALPHAOPERATION :
- return _T("D3DERR_UNSUPPORTEDALPHAOPERATION");
- case D3DERR_UNSUPPORTEDALPHAARG :
- return _T("D3DERR_UNSUPPORTEDALPHAARG");
- case D3DERR_TOOMANYOPERATIONS :
- return _T("D3DERR_TOOMANYOPERATIONS");
- case D3DERR_CONFLICTINGTEXTUREFILTER :
- return _T("D3DERR_CONFLICTINGTEXTUREFILTER");
- case D3DERR_UNSUPPORTEDFACTORVALUE :
- return _T("D3DERR_UNSUPPORTEDFACTORVALUE");
- case D3DERR_CONFLICTINGRENDERSTATE :
- return _T("D3DERR_CONFLICTINGRENDERSTATE");
- case D3DERR_UNSUPPORTEDTEXTUREFILTER :
- return _T("D3DERR_UNSUPPORTEDTEXTUREFILTER");
- case D3DERR_CONFLICTINGTEXTUREPALETTE :
- return _T("D3DERR_CONFLICTINGTEXTUREPALETTE");
- case D3DERR_DRIVERINTERNALERROR :
- return _T("D3DERR_DRIVERINTERNALERROR");
- case D3DERR_NOTFOUND :
- return _T("D3DERR_NOTFOUND");
- case D3DERR_MOREDATA :
- return _T("D3DERR_MOREDATA");
- case D3DERR_DEVICELOST :
- return _T("D3DERR_DEVICELOST");
- case D3DERR_DEVICENOTRESET :
- return _T("D3DERR_DEVICENOTRESET");
- case D3DERR_NOTAVAILABLE :
- return _T("D3DERR_NOTAVAILABLE");
- case D3DERR_OUTOFVIDEOMEMORY :
- return _T("D3DERR_OUTOFVIDEOMEMORY");
- case D3DERR_INVALIDDEVICE :
- return _T("D3DERR_INVALIDDEVICE");
- case D3DERR_INVALIDCALL :
- return _T("D3DERR_INVALIDCALL");
- case D3DERR_DRIVERINVALIDCALL :
- return _T("D3DERR_DRIVERINVALIDCALL");
- case D3DERR_WASSTILLDRAWING :
- return _T("D3DERR_WASSTILLDRAWING");
- case D3DOK_NOAUTOGEN :
- return _T("D3DOK_NOAUTOGEN");
- case D3DERR_DEVICEREMOVED :
- return _T("D3DERR_DEVICEREMOVED");
- case S_NOT_RESIDENT :
- return _T("S_NOT_RESIDENT");
- case S_RESIDENT_IN_SHARED_MEMORY :
- return _T("S_RESIDENT_IN_SHARED_MEMORY");
- case S_PRESENT_MODE_CHANGED :
- return _T("S_PRESENT_MODE_CHANGED");
- case S_PRESENT_OCCLUDED :
- return _T("S_PRESENT_OCCLUDED");
- case D3DERR_DEVICEHUNG :
- return _T("D3DERR_DEVICEHUNG");
- }
-
- CString errmsg;
- LPVOID lpMsgBuf;
- if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
- _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
- {
- errmsg = (LPCTSTR)lpMsgBuf;
- LocalFree(lpMsgBuf);
- }
- CString Temp;
- Temp.Format(L"0x%08x ", _Error);
- return Temp + errmsg;
+ switch (_Error)
+ {
+ case D3DERR_WRONGTEXTUREFORMAT : return _T("D3DERR_WRONGTEXTUREFORMAT");
+ case D3DERR_UNSUPPORTEDCOLOROPERATION : return _T("D3DERR_UNSUPPORTEDCOLOROPERATION");
+ case D3DERR_UNSUPPORTEDCOLORARG : return _T("D3DERR_UNSUPPORTEDCOLORARG");
+ case D3DERR_UNSUPPORTEDALPHAOPERATION : return _T("D3DERR_UNSUPPORTEDALPHAOPERATION");
+ case D3DERR_UNSUPPORTEDALPHAARG : return _T("D3DERR_UNSUPPORTEDALPHAARG");
+ case D3DERR_TOOMANYOPERATIONS : return _T("D3DERR_TOOMANYOPERATIONS");
+ case D3DERR_CONFLICTINGTEXTUREFILTER : return _T("D3DERR_CONFLICTINGTEXTUREFILTER");
+ case D3DERR_UNSUPPORTEDFACTORVALUE : return _T("D3DERR_UNSUPPORTEDFACTORVALUE");
+ case D3DERR_CONFLICTINGRENDERSTATE : return _T("D3DERR_CONFLICTINGRENDERSTATE");
+ case D3DERR_UNSUPPORTEDTEXTUREFILTER : return _T("D3DERR_UNSUPPORTEDTEXTUREFILTER");
+ case D3DERR_CONFLICTINGTEXTUREPALETTE : return _T("D3DERR_CONFLICTINGTEXTUREPALETTE");
+ case D3DERR_DRIVERINTERNALERROR : return _T("D3DERR_DRIVERINTERNALERROR");
+ case D3DERR_NOTFOUND : return _T("D3DERR_NOTFOUND");
+ case D3DERR_MOREDATA : return _T("D3DERR_MOREDATA");
+ case D3DERR_DEVICELOST : return _T("D3DERR_DEVICELOST");
+ case D3DERR_DEVICENOTRESET : return _T("D3DERR_DEVICENOTRESET");
+ case D3DERR_NOTAVAILABLE : return _T("D3DERR_NOTAVAILABLE");
+ case D3DERR_OUTOFVIDEOMEMORY : return _T("D3DERR_OUTOFVIDEOMEMORY");
+ case D3DERR_INVALIDDEVICE : return _T("D3DERR_INVALIDDEVICE");
+ case D3DERR_INVALIDCALL : return _T("D3DERR_INVALIDCALL");
+ case D3DERR_DRIVERINVALIDCALL : return _T("D3DERR_DRIVERINVALIDCALL");
+ case D3DERR_WASSTILLDRAWING : return _T("D3DERR_WASSTILLDRAWING");
+ case D3DOK_NOAUTOGEN : return _T("D3DOK_NOAUTOGEN");
+ case D3DERR_DEVICEREMOVED : return _T("D3DERR_DEVICEREMOVED");
+ case S_NOT_RESIDENT : return _T("S_NOT_RESIDENT");
+ case S_RESIDENT_IN_SHARED_MEMORY : return _T("S_RESIDENT_IN_SHARED_MEMORY");
+ case S_PRESENT_MODE_CHANGED : return _T("S_PRESENT_MODE_CHANGED");
+ case S_PRESENT_OCCLUDED : return _T("S_PRESENT_OCCLUDED");
+ case D3DERR_DEVICEHUNG : return _T("D3DERR_DEVICEHUNG");
+ }
+
+ CString errmsg;
+ LPVOID lpMsgBuf;
+ if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
+ _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
+ {
+ errmsg = (LPCTSTR)lpMsgBuf;
+ LocalFree(lpMsgBuf);
+ }
+ CString Temp;
+ Temp.Format(L"0x%08x ", _Error);
+ return Temp + errmsg;
}
CBaseAP::CBaseAP(HWND hWnd, HRESULT& hr, CString &_Error):
- ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error),
- m_ScreenSize(0, 0),
- m_bicubicA(0),
- m_nDXSurface(1),
- m_nVMR9Surfaces(0),
- m_iVMR9Surface(0),
- m_nCurSurface(0),
- m_bSnapToVSync(false),
- m_bInterlaced(0),
- m_nUsedBuffer(0),
- m_bNeedPendingResetDevice(0),
- m_bPendingResetDevice(0),
- m_TextScale(1.0),
- m_dMainThreadId(0),
- m_bNeedCheckSample(true),
- m_hEvtQuit(INVALID_HANDLE_VALUE),
- m_bIsFullscreen((AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode())),
- m_uSyncGlitches(0),
- m_pGenlock(NULL),
- m_lAudioLag(0),
- m_lAudioLagMin(10000),
- m_lAudioLagMax(-10000),
- m_pAudioStats(NULL),
- m_nNextJitter(0),
- m_nNextSyncOffset(0),
- m_llLastSyncTime(0),
- m_fAvrFps(0.0),
- m_fJitterStdDev(0.0),
- m_fSyncOffsetStdDev(0.0),
- m_fSyncOffsetAvr(0.0),
- m_llHysteresis(0),
- m_uD3DRefreshRate(0),
- m_dD3DRefreshCycle(0),
- m_dDetectedScanlineTime(0.0),
- m_dEstRefreshCycle(0.0),
- m_dFrameCycle(0.0),
- m_dOptimumDisplayCycle(0.0),
- m_dCycleDifference(1.0),
- m_llEstVBlankTime(0)
-{
- if(FAILED(hr))
- {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
-
- HINSTANCE hDll;
- m_pD3DXLoadSurfaceFromMemory = NULL;
- m_pD3DXCreateLine = NULL;
- m_pD3DXCreateFont = NULL;
- m_pD3DXCreateSprite = NULL;
- hDll = AfxGetMyApp()->GetD3X9Dll();
- if(hDll)
- {
- (FARPROC &)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
- (FARPROC &)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
- (FARPROC &)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
- (FARPROC &)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
- }
- else
- {
- _Error += L"No D3DX9 dll found. To enable stats, shaders and complex resizers, please install the latest DirectX End-User Runtime.\n";
- }
-
- m_pDwmIsCompositionEnabled = NULL;
- m_pDwmEnableComposition = NULL;
- m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
- if(m_hDWMAPI)
- {
- (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
- (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
- }
-
- m_pDirect3DCreate9Ex = NULL;
- m_hD3D9 = LoadLibrary(L"d3d9.dll");
- if(m_hD3D9)
- (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
-
- ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
-
- AppSettings& s = AfxGetAppSettings();
- if(s.m_RenderSettings.iVMRDisableDesktopComposition)
- {
- m_bDesktopCompositionDisabled = true;
- if(m_pDwmEnableComposition) m_pDwmEnableComposition(0);
- }
- else
- {
- m_bDesktopCompositionDisabled = false;
- }
-
- m_pGenlock = new CGenlock(s.m_RenderSettings.fTargetSyncOffset, s.m_RenderSettings.fControlLimit, s.m_RenderSettings.iLineDelta, s.m_RenderSettings.iColumnDelta, s.m_RenderSettings.fCycleDelta, 0); // Must be done before CreateDXDevice
- hr = CreateDXDevice(_Error);
- memset(m_pllJitter, 0, sizeof(m_pllJitter));
- memset(m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
-}
-
-CBaseAP::~CBaseAP()
-{
- if(m_bDesktopCompositionDisabled)
- {
- m_bDesktopCompositionDisabled = false;
- if(m_pDwmEnableComposition)
- m_pDwmEnableComposition(1);
- }
-
- m_pFont = NULL;
- m_pLine = NULL;
- m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
- m_pPSC.Free();
- m_pD3D = NULL;
- m_pD3DEx = NULL;
- if(m_hDWMAPI)
- {
- FreeLibrary(m_hDWMAPI);
- m_hDWMAPI = NULL;
- }
- if(m_hD3D9)
- {
- FreeLibrary(m_hD3D9);
- m_hD3D9 = NULL;
- }
- m_pAudioStats = NULL;
- if(m_pGenlock)
- {
- delete m_pGenlock;
- m_pGenlock = NULL;
- }
+ ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error),
+ m_ScreenSize(0, 0),
+ m_bicubicA(0),
+ m_nDXSurface(1),
+ m_nVMR9Surfaces(0),
+ m_iVMR9Surface(0),
+ m_nCurSurface(0),
+ m_bSnapToVSync(false),
+ m_bInterlaced(0),
+ m_nUsedBuffer(0),
+ m_bNeedPendingResetDevice(0),
+ m_bPendingResetDevice(0),
+ m_TextScale(1.0),
+ m_dMainThreadId(0),
+ m_bNeedCheckSample(true),
+ m_hEvtQuit(INVALID_HANDLE_VALUE),
+ m_bIsFullscreen((AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode())),
+ m_uSyncGlitches(0),
+ m_pGenlock(NULL),
+ m_lAudioLag(0),
+ m_lAudioLagMin(10000),
+ m_lAudioLagMax(-10000),
+ m_pAudioStats(NULL),
+ m_nNextJitter(0),
+ m_nNextSyncOffset(0),
+ m_llLastSyncTime(0),
+ m_fAvrFps(0.0),
+ m_fJitterStdDev(0.0),
+ m_fSyncOffsetStdDev(0.0),
+ m_fSyncOffsetAvr(0.0),
+ m_llHysteresis(0),
+ m_uD3DRefreshRate(0),
+ m_dD3DRefreshCycle(0),
+ m_dDetectedScanlineTime(0.0),
+ m_dEstRefreshCycle(0.0),
+ m_dFrameCycle(0.0),
+ m_dOptimumDisplayCycle(0.0),
+ m_dCycleDifference(1.0),
+ m_llEstVBlankTime(0)
+{
+ if(FAILED(hr))
+ {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
+
+ HINSTANCE hDll;
+ m_pD3DXLoadSurfaceFromMemory = NULL;
+ m_pD3DXCreateLine = NULL;
+ m_pD3DXCreateFont = NULL;
+ m_pD3DXCreateSprite = NULL;
+ hDll = AfxGetMyApp()->GetD3X9Dll();
+ if(hDll)
+ {
+ (FARPROC &)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
+ (FARPROC &)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
+ (FARPROC &)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
+ (FARPROC &)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
+ }
+ else
+ {
+ _Error += L"No D3DX9 dll found. To enable stats, shaders and complex resizers, please install the latest DirectX End-User Runtime.\n";
+ }
+
+ m_pDwmIsCompositionEnabled = NULL;
+ m_pDwmEnableComposition = NULL;
+ m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
+ if (m_hDWMAPI)
+ {
+ (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
+ (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
+ }
+
+ m_pDirect3DCreate9Ex = NULL;
+ m_hD3D9 = LoadLibrary(L"d3d9.dll");
+ if (m_hD3D9)
+ (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+
+ ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
+
+ AppSettings& s = AfxGetAppSettings();
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition) m_pDwmEnableComposition(0);
+ }
+ else
+ {
+ m_bDesktopCompositionDisabled = false;
+ }
+
+ m_pGenlock = new CGenlock(s.m_RenderSettings.fTargetSyncOffset, s.m_RenderSettings.fControlLimit, s.m_RenderSettings.iLineDelta, s.m_RenderSettings.iColumnDelta, s.m_RenderSettings.fCycleDelta, 0); // Must be done before CreateDXDevice
+ hr = CreateDXDevice(_Error);
+ memset (m_pllJitter, 0, sizeof(m_pllJitter));
+ memset (m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
+}
+
+CBaseAP::~CBaseAP()
+{
+ if (m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(1);
+ }
+
+ m_pFont = NULL;
+ m_pLine = NULL;
+ m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
+ m_pPSC.Free();
+ m_pD3D = NULL;
+ m_pD3DEx = NULL;
+ if (m_hDWMAPI)
+ {
+ FreeLibrary(m_hDWMAPI);
+ m_hDWMAPI = NULL;
+ }
+ if (m_hD3D9)
+ {
+ FreeLibrary(m_hD3D9);
+ m_hD3D9 = NULL;
+ }
+ m_pAudioStats = NULL;
+ if (m_pGenlock)
+ {
+ delete m_pGenlock;
+ m_pGenlock = NULL;
+ }
}
template<int texcoords>
void CBaseAP::AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
{
- double offset = 0.5;
+ double offset = 0.5;
- for(int i = 0; i < 4; i++)
- {
- v[i].x -= offset;
- v[i].y -= offset;
+ for(int i = 0; i < 4; i++)
+ {
+ v[i].x -= offset;
+ v[i].y -= offset;
- for(int j = 0; j < max(texcoords - 1, 1); j++)
- {
- v[i].t[j].u -= offset * dx;
- v[i].t[j].v -= offset * dy;
- }
+ for(int j = 0; j < max(texcoords-1, 1); j++)
+ {
+ v[i].t[j].u -= offset*dx;
+ v[i].t[j].v -= offset*dy;
+ }
- if(texcoords > 1)
- {
- v[i].t[texcoords-1].u -= offset;
- v[i].t[texcoords-1].v -= offset;
- }
- }
+ if(texcoords > 1)
+ {
+ v[i].t[texcoords-1].u -= offset;
+ v[i].t[texcoords-1].v -= offset;
+ }
+ }
}
template<int texcoords>
HRESULT CBaseAP::TextureBlt(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter = D3DTEXF_LINEAR)
{
- if(!pD3DDev) return E_POINTER;
-
- DWORD FVF = 0;
- switch(texcoords)
- {
- case 1:
- FVF = D3DFVF_TEX1;
- break;
- case 2:
- FVF = D3DFVF_TEX2;
- break;
- case 3:
- FVF = D3DFVF_TEX3;
- break;
- case 4:
- FVF = D3DFVF_TEX4;
- break;
- case 5:
- FVF = D3DFVF_TEX5;
- break;
- case 6:
- FVF = D3DFVF_TEX6;
- break;
- case 7:
- FVF = D3DFVF_TEX7;
- break;
- case 8:
- FVF = D3DFVF_TEX8;
- break;
- default:
- return E_FAIL;
- }
-
- HRESULT hr;
- do
- {
- hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
-
- for(int i = 0; i < texcoords; i++)
- {
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
-
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- }
-
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
-
- MYD3DVERTEX<texcoords> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
-
- for(int i = 0; i < texcoords; i++)
- {
- pD3DDev->SetTexture(i, NULL);
- }
-
- return S_OK;
- }
- while(0);
- return E_FAIL;
+ if(!pD3DDev) return E_POINTER;
+
+ DWORD FVF = 0;
+ switch(texcoords)
+ {
+ case 1: FVF = D3DFVF_TEX1; break;
+ case 2: FVF = D3DFVF_TEX2; break;
+ case 3: FVF = D3DFVF_TEX3; break;
+ case 4: FVF = D3DFVF_TEX4; break;
+ case 5: FVF = D3DFVF_TEX5; break;
+ case 6: FVF = D3DFVF_TEX6; break;
+ case 7: FVF = D3DFVF_TEX7; break;
+ case 8: FVF = D3DFVF_TEX8; break;
+ default: return E_FAIL;
+ }
+
+ HRESULT hr;
+ do
+ {
+ hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
+
+ for(int i = 0; i < texcoords; i++)
+ {
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
+
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ }
+
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
+
+ MYD3DVERTEX<texcoords> tmp = v[2]; v[2] = v[3]; v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+
+ for(int i = 0; i < texcoords; i++)
+ {
+ pD3DDev->SetTexture(i, NULL);
+ }
+
+ return S_OK;
+ }
+ while(0);
+ return E_FAIL;
}
HRESULT CBaseAP::DrawRectBase(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<0> v[4])
{
- if(!pD3DDev) return E_POINTER;
+ if(!pD3DDev) return E_POINTER;
- do
- {
- HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ do
+ {
+ HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
- MYD3DVERTEX<0> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ MYD3DVERTEX<0> tmp = v[2]; v[2] = v[3]; v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- return S_OK;
- }
- while(0);
- return E_FAIL;
+ return S_OK;
+ }
+ while(0);
+ return E_FAIL;
}
MFOffset CBaseAP::GetOffset(float v)
{
- MFOffset offset;
- offset.value = short(v);
- offset.fract = WORD(65536 * (v - offset.value));
- return offset;
+ MFOffset offset;
+ offset.value = short(v);
+ offset.fract = WORD(65536 * (v-offset.value));
+ return offset;
}
MFVideoArea CBaseAP::GetArea(float x, float y, DWORD width, DWORD height)
{
- MFVideoArea area;
- area.OffsetX = GetOffset(x);
- area.OffsetY = GetOffset(y);
- area.Area.cx = width;
- area.Area.cy = height;
- return area;
+ MFVideoArea area;
+ area.OffsetX = GetOffset(x);
+ area.OffsetY = GetOffset(y);
+ area.Area.cx = width;
+ area.Area.cy = height;
+ return area;
}
void CBaseAP::ResetStats()
{
- m_pGenlock->ResetStats();
- m_lAudioLag = 0;
- m_lAudioLagMin = 10000;
- m_lAudioLagMax = -10000;
- m_MinJitter = MAXLONG64;
- m_MaxJitter = MINLONG64;
- m_MinSyncOffset = MAXLONG64;
- m_MaxSyncOffset = MINLONG64;
- m_uSyncGlitches = 0;
- m_pcFramesDropped = 0;
+ m_pGenlock->ResetStats();
+ m_lAudioLag = 0;
+ m_lAudioLagMin = 10000;
+ m_lAudioLagMax = -10000;
+ m_MinJitter = MAXLONG64;
+ m_MaxJitter = MINLONG64;
+ m_MinSyncOffset = MAXLONG64;
+ m_MaxSyncOffset = MINLONG64;
+ m_uSyncGlitches = 0;
+ m_pcFramesDropped = 0;
}
bool CBaseAP::SettingsNeedResetDevice()
{
- AppSettings& s = AfxGetAppSettings();
- CMPlayerCApp::Settings::CRendererSettingsEVR & New = AfxGetAppSettings().m_RenderSettings;
- CMPlayerCApp::Settings::CRendererSettingsEVR & Current = m_LastRendererSettings;
-
- bool bRet = false;
- if(!m_bIsFullscreen)
- {
- if(Current.iVMRDisableDesktopComposition)
- {
- if(!m_bDesktopCompositionDisabled)
- {
- m_bDesktopCompositionDisabled = true;
- if(m_pDwmEnableComposition)
- m_pDwmEnableComposition(0);
- }
- }
- else
- {
- if(m_bDesktopCompositionDisabled)
- {
- m_bDesktopCompositionDisabled = false;
- if(m_pDwmEnableComposition)
- m_pDwmEnableComposition(1);
- }
- }
- }
- bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
- m_LastRendererSettings = s.m_RenderSettings;
- return bRet;
+ AppSettings& s = AfxGetAppSettings();
+ CMPlayerCApp::Settings::CRendererSettingsEVR & New = AfxGetAppSettings().m_RenderSettings;
+ CMPlayerCApp::Settings::CRendererSettingsEVR & Current = m_LastRendererSettings;
+
+ bool bRet = false;
+ if (!m_bIsFullscreen)
+ {
+ if (Current.iVMRDisableDesktopComposition)
+ {
+ if (!m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(0);
+ }
+ }
+ else
+ {
+ if (m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(1);
+ }
+ }
+ }
+ bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
+ m_LastRendererSettings = s.m_RenderSettings;
+ return bRet;
}
HRESULT CBaseAP::CreateDXDevice(CString &_Error)
{
- TRACE("--> CBaseAP::CreateDXDevice on thread: %d\n", GetCurrentThreadId());
- AppSettings& s = AfxGetAppSettings();
- m_LastRendererSettings = s.m_RenderSettings;
- HRESULT hr = E_FAIL;
-
- m_pFont = NULL;
- m_pSprite = NULL;
- m_pLine = NULL;
-
- m_pPSC.Free();
- m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
- m_pD3D = NULL;
- m_pD3DEx = NULL;
-
- m_pResizerPixelShader[0] = 0;
- m_pResizerPixelShader[1] = 0;
- m_pResizerPixelShader[2] = 0;
- m_pResizerPixelShader[3] = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
- pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
-
- if(m_pDirect3DCreate9Ex)
- {
- _tprintf(_T("m_pDirect3DCreate9Ex\n"));
- m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx)
- {
- m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
- }
- }
- if(!m_pD3DEx)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
- if(!m_pD3D)
- {
- _Error += L"Failed to create Direct3D device\n";
- return E_UNEXPECTED;
- }
- _tprintf(_T("m_pDirect3DCreate9\n"));
- }
- else
- m_pD3D = m_pD3DEx;
-
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
- {
- _Error += L"Can not retrieve display mode data\n";
- return E_UNEXPECTED;
- }
-
- if FAILED(m_pD3D->GetDeviceCaps(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, &m_caps))
- if((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0)
- {
- _Error += L"Video card does not have scanline access. Display synchronization is not possible.\n";
- return E_UNEXPECTED;
- }
-
- m_uD3DRefreshRate = d3ddm.RefreshRate;
- m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
- m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
- m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
-
- BOOL bCompositionEnabled = false;
- if(m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- m_bCompositionEnabled = bCompositionEnabled != 0;
-
- ZeroMemory(&pp, sizeof(pp));
- if(m_bIsFullscreen) // Exclusive mode fullscreen
- {
- pp.Windowed = FALSE;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- pp.hDeviceWindow = m_hWnd;
- _tprintf(_T("Wnd in CreateDXDevice: %d\n"), m_hWnd);
- pp.BackBufferCount = 3;
- pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
- if(m_bHighColorResolution)
- {
- if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false)))
- {
- m_strStatsMsg[MSG_ERROR].Format(L"10 bit RGB is not supported by this graphics device in this resolution.");
- m_bHighColorResolution = false;
- }
- }
-
- if(m_bHighColorResolution)
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- else
- pp.BackBufferFormat = d3ddm.Format;
-
- if(m_pD3DEx)
- {
- D3DDISPLAYMODEEX DisplayMode;
- ZeroMemory(&DisplayMode, sizeof(DisplayMode));
- DisplayMode.Size = sizeof(DisplayMode);
- m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
-
- DisplayMode.Format = pp.BackBufferFormat;
- pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
-
- if FAILED(m_pD3DEx->CreateDeviceEx(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &pp, &DisplayMode, &m_pD3DDevEx))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- if(m_pD3DDevEx)
- {
- m_pD3DDev = m_pD3DDevEx;
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = DisplayMode.Format;
- }
- }
- else
- {
- if FAILED(m_pD3D->CreateDevice(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &pp, &m_pD3DDev))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- _tprintf(_T("Created full-screen device\n"));
- if(m_pD3DDev)
- {
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = d3ddm.Format;
- }
- }
- }
- else // Windowed
- {
- pp.Windowed = TRUE;
- pp.hDeviceWindow = m_hWnd;
- pp.SwapEffect = D3DSWAPEFFECT_COPY;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferCount = 1;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- m_BackbufferType = d3ddm.Format;
- m_DisplayType = d3ddm.Format;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
- if(m_bHighColorResolution)
- {
- if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false)))
- {
- m_strStatsMsg[MSG_ERROR].Format(L"10 bit RGB is not supported by this graphics device in this resolution.");
- m_bHighColorResolution = false;
- }
- }
-
- if(m_bHighColorResolution)
- {
- m_BackbufferType = D3DFMT_A2R10G10B10;
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- }
- if(bCompositionEnabled)
- {
- // Desktop composition presents the whole desktop
- pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- }
- if(m_pD3DEx)
- {
- if FAILED(m_pD3DEx->CreateDeviceEx(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &pp, NULL, &m_pD3DDevEx))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- if(m_pD3DDevEx) m_pD3DDev = m_pD3DDevEx;
- }
- else
- {
- if FAILED(m_pD3D->CreateDevice(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &pp, &m_pD3DDev))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- _tprintf(_T("Created windowed device\n"));
- }
- }
-
- if(m_pD3DDevEx)
- {
- m_pD3DDevEx->SetGPUThreadPriority(7);
- }
-
- m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
- m_filter = D3DTEXF_NONE;
-
- if(m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFLINEAR && m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR)
- m_filter = D3DTEXF_LINEAR;
-
- m_bicubicA = 0;
-
- CSize size;
- switch(AfxGetAppSettings().nSPCMaxRes)
- {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if(m_pAllocator)
- {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- }
- else
- {
- m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- {
- _Error += L"CDX9SubPicAllocator failed\n";
- return E_FAIL;
- }
- }
-
- hr = S_OK;
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue)
- {
- _tprintf(_T("m_pSubPicQueue != NULL\n"));
- m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
- }
-
- m_pSubPicQueue = NULL;
- m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr))
- {
- _Error += L"m_pSubPicQueue failed\n";
- return E_FAIL;
- }
-
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
-
- if(m_pD3DXCreateFont)
- {
- int MinSize = 1600;
- int CurrentSize = min(m_ScreenSize.cx, MinSize);
- double Scale = double(CurrentSize) / double(MinSize);
- m_TextScale = Scale;
- m_pD3DXCreateFont(m_pD3DDev, -24.0 * Scale, -11.0 * Scale, CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
- DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
- }
- if(m_pD3DXCreateSprite) m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
- if(m_pD3DXCreateLine) m_pD3DXCreateLine(m_pD3DDev, &m_pLine);
- return S_OK;
-}
+ TRACE("--> CBaseAP::CreateDXDevice on thread: %d\n", GetCurrentThreadId());
+ AppSettings& s = AfxGetAppSettings();
+ m_LastRendererSettings = s.m_RenderSettings;
+ HRESULT hr = E_FAIL;
+
+ m_pFont = NULL;
+ m_pSprite = NULL;
+ m_pLine = NULL;
+
+ m_pPSC.Free();
+ m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
+ m_pD3D = NULL;
+ m_pD3DEx = NULL;
+
+ m_pResizerPixelShader[0] = 0;
+ m_pResizerPixelShader[1] = 0;
+ m_pResizerPixelShader[2] = 0;
+ m_pResizerPixelShader[3] = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+ pos = m_pPixelShaders.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+
+ if (m_pDirect3DCreate9Ex)
+ {
+ _tprintf(_T("m_pDirect3DCreate9Ex\n"));
+ m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
+ if(!m_pD3DEx)
+ {
+ m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
+ }
+ if(!m_pD3DEx)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if(!m_pD3D)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+ if(!m_pD3D)
+ {
+ _Error += L"Failed to create Direct3D device\n";
+ return E_UNEXPECTED;
+ }
+ _tprintf(_T("m_pDirect3DCreate9\n"));
+ }
+ else
+ m_pD3D = m_pD3DEx;
+
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
+ {
+ _Error += L"Can not retrieve display mode data\n";
+ return E_UNEXPECTED;
+ }
+
+ if FAILED(m_pD3D->GetDeviceCaps(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, &m_caps))
+ if ((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0)
+ {
+ _Error += L"Video card does not have scanline access. Display synchronization is not possible.\n";
+ return E_UNEXPECTED;
+ }
+
+ m_uD3DRefreshRate = d3ddm.RefreshRate;
+ m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
+ m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
+ m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
+
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ m_bCompositionEnabled = bCompositionEnabled != 0;
+
+ ZeroMemory(&pp, sizeof(pp));
+ if (m_bIsFullscreen) // Exclusive mode fullscreen
+ {
+ pp.Windowed = FALSE;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ pp.hDeviceWindow = m_hWnd;
+ _tprintf(_T("Wnd in CreateDXDevice: %d\n"), m_hWnd);
+ pp.BackBufferCount = 3;
+ pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
+ if (m_bHighColorResolution)
+ {
+ if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false)))
+ {
+ m_strStatsMsg[MSG_ERROR].Format (L"10 bit RGB is not supported by this graphics device in this resolution.");
+ m_bHighColorResolution = false;
+ }
+ }
+
+ if (m_bHighColorResolution)
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ else
+ pp.BackBufferFormat = d3ddm.Format;
+
+ if (m_pD3DEx)
+ {
+ D3DDISPLAYMODEEX DisplayMode;
+ ZeroMemory(&DisplayMode, sizeof(DisplayMode));
+ DisplayMode.Size = sizeof(DisplayMode);
+ m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
+
+ DisplayMode.Format = pp.BackBufferFormat;
+ pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
+
+ if FAILED(m_pD3DEx->CreateDeviceEx(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, &pp, &DisplayMode, &m_pD3DDevEx))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ if (m_pD3DDevEx)
+ {
+ m_pD3DDev = m_pD3DDevEx;
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = DisplayMode.Format;
+ }
+ }
+ else
+ {
+ if FAILED(m_pD3D->CreateDevice(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, &pp, &m_pD3DDev))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ _tprintf(_T("Created full-screen device\n"));
+ if (m_pD3DDev)
+ {
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = d3ddm.Format;
+ }
+ }
+ }
+ else // Windowed
+ {
+ pp.Windowed = TRUE;
+ pp.hDeviceWindow = m_hWnd;
+ pp.SwapEffect = D3DSWAPEFFECT_COPY;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ m_BackbufferType = d3ddm.Format;
+ m_DisplayType = d3ddm.Format;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
+ if (m_bHighColorResolution)
+ {
+ if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false)))
+ {
+ m_strStatsMsg[MSG_ERROR].Format (L"10 bit RGB is not supported by this graphics device in this resolution.");
+ m_bHighColorResolution = false;
+ }
+ }
+
+ if (m_bHighColorResolution)
+ {
+ m_BackbufferType = D3DFMT_A2R10G10B10;
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ }
+ if (bCompositionEnabled)
+ {
+ // Desktop composition presents the whole desktop
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ }
+ else
+ {
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
+ if (m_pD3DEx)
+ {
+ if FAILED(m_pD3DEx->CreateDeviceEx(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, &pp, NULL, &m_pD3DDevEx))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ if (m_pD3DDevEx) m_pD3DDev = m_pD3DDevEx;
+ }
+ else
+ {
+ if FAILED(m_pD3D->CreateDevice(GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, &pp, &m_pD3DDev))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ _tprintf(_T("Created windowed device\n"));
+ }
+ }
+
+ if (m_pD3DDevEx)
+ {
+ m_pD3DDevEx->SetGPUThreadPriority(7);
+ }
+
+ m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
+ m_filter = D3DTEXF_NONE;
+
+ if(m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR && m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR)
+ m_filter = D3DTEXF_LINEAR;
+
+ m_bicubicA = 0;
+
+ CSize size;
+ switch(AfxGetAppSettings().nSPCMaxRes)
+ {
+ case 0: default: size = m_ScreenSize; break;
+ case 1: size.SetSize(1024, 768); break;
+ case 2: size.SetSize(800, 600); break;
+ case 3: size.SetSize(640, 480); break;
+ case 4: size.SetSize(512, 384); break;
+ case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
+ }
+
+ if(m_pAllocator)
+ {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ }
+ else
+ {
+ m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ if(!m_pAllocator)
+ {
+ _Error += L"CDX9SubPicAllocator failed\n";
+ return E_FAIL;
+ }
+ }
+
+ hr = S_OK;
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if(m_pSubPicQueue)
+ {
+ _tprintf(_T("m_pSubPicQueue != NULL\n"));
+ m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+ }
+
+ m_pSubPicQueue = NULL;
+ m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if(!m_pSubPicQueue || FAILED(hr))
+ {
+ _Error += L"m_pSubPicQueue failed\n";
+ return E_FAIL;
+ }
+
+ if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+
+ if (m_pD3DXCreateFont)
+ {
+ int MinSize = 1600;
+ int CurrentSize = min(m_ScreenSize.cx, MinSize);
+ double Scale = double(CurrentSize) / double(MinSize);
+ m_TextScale = Scale;
+ m_pD3DXCreateFont(m_pD3DDev, -24.0*Scale, -11.0*Scale, CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
+ DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
+ }
+ if (m_pD3DXCreateSprite) m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
+ if (m_pD3DXCreateLine) m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
+ return S_OK;
+}
HRESULT CBaseAP::ResetDXDevice(CString &_Error)
{
- AppSettings& s = AfxGetAppSettings();
- m_LastRendererSettings = s.m_RenderSettings;
- HRESULT hr = E_FAIL;
+ AppSettings& s = AfxGetAppSettings();
+ m_LastRendererSettings = s.m_RenderSettings;
+ HRESULT hr = E_FAIL;
- hr = m_pD3DDev->TestCooperativeLevel();
- if((hr != D3DERR_DEVICENOTRESET) && (hr != D3D_OK)) return hr;
+ hr = m_pD3DDev->TestCooperativeLevel();
+ if ((hr != D3DERR_DEVICENOTRESET) && (hr != D3D_OK)) return hr;
CComPtr<IEnumPins> rendererInputEnum;
- vector<CComPtr<IPin>> decoderOutput;
- vector<CComPtr<IPin>> rendererInput;
- FILTER_INFO filterInfo;
-
- bool disconnected = FALSE;
-
- // Disconnect all pins to release video memory resources
- if(m_pD3DDev)
- {
- ZeroMemory(&filterInfo, sizeof(filterInfo));
- m_pOuterEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
- if(SUCCEEDED(m_pOuterEVR->EnumPins(&rendererInputEnum)))
- {
- CComPtr<IPin> input;
- CComPtr<IPin> output;
- while(hr = rendererInputEnum->Next(1, &input.p, 0), hr == S_OK) // Must have .p here
- {
- _tprintf(_T("Pin found\n"));
- input->ConnectedTo(&output.p);
- if(output != NULL)
- {
- rendererInput.push_back(input);
- decoderOutput.push_back(output);
- }
- input.Release();
- output.Release();
- }
- }
- else return hr;
- for(DWORD i = 0; i < decoderOutput.size(); i++)
- {
- _tprintf(_T("Disconnecting pin\n"));
- filterInfo.pGraph->Disconnect(decoderOutput.at(i).p);
- filterInfo.pGraph->Disconnect(rendererInput.at(i).p);
- _tprintf(_T("Pin disconnected\n"));
- }
- disconnected = true;
- }
-
- // Release more resources
- m_pSubPicQueue = NULL;
- m_pFont = NULL;
- m_pSprite = NULL;
- m_pLine = NULL;
- m_pPSC.Free();
-
- m_pResizerPixelShader[0] = 0;
- m_pResizerPixelShader[1] = 0;
- m_pResizerPixelShader[2] = 0;
- m_pResizerPixelShader[3] = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
- pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
-
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
- {
- _Error += L"Can not retrieve display mode data\n";
- return E_UNEXPECTED;
- }
-
- m_uD3DRefreshRate = d3ddm.RefreshRate;
- m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
- m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
- m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
-
- D3DPRESENT_PARAMETERS pp;
- ZeroMemory(&pp, sizeof(pp));
-
- BOOL bCompositionEnabled = false;
- if(m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- m_bCompositionEnabled = bCompositionEnabled != 0;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
-
- if(m_bIsFullscreen) // Exclusive mode fullscreen
- {
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- if(m_bHighColorResolution)
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- else
- pp.BackBufferFormat = d3ddm.Format;
- if(FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false)))
- {
- _Error += L"10 bit RGB is not supported by this graphics device in exclusive mode fullscreen.\n";
- return hr;
- }
-
- D3DDISPLAYMODEEX DisplayMode;
- ZeroMemory(&DisplayMode, sizeof(DisplayMode));
- DisplayMode.Size = sizeof(DisplayMode);
- if(m_pD3DDevEx)
- {
- m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
- DisplayMode.Format = pp.BackBufferFormat;
- pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
- if FAILED(m_pD3DDevEx->Reset(&pp))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- }
- else if(m_pD3DDev)
- {
- if FAILED(m_pD3DDev->Reset(&pp))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- }
- else
- {
- _Error += L"No device.\n";
- return hr;
- }
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = d3ddm.Format;
- }
- else // Windowed
- {
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- m_BackbufferType = d3ddm.Format;
- m_DisplayType = d3ddm.Format;
- if(m_bHighColorResolution)
- {
- m_BackbufferType = D3DFMT_A2R10G10B10;
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- }
- if(FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false)))
- {
- _Error += L"10 bit RGB is not supported by this graphics device in windowed mode.\n";
- return hr;
- }
- if(bCompositionEnabled)
- {
- // Desktop composition presents the whole desktop
- pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- }
- if(m_pD3DDevEx)
- if FAILED(m_pD3DDevEx->Reset(&pp))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- else if(m_pD3DDev)
- if FAILED(m_pD3DDevEx->Reset(&pp))
- {
- _Error += GothSyncErrorMessage(hr, m_hD3D9);
- return hr;
- }
- else
- {
- _Error += L"No device.\n";
- return hr;
- }
- }
-
- if(disconnected)
- {
- for(DWORD i = 0; i < decoderOutput.size(); i++)
- {
- if(FAILED(filterInfo.pGraph->ConnectDirect(decoderOutput.at(i).p, rendererInput.at(i).p, NULL)))
- {
- return hr;
- }
- }
-
- if(filterInfo.pGraph != NULL)
- {
- filterInfo.pGraph->Release();
- }
- }
-
- m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
- m_filter = D3DTEXF_NONE;
-
- if((m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFLINEAR)
- && (m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR))
- m_filter = D3DTEXF_LINEAR;
-
- m_bicubicA = 0;
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
- CSize size;
- switch(AfxGetAppSettings().nSPCMaxRes)
- {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if(m_pAllocator)
- {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- }
- else
- {
- m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- {
- _Error += L"CDX9SubPicAllocator failed\n";
-
- return E_FAIL;
- }
- }
-
- hr = S_OK;
- m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr))
- {
- _Error += L"m_pSubPicQueue failed\n";
-
- return E_FAIL;
- }
-
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
-
- m_pFont = NULL;
- if(m_pD3DXCreateFont)
- {
- int MinSize = 1600;
- int CurrentSize = min(m_ScreenSize.cx, MinSize);
- double Scale = double(CurrentSize) / double(MinSize);
- m_TextScale = Scale;
- m_pD3DXCreateFont(m_pD3DDev, -24.0 * Scale, -11.0 * Scale, CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
- DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
- }
- m_pSprite = NULL;
- if(m_pD3DXCreateSprite) m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
- m_pLine = NULL;
- if(m_pD3DXCreateLine) m_pD3DXCreateLine(m_pD3DDev, &m_pLine);
- return S_OK;
+ vector<CComPtr<IPin>> decoderOutput;
+ vector<CComPtr<IPin>> rendererInput;
+ FILTER_INFO filterInfo;
+
+ bool disconnected = FALSE;
+
+ // Disconnect all pins to release video memory resources
+ if (m_pD3DDev)
+ {
+ ZeroMemory(&filterInfo, sizeof(filterInfo));
+ m_pOuterEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
+ if (SUCCEEDED(m_pOuterEVR->EnumPins(&rendererInputEnum)))
+ {
+ CComPtr<IPin> input;
+ CComPtr<IPin> output;
+ while (hr = rendererInputEnum->Next(1, &input.p, 0), hr == S_OK) // Must have .p here
+ {
+ _tprintf(_T("Pin found\n"));
+ input->ConnectedTo(&output.p);
+ if (output != NULL)
+ {
+ rendererInput.push_back(input);
+ decoderOutput.push_back(output);
+ }
+ input.Release();
+ output.Release();
+ }
+ }
+ else return hr;
+ for (DWORD i = 0; i < decoderOutput.size(); i++)
+ {
+ _tprintf(_T("Disconnecting pin\n"));
+ filterInfo.pGraph->Disconnect(decoderOutput.at(i).p);
+ filterInfo.pGraph->Disconnect(rendererInput.at(i).p);
+ _tprintf(_T("Pin disconnected\n"));
+ }
+ disconnected = true;
+ }
+
+ // Release more resources
+ m_pSubPicQueue = NULL;
+ m_pFont = NULL;
+ m_pSprite = NULL;
+ m_pLine = NULL;
+ m_pPSC.Free();
+
+ m_pResizerPixelShader[0] = 0;
+ m_pResizerPixelShader[1] = 0;
+ m_pResizerPixelShader[2] = 0;
+ m_pResizerPixelShader[3] = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+ pos = m_pPixelShaders.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
+ {
+ _Error += L"Can not retrieve display mode data\n";
+ return E_UNEXPECTED;
+ }
+
+ m_uD3DRefreshRate = d3ddm.RefreshRate;
+ m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
+ m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
+ m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
+
+ D3DPRESENT_PARAMETERS pp;
+ ZeroMemory(&pp, sizeof(pp));
+
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ m_bCompositionEnabled = bCompositionEnabled != 0;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
+
+ if (m_bIsFullscreen) // Exclusive mode fullscreen
+ {
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ if (m_bHighColorResolution)
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ else
+ pp.BackBufferFormat = d3ddm.Format;
+ if(FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false)))
+ {
+ _Error += L"10 bit RGB is not supported by this graphics device in exclusive mode fullscreen.\n";
+ return hr;
+ }
+
+ D3DDISPLAYMODEEX DisplayMode;
+ ZeroMemory(&DisplayMode, sizeof(DisplayMode));
+ DisplayMode.Size = sizeof(DisplayMode);
+ if (m_pD3DDevEx)
+ {
+ m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
+ DisplayMode.Format = pp.BackBufferFormat;
+ pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
+ if FAILED(m_pD3DDevEx->Reset(&pp))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ }
+ else if (m_pD3DDev)
+ {
+ if FAILED(m_pD3DDev->Reset(&pp))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ }
+ else
+ {
+ _Error += L"No device.\n";
+ return hr;
+ }
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = d3ddm.Format;
+ }
+ else // Windowed
+ {
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ m_BackbufferType = d3ddm.Format;
+ m_DisplayType = d3ddm.Format;
+ if (m_bHighColorResolution)
+ {
+ m_BackbufferType = D3DFMT_A2R10G10B10;
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ }
+ if(FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false)))
+ {
+ _Error += L"10 bit RGB is not supported by this graphics device in windowed mode.\n";
+ return hr;
+ }
+ if (bCompositionEnabled)
+ {
+ // Desktop composition presents the whole desktop
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ }
+ else
+ {
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
+ if (m_pD3DDevEx)
+ if FAILED(m_pD3DDevEx->Reset(&pp))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ else if (m_pD3DDev)
+ if FAILED(m_pD3DDevEx->Reset(&pp))
+ {
+ _Error += GothSyncErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ else
+ {
+ _Error += L"No device.\n";
+ return hr;
+ }
+ }
+
+ if (disconnected)
+ {
+ for (DWORD i = 0; i < decoderOutput.size(); i++)
+ {
+ if (FAILED(filterInfo.pGraph->ConnectDirect(decoderOutput.at(i).p, rendererInput.at(i).p, NULL)))
+ {
+ return hr;
+ }
+ }
+
+ if (filterInfo.pGraph != NULL)
+ {
+ filterInfo.pGraph->Release();
+ }
+ }
+
+ m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
+ m_filter = D3DTEXF_NONE;
+
+ if((m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
+ && (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR))
+ m_filter = D3DTEXF_LINEAR;
+
+ m_bicubicA = 0;
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+ CSize size;
+ switch(AfxGetAppSettings().nSPCMaxRes)
+ {
+ case 0: default: size = m_ScreenSize; break;
+ case 1: size.SetSize(1024, 768); break;
+ case 2: size.SetSize(800, 600); break;
+ case 3: size.SetSize(640, 480); break;
+ case 4: size.SetSize(512, 384); break;
+ case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
+ }
+
+ if(m_pAllocator)
+ {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ }
+ else
+ {
+ m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ if(!m_pAllocator)
+ {
+ _Error += L"CDX9SubPicAllocator failed\n";
+
+ return E_FAIL;
+ }
+ }
+
+ hr = S_OK;
+ m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if(!m_pSubPicQueue || FAILED(hr))
+ {
+ _Error += L"m_pSubPicQueue failed\n";
+
+ return E_FAIL;
+ }
+
+ if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+
+ m_pFont = NULL;
+ if (m_pD3DXCreateFont)
+ {
+ int MinSize = 1600;
+ int CurrentSize = min(m_ScreenSize.cx, MinSize);
+ double Scale = double(CurrentSize) / double(MinSize);
+ m_TextScale = Scale;
+ m_pD3DXCreateFont(m_pD3DDev, -24.0*Scale, -11.0*Scale, CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
+ DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
+ }
+ m_pSprite = NULL;
+ if (m_pD3DXCreateSprite) m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
+ m_pLine = NULL;
+ if (m_pD3DXCreateLine) m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
+ return S_OK;
}
HRESULT CBaseAP::AllocSurfaces(D3DFORMAT Format)
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_allocatorLock);
-
- AppSettings& s = AfxGetAppSettings();
-
- for(int i = 0; i < m_nDXSurface + 2; i++)
- {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
-
- m_pScreenSizeTemporaryTexture[0] = NULL;
- m_pScreenSizeTemporaryTexture[1] = NULL;
- m_SurfaceType = Format;
-
- HRESULT hr;
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- {
- int nTexturesNeeded = s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nDXSurface + 2 : 1;
-
- for(int i = 0; i < nTexturesNeeded; i++)
- {
- if(FAILED(hr = m_pD3DDev->CreateTexture(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL)))
- return hr;
-
- if(FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i])))
- return hr;
- }
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D)
- {
- for(int i = 0; i < m_nDXSurface + 2; i++)
- {
- m_pVideoTexture[i] = NULL;
- }
- }
- }
- else
- {
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL)))
- return hr;
- }
-
- hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
- return S_OK;
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_allocatorLock);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ for(int i = 0; i < m_nDXSurface+2; i++)
+ {
+ m_pVideoTexture[i] = NULL;
+ m_pVideoSurface[i] = NULL;
+ }
+
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
+ m_SurfaceType = Format;
+
+ HRESULT hr;
+ if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ {
+ int nTexturesNeeded = s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nDXSurface+2 : 1;
+
+ for(int i = 0; i < nTexturesNeeded; i++)
+ {
+ if(FAILED(hr = m_pD3DDev->CreateTexture(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL)))
+ return hr;
+
+ if(FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i])))
+ return hr;
+ }
+ if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D)
+ {
+ for(int i = 0; i < m_nDXSurface+2; i++)
+ {
+ m_pVideoTexture[i] = NULL;
+ }
+ }
+ }
+ else
+ {
+ if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL)))
+ return hr;
+ }
+
+ hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
+ return S_OK;
}
void CBaseAP::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_allocatorLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_allocatorLock);
- for(int i = 0; i < m_nDXSurface + 2; i++)
- {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
+ for(int i = 0; i < m_nDXSurface+2; i++)
+ {
+ m_pVideoTexture[i] = NULL;
+ m_pVideoSurface[i] = NULL;
+ }
}
UINT CBaseAP::GetAdapter(IDirect3D9* pD3D)
{
- if(m_hWnd == NULL || pD3D == NULL) return D3DADAPTER_DEFAULT;
+ if(m_hWnd == NULL || pD3D == NULL) return D3DADAPTER_DEFAULT;
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor == NULL) return D3DADAPTER_DEFAULT;
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(hMonitor == NULL) return D3DADAPTER_DEFAULT;
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
- HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor) return adp;
- }
- return D3DADAPTER_DEFAULT;
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
+ {
+ HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
+ if(hAdpMon == hMonitor) return adp;
+ }
+ return D3DADAPTER_DEFAULT;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CBaseAP::CreateRenderer(IUnknown** ppRenderer)
{
- return E_NOTIMPL;
-}
-
-bool CBaseAP::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
-{
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pSurface->GetDesc(&d3dsd)))
- return(false);
-
- int w = d3dsd.Width, h = d3dsd.Height;
- int sw = s.Width(), sh = s.Height();
- int dw = d.Width(), dh = d.Height();
-
- if(d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
- || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0)
- {
- s.SetRectEmpty();
- d.SetRectEmpty();
- return(true);
- }
- if(d.right > w)
- {
- s.right -= (d.right - w) * sw / dw;
- d.right = w;
- }
- if(d.bottom > h)
- {
- s.bottom -= (d.bottom - h) * sh / dh;
- d.bottom = h;
- }
- if(d.left < 0)
- {
- s.left += (0 - d.left) * sw / dw;
- d.left = 0;
- }
- if(d.top < 0)
- {
- s.top += (0 - d.top) * sh / dh;
- d.top = 0;
- }
- return(true);
+ return E_NOTIMPL;
+}
+
+bool CBaseAP::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
+{
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if(FAILED(pSurface->GetDesc(&d3dsd)))
+ return(false);
+
+ int w = d3dsd.Width, h = d3dsd.Height;
+ int sw = s.Width(), sh = s.Height();
+ int dw = d.Width(), dh = d.Height();
+
+ if(d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
+ || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0)
+ {
+ s.SetRectEmpty();
+ d.SetRectEmpty();
+ return(true);
+ }
+ if(d.right > w) {s.right -= (d.right-w)*sw/dw; d.right = w;}
+ if(d.bottom > h) {s.bottom -= (d.bottom-h)*sh/dh; d.bottom = h;}
+ if(d.left < 0) {s.left += (0-d.left)*sw/dw; d.left = 0;}
+ if(d.top < 0) {s.top += (0-d.top)*sh/dh; d.top = 0;}
+ return(true);
}
HRESULT CBaseAP::InitResizers(float bicubicA, bool bNeedScreenSizeTexture)
{
- HRESULT hr;
- do
- {
- if(bicubicA)
- {
- if(!m_pResizerPixelShader[0])
- break;
- if(!m_pResizerPixelShader[1])
- break;
- if(!m_pResizerPixelShader[2])
- break;
- if(!m_pResizerPixelShader[3])
- break;
- if(m_bicubicA != bicubicA)
- break;
- if(!m_pScreenSizeTemporaryTexture[0])
- break;
- if(bNeedScreenSizeTexture)
- {
- if(!m_pScreenSizeTemporaryTexture[1])
- break;
- }
- }
- else
- {
- if(!m_pResizerPixelShader[0])
- break;
- if(bNeedScreenSizeTexture)
- {
- if(!m_pScreenSizeTemporaryTexture[0])
- break;
- if(!m_pScreenSizeTemporaryTexture[1])
- break;
- }
- }
- return S_OK;
- }
- while(0);
-
- m_bicubicA = bicubicA;
- m_pScreenSizeTemporaryTexture[0] = NULL;
- m_pScreenSizeTemporaryTexture[1] = NULL;
-
- for(int i = 0; i < countof(m_pResizerPixelShader); i++)
- m_pResizerPixelShader[i] = NULL;
-
- if(m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) return E_FAIL;
-
- LPCSTR pProfile = m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
-
- CStringA str;
- if(!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) return E_FAIL;
-
- CStringA A;
- A.Format("(%f)", bicubicA);
- str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
-
- LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
-
- ASSERT(countof(pEntries) == countof(m_pResizerPixelShader));
- for(int i = 0; i < countof(pEntries); i++)
- {
- CString ErrorMessage;
- CString DissAssembly;
- hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShader[i], &DissAssembly, &ErrorMessage);
- if(FAILED(hr))
- {
- TRACE("%ws", ErrorMessage.GetString());
- ASSERT(0);
- return hr;
- }
- }
- if(m_bicubicA || bNeedScreenSizeTexture)
- {
- if(FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL)))
- {
- ASSERT(0);
- m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
- }
- }
- if(m_bicubicA || bNeedScreenSizeTexture)
- {
- if(FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL)))
- {
- ASSERT(0);
- m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
- }
- }
- return S_OK;
+ HRESULT hr;
+ do
+ {
+ if (bicubicA)
+ {
+ if (!m_pResizerPixelShader[0])
+ break;
+ if (!m_pResizerPixelShader[1])
+ break;
+ if (!m_pResizerPixelShader[2])
+ break;
+ if (!m_pResizerPixelShader[3])
+ break;
+ if (m_bicubicA != bicubicA)
+ break;
+ if (!m_pScreenSizeTemporaryTexture[0])
+ break;
+ if (bNeedScreenSizeTexture)
+ {
+ if (!m_pScreenSizeTemporaryTexture[1])
+ break;
+ }
+ }
+ else
+ {
+ if (!m_pResizerPixelShader[0])
+ break;
+ if (bNeedScreenSizeTexture)
+ {
+ if (!m_pScreenSizeTemporaryTexture[0])
+ break;
+ if (!m_pScreenSizeTemporaryTexture[1])
+ break;
+ }
+ }
+ return S_OK;
+ }
+ while (0);
+
+ m_bicubicA = bicubicA;
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
+
+ for(int i = 0; i < countof(m_pResizerPixelShader); i++)
+ m_pResizerPixelShader[i] = NULL;
+
+ if(m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) return E_FAIL;
+
+ LPCSTR pProfile = m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
+
+ CStringA str;
+ if(!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) return E_FAIL;
+
+ CStringA A;
+ A.Format("(%f)", bicubicA);
+ str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
+
+ LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
+
+ ASSERT(countof(pEntries) == countof(m_pResizerPixelShader));
+ for(int i = 0; i < countof(pEntries); i++)
+ {
+ CString ErrorMessage;
+ CString DissAssembly;
+ hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShader[i], &DissAssembly, &ErrorMessage);
+ if(FAILED(hr))
+ {
+ TRACE("%ws", ErrorMessage.GetString());
+ ASSERT (0);
+ return hr;
+ }
+ }
+ if(m_bicubicA || bNeedScreenSizeTexture)
+ {
+ if(FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL)))
+ {
+ ASSERT(0);
+ m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
+ }
+ }
+ if(m_bicubicA || bNeedScreenSizeTexture)
+ {
+ if(FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL)))
+ {
+ ASSERT(0);
+ m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
+ }
+ }
+ return S_OK;
}
HRESULT CBaseAP::TextureCopy(CComPtr<IDirect3DTexture9> pTexture)
{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
-
- float w = (float)desc.Width;
- float h = (float)desc.Height;
- MYD3DVERTEX<1> v[] =
- {
- {0, 0, 0.5f, 2.0f, 0, 0},
- {w, 0, 0.5f, 2.0f, 1, 0},
- {0, h, 0.5f, 2.0f, 0, 1},
- {w, h, 0.5f, 2.0f, 1, 1},
- };
- for(int i = 0; i < countof(v); i++)
- {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
- hr = m_pD3DDev->SetTexture(0, pTexture);
- return TextureBlt(m_pD3DDev, v, D3DTEXF_LINEAR);
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
+
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
+ MYD3DVERTEX<1> v[] =
+ {
+ {0, 0, 0.5f, 2.0f, 0, 0},
+ {w, 0, 0.5f, 2.0f, 1, 0},
+ {0, h, 0.5f, 2.0f, 0, 1},
+ {w, h, 0.5f, 2.0f, 1, 1},
+ };
+ for(int i = 0; i < countof(v); i++)
+ {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ return TextureBlt(m_pD3DDev, v, D3DTEXF_LINEAR);
}
HRESULT CBaseAP::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect)
{
- DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
- MYD3DVERTEX<0> v[] =
- {
- {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
- };
- for(int i = 0; i < countof(v); i++)
- {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
- return DrawRectBase(m_pD3DDev, v);
+ DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
+ MYD3DVERTEX<0> v[] =
+ {
+ {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ };
+ for(int i = 0; i < countof(v); i++)
+ {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+ return DrawRectBase(m_pD3DDev, v);
}
HRESULT CBaseAP::TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
- float w = (float)desc.Width;
- float h = (float)desc.Height;
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
- float dx = 1.0f / w;
- float dy = 1.0f / h;
- float dx2 = 1.0 / w;
- float dy2 = 1.0 / h;
+ float dx = 1.0f/w;
+ float dy = 1.0f/h;
+ float dx2 = 1.0/w;
+ float dy2 = 1.0/h;
- MYD3DVERTEX<1> v[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, SrcRect.left * dx2, SrcRect.top * dy2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, SrcRect.right * dx2, SrcRect.top * dy2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, SrcRect.left * dx2, SrcRect.bottom * dy2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, SrcRect.right * dx2, SrcRect.bottom * dy2},
- };
- AdjustQuad(v, 0, 0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(NULL);
- hr = TextureBlt(m_pD3DDev, v, filter);
- return hr;
+ MYD3DVERTEX<1> v[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, SrcRect.left * dx2, SrcRect.top * dy2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, SrcRect.right * dx2, SrcRect.top * dy2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, SrcRect.left * dx2, SrcRect.bottom * dy2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, SrcRect.right * dx2, SrcRect.bottom * dy2},
+ };
+ AdjustQuad(v, 0, 0);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ hr = TextureBlt(m_pD3DDev, v, filter);
+ return hr;
}
HRESULT CBaseAP::TextureResizeBilinear(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect)
{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
-
- float w = (float)desc.Width;
- float h = (float)desc.Height;
-
- float dx = 1.0f / w;
- float dy = 1.0f / h;
- float tx0 = SrcRect.left;
- float tx1 = SrcRect.right;
- float ty0 = SrcRect.top;
- float ty1 = SrcRect.bottom;
-
- MYD3DVERTEX<1> v[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
- };
- AdjustQuad(v, 1.0, 1.0);
- float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[0]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
+
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
+
+ float dx = 1.0f/w;
+ float dy = 1.0f/h;
+ float tx0 = SrcRect.left;
+ float tx1 = SrcRect.right;
+ float ty0 = SrcRect.top;
+ float ty1 = SrcRect.bottom;
+
+ MYD3DVERTEX<1> v[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
+ };
+ AdjustQuad(v, 1.0, 1.0);
+ float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[0]);
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ m_pD3DDev->SetPixelShader(NULL);
+ return hr;
}
HRESULT CBaseAP::TextureResizeBicubic1pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect)
{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
-
- double w = (double)desc.Width;
- double h = (double)desc.Height;
-
- double sw = SrcRect.Width();
- double sh = SrcRect.Height();
-
- double dx = 1.0f / w;
- double dy = 1.0f / h;
-
- float dx2 = 1.0f / w;
- float dy2 = 1.0f / h;
- float tx0 = SrcRect.left;
- float tx1 = SrcRect.right;
- float ty0 = SrcRect.top;
- float ty1 = SrcRect.bottom;
-
- MYD3DVERTEX<1> v[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
- };
- AdjustQuad(v, 1.0, 1.0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
- float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[1]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
+
+ double w = (double)desc.Width;
+ double h = (double)desc.Height;
+
+ double sw = SrcRect.Width();
+ double sh = SrcRect.Height();
+
+ double dx = 1.0f/w;
+ double dy = 1.0f/h;
+
+ float dx2 = 1.0f/w;
+ float dy2 = 1.0f/h;
+ float tx0 = SrcRect.left;
+ float tx1 = SrcRect.right;
+ float ty0 = SrcRect.top;
+ float ty1 = SrcRect.bottom;
+
+ MYD3DVERTEX<1> v[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
+ };
+ AdjustQuad(v, 1.0, 1.0);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[1]);
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ m_pD3DDev->SetPixelShader(NULL);
+ return hr;
}
HRESULT CBaseAP::TextureResizeBicubic2pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect)
{
- // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- HRESULT hr;
-
- // rotated?
- if(dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
- || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
-
- float Tex0_Width = desc.Width;
- float Tex0_Height = desc.Height;
-
- double dx0 = 1.0 / desc.Width;
- double dy0 = 1.0 / desc.Height;
-
- CSize SrcTextSize = CSize(desc.Width, desc.Height);
- double w = (double)SrcRect.Width();
- double h = (double)SrcRect.Height();
-
- CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
-
- if(!m_pScreenSizeTemporaryTexture[0] || FAILED(m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc)))
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- float Tex1_Width = desc.Width;
- float Tex1_Height = desc.Height;
-
- double dx1 = 1.0 / desc.Width;
- double dy1 = 1.0 / desc.Height;
-
- double dw = (double)dst1.Width() / desc.Width;
- double dh = (double)dst1.Height() / desc.Height;
-
- float dx2 = 1.0f / SrcTextSize.cx;
- float dy2 = 1.0f / SrcTextSize.cy;
- float tx0 = SrcRect.left;
- float tx1 = SrcRect.right;
- float ty0 = SrcRect.top;
- float ty1 = SrcRect.bottom;
-
- float tx0_2 = 0;
- float tx1_2 = dst1.Width();
- float ty0_2 = 0;
- float ty1_2 = h;
-
- if(dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- MYD3DVERTEX<1> vx[] =
- {
- {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
- {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
- {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
- {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
- };
- AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug ici, génére des bandes verticales! TODO : pourquoi ??????
- MYD3DVERTEX<1> vy[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0 / dst[0].z, tx0_2, ty0_2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0 / dst[1].z, tx1_2, ty0_2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0 / dst[2].z, tx0_2, ty1_2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0 / dst[3].z, tx1_2, ty1_2},
- };
- AdjustQuad(vy, 0.0, 1.0);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[2]);
- {
- float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- }
- hr = m_pD3DDev->SetTexture(0, pTexture);
- CComPtr<IDirect3DSurface9> pRTOld;
- hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[0]->GetSurfaceLevel(0, &pRT);
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[3]);
- {
- float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
- }
- hr = m_pD3DDev->SetTexture(0, m_pScreenSizeTemporaryTexture[0]);
- hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
- hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ HRESULT hr;
+
+ // rotated?
+ if(dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
+ || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ D3DSURFACE_DESC desc;
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
+
+ float Tex0_Width = desc.Width;
+ float Tex0_Height = desc.Height;
+
+ double dx0 = 1.0/desc.Width;
+ double dy0 = 1.0/desc.Height;
+
+ CSize SrcTextSize = CSize(desc.Width, desc.Height);
+ double w = (double)SrcRect.Width();
+ double h = (double)SrcRect.Height();
+
+ CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
+
+ if(!m_pScreenSizeTemporaryTexture[0] || FAILED(m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc)))
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ float Tex1_Width = desc.Width;
+ float Tex1_Height = desc.Height;
+
+ double dx1 = 1.0/desc.Width;
+ double dy1 = 1.0/desc.Height;
+
+ double dw = (double)dst1.Width() / desc.Width;
+ double dh = (double)dst1.Height() / desc.Height;
+
+ float dx2 = 1.0f/SrcTextSize.cx;
+ float dy2 = 1.0f/SrcTextSize.cy;
+ float tx0 = SrcRect.left;
+ float tx1 = SrcRect.right;
+ float ty0 = SrcRect.top;
+ float ty1 = SrcRect.bottom;
+
+ float tx0_2 = 0;
+ float tx1_2 = dst1.Width();
+ float ty0_2 = 0;
+ float ty1_2 = h;
+
+ if(dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ MYD3DVERTEX<1> vx[] =
+ {
+ {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
+ {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
+ {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
+ {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
+ };
+ AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug ici, génére des bandes verticales! TODO : pourquoi ??????
+ MYD3DVERTEX<1> vy[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0/dst[0].z, tx0_2, ty0_2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0/dst[1].z, tx1_2, ty0_2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0/dst[2].z, tx0_2, ty1_2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0/dst[3].z, tx1_2, ty1_2},
+ };
+ AdjustQuad(vy, 0.0, 1.0);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[2]);
+ {
+ float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ }
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ CComPtr<IDirect3DSurface9> pRTOld;
+ hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[0]->GetSurfaceLevel(0, &pRT);
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[3]);
+ {
+ float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+ }
+ hr = m_pD3DDev->SetTexture(0, m_pScreenSizeTemporaryTexture[0]);
+ hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
+ hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
+ m_pD3DDev->SetPixelShader(NULL);
+ return hr;
}
HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture)
{
- if(!pSrc || !pDst)
- return E_POINTER;
+ if(!pSrc || !pDst)
+ return E_POINTER;
- CRect src(*pSrc), dst(*pDst);
+ CRect src(*pSrc), dst(*pDst);
- HRESULT hr;
+ HRESULT hr;
- do
- {
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
- break;
+ do
+ {
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
+ break;
- float w = (float)d3dsd.Width;
- float h = (float)d3dsd.Height;
+ float w = (float)d3dsd.Width;
+ float h = (float)d3dsd.Height;
- struct
- {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] =
- {
- {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
- {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
- {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
- {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
- };
+ struct
+ {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] =
+ {
+ {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
+ {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
+ {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
+ };
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- DWORD abe, sb, db;
- hr = m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe);
- hr = m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb);
- hr = m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db);
+ DWORD abe, sb, db;
+ hr = m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe);
+ hr = m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb);
+ hr = m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db);
- hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
- hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
+ hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
+ hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetPixelShader(NULL);
+ hr = m_pD3DDev->SetPixelShader(NULL);
- hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
- hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
+ hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
+ hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
- m_pD3DDev->SetTexture(0, NULL);
+ m_pD3DDev->SetTexture(0, NULL);
- m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
- m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
- m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
+ m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
+ m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
+ m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
- return S_OK;
- }
- while(0);
- return E_FAIL;
+ return S_OK;
+ }
+ while(0);
+ return E_FAIL;
}
// Update the array m_pllJitter with a new vsync period. Calculate min, max and stddev.
void CBaseAP::SyncStats(LONGLONG syncTime)
{
- m_nNextJitter = (m_nNextJitter + 1) % NB_JITTER;
- m_pllJitter[m_nNextJitter] = syncTime - m_llLastSyncTime;
- double syncDeviation = ((double)m_pllJitter[m_nNextJitter] - m_fJitterMean) / 10000.0;
- if(abs(syncDeviation) > (GetDisplayCycle() / 2))
- m_uSyncGlitches++;
-
- LONGLONG llJitterSum = 0;
- LONGLONG llJitterSumAvg = 0;
- for(int i = 0; i < NB_JITTER; i++)
- {
- LONGLONG Jitter = m_pllJitter[i];
- llJitterSum += Jitter;
- llJitterSumAvg += Jitter;
- }
- m_fJitterMean = double(llJitterSumAvg) / NB_JITTER;
- double DeviationSum = 0;
-
- for(int i = 0; i < NB_JITTER; i++)
- {
- LONGLONG DevInt = m_pllJitter[i] - m_fJitterMean;
- double Deviation = DevInt;
- DeviationSum += Deviation * Deviation;
- m_MaxJitter = max(m_MaxJitter, DevInt);
- m_MinJitter = min(m_MinJitter, DevInt);
- }
-
- m_fJitterStdDev = sqrt(DeviationSum / NB_JITTER);
- m_fAvrFps = 10000000.0 / (double(llJitterSum) / NB_JITTER);
- m_llLastSyncTime = syncTime;
+ m_nNextJitter = (m_nNextJitter+1) % NB_JITTER;
+ m_pllJitter[m_nNextJitter] = syncTime - m_llLastSyncTime;
+ double syncDeviation = ((double)m_pllJitter[m_nNextJitter] - m_fJitterMean) / 10000.0;
+ if (abs(syncDeviation) > (GetDisplayCycle() / 2))
+ m_uSyncGlitches++;
+
+ LONGLONG llJitterSum = 0;
+ LONGLONG llJitterSumAvg = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG Jitter = m_pllJitter[i];
+ llJitterSum += Jitter;
+ llJitterSumAvg += Jitter;
+ }
+ m_fJitterMean = double(llJitterSumAvg) / NB_JITTER;
+ double DeviationSum = 0;
+
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG DevInt = m_pllJitter[i] - m_fJitterMean;
+ double Deviation = DevInt;
+ DeviationSum += Deviation*Deviation;
+ m_MaxJitter = max(m_MaxJitter, DevInt);
+ m_MinJitter = min(m_MinJitter, DevInt);
+ }
+
+ m_fJitterStdDev = sqrt(DeviationSum/NB_JITTER);
+ m_fAvrFps = 10000000.0/(double(llJitterSum)/NB_JITTER);
+ m_llLastSyncTime = syncTime;
}
// Collect the difference between periodEnd and periodStart in an array, calculate mean and stddev.
void CBaseAP::SyncOffsetStats(LONGLONG syncOffset)
{
- m_nNextSyncOffset = (m_nNextSyncOffset + 1) % NB_JITTER;
- m_pllSyncOffset[m_nNextSyncOffset] = syncOffset;
-
- LONGLONG AvrageSum = 0;
- for(int i = 0; i < NB_JITTER; i++)
- {
- LONGLONG Offset = m_pllSyncOffset[i];
- AvrageSum += Offset;
- m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
- m_MinSyncOffset = min(m_MinSyncOffset, Offset);
- }
- double MeanOffset = double(AvrageSum) / NB_JITTER;
- double DeviationSum = 0;
- for(int i = 0; i < NB_JITTER; i++)
- {
- double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
- DeviationSum += Deviation * Deviation;
- }
- double StdDev = sqrt(DeviationSum / NB_JITTER);
-
- m_fSyncOffsetAvr = MeanOffset;
- m_fSyncOffsetStdDev = StdDev;
+ m_nNextSyncOffset = (m_nNextSyncOffset+1) % NB_JITTER;
+ m_pllSyncOffset[m_nNextSyncOffset] = syncOffset;
+
+ LONGLONG AvrageSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG Offset = m_pllSyncOffset[i];
+ AvrageSum += Offset;
+ m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
+ m_MinSyncOffset = min(m_MinSyncOffset, Offset);
+ }
+ double MeanOffset = double(AvrageSum)/NB_JITTER;
+ double DeviationSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
+ DeviationSum += Deviation*Deviation;
+ }
+ double StdDev = sqrt(DeviationSum/NB_JITTER);
+
+ m_fSyncOffsetAvr = MeanOffset;
+ m_fSyncOffsetStdDev = StdDev;
}
void CBaseAP::UpdateAlphaBitmap()
{
- m_VMR9AlphaBitmapData.Free();
+ m_VMR9AlphaBitmapData.Free();
- if((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
- {
- HBITMAP hBitmap = (HBITMAP)GetCurrentObject(m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
- if(!hBitmap)
- return;
- DIBSECTION info = {0};
- if(!::GetObject(hBitmap, sizeof(DIBSECTION), &info))
- return;
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
+ {
+ HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
+ if (!hBitmap)
+ return;
+ DIBSECTION info = {0};
+ if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info ))
+ return;
- m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
- m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
+ m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
+ m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
- if(m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight))
- {
- memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
- }
- }
+ if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight))
+ {
+ memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
+ }
+ }
}
// Present a sample (frame) using DirectX.
STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
{
- AppSettings& s = AfxGetAppSettings();
- CMPlayerCApp * pApp = AfxGetMyApp();
- D3DRASTER_STATUS rasterStatus;
- REFERENCE_TIME llCurRefTime = 0;
- REFERENCE_TIME llSyncOffset = 0;
- double dSyncOffset = 0.0;
-
- CAutoLock cRenderLock(&m_allocatorLock);
-
- // Estimate time for next vblank based on number of remaining lines in this frame. This algorithm seems to be
- // accurate within one ms why there should not be any need for a more accurate one. The wiggly line seen
- // when using sync to nearest and sync display is most likely due to inaccuracies in the audio-card-based
- // reference clock. The wiggles are not seen with the perfcounter-based reference clock of the sync to video option.
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- m_uScanLineEnteringPaint = rasterStatus.ScanLine;
- if(m_pRefClock) m_pRefClock->GetTime(&llCurRefTime);
- dSyncOffset = (m_ScreenSize.cy - m_uScanLineEnteringPaint) * m_dDetectedScanlineTime; // ms
- llSyncOffset = REFERENCE_TIME(10000.0 * dSyncOffset); // Reference time units (100 ns)
- m_llEstVBlankTime = llCurRefTime + llSyncOffset; // Estimated time for the start of next vblank
-
- if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
- || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
- || !m_pVideoSurface)
- {
- return(false);
- }
-
- HRESULT hr;
- CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
- CRect rDstVid(m_VideoRect);
- CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
- CRect rDstPri(m_WindowRect);
-
- m_pD3DDev->BeginScene();
- CComPtr<IDirect3DSurface9> pBackBuffer;
- m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
- m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- if(!rDstVid.IsRectEmpty())
- {
- if(m_pVideoTexture[m_nCurSurface])
- {
- CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
-
- if(m_pVideoTexture[m_nDXSurface] && m_pVideoTexture[m_nDXSurface+1] && !m_pPixelShaders.IsEmpty())
- {
- static __int64 counter = 0;
- static long start = clock();
-
- long stop = clock();
- long diff = stop - start;
-
- if(diff >= 10 * 60 * CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
-
- int src = m_nCurSurface, dst = m_nDXSurface;
-
- D3DSURFACE_DESC desc;
- m_pVideoTexture[src]->GetLevelDesc(0, &desc);
-
- float fConstData[][4] =
- {
- {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
- };
-
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
-
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pD3DDev->GetRenderTarget(0, &pRT);
-
- POSITION pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
- pVideoTexture = m_pVideoTexture[dst];
-
- hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- if(!Shader.m_pPixelShader)
- Shader.Compile(m_pPSC);
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- TextureCopy(m_pVideoTexture[src]);
-
- src = dst;
- if(++dst >= m_nDXSurface + 2) dst = m_nDXSurface;
- }
-
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- hr = m_pD3DDev->SetPixelShader(NULL);
- }
-
- Vector dst[4];
- Transform(rDstVid, dst);
-
- DWORD iDX9Resizer = s.iDX9Resizer;
-
- float A = 0;
-
- switch(iDX9Resizer)
- {
- case 3:
- A = -0.60f;
- break;
- case 4:
- A = -0.751f;
- break; // FIXME : 0.75 crash recent D3D, or eat CPU
- case 5:
- A = -1.00f;
- break;
- }
- bool bScreenSpacePixelShaders = !m_pPixelShadersScreenSpace.IsEmpty();
-
- hr = InitResizers(A, bScreenSpacePixelShaders);
-
- if(!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1])
- bScreenSpacePixelShaders = false;
-
- if(bScreenSpacePixelShaders)
- {
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
- if(hr != S_OK)
- bScreenSpacePixelShaders = false;
- if(bScreenSpacePixelShaders)
- {
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- if(hr != S_OK)
- bScreenSpacePixelShaders = false;
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- }
- }
-
- if(rSrcVid.Size() != rDstVid.Size())
- {
- if(iDX9Resizer == 0 || iDX9Resizer == 1)
- {
- D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
- hr = TextureResize(pVideoTexture, dst, Filter, rSrcVid);
- }
- else if(iDX9Resizer == 2)
- {
- hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
- }
- else if(iDX9Resizer >= 3)
- {
- hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
- }
- }
- else hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
-
- if(bScreenSpacePixelShaders)
- {
- static __int64 counter = 555;
- static long start = clock() + 333;
-
- long stop = clock() + 333;
- long diff = stop - start;
-
- if(diff >= 10 * 60 * CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
-
- D3DSURFACE_DESC desc;
- m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc);
-
- float fConstData[][4] =
- {
- {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
- };
-
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
-
- int src = 1, dst = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
- if(m_pPixelShadersScreenSpace.GetTailPosition() == pos)
- {
- m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- }
- else
- {
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[dst]->GetSurfaceLevel(0, &pRT);
- m_pD3DDev->SetRenderTarget(0, pRT);
- }
-
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- if(!Shader.m_pPixelShader)
- Shader.Compile(m_pPSC);
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- TextureCopy(m_pScreenSizeTemporaryTexture[src]);
-
- swap(src, dst);
- }
-
- hr = m_pD3DDev->SetPixelShader(NULL);
- }
- }
- else
- {
- if(pBackBuffer)
- {
- ClipToSurface(pBackBuffer, rSrcVid, rDstVid);
- // rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect
- rSrcVid.left &= ~1;
- rSrcVid.right &= ~1;
- rSrcVid.top &= ~1;
- rSrcVid.bottom &= ~1;
- hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
- if(FAILED(hr)) return false;
- }
- }
- }
- AlphaBltSubPic(rSrcPri.Size());
- if(m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE)
- {
- CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
- CRect rcSrc(m_VMR9AlphaBitmap.rSrc);
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- if((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData)
- {
- if((m_pD3DXLoadSurfaceFromMemory != NULL) &&
- SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
- D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)))
- {
- if(SUCCEEDED(hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface)))
- {
- hr = m_pD3DXLoadSurfaceFromMemory(m_pOSDSurface, NULL, NULL, (BYTE *)m_VMR9AlphaBitmapData, D3DFMT_A8R8G8B8, m_VMR9AlphaBitmapWidthBytes,
- NULL, &m_VMR9AlphaBitmapRect, D3DX_FILTER_NONE, m_VMR9AlphaBitmap.clrSrcKey);
- }
- if(FAILED(hr))
- {
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- }
- }
- }
- m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
- }
- if(pApp->m_fDisplayStats) DrawStats();
- if(m_pOSDTexture) AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
- m_pD3DDev->EndScene();
-
- if(m_pD3DDevEx)
- {
- if(m_bIsFullscreen)
- hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
- else
- hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
- }
- else
- {
- if(m_bIsFullscreen)
- hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
- else
- hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
- }
- if(FAILED(hr)) _tprintf(_T("Device lost or something\n"));
- // Calculate timing statistics
- if(m_pRefClock) m_pRefClock->GetTime(&llCurRefTime); // To check if we called Present too late to hit the right vsync
- m_llEstVBlankTime = max(m_llEstVBlankTime, llCurRefTime); // Sometimes the real value is larger than the estimated value (but never smaller)
- if(pApp->m_fDisplayStats < 3) // Partial on-screen statistics
- SyncStats(m_llEstVBlankTime); // Max of estimate and real. Sometimes Present may actually return immediately so we need the estimate as a lower bound
- if(pApp->m_fDisplayStats == 1) // Full on-screen statistics
- SyncOffsetStats(-llSyncOffset); // Minus because we want time to flow downward in the graph in DrawStats
-
- // Adjust sync
- double frameCycle = (double)((m_llSampleTime - m_llLastSampleTime) / 10000.0);
- if(frameCycle < 0) frameCycle = 0.0; // Happens when searching.
-
- if(s.m_RenderSettings.bSynchronizeVideo) m_pGenlock->ControlClock(dSyncOffset, frameCycle);
- else if(s.m_RenderSettings.bSynchronizeDisplay) m_pGenlock->ControlDisplay(dSyncOffset, frameCycle);
- else m_pGenlock->UpdateStats(dSyncOffset, frameCycle); // No sync or sync to nearest neighbor
-
- m_dFrameCycle = m_pGenlock->frameCycleAvg;
- if(m_dFrameCycle > 0.0) m_fps = 1000.0 / m_dFrameCycle;
- m_dCycleDifference = GetCycleDifference();
- if(abs(m_dCycleDifference) < 0.05) // If less than 5% speed difference
- m_bSnapToVSync = true;
- else
- m_bSnapToVSync = false;
-
- // Check how well audio is matching rate (if at all)
- DWORD tmp;
- if(m_pAudioStats != NULL)
- {
- m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_ACCUMERROR, &m_lAudioLag, &tmp);
- m_lAudioLagMin = min((long)m_lAudioLag, m_lAudioLagMin);
- m_lAudioLagMax = max((long)m_lAudioLag, m_lAudioLagMax);
- m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_MODE, &m_lAudioSlaveMode, &tmp);
- }
-
- if(pApp->m_bResetStats)
- {
- ResetStats();
- pApp->m_bResetStats = false;
- }
-
- bool fResetDevice = m_bPendingResetDevice;
- if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || hr == S_PRESENT_MODE_CHANGED)
- fResetDevice = true;
- if(SettingsNeedResetDevice())
- fResetDevice = true;
-
- BOOL bCompositionEnabled = false;
- if(m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- if((bCompositionEnabled != 0) != m_bCompositionEnabled)
- {
- if(m_bIsFullscreen)
- {
- m_bCompositionEnabled = (bCompositionEnabled != 0);
- }
- else
- fResetDevice = true;
- }
-
- if(s.fResetDevice)
- {
- D3DDEVICE_CREATION_PARAMETERS Parameters;
- if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters)) && m_pD3D->GetAdapterMonitor(Parameters.AdapterOrdinal) != m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)))
- fResetDevice = true;
- }
-
- if(fResetDevice)
- {
- if(m_bNeedPendingResetDevice)
- {
- m_bPendingResetDevice = true;
- }
- else
- {
- if(m_dMainThreadId && m_dMainThreadId == GetCurrentThreadId())
- {
- m_bPendingResetDevice = false;
-
- ResetDevice();
- }
- else
- m_bPendingResetDevice = true;
- }
- }
- return(true);
+ AppSettings& s = AfxGetAppSettings();
+ CMPlayerCApp * pApp = AfxGetMyApp();
+ D3DRASTER_STATUS rasterStatus;
+ REFERENCE_TIME llCurRefTime = 0;
+ REFERENCE_TIME llSyncOffset = 0;
+ double dSyncOffset = 0.0;
+
+ CAutoLock cRenderLock(&m_allocatorLock);
+
+ // Estimate time for next vblank based on number of remaining lines in this frame. This algorithm seems to be
+ // accurate within one ms why there should not be any need for a more accurate one. The wiggly line seen
+ // when using sync to nearest and sync display is most likely due to inaccuracies in the audio-card-based
+ // reference clock. The wiggles are not seen with the perfcounter-based reference clock of the sync to video option.
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ m_uScanLineEnteringPaint = rasterStatus.ScanLine;
+ if (m_pRefClock) m_pRefClock->GetTime(&llCurRefTime);
+ dSyncOffset = (m_ScreenSize.cy - m_uScanLineEnteringPaint) * m_dDetectedScanlineTime; // ms
+ llSyncOffset = REFERENCE_TIME(10000.0 * dSyncOffset); // Reference time units (100 ns)
+ m_llEstVBlankTime = llCurRefTime + llSyncOffset; // Estimated time for the start of next vblank
+
+ if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
+ || !m_pVideoSurface)
+ {
+ return(false);
+ }
+
+ HRESULT hr;
+ CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
+ CRect rDstVid(m_VideoRect);
+ CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
+ CRect rDstPri(m_WindowRect);
+
+ m_pD3DDev->BeginScene();
+ CComPtr<IDirect3DSurface9> pBackBuffer;
+ m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ if(!rDstVid.IsRectEmpty())
+ {
+ if(m_pVideoTexture[m_nCurSurface])
+ {
+ CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
+
+ if(m_pVideoTexture[m_nDXSurface] && m_pVideoTexture[m_nDXSurface+1] && !m_pPixelShaders.IsEmpty())
+ {
+ static __int64 counter = 0;
+ static long start = clock();
+
+ long stop = clock();
+ long diff = stop - start;
+
+ if(diff >= 10*60*CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+
+ int src = m_nCurSurface, dst = m_nDXSurface;
+
+ D3DSURFACE_DESC desc;
+ m_pVideoTexture[src]->GetLevelDesc(0, &desc);
+
+ float fConstData[][4] =
+ {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
+
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pD3DDev->GetRenderTarget(0, &pRT);
+
+ POSITION pos = m_pPixelShaders.GetHeadPosition();
+ while(pos)
+ {
+ pVideoTexture = m_pVideoTexture[dst];
+
+ hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
+ CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
+ if (!Shader.m_pPixelShader)
+ Shader.Compile(m_pPSC);
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pVideoTexture[src]);
+
+ src = dst;
+ if(++dst >= m_nDXSurface+2) dst = m_nDXSurface;
+ }
+
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ }
+
+ Vector dst[4];
+ Transform(rDstVid, dst);
+
+ DWORD iDX9Resizer = s.iDX9Resizer;
+
+ float A = 0;
+
+ switch(iDX9Resizer)
+ {
+ case 3: A = -0.60f; break;
+ case 4: A = -0.751f; break; // FIXME : 0.75 crash recent D3D, or eat CPU
+ case 5: A = -1.00f; break;
+ }
+ bool bScreenSpacePixelShaders = !m_pPixelShadersScreenSpace.IsEmpty();
+
+ hr = InitResizers(A, bScreenSpacePixelShaders);
+
+ if (!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1])
+ bScreenSpacePixelShaders = false;
+
+ if (bScreenSpacePixelShaders)
+ {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
+ if (hr != S_OK)
+ bScreenSpacePixelShaders = false;
+ if (bScreenSpacePixelShaders)
+ {
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ if (hr != S_OK)
+ bScreenSpacePixelShaders = false;
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ }
+ }
+
+ if(rSrcVid.Size() != rDstVid.Size())
+ {
+ if(iDX9Resizer == 0 || iDX9Resizer == 1)
+ {
+ D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
+ hr = TextureResize(pVideoTexture, dst, Filter, rSrcVid);
+ }
+ else if(iDX9Resizer == 2)
+ {
+ hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
+ }
+ else if(iDX9Resizer >= 3)
+ {
+ hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
+ }
+ }
+ else hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
+
+ if (bScreenSpacePixelShaders)
+ {
+ static __int64 counter = 555;
+ static long start = clock() + 333;
+
+ long stop = clock() + 333;
+ long diff = stop - start;
+
+ if(diff >= 10*60*CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+
+ D3DSURFACE_DESC desc;
+ m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc);
+
+ float fConstData[][4] =
+ {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
+
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+
+ int src = 1, dst = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ if (m_pPixelShadersScreenSpace.GetTailPosition() == pos)
+ {
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ }
+ else
+ {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[dst]->GetSurfaceLevel(0, &pRT);
+ m_pD3DDev->SetRenderTarget(0, pRT);
+ }
+
+ CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ if (!Shader.m_pPixelShader)
+ Shader.Compile(m_pPSC);
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pScreenSizeTemporaryTexture[src]);
+
+ swap(src, dst);
+ }
+
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ }
+ }
+ else
+ {
+ if(pBackBuffer)
+ {
+ ClipToSurface(pBackBuffer, rSrcVid, rDstVid);
+ // rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect
+ rSrcVid.left &= ~1; rSrcVid.right &= ~1;
+ rSrcVid.top &= ~1; rSrcVid.bottom &= ~1;
+ hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
+ if(FAILED(hr)) return false;
+ }
+ }
+ }
+ AlphaBltSubPic(rSrcPri.Size());
+ if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE)
+ {
+ CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
+ CRect rcSrc (m_VMR9AlphaBitmap.rSrc);
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData)
+ {
+ if( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
+ SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
+ D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) )
+ {
+ if (SUCCEEDED (hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface)))
+ {
+ hr = m_pD3DXLoadSurfaceFromMemory (m_pOSDSurface, NULL, NULL, (BYTE *)m_VMR9AlphaBitmapData, D3DFMT_A8R8G8B8, m_VMR9AlphaBitmapWidthBytes,
+ NULL, &m_VMR9AlphaBitmapRect, D3DX_FILTER_NONE, m_VMR9AlphaBitmap.clrSrcKey);
+ }
+ if (FAILED (hr))
+ {
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ }
+ }
+ }
+ m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
+ }
+ if (pApp->m_fDisplayStats) DrawStats();
+ if (m_pOSDTexture) AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+ m_pD3DDev->EndScene();
+
+ if (m_pD3DDevEx)
+ {
+ if (m_bIsFullscreen)
+ hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
+ else
+ hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
+ }
+ else
+ {
+ if (m_bIsFullscreen)
+ hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
+ else
+ hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ }
+ if(FAILED(hr)) _tprintf(_T("Device lost or something\n"));
+ // Calculate timing statistics
+ if (m_pRefClock) m_pRefClock->GetTime(&llCurRefTime); // To check if we called Present too late to hit the right vsync
+ m_llEstVBlankTime = max(m_llEstVBlankTime, llCurRefTime); // Sometimes the real value is larger than the estimated value (but never smaller)
+ if (pApp->m_fDisplayStats < 3) // Partial on-screen statistics
+ SyncStats(m_llEstVBlankTime); // Max of estimate and real. Sometimes Present may actually return immediately so we need the estimate as a lower bound
+ if (pApp->m_fDisplayStats == 1) // Full on-screen statistics
+ SyncOffsetStats(-llSyncOffset); // Minus because we want time to flow downward in the graph in DrawStats
+
+ // Adjust sync
+ double frameCycle = (double)((m_llSampleTime - m_llLastSampleTime) / 10000.0);
+ if (frameCycle < 0) frameCycle = 0.0; // Happens when searching.
+
+ if (s.m_RenderSettings.bSynchronizeVideo) m_pGenlock->ControlClock(dSyncOffset, frameCycle);
+ else if (s.m_RenderSettings.bSynchronizeDisplay) m_pGenlock->ControlDisplay(dSyncOffset, frameCycle);
+ else m_pGenlock->UpdateStats(dSyncOffset, frameCycle); // No sync or sync to nearest neighbor
+
+ m_dFrameCycle = m_pGenlock->frameCycleAvg;
+ if (m_dFrameCycle > 0.0) m_fps = 1000.0 / m_dFrameCycle;
+ m_dCycleDifference = GetCycleDifference();
+ if (abs(m_dCycleDifference) < 0.05) // If less than 5% speed difference
+ m_bSnapToVSync = true;
+ else
+ m_bSnapToVSync = false;
+
+ // Check how well audio is matching rate (if at all)
+ DWORD tmp;
+ if (m_pAudioStats != NULL)
+ {
+ m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_ACCUMERROR, &m_lAudioLag, &tmp);
+ m_lAudioLagMin = min((long)m_lAudioLag, m_lAudioLagMin);
+ m_lAudioLagMax = max((long)m_lAudioLag, m_lAudioLagMax);
+ m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_MODE, &m_lAudioSlaveMode, &tmp);
+ }
+
+ if (pApp->m_bResetStats)
+ {
+ ResetStats();
+ pApp->m_bResetStats = false;
+ }
+
+ bool fResetDevice = m_bPendingResetDevice;
+ if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || hr == S_PRESENT_MODE_CHANGED)
+ fResetDevice = true;
+ if (SettingsNeedResetDevice())
+ fResetDevice = true;
+
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ if ((bCompositionEnabled != 0) != m_bCompositionEnabled)
+ {
+ if (m_bIsFullscreen)
+ {
+ m_bCompositionEnabled = (bCompositionEnabled != 0);
+ }
+ else
+ fResetDevice = true;
+ }
+
+ if(s.fResetDevice)
+ {
+ D3DDEVICE_CREATION_PARAMETERS Parameters;
+ if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters)) && m_pD3D->GetAdapterMonitor(Parameters.AdapterOrdinal) != m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)))
+ fResetDevice = true;
+ }
+
+ if(fResetDevice)
+ {
+ if (m_bNeedPendingResetDevice)
+ {
+ m_bPendingResetDevice = true;
+ }
+ else
+ {
+ if (m_dMainThreadId && m_dMainThreadId == GetCurrentThreadId())
+ {
+ m_bPendingResetDevice = false;
+
+ ResetDevice();
+ }
+ else
+ m_bPendingResetDevice = true;
+ }
+ }
+ return(true);
}
bool CBaseAP::ResetDevice()
{
- DeleteSurfaces();
- HRESULT hr;
- CString Error;
- if(FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) return false;
- m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
- m_pGenlock->GetTiming();
- OnResetDevice();
- return true;
+ DeleteSurfaces();
+ HRESULT hr;
+ CString Error;
+ if(FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) return false;
+ m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
+ m_pGenlock->GetTiming();
+ OnResetDevice();
+ return true;
}
void CBaseAP::DrawText(const RECT &rc, const CString &strText, int _Priority)
{
- if(_Priority < 1) return;
- int Quality = 1;
- D3DXCOLOR Color1(1.0f, 0.2f, 0.2f, 1.0f);
- D3DXCOLOR Color0(0.0f, 0.0f, 0.0f, 1.0f);
- RECT Rect1 = rc;
- RECT Rect2 = rc;
- if(Quality == 1)
- OffsetRect(&Rect2 , 2, 2);
- else
- OffsetRect(&Rect2 , -1, -1);
- if(Quality > 0)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 1, 0);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 1, 0);
- if(Quality > 2)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 0, 1);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 0, 1);
- if(Quality > 1)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , -1, 0);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , -1, 0);
- if(Quality > 2)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- OffsetRect(&Rect2 , 0, -1);
- if(Quality > 3)
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
+ if (_Priority < 1) return;
+ int Quality = 1;
+ D3DXCOLOR Color1(1.0f, 0.2f, 0.2f, 1.0f );
+ D3DXCOLOR Color0(0.0f, 0.0f, 0.0f, 1.0f );
+ RECT Rect1 = rc;
+ RECT Rect2 = rc;
+ if (Quality == 1)
+ OffsetRect(&Rect2 , 2, 2);
+ else
+ OffsetRect(&Rect2 , -1, -1);
+ if (Quality > 0)
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 1, 0);
+ if (Quality > 3)
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 1, 0);
+ if (Quality > 2)
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, 1);
+ if (Quality > 3)
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, 1);
+ if (Quality > 1)
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , -1, 0);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , -1, 0);
+ if (Quality > 2)
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, -1);
+ if (Quality > 3)
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
}
void CBaseAP::DrawStats()
{
- AppSettings& s = AfxGetAppSettings();
- CMPlayerCApp * pApp = AfxGetMyApp();
-
- LONGLONG llMaxJitter = m_MaxJitter;
- LONGLONG llMinJitter = m_MinJitter;
- LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
- LONGLONG llMinSyncOffset = m_MinSyncOffset;
-
- RECT rc = {20, 20, 520, 520 };
- // pApp->m_fDisplayStats = 1 for full stats, 2 for little less, 3 for basic, 0 for no stats
- if(m_pFont && m_pSprite)
- {
- m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
- CString strText;
- int TextHeight = 25.0 * m_TextScale + 0.5;
-
- strText.Format(L"Frames drawn from stream start: %d | Sample time stamp: %d ms", m_pcFramesDrawn, (LONG)(m_llSampleTime / 10000));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(pApp->m_fDisplayStats == 1)
- {
- strText.Format(L"Frame cycle: %.3f ms [%.3f ms, %.3f ms] | Frame rate: %.3f fps", m_dFrameCycle, m_pGenlock->minFrameCycle, m_pGenlock->maxFrameCycle, m_fps);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Measured closest match display cycle: %.3f ms | Measured base display cycle: %.3f ms", m_dOptimumDisplayCycle, m_dEstRefreshCycle);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Display cycle - frame cycle mismatch: %.3f %%", 100 * m_dCycleDifference);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Actual frame cycle: %+5.3f ms [%+.3f ms, %+.3f ms] | Actual frame rate: %.3f fps", m_fJitterMean / 10000.0, (double(llMinJitter) / 10000.0), (double(llMaxJitter) / 10000.0), 10000000.0 / m_fJitterMean);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Display cycle from Windows: %.3f ms | Display refresh rate from Windows: %d Hz", m_dD3DRefreshCycle, m_uD3DRefreshRate);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(m_pGenlock->powerstripTimingExists)
- {
- strText.Format(L"Display cycle from Powerstrip: %.3f ms | Display refresh rate from Powerstrip: %.3f Hz", 1000.0 / m_pGenlock->curDisplayFreq, m_pGenlock->curDisplayFreq);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- if((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0)
- {
- strText.Format(L"Graphics device does not support scan line access. No sync is possible");
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- strText.Format(L"Video resolution: %d x %d | Aspect ratio: %d x %d", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Display resolution: %d x %d", m_ScreenSize.cx, m_ScreenSize.cy);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(s.m_RenderSettings.bSynchronizeDisplay || s.m_RenderSettings.bSynchronizeVideo)
- {
- if(s.m_RenderSettings.bSynchronizeDisplay && !m_pGenlock->PowerstripRunning())
- {
- strText.Format(L"PowerStrip is not running. No display sync is possible.");
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- else
- {
- strText.Format(L"Sync adjustment: %d | # of adjustments: %d", m_pGenlock->adjDelta, (m_pGenlock->clockAdjustmentsMade + m_pGenlock->displayAdjustmentsMade) / 2);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
- }
-
- strText.Format(L"Average sync offset: %3.1f ms [%.1f ms, %.1f ms] | Target sync offset: %3.1f ms", m_pGenlock->syncOffsetAvg, m_pGenlock->minSyncOffset, m_pGenlock->maxSyncOffset, s.m_RenderSettings.fTargetSyncOffset);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if(pApp->m_fDisplayStats < 3)
- {
- strText.Format(L"# of sync glitches: %d", m_uSyncGlitches);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"# of frames dropped: %d", m_pcFramesDropped);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- if(pApp->m_fDisplayStats == 1)
- {
- if(m_pAudioStats && s.m_RenderSettings.bSynchronizeVideo)
- {
- strText.Format(L"Audio lag: %3d ms [%d ms, %d ms] | %s", m_lAudioLag, m_lAudioLagMin, m_lAudioLagMax, (m_lAudioSlaveMode == 4) ? _T("Audio renderer is matching rate (for analog sound output)") : _T("Audio renderer is not matching rate"));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- strText.Format(L"Sample waiting time: %d ms", m_lNextSampleWait);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- if(s.m_RenderSettings.bSynchronizeNearest)
- {
- strText.Format(L"Sample paint time correction: %2d ms | Hysteresis: %d", m_lShiftToNearest, m_llHysteresis / 10000);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- strText.Format(L"Buffered: %3d | Free: %3d | Current surface: %3d", m_nUsedBuffer, m_nDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Settings: ");
-
- if(m_bIsFullscreen)
- strText += "D3DFS ";
- if(s.m_RenderSettings.iVMRDisableDesktopComposition)
- strText += "DisDC ";
- if(s.m_RenderSettings.bSynchronizeVideo)
- strText += "SyncVideo ";
- if(s.m_RenderSettings.bSynchronizeDisplay)
- strText += "SyncDisplay ";
- if(s.m_RenderSettings.bSynchronizeNearest)
- strText += "SyncNearest ";
- if(m_bHighColorResolution)
- strText += "10 bit ";
- if(s.m_RenderSettings.iEVROutputRange == 0)
- strText += "0-255 ";
- else if(s.m_RenderSettings.iEVROutputRange == 1)
- strText += "16-235 ";
-
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"%s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"DirectX SDK: %d", AfxGetMyApp()->GetDXSdkRelease());
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- for(int i = 0; i < 6; i++)
- {
- if(m_strStatsMsg[i][0])
- {
- DrawText(rc, m_strStatsMsg[i], 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
- }
- OffsetRect(&rc, 0, TextHeight); // Extra "line feed"
- m_pSprite->End();
- }
-
- if(m_pLine && (pApp->m_fDisplayStats < 3))
- {
- D3DXVECTOR2 Points[NB_JITTER];
- int nIndex;
-
- int DrawWidth = 625;
- int DrawHeight = 250;
- int Alpha = 80;
- int StartX = rc.left;
- int StartY = rc.top;
-
- DrawRect(RGB(0, 0, 0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
- m_pLine->SetWidth(2.5);
- m_pLine->SetAntialias(1);
- m_pLine->Begin();
-
- for(int i = 0; i <= DrawHeight; i += 5)
- {
- Points[0].x = (FLOAT)StartX;
- Points[0].y = (FLOAT)(StartY + i);
- Points[1].x = (FLOAT)(StartX + ((i + 25) % 25 ? 50 : 625));
- Points[1].y = (FLOAT)(StartY + i);
- m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
- }
-
- for(int i = 0; i < DrawWidth; i += 125) // Every 25:th sample
- {
- Points[0].x = (FLOAT)(StartX + i);
- Points[0].y = (FLOAT)(StartY + DrawHeight / 2);
- Points[1].x = (FLOAT)(StartX + i);
- Points[1].y = (FLOAT)(StartY + DrawHeight / 2 + 10);
- m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
- }
-
- for(int i = 0; i < NB_JITTER; i++)
- {
- nIndex = (m_nNextJitter + 1 + i) % NB_JITTER;
- if(nIndex < 0)
- nIndex += NB_JITTER;
- double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
- Points[i].x = (FLOAT)(StartX + (i * 5));
- Points[i].y = (FLOAT)(StartY + (Jitter / 2000.0 + 125.0));
- }
- m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(255, 100, 100));
-
- if(pApp->m_fDisplayStats == 1) // Full on-screen statistics
- {
- for(int i = 0; i < NB_JITTER; i++)
- {
- nIndex = (m_nNextSyncOffset + 1 + i) % NB_JITTER;
- if(nIndex < 0)
- nIndex += NB_JITTER;
- Points[i].x = (FLOAT)(StartX + (i * 5));
- Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]) / 2000 + 125));
- }
- m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(100, 200, 100));
- }
- m_pLine->End();
- }
+ AppSettings& s = AfxGetAppSettings();
+ CMPlayerCApp * pApp = AfxGetMyApp();
+
+ LONGLONG llMaxJitter = m_MaxJitter;
+ LONGLONG llMinJitter = m_MinJitter;
+ LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
+ LONGLONG llMinSyncOffset = m_MinSyncOffset;
+
+ RECT rc = {20, 20, 520, 520 };
+ // pApp->m_fDisplayStats = 1 for full stats, 2 for little less, 3 for basic, 0 for no stats
+ if (m_pFont && m_pSprite)
+ {
+ m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
+ CString strText;
+ int TextHeight = 25.0*m_TextScale + 0.5;
+
+ strText.Format(L"Frames drawn from stream start: %d | Sample time stamp: %d ms", m_pcFramesDrawn, (LONG)(m_llSampleTime / 10000));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (pApp->m_fDisplayStats == 1)
+ {
+ strText.Format(L"Frame cycle: %.3f ms [%.3f ms, %.3f ms] | Frame rate: %.3f fps", m_dFrameCycle, m_pGenlock->minFrameCycle, m_pGenlock->maxFrameCycle, m_fps);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Measured closest match display cycle: %.3f ms | Measured base display cycle: %.3f ms", m_dOptimumDisplayCycle, m_dEstRefreshCycle);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Display cycle - frame cycle mismatch: %.3f %%", 100 * m_dCycleDifference);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Actual frame cycle: %+5.3f ms [%+.3f ms, %+.3f ms] | Actual frame rate: %.3f fps", m_fJitterMean / 10000.0, (double(llMinJitter)/10000.0), (double(llMaxJitter)/10000.0), 10000000.0 / m_fJitterMean);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Display cycle from Windows: %.3f ms | Display refresh rate from Windows: %d Hz", m_dD3DRefreshCycle, m_uD3DRefreshRate);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (m_pGenlock->powerstripTimingExists)
+ {
+ strText.Format(L"Display cycle from Powerstrip: %.3f ms | Display refresh rate from Powerstrip: %.3f Hz", 1000.0 / m_pGenlock->curDisplayFreq, m_pGenlock->curDisplayFreq);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if ((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0)
+ {
+ strText.Format(L"Graphics device does not support scan line access. No sync is possible");
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ strText.Format(L"Video resolution: %d x %d | Aspect ratio: %d x %d", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Display resolution: %d x %d", m_ScreenSize.cx, m_ScreenSize.cy);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (s.m_RenderSettings.bSynchronizeDisplay || s.m_RenderSettings.bSynchronizeVideo)
+ {
+ if (s.m_RenderSettings.bSynchronizeDisplay && !m_pGenlock->PowerstripRunning())
+ {
+ strText.Format(L"PowerStrip is not running. No display sync is possible.");
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ else
+ {
+ strText.Format(L"Sync adjustment: %d | # of adjustments: %d", m_pGenlock->adjDelta, (m_pGenlock->clockAdjustmentsMade + m_pGenlock->displayAdjustmentsMade) / 2);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+ }
+
+ strText.Format(L"Average sync offset: %3.1f ms [%.1f ms, %.1f ms] | Target sync offset: %3.1f ms", m_pGenlock->syncOffsetAvg, m_pGenlock->minSyncOffset, m_pGenlock->maxSyncOffset, s.m_RenderSettings.fTargetSyncOffset);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (pApp->m_fDisplayStats < 3)
+ {
+ strText.Format(L"# of sync glitches: %d", m_uSyncGlitches);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"# of frames dropped: %d", m_pcFramesDropped);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (pApp->m_fDisplayStats == 1)
+ {
+ if (m_pAudioStats && s.m_RenderSettings.bSynchronizeVideo)
+ {
+ strText.Format(L"Audio lag: %3d ms [%d ms, %d ms] | %s", m_lAudioLag, m_lAudioLagMin, m_lAudioLagMax, (m_lAudioSlaveMode == 4) ? _T("Audio renderer is matching rate (for analog sound output)") : _T("Audio renderer is not matching rate"));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ strText.Format(L"Sample waiting time: %d ms", m_lNextSampleWait);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ if (s.m_RenderSettings.bSynchronizeNearest)
+ {
+ strText.Format(L"Sample paint time correction: %2d ms | Hysteresis: %d", m_lShiftToNearest, m_llHysteresis /10000);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ strText.Format(L"Buffered: %3d | Free: %3d | Current surface: %3d", m_nUsedBuffer, m_nDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Settings: ");
+
+ if (m_bIsFullscreen)
+ strText += "D3DFS ";
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ strText += "DisDC ";
+ if (s.m_RenderSettings.bSynchronizeVideo)
+ strText += "SyncVideo ";
+ if (s.m_RenderSettings.bSynchronizeDisplay)
+ strText += "SyncDisplay ";
+ if (s.m_RenderSettings.bSynchronizeNearest)
+ strText += "SyncNearest ";
+ if (m_bHighColorResolution)
+ strText += "10 bit ";
+ if (s.m_RenderSettings.iEVROutputRange == 0)
+ strText += "0-255 ";
+ else if (s.m_RenderSettings.iEVROutputRange == 1)
+ strText += "16-235 ";
+
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"%s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"DirectX SDK: %d", AfxGetMyApp()->GetDXSdkRelease());
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ for (int i=0; i<6; i++)
+ {
+ if (m_strStatsMsg[i][0])
+ {
+ DrawText(rc, m_strStatsMsg[i], 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+ }
+ OffsetRect(&rc, 0, TextHeight); // Extra "line feed"
+ m_pSprite->End();
+ }
+
+ if (m_pLine && (pApp->m_fDisplayStats < 3))
+ {
+ D3DXVECTOR2 Points[NB_JITTER];
+ int nIndex;
+
+ int DrawWidth = 625;
+ int DrawHeight = 250;
+ int Alpha = 80;
+ int StartX = rc.left;
+ int StartY = rc.top;
+
+ DrawRect(RGB(0, 0, 0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
+ m_pLine->SetWidth(2.5);
+ m_pLine->SetAntialias(1);
+ m_pLine->Begin();
+
+ for (int i = 0; i <= DrawHeight; i += 5)
+ {
+ Points[0].x = (FLOAT)StartX;
+ Points[0].y = (FLOAT)(StartY + i);
+ Points[1].x = (FLOAT)(StartX + ((i + 25) % 25 ? 50 : 625));
+ Points[1].y = (FLOAT)(StartY + i);
+ m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
+ }
+
+ for (int i = 0; i < DrawWidth; i += 125) // Every 25:th sample
+ {
+ Points[0].x = (FLOAT)(StartX + i);
+ Points[0].y = (FLOAT)(StartY + DrawHeight / 2);
+ Points[1].x = (FLOAT)(StartX + i);
+ Points[1].y = (FLOAT)(StartY + DrawHeight / 2 + 10);
+ m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
+ }
+
+ for (int i = 0; i < NB_JITTER; i++)
+ {
+ nIndex = (m_nNextJitter + 1 + i) % NB_JITTER;
+ if (nIndex < 0)
+ nIndex += NB_JITTER;
+ double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
+ Points[i].x = (FLOAT)(StartX + (i * 5));
+ Points[i].y = (FLOAT)(StartY + (Jitter / 2000.0 + 125.0));
+ }
+ m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(255, 100, 100));
+
+ if (pApp->m_fDisplayStats == 1) // Full on-screen statistics
+ {
+ for (int i = 0; i < NB_JITTER; i++)
+ {
+ nIndex = (m_nNextSyncOffset + 1 + i) % NB_JITTER;
+ if (nIndex < 0)
+ nIndex += NB_JITTER;
+ Points[i].x = (FLOAT)(StartX + (i * 5));
+ Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]) / 2000 + 125));
+ }
+ m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(100, 200, 100));
+ }
+ m_pLine->End();
+ }
}
double CBaseAP::GetRefreshRate()
{
- if(m_pGenlock->powerstripTimingExists) return m_pGenlock->curDisplayFreq;
- else return (double)m_uD3DRefreshRate;
+ if (m_pGenlock->powerstripTimingExists) return m_pGenlock->curDisplayFreq;
+ else return (double)m_uD3DRefreshRate;
}
double CBaseAP::GetDisplayCycle()
{
- if(m_pGenlock->powerstripTimingExists) return 1000.0 / m_pGenlock->curDisplayFreq;
- else return (double)m_dD3DRefreshCycle;
+ if (m_pGenlock->powerstripTimingExists) return 1000.0 / m_pGenlock->curDisplayFreq;
+ else return (double)m_dD3DRefreshCycle;
}
double CBaseAP::GetCycleDifference()
{
- double dBaseDisplayCycle = GetDisplayCycle();
- UINT i;
- double minDiff = 1.0;
- if(dBaseDisplayCycle == 0.0 || m_dFrameCycle == 0.0)
- return 1.0;
- else
- {
- for(i = 1; i <= 8; i++) // Try a lot of multiples of the display frequency
- {
- double dDisplayCycle = i * dBaseDisplayCycle;
- double diff = (dDisplayCycle - m_dFrameCycle) / m_dFrameCycle;
- if(abs(diff) < abs(minDiff))
- {
- minDiff = diff;
- m_dOptimumDisplayCycle = dDisplayCycle;
- }
- }
- }
- return minDiff;
+ double dBaseDisplayCycle = GetDisplayCycle();
+ UINT i;
+ double minDiff = 1.0;
+ if (dBaseDisplayCycle == 0.0 || m_dFrameCycle == 0.0)
+ return 1.0;
+ else
+ {
+ for (i = 1; i <= 8; i++) // Try a lot of multiples of the display frequency
+ {
+ double dDisplayCycle = i * dBaseDisplayCycle;
+ double diff = (dDisplayCycle - m_dFrameCycle) / m_dFrameCycle;
+ if (abs(diff) < abs(minDiff))
+ {
+ minDiff = diff;
+ m_dOptimumDisplayCycle = dDisplayCycle;
+ }
+ }
+ }
+ return minDiff;
}
void CBaseAP::EstimateRefreshTimings()
{
- if(m_pD3DDev)
- {
- CMPlayerCApp *pApp = AfxGetMyApp();
- D3DRASTER_STATUS rasterStatus;
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while(rasterStatus.ScanLine != 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while(rasterStatus.ScanLine == 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- LONGLONG startTime = pApp->GetPerfCounter();
- UINT startLine = rasterStatus.ScanLine;
- LONGLONG endTime = 0;
- LONGLONG time = 0;
- UINT endLine = 0;
- UINT line = 0;
- bool done = false;
- while(!done) // Estimate time for one scan line
- {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- line = rasterStatus.ScanLine;
- time = pApp->GetPerfCounter();
- if(line > 0)
- {
- endLine = line;
- endTime = time;
- }
- else
- done = true;
- }
- m_dDetectedScanlineTime = (double)(endTime - startTime) / (double)((endLine - startLine) * 10000.0);
-
- // Estimate the display refresh rate from the vsyncs
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while(rasterStatus.ScanLine != 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- // Now we're at the start of a vsync
- startTime = pApp->GetPerfCounter();
- UINT i;
- for(i = 1; i <= 50; i++)
- {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while(rasterStatus.ScanLine == 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while(rasterStatus.ScanLine != 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- // Now we're at the next vsync
- }
- endTime = pApp->GetPerfCounter();
- m_dEstRefreshCycle = (double)(endTime - startTime) / ((i - 1) * 10000.0);
- }
+ if (m_pD3DDev)
+ {
+ CMPlayerCApp *pApp = AfxGetMyApp();
+ D3DRASTER_STATUS rasterStatus;
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine != 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine == 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ LONGLONG startTime = pApp->GetPerfCounter();
+ UINT startLine = rasterStatus.ScanLine;
+ LONGLONG endTime = 0;
+ LONGLONG time = 0;
+ UINT endLine = 0;
+ UINT line = 0;
+ bool done = false;
+ while (!done) // Estimate time for one scan line
+ {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ line = rasterStatus.ScanLine;
+ time = pApp->GetPerfCounter();
+ if (line > 0)
+ {
+ endLine = line;
+ endTime = time;
+ }
+ else
+ done = true;
+ }
+ m_dDetectedScanlineTime = (double)(endTime - startTime) / (double)((endLine - startLine) * 10000.0);
+
+ // Estimate the display refresh rate from the vsyncs
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine != 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ // Now we're at the start of a vsync
+ startTime = pApp->GetPerfCounter();
+ UINT i;
+ for (i = 1; i <= 50; i++)
+ {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine == 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine != 0) m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ // Now we're at the next vsync
+ }
+ endTime = pApp->GetPerfCounter();
+ m_dEstRefreshCycle = (double)(endTime - startTime) / ((i - 1) * 10000.0);
+ }
}
bool CBaseAP::ExtractInterlaced(const AM_MEDIA_TYPE* pmt)
{
- if(pmt->formattype == FORMAT_VideoInfo)
- return false;
- else if(pmt->formattype == FORMAT_VideoInfo2)
- return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else if(pmt->formattype == FORMAT_MPEGVideo)
- return false;
- else if(pmt->formattype == FORMAT_MPEG2Video)
- return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else
- return false;
+ if (pmt->formattype==FORMAT_VideoInfo)
+ return false;
+ else if (pmt->formattype==FORMAT_VideoInfo2)
+ return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ else if (pmt->formattype==FORMAT_MPEGVideo)
+ return false;
+ else if (pmt->formattype==FORMAT_MPEG2Video)
+ return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ else
+ return false;
}
STDMETHODIMP CBaseAP::GetDIB(BYTE* lpDib, DWORD* size)
{
- CheckPointer(size, E_POINTER);
-
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- memset(&desc, 0, sizeof(desc));
- m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
-
- DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if(!lpDib)
- {
- *size = required;
- return S_OK;
- }
- if(*size < required) return E_OUTOFMEMORY;
- *size = required;
-
- CComPtr<IDirect3DSurface9> pSurface = m_pVideoSurface[m_nCurSurface];
- D3DLOCKED_RECT r;
- if(FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
- {
- pSurface = NULL;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
- || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
- || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
- return hr;
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = desc.Width;
- bih->biHeight = desc.Height;
- bih->biBitCount = 32;
- bih->biPlanes = 1;
- bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
-
- BitBltFromRGBToRGB(
- bih->biWidth, bih->biHeight,
- (BYTE*)(bih + 1), bih->biWidth * bih->biBitCount >> 3, bih->biBitCount,
- (BYTE*)r.pBits + r.Pitch*(desc.Height - 1), -(int)r.Pitch, 32);
-
- pSurface->UnlockRect();
-
- return S_OK;
+ CheckPointer(size, E_POINTER);
+
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ memset(&desc, 0, sizeof(desc));
+ m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
+
+ DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
+ if(!lpDib) {*size = required; return S_OK;}
+ if(*size < required) return E_OUTOFMEMORY;
+ *size = required;
+
+ CComPtr<IDirect3DSurface9> pSurface = m_pVideoSurface[m_nCurSurface];
+ D3DLOCKED_RECT r;
+ if(FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
+ {
+ pSurface = NULL;
+ if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY)))
+ return hr;
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = desc.Width;
+ bih->biHeight = desc.Height;
+ bih->biBitCount = 32;
+ bih->biPlanes = 1;
+ bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
+
+ BitBltFromRGBToRGB(
+ bih->biWidth, bih->biHeight,
+ (BYTE*)(bih + 1), bih->biWidth*bih->biBitCount>>3, bih->biBitCount,
+ (BYTE*)r.pBits + r.Pitch*(desc.Height-1), -(int)r.Pitch, 32);
+
+ pSurface->UnlockRect();
+
+ return S_OK;
}
STDMETHODIMP CBaseAP::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return SetPixelShader2(pSrcData, pTarget, false);
+ return SetPixelShader2(pSrcData, pTarget, false);
}
STDMETHODIMP CBaseAP::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
{
- CAutoLock cRenderLock(&m_allocatorLock);
+ CAutoLock cRenderLock(&m_allocatorLock);
- CAtlList<CExternalPixelShader> *pPixelShaders;
- if(bScreenSpace)
- pPixelShaders = &m_pPixelShadersScreenSpace;
- else
- pPixelShaders = &m_pPixelShaders;
+ CAtlList<CExternalPixelShader> *pPixelShaders;
+ if (bScreenSpace)
+ pPixelShaders = &m_pPixelShadersScreenSpace;
+ else
+ pPixelShaders = &m_pPixelShaders;
- if(!pSrcData && !pTarget)
- {
- pPixelShaders->RemoveAll();
- m_pD3DDev->SetPixelShader(NULL);
- return S_OK;
- }
+ if(!pSrcData && !pTarget)
+ {
+ pPixelShaders->RemoveAll();
+ m_pD3DDev->SetPixelShader(NULL);
+ return S_OK;
+ }
- if(!pSrcData || !pTarget)
- return E_INVALIDARG;
+ if(!pSrcData || !pTarget)
+ return E_INVALIDARG;
- CExternalPixelShader Shader;
- Shader.m_SourceData = pSrcData;
- Shader.m_SourceTarget = pTarget;
+ CExternalPixelShader Shader;
+ Shader.m_SourceData = pSrcData;
+ Shader.m_SourceTarget = pTarget;
- CComPtr<IDirect3DPixelShader9> pPixelShader;
+ CComPtr<IDirect3DPixelShader9> pPixelShader;
- HRESULT hr = Shader.Compile(m_pPSC);
- if(FAILED(hr))
- return hr;
+ HRESULT hr = Shader.Compile(m_pPSC);
+ if(FAILED(hr))
+ return hr;
- pPixelShaders->AddTail(Shader);
- Paint(true);
- return S_OK;
+ pPixelShaders->AddTail(Shader);
+ Paint(true);
+ return S_OK;
}
CSyncAP::CSyncAP(HWND hWnd, HRESULT& hr, CString &_Error): CBaseAP(hWnd, hr, _Error)
{
- HMODULE hLib;
- AppSettings& s = AfxGetAppSettings();
-
- m_nResetToken = 0;
- m_hRenderThread = INVALID_HANDLE_VALUE;
- m_hMixerThread = INVALID_HANDLE_VALUE;
- m_hEvtFlush = INVALID_HANDLE_VALUE;
- m_hEvtQuit = INVALID_HANDLE_VALUE;
- m_bEvtQuit = 0;
- m_bEvtFlush = 0;
-
- m_bNeedPendingResetDevice = true;
-
- if(FAILED(hr))
- {
- _Error += L"SyncAP failed\n";
- return;
- }
-
- // Load EVR specifics DLLs
- hLib = LoadLibrary(L"dxva2.dll");
- pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress(hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
-
- // Load EVR functions
- hLib = LoadLibrary(L"evr.dll");
- pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer)GetProcAddress(hLib, "MFCreateDXSurfaceBuffer") : NULL;
- pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface)GetProcAddress(hLib, "MFCreateVideoSampleFromSurface") : NULL;
- pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType)GetProcAddress(hLib, "MFCreateVideoMediaType") : NULL;
-
- if(!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType)
- {
- if(!pfDXVA2CreateDirect3DDeviceManager9)
- _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
- if(!pfMFCreateDXSurfaceBuffer)
- _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
- if(!pfMFCreateVideoSampleFromSurface)
- _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
- if(!pfMFCreateVideoMediaType)
- _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
- hr = E_FAIL;
- return;
- }
-
- // Load Vista specific DLLs
- hLib = LoadLibrary(L"avrt.dll");
- pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress(hLib, "AvSetMmThreadCharacteristicsW") : NULL;
- pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress(hLib, "AvSetMmThreadPriority") : NULL;
- pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress(hLib, "AvRevertMmThreadCharacteristics") : NULL;
-
- // Init DXVA manager
- hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
- if(SUCCEEDED(hr))
- {
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if(!SUCCEEDED(hr))
- {
- _Error += L"m_pD3DManager->ResetDevice failed\n";
- }
- }
- else
- _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
-
- CComPtr<IDirectXVideoDecoderService> pDecoderService;
- HANDLE hDevice;
- if(SUCCEEDED(m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
- SUCCEEDED(m_pD3DManager->GetVideoService(hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService)))
- {
- HookDirectXVideoDecoderService(pDecoderService);
- m_pD3DManager->CloseDeviceHandle(hDevice);
- }
-
- // Bufferize frame only with 3D texture
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- m_nDXSurface = max(min(s.iEvrBuffers, MAX_PICTURE_SLOTS - 2), 4);
- else
- m_nDXSurface = 1;
-
- m_nRenderState = Shutdown;
- m_bStepping = false;
- m_bUseInternalTimer = false;
- m_LastSetOutputRange = -1;
- m_bPendingRenegotiate = false;
- m_bPendingMediaFinished = false;
- m_pCurrentDisplaydSample = NULL;
- m_nStepCount = 0;
- m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
- m_BorderColor = RGB(0, 0, 0);
- m_pOuterEVR = NULL;
- m_bPrerolled = false;
- m_lShiftToNearest = -1; // Illegal value to start with
+ HMODULE hLib;
+ AppSettings& s = AfxGetAppSettings();
+
+ m_nResetToken = 0;
+ m_hRenderThread = INVALID_HANDLE_VALUE;
+ m_hMixerThread= INVALID_HANDLE_VALUE;
+ m_hEvtFlush = INVALID_HANDLE_VALUE;
+ m_hEvtQuit = INVALID_HANDLE_VALUE;
+ m_bEvtQuit = 0;
+ m_bEvtFlush = 0;
+
+ m_bNeedPendingResetDevice = true;
+
+ if (FAILED (hr))
+ {
+ _Error += L"SyncAP failed\n";
+ return;
+ }
+
+ // Load EVR specifics DLLs
+ hLib = LoadLibrary (L"dxva2.dll");
+ pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress (hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
+
+ // Load EVR functions
+ hLib = LoadLibrary (L"evr.dll");
+ pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer)GetProcAddress (hLib, "MFCreateDXSurfaceBuffer") : NULL;
+ pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface)GetProcAddress (hLib, "MFCreateVideoSampleFromSurface") : NULL;
+ pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType)GetProcAddress (hLib, "MFCreateVideoMediaType") : NULL;
+
+ if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType)
+ {
+ if (!pfDXVA2CreateDirect3DDeviceManager9)
+ _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
+ if (!pfMFCreateDXSurfaceBuffer)
+ _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
+ if (!pfMFCreateVideoSampleFromSurface)
+ _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
+ if (!pfMFCreateVideoMediaType)
+ _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ hr = E_FAIL;
+ return;
+ }
+
+ // Load Vista specific DLLs
+ hLib = LoadLibrary (L"avrt.dll");
+ pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW") : NULL;
+ pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress (hLib, "AvSetMmThreadPriority") : NULL;
+ pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress (hLib, "AvRevertMmThreadCharacteristics") : NULL;
+
+ // Init DXVA manager
+ hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
+ if (SUCCEEDED (hr))
+ {
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (!SUCCEEDED (hr))
+ {
+ _Error += L"m_pD3DManager->ResetDevice failed\n";
+ }
+ }
+ else
+ _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
+
+ CComPtr<IDirectXVideoDecoderService> pDecoderService;
+ HANDLE hDevice;
+ if (SUCCEEDED (m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
+ SUCCEEDED (m_pD3DManager->GetVideoService (hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService)))
+ {
+ HookDirectXVideoDecoderService (pDecoderService);
+ m_pD3DManager->CloseDeviceHandle (hDevice);
+ }
+
+ // Bufferize frame only with 3D texture
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ m_nDXSurface = max(min (s.iEvrBuffers, MAX_PICTURE_SLOTS-2), 4);
+ else
+ m_nDXSurface = 1;
+
+ m_nRenderState = Shutdown;
+ m_bStepping = false;
+ m_bUseInternalTimer = false;
+ m_LastSetOutputRange = -1;
+ m_bPendingRenegotiate = false;
+ m_bPendingMediaFinished = false;
+ m_pCurrentDisplaydSample = NULL;
+ m_nStepCount = 0;
+ m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
+ m_BorderColor = RGB (0,0,0);
+ m_pOuterEVR = NULL;
+ m_bPrerolled = false;
+ m_lShiftToNearest = -1; // Illegal value to start with
}
CSyncAP::~CSyncAP(void)
{
- StopWorkerThreads();
- m_pMediaType = NULL;
- m_pClock = NULL;
- m_pD3DManager = NULL;
+ StopWorkerThreads();
+ m_pMediaType = NULL;
+ m_pClock = NULL;
+ m_pD3DManager = NULL;
}
-HRESULT CSyncAP::CheckShutdown() const
+HRESULT CSyncAP::CheckShutdown() const
{
- if(m_nRenderState == Shutdown) return MF_E_SHUTDOWN;
- else return S_OK;
+ if (m_nRenderState == Shutdown) return MF_E_SHUTDOWN;
+ else return S_OK;
}
void CSyncAP::StartWorkerThreads()
{
- DWORD dwThreadId;
- if(m_nRenderState == Shutdown)
- {
- m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hEvtFlush = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hEvtSkip = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hMixerThread = ::CreateThread(NULL, 0, MixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hMixerThread, THREAD_PRIORITY_HIGHEST);
- m_hRenderThread = ::CreateThread(NULL, 0, RenderThreadStatic, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hRenderThread, THREAD_PRIORITY_TIME_CRITICAL);
- m_nRenderState = Stopped;
- }
+ DWORD dwThreadId;
+ if (m_nRenderState == Shutdown)
+ {
+ m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hEvtFlush = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hEvtSkip = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hMixerThread = ::CreateThread(NULL, 0, MixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hMixerThread, THREAD_PRIORITY_HIGHEST);
+ m_hRenderThread = ::CreateThread(NULL, 0, RenderThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hRenderThread, THREAD_PRIORITY_TIME_CRITICAL);
+ m_nRenderState = Stopped;
+ }
}
void CSyncAP::StopWorkerThreads()
{
- if(m_nRenderState != Shutdown)
- {
- SetEvent(m_hEvtFlush);
- m_bEvtFlush = true;
- SetEvent(m_hEvtQuit);
- m_bEvtQuit = true;
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- if((m_hRenderThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hRenderThread, 10000) == WAIT_TIMEOUT))
- {
- ASSERT(FALSE);
- TerminateThread(m_hRenderThread, 0xDEAD);
- }
- if(m_hRenderThread != INVALID_HANDLE_VALUE) CloseHandle(m_hRenderThread);
- if((m_hMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hMixerThread, 10000) == WAIT_TIMEOUT))
- {
- ASSERT(FALSE);
- TerminateThread(m_hMixerThread, 0xDEAD);
- }
- if(m_hMixerThread != INVALID_HANDLE_VALUE) CloseHandle(m_hMixerThread);
-
- if(m_hEvtFlush != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtFlush);
- if(m_hEvtQuit != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtQuit);
- if(m_hEvtSkip != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtSkip);
-
- m_bEvtFlush = false;
- m_bEvtQuit = false;
- m_bEvtSkip = false;
- }
- m_nRenderState = Shutdown;
+ if (m_nRenderState != Shutdown)
+ {
+ SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
+ SetEvent(m_hEvtQuit);
+ m_bEvtQuit = true;
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ if ((m_hRenderThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hRenderThread, 10000) == WAIT_TIMEOUT))
+ {
+ ASSERT (FALSE);
+ TerminateThread (m_hRenderThread, 0xDEAD);
+ }
+ if (m_hRenderThread != INVALID_HANDLE_VALUE) CloseHandle (m_hRenderThread);
+ if ((m_hMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hMixerThread, 10000) == WAIT_TIMEOUT))
+ {
+ ASSERT (FALSE);
+ TerminateThread (m_hMixerThread, 0xDEAD);
+ }
+ if (m_hMixerThread != INVALID_HANDLE_VALUE) CloseHandle (m_hMixerThread);
+
+ if (m_hEvtFlush != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtFlush);
+ if (m_hEvtQuit != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtQuit);
+ if (m_hEvtSkip != INVALID_HANDLE_VALUE) CloseHandle(m_hEvtSkip);
+
+ m_bEvtFlush = false;
+ m_bEvtQuit = false;
+ m_bEvtSkip = false;
+ }
+ m_nRenderState = Shutdown;
}
STDMETHODIMP CSyncAP::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
- HRESULT hr = E_FAIL;
+ CheckPointer(ppRenderer, E_POINTER);
+ *ppRenderer = NULL;
+ HRESULT hr = E_FAIL;
- do
- {
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ do
+ {
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- CSyncRenderer *pOuterEVR = DNew CSyncRenderer(NAME("CSyncRenderer"), pUnk, hr, &m_VMR9AlphaBitmap, this);
- m_pOuterEVR = pOuterEVR;
+ CSyncRenderer *pOuterEVR = DNew CSyncRenderer(NAME("CSyncRenderer"), pUnk, hr, &m_VMR9AlphaBitmap, this);
+ m_pOuterEVR = pOuterEVR;
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
- CComQIPtr<IBaseFilter> pBF = pUnk;
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
+ CComQIPtr<IBaseFilter> pBF = pUnk;
- if(FAILED(hr)) break;
+ if (FAILED(hr)) break;
- // Set EVR custom presenter
- CComPtr<IMFVideoPresenter> pVP;
- CComPtr<IMFVideoRenderer> pMFVR;
- CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
+ // Set EVR custom presenter
+ CComPtr<IMFVideoPresenter> pVP;
+ CComPtr<IMFVideoRenderer> pMFVR;
+ CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
- hr = pMFGS->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
+ hr = pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
- if(SUCCEEDED(hr)) hr = QueryInterface(__uuidof(IMFVideoPresenter), (void**)&pVP);
- if(SUCCEEDED(hr)) hr = pMFVR->InitializeRenderer(NULL, pVP);
+ if(SUCCEEDED(hr)) hr = QueryInterface(__uuidof(IMFVideoPresenter), (void**)&pVP);
+ if(SUCCEEDED(hr)) hr = pMFVR->InitializeRenderer(NULL, pVP);
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- m_bUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if(FAILED(hr))
- *ppRenderer = NULL;
- else
- *ppRenderer = pBF.Detach();
- }
- while(0);
+ m_bUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ if(FAILED(hr))
+ *ppRenderer = NULL;
+ else
+ *ppRenderer = pBF.Detach();
+ } while (0);
- return hr;
+ return hr;
}
STDMETHODIMP_(bool) CSyncAP::Paint(bool fAll)
{
- return __super::Paint(fAll);
+ return __super::Paint(fAll);
}
STDMETHODIMP CSyncAP::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- HRESULT hr;
- if(riid == __uuidof(IMFClockStateSink))
- hr = GetInterface((IMFClockStateSink*)this, ppv);
- else if(riid == __uuidof(IMFVideoPresenter))
- hr = GetInterface((IMFVideoPresenter*)this, ppv);
- else if(riid == __uuidof(IMFTopologyServiceLookupClient))
- hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- else if(riid == __uuidof(IMFVideoDeviceID))
- hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- else if(riid == __uuidof(IMFGetService))
- hr = GetInterface((IMFGetService*)this, ppv);
- else if(riid == __uuidof(IMFAsyncCallback))
- hr = GetInterface((IMFAsyncCallback*)this, ppv);
- else if(riid == __uuidof(IMFVideoDisplayControl))
- hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- else if(riid == __uuidof(IEVRTrustedVideoPlugin))
- hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- else if(riid == IID_IQualProp)
- hr = GetInterface((IQualProp*)this, ppv);
- else if(riid == __uuidof(IMFRateSupport))
- hr = GetInterface((IMFRateSupport*)this, ppv);
- else if(riid == __uuidof(IDirect3DDeviceManager9))
- hr = m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppv);
- else
- hr = __super::NonDelegatingQueryInterface(riid, ppv);
-
- return hr;
+ HRESULT hr;
+ if(riid == __uuidof(IMFClockStateSink))
+ hr = GetInterface((IMFClockStateSink*)this, ppv);
+ else if(riid == __uuidof(IMFVideoPresenter))
+ hr = GetInterface((IMFVideoPresenter*)this, ppv);
+ else if(riid == __uuidof(IMFTopologyServiceLookupClient))
+ hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
+ else if(riid == __uuidof(IMFVideoDeviceID))
+ hr = GetInterface((IMFVideoDeviceID*)this, ppv);
+ else if(riid == __uuidof(IMFGetService))
+ hr = GetInterface((IMFGetService*)this, ppv);
+ else if(riid == __uuidof(IMFAsyncCallback))
+ hr = GetInterface((IMFAsyncCallback*)this, ppv);
+ else if(riid == __uuidof(IMFVideoDisplayControl))
+ hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
+ else if(riid == __uuidof(IEVRTrustedVideoPlugin))
+ hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
+ else if(riid == IID_IQualProp)
+ hr = GetInterface((IQualProp*)this, ppv);
+ else if(riid == __uuidof(IMFRateSupport))
+ hr = GetInterface((IMFRateSupport*)this, ppv);
+ else if(riid == __uuidof(IDirect3DDeviceManager9))
+ hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
+ else
+ hr = __super::NonDelegatingQueryInterface(riid, ppv);
+
+ return hr;
}
// IMFClockStateSink
STDMETHODIMP CSyncAP::OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset)
{
- m_nRenderState = Started;
- return S_OK;
+ m_nRenderState = Started;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockStop(MFTIME hnsSystemTime)
{
- m_nRenderState = Stopped;
- return S_OK;
+ m_nRenderState = Stopped;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockPause(MFTIME hnsSystemTime)
{
- m_nRenderState = Paused;
- return S_OK;
+ m_nRenderState = Paused;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockRestart(MFTIME hnsSystemTime)
{
- m_nRenderState = Started;
- return S_OK;
+ m_nRenderState = Started;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockSetRate(MFTIME hnsSystemTime, float flRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IBaseFilter delegate
bool CSyncAP::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue)
{
- CAutoLock lock(&m_SampleQueueLock);
- switch(m_nRenderState)
- {
- case Started:
- *State = State_Running;
- break;
- case Paused:
- *State = State_Paused;
- break;
- case Stopped:
- *State = State_Stopped;
- break;
- default:
- *State = State_Stopped;
- _ReturnValue = E_FAIL;
- }
- _ReturnValue = S_OK;
- return true;
+ CAutoLock lock(&m_SampleQueueLock);
+ switch(m_nRenderState)
+ {
+ case Started: *State = State_Running; break;
+ case Paused: *State = State_Paused; break;
+ case Stopped: *State = State_Stopped; break;
+ default: *State = State_Stopped; _ReturnValue = E_FAIL;
+ }
+ _ReturnValue = S_OK;
+ return true;
}
// IQualProp
STDMETHODIMP CSyncAP::get_FramesDroppedInRenderer(int *pcFrames)
{
- *pcFrames = m_pcFramesDropped;
- return S_OK;
+ *pcFrames = m_pcFramesDropped;
+ return S_OK;
}
STDMETHODIMP CSyncAP::get_FramesDrawn(int *pcFramesDrawn)
{
- *pcFramesDrawn = m_pcFramesDrawn;
- return S_OK;
+ *pcFramesDrawn = m_pcFramesDrawn;
+ return S_OK;
}
STDMETHODIMP CSyncAP::get_AvgFrameRate(int *piAvgFrameRate)
{
- *piAvgFrameRate = (int)(m_fAvrFps * 100);
- return S_OK;
+ *piAvgFrameRate = (int)(m_fAvrFps * 100);
+ return S_OK;
}
STDMETHODIMP CSyncAP::get_Jitter(int *iJitter)
{
- *iJitter = (int)((m_fJitterStdDev / 10000.0) + 0.5);
- return S_OK;
+ *iJitter = (int)((m_fJitterStdDev/10000.0) + 0.5);
+ return S_OK;
}
STDMETHODIMP CSyncAP::get_AvgSyncOffset(int *piAvg)
{
- *piAvg = (int)((m_fSyncOffsetAvr / 10000.0) + 0.5);
- return S_OK;
+ *piAvg = (int)((m_fSyncOffsetAvr/10000.0) + 0.5);
+ return S_OK;
}
STDMETHODIMP CSyncAP::get_DevSyncOffset(int *piDev)
{
- *piDev = (int)((m_fSyncOffsetStdDev / 10000.0) + 0.5);
- return S_OK;
+ *piDev = (int)((m_fSyncOffsetStdDev/10000.0) + 0.5);
+ return S_OK;
}
// IMFRateSupport
STDMETHODIMP CSyncAP::GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
{
- *pflRate = 0;
- return S_OK;
+ *pflRate = 0;
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
{
- HRESULT hr = S_OK;
- float fMaxRate = 0.0f;
+ HRESULT hr = S_OK;
+ float fMaxRate = 0.0f;
- CAutoLock lock(this);
+ CAutoLock lock(this);
- CheckPointer(pflRate, E_POINTER);
- CheckHR(CheckShutdown());
+ CheckPointer(pflRate, E_POINTER);
+ CheckHR(CheckShutdown());
- // Get the maximum forward rate.
- fMaxRate = GetMaxRate(fThin);
+ // Get the maximum forward rate.
+ fMaxRate = GetMaxRate(fThin);
- // For reverse playback, swap the sign.
- if(eDirection == MFRATE_REVERSE)
- fMaxRate = -fMaxRate;
+ // For reverse playback, swap the sign.
+ if (eDirection == MFRATE_REVERSE)
+ fMaxRate = -fMaxRate;
- *pflRate = fMaxRate;
- return hr;
+ *pflRate = fMaxRate;
+ return hr;
}
STDMETHODIMP CSyncAP::IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate)
{
- // fRate can be negative for reverse playback.
- // pfNearestSupportedRate can be NULL.
- CAutoLock lock(this);
- HRESULT hr = S_OK;
- float fMaxRate = 0.0f;
- float fNearestRate = flRate; // Default.
-
- CheckPointer(pflNearestSupportedRate, E_POINTER);
- CheckHR(hr = CheckShutdown());
-
- // Find the maximum forward rate.
- fMaxRate = GetMaxRate(fThin);
-
- if(fabsf(flRate) > fMaxRate)
- {
- // The (absolute) requested rate exceeds the maximum rate.
- hr = MF_E_UNSUPPORTED_RATE;
-
- // The nearest supported rate is fMaxRate.
- fNearestRate = fMaxRate;
- if(flRate < 0)
- {
- // For reverse playback, swap the sign.
- fNearestRate = -fNearestRate;
- }
- }
- // Return the nearest supported rate if the caller requested it.
- if(pflNearestSupportedRate != NULL) *pflNearestSupportedRate = fNearestRate;
- return hr;
+ // fRate can be negative for reverse playback.
+ // pfNearestSupportedRate can be NULL.
+ CAutoLock lock(this);
+ HRESULT hr = S_OK;
+ float fMaxRate = 0.0f;
+ float fNearestRate = flRate; // Default.
+
+ CheckPointer (pflNearestSupportedRate, E_POINTER);
+ CheckHR(hr = CheckShutdown());
+
+ // Find the maximum forward rate.
+ fMaxRate = GetMaxRate(fThin);
+
+ if (fabsf(flRate) > fMaxRate)
+ {
+ // The (absolute) requested rate exceeds the maximum rate.
+ hr = MF_E_UNSUPPORTED_RATE;
+
+ // The nearest supported rate is fMaxRate.
+ fNearestRate = fMaxRate;
+ if (flRate < 0)
+ {
+ // For reverse playback, swap the sign.
+ fNearestRate = -fNearestRate;
+ }
+ }
+ // Return the nearest supported rate if the caller requested it.
+ if (pflNearestSupportedRate != NULL) *pflNearestSupportedRate = fNearestRate;
+ return hr;
}
float CSyncAP::GetMaxRate(BOOL bThin)
{
- float fMaxRate = FLT_MAX; // Default.
- UINT32 fpsNumerator = 0, fpsDenominator = 0;
- UINT MonitorRateHz = 0;
+ float fMaxRate = FLT_MAX; // Default.
+ UINT32 fpsNumerator = 0, fpsDenominator = 0;
+ UINT MonitorRateHz = 0;
- if(!bThin && (m_pMediaType != NULL))
- {
- // Non-thinned: Use the frame rate and monitor refresh rate.
+ if (!bThin && (m_pMediaType != NULL))
+ {
+ // Non-thinned: Use the frame rate and monitor refresh rate.
- // Frame rate:
- MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
- &fpsNumerator, &fpsDenominator);
+ // Frame rate:
+ MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
+ &fpsNumerator, &fpsDenominator);
- // Monitor refresh rate:
- MonitorRateHz = m_uD3DRefreshRate; // D3DDISPLAYMODE
+ // Monitor refresh rate:
+ MonitorRateHz = m_uD3DRefreshRate; // D3DDISPLAYMODE
- if(fpsDenominator && fpsNumerator && MonitorRateHz)
- {
- // Max Rate = Refresh Rate / Frame Rate
- fMaxRate = (float)MulDiv(MonitorRateHz, fpsDenominator, fpsNumerator);
- }
- }
- return fMaxRate;
+ if (fpsDenominator && fpsNumerator && MonitorRateHz)
+ {
+ // Max Rate = Refresh Rate / Frame Rate
+ fMaxRate = (float)MulDiv(MonitorRateHz, fpsDenominator, fpsNumerator);
+ }
+ }
+ return fMaxRate;
}
void CSyncAP::CompleteFrameStep(bool bCancel)
{
- if(m_nStepCount > 0)
- {
- if(bCancel || (m_nStepCount == 1))
- {
- m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
- m_nStepCount = 0;
- }
- else
- m_nStepCount--;
- }
+ if (m_nStepCount > 0)
+ {
+ if (bCancel || (m_nStepCount == 1))
+ {
+ m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
+ m_nStepCount = 0;
+ }
+ else
+ m_nStepCount--;
+ }
}
// IMFVideoPresenter
STDMETHODIMP CSyncAP::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam)
{
- HRESULT hr = S_OK;
- AppSettings& s = AfxGetAppSettings();
-
- switch(eMessage)
- {
- case MFVP_MESSAGE_BEGINSTREAMING:
- hr = BeginStreaming();
- m_llHysteresis = 0;
- m_lShiftToNearest = 0;
- m_bStepping = false;
- break;
-
- case MFVP_MESSAGE_CANCELSTEP:
- m_bStepping = false;
- CompleteFrameStep(true);
- break;
-
- case MFVP_MESSAGE_ENDOFSTREAM:
- m_bPendingMediaFinished = true;
- break;
-
- case MFVP_MESSAGE_ENDSTREAMING:
- {
- m_pGenlock->ResetTiming();
- m_pRefClock = NULL;
- }
- break;
-
- case MFVP_MESSAGE_FLUSH:
- SetEvent(m_hEvtFlush);
- m_bEvtFlush = true;
- while(WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0);
- break;
-
- case MFVP_MESSAGE_INVALIDATEMEDIATYPE:
- m_bPendingRenegotiate = true;
- while(*((volatile bool *)&m_bPendingRenegotiate)) Sleep(1);
- break;
-
- case MFVP_MESSAGE_PROCESSINPUTNOTIFY:
- break;
-
- case MFVP_MESSAGE_STEP:
- m_nStepCount = ulParam;
- m_bStepping = true;
- break;
-
- default :
- ASSERT(FALSE);
- break;
- }
- return hr;
+ HRESULT hr = S_OK;
+ AppSettings& s = AfxGetAppSettings();
+
+ switch (eMessage)
+ {
+ case MFVP_MESSAGE_BEGINSTREAMING:
+ hr = BeginStreaming();
+ m_llHysteresis = 0;
+ m_lShiftToNearest = 0;
+ m_bStepping = false;
+ break;
+
+ case MFVP_MESSAGE_CANCELSTEP:
+ m_bStepping = false;
+ CompleteFrameStep(true);
+ break;
+
+ case MFVP_MESSAGE_ENDOFSTREAM:
+ m_bPendingMediaFinished = true;
+ break;
+
+ case MFVP_MESSAGE_ENDSTREAMING:
+ {
+ m_pGenlock->ResetTiming();
+ m_pRefClock = NULL;
+ }
+ break;
+
+ case MFVP_MESSAGE_FLUSH:
+ SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
+ while (WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0);
+ break;
+
+ case MFVP_MESSAGE_INVALIDATEMEDIATYPE:
+ m_bPendingRenegotiate = true;
+ while (*((volatile bool *)&m_bPendingRenegotiate)) Sleep(1);
+ break;
+
+ case MFVP_MESSAGE_PROCESSINPUTNOTIFY:
+ break;
+
+ case MFVP_MESSAGE_STEP:
+ m_nStepCount = ulParam;
+ m_bStepping = true;
+ break;
+
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+ return hr;
}
HRESULT CSyncAP::IsMediaTypeSupported(IMFMediaType* pMixerType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia;
- UINT nInterlaceMode;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia;
+ UINT nInterlaceMode;
- CheckHR(pMixerType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
- CheckHR(pMixerType->GetUINT32(MF_MT_INTERLACE_MODE, &nInterlaceMode));
+ CheckHR (pMixerType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
+ CheckHR (pMixerType->GetUINT32 (MF_MT_INTERLACE_MODE, &nInterlaceMode));
- if((pAMMedia->majortype != MEDIATYPE_Video)) hr = MF_E_INVALIDMEDIATYPE;
- pMixerType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
- return hr;
+ if ( (pAMMedia->majortype != MEDIATYPE_Video)) hr = MF_E_INVALIDMEDIATYPE;
+ pMixerType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
+ return hr;
}
HRESULT CSyncAP::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE *pAMMedia = NULL;
- LARGE_INTEGER i64Size;
- MFVIDEOFORMAT *VideoFormat;
-
- CheckHR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
-
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
- hr = pfMFCreateVideoMediaType(VideoFormat, &m_pMediaType);
-
- m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
- m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
-
- if(SUCCEEDED(hr))
- {
- i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
- i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
- m_pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
- m_pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
- AppSettings& s = AfxGetAppSettings();
-
- if(s.m_RenderSettings.iEVROutputRange == 1)
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- else
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
-
- m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
- i64Size.HighPart = m_AspectRatio.cx;
- i64Size.LowPart = m_AspectRatio.cy;
- m_pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
-
- MFVideoArea Area = GetArea(0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
- m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
- }
-
- m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
- m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
-
- bool bDoneSomething = true;
-
- if(m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1)
- {
- while(bDoneSomething)
- {
- bDoneSomething = false;
- INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
- INT i;
- for(i = 2; i < MinNum + 1; ++i)
- {
- if(m_AspectRatio.cx % i == 0 && m_AspectRatio.cy % i == 0)
- break;
- }
- if(i != MinNum + 1)
- {
- m_AspectRatio.cx = m_AspectRatio.cx / i;
- m_AspectRatio.cy = m_AspectRatio.cy / i;
- bDoneSomething = true;
- }
- }
- }
-
- pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
- m_pMediaType->QueryInterface(__uuidof(IMFMediaType), (void**) pType);
-
- return hr;
+ HRESULT hr;
+ AM_MEDIA_TYPE *pAMMedia = NULL;
+ LARGE_INTEGER i64Size;
+ MFVIDEOFORMAT *VideoFormat;
+
+ CheckHR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
+
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+ hr = pfMFCreateVideoMediaType(VideoFormat, &m_pMediaType);
+
+ m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
+ m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
+
+ if (SUCCEEDED (hr))
+ {
+ i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
+ i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
+ m_pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
+ m_pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.m_RenderSettings.iEVROutputRange == 1)
+ m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
+ else
+ m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+
+ m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
+ i64Size.HighPart = m_AspectRatio.cx;
+ i64Size.LowPart = m_AspectRatio.cy;
+ m_pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
+
+ MFVideoArea Area = GetArea(0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
+ m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+ }
+
+ m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
+ m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
+
+ bool bDoneSomething = true;
+
+ if(m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1)
+ {
+ while (bDoneSomething)
+ {
+ bDoneSomething = false;
+ INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
+ INT i;
+ for (i = 2; i < MinNum+1; ++i)
+ {
+ if (m_AspectRatio.cx%i == 0 && m_AspectRatio.cy%i ==0)
+ break;
+ }
+ if (i != MinNum + 1)
+ {
+ m_AspectRatio.cx = m_AspectRatio.cx / i;
+ m_AspectRatio.cy = m_AspectRatio.cy / i;
+ bDoneSomething = true;
+ }
+ }
+ }
+
+ pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
+ m_pMediaType->QueryInterface(__uuidof(IMFMediaType), (void**) pType);
+
+ return hr;
}
HRESULT CSyncAP::SetMediaType(IMFMediaType* pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = NULL;
- CString strTemp;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ CString strTemp;
- CheckPointer(pType, E_POINTER);
- CheckHR(pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
+ CheckPointer(pType, E_POINTER);
+ CheckHR(pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
- hr = InitializeDevice(pAMMedia);
- if(SUCCEEDED(hr))
- {
- strTemp = GetMediaTypeName(pAMMedia->subtype);
- strTemp.Replace(L"MEDIASUBTYPE_", L"");
- m_strStatsMsg[MSG_MIXEROUT].Format(L"Mixer output: %s", strTemp);
- }
+ hr = InitializeDevice(pAMMedia);
+ if (SUCCEEDED(hr))
+ {
+ strTemp = GetMediaTypeName(pAMMedia->subtype);
+ strTemp.Replace(L"MEDIASUBTYPE_", L"");
+ m_strStatsMsg[MSG_MIXEROUT].Format (L"Mixer output: %s", strTemp);
+ }
- pType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
+ pType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
- return hr;
+ return hr;
}
typedef struct
{
- const int Format;
- const LPCTSTR Description;
+ const int Format;
+ const LPCTSTR Description;
} D3DFORMAT_TYPE;
LONGLONG CSyncAP::GetMediaTypeMerit(IMFMediaType *pMediaType)
{
- AM_MEDIA_TYPE *pAMMedia = NULL;
- MFVIDEOFORMAT *VideoFormat;
-
- HRESULT hr;
- CheckHR(pMediaType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
-
- LONGLONG Merit = 0;
- switch(VideoFormat->surfaceInfo.Format)
- {
- case FCC('NV12'):
- Merit = 90000000;
- break;
- case FCC('YV12'):
- Merit = 80000000;
- break;
- case FCC('YUY2'):
- Merit = 70000000;
- break;
- case FCC('UYVY'):
- Merit = 60000000;
- break;
-
- case D3DFMT_X8R8G8B8: // Never opt for RGB
- case D3DFMT_A8R8G8B8:
- case D3DFMT_R8G8B8:
- case D3DFMT_R5G6B5:
- Merit = 0;
- break;
- default:
- Merit = 1000;
- break;
- }
- pMediaType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
- return Merit;
+ AM_MEDIA_TYPE *pAMMedia = NULL;
+ MFVIDEOFORMAT *VideoFormat;
+
+ HRESULT hr;
+ CheckHR(pMediaType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia));
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+
+ LONGLONG Merit = 0;
+ switch (VideoFormat->surfaceInfo.Format)
+ {
+ case FCC('NV12'): Merit = 90000000; break;
+ case FCC('YV12'): Merit = 80000000; break;
+ case FCC('YUY2'): Merit = 70000000; break;
+ case FCC('UYVY'): Merit = 60000000; break;
+
+ case D3DFMT_X8R8G8B8: // Never opt for RGB
+ case D3DFMT_A8R8G8B8:
+ case D3DFMT_R8G8B8:
+ case D3DFMT_R5G6B5:
+ Merit = 0;
+ break;
+ default: Merit = 1000; break;
+ }
+ pMediaType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
+ return Merit;
}
HRESULT CSyncAP::RenegotiateMediaType()
{
- HRESULT hr = S_OK;
-
- CComPtr<IMFMediaType> pMixerType;
- CComPtr<IMFMediaType> pType;
-
- if(!m_pMixer) return MF_E_INVALIDREQUEST;
-
- CInterfaceArray<IMFMediaType> ValidMixerTypes;
- // Loop through all of the mixer's proposed output types.
- DWORD iTypeIndex = 0;
- while((hr != MF_E_NO_MORE_TYPES))
- {
- pMixerType = NULL;
- pType = NULL;
- m_pMediaType = NULL;
-
- // Step 1. Get the next media type supported by mixer.
- hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
- if(FAILED(hr))
- {
- break;
- }
- // Step 2. Check if we support this media type.
- if(SUCCEEDED(hr))
- hr = IsMediaTypeSupported(pMixerType);
- if(SUCCEEDED(hr))
- hr = CreateProposedOutputType(pMixerType, &pType);
- // Step 4. Check if the mixer will accept this media type.
- if(SUCCEEDED(hr))
- hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
- if(SUCCEEDED(hr))
- {
- LONGLONG Merit = GetMediaTypeMerit(pType);
-
- int nTypes = ValidMixerTypes.GetCount();
- int iInsertPos = 0;
- for(int i = 0; i < nTypes; ++i)
- {
- LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
- if(Merit > ThisMerit)
- {
- iInsertPos = i;
- break;
- }
- else
- iInsertPos = i + 1;
- }
- ValidMixerTypes.InsertAt(iInsertPos, pType);
- }
- }
-
- int nValidTypes = ValidMixerTypes.GetCount();
- for(int i = 0; i < nValidTypes; ++i)
- {
- pType = ValidMixerTypes[i];
- }
-
- for(int i = 0; i < nValidTypes; ++i)
- {
- pType = ValidMixerTypes[i];
- hr = SetMediaType(pType);
- if(SUCCEEDED(hr))
- {
- hr = m_pMixer->SetOutputType(0, pType, 0);
- // If something went wrong, clear the media type.
- if(FAILED(hr))
- {
- SetMediaType(NULL);
- }
- else
- break;
- }
- }
-
- pMixerType = NULL;
- pType = NULL;
- return hr;
+ HRESULT hr = S_OK;
+
+ CComPtr<IMFMediaType> pMixerType;
+ CComPtr<IMFMediaType> pType;
+
+ if (!m_pMixer) return MF_E_INVALIDREQUEST;
+
+ CInterfaceArray<IMFMediaType> ValidMixerTypes;
+ // Loop through all of the mixer's proposed output types.
+ DWORD iTypeIndex = 0;
+ while ((hr != MF_E_NO_MORE_TYPES))
+ {
+ pMixerType = NULL;
+ pType = NULL;
+ m_pMediaType = NULL;
+
+ // Step 1. Get the next media type supported by mixer.
+ hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
+ if (FAILED(hr))
+ {
+ break;
+ }
+ // Step 2. Check if we support this media type.
+ if (SUCCEEDED(hr))
+ hr = IsMediaTypeSupported(pMixerType);
+ if (SUCCEEDED(hr))
+ hr = CreateProposedOutputType(pMixerType, &pType);
+ // Step 4. Check if the mixer will accept this media type.
+ if (SUCCEEDED(hr))
+ hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
+ if (SUCCEEDED(hr))
+ {
+ LONGLONG Merit = GetMediaTypeMerit(pType);
+
+ int nTypes = ValidMixerTypes.GetCount();
+ int iInsertPos = 0;
+ for (int i = 0; i < nTypes; ++i)
+ {
+ LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
+ if (Merit > ThisMerit)
+ {
+ iInsertPos = i;
+ break;
+ }
+ else
+ iInsertPos = i+1;
+ }
+ ValidMixerTypes.InsertAt(iInsertPos, pType);
+ }
+ }
+
+ int nValidTypes = ValidMixerTypes.GetCount();
+ for (int i = 0; i < nValidTypes; ++i)
+ {
+ pType = ValidMixerTypes[i];
+ }
+
+ for (int i = 0; i < nValidTypes; ++i)
+ {
+ pType = ValidMixerTypes[i];
+ hr = SetMediaType(pType);
+ if (SUCCEEDED(hr))
+ {
+ hr = m_pMixer->SetOutputType(0, pType, 0);
+ // If something went wrong, clear the media type.
+ if (FAILED(hr))
+ {
+ SetMediaType(NULL);
+ }
+ else
+ break;
+ }
+ }
+
+ pMixerType = NULL;
+ pType = NULL;
+ return hr;
}
bool CSyncAP::GetSampleFromMixer()
{
- MFT_OUTPUT_DATA_BUFFER Buffer;
- HRESULT hr = S_OK;
- DWORD dwStatus;
- LONGLONG llClockBefore = 0;
- LONGLONG llClockAfter = 0;
- LONGLONG llMixerLatency;
-
- UINT dwSurface;
- bool newSample = false;
-
- while(SUCCEEDED(hr)) // Get as many frames as there are and that we have samples for
- {
- CComPtr<IMFSample> pSample;
- CComPtr<IMFSample> pNewSample;
- if(FAILED(GetFreeSample(&pSample))) // All samples are taken for the moment. Better luck next time
- {
- break;
- }
-
- memset(&Buffer, 0, sizeof(Buffer));
- Buffer.pSample = pSample;
- pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
- {
- llClockBefore = AfxGetMyApp()->GetPerfCounter();
- hr = m_pMixer->ProcessOutput(0 , 1, &Buffer, &dwStatus);
- llClockAfter = AfxGetMyApp()->GetPerfCounter();
- }
-
- if(hr == MF_E_TRANSFORM_NEED_MORE_INPUT) // There are no samples left in the mixer
- {
- MoveToFreeList(pSample, false);
- break;
- }
- if(m_pSink)
- {
- llMixerLatency = llClockAfter - llClockBefore;
- m_pSink->Notify(EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
- }
-
- newSample = true;
-
- if(AfxGetMyApp()->m_fTearingTest)
- {
- RECT rcTearing;
-
- rcTearing.left = m_nTearingPos;
- rcTearing.top = 0;
- rcTearing.right = rcTearing.left + 4;
- rcTearing.bottom = m_NativeVideoSize.cy;
- m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
-
- rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
- rcTearing.right = rcTearing.left + 4;
- m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
- m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
- }
- MoveToScheduledList(pSample, false); // Schedule, then go back to see if there is more where that came from
- }
- return newSample;
+ MFT_OUTPUT_DATA_BUFFER Buffer;
+ HRESULT hr = S_OK;
+ DWORD dwStatus;
+ LONGLONG llClockBefore = 0;
+ LONGLONG llClockAfter = 0;
+ LONGLONG llMixerLatency;
+
+ UINT dwSurface;
+ bool newSample = false;
+
+ while(SUCCEEDED(hr)) // Get as many frames as there are and that we have samples for
+ {
+ CComPtr<IMFSample> pSample;
+ CComPtr<IMFSample> pNewSample;
+ if (FAILED(GetFreeSample(&pSample))) // All samples are taken for the moment. Better luck next time
+ {
+ break;
+ }
+
+ memset(&Buffer, 0, sizeof(Buffer));
+ Buffer.pSample = pSample;
+ pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
+ {
+ llClockBefore = AfxGetMyApp()->GetPerfCounter();
+ hr = m_pMixer->ProcessOutput(0 , 1, &Buffer, &dwStatus);
+ llClockAfter = AfxGetMyApp()->GetPerfCounter();
+ }
+
+ if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) // There are no samples left in the mixer
+ {
+ MoveToFreeList(pSample, false);
+ break;
+ }
+ if (m_pSink)
+ {
+ llMixerLatency = llClockAfter - llClockBefore;
+ m_pSink->Notify (EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
+ }
+
+ newSample = true;
+
+ if (AfxGetMyApp()->m_fTearingTest)
+ {
+ RECT rcTearing;
+
+ rcTearing.left = m_nTearingPos;
+ rcTearing.top = 0;
+ rcTearing.right = rcTearing.left + 4;
+ rcTearing.bottom = m_NativeVideoSize.cy;
+ m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+
+ rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
+ rcTearing.right = rcTearing.left + 4;
+ m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+ m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
+ }
+ MoveToScheduledList(pSample, false); // Schedule, then go back to see if there is more where that came from
+ }
+ return newSample;
}
STDMETHODIMP CSyncAP::GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType)
{
- HRESULT hr = S_OK;
- CAutoLock lock(this);
- CheckPointer(ppMediaType, E_POINTER);
- CheckHR(CheckShutdown());
+ HRESULT hr = S_OK;
+ CAutoLock lock(this);
+ CheckPointer(ppMediaType, E_POINTER);
+ CheckHR(CheckShutdown());
- if(m_pMediaType == NULL)
- CheckHR(MF_E_NOT_INITIALIZED);
+ if (m_pMediaType == NULL)
+ CheckHR(MF_E_NOT_INITIALIZED);
- CheckHR(m_pMediaType->QueryInterface(__uuidof(IMFVideoMediaType), (void**)&ppMediaType));
- return hr;
+ CheckHR(m_pMediaType->QueryInterface(__uuidof(IMFVideoMediaType), (void**)&ppMediaType));
+ return hr;
}
-// IMFTopologyServiceLookupClient
+// IMFTopologyServiceLookupClient
STDMETHODIMP CSyncAP::InitServicePointers(__in IMFTopologyServiceLookup *pLookup)
{
- HRESULT hr;
- DWORD dwObjects = 1;
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE, __uuidof(IMFTransform), (void**)&m_pMixer, &dwObjects);
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof(IMediaEventSink), (void**)&m_pSink, &dwObjects);
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof(IMFClock), (void**)&m_pClock, &dwObjects);
- StartWorkerThreads();
- return S_OK;
+ HRESULT hr;
+ DWORD dwObjects = 1;
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE, __uuidof (IMFTransform), (void**)&m_pMixer, &dwObjects);
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof (IMediaEventSink ), (void**)&m_pSink, &dwObjects);
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof (IMFClock ), (void**)&m_pClock, &dwObjects);
+ StartWorkerThreads();
+ return S_OK;
}
STDMETHODIMP CSyncAP::ReleaseServicePointers()
{
- StopWorkerThreads();
- m_pMixer = NULL;
- m_pSink = NULL;
- m_pClock = NULL;
- return S_OK;
+ StopWorkerThreads();
+ m_pMixer = NULL;
+ m_pSink = NULL;
+ m_pClock = NULL;
+ return S_OK;
}
// IMFVideoDeviceID
-STDMETHODIMP CSyncAP::GetDeviceID(__out IID *pDeviceID)
+STDMETHODIMP CSyncAP::GetDeviceID( __out IID *pDeviceID)
{
- CheckPointer(pDeviceID, E_POINTER);
- *pDeviceID = IID_IDirect3DDevice9;
- return S_OK;
+ CheckPointer(pDeviceID, E_POINTER);
+ *pDeviceID = IID_IDirect3DDevice9;
+ return S_OK;
}
// IMFGetService
-STDMETHODIMP CSyncAP::GetService(__RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID *ppvObject)
+STDMETHODIMP CSyncAP::GetService( __RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID *ppvObject)
{
- if(guidService == MR_VIDEO_RENDER_SERVICE)
- return NonDelegatingQueryInterface(riid, ppvObject);
- else if(guidService == MR_VIDEO_ACCELERATION_SERVICE)
- return m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
+ if (guidService == MR_VIDEO_RENDER_SERVICE)
+ return NonDelegatingQueryInterface (riid, ppvObject);
+ else if (guidService == MR_VIDEO_ACCELERATION_SERVICE)
+ return m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
// IMFAsyncCallback
-STDMETHODIMP CSyncAP::GetParameters(__RPC__out DWORD *pdwFlags, __RPC__out DWORD *pdwQueue)
+STDMETHODIMP CSyncAP::GetParameters( __RPC__out DWORD *pdwFlags, __RPC__out DWORD *pdwQueue)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncAP::Invoke(__RPC__in_opt IMFAsyncResult *pAsyncResult)
+STDMETHODIMP CSyncAP::Invoke( __RPC__in_opt IMFAsyncResult *pAsyncResult)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IMFVideoDisplayControl
STDMETHODIMP CSyncAP::GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
{
- if(pszVideo)
- {
- pszVideo->cx = m_NativeVideoSize.cx;
- pszVideo->cy = m_NativeVideoSize.cy;
- }
- if(pszARVideo)
- {
- pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
- pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
- }
- return S_OK;
+ if (pszVideo)
+ {
+ pszVideo->cx = m_NativeVideoSize.cx;
+ pszVideo->cy = m_NativeVideoSize.cy;
+ }
+ if (pszARVideo)
+ {
+ pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
+ pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
+ }
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax)
{
- if(pszMin)
- {
- pszMin->cx = 1;
- pszMin->cy = 1;
- }
-
- if(pszMax)
- {
- D3DDISPLAYMODE d3ddm;
-
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
- {
- pszMax->cx = d3ddm.Width;
- pszMax->cy = d3ddm.Height;
- }
- }
- return S_OK;
+ if (pszMin)
+ {
+ pszMin->cx = 1;
+ pszMin->cy = 1;
+ }
+
+ if (pszMax)
+ {
+ D3DDISPLAYMODE d3ddm;
+
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
+ {
+ pszMax->cx = d3ddm.Width;
+ pszMax->cy = d3ddm.Height;
+ }
+ }
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest)
{
- if(pnrcSource)
- {
- pnrcSource->left = 0.0;
- pnrcSource->top = 0.0;
- pnrcSource->right = 1.0;
- pnrcSource->bottom = 1.0;
- }
- if(prcDest)
- memcpy(prcDest, &m_VideoRect, sizeof(m_VideoRect)); //GetClientRect (m_hWnd, prcDest);
- return S_OK;
+ if (pnrcSource)
+ {
+ pnrcSource->left = 0.0;
+ pnrcSource->top = 0.0;
+ pnrcSource->right = 1.0;
+ pnrcSource->bottom = 1.0;
+ }
+ if (prcDest)
+ memcpy (prcDest, &m_VideoRect, sizeof(m_VideoRect));//GetClientRect (m_hWnd, prcDest);
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetAspectRatioMode(DWORD dwAspectRatioMode)
{
- m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
- return S_OK;
+ m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetAspectRatioMode(DWORD *pdwAspectRatioMode)
{
- CheckPointer(pdwAspectRatioMode, E_POINTER);
- *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
- return S_OK;
+ CheckPointer (pdwAspectRatioMode, E_POINTER);
+ *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetVideoWindow(HWND hwndVideo)
{
- ASSERT(m_hWnd == hwndVideo);
- return S_OK;
+ ASSERT (m_hWnd == hwndVideo);
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetVideoWindow(HWND *phwndVideo)
{
- CheckPointer(phwndVideo, E_POINTER);
- *phwndVideo = m_hWnd;
- return S_OK;
+ CheckPointer(phwndVideo, E_POINTER);
+ *phwndVideo = m_hWnd;
+ return S_OK;
}
STDMETHODIMP CSyncAP::RepaintVideo()
{
- Paint(true);
- return S_OK;
+ Paint(true);
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp)
{
- ASSERT(FALSE);
- return E_NOTIMPL;
+ ASSERT (FALSE);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncAP::SetBorderColor(COLORREF Clr)
{
- m_BorderColor = Clr;
- return S_OK;
+ m_BorderColor = Clr;
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetBorderColor(COLORREF *pClr)
{
- CheckPointer(pClr, E_POINTER);
- *pClr = m_BorderColor;
- return S_OK;
+ CheckPointer (pClr, E_POINTER);
+ *pClr = m_BorderColor;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetRenderingPrefs(DWORD dwRenderFlags)
{
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
- return S_OK;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
+ return S_OK;
}
STDMETHODIMP CSyncAP::GetRenderingPrefs(DWORD *pdwRenderFlags)
{
- CheckPointer(pdwRenderFlags, E_POINTER);
- *pdwRenderFlags = m_dwVideoRenderPrefs;
- return S_OK;
+ CheckPointer(pdwRenderFlags, E_POINTER);
+ *pdwRenderFlags = m_dwVideoRenderPrefs;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetFullscreen(BOOL fFullscreen)
{
- ASSERT(FALSE);
- return E_NOTIMPL;
+ ASSERT (FALSE);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncAP::GetFullscreen(BOOL *pfFullscreen)
{
- ASSERT(FALSE);
- return E_NOTIMPL;
+ ASSERT (FALSE);
+ return E_NOTIMPL;
}
// IEVRTrustedVideoPlugin
STDMETHODIMP CSyncAP::IsInTrustedVideoMode(BOOL *pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
STDMETHODIMP CSyncAP::CanConstrict(BOOL *pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetConstriction(DWORD dwKPix)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSyncAP::DisableImageExport(BOOL bDisable)
{
- return S_OK;
+ return S_OK;
}
// IDirect3DDeviceManager9
-STDMETHODIMP CSyncAP::ResetDevice(IDirect3DDevice9 *pDevice, UINT resetToken)
+STDMETHODIMP CSyncAP::ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken)
{
- HRESULT hr = m_pD3DManager->ResetDevice(pDevice, resetToken);
- return hr;
+ HRESULT hr = m_pD3DManager->ResetDevice (pDevice, resetToken);
+ return hr;
}
STDMETHODIMP CSyncAP::OpenDeviceHandle(HANDLE *phDevice)
{
- HRESULT hr = m_pD3DManager->OpenDeviceHandle(phDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->OpenDeviceHandle (phDevice);
+ return hr;
}
STDMETHODIMP CSyncAP::CloseDeviceHandle(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
+ return hr;
}
STDMETHODIMP CSyncAP::TestDevice(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->TestDevice(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->TestDevice(hDevice);
+ return hr;
}
STDMETHODIMP CSyncAP::LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock)
{
- HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
- return hr;
+ HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
+ return hr;
}
STDMETHODIMP CSyncAP::UnlockDevice(HANDLE hDevice, BOOL fSaveState)
{
- HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
- return hr;
+ HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
+ return hr;
}
STDMETHODIMP CSyncAP::GetVideoService(HANDLE hDevice, REFIID riid, void **ppService)
{
- HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
+ HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
- if(riid == __uuidof(IDirectXVideoDecoderService))
- {
- UINT nNbDecoder = 5;
- GUID* pDecoderGuid;
- IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) * ppService;
- pDXVAVideoDecoder->GetDecoderDeviceGuids(&nNbDecoder, &pDecoderGuid);
- }
- else if(riid == __uuidof(IDirectXVideoProcessorService))
- {
- IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) * ppService;
- }
+ if (riid == __uuidof(IDirectXVideoDecoderService))
+ {
+ UINT nNbDecoder = 5;
+ GUID* pDecoderGuid;
+ IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
+ pDXVAVideoDecoder->GetDecoderDeviceGuids (&nNbDecoder, &pDecoderGuid);
+ }
+ else if (riid == __uuidof(IDirectXVideoProcessorService))
+ {
+ IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CSyncAP::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- // This function should be called...
- ASSERT(FALSE);
+ // This function should be called...
+ ASSERT (FALSE);
- if(lpWidth) *lpWidth = m_NativeVideoSize.cx;
- if(lpHeight) *lpHeight = m_NativeVideoSize.cy;
- if(lpARWidth) *lpARWidth = m_AspectRatio.cx;
- if(lpARHeight) *lpARHeight = m_AspectRatio.cy;
- return S_OK;
+ if(lpWidth) *lpWidth = m_NativeVideoSize.cx;
+ if(lpHeight) *lpHeight = m_NativeVideoSize.cy;
+ if(lpARWidth) *lpARWidth = m_AspectRatio.cx;
+ if(lpARHeight) *lpARHeight = m_AspectRatio.cy;
+ return S_OK;
}
STDMETHODIMP CSyncAP::InitializeDevice(AM_MEDIA_TYPE* pMediaType)
{
- HRESULT hr;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_allocatorLock);
-
- RemoveAllSamples();
- DeleteSurfaces();
-
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*) pMediaType->pbFormat;
- int w = vih2->bmiHeader.biWidth;
- int h = abs(vih2->bmiHeader.biHeight);
-
- m_NativeVideoSize = CSize(w, h);
- if(m_bHighColorResolution)
- hr = AllocSurfaces(D3DFMT_A2R10G10B10);
- else
- hr = AllocSurfaces(D3DFMT_X8R8G8B8);
-
- for(int i = 0; i < m_nDXSurface; i++)
- {
- CComPtr<IMFSample> pMFSample;
- hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
- if(SUCCEEDED(hr))
- {
- pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail(pMFSample);
- }
- ASSERT(SUCCEEDED(hr));
- }
- return hr;
+ HRESULT hr;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_allocatorLock);
+
+ RemoveAllSamples();
+ DeleteSurfaces();
+
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*) pMediaType->pbFormat;
+ int w = vih2->bmiHeader.biWidth;
+ int h = abs(vih2->bmiHeader.biHeight);
+
+ m_NativeVideoSize = CSize(w, h);
+ if (m_bHighColorResolution)
+ hr = AllocSurfaces(D3DFMT_A2R10G10B10);
+ else
+ hr = AllocSurfaces(D3DFMT_X8R8G8B8);
+
+ for(int i = 0; i < m_nDXSurface; i++)
+ {
+ CComPtr<IMFSample> pMFSample;
+ hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ if (SUCCEEDED (hr))
+ {
+ pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail (pMFSample);
+ }
+ ASSERT (SUCCEEDED (hr));
+ }
+ return hr;
}
DWORD WINAPI CSyncAP::MixerThreadStatic(LPVOID lpParam)
{
- CSyncAP *pThis = (CSyncAP*) lpParam;
- pThis->MixerThread();
- return 0;
+ CSyncAP *pThis = (CSyncAP*) lpParam;
+ pThis->MixerThread();
+ return 0;
}
void CSyncAP::MixerThread()
{
- HANDLE hAvrt;
- HANDLE hEvts[] = {m_hEvtQuit};
- bool bQuit = false;
- TIMECAPS tc;
- DWORD dwResolution;
- DWORD dwUser = 0;
- DWORD dwTaskIndex = 0;
-
- timeGetDevCaps(&tc, sizeof(TIMECAPS));
- dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
- dwUser = timeBeginPeriod(dwResolution);
-
- while(!bQuit)
- {
- DWORD dwObject = WaitForMultipleObjects(countof(hEvts), hEvts, FALSE, 1);
- switch(dwObject)
- {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_TIMEOUT :
- {
- bool bNewSample = false;
- {
- CAutoLock AutoLock(&m_ImageProcessingLock);
- bNewSample = GetSampleFromMixer();
- }
- if(m_bUseInternalTimer && m_pSubPicQueue)
- {
- m_pSubPicQueue->SetFPS(m_fps);
- }
- }
- break;
- }
- }
- timeEndPeriod(dwResolution);
+ HANDLE hAvrt;
+ HANDLE hEvts[] = {m_hEvtQuit};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+ DWORD dwTaskIndex = 0;
+
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+
+ while (!bQuit)
+ {
+ DWORD dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject)
+ {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT :
+ {
+ bool bNewSample = false;
+ {
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ bNewSample = GetSampleFromMixer();
+ }
+ if(m_bUseInternalTimer && m_pSubPicQueue)
+ {
+ m_pSubPicQueue->SetFPS(m_fps);
+ }
+ }
+ break;
+ }
+ }
+ timeEndPeriod (dwResolution);
}
DWORD WINAPI CSyncAP::RenderThreadStatic(LPVOID lpParam)
{
- CSyncAP *pThis = (CSyncAP*)lpParam;
- pThis->RenderThread();
- return 0;
+ CSyncAP *pThis = (CSyncAP*)lpParam;
+ pThis->RenderThread();
+ return 0;
}
// Get samples that have been received and queued up by MixerThread() and present them at the correct time by calling Paint().
void CSyncAP::RenderThread()
{
- HANDLE hAvrt;
- DWORD dwTaskIndex = 0;
- HANDLE hEvts[] = {m_hEvtQuit, m_hEvtFlush, m_hEvtSkip};
- bool bQuit = false;
- TIMECAPS tc;
- DWORD dwResolution;
- LONGLONG llRefClockTime;
- double dTargetSyncOffset;
- MFTIME llSystemTime;
- DWORD dwUser = 0;
- DWORD dwObject;
- int nSamplesLeft;
- CComPtr<IMFSample>pNewSample = NULL; // The sample next in line to be presented
-
- // Tell Vista Multimedia Class Scheduler we are doing threaded playback (increase priority)
- if(pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
- if(pfAvSetMmThreadPriority) pfAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH);
-
- AppSettings& s = AfxGetAppSettings();
-
- // Set timer resolution
- timeGetDevCaps(&tc, sizeof(TIMECAPS));
- dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
- dwUser = timeBeginPeriod(dwResolution);
- pNewSample = NULL;
-
- while(!bQuit)
- {
- m_lNextSampleWait = 1; // Default value for running this loop
- nSamplesLeft = 0;
- bool stepForward = false;
- LONG lDisplayCycle = (LONG)(GetDisplayCycle());
- LONG lDisplayCycle2 = (LONG)(GetDisplayCycle() / 2.0); // These are a couple of empirically determined constants used the control the "snap" function
- LONG lDisplayCycle4 = (LONG)(GetDisplayCycle() / 4.0);
-
- AppSettings& s = AfxGetAppSettings();
- dTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
-
- if((m_nRenderState == Started || !m_bPrerolled) && !pNewSample) // If either streaming or the pre-roll sample and no sample yet fetched
- {
- if(SUCCEEDED(GetScheduledSample(&pNewSample, nSamplesLeft))) // Get the next sample
- {
- m_llLastSampleTime = m_llSampleTime;
- if(!m_bPrerolled)
- {
- m_bPrerolled = true; // m_bPrerolled is a ticket to show one (1) frame immediately
- m_lNextSampleWait = 0; // Present immediately
- }
- else if(SUCCEEDED(pNewSample->GetSampleTime(&m_llSampleTime))) // Get zero-based sample due time
- {
- if(m_llLastSampleTime == m_llSampleTime) // In the rare case there are duplicate frames in the movie. There really shouldn't be but it happens.
- {
- MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- m_lNextSampleWait = 0;
- }
- else
- {
- m_pClock->GetCorrelatedTime(0, &llRefClockTime, &llSystemTime); // Get zero-based reference clock time. llSystemTime is not used for anything here
- m_lNextSampleWait = (LONG)((m_llSampleTime - llRefClockTime) / 10000); // Time left until sample is due, in ms
- if(m_bStepping)
- {
- m_lNextSampleWait = 0;
- }
- else if(s.m_RenderSettings.bSynchronizeNearest) // Present at the closest "safe" occasion at dTargetSyncOffset ms before vsync to avoid tearing
- {
- if(m_lNextSampleWait < -lDisplayCycle) // We have to allow slightly negative numbers at this stage. Otherwise we get "choking" when frame rate > refresh rate
- {
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- }
- REFERENCE_TIME rtRefClockTimeNow;
- if(m_pRefClock) m_pRefClock->GetTime(&rtRefClockTimeNow); // Reference clock time now
- LONG lLastVsyncTime = (LONG)((m_llEstVBlankTime - rtRefClockTimeNow) / 10000); // Last vsync time relative to now
- if(abs(lLastVsyncTime) > lDisplayCycle) lLastVsyncTime = - lDisplayCycle; // To even out glitches in the beginning
-
- LONGLONG llNextSampleWait = (LONGLONG)(((double)lLastVsyncTime + GetDisplayCycle() - dTargetSyncOffset) * 10000); // Time from now util next safe time to Paint()
- while((llRefClockTime + llNextSampleWait) < (m_llSampleTime + m_llHysteresis)) // While the proposed time is in the past of sample presentation time
- {
- llNextSampleWait = llNextSampleWait + (LONGLONG)(GetDisplayCycle() * 10000); // Try the next possible time, one display cycle ahead
- }
- m_lNextSampleWait = (LONG)(llNextSampleWait / 10000);
- m_lShiftToNearestPrev = m_lShiftToNearest;
- m_lShiftToNearest = (LONG)((llRefClockTime + llNextSampleWait - m_llSampleTime) / 10000); // The adjustment made to get to the sweet point in time, in ms
-
- // If m_lShiftToNearest is pushed a whole cycle into the future, then we are getting more frames
- // than we can chew and we need to throw one away. We don't want to wait many cycles and skip many
- // frames.
- if(m_lShiftToNearest > (lDisplayCycle + 1))
- {
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- }
-
- // We need to add a hysteresis to the control of the timing adjustment to avoid judder when
- // presentation time is close to vsync and the renderer couldn't otherwise make up its mind
- // whether to present before the vsync or after. That kind of indecisiveness leads to judder.
- if(m_bSnapToVSync)
- {
-
- if((m_lShiftToNearestPrev - m_lShiftToNearest) > lDisplayCycle2) // If a step down in the m_lShiftToNearest function. Display slower than video.
- {
- m_bVideoSlowerThanDisplay = false;
- m_llHysteresis = -(LONGLONG)(10000 * lDisplayCycle4);
- }
- else if((m_lShiftToNearest - m_lShiftToNearestPrev) > lDisplayCycle2) // If a step up
- {
- m_bVideoSlowerThanDisplay = true;
- m_llHysteresis = (LONGLONG)(10000 * lDisplayCycle4);
- }
- else if((m_lShiftToNearest < (3 * lDisplayCycle4)) && (m_lShiftToNearest > lDisplayCycle4))
- m_llHysteresis = 0; // Reset when between 1/4 and 3/4 of the way either way
-
- if((m_lShiftToNearest < lDisplayCycle2) && (m_llHysteresis > 0)) m_llHysteresis = 0; // Should never really be in this territory.
- if(m_lShiftToNearest < 0) m_llHysteresis = 0; // A glitch might get us to a sticky state where both these numbers are negative.
- if((m_lShiftToNearest > lDisplayCycle2) && (m_llHysteresis < 0)) m_llHysteresis = 0;
- }
- }
-
- if(m_lNextSampleWait < 0) // Skip late or duplicate sample.
- {
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- }
-
- if(m_lNextSampleWait > 1000)
- {
- m_lNextSampleWait = 1000; // So as to avoid full a full stop when sample is far in the future (shouldn't really happen).
- }
- }
- } // if got new sample
- }
- }
- // Wait for the next presentation time (m_lNextSampleWait) or some other event.
- dwObject = WaitForMultipleObjects(countof(hEvts), hEvts, FALSE, (DWORD)m_lNextSampleWait);
- switch(dwObject)
- {
- case WAIT_OBJECT_0: // Quit
- bQuit = true;
- break;
-
- case WAIT_OBJECT_0 + 1: // Flush
- if(pNewSample) MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- FlushSamples();
- m_bEvtFlush = false;
- ResetEvent(m_hEvtFlush);
- m_bPrerolled = false;
- m_lShiftToNearest = 0;
- stepForward = true;
- break;
-
- case WAIT_OBJECT_0 + 2: // Skip sample
- m_pcFramesDropped++;
- m_llSampleTime = m_llLastSampleTime; // This sample will never be shown
- m_bEvtSkip = false;
- ResetEvent(m_hEvtSkip);
- stepForward = true;
- break;
-
- case WAIT_TIMEOUT: // Time to show the sample or something
- if(m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate)
- {
- if(pNewSample) MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- FlushSamples();
- RenegotiateMediaType();
- m_bPendingRenegotiate = false;
- }
-
- if(m_bPendingResetDevice)
- {
- m_bPendingResetDevice = false;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_allocatorLock);
- if(pNewSample) MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- RemoveAllSamples();
- CBaseAP::ResetDevice();
-
- for(int i = 0; i < m_nDXSurface; i++)
- {
- CComPtr<IMFSample> pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
- if(SUCCEEDED(hr))
- {
- pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail(pMFSample);
- }
- ASSERT(SUCCEEDED(hr));
- }
- }
- else if(m_nStepCount < 0)
- {
- m_nStepCount = 0;
- m_pcFramesDropped++;
- stepForward = true;
- }
- else if(pNewSample && (m_nStepCount > 0))
- {
- pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- if(!g_bExternalSubtitleTime) __super::SetTime(g_tSegmentStart + m_llSampleTime);
- Paint(true);
- CompleteFrameStep(false);
- m_pcFramesDrawn++;
- stepForward = true;
- }
- else if(pNewSample && !m_bStepping) // When a stepped frame is shown, a new one is fetched that we don't want to show here while stepping
- {
- pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
- if(!g_bExternalSubtitleTime) __super::SetTime(g_tSegmentStart + m_llSampleTime);
- Paint(true);
- m_pcFramesDrawn++;
- stepForward = true;
- }
- break;
- } // switch
- if(pNewSample && stepForward)
- {
- MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- }
- } // while
- if(pNewSample)
- {
- MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- }
- timeEndPeriod(dwResolution);
- if(pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics(hAvrt);
+ HANDLE hAvrt;
+ DWORD dwTaskIndex = 0;
+ HANDLE hEvts[] = {m_hEvtQuit, m_hEvtFlush, m_hEvtSkip};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ LONGLONG llRefClockTime;
+ double dTargetSyncOffset;
+ MFTIME llSystemTime;
+ DWORD dwUser = 0;
+ DWORD dwObject;
+ int nSamplesLeft;
+ CComPtr<IMFSample>pNewSample = NULL; // The sample next in line to be presented
+
+ // Tell Vista Multimedia Class Scheduler we are doing threaded playback (increase priority)
+ if (pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+ if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ // Set timer resolution
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+ pNewSample = NULL;
+
+ while (!bQuit)
+ {
+ m_lNextSampleWait = 1; // Default value for running this loop
+ nSamplesLeft = 0;
+ bool stepForward = false;
+ LONG lDisplayCycle = (LONG)(GetDisplayCycle());
+ LONG lDisplayCycle2 = (LONG)(GetDisplayCycle() / 2.0); // These are a couple of empirically determined constants used the control the "snap" function
+ LONG lDisplayCycle4 = (LONG)(GetDisplayCycle() / 4.0);
+
+ AppSettings& s = AfxGetAppSettings();
+ dTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+
+ if ((m_nRenderState == Started || !m_bPrerolled) && !pNewSample) // If either streaming or the pre-roll sample and no sample yet fetched
+ {
+ if (SUCCEEDED(GetScheduledSample(&pNewSample, nSamplesLeft))) // Get the next sample
+ {
+ m_llLastSampleTime = m_llSampleTime;
+ if (!m_bPrerolled)
+ {
+ m_bPrerolled = true; // m_bPrerolled is a ticket to show one (1) frame immediately
+ m_lNextSampleWait = 0; // Present immediately
+ }
+ else if (SUCCEEDED(pNewSample->GetSampleTime(&m_llSampleTime))) // Get zero-based sample due time
+ {
+ if (m_llLastSampleTime == m_llSampleTime) // In the rare case there are duplicate frames in the movie. There really shouldn't be but it happens.
+ {
+ MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ m_lNextSampleWait = 0;
+ }
+ else
+ {
+ m_pClock->GetCorrelatedTime(0, &llRefClockTime, &llSystemTime); // Get zero-based reference clock time. llSystemTime is not used for anything here
+ m_lNextSampleWait = (LONG)((m_llSampleTime - llRefClockTime) / 10000); // Time left until sample is due, in ms
+ if (m_bStepping)
+ {
+ m_lNextSampleWait = 0;
+ }
+ else if (s.m_RenderSettings.bSynchronizeNearest) // Present at the closest "safe" occasion at dTargetSyncOffset ms before vsync to avoid tearing
+ {
+ if (m_lNextSampleWait < -lDisplayCycle) // We have to allow slightly negative numbers at this stage. Otherwise we get "choking" when frame rate > refresh rate
+ {
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ }
+ REFERENCE_TIME rtRefClockTimeNow; if (m_pRefClock) m_pRefClock->GetTime(&rtRefClockTimeNow); // Reference clock time now
+ LONG lLastVsyncTime = (LONG)((m_llEstVBlankTime - rtRefClockTimeNow) / 10000); // Last vsync time relative to now
+ if (abs(lLastVsyncTime) > lDisplayCycle) lLastVsyncTime = - lDisplayCycle; // To even out glitches in the beginning
+
+ LONGLONG llNextSampleWait = (LONGLONG)(((double)lLastVsyncTime + GetDisplayCycle() - dTargetSyncOffset) * 10000); // Time from now util next safe time to Paint()
+ while ((llRefClockTime + llNextSampleWait) < (m_llSampleTime + m_llHysteresis)) // While the proposed time is in the past of sample presentation time
+ {
+ llNextSampleWait = llNextSampleWait + (LONGLONG)(GetDisplayCycle() * 10000); // Try the next possible time, one display cycle ahead
+ }
+ m_lNextSampleWait = (LONG)(llNextSampleWait / 10000);
+ m_lShiftToNearestPrev = m_lShiftToNearest;
+ m_lShiftToNearest = (LONG)((llRefClockTime + llNextSampleWait - m_llSampleTime) / 10000); // The adjustment made to get to the sweet point in time, in ms
+
+ // If m_lShiftToNearest is pushed a whole cycle into the future, then we are getting more frames
+ // than we can chew and we need to throw one away. We don't want to wait many cycles and skip many
+ // frames.
+ if (m_lShiftToNearest > (lDisplayCycle + 1))
+ {
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ }
+
+ // We need to add a hysteresis to the control of the timing adjustment to avoid judder when
+ // presentation time is close to vsync and the renderer couldn't otherwise make up its mind
+ // whether to present before the vsync or after. That kind of indecisiveness leads to judder.
+ if (m_bSnapToVSync)
+ {
+
+ if ((m_lShiftToNearestPrev - m_lShiftToNearest) > lDisplayCycle2) // If a step down in the m_lShiftToNearest function. Display slower than video.
+ {
+ m_bVideoSlowerThanDisplay = false;
+ m_llHysteresis = -(LONGLONG)(10000 * lDisplayCycle4);
+ }
+ else if ((m_lShiftToNearest - m_lShiftToNearestPrev) > lDisplayCycle2) // If a step up
+ {
+ m_bVideoSlowerThanDisplay = true;
+ m_llHysteresis = (LONGLONG)(10000 * lDisplayCycle4);
+ }
+ else if ((m_lShiftToNearest < (3 * lDisplayCycle4)) && (m_lShiftToNearest > lDisplayCycle4))
+ m_llHysteresis = 0; // Reset when between 1/4 and 3/4 of the way either way
+
+ if ((m_lShiftToNearest < lDisplayCycle2) && (m_llHysteresis > 0)) m_llHysteresis = 0; // Should never really be in this territory.
+ if (m_lShiftToNearest < 0) m_llHysteresis = 0; // A glitch might get us to a sticky state where both these numbers are negative.
+ if ((m_lShiftToNearest > lDisplayCycle2) && (m_llHysteresis < 0)) m_llHysteresis = 0;
+ }
+ }
+
+ if (m_lNextSampleWait < 0) // Skip late or duplicate sample.
+ {
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ }
+
+ if (m_lNextSampleWait > 1000)
+ {
+ m_lNextSampleWait = 1000; // So as to avoid full a full stop when sample is far in the future (shouldn't really happen).
+ }
+ }
+ } // if got new sample
+ }
+ }
+ // Wait for the next presentation time (m_lNextSampleWait) or some other event.
+ dwObject = WaitForMultipleObjects(countof(hEvts), hEvts, FALSE, (DWORD)m_lNextSampleWait);
+ switch (dwObject)
+ {
+ case WAIT_OBJECT_0: // Quit
+ bQuit = true;
+ break;
+
+ case WAIT_OBJECT_0 + 1: // Flush
+ if (pNewSample) MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ FlushSamples();
+ m_bEvtFlush = false;
+ ResetEvent(m_hEvtFlush);
+ m_bPrerolled = false;
+ m_lShiftToNearest = 0;
+ stepForward = true;
+ break;
+
+ case WAIT_OBJECT_0 + 2: // Skip sample
+ m_pcFramesDropped++;
+ m_llSampleTime = m_llLastSampleTime; // This sample will never be shown
+ m_bEvtSkip = false;
+ ResetEvent(m_hEvtSkip);
+ stepForward = true;
+ break;
+
+ case WAIT_TIMEOUT: // Time to show the sample or something
+ if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate)
+ {
+ if (pNewSample) MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ FlushSamples();
+ RenegotiateMediaType();
+ m_bPendingRenegotiate = false;
+ }
+
+ if (m_bPendingResetDevice)
+ {
+ m_bPendingResetDevice = false;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_allocatorLock);
+ if (pNewSample) MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ RemoveAllSamples();
+ CBaseAP::ResetDevice();
+
+ for(int i = 0; i < m_nDXSurface; i++)
+ {
+ CComPtr<IMFSample> pMFSample;
+ HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
+ if (SUCCEEDED (hr))
+ {
+ pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail(pMFSample);
+ }
+ ASSERT(SUCCEEDED (hr));
+ }
+ }
+ else if (m_nStepCount < 0)
+ {
+ m_nStepCount = 0;
+ m_pcFramesDropped++;
+ stepForward = true;
+ }
+ else if (pNewSample && (m_nStepCount > 0))
+ {
+ pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ if (!g_bExternalSubtitleTime) __super::SetTime (g_tSegmentStart + m_llSampleTime);
+ Paint(true);
+ CompleteFrameStep(false);
+ m_pcFramesDrawn++;
+ stepForward = true;
+ }
+ else if (pNewSample && !m_bStepping) // When a stepped frame is shown, a new one is fetched that we don't want to show here while stepping
+ {
+ pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
+ if (!g_bExternalSubtitleTime) __super::SetTime (g_tSegmentStart + m_llSampleTime);
+ Paint(true);
+ m_pcFramesDrawn++;
+ stepForward = true;
+ }
+ break;
+ } // switch
+ if (pNewSample && stepForward)
+ {
+ MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ }
+ } // while
+ if (pNewSample)
+ {
+ MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ }
+ timeEndPeriod (dwResolution);
+ if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics(hAvrt);
}
void CSyncAP::OnResetDevice()
{
- TRACE("--> CSyncAP::OnResetDevice on thread: %d\n", GetCurrentThreadId());
- HRESULT hr;
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if(m_pSink) m_pSink->Notify(EC_DISPLAY_CHANGED, 0, 0);
- if(m_pSink) m_pSink->Notify(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_NativeVideoSize.cx, m_NativeVideoSize.cy), 0);
+ TRACE("--> CSyncAP::OnResetDevice on thread: %d\n", GetCurrentThreadId());
+ HRESULT hr;
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (m_pSink) m_pSink->Notify(EC_DISPLAY_CHANGED, 0, 0);
+ if (m_pSink) m_pSink->Notify(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_NativeVideoSize.cx, m_NativeVideoSize.cy), 0);
}
void CSyncAP::RemoveAllSamples()
{
- CAutoLock AutoLock(&m_ImageProcessingLock);
- FlushSamples();
- m_ScheduledSamples.RemoveAll();
- m_FreeSamples.RemoveAll();
- ASSERT(m_nUsedBuffer == 0);
- m_nUsedBuffer = 0;
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ FlushSamples();
+ m_ScheduledSamples.RemoveAll();
+ m_FreeSamples.RemoveAll();
+ ASSERT(m_nUsedBuffer == 0);
+ m_nUsedBuffer = 0;
}
HRESULT CSyncAP::GetFreeSample(IMFSample** ppSample)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- if(m_FreeSamples.GetCount() > 1) // Cannot use first free buffer (can be currently displayed)
- {
- InterlockedIncrement(&m_nUsedBuffer);
- *ppSample = m_FreeSamples.RemoveHead().Detach();
- }
- else
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ if (m_FreeSamples.GetCount() > 1) // Cannot use first free buffer (can be currently displayed)
+ {
+ InterlockedIncrement(&m_nUsedBuffer);
+ *ppSample = m_FreeSamples.RemoveHead().Detach();
+ }
+ else
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- return hr;
+ return hr;
}
HRESULT CSyncAP::GetScheduledSample(IMFSample** ppSample, int &_Count)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- _Count = m_ScheduledSamples.GetCount();
- if(_Count > 0)
- {
- *ppSample = m_ScheduledSamples.RemoveHead().Detach();
- --_Count;
- }
- else
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ _Count = m_ScheduledSamples.GetCount();
+ if (_Count > 0)
+ {
+ *ppSample = m_ScheduledSamples.RemoveHead().Detach();
+ --_Count;
+ }
+ else
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- return hr;
+ return hr;
}
void CSyncAP::MoveToFreeList(IMFSample* pSample, bool bTail)
{
- CAutoLock lock(&m_SampleQueueLock);
- InterlockedDecrement(&m_nUsedBuffer);
- if(m_bPendingMediaFinished && m_nUsedBuffer == 0)
- {
- m_bPendingMediaFinished = false;
- m_pSink->Notify(EC_COMPLETE, 0, 0);
- }
- if(bTail)
- m_FreeSamples.AddTail(pSample);
- else
- m_FreeSamples.AddHead(pSample);
+ CAutoLock lock(&m_SampleQueueLock);
+ InterlockedDecrement(&m_nUsedBuffer);
+ if (m_bPendingMediaFinished && m_nUsedBuffer == 0)
+ {
+ m_bPendingMediaFinished = false;
+ m_pSink->Notify(EC_COMPLETE, 0, 0);
+ }
+ if (bTail)
+ m_FreeSamples.AddTail(pSample);
+ else
+ m_FreeSamples.AddHead(pSample);
}
void CSyncAP::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
- if(_bSorted)
- {
- CAutoLock lock(&m_SampleQueueLock);
- m_ScheduledSamples.AddHead(pSample);
- }
- else
- {
- CAutoLock lock(&m_SampleQueueLock);
- m_ScheduledSamples.AddTail(pSample);
- }
+ if (_bSorted)
+ {
+ CAutoLock lock(&m_SampleQueueLock);
+ m_ScheduledSamples.AddHead(pSample);
+ }
+ else
+ {
+ CAutoLock lock(&m_SampleQueueLock);
+ m_ScheduledSamples.AddTail(pSample);
+ }
}
void CSyncAP::FlushSamples()
{
- CAutoLock lock(this);
- CAutoLock lock2(&m_SampleQueueLock);
- FlushSamplesInternal();
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_SampleQueueLock);
+ FlushSamplesInternal();
}
void CSyncAP::FlushSamplesInternal()
{
- m_bPrerolled = false;
- while(m_ScheduledSamples.GetCount() > 0)
- {
- CComPtr<IMFSample> pMFSample;
- pMFSample = m_ScheduledSamples.RemoveHead();
- MoveToFreeList(pMFSample, true);
- }
+ m_bPrerolled = false;
+ while (m_ScheduledSamples.GetCount() > 0)
+ {
+ CComPtr<IMFSample> pMFSample;
+ pMFSample = m_ScheduledSamples.RemoveHead();
+ MoveToFreeList(pMFSample, true);
+ }
}
HRESULT CSyncAP::BeginStreaming()
{
- AppSettings& s = AfxGetAppSettings();
- m_pcFramesDropped = 0;
- m_pcFramesDrawn = 0;
+ AppSettings& s = AfxGetAppSettings();
+ m_pcFramesDropped = 0;
+ m_pcFramesDrawn = 0;
- if(s.m_RenderSettings.bSynchronizeVideo)
- m_pGenlock->AdviseSyncClock(((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_pSyncClock);
- CComPtr<IBaseFilter> pEVR;
- FILTER_INFO filterInfo;
- ZeroMemory(&filterInfo, sizeof(filterInfo));
- m_pOuterEVR->QueryInterface(__uuidof(IBaseFilter), (void**)&pEVR);
- pEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
+ if (s.m_RenderSettings.bSynchronizeVideo)
+ m_pGenlock->AdviseSyncClock(((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_pSyncClock);
+ CComPtr<IBaseFilter> pEVR;
+ FILTER_INFO filterInfo;
+ ZeroMemory(&filterInfo, sizeof(filterInfo));
+ m_pOuterEVR->QueryInterface (__uuidof(IBaseFilter), (void**)&pEVR);
+ pEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
- BeginEnumFilters(filterInfo.pGraph, pEF, pBF)
- if(CComQIPtr<IAMAudioRendererStats> pAS = pBF)
- {
- m_pAudioStats = pAS;
- };
- EndEnumFilters
+ BeginEnumFilters(filterInfo.pGraph, pEF, pBF)
+ if(CComQIPtr<IAMAudioRendererStats> pAS = pBF)
+ {
+ m_pAudioStats = pAS;
+ };
+ EndEnumFilters
- pEVR->GetSyncSource(&m_pRefClock);
- if(filterInfo.pGraph) filterInfo.pGraph->Release();
- m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
- m_pGenlock->GetTiming();
+ pEVR->GetSyncSource(&m_pRefClock);
+ if (filterInfo.pGraph) filterInfo.pGraph->Release();
+ m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
+ m_pGenlock->GetTiming();
- ResetStats();
- EstimateRefreshTimings();
- if(m_dFrameCycle > 0.0) m_dCycleDifference = GetCycleDifference(); // Might have moved to another display
- return S_OK;
+ ResetStats();
+ EstimateRefreshTimings();
+ if (m_dFrameCycle > 0.0) m_dCycleDifference = GetCycleDifference(); // Might have moved to another display
+ return S_OK;
}
HRESULT CreateSyncRenderer(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
{
- HRESULT hr = E_FAIL;
- if(clsid == CLSID_SyncAllocatorPresenter)
- {
- CString Error;
- *ppAP = DNew CSyncAP(hWnd, hr, Error);
- (*ppAP)->AddRef();
-
- if(FAILED(hr))
- {
- Error += L"\n";
- Error += GothSyncErrorMessage(hr, NULL);
- MessageBox(hWnd, Error, L"Error creating Sync Renderer", MB_OK | MB_ICONERROR);
- (*ppAP)->Release();
- *ppAP = NULL;
- }
- else if(!Error.IsEmpty())
- {
- MessageBox(hWnd, Error, L"Warning creating Sync Renderer", MB_OK | MB_ICONWARNING);
- }
- }
- return hr;
+ HRESULT hr = E_FAIL;
+ if (clsid == CLSID_SyncAllocatorPresenter)
+ {
+ CString Error;
+ *ppAP = DNew CSyncAP(hWnd, hr, Error);
+ (*ppAP)->AddRef();
+
+ if(FAILED(hr))
+ {
+ Error += L"\n";
+ Error += GothSyncErrorMessage(hr, NULL);
+ MessageBox(hWnd, Error, L"Error creating Sync Renderer", MB_OK | MB_ICONERROR);
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ }
+ else if (!Error.IsEmpty())
+ {
+ MessageBox(hWnd, Error, L"Warning creating Sync Renderer", MB_OK|MB_ICONWARNING);
+ }
+ }
+ return hr;
}
CSyncRenderer::CSyncRenderer(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CSyncAP *pAllocatorPresenter): CUnknown(pName, pUnk)
{
- hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
- m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
- m_pAllocatorPresenter = pAllocatorPresenter;
+ hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
+ m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = pAllocatorPresenter;
}
CSyncRenderer::~CSyncRenderer()
@@ -4028,401 +3888,401 @@ CSyncRenderer::~CSyncRenderer()
HRESULT STDMETHODCALLTYPE CSyncRenderer::GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State)
{
- HRESULT ReturnValue;
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->GetState(dwMilliSecsTimeout, State);
- return E_NOTIMPL;
+ HRESULT ReturnValue;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetState(dwMilliSecsTimeout, State);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::EnumPins(__out IEnumPins **ppEnum)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->EnumPins(ppEnum);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->EnumPins(ppEnum);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::FindPin(LPCWSTR Id, __out IPin **ppPin)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->FindPin(Id, ppPin);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->FindPin(Id, ppPin);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::QueryFilterInfo(__out FILTER_INFO *pInfo)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->QueryFilterInfo(pInfo);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->QueryFilterInfo(pInfo);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->JoinFilterGraph(pGraph, pName);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->JoinFilterGraph(pGraph, pName);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::QueryVendorInfo(__out LPWSTR *pVendorInfo)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->QueryVendorInfo(pVendorInfo);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->QueryVendorInfo(pVendorInfo);
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::Stop(void)
+STDMETHODIMP CSyncRenderer::Stop( void)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->Stop();
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Stop();
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::Pause(void)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->Pause();
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Pause();
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::Run(REFERENCE_TIME tStart)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->Run(tStart);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Run(tStart);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::SetSyncSource(__in_opt IReferenceClock *pClock)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->SetSyncSource(pClock);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->SetSyncSource(pClock);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::GetSyncSource(__deref_out_opt IReferenceClock **pClock)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->GetSyncSource(pClock);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetSyncSource(pClock);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::GetClassID(__RPC__out CLSID *pClassID)
{
- CComPtr<IBaseFilter> pEVRBase;
- if(m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if(pEVRBase)
- return pEVRBase->GetClassID(pClassID);
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetClassID(pClassID);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::support_ffdshow()
{
- queue_ffdshow_support = true;
- return S_OK;
+ queue_ffdshow_support = true;
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- HRESULT hr;
-
- if(riid == __uuidof(IVMRMixerBitmap9))
- return GetInterface((IVMRMixerBitmap9*)this, ppv);
-
- if(riid == __uuidof(IBaseFilter))
- {
- return GetInterface((IBaseFilter*)this, ppv);
- }
-
- if(riid == __uuidof(IMediaFilter))
- {
- return GetInterface((IMediaFilter*)this, ppv);
- }
- if(riid == __uuidof(IPersist))
- {
- return GetInterface((IPersist*)this, ppv);
- }
- if(riid == __uuidof(IBaseFilter))
- {
- return GetInterface((IBaseFilter*)this, ppv);
- }
-
- hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if(m_pEVR && FAILED(hr))
- {
- if(riid == __uuidof(IVMRffdshow9)) // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
- return GetInterface((IVMRffdshow9*)this, ppv);
- }
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ HRESULT hr;
+
+ if(riid == __uuidof(IVMRMixerBitmap9))
+ return GetInterface((IVMRMixerBitmap9*)this, ppv);
+
+ if (riid == __uuidof(IBaseFilter))
+ {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
+
+ if (riid == __uuidof(IMediaFilter))
+ {
+ return GetInterface((IMediaFilter*)this, ppv);
+ }
+ if (riid == __uuidof(IPersist))
+ {
+ return GetInterface((IPersist*)this, ppv);
+ }
+ if (riid == __uuidof(IBaseFilter))
+ {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
+
+ hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ if(m_pEVR && FAILED(hr))
+ {
+ if(riid == __uuidof(IVMRffdshow9)) // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ return GetInterface((IVMRffdshow9*)this, ppv);
+ }
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
}
CGenlock::CGenlock(DOUBLE target, DOUBLE limit, INT lineD, INT colD, DOUBLE clockD, UINT mon):
- targetSyncOffset(target), // Target sync offset, typically around 10 ms
- controlLimit(limit), // How much sync offset is allowed to drift from target sync offset before control kicks in
- lineDelta(lineD), // Number of rows used in display frequency adjustment, typically 1 (one)
- columnDelta(colD), // Number of columns used in display frequency adjustment, typically 1 - 2
- cycleDelta(clockD), // Delta used in clock speed adjustment. In fractions of 1.0. Typically around 0.001
- monitor(mon) // The monitor to be adjusted if the display refresh rate is the controlled parameter
-{
- lowSyncOffset = targetSyncOffset - controlLimit;
- highSyncOffset = targetSyncOffset + controlLimit;
- adjDelta = 0;
- displayAdjustmentsMade = 0;
- clockAdjustmentsMade = 0;
- displayFreqCruise = 0;
- displayFreqFaster = 0;
- displayFreqSlower = 0;
- curDisplayFreq = 0;
- psWnd = NULL;
- liveSource = FALSE;
- powerstripTimingExists = FALSE;
- syncOffsetFifo = new MovingAverage(64);
- frameCycleFifo = new MovingAverage(4);
+ targetSyncOffset(target), // Target sync offset, typically around 10 ms
+ controlLimit(limit), // How much sync offset is allowed to drift from target sync offset before control kicks in
+ lineDelta(lineD), // Number of rows used in display frequency adjustment, typically 1 (one)
+ columnDelta(colD), // Number of columns used in display frequency adjustment, typically 1 - 2
+ cycleDelta(clockD), // Delta used in clock speed adjustment. In fractions of 1.0. Typically around 0.001
+ monitor(mon) // The monitor to be adjusted if the display refresh rate is the controlled parameter
+{
+ lowSyncOffset = targetSyncOffset - controlLimit;
+ highSyncOffset = targetSyncOffset + controlLimit;
+ adjDelta = 0;
+ displayAdjustmentsMade = 0;
+ clockAdjustmentsMade = 0;
+ displayFreqCruise = 0;
+ displayFreqFaster = 0;
+ displayFreqSlower = 0;
+ curDisplayFreq = 0;
+ psWnd = NULL;
+ liveSource = FALSE;
+ powerstripTimingExists = FALSE;
+ syncOffsetFifo = new MovingAverage(64);
+ frameCycleFifo = new MovingAverage(4);
}
CGenlock::~CGenlock()
{
- ResetTiming();
- if(syncOffsetFifo != NULL)
- {
- delete syncOffsetFifo;
- syncOffsetFifo = NULL;
- }
- if(frameCycleFifo != NULL)
- {
- delete frameCycleFifo;
- frameCycleFifo = NULL;
- }
- syncClock = NULL;
+ ResetTiming();
+ if(syncOffsetFifo != NULL)
+ {
+ delete syncOffsetFifo;
+ syncOffsetFifo = NULL;
+ }
+ if(frameCycleFifo != NULL)
+ {
+ delete frameCycleFifo;
+ frameCycleFifo = NULL;
+ }
+ syncClock = NULL;
};
BOOL CGenlock::PowerstripRunning()
{
- psWnd = FindWindow(_T("TPShidden"), NULL);
- if(!psWnd) return FALSE; // Powerstrip is not running
- else return TRUE;
+ psWnd = FindWindow(_T("TPShidden"), NULL);
+ if (!psWnd) return FALSE; // Powerstrip is not running
+ else return TRUE;
}
// Get the display timing parameters through PowerStrip (if running).
HRESULT CGenlock::GetTiming()
{
- ATOM getTiming;
- LPARAM lParam = NULL;
- WPARAM wParam = monitor;
- INT i = 0;
- INT j = 0;
- INT params = 0;
- BOOL done = FALSE;
- TCHAR tmpStr[MAX_LOADSTRING];
-
- CAutoLock lock(&csGenlockLock);
- if(!PowerstripRunning()) return E_FAIL;
-
- getTiming = static_cast<ATOM>(SendMessage(psWnd, UM_GETTIMING, wParam, lParam));
- GlobalGetAtomName(getTiming, savedTiming, MAX_LOADSTRING);
-
- while(params < TIMING_PARAM_CNT)
- {
- while(savedTiming[i] != ',' && savedTiming[i] != '\0')
- {
- tmpStr[j++] = savedTiming[i];
- tmpStr[j] = '\0';
- i++;
- }
- i++; // Skip trailing comma
- j = 0;
- displayTiming[params] = _ttoi(tmpStr);
- displayTimingSave[params] = displayTiming[params];
- params++;
- }
-
- // The display update frequency is controlled by adding and subtracting pixels form the
- // image. This is done by either subtracting columns or rows or both. Some displays like
- // row adjustments and some column adjustments. One should probably not do both.
- StringCchPrintf(faster, MAX_LOADSTRING, TEXT("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
- displayTiming[0],
- displayTiming[HFRONTPORCH] - columnDelta,
- displayTiming[2],
- displayTiming[3],
- displayTiming[4],
- displayTiming[VFRONTPORCH] - lineDelta,
- displayTiming[6],
- displayTiming[7],
- displayTiming[PIXELCLOCK],
- displayTiming[9]
- );
-
- // Nominal update frequency
- StringCchPrintf(cruise, MAX_LOADSTRING, TEXT("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
- displayTiming[0],
- displayTiming[HFRONTPORCH],
- displayTiming[2],
- displayTiming[3],
- displayTiming[4],
- displayTiming[VFRONTPORCH],
- displayTiming[6],
- displayTiming[7],
- displayTiming[PIXELCLOCK],
- displayTiming[9]
- );
-
- // Lower than nominal update frequency
- StringCchPrintf(slower, MAX_LOADSTRING, TEXT("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
- displayTiming[0],
- displayTiming[HFRONTPORCH] + columnDelta,
- displayTiming[2],
- displayTiming[3],
- displayTiming[4],
- displayTiming[VFRONTPORCH] + lineDelta,
- displayTiming[6],
- displayTiming[7],
- displayTiming[PIXELCLOCK],
- displayTiming[9]
- );
-
- totalColumns = displayTiming[HACTIVE] + displayTiming[HFRONTPORCH] + displayTiming[HSYNCWIDTH] + displayTiming[HBACKPORCH];
- totalLines = displayTiming[VACTIVE] + displayTiming[VFRONTPORCH] + displayTiming[VSYNCWIDTH] + displayTiming[VBACKPORCH];
- pixelClock = 1000 * displayTiming[PIXELCLOCK]; // Pixels/s
- displayFreqCruise = (DOUBLE)pixelClock / (totalLines * totalColumns); // Frames/s
- displayFreqSlower = (DOUBLE)pixelClock / ((totalLines + lineDelta) * (totalColumns + columnDelta));
- displayFreqFaster = (DOUBLE)pixelClock / ((totalLines - lineDelta) * (totalColumns - columnDelta));
- curDisplayFreq = displayFreqCruise;
- GlobalDeleteAtom(getTiming);
- adjDelta = 0;
- powerstripTimingExists = TRUE;
- return S_OK;
+ ATOM getTiming;
+ LPARAM lParam = NULL;
+ WPARAM wParam = monitor;
+ INT i = 0;
+ INT j = 0;
+ INT params = 0;
+ BOOL done = FALSE;
+ TCHAR tmpStr[MAX_LOADSTRING];
+
+ CAutoLock lock(&csGenlockLock);
+ if (!PowerstripRunning()) return E_FAIL;
+
+ getTiming = static_cast<ATOM>(SendMessage(psWnd, UM_GETTIMING, wParam, lParam));
+ GlobalGetAtomName(getTiming, savedTiming, MAX_LOADSTRING);
+
+ while (params < TIMING_PARAM_CNT)
+ {
+ while (savedTiming[i] != ',' && savedTiming[i] != '\0')
+ {
+ tmpStr[j++] = savedTiming[i];
+ tmpStr[j] = '\0';
+ i++;
+ }
+ i++; // Skip trailing comma
+ j = 0;
+ displayTiming[params] = _ttoi(tmpStr);
+ displayTimingSave[params] = displayTiming[params];
+ params++;
+ }
+
+ // The display update frequency is controlled by adding and subtracting pixels form the
+ // image. This is done by either subtracting columns or rows or both. Some displays like
+ // row adjustments and some column adjustments. One should probably not do both.
+ StringCchPrintf(faster, MAX_LOADSTRING, TEXT("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
+ displayTiming[0],
+ displayTiming[HFRONTPORCH] - columnDelta,
+ displayTiming[2],
+ displayTiming[3],
+ displayTiming[4],
+ displayTiming[VFRONTPORCH] - lineDelta,
+ displayTiming[6],
+ displayTiming[7],
+ displayTiming[PIXELCLOCK],
+ displayTiming[9]
+ );
+
+ // Nominal update frequency
+ StringCchPrintf(cruise, MAX_LOADSTRING, TEXT("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
+ displayTiming[0],
+ displayTiming[HFRONTPORCH],
+ displayTiming[2],
+ displayTiming[3],
+ displayTiming[4],
+ displayTiming[VFRONTPORCH],
+ displayTiming[6],
+ displayTiming[7],
+ displayTiming[PIXELCLOCK],
+ displayTiming[9]
+ );
+
+ // Lower than nominal update frequency
+ StringCchPrintf(slower, MAX_LOADSTRING, TEXT("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
+ displayTiming[0],
+ displayTiming[HFRONTPORCH] + columnDelta,
+ displayTiming[2],
+ displayTiming[3],
+ displayTiming[4],
+ displayTiming[VFRONTPORCH] + lineDelta,
+ displayTiming[6],
+ displayTiming[7],
+ displayTiming[PIXELCLOCK],
+ displayTiming[9]
+ );
+
+ totalColumns = displayTiming[HACTIVE] + displayTiming[HFRONTPORCH] + displayTiming[HSYNCWIDTH] + displayTiming[HBACKPORCH];
+ totalLines = displayTiming[VACTIVE] + displayTiming[VFRONTPORCH] + displayTiming[VSYNCWIDTH] + displayTiming[VBACKPORCH];
+ pixelClock = 1000 * displayTiming[PIXELCLOCK]; // Pixels/s
+ displayFreqCruise = (DOUBLE)pixelClock / (totalLines * totalColumns); // Frames/s
+ displayFreqSlower = (DOUBLE)pixelClock / ((totalLines + lineDelta) * (totalColumns + columnDelta));
+ displayFreqFaster = (DOUBLE)pixelClock / ((totalLines - lineDelta) * (totalColumns - columnDelta));
+ curDisplayFreq = displayFreqCruise;
+ GlobalDeleteAtom(getTiming);
+ adjDelta = 0;
+ powerstripTimingExists = TRUE;
+ return S_OK;
}
// Reset display timing parameters to nominal.
HRESULT CGenlock::ResetTiming()
{
- LPARAM lParam = NULL;
- WPARAM wParam = monitor;
- ATOM setTiming;
- LRESULT ret;
- CAutoLock lock(&csGenlockLock);
+ LPARAM lParam = NULL;
+ WPARAM wParam = monitor;
+ ATOM setTiming;
+ LRESULT ret;
+ CAutoLock lock(&csGenlockLock);
- if(!PowerstripRunning()) return E_FAIL;
+ if (!PowerstripRunning()) return E_FAIL;
- if(displayAdjustmentsMade > 0)
- {
- setTiming = GlobalAddAtom(cruise);
- lParam = setTiming;
- ret = SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- curDisplayFreq = displayFreqCruise;
- }
- adjDelta = 0;
- return S_OK;
+ if (displayAdjustmentsMade > 0)
+ {
+ setTiming = GlobalAddAtom(cruise);
+ lParam = setTiming;
+ ret = SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ curDisplayFreq = displayFreqCruise;
+ }
+ adjDelta = 0;
+ return S_OK;
}
// Reset reference clock speed to nominal.
HRESULT CGenlock::ResetClock()
{
- adjDelta = 0;
- if(syncClock == NULL) return E_FAIL;
- else return syncClock->AdjustClock(1.0);
- return S_OK;
+ adjDelta = 0;
+ if (syncClock == NULL) return E_FAIL;
+ else return syncClock->AdjustClock(1.0);
+ return S_OK;
}
HRESULT CGenlock::SetTargetSyncOffset(DOUBLE targetD)
{
- targetSyncOffset = targetD;
- lowSyncOffset = targetD - controlLimit;
- highSyncOffset = targetD + controlLimit;
- return S_OK;
+ targetSyncOffset = targetD;
+ lowSyncOffset = targetD - controlLimit;
+ highSyncOffset = targetD + controlLimit;
+ return S_OK;
}
HRESULT CGenlock::GetTargetSyncOffset(DOUBLE *targetD)
{
- *targetD = targetSyncOffset;
- return S_OK;
+ *targetD = targetSyncOffset;
+ return S_OK;
}
HRESULT CGenlock::SetControlLimit(DOUBLE cL)
{
- controlLimit = cL;
- return S_OK;
+ controlLimit = cL;
+ return S_OK;
}
HRESULT CGenlock::GetControlLimit(DOUBLE *cL)
{
- *cL = controlLimit;
- return S_OK;
+ *cL = controlLimit;
+ return S_OK;
}
HRESULT CGenlock::SetDisplayResolution(UINT columns, UINT lines)
{
- visibleColumns = columns;
- visibleLines = lines;
- return S_OK;
+ visibleColumns = columns;
+ visibleLines = lines;
+ return S_OK;
}
HRESULT CGenlock::AdviseSyncClock(CComPtr<ISyncClock> sC)
{
- if(!sC) return E_FAIL;
- if(syncClock) syncClock = NULL; // Release any outstanding references if this is called repeatedly
- syncClock = sC;
- return S_OK;
+ if (!sC) return E_FAIL;
+ if (syncClock) syncClock = NULL; // Release any outstanding references if this is called repeatedly
+ syncClock = sC;
+ return S_OK;
}
// Set the monitor to control. This is best done manually as not all monitors can be controlled
@@ -4430,149 +4290,151 @@ HRESULT CGenlock::AdviseSyncClock(CComPtr<ISyncClock> sC)
// The PowerStrip API uses zero-based monitor numbers, i.e. the default monitor is 0.
HRESULT CGenlock::SetMonitor(UINT mon)
{
- monitor = mon;
- return S_OK;
+ monitor = mon;
+ return S_OK;
}
HRESULT CGenlock::ResetStats()
{
- CAutoLock lock(&csGenlockLock);
- minSyncOffset = 1000000.0;
- maxSyncOffset = -1000000.0;
- minFrameCycle = 1000000.0;
- maxFrameCycle = -1000000.0;
- displayAdjustmentsMade = 0;
- clockAdjustmentsMade = 0;
- return S_OK;
+ CAutoLock lock(&csGenlockLock);
+ minSyncOffset = 1000000.0;
+ maxSyncOffset = -1000000.0;
+ minFrameCycle = 1000000.0;
+ maxFrameCycle = -1000000.0;
+ displayAdjustmentsMade = 0;
+ clockAdjustmentsMade = 0;
+ return S_OK;
}
// Synchronize by adjusting display refresh rate
HRESULT CGenlock::ControlDisplay(double syncOffset, double frameCycle)
{
- LPARAM lParam = NULL;
- WPARAM wParam = monitor;
- ATOM setTiming;
-
- AppSettings& s = AfxGetAppSettings();
- targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
- lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
- highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
-
- syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
- minSyncOffset = min(minSyncOffset, syncOffset);
- maxSyncOffset = max(maxSyncOffset, syncOffset);
- frameCycleAvg = frameCycleFifo->Average(frameCycle);
- minFrameCycle = min(minFrameCycle, frameCycle);
- maxFrameCycle = max(maxFrameCycle, frameCycle);
-
- if(!PowerstripRunning() || !powerstripTimingExists) return E_FAIL;
- // Adjust as seldom as possible by checking the current controlState before changing it.
- if((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
- // Speed up display refresh rate by subtracting pixels from the image.
- {
- adjDelta = 1; // Increase refresh rate
- curDisplayFreq = displayFreqFaster;
- setTiming = GlobalAddAtom(faster);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- }
- else
- // Slow down display refresh rate by adding pixels to the image.
- if((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1))
- {
- adjDelta = -1;
- curDisplayFreq = displayFreqSlower;
- setTiming = GlobalAddAtom(slower);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- }
- else
- // Cruise.
- if((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1))
- {
- adjDelta = 0;
- curDisplayFreq = displayFreqCruise;
- setTiming = GlobalAddAtom(cruise);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- }
- else if((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1))
- {
- adjDelta = 0;
- curDisplayFreq = displayFreqCruise;
- setTiming = GlobalAddAtom(cruise);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- }
- return S_OK;
+ LPARAM lParam = NULL;
+ WPARAM wParam = monitor;
+ ATOM setTiming;
+
+ AppSettings& s = AfxGetAppSettings();
+ targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+ lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
+ highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
+
+ syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
+ minSyncOffset = min(minSyncOffset, syncOffset);
+ maxSyncOffset = max(maxSyncOffset, syncOffset);
+ frameCycleAvg = frameCycleFifo->Average(frameCycle);
+ minFrameCycle = min(minFrameCycle, frameCycle);
+ maxFrameCycle = max(maxFrameCycle, frameCycle);
+
+ if (!PowerstripRunning() || !powerstripTimingExists) return E_FAIL;
+ // Adjust as seldom as possible by checking the current controlState before changing it.
+ if ((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
+ // Speed up display refresh rate by subtracting pixels from the image.
+ {
+ adjDelta = 1; // Increase refresh rate
+ curDisplayFreq = displayFreqFaster;
+ setTiming = GlobalAddAtom(faster);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ }
+ else
+ // Slow down display refresh rate by adding pixels to the image.
+ if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1))
+ {
+ adjDelta = -1;
+ curDisplayFreq = displayFreqSlower;
+ setTiming = GlobalAddAtom(slower);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ }
+ else
+ // Cruise.
+ if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1))
+ {
+ adjDelta = 0;
+ curDisplayFreq = displayFreqCruise;
+ setTiming = GlobalAddAtom(cruise);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ }
+ else
+ if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1))
+ {
+ adjDelta = 0;
+ curDisplayFreq = displayFreqCruise;
+ setTiming = GlobalAddAtom(cruise);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ }
+ return S_OK;
}
// Synchronize by adjusting reference clock rate (and therefore video FPS).
// Todo: check so that we don't have a live source
HRESULT CGenlock::ControlClock(double syncOffset, double frameCycle)
{
- AppSettings& s = AfxGetAppSettings();
- targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
- lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
- highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
-
- syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
- minSyncOffset = min(minSyncOffset, syncOffset);
- maxSyncOffset = max(maxSyncOffset, syncOffset);
- frameCycleAvg = frameCycleFifo->Average(frameCycle);
- minFrameCycle = min(minFrameCycle, frameCycle);
- maxFrameCycle = max(maxFrameCycle, frameCycle);
-
- if(!syncClock) return E_FAIL;
- // Adjust as seldom as possible by checking the current controlState before changing it.
- if((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
- // Slow down video stream.
- {
- adjDelta = 1;
- syncClock->AdjustClock(1.0 - cycleDelta); // Makes the clock move slower by providing smaller increments
- clockAdjustmentsMade++;
- }
- else
- // Speed up video stream.
- if((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1))
- {
- adjDelta = -1;
- syncClock->AdjustClock(1.0 + cycleDelta);
- clockAdjustmentsMade++;
- }
- else
- // Cruise.
- if((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1))
- {
- adjDelta = 0;
- syncClock->AdjustClock(1.0);
- clockAdjustmentsMade++;
- }
- else if((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1))
- {
- adjDelta = 0;
- syncClock->AdjustClock(1.0);
- clockAdjustmentsMade++;
- }
- return S_OK;
+ AppSettings& s = AfxGetAppSettings();
+ targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+ lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
+ highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
+
+ syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
+ minSyncOffset = min(minSyncOffset, syncOffset);
+ maxSyncOffset = max(maxSyncOffset, syncOffset);
+ frameCycleAvg = frameCycleFifo->Average(frameCycle);
+ minFrameCycle = min(minFrameCycle, frameCycle);
+ maxFrameCycle = max(maxFrameCycle, frameCycle);
+
+ if (!syncClock) return E_FAIL;
+ // Adjust as seldom as possible by checking the current controlState before changing it.
+ if ((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
+ // Slow down video stream.
+ {
+ adjDelta = 1;
+ syncClock->AdjustClock(1.0 - cycleDelta); // Makes the clock move slower by providing smaller increments
+ clockAdjustmentsMade++;
+ }
+ else
+ // Speed up video stream.
+ if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1))
+ {
+ adjDelta = -1;
+ syncClock->AdjustClock(1.0 + cycleDelta);
+ clockAdjustmentsMade++;
+ }
+ else
+ // Cruise.
+ if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1))
+ {
+ adjDelta = 0;
+ syncClock->AdjustClock(1.0);
+ clockAdjustmentsMade++;
+ }
+ else
+ if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1))
+ {
+ adjDelta = 0;
+ syncClock->AdjustClock(1.0);
+ clockAdjustmentsMade++;
+ }
+ return S_OK;
}
// Don't adjust anything, just update the syncOffset stats
HRESULT CGenlock::UpdateStats(double syncOffset, double frameCycle)
{
- syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
- minSyncOffset = min(minSyncOffset, syncOffset);
- maxSyncOffset = max(maxSyncOffset, syncOffset);
- frameCycleAvg = frameCycleFifo->Average(frameCycle);
- minFrameCycle = min(minFrameCycle, frameCycle);
- maxFrameCycle = max(maxFrameCycle, frameCycle);
- return S_OK;
+ syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
+ minSyncOffset = min(minSyncOffset, syncOffset);
+ maxSyncOffset = max(maxSyncOffset, syncOffset);
+ frameCycleAvg = frameCycleFifo->Average(frameCycle);
+ minFrameCycle = min(minFrameCycle, frameCycle);
+ maxFrameCycle = max(maxFrameCycle, frameCycle);
+ return S_OK;
} \ No newline at end of file
diff --git a/src/apps/mplayerc/SyncRenderer.h b/src/apps/mplayerc/SyncRenderer.h
index 777694dd4..6e60beb3a 100644
--- a/src/apps/mplayerc/SyncRenderer.h
+++ b/src/apps/mplayerc/SyncRenderer.h
@@ -36,21 +36,21 @@ extern bool g_bExternalSubtitleTime;
// the display frequency in one of the video - display synchronization modes.
// Powerstrip can also through a CGenlock object give very accurate timing data
// (given) that the gfx board is supported by PS.
-#define UM_SETCUSTOMTIMING (WM_USER+200)
-#define UM_SETREFRESHRATE (WM_USER+201)
-#define UM_SETPOLARITY (WM_USER+202)
-#define UM_REMOTECONTROL (WM_USER+210)
-#define UM_SETGAMMARAMP (WM_USER+203)
+#define UM_SETCUSTOMTIMING (WM_USER+200)
+#define UM_SETREFRESHRATE (WM_USER+201)
+#define UM_SETPOLARITY (WM_USER+202)
+#define UM_REMOTECONTROL (WM_USER+210)
+#define UM_SETGAMMARAMP (WM_USER+203)
#define UM_CREATERESOLUTION (WM_USER+204)
#define UM_GETTIMING (WM_USER+205)
#define UM_SETCUSTOMTIMINGFAST (WM_USER+211) // Sets timing without writing to file. Faster
-#define PositiveHorizontalPolarity 0x00
-#define PositiveVerticalPolarity 0x00
-#define NegativeHorizontalPolarity 0x02
-#define NegativeVerticalPolarity 0x04
-#define HideTrayIcon 0x00
-#define ShowTrayIcon 0x01
+#define PositiveHorizontalPolarity 0x00
+#define PositiveVerticalPolarity 0x00
+#define NegativeHorizontalPolarity 0x02
+#define NegativeVerticalPolarity 0x04
+#define HideTrayIcon 0x00
+#define ShowTrayIcon 0x01
#define ClosePowerStrip 0x63
#define HACTIVE 0
@@ -73,611 +73,604 @@ static const GUID GUID_SURFACE_INDEX = { 0x30c8e9f6, 0x415, 0x4b81, { 0xa3, 0x15
namespace GothSync
{
-typedef enum
-{
- MSG_MIXERIN,
- MSG_MIXEROUT,
- MSG_ERROR
-} EVR_STATS_MSG;
-
-#pragma pack(push, 1)
-
-template<int texcoords>
-struct MYD3DVERTEX
-{
- float x, y, z, rhw;
- struct
- {
- float u, v;
- } t[texcoords];
-};
-
-template<>
-struct MYD3DVERTEX<0>
-{
- float x, y, z, rhw;
- DWORD Diffuse;
-};
-
-#pragma pack(pop)
-
-class CGenlock;
-class CSyncRenderer;
-
-// Base allocator-presenter
-class CBaseAP:
- public ISubPicAllocatorPresenterImpl
-{
-protected:
- CMPlayerCApp::Settings::CRendererSettingsEVR m_LastRendererSettings;
-
- HMODULE m_hDWMAPI;
- HRESULT(__stdcall * m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
- HRESULT(__stdcall * m_pDwmEnableComposition)(UINT uCompositionAction);
- HMODULE m_hD3D9;
- HRESULT(__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
-
- CCritSec m_allocatorLock;
- CComPtr<IDirect3D9Ex> m_pD3DEx;
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
-
- CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_PICTURE_SLOTS];
- CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_PICTURE_SLOTS];
- CComPtr<IDirect3DTexture9> m_pOSDTexture;
- CComPtr<IDirect3DSurface9> m_pOSDSurface;
- CComPtr<ID3DXLine> m_pLine;
- CComPtr<ID3DXFont> m_pFont;
- CComPtr<ID3DXSprite> m_pSprite;
- CSyncRenderer *m_pOuterEVR;
-
- class CExternalPixelShader
- {
- public:
- CComPtr<IDirect3DPixelShader9> m_pPixelShader;
- CStringA m_SourceData;
- CStringA m_SourceTarget;
- HRESULT Compile(CPixelShaderCompiler *pCompiler)
- {
- HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if(FAILED(hr)) return hr;
- return S_OK;
- }
- };
-
- CAutoPtr<CPixelShaderCompiler> m_pPSC;
- CAtlList<CExternalPixelShader> m_pPixelShaders;
- CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
- CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
- CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
-
- D3DFORMAT m_SurfaceType;
- D3DFORMAT m_BackbufferType;
- D3DFORMAT m_DisplayType;
- D3DTEXTUREFILTERTYPE m_filter;
- D3DCAPS9 m_caps;
- D3DPRESENT_PARAMETERS pp;
-
- bool SettingsNeedResetDevice();
- virtual HRESULT CreateDXDevice(CString &_Error);
- virtual HRESULT ResetDXDevice(CString &_Error);
- virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
- virtual void DeleteSurfaces();
-
- HANDLE m_hEvtQuit; // Stop rendering thread event
- UINT GetAdapter(IDirect3D9 *pD3D);
-
- float m_bicubicA;
- HRESULT InitResizers(float bicubicA, bool bNeedScreenSizeTexture);
-
- // Functions to trace timing performance
- void SyncStats(LONGLONG syncTime);
- void SyncOffsetStats(LONGLONG syncOffset);
- void DrawText(const RECT &rc, const CString &strText, int _Priority);
- void DrawStats();
-
- template<int texcoords>
- void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy);
- template<int texcoords>
- HRESULT TextureBlt(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter);
- MFOffset GetOffset(float v);
- MFVideoArea GetArea(float x, float y, DWORD width, DWORD height);
- bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d);
-
- HRESULT DrawRectBase(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<0> v[4]);
- HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
- HRESULT TextureCopy(CComPtr<IDirect3DTexture9> pTexture);
- HRESULT TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect);
- HRESULT TextureResizeBilinear(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
- HRESULT TextureResizeBicubic1pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
- HRESULT TextureResizeBicubic2pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
-
- typedef HRESULT(WINAPI * D3DXLoadSurfaceFromMemoryPtr)(
- LPDIRECT3DSURFACE9 pDestSurface,
- CONST PALETTEENTRY* pDestPalette,
- CONST RECT* pDestRect,
- LPCVOID pSrcMemory,
- D3DFORMAT SrcFormat,
- UINT SrcPitch,
- CONST PALETTEENTRY* pSrcPalette,
- CONST RECT* pSrcRect,
- DWORD Filter,
- D3DCOLOR ColorKey);
-
- typedef HRESULT(WINAPI* D3DXCreateLinePtr)
- (LPDIRECT3DDEVICE9 pDevice,
- LPD3DXLINE* ppLine);
-
- typedef HRESULT(WINAPI* D3DXCreateFontPtr)(
- LPDIRECT3DDEVICE9 pDevice,
- int Height,
- UINT Width,
- UINT Weight,
- UINT MipLevels,
- bool Italic,
- DWORD CharSet,
- DWORD OutputPrecision,
- DWORD Quality,
- DWORD PitchAndFamily,
- LPCWSTR pFaceName,
- LPD3DXFONT* ppFont);
-
- HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture);
-
- virtual void OnResetDevice() {};
- virtual bool ResetDevice();
-
- int m_nTearingPos;
- VMR9AlphaBitmap m_VMR9AlphaBitmap;
- CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
- CRect m_VMR9AlphaBitmapRect;
- int m_VMR9AlphaBitmapWidthBytes;
-
- D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
- D3DXCreateLinePtr m_pD3DXCreateLine;
- D3DXCreateFontPtr m_pD3DXCreateFont;
- HRESULT(__stdcall *m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE * ppSprite);
-
- int m_nDXSurface; // Total number of DX Surfaces
- int m_nVMR9Surfaces;
- int m_iVMR9Surface;
- int m_nCurSurface; // Surface currently displayed
- long m_nUsedBuffer;
- bool m_bNeedPendingResetDevice;
- bool m_bPendingResetDevice;
-
- LONG m_lNextSampleWait; // Waiting time for next sample in EVR
- bool m_bSnapToVSync; // True if framerate is low enough so that snap to vsync makes sense
-
- UINT m_uScanLineEnteringPaint; // The active scan line when entering Paint()
- REFERENCE_TIME m_llEstVBlankTime; // Next vblank start time in reference clock "coordinates"
-
- double m_fAvrFps; // Estimate the true FPS as given by the distance between vsyncs when a frame has been presented
- double m_fJitterStdDev; // VSync estimate std dev
- double m_fJitterMean; // Mean time between two syncpulses when a frame has been presented (i.e. when Paint() has been called
-
- double m_fSyncOffsetAvr; // Mean time between the call of Paint() and vsync. To avoid tearing this should be several ms at least
- double m_fSyncOffsetStdDev; // The std dev of the above
-
- bool m_bHighColorResolution;
- bool m_bCompositionEnabled;
- bool m_bDesktopCompositionDisabled;
- bool m_bIsFullscreen;
- bool m_bNeedCheckSample;
- DWORD m_dMainThreadId;
-
- CSize m_ScreenSize;
-
- // Display and frame rates and cycles
- double m_dDetectedScanlineTime; // Time for one (horizontal) scan line. Extracted at stream start and used to calculate vsync time
- UINT m_uD3DRefreshRate; // As got when creating the d3d device
- double m_dD3DRefreshCycle; // Display refresh cycle ms
- double m_dEstRefreshCycle; // As estimated from scan lines
- double m_dFrameCycle; // Average sample time, extracted from the samples themselves
- // double m_fps is defined in ISubPic.h
- double m_dOptimumDisplayCycle; // The display cycle that is closest to the frame rate. A multiple of the actual display cycle
- double m_dCycleDifference; // Difference in video and display cycle time relative to the video cycle time
-
- UINT m_pcFramesDropped;
- UINT m_pcFramesDuplicated;
- UINT m_pcFramesDrawn;
-
- LONGLONG m_pllJitter [NB_JITTER]; // Vertical sync time stats
- LONGLONG m_pllSyncOffset [NB_JITTER]; // Sync offset time stats
- int m_nNextJitter;
- int m_nNextSyncOffset;
- LONGLONG m_JitterStdDev;
-
- LONGLONG m_llLastSyncTime;
-
- LONGLONG m_MaxJitter;
- LONGLONG m_MinJitter;
- LONGLONG m_MaxSyncOffset;
- LONGLONG m_MinSyncOffset;
- UINT m_uSyncGlitches;
-
- LONGLONG m_llSampleTime, m_llLastSampleTime; // Present time for the current sample
- LONG m_lSampleLatency, m_lLastSampleLatency; // Time between intended and actual presentation time
- LONG m_lMinSampleLatency, m_lLastMinSampleLatency;
- LONGLONG m_llHysteresis;
- LONG m_lHysteresis;
- LONG m_lShiftToNearest, m_lShiftToNearestPrev;
- bool m_bVideoSlowerThanDisplay;
-
- int m_bInterlaced;
- double m_TextScale;
- CString m_strStatsMsg[10];
-
- CGenlock *m_pGenlock; // The video - display synchronizer class
- CComPtr<IReferenceClock> m_pRefClock; // The reference clock. Used in Paint()
- CComPtr<IAMAudioRendererStats> m_pAudioStats; // Audio statistics from audio renderer. To check so that audio is in sync
- DWORD m_lAudioLag; // Time difference between audio and video when the audio renderer is matching rate to the external reference clock
- long m_lAudioLagMin, m_lAudioLagMax; // The accumulated difference between the audio renderer and the master clock
- DWORD m_lAudioSlaveMode; // To check whether the audio renderer matches rate with SyncClock (returns the value 4 if it does)
-
- double GetRefreshRate(); // Get the best estimate of the display refresh rate in Hz
- double GetDisplayCycle(); // Get the best estimate of the display cycle time in milliseconds
- double GetCycleDifference(); // Get the difference in video and display cycle times.
- void EstimateRefreshTimings(); // Estimate the times for one scan line and one frame respectively from the actual refresh data
- bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt);
-
-public:
- CBaseAP(HWND hWnd, HRESULT& hr, CString &_Error);
- ~CBaseAP();
-
- CCritSec m_VMR9AlphaBitmapLock;
- void UpdateAlphaBitmap();
- void ResetStats();
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
-};
-
-class CSyncAP:
- public CBaseAP,
- public IMFGetService,
- public IMFTopologyServiceLookupClient,
- public IMFVideoDeviceID,
- public IMFVideoPresenter,
- public IDirect3DDeviceManager9,
- public IMFAsyncCallback,
- public IQualProp,
- public IMFRateSupport,
- public IMFVideoDisplayControl,
- public IEVRTrustedVideoPlugin
-
-{
-public:
- CSyncAP(HWND hWnd, HRESULT& hr, CString &_Error);
- ~CSyncAP(void);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
-
- // IMFClockStateSink
- STDMETHODIMP OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset);
- STDMETHODIMP STDMETHODCALLTYPE OnClockStop(MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockPause(MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockSetRate(MFTIME hnsSystemTime, float flRate);
-
- // IBaseFilter delegate
- bool GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue);
-
- // IQualProp (EVR statistics window). These are incompletely implemented currently
- STDMETHODIMP get_FramesDroppedInRenderer(int *pcFrames);
- STDMETHODIMP get_FramesDrawn(int *pcFramesDrawn);
- STDMETHODIMP get_AvgFrameRate(int *piAvgFrameRate);
- STDMETHODIMP get_Jitter(int *iJitter);
- STDMETHODIMP get_AvgSyncOffset(int *piAvg);
- STDMETHODIMP get_DevSyncOffset(int *piDev);
-
- // IMFRateSupport
- STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate);
- float GetMaxRate(BOOL bThin);
-
- // IMFVideoPresenter
- STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
- STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType);
-
- // IMFTopologyServiceLookupClient
- STDMETHODIMP InitServicePointers(__in IMFTopologyServiceLookup *pLookup);
- STDMETHODIMP ReleaseServicePointers();
-
- // IMFVideoDeviceID
- STDMETHODIMP GetDeviceID(__out IID *pDeviceID);
-
- // IMFGetService
- STDMETHODIMP GetService(__RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID *ppvObject);
-
- // IMFAsyncCallback
- STDMETHODIMP GetParameters(__RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue);
- STDMETHODIMP Invoke(__RPC__in_opt IMFAsyncResult *pAsyncResult);
-
- // IMFVideoDisplayControl
- STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo);
- STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax);
- STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest);
- STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest);
- STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
- STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode);
- STDMETHODIMP SetVideoWindow(HWND hwndVideo);
- STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
- STDMETHODIMP RepaintVideo(void);
- STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF *pClr);
- STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
- STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags);
- STDMETHODIMP SetFullscreen(BOOL fFullscreen);
- STDMETHODIMP GetFullscreen(BOOL *pfFullscreen);
-
- // IEVRTrustedVideoPlugin
- STDMETHODIMP IsInTrustedVideoMode(BOOL *pYes);
- STDMETHODIMP CanConstrict(BOOL *pYes);
- STDMETHODIMP SetConstriction(DWORD dwKPix);
- STDMETHODIMP DisableImageExport(BOOL bDisable);
-
- // IDirect3DDeviceManager9
- STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice, UINT resetToken);
- STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
- STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
- STDMETHODIMP TestDevice(HANDLE hDevice);
- STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
- STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
- STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void **ppService);
-
-protected:
- void OnResetDevice();
- MFCLOCK_STATE m_LastClockState;
-
-private:
- // dxva.dll
- typedef HRESULT(__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
- // mf.dll
- typedef HRESULT(__stdcall *PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
- // evr.dll
- typedef HRESULT(__stdcall *PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
- typedef HRESULT(__stdcall *PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
- typedef HRESULT(__stdcall *PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
- // avrt.dll
- typedef HANDLE(__stdcall *PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
- typedef BOOL (__stdcall *PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
- typedef BOOL (__stdcall *PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
-
- typedef enum
- {
- Started = State_Running,
- Stopped = State_Stopped,
- Paused = State_Paused,
- Shutdown = State_Running + 1
- } RENDER_STATE;
-
- CComPtr<IMFClock> m_pClock;
- CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
- CComPtr<IMFTransform> m_pMixer;
- CComPtr<IMediaEventSink> m_pSink;
- CComPtr<IMFVideoMediaType> m_pMediaType;
- MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
- MFVideoRenderPrefs m_dwVideoRenderPrefs;
- COLORREF m_BorderColor;
-
- HANDLE m_hEvtQuit; // Stop rendering thread event
- bool m_bEvtQuit;
- HANDLE m_hEvtFlush; // Discard all buffers
- bool m_bEvtFlush;
- HANDLE m_hEvtSkip; // Skip frame
- bool m_bEvtSkip;
-
- bool m_bUseInternalTimer;
- int32 m_LastSetOutputRange;
- bool m_bPendingRenegotiate;
- bool m_bPendingMediaFinished;
- bool m_bPrerolled; // true if first sample has been displayed.
-
- HANDLE m_hRenderThread;
- HANDLE m_hMixerThread;
- RENDER_STATE m_nRenderState;
- bool m_bStepping;
-
- CCritSec m_SampleQueueLock;
- CCritSec m_ImageProcessingLock;
-
- CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
- CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
- IMFSample *m_pCurrentDisplaydSample;
- UINT m_nResetToken;
- int m_nStepCount;
-
- bool GetSampleFromMixer();
- void MixerThread();
- static DWORD WINAPI MixerThreadStatic(LPVOID lpParam);
- void RenderThread();
- static DWORD WINAPI RenderThreadStatic(LPVOID lpParam);
-
- void StartWorkerThreads();
- void StopWorkerThreads();
- HRESULT CheckShutdown() const;
- void CompleteFrameStep(bool bCancel);
-
- void RemoveAllSamples();
- HRESULT BeginStreaming();
- HRESULT GetFreeSample(IMFSample** ppSample);
- HRESULT GetScheduledSample(IMFSample** ppSample, int &_Count);
- void MoveToFreeList(IMFSample* pSample, bool bTail);
- void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
- void FlushSamples();
- void FlushSamplesInternal();
-
- LONGLONG GetMediaTypeMerit(IMFMediaType *pMediaType);
- HRESULT RenegotiateMediaType();
- HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
- HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
- HRESULT SetMediaType(IMFMediaType* pType);
-
- // Functions pointers for Vista/.NET3 specific library
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
- PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
- PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
-
- PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
- PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
- PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
-};
-
-class CSyncRenderer:
- public CUnknown,
- public IVMRffdshow9,
- public IVMRMixerBitmap9,
- public IBaseFilter
-{
- CComPtr<IUnknown> m_pEVR;
- VMR9AlphaBitmap *m_pVMR9AlphaBitmap;
- CSyncAP *m_pAllocatorPresenter;
-
-public:
- CSyncRenderer(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CSyncAP *pAllocatorPresenter);
- ~CSyncRenderer();
-
- // IBaseFilter
- virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum);
- virtual HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, __out IPin **ppPin);
- virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo);
- virtual HRESULT STDMETHODCALLTYPE JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName);
- virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo);
- virtual HRESULT STDMETHODCALLTYPE Stop(void);
- virtual HRESULT STDMETHODCALLTYPE Pause(void);
- virtual HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
- virtual HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
- virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock);
- virtual HRESULT STDMETHODCALLTYPE GetSyncSource(__deref_out_opt IReferenceClock **pClock);
- virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID);
-
- // IVMRffdshow9
- virtual HRESULT STDMETHODCALLTYPE support_ffdshow();
-
- // IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
-
- DECLARE_IUNKNOWN;
- virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid, void** ppvObject);
-};
-
-class CGenlock
-{
-public:
- class MovingAverage
- {
- public:
- MovingAverage(INT size):
- fifoSize(size),
- oldestSample(0),
- sum(0)
- {
- if(fifoSize > MAX_FIFO_SIZE)
- {
- fifoSize = MAX_FIFO_SIZE;
- }
- for(INT i = 0; i < MAX_FIFO_SIZE; i++)
- fifo[i] = 0;
- }
-
- ~MovingAverage()
- {
- }
-
- double Average(double sample)
- {
- sum = sum + sample - fifo[oldestSample];
- fifo[oldestSample] = sample;
- oldestSample++;
- if(oldestSample == fifoSize)
- oldestSample = 0;
- return sum / fifoSize;
- }
-
- private:
- INT fifoSize;
- double fifo[MAX_FIFO_SIZE];
- INT oldestSample;
- double sum;
- };
-
- CGenlock(DOUBLE target, DOUBLE limit, INT rowD, INT colD, DOUBLE clockD, UINT mon);
- ~CGenlock();
-
- BOOL PowerstripRunning(); // TRUE if PowerStrip is running
- HRESULT GetTiming(); // Get the string representing the display's current timing parameters
- HRESULT ResetTiming(); // Reset timing to what was last registered by GetTiming()
- HRESULT ResetClock(); // Reset reference clock speed to nominal
- HRESULT SetTargetSyncOffset(DOUBLE targetD);
- HRESULT GetTargetSyncOffset(DOUBLE *targetD);
- HRESULT SetControlLimit(DOUBLE cL);
- HRESULT GetControlLimit(DOUBLE *cL);
- HRESULT SetDisplayResolution(UINT columns, UINT lines);
- HRESULT AdviseSyncClock(CComPtr<ISyncClock> sC);
- HRESULT SetMonitor(UINT mon); // Set the number of the monitor to synchronize
- HRESULT ResetStats(); // Reset timing statistics
-
- HRESULT ControlDisplay(double syncOffset, double frameCycle); // Adjust the frequency of the display if needed
- HRESULT ControlClock(double syncOffset, double frameCycle); // Adjust the frequency of the clock if needed
- HRESULT UpdateStats(double syncOffset, double frameCycle); // Don't adjust anything, just update the syncOffset stats
-
- BOOL powerstripTimingExists; // TRUE if display timing has been got through Powerstrip
- BOOL liveSource; // TRUE if live source -> display sync is the only option
- INT adjDelta; // -1 for display slower in relation to video, 0 for keep, 1 for faster
- INT lineDelta; // The number of rows added or subtracted when adjusting display fps
- INT columnDelta; // The number of colums added or subtracted when adjusting display fps
- DOUBLE cycleDelta; // Adjustment factor for cycle time as fraction of nominal value
- UINT displayAdjustmentsMade; // The number of adjustments made to display refresh rate
- UINT clockAdjustmentsMade; // The number of adjustments made to clock frequency
-
- UINT totalLines, totalColumns; // Including the porches and sync widths
- UINT visibleLines, visibleColumns; // The nominal resolution
- MovingAverage *syncOffsetFifo;
- MovingAverage *frameCycleFifo;
- DOUBLE minSyncOffset, maxSyncOffset;
- DOUBLE syncOffsetAvg; // Average of the above
- DOUBLE minFrameCycle, maxFrameCycle;
- DOUBLE frameCycleAvg;
-
- UINT pixelClock; // In pixels/s
- DOUBLE displayFreqCruise; // Nominal display frequency in frames/s
- DOUBLE displayFreqSlower;
- DOUBLE displayFreqFaster;
- DOUBLE curDisplayFreq; // Current (adjusted) display frequency
- DOUBLE controlLimit; // How much the sync offset is allowed to drift from target sync offset
- WPARAM monitor; // The monitor to be controlled. 0-based.
- CComPtr<ISyncClock> syncClock; // Interface to an adjustable reference clock
-
-private:
- HWND psWnd; // PowerStrip window
- const static INT TIMING_PARAM_CNT = 10;
- const static INT MAX_LOADSTRING = 100;
- UINT displayTiming[TIMING_PARAM_CNT]; // Display timing parameters
- UINT displayTimingSave[TIMING_PARAM_CNT]; // So that we can reset the display at exit
- TCHAR faster[MAX_LOADSTRING]; // String corresponding to faster display frequency
- TCHAR cruise[MAX_LOADSTRING]; // String corresponding to nominal display frequency
- TCHAR slower[MAX_LOADSTRING]; // String corresponding to slower display frequency
- TCHAR savedTiming[MAX_LOADSTRING]; // String version of saved timing (to be restored upon exit)
- DOUBLE lowSyncOffset; // The closest we want to let the scheduled render time to get to the next vsync. In % of the frame time
- DOUBLE targetSyncOffset; // Where we want the scheduled render time to be in relation to the next vsync
- DOUBLE highSyncOffset; // The furthers we want to let the scheduled render time to get to the next vsync
- CCritSec csGenlockLock;
-};
+ typedef enum
+ {
+ MSG_MIXERIN,
+ MSG_MIXEROUT,
+ MSG_ERROR
+ } EVR_STATS_MSG;
+
+ #pragma pack(push, 1)
+
+ template<int texcoords>
+ struct MYD3DVERTEX {float x, y, z, rhw; struct {float u, v;} t[texcoords];};
+
+ template<>
+ struct MYD3DVERTEX<0>
+ {
+ float x, y, z, rhw;
+ DWORD Diffuse;
+ };
+
+ #pragma pack(pop)
+
+ class CGenlock;
+ class CSyncRenderer;
+
+ // Base allocator-presenter
+ class CBaseAP:
+ public ISubPicAllocatorPresenterImpl
+ {
+ protected:
+ CMPlayerCApp::Settings::CRendererSettingsEVR m_LastRendererSettings;
+
+ HMODULE m_hDWMAPI;
+ HRESULT (__stdcall * m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
+ HRESULT (__stdcall * m_pDwmEnableComposition)(UINT uCompositionAction);
+ HMODULE m_hD3D9;
+ HRESULT (__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
+
+ CCritSec m_allocatorLock;
+ CComPtr<IDirect3D9Ex> m_pD3DEx;
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+
+ CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_PICTURE_SLOTS];
+ CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_PICTURE_SLOTS];
+ CComPtr<IDirect3DTexture9> m_pOSDTexture;
+ CComPtr<IDirect3DSurface9> m_pOSDSurface;
+ CComPtr<ID3DXLine> m_pLine;
+ CComPtr<ID3DXFont> m_pFont;
+ CComPtr<ID3DXSprite> m_pSprite;
+ CSyncRenderer *m_pOuterEVR;
+
+ class CExternalPixelShader
+ {
+ public:
+ CComPtr<IDirect3DPixelShader9> m_pPixelShader;
+ CStringA m_SourceData;
+ CStringA m_SourceTarget;
+ HRESULT Compile(CPixelShaderCompiler *pCompiler)
+ {
+ HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
+ if(FAILED(hr)) return hr;
+ return S_OK;
+ }
+ };
+
+ CAutoPtr<CPixelShaderCompiler> m_pPSC;
+ CAtlList<CExternalPixelShader> m_pPixelShaders;
+ CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
+ CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
+ CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
+
+ D3DFORMAT m_SurfaceType;
+ D3DFORMAT m_BackbufferType;
+ D3DFORMAT m_DisplayType;
+ D3DTEXTUREFILTERTYPE m_filter;
+ D3DCAPS9 m_caps;
+ D3DPRESENT_PARAMETERS pp;
+
+ bool SettingsNeedResetDevice();
+ virtual HRESULT CreateDXDevice(CString &_Error);
+ virtual HRESULT ResetDXDevice(CString &_Error);
+ virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
+ virtual void DeleteSurfaces();
+
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ UINT GetAdapter(IDirect3D9 *pD3D);
+
+ float m_bicubicA;
+ HRESULT InitResizers(float bicubicA, bool bNeedScreenSizeTexture);
+
+ // Functions to trace timing performance
+ void SyncStats(LONGLONG syncTime);
+ void SyncOffsetStats(LONGLONG syncOffset);
+ void DrawText(const RECT &rc, const CString &strText, int _Priority);
+ void DrawStats();
+
+ template<int texcoords>
+ void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy);
+ template<int texcoords>
+ HRESULT TextureBlt(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter);
+ MFOffset GetOffset(float v);
+ MFVideoArea GetArea(float x, float y, DWORD width, DWORD height);
+ bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d);
+
+ HRESULT DrawRectBase(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<0> v[4]);
+ HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
+ HRESULT TextureCopy(CComPtr<IDirect3DTexture9> pTexture);
+ HRESULT TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect);
+ HRESULT TextureResizeBilinear(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
+ HRESULT TextureResizeBicubic1pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
+ HRESULT TextureResizeBicubic2pass(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], const CRect &SrcRect);
+
+ typedef HRESULT (WINAPI * D3DXLoadSurfaceFromMemoryPtr)(
+ LPDIRECT3DSURFACE9 pDestSurface,
+ CONST PALETTEENTRY* pDestPalette,
+ CONST RECT* pDestRect,
+ LPCVOID pSrcMemory,
+ D3DFORMAT SrcFormat,
+ UINT SrcPitch,
+ CONST PALETTEENTRY* pSrcPalette,
+ CONST RECT* pSrcRect,
+ DWORD Filter,
+ D3DCOLOR ColorKey);
+
+ typedef HRESULT (WINAPI* D3DXCreateLinePtr)
+ (LPDIRECT3DDEVICE9 pDevice,
+ LPD3DXLINE* ppLine);
+
+ typedef HRESULT (WINAPI* D3DXCreateFontPtr)(
+ LPDIRECT3DDEVICE9 pDevice,
+ int Height,
+ UINT Width,
+ UINT Weight,
+ UINT MipLevels,
+ bool Italic,
+ DWORD CharSet,
+ DWORD OutputPrecision,
+ DWORD Quality,
+ DWORD PitchAndFamily,
+ LPCWSTR pFaceName,
+ LPD3DXFONT* ppFont);
+
+ HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture);
+
+ virtual void OnResetDevice() {};
+ virtual bool ResetDevice();
+
+ int m_nTearingPos;
+ VMR9AlphaBitmap m_VMR9AlphaBitmap;
+ CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
+ CRect m_VMR9AlphaBitmapRect;
+ int m_VMR9AlphaBitmapWidthBytes;
+
+ D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
+ D3DXCreateLinePtr m_pD3DXCreateLine;
+ D3DXCreateFontPtr m_pD3DXCreateFont;
+ HRESULT (__stdcall *m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE * ppSprite);
+
+ int m_nDXSurface; // Total number of DX Surfaces
+ int m_nVMR9Surfaces;
+ int m_iVMR9Surface;
+ int m_nCurSurface; // Surface currently displayed
+ long m_nUsedBuffer;
+ bool m_bNeedPendingResetDevice;
+ bool m_bPendingResetDevice;
+
+ LONG m_lNextSampleWait; // Waiting time for next sample in EVR
+ bool m_bSnapToVSync; // True if framerate is low enough so that snap to vsync makes sense
+
+ UINT m_uScanLineEnteringPaint; // The active scan line when entering Paint()
+ REFERENCE_TIME m_llEstVBlankTime; // Next vblank start time in reference clock "coordinates"
+
+ double m_fAvrFps; // Estimate the true FPS as given by the distance between vsyncs when a frame has been presented
+ double m_fJitterStdDev; // VSync estimate std dev
+ double m_fJitterMean; // Mean time between two syncpulses when a frame has been presented (i.e. when Paint() has been called
+
+ double m_fSyncOffsetAvr; // Mean time between the call of Paint() and vsync. To avoid tearing this should be several ms at least
+ double m_fSyncOffsetStdDev; // The std dev of the above
+
+ bool m_bHighColorResolution;
+ bool m_bCompositionEnabled;
+ bool m_bDesktopCompositionDisabled;
+ bool m_bIsFullscreen;
+ bool m_bNeedCheckSample;
+ DWORD m_dMainThreadId;
+
+ CSize m_ScreenSize;
+
+ // Display and frame rates and cycles
+ double m_dDetectedScanlineTime; // Time for one (horizontal) scan line. Extracted at stream start and used to calculate vsync time
+ UINT m_uD3DRefreshRate; // As got when creating the d3d device
+ double m_dD3DRefreshCycle; // Display refresh cycle ms
+ double m_dEstRefreshCycle; // As estimated from scan lines
+ double m_dFrameCycle; // Average sample time, extracted from the samples themselves
+ // double m_fps is defined in ISubPic.h
+ double m_dOptimumDisplayCycle; // The display cycle that is closest to the frame rate. A multiple of the actual display cycle
+ double m_dCycleDifference; // Difference in video and display cycle time relative to the video cycle time
+
+ UINT m_pcFramesDropped;
+ UINT m_pcFramesDuplicated;
+ UINT m_pcFramesDrawn;
+
+ LONGLONG m_pllJitter [NB_JITTER]; // Vertical sync time stats
+ LONGLONG m_pllSyncOffset [NB_JITTER]; // Sync offset time stats
+ int m_nNextJitter;
+ int m_nNextSyncOffset;
+ LONGLONG m_JitterStdDev;
+
+ LONGLONG m_llLastSyncTime;
+
+ LONGLONG m_MaxJitter;
+ LONGLONG m_MinJitter;
+ LONGLONG m_MaxSyncOffset;
+ LONGLONG m_MinSyncOffset;
+ UINT m_uSyncGlitches;
+
+ LONGLONG m_llSampleTime, m_llLastSampleTime; // Present time for the current sample
+ LONG m_lSampleLatency, m_lLastSampleLatency; // Time between intended and actual presentation time
+ LONG m_lMinSampleLatency, m_lLastMinSampleLatency;
+ LONGLONG m_llHysteresis;
+ LONG m_lHysteresis;
+ LONG m_lShiftToNearest, m_lShiftToNearestPrev;
+ bool m_bVideoSlowerThanDisplay;
+
+ int m_bInterlaced;
+ double m_TextScale;
+ CString m_strStatsMsg[10];
+
+ CGenlock *m_pGenlock; // The video - display synchronizer class
+ CComPtr<IReferenceClock> m_pRefClock; // The reference clock. Used in Paint()
+ CComPtr<IAMAudioRendererStats> m_pAudioStats; // Audio statistics from audio renderer. To check so that audio is in sync
+ DWORD m_lAudioLag; // Time difference between audio and video when the audio renderer is matching rate to the external reference clock
+ long m_lAudioLagMin, m_lAudioLagMax; // The accumulated difference between the audio renderer and the master clock
+ DWORD m_lAudioSlaveMode; // To check whether the audio renderer matches rate with SyncClock (returns the value 4 if it does)
+
+ double GetRefreshRate(); // Get the best estimate of the display refresh rate in Hz
+ double GetDisplayCycle(); // Get the best estimate of the display cycle time in milliseconds
+ double GetCycleDifference(); // Get the difference in video and display cycle times.
+ void EstimateRefreshTimings(); // Estimate the times for one scan line and one frame respectively from the actual refresh data
+ bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt);
+
+ public:
+ CBaseAP(HWND hWnd, HRESULT& hr, CString &_Error);
+ ~CBaseAP();
+
+ CCritSec m_VMR9AlphaBitmapLock;
+ void UpdateAlphaBitmap();
+ void ResetStats();
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ };
+
+ class CSyncAP:
+ public CBaseAP,
+ public IMFGetService,
+ public IMFTopologyServiceLookupClient,
+ public IMFVideoDeviceID,
+ public IMFVideoPresenter,
+ public IDirect3DDeviceManager9,
+ public IMFAsyncCallback,
+ public IQualProp,
+ public IMFRateSupport,
+ public IMFVideoDisplayControl,
+ public IEVRTrustedVideoPlugin
+
+ {
+ public:
+ CSyncAP(HWND hWnd, HRESULT& hr, CString &_Error);
+ ~CSyncAP(void);
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
+
+ // IMFClockStateSink
+ STDMETHODIMP OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockStop(MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockPause(MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockSetRate(MFTIME hnsSystemTime, float flRate);
+
+ // IBaseFilter delegate
+ bool GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue);
+
+ // IQualProp (EVR statistics window). These are incompletely implemented currently
+ STDMETHODIMP get_FramesDroppedInRenderer(int *pcFrames);
+ STDMETHODIMP get_FramesDrawn(int *pcFramesDrawn);
+ STDMETHODIMP get_AvgFrameRate(int *piAvgFrameRate);
+ STDMETHODIMP get_Jitter(int *iJitter);
+ STDMETHODIMP get_AvgSyncOffset(int *piAvg);
+ STDMETHODIMP get_DevSyncOffset(int *piDev);
+
+ // IMFRateSupport
+ STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
+ STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
+ STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate);
+ float GetMaxRate(BOOL bThin);
+
+ // IMFVideoPresenter
+ STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
+ STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType);
+
+ // IMFTopologyServiceLookupClient
+ STDMETHODIMP InitServicePointers(__in IMFTopologyServiceLookup *pLookup);
+ STDMETHODIMP ReleaseServicePointers();
+
+ // IMFVideoDeviceID
+ STDMETHODIMP GetDeviceID(__out IID *pDeviceID);
+
+ // IMFGetService
+ STDMETHODIMP GetService (__RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID *ppvObject);
+
+ // IMFAsyncCallback
+ STDMETHODIMP GetParameters(__RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue);
+ STDMETHODIMP Invoke(__RPC__in_opt IMFAsyncResult *pAsyncResult);
+
+ // IMFVideoDisplayControl
+ STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo);
+ STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax);
+ STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest);
+ STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest);
+ STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
+ STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode);
+ STDMETHODIMP SetVideoWindow(HWND hwndVideo);
+ STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
+ STDMETHODIMP RepaintVideo( void);
+ STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF *pClr);
+ STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
+ STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags);
+ STDMETHODIMP SetFullscreen(BOOL fFullscreen);
+ STDMETHODIMP GetFullscreen(BOOL *pfFullscreen);
+
+ // IEVRTrustedVideoPlugin
+ STDMETHODIMP IsInTrustedVideoMode(BOOL *pYes);
+ STDMETHODIMP CanConstrict(BOOL *pYes);
+ STDMETHODIMP SetConstriction(DWORD dwKPix);
+ STDMETHODIMP DisableImageExport(BOOL bDisable);
+
+ // IDirect3DDeviceManager9
+ STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
+ STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
+ STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
+ STDMETHODIMP TestDevice(HANDLE hDevice);
+ STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
+ STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
+ STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void **ppService);
+
+ protected:
+ void OnResetDevice();
+ MFCLOCK_STATE m_LastClockState;
+
+ private:
+ // dxva.dll
+ typedef HRESULT (__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
+ // mf.dll
+ typedef HRESULT (__stdcall *PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
+ // evr.dll
+ typedef HRESULT (__stdcall *PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
+ typedef HRESULT (__stdcall *PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
+ typedef HRESULT (__stdcall *PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
+ // avrt.dll
+ typedef HANDLE (__stdcall *PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
+ typedef BOOL (__stdcall *PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
+ typedef BOOL (__stdcall *PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
+
+ typedef enum
+ {
+ Started = State_Running,
+ Stopped = State_Stopped,
+ Paused = State_Paused,
+ Shutdown = State_Running + 1
+ } RENDER_STATE;
+
+ CComPtr<IMFClock> m_pClock;
+ CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
+ CComPtr<IMFTransform> m_pMixer;
+ CComPtr<IMediaEventSink> m_pSink;
+ CComPtr<IMFVideoMediaType> m_pMediaType;
+ MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
+ MFVideoRenderPrefs m_dwVideoRenderPrefs;
+ COLORREF m_BorderColor;
+
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ bool m_bEvtQuit;
+ HANDLE m_hEvtFlush; // Discard all buffers
+ bool m_bEvtFlush;
+ HANDLE m_hEvtSkip; // Skip frame
+ bool m_bEvtSkip;
+
+ bool m_bUseInternalTimer;
+ int32 m_LastSetOutputRange;
+ bool m_bPendingRenegotiate;
+ bool m_bPendingMediaFinished;
+ bool m_bPrerolled; // true if first sample has been displayed.
+
+ HANDLE m_hRenderThread;
+ HANDLE m_hMixerThread;
+ RENDER_STATE m_nRenderState;
+ bool m_bStepping;
+
+ CCritSec m_SampleQueueLock;
+ CCritSec m_ImageProcessingLock;
+
+ CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
+ CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
+ IMFSample *m_pCurrentDisplaydSample;
+ UINT m_nResetToken;
+ int m_nStepCount;
+
+ bool GetSampleFromMixer();
+ void MixerThread();
+ static DWORD WINAPI MixerThreadStatic(LPVOID lpParam);
+ void RenderThread();
+ static DWORD WINAPI RenderThreadStatic(LPVOID lpParam);
+
+ void StartWorkerThreads();
+ void StopWorkerThreads();
+ HRESULT CheckShutdown() const;
+ void CompleteFrameStep(bool bCancel);
+
+ void RemoveAllSamples();
+ HRESULT BeginStreaming();
+ HRESULT GetFreeSample(IMFSample** ppSample);
+ HRESULT GetScheduledSample(IMFSample** ppSample, int &_Count);
+ void MoveToFreeList(IMFSample* pSample, bool bTail);
+ void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
+ void FlushSamples();
+ void FlushSamplesInternal();
+
+ LONGLONG GetMediaTypeMerit(IMFMediaType *pMediaType);
+ HRESULT RenegotiateMediaType();
+ HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
+ HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
+ HRESULT SetMediaType(IMFMediaType* pType);
+
+ // Functions pointers for Vista/.NET3 specific library
+ PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
+ PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
+ PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
+ PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
+
+ PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
+ PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
+ PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
+ };
+
+ class CSyncRenderer:
+ public CUnknown,
+ public IVMRffdshow9,
+ public IVMRMixerBitmap9,
+ public IBaseFilter
+ {
+ CComPtr<IUnknown> m_pEVR;
+ VMR9AlphaBitmap *m_pVMR9AlphaBitmap;
+ CSyncAP *m_pAllocatorPresenter;
+
+ public:
+ CSyncRenderer(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CSyncAP *pAllocatorPresenter);
+ ~CSyncRenderer();
+
+ // IBaseFilter
+ virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum);
+ virtual HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, __out IPin **ppPin);
+ virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo);
+ virtual HRESULT STDMETHODCALLTYPE JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName);
+ virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo);
+ virtual HRESULT STDMETHODCALLTYPE Stop(void);
+ virtual HRESULT STDMETHODCALLTYPE Pause(void);
+ virtual HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
+ virtual HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
+ virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock);
+ virtual HRESULT STDMETHODCALLTYPE GetSyncSource(__deref_out_opt IReferenceClock **pClock);
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID);
+
+ // IVMRffdshow9
+ virtual HRESULT STDMETHODCALLTYPE support_ffdshow();
+
+ // IVMRMixerBitmap9
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
+ STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
+ STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
+
+ DECLARE_IUNKNOWN;
+ virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid, void** ppvObject);
+ };
+
+ class CGenlock
+ {
+ public:
+ class MovingAverage
+ {
+ public:
+ MovingAverage(INT size):
+ fifoSize(size),
+ oldestSample(0),
+ sum(0)
+ {
+ if (fifoSize > MAX_FIFO_SIZE)
+ {
+ fifoSize = MAX_FIFO_SIZE;
+ }
+ for (INT i = 0; i < MAX_FIFO_SIZE; i++)
+ fifo[i] = 0;
+ }
+
+ ~MovingAverage()
+ {
+ }
+
+ double Average(double sample)
+ {
+ sum = sum + sample - fifo[oldestSample];
+ fifo[oldestSample] = sample;
+ oldestSample++;
+ if (oldestSample == fifoSize)
+ oldestSample = 0;
+ return sum / fifoSize;
+ }
+
+ private:
+ INT fifoSize;
+ double fifo[MAX_FIFO_SIZE];
+ INT oldestSample;
+ double sum;
+ };
+
+ CGenlock(DOUBLE target, DOUBLE limit, INT rowD, INT colD, DOUBLE clockD, UINT mon);
+ ~CGenlock();
+
+ BOOL PowerstripRunning(); // TRUE if PowerStrip is running
+ HRESULT GetTiming(); // Get the string representing the display's current timing parameters
+ HRESULT ResetTiming(); // Reset timing to what was last registered by GetTiming()
+ HRESULT ResetClock(); // Reset reference clock speed to nominal
+ HRESULT SetTargetSyncOffset(DOUBLE targetD);
+ HRESULT GetTargetSyncOffset(DOUBLE *targetD);
+ HRESULT SetControlLimit(DOUBLE cL);
+ HRESULT GetControlLimit(DOUBLE *cL);
+ HRESULT SetDisplayResolution(UINT columns, UINT lines);
+ HRESULT AdviseSyncClock(CComPtr<ISyncClock> sC);
+ HRESULT SetMonitor(UINT mon); // Set the number of the monitor to synchronize
+ HRESULT ResetStats(); // Reset timing statistics
+
+ HRESULT ControlDisplay(double syncOffset, double frameCycle); // Adjust the frequency of the display if needed
+ HRESULT ControlClock(double syncOffset, double frameCycle); // Adjust the frequency of the clock if needed
+ HRESULT UpdateStats(double syncOffset, double frameCycle); // Don't adjust anything, just update the syncOffset stats
+
+ BOOL powerstripTimingExists; // TRUE if display timing has been got through Powerstrip
+ BOOL liveSource; // TRUE if live source -> display sync is the only option
+ INT adjDelta; // -1 for display slower in relation to video, 0 for keep, 1 for faster
+ INT lineDelta; // The number of rows added or subtracted when adjusting display fps
+ INT columnDelta; // The number of colums added or subtracted when adjusting display fps
+ DOUBLE cycleDelta; // Adjustment factor for cycle time as fraction of nominal value
+ UINT displayAdjustmentsMade; // The number of adjustments made to display refresh rate
+ UINT clockAdjustmentsMade; // The number of adjustments made to clock frequency
+
+ UINT totalLines, totalColumns; // Including the porches and sync widths
+ UINT visibleLines, visibleColumns; // The nominal resolution
+ MovingAverage *syncOffsetFifo;
+ MovingAverage *frameCycleFifo;
+ DOUBLE minSyncOffset, maxSyncOffset;
+ DOUBLE syncOffsetAvg; // Average of the above
+ DOUBLE minFrameCycle, maxFrameCycle;
+ DOUBLE frameCycleAvg;
+
+ UINT pixelClock; // In pixels/s
+ DOUBLE displayFreqCruise; // Nominal display frequency in frames/s
+ DOUBLE displayFreqSlower;
+ DOUBLE displayFreqFaster;
+ DOUBLE curDisplayFreq; // Current (adjusted) display frequency
+ DOUBLE controlLimit; // How much the sync offset is allowed to drift from target sync offset
+ WPARAM monitor; // The monitor to be controlled. 0-based.
+ CComPtr<ISyncClock> syncClock; // Interface to an adjustable reference clock
+
+ private:
+ HWND psWnd; // PowerStrip window
+ const static INT TIMING_PARAM_CNT = 10;
+ const static INT MAX_LOADSTRING = 100;
+ UINT displayTiming[TIMING_PARAM_CNT]; // Display timing parameters
+ UINT displayTimingSave[TIMING_PARAM_CNT]; // So that we can reset the display at exit
+ TCHAR faster[MAX_LOADSTRING]; // String corresponding to faster display frequency
+ TCHAR cruise[MAX_LOADSTRING]; // String corresponding to nominal display frequency
+ TCHAR slower[MAX_LOADSTRING]; // String corresponding to slower display frequency
+ TCHAR savedTiming[MAX_LOADSTRING]; // String version of saved timing (to be restored upon exit)
+ DOUBLE lowSyncOffset; // The closest we want to let the scheduled render time to get to the next vsync. In % of the frame time
+ DOUBLE targetSyncOffset; // Where we want the scheduled render time to be in relation to the next vsync
+ DOUBLE highSyncOffset; // The furthers we want to let the scheduled render time to get to the next vsync
+ CCritSec csGenlockLock;
+ };
}
diff --git a/src/apps/mplayerc/TextPassThruFilter.cpp b/src/apps/mplayerc/TextPassThruFilter.cpp
index ab408588d..eae5d94d2 100644
--- a/src/apps/mplayerc/TextPassThruFilter.cpp
+++ b/src/apps/mplayerc/TextPassThruFilter.cpp
@@ -37,33 +37,33 @@
class CTextPassThruInputPin : public CSubtitleInputPin
{
- CTextPassThruFilter* m_pTPTFilter;
- CComPtr<ISubStream> m_pSubStreamOld;
+ CTextPassThruFilter* m_pTPTFilter;
+ CComPtr<ISubStream> m_pSubStreamOld;
protected:
- void AddSubStream(ISubStream* pSubStream)
- {
- if(m_pSubStreamOld)
- {
- if(pSubStream) m_pTPTFilter->m_pMainFrame->ReplaceSubtitle(m_pSubStreamOld, pSubStream);
- m_pSubStreamOld = NULL;
- }
- }
-
- void RemoveSubStream(ISubStream* pSubStream)
- {
- m_pSubStreamOld = pSubStream;
- }
-
- void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream)
- {
- m_pTPTFilter->m_pMainFrame->InvalidateSubtitle((DWORD_PTR)pSubStream, rtStart);
- }
+ void AddSubStream(ISubStream* pSubStream)
+ {
+ if(m_pSubStreamOld)
+ {
+ if(pSubStream) m_pTPTFilter->m_pMainFrame->ReplaceSubtitle(m_pSubStreamOld, pSubStream);
+ m_pSubStreamOld = NULL;
+ }
+ }
+
+ void RemoveSubStream(ISubStream* pSubStream)
+ {
+ m_pSubStreamOld = pSubStream;
+ }
+
+ void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream)
+ {
+ m_pTPTFilter->m_pMainFrame->InvalidateSubtitle((DWORD_PTR)pSubStream, rtStart);
+ }
public:
CTextPassThruInputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- STDMETHODIMP Receive(IMediaSample* pSample);
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ STDMETHODIMP Receive(IMediaSample* pSample);
STDMETHODIMP EndOfStream();
STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush();
@@ -75,156 +75,151 @@ public:
class CTextPassThruOutputPin : public CBaseOutputPin
{
- CTextPassThruFilter* m_pTPTFilter;
+ CTextPassThruFilter* m_pTPTFilter;
public:
CTextPassThruOutputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, HRESULT* phr);
HRESULT CheckMediaType(const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q)
- {
- return S_OK;
- }
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q) {return S_OK;}
};
///////////
CTextPassThruInputPin::CTextPassThruInputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr)
- : CSubtitleInputPin(pTPTFilter, pLock, pSubLock, phr)
- , m_pTPTFilter(pTPTFilter)
+ : CSubtitleInputPin(pTPTFilter, pLock, pSubLock, phr)
+ , m_pTPTFilter(pTPTFilter)
{
}
STDMETHODIMP CTextPassThruInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- HRESULT hr = __super::NewSegment(tStart, tStop, dRate);
- if(FAILED(hr)) return hr;
- return m_pTPTFilter->m_pOutput->DeliverNewSegment(tStart, tStop, dRate);
+ HRESULT hr = __super::NewSegment(tStart, tStop, dRate);
+ if(FAILED(hr)) return hr;
+ return m_pTPTFilter->m_pOutput->DeliverNewSegment(tStart, tStop, dRate);
}
STDMETHODIMP CTextPassThruInputPin::Receive(IMediaSample* pSample)
{
- HRESULT hr = __super::Receive(pSample);
- if(FAILED(hr)) return hr;
- return m_pTPTFilter->m_pOutput->Deliver(pSample);
+ HRESULT hr = __super::Receive(pSample);
+ if(FAILED(hr)) return hr;
+ return m_pTPTFilter->m_pOutput->Deliver(pSample);
}
STDMETHODIMP CTextPassThruInputPin::EndOfStream()
{
- HRESULT hr = __super::EndOfStream();
- if(FAILED(hr)) return hr;
- return m_pTPTFilter->m_pOutput->DeliverEndOfStream();
+ HRESULT hr = __super::EndOfStream();
+ if(FAILED(hr)) return hr;
+ return m_pTPTFilter->m_pOutput->DeliverEndOfStream();
}
STDMETHODIMP CTextPassThruInputPin::BeginFlush()
{
- HRESULT hr = __super::BeginFlush();
- if(FAILED(hr)) return hr;
- return m_pTPTFilter->m_pOutput->DeliverBeginFlush();
+ HRESULT hr = __super::BeginFlush();
+ if(FAILED(hr)) return hr;
+ return m_pTPTFilter->m_pOutput->DeliverBeginFlush();
}
STDMETHODIMP CTextPassThruInputPin::EndFlush()
{
- HRESULT hr = __super::EndFlush();
- if(FAILED(hr)) return hr;
- return m_pTPTFilter->m_pOutput->DeliverEndFlush();
+ HRESULT hr = __super::EndFlush();
+ if(FAILED(hr)) return hr;
+ return m_pTPTFilter->m_pOutput->DeliverEndFlush();
}
//
CTextPassThruOutputPin::CTextPassThruOutputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(NAME(""), pTPTFilter, pLock, phr, L"Out")
- , m_pTPTFilter(pTPTFilter)
+ : CBaseOutputPin(NAME(""), pTPTFilter, pLock, phr, L"Out")
+ , m_pTPTFilter(pTPTFilter)
{
}
HRESULT CTextPassThruOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- CMediaType mt;
- return S_OK == m_pTPTFilter->m_pInput->ConnectionMediaType(&mt) && mt == *mtOut
- ? S_OK
- : E_FAIL;
+ CMediaType mt;
+ return S_OK == m_pTPTFilter->m_pInput->ConnectionMediaType(&mt) && mt == *mtOut
+ ? S_OK
+ : E_FAIL;
}
HRESULT CTextPassThruOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pTPTFilter->m_pInput->IsConnected() == FALSE)
- return E_UNEXPECTED;
+ if(m_pTPTFilter->m_pInput->IsConnected() == FALSE)
+ return E_UNEXPECTED;
- CComPtr<IMemAllocator> pAllocatorIn;
- m_pTPTFilter->m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ CComPtr<IMemAllocator> pAllocatorIn;
+ m_pTPTFilter->m_pInput->GetAllocator(&pAllocatorIn);
+ if(!pAllocatorIn) return E_UNEXPECTED;
- pAllocatorIn->GetProperties(pProperties);
+ pAllocatorIn->GetProperties(pProperties);
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
- return hr;
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ return hr;
- return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CTextPassThruOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pTPTFilter->m_pInput->IsConnected() == FALSE)
- return E_UNEXPECTED;
+ if(m_pTPTFilter->m_pInput->IsConnected() == FALSE)
+ return E_UNEXPECTED;
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) return E_INVALIDARG;
+ if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
- m_pTPTFilter->m_pInput->ConnectionMediaType(pmt);
+ m_pTPTFilter->m_pInput->ConnectionMediaType(pmt);
- return S_OK;
+ return S_OK;
}
//
// CTextPassThruFilter
//
-CTextPassThruFilter::CTextPassThruFilter(CMainFrame* pMainFrame)
- : CBaseFilter(NAME("CTextPassThruFilter"), NULL, this, __uuidof(this))
- , m_pMainFrame(pMainFrame)
+CTextPassThruFilter::CTextPassThruFilter(CMainFrame* pMainFrame)
+ : CBaseFilter(NAME("CTextPassThruFilter"), NULL, this, __uuidof(this))
+ , m_pMainFrame(pMainFrame)
{
- HRESULT hr;
- m_pInput = DNew CTextPassThruInputPin(this, this, &m_pMainFrame->m_csSubLock, &hr);
- m_pOutput = DNew CTextPassThruOutputPin(this, this, &hr);
+ HRESULT hr;
+ m_pInput = DNew CTextPassThruInputPin(this, this, &m_pMainFrame->m_csSubLock, &hr);
+ m_pOutput = DNew CTextPassThruOutputPin(this, this, &hr);
}
CTextPassThruFilter::~CTextPassThruFilter()
{
- delete m_pInput;
- m_pInput = NULL;
- delete m_pOutput;
- m_pOutput = NULL;
+ delete m_pInput; m_pInput = NULL;
+ delete m_pOutput; m_pOutput = NULL;
}
STDMETHODIMP CTextPassThruFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if(m_pInput && riid == __uuidof(ISubStream))
- {
- if(CComPtr<ISubStream> pSubStream = m_pInput->GetSubStream())
- {
- *ppv = pSubStream.Detach();
- return S_OK;
- }
- }
+ if(m_pInput && riid == __uuidof(ISubStream))
+ {
+ if(CComPtr<ISubStream> pSubStream = m_pInput->GetSubStream())
+ {
+ *ppv = pSubStream.Detach();
+ return S_OK;
+ }
+ }
- return __super::NonDelegatingQueryInterface(riid, ppv);
+ return __super::NonDelegatingQueryInterface(riid, ppv);
}
int CTextPassThruFilter::GetPinCount()
{
- return 2;
+ return 2;
}
CBasePin* CTextPassThruFilter::GetPin(int n)
{
- if(n == 0) return m_pInput;
- else if(n == 1) return m_pOutput;
- return NULL;
+ if(n == 0) return m_pInput;
+ else if(n == 1) return m_pOutput;
+ return NULL;
}
diff --git a/src/apps/mplayerc/TextPassThruFilter.h b/src/apps/mplayerc/TextPassThruFilter.h
index 42fcdfc62..8b34af267 100644
--- a/src/apps/mplayerc/TextPassThruFilter.h
+++ b/src/apps/mplayerc/TextPassThruFilter.h
@@ -28,21 +28,21 @@ class CTextPassThruInputPin;
[uuid("E2BA9B7B-B65D-4804-ACB2-89C3E55511DB")]
class CTextPassThruFilter : public CBaseFilter, public CCritSec
{
- friend class CTextPassThruInputPin;
- friend class CTextPassThruOutputPin;
+ friend class CTextPassThruInputPin;
+ friend class CTextPassThruOutputPin;
- CTextPassThruInputPin* m_pInput;
- CTextPassThruOutputPin* m_pOutput;
+ CTextPassThruInputPin* m_pInput;
+ CTextPassThruOutputPin* m_pOutput;
- CMainFrame* m_pMainFrame;
+ CMainFrame* m_pMainFrame;
public:
- CTextPassThruFilter(CMainFrame* pMainFrame);
- virtual ~CTextPassThruFilter();
+ CTextPassThruFilter(CMainFrame* pMainFrame);
+ virtual ~CTextPassThruFilter();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- int GetPinCount();
- CBasePin* GetPin(int n);
+ int GetPinCount();
+ CBasePin* GetPin(int n);
};
diff --git a/src/apps/mplayerc/TunerScanDlg.cpp b/src/apps/mplayerc/TunerScanDlg.cpp
index dab09bba2..bae4cb0c9 100644
--- a/src/apps/mplayerc/TunerScanDlg.cpp
+++ b/src/apps/mplayerc/TunerScanDlg.cpp
@@ -31,10 +31,10 @@
enum TSC_COLUMN
{
- TSCC_NUMBER,
- TSCC_NAME,
- TSCC_FREQUENCY,
- TSCC_CHANNEL
+ TSCC_NUMBER,
+ TSCC_NAME,
+ TSCC_FREQUENCY,
+ TSCC_CHANNEL
};
// CTunerScanDlg dialog
@@ -42,11 +42,11 @@ enum TSC_COLUMN
IMPLEMENT_DYNAMIC(CTunerScanDlg, CDialog)
CTunerScanDlg::CTunerScanDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CTunerScanDlg::IDD, pParent)
- , m_ulFrequencyStart(474000)
- , m_ulFrequencyEnd(858000)
- , m_ulBandwidth(8000)
- , m_bInProgress(false)
+ : CDialog(CTunerScanDlg::IDD, pParent)
+ , m_ulFrequencyStart(474000)
+ , m_ulFrequencyEnd(858000)
+ , m_ulBandwidth(8000)
+ , m_bInProgress(false)
{
}
@@ -56,46 +56,46 @@ CTunerScanDlg::~CTunerScanDlg()
BOOL CTunerScanDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
+ CDialog::OnInitDialog();
+
+ m_ChannelList.InsertColumn(TSCC_NUMBER, _T("N°"), LVCFMT_LEFT, 50);
+ m_ChannelList.InsertColumn(TSCC_NAME, _T("Name"), LVCFMT_LEFT, 250);
+ m_ChannelList.InsertColumn(TSCC_FREQUENCY, _T("Frequency"), LVCFMT_LEFT, 100);
+ m_ChannelList.InsertColumn(TSCC_CHANNEL, _T("Channel"), LVCFMT_LEFT, 0);
- m_ChannelList.InsertColumn(TSCC_NUMBER, _T("N°"), LVCFMT_LEFT, 50);
- m_ChannelList.InsertColumn(TSCC_NAME, _T("Name"), LVCFMT_LEFT, 250);
- m_ChannelList.InsertColumn(TSCC_FREQUENCY, _T("Frequency"), LVCFMT_LEFT, 100);
- m_ChannelList.InsertColumn(TSCC_CHANNEL, _T("Channel"), LVCFMT_LEFT, 0);
+ m_Progress.SetRange(0, 100);
+ m_Strength.SetRange(0, 100);
+ m_Quality.SetRange(0, 100);
+ m_btnSave.EnableWindow(FALSE);
- m_Progress.SetRange(0, 100);
- m_Strength.SetRange(0, 100);
- m_Quality.SetRange(0, 100);
- m_btnSave.EnableWindow(FALSE);
-
- return TRUE;
+ return TRUE;
}
void CTunerScanDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_FREQ_START, m_ulFrequencyStart);
- DDX_Text(pDX, IDC_FREQ_END, m_ulFrequencyEnd);
- DDX_Text(pDX, IDC_BANDWIDTH, m_ulBandwidth);
- DDX_Control(pDX, IDC_PROGRESS, m_Progress);
- DDX_Control(pDX, IDC_STRENGTH, m_Strength);
- DDX_Control(pDX, IDC_QUALITY, m_Quality);
- DDX_Control(pDX, IDC_CHANNEL_LIST, m_ChannelList);
- DDX_Control(pDX, ID_START, m_btnStart);
- DDX_Control(pDX, ID_SAVE, m_btnSave);
- DDX_Control(pDX, IDCANCEL, m_btnCancel);
+ CDialog::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_FREQ_START, m_ulFrequencyStart);
+ DDX_Text(pDX, IDC_FREQ_END, m_ulFrequencyEnd);
+ DDX_Text(pDX, IDC_BANDWIDTH, m_ulBandwidth);
+ DDX_Control(pDX, IDC_PROGRESS, m_Progress);
+ DDX_Control(pDX, IDC_STRENGTH, m_Strength);
+ DDX_Control(pDX, IDC_QUALITY, m_Quality);
+ DDX_Control(pDX, IDC_CHANNEL_LIST, m_ChannelList);
+ DDX_Control(pDX, ID_START, m_btnStart);
+ DDX_Control(pDX, ID_SAVE, m_btnSave);
+ DDX_Control(pDX, IDCANCEL, m_btnCancel);
}
BEGIN_MESSAGE_MAP(CTunerScanDlg, CDialog)
- ON_MESSAGE(WM_TUNER_SCAN_PROGRESS, OnScanProgress)
- ON_MESSAGE(WM_TUNER_SCAN_END, OnScanEnd)
- ON_MESSAGE(WM_TUNER_STATS, OnStats)
- ON_MESSAGE(WM_TUNER_NEW_CHANNEL, OnNewChannel)
- ON_BN_CLICKED(ID_SAVE, &CTunerScanDlg::OnBnClickedSave)
- ON_BN_CLICKED(ID_START, &CTunerScanDlg::OnBnClickedStart)
- ON_BN_CLICKED(IDCANCEL, &CTunerScanDlg::OnBnClickedCancel)
+ ON_MESSAGE(WM_TUNER_SCAN_PROGRESS, OnScanProgress)
+ ON_MESSAGE(WM_TUNER_SCAN_END, OnScanEnd)
+ ON_MESSAGE(WM_TUNER_STATS, OnStats)
+ ON_MESSAGE(WM_TUNER_NEW_CHANNEL, OnNewChannel)
+ ON_BN_CLICKED(ID_SAVE, &CTunerScanDlg::OnBnClickedSave)
+ ON_BN_CLICKED(ID_START, &CTunerScanDlg::OnBnClickedStart)
+ ON_BN_CLICKED(IDCANCEL, &CTunerScanDlg::OnBnClickedCancel)
END_MESSAGE_MAP()
@@ -103,106 +103,106 @@ END_MESSAGE_MAP()
void CTunerScanDlg::OnBnClickedSave()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.DVBChannels.RemoveAll();
+ s.DVBChannels.RemoveAll();
- for(int i = 0; i < m_ChannelList.GetItemCount(); i++)
- {
- CDVBChannel Channel;
- Channel.FromString(m_ChannelList.GetItemText(i, TSCC_CHANNEL));
- Channel.SetPrefNumber(i);
- s.DVBChannels.AddTail(Channel);
- }
+ for (int i=0;i <m_ChannelList.GetItemCount(); i++)
+ {
+ CDVBChannel Channel;
+ Channel.FromString (m_ChannelList.GetItemText (i, TSCC_CHANNEL));
+ Channel.SetPrefNumber(i);
+ s.DVBChannels.AddTail (Channel);
+ }
- OnOK();
+ OnOK();
}
void CTunerScanDlg::OnBnClickedStart()
{
- if(!m_bInProgress)
- {
- CAutoPtr<TunerScanData> pTSD(DNew TunerScanData);
- pTSD->Hwnd = m_hWnd;
- pTSD->FrequencyStart = m_ulFrequencyStart;
- pTSD->FrequencyStop = m_ulFrequencyEnd;
- pTSD->Bandwidth = m_ulBandwidth;
-
- m_ChannelList.DeleteAllItems();
- ((CMainFrame*)AfxGetMainWnd())->StartTunerScan(pTSD);
-
- SetProgress(true);
- }
- else
- ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
+ if (!m_bInProgress)
+ {
+ CAutoPtr<TunerScanData> pTSD (DNew TunerScanData);
+ pTSD->Hwnd = m_hWnd;
+ pTSD->FrequencyStart = m_ulFrequencyStart;
+ pTSD->FrequencyStop = m_ulFrequencyEnd;
+ pTSD->Bandwidth = m_ulBandwidth;
+
+ m_ChannelList.DeleteAllItems();
+ ((CMainFrame*)AfxGetMainWnd())->StartTunerScan (pTSD);
+
+ SetProgress (true);
+ }
+ else
+ ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
}
void CTunerScanDlg::OnBnClickedCancel()
{
- if(m_bInProgress)
- ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
+ if (m_bInProgress)
+ ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
- OnCancel();
+ OnCancel();
}
LRESULT CTunerScanDlg::OnScanProgress(WPARAM wParam, LPARAM lParam)
{
- m_Progress.SetPos(wParam);
- return TRUE;
+ m_Progress.SetPos(wParam);
+ return TRUE;
}
LRESULT CTunerScanDlg::OnScanEnd(WPARAM wParam, LPARAM lParam)
-{
- SetProgress(false);
- return TRUE;
+{
+ SetProgress (false);
+ return TRUE;
}
LRESULT CTunerScanDlg::OnStats(WPARAM wParam, LPARAM lParam)
{
- m_Strength.SetPos((int)wParam);
- m_Quality.SetPos((int)lParam);
- return TRUE;
+ m_Strength.SetPos ((int)wParam);
+ m_Quality.SetPos ((int)lParam);
+ return TRUE;
}
LRESULT CTunerScanDlg::OnNewChannel(WPARAM wParam, LPARAM lParam)
{
- CDVBChannel Channel;
- CString strTemp;
- int nItem;
- Channel.FromString((LPCTSTR) lParam);
-
- strTemp.Format(_T("%03d"), Channel.GetOriginNumber());
- nItem = m_ChannelList.InsertItem(m_ChannelList.GetItemCount(), strTemp);
-
- strTemp.Format(_T("%d"), m_ChannelList.GetItemCount());
- m_ChannelList.SetItemText(nItem, TSCC_NUMBER, strTemp);
-
- m_ChannelList.SetItemText(nItem, TSCC_NAME, Channel.GetName());
-
- strTemp.Format(_T("%d"), Channel.GetFrequency());
- m_ChannelList.SetItemText(nItem, TSCC_FREQUENCY, strTemp);
-
- m_ChannelList.SetItemText(nItem, TSCC_CHANNEL, (LPCTSTR) lParam);
-
-
- return TRUE;
+ CDVBChannel Channel;
+ CString strTemp;
+ int nItem;
+ Channel.FromString ((LPCTSTR) lParam);
+
+ strTemp.Format(_T("%03d"), Channel.GetOriginNumber());
+ nItem = m_ChannelList.InsertItem (m_ChannelList.GetItemCount(), strTemp);
+
+ strTemp.Format(_T("%d"), m_ChannelList.GetItemCount());
+ m_ChannelList.SetItemText (nItem, TSCC_NUMBER, strTemp);
+
+ m_ChannelList.SetItemText (nItem, TSCC_NAME, Channel.GetName());
+
+ strTemp.Format(_T("%d"), Channel.GetFrequency());
+ m_ChannelList.SetItemText (nItem, TSCC_FREQUENCY, strTemp);
+
+ m_ChannelList.SetItemText (nItem, TSCC_CHANNEL, (LPCTSTR) lParam);
+
+
+ return TRUE;
}
-void CTunerScanDlg::SetProgress(bool bState)
+void CTunerScanDlg::SetProgress (bool bState)
{
- if(bState)
- {
- m_btnStart.SetWindowTextW(_T("Stop"));
- m_btnSave.EnableWindow(FALSE);
- }
- else
- {
- m_btnStart.SetWindowTextW(_T("Start"));
- m_Progress.SetPos(0);
- m_btnSave.EnableWindow(TRUE);
- }
-
- m_bInProgress = bState;
+ if (bState)
+ {
+ m_btnStart.SetWindowTextW(_T("Stop"));
+ m_btnSave.EnableWindow(FALSE);
+ }
+ else
+ {
+ m_btnStart.SetWindowTextW(_T("Start"));
+ m_Progress.SetPos (0);
+ m_btnSave.EnableWindow(TRUE);
+ }
+
+ m_bInProgress = bState;
} \ No newline at end of file
diff --git a/src/apps/mplayerc/TunerScanDlg.h b/src/apps/mplayerc/TunerScanDlg.h
index ddce90601..43b58fa9e 100644
--- a/src/apps/mplayerc/TunerScanDlg.h
+++ b/src/apps/mplayerc/TunerScanDlg.h
@@ -29,40 +29,40 @@
class CTunerScanDlg : public CDialog
{
- DECLARE_DYNAMIC(CTunerScanDlg)
+ DECLARE_DYNAMIC(CTunerScanDlg)
public:
- CTunerScanDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CTunerScanDlg();
+ CTunerScanDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CTunerScanDlg();
// Dialog Data
- enum { IDD = IDD_TUNER_SCAN };
+ enum { IDD = IDD_TUNER_SCAN };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- void SetProgress(bool bState);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ void SetProgress (bool bState);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- ULONG m_ulFrequencyStart;
- ULONG m_ulFrequencyEnd;
- ULONG m_ulBandwidth;
- CProgressCtrl m_Progress;
- CProgressCtrl m_Strength;
- CProgressCtrl m_Quality;
- CListCtrl m_ChannelList;
- bool m_bInProgress;
+ ULONG m_ulFrequencyStart;
+ ULONG m_ulFrequencyEnd;
+ ULONG m_ulBandwidth;
+ CProgressCtrl m_Progress;
+ CProgressCtrl m_Strength;
+ CProgressCtrl m_Quality;
+ CListCtrl m_ChannelList;
+ bool m_bInProgress;
- afx_msg LRESULT OnScanProgress(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnScanEnd(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnStats(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnNewChannel(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnScanProgress(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnScanEnd(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnStats(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnNewChannel(WPARAM wParam, LPARAM lParam);
- afx_msg void OnBnClickedSave();
- afx_msg void OnBnClickedStart();
- afx_msg void OnBnClickedCancel();
- virtual BOOL OnInitDialog();
- CButton m_btnStart;
- CButton m_btnSave;
- CButton m_btnCancel;
+ afx_msg void OnBnClickedSave();
+ afx_msg void OnBnClickedStart();
+ afx_msg void OnBnClickedCancel();
+ virtual BOOL OnInitDialog();
+ CButton m_btnStart;
+ CButton m_btnSave;
+ CButton m_btnCancel;
};
diff --git a/src/apps/mplayerc/VMR9AllocatorPresenter.cpp b/src/apps/mplayerc/VMR9AllocatorPresenter.cpp
index fb3859252..b58c55efe 100644
--- a/src/apps/mplayerc/VMR9AllocatorPresenter.cpp
+++ b/src/apps/mplayerc/VMR9AllocatorPresenter.cpp
@@ -31,544 +31,298 @@
namespace DSObjects
{
-class COuterVMR9
- : public CUnknown
- , public IVideoWindow
- , public IBasicVideo2
- , public IVMRWindowlessControl
- , public IVMRffdshow9
- , public IVMRMixerBitmap9
-{
- CComPtr<IUnknown> m_pVMR;
- VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
- CDX9AllocatorPresenter *m_pAllocatorPresenter;
-
-public:
-
- COuterVMR9(const TCHAR* pName, LPUNKNOWN pUnk, VMR9AlphaBitmap* pVMR9AlphaBitmap, CDX9AllocatorPresenter *_pAllocatorPresenter) : CUnknown(pName, pUnk)
- {
- m_pVMR.CoCreateInstance(CLSID_VideoMixingRenderer9, GetOwner());
- m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
- m_pAllocatorPresenter = _pAllocatorPresenter;
- }
-
- ~COuterVMR9()
- {
- m_pVMR = NULL;
- }
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- HRESULT hr;
-
- // Casimir666 : en mode Renderless faire l'incrustation à la place du VMR
- if(riid == __uuidof(IVMRMixerBitmap9))
- return GetInterface((IVMRMixerBitmap9*)this, ppv);
-
- hr = m_pVMR ? m_pVMR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if(m_pVMR && FAILED(hr))
- {
- if(riid == __uuidof(IVideoWindow))
- return GetInterface((IVideoWindow*)this, ppv);
- if(riid == __uuidof(IBasicVideo))
- return GetInterface((IBasicVideo*)this, ppv);
- if(riid == __uuidof(IBasicVideo2))
- return GetInterface((IBasicVideo2*)this, ppv);
- if(riid == __uuidof(IVMRffdshow9)) // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
- return GetInterface((IVMRffdshow9*)this, ppv);
- /* if(riid == __uuidof(IVMRWindowlessControl))
- return GetInterface((IVMRWindowlessControl*)this, ppv);
- */
- }
-
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- // IVMRWindowlessControl
-
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- return pWC9->GetNativeVideoSize(lpWidth, lpHeight, lpARWidth, lpARHeight);
- }
-
- return E_NOTIMPL;
- }
- STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- return pWC9->GetVideoPosition(lpSRCRect, lpDSTRect);
- }
-
- return E_NOTIMPL;
- }
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- *lpAspectRatioMode = VMR_ARMODE_NONE;
- return S_OK;
- }
-
- return E_NOTIMPL;
- }
- STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetVideoClippingWindow(HWND hwnd)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP DisplayModeChanged()
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetCurrentImage(BYTE** lpDib)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetBorderColor(COLORREF Clr)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetBorderColor(COLORREF* lpClr)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetColorKey(COLORREF Clr)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetColorKey(COLORREF* lpClr)
- {
- return E_NOTIMPL;
- }
-
- // IVideoWindow
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Caption(BSTR strCaption)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Caption(BSTR* strCaption)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_WindowStyle(long WindowStyle)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WindowStyle(long* WindowStyle)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_WindowStyleEx(long WindowStyleEx)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_AutoShow(long AutoShow)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_AutoShow(long* AutoShow)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_WindowState(long WindowState)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WindowState(long* WindowState)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_BackgroundPalette(long BackgroundPalette)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Visible(long Visible)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Visible(long* pVisible)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Left(long Left)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Left(long* pLeft)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Width(long Width)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Width(long* pWidth)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pWidth = d.Width();
- return hr;
- }
-
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Top(long Top)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Top(long* pTop)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Height(long Height)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Height(long* pHeight)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pHeight = d.Height();
- return hr;
- }
-
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Owner(OAHWND Owner)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Owner(OAHWND* Owner)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_MessageDrain(OAHWND Drain)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MessageDrain(OAHWND* Drain)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BorderColor(long* Color)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_BorderColor(long Color)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_FullScreenMode(long* FullScreenMode)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_FullScreenMode(long FullScreenMode)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetWindowForeground(long Focus)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP HideCursor(long HideCursor)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP IsCursorHidden(long* CursorHidden)
- {
- return E_NOTIMPL;
- }
-
- // IBasicVideo2
- STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BitRate(long* pBitRate)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BitErrorRate(long* pBitErrorRate)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_VideoWidth(long* pVideoWidth)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_VideoHeight(long* pVideoHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceLeft(long SourceLeft)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceLeft(long* pSourceLeft)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceWidth(long SourceWidth)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceWidth(long* pSourceWidth)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceTop(long SourceTop)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceTop(long* pSourceTop)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceHeight(long SourceHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceHeight(long* pSourceHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationLeft(long DestinationLeft)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationLeft(long* pDestinationLeft)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationWidth(long DestinationWidth)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationWidth(long* pDestinationWidth)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationTop(long DestinationTop)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationTop(long* pDestinationTop)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationHeight(long DestinationHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationHeight(long* pDestinationHeight)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
- {
- // DVD Nav. bug workaround fix
- {
- *pLeft = *pTop = 0;
- return GetVideoSize(pWidth, pHeight);
- }
- /*
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pLeft = s.left;
- *pTop = s.top;
- *pWidth = s.Width();
- *pHeight = s.Height();
- return hr;
- }
- */
- return E_NOTIMPL;
- }
- STDMETHODIMP SetDefaultSourcePosition()
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pLeft = d.left;
- *pTop = d.top;
- *pWidth = d.Width();
- *pHeight = d.Height();
- return hr;
- }
-
- return E_NOTIMPL;
- }
- STDMETHODIMP SetDefaultDestinationPosition()
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- LONG aw, ah;
- // return pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
- // DVD Nav. bug workaround fix
- HRESULT hr = pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
- *pWidth = *pHeight * aw / ah;
- return hr;
- }
-
- return E_NOTIMPL;
- }
- // IVMRffdshow9
- STDMETHODIMP support_ffdshow()
- {
- queue_ffdshow_support = true;
- return S_OK;
- }
-
- STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP IsUsingDefaultSource()
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP IsUsingDefaultDestination()
- {
- return E_NOTIMPL;
- }
-
- STDMETHODIMP GetPreferredAspectRatio(long* plAspectX, long* plAspectY)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- LONG w, h;
- return pWC9->GetNativeVideoSize(&w, &h, plAspectX, plAspectY);
- }
-
- return E_NOTIMPL;
- }
-
- // IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
- {
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
- }
-
- STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
- {
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
- }
-
- STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
- {
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
- }
-};
+ class COuterVMR9
+ : public CUnknown
+ , public IVideoWindow
+ , public IBasicVideo2
+ , public IVMRWindowlessControl
+ , public IVMRffdshow9
+ , public IVMRMixerBitmap9
+ {
+ CComPtr<IUnknown> m_pVMR;
+ VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
+ CDX9AllocatorPresenter *m_pAllocatorPresenter;
+
+ public:
+
+ COuterVMR9(const TCHAR* pName, LPUNKNOWN pUnk, VMR9AlphaBitmap* pVMR9AlphaBitmap, CDX9AllocatorPresenter *_pAllocatorPresenter) : CUnknown(pName, pUnk)
+ {
+ m_pVMR.CoCreateInstance(CLSID_VideoMixingRenderer9, GetOwner());
+ m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = _pAllocatorPresenter;
+ }
+
+ ~COuterVMR9()
+ {
+ m_pVMR = NULL;
+ }
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ HRESULT hr;
+
+ // Casimir666 : en mode Renderless faire l'incrustation à la place du VMR
+ if(riid == __uuidof(IVMRMixerBitmap9))
+ return GetInterface((IVMRMixerBitmap9*)this, ppv);
+
+ hr = m_pVMR ? m_pVMR->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ if(m_pVMR && FAILED(hr))
+ {
+ if(riid == __uuidof(IVideoWindow))
+ return GetInterface((IVideoWindow*)this, ppv);
+ if(riid == __uuidof(IBasicVideo))
+ return GetInterface((IBasicVideo*)this, ppv);
+ if(riid == __uuidof(IBasicVideo2))
+ return GetInterface((IBasicVideo2*)this, ppv);
+ if(riid == __uuidof(IVMRffdshow9)) // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ return GetInterface((IVMRffdshow9*)this, ppv);
+ /* if(riid == __uuidof(IVMRWindowlessControl))
+ return GetInterface((IVMRWindowlessControl*)this, ppv);
+ */
+ }
+
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ // IVMRWindowlessControl
+
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ return pWC9->GetNativeVideoSize(lpWidth, lpHeight, lpARWidth, lpARHeight);
+ }
+
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {return E_NOTIMPL;}
+ STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {return E_NOTIMPL;}
+ STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect) {return E_NOTIMPL;}
+ STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ return pWC9->GetVideoPosition(lpSRCRect, lpDSTRect);
+ }
+
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ *lpAspectRatioMode = VMR_ARMODE_NONE;
+ return S_OK;
+ }
+
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode) {return E_NOTIMPL;}
+ STDMETHODIMP SetVideoClippingWindow(HWND hwnd) {return E_NOTIMPL;}
+ STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc) {return E_NOTIMPL;}
+ STDMETHODIMP DisplayModeChanged() {return E_NOTIMPL;}
+ STDMETHODIMP GetCurrentImage(BYTE** lpDib) {return E_NOTIMPL;}
+ STDMETHODIMP SetBorderColor(COLORREF Clr) {return E_NOTIMPL;}
+ STDMETHODIMP GetBorderColor(COLORREF* lpClr) {return E_NOTIMPL;}
+ STDMETHODIMP SetColorKey(COLORREF Clr) {return E_NOTIMPL;}
+ STDMETHODIMP GetColorKey(COLORREF* lpClr) {return E_NOTIMPL;}
+
+ // IVideoWindow
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
+ STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) {return E_NOTIMPL;}
+ STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) {return E_NOTIMPL;}
+ STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) {return E_NOTIMPL;}
+ STDMETHODIMP put_Caption(BSTR strCaption) {return E_NOTIMPL;}
+ STDMETHODIMP get_Caption(BSTR* strCaption) {return E_NOTIMPL;}
+ STDMETHODIMP put_WindowStyle(long WindowStyle) {return E_NOTIMPL;}
+ STDMETHODIMP get_WindowStyle(long* WindowStyle) {return E_NOTIMPL;}
+ STDMETHODIMP put_WindowStyleEx(long WindowStyleEx) {return E_NOTIMPL;}
+ STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx) {return E_NOTIMPL;}
+ STDMETHODIMP put_AutoShow(long AutoShow) {return E_NOTIMPL;}
+ STDMETHODIMP get_AutoShow(long* AutoShow) {return E_NOTIMPL;}
+ STDMETHODIMP put_WindowState(long WindowState) {return E_NOTIMPL;}
+ STDMETHODIMP get_WindowState(long* WindowState) {return E_NOTIMPL;}
+ STDMETHODIMP put_BackgroundPalette(long BackgroundPalette) {return E_NOTIMPL;}
+ STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette) {return E_NOTIMPL;}
+ STDMETHODIMP put_Visible(long Visible) {return E_NOTIMPL;}
+ STDMETHODIMP get_Visible(long* pVisible) {return E_NOTIMPL;}
+ STDMETHODIMP put_Left(long Left) {return E_NOTIMPL;}
+ STDMETHODIMP get_Left(long* pLeft) {return E_NOTIMPL;}
+ STDMETHODIMP put_Width(long Width) {return E_NOTIMPL;}
+ STDMETHODIMP get_Width(long* pWidth)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pWidth = d.Width();
+ return hr;
+ }
+
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_Top(long Top) {return E_NOTIMPL;}
+ STDMETHODIMP get_Top(long* pTop) {return E_NOTIMPL;}
+ STDMETHODIMP put_Height(long Height) {return E_NOTIMPL;}
+ STDMETHODIMP get_Height(long* pHeight)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pHeight = d.Height();
+ return hr;
+ }
+
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_Owner(OAHWND Owner) {return E_NOTIMPL;}
+ STDMETHODIMP get_Owner(OAHWND* Owner) {return E_NOTIMPL;}
+ STDMETHODIMP put_MessageDrain(OAHWND Drain) {return E_NOTIMPL;}
+ STDMETHODIMP get_MessageDrain(OAHWND* Drain) {return E_NOTIMPL;}
+ STDMETHODIMP get_BorderColor(long* Color) {return E_NOTIMPL;}
+ STDMETHODIMP put_BorderColor(long Color) {return E_NOTIMPL;}
+ STDMETHODIMP get_FullScreenMode(long* FullScreenMode) {return E_NOTIMPL;}
+ STDMETHODIMP put_FullScreenMode(long FullScreenMode) {return E_NOTIMPL;}
+ STDMETHODIMP SetWindowForeground(long Focus) {return E_NOTIMPL;}
+ STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam) {return E_NOTIMPL;}
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
+ STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
+ STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
+ STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
+ STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
+ STDMETHODIMP HideCursor(long HideCursor) {return E_NOTIMPL;}
+ STDMETHODIMP IsCursorHidden(long* CursorHidden) {return E_NOTIMPL;}
+
+ // IBasicVideo2
+ STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame) {return E_NOTIMPL;}
+ STDMETHODIMP get_BitRate(long* pBitRate) {return E_NOTIMPL;}
+ STDMETHODIMP get_BitErrorRate(long* pBitErrorRate) {return E_NOTIMPL;}
+ STDMETHODIMP get_VideoWidth(long* pVideoWidth) {return E_NOTIMPL;}
+ STDMETHODIMP get_VideoHeight(long* pVideoHeight) {return E_NOTIMPL;}
+ STDMETHODIMP put_SourceLeft(long SourceLeft) {return E_NOTIMPL;}
+ STDMETHODIMP get_SourceLeft(long* pSourceLeft) {return E_NOTIMPL;}
+ STDMETHODIMP put_SourceWidth(long SourceWidth) {return E_NOTIMPL;}
+ STDMETHODIMP get_SourceWidth(long* pSourceWidth) {return E_NOTIMPL;}
+ STDMETHODIMP put_SourceTop(long SourceTop) {return E_NOTIMPL;}
+ STDMETHODIMP get_SourceTop(long* pSourceTop) {return E_NOTIMPL;}
+ STDMETHODIMP put_SourceHeight(long SourceHeight) {return E_NOTIMPL;}
+ STDMETHODIMP get_SourceHeight(long* pSourceHeight) {return E_NOTIMPL;}
+ STDMETHODIMP put_DestinationLeft(long DestinationLeft) {return E_NOTIMPL;}
+ STDMETHODIMP get_DestinationLeft(long* pDestinationLeft) {return E_NOTIMPL;}
+ STDMETHODIMP put_DestinationWidth(long DestinationWidth) {return E_NOTIMPL;}
+ STDMETHODIMP get_DestinationWidth(long* pDestinationWidth) {return E_NOTIMPL;}
+ STDMETHODIMP put_DestinationTop(long DestinationTop) {return E_NOTIMPL;}
+ STDMETHODIMP get_DestinationTop(long* pDestinationTop) {return E_NOTIMPL;}
+ STDMETHODIMP put_DestinationHeight(long DestinationHeight) {return E_NOTIMPL;}
+ STDMETHODIMP get_DestinationHeight(long* pDestinationHeight) {return E_NOTIMPL;}
+ STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
+ STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
+ {
+ // DVD Nav. bug workaround fix
+ {
+ *pLeft = *pTop = 0;
+ return GetVideoSize(pWidth, pHeight);
+ }
+ /*
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pLeft = s.left;
+ *pTop = s.top;
+ *pWidth = s.Width();
+ *pHeight = s.Height();
+ return hr;
+ }
+ */
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetDefaultSourcePosition() {return E_NOTIMPL;}
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
+ STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pLeft = d.left;
+ *pTop = d.top;
+ *pWidth = d.Width();
+ *pHeight = d.Height();
+ return hr;
+ }
+
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetDefaultDestinationPosition() {return E_NOTIMPL;}
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ LONG aw, ah;
+ // return pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
+ // DVD Nav. bug workaround fix
+ HRESULT hr = pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
+ *pWidth = *pHeight * aw / ah;
+ return hr;
+ }
+
+ return E_NOTIMPL;
+ }
+ // IVMRffdshow9
+ STDMETHODIMP support_ffdshow()
+ {
+ queue_ffdshow_support = true;
+ return S_OK;
+ }
+
+ STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette) {return E_NOTIMPL;}
+ STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage) {return E_NOTIMPL;}
+ STDMETHODIMP IsUsingDefaultSource() {return E_NOTIMPL;}
+ STDMETHODIMP IsUsingDefaultDestination() {return E_NOTIMPL;}
+
+ STDMETHODIMP GetPreferredAspectRatio(long* plAspectX, long* plAspectY)
+ {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ LONG w, h;
+ return pWC9->GetNativeVideoSize(&w, &h, plAspectX, plAspectY);
+ }
+
+ return E_NOTIMPL;
+ }
+
+ // IVMRMixerBitmap9
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
+ {
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
+ }
+
+ STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
+ {
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
+ }
+
+ STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
+ {
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
+ }
+ };
}
using namespace DSObjects;
@@ -579,10 +333,10 @@ using namespace DSObjects;
#define MY_USER_ID 0x6ABE51
-CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
- , m_fUseInternalTimer(false)
- , m_rtPrevStart(-1)
+CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+ : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
+ , m_fUseInternalTimer(false)
+ , m_rtPrevStart(-1)
{
}
@@ -590,120 +344,120 @@ STDMETHODIMP CVMR9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, v
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IVMRSurfaceAllocator9)
- QI(IVMRImagePresenter9)
- QI(IVMRWindowlessControl9)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IVMRSurfaceAllocator9)
+ QI(IVMRImagePresenter9)
+ QI(IVMRWindowlessControl9)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CVMR9AllocatorPresenter::CreateDevice(CString &_Error)
{
- HRESULT hr = __super::CreateDevice(_Error);
- if(FAILED(hr))
- return hr;
-
- if(m_pIVMRSurfAllocNotify)
- {
- HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
- if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor)))
- {
- _Error += L"m_pIVMRSurfAllocNotify->ChangeD3DDevice failed";
- return(false);
- }
- }
-
- return hr;
+ HRESULT hr = __super::CreateDevice(_Error);
+ if(FAILED(hr))
+ return hr;
+
+ if(m_pIVMRSurfAllocNotify)
+ {
+ HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor)))
+ {
+ _Error += L"m_pIVMRSurfAllocNotify->ChangeD3DDevice failed";
+ return(false);
+ }
+ }
+
+ return hr;
}
void CVMR9AllocatorPresenter::DeleteSurfaces()
{
CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cRenderLock(&m_RenderLock);
- m_pSurfaces.RemoveAll();
+ m_pSurfaces.RemoveAll();
- return __super::DeleteSurfaces();
+ return __super::DeleteSurfaces();
}
STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
+ *ppRenderer = NULL;
- HRESULT hr;
+ HRESULT hr;
- do
- {
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ do
+ {
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- COuterVMR9 *pOuter = DNew COuterVMR9(NAME("COuterVMR9"), pUnk, &m_VMR9AlphaBitmap, this);
+ COuterVMR9 *pOuter = DNew COuterVMR9(NAME("COuterVMR9"), pUnk, &m_VMR9AlphaBitmap, this);
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuter);
- CComQIPtr<IBaseFilter> pBF = pUnk;
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuter);
+ CComQIPtr<IBaseFilter> pBF = pUnk;
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if(CComQIPtr<IAMVideoAccelerator> pAMVA = pPin)
- HookAMVideoAccelerator((IAMVideoAcceleratorC*)(IAMVideoAccelerator*)pAMVA);
+ if(CComQIPtr<IAMVideoAccelerator> pAMVA = pPin)
+ HookAMVideoAccelerator((IAMVideoAcceleratorC*)(IAMVideoAccelerator*)pAMVA);
- CComQIPtr<IVMRFilterConfig9> pConfig = pBF;
- if(!pConfig)
- break;
+ CComQIPtr<IVMRFilterConfig9> pConfig = pBF;
+ if(!pConfig)
+ break;
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if(s.fVMR9MixerMode)
- {
- if(FAILED(hr = pConfig->SetNumberOfStreams(1)))
- break;
+ if(s.fVMR9MixerMode)
+ {
+ if(FAILED(hr = pConfig->SetNumberOfStreams(1)))
+ break;
- if(CComQIPtr<IVMRMixerControl9> pMC = pBF)
- {
- DWORD dwPrefs;
- pMC->GetMixingPrefs(&dwPrefs);
+ if(CComQIPtr<IVMRMixerControl9> pMC = pBF)
+ {
+ DWORD dwPrefs;
+ pMC->GetMixingPrefs(&dwPrefs);
- // See http://msdn.microsoft.com/en-us/library/dd390928(VS.85).aspx
- dwPrefs |= MixerPref9_NonSquareMixing;
- dwPrefs |= MixerPref9_NoDecimation;
- if(s.fVMR9MixerYUV && !AfxGetMyApp()->IsVistaOrAbove())
- {
- dwPrefs &= ~MixerPref9_RenderTargetMask;
- dwPrefs |= MixerPref9_RenderTargetYUV;
- }
- pMC->SetMixingPrefs(dwPrefs);
- }
- }
+ // See http://msdn.microsoft.com/en-us/library/dd390928(VS.85).aspx
+ dwPrefs |= MixerPref9_NonSquareMixing;
+ dwPrefs |= MixerPref9_NoDecimation;
+ if(s.fVMR9MixerYUV && !AfxGetMyApp()->IsVistaOrAbove())
+ {
+ dwPrefs &= ~MixerPref9_RenderTargetMask;
+ dwPrefs |= MixerPref9_RenderTargetYUV;
+ }
+ pMC->SetMixingPrefs(dwPrefs);
+ }
+ }
- if(FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless)))
- break;
+ if(FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless)))
+ break;
- CComQIPtr<IVMRSurfaceAllocatorNotify9> pSAN = pBF;
- if(!pSAN)
- break;
+ CComQIPtr<IVMRSurfaceAllocatorNotify9> pSAN = pBF;
+ if(!pSAN)
+ break;
- if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator9*>(this)))
- || FAILED(hr = AdviseNotify(pSAN)))
- break;
+ if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator9*>(this)))
+ || FAILED(hr = AdviseNotify(pSAN)))
+ break;
- *ppRenderer = (IUnknown*)pBF.Detach();
+ *ppRenderer = (IUnknown*)pBF.Detach();
- return S_OK;
- }
- while(0);
+ return S_OK;
+ }
+ while(0);
return E_FAIL;
}
STDMETHODIMP_(void) CVMR9AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
{
- __super::SetTime(rtNow);
- //m_fUseInternalTimer = false;
+ __super::SetTime(rtNow);
+ //m_fUseInternalTimer = false;
}
// IVMRSurfaceAllocator9
@@ -711,68 +465,68 @@ STDMETHODIMP_(void) CVMR9AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers)
{
- if(!lpAllocInfo || !lpNumBuffers)
- return E_POINTER;
+ if(!lpAllocInfo || !lpNumBuffers)
+ return E_POINTER;
- if(!m_pIVMRSurfAllocNotify)
- return E_FAIL;
+ if(!m_pIVMRSurfAllocNotify)
+ return E_FAIL;
- if((GetAsyncKeyState(VK_CONTROL) & 0x80000000))
- if(lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I')
- return E_FAIL;
+ if((GetAsyncKeyState(VK_CONTROL)&0x80000000))
+ if(lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I')
+ return E_FAIL;
- DeleteSurfaces();
+ DeleteSurfaces();
- int nOriginal = *lpNumBuffers;
+ int nOriginal = *lpNumBuffers;
- if(*lpNumBuffers == 1)
- {
- *lpNumBuffers = 4;
- m_nVMR9Surfaces = 4;
- }
- else
- m_nVMR9Surfaces = 0;
- m_pSurfaces.SetCount(*lpNumBuffers);
+ if (*lpNumBuffers == 1)
+ {
+ *lpNumBuffers = 4;
+ m_nVMR9Surfaces = 4;
+ }
+ else
+ m_nVMR9Surfaces = 0;
+ m_pSurfaces.SetCount(*lpNumBuffers);
- int w = lpAllocInfo->dwWidth;
- int h = abs((int)lpAllocInfo->dwHeight);
+ int w = lpAllocInfo->dwWidth;
+ int h = abs((int)lpAllocInfo->dwHeight);
- HRESULT hr;
+ HRESULT hr;
- if(lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget)
- lpAllocInfo->dwFlags |= VMR9AllocFlag_TextureSurface;
+ if(lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget)
+ lpAllocInfo->dwFlags |= VMR9AllocFlag_TextureSurface;
- hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &m_pSurfaces[0]);
- if(FAILED(hr)) return hr;
+ hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &m_pSurfaces[0]);
+ if(FAILED(hr)) return hr;
- m_pSurfaces.SetCount(*lpNumBuffers);
+ m_pSurfaces.SetCount(*lpNumBuffers);
- m_NativeVideoSize = m_AspectRatio = CSize(w, h);
- m_bNeedCheckSample = true;
- int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) m_AspectRatio.SetSize(arx, ary);
+ m_NativeVideoSize = m_AspectRatio = CSize(w, h);
+ m_bNeedCheckSample = true;
+ int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
+ if(arx > 0 && ary > 0) m_AspectRatio.SetSize(arx, ary);
- if(FAILED(hr = AllocSurfaces()))
- return hr;
+ if(FAILED(hr = AllocSurfaces()))
+ return hr;
- if(!(lpAllocInfo->dwFlags & VMR9AllocFlag_TextureSurface))
- {
- // test if the colorspace is acceptable
- if(FAILED(hr = m_pD3DDev->StretchRect(m_pSurfaces[0], NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE)))
- {
- DeleteSurfaces();
- return E_FAIL;
- }
- }
+ if(!(lpAllocInfo->dwFlags & VMR9AllocFlag_TextureSurface))
+ {
+ // test if the colorspace is acceptable
+ if(FAILED(hr = m_pD3DDev->StretchRect(m_pSurfaces[0], NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE)))
+ {
+ DeleteSurfaces();
+ return E_FAIL;
+ }
+ }
- hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
+ hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
- if(m_nVMR9Surfaces && m_nVMR9Surfaces != *lpNumBuffers)
- m_nVMR9Surfaces = *lpNumBuffers;
- *lpNumBuffers = min(nOriginal, *lpNumBuffers);
- m_iVMR9Surface = 0;
+ if (m_nVMR9Surfaces && m_nVMR9Surfaces != *lpNumBuffers)
+ m_nVMR9Surfaces = *lpNumBuffers;
+ *lpNumBuffers = min(nOriginal, *lpNumBuffers);
+ m_iVMR9Surface = 0;
- return hr;
+ return hr;
}
STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
@@ -784,39 +538,39 @@ STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface)
{
if(!lplpSurface)
- return E_POINTER;
+ return E_POINTER;
- if(SurfaceIndex >= m_pSurfaces.GetCount())
+ if(SurfaceIndex >= m_pSurfaces.GetCount())
return E_FAIL;
- CAutoLock cRenderLock(&m_RenderLock);
-
- if(m_nVMR9Surfaces)
- {
- ++m_iVMR9Surface;
- m_iVMR9Surface = m_iVMR9Surface % m_nVMR9Surfaces;
- (*lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex])->AddRef();
- }
- else
- {
- m_iVMR9Surface = SurfaceIndex;
- (*lplpSurface = m_pSurfaces[SurfaceIndex])->AddRef();
- }
-
- return S_OK;
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ if (m_nVMR9Surfaces)
+ {
+ ++m_iVMR9Surface;
+ m_iVMR9Surface = m_iVMR9Surface % m_nVMR9Surfaces;
+ (*lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex])->AddRef();
+ }
+ else
+ {
+ m_iVMR9Surface = SurfaceIndex;
+ (*lplpSurface = m_pSurfaces[SurfaceIndex])->AddRef();
+ }
+
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify)
{
CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cRenderLock(&m_RenderLock);
- m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
+ m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
- HRESULT hr;
+ HRESULT hr;
HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
if(FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, hMonitor)))
- return hr;
+ return hr;
return S_OK;
}
@@ -826,218 +580,191 @@ STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9*
STDMETHODIMP CVMR9AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cRenderLock(&m_RenderLock);
ASSERT(m_pD3DDev);
- return m_pD3DDev ? S_OK : E_FAIL;
+ return m_pD3DDev ? S_OK : E_FAIL;
}
STDMETHODIMP CVMR9AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo)
{
- CheckPointer(m_pIVMRSurfAllocNotify, E_UNEXPECTED);
-
- m_MainThreadId = GetCurrentThreadId();
-
- if(m_rtTimePerFrame == 0 || m_bNeedCheckSample)
- {
- m_bNeedCheckSample = false;
- CComPtr<IBaseFilter> pVMR9;
- CComPtr<IPin> pPin;
- CMediaType mt;
-
- if(SUCCEEDED(m_pIVMRSurfAllocNotify->QueryInterface(__uuidof(IBaseFilter), (void**)&pVMR9)) &&
- SUCCEEDED(pVMR9->FindPin(L"VMR Input0", &pPin)) &&
- SUCCEEDED(pPin->ConnectionMediaType(&mt)))
- {
- ExtractAvgTimePerFrame(&mt, m_rtTimePerFrame);
-
- CSize NativeVideoSize = m_NativeVideoSize;
- CSize AspectRatio = m_AspectRatio;
- if(mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_MPEGVideo)
- {
- VIDEOINFOHEADER *vh = (VIDEOINFOHEADER*)mt.pbFormat;
-
- NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
- if(vh->rcTarget.right - vh->rcTarget.left > 0)
- NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
- else if(vh->rcSource.right - vh->rcSource.left > 0)
- NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
-
- if(vh->rcTarget.bottom - vh->rcTarget.top > 0)
- NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
- else if(vh->rcSource.bottom - vh->rcSource.top > 0)
- NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
- }
- else if(mt.formattype == FORMAT_VideoInfo2 || mt.formattype == FORMAT_MPEG2Video)
- {
- VIDEOINFOHEADER2 *vh = (VIDEOINFOHEADER2*)mt.pbFormat;
-
- if(vh->dwPictAspectRatioX && vh->dwPictAspectRatioY)
- AspectRatio = CSize(vh->dwPictAspectRatioX, vh->dwPictAspectRatioY);
-
- NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
- if(vh->rcTarget.right - vh->rcTarget.left > 0)
- NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
- else if(vh->rcSource.right - vh->rcSource.left > 0)
- NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
-
- if(vh->rcTarget.bottom - vh->rcTarget.top > 0)
- NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
- else if(vh->rcSource.bottom - vh->rcSource.top > 0)
- NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
- }
- if(m_NativeVideoSize != NativeVideoSize || m_AspectRatio != AspectRatio)
- {
- m_NativeVideoSize = NativeVideoSize;
- m_AspectRatio = AspectRatio;
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
- }
- // If framerate not set by Video Decoder choose 23.97...
- if(m_rtTimePerFrame == 0) m_rtTimePerFrame = 417166;
-
- m_fps = 10000000.0 / m_rtTimePerFrame;
-
-
- }
+ CheckPointer(m_pIVMRSurfAllocNotify, E_UNEXPECTED);
+
+ m_MainThreadId = GetCurrentThreadId();
+
+ if (m_rtTimePerFrame == 0 || m_bNeedCheckSample)
+ {
+ m_bNeedCheckSample = false;
+ CComPtr<IBaseFilter> pVMR9;
+ CComPtr<IPin> pPin;
+ CMediaType mt;
+
+ if (SUCCEEDED (m_pIVMRSurfAllocNotify->QueryInterface (__uuidof(IBaseFilter), (void**)&pVMR9)) &&
+ SUCCEEDED (pVMR9->FindPin(L"VMR Input0", &pPin)) &&
+ SUCCEEDED (pPin->ConnectionMediaType(&mt)) )
+ {
+ ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
+
+ CSize NativeVideoSize = m_NativeVideoSize;
+ CSize AspectRatio = m_AspectRatio;
+ if (mt.formattype==FORMAT_VideoInfo || mt.formattype==FORMAT_MPEGVideo)
+ {
+ VIDEOINFOHEADER *vh = (VIDEOINFOHEADER*)mt.pbFormat;
+
+ NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
+ if (vh->rcTarget.right - vh->rcTarget.left > 0)
+ NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
+ else if (vh->rcSource.right - vh->rcSource.left > 0)
+ NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
+
+ if (vh->rcTarget.bottom - vh->rcTarget.top > 0)
+ NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
+ else if (vh->rcSource.bottom - vh->rcSource.top > 0)
+ NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
+ }
+ else if (mt.formattype==FORMAT_VideoInfo2 || mt.formattype==FORMAT_MPEG2Video)
+ {
+ VIDEOINFOHEADER2 *vh = (VIDEOINFOHEADER2*)mt.pbFormat;
+
+ if (vh->dwPictAspectRatioX && vh->dwPictAspectRatioY)
+ AspectRatio = CSize(vh->dwPictAspectRatioX, vh->dwPictAspectRatioY);
+
+ NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
+ if (vh->rcTarget.right - vh->rcTarget.left > 0)
+ NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
+ else if (vh->rcSource.right - vh->rcSource.left > 0)
+ NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
+
+ if (vh->rcTarget.bottom - vh->rcTarget.top > 0)
+ NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
+ else if (vh->rcSource.bottom - vh->rcSource.top > 0)
+ NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
+ }
+ if (m_NativeVideoSize != NativeVideoSize || m_AspectRatio != AspectRatio)
+ {
+ m_NativeVideoSize = NativeVideoSize;
+ m_AspectRatio = AspectRatio;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
+ }
+ // If framerate not set by Video Decoder choose 23.97...
+ if (m_rtTimePerFrame == 0) m_rtTimePerFrame = 417166;
+
+ m_fps = 10000000.0 / m_rtTimePerFrame;
+
+
+ }
HRESULT hr;
- if(!lpPresInfo || !lpPresInfo->lpSurf)
- return E_POINTER;
-
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
-
- CComPtr<IDirect3DTexture9> pTexture;
- lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
-
- if(pTexture)
- {
- m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
- if(m_pVideoTexture[m_nCurSurface])
- m_pVideoTexture[m_nCurSurface] = pTexture;
- }
- else
- {
- hr = m_pD3DDev->StretchRect(lpPresInfo->lpSurf, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
- }
-
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
- {
- if(m_pSubPicQueue)
- {
- m_pSubPicQueue->SetFPS(m_fps);
-
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
- {
- __super::SetTime(g_tSegmentStart + g_tSampleStart);
- }
- }
- }
-
- CSize VideoSize = m_NativeVideoSize;
- int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) VideoSize.cx = VideoSize.cy * arx / ary;
- if(VideoSize != GetVideoSize())
- {
- m_AspectRatio.SetSize(arx, ary);
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
-
- // Tear test bars
- if(AfxGetMyApp()->m_fTearingTest)
- {
- RECT rcTearing;
-
- rcTearing.left = m_nTearingPos;
- rcTearing.top = 0;
- rcTearing.right = rcTearing.left + 4;
- rcTearing.bottom = m_NativeVideoSize.cy;
- m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
-
- rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
- rcTearing.right = rcTearing.left + 4;
- m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
-
- m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
- }
-
- Paint(true);
+ if(!lpPresInfo || !lpPresInfo->lpSurf)
+ return E_POINTER;
+
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ CComPtr<IDirect3DTexture9> pTexture;
+ lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
+
+ if(pTexture)
+ {
+ m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
+ if(m_pVideoTexture[m_nCurSurface])
+ m_pVideoTexture[m_nCurSurface] = pTexture;
+ }
+ else
+ {
+ hr = m_pD3DDev->StretchRect(lpPresInfo->lpSurf, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
+ }
+
+ if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
+ {
+ if(m_pSubPicQueue)
+ {
+ m_pSubPicQueue->SetFPS(m_fps);
+
+ if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
+ {
+ __super::SetTime(g_tSegmentStart + g_tSampleStart);
+ }
+ }
+ }
+
+ CSize VideoSize = m_NativeVideoSize;
+ int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
+ if(arx > 0 && ary > 0) VideoSize.cx = VideoSize.cy*arx/ary;
+ if(VideoSize != GetVideoSize())
+ {
+ m_AspectRatio.SetSize(arx, ary);
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
+
+ // Tear test bars
+ if (AfxGetMyApp()->m_fTearingTest)
+ {
+ RECT rcTearing;
+
+ rcTearing.left = m_nTearingPos;
+ rcTearing.top = 0;
+ rcTearing.right = rcTearing.left + 4;
+ rcTearing.bottom = m_NativeVideoSize.cy;
+ m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+
+ rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
+ rcTearing.right = rcTearing.left + 4;
+ m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+
+ m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
+ }
+
+ Paint(true);
return S_OK;
}
// IVMRWindowlessControl9
//
-// It is only implemented (partially) for the dvd navigator's
-// menu handling, which needs to know a few things about the
+// It is only implemented (partially) for the dvd navigator's
+// menu handling, which needs to know a few things about the
// location of our window.
STDMETHODIMP CVMR9AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- if(lpWidth) *lpWidth = m_NativeVideoSize.cx;
- if(lpHeight) *lpHeight = m_NativeVideoSize.cy;
- if(lpARWidth) *lpARWidth = m_AspectRatio.cx;
- if(lpARHeight) *lpARHeight = m_AspectRatio.cy;
- return S_OK;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect)
-{
- return E_NOTIMPL; // we have our own method for this
+ if(lpWidth) *lpWidth = m_NativeVideoSize.cx;
+ if(lpHeight) *lpHeight = m_NativeVideoSize.cy;
+ if(lpARWidth) *lpARWidth = m_AspectRatio.cx;
+ if(lpARHeight) *lpARHeight = m_AspectRatio.cy;
+ return S_OK;
}
+STDMETHODIMP CVMR9AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {return E_NOTIMPL;}
+STDMETHODIMP CVMR9AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {return E_NOTIMPL;}
+STDMETHODIMP CVMR9AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect) {return E_NOTIMPL;} // we have our own method for this
STDMETHODIMP CVMR9AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
{
- CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
- CopyRect(lpDSTRect, &m_VideoRect);
- return S_OK;
+ CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
+ CopyRect(lpDSTRect, &m_VideoRect);
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
- return S_OK;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::SetVideoClippingWindow(HWND hwnd)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::DisplayModeChanged()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::GetCurrentImage(BYTE** lpDib)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR9AllocatorPresenter::SetBorderColor(COLORREF Clr)
-{
- return E_NOTIMPL;
+ if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ return S_OK;
}
+STDMETHODIMP CVMR9AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode) {return E_NOTIMPL;}
+STDMETHODIMP CVMR9AllocatorPresenter::SetVideoClippingWindow(HWND hwnd) {return E_NOTIMPL;}
+STDMETHODIMP CVMR9AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc) {return E_NOTIMPL;}
+STDMETHODIMP CVMR9AllocatorPresenter::DisplayModeChanged() {return E_NOTIMPL;}
+STDMETHODIMP CVMR9AllocatorPresenter::GetCurrentImage(BYTE** lpDib) {return E_NOTIMPL;}
+STDMETHODIMP CVMR9AllocatorPresenter::SetBorderColor(COLORREF Clr) {return E_NOTIMPL;}
STDMETHODIMP CVMR9AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if(lpClr) *lpClr = 0;
- return S_OK;
+ if(lpClr) *lpClr = 0;
+ return S_OK;
}
diff --git a/src/apps/mplayerc/VMR9AllocatorPresenter.h b/src/apps/mplayerc/VMR9AllocatorPresenter.h
index 66130fc4c..d3f3d2bb6 100644
--- a/src/apps/mplayerc/VMR9AllocatorPresenter.h
+++ b/src/apps/mplayerc/VMR9AllocatorPresenter.h
@@ -26,56 +26,56 @@
namespace DSObjects
{
-class CVMR9AllocatorPresenter
- : public CDX9AllocatorPresenter
- , public IVMRSurfaceAllocator9
- , public IVMRImagePresenter9
- , public IVMRWindowlessControl9
-{
-protected:
- CComPtr<IVMRSurfaceAllocatorNotify9> m_pIVMRSurfAllocNotify;
- CInterfaceArray<IDirect3DSurface9> m_pSurfaces;
-
- HRESULT CreateDevice(CString &_Error);
- void DeleteSurfaces();
+ class CVMR9AllocatorPresenter
+ : public CDX9AllocatorPresenter
+ , public IVMRSurfaceAllocator9
+ , public IVMRImagePresenter9
+ , public IVMRWindowlessControl9
+ {
+ protected:
+ CComPtr<IVMRSurfaceAllocatorNotify9> m_pIVMRSurfAllocNotify;
+ CInterfaceArray<IDirect3DSurface9> m_pSurfaces;
- bool m_fUseInternalTimer;
- REFERENCE_TIME m_rtPrevStart;
+ HRESULT CreateDevice(CString &_Error);
+ void DeleteSurfaces();
-public:
- CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
+ bool m_fUseInternalTimer;
+ REFERENCE_TIME m_rtPrevStart;
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ public:
+ CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IVMRSurfaceAllocator9
- STDMETHODIMP InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers);
- STDMETHODIMP TerminateDevice(DWORD_PTR dwID);
- STDMETHODIMP GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface);
- STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify);
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
+
+ // IVMRSurfaceAllocator9
+ STDMETHODIMP InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers);
+ STDMETHODIMP TerminateDevice(DWORD_PTR dwID);
+ STDMETHODIMP GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface);
+ STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify);
- // IVMRImagePresenter9
- STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo);
+ // IVMRImagePresenter9
+ STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo);
- // IVMRWindowlessControl9
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
- STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
- STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
- STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
- STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
- STDMETHODIMP DisplayModeChanged();
- STDMETHODIMP GetCurrentImage(BYTE** lpDib);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF* lpClr);
-};
+ // IVMRWindowlessControl9
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
+ STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
+ STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
+ STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
+ STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
+ STDMETHODIMP DisplayModeChanged();
+ STDMETHODIMP GetCurrentImage(BYTE** lpDib);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF* lpClr);
+ };
}
diff --git a/src/apps/mplayerc/VMROSD.cpp b/src/apps/mplayerc/VMROSD.cpp
index 34a5b67dc..800d5b5b5 100644
--- a/src/apps/mplayerc/VMROSD.cpp
+++ b/src/apps/mplayerc/VMROSD.cpp
@@ -27,405 +27,405 @@
#define SEEKBAR_HEIGHT 60
#define SLIDER_BAR_HEIGHT 10
#define SLIDER_CURSOR_HEIGHT 30
-#define SLIDER_CURSOR_WIDTH 15
+#define SLIDER_CURSOR_WIDTH 15
CVMROSD::CVMROSD(void)
{
- m_Color[OSD_TRANSPARENT] = RGB(0, 0, 0);
- m_Color[OSD_BACKGROUND] = RGB(0, 96, 183);
- m_Color[OSD_BORDER] = RGB(255, 255, 255);
- m_Color[OSD_TEXT] = RGB(255, 255, 255);
- m_Color[OSD_BAR] = RGB(4, 200, 12);
- m_Color[OSD_CURSOR] = RGB(23, 50, 247);
-
- m_penBorder.CreatePen(PS_SOLID, 1, m_Color[OSD_BORDER]);
- m_penCursor.CreatePen(PS_SOLID, 4, m_Color[OSD_CURSOR]);
- m_brushBack.CreateSolidBrush(m_Color[OSD_BACKGROUND]);
- m_brushBar.CreateSolidBrush(m_Color[OSD_BAR]);
-
- m_nMessagePos = OSD_NOMESSAGE;
- m_bSeekBarVisible = false;
- m_bCursorMoving = false;
- m_pMFVMB = NULL;
- m_pVMB = NULL;
- memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
-
- m_FontSize = 0;
- m_OSD_Font = _T("");
+ m_Color[OSD_TRANSPARENT] = RGB( 0, 0, 0);
+ m_Color[OSD_BACKGROUND] = RGB( 0, 96, 183);
+ m_Color[OSD_BORDER] = RGB(255, 255, 255);
+ m_Color[OSD_TEXT] = RGB(255, 255, 255);
+ m_Color[OSD_BAR] = RGB( 4, 200, 12);
+ m_Color[OSD_CURSOR] = RGB( 23, 50, 247);
+
+ m_penBorder.CreatePen(PS_SOLID, 1, m_Color[OSD_BORDER]);
+ m_penCursor.CreatePen(PS_SOLID, 4, m_Color[OSD_CURSOR]);
+ m_brushBack.CreateSolidBrush(m_Color[OSD_BACKGROUND]);
+ m_brushBar.CreateSolidBrush (m_Color[OSD_BAR]);
+
+ m_nMessagePos = OSD_NOMESSAGE;
+ m_bSeekBarVisible = false;
+ m_bCursorMoving = false;
+ m_pMFVMB = NULL;
+ m_pVMB = NULL;
+ memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
+
+ m_FontSize = 0;
+ m_OSD_Font = _T("");
}
CVMROSD::~CVMROSD(void)
{
- m_MemDC.DeleteDC();
+ m_MemDC.DeleteDC();
}
void CVMROSD::OnSize(UINT nType, int cx, int cy)
{
- if(m_pWnd && (m_pVMB || m_pMFVMB))
- {
- if(m_bSeekBarVisible)
- {
- m_bCursorMoving = false;
- m_bSeekBarVisible = false;
- Invalidate();
- }
- UpdateBitmap();
- }
+ if (m_pWnd && (m_pVMB || m_pMFVMB))
+ {
+ if (m_bSeekBarVisible)
+ {
+ m_bCursorMoving = false;
+ m_bSeekBarVisible = false;
+ Invalidate();
+ }
+ UpdateBitmap();
+ }
}
void CVMROSD::UpdateBitmap()
{
- CAutoLock Lock(&m_Lock);
- CRect rc;
- CWindowDC dc(m_pWnd);
-
- CalcRect();
-
- m_MemDC.DeleteDC();
- memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
-
- if(m_MemDC.CreateCompatibleDC(&dc))
- {
- BITMAPINFO bmi = {0};
- HBITMAP hbmpRender;
-
- ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = m_rectWnd.Width();
- bmi.bmiHeader.biHeight = - (int) m_rectWnd.Height(); // top-down
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
-
- hbmpRender = CreateDIBSection(m_MemDC, &bmi, DIB_RGB_COLORS, NULL, NULL, NULL);
- m_MemDC.SelectObject(hbmpRender);
-
- if(::GetObject(hbmpRender, sizeof(BITMAP), &m_BitmapInfo) != 0)
- {
- // Configure the VMR's bitmap structure
- if(m_pVMB)
- {
- ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
- m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_HDC | VMRBITMAP_SRCCOLORKEY;
- m_VMR9AlphaBitmap.hdc = m_MemDC;
- m_VMR9AlphaBitmap.rSrc = m_rectWnd;
- m_VMR9AlphaBitmap.rDest.left = 0;
- m_VMR9AlphaBitmap.rDest.top = 0;
- m_VMR9AlphaBitmap.rDest.right = 1.0;
- m_VMR9AlphaBitmap.rDest.bottom = 1.0;
- m_VMR9AlphaBitmap.fAlpha = 1.0;
- m_VMR9AlphaBitmap.clrSrcKey = m_Color[OSD_TRANSPARENT];
- }
- else if(m_pMFVMB)
- {
- ZeroMemory(&m_MFVideoAlphaBitmap, sizeof(m_MFVideoAlphaBitmap));
- m_MFVideoAlphaBitmap.params.dwFlags = MFVideoAlphaBitmap_SrcColorKey;
- m_MFVideoAlphaBitmap.params.clrSrcKey = m_Color[OSD_TRANSPARENT];
- m_MFVideoAlphaBitmap.params.rcSrc = m_rectWnd;
- m_MFVideoAlphaBitmap.params.nrcDest.right = 1;
- m_MFVideoAlphaBitmap.params.nrcDest.bottom = 1;
- m_MFVideoAlphaBitmap.GetBitmapFromDC = TRUE;
- m_MFVideoAlphaBitmap.bitmap.hdc = m_MemDC;
- }
- m_MemDC.SetTextColor(RGB(255, 255, 255));
- m_MemDC.SetBkMode(TRANSPARENT);
- }
-
- if(m_MainFont.GetSafeHandle())
- m_MemDC.SelectObject(m_MainFont);
-
- DeleteObject(hbmpRender);
- }
+ CAutoLock Lock(&m_Lock);
+ CRect rc;
+ CWindowDC dc (m_pWnd);
+
+ CalcRect();
+
+ m_MemDC.DeleteDC();
+ memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
+
+ if (m_MemDC.CreateCompatibleDC (&dc))
+ {
+ BITMAPINFO bmi = {0};
+ HBITMAP hbmpRender;
+
+ ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = m_rectWnd.Width();
+ bmi.bmiHeader.biHeight = - (int) m_rectWnd.Height(); // top-down
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ hbmpRender = CreateDIBSection( m_MemDC, &bmi, DIB_RGB_COLORS, NULL, NULL, NULL );
+ m_MemDC.SelectObject (hbmpRender);
+
+ if (::GetObject(hbmpRender, sizeof(BITMAP), &m_BitmapInfo) != 0)
+ {
+ // Configure the VMR's bitmap structure
+ if (m_pVMB)
+ {
+ ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap) );
+ m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_HDC | VMRBITMAP_SRCCOLORKEY;
+ m_VMR9AlphaBitmap.hdc = m_MemDC;
+ m_VMR9AlphaBitmap.rSrc = m_rectWnd;
+ m_VMR9AlphaBitmap.rDest.left = 0;
+ m_VMR9AlphaBitmap.rDest.top = 0;
+ m_VMR9AlphaBitmap.rDest.right = 1.0;
+ m_VMR9AlphaBitmap.rDest.bottom = 1.0;
+ m_VMR9AlphaBitmap.fAlpha = 1.0;
+ m_VMR9AlphaBitmap.clrSrcKey = m_Color[OSD_TRANSPARENT];
+ }
+ else if (m_pMFVMB)
+ {
+ ZeroMemory(&m_MFVideoAlphaBitmap, sizeof(m_MFVideoAlphaBitmap) );
+ m_MFVideoAlphaBitmap.params.dwFlags = MFVideoAlphaBitmap_SrcColorKey;
+ m_MFVideoAlphaBitmap.params.clrSrcKey = m_Color[OSD_TRANSPARENT];
+ m_MFVideoAlphaBitmap.params.rcSrc = m_rectWnd;
+ m_MFVideoAlphaBitmap.params.nrcDest.right = 1;
+ m_MFVideoAlphaBitmap.params.nrcDest.bottom = 1;
+ m_MFVideoAlphaBitmap.GetBitmapFromDC = TRUE;
+ m_MFVideoAlphaBitmap.bitmap.hdc = m_MemDC;
+ }
+ m_MemDC.SetTextColor(RGB(255, 255, 255));
+ m_MemDC.SetBkMode(TRANSPARENT);
+ }
+
+ if(m_MainFont.GetSafeHandle())
+ m_MemDC.SelectObject(m_MainFont);
+
+ DeleteObject(hbmpRender);
+ }
}
-void CVMROSD::Start(CWnd* pWnd, CComPtr<IVMRMixerBitmap9> pVMB)
+void CVMROSD::Start (CWnd* pWnd, CComPtr<IVMRMixerBitmap9> pVMB)
{
- m_pVMB = pVMB;
- m_pMFVMB = NULL;
- m_pWnd = pWnd;
- UpdateBitmap();
+ m_pVMB = pVMB;
+ m_pMFVMB = NULL;
+ m_pWnd = pWnd;
+ UpdateBitmap();
}
-void CVMROSD::Start(CWnd* pWnd, CComPtr<IMFVideoMixerBitmap> pMFVMB)
+void CVMROSD::Start (CWnd* pWnd, CComPtr<IMFVideoMixerBitmap> pMFVMB)
{
- m_pMFVMB = pMFVMB;
- m_pVMB = NULL;
- m_pWnd = pWnd;
- UpdateBitmap();
+ m_pMFVMB = pMFVMB;
+ m_pVMB = NULL;
+ m_pWnd = pWnd;
+ UpdateBitmap();
}
void CVMROSD::Stop()
{
- m_pVMB.Release();
- m_pWnd = NULL;
+ m_pVMB.Release();
+ m_pWnd = NULL;
}
void CVMROSD::CalcRect()
{
- if(m_pWnd)
- {
- m_pWnd->GetClientRect(&m_rectWnd);
-
- m_rectSeekBar.left = m_rectWnd.left + 10;
- m_rectSeekBar.right = m_rectWnd.right - 10;
- m_rectSeekBar.top = m_rectWnd.bottom - SEEKBAR_HEIGHT;
- m_rectSeekBar.bottom = m_rectSeekBar.top + SEEKBAR_HEIGHT;
-
- m_rectSeekBar.left = m_rectSeekBar.left;
- m_rectSeekBar.right = m_rectSeekBar.right;
- m_rectSeekBar.top = m_rectSeekBar.top;
- m_rectSeekBar.bottom = m_rectSeekBar.bottom;
- }
+ if (m_pWnd)
+ {
+ m_pWnd->GetClientRect(&m_rectWnd);
+
+ m_rectSeekBar.left = m_rectWnd.left + 10;
+ m_rectSeekBar.right = m_rectWnd.right - 10;
+ m_rectSeekBar.top = m_rectWnd.bottom - SEEKBAR_HEIGHT;
+ m_rectSeekBar.bottom = m_rectSeekBar.top + SEEKBAR_HEIGHT;
+
+ m_rectSeekBar.left = m_rectSeekBar.left;
+ m_rectSeekBar.right = m_rectSeekBar.right;
+ m_rectSeekBar.top = m_rectSeekBar.top;
+ m_rectSeekBar.bottom = m_rectSeekBar.bottom;
+ }
}
void CVMROSD::DrawRect(CRect* rect, CBrush* pBrush, CPen* pPen)
{
- if(pPen)
- m_MemDC.SelectObject(pPen);
- else
- m_MemDC.SelectStockObject(NULL_PEN);
+ if (pPen)
+ m_MemDC.SelectObject (pPen);
+ else
+ m_MemDC.SelectStockObject(NULL_PEN);
- if(pBrush)
- m_MemDC.SelectObject(pBrush);
- else
- m_MemDC.SelectStockObject(HOLLOW_BRUSH);
+ if (pBrush)
+ m_MemDC.SelectObject (pBrush);
+ else
+ m_MemDC.SelectStockObject(HOLLOW_BRUSH);
- m_MemDC.Rectangle(rect);
+ m_MemDC.Rectangle (rect);
}
void CVMROSD::DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPos)
{
- m_rectBar.left = rect->left + 10;
- m_rectBar.right = rect->right - 10;
- m_rectBar.top = rect->top + (rect->Height() - SLIDER_BAR_HEIGHT) / 2;
- m_rectBar.bottom = m_rectBar.top + SLIDER_BAR_HEIGHT;
-
- if(llMax == llMin)
- m_rectCursor.left = m_rectBar.left;
- else
- m_rectCursor.left = m_rectBar.left + (long)((m_rectBar.Width() - SLIDER_CURSOR_WIDTH) * llPos / (llMax - llMin));
- m_rectCursor.right = m_rectCursor.left + SLIDER_CURSOR_WIDTH;
- m_rectCursor.top = rect->top + (rect->Height() - SLIDER_CURSOR_HEIGHT) / 2;
- m_rectCursor.bottom = m_rectCursor.top + SLIDER_CURSOR_HEIGHT;
-
- DrawRect(rect, &m_brushBack, &m_penBorder);
- DrawRect(&m_rectBar, &m_brushBar);
- DrawRect(&m_rectCursor, NULL, &m_penCursor);
+ m_rectBar.left = rect->left + 10;
+ m_rectBar.right = rect->right - 10;
+ m_rectBar.top = rect->top + (rect->Height() - SLIDER_BAR_HEIGHT) / 2;
+ m_rectBar.bottom = m_rectBar.top + SLIDER_BAR_HEIGHT;
+
+ if (llMax == llMin)
+ m_rectCursor.left = m_rectBar.left;
+ else
+ m_rectCursor.left = m_rectBar.left + (long)((m_rectBar.Width() - SLIDER_CURSOR_WIDTH) * llPos / (llMax-llMin));
+ m_rectCursor.right = m_rectCursor.left + SLIDER_CURSOR_WIDTH;
+ m_rectCursor.top = rect->top + (rect->Height() - SLIDER_CURSOR_HEIGHT) / 2;
+ m_rectCursor.bottom = m_rectCursor.top + SLIDER_CURSOR_HEIGHT;
+
+ DrawRect (rect, &m_brushBack, &m_penBorder);
+ DrawRect (&m_rectBar, &m_brushBar);
+ DrawRect (&m_rectCursor, NULL, &m_penCursor);
}
void CVMROSD::DrawMessage()
{
- if(m_BitmapInfo.bmWidth * m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel / 8) == 0)
- return;
- if(m_nMessagePos != OSD_NOMESSAGE)
- {
- CRect rectText(0, 0, 0, 0);
- CRect rectMessages;
-
- m_MemDC.DrawText(m_strMessage, &rectText, DT_CALCRECT);
- rectText.InflateRect(20, 10);
- switch(m_nMessagePos)
- {
- case OSD_TOPLEFT :
- rectMessages = CRect(10, 10, rectText.right + 10, rectText.bottom + 10);
- break;
- case OSD_TOPRIGHT :
- default :
- rectMessages = CRect(m_rectWnd.right - 10 - rectText.Width(), 10, m_rectWnd.right - 10, rectText.bottom + 10);
- break;
- }
- DrawRect(&rectMessages, &m_brushBack, &m_penBorder);
- m_MemDC.DrawText(m_strMessage, &rectMessages, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
- }
+ if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0)
+ return;
+ if (m_nMessagePos != OSD_NOMESSAGE)
+ {
+ CRect rectText (0,0,0,0);
+ CRect rectMessages;
+
+ m_MemDC.DrawText (m_strMessage, &rectText, DT_CALCRECT);
+ rectText.InflateRect(20, 10);
+ switch (m_nMessagePos)
+ {
+ case OSD_TOPLEFT :
+ rectMessages = CRect (10, 10, rectText.right + 10, rectText.bottom + 10);
+ break;
+ case OSD_TOPRIGHT :
+ default :
+ rectMessages = CRect (m_rectWnd.right-10-rectText.Width(), 10, m_rectWnd.right-10, rectText.bottom + 10);
+ break;
+ }
+ DrawRect (&rectMessages, &m_brushBack, &m_penBorder);
+ m_MemDC.DrawText (m_strMessage, &rectMessages, DT_SINGLELINE |DT_CENTER|DT_VCENTER);
+ }
}
void CVMROSD::Invalidate()
{
- CAutoLock Lock(&m_Lock);
- if(m_BitmapInfo.bmWidth * m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel / 8) == 0)
- return;
- memsetd(m_BitmapInfo.bmBits, 0xff000000, m_BitmapInfo.bmWidth * m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel / 8));
-
- if(m_bSeekBarVisible) DrawSlider(&m_rectSeekBar, m_llSeekMin, m_llSeekMax, m_llSeekPos);
- DrawMessage();
-
- if(m_pVMB)
- {
- m_VMR9AlphaBitmap.dwFlags &= ~VMRBITMAP_DISABLE;
- m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
- }
- else if(m_pMFVMB)
- {
- m_pMFVMB->SetAlphaBitmap(&m_MFVideoAlphaBitmap);
- }
+ CAutoLock Lock(&m_Lock);
+ if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0)
+ return;
+ memsetd(m_BitmapInfo.bmBits, 0xff000000, m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8));
+
+ if (m_bSeekBarVisible) DrawSlider(&m_rectSeekBar, m_llSeekMin, m_llSeekMax, m_llSeekPos);
+ DrawMessage();
+
+ if (m_pVMB)
+ {
+ m_VMR9AlphaBitmap.dwFlags &= ~VMRBITMAP_DISABLE;
+ m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
+ }
+ else if (m_pMFVMB)
+ {
+ m_pMFVMB->SetAlphaBitmap (&m_MFVideoAlphaBitmap);
+ }
}
void CVMROSD::UpdateSeekBarPos(CPoint point)
{
- m_llSeekPos = (point.x - m_rectBar.left) * (m_llSeekMax - m_llSeekMin) / (m_rectBar.Width() - SLIDER_CURSOR_WIDTH);
- m_llSeekPos = max(m_llSeekPos, m_llSeekMin);
- m_llSeekPos = min(m_llSeekPos, m_llSeekMax);
-
- if(m_pWnd)
- AfxGetApp()->GetMainWnd()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_llSeekPos, SB_THUMBTRACK), (LPARAM)m_pWnd->m_hWnd);
+ m_llSeekPos = (point.x - m_rectBar.left) * (m_llSeekMax-m_llSeekMin) / (m_rectBar.Width() - SLIDER_CURSOR_WIDTH);
+ m_llSeekPos = max (m_llSeekPos, m_llSeekMin);
+ m_llSeekPos = min (m_llSeekPos, m_llSeekMax);
+
+ if (m_pWnd)
+ AfxGetApp()->GetMainWnd()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_llSeekPos, SB_THUMBTRACK), (LPARAM)m_pWnd->m_hWnd);
}
bool CVMROSD::OnMouseMove(UINT nFlags, CPoint point)
{
- bool bRet = false;
-
- if(m_pVMB || m_pMFVMB)
- {
- if(m_bCursorMoving)
- {
- UpdateSeekBarPos(point);
- Invalidate();
- }
- else if(!m_bSeekBarVisible && AfxGetAppSettings().IsD3DFullscreen() && m_rectSeekBar.PtInRect(point))
- {
- m_bSeekBarVisible = true;
- Invalidate();
- }
- else if(m_bSeekBarVisible && !m_rectSeekBar.PtInRect(point))
- {
- m_bSeekBarVisible = false;
- // Add new timer for removing any messages
- if(m_pWnd)
- {
- KillTimer(m_pWnd->m_hWnd, (long)this);
- SetTimer(m_pWnd->m_hWnd, (long)this, 1000, (TIMERPROC)TimerFunc);
- }
- Invalidate();
- }
- else
- bRet = false;
- }
-
- return bRet;
+ bool bRet = false;
+
+ if (m_pVMB || m_pMFVMB)
+ {
+ if (m_bCursorMoving)
+ {
+ UpdateSeekBarPos(point);
+ Invalidate();
+ }
+ else if (!m_bSeekBarVisible && AfxGetAppSettings().IsD3DFullscreen() && m_rectSeekBar.PtInRect(point))
+ {
+ m_bSeekBarVisible = true;
+ Invalidate();
+ }
+ else if (m_bSeekBarVisible && !m_rectSeekBar.PtInRect(point))
+ {
+ m_bSeekBarVisible = false;
+ // Add new timer for removing any messages
+ if (m_pWnd)
+ {
+ KillTimer(m_pWnd->m_hWnd, (long)this);
+ SetTimer(m_pWnd->m_hWnd, (long)this, 1000, (TIMERPROC)TimerFunc);
+ }
+ Invalidate();
+ }
+ else
+ bRet = false;
+ }
+
+ return bRet;
}
bool CVMROSD::OnLButtonDown(UINT nFlags, CPoint point)
{
- bool bRet = false;
- if(m_pVMB || m_pMFVMB)
- {
- if(m_rectCursor.PtInRect(point))
- {
- m_bCursorMoving = true;
- bRet = true;
- }
- else if(m_rectSeekBar.PtInRect(point))
- {
- bRet = true;
- UpdateSeekBarPos(point);
- Invalidate();
- }
- }
-
- return bRet;
+ bool bRet = false;
+ if (m_pVMB || m_pMFVMB)
+ {
+ if (m_rectCursor.PtInRect (point))
+ {
+ m_bCursorMoving = true;
+ bRet = true;
+ }
+ else if (m_rectSeekBar.PtInRect(point))
+ {
+ bRet = true;
+ UpdateSeekBarPos(point);
+ Invalidate();
+ }
+ }
+
+ return bRet;
}
bool CVMROSD::OnLButtonUp(UINT nFlags, CPoint point)
{
- bool bRet = false;
-
- if(m_pVMB || m_pMFVMB)
- {
- m_bCursorMoving = false;
-
- bRet = (m_rectCursor.PtInRect(point) || m_rectSeekBar.PtInRect(point));
- }
- return bRet;
+ bool bRet = false;
+
+ if (m_pVMB || m_pMFVMB)
+ {
+ m_bCursorMoving = false;
+
+ bRet = (m_rectCursor.PtInRect (point) || m_rectSeekBar.PtInRect(point));
+ }
+ return bRet;
}
__int64 CVMROSD::GetPos()
{
- return m_llSeekPos;
+ return m_llSeekPos;
}
void CVMROSD::SetPos(__int64 pos)
{
- m_llSeekPos = pos;
+ m_llSeekPos = pos;
}
void CVMROSD::SetRange(__int64 start, __int64 stop)
{
- m_llSeekMin = start;
- m_llSeekMax = stop;
+ m_llSeekMin = start;
+ m_llSeekMax = stop;
}
void CVMROSD::GetRange(__int64& start, __int64& stop)
{
- start = m_llSeekMin;
- stop = m_llSeekMax;
+ start = m_llSeekMin;
+ stop = m_llSeekMax;
}
void CVMROSD::TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
{
- CVMROSD* pVMROSD = (CVMROSD*) nIDEvent;
- if(pVMROSD)
- {
- pVMROSD->ClearMessage();
- }
- KillTimer(hWnd, nIDEvent);
+ CVMROSD* pVMROSD = (CVMROSD*) nIDEvent;
+ if (pVMROSD)
+ {
+ pVMROSD->ClearMessage();
+ }
+ KillTimer(hWnd, nIDEvent);
}
void CVMROSD::ClearMessage()
{
- CAutoLock Lock(&m_Lock);
- if(m_bSeekBarVisible)
- return;
- if(m_pVMB)
- {
- DWORD dwBackup = (m_VMR9AlphaBitmap.dwFlags | VMRBITMAP_DISABLE);
- m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_DISABLE;
- m_nMessagePos = OSD_NOMESSAGE;
- m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
- m_VMR9AlphaBitmap.dwFlags = dwBackup;
- }
- else if(m_pMFVMB)
- {
- m_pMFVMB->ClearAlphaBitmap();
- }
+ CAutoLock Lock(&m_Lock);
+ if (m_bSeekBarVisible)
+ return;
+ if (m_pVMB)
+ {
+ DWORD dwBackup = (m_VMR9AlphaBitmap.dwFlags | VMRBITMAP_DISABLE);
+ m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_DISABLE;
+ m_nMessagePos = OSD_NOMESSAGE;
+ m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
+ m_VMR9AlphaBitmap.dwFlags = dwBackup;
+ }
+ else if (m_pMFVMB)
+ {
+ m_pMFVMB->ClearAlphaBitmap();
+ }
}
-void CVMROSD::DisplayMessage(OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration, int FontSize, CString OSD_Font)
+void CVMROSD::DisplayMessage (OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration, int FontSize, CString OSD_Font)
{
- if(m_pVMB || m_pMFVMB)
- {
- m_nMessagePos = nPos;
- m_strMessage = strMsg;
-
- int temp_m_FontSize = m_FontSize;
- CString temp_m_OSD_Font = m_OSD_Font;
-
- if(FontSize == 0) m_FontSize = AfxGetAppSettings().nOSD_Size;
- else m_FontSize = FontSize;
- if(m_FontSize < 10 || m_FontSize > 26) m_FontSize = 20;
- if(OSD_Font == _T("")) m_OSD_Font = AfxGetAppSettings().m_OSD_Font;
- else m_OSD_Font = OSD_Font;
-
- if((temp_m_FontSize != m_FontSize) || (temp_m_OSD_Font != m_OSD_Font))
- {
- if(m_MainFont.GetSafeHandle())
- m_MainFont.DeleteObject();
-
- m_MainFont.CreatePointFont(m_FontSize * 10, m_OSD_Font);
- m_MemDC.SelectObject(m_MainFont);
- }
-
- if(m_pWnd)
- {
- KillTimer(m_pWnd->m_hWnd, (long)this);
- if(nDuration != -1) SetTimer(m_pWnd->m_hWnd, (long)this, nDuration, (TIMERPROC)TimerFunc);
- }
- Invalidate();
- }
+ if (m_pVMB || m_pMFVMB)
+ {
+ m_nMessagePos = nPos;
+ m_strMessage = strMsg;
+
+ int temp_m_FontSize = m_FontSize;
+ CString temp_m_OSD_Font = m_OSD_Font;
+
+ if (FontSize == 0) m_FontSize = AfxGetAppSettings().nOSD_Size;
+ else m_FontSize = FontSize;
+ if (m_FontSize<10 || m_FontSize>26) m_FontSize=20;
+ if (OSD_Font == _T("")) m_OSD_Font = AfxGetAppSettings().m_OSD_Font;
+ else m_OSD_Font = OSD_Font;
+
+ if((temp_m_FontSize != m_FontSize) || (temp_m_OSD_Font != m_OSD_Font))
+ {
+ if(m_MainFont.GetSafeHandle())
+ m_MainFont.DeleteObject();
+
+ m_MainFont.CreatePointFont(m_FontSize*10, m_OSD_Font);
+ m_MemDC.SelectObject(m_MainFont);
+ }
+
+ if (m_pWnd)
+ {
+ KillTimer(m_pWnd->m_hWnd, (long)this);
+ if (nDuration != -1) SetTimer(m_pWnd->m_hWnd, (long)this, nDuration, (TIMERPROC)TimerFunc);
+ }
+ Invalidate();
+ }
}
diff --git a/src/apps/mplayerc/VMROSD.h b/src/apps/mplayerc/VMROSD.h
index d4b7083d5..c5abf2c9c 100644
--- a/src/apps/mplayerc/VMROSD.h
+++ b/src/apps/mplayerc/VMROSD.h
@@ -30,90 +30,90 @@
typedef enum
{
- OSD_TRANSPARENT,
- OSD_BACKGROUND,
- OSD_BORDER,
- OSD_TEXT,
- OSD_BAR,
- OSD_CURSOR,
- OSD_LAST
+ OSD_TRANSPARENT,
+ OSD_BACKGROUND,
+ OSD_BORDER,
+ OSD_TEXT,
+ OSD_BAR,
+ OSD_CURSOR,
+ OSD_LAST
} OSD_COLORS;
typedef enum
{
- OSD_NOMESSAGE,
- OSD_TOPLEFT,
- OSD_TOPRIGHT,
+ OSD_NOMESSAGE,
+ OSD_TOPLEFT,
+ OSD_TOPRIGHT,
} OSD_MESSAGEPOS;
class CVMROSD
{
public:
- CVMROSD(void);
- ~CVMROSD(void);
+ CVMROSD(void);
+ ~CVMROSD(void);
- void Start(CWnd* pWnd, CComPtr<IVMRMixerBitmap9> pVMB);
- void Start(CWnd* pWnd, CComPtr<IMFVideoMixerBitmap> pVMB);
- void Stop();
+ void Start (CWnd* pWnd, CComPtr<IVMRMixerBitmap9> pVMB);
+ void Start (CWnd* pWnd, CComPtr<IMFVideoMixerBitmap> pVMB);
+ void Stop();
- void DisplayMessage(OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration = 5000, int FontSize = 0, CString OSD_Font = _T(""));
- void ClearMessage();
+ void DisplayMessage (OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration = 5000, int FontSize = 0, CString OSD_Font = _T(""));
+ void ClearMessage();
- __int64 GetPos();
- void SetPos(__int64 pos);
- void SetRange(__int64 start, __int64 stop);
- void GetRange(__int64& start, __int64& stop);
+ __int64 GetPos();
+ void SetPos(__int64 pos);
+ void SetRange(__int64 start, __int64 stop);
+ void GetRange(__int64& start, __int64& stop);
- void OnSize(UINT nType, int cx, int cy);
- bool OnMouseMove(UINT nFlags, CPoint point);
- bool OnLButtonDown(UINT nFlags, CPoint point);
- bool OnLButtonUp(UINT nFlags, CPoint point);
+ void OnSize(UINT nType, int cx, int cy);
+ bool OnMouseMove(UINT nFlags, CPoint point);
+ bool OnLButtonDown(UINT nFlags, CPoint point);
+ bool OnLButtonUp(UINT nFlags, CPoint point);
private :
- CComPtr<IVMRMixerBitmap9> m_pVMB;
- CComPtr<IMFVideoMixerBitmap> m_pMFVMB;
- CWnd* m_pWnd;
-
- CCritSec m_Lock;
- CDC m_MemDC;
- VMR9AlphaBitmap m_VMR9AlphaBitmap;
- MFVideoAlphaBitmap m_MFVideoAlphaBitmap;
- BITMAP m_BitmapInfo;
-
- CFont m_MainFont;
- CPen m_penBorder;
- CPen m_penCursor;
- CBrush m_brushBack;
- CBrush m_brushBar;
- int m_FontSize;
- CString m_OSD_Font;
-
- CRect m_rectWnd;
- COLORREF m_Color[OSD_LAST];
-
- // Curseur de calage
- CRect m_rectSeekBar;
- CRect m_rectCursor;
- CRect m_rectBar;
- bool m_bCursorMoving;
- bool m_bSeekBarVisible;
- __int64 m_llSeekMin;
- __int64 m_llSeekMax;
- __int64 m_llSeekPos;
-
- // Messages
- CString m_strMessage;
- OSD_MESSAGEPOS m_nMessagePos;
-
- void UpdateBitmap();
- void CalcRect();
- void UpdateSeekBarPos(CPoint point);
- void DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPos);
- void DrawRect(CRect* rect, CBrush* pBrush = NULL, CPen* pPen = NULL);
- void Invalidate();
- void DrawMessage();
-
- static void CALLBACK TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime);
+ CComPtr<IVMRMixerBitmap9> m_pVMB;
+ CComPtr<IMFVideoMixerBitmap> m_pMFVMB;
+ CWnd* m_pWnd;
+
+ CCritSec m_Lock;
+ CDC m_MemDC;
+ VMR9AlphaBitmap m_VMR9AlphaBitmap;
+ MFVideoAlphaBitmap m_MFVideoAlphaBitmap;
+ BITMAP m_BitmapInfo;
+
+ CFont m_MainFont;
+ CPen m_penBorder;
+ CPen m_penCursor;
+ CBrush m_brushBack;
+ CBrush m_brushBar;
+ int m_FontSize;
+ CString m_OSD_Font;
+
+ CRect m_rectWnd;
+ COLORREF m_Color[OSD_LAST];
+
+ // Curseur de calage
+ CRect m_rectSeekBar;
+ CRect m_rectCursor;
+ CRect m_rectBar;
+ bool m_bCursorMoving;
+ bool m_bSeekBarVisible;
+ __int64 m_llSeekMin;
+ __int64 m_llSeekMax;
+ __int64 m_llSeekPos;
+
+ // Messages
+ CString m_strMessage;
+ OSD_MESSAGEPOS m_nMessagePos;
+
+ void UpdateBitmap();
+ void CalcRect();
+ void UpdateSeekBarPos(CPoint point);
+ void DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPos);
+ void DrawRect(CRect* rect, CBrush* pBrush = NULL, CPen* pPen = NULL);
+ void Invalidate();
+ void DrawMessage();
+
+ static void CALLBACK TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime);
};
diff --git a/src/apps/mplayerc/VolumeCtrl.cpp b/src/apps/mplayerc/VolumeCtrl.cpp
index 23bfc1343..2da29e9e7 100644
--- a/src/apps/mplayerc/VolumeCtrl.cpp
+++ b/src/apps/mplayerc/VolumeCtrl.cpp
@@ -39,38 +39,38 @@ CVolumeCtrl::~CVolumeCtrl()
bool CVolumeCtrl::Create(CWnd* pParentWnd)
{
- if(!CSliderCtrl::Create(WS_CHILD | WS_VISIBLE | TBS_NOTICKS | TBS_HORZ, CRect(0, 0, 0, 0), pParentWnd, IDC_SLIDER1))
- return(false);
+ if(!CSliderCtrl::Create(WS_CHILD|WS_VISIBLE|TBS_NOTICKS|TBS_HORZ, CRect(0,0,0,0), pParentWnd, IDC_SLIDER1))
+ return(false);
- SetRange(1, 100);
- SetPosInternal(AfxGetAppSettings().nVolume);
- SetPageSize(5);
- SetLineSize(0);
+ SetRange(1, 100);
+ SetPosInternal(AfxGetAppSettings().nVolume);
+ SetPageSize(5);
+ SetLineSize(0);
- return(true);
+ return(true);
}
void CVolumeCtrl::SetPosInternal(int pos)
{
- SetPos(pos);
- GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); // this will be reflected back on us
+ SetPos(pos);
+ GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); // this will be reflected back on us
}
void CVolumeCtrl::IncreaseVolume()
{
- (GetPos() == 1) ? SetPosInternal(GetPos() + GetPageSize() - 1) : SetPosInternal(GetPos() + GetPageSize());
+ (GetPos() == 1) ? SetPosInternal(GetPos() + GetPageSize() - 1) : SetPosInternal(GetPos() + GetPageSize());
}
void CVolumeCtrl::DecreaseVolume()
{
- SetPosInternal(GetPos() - GetPageSize());
+ SetPosInternal(GetPos() - GetPageSize());
}
BEGIN_MESSAGE_MAP(CVolumeCtrl, CSliderCtrl)
- ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdraw)
- ON_WM_LBUTTONDOWN()
- ON_WM_SETFOCUS()
- ON_WM_HSCROLL_REFLECT()
+ ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdraw)
+ ON_WM_LBUTTONDOWN()
+ ON_WM_SETFOCUS()
+ ON_WM_HSCROLL_REFLECT()
END_MESSAGE_MAP()
// CVolumeCtrl message handlers
@@ -78,108 +78,108 @@ END_MESSAGE_MAP()
void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
-
- LRESULT lr = CDRF_DODEFAULT;
-
- if(m_fSelfDrawn)
- switch(pNMCD->dwDrawStage)
- {
- case CDDS_PREPAINT:
- lr = CDRF_NOTIFYITEMDRAW;
- break;
-
- case CDDS_ITEMPREPAINT:
- if(pNMCD->dwItemSpec == TBCD_CHANNEL)
- {
- CDC dc;
- dc.Attach(pNMCD->hdc);
-
- CRect r;
- GetClientRect(r);
- r.DeflateRect(8, 4, 10, 6);
- CopyRect(&pNMCD->rc, &r);
- CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
- CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
- CPen* old = dc.SelectObject(&light);
- dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top);
- dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom);
- dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom);
- dc.SelectObject(&shadow);
- dc.LineTo(pNMCD->rc.right, pNMCD->rc.top);
- dc.SelectObject(old);
-
- dc.Detach();
- lr = CDRF_SKIPDEFAULT;
- }
- else if(pNMCD->dwItemSpec == TBCD_THUMB)
- {
- CDC dc;
- dc.Attach(pNMCD->hdc);
- pNMCD->rc.bottom--;
- CRect r(pNMCD->rc);
- r.DeflateRect(0, 0, 1, 0);
-
- COLORREF shadow = GetSysColor(COLOR_3DSHADOW);
- COLORREF light = GetSysColor(COLOR_3DHILIGHT);
- dc.Draw3dRect(&r, light, 0);
- r.DeflateRect(0, 0, 1, 1);
- dc.Draw3dRect(&r, light, shadow);
- r.DeflateRect(1, 1, 1, 1);
- dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
- dc.SetPixel(r.left + 7, r.top - 1, GetSysColor(COLOR_BTNFACE));
-
- dc.Detach();
- lr = CDRF_SKIPDEFAULT;
- }
-
- break;
- };
-
- pNMCD->uItemState &= ~CDIS_FOCUS;
-
- *pResult = lr;
+ LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
+
+ LRESULT lr = CDRF_DODEFAULT;
+
+ if(m_fSelfDrawn)
+ switch(pNMCD->dwDrawStage)
+ {
+ case CDDS_PREPAINT:
+ lr = CDRF_NOTIFYITEMDRAW;
+ break;
+
+ case CDDS_ITEMPREPAINT:
+ if(pNMCD->dwItemSpec == TBCD_CHANNEL)
+ {
+ CDC dc;
+ dc.Attach(pNMCD->hdc);
+
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(8, 4, 10, 6);
+ CopyRect(&pNMCD->rc, &r);
+ CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
+ CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
+ CPen* old = dc.SelectObject(&light);
+ dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top);
+ dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom);
+ dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom);
+ dc.SelectObject(&shadow);
+ dc.LineTo(pNMCD->rc.right, pNMCD->rc.top);
+ dc.SelectObject(old);
+
+ dc.Detach();
+ lr = CDRF_SKIPDEFAULT;
+ }
+ else if(pNMCD->dwItemSpec == TBCD_THUMB)
+ {
+ CDC dc;
+ dc.Attach(pNMCD->hdc);
+ pNMCD->rc.bottom--;
+ CRect r(pNMCD->rc);
+ r.DeflateRect(0, 0, 1, 0);
+
+ COLORREF shadow = GetSysColor(COLOR_3DSHADOW);
+ COLORREF light = GetSysColor(COLOR_3DHILIGHT);
+ dc.Draw3dRect(&r, light, 0);
+ r.DeflateRect(0, 0, 1, 1);
+ dc.Draw3dRect(&r, light, shadow);
+ r.DeflateRect(1, 1, 1, 1);
+ dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
+ dc.SetPixel(r.left+7, r.top-1, GetSysColor(COLOR_BTNFACE));
+
+ dc.Detach();
+ lr = CDRF_SKIPDEFAULT;
+ }
+
+ break;
+ };
+
+ pNMCD->uItemState &= ~CDIS_FOCUS;
+
+ *pResult = lr;
}
void CVolumeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
- CRect r;
- GetChannelRect(&r);
+ CRect r;
+ GetChannelRect(&r);
+
+ if(r.left >= r.right) return;
- if(r.left >= r.right) return;
+ int start, stop;
+ GetRange(start, stop);
- int start, stop;
- GetRange(start, stop);
+ int pos = GetPos();
- int pos = GetPos();
+ r.left += 3;
+ r.right -= 4;
- r.left += 3;
- r.right -= 4;
+ if(point.x < r.left) SetPos(start);
+ else if(point.x >= r.right) SetPos(stop);
+ else
+ {
+ int w = r.right - r.left;
+ if(start < stop)
+ SetPosInternal(start + ((stop - start) * (point.x - r.left) + (w/2)) / w);
+ }
- if(point.x < r.left) SetPos(start);
- else if(point.x >= r.right) SetPos(stop);
- else
- {
- int w = r.right - r.left;
- if(start < stop)
- SetPosInternal(start + ((stop - start) *(point.x - r.left) + (w / 2)) / w);
- }
-
- CSliderCtrl::OnLButtonDown(nFlags, point);
+ CSliderCtrl::OnLButtonDown(nFlags, point);
}
void CVolumeCtrl::OnSetFocus(CWnd* pOldWnd)
{
- CSliderCtrl::OnSetFocus(pOldWnd);
+ CSliderCtrl::OnSetFocus(pOldWnd);
- AfxGetMainWnd()->SetFocus(); // don't focus on us, parents will take care of our positioning
+ AfxGetMainWnd()->SetFocus(); // don't focus on us, parents will take care of our positioning
}
void CVolumeCtrl::HScroll(UINT nSBCode, UINT nPos)
{
- AfxGetAppSettings().nVolume = GetPos();
+ AfxGetAppSettings().nVolume = GetPos();
- CFrameWnd* pFrame = GetParentFrame();
- if(pFrame && pFrame != GetParent())
- pFrame->PostMessage(WM_HSCROLL, MAKEWPARAM((short)nPos, nSBCode), (LPARAM)m_hWnd);
+ CFrameWnd* pFrame = GetParentFrame();
+ if(pFrame && pFrame != GetParent())
+ pFrame->PostMessage(WM_HSCROLL, MAKEWPARAM((short)nPos, nSBCode), (LPARAM)m_hWnd);
}
diff --git a/src/apps/mplayerc/VolumeCtrl.h b/src/apps/mplayerc/VolumeCtrl.h
index 6a1a9c55c..76c9b3f9d 100644
--- a/src/apps/mplayerc/VolumeCtrl.h
+++ b/src/apps/mplayerc/VolumeCtrl.h
@@ -27,27 +27,27 @@
class CVolumeCtrl : public CSliderCtrl
{
- DECLARE_DYNAMIC(CVolumeCtrl)
+ DECLARE_DYNAMIC(CVolumeCtrl)
private:
- bool m_fSelfDrawn;
+ bool m_fSelfDrawn;
public:
- CVolumeCtrl(bool fSelfDrawn = true);
- virtual ~CVolumeCtrl();
+ CVolumeCtrl(bool fSelfDrawn = true);
+ virtual ~CVolumeCtrl();
- bool Create(CWnd* pParentWnd);
+ bool Create(CWnd* pParentWnd);
- void IncreaseVolume(), DecreaseVolume();
+ void IncreaseVolume(), DecreaseVolume();
- void SetPosInternal(int pos);
+ void SetPosInternal(int pos);
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void HScroll(UINT nSBCode, UINT nPos);
+ afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg void HScroll(UINT nSBCode, UINT nPos);
};
diff --git a/src/apps/mplayerc/WebClientSocket.cpp b/src/apps/mplayerc/WebClientSocket.cpp
index cd5c24b07..d1eb1556a 100644
--- a/src/apps/mplayerc/WebClientSocket.cpp
+++ b/src/apps/mplayerc/WebClientSocket.cpp
@@ -30,9 +30,9 @@
#include "WebServer.h"
#include "WebClientSocket.h"
-CWebClientSocket::CWebClientSocket(CWebServer* pWebServer, CMainFrame* pMainFrame)
- : m_pWebServer(pWebServer)
- , m_pMainFrame(pMainFrame)
+CWebClientSocket::CWebClientSocket(CWebServer* pWebServer, CMainFrame* pMainFrame)
+ : m_pWebServer(pWebServer)
+ , m_pMainFrame(pMainFrame)
{
}
@@ -42,701 +42,677 @@ CWebClientSocket::~CWebClientSocket()
bool CWebClientSocket::SetCookie(CString name, CString value, __time64_t expire, CString path, CString domain)
{
- if(name.IsEmpty()) return(false);
- if(value.IsEmpty())
- {
- m_cookie.RemoveKey(name);
- return true;
- }
-
- m_cookie[name] = value;
-
- m_cookieattribs[name].path = path;
- m_cookieattribs[name].domain = domain;
-
- if(expire >= 0)
- {
- CTime t(expire);
- SYSTEMTIME st;
- t.GetAsSystemTime(st);
- CStringA str;
- SystemTimeToHttpDate(st, str);
- m_cookieattribs[name].expire = str;
- }
+ if(name.IsEmpty()) return(false);
+ if(value.IsEmpty()) {m_cookie.RemoveKey(name); return true;}
- return true;
+ m_cookie[name] = value;
+
+ m_cookieattribs[name].path = path;
+ m_cookieattribs[name].domain = domain;
+
+ if(expire >= 0)
+ {
+ CTime t(expire);
+ SYSTEMTIME st;
+ t.GetAsSystemTime(st);
+ CStringA str;
+ SystemTimeToHttpDate(st, str);
+ m_cookieattribs[name].expire = str;
+ }
+
+ return true;
}
void CWebClientSocket::Clear()
{
- m_hdr.Empty();
- m_hdrlines.RemoveAll();
- m_data.Empty();
-
- m_cmd.Empty();
- m_path.Empty();
- m_ver.Empty();
- m_get.RemoveAll();
- m_post.RemoveAll();
- m_cookie.RemoveAll();
- m_request.RemoveAll();
+ m_hdr.Empty();
+ m_hdrlines.RemoveAll();
+ m_data.Empty();
+
+ m_cmd.Empty();
+ m_path.Empty();
+ m_ver.Empty();
+ m_get.RemoveAll();
+ m_post.RemoveAll();
+ m_cookie.RemoveAll();
+ m_request.RemoveAll();
}
void CWebClientSocket::Header()
{
- if(m_cmd.IsEmpty())
- {
- if(m_hdr.IsEmpty()) return;
-
- CAtlList<CString> lines;
- Explode(m_hdr, lines, '\n');
- CString str = lines.RemoveHead();
-
- CAtlList<CString> sl;
- ExplodeMin(str, sl, ' ', 3);
- m_cmd = sl.RemoveHead().MakeUpper();
- m_path = sl.RemoveHead();
- m_ver = sl.RemoveHead().MakeUpper();
- ASSERT(sl.GetCount() == 0);
-
- POSITION pos = lines.GetHeadPosition();
- while(pos)
- {
- Explode(lines.GetNext(pos), sl, ':', 2);
- if(sl.GetCount() == 2)
- m_hdrlines[sl.GetHead().MakeLower()] = sl.GetTail();
- }
- }
-
- // remember new cookies
-
- POSITION pos = m_hdrlines.GetStartPosition();
- while(pos)
- {
- CString key, value;
- m_hdrlines.GetNextAssoc(pos, key, value);
-
- if(key == _T("cookie"))
- {
- CAtlList<CString> sl;
- Explode(value, sl, ';');
- POSITION pos2 = sl.GetHeadPosition();
- while(pos2)
- {
- CAtlList<CString> sl2;
- Explode(sl.GetNext(pos2), sl2, '=', 2);
- m_cookie[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
- }
- }
- }
-
- // start new session
-
- if(!m_cookie.Lookup(_T("MPCSESSIONID"), m_sessid))
- {
- srand((unsigned int)time(NULL));
- m_sessid.Format(_T("%08x"), rand() * 0x12345678);
- SetCookie(_T("MPCSESSIONID"), m_sessid);
- }
- else
- {
- // TODO: load session
- }
-
- CStringA reshdr, resbody;
-
- if(m_cmd == _T("POST"))
- {
- CString str;
- if(m_hdrlines.Lookup(_T("content-length"), str))
- {
- int len = _tcstol(str, NULL, 10);
- str.Empty();
-
- int err;
- char c;
-
- int timeout = 1000;
-
- do
- {
- for(; len > 0 && (err = Receive(&c, 1)) > 0; len--)
- {
- m_data += c;
- if(c == '\r') continue;
- str += c;
- if(c == '\n' || len == 1)
- {
- CAtlList<CString> sl;
- Explode(AToT(UrlDecode(TToA(str))), sl, '&'); // FIXME
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- CAtlList<CString> sl2;
- Explode(sl.GetNext(pos), sl2, '=', 2);
- m_post[sl2.GetHead().MakeLower()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
- }
- str.Empty();
- }
- }
-
- if(err == SOCKET_ERROR)
- Sleep(1);
- }
- while(err == SOCKET_ERROR && GetLastError() == WSAEWOULDBLOCK
- && timeout-- > 0); // FIXME: this is just a dirty fix now
-
- // FIXME: with IE it will only work if I read +2 bytes (?), btw Receive will just return -1
- Receive(&c, 1);
- Receive(&c, 1);
- }
- }
-
- if(m_cmd == _T("GET") || m_cmd == _T("HEAD") || m_cmd == _T("POST"))
- {
- CAtlList<CString> sl;
-
- Explode(m_path, sl, '?', 2);
- m_path = sl.RemoveHead();
- m_query.Empty();
-
- if(!sl.IsEmpty())
- {
- m_query = sl.GetTail();
-
- Explode(Explode(m_query, sl, '#', 2), sl, '&'); // oh yeah
- // Explode(AToT(UrlDecode(TToA(Explode(m_query, sl, '#', 2)))), sl, '&'); // oh yeah
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- CAtlList<CString> sl2;
- Explode(AToT(UrlDecode(TToA(sl.GetNext(pos)))), sl2, '=', 2);
- // Explode(sl.GetNext(pos), sl2, '=', 2);
- m_get[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
- }
- }
-
- // m_request <-- m_get+m_post+m_cookie
- {
+ if(m_cmd.IsEmpty())
+ {
+ if(m_hdr.IsEmpty()) return;
+
+ CAtlList<CString> lines;
+ Explode(m_hdr, lines, '\n');
+ CString str = lines.RemoveHead();
+
+ CAtlList<CString> sl;
+ ExplodeMin(str, sl, ' ', 3);
+ m_cmd = sl.RemoveHead().MakeUpper();
+ m_path = sl.RemoveHead();
+ m_ver = sl.RemoveHead().MakeUpper();
+ ASSERT(sl.GetCount() == 0);
+
+ POSITION pos = lines.GetHeadPosition();
+ while(pos)
+ {
+ Explode(lines.GetNext(pos), sl, ':', 2);
+ if(sl.GetCount() == 2)
+ m_hdrlines[sl.GetHead().MakeLower()] = sl.GetTail();
+ }
+ }
+
+ // remember new cookies
+
+ POSITION pos = m_hdrlines.GetStartPosition();
+ while(pos)
+ {
+ CString key, value;
+ m_hdrlines.GetNextAssoc(pos, key, value);
+
+ if(key == _T("cookie"))
+ {
+ CAtlList<CString> sl;
+ Explode(value, sl, ';');
+ POSITION pos2 = sl.GetHeadPosition();
+ while(pos2)
+ {
+ CAtlList<CString> sl2;
+ Explode(sl.GetNext(pos2), sl2, '=', 2);
+ m_cookie[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
+ }
+ }
+ }
+
+ // start new session
+
+ if(!m_cookie.Lookup(_T("MPCSESSIONID"), m_sessid))
+ {
+ srand((unsigned int)time(NULL));
+ m_sessid.Format(_T("%08x"), rand()*0x12345678);
+ SetCookie(_T("MPCSESSIONID"), m_sessid);
+ }
+ else
+ {
+ // TODO: load session
+ }
+
+ CStringA reshdr, resbody;
+
+ if(m_cmd == _T("POST"))
+ {
+ CString str;
+ if(m_hdrlines.Lookup(_T("content-length"), str))
+ {
+ int len = _tcstol(str, NULL, 10);
+ str.Empty();
+
+ int err;
+ char c;
+
+ int timeout = 1000;
+
+ do
+ {
+ for(; len > 0 && (err = Receive(&c, 1)) > 0; len--)
+ {
+ m_data += c;
+ if(c == '\r') continue;
+ str += c;
+ if(c == '\n' || len == 1)
+ {
+ CAtlList<CString> sl;
+ Explode(AToT(UrlDecode(TToA(str))), sl, '&'); // FIXME
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ CAtlList<CString> sl2;
+ Explode(sl.GetNext(pos), sl2, '=', 2);
+ m_post[sl2.GetHead().MakeLower()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
+ }
+ str.Empty();
+ }
+ }
+
+ if(err == SOCKET_ERROR)
+ Sleep(1);
+ }
+ while(err == SOCKET_ERROR && GetLastError() == WSAEWOULDBLOCK
+ && timeout-- > 0); // FIXME: this is just a dirty fix now
+
+ // FIXME: with IE it will only work if I read +2 bytes (?), btw Receive will just return -1
+ Receive(&c, 1);
+ Receive(&c, 1);
+ }
+ }
+
+ if(m_cmd == _T("GET") || m_cmd == _T("HEAD") || m_cmd == _T("POST"))
+ {
+ CAtlList<CString> sl;
+
+ Explode(m_path, sl, '?', 2);
+ m_path = sl.RemoveHead();
+ m_query.Empty();
+
+ if(!sl.IsEmpty())
+ {
+ m_query = sl.GetTail();
+
+ Explode(Explode(m_query, sl, '#', 2), sl, '&'); // oh yeah
+ // Explode(AToT(UrlDecode(TToA(Explode(m_query, sl, '#', 2)))), sl, '&'); // oh yeah
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ CAtlList<CString> sl2;
+ Explode(AToT(UrlDecode(TToA(sl.GetNext(pos)))), sl2, '=', 2);
+ // Explode(sl.GetNext(pos), sl2, '=', 2);
+ m_get[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
+ }
+ }
+
+ // m_request <-- m_get+m_post+m_cookie
+ {
CString key, value;
- POSITION pos;
- pos = m_get.GetStartPosition();
- while(pos)
- {
- m_get.GetNextAssoc(pos, key, value);
- m_request[key] = value;
- }
- pos = m_post.GetStartPosition();
- while(pos)
- {
- m_post.GetNextAssoc(pos, key, value);
- m_request[key] = value;
- }
- pos = m_cookie.GetStartPosition();
- while(pos)
- {
- m_cookie.GetNextAssoc(pos, key, value);
- m_request[key] = value;
- }
- }
-
- m_pWebServer->OnRequest(this, reshdr, resbody);
- }
- else
- {
- reshdr = "HTTP/1.0 400 Bad Request\r\n";
- }
-
- if(!reshdr.IsEmpty())
- {
- // cookies
- {
- POSITION pos = m_cookie.GetStartPosition();
- while(pos)
- {
- CString key, value;
- m_cookie.GetNextAssoc(pos, key, value);
- reshdr += "Set-Cookie: " + key + "=" + value;
- POSITION pos2 = m_cookieattribs.GetStartPosition();
- while(pos2)
- {
- CString key;
- cookie_attribs value;
- m_cookieattribs.GetNextAssoc(pos2, key, value);
- if(!value.path.IsEmpty()) reshdr += " path=" + value.path;
- if(!value.expire.IsEmpty()) reshdr += " expire=" + value.expire;
- if(!value.domain.IsEmpty()) reshdr += " domain=" + value.domain;
- }
- reshdr += "\r\n";
- }
- }
-
- reshdr +=
- "Server: MPC WebServer\r\n"
- "Connection: close\r\n"
- "\r\n";
-
- Send(reshdr, reshdr.GetLength());
-
- if(m_cmd != _T("HEAD") && reshdr.Find("HTTP/1.0 200 OK") == 0 && !resbody.IsEmpty())
- {
- Send(resbody, resbody.GetLength());
- }
-
- CString connection = _T("close");
- m_hdrlines.Lookup(_T("connection"), connection);
-
- Clear();
-
- // TODO
- // if(connection == _T("close"))
- OnClose(0);
- }
+ POSITION pos;
+ pos = m_get.GetStartPosition();
+ while(pos) {m_get.GetNextAssoc(pos, key, value); m_request[key] = value;}
+ pos = m_post.GetStartPosition();
+ while(pos) {m_post.GetNextAssoc(pos, key, value); m_request[key] = value;}
+ pos = m_cookie.GetStartPosition();
+ while(pos) {m_cookie.GetNextAssoc(pos, key, value); m_request[key] = value;}
+ }
+
+ m_pWebServer->OnRequest(this, reshdr, resbody);
+ }
+ else
+ {
+ reshdr = "HTTP/1.0 400 Bad Request\r\n";
+ }
+
+ if(!reshdr.IsEmpty())
+ {
+ // cookies
+ {
+ POSITION pos = m_cookie.GetStartPosition();
+ while(pos)
+ {
+ CString key, value;
+ m_cookie.GetNextAssoc(pos, key, value);
+ reshdr += "Set-Cookie: " + key + "=" + value;
+ POSITION pos2 = m_cookieattribs.GetStartPosition();
+ while(pos2)
+ {
+ CString key;
+ cookie_attribs value;
+ m_cookieattribs.GetNextAssoc(pos2, key, value);
+ if(!value.path.IsEmpty()) reshdr += " path=" + value.path;
+ if(!value.expire.IsEmpty()) reshdr += " expire=" + value.expire;
+ if(!value.domain.IsEmpty()) reshdr += " domain=" + value.domain;
+ }
+ reshdr += "\r\n";
+ }
+ }
+
+ reshdr +=
+ "Server: MPC WebServer\r\n"
+ "Connection: close\r\n"
+ "\r\n";
+
+ Send(reshdr, reshdr.GetLength());
+
+ if(m_cmd != _T("HEAD") && reshdr.Find("HTTP/1.0 200 OK") == 0 && !resbody.IsEmpty())
+ {
+ Send(resbody, resbody.GetLength());
+ }
+
+ CString connection = _T("close");
+ m_hdrlines.Lookup(_T("connection"), connection);
+
+ Clear();
+
+ // TODO
+ // if(connection == _T("close"))
+ OnClose(0);
+ }
}
//
void CWebClientSocket::OnReceive(int nErrorCode)
{
- if(nErrorCode == 0)
- {
- char c;
- while(Receive(&c, 1) > 0)
- {
- if(c == '\r') continue;
- else m_hdr += c;
-
- int len = m_hdr.GetLength();
- if(len >= 2 && m_hdr[len-2] == '\n' && m_hdr[len-1] == '\n')
- {
- Header();
- return;
- }
- }
- }
-
- __super::OnReceive(nErrorCode);
+ if(nErrorCode == 0)
+ {
+ char c;
+ while(Receive(&c, 1) > 0)
+ {
+ if(c == '\r') continue;
+ else m_hdr += c;
+
+ int len = m_hdr.GetLength();
+ if(len >= 2 && m_hdr[len-2] == '\n' && m_hdr[len-1] == '\n')
+ {
+ Header();
+ return;
+ }
+ }
+ }
+
+ __super::OnReceive(nErrorCode);
}
void CWebClientSocket::OnClose(int nErrorCode)
{
- // TODO: save session
- m_pWebServer->OnClose(this);
- __super::OnClose(nErrorCode);
+ // TODO: save session
+ m_pWebServer->OnClose(this);
+ __super::OnClose(nErrorCode);
}
////////////////////
bool CWebClientSocket::OnCommand(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString arg;
- if(m_request.Lookup(_T("wm_command"), arg))
- {
- int id = _ttol(arg);
-
- if(id > 0)
- {
- if(id == ID_FILE_EXIT) m_pMainFrame->PostMessage(WM_COMMAND, id);
- else m_pMainFrame->SendMessage(WM_COMMAND, id);
- }
- else
- {
- if(arg == CMD_SETPOS && m_request.Lookup(_T("position"), arg))
- {
- int h, m, s, ms = 0;
- TCHAR c;
- if(_stscanf(arg, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms) >= 5)
- {
- REFERENCE_TIME rtPos = 10000i64 * (((h * 60 + m) * 60 + s) * 1000 + ms);
- m_pMainFrame->SeekTo(rtPos);
- for(int retries = 20; retries-- > 0; Sleep(50))
- {
- if(abs((int)((rtPos - m_pMainFrame->GetPos()) / 10000)) < 100)
- break;
- }
- }
- }
- else if(arg == CMD_SETPOS && m_request.Lookup(_T("percent"), arg))
- {
- float percent = 0;
- if(_stscanf_s(arg, _T("%f"), &percent) == 1)
- m_pMainFrame->SeekTo((REFERENCE_TIME)(percent / 100 * m_pMainFrame->GetDur()));
- }
- else if(arg == CMD_SETVOLUME && m_request.Lookup(_T("volume"), arg))
- {
- int volume = _tcstol(arg, NULL, 10);
- m_pMainFrame->m_wndToolBar.Volume = min(max(volume, 1), 100);
- m_pMainFrame->OnPlayVolume(0);
- }
- }
- }
-
- CString ref;
- if(!m_hdrlines.Lookup(_T("referer"), ref))
- return true;
-
- hdr =
- "HTTP/1.0 302 Found\r\n"
- "Location: " + CStringA(ref) + "\r\n";
-
- return true;
+ CString arg;
+ if(m_request.Lookup(_T("wm_command"), arg))
+ {
+ int id = _ttol(arg);
+
+ if(id > 0)
+ {
+ if(id == ID_FILE_EXIT) m_pMainFrame->PostMessage(WM_COMMAND, id);
+ else m_pMainFrame->SendMessage(WM_COMMAND, id);
+ }
+ else
+ {
+ if(arg == CMD_SETPOS && m_request.Lookup(_T("position"), arg))
+ {
+ int h, m, s, ms = 0;
+ TCHAR c;
+ if(_stscanf(arg, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms) >= 5)
+ {
+ REFERENCE_TIME rtPos = 10000i64*(((h*60+m)*60+s)*1000+ms);
+ m_pMainFrame->SeekTo(rtPos);
+ for(int retries = 20; retries-- > 0; Sleep(50))
+ {
+ if(abs((int)((rtPos - m_pMainFrame->GetPos())/10000)) < 100)
+ break;
+ }
+ }
+ }
+ else if(arg == CMD_SETPOS && m_request.Lookup(_T("percent"), arg))
+ {
+ float percent = 0;
+ if(_stscanf_s(arg, _T("%f"), &percent) == 1)
+ m_pMainFrame->SeekTo((REFERENCE_TIME)(percent / 100 * m_pMainFrame->GetDur()));
+ }
+ else if(arg == CMD_SETVOLUME && m_request.Lookup(_T("volume"), arg))
+ {
+ int volume = _tcstol(arg, NULL, 10);
+ m_pMainFrame->m_wndToolBar.Volume = min(max(volume, 1), 100);
+ m_pMainFrame->OnPlayVolume(0);
+ }
+ }
+ }
+
+ CString ref;
+ if(!m_hdrlines.Lookup(_T("referer"), ref))
+ return true;
+
+ hdr =
+ "HTTP/1.0 302 Found\r\n"
+ "Location: " + CStringA(ref) + "\r\n";
+
+ return true;
}
bool CWebClientSocket::OnIndex(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CStringA wmcoptions;
+ CStringA wmcoptions;
- // generate page
+ // generate page
- AppSettings& s = AfxGetAppSettings();
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- CStringA str;
- str.Format("%d", wc.cmd);
- wmcoptions += "<option value=\"" + str + "\">"
- + CStringA(wc.GetName()) + "\r\n";
- }
+ AppSettings& s = AfxGetAppSettings();
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos)
+ {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ CStringA str;
+ str.Format("%d", wc.cmd);
+ wmcoptions += "<option value=\"" + str + "\">"
+ + CStringA(wc.GetName()) + "\r\n";
+ }
- m_pWebServer->LoadPage(IDR_HTML_INDEX, body, m_path);
- body.Replace("[wmcoptions]", wmcoptions);
+ m_pWebServer->LoadPage(IDR_HTML_INDEX, body, m_path);
+ body.Replace("[wmcoptions]", wmcoptions);
- return true;
+ return true;
}
bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CAtlList<CStringA> rootdrives;
- for(TCHAR drive[] = _T("A:"); drive[0] <= 'Z'; drive[0]++)
- if(GetDriveType(drive) != DRIVE_NO_ROOT_DIR)
- rootdrives.AddTail(CStringA(drive) + '\\');
-
- // process GET
-
- CString path;
- CFileStatus fs;
- if(m_get.Lookup(_T("path"), path))
- {
- path = WToT(UTF8To16(TToA(path)));
-
- if(CFileGetStatus(path, fs) && !(fs.m_attribute & CFile::directory))
- {
- // TODO: make a new message for just opening files, this is a bit overkill now...
-
- CAtlList<CString> cmdln;
-
- cmdln.AddTail(path);
-
- CString focus;
- if(m_get.Lookup(_T("focus"), focus) && !focus.CompareNoCase(_T("no")))
- cmdln.AddTail(_T("/nofocus"));
-
- int len = 0;
-
- POSITION pos = cmdln.GetHeadPosition();
- while(pos)
- {
- CString& str = cmdln.GetNext(pos);
- len += (str.GetLength() + 1) * sizeof(TCHAR);
- }
-
- CAutoVectorPtr<BYTE> buff;
- if(buff.Allocate(4 + len))
- {
- BYTE* p = buff;
- *(DWORD*)p = cmdln.GetCount();
- p += sizeof(DWORD);
-
- POSITION pos = cmdln.GetHeadPosition();
- while(pos)
- {
- CString& str = cmdln.GetNext(pos);
- len = (str.GetLength() + 1) * sizeof(TCHAR);
- memcpy(p, (LPCTSTR)str, len);
- p += len;
- }
-
- COPYDATASTRUCT cds;
- cds.dwData = 0x6ABE51;
- cds.cbData = p - buff;
- cds.lpData = (void*)(BYTE*)buff;
- m_pMainFrame->SendMessage(WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
- }
-
- CPath p(path);
- p.RemoveFileSpec();
- path = (LPCTSTR)p;
- }
- }
- else
- {
- path = m_pMainFrame->m_wndPlaylistBar.GetCur();
-
- if(CFileGetStatus(path, fs) && !(fs.m_attribute & CFile::directory))
- {
- CPath p(path);
- p.RemoveFileSpec();
- path = (LPCTSTR)p;
- }
- }
-
- if(path.Find(_T("://")) >= 0)
- path.Empty();
-
- if(CFileGetStatus(path, fs) && (fs.m_attribute & CFile::directory)
- || path.Find(_T("\\")) == 0) // FIXME
- {
- CPath p(path);
- p.Canonicalize();
- p.MakePretty();
- p.AddBackslash();
- path = (LPCTSTR)p;
- }
-
- CStringA files;
-
- if(path.IsEmpty())
- {
- POSITION pos = rootdrives.GetHeadPosition();
- while(pos)
- {
- CStringA& drive = rootdrives.GetNext(pos);
-
- files += "<tr class=\"dir\">\r\n";
- files +=
- "<td class=\"dirname\"><a href=\"[path]?path=" + UrlEncode(drive) + "\">" + drive + "</a></td>"
- "<td class=\"dirtype\">Directory</td>"
- "<td class=\"dirsize\">&nbsp</td>\r\n"
- "<td class=\"dirdate\">&nbsp</td>";
- files += "</tr>\r\n";
- }
-
- path = "Root";
- }
- else
- {
- CString parent;
-
- if(path.GetLength() > 3)
- {
- CPath p(path + "..");
- p.Canonicalize();
- p.AddBackslash();
- parent = (LPCTSTR)p;
- }
-
- files += "<tr class=\"dir\">\r\n";
- files +=
- "<td class=\"dirname\"><a href=\"[path]?path=" + parent + "\">..</a></td>"
- "<td class=\"dirtype\">Directory</td>"
- "<td class=\"dirsize\">&nbsp</td>\r\n"
- "<td class=\"dirdate\">&nbsp</td>";
- files += "</tr>\r\n";
-
- WIN32_FIND_DATA fd = {0};
-
- HANDLE hFind = FindFirstFile(path + "*.*", &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || fd.cFileName[0] == '.')
- continue;
-
- CString fullpath = path + fd.cFileName;
-
- files += "<tr class=\"dir\">\r\n";
- files +=
- "<td class=\"dirname\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
- "<td class=\"dirtype\">Directory</td>"
- "<td class=\"dirsize\">&nbsp</td>\r\n"
- "<td class=\"dirdate\"><nobr>" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</nobr></td>";
- files += "</tr>\r\n";
- }
- while(FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
-
- hFind = FindFirstFile(path + "*.*", &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- continue;
-
- CString fullpath = path + fd.cFileName;
- TCHAR *ext = _tcsrchr(fd.cFileName, '.');
- if(ext != NULL) ext++;
-
- CStringA size;
- size.Format("%I64dK", ((UINT64)fd.nFileSizeHigh << 22) | (fd.nFileSizeLow >> 10));
-
- CString type(_T("&nbsp"));
- LoadType(fullpath, type);
-
- if(ext != NULL)
- files += "<tr class=\"" + UTF8(ext) + "\">\r\n";
- else
- files += "<tr class=\"noext\">\r\n";
- files +=
- "<td class=\"filename\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
- "<td class=\"filetype\"><nobr>" + UTF8(type) + "</nobr></td>"
- "<td class=\"filesize\" align=\"right\"><nobr>" + size + "</nobr></td>\r\n"
- "<td class=\"filedate\"><nobr>" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</nobr></td>";
- files += "</tr>\r\n";
- }
- while(FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
- }
-
- m_pWebServer->LoadPage(IDR_HTML_BROWSER, body, m_path);
- body.Replace("[charset]", "UTF-8"); // FIXME: win9x build...
- body.Replace("[currentdir]", UTF8(path));
- body.Replace("[currentfiles]", files);
-
- return true;
+ CAtlList<CStringA> rootdrives;
+ for(TCHAR drive[] = _T("A:"); drive[0] <= 'Z'; drive[0]++)
+ if(GetDriveType(drive) != DRIVE_NO_ROOT_DIR)
+ rootdrives.AddTail(CStringA(drive) + '\\');
+
+ // process GET
+
+ CString path;
+ CFileStatus fs;
+ if(m_get.Lookup(_T("path"), path))
+ {
+ path = WToT(UTF8To16(TToA(path)));
+
+ if(CFileGetStatus(path, fs) && !(fs.m_attribute&CFile::directory))
+ {
+ // TODO: make a new message for just opening files, this is a bit overkill now...
+
+ CAtlList<CString> cmdln;
+
+ cmdln.AddTail(path);
+
+ CString focus;
+ if(m_get.Lookup(_T("focus"), focus) && !focus.CompareNoCase(_T("no")))
+ cmdln.AddTail(_T("/nofocus"));
+
+ int len = 0;
+
+ POSITION pos = cmdln.GetHeadPosition();
+ while(pos)
+ {
+ CString& str = cmdln.GetNext(pos);
+ len += (str.GetLength()+1)*sizeof(TCHAR);
+ }
+
+ CAutoVectorPtr<BYTE> buff;
+ if(buff.Allocate(4+len))
+ {
+ BYTE* p = buff;
+ *(DWORD*)p = cmdln.GetCount();
+ p += sizeof(DWORD);
+
+ POSITION pos = cmdln.GetHeadPosition();
+ while(pos)
+ {
+ CString& str = cmdln.GetNext(pos);
+ len = (str.GetLength()+1)*sizeof(TCHAR);
+ memcpy(p, (LPCTSTR)str, len);
+ p += len;
+ }
+
+ COPYDATASTRUCT cds;
+ cds.dwData = 0x6ABE51;
+ cds.cbData = p - buff;
+ cds.lpData = (void*)(BYTE*)buff;
+ m_pMainFrame->SendMessage(WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
+ }
+
+ CPath p(path);
+ p.RemoveFileSpec();
+ path = (LPCTSTR)p;
+ }
+ }
+ else
+ {
+ path = m_pMainFrame->m_wndPlaylistBar.GetCur();
+
+ if(CFileGetStatus(path, fs) && !(fs.m_attribute&CFile::directory))
+ {
+ CPath p(path);
+ p.RemoveFileSpec();
+ path = (LPCTSTR)p;
+ }
+ }
+
+ if(path.Find(_T("://")) >= 0)
+ path.Empty();
+
+ if(CFileGetStatus(path, fs) && (fs.m_attribute&CFile::directory)
+ || path.Find(_T("\\")) == 0) // FIXME
+ {
+ CPath p(path);
+ p.Canonicalize();
+ p.MakePretty();
+ p.AddBackslash();
+ path = (LPCTSTR)p;
+ }
+
+ CStringA files;
+
+ if(path.IsEmpty())
+ {
+ POSITION pos = rootdrives.GetHeadPosition();
+ while(pos)
+ {
+ CStringA& drive = rootdrives.GetNext(pos);
+
+ files += "<tr class=\"dir\">\r\n";
+ files +=
+ "<td class=\"dirname\"><a href=\"[path]?path=" + UrlEncode(drive) + "\">" + drive + "</a></td>"
+ "<td class=\"dirtype\">Directory</td>"
+ "<td class=\"dirsize\">&nbsp</td>\r\n"
+ "<td class=\"dirdate\">&nbsp</td>";
+ files += "</tr>\r\n";
+ }
+
+ path = "Root";
+ }
+ else
+ {
+ CString parent;
+
+ if(path.GetLength() > 3)
+ {
+ CPath p(path + "..");
+ p.Canonicalize();
+ p.AddBackslash();
+ parent = (LPCTSTR)p;
+ }
+
+ files += "<tr class=\"dir\">\r\n";
+ files +=
+ "<td class=\"dirname\"><a href=\"[path]?path=" + parent + "\">..</a></td>"
+ "<td class=\"dirtype\">Directory</td>"
+ "<td class=\"dirsize\">&nbsp</td>\r\n"
+ "<td class=\"dirdate\">&nbsp</td>";
+ files += "</tr>\r\n";
+
+ WIN32_FIND_DATA fd = {0};
+
+ HANDLE hFind = FindFirstFile(path + "*.*", &fd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if(!(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) || fd.cFileName[0] == '.')
+ continue;
+
+ CString fullpath = path + fd.cFileName;
+
+ files += "<tr class=\"dir\">\r\n";
+ files +=
+ "<td class=\"dirname\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
+ "<td class=\"dirtype\">Directory</td>"
+ "<td class=\"dirsize\">&nbsp</td>\r\n"
+ "<td class=\"dirdate\"><nobr>" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</nobr></td>";
+ files += "</tr>\r\n";
+ }
+ while(FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+
+ hFind = FindFirstFile(path + "*.*", &fd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
+ continue;
+
+ CString fullpath = path + fd.cFileName;
+ TCHAR *ext = _tcsrchr(fd.cFileName, '.');
+ if (ext != NULL) ext++;
+
+ CStringA size;
+ size.Format("%I64dK", ((UINT64)fd.nFileSizeHigh<<22)|(fd.nFileSizeLow>>10));
+
+ CString type(_T("&nbsp"));
+ LoadType(fullpath, type);
+
+ if (ext != NULL)
+ files += "<tr class=\"" + UTF8(ext) + "\">\r\n";
+ else
+ files += "<tr class=\"noext\">\r\n";
+ files +=
+ "<td class=\"filename\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
+ "<td class=\"filetype\"><nobr>" + UTF8(type) + "</nobr></td>"
+ "<td class=\"filesize\" align=\"right\"><nobr>" + size + "</nobr></td>\r\n"
+ "<td class=\"filedate\"><nobr>" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</nobr></td>";
+ files += "</tr>\r\n";
+ }
+ while(FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+ }
+
+ m_pWebServer->LoadPage(IDR_HTML_BROWSER, body, m_path);
+ body.Replace("[charset]", "UTF-8"); // FIXME: win9x build...
+ body.Replace("[currentdir]", UTF8(path));
+ body.Replace("[currentfiles]", files);
+
+ return true;
}
bool CWebClientSocket::OnControls(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString path = m_pMainFrame->m_wndPlaylistBar.GetCur();
- CString dir;
-
- if(!path.IsEmpty())
- {
- CPath p(path);
- p.RemoveFileSpec();
- dir = (LPCTSTR)p;
- }
-
- OAFilterState fs = m_pMainFrame->GetMediaState();
- CString state;
- state.Format(_T("%d"), fs);
- CString statestring;
- switch(fs)
- {
- case State_Stopped:
- statestring = ResStr(IDS_CONTROLS_STOPPED);
- break;
- case State_Paused:
- statestring = ResStr(IDS_CONTROLS_PAUSED);
- break;
- case State_Running:
- statestring = ResStr(IDS_CONTROLS_PLAYING);
- break;
- default:
- statestring = _T("n/a");
- break;
- }
-
- int pos = (int)(m_pMainFrame->GetPos() / 10000);
- int dur = (int)(m_pMainFrame->GetDur() / 10000);
-
- CString position, duration;
- position.Format(_T("%d"), pos);
- duration.Format(_T("%d"), dur);
-
- CString positionstring, durationstring, playbackrate;
+ CString path = m_pMainFrame->m_wndPlaylistBar.GetCur();
+ CString dir;
+
+ if(!path.IsEmpty())
+ {
+ CPath p(path);
+ p.RemoveFileSpec();
+ dir = (LPCTSTR)p;
+ }
+
+ OAFilterState fs = m_pMainFrame->GetMediaState();
+ CString state;
+ state.Format(_T("%d"), fs);
+ CString statestring;
+ switch(fs)
+ {
+ case State_Stopped: statestring = ResStr(IDS_CONTROLS_STOPPED); break;
+ case State_Paused: statestring = ResStr(IDS_CONTROLS_PAUSED); break;
+ case State_Running: statestring = ResStr(IDS_CONTROLS_PLAYING); break;
+ default: statestring = _T("n/a"); break;
+ }
+
+ int pos = (int)(m_pMainFrame->GetPos()/10000);
+ int dur = (int)(m_pMainFrame->GetDur()/10000);
+
+ CString position, duration;
+ position.Format(_T("%d"), pos);
+ duration.Format(_T("%d"), dur);
+
+ CString positionstring, durationstring, playbackrate;
// positionstring.Format(_T("%02d:%02d:%02d.%03d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60, pos%1000);
// durationstring.Format(_T("%02d:%02d:%02d.%03d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60, dur%1000);
- positionstring.Format(_T("%02d:%02d:%02d"), (pos / 3600000), (pos / 60000) % 60, (pos / 1000) % 60);
- durationstring.Format(_T("%02d:%02d:%02d"), (dur / 3600000), (dur / 60000) % 60, (dur / 1000) % 60);
- playbackrate = _T("1"); // TODO
-
- CString volumelevel, muted;
- volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
- muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
-
- CString reloadtime(_T("0")); // TODO
-
- m_pWebServer->LoadPage(IDR_HTML_CONTROLS, body, m_path);
- body.Replace("[charset]", "UTF-8"); // FIXME: win9x build...
- body.Replace("[filepatharg]", UTF8Arg(path));
- body.Replace("[filepath]", UTF8(path));
- body.Replace("[filedirarg]", UTF8Arg(dir));
- body.Replace("[filedir]", UTF8(dir));
- body.Replace("[state]", UTF8(state));
- body.Replace("[statestring]", UTF8(statestring));
- body.Replace("[position]", UTF8(position));
- body.Replace("[positionstring]", UTF8(positionstring));
- body.Replace("[duration]", UTF8(duration));
- body.Replace("[durationstring]", UTF8(durationstring));
- body.Replace("[volumelevel]", UTF8(volumelevel));
- body.Replace("[muted]", UTF8(muted));
- body.Replace("[playbackrate]", UTF8(playbackrate));
- body.Replace("[reloadtime]", UTF8(reloadtime));
-
- return true;
+ positionstring.Format(_T("%02d:%02d:%02d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60);
+ durationstring.Format(_T("%02d:%02d:%02d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60);
+ playbackrate = _T("1"); // TODO
+
+ CString volumelevel, muted;
+ volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
+ muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
+
+ CString reloadtime(_T("0")); // TODO
+
+ m_pWebServer->LoadPage(IDR_HTML_CONTROLS, body, m_path);
+ body.Replace("[charset]", "UTF-8"); // FIXME: win9x build...
+ body.Replace("[filepatharg]", UTF8Arg(path));
+ body.Replace("[filepath]", UTF8(path));
+ body.Replace("[filedirarg]", UTF8Arg(dir));
+ body.Replace("[filedir]", UTF8(dir));
+ body.Replace("[state]", UTF8(state));
+ body.Replace("[statestring]", UTF8(statestring));
+ body.Replace("[position]", UTF8(position));
+ body.Replace("[positionstring]", UTF8(positionstring));
+ body.Replace("[duration]", UTF8(duration));
+ body.Replace("[durationstring]", UTF8(durationstring));
+ body.Replace("[volumelevel]", UTF8(volumelevel));
+ body.Replace("[muted]", UTF8(muted));
+ body.Replace("[playbackrate]", UTF8(playbackrate));
+ body.Replace("[reloadtime]", UTF8(reloadtime));
+
+ return true;
}
bool CWebClientSocket::OnStatus(CStringA& hdr, CStringA& body, CStringA& mime)
{
- /*
- CString path = m_pMainFrame->m_wndPlaylistBar.GetCur(), dir;
- if(!path.IsEmpty()) {CPath p(path); p.RemoveFileSpec(); dir = (LPCTSTR)p;}
- path.Replace(_T("'"), _T("\\'"));
- dir.Replace(_T("'"), _T("\\'"));
-
- CString volumelevel, muted;
- volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
- muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
- body.Replace("[volumelevel]", UTF8(volumelevel));
- body.Replace("[muted]", UTF8(muted));
- */
- CString title;
- m_pMainFrame->GetWindowText(title);
-
- CString status;// = m_pMainFrame->GetStatusMessage();
- OAFilterState fs = m_pMainFrame->GetMediaState();
- switch(fs)
- {
- case State_Stopped:
- status = ResStr(IDS_CONTROLS_STOPPED);
- break;
- case State_Paused:
- status = ResStr(IDS_CONTROLS_PAUSED);
- break;
- case State_Running:
- status = ResStr(IDS_CONTROLS_PLAYING);
- break;
- default:
- status = _T("n/a");
- break;
- }
-
- int pos = (int)(m_pMainFrame->GetPos() / 10000);
- int dur = (int)(m_pMainFrame->GetDur() / 10000);
-
- CString posstr, durstr;
- posstr.Format(_T("%02d:%02d:%02d"), (pos / 3600000), (pos / 60000) % 60, (pos / 1000) % 60);
- durstr.Format(_T("%02d:%02d:%02d"), (dur / 3600000), (dur / 60000) % 60, (dur / 1000) % 60);
-
- title.Replace(_T("'"), _T("\\'"));
- status.Replace(_T("'"), _T("\\'"));
-
- body.Format("OnStatus('%s', '%s', %d, '%s', %d, '%s', %d, %d)", // , '%s', '%s'
- UTF8(title), UTF8(status),
- pos, UTF8(posstr), dur, UTF8(durstr),
- m_pMainFrame->IsMuted(), m_pMainFrame->GetVolume()
- /*, UTF8(path), UTF8(dir)*/);
+/*
+ CString path = m_pMainFrame->m_wndPlaylistBar.GetCur(), dir;
+ if(!path.IsEmpty()) {CPath p(path); p.RemoveFileSpec(); dir = (LPCTSTR)p;}
+ path.Replace(_T("'"), _T("\\'"));
+ dir.Replace(_T("'"), _T("\\'"));
+
+ CString volumelevel, muted;
+ volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
+ muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
+ body.Replace("[volumelevel]", UTF8(volumelevel));
+ body.Replace("[muted]", UTF8(muted));
+*/
+ CString title;
+ m_pMainFrame->GetWindowText(title);
+
+ CString status;// = m_pMainFrame->GetStatusMessage();
+ OAFilterState fs = m_pMainFrame->GetMediaState();
+ switch (fs)
+ {
+ case State_Stopped:
+ status = ResStr(IDS_CONTROLS_STOPPED);
+ break;
+ case State_Paused:
+ status = ResStr(IDS_CONTROLS_PAUSED);
+ break;
+ case State_Running:
+ status = ResStr(IDS_CONTROLS_PLAYING);
+ break;
+ default:
+ status = _T("n/a");
+ break;
+ }
+
+ int pos = (int)(m_pMainFrame->GetPos()/10000);
+ int dur = (int)(m_pMainFrame->GetDur()/10000);
+
+ CString posstr, durstr;
+ posstr.Format(_T("%02d:%02d:%02d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60);
+ durstr.Format(_T("%02d:%02d:%02d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60);
+
+ title.Replace(_T("'"), _T("\\'"));
+ status.Replace(_T("'"), _T("\\'"));
+
+ body.Format("OnStatus('%s', '%s', %d, '%s', %d, '%s', %d, %d)", // , '%s', '%s'
+ UTF8(title), UTF8(status),
+ pos, UTF8(posstr), dur, UTF8(durstr),
+ m_pMainFrame->IsMuted(), m_pMainFrame->GetVolume()
+ /*, UTF8(path), UTF8(dir)*/);
return true;
}
bool CWebClientSocket::OnError404(CStringA& hdr, CStringA& body, CStringA& mime)
{
- m_pWebServer->LoadPage(IDR_HTML_404, body, m_path);
+ m_pWebServer->LoadPage(IDR_HTML_404, body, m_path);
return true;
}
bool CWebClientSocket::OnPlayer(CStringA& hdr, CStringA& body, CStringA& mime)
{
- m_pWebServer->LoadPage(IDR_HTML_PLAYER, body, m_path);
+ m_pWebServer->LoadPage(IDR_HTML_PLAYER, body, m_path);
return true;
}
@@ -744,52 +720,52 @@ bool CWebClientSocket::OnPlayer(CStringA& hdr, CStringA& body, CStringA& mime)
bool CWebClientSocket::OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& mime)
{
- // TODO: add quality control and return logo when nothing is loaded
-
- bool fRet = false;
-
- BYTE* pData = NULL;
- long size = 0;
- CAtlArray<BYTE> jpeg;
- if(m_pMainFrame->GetDIB(&pData, size, true))
- {
- if(CJpegEncoderMem().Encode(pData, jpeg))
- {
- hdr +=
- "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
- "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
- "Pragma: no-cache\r\n";
- body = CStringA((char*)jpeg.GetData(), jpeg.GetCount());
- mime = "image/jpeg";
- fRet = true;
- }
-
- delete [] pData;
- }
-
- return fRet;
+ // TODO: add quality control and return logo when nothing is loaded
+
+ bool fRet = false;
+
+ BYTE* pData = NULL;
+ long size = 0;
+ CAtlArray<BYTE> jpeg;
+ if(m_pMainFrame->GetDIB(&pData, size, true))
+ {
+ if(CJpegEncoderMem().Encode(pData, jpeg))
+ {
+ hdr +=
+ "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
+ "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
+ "Pragma: no-cache\r\n";
+ body = CStringA((char*)jpeg.GetData(), jpeg.GetCount());
+ mime = "image/jpeg";
+ fRet = true;
+ }
+
+ delete [] pData;
+ }
+
+ return fRet;
}
#include "ConvertDlg.h"
bool CWebClientSocket::OnConvRes(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString id;
- if(!m_get.Lookup(_T("id"), id))
- return false;
+ CString id;
+ if(!m_get.Lookup(_T("id"), id))
+ return false;
- DWORD key = 0;
- if(1 != _stscanf_s(id, _T("%x"), &key) || key == 0)
- return false;
+ DWORD key = 0;
+ if(1 != _stscanf_s(id, _T("%x"), &key) || key == 0)
+ return false;
- CAutoLock cAutoLock(&CDSMResource::m_csResources);
+ CAutoLock cAutoLock(&CDSMResource::m_csResources);
- CDSMResource* res = NULL;
- if(!CDSMResource::m_resources.Lookup(key, res) || !res)
- return false;
+ CDSMResource* res = NULL;
+ if(!CDSMResource::m_resources.Lookup(key, res) || !res)
+ return false;
- body = CStringA((const char*)res->data.GetData(), res->data.GetCount());
- mime = CString(res->mime);
+ body = CStringA((const char*)res->data.GetData(), res->data.GetCount());
+ mime = CString(res->mime);
- return true;
+ return true;
}
diff --git a/src/apps/mplayerc/WebClientSocket.h b/src/apps/mplayerc/WebClientSocket.h
index dda893870..8756b279d 100644
--- a/src/apps/mplayerc/WebClientSocket.h
+++ b/src/apps/mplayerc/WebClientSocket.h
@@ -27,44 +27,41 @@ class CWebServer;
class CWebClientSocket : public CAsyncSocket
{
- CWebServer* m_pWebServer;
- CMainFrame* m_pMainFrame;
+ CWebServer* m_pWebServer;
+ CMainFrame* m_pMainFrame;
- CString m_hdr;
+ CString m_hdr;
- struct cookie_attribs
- {
- CString path, expire, domain;
- };
- CAtlStringMap<cookie_attribs> m_cookieattribs;
+ struct cookie_attribs {CString path, expire, domain;};
+ CAtlStringMap<cookie_attribs> m_cookieattribs;
- void Clear();
- void Header();
+ void Clear();
+ void Header();
protected:
- void OnReceive(int nErrorCode);
- void OnClose(int nErrorCode);
+ void OnReceive(int nErrorCode);
+ void OnClose(int nErrorCode);
public:
- CWebClientSocket(CWebServer* pWebServer, CMainFrame* pMainFrame);
- virtual ~CWebClientSocket();
+ CWebClientSocket(CWebServer* pWebServer, CMainFrame* pMainFrame);
+ virtual ~CWebClientSocket();
- bool SetCookie(CString name, CString value = _T(""), __time64_t expire = -1, CString path = _T("/"), CString domain = _T(""));
+ bool SetCookie(CString name, CString value = _T(""), __time64_t expire = -1, CString path = _T("/"), CString domain = _T(""));
- CString m_sessid;
- CString m_cmd, m_path, m_query, m_ver;
- CStringA m_data;
- CAtlStringMap<> m_hdrlines;
- CAtlStringMap<> m_get, m_post, m_cookie;
- CAtlStringMap<> m_request;
+ CString m_sessid;
+ CString m_cmd, m_path, m_query, m_ver;
+ CStringA m_data;
+ CAtlStringMap<> m_hdrlines;
+ CAtlStringMap<> m_get, m_post, m_cookie;
+ CAtlStringMap<> m_request;
- bool OnCommand(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnIndex(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnControls(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnStatus(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnError404(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnPlayer(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnConvRes(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnCommand(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnIndex(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnControls(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnStatus(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnError404(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnPlayer(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnConvRes(CStringA& hdr, CStringA& body, CStringA& mime);
};
diff --git a/src/apps/mplayerc/WebServer.cpp b/src/apps/mplayerc/WebServer.cpp
index 4e387c82b..ca25c7fad 100644
--- a/src/apps/mplayerc/WebServer.cpp
+++ b/src/apps/mplayerc/WebServer.cpp
@@ -37,120 +37,120 @@ CAtlStringMap<UINT> CWebServer::m_downloads;
CAtlStringMap<CStringA, CStringA> CWebServer::m_mimes;
CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
- : m_pMainFrame(pMainFrame)
- , m_nPort(nPort)
+ : m_pMainFrame(pMainFrame)
+ , m_nPort(nPort)
{
- if(m_internalpages.IsEmpty())
- {
- m_internalpages[_T("/")] = &CWebClientSocket::OnIndex;
- m_internalpages[_T("/index.html")] = &CWebClientSocket::OnIndex;
- m_internalpages[_T("/browser.html")] = &CWebClientSocket::OnBrowser;
- m_internalpages[_T("/controls.html")] = &CWebClientSocket::OnControls;
- m_internalpages[_T("/command.html")] = &CWebClientSocket::OnCommand;
- m_internalpages[_T("/status.html")] = &CWebClientSocket::OnStatus;
- m_internalpages[_T("/player.html")] = &CWebClientSocket::OnPlayer;
- m_internalpages[_T("/snapshot.jpg")] = &CWebClientSocket::OnSnapShotJpeg;
- m_internalpages[_T("/404.html")] = &CWebClientSocket::OnError404;
- m_internalpages[_T("/convres.html")] = &CWebClientSocket::OnConvRes;
- }
-
- if(m_downloads.IsEmpty())
- {
- m_downloads[_T("/default.css")] = IDF_DEFAULT_CSS;
- m_downloads[_T("/vbg.gif")] = IDF_VBR_GIF;
- m_downloads[_T("/vbs.gif")] = IDF_VBS_GIF;
- m_downloads[_T("/sliderbar.gif")] = IDF_SLIDERBAR_GIF;
- m_downloads[_T("/slidergrip.gif")] = IDF_SLIDERGRIP_GIF;
- m_downloads[_T("/sliderback.gif")] = IDF_SLIDERBACK_GIF;
- m_downloads[_T("/1pix.gif")] = IDF_1PIX_GIF;
- m_downloads[_T("/headericon.png")] = IDF_HEADERICON_PNG;
- m_downloads[_T("/headerback.png")] = IDF_HEADERBACK_PNG;
- m_downloads[_T("/headerclose.png")] = IDF_HEADERCLOSE_PNG;
- m_downloads[_T("/leftside.png")] = IDF_LEFTSIDE_PNG;
- m_downloads[_T("/rightside.png")] = IDF_RIGHTSIDE_PNG;
- m_downloads[_T("/bottomside.png")] = IDF_BOTTOMSIDE_PNG;
- m_downloads[_T("/leftbottomside.png")] = IDF_LEFTBOTTOMSIDE_PNG;
- m_downloads[_T("/rightbottomside.png")] = IDF_RIGHTBOTTOMSIDE_PNG;
- m_downloads[_T("/seekbarleft.png")] = IDF_SEEKBARLEFT_PNG;
- m_downloads[_T("/seekbarmid.png")] = IDF_SEEKBARMID_PNG;
- m_downloads[_T("/seekbarright.png")] = IDF_SEEKBARRIGHT_PNG;
- m_downloads[_T("/seekbargrip.png")] = IDF_SEEKBARGRIP_PNG;
- m_downloads[_T("/logo.png")] = IDF_LOGO7;
- m_downloads[_T("/controlback.png")] = IDF_CONTROLBACK_PNG;
- m_downloads[_T("/controlbuttonplay.png")] = IDF_CONTROLBUTTONPLAY_PNG;
- m_downloads[_T("/controlbuttonpause.png")] = IDF_CONTROLBUTTONPAUSE_PNG;
- m_downloads[_T("/controlbuttonstop.png")] = IDF_CONTROLBUTTONSTOP_PNG;
- m_downloads[_T("/controlbuttonskipback.png")] = IDF_CONTROLBUTTONSKIPBACK_PNG;
- m_downloads[_T("/controlbuttondecrate.png")] = IDF_CONTROLBUTTONDECRATE_PNG;
- m_downloads[_T("/controlbuttonincrate.png")] = IDF_CONTROLBUTTONINCRATE_PNG;
- m_downloads[_T("/controlbuttonskipforward.png")] = IDF_CONTROLBUTTONSKIPFORWARD_PNG;
- m_downloads[_T("/controlbuttonstep.png")] = IDF_CONTROLBUTTONSTEP_PNG;
- m_downloads[_T("/controlvolumeon.png")] = IDF_CONTROLVOLUMEON_PNG;
- m_downloads[_T("/controlvolumeoff.png")] = IDF_CONTROLVOLUMEOFF_PNG;
- m_downloads[_T("/controlvolumebar.png")] = IDF_CONTROLVOLUMEBAR_PNG;
- m_downloads[_T("/controlvolumegrip.png")] = IDF_CONTROLVOLUMEGRIP_PNG;
- }
-
- CRegKey key;
- CString str(_T("MIME\\Database\\Content Type"));
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ))
- {
- TCHAR buff[256];
- DWORD len = countof(buff);
- for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = countof(buff))
- {
- CRegKey mime;
- TCHAR ext[64];
- ULONG len = countof(ext);
- if(ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
- && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len))
- m_mimes[CStringA(ext).MakeLower()] = CStringA(buff).MakeLower();
- }
- }
-
- m_mimes[".html"] = "text/html";
- m_mimes[".txt"] = "text/plain";
- m_mimes[".css"] = "text/css";
- m_mimes[".gif"] = "image/gif";
- m_mimes[".jpeg"] = "image/jpeg";
- m_mimes[".jpg"] = "image/jpeg";
- m_mimes[".png"] = "image/png";
-
- GetModuleFileName(AfxGetInstanceHandle(), str.GetBuffer(MAX_PATH), MAX_PATH);
- str.ReleaseBuffer();
- m_webroot = CPath(str);
- m_webroot.RemoveFileSpec();
-
- CString WebRoot = AfxGetAppSettings().WebRoot;
- WebRoot.Replace('/', '\\');
- WebRoot.Trim();
- CPath p(WebRoot);
- if(WebRoot.Find(_T(":\\")) < 0 && WebRoot.Find(_T("\\\\")) < 0) m_webroot.Append(WebRoot);
- else m_webroot = p;
- m_webroot.Canonicalize();
- m_webroot.MakePretty();
- if(!m_webroot.IsDirectory()) m_webroot = CPath();
-
- CAtlList<CString> sl;
- Explode(AfxGetAppSettings().WebServerCGI, sl, ';');
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- CAtlList<CString> sl2;
- CString ext = Explode(sl.GetNext(pos), sl2, '=', 2);
- if(sl2.GetCount() < 2) continue;
- m_cgi[ext] = sl2.GetTail();
- }
-
- m_ThreadId = 0;
+ if(m_internalpages.IsEmpty())
+ {
+ m_internalpages[_T("/")] = &CWebClientSocket::OnIndex;
+ m_internalpages[_T("/index.html")] = &CWebClientSocket::OnIndex;
+ m_internalpages[_T("/browser.html")] = &CWebClientSocket::OnBrowser;
+ m_internalpages[_T("/controls.html")] = &CWebClientSocket::OnControls;
+ m_internalpages[_T("/command.html")] = &CWebClientSocket::OnCommand;
+ m_internalpages[_T("/status.html")] = &CWebClientSocket::OnStatus;
+ m_internalpages[_T("/player.html")] = &CWebClientSocket::OnPlayer;
+ m_internalpages[_T("/snapshot.jpg")] = &CWebClientSocket::OnSnapShotJpeg;
+ m_internalpages[_T("/404.html")] = &CWebClientSocket::OnError404;
+ m_internalpages[_T("/convres.html")] = &CWebClientSocket::OnConvRes;
+ }
+
+ if(m_downloads.IsEmpty())
+ {
+ m_downloads[_T("/default.css")] = IDF_DEFAULT_CSS;
+ m_downloads[_T("/vbg.gif")] = IDF_VBR_GIF;
+ m_downloads[_T("/vbs.gif")] = IDF_VBS_GIF;
+ m_downloads[_T("/sliderbar.gif")] = IDF_SLIDERBAR_GIF;
+ m_downloads[_T("/slidergrip.gif")] = IDF_SLIDERGRIP_GIF;
+ m_downloads[_T("/sliderback.gif")] = IDF_SLIDERBACK_GIF;
+ m_downloads[_T("/1pix.gif")] = IDF_1PIX_GIF;
+ m_downloads[_T("/headericon.png")] = IDF_HEADERICON_PNG;
+ m_downloads[_T("/headerback.png")] = IDF_HEADERBACK_PNG;
+ m_downloads[_T("/headerclose.png")] = IDF_HEADERCLOSE_PNG;
+ m_downloads[_T("/leftside.png")] = IDF_LEFTSIDE_PNG;
+ m_downloads[_T("/rightside.png")] = IDF_RIGHTSIDE_PNG;
+ m_downloads[_T("/bottomside.png")] = IDF_BOTTOMSIDE_PNG;
+ m_downloads[_T("/leftbottomside.png")] = IDF_LEFTBOTTOMSIDE_PNG;
+ m_downloads[_T("/rightbottomside.png")] = IDF_RIGHTBOTTOMSIDE_PNG;
+ m_downloads[_T("/seekbarleft.png")] = IDF_SEEKBARLEFT_PNG;
+ m_downloads[_T("/seekbarmid.png")] = IDF_SEEKBARMID_PNG;
+ m_downloads[_T("/seekbarright.png")] = IDF_SEEKBARRIGHT_PNG;
+ m_downloads[_T("/seekbargrip.png")] = IDF_SEEKBARGRIP_PNG;
+ m_downloads[_T("/logo.png")] = IDF_LOGO7;
+ m_downloads[_T("/controlback.png")] = IDF_CONTROLBACK_PNG;
+ m_downloads[_T("/controlbuttonplay.png")] = IDF_CONTROLBUTTONPLAY_PNG;
+ m_downloads[_T("/controlbuttonpause.png")] = IDF_CONTROLBUTTONPAUSE_PNG;
+ m_downloads[_T("/controlbuttonstop.png")] = IDF_CONTROLBUTTONSTOP_PNG;
+ m_downloads[_T("/controlbuttonskipback.png")] = IDF_CONTROLBUTTONSKIPBACK_PNG;
+ m_downloads[_T("/controlbuttondecrate.png")] = IDF_CONTROLBUTTONDECRATE_PNG;
+ m_downloads[_T("/controlbuttonincrate.png")] = IDF_CONTROLBUTTONINCRATE_PNG;
+ m_downloads[_T("/controlbuttonskipforward.png")] = IDF_CONTROLBUTTONSKIPFORWARD_PNG;
+ m_downloads[_T("/controlbuttonstep.png")] = IDF_CONTROLBUTTONSTEP_PNG;
+ m_downloads[_T("/controlvolumeon.png")] = IDF_CONTROLVOLUMEON_PNG;
+ m_downloads[_T("/controlvolumeoff.png")] = IDF_CONTROLVOLUMEOFF_PNG;
+ m_downloads[_T("/controlvolumebar.png")] = IDF_CONTROLVOLUMEBAR_PNG;
+ m_downloads[_T("/controlvolumegrip.png")] = IDF_CONTROLVOLUMEGRIP_PNG;
+ }
+
+ CRegKey key;
+ CString str(_T("MIME\\Database\\Content Type"));
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ))
+ {
+ TCHAR buff[256];
+ DWORD len = countof(buff);
+ for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = countof(buff))
+ {
+ CRegKey mime;
+ TCHAR ext[64];
+ ULONG len = countof(ext);
+ if(ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
+ && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len))
+ m_mimes[CStringA(ext).MakeLower()] = CStringA(buff).MakeLower();
+ }
+ }
+
+ m_mimes[".html"] = "text/html";
+ m_mimes[".txt"] = "text/plain";
+ m_mimes[".css"] = "text/css";
+ m_mimes[".gif"] = "image/gif";
+ m_mimes[".jpeg"] = "image/jpeg";
+ m_mimes[".jpg"] = "image/jpeg";
+ m_mimes[".png"] = "image/png";
+
+ GetModuleFileName(AfxGetInstanceHandle(), str.GetBuffer(MAX_PATH), MAX_PATH);
+ str.ReleaseBuffer();
+ m_webroot = CPath(str);
+ m_webroot.RemoveFileSpec();
+
+ CString WebRoot = AfxGetAppSettings().WebRoot;
+ WebRoot.Replace('/', '\\');
+ WebRoot.Trim();
+ CPath p(WebRoot);
+ if(WebRoot.Find(_T(":\\")) < 0 && WebRoot.Find(_T("\\\\")) < 0) m_webroot.Append(WebRoot);
+ else m_webroot = p;
+ m_webroot.Canonicalize();
+ m_webroot.MakePretty();
+ if(!m_webroot.IsDirectory()) m_webroot = CPath();
+
+ CAtlList<CString> sl;
+ Explode(AfxGetAppSettings().WebServerCGI, sl, ';');
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ CAtlList<CString> sl2;
+ CString ext = Explode(sl.GetNext(pos), sl2, '=', 2);
+ if(sl2.GetCount() < 2) continue;
+ m_cgi[ext] = sl2.GetTail();
+ }
+
+ m_ThreadId = 0;
m_hThread = ::CreateThread(NULL, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
}
CWebServer::~CWebServer()
{
if(m_hThread != NULL)
- {
- PostThreadMessage(m_ThreadId, WM_QUIT, 0, 0);
+ {
+ PostThreadMessage(m_ThreadId, WM_QUIT, 0, 0);
WaitForSingleObject(m_hThread, 10000);
EXECUTE_ASSERT(CloseHandle(m_hThread));
}
@@ -158,511 +158,480 @@ CWebServer::~CWebServer()
DWORD WINAPI CWebServer::StaticThreadProc(LPVOID lpParam)
{
- return ((CWebServer*)lpParam)->ThreadProc();
+ return ((CWebServer*)lpParam)->ThreadProc();
}
DWORD CWebServer::ThreadProc()
{
- if(!AfxSocketInit(NULL))
- return -1;
+ if(!AfxSocketInit(NULL))
+ return -1;
- CWebServerSocket s(this, m_nPort);
+ CWebServerSocket s(this, m_nPort);
- MSG msg;
- while((int)GetMessage(&msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
+ MSG msg;
+ while((int)GetMessage(&msg, NULL, 0, 0) > 0)
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
- return 0;
+ return 0;
}
static void PutFileContents(LPCTSTR fn, const CStringA& data)
{
- if(FILE* f = _tfopen(fn, _T("wb")))
- {
- fwrite((LPCSTR)data, 1, data.GetLength(), f);
- fclose(f);
- }
+ if(FILE* f = _tfopen(fn, _T("wb")))
+ {
+ fwrite((LPCSTR)data, 1, data.GetLength(), f);
+ fclose(f);
+ }
}
void CWebServer::Deploy(CString dir)
{
- CStringA data;
- if(LoadResource(IDR_HTML_INDEX, data, RT_HTML)) PutFileContents(dir + _T("index.html"), data);
- if(LoadResource(IDR_HTML_BROWSER, data, RT_HTML)) PutFileContents(dir + _T("browser.html"), data);
- if(LoadResource(IDR_HTML_CONTROLS, data, RT_HTML)) PutFileContents(dir + _T("controls.html"), data);
- if(LoadResource(IDR_HTML_404, data, RT_HTML)) PutFileContents(dir + _T("404.html"), data);
- if(LoadResource(IDR_HTML_PLAYER, data, RT_HTML)) PutFileContents(dir + _T("player.html"), data);
-
- POSITION pos = m_downloads.GetStartPosition();
- while(pos)
- {
- CString fn;
- UINT id;
- m_downloads.GetNextAssoc(pos, fn, id);
- if(LoadResource(id, data, _T("FILE")))
- PutFileContents(dir + fn, data);
- }
+ CStringA data;
+ if(LoadResource(IDR_HTML_INDEX, data, RT_HTML)) PutFileContents(dir + _T("index.html"), data);
+ if(LoadResource(IDR_HTML_BROWSER, data, RT_HTML)) PutFileContents(dir + _T("browser.html"), data);
+ if(LoadResource(IDR_HTML_CONTROLS, data, RT_HTML)) PutFileContents(dir + _T("controls.html"), data);
+ if(LoadResource(IDR_HTML_404, data, RT_HTML)) PutFileContents(dir + _T("404.html"), data);
+ if(LoadResource(IDR_HTML_PLAYER, data, RT_HTML)) PutFileContents(dir + _T("player.html"), data);
+
+ POSITION pos = m_downloads.GetStartPosition();
+ while(pos)
+ {
+ CString fn;
+ UINT id;
+ m_downloads.GetNextAssoc(pos, fn, id);
+ if(LoadResource(id, data, _T("FILE")))
+ PutFileContents(dir + fn, data);
+ }
}
bool CWebServer::ToLocalPath(CString& path, CString& redir)
{
- if(!path.IsEmpty() && m_webroot.IsDirectory())
- {
- CString str = path;
- str.Replace('/', '\\');
- str.TrimLeft('\\');
-
- CPath p;
- p.Combine(m_webroot, str);
- p.Canonicalize();
-
- if(p.IsDirectory())
- {
- CAtlList<CString> sl;
- Explode(AfxGetAppSettings().WebDefIndex, sl, ';');
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- str = sl.GetNext(pos);
- CPath p2 = p;
- p2.Append(str);
- if(p2.FileExists())
- {
- p = p2;
- redir = path;
- if(redir.GetAt(redir.GetLength() - 1) != '/') redir += '/';
- redir += str;
- break;
- }
- }
- }
-
- if(_tcslen(p) > _tcslen(m_webroot) && p.FileExists())
- {
- path = (LPCTSTR)p;
- return true;
- }
- }
-
- return false;
+ if(!path.IsEmpty() && m_webroot.IsDirectory())
+ {
+ CString str = path;
+ str.Replace('/', '\\');
+ str.TrimLeft('\\');
+
+ CPath p;
+ p.Combine(m_webroot, str);
+ p.Canonicalize();
+
+ if(p.IsDirectory())
+ {
+ CAtlList<CString> sl;
+ Explode(AfxGetAppSettings().WebDefIndex, sl, ';');
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ str = sl.GetNext(pos);
+ CPath p2 = p;
+ p2.Append(str);
+ if(p2.FileExists())
+ {
+ p = p2;
+ redir = path;
+ if(redir.GetAt(redir.GetLength()-1) != '/') redir += '/';
+ redir += str;
+ break;
+ }
+ }
+ }
+
+ if(_tcslen(p) > _tcslen(m_webroot) && p.FileExists())
+ {
+ path = (LPCTSTR)p;
+ return true;
+ }
+ }
+
+ return false;
}
bool CWebServer::LoadPage(UINT resid, CStringA& str, CString path)
{
- CString redir;
- if(ToLocalPath(path, redir))
- {
- if(FILE* f = _tfopen(path, _T("rb")))
- {
- fseek(f, 0, 2);
- char* buff = str.GetBufferSetLength(ftell(f));
- fseek(f, 0, 0);
- int len = fread(buff, 1, str.GetLength(), f);
- fclose(f);
- return len == str.GetLength();
- }
- }
-
- return LoadResource(resid, str, RT_HTML);
+ CString redir;
+ if(ToLocalPath(path, redir))
+ {
+ if(FILE* f = _tfopen(path, _T("rb")))
+ {
+ fseek(f, 0, 2);
+ char* buff = str.GetBufferSetLength(ftell(f));
+ fseek(f, 0, 0);
+ int len = fread(buff, 1, str.GetLength(), f);
+ fclose(f);
+ return len == str.GetLength();
+ }
+ }
+
+ return LoadResource(resid, str, RT_HTML);
}
void CWebServer::OnAccept(CWebServerSocket* pServer)
{
- CAutoPtr<CWebClientSocket> p(DNew CWebClientSocket(this, m_pMainFrame));
- if(pServer->Accept(*p))
- {
- CString name;
- UINT port;
- if(AfxGetAppSettings().fWebServerLocalhostOnly && p->GetPeerName(name, port) && name != _T("127.0.0.1"))
- {
- p->Close();
- return;
- }
-
- m_clients.AddTail(p);
- }
+ CAutoPtr<CWebClientSocket> p(DNew CWebClientSocket(this, m_pMainFrame));
+ if(pServer->Accept(*p))
+ {
+ CString name;
+ UINT port;
+ if(AfxGetAppSettings().fWebServerLocalhostOnly && p->GetPeerName(name, port) && name != _T("127.0.0.1"))
+ {
+ p->Close();
+ return;
+ }
+
+ m_clients.AddTail(p);
+ }
}
void CWebServer::OnClose(CWebClientSocket* pClient)
{
- POSITION pos = m_clients.GetHeadPosition();
- while(pos)
- {
- POSITION cur = pos;
- if(m_clients.GetNext(pos) == pClient)
- {
- m_clients.RemoveAt(cur);
- break;
- }
- }
+ POSITION pos = m_clients.GetHeadPosition();
+ while(pos)
+ {
+ POSITION cur = pos;
+ if(m_clients.GetNext(pos) == pClient)
+ {
+ m_clients.RemoveAt(cur);
+ break;
+ }
+ }
}
void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& body)
{
- CPath p(pClient->m_path);
- CStringA ext = p.GetExtension().MakeLower();
- CStringA mime;
- if(ext.IsEmpty()) mime = "text/html";
- else m_mimes.Lookup(ext, mime);
-
- hdr = "HTTP/1.0 200 OK\r\n";
-
- bool fHandled = false, fCGI = false;
-
- if(!fHandled && m_webroot.IsDirectory())
- {
- CStringA tmphdr;
- fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime);
-
- if(fHandled)
- {
- tmphdr.Replace("\r\n", "\n");
- CAtlList<CStringA> hdrlines;
- ExplodeMin(tmphdr, hdrlines, '\n');
- POSITION pos = hdrlines.GetHeadPosition();
- while(pos)
- {
- POSITION cur = pos;
- CAtlList<CStringA> sl;
- CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2);
- if(sl.GetCount() < 2) continue;
- key.Trim().MakeLower();
- if(key == "content-type")
- {
- mime = sl.GetTail().Trim();
- hdrlines.RemoveAt(cur);
- }
- else if(key == "content-length")
- {
- hdrlines.RemoveAt(cur);
- }
- }
- tmphdr = Implode(hdrlines, '\n');
- tmphdr.Replace("\n", "\r\n");
- hdr += tmphdr + "\r\n";
- }
- }
-
- RequestHandler rh = NULL;
- if(!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime))
- {
- if(mime.IsEmpty()) mime = "text/html";
-
- CString redir;
- if(pClient->m_get.Lookup(_T("redir"), redir)
- || pClient->m_post.Lookup(_T("redir"), redir))
- {
- if(redir.IsEmpty()) redir = '/';
-
- hdr =
- "HTTP/1.0 302 Found\r\n"
- "Location: " + CStringA(redir) + "\r\n";
- return;
- }
-
- fHandled = true;
- }
-
- if(!fHandled && m_webroot.IsDirectory())
- {
- fHandled = LoadPage(0, body, pClient->m_path);
- }
-
- UINT resid;
- CStringA res;
- if(!fHandled && m_downloads.Lookup(pClient->m_path, resid) && LoadResource(resid, res, _T("FILE")))
- {
- if(mime.IsEmpty()) mime = "application/octet-stream";
- memcpy(body.GetBufferSetLength(res.GetLength()), res.GetBuffer(), res.GetLength());
- fHandled = true;
- }
-
- if(!fHandled)
- {
- hdr = mime == "text/html"
- ? "HTTP/1.0 301 Moved Permanently\r\n" "Location: /404.html\r\n"
- : "HTTP/1.0 404 Not Found\r\n";
- return;
- }
-
- if(mime == "text/html" && !fCGI)
- {
- hdr +=
- "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
- "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
- "Pragma: no-cache\r\n";
-
- CStringA debug;
- if(AfxGetAppSettings().fWebServerPrintDebugInfo)
- {
- debug += "<hr>\r\n";
- CString key, value;
- POSITION pos;
- pos = pClient->m_hdrlines.GetStartPosition();
- while(pos)
- {
- pClient->m_hdrlines.GetNextAssoc(pos, key, value);
- debug += "HEADER[" + key + "] = " + value + "<br>\r\n";
- }
- debug += "cmd: " + pClient->m_cmd + "<br>\r\n";
- debug += "path: " + pClient->m_path + "<br>\r\n";
- debug += "ver: " + pClient->m_ver + "<br>\r\n";
- pos = pClient->m_get.GetStartPosition();
- while(pos)
- {
- pClient->m_get.GetNextAssoc(pos, key, value);
- debug += "GET[" + key + "] = " + value + "<br>\r\n";
- }
- pos = pClient->m_post.GetStartPosition();
- while(pos)
- {
- pClient->m_post.GetNextAssoc(pos, key, value);
- debug += "POST[" + key + "] = " + value + "<br>\r\n";
- }
- pos = pClient->m_cookie.GetStartPosition();
- while(pos)
- {
- pClient->m_cookie.GetNextAssoc(pos, key, value);
- debug += "COOKIE[" + key + "] = " + value + "<br>\r\n";
- }
- pos = pClient->m_request.GetStartPosition();
- while(pos)
- {
- pClient->m_request.GetNextAssoc(pos, key, value);
- debug += "REQUEST[" + key + "] = " + value + "<br>\r\n";
- }
- }
-
- body.Replace("[path]", CStringA(pClient->m_path));
- body.Replace("[indexpath]", "/index.html");
- body.Replace("[commandpath]", "/command.html");
- body.Replace("[browserpath]", "/browser.html");
- body.Replace("[controlspath]", "/controls.html");
- body.Replace("[wmcname]", "wm_command");
- body.Replace("[setposcommand]", CMD_SETPOS);
- body.Replace("[setvolumecommand]", CMD_SETVOLUME);
- body.Replace("[debug]", debug);
- // TODO: add more general tags to replace
- }
-
- // gzip
- if(AfxGetAppSettings().fWebServerUseCompression && hdr.Find("Content-Encoding:") < 0)
- do
- {
- CString accept_encoding;
- pClient->m_hdrlines.Lookup(_T("accept-encoding"), accept_encoding);
- accept_encoding.MakeLower();
- CAtlList<CString> sl;
- ExplodeMin(accept_encoding, sl, ',');
- if(!sl.Find(_T("gzip"))) break;
-
- CHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPathA(MAX_PATH, path) || !GetTempFileNameA(path, "mpc_gz", 0, fn))
- break;
-
- gzFile gf = gzopen(fn, "wb9");
- if(!gf || gzwrite(gf, (LPVOID)(LPCSTR)body, body.GetLength()) != body.GetLength())
- {
- if(gf) gzclose(gf);
- DeleteFileA(fn);
- break;
- }
- gzclose(gf);
-
- FILE* f = fopen(fn, "rb");
- if(!f)
- {
- DeleteFileA(fn);
- break;
- }
- fseek(f, 0, 2);
- CHAR* s = body.GetBufferSetLength(ftell(f));
- fseek(f, 0, 0);
- int len = fread(s, 1, body.GetLength(), f);
- ASSERT(len == body.GetLength());
- fclose(f);
- DeleteFileA(fn);
-
- hdr += "Content-Encoding: gzip\r\n";
- }
- while(0);
-
- CStringA content;
- content.Format(
- "Content-Type: %s\r\n"
- "Content-Length: %d\r\n",
- mime, body.GetLength());
- hdr += content;
+ CPath p(pClient->m_path);
+ CStringA ext = p.GetExtension().MakeLower();
+ CStringA mime;
+ if(ext.IsEmpty()) mime = "text/html";
+ else m_mimes.Lookup(ext, mime);
+
+ hdr = "HTTP/1.0 200 OK\r\n";
+
+ bool fHandled = false, fCGI = false;
+
+ if(!fHandled && m_webroot.IsDirectory())
+ {
+ CStringA tmphdr;
+ fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime);
+
+ if(fHandled)
+ {
+ tmphdr.Replace("\r\n", "\n");
+ CAtlList<CStringA> hdrlines;
+ ExplodeMin(tmphdr, hdrlines, '\n');
+ POSITION pos = hdrlines.GetHeadPosition();
+ while(pos)
+ {
+ POSITION cur = pos;
+ CAtlList<CStringA> sl;
+ CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2);
+ if(sl.GetCount() < 2) continue;
+ key.Trim().MakeLower();
+ if(key == "content-type") {mime = sl.GetTail().Trim(); hdrlines.RemoveAt(cur);}
+ else if(key == "content-length") {hdrlines.RemoveAt(cur);}
+ }
+ tmphdr = Implode(hdrlines, '\n');
+ tmphdr.Replace("\n", "\r\n");
+ hdr += tmphdr + "\r\n";
+ }
+ }
+
+ RequestHandler rh = NULL;
+ if(!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime))
+ {
+ if(mime.IsEmpty()) mime = "text/html";
+
+ CString redir;
+ if(pClient->m_get.Lookup(_T("redir"), redir)
+ || pClient->m_post.Lookup(_T("redir"), redir))
+ {
+ if(redir.IsEmpty()) redir = '/';
+
+ hdr =
+ "HTTP/1.0 302 Found\r\n"
+ "Location: " + CStringA(redir) + "\r\n";
+ return;
+ }
+
+ fHandled = true;
+ }
+
+ if(!fHandled && m_webroot.IsDirectory())
+ {
+ fHandled = LoadPage(0, body, pClient->m_path);
+ }
+
+ UINT resid;
+ CStringA res;
+ if(!fHandled && m_downloads.Lookup(pClient->m_path, resid) && LoadResource(resid, res, _T("FILE")))
+ {
+ if(mime.IsEmpty()) mime = "application/octet-stream";
+ memcpy(body.GetBufferSetLength(res.GetLength()), res.GetBuffer(), res.GetLength());
+ fHandled = true;
+ }
+
+ if(!fHandled)
+ {
+ hdr = mime == "text/html"
+ ? "HTTP/1.0 301 Moved Permanently\r\n" "Location: /404.html\r\n"
+ : "HTTP/1.0 404 Not Found\r\n";
+ return;
+ }
+
+ if(mime == "text/html" && !fCGI)
+ {
+ hdr +=
+ "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
+ "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
+ "Pragma: no-cache\r\n";
+
+ CStringA debug;
+ if(AfxGetAppSettings().fWebServerPrintDebugInfo)
+ {
+ debug += "<hr>\r\n";
+ CString key, value;
+ POSITION pos;
+ pos = pClient->m_hdrlines.GetStartPosition();
+ while(pos) {pClient->m_hdrlines.GetNextAssoc(pos, key, value); debug += "HEADER[" + key + "] = " + value + "<br>\r\n";}
+ debug += "cmd: " + pClient->m_cmd + "<br>\r\n";
+ debug += "path: " + pClient->m_path + "<br>\r\n";
+ debug += "ver: " + pClient->m_ver + "<br>\r\n";
+ pos = pClient->m_get.GetStartPosition();
+ while(pos) {pClient->m_get.GetNextAssoc(pos, key, value); debug += "GET[" + key + "] = " + value + "<br>\r\n";}
+ pos = pClient->m_post.GetStartPosition();
+ while(pos) {pClient->m_post.GetNextAssoc(pos, key, value); debug += "POST[" + key + "] = " + value + "<br>\r\n";}
+ pos = pClient->m_cookie.GetStartPosition();
+ while(pos) {pClient->m_cookie.GetNextAssoc(pos, key, value); debug += "COOKIE[" + key + "] = " + value + "<br>\r\n";}
+ pos = pClient->m_request.GetStartPosition();
+ while(pos) {pClient->m_request.GetNextAssoc(pos, key, value); debug += "REQUEST[" + key + "] = " + value + "<br>\r\n";}
+ }
+
+ body.Replace("[path]", CStringA(pClient->m_path));
+ body.Replace("[indexpath]", "/index.html");
+ body.Replace("[commandpath]", "/command.html");
+ body.Replace("[browserpath]", "/browser.html");
+ body.Replace("[controlspath]", "/controls.html");
+ body.Replace("[wmcname]", "wm_command");
+ body.Replace("[setposcommand]", CMD_SETPOS);
+ body.Replace("[setvolumecommand]", CMD_SETVOLUME);
+ body.Replace("[debug]", debug);
+ // TODO: add more general tags to replace
+ }
+
+ // gzip
+ if(AfxGetAppSettings().fWebServerUseCompression && hdr.Find("Content-Encoding:") < 0)
+ do
+ {
+ CString accept_encoding;
+ pClient->m_hdrlines.Lookup(_T("accept-encoding"), accept_encoding);
+ accept_encoding.MakeLower();
+ CAtlList<CString> sl;
+ ExplodeMin(accept_encoding, sl, ',');
+ if(!sl.Find(_T("gzip"))) break;
+
+ CHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if(!GetTempPathA(MAX_PATH, path) || !GetTempFileNameA(path, "mpc_gz", 0, fn))
+ break;
+
+ gzFile gf = gzopen(fn, "wb9");
+ if(!gf || gzwrite(gf, (LPVOID)(LPCSTR)body, body.GetLength()) != body.GetLength())
+ {
+ if(gf) gzclose(gf);
+ DeleteFileA(fn);
+ break;
+ }
+ gzclose(gf);
+
+ FILE* f = fopen(fn, "rb");
+ if(!f) {DeleteFileA(fn); break;}
+ fseek(f, 0, 2);
+ CHAR* s = body.GetBufferSetLength(ftell(f));
+ fseek(f, 0, 0);
+ int len = fread(s, 1, body.GetLength(), f);
+ ASSERT(len == body.GetLength());
+ fclose(f);
+ DeleteFileA(fn);
+
+ hdr += "Content-Encoding: gzip\r\n";
+ }
+ while(0);
+
+ CStringA content;
+ content.Format(
+ "Content-Type: %s\r\n"
+ "Content-Length: %d\r\n",
+ mime, body.GetLength());
+ hdr += content;
}
static DWORD WINAPI KillCGI(LPVOID lParam)
{
- HANDLE hProcess = (HANDLE)lParam;
- if(WaitForSingleObject(hProcess, 30000) == WAIT_TIMEOUT)
- TerminateProcess(hProcess, 0);
- return 0;
+ HANDLE hProcess = (HANDLE)lParam;
+ if(WaitForSingleObject(hProcess, 30000) == WAIT_TIMEOUT)
+ TerminateProcess(hProcess, 0);
+ return 0;
}
bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString path = pClient->m_path, redir = path;
- if(!ToLocalPath(path, redir)) return false;
- CString ext = CPath(path).GetExtension().MakeLower();
- CPath dir(path);
- dir.RemoveFileSpec();
-
- CString cgi;
- if(!m_cgi.Lookup(ext, cgi) || !CPath(cgi).FileExists())
- return false;
-
- HANDLE hProcess = GetCurrentProcess();
- HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup = NULL;
- HANDLE hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup = NULL;
-
- SECURITY_ATTRIBUTES saAttr;
- ZeroMemory(&saAttr, sizeof(saAttr));
- saAttr.nLength = sizeof(saAttr);
- saAttr.bInheritHandle = TRUE;
-
- if(CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
- {
- BOOL fSuccess = DuplicateHandle(hProcess, hChildStdoutRd, hProcess, &hChildStdoutRdDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
- CloseHandle(hChildStdoutRd);
- }
-
- if(CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
- {
- BOOL fSuccess = DuplicateHandle(hProcess, hChildStdinWr, hProcess, &hChildStdinWrDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
- CloseHandle(hChildStdinWr);
- }
-
- STARTUPINFO siStartInfo;
- ZeroMemory(&siStartInfo, sizeof(siStartInfo));
- siStartInfo.cb = sizeof(siStartInfo);
- siStartInfo.hStdError = hChildStdoutWr;
- siStartInfo.hStdOutput = hChildStdoutWr;
- siStartInfo.hStdInput = hChildStdinRd;
- siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
- siStartInfo.wShowWindow = SW_HIDE;
-
- PROCESS_INFORMATION piProcInfo;
- ZeroMemory(&piProcInfo, sizeof(piProcInfo));
-
- CStringA envstr;
-
- if(LPVOID lpvEnv = GetEnvironmentStrings())
- {
- CString str;
-
- CAtlList<CString> env;
- for(LPTSTR lpszVariable = (LPTSTR)lpvEnv; *lpszVariable; lpszVariable += _tcslen(lpszVariable) + 1)
- if(lpszVariable != (LPTSTR)lpvEnv)
- env.AddTail(lpszVariable);
-
- env.AddTail(_T("GATEWAY_INTERFACE=CGI/1.1"));
- env.AddTail(_T("SERVER_SOFTWARE=Media Player Classic/6.4.x.y"));
- env.AddTail(_T("SERVER_PROTOCOL=") + pClient->m_ver);
- env.AddTail(_T("REQUEST_METHOD=") + pClient->m_cmd);
- env.AddTail(_T("PATH_INFO=") + redir);
- env.AddTail(_T("PATH_TRANSLATED=") + path);
- env.AddTail(_T("SCRIPT_NAME=") + redir);
- env.AddTail(_T("QUERY_STRING=") + pClient->m_query);
-
- if(pClient->m_hdrlines.Lookup(_T("content-type"), str))
- env.AddTail(_T("CONTENT_TYPE=") + str);
- if(pClient->m_hdrlines.Lookup(_T("content-length"), str))
- env.AddTail(_T("CONTENT_LENGTH=") + str);
-
- POSITION pos = pClient->m_hdrlines.GetStartPosition();
- while(pos)
- {
- CString key = pClient->m_hdrlines.GetKeyAt(pos);
- CString value = pClient->m_hdrlines.GetNextValue(pos);
- key.Replace(_T("-"), _T("_"));
- key.MakeUpper();
- env.AddTail(_T("HTTP_") + key + _T("=") + value);
- }
-
- CString name;
- UINT port;
-
- if(pClient->GetPeerName(name, port))
- {
- str.Format(_T("%d"), port);
- env.AddTail(_T("REMOTE_ADDR=") + name);
- env.AddTail(_T("REMOTE_HOST=") + name);
- env.AddTail(_T("REMOTE_PORT=") + str);
- }
-
- if(pClient->GetSockName(name, port))
- {
- str.Format(_T("%d"), port);
- env.AddTail(_T("SERVER_NAME=") + name);
- env.AddTail(_T("SERVER_PORT=") + str);
- }
-
- env.AddTail(_T("\0"));
-
- str = Implode(env, '\0');
- envstr = CStringA(str, str.GetLength());
-
- FreeEnvironmentStrings((LPTSTR)lpvEnv);
- }
-
- TCHAR* cmdln = DNew TCHAR[32768];
- _sntprintf(cmdln, 32768, _T("\"%s\" \"%s\""), cgi, path);
-
- if(hChildStdinRd && hChildStdoutWr)
- if(CreateProcess(
- NULL, cmdln, NULL, NULL, TRUE, 0,
- envstr.GetLength() ? (LPVOID)(LPCSTR)envstr : NULL,
- dir, &siStartInfo, &piProcInfo))
- {
- DWORD ThreadId;
- CreateThread(NULL, 0, KillCGI, (LPVOID)piProcInfo.hProcess, 0, &ThreadId);
-
- static const int BUFFSIZE = 1024;
- DWORD dwRead, dwWritten = 0;
-
- int i = 0, len = pClient->m_data.GetLength();
- for(; i < len; i += dwWritten)
- if(!WriteFile(hChildStdinWrDup, (LPCSTR)pClient->m_data + i, min(len - i, BUFFSIZE), &dwWritten, NULL))
- break;
-
- CloseHandle(hChildStdinWrDup);
- CloseHandle(hChildStdoutWr);
-
- body.Empty();
-
- CStringA buff;
- while(i == len && ReadFile(hChildStdoutRdDup, buff.GetBuffer(BUFFSIZE), BUFFSIZE, &dwRead, NULL) && dwRead)
- {
- buff.ReleaseBufferSetLength(dwRead);
- body += buff;
- }
-
- int hdrend = body.Find("\r\n\r\n");
- if(hdrend >= 0)
- {
- hdr = body.Left(hdrend + 2);
- body = body.Mid(hdrend + 4);
- }
-
- CloseHandle(hChildStdinRd);
- CloseHandle(hChildStdoutRdDup);
-
- CloseHandle(piProcInfo.hProcess);
- CloseHandle(piProcInfo.hThread);
- }
- else
- {
- body = _T("CGI Error");
- }
-
- delete [] cmdln;
-
- return true;
+ CString path = pClient->m_path, redir = path;
+ if(!ToLocalPath(path, redir)) return false;
+ CString ext = CPath(path).GetExtension().MakeLower();
+ CPath dir(path);
+ dir.RemoveFileSpec();
+
+ CString cgi;
+ if(!m_cgi.Lookup(ext, cgi) || !CPath(cgi).FileExists())
+ return false;
+
+ HANDLE hProcess = GetCurrentProcess();
+ HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup = NULL;
+ HANDLE hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup = NULL;
+
+ SECURITY_ATTRIBUTES saAttr;
+ ZeroMemory(&saAttr, sizeof(saAttr));
+ saAttr.nLength = sizeof(saAttr);
+ saAttr.bInheritHandle = TRUE;
+
+ if(CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
+ {
+ BOOL fSuccess = DuplicateHandle(hProcess, hChildStdoutRd, hProcess, &hChildStdoutRdDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ CloseHandle(hChildStdoutRd);
+ }
+
+ if(CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
+ {
+ BOOL fSuccess = DuplicateHandle(hProcess, hChildStdinWr, hProcess, &hChildStdinWrDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ CloseHandle(hChildStdinWr);
+ }
+
+ STARTUPINFO siStartInfo;
+ ZeroMemory(&siStartInfo, sizeof(siStartInfo));
+ siStartInfo.cb = sizeof(siStartInfo);
+ siStartInfo.hStdError = hChildStdoutWr;
+ siStartInfo.hStdOutput = hChildStdoutWr;
+ siStartInfo.hStdInput = hChildStdinRd;
+ siStartInfo.dwFlags |= STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
+ siStartInfo.wShowWindow = SW_HIDE;
+
+ PROCESS_INFORMATION piProcInfo;
+ ZeroMemory(&piProcInfo, sizeof(piProcInfo));
+
+ CStringA envstr;
+
+ if(LPVOID lpvEnv = GetEnvironmentStrings())
+ {
+ CString str;
+
+ CAtlList<CString> env;
+ for(LPTSTR lpszVariable = (LPTSTR)lpvEnv; *lpszVariable; lpszVariable += _tcslen(lpszVariable)+1)
+ if(lpszVariable != (LPTSTR)lpvEnv)
+ env.AddTail(lpszVariable);
+
+ env.AddTail(_T("GATEWAY_INTERFACE=CGI/1.1"));
+ env.AddTail(_T("SERVER_SOFTWARE=Media Player Classic/6.4.x.y"));
+ env.AddTail(_T("SERVER_PROTOCOL=") + pClient->m_ver);
+ env.AddTail(_T("REQUEST_METHOD=") + pClient->m_cmd);
+ env.AddTail(_T("PATH_INFO=") + redir);
+ env.AddTail(_T("PATH_TRANSLATED=") + path);
+ env.AddTail(_T("SCRIPT_NAME=") + redir);
+ env.AddTail(_T("QUERY_STRING=") + pClient->m_query);
+
+ if(pClient->m_hdrlines.Lookup(_T("content-type"), str))
+ env.AddTail(_T("CONTENT_TYPE=") + str);
+ if(pClient->m_hdrlines.Lookup(_T("content-length"), str))
+ env.AddTail(_T("CONTENT_LENGTH=") + str);
+
+ POSITION pos = pClient->m_hdrlines.GetStartPosition();
+ while(pos)
+ {
+ CString key = pClient->m_hdrlines.GetKeyAt(pos);
+ CString value = pClient->m_hdrlines.GetNextValue(pos);
+ key.Replace(_T("-"), _T("_"));
+ key.MakeUpper();
+ env.AddTail(_T("HTTP_") + key + _T("=") + value);
+ }
+
+ CString name;
+ UINT port;
+
+ if(pClient->GetPeerName(name, port))
+ {
+ str.Format(_T("%d"), port);
+ env.AddTail(_T("REMOTE_ADDR=")+name);
+ env.AddTail(_T("REMOTE_HOST=")+name);
+ env.AddTail(_T("REMOTE_PORT=")+str);
+ }
+
+ if(pClient->GetSockName(name, port))
+ {
+ str.Format(_T("%d"), port);
+ env.AddTail(_T("SERVER_NAME=")+name);
+ env.AddTail(_T("SERVER_PORT=")+str);
+ }
+
+ env.AddTail(_T("\0"));
+
+ str = Implode(env, '\0');
+ envstr = CStringA(str, str.GetLength());
+
+ FreeEnvironmentStrings((LPTSTR)lpvEnv);
+ }
+
+ TCHAR* cmdln = DNew TCHAR[32768];
+ _sntprintf(cmdln, 32768, _T("\"%s\" \"%s\""), cgi, path);
+
+ if(hChildStdinRd && hChildStdoutWr)
+ if(CreateProcess(
+ NULL, cmdln, NULL, NULL, TRUE, 0,
+ envstr.GetLength() ? (LPVOID)(LPCSTR)envstr : NULL,
+ dir, &siStartInfo, &piProcInfo))
+ {
+ DWORD ThreadId;
+ CreateThread(NULL, 0, KillCGI, (LPVOID)piProcInfo.hProcess, 0, &ThreadId);
+
+ static const int BUFFSIZE = 1024;
+ DWORD dwRead, dwWritten = 0;
+
+ int i = 0, len = pClient->m_data.GetLength();
+ for(; i < len; i += dwWritten)
+ if(!WriteFile(hChildStdinWrDup, (LPCSTR)pClient->m_data + i, min(len - i, BUFFSIZE), &dwWritten, NULL))
+ break;
+
+ CloseHandle(hChildStdinWrDup);
+ CloseHandle(hChildStdoutWr);
+
+ body.Empty();
+
+ CStringA buff;
+ while(i == len && ReadFile(hChildStdoutRdDup, buff.GetBuffer(BUFFSIZE), BUFFSIZE, &dwRead, NULL) && dwRead)
+ {
+ buff.ReleaseBufferSetLength(dwRead);
+ body += buff;
+ }
+
+ int hdrend = body.Find("\r\n\r\n");
+ if(hdrend >= 0)
+ {
+ hdr = body.Left(hdrend+2);
+ body = body.Mid(hdrend+4);
+ }
+
+ CloseHandle(hChildStdinRd);
+ CloseHandle(hChildStdoutRdDup);
+
+ CloseHandle(piProcInfo.hProcess);
+ CloseHandle(piProcInfo.hThread);
+ }
+ else
+ {
+ body = _T("CGI Error");
+ }
+
+ delete [] cmdln;
+
+ return true;
}
diff --git a/src/apps/mplayerc/WebServer.h b/src/apps/mplayerc/WebServer.h
index 617649c00..d60859200 100644
--- a/src/apps/mplayerc/WebServer.h
+++ b/src/apps/mplayerc/WebServer.h
@@ -39,35 +39,35 @@ class CMainFrame;
class CWebServer
{
- CMainFrame* m_pMainFrame;
- int m_nPort;
+ CMainFrame* m_pMainFrame;
+ int m_nPort;
- DWORD ThreadProc();
- static DWORD WINAPI StaticThreadProc(LPVOID lpParam);
- DWORD m_ThreadId;
- HANDLE m_hThread;
+ DWORD ThreadProc();
+ static DWORD WINAPI StaticThreadProc(LPVOID lpParam);
+ DWORD m_ThreadId;
+ HANDLE m_hThread;
- CAutoPtrList<CWebClientSocket> m_clients;
+ CAutoPtrList<CWebClientSocket> m_clients;
- typedef bool (CWebClientSocket::*RequestHandler)(CStringA& hdr, CStringA& body, CStringA& mime);
- static CAtlStringMap<RequestHandler> m_internalpages;
- static CAtlStringMap<UINT> m_downloads;
- static CAtlStringMap<CStringA, CStringA> m_mimes;
- CPath m_webroot;
+ typedef bool (CWebClientSocket::*RequestHandler)(CStringA& hdr, CStringA& body, CStringA& mime);
+ static CAtlStringMap<RequestHandler> m_internalpages;
+ static CAtlStringMap<UINT> m_downloads;
+ static CAtlStringMap<CStringA, CStringA> m_mimes;
+ CPath m_webroot;
- CAtlStringMap<> m_cgi;
- bool CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& body, CStringA& mime);
+ CAtlStringMap<> m_cgi;
+ bool CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& body, CStringA& mime);
public:
- CWebServer(CMainFrame* pMainFrame, int nPort = 13579);
- virtual ~CWebServer();
+ CWebServer(CMainFrame* pMainFrame, int nPort = 13579);
+ virtual ~CWebServer();
- static void Deploy(CString dir);
+ static void Deploy(CString dir);
- bool ToLocalPath(CString& path, CString& redir);
- bool LoadPage(UINT resid, CStringA& str, CString path = _T(""));
+ bool ToLocalPath(CString& path, CString& redir);
+ bool LoadPage(UINT resid, CStringA& str, CString path = _T(""));
- void OnAccept(CWebServerSocket* pServer);
- void OnClose(CWebClientSocket* pClient);
- void OnRequest(CWebClientSocket* pClient, CStringA& reshdr, CStringA& resbody);
+ void OnAccept(CWebServerSocket* pServer);
+ void OnClose(CWebClientSocket* pClient);
+ void OnRequest(CWebClientSocket* pClient, CStringA& reshdr, CStringA& resbody);
};
diff --git a/src/apps/mplayerc/WebServerSocket.cpp b/src/apps/mplayerc/WebServerSocket.cpp
index c9531d58a..aa8822055 100644
--- a/src/apps/mplayerc/WebServerSocket.cpp
+++ b/src/apps/mplayerc/WebServerSocket.cpp
@@ -25,11 +25,11 @@
#include "WebServer.h"
#include "WebServerSocket.h"
-CWebServerSocket::CWebServerSocket(CWebServer* pWebServer, int port)
- : m_pWebServer(pWebServer)
+CWebServerSocket::CWebServerSocket(CWebServer* pWebServer, int port)
+ : m_pWebServer(pWebServer)
{
- Create(port);
- Listen();
+ Create(port);
+ Listen();
}
CWebServerSocket::~CWebServerSocket()
@@ -38,8 +38,8 @@ CWebServerSocket::~CWebServerSocket()
void CWebServerSocket::OnAccept(int nErrorCode)
{
- if(nErrorCode == 0 && m_pWebServer)
- m_pWebServer->OnAccept(this);
+ if(nErrorCode == 0 && m_pWebServer)
+ m_pWebServer->OnAccept(this);
- __super::OnAccept(nErrorCode);
+ __super::OnAccept(nErrorCode);
}
diff --git a/src/apps/mplayerc/WebServerSocket.h b/src/apps/mplayerc/WebServerSocket.h
index 839357b08..db6265bad 100644
--- a/src/apps/mplayerc/WebServerSocket.h
+++ b/src/apps/mplayerc/WebServerSocket.h
@@ -27,12 +27,12 @@ class CWebServer;
class CWebServerSocket : public CAsyncSocket
{
- CWebServer* m_pWebServer;
+ CWebServer* m_pWebServer;
protected:
- void OnAccept(int nErrorCode);
+ void OnAccept(int nErrorCode);
public:
- CWebServerSocket(CWebServer* pWebServer, int port = 13579);
- virtual ~CWebServerSocket();
+ CWebServerSocket(CWebServer* pWebServer, int port = 13579);
+ virtual ~CWebServerSocket();
};
diff --git a/src/apps/mplayerc/jpeg.cpp b/src/apps/mplayerc/jpeg.cpp
index b7572899f..6fe4c5fc7 100644
--- a/src/apps/mplayerc/jpeg.cpp
+++ b/src/apps/mplayerc/jpeg.cpp
@@ -29,126 +29,126 @@
bool CJpegEncoder::PutBit(int b, int n)
{
- if(n > 24 || n <= 0) return(false);
-
- m_bbuff <<= n;
- m_bbuff |= b & ((1 << n) - 1);
- m_bwidth += n;
-
- while(m_bwidth >= 8)
- {
- BYTE c = (BYTE)(m_bbuff >> (m_bwidth - 8));
- PutByte(c);
- if(c == 0xff) PutByte(0);
- m_bwidth -= 8;
- }
-
- return(true);
+ if(n > 24 || n <= 0) return(false);
+
+ m_bbuff <<= n;
+ m_bbuff |= b & ((1 << n) - 1);
+ m_bwidth += n;
+
+ while(m_bwidth >= 8)
+ {
+ BYTE c = (BYTE)(m_bbuff >> (m_bwidth - 8));
+ PutByte(c);
+ if(c == 0xff) PutByte(0);
+ m_bwidth -= 8;
+ }
+
+ return(true);
}
void CJpegEncoder::Flush()
{
- if(m_bwidth > 0)
- {
- BYTE c = m_bbuff << (8 - m_bwidth);
- PutByte(c);
- if(c == 0xff) PutByte(0);
- }
-
- m_bbuff = m_bwidth = 0;
+ if(m_bwidth > 0)
+ {
+ BYTE c = m_bbuff << (8 - m_bwidth);
+ PutByte(c);
+ if(c == 0xff) PutByte(0);
+ }
+
+ m_bbuff = m_bwidth = 0;
}
///////
int CJpegEncoder::GetBitWidth(short q)
{
- if(q == 0) return(0);
- if(q < 0) q = -q;
+ if(q == 0) return(0);
+ if(q < 0) q = -q;
- int width = 15;
- for(; !(q & 0x4000); q <<= 1, width--);
- return(width);
+ int width = 15;
+ for(; !(q&0x4000); q <<= 1, width--);
+ return(width);
}
///////
void CJpegEncoder::WriteSOI()
{
- PutByte(0xff);
- PutByte(0xd8);
+ PutByte(0xff);
+ PutByte(0xd8);
}
void CJpegEncoder::WriteDQT()
{
- PutByte(0xff);
- PutByte(0xdb);
-
- WORD size = 2 + 2 * (65 + 64 * 0);
- PutByte(size >> 8);
- PutByte(size & 0xff);
-
- for(int c = 0; c < 2; c++)
- {
- PutByte(c);
- PutBytes(quanttbl[c], 64);
- }
+ PutByte(0xff);
+ PutByte(0xdb);
+
+ WORD size = 2 + 2*(65 + 64*0);
+ PutByte(size>>8);
+ PutByte(size&0xff);
+
+ for(int c = 0; c < 2; c++)
+ {
+ PutByte(c);
+ PutBytes(quanttbl[c], 64);
+ }
}
void CJpegEncoder::WriteSOF0()
{
- PutByte(0xff);
- PutByte(0xc0);
+ PutByte(0xff);
+ PutByte(0xc0);
- WORD size = 8 + 3 * ColorComponents;
- PutByte(size >> 8);
- PutByte(size & 0xff);
+ WORD size = 8 + 3*ColorComponents;
+ PutByte(size>>8);
+ PutByte(size&0xff);
- PutByte(8); // precision
+ PutByte(8); // precision
- PutByte(m_h >> 8);
- PutByte(m_h & 0xff);
- PutByte(m_w >> 8);
- PutByte(m_w & 0xff);
+ PutByte(m_h>>8);
+ PutByte(m_h&0xff);
+ PutByte(m_w>>8);
+ PutByte(m_w&0xff);
- PutByte(ColorComponents); // color components
+ PutByte(ColorComponents); // color components
- PutByte(1); // component id
- PutByte(0x11); // hor | ver sampling factor
- PutByte(0); // quant. tbl. id
+ PutByte(1); // component id
+ PutByte(0x11); // hor | ver sampling factor
+ PutByte(0); // quant. tbl. id
- PutByte(2); // component id
- PutByte(0x11); // hor | ver sampling factor
- PutByte(1); // quant. tbl. id
+ PutByte(2); // component id
+ PutByte(0x11); // hor | ver sampling factor
+ PutByte(1); // quant. tbl. id
- PutByte(3); // component id
- PutByte(0x11); // hor | ver sampling factor
- PutByte(1); // quant. tbl. id
+ PutByte(3); // component id
+ PutByte(0x11); // hor | ver sampling factor
+ PutByte(1); // quant. tbl. id
}
void CJpegEncoder::WriteDHT()
{
- PutByte(0xff);
- PutByte(0xc4);
-
- WORD size = 0x01A2; // 2 + n*(17+mi);
- PutByte(size >> 8);
- PutByte(size & 0xff);
-
- PutByte(0x00); // tbl class (DC) | tbl id
- PutBytes(DCVLC_NumByLength[0], 16);
- for(int i = 0; i < 12; i++) PutByte(i);
-
- PutByte(0x01); // tbl class (DC) | tbl id
- PutBytes(DCVLC_NumByLength[1], 16);
- for(int i = 0; i < 12; i++) PutByte(i);
-
- PutByte(0x10); // tbl class (AC) | tbl id
- PutBytes(ACVLC_NumByLength[0], 16);
- PutBytes(ACVLC_Data[0], sizeof(ACVLC_Data[0]));
-
- PutByte(0x11); // tbl class (AC) | tbl id
- PutBytes(ACVLC_NumByLength[1], 16);
- PutBytes(ACVLC_Data[1], sizeof(ACVLC_Data[1]));
+ PutByte(0xff);
+ PutByte(0xc4);
+
+ WORD size = 0x01A2; // 2 + n*(17+mi);
+ PutByte(size>>8);
+ PutByte(size&0xff);
+
+ PutByte(0x00); // tbl class (DC) | tbl id
+ PutBytes(DCVLC_NumByLength[0], 16);
+ for(int i = 0; i < 12; i++) PutByte(i);
+
+ PutByte(0x01); // tbl class (DC) | tbl id
+ PutBytes(DCVLC_NumByLength[1], 16);
+ for(int i = 0; i < 12; i++) PutByte(i);
+
+ PutByte(0x10); // tbl class (AC) | tbl id
+ PutBytes(ACVLC_NumByLength[0], 16);
+ PutBytes(ACVLC_Data[0], sizeof(ACVLC_Data[0]));
+
+ PutByte(0x11); // tbl class (AC) | tbl id
+ PutBytes(ACVLC_NumByLength[1], 16);
+ PutBytes(ACVLC_Data[1], sizeof(ACVLC_Data[1]));
}
// float(1.0 / sqrt(2.0))
@@ -157,128 +157,128 @@ void CJpegEncoder::WriteDHT()
void CJpegEncoder::WriteSOS()
{
- PutByte(0xff);
- PutByte(0xda);
-
- WORD size = 6 + 2 * ColorComponents;
- PutByte(size >> 8);
- PutByte(size & 0xff);
-
- PutByte(ColorComponents); // color components: 3
-
- PutByte(1); // component id
- PutByte(0x00); // DC | AC huff tbl
+ PutByte(0xff);
+ PutByte(0xda);
- PutByte(2); // component id
- PutByte(0x11); // DC | AC huff tbl
+ WORD size = 6 + 2*ColorComponents;
+ PutByte(size>>8);
+ PutByte(size&0xff);
- PutByte(3); // component id
- PutByte(0x11); // DC | AC huff tbl
+ PutByte(ColorComponents); // color components: 3
- PutByte(0); // ss, first AC
- PutByte(63); // se, last AC
+ PutByte(1); // component id
+ PutByte(0x00); // DC | AC huff tbl
- PutByte(0); // ah | al
+ PutByte(2); // component id
+ PutByte(0x11); // DC | AC huff tbl
- static float cosuv[8][8][8][8];
+ PutByte(3); // component id
+ PutByte(0x11); // DC | AC huff tbl
- // oh yeah, we don't need no fast dct :)
- for(int v = 0; v < 8; v++)
- for(int u = 0; u < 8; u++)
- for(int j = 0; j < 8; j++)
- for(int i = 0; i < 8; i++)
- cosuv[v][u][j][i] = (float)(cos((2 * i + 1) * u * PI / 16) * cos((2 * j + 1) * v * PI / 16));
+ PutByte(0); // ss, first AC
+ PutByte(63); // se, last AC
- int prevDC[3] = {0, 0, 0};
+ PutByte(0); // ah | al
- for(int y = 0; y < m_h; y += 8)
- {
- int jj = min(m_h - y, 8);
+ static float cosuv[8][8][8][8];
- for(int x = 0; x < m_w; x += 8)
- {
- int ii = min(m_w - x, 8);
+ // oh yeah, we don't need no fast dct :)
+ for(int v = 0; v < 8; v++)
+ for(int u = 0; u < 8; u++)
+ for(int j = 0; j < 8; j++)
+ for(int i = 0; i < 8; i++)
+ cosuv[v][u][j][i] = (float)(cos((2*i+1)*u*PI/16) * cos((2*j+1)*v*PI/16));
- for(int c = 0; c < ColorComponents; c++)
- {
- int cc = !!c;
+ int prevDC[3] = {0, 0, 0};
- int ACs = 0;
+ for(int y = 0; y < m_h; y += 8)
+ {
+ int jj = min(m_h - y, 8);
- static short block[64];
+ for(int x = 0; x < m_w; x += 8)
+ {
+ int ii = min(m_w - x, 8);
- for(int zigzag = 0; zigzag < 64; zigzag++)
- {
- BYTE u = zigzagU[zigzag];
- BYTE v = zigzagV[zigzag];
+ for(int c = 0; c < ColorComponents; c++)
+ {
+ int cc = !!c;
- float F = 0;
- /*
- for(int j = 0; j < jj; j++)
- for(int i = 0; i < ii; i++)
- F += (signed char)m_p[((y+j)*m_w + (x+i))*4 + c] * cosuv[v][u][j][i];
- */
- for(int j = 0; j < jj; j++)
- {
- signed char* p = (signed char*)&m_p[((y+j)*m_w + x)*4 + c];
- for(int i = 0; i < ii; i++, p += 4)
- F += *p * cosuv[v][u][j][i];
- }
+ int ACs = 0;
- float cu = !u ? invsq2 : 1.0f;
- float cv = !v ? invsq2 : 1.0f;
+ static short block[64];
- block[zigzag] = short(2.0 / 8.0 * cu * cv * F) / quanttbl[cc][zigzag];
- }
+ for(int zigzag = 0; zigzag < 64; zigzag++)
+ {
+ BYTE u = zigzagU[zigzag];
+ BYTE v = zigzagV[zigzag];
- short DC = block[0] - prevDC[c];
- prevDC[c] = block[0];
-
- int size = GetBitWidth(DC);
- PutBit(DCVLC[cc][size], DCVLC_Size[cc][size]);
-
- if(DC < 0) DC = DC - 1;
- PutBit(DC, size);
-
- int j;
- for(j = 64; j > 1 && !block[j-1]; j--);
-
- for(int i = 1; i < j; i++)
- {
- short AC = block[i];
-
- if(AC == 0)
- {
- if(++ACs == 16)
- {
- PutBit(ACVLC[cc][15][0], ACVLC_Size[cc][15][0]);
- ACs = 0;
- }
- }
- else
- {
- int size = GetBitWidth(AC);
- PutBit(ACVLC[cc][ACs][size], ACVLC_Size[cc][ACs][size]);
-
- if(AC < 0) AC--;
- PutBit(AC, size);
-
- ACs = 0;
- }
- }
-
- if(j < 64) PutBit(ACVLC[cc][0][0], ACVLC_Size[cc][0][0]);
- }
- }
- }
-
- Flush();
+ float F = 0;
+/*
+ for(int j = 0; j < jj; j++)
+ for(int i = 0; i < ii; i++)
+ F += (signed char)m_p[((y+j)*m_w + (x+i))*4 + c] * cosuv[v][u][j][i];
+*/
+ for(int j = 0; j < jj; j++)
+ {
+ signed char* p = (signed char*)&m_p[((y+j)*m_w + x)*4 + c];
+ for(int i = 0; i < ii; i++, p += 4)
+ F += *p * cosuv[v][u][j][i];
+ }
+
+ float cu = !u ? invsq2 : 1.0f;
+ float cv = !v ? invsq2 : 1.0f;
+
+ block[zigzag] = short(2.0 / 8.0 * cu * cv * F) / quanttbl[cc][zigzag];
+ }
+
+ short DC = block[0] - prevDC[c];
+ prevDC[c] = block[0];
+
+ int size = GetBitWidth(DC);
+ PutBit(DCVLC[cc][size], DCVLC_Size[cc][size]);
+
+ if(DC < 0) DC = DC - 1;
+ PutBit(DC, size);
+
+ int j;
+ for(j = 64; j > 1 && !block[j-1]; j--);
+
+ for(int i = 1; i < j; i++)
+ {
+ short AC = block[i];
+
+ if(AC == 0)
+ {
+ if(++ACs == 16)
+ {
+ PutBit(ACVLC[cc][15][0], ACVLC_Size[cc][15][0]);
+ ACs = 0;
+ }
+ }
+ else
+ {
+ int size = GetBitWidth(AC);
+ PutBit(ACVLC[cc][ACs][size], ACVLC_Size[cc][ACs][size]);
+
+ if(AC < 0) AC--;
+ PutBit(AC, size);
+
+ ACs = 0;
+ }
+ }
+
+ if(j < 64) PutBit(ACVLC[cc][0][0], ACVLC_Size[cc][0][0]);
+ }
+ }
+ }
+
+ Flush();
}
void CJpegEncoder::WriteEOI()
{
- PutByte(0xff);
- PutByte(0xd9);
+ PutByte(0xff);
+ PutByte(0xd9);
}
//
@@ -289,88 +289,88 @@ CJpegEncoder::CJpegEncoder()
bool CJpegEncoder::Encode(const BYTE* dib)
{
- m_bbuff = m_bwidth = 0;
+ m_bbuff = m_bwidth = 0;
- BITMAPINFO* bi = (BITMAPINFO*)dib;
+ BITMAPINFO* bi = (BITMAPINFO*)dib;
- int bpp = bi->bmiHeader.biBitCount;
+ int bpp = bi->bmiHeader.biBitCount;
- if(bpp != 16 && bpp != 24 && bpp != 32) // 16 & 24 not tested!!! there may be some alignment problems when the row size is not 4*something in bytes
- return false;
+ if(bpp != 16 && bpp != 24 && bpp != 32) // 16 & 24 not tested!!! there may be some alignment problems when the row size is not 4*something in bytes
+ return false;
- m_w = bi->bmiHeader.biWidth;
- m_h = abs(bi->bmiHeader.biHeight);
- m_p = DNew BYTE[m_w*m_h*4];
+ m_w = bi->bmiHeader.biWidth;
+ m_h = abs(bi->bmiHeader.biHeight);
+ m_p = DNew BYTE[m_w*m_h*4];
- const BYTE* src = dib + sizeof(bi->bmiHeader);
- if(bi->bmiHeader.biBitCount <= 8)
- {
- if(bi->bmiHeader.biClrUsed) src += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else src += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
- }
+ const BYTE* src = dib + sizeof(bi->bmiHeader);
+ if(bi->bmiHeader.biBitCount <= 8)
+ {
+ if(bi->bmiHeader.biClrUsed) src += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
+ else src += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ }
- int srcpitch = m_w * (bpp >> 3);
- int dstpitch = m_w * 4;
+ int srcpitch = m_w*(bpp>>3);
+ int dstpitch = m_w*4;
- BitBltFromRGBToRGB(
- m_w, m_h,
- m_p, dstpitch, 32,
- (BYTE*)src + srcpitch*(m_h - 1), -srcpitch, bpp);
+ BitBltFromRGBToRGB(
+ m_w, m_h,
+ m_p, dstpitch, 32,
+ (BYTE*)src + srcpitch*(m_h-1), -srcpitch, bpp);
- BYTE* p = m_p;
- for(BYTE* e = p + m_h * dstpitch; p < e; p += 4)
- {
- int r = p[2], g = p[1], b = p[0];
+ BYTE* p = m_p;
+ for(BYTE* e = p + m_h*dstpitch; p < e; p += 4)
+ {
+ int r = p[2], g = p[1], b = p[0];
- p[0] = (BYTE)min(max(0.2990 * r + 0.5870 * g + 0.1140 * b, 0), 255) - 128;
- p[1] = (BYTE)min(max(-0.1687 * r - 0.3313 * g + 0.5000 * b + 128, 0), 255) - 128;
- p[2] = (BYTE)min(max(0.5000 * r - 0.4187 * g - 0.0813 * b + 128, 0), 255) - 128;
- }
+ p[0] = (BYTE)min(max(0.2990*r+0.5870*g+0.1140*b, 0), 255) - 128;
+ p[1] = (BYTE)min(max(-0.1687*r-0.3313*g+0.5000*b + 128, 0), 255) - 128;
+ p[2] = (BYTE)min(max(0.5000*r-0.4187*g-0.0813*b + 128, 0), 255) - 128;
+ }
- if(quanttbl[0][0] == 16)
- {
- for(int i = 0; i < countof(quanttbl); i++)
- for(int j = 0; j < countof(quanttbl[0]); j++)
- quanttbl[i][j] >>= 2; // the default quantization table contains a little too large values
- }
+ if(quanttbl[0][0] == 16)
+ {
+ for(int i = 0; i < countof(quanttbl); i++)
+ for(int j = 0; j < countof(quanttbl[0]); j++)
+ quanttbl[i][j] >>= 2; // the default quantization table contains a little too large values
+ }
- WriteSOI();
- WriteDQT();
- WriteSOF0();
- WriteDHT();
- WriteSOS();
- WriteEOI();
+ WriteSOI();
+ WriteDQT();
+ WriteSOF0();
+ WriteDHT();
+ WriteSOS();
+ WriteEOI();
- delete [] m_p;
+ delete [] m_p;
- return true;
+ return true;
}
//////////
CJpegEncoderFile::CJpegEncoderFile(LPCTSTR fn)
{
- m_fn = fn;
- m_file = NULL;
+ m_fn = fn;
+ m_file = NULL;
}
bool CJpegEncoderFile::PutByte(BYTE b)
{
- return fputc(b, m_file) != EOF;
+ return fputc(b, m_file) != EOF;
}
bool CJpegEncoderFile::PutBytes(const void* pData, int len)
{
- return fwrite(pData, 1, len, m_file) == len;
+ return fwrite(pData, 1, len, m_file) == len;
}
bool CJpegEncoderFile::Encode(const BYTE* dib)
{
- if(!(m_file = _tfopen(m_fn, _T("wb")))) return false;
- bool ret = __super::Encode(dib);
- fclose(m_file);
- m_file = NULL;
- return ret;
+ if(!(m_file = _tfopen(m_fn, _T("wb")))) return false;
+ bool ret = __super::Encode(dib);
+ fclose(m_file);
+ m_file = NULL;
+ return ret;
}
//////////
@@ -381,21 +381,21 @@ CJpegEncoderMem::CJpegEncoderMem()
bool CJpegEncoderMem::PutByte(BYTE b)
{
- m_pdata->Add(b); // yeah... a bit unbuffered, for now
- return true;
+ m_pdata->Add(b); // yeah... a bit unbuffered, for now
+ return true;
}
bool CJpegEncoderMem::PutBytes(const void* pData, int len)
{
- CAtlArray<BYTE> moredata;
- moredata.SetCount(len);
- memcpy(moredata.GetData(), pData, len);
- m_pdata->Append(moredata);
- return true;
+ CAtlArray<BYTE> moredata;
+ moredata.SetCount(len);
+ memcpy(moredata.GetData(), pData, len);
+ m_pdata->Append(moredata);
+ return true;
}
bool CJpegEncoderMem::Encode(const BYTE* dib, CAtlArray<BYTE>& data)
{
- m_pdata = &data;
- return __super::Encode(dib);
+ m_pdata = &data;
+ return __super::Encode(dib);
}
diff --git a/src/apps/mplayerc/jpeg.h b/src/apps/mplayerc/jpeg.h
index 45bf7a8ea..4aa97cf2a 100644
--- a/src/apps/mplayerc/jpeg.h
+++ b/src/apps/mplayerc/jpeg.h
@@ -25,57 +25,57 @@
class CJpegEncoder
{
- static const int ColorComponents = 3;
+ static const int ColorComponents = 3;
- int m_w, m_h;
- BYTE* m_p;
+ int m_w, m_h;
+ BYTE* m_p;
- unsigned int m_bbuff, m_bwidth;
- bool PutBit(int b, int n);
- void Flush();
- int GetBitWidth(short q);
+ unsigned int m_bbuff, m_bwidth;
+ bool PutBit(int b, int n);
+ void Flush();
+ int GetBitWidth(short q);
- void WriteSOI();
- void WriteDQT();
- void WriteSOF0();
- void WriteDHT();
- void WriteSOS();
- void WriteEOI();
+ void WriteSOI();
+ void WriteDQT();
+ void WriteSOF0();
+ void WriteDHT();
+ void WriteSOS();
+ void WriteEOI();
protected:
- virtual bool PutByte(BYTE b) = 0;
- virtual bool PutBytes(const void* pData, int len) = 0;
- virtual bool Encode(const BYTE* dib);
+ virtual bool PutByte(BYTE b) = 0;
+ virtual bool PutBytes(const void* pData, int len) = 0;
+ virtual bool Encode(const BYTE* dib);
public:
- CJpegEncoder();
+ CJpegEncoder();
};
class CJpegEncoderFile : public CJpegEncoder
{
- CString m_fn;
- FILE* m_file;
+ CString m_fn;
+ FILE* m_file;
protected:
- bool PutByte(BYTE b);
- bool PutBytes(const void* pData, int len);
+ bool PutByte(BYTE b);
+ bool PutBytes(const void* pData, int len);
public:
- CJpegEncoderFile(LPCTSTR fn);
+ CJpegEncoderFile(LPCTSTR fn);
- bool Encode(const BYTE* dib);
+ bool Encode(const BYTE* dib);
};
class CJpegEncoderMem : public CJpegEncoder
{
- CAtlArray<BYTE>* m_pdata;
+ CAtlArray<BYTE>* m_pdata;
protected:
- bool PutByte(BYTE b);
- bool PutBytes(const void* pData, int len);
+ bool PutByte(BYTE b);
+ bool PutBytes(const void* pData, int len);
public:
- CJpegEncoderMem();
+ CJpegEncoderMem();
- bool Encode(const BYTE* dib, CAtlArray<BYTE>& data);
+ bool Encode(const BYTE* dib, CAtlArray<BYTE>& data);
};
diff --git a/src/apps/mplayerc/jpeg_tables.h b/src/apps/mplayerc/jpeg_tables.h
index cf5ca8ce1..fa4fba2fd 100644
--- a/src/apps/mplayerc/jpeg_tables.h
+++ b/src/apps/mplayerc/jpeg_tables.h
@@ -25,232 +25,232 @@
/* Tables */
-static unsigned char quanttbl[2][64] =
+static unsigned char quanttbl[2][64] =
{
- {
- 16,
- 11, 12,
- 14, 12, 10,
- 16, 14, 13, 14,
- 18, 17, 16, 19, 24,
- 40, 26, 24, 22, 22, 24,
- 49, 35, 37, 29, 40, 58, 51,
- 61, 30, 57, 51, 56, 55, 64, 72,
- 92, 78, 64, 68, 87, 69, 55,
- 56, 80, 109, 81, 87, 95,
- 98, 103, 104, 103, 62,
- 77, 113, 121, 112,
- 100, 120, 92,
- 101, 103,
- 99
- },
- {
- 17,
- 18, 18,
- 24, 21, 24,
- 47, 26, 26, 47,
- 99, 66, 56, 66, 99,
- 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99,
- 99, 99, 99, 99,
- 99, 99, 99,
- 99, 99,
- 99
- }
+ {
+ 16,
+ 11, 12,
+ 14, 12, 10,
+ 16, 14, 13, 14,
+ 18, 17, 16, 19, 24,
+ 40, 26, 24, 22, 22, 24,
+ 49, 35, 37, 29, 40, 58, 51,
+ 61, 30, 57, 51, 56, 55, 64, 72,
+ 92, 78, 64, 68, 87, 69, 55,
+ 56, 80, 109, 81, 87, 95,
+ 98, 103, 104, 103, 62,
+ 77, 113, 121, 112,
+ 100, 120, 92,
+ 101, 103,
+ 99
+ },
+ {
+ 17,
+ 18, 18,
+ 24, 21, 24,
+ 47, 26, 26, 47,
+ 99, 66, 56, 66, 99,
+ 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99,
+ 99, 99, 99, 99,
+ 99, 99, 99,
+ 99, 99,
+ 99
+ }
};
-static unsigned char zigzagU[64] =
+static unsigned char zigzagU[64] =
{
- 0,
- 1, 0,
- 0, 1, 2,
- 3, 2, 1, 0,
- 0, 1, 2, 3, 4,
- 5, 4, 3, 2, 1, 0,
- 0, 1, 2, 3, 4, 5, 6,
- 7, 6, 5, 4, 3, 2, 1, 0,
- 1, 2, 3, 4, 5, 6, 7,
- 7, 6, 5, 4, 3, 2,
- 3, 4, 5, 6, 7,
- 7, 6, 5, 4,
- 5, 6, 7,
- 7, 6,
- 7,
+ 0,
+ 1, 0,
+ 0, 1, 2,
+ 3, 2, 1, 0,
+ 0, 1, 2, 3, 4,
+ 5, 4, 3, 2, 1, 0,
+ 0, 1, 2, 3, 4, 5, 6,
+ 7, 6, 5, 4, 3, 2, 1, 0,
+ 1, 2, 3, 4, 5, 6, 7,
+ 7, 6, 5, 4, 3, 2,
+ 3, 4, 5, 6, 7,
+ 7, 6, 5, 4,
+ 5, 6, 7,
+ 7, 6,
+ 7,
};
-static unsigned char zigzagV[64] =
+static unsigned char zigzagV[64] =
{
- 0,
- 0, 1,
- 2, 1, 0,
- 0, 1, 2, 3,
- 4, 3, 2, 1, 0,
- 0, 1, 2, 3, 4, 5,
- 6, 5, 4, 3, 2, 1, 0,
- 0, 1, 2, 3, 4, 5, 6, 7,
- 7, 6, 5, 4, 3, 2, 1,
- 2, 3, 4, 5, 6, 7,
- 7, 6, 5, 4, 3,
- 4, 5, 6, 7,
- 7, 6, 5,
- 6, 7,
- 7,
+ 0,
+ 0, 1,
+ 2, 1, 0,
+ 0, 1, 2, 3,
+ 4, 3, 2, 1, 0,
+ 0, 1, 2, 3, 4, 5,
+ 6, 5, 4, 3, 2, 1, 0,
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 7, 6, 5, 4, 3, 2, 1,
+ 2, 3, 4, 5, 6, 7,
+ 7, 6, 5, 4, 3,
+ 4, 5, 6, 7,
+ 7, 6, 5,
+ 6, 7,
+ 7,
};
-static unsigned short DCVLC[2][12] =
+static unsigned short DCVLC[2][12] =
{
- {0, 2, 3, 4, 5, 6, 14, 30, 62, 126, 254, 510},
- {0, 1, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046}
+ {0, 2, 3, 4, 5, 6, 14, 30, 62, 126, 254, 510},
+ {0, 1, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046}
};
-static unsigned char DCVLC_Size[2][12] =
+static unsigned char DCVLC_Size[2][12] =
{
- {2, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
- {2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
+ {2, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
+ {2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
};
-static unsigned char DCVLC_NumByLength[2][16] =
+static unsigned char DCVLC_NumByLength[2][16] =
{
- {0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
- {0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
+ {0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
+ {0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
};
-static unsigned short ACVLC[2][16][11] =
+static unsigned short ACVLC[2][16][11] =
{
- {
- {10, 0, 1, 4, 11, 26, 120, 248, 1014, 65410, 65410},
- {0, 12, 27, 121, 502, 2038, 65412, 65413, 65414, 65415, 65416},
- {0, 28, 249, 1015, 4084, 65417, 65418, 65419, 65420, 65421, 65422},
- {0, 58, 503, 8181, 65423, 65424, 65425, 65426, 65427, 65428, 65429},
- {0, 59, 1016, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437},
- {0, 122, 2039, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445},
- {0, 123, 4086, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453},
- {0, 250, 4087, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461},
- {0, 504, 32704, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469},
- {0, 505, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478},
- {0, 506, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487},
- {0, 1017, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496},
- {0, 1018, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505},
- {0, 2040, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514},
- {0, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524},
- {2041, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534}
- },
- {
- {0, 1, 4, 10, 24, 25, 56, 120, 500, 1014, 4084},
- {0, 11, 57, 246, 501, 2038, 4085, 65416, 65417, 65418, 65419},
- {0, 26, 247, 1015, 4086, 32706, 65420, 65421, 65422, 65423, 65424},
- {0, 27, 248, 1016, 4087, 65425, 65426, 65427, 65428, 65429, 65430},
- {0, 58, 502, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438},
- {0, 59, 1017, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446},
- {0, 121, 2039, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454},
- {0, 122, 2040, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462},
- {0, 249, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471},
- {0, 503, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480},
- {0, 504, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489},
- {0, 505, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498},
- {0, 506, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507},
- {0, 2041, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516},
- {0, 16352, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525},
- {1018, 32707, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534}
- }
+ {
+ {10, 0, 1, 4, 11, 26, 120, 248, 1014, 65410, 65410},
+ {0, 12, 27, 121, 502, 2038, 65412, 65413, 65414, 65415, 65416},
+ {0, 28, 249, 1015, 4084, 65417, 65418, 65419, 65420, 65421, 65422},
+ {0, 58, 503, 8181, 65423, 65424, 65425, 65426, 65427, 65428, 65429},
+ {0, 59, 1016, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437},
+ {0, 122, 2039, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445},
+ {0, 123, 4086, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453},
+ {0, 250, 4087, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461},
+ {0, 504, 32704, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469},
+ {0, 505, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478},
+ {0, 506, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487},
+ {0, 1017, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496},
+ {0, 1018, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505},
+ {0, 2040, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514},
+ {0, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524},
+ {2041, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534}
+ },
+ {
+ {0, 1, 4, 10, 24, 25, 56, 120, 500, 1014, 4084},
+ {0, 11, 57, 246, 501, 2038, 4085, 65416, 65417, 65418, 65419},
+ {0, 26, 247, 1015, 4086, 32706, 65420, 65421, 65422, 65423, 65424},
+ {0, 27, 248, 1016, 4087, 65425, 65426, 65427, 65428, 65429, 65430},
+ {0, 58, 502, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438},
+ {0, 59, 1017, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446},
+ {0, 121, 2039, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454},
+ {0, 122, 2040, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462},
+ {0, 249, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471},
+ {0, 503, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480},
+ {0, 504, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489},
+ {0, 505, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498},
+ {0, 506, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507},
+ {0, 2041, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516},
+ {0, 16352, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525},
+ {1018, 32707, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534}
+ }
};
-static unsigned char ACVLC_Size[2][16][11] =
+static unsigned char ACVLC_Size[2][16][11] =
{
- {
- {4, 2, 2, 3, 4, 5, 7, 8, 10, 16, 16},
- {0, 4, 5, 7, 9, 11, 16, 16, 16, 16, 16},
- {0, 5, 8, 10, 12, 16, 16, 16, 16, 16, 16},
- {0, 6, 9, 12, 16, 16, 16, 16, 16, 16, 16},
- {0, 6, 10, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 7, 11, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 7, 12, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 8, 12, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 9, 15, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}
- },
- {
- {2, 2, 3, 4, 5, 5, 6, 7, 9, 10, 12},
- {0, 4, 6, 8, 9, 11, 12, 16, 16, 16, 16},
- {0, 5, 8, 10, 12, 15, 16, 16, 16, 16, 16},
- {0, 5, 8, 10, 12, 16, 16, 16, 16, 16, 16},
- {0, 6, 9, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 6, 10, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 7, 11, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 7, 11, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {0, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16},
- {10, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16}
- }
+ {
+ {4, 2, 2, 3, 4, 5, 7, 8, 10, 16, 16},
+ {0, 4, 5, 7, 9, 11, 16, 16, 16, 16, 16},
+ {0, 5, 8, 10, 12, 16, 16, 16, 16, 16, 16},
+ {0, 6, 9, 12, 16, 16, 16, 16, 16, 16, 16},
+ {0, 6, 10, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 7, 11, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 7, 12, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 8, 12, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 9, 15, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}
+ },
+ {
+ {2, 2, 3, 4, 5, 5, 6, 7, 9, 10, 12},
+ {0, 4, 6, 8, 9, 11, 12, 16, 16, 16, 16},
+ {0, 5, 8, 10, 12, 15, 16, 16, 16, 16, 16},
+ {0, 5, 8, 10, 12, 16, 16, 16, 16, 16, 16},
+ {0, 6, 9, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 6, 10, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 7, 11, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 7, 11, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {0, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+ {10, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16}
+ }
};
-static unsigned char ACVLC_NumByLength[2][16] =
+static unsigned char ACVLC_NumByLength[2][16] =
{
- {0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125},
- {0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119}
+ {0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125},
+ {0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119}
};
-static unsigned char ACVLC_Data[2][162] =
+static unsigned char ACVLC_Data[2][162] =
{
- {
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
- 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
- 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, 0x08,
- 0x23, 0x42, 0xB1, 0xC1, 0x15, 0x52, 0xD1, 0xF0,
- 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16,
- 0x17, 0x18, 0x19, 0x1A, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
- 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
- 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
- 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
- 0x7A, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
- 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
- 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6,
- 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5,
- 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4,
- 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE1, 0xE2,
- 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
- 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
- 0xF9, 0xFA
- },
- {
- 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
- 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
- 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
- 0xA1, 0xB1, 0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0,
- 0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34,
- 0xE1, 0x25, 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26,
- 0x27, 0x28, 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38,
- 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7A, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96,
- 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5,
- 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4,
- 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3,
- 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2,
- 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
- 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9,
- 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
- 0xF9, 0xFA
- }
+ {
+ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
+ 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
+ 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, 0x08,
+ 0x23, 0x42, 0xB1, 0xC1, 0x15, 0x52, 0xD1, 0xF0,
+ 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16,
+ 0x17, 0x18, 0x19, 0x1A, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
+ 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+ 0x7A, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
+ 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6,
+ 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5,
+ 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4,
+ 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE1, 0xE2,
+ 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
+ 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
+ 0xF9, 0xFA
+ },
+ {
+ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
+ 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
+ 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
+ 0xA1, 0xB1, 0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0,
+ 0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34,
+ 0xE1, 0x25, 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26,
+ 0x27, 0x28, 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38,
+ 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7A, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5,
+ 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4,
+ 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3,
+ 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2,
+ 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
+ 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9,
+ 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
+ 0xF9, 0xFA
+ }
};
diff --git a/src/apps/mplayerc/libpng.c b/src/apps/mplayerc/libpng.c
index 227278494..ee43b788e 100644
--- a/src/apps/mplayerc/libpng.c
+++ b/src/apps/mplayerc/libpng.c
@@ -29,31 +29,31 @@
static void read_data_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
- struct png_t* png = (struct png_t*)png_get_progressive_ptr(png_ptr);
- if(png->pos + length > png->size) png_error(png_ptr, "Read Error");
- memcpy(data, &png->data[png->pos], length);
- png->pos += length;
+ struct png_t* png = (struct png_t*)png_get_progressive_ptr(png_ptr);
+ if(png->pos + length > png->size) png_error(png_ptr, "Read Error");
+ memcpy(data, &png->data[png->pos], length);
+ png->pos += length;
}
unsigned char* DecompressPNG(struct png_t* png, int* w, int* h)
{
png_structp png_ptr;
- png_infop info_ptr;
- png_infop end_info;
+ png_infop info_ptr;
+ png_infop end_info;
- unsigned char* pic;
- unsigned char* row;
- unsigned int x, y, c;
+ unsigned char* pic;
+ unsigned char* row;
+ unsigned int x, y, c;
- if(png_sig_cmp(png->data, 0, 8) != 0)
- return NULL;
+ if(png_sig_cmp(png->data, 0, 8) != 0)
+ return NULL;
- png->pos = 8;
+ png->pos = 8;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- // (png_voidp)user_error_ptr, user_error_fn, user_warning_fn);
- if(!png_ptr)
- return NULL;
+ // (png_voidp)user_error_ptr, user_error_fn, user_warning_fn);
+ if(!png_ptr)
+ return NULL;
png_set_read_fn(png_ptr, (png_voidp)png, read_data_fn);
@@ -77,42 +77,42 @@ unsigned char* DecompressPNG(struct png_t* png, int* w, int* h)
return NULL;
}
- png_set_sig_bytes(png_ptr, 8);
+ png_set_sig_bytes(png_ptr, 8);
- png_read_png(
- png_ptr, info_ptr,
- PNG_TRANSFORM_STRIP_16 |
- PNG_TRANSFORM_STRIP_ALPHA |
- PNG_TRANSFORM_PACKING |
- PNG_TRANSFORM_EXPAND |
- PNG_TRANSFORM_BGR,
- NULL);
+ png_read_png(
+ png_ptr, info_ptr,
+ PNG_TRANSFORM_STRIP_16 |
+ PNG_TRANSFORM_STRIP_ALPHA |
+ PNG_TRANSFORM_PACKING |
+ PNG_TRANSFORM_EXPAND |
+ PNG_TRANSFORM_BGR,
+ NULL);
- if(png_get_channels(png_ptr, info_ptr) != 3)
- {
+ if(png_get_channels(png_ptr, info_ptr) != 3)
+ {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
- return NULL;
- }
+ return NULL;
+ }
- pic = calloc(info_ptr->width * info_ptr->height, 4);
+ pic = calloc(info_ptr->width * info_ptr->height, 4);
- *w = info_ptr->width;
- *h = info_ptr->height;
+ *w = info_ptr->width;
+ *h = info_ptr->height;
- for(y = 0; y < info_ptr->height; y++)
- {
- row = &pic[y * info_ptr->width * 4];
-
- for(x = 0; x < info_ptr->width * 3; row += 4)
- {
- for(c = 0; c < 3; c++)
- {
- row[c] = info_ptr->row_pointers[y][x++];
- }
- }
- }
+ for(y = 0; y < info_ptr->height; y++)
+ {
+ row = &pic[y * info_ptr->width * 4];
+
+ for(x = 0; x < info_ptr->width*3; row += 4)
+ {
+ for(c = 0; c < 3; c++)
+ {
+ row[c] = info_ptr->row_pointers[y][x++];
+ }
+ }
+ }
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
- return pic;
+ return pic;
}
diff --git a/src/apps/mplayerc/libpng.h b/src/apps/mplayerc/libpng.h
index 98354380b..8593b1fba 100644
--- a/src/apps/mplayerc/libpng.h
+++ b/src/apps/mplayerc/libpng.h
@@ -23,11 +23,7 @@
#pragma once
-struct png_t
-{
- unsigned char* data;
- unsigned int size, pos;
-};
+struct png_t {unsigned char* data; unsigned int size, pos;};
#ifdef __cplusplus
@@ -38,31 +34,31 @@ extern "C" unsigned char* DecompressPNG(struct png_t* png, int* w, int* h);
class CPngImage : public CImage
{
public:
- bool LoadFromResource(UINT id)
- {
- bool ret = false;
+ bool LoadFromResource(UINT id)
+ {
+ bool ret = false;
- CStringA str;
- if(LoadResource(id, str, _T("FILE")))
- {
- struct png_t png;
- png.data = (unsigned char*)(LPCSTR)str;
- png.size = str.GetLength();
- int w, h;
- if(BYTE* p = DecompressPNG(&png, &w, &h))
- {
- if(Create(w, -h, 32))
- {
- for(int y = 0; y < h; y++)
- memcpy(GetPixelAddress(0, y), &p[w*4*y], w * 4);
- ret = true;
- }
+ CStringA str;
+ if(LoadResource(id, str, _T("FILE")))
+ {
+ struct png_t png;
+ png.data = (unsigned char*)(LPCSTR)str;
+ png.size = str.GetLength();
+ int w, h;
+ if(BYTE* p = DecompressPNG(&png, &w, &h))
+ {
+ if(Create(w, -h, 32))
+ {
+ for(int y = 0; y < h; y++)
+ memcpy(GetPixelAddress(0, y), &p[w*4*y], w*4);
+ ret = true;
+ }
- free(p);
- }
- }
+ free(p);
+ }
+ }
- return ret;
- }
+ return ret;
+ }
};
#endif /* __cplusplus */
diff --git a/src/apps/mplayerc/madVRAllocatorPresenter.cpp b/src/apps/mplayerc/madVRAllocatorPresenter.cpp
index 3ffab9011..53f4407e4 100644
--- a/src/apps/mplayerc/madVRAllocatorPresenter.cpp
+++ b/src/apps/mplayerc/madVRAllocatorPresenter.cpp
@@ -33,129 +33,108 @@ using namespace DSObjects;
//
CmadVRAllocatorPresenter::CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
- , m_ScreenSize(0, 0)
+ : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
+ , m_ScreenSize(0, 0)
{
- if(FAILED(hr))
- {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
+ if(FAILED(hr))
+ {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
- hr = S_OK;
+ hr = S_OK;
}
CmadVRAllocatorPresenter::~CmadVRAllocatorPresenter()
{
- if(m_pSRCB)
- {
- // nasty, but we have to let it know about our death somehow
- ((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
- }
-
- // the order is important here
- m_pSubPicQueue = NULL;
- m_pAllocator = NULL;
- m_pDXR = NULL;
+ if(m_pSRCB)
+ {
+ // nasty, but we have to let it know about our death somehow
+ ((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
+ }
+
+ // the order is important here
+ m_pSubPicQueue = NULL;
+ m_pAllocator = NULL;
+ m_pDXR = NULL;
}
STDMETHODIMP CmadVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- /*
- if(riid == __uuidof(IVideoWindow))
- return GetInterface((IVideoWindow*)this, ppv);
- if(riid == __uuidof(IBasicVideo))
- return GetInterface((IBasicVideo*)this, ppv);
- if(riid == __uuidof(IBasicVideo2))
- return GetInterface((IBasicVideo2*)this, ppv);
- */
- /*
- if(riid == __uuidof(IVMRWindowlessControl))
- return GetInterface((IVMRWindowlessControl*)this, ppv);
- */
-
- if(riid != IID_IUnknown && m_pDXR)
- {
- if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv)))
- return S_OK;
- }
-
- return __super::NonDelegatingQueryInterface(riid, ppv);
+/*
+ if(riid == __uuidof(IVideoWindow))
+ return GetInterface((IVideoWindow*)this, ppv);
+ if(riid == __uuidof(IBasicVideo))
+ return GetInterface((IBasicVideo*)this, ppv);
+ if(riid == __uuidof(IBasicVideo2))
+ return GetInterface((IBasicVideo2*)this, ppv);
+*/
+/*
+ if(riid == __uuidof(IVMRWindowlessControl))
+ return GetInterface((IVMRWindowlessControl*)this, ppv);
+*/
+
+ if(riid != IID_IUnknown && m_pDXR)
+ {
+ if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv)))
+ return S_OK;
+ }
+
+ return __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
{
- CheckPointer(pD3DDev, E_POINTER);
-
- CSize size;
- switch(AfxGetAppSettings().nSPCMaxRes)
- {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if(m_pAllocator)
- {
- m_pAllocator->ChangeDevice(pD3DDev);
- }
- else
- {
- m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- return E_FAIL;
- }
-
- HRESULT hr = S_OK;
-
- m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr))
- return E_FAIL;
-
- if(m_SubPicProvider) m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
-
- return S_OK;
+ CheckPointer(pD3DDev, E_POINTER);
+
+ CSize size;
+ switch(AfxGetAppSettings().nSPCMaxRes)
+ {
+ case 0: default: size = m_ScreenSize; break;
+ case 1: size.SetSize(1024, 768); break;
+ case 2: size.SetSize(800, 600); break;
+ case 3: size.SetSize(640, 480); break;
+ case 4: size.SetSize(512, 384); break;
+ case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
+ }
+
+ if(m_pAllocator)
+ {
+ m_pAllocator->ChangeDevice(pD3DDev);
+ }
+ else
+ {
+ m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ if(!m_pAllocator)
+ return E_FAIL;
+ }
+
+ HRESULT hr = S_OK;
+
+ m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, !AfxGetAppSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if(!m_pSubPicQueue || FAILED(hr))
+ return E_FAIL;
+
+ if(m_SubPicProvider) m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+
+ return S_OK;
}
HRESULT CmadVRAllocatorPresenter::Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int right, int bottom, int width, int height)
-{
- __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
- SetTime(rtStart);
- if(atpf > 0 && m_pSubPicQueue) m_pSubPicQueue->SetFPS(10000000.0 / atpf);
- AlphaBltSubPic(CSize(width, height));
- return S_OK;
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int right, int bottom, int width, int height)
+{
+ __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
+ SetTime(rtStart);
+ if(atpf > 0 && m_pSubPicQueue) m_pSubPicQueue->SetFPS(10000000.0 / atpf);
+ AlphaBltSubPic(CSize(width, height));
+ return S_OK;
}
// ISubPicAllocatorPresenter
@@ -164,80 +143,72 @@ STDMETHODIMP CmadVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
CheckPointer(ppRenderer, E_POINTER);
- if(m_pDXR) return E_UNEXPECTED;
- m_pDXR.CoCreateInstance(CLSID_madVR, GetOwner());
- if(!m_pDXR) return E_FAIL;
+ if(m_pDXR) return E_UNEXPECTED;
+ m_pDXR.CoCreateInstance(CLSID_madVR, GetOwner());
+ if(!m_pDXR) return E_FAIL;
- CComQIPtr<ISubRender> pSR = m_pDXR;
- if(!pSR)
- {
- m_pDXR = NULL;
- return E_FAIL;
- }
+ CComQIPtr<ISubRender> pSR = m_pDXR;
+ if(!pSR) {m_pDXR = NULL; return E_FAIL;}
- m_pSRCB = DNew CSubRenderCallback(this);
- if(FAILED(pSR->SetCallback(m_pSRCB)))
- {
- m_pDXR = NULL;
- return E_FAIL;
- }
+ m_pSRCB = DNew CSubRenderCallback(this);
+ if(FAILED(pSR->SetCallback(m_pSRCB))) {m_pDXR = NULL; return E_FAIL;}
- (*ppRenderer = this)->AddRef();
+ (*ppRenderer = this)->AddRef();
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- if(GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
- m_ScreenSize.SetSize(mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top);
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
+ m_ScreenSize.SetSize(mi.rcMonitor.right-mi.rcMonitor.left, mi.rcMonitor.bottom-mi.rcMonitor.top);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(void) CmadVRAllocatorPresenter::SetPosition(RECT w, RECT v)
{
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
- {
- pBV->SetDefaultSourcePosition();
- pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
- }
-
- if(CComQIPtr<IVideoWindow> pVW = m_pDXR)
- {
- pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
- }
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ {
+ pBV->SetDefaultSourcePosition();
+ pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
+ }
+
+ if(CComQIPtr<IVideoWindow> pVW = m_pDXR)
+ {
+ pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
+ }
}
STDMETHODIMP_(SIZE) CmadVRAllocatorPresenter::GetVideoSize(bool fCorrectAR)
{
- SIZE size = {0, 0};
-
- if(!fCorrectAR)
- {
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
- pBV->GetVideoSize(&size.cx, &size.cy);
- }
- else
- {
- if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR)
- pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
- }
-
- return size;
+ SIZE size = {0, 0};
+
+ if(!fCorrectAR)
+ {
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ pBV->GetVideoSize(&size.cx, &size.cy);
+ }
+ else
+ {
+ if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR)
+ pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
+ }
+
+ return size;
}
STDMETHODIMP_(bool) CmadVRAllocatorPresenter::Paint(bool fAll)
{
- return false; // TODO
+ return false; // TODO
}
STDMETHODIMP CmadVRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- HRESULT hr = E_NOTIMPL;
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
- hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
- return hr;
+ HRESULT hr = E_NOTIMPL;
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
+ return hr;
}
STDMETHODIMP CmadVRAllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return E_NOTIMPL; // TODO
+ return E_NOTIMPL; // TODO
}
diff --git a/src/apps/mplayerc/madVRAllocatorPresenter.h b/src/apps/mplayerc/madVRAllocatorPresenter.h
index 1bf230a71..6e6d20345 100644
--- a/src/apps/mplayerc/madVRAllocatorPresenter.h
+++ b/src/apps/mplayerc/madVRAllocatorPresenter.h
@@ -26,79 +26,79 @@
namespace DSObjects
{
-class CmadVRAllocatorPresenter
- : public ISubPicAllocatorPresenterImpl
-{
- class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
- {
- CmadVRAllocatorPresenter* m_pDXRAP;
-
- public:
- CSubRenderCallback(CmadVRAllocatorPresenter* pDXRAP)
- : CUnknown(_T("CSubRender"), NULL)
- , m_pDXRAP(pDXRAP)
- {
- }
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- return
- QI(ISubRenderCallback)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- void SetDXRAP(CmadVRAllocatorPresenter* pDXRAP)
- {
- CAutoLock cAutoLock(this);
- m_pDXRAP = pDXRAP;
- }
-
- // ISubRenderCallback
-
- STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev)
- {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
- }
-
- STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height)
- {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
-
- // ISubRendererCallback2
-
- STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height)
- {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
- };
-
- CComPtr<IUnknown> m_pDXR;
- CComPtr<ISubRenderCallback> m_pSRCB;
- CSize m_ScreenSize;
-
-public:
- CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
- virtual ~CmadVRAllocatorPresenter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
- HRESULT Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int bottom, int right, int width, int height);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
- STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
-};
+ class CmadVRAllocatorPresenter
+ : public ISubPicAllocatorPresenterImpl
+ {
+ class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
+ {
+ CmadVRAllocatorPresenter* m_pDXRAP;
+
+ public:
+ CSubRenderCallback(CmadVRAllocatorPresenter* pDXRAP)
+ : CUnknown(_T("CSubRender"), NULL)
+ , m_pDXRAP(pDXRAP)
+ {
+ }
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ return
+ QI(ISubRenderCallback)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ void SetDXRAP(CmadVRAllocatorPresenter* pDXRAP)
+ {
+ CAutoLock cAutoLock(this);
+ m_pDXRAP = pDXRAP;
+ }
+
+ // ISubRenderCallback
+
+ STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev)
+ {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
+ }
+
+ STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height)
+ {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+
+ // ISubRendererCallback2
+
+ STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height)
+ {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+ };
+
+ CComPtr<IUnknown> m_pDXR;
+ CComPtr<ISubRenderCallback> m_pSRCB;
+ CSize m_ScreenSize;
+
+ public:
+ CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
+ virtual ~CmadVRAllocatorPresenter();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
+ HRESULT Render(
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int bottom, int right, int width, int height);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
+ STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ };
}
diff --git a/src/apps/mplayerc/mpciconlib.cpp b/src/apps/mplayerc/mpciconlib.cpp
index 40e939186..8445b96b6 100644
--- a/src/apps/mplayerc/mpciconlib.cpp
+++ b/src/apps/mplayerc/mpciconlib.cpp
@@ -3,114 +3,114 @@
int main()
{
- return 0;
+ return 0;
}
int get_icon_index(CString ext)
{
- int iconindex = -1;
+ int iconindex = -1;
- if(ext.CompareNoCase(_T(".3g2")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".3gp")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".3gp2")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".3gpp")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".aac")) == 0) iconindex = IDI_AAC_ICON;
- else if(ext.CompareNoCase(_T(".ac3")) == 0) iconindex = IDI_DVDA_ICON;
- else if(ext.CompareNoCase(_T(".aif")) == 0) iconindex = IDI_AIFF_ICON;
- else if(ext.CompareNoCase(_T(".aifc")) == 0) iconindex = IDI_AIFF_ICON;
- else if(ext.CompareNoCase(_T(".aiff")) == 0) iconindex = IDI_AIFF_ICON;
- else if(ext.CompareNoCase(_T(".alac")) == 0) iconindex = IDI_ALAC_ICON;
- else if(ext.CompareNoCase(_T(".amr")) == 0) iconindex = IDI_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".amv")) == 0) iconindex = IDI_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".ape")) == 0) iconindex = IDI_NONE;
- else if(ext.CompareNoCase(_T(".asf")) == 0) iconindex = IDI_WMV_ICON;
- else if(ext.CompareNoCase(_T(".asx")) == 0) iconindex = IDI_PLS_ICON;
- else if(ext.CompareNoCase(_T(".au")) == 0) iconindex = IDI_AU_ICON;
- else if(ext.CompareNoCase(_T(".avi")) == 0) iconindex = IDI_AVI_ICON;
- else if(ext.CompareNoCase(_T(".bik")) == 0) iconindex = IDI_BIK_ICON;
- else if(ext.CompareNoCase(_T(".cda")) == 0) iconindex = IDI_CDA_ICON;
- else if(ext.CompareNoCase(_T(".d2v")) == 0) iconindex = IDI_D2V_ICON;
- else if(ext.CompareNoCase(_T(".divx")) == 0) iconindex = IDI_AVI_ICON;
- else if(ext.CompareNoCase(_T(".drc")) == 0) iconindex = IDI_DRC_ICON;
- else if(ext.CompareNoCase(_T(".dsa")) == 0) iconindex = IDI_DSM_ICON;
- else if(ext.CompareNoCase(_T(".dsm")) == 0) iconindex = IDI_DSM_ICON;
- else if(ext.CompareNoCase(_T(".dss")) == 0) iconindex = IDI_DSM_ICON;
- else if(ext.CompareNoCase(_T(".dsv")) == 0) iconindex = IDI_DSM_ICON;
- else if(ext.CompareNoCase(_T(".dts")) == 0) iconindex = IDI_DVDA_ICON;
- else if(ext.CompareNoCase(_T(".evo")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".flac")) == 0) iconindex = IDI_FLAC_ICON;
- else if(ext.CompareNoCase(_T(".flic")) == 0) iconindex = IDI_FLIC_ICON;
- else if(ext.CompareNoCase(_T(".flv")) == 0) iconindex = IDI_FLV_ICON;
- else if(ext.CompareNoCase(_T(".iflv")) == 0) iconindex = IDI_FLV_ICON;
- else if(ext.CompareNoCase(_T(".f4v")) == 0) iconindex = IDI_FLV_ICON;
- else if(ext.CompareNoCase(_T(".hdmov")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".ifo")) == 0) iconindex = IDI_DVDF_ICON;
- else if(ext.CompareNoCase(_T(".ivf")) == 0) iconindex = IDI_IVF_ICON;
- else if(ext.CompareNoCase(_T(".m1a")) == 0) iconindex = IDI_MPA_ICON;
- else if(ext.CompareNoCase(_T(".m1v")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m2a")) == 0) iconindex = IDI_MPA_ICON;
- else if(ext.CompareNoCase(_T(".m2t")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m2ts")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m2v")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m3u")) == 0) iconindex = IDI_PLS_ICON;
- else if(ext.CompareNoCase(_T(".bdmv")) == 0) iconindex = IDI_PLS_ICON;
- else if(ext.CompareNoCase(_T(".m4a")) == 0) iconindex = IDI_AAC_ICON;
- else if(ext.CompareNoCase(_T(".m4b")) == 0) iconindex = IDI_AAC_ICON;
- else if(ext.CompareNoCase(_T(".m4v")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".mid")) == 0) iconindex = IDI_MID_ICON;
- else if(ext.CompareNoCase(_T(".midi")) == 0) iconindex = IDI_MID_ICON;
- else if(ext.CompareNoCase(_T(".mka")) == 0) iconindex = IDI_MKA_ICON;
- else if(ext.CompareNoCase(_T(".mkv")) == 0) iconindex = IDI_MKV_ICON;
- else if(ext.CompareNoCase(_T(".mov")) == 0) iconindex = IDI_MOV_ICON;
- else if(ext.CompareNoCase(_T(".mp2")) == 0) iconindex = IDI_MPC_ICON;
- else if(ext.CompareNoCase(_T(".mp2v")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mp3")) == 0) iconindex = IDI_MP3_ICON;
- else if(ext.CompareNoCase(_T(".mp4")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".mpa")) == 0) iconindex = IDI_MPA_ICON;
- else if(ext.CompareNoCase(_T(".mpc")) == 0) iconindex = IDI_MPC_ICON;
- else if(ext.CompareNoCase(_T(".mpcpl")) == 0) iconindex = IDI_PLS_ICON;
- else if(ext.CompareNoCase(_T(".mpe")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mpeg")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mpg")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mpv2")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mts")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".oga")) == 0) iconindex = IDI_OGG_ICON;
- else if(ext.CompareNoCase(_T(".ogg")) == 0) iconindex = IDI_OGG_ICON;
- else if(ext.CompareNoCase(_T(".ogm")) == 0) iconindex = IDI_OGM_ICON;
- else if(ext.CompareNoCase(_T(".ogv")) == 0) iconindex = IDI_OGM_ICON;
- else if(ext.CompareNoCase(_T(".pls")) == 0) iconindex = IDI_PLS_ICON;
- else if(ext.CompareNoCase(_T(".pva")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".pss")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".qt")) == 0) iconindex = IDI_MOV_ICON;
- else if(ext.CompareNoCase(_T(".ra")) == 0) iconindex = IDI_RA_ICON;
- else if(ext.CompareNoCase(_T(".ram")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".ratdvd")) == 0) iconindex = IDI_RATDVD_ICON;
- else if(ext.CompareNoCase(_T(".rm")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".rmi")) == 0) iconindex = IDI_MID_ICON;
- else if(ext.CompareNoCase(_T(".rmm")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".rmvb")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".roq")) == 0) iconindex = IDI_ROQ_ICON;
- else if(ext.CompareNoCase(_T(".rp")) == 0) iconindex = IDI_RT_ICON;
- else if(ext.CompareNoCase(_T(".rpm")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".rt")) == 0) iconindex = IDI_RT_ICON;
- else if(ext.CompareNoCase(_T(".smi")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".smil")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".smk")) == 0) iconindex = IDI_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".snd")) == 0) iconindex = IDI_AU_ICON;
- else if(ext.CompareNoCase(_T(".tp")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".tpr")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".ts")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".vob")) == 0) iconindex = IDI_DVDF_ICON;
- else if(ext.CompareNoCase(_T(".vp6")) == 0) iconindex = IDI_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".wav")) == 0) iconindex = IDI_WAV_ICON;
- else if(ext.CompareNoCase(_T(".wax")) == 0) iconindex = IDI_PLS_ICON;
- else if(ext.CompareNoCase(_T(".wm")) == 0) iconindex = IDI_WMV_ICON;
- else if(ext.CompareNoCase(_T(".wma")) == 0) iconindex = IDI_WMA_ICON;
- else if(ext.CompareNoCase(_T(".wmp")) == 0) iconindex = IDI_WMV_ICON;
- else if(ext.CompareNoCase(_T(".wmv")) == 0) iconindex = IDI_WMV_ICON;
- else if(ext.CompareNoCase(_T(".wmx")) == 0) iconindex = IDI_PLS_ICON;
- else if(ext.CompareNoCase(_T(".wv")) == 0) iconindex = IDI_NONE;
- else if(ext.CompareNoCase(_T(".wvx")) == 0) iconindex = IDI_PLS_ICON;
+ if(ext.CompareNoCase(_T(".3g2")) == 0) iconindex = IDI_MP4_ICON;
+ else if(ext.CompareNoCase(_T(".3gp")) == 0) iconindex = IDI_MP4_ICON;
+ else if(ext.CompareNoCase(_T(".3gp2")) == 0) iconindex = IDI_MP4_ICON;
+ else if(ext.CompareNoCase(_T(".3gpp")) == 0) iconindex = IDI_MP4_ICON;
+ else if(ext.CompareNoCase(_T(".aac")) == 0) iconindex = IDI_AAC_ICON;
+ else if(ext.CompareNoCase(_T(".ac3")) == 0) iconindex = IDI_DVDA_ICON;
+ else if(ext.CompareNoCase(_T(".aif")) == 0) iconindex = IDI_AIFF_ICON;
+ else if(ext.CompareNoCase(_T(".aifc")) == 0) iconindex = IDI_AIFF_ICON;
+ else if(ext.CompareNoCase(_T(".aiff")) == 0) iconindex = IDI_AIFF_ICON;
+ else if(ext.CompareNoCase(_T(".alac")) == 0) iconindex = IDI_ALAC_ICON;
+ else if(ext.CompareNoCase(_T(".amr")) == 0) iconindex = IDI_OTHER_ICON;
+ else if(ext.CompareNoCase(_T(".amv")) == 0) iconindex = IDI_OTHER_ICON;
+ else if(ext.CompareNoCase(_T(".ape")) == 0) iconindex = IDI_NONE;
+ else if(ext.CompareNoCase(_T(".asf")) == 0) iconindex = IDI_WMV_ICON;
+ else if(ext.CompareNoCase(_T(".asx")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".au")) == 0) iconindex = IDI_AU_ICON;
+ else if(ext.CompareNoCase(_T(".avi")) == 0) iconindex = IDI_AVI_ICON;
+ else if(ext.CompareNoCase(_T(".bik")) == 0) iconindex = IDI_BIK_ICON;
+ else if(ext.CompareNoCase(_T(".cda")) == 0) iconindex = IDI_CDA_ICON;
+ else if(ext.CompareNoCase(_T(".d2v")) == 0) iconindex = IDI_D2V_ICON;
+ else if(ext.CompareNoCase(_T(".divx")) == 0) iconindex = IDI_AVI_ICON;
+ else if(ext.CompareNoCase(_T(".drc")) == 0) iconindex = IDI_DRC_ICON;
+ else if(ext.CompareNoCase(_T(".dsa")) == 0) iconindex = IDI_DSM_ICON;
+ else if(ext.CompareNoCase(_T(".dsm")) == 0) iconindex = IDI_DSM_ICON;
+ else if(ext.CompareNoCase(_T(".dss")) == 0) iconindex = IDI_DSM_ICON;
+ else if(ext.CompareNoCase(_T(".dsv")) == 0) iconindex = IDI_DSM_ICON;
+ else if(ext.CompareNoCase(_T(".dts")) == 0) iconindex = IDI_DVDA_ICON;
+ else if(ext.CompareNoCase(_T(".evo")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".flac")) == 0) iconindex = IDI_FLAC_ICON;
+ else if(ext.CompareNoCase(_T(".flic")) == 0) iconindex = IDI_FLIC_ICON;
+ else if(ext.CompareNoCase(_T(".flv")) == 0) iconindex = IDI_FLV_ICON;
+ else if(ext.CompareNoCase(_T(".iflv")) == 0) iconindex = IDI_FLV_ICON;
+ else if(ext.CompareNoCase(_T(".f4v")) == 0) iconindex = IDI_FLV_ICON;
+ else if(ext.CompareNoCase(_T(".hdmov")) == 0) iconindex = IDI_MP4_ICON;
+ else if(ext.CompareNoCase(_T(".ifo")) == 0) iconindex = IDI_DVDF_ICON;
+ else if(ext.CompareNoCase(_T(".ivf")) == 0) iconindex = IDI_IVF_ICON;
+ else if(ext.CompareNoCase(_T(".m1a")) == 0) iconindex = IDI_MPA_ICON;
+ else if(ext.CompareNoCase(_T(".m1v")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".m2a")) == 0) iconindex = IDI_MPA_ICON;
+ else if(ext.CompareNoCase(_T(".m2t")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".m2ts")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".m2v")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".m3u")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".bdmv")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".m4a")) == 0) iconindex = IDI_AAC_ICON;
+ else if(ext.CompareNoCase(_T(".m4b")) == 0) iconindex = IDI_AAC_ICON;
+ else if(ext.CompareNoCase(_T(".m4v")) == 0) iconindex = IDI_MP4_ICON;
+ else if(ext.CompareNoCase(_T(".mid")) == 0) iconindex = IDI_MID_ICON;
+ else if(ext.CompareNoCase(_T(".midi")) == 0) iconindex = IDI_MID_ICON;
+ else if(ext.CompareNoCase(_T(".mka")) == 0) iconindex = IDI_MKA_ICON;
+ else if(ext.CompareNoCase(_T(".mkv")) == 0) iconindex = IDI_MKV_ICON;
+ else if(ext.CompareNoCase(_T(".mov")) == 0) iconindex = IDI_MOV_ICON;
+ else if(ext.CompareNoCase(_T(".mp2")) == 0) iconindex = IDI_MPC_ICON;
+ else if(ext.CompareNoCase(_T(".mp2v")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".mp3")) == 0) iconindex = IDI_MP3_ICON;
+ else if(ext.CompareNoCase(_T(".mp4")) == 0) iconindex = IDI_MP4_ICON;
+ else if(ext.CompareNoCase(_T(".mpa")) == 0) iconindex = IDI_MPA_ICON;
+ else if(ext.CompareNoCase(_T(".mpc")) == 0) iconindex = IDI_MPC_ICON;
+ else if(ext.CompareNoCase(_T(".mpcpl")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".mpe")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".mpeg")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".mpg")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".mpv2")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".mts")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".oga")) == 0) iconindex = IDI_OGG_ICON;
+ else if(ext.CompareNoCase(_T(".ogg")) == 0) iconindex = IDI_OGG_ICON;
+ else if(ext.CompareNoCase(_T(".ogm")) == 0) iconindex = IDI_OGM_ICON;
+ else if(ext.CompareNoCase(_T(".ogv")) == 0) iconindex = IDI_OGM_ICON;
+ else if(ext.CompareNoCase(_T(".pls")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".pva")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".pss")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".qt")) == 0) iconindex = IDI_MOV_ICON;
+ else if(ext.CompareNoCase(_T(".ra")) == 0) iconindex = IDI_RA_ICON;
+ else if(ext.CompareNoCase(_T(".ram")) == 0) iconindex = IDI_RM_ICON;
+ else if(ext.CompareNoCase(_T(".ratdvd")) == 0) iconindex = IDI_RATDVD_ICON;
+ else if(ext.CompareNoCase(_T(".rm")) == 0) iconindex = IDI_RM_ICON;
+ else if(ext.CompareNoCase(_T(".rmi")) == 0) iconindex = IDI_MID_ICON;
+ else if(ext.CompareNoCase(_T(".rmm")) == 0) iconindex = IDI_RM_ICON;
+ else if(ext.CompareNoCase(_T(".rmvb")) == 0) iconindex = IDI_RM_ICON;
+ else if(ext.CompareNoCase(_T(".roq")) == 0) iconindex = IDI_ROQ_ICON;
+ else if(ext.CompareNoCase(_T(".rp")) == 0) iconindex = IDI_RT_ICON;
+ else if(ext.CompareNoCase(_T(".rpm")) == 0) iconindex = IDI_RM_ICON;
+ else if(ext.CompareNoCase(_T(".rt")) == 0) iconindex = IDI_RT_ICON;
+ else if(ext.CompareNoCase(_T(".smi")) == 0) iconindex = IDI_RM_ICON;
+ else if(ext.CompareNoCase(_T(".smil")) == 0) iconindex = IDI_RM_ICON;
+ else if(ext.CompareNoCase(_T(".smk")) == 0) iconindex = IDI_OTHER_ICON;
+ else if(ext.CompareNoCase(_T(".snd")) == 0) iconindex = IDI_AU_ICON;
+ else if(ext.CompareNoCase(_T(".tp")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".tpr")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".ts")) == 0) iconindex = IDI_MPG_ICON;
+ else if(ext.CompareNoCase(_T(".vob")) == 0) iconindex = IDI_DVDF_ICON;
+ else if(ext.CompareNoCase(_T(".vp6")) == 0) iconindex = IDI_OTHER_ICON;
+ else if(ext.CompareNoCase(_T(".wav")) == 0) iconindex = IDI_WAV_ICON;
+ else if(ext.CompareNoCase(_T(".wax")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".wm")) == 0) iconindex = IDI_WMV_ICON;
+ else if(ext.CompareNoCase(_T(".wma")) == 0) iconindex = IDI_WMA_ICON;
+ else if(ext.CompareNoCase(_T(".wmp")) == 0) iconindex = IDI_WMV_ICON;
+ else if(ext.CompareNoCase(_T(".wmv")) == 0) iconindex = IDI_WMV_ICON;
+ else if(ext.CompareNoCase(_T(".wmx")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".wv")) == 0) iconindex = IDI_NONE;
+ else if(ext.CompareNoCase(_T(".wvx")) == 0) iconindex = IDI_PLS_ICON;
- return iconindex;
+ return iconindex;
}
diff --git a/src/apps/mplayerc/mpciconlib.h b/src/apps/mplayerc/mpciconlib.h
index aed4f5e21..fba666c93 100644
--- a/src/apps/mplayerc/mpciconlib.h
+++ b/src/apps/mplayerc/mpciconlib.h
@@ -47,7 +47,7 @@
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 39
diff --git a/src/apps/mplayerc/mplayerc.cpp b/src/apps/mplayerc/mplayerc.cpp
index 3dc3b3f50..517899ed2 100644
--- a/src/apps/mplayerc/mplayerc.cpp
+++ b/src/apps/mplayerc/mplayerc.cpp
@@ -45,147 +45,147 @@
void CorrectComboListWidth(CComboBox& box, CFont* pWndFont)
{
- int cnt = box.GetCount();
- if(cnt <= 0) return;
+ int cnt = box.GetCount();
+ if(cnt <= 0) return;
- CDC* pDC = box.GetDC();
- pDC->SelectObject(pWndFont);
+ CDC* pDC = box.GetDC();
+ pDC->SelectObject(pWndFont);
- int maxw = box.GetDroppedWidth();
+ int maxw = box.GetDroppedWidth();
- for(int i = 0; i < cnt; i++)
- {
- CString str;
- box.GetLBText(i, str);
- int w = pDC->GetTextExtent(str).cx + 22;
- if(maxw < w) maxw = w;
- }
+ for(int i = 0; i < cnt; i++)
+ {
+ CString str;
+ box.GetLBText(i, str);
+ int w = pDC->GetTextExtent(str).cx + 22;
+ if(maxw < w) maxw = w;
+ }
- box.ReleaseDC(pDC);
+ box.ReleaseDC(pDC);
- box.SetDroppedWidth(maxw);
+ box.SetDroppedWidth(maxw);
}
HICON LoadIcon(CString fn, bool fSmall)
{
- if(fn.IsEmpty()) return(NULL);
+ if(fn.IsEmpty()) return(NULL);
- CString ext = fn.Left(fn.Find(_T("://")) + 1).TrimRight(':');
- if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
- ext = _T(".") + fn.Mid(fn.ReverseFind('.') + 1);
+ CString ext = fn.Left(fn.Find(_T("://"))+1).TrimRight(':');
+ if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
+ ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
- CSize size(fSmall ? 16 : 32, fSmall ? 16 : 32);
-
- if(!ext.CompareNoCase(_T(".ifo")))
- {
- if(HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DVD), IMAGE_ICON, size.cx, size.cy, 0))
- return(hIcon);
- }
+ CSize size(fSmall?16:32,fSmall?16:32);
- if(!ext.CompareNoCase(_T(".cda")))
- {
- if(HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIOCD), IMAGE_ICON, size.cx, size.cy, 0))
- return(hIcon);
- }
+ if(!ext.CompareNoCase(_T(".ifo")))
+ {
+ if(HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DVD), IMAGE_ICON, size.cx, size.cy, 0))
+ return(hIcon);
+ }
- do
- {
- CRegKey key;
+ if(!ext.CompareNoCase(_T(".cda")))
+ {
+ if(HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIOCD), IMAGE_ICON, size.cx, size.cy, 0))
+ return(hIcon);
+ }
- TCHAR buff[256];
- ULONG len;
+ do
+ {
+ CRegKey key;
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ))
- {
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext, KEY_READ))
- break;
+ TCHAR buff[256];
+ ULONG len;
- len = sizeof(buff);
- memset(buff, 0, len);
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (ext = buff).Trim().IsEmpty())
- break;
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ))
+ {
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext, KEY_READ))
+ break;
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ))
- break;
- }
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (ext = buff).Trim().IsEmpty())
+ break;
- CString icon;
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ))
+ break;
+ }
- len = sizeof(buff);
- memset(buff, 0, len);
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (icon = buff).Trim().IsEmpty())
- break;
+ CString icon;
- int i = icon.ReverseFind(',');
- if(i < 0) break;
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (icon = buff).Trim().IsEmpty())
+ break;
- int id = 0;
- if(_stscanf_s(icon.Mid(i + 1), _T("%d"), &id) != 1)
- break;
+ int i = icon.ReverseFind(',');
+ if(i < 0) break;
+
+ int id = 0;
+ if(_stscanf_s(icon.Mid(i+1), _T("%d"), &id) != 1)
+ break;
- icon = icon.Left(i);
+ icon = icon.Left(i);
- HICON hIcon = NULL;
- UINT cnt = fSmall
- ? ExtractIconEx(icon, id, NULL, &hIcon, 1)
- : ExtractIconEx(icon, id, &hIcon, NULL, 1);
- if(hIcon) return hIcon;
- }
- while(0);
+ HICON hIcon = NULL;
+ UINT cnt = fSmall
+ ? ExtractIconEx(icon, id, NULL, &hIcon, 1)
+ : ExtractIconEx(icon, id, &hIcon, NULL, 1);
+ if(hIcon) return hIcon;
+ }
+ while(0);
- return((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_UNKNOWN), IMAGE_ICON, size.cx, size.cy, 0));
+ return((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_UNKNOWN), IMAGE_ICON, size.cx, size.cy, 0));
}
bool LoadType(CString fn, CString& type)
{
- CRegKey key;
+ CRegKey key;
- TCHAR buff[256];
- ULONG len;
+ TCHAR buff[256];
+ ULONG len;
- if(fn.IsEmpty()) return(NULL);
+ if(fn.IsEmpty()) return(NULL);
- CString ext = fn.Left(fn.Find(_T("://")) + 1).TrimRight(':');
- if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
- ext = _T(".") + fn.Mid(fn.ReverseFind('.') + 1);
+ CString ext = fn.Left(fn.Find(_T("://"))+1).TrimRight(':');
+ if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
+ ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext))
- return(false);
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext))
+ return(false);
- CString tmp = ext;
+ CString tmp = ext;
while(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, tmp))
- {
- len = sizeof(buff);
- memset(buff, 0, len);
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
- break;
+ {
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
+ break;
- CString str(buff);
- str.Trim();
+ CString str(buff);
+ str.Trim();
- if(str.IsEmpty() || str == tmp)
- break;
+ if(str.IsEmpty() || str == tmp)
+ break;
- tmp = str;
- }
+ tmp = str;
+ }
- type = tmp;
+ type = tmp;
- return(true);
+ return(true);
}
bool LoadResource(UINT resid, CStringA& str, LPCTSTR restype)
{
- str.Empty();
- HRSRC hrsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(resid), restype);
- if(!hrsrc) return(false);
- HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hrsrc);
- if(!hGlobal) return(false);
- DWORD size = SizeofResource(AfxGetApp()->m_hInstance, hrsrc);
- if(!size) return(false);
- memcpy(str.GetBufferSetLength(size), LockResource(hGlobal), size);
- return(true);
+ str.Empty();
+ HRSRC hrsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(resid), restype);
+ if(!hrsrc) return(false);
+ HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hrsrc);
+ if(!hGlobal) return(false);
+ DWORD size = SizeofResource(AfxGetApp()->m_hInstance, hrsrc);
+ if(!size) return(false);
+ memcpy(str.GetBufferSetLength(size), LockResource(hGlobal), size);
+ return(true);
}
/////////////////////////////////////////////////////////////////////////////
@@ -196,92 +196,92 @@ extern "C" char *GetFfmpegCompiler();
class CAboutDlg : public CDialog
{
public:
- CAboutDlg();
+ CAboutDlg();
// Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
+ //{{AFX_DATA(CAboutDlg)
+ enum { IDD = IDD_ABOUTBOX };
+ //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
-protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CAboutDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
// Implementation
protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CAboutDlg)
+ // No message handlers
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
public:
- CString m_appname;
- virtual BOOL OnInitDialog()
- {
- USES_CONVERSION;
- UpdateData();
- m_strBuildNumber = AfxGetMyApp()->m_strVersion;
-
-#if (_MSC_VER == 1500)
-#if (_MSC_FULL_VER >= 150030729)
- m_MPCCompiler = _T("MSVC 2008 SP1");
-#else
- m_MPCCompiler = _T("MSVC 2008");
-#endif
-#elif (_MSC_VER < 1500)
-#error Compiler is not supported!
-#endif
+ CString m_appname;
+ virtual BOOL OnInitDialog()
+ {
+ USES_CONVERSION;
+ UpdateData();
+ m_strBuildNumber = AfxGetMyApp()->m_strVersion;
+
+ #if (_MSC_VER == 1500)
+ #if (_MSC_FULL_VER >= 150030729)
+ m_MPCCompiler = _T("MSVC 2008 SP1");
+ #else
+ m_MPCCompiler = _T("MSVC 2008");
+ #endif
+ #elif (_MSC_VER < 1500)
+ #error Compiler is not supported!
+ #endif
#if INCLUDE_MPC_VIDEO_DECODER | INCLUDE_MPC_DXVA_VIDEO_DECODER
- m_FfmpegCompiler.Format(A2W(GetFfmpegCompiler()));
+ m_FfmpegCompiler.Format (A2W(GetFfmpegCompiler()));
#endif
- UpdateData(FALSE);
- return TRUE;
- }
- CString m_strBuildNumber;
- CString m_MPCCompiler;
- CString m_FfmpegCompiler;
- afx_msg void OnHomepage(NMHDR *pNMHDR, LRESULT *pResult);
+ UpdateData(FALSE);
+ return TRUE;
+ }
+ CString m_strBuildNumber;
+ CString m_MPCCompiler;
+ CString m_FfmpegCompiler;
+ afx_msg void OnHomepage(NMHDR *pNMHDR, LRESULT *pResult);
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD), m_appname(_T(""))
- , m_strBuildNumber(_T(""))
- , m_MPCCompiler(_T(""))
- , m_FfmpegCompiler(_T(""))
+, m_strBuildNumber(_T(""))
+, m_MPCCompiler(_T(""))
+, m_FfmpegCompiler(_T(""))
{
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
+ //{{AFX_DATA_INIT(CAboutDlg)
+ //}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- DDX_Text(pDX, IDC_STATIC1, m_appname);
- DDX_Text(pDX, IDC_BUILD_NUMBER, m_strBuildNumber);
- DDX_Text(pDX, IDC_MPC_COMPILER, m_MPCCompiler);
- DDX_Text(pDX, IDC_FFMPEG_COMPILER, m_FfmpegCompiler);
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CAboutDlg)
+ //}}AFX_DATA_MAP
+ DDX_Text(pDX, IDC_STATIC1, m_appname);
+ DDX_Text(pDX, IDC_BUILD_NUMBER, m_strBuildNumber);
+ DDX_Text(pDX, IDC_MPC_COMPILER, m_MPCCompiler);
+ DDX_Text(pDX, IDC_FFMPEG_COMPILER, m_FfmpegCompiler);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- ON_NOTIFY(NM_CLICK, IDC_SOURCEFORGE_LINK, &CAboutDlg::OnHomepage)
+ //{{AFX_MSG_MAP(CAboutDlg)
+ // No message handlers
+ //}}AFX_MSG_MAP
+ ON_NOTIFY(NM_CLICK, IDC_SOURCEFORGE_LINK, &CAboutDlg::OnHomepage)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMPlayerCApp
BEGIN_MESSAGE_MAP(CMPlayerCApp, CWinApp)
- //{{AFX_MSG_MAP(CMPlayerCApp)
- ON_COMMAND(ID_HELP_ABOUT, OnAppAbout)
- ON_COMMAND(ID_FILE_EXIT, OnFileExit)
- //}}AFX_MSG_MAP
- ON_COMMAND(ID_HELP_SHOWCOMMANDLINESWITCHES, OnHelpShowcommandlineswitches)
+ //{{AFX_MSG_MAP(CMPlayerCApp)
+ ON_COMMAND(ID_HELP_ABOUT, OnAppAbout)
+ ON_COMMAND(ID_FILE_EXIT, OnFileExit)
+ //}}AFX_MSG_MAP
+ ON_COMMAND(ID_HELP_SHOWCOMMANDLINESWITCHES, OnHelpShowcommandlineswitches)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -290,45 +290,45 @@ END_MESSAGE_MAP()
CMPlayerCApp::CMPlayerCApp()
// : m_hMutexOneInstance(NULL)
{
- CFileVersionInfo Version;
- TCHAR strApp [_MAX_PATH];
+ CFileVersionInfo Version;
+ TCHAR strApp [_MAX_PATH];
- GetModuleFileNameEx(GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, MAX_PATH);
- Version.Create(strApp);
- m_strVersion = Version.GetFileVersionEx();
+ GetModuleFileNameEx (GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, MAX_PATH);
+ Version.Create (strApp);
+ m_strVersion = Version.GetFileVersionEx();
- m_fTearingTest = false;
- m_fDisplayStats = false;
- m_bResetStats = false;
- m_hD3DX9Dll = NULL;
- m_nDXSdkRelease = 0;
- memset(&m_ColorControl, 0, sizeof(m_ColorControl));
- m_ColorControl[0].dwSize = sizeof(COLORPROPERTY_RANGE);
- m_ColorControl[0].dwProperty = Brightness;
- m_ColorControl[1].dwSize = sizeof(COLORPROPERTY_RANGE);
- m_ColorControl[1].dwProperty = Contrast;
- m_ColorControl[2].dwSize = sizeof(COLORPROPERTY_RANGE);
- m_ColorControl[2].dwProperty = Hue;
- m_ColorControl[3].dwSize = sizeof(COLORPROPERTY_RANGE);
- m_ColorControl[3].dwProperty = Saturation;
+ m_fTearingTest = false;
+ m_fDisplayStats = false;
+ m_bResetStats = false;
+ m_hD3DX9Dll = NULL;
+ m_nDXSdkRelease = 0;
+ memset (&m_ColorControl, 0, sizeof(m_ColorControl));
+ m_ColorControl[0].dwSize = sizeof (COLORPROPERTY_RANGE);
+ m_ColorControl[0].dwProperty = Brightness;
+ m_ColorControl[1].dwSize = sizeof (COLORPROPERTY_RANGE);
+ m_ColorControl[1].dwProperty = Contrast;
+ m_ColorControl[2].dwSize = sizeof (COLORPROPERTY_RANGE);
+ m_ColorControl[2].dwProperty = Hue;
+ m_ColorControl[3].dwSize = sizeof (COLORPROPERTY_RANGE);
+ m_ColorControl[3].dwProperty = Saturation;
- GetRemoteControlCode = GetRemoteControlCodeMicrosoft;
+ GetRemoteControlCode = GetRemoteControlCodeMicrosoft;
}
void CMPlayerCApp::ShowCmdlnSwitches()
{
- CString s;
+ CString s;
- if(m_s.nCLSwitches & CLSW_UNRECOGNIZEDSWITCH)
- {
- CAtlList<CString> sl;
- for(int i = 0; i < __argc; i++) sl.AddTail(__targv[i]);
- s += ResStr(IDS_UNKNOWN_SWITCH) + Implode(sl, ' ') + _T("\n\n");
- }
+ if(m_s.nCLSwitches&CLSW_UNRECOGNIZEDSWITCH)
+ {
+ CAtlList<CString> sl;
+ for(int i = 0; i < __argc; i++) sl.AddTail(__targv[i]);
+ s += ResStr(IDS_UNKNOWN_SWITCH) + Implode(sl, ' ') + _T("\n\n");
+ }
- s += ResStr(IDS_USAGE);
+ s += ResStr (IDS_USAGE);
- AfxMessageBox(s);
+ AfxMessageBox(s);
}
/////////////////////////////////////////////////////////////////////////////
@@ -340,132 +340,132 @@ HWND g_hWnd = NULL;
bool CMPlayerCApp::StoreSettingsToIni()
{
- CString ini = GetIniPath();
- /*
- FILE* f;
- if(!(f = _tfopen(ini, _T("r+"))) && !(f = _tfopen(ini, _T("w"))))
- return StoreSettingsToRegistry();
- fclose(f);
- */
- if(m_pszRegistryKey) free((void*)m_pszRegistryKey);
- m_pszRegistryKey = NULL;
- if(m_pszProfileName) free((void*)m_pszProfileName);
- m_pszProfileName = _tcsdup(ini);
+ CString ini = GetIniPath();
+/*
+ FILE* f;
+ if(!(f = _tfopen(ini, _T("r+"))) && !(f = _tfopen(ini, _T("w"))))
+ return StoreSettingsToRegistry();
+ fclose(f);
+*/
+ if(m_pszRegistryKey) free((void*)m_pszRegistryKey);
+ m_pszRegistryKey = NULL;
+ if(m_pszProfileName) free((void*)m_pszProfileName);
+ m_pszProfileName = _tcsdup(ini);
- return(true);
+ return(true);
}
bool CMPlayerCApp::StoreSettingsToRegistry()
{
- _tremove(GetIniPath());
+ _tremove(GetIniPath());
- if(m_pszRegistryKey) free((void*)m_pszRegistryKey);
- m_pszRegistryKey = NULL;
+ if(m_pszRegistryKey) free((void*)m_pszRegistryKey);
+ m_pszRegistryKey = NULL;
- SetRegistryKey(_T("Gabest"));
+ SetRegistryKey(_T("Gabest"));
- return(true);
+ return(true);
}
CString CMPlayerCApp::GetIniPath()
{
- CString path;
- GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
- path.ReleaseBuffer();
- path = path.Left(path.ReverseFind('.') + 1) + _T("ini");
- return(path);
+ CString path;
+ GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
+ path.ReleaseBuffer();
+ path = path.Left(path.ReverseFind('.')+1) + _T("ini");
+ return(path);
}
bool CMPlayerCApp::IsIniValid()
{
- CFileStatus fs;
- return CFileGetStatus(GetIniPath(), fs) && fs.m_size > 0;
+ CFileStatus fs;
+ return CFileGetStatus(GetIniPath(), fs) && fs.m_size > 0;
}
bool CMPlayerCApp::GetAppSavePath(CString& path)
{
- path.Empty();
+ path.Empty();
- if(IsIniValid()) // If settings ini file found, store stuff in the same folder as the exe file
- {
- GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
- path.ReleaseBuffer();
- path = path.Left(path.ReverseFind('\\'));
- }
- else
- {
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ))
- {
- ULONG len = MAX_PATH;
- if(ERROR_SUCCESS == key.QueryStringValue(_T("AppData"), path.GetBuffer(MAX_PATH), &len))
- path.ReleaseBufferSetLength(len);
- }
-
- if(path.IsEmpty())
- return(false);
-
- CPath p;
- p.Combine(path, _T("Media Player Classic"));
- path = (LPCTSTR)p;
- }
+ if(IsIniValid()) // If settings ini file found, store stuff in the same folder as the exe file
+ {
+ GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
+ path.ReleaseBuffer();
+ path = path.Left(path.ReverseFind('\\'));
+ }
+ else
+ {
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ))
+ {
+ ULONG len = MAX_PATH;
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("AppData"), path.GetBuffer(MAX_PATH), &len))
+ path.ReleaseBufferSetLength(len);
+ }
+
+ if(path.IsEmpty())
+ return(false);
- return(true);
+ CPath p;
+ p.Combine(path, _T("Media Player Classic"));
+ path = (LPCTSTR)p;
+ }
+
+ return(true);
}
void CMPlayerCApp::PreProcessCommandLine()
{
- m_cmdln.RemoveAll();
- for(int i = 1; i < __argc; i++)
- {
- CString str = CString(__targv[i]).Trim(_T(" \""));
-
- if(str[0] != '/' && str[0] != '-' && str.Find(_T(":")) < 0)
- {
- LPTSTR p = NULL;
- CString str2;
- str2.ReleaseBuffer(GetFullPathName(str, MAX_PATH, str2.GetBuffer(MAX_PATH), &p));
- CFileStatus fs;
- if(!str2.IsEmpty() && CFileGetStatus(str2, fs)) str = str2;
- }
-
- m_cmdln.AddTail(str);
- }
+ m_cmdln.RemoveAll();
+ for(int i = 1; i < __argc; i++)
+ {
+ CString str = CString(__targv[i]).Trim(_T(" \""));
+
+ if(str[0] != '/' && str[0] != '-' && str.Find(_T(":")) < 0)
+ {
+ LPTSTR p = NULL;
+ CString str2;
+ str2.ReleaseBuffer(GetFullPathName(str, MAX_PATH, str2.GetBuffer(MAX_PATH), &p));
+ CFileStatus fs;
+ if(!str2.IsEmpty() && CFileGetStatus(str2, fs)) str = str2;
+ }
+
+ m_cmdln.AddTail(str);
+ }
}
void CMPlayerCApp::SendCommandLine(HWND hWnd)
{
- if(m_cmdln.IsEmpty())
- return;
+ if(m_cmdln.IsEmpty())
+ return;
- int bufflen = sizeof(DWORD);
+ int bufflen = sizeof(DWORD);
- POSITION pos = m_cmdln.GetHeadPosition();
- while(pos) bufflen += (m_cmdln.GetNext(pos).GetLength() + 1) * sizeof(TCHAR);
+ POSITION pos = m_cmdln.GetHeadPosition();
+ while(pos) bufflen += (m_cmdln.GetNext(pos).GetLength()+1)*sizeof(TCHAR);
- CAutoVectorPtr<BYTE> buff;
- if(!buff.Allocate(bufflen))
- return;
+ CAutoVectorPtr<BYTE> buff;
+ if(!buff.Allocate(bufflen))
+ return;
- BYTE* p = buff;
+ BYTE* p = buff;
- *(DWORD*)p = m_cmdln.GetCount();
- p += sizeof(DWORD);
+ *(DWORD*)p = m_cmdln.GetCount();
+ p += sizeof(DWORD);
- pos = m_cmdln.GetHeadPosition();
- while(pos)
- {
- CString s = m_cmdln.GetNext(pos);
- int len = (s.GetLength() + 1) * sizeof(TCHAR);
- memcpy(p, s, len);
- p += len;
- }
+ pos = m_cmdln.GetHeadPosition();
+ while(pos)
+ {
+ CString s = m_cmdln.GetNext(pos);
+ int len = (s.GetLength()+1)*sizeof(TCHAR);
+ memcpy(p, s, len);
+ p += len;
+ }
- COPYDATASTRUCT cds;
- cds.dwData = 0x6ABE51;
- cds.cbData = bufflen;
- cds.lpData = (void*)(BYTE*)buff;
- SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
+ COPYDATASTRUCT cds;
+ cds.dwData = 0x6ABE51;
+ cds.cbData = bufflen;
+ cds.lpData = (void*)(BYTE*)buff;
+ SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
}
/////////////////////////////////////////////////////////////////////////////
@@ -476,39 +476,39 @@ void CMPlayerCApp::SendCommandLine(HWND hWnd)
#include <detours/detours.h>
BOOL (__stdcall * Real_IsDebuggerPresent)(void)
-= IsDebuggerPresent;
-
-LONG(__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
- LPDEVMODEA a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
-= ChangeDisplaySettingsExA;
-
-LONG(__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
- LPDEVMODEW a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
-= ChangeDisplaySettingsExW;
-
-HANDLE(__stdcall * Real_CreateFileA)(LPCSTR a0,
- DWORD a1,
- DWORD a2,
- LPSECURITY_ATTRIBUTES a3,
- DWORD a4,
- DWORD a5,
- HANDLE a6)
-= CreateFileA;
-
-HANDLE(__stdcall * Real_CreateFileW)(LPCWSTR a0,
- DWORD a1,
- DWORD a2,
- LPSECURITY_ATTRIBUTES a3,
- DWORD a4,
- DWORD a5,
- HANDLE a6)
-= CreateFileW;
+ = IsDebuggerPresent;
+
+LONG (__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
+ LPDEVMODEA a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExA;
+
+LONG (__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
+ LPDEVMODEW a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExW;
+
+HANDLE (__stdcall * Real_CreateFileA)(LPCSTR a0,
+ DWORD a1,
+ DWORD a2,
+ LPSECURITY_ATTRIBUTES a3,
+ DWORD a4,
+ DWORD a5,
+ HANDLE a6)
+ = CreateFileA;
+
+HANDLE (__stdcall * Real_CreateFileW)(LPCWSTR a0,
+ DWORD a1,
+ DWORD a2,
+ LPSECURITY_ATTRIBUTES a3,
+ DWORD a4,
+ DWORD a5,
+ HANDLE a6)
+ = CreateFileW;
BOOL (__stdcall * Real_DeviceIoControl)(HANDLE a0,
DWORD a1,
@@ -518,177 +518,177 @@ BOOL (__stdcall * Real_DeviceIoControl)(HANDLE a0,
DWORD a5,
LPDWORD a6,
LPOVERLAPPED a7)
-= DeviceIoControl;
+ = DeviceIoControl;
-MMRESULT(__stdcall * Real_mixerSetControlDetails)(HMIXEROBJ hmxobj,
- LPMIXERCONTROLDETAILS pmxcd,
- DWORD fdwDetails)
-= mixerSetControlDetails;
+MMRESULT (__stdcall * Real_mixerSetControlDetails)( HMIXEROBJ hmxobj,
+ LPMIXERCONTROLDETAILS pmxcd,
+ DWORD fdwDetails)
+ = mixerSetControlDetails;
-typedef NTSTATUS(WINAPI *FUNC_NTQUERYINFORMATIONPROCESS)(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength);
+typedef NTSTATUS (WINAPI *FUNC_NTQUERYINFORMATIONPROCESS)(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength);
static FUNC_NTQUERYINFORMATIONPROCESS Real_NtQueryInformationProcess = NULL;
/*
-NTSTATUS (* Real_NtQueryInformationProcess) (HANDLE ProcessHandle,
- PROCESSINFOCLASS ProcessInformationClass,
- PVOID ProcessInformation,
- ULONG ProcessInformationLength,
+NTSTATUS (* Real_NtQueryInformationProcess) (HANDLE ProcessHandle,
+ PROCESSINFOCLASS ProcessInformationClass,
+ PVOID ProcessInformation,
+ ULONG ProcessInformationLength,
PULONG ReturnLength)
= NULL;*/
BOOL WINAPI Mine_IsDebuggerPresent()
{
- TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
- return FALSE;
+ TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
+ return FALSE;
}
NTSTATUS WINAPI Mine_NtQueryInformationProcess(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength)
{
- NTSTATUS nRet;
+ NTSTATUS nRet;
- nRet = Real_NtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength);
+ nRet = Real_NtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength);
- if(ProcessInformationClass == ProcessBasicInformation)
- {
- PROCESS_BASIC_INFORMATION* pbi = (PROCESS_BASIC_INFORMATION*)ProcessInformation;
- PEB_NT* pPEB;
- PEB_NT PEB;
-
- pPEB = (PEB_NT*)pbi->PebBaseAddress;
- ReadProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
- PEB.BeingDebugged = 0;
- WriteProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
- }
- else if(ProcessInformationClass == 7) // ProcessDebugPort
- {
- BOOL* pDebugPort = (BOOL*)ProcessInformation;
- *pDebugPort = FALSE;
- }
+ if (ProcessInformationClass == ProcessBasicInformation)
+ {
+ PROCESS_BASIC_INFORMATION* pbi = (PROCESS_BASIC_INFORMATION*)ProcessInformation;
+ PEB_NT* pPEB;
+ PEB_NT PEB;
+
+ pPEB = (PEB_NT*)pbi->PebBaseAddress;
+ ReadProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
+ PEB.BeingDebugged = 0;
+ WriteProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
+ }
+ else if (ProcessInformationClass == 7) // ProcessDebugPort
+ {
+ BOOL* pDebugPort = (BOOL*)ProcessInformation;
+ *pDebugPort = FALSE;
+ }
- return nRet;
+ return nRet;
}
LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
{
- if(dwFlags & CDS_VIDEOPARAMETERS)
- {
- VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
-
- if(vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
- && (vp->dwFlags & VP_FLAGS_COPYPROTECT))
- {
- if(vp->dwCommand == VP_COMMAND_GET)
- {
- if((vp->dwTVStandard & VP_TV_STANDARD_WIN_VGA)
- && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA)
- {
- TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
- vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
- }
- }
- else if(vp->dwCommand == VP_COMMAND_SET)
- {
- TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
- return 0;
- }
- }
- }
-
- return ret;
+ if(dwFlags&CDS_VIDEOPARAMETERS)
+ {
+ VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
+
+ if(vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
+ && (vp->dwFlags&VP_FLAGS_COPYPROTECT))
+ {
+ if(vp->dwCommand == VP_COMMAND_GET)
+ {
+ if((vp->dwTVStandard&VP_TV_STANDARD_WIN_VGA)
+ && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA)
+ {
+ TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
+ vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
+ }
+ }
+ else if(vp->dwCommand == VP_COMMAND_SET)
+ {
+ TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
+ return 0;
+ }
+ }
+ }
+
+ return ret;
}
LONG WINAPI Mine_ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(
- Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
- dwFlags,
- lParam);
+ return Mine_ChangeDisplaySettingsEx(
+ Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
+ dwFlags,
+ lParam);
}
LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(
- Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
- dwFlags,
- lParam);
+ return Mine_ChangeDisplaySettingsEx(
+ Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
+ dwFlags,
+ lParam);
}
HANDLE WINAPI Mine_CreateFileA(LPCSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7)
{
- //CStringA fn(p1);
- //fn.MakeLower();
- //int i = fn.Find(".part");
- //if(i > 0 && i == fn.GetLength() - 5)
- p3 |= FILE_SHARE_WRITE;
+ //CStringA fn(p1);
+ //fn.MakeLower();
+ //int i = fn.Find(".part");
+ //if(i > 0 && i == fn.GetLength() - 5)
+ p3 |= FILE_SHARE_WRITE;
- return Real_CreateFileA(p1, p2, p3, p4, p5, p6, p7);
+ return Real_CreateFileA(p1, p2, p3, p4, p5, p6, p7);
}
BOOL CreateFakeVideoTS(LPCWSTR strIFOPath, LPWSTR strFakeFile, size_t nFakeFileSize)
{
- BOOL bRet = FALSE;
+ BOOL bRet = FALSE;
WCHAR szTempPath[_MAX_PATH];
- WCHAR strFileName[_MAX_PATH];
- WCHAR strExt[_MAX_EXT];
- CIfo Ifo;
+ WCHAR strFileName[_MAX_PATH];
+ WCHAR strExt[_MAX_EXT];
+ CIfo Ifo;
- if(!GetTempPathW(MAX_PATH, szTempPath)) return FALSE;
+ if (!GetTempPathW(MAX_PATH, szTempPath)) return FALSE;
- _wsplitpath_s(strIFOPath, NULL, 0, NULL, 0, strFileName, countof(strFileName), strExt, countof(strExt));
- _snwprintf_s(strFakeFile, nFakeFileSize, _TRUNCATE, L"%sMPC%s%s", szTempPath, strFileName, strExt);
+ _wsplitpath_s (strIFOPath, NULL, 0, NULL, 0, strFileName, countof(strFileName), strExt, countof(strExt));
+ _snwprintf_s (strFakeFile, nFakeFileSize, _TRUNCATE, L"%sMPC%s%s", szTempPath, strFileName, strExt);
- if(Ifo.OpenFile(strIFOPath) &&
- Ifo.RemoveUOPs() &&
- Ifo.SaveFile(strFakeFile))
+ if (Ifo.OpenFile (strIFOPath) &&
+ Ifo.RemoveUOPs() &&
+ Ifo.SaveFile (strFakeFile))
{
- bRet = TRUE;
- }
+ bRet = TRUE;
+ }
- return bRet;
+ return bRet;
}
HANDLE WINAPI Mine_CreateFileW(LPCWSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7)
{
- HANDLE hFile = INVALID_HANDLE_VALUE;
- WCHAR strFakeFile[_MAX_PATH];
- int nLen = wcslen(p1);
-
- p3 |= FILE_SHARE_WRITE;
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+ WCHAR strFakeFile[_MAX_PATH];
+ int nLen = wcslen(p1);
- if(nLen >= 4 && _wcsicmp(p1 + nLen - 4, L".ifo") == 0)
- {
- if(CreateFakeVideoTS(p1, strFakeFile, countof(strFakeFile)))
- {
- hFile = Real_CreateFileW(strFakeFile, p2, p3, p4, p5, p6, p7);
- }
- }
+ p3 |= FILE_SHARE_WRITE;
- if(hFile == INVALID_HANDLE_VALUE)
- hFile = Real_CreateFileW(p1, p2, p3, p4, p5, p6, p7);
+ if (nLen>=4 && _wcsicmp (p1 + nLen-4, L".ifo") == 0)
+ {
+ if (CreateFakeVideoTS(p1, strFakeFile, countof(strFakeFile)))
+ {
+ hFile = Real_CreateFileW(strFakeFile, p2, p3, p4, p5, p6, p7);
+ }
+ }
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ hFile = Real_CreateFileW(p1, p2, p3, p4, p5, p6, p7);
- return hFile;
+ return hFile;
}
MMRESULT WINAPI Mine_mixerSetControlDetails(HMIXEROBJ hmxobj, LPMIXERCONTROLDETAILS pmxcd, DWORD fdwDetails)
{
- if(fdwDetails == (MIXER_OBJECTF_HMIXER | MIXER_SETCONTROLDETAILSF_VALUE))
- return MMSYSERR_NOERROR; // don't touch the mixer, kthx
- return Real_mixerSetControlDetails(hmxobj, pmxcd, fdwDetails);
+ if(fdwDetails == (MIXER_OBJECTF_HMIXER|MIXER_SETCONTROLDETAILSF_VALUE))
+ return MMSYSERR_NOERROR; // don't touch the mixer, kthx
+ return Real_mixerSetControlDetails(hmxobj, pmxcd, fdwDetails);
}
BOOL WINAPI Mine_DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
{
- BOOL ret = Real_DeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
+ BOOL ret = Real_DeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
- if(IOCTL_DVD_GET_REGION == dwIoControlCode && lpOutBuffer
- && lpBytesReturned && *lpBytesReturned == sizeof(DVD_REGION))
- {
- DVD_REGION* pDVDRegion = (DVD_REGION*)lpOutBuffer;
- pDVDRegion->SystemRegion = ~pDVDRegion->RegionData;
- }
+ if(IOCTL_DVD_GET_REGION == dwIoControlCode && lpOutBuffer
+ && lpBytesReturned && *lpBytesReturned == sizeof(DVD_REGION))
+ {
+ DVD_REGION* pDVDRegion = (DVD_REGION*)lpOutBuffer;
+ pDVDRegion->SystemRegion = ~pDVDRegion->RegionData;
+ }
- return ret;
+ return ret;
}
#include "../../subtitles/SSF.h"
@@ -698,120 +698,120 @@ BOOL WINAPI Mine_DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
class ssftest
{
public:
- ssftest()
- {
- Sleep(10000);
+ ssftest()
+ {
+ Sleep(10000);
- MessageBeep(-1);
+ MessageBeep(-1);
// 8; //
- SubPicDesc spd;
- spd.w = 640;
- spd.h = 480;
- spd.bpp = 32;
- spd.pitch = spd.w * spd.bpp >> 3;
- spd.type = MSP_RGB32;
- spd.vidrect = CRect(0, 0, spd.w, spd.h);
- spd.bits = DNew BYTE[spd.pitch*spd.h];
-
- CCritSec csLock;
- /*
- CRenderedTextSubtitle s(&csLock);
- s.Open(_T("../../subtitles/libssf/demo/demo.ssa"), 1);
-
- for(int i = 2*60*1000+2000; i < 2*60*1000+17000; i += 10)
- {
- memsetd(spd.bits, 0xff000000, spd.pitch*spd.h);
- CRect bbox;
- bbox.SetRectEmpty();
- s.Render(spd, 10000i64*i, 25, bbox);
- }
- */
- try
- {
- ssf::CRenderer s(&csLock);
- s.Open(_T("../../subtitles/libssf/demo/demo.ssf"));
-
- for(int i = 2 * 60 * 1000 + 2000; i < 2 * 60 * 1000 + 17000; i += 40)
- // for(int i = 2*60*1000+2000; i < 2*60*1000+17000; i += 1000)
- //for(int i = 0; i < 5000; i += 40)
- {
- memsetd(spd.bits, 0xff000000, spd.pitch * spd.h);
- CRect bbox;
- bbox.SetRectEmpty();
- s.Render(spd, 10000i64 * i, 25, bbox);
- }
- }
- catch(ssf::Exception& e)
- {
- UNREFERENCED_PARAMETER(e);
- TRACE(_T("%s\n"), e.ToString());
- ASSERT(0);
- }
-
- delete [] spd.bits;
-
- ::ExitProcess(0);
- }
+ SubPicDesc spd;
+ spd.w = 640;
+ spd.h = 480;
+ spd.bpp = 32;
+ spd.pitch = spd.w*spd.bpp>>3;
+ spd.type = MSP_RGB32;
+ spd.vidrect = CRect(0, 0, spd.w, spd.h);
+ spd.bits = DNew BYTE[spd.pitch*spd.h];
+
+ CCritSec csLock;
+/*
+ CRenderedTextSubtitle s(&csLock);
+ s.Open(_T("../../subtitles/libssf/demo/demo.ssa"), 1);
+
+ for(int i = 2*60*1000+2000; i < 2*60*1000+17000; i += 10)
+ {
+ memsetd(spd.bits, 0xff000000, spd.pitch*spd.h);
+ CRect bbox;
+ bbox.SetRectEmpty();
+ s.Render(spd, 10000i64*i, 25, bbox);
+ }
+*/
+ try
+ {
+ ssf::CRenderer s(&csLock);
+ s.Open(_T("../../subtitles/libssf/demo/demo.ssf"));
+
+ for(int i = 2*60*1000+2000; i < 2*60*1000+17000; i += 40)
+ // for(int i = 2*60*1000+2000; i < 2*60*1000+17000; i += 1000)
+ //for(int i = 0; i < 5000; i += 40)
+ {
+ memsetd(spd.bits, 0xff000000, spd.pitch*spd.h);
+ CRect bbox;
+ bbox.SetRectEmpty();
+ s.Render(spd, 10000i64*i, 25, bbox);
+ }
+ }
+ catch(ssf::Exception& e)
+ {
+ UNREFERENCED_PARAMETER(e);
+ TRACE(_T("%s\n"), e.ToString());
+ ASSERT(0);
+ }
+
+ delete [] spd.bits;
+
+ ::ExitProcess(0);
+ }
};
BOOL CMPlayerCApp::InitInstance()
{
- long lError;
-
-#ifdef GOTHTRACE
- // Used for tracing when debugger can't be used, e.g. when using some commercial decoders
- // Print traces usint _tprintf()
- if(AllocConsole())
- {
- FILE * foo; // Not used
- freopen_s(&foo, "conin$", "r", stdin); // Redirect stdin etc. to console
- freopen_s(&foo, "conout$", "w", stdout);
- freopen_s(&foo, "conout$", "w", stderr);
- }
- else
- AfxMessageBox(_T("Could not create console"));
-#endif
-
- DetourRestoreAfterWith();
+ long lError;
+
+ #ifdef GOTHTRACE
+ // Used for tracing when debugger can't be used, e.g. when using some commercial decoders
+ // Print traces usint _tprintf()
+ if (AllocConsole())
+ {
+ FILE * foo; // Not used
+ freopen_s(&foo, "conin$", "r", stdin); // Redirect stdin etc. to console
+ freopen_s(&foo, "conout$", "w", stdout);
+ freopen_s(&foo, "conout$", "w", stderr);
+ }
+ else
+ AfxMessageBox(_T("Could not create console"));
+ #endif
+
+ DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
- DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
- DetourAttach(&(PVOID&)Real_CreateFileA, (PVOID)Mine_CreateFileA);
- DetourAttach(&(PVOID&)Real_CreateFileW, (PVOID)Mine_CreateFileW);
- DetourAttach(&(PVOID&)Real_mixerSetControlDetails, (PVOID)Mine_mixerSetControlDetails);
- DetourAttach(&(PVOID&)Real_DeviceIoControl, (PVOID)Mine_DeviceIoControl);
+ DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
+ DetourAttach(&(PVOID&)Real_CreateFileA, (PVOID)Mine_CreateFileA);
+ DetourAttach(&(PVOID&)Real_CreateFileW, (PVOID)Mine_CreateFileW);
+ DetourAttach(&(PVOID&)Real_mixerSetControlDetails, (PVOID)Mine_mixerSetControlDetails);
+ DetourAttach(&(PVOID&)Real_DeviceIoControl, (PVOID)Mine_DeviceIoControl);
- HMODULE hNTDLL = LoadLibrary(_T("ntdll.dll"));
+ HMODULE hNTDLL = LoadLibrary (_T("ntdll.dll"));
#ifndef _DEBUG // Disable NtQueryInformationProcess in debug (prevent VS debugger to stop on crash address)
- if(hNTDLL)
- {
- Real_NtQueryInformationProcess = (FUNC_NTQUERYINFORMATIONPROCESS)GetProcAddress(hNTDLL, "NtQueryInformationProcess");
+ if (hNTDLL)
+ {
+ Real_NtQueryInformationProcess = (FUNC_NTQUERYINFORMATIONPROCESS)GetProcAddress (hNTDLL, "NtQueryInformationProcess");
- if(Real_NtQueryInformationProcess)
- DetourAttach(&(PVOID&)Real_NtQueryInformationProcess, (PVOID)Mine_NtQueryInformationProcess);
- }
+ if (Real_NtQueryInformationProcess)
+ DetourAttach(&(PVOID&)Real_NtQueryInformationProcess, (PVOID)Mine_NtQueryInformationProcess);
+ }
#endif
- CFilterMapper2::Init();
+ CFilterMapper2::Init();
lError = DetourTransactionCommit();
- ASSERT(lError == NOERROR);
+ ASSERT (lError == NOERROR);
- HRESULT hr;
+ HRESULT hr;
if(FAILED(hr = OleInitialize(0)))
- {
+ {
AfxMessageBox(_T("OleInitialize failed!"));
- return FALSE;
- }
+ return FALSE;
+ }
WNDCLASS wndcls;
memset(&wndcls, 0, sizeof(WNDCLASS));
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
- wndcls.lpfnWndProc = ::DefWindowProc;
+ wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.hInstance = AfxGetInstanceHandle();
wndcls.hIcon = LoadIcon(IDR_MAINFRAME);
wndcls.hCursor = LoadCursor(IDC_ARROW);
@@ -819,381 +819,341 @@ BOOL CMPlayerCApp::InitInstance()
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = MPC_WND_CLASS_NAME;
- if(!AfxRegisterClass(&wndcls))
+ if(!AfxRegisterClass(&wndcls))
{
- AfxMessageBox(_T("MainFrm class registration failed!"));
- return FALSE;
+ AfxMessageBox(_T("MainFrm class registration failed!"));
+ return FALSE;
}
- if(!AfxSocketInit(NULL))
- {
+ if(!AfxSocketInit(NULL))
+ {
AfxMessageBox(_T("AfxSocketInit failed!"));
- return FALSE;
- }
-
- PreProcessCommandLine();
-
- if(IsIniValid())
- StoreSettingsToIni();
- else
- {
- StoreSettingsToRegistry();
-
- // Only create a folder when using registry to store settings
- CString AppSavePath;
- if(GetAppSavePath(AppSavePath))
- CreateDirectory(AppSavePath, NULL);
- }
-
- m_s.ParseCommandLine(m_cmdln);
-
- if(m_s.nCLSwitches&(CLSW_HELP | CLSW_UNRECOGNIZEDSWITCH))
- {
- m_s.UpdateData(false);
- ShowCmdlnSwitches();
- return FALSE;
- }
-
- if((m_s.nCLSwitches & CLSW_CLOSE) && m_s.slFiles.IsEmpty())
- {
- return FALSE;
- }
-
- m_s.UpdateData(false);
-
- if((m_s.nCLSwitches & CLSW_REGEXTVID) || (m_s.nCLSwitches & CLSW_REGEXTAUD))
- {
- CMediaFormats& mf = m_s.Formats;
-
- for(int i = 0; i < (int)mf.GetCount(); i++)
- {
- if(!mf[i].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE))) continue;
-
- bool fAudioOnly = mf[i].IsAudioOnly();
-
- int j = 0;
- CString str = mf[i].GetExtsWithPeriod();
- for(CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j))
- {
- if(((m_s.nCLSwitches & CLSW_REGEXTVID) && !fAudioOnly) || ((m_s.nCLSwitches & CLSW_REGEXTAUD) && fAudioOnly))
- {
- CPPageFormats::RegisterExt(ext, mf[i].GetLabel(), true);
- }
- }
- }
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-
- return FALSE;
- }
-
- if((m_s.nCLSwitches & CLSW_UNREGEXT))
- {
- CMediaFormats& mf = m_s.Formats;
-
- for(int i = 0; i < (int)mf.GetCount(); i++)
- {
- int j = 0;
- CString str = mf[i].GetExtsWithPeriod();
- for(CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j))
- {
- CPPageFormats::RegisterExt(ext, mf[i].GetLabel(), false);
- }
- }
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-
- return FALSE;
- }
-
- // Enable to open options with administrator privilege (for Vista UAC)
- if(m_s.nCLSwitches & CLSW_ADMINOPTION)
- {
- switch(m_s.iAdminOption)
- {
- case CPPageFormats::IDD :
- {
- CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), NULL, NULL, m_s.iAdminOption);
- options.LockPage();
- options.DoModal();
- }
- break;
-
- default :
- ASSERT(FALSE);
- }
- return FALSE;
- }
-
- m_mutexOneInstance.Create(NULL, TRUE, MPC_WND_CLASS_NAME);
-
- if(GetLastError() == ERROR_ALREADY_EXISTS
- && (!(m_s.fAllowMultipleInst || (m_s.nCLSwitches & CLSW_NEW) || m_cmdln.IsEmpty())
- || (m_s.nCLSwitches & CLSW_ADD)))
- {
- int wait_count = 0;
- HWND hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
- while(!hWnd && (wait_count++ < 200))
- {
- Sleep(100);
- hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
- }
- if(hWnd && (wait_count < 200))
- {
- SetForegroundWindow(hWnd);
-
- if(!(m_s.nCLSwitches & CLSW_MINIMIZED) && IsIconic(hWnd))
- ShowWindow(hWnd, SW_RESTORE);
-
- SendCommandLine(hWnd);
-
- return FALSE;
- }
- }
-
- if(!__super::InitInstance())
- {
- AfxMessageBox(_T("InitInstance failed!"));
- return FALSE;
- }
-
- CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, _T("Software\\Gabest\\Media Player Classic")))
- {
- CString path;
- GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
- path.ReleaseBuffer();
- key.SetStringValue(_T("ExePath"), path);
- }
-
- AfxEnableControlContainer();
-
- CMainFrame* pFrame = DNew CMainFrame;
- m_pMainWnd = pFrame;
- if(!pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL))
- {
- AfxMessageBox(_T("CMainFrame::LoadFrame failed!"));
- return FALSE;
- }
- pFrame->SetDefaultWindowRect((m_s.nCLSwitches & CLSW_MONITOR) ? m_s.iMonitor : 0);
- pFrame->RestoreFloatingControlBars();
- pFrame->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
- pFrame->DragAcceptFiles();
- pFrame->ShowWindow((m_s.nCLSwitches & CLSW_MINIMIZED) ? SW_SHOWMINIMIZED : SW_SHOW);
- pFrame->UpdateWindow();
- pFrame->m_hAccelTable = m_s.hAccel;
- m_s.WinLircClient.SetHWND(m_pMainWnd->m_hWnd);
- if(m_s.fWinLirc) m_s.WinLircClient.Connect(m_s.WinLircAddr);
- m_s.UIceClient.SetHWND(m_pMainWnd->m_hWnd);
- if(m_s.fUIce) m_s.UIceClient.Connect(m_s.UIceAddr);
-
- SendCommandLine(m_pMainWnd->m_hWnd);
- RegisterHotkeys();
-
- pFrame->SetFocus();
-
- return TRUE;
+ return FALSE;
+ }
+
+ PreProcessCommandLine();
+
+ if(IsIniValid())
+ StoreSettingsToIni();
+ else
+ {
+ StoreSettingsToRegistry();
+
+ // Only create a folder when using registry to store settings
+ CString AppSavePath;
+ if(GetAppSavePath(AppSavePath))
+ CreateDirectory(AppSavePath, NULL);
+ }
+
+ m_s.ParseCommandLine(m_cmdln);
+
+ if(m_s.nCLSwitches&(CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH))
+ {
+ m_s.UpdateData(false);
+ ShowCmdlnSwitches();
+ return FALSE;
+ }
+
+ if((m_s.nCLSwitches&CLSW_CLOSE) && m_s.slFiles.IsEmpty())
+ {
+ return FALSE;
+ }
+
+ m_s.UpdateData(false);
+
+ if((m_s.nCLSwitches&CLSW_REGEXTVID) || (m_s.nCLSwitches&CLSW_REGEXTAUD))
+ {
+ CMediaFormats& mf = m_s.Formats;
+
+ for(int i = 0; i < (int)mf.GetCount(); i++)
+ {
+ if(!mf[i].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE))) continue;
+
+ bool fAudioOnly = mf[i].IsAudioOnly();
+
+ int j = 0;
+ CString str = mf[i].GetExtsWithPeriod();
+ for(CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j))
+ {
+ if(((m_s.nCLSwitches&CLSW_REGEXTVID) && !fAudioOnly) || ((m_s.nCLSwitches&CLSW_REGEXTAUD) && fAudioOnly)) {
+ CPPageFormats::RegisterExt(ext, mf[i].GetLabel(), true);
+ }
+ }
+ }
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+
+ return FALSE;
+ }
+
+ if((m_s.nCLSwitches&CLSW_UNREGEXT))
+ {
+ CMediaFormats& mf = m_s.Formats;
+
+ for(int i = 0; i < (int)mf.GetCount(); i++)
+ {
+ int j = 0;
+ CString str = mf[i].GetExtsWithPeriod();
+ for(CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j))
+ {
+ CPPageFormats::RegisterExt(ext, mf[i].GetLabel(), false);
+ }
+ }
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+
+ return FALSE;
+ }
+
+ // Enable to open options with administrator privilege (for Vista UAC)
+ if (m_s.nCLSwitches & CLSW_ADMINOPTION)
+ {
+ switch (m_s.iAdminOption)
+ {
+ case CPPageFormats::IDD :
+ {
+ CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), NULL, NULL, m_s.iAdminOption);
+ options.LockPage();
+ options.DoModal();
+ }
+ break;
+
+ default :
+ ASSERT (FALSE);
+ }
+ return FALSE;
+ }
+
+ m_mutexOneInstance.Create(NULL, TRUE, MPC_WND_CLASS_NAME);
+
+ if(GetLastError() == ERROR_ALREADY_EXISTS
+ && (!(m_s.fAllowMultipleInst || (m_s.nCLSwitches&CLSW_NEW) || m_cmdln.IsEmpty())
+ || (m_s.nCLSwitches&CLSW_ADD)))
+ {
+ int wait_count = 0;
+ HWND hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
+ while(!hWnd && (wait_count++<200))
+ {
+ Sleep(100);
+ hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
+ }
+ if(hWnd && (wait_count<200))
+ {
+ SetForegroundWindow(hWnd);
+
+ if(!(m_s.nCLSwitches&CLSW_MINIMIZED) && IsIconic(hWnd))
+ ShowWindow(hWnd, SW_RESTORE);
+
+ SendCommandLine(hWnd);
+
+ return FALSE;
+ }
+ }
+
+ if(!__super::InitInstance())
+ {
+ AfxMessageBox(_T("InitInstance failed!"));
+ return FALSE;
+ }
+
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, _T("Software\\Gabest\\Media Player Classic")))
+ {
+ CString path;
+ GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(MAX_PATH), MAX_PATH);
+ path.ReleaseBuffer();
+ key.SetStringValue(_T("ExePath"), path);
+ }
+
+ AfxEnableControlContainer();
+
+ CMainFrame* pFrame = DNew CMainFrame;
+ m_pMainWnd = pFrame;
+ if ( !pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE, NULL, NULL) )
+ {
+ AfxMessageBox(_T("CMainFrame::LoadFrame failed!"));
+ return FALSE;
+ }
+ pFrame->SetDefaultWindowRect((m_s.nCLSwitches&CLSW_MONITOR)?m_s.iMonitor:0);
+ pFrame->RestoreFloatingControlBars();
+ pFrame->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
+ pFrame->DragAcceptFiles();
+ pFrame->ShowWindow((m_s.nCLSwitches&CLSW_MINIMIZED)?SW_SHOWMINIMIZED:SW_SHOW);
+ pFrame->UpdateWindow();
+ pFrame->m_hAccelTable = m_s.hAccel;
+ m_s.WinLircClient.SetHWND(m_pMainWnd->m_hWnd);
+ if(m_s.fWinLirc) m_s.WinLircClient.Connect(m_s.WinLircAddr);
+ m_s.UIceClient.SetHWND(m_pMainWnd->m_hWnd);
+ if(m_s.fUIce) m_s.UIceClient.Connect(m_s.UIceAddr);
+
+ SendCommandLine(m_pMainWnd->m_hWnd);
+ RegisterHotkeys();
+
+ pFrame->SetFocus();
+
+ return TRUE;
}
UINT CMPlayerCApp::GetRemoteControlCodeMicrosoft(UINT nInputcode, HRAWINPUT hRawInput)
{
- UINT dwSize = 0;
- BYTE* pRawBuffer = NULL;
- UINT nMceCmd = 0;
-
- // Support for MCE remote control
- GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
- if(dwSize > 0)
- {
- pRawBuffer = DNew BYTE[dwSize];
- if(GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1)
- {
- RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
- if(raw->header.dwType == RIM_TYPEHID)
- {
- nMceCmd = 0x10000 + (raw->data.hid.bRawData[1] | raw->data.hid.bRawData[2] << 8);
- }
- }
- delete [] pRawBuffer;
- }
-
- return nMceCmd;
+ UINT dwSize = 0;
+ BYTE* pRawBuffer = NULL;
+ UINT nMceCmd = 0;
+
+ // Support for MCE remote control
+ GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
+ if (dwSize > 0)
+ {
+ pRawBuffer = DNew BYTE[dwSize];
+ if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1)
+ {
+ RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
+ if(raw->header.dwType == RIM_TYPEHID)
+ {
+ nMceCmd = 0x10000 + (raw->data.hid.bRawData[1] | raw->data.hid.bRawData[2] << 8);
+ }
+ }
+ delete [] pRawBuffer;
+ }
+
+ return nMceCmd;
}
UINT CMPlayerCApp::GetRemoteControlCodeSRM7500(UINT nInputcode, HRAWINPUT hRawInput)
{
- UINT dwSize = 0;
- BYTE* pRawBuffer = NULL;
- UINT nMceCmd = 0;
-
- GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
- if(dwSize > 21)
- {
- pRawBuffer = DNew BYTE[dwSize];
- if(GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1)
- {
- RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
-
- // data.hid.bRawData[21] set to one when key is pressed
- if(raw->header.dwType == RIM_TYPEHID && raw->data.hid.bRawData[21] == 1)
- {
- // data.hid.bRawData[21] has keycode
- switch(raw->data.hid.bRawData[20])
- {
- case 0x0033 :
- nMceCmd = MCE_DETAILS;
- break;
- case 0x0022 :
- nMceCmd = MCE_GUIDE;
- break;
- case 0x0036 :
- nMceCmd = MCE_MYTV;
- break;
- case 0x0026 :
- nMceCmd = MCE_RECORDEDTV;
- break;
- case 0x0005 :
- nMceCmd = MCE_RED;
- break;
- case 0x0002 :
- nMceCmd = MCE_GREEN;
- break;
- case 0x0045 :
- nMceCmd = MCE_YELLOW;
- break;
- case 0x0046 :
- nMceCmd = MCE_BLUE;
- break;
- case 0x000A :
- nMceCmd = MCE_MEDIA_PREVIOUSTRACK;
- break;
- case 0x004A :
- nMceCmd = MCE_MEDIA_NEXTTRACK;
- break;
- }
- }
- }
- delete [] pRawBuffer;
- }
-
- return nMceCmd;
+ UINT dwSize = 0;
+ BYTE* pRawBuffer = NULL;
+ UINT nMceCmd = 0;
+
+ GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
+ if (dwSize > 21)
+ {
+ pRawBuffer = DNew BYTE[dwSize];
+ if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1)
+ {
+ RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
+
+ // data.hid.bRawData[21] set to one when key is pressed
+ if(raw->header.dwType == RIM_TYPEHID && raw->data.hid.bRawData[21] == 1)
+ {
+ // data.hid.bRawData[21] has keycode
+ switch (raw->data.hid.bRawData[20])
+ {
+ case 0x0033 : nMceCmd = MCE_DETAILS; break;
+ case 0x0022 : nMceCmd = MCE_GUIDE; break;
+ case 0x0036 : nMceCmd = MCE_MYTV; break;
+ case 0x0026 : nMceCmd = MCE_RECORDEDTV; break;
+ case 0x0005 : nMceCmd = MCE_RED; break;
+ case 0x0002 : nMceCmd = MCE_GREEN; break;
+ case 0x0045 : nMceCmd = MCE_YELLOW; break;
+ case 0x0046 : nMceCmd = MCE_BLUE; break;
+ case 0x000A : nMceCmd = MCE_MEDIA_PREVIOUSTRACK; break;
+ case 0x004A : nMceCmd = MCE_MEDIA_NEXTTRACK; break;
+ }
+ }
+ }
+ delete [] pRawBuffer;
+ }
+
+ return nMceCmd;
}
void CMPlayerCApp::RegisterHotkeys()
{
- RAWINPUTDEVICELIST InputDeviceList[50];
- UINT nInputDeviceCount = countof(InputDeviceList);
- RID_DEVICE_INFO DevInfo;
- RAWINPUTDEVICE MCEInputDevice[] =
- {
- // usUsagePage usUsage dwFlags hwndTarget
- { 0xFFBC, 0x88, 0, NULL},
- { 0x000C, 0x01, 0, NULL},
- { 0x000C, 0x80, 0, NULL}
- };
-
- // Register MCE Remote Control raw input
- for(int i = 0; i < countof(MCEInputDevice); i++)
- MCEInputDevice[i].hwndTarget = m_pMainWnd->m_hWnd;
-
- nInputDeviceCount = GetRawInputDeviceList(InputDeviceList, &nInputDeviceCount, sizeof(RAWINPUTDEVICELIST));
- for(int i = 0; i < nInputDeviceCount; i++)
- {
- UINT nTemp = sizeof(DevInfo);
- if(GetRawInputDeviceInfo(InputDeviceList[i].hDevice, RIDI_DEVICEINFO, &DevInfo, &nTemp) > 0)
- {
- if(DevInfo.hid.dwVendorId == 0x00000471 && // Philips HID vendor id
- DevInfo.hid.dwProductId == 0x00000617) // IEEE802.15.4 RF Dongle (SRM 7500)
- {
- MCEInputDevice[0].usUsagePage = DevInfo.hid.usUsagePage;
- MCEInputDevice[0].usUsage = DevInfo.hid.usUsage;
- GetRemoteControlCode = GetRemoteControlCodeSRM7500;
- }
- }
- }
-
-
- RegisterRawInputDevices(MCEInputDevice, countof(MCEInputDevice), sizeof(RAWINPUTDEVICE));
-
-
- if(m_s.fGlobalMedia)
- {
- POSITION pos = m_s.wmcmds.GetHeadPosition();
-
- while(pos)
- {
- wmcmd& wc = m_s.wmcmds.GetNext(pos);
- if(wc.appcmd != 0)
- RegisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd, 0, GetVKFromAppCommand(wc.appcmd));
- }
- }
+ RAWINPUTDEVICELIST InputDeviceList[50];
+ UINT nInputDeviceCount = countof(InputDeviceList);
+ RID_DEVICE_INFO DevInfo;
+ RAWINPUTDEVICE MCEInputDevice[] =
+ {
+ // usUsagePage usUsage dwFlags hwndTarget
+ { 0xFFBC, 0x88, 0, NULL},
+ { 0x000C, 0x01, 0, NULL},
+ { 0x000C, 0x80, 0, NULL}
+ };
+
+ // Register MCE Remote Control raw input
+ for (int i=0; i<countof(MCEInputDevice); i++)
+ MCEInputDevice[i].hwndTarget = m_pMainWnd->m_hWnd;
+
+ nInputDeviceCount = GetRawInputDeviceList (InputDeviceList, &nInputDeviceCount, sizeof(RAWINPUTDEVICELIST));
+ for (int i=0; i<nInputDeviceCount; i++)
+ {
+ UINT nTemp = sizeof(DevInfo);
+ if (GetRawInputDeviceInfo (InputDeviceList[i].hDevice, RIDI_DEVICEINFO, &DevInfo, &nTemp)>0)
+ {
+ if (DevInfo.hid.dwVendorId == 0x00000471 && // Philips HID vendor id
+ DevInfo.hid.dwProductId == 0x00000617) // IEEE802.15.4 RF Dongle (SRM 7500)
+ {
+ MCEInputDevice[0].usUsagePage = DevInfo.hid.usUsagePage;
+ MCEInputDevice[0].usUsage = DevInfo.hid.usUsage;
+ GetRemoteControlCode = GetRemoteControlCodeSRM7500;
+ }
+ }
+ }
+
+
+ RegisterRawInputDevices (MCEInputDevice, countof(MCEInputDevice), sizeof(RAWINPUTDEVICE));
+
+
+ if (m_s.fGlobalMedia)
+ {
+ POSITION pos = m_s.wmcmds.GetHeadPosition();
+
+ while(pos)
+ {
+ wmcmd& wc = m_s.wmcmds.GetNext(pos);
+ if (wc.appcmd != 0)
+ RegisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd, 0, GetVKFromAppCommand (wc.appcmd));
+ }
+ }
}
void CMPlayerCApp::UnregisterHotkeys()
{
- if(m_s.fGlobalMedia)
- {
- POSITION pos = m_s.wmcmds.GetHeadPosition();
-
- while(pos)
- {
- wmcmd& wc = m_s.wmcmds.GetNext(pos);
- if(wc.appcmd != 0)
- UnregisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd);
- }
- }
+ if (m_s.fGlobalMedia)
+ {
+ POSITION pos = m_s.wmcmds.GetHeadPosition();
+
+ while(pos)
+ {
+ wmcmd& wc = m_s.wmcmds.GetNext(pos);
+ if (wc.appcmd != 0)
+ UnregisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd);
+ }
+ }
}
UINT CMPlayerCApp::GetVKFromAppCommand(UINT nAppCommand)
{
- switch(nAppCommand)
- {
- case APPCOMMAND_BROWSER_BACKWARD :
- return VK_BROWSER_BACK;
- case APPCOMMAND_BROWSER_FORWARD :
- return VK_BROWSER_FORWARD;
- case APPCOMMAND_BROWSER_REFRESH :
- return VK_BROWSER_REFRESH;
- case APPCOMMAND_BROWSER_STOP :
- return VK_BROWSER_STOP;
- case APPCOMMAND_BROWSER_SEARCH :
- return VK_BROWSER_SEARCH;
- case APPCOMMAND_BROWSER_FAVORITES :
- return VK_BROWSER_FAVORITES;
- case APPCOMMAND_BROWSER_HOME :
- return VK_BROWSER_HOME;
- case APPCOMMAND_VOLUME_MUTE :
- return VK_VOLUME_MUTE;
- case APPCOMMAND_VOLUME_DOWN :
- return VK_VOLUME_DOWN;
- case APPCOMMAND_VOLUME_UP :
- return VK_VOLUME_UP;
- case APPCOMMAND_MEDIA_NEXTTRACK :
- return VK_MEDIA_NEXT_TRACK;
- case APPCOMMAND_MEDIA_PREVIOUSTRACK :
- return VK_MEDIA_PREV_TRACK;
- case APPCOMMAND_MEDIA_STOP :
- return VK_MEDIA_STOP;
- case APPCOMMAND_MEDIA_PLAY_PAUSE :
- return VK_MEDIA_PLAY_PAUSE;
- case APPCOMMAND_LAUNCH_MAIL :
- return VK_LAUNCH_MAIL;
- case APPCOMMAND_LAUNCH_MEDIA_SELECT :
- return VK_LAUNCH_MEDIA_SELECT;
- case APPCOMMAND_LAUNCH_APP1 :
- return VK_LAUNCH_APP1;
- case APPCOMMAND_LAUNCH_APP2 :
- return VK_LAUNCH_APP2;
- }
-
- return 0;
-}
+ switch (nAppCommand)
+ {
+ case APPCOMMAND_BROWSER_BACKWARD : return VK_BROWSER_BACK;
+ case APPCOMMAND_BROWSER_FORWARD : return VK_BROWSER_FORWARD;
+ case APPCOMMAND_BROWSER_REFRESH : return VK_BROWSER_REFRESH;
+ case APPCOMMAND_BROWSER_STOP : return VK_BROWSER_STOP;
+ case APPCOMMAND_BROWSER_SEARCH : return VK_BROWSER_SEARCH;
+ case APPCOMMAND_BROWSER_FAVORITES : return VK_BROWSER_FAVORITES;
+ case APPCOMMAND_BROWSER_HOME : return VK_BROWSER_HOME;
+ case APPCOMMAND_VOLUME_MUTE : return VK_VOLUME_MUTE;
+ case APPCOMMAND_VOLUME_DOWN : return VK_VOLUME_DOWN;
+ case APPCOMMAND_VOLUME_UP : return VK_VOLUME_UP;
+ case APPCOMMAND_MEDIA_NEXTTRACK : return VK_MEDIA_NEXT_TRACK;
+ case APPCOMMAND_MEDIA_PREVIOUSTRACK : return VK_MEDIA_PREV_TRACK;
+ case APPCOMMAND_MEDIA_STOP : return VK_MEDIA_STOP;
+ case APPCOMMAND_MEDIA_PLAY_PAUSE : return VK_MEDIA_PLAY_PAUSE;
+ case APPCOMMAND_LAUNCH_MAIL : return VK_LAUNCH_MAIL;
+ case APPCOMMAND_LAUNCH_MEDIA_SELECT : return VK_LAUNCH_MEDIA_SELECT;
+ case APPCOMMAND_LAUNCH_APP1 : return VK_LAUNCH_APP1;
+ case APPCOMMAND_LAUNCH_APP2 : return VK_LAUNCH_APP2;
+ }
+
+ return 0;}
int CMPlayerCApp::ExitInstance()
{
- m_s.UpdateData(true);
+ m_s.UpdateData(true);
- OleUninitialize();
+ OleUninitialize();
- return CWinApp::ExitInstance();
+ return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
@@ -1202,124 +1162,124 @@ int CMPlayerCApp::ExitInstance()
void CMPlayerCApp::OnAppAbout()
{
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
+ CAboutDlg aboutDlg;
+ aboutDlg.DoModal();
}
void CMPlayerCApp::OnFileExit()
{
- OnAppExit();
+ OnAppExit();
}
// CRemoteCtrlClient
-CRemoteCtrlClient::CRemoteCtrlClient()
- : m_pWnd(NULL)
- , m_nStatus(DISCONNECTED)
+CRemoteCtrlClient::CRemoteCtrlClient()
+ : m_pWnd(NULL)
+ , m_nStatus(DISCONNECTED)
{
}
void CRemoteCtrlClient::SetHWND(HWND hWnd)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- m_pWnd = CWnd::FromHandle(hWnd);
+ m_pWnd = CWnd::FromHandle(hWnd);
}
void CRemoteCtrlClient::Connect(CString addr)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- if(m_nStatus == CONNECTING && m_addr == addr)
- {
- TRACE(_T("CRemoteCtrlClient (Connect): already connecting to %s\n"), addr);
- return;
- }
+ if(m_nStatus == CONNECTING && m_addr == addr)
+ {
+ TRACE(_T("CRemoteCtrlClient (Connect): already connecting to %s\n"), addr);
+ return;
+ }
- if(m_nStatus == CONNECTED && m_addr == addr)
- {
- TRACE(_T("CRemoteCtrlClient (Connect): already connected to %s\n"), addr);
- return;
- }
+ if(m_nStatus == CONNECTED && m_addr == addr)
+ {
+ TRACE(_T("CRemoteCtrlClient (Connect): already connected to %s\n"), addr);
+ return;
+ }
- m_nStatus = CONNECTING;
+ m_nStatus = CONNECTING;
- TRACE(_T("CRemoteCtrlClient (Connect): connecting to %s\n"), addr);
+ TRACE(_T("CRemoteCtrlClient (Connect): connecting to %s\n"), addr);
- Close();
+ Close();
- Create();
+ Create();
- CString ip = addr.Left(addr.Find(':') + 1).TrimRight(':');
- int port = _tcstol(addr.Mid(addr.Find(':') + 1), NULL, 10);
+ CString ip = addr.Left(addr.Find(':')+1).TrimRight(':');
+ int port = _tcstol(addr.Mid(addr.Find(':')+1), NULL, 10);
- __super::Connect(ip, port);
+ __super::Connect(ip, port);
- m_addr = addr;
+ m_addr = addr;
}
void CRemoteCtrlClient::OnConnect(int nErrorCode)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- m_nStatus = (nErrorCode == 0 ? CONNECTED : DISCONNECTED);
+ m_nStatus = (nErrorCode == 0 ? CONNECTED : DISCONNECTED);
- TRACE(_T("CRemoteCtrlClient (OnConnect): %d\n"), nErrorCode);
+ TRACE(_T("CRemoteCtrlClient (OnConnect): %d\n"), nErrorCode);
}
void CRemoteCtrlClient::OnClose(int nErrorCode)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- if(m_hSocket != INVALID_SOCKET && m_nStatus == CONNECTED)
- {
- TRACE(_T("CRemoteCtrlClient (OnClose): connection lost\n"));
- }
+ if(m_hSocket != INVALID_SOCKET && m_nStatus == CONNECTED)
+ {
+ TRACE(_T("CRemoteCtrlClient (OnClose): connection lost\n"));
+ }
- m_nStatus = DISCONNECTED;
+ m_nStatus = DISCONNECTED;
- TRACE(_T("CRemoteCtrlClient (OnClose): %d\n"), nErrorCode);
+ TRACE(_T("CRemoteCtrlClient (OnClose): %d\n"), nErrorCode);
}
void CRemoteCtrlClient::OnReceive(int nErrorCode)
{
- if(nErrorCode != 0 || !m_pWnd) return;
+ if(nErrorCode != 0 || !m_pWnd) return;
- CStringA str;
- int ret = Receive(str.GetBuffer(256), 255, 0);
- if(ret <= 0) return;
- str.ReleaseBuffer(ret);
+ CStringA str;
+ int ret = Receive(str.GetBuffer(256), 255, 0);
+ if(ret <= 0) return;
+ str.ReleaseBuffer(ret);
- TRACE(_T("CRemoteCtrlClient (OnReceive): %s\n"), CString(str));
+ TRACE(_T("CRemoteCtrlClient (OnReceive): %s\n"), CString(str));
- OnCommand(str);
+ OnCommand(str);
- __super::OnReceive(nErrorCode);
+ __super::OnReceive(nErrorCode);
}
void CRemoteCtrlClient::ExecuteCommand(CStringA cmd, int repcnt)
{
- cmd.Trim();
- if(cmd.IsEmpty()) return;
- cmd.Replace(' ', '_');
-
- AppSettings& s = AfxGetAppSettings();
-
- POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
- wmcmd wc = s.wmcmds.GetNext(pos);
- CStringA name = TToA(wc.GetName());
- name.Replace(' ', '_');
- if((repcnt == 0 && wc.rmrepcnt == 0 || wc.rmrepcnt > 0 && (repcnt % wc.rmrepcnt) == 0)
- && (!name.CompareNoCase(cmd) || !wc.rmcmd.CompareNoCase(cmd) || wc.cmd == (WORD)strtol(cmd, NULL, 10)))
- {
- CAutoLock cAutoLock(&m_csLock);
- TRACE(_T("CRemoteCtrlClient (calling command): %s\n"), wc.GetName());
- m_pWnd->SendMessage(WM_COMMAND, wc.cmd);
- break;
- }
- }
+ cmd.Trim();
+ if(cmd.IsEmpty()) return;
+ cmd.Replace(' ', '_');
+
+ AppSettings& s = AfxGetAppSettings();
+
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while(pos)
+ {
+ wmcmd wc = s.wmcmds.GetNext(pos);
+ CStringA name = TToA(wc.GetName());
+ name.Replace(' ', '_');
+ if((repcnt == 0 && wc.rmrepcnt == 0 || wc.rmrepcnt > 0 && (repcnt%wc.rmrepcnt) == 0)
+ && (!name.CompareNoCase(cmd) || !wc.rmcmd.CompareNoCase(cmd) || wc.cmd == (WORD)strtol(cmd, NULL, 10)))
+ {
+ CAutoLock cAutoLock(&m_csLock);
+ TRACE(_T("CRemoteCtrlClient (calling command): %s\n"), wc.GetName());
+ m_pWnd->SendMessage(WM_COMMAND, wc.cmd);
+ break;
+ }
+ }
}
// CWinLircClient
@@ -1330,18 +1290,18 @@ CWinLircClient::CWinLircClient()
void CWinLircClient::OnCommand(CStringA str)
{
- TRACE(_T("CWinLircClient (OnCommand): %s\n"), CString(str));
+ TRACE(_T("CWinLircClient (OnCommand): %s\n"), CString(str));
- int i = 0, j = 0, repcnt = 0;
- for(CStringA token = str.Tokenize(" ", i);
- !token.IsEmpty();
- token = str.Tokenize(" ", i), j++)
- {
- if(j == 1)
- repcnt = strtol(token, NULL, 16);
- else if(j == 2)
- ExecuteCommand(token, repcnt);
- }
+ int i = 0, j = 0, repcnt = 0;
+ for(CStringA token = str.Tokenize(" ", i);
+ !token.IsEmpty();
+ token = str.Tokenize(" ", i), j++)
+ {
+ if(j == 1)
+ repcnt = strtol(token, NULL, 16);
+ else if(j == 2)
+ ExecuteCommand(token, repcnt);
+ }
}
// CUIceClient
@@ -1352,28 +1312,28 @@ CUIceClient::CUIceClient()
void CUIceClient::OnCommand(CStringA str)
{
- TRACE(_T("CUIceClient (OnCommand): %s\n"), CString(str));
+ TRACE(_T("CUIceClient (OnCommand): %s\n"), CString(str));
- CStringA cmd;
- int i = 0, j = 0;
- for(CStringA token = str.Tokenize("|", i);
- !token.IsEmpty();
- token = str.Tokenize("|", i), j++)
- {
- if(j == 0)
- cmd = token;
- else if(j == 1)
- ExecuteCommand(cmd, strtol(token, NULL, 16));
- }
+ CStringA cmd;
+ int i = 0, j = 0;
+ for(CStringA token = str.Tokenize("|", i);
+ !token.IsEmpty();
+ token = str.Tokenize("|", i), j++)
+ {
+ if(j == 0)
+ cmd = token;
+ else if(j == 1)
+ ExecuteCommand(cmd, strtol(token, NULL, 16));
+ }
}
// CMPlayerCApp::Settings
-CMPlayerCApp::Settings::Settings()
- : fInitialized(false)
- , MRU(0, _T("Recent File List"), _T("File%d"), 20)
- , MRUDub(0, _T("Recent Dub List"), _T("Dub%d"), 20)
- , hAccel(NULL)
+CMPlayerCApp::Settings::Settings()
+ : fInitialized(false)
+ , MRU(0, _T("Recent File List"), _T("File%d"), 20)
+ , MRUDub(0, _T("Recent Dub List"), _T("Dub%d"), 20)
+ , hAccel(NULL)
{
}
@@ -1382,1516 +1342,1475 @@ CMPlayerCApp::Settings::Settings()
void CMPlayerCApp::Settings::CreateCommands()
{
#define ADDCMD(cmd) wmcmds.AddTail(wmcmd##cmd)
- ADDCMD((ID_FILE_OPENQUICK, 'Q', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_0));
- ADDCMD((ID_FILE_OPENMEDIA, 'O', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_FILE));
- ADDCMD((ID_FILE_OPENDVD, 'D', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DVD));
- ADDCMD((ID_FILE_OPENDEVICE, 'V', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DEVICE));
- ADDCMD((ID_FILE_SAVE_COPY, 0, FVIRTKEY | FNOINVERT, IDS_AG_SAVE_AS));
- ADDCMD((ID_FILE_SAVE_IMAGE, 'I', FVIRTKEY | FALT | FNOINVERT, IDS_AG_SAVE_IMAGE));
- ADDCMD((ID_FILE_SAVE_IMAGE_AUTO, VK_F5, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_6));
- ADDCMD((ID_FILE_LOAD_SUBTITLE, 'L', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_LOAD_SUBTITLE));
- ADDCMD((ID_FILE_SAVE_SUBTITLE, 'S', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_SAVE_SUBTITLE));
- ADDCMD((ID_FILE_CLOSEPLAYLIST, 'C', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_CLOSE));
- ADDCMD((ID_FILE_PROPERTIES, VK_F10, FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PROPERTIES));
- ADDCMD((ID_FILE_EXIT, 'X', FVIRTKEY | FALT | FNOINVERT, IDS_AG_EXIT));
- ADDCMD((ID_PLAY_PLAYPAUSE, VK_SPACE, FVIRTKEY | FNOINVERT, IDS_AG_PLAYPAUSE, APPCOMMAND_MEDIA_PLAY_PAUSE, wmcmd::LDOWN));
- ADDCMD((ID_PLAY_PLAY, 0, FVIRTKEY | FNOINVERT, IDS_AG_PLAY, APPCOMMAND_MEDIA_PLAY));
- ADDCMD((ID_PLAY_PAUSE, 0, FVIRTKEY | FNOINVERT, IDS_AG_PAUSE, APPCOMMAND_MEDIA_PAUSE));
- ADDCMD((ID_PLAY_STOP, VK_OEM_PERIOD, FVIRTKEY | FNOINVERT, IDS_AG_STOP, APPCOMMAND_MEDIA_STOP));
- ADDCMD((ID_PLAY_FRAMESTEP, VK_RIGHT, FVIRTKEY | FNOINVERT, IDS_AG_FRAMESTEP));
- ADDCMD((ID_PLAY_FRAMESTEPCANCEL, VK_LEFT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_16));
- ADDCMD((ID_PLAY_GOTO, 'G', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_GO_TO));
- ADDCMD((ID_PLAY_INCRATE, VK_UP, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_INCREASE_RATE));
- ADDCMD((ID_PLAY_DECRATE, VK_DOWN, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_DECREASE_RATE));
- ADDCMD((ID_PLAY_RESETRATE, 'R', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_RESET_RATE));
- ADDCMD((ID_PLAY_INCAUDDELAY, VK_ADD, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_21));
- ADDCMD((ID_PLAY_DECAUDDELAY, VK_SUBTRACT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_22));
- ADDCMD((ID_PLAY_SEEKFORWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_23));
- ADDCMD((ID_PLAY_SEEKBACKWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_24));
- ADDCMD((ID_PLAY_SEEKFORWARDMED, VK_RIGHT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_25));
- ADDCMD((ID_PLAY_SEEKBACKWARDMED, VK_LEFT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_26));
- ADDCMD((ID_PLAY_SEEKFORWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_27));
- ADDCMD((ID_PLAY_SEEKBACKWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_28));
- ADDCMD((ID_PLAY_SEEKKEYFORWARD, VK_RIGHT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_29));
- ADDCMD((ID_PLAY_SEEKKEYBACKWARD, VK_LEFT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_30));
- ADDCMD((ID_NAVIGATE_SKIPFORWARD, VK_NEXT, FVIRTKEY | FNOINVERT, IDS_AG_NEXT, APPCOMMAND_MEDIA_NEXTTRACK, wmcmd::X2DOWN));
- ADDCMD((ID_NAVIGATE_SKIPBACK, VK_PRIOR, FVIRTKEY | FNOINVERT, IDS_AG_PREVIOUS, APPCOMMAND_MEDIA_PREVIOUSTRACK, wmcmd::X1DOWN));
- ADDCMD((ID_NAVIGATE_SKIPFORWARDPLITEM, VK_NEXT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_33));
- ADDCMD((ID_NAVIGATE_SKIPBACKPLITEM, VK_PRIOR, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_34));
- ADDCMD((ID_NAVIGATE_TUNERSCAN, 'T', FVIRTKEY | FSHIFT | FNOINVERT, IDS_NAVIGATE_TUNERSCAN));
- ADDCMD((ID_FAVORITES_QUICKADDFAVORITE, 'Q', FVIRTKEY | FSHIFT | FNOINVERT, IDS_FAVORITES_QUICKADDFAVORITE));
- ADDCMD((ID_VIEW_CAPTIONMENU, '0', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTION));
- ADDCMD((ID_VIEW_SEEKER, '1', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SEEKER));
- ADDCMD((ID_VIEW_CONTROLS, '2', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CONTROLS));
- ADDCMD((ID_VIEW_INFORMATION, '3', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_INFO));
- ADDCMD((ID_VIEW_STATISTICS, '4', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATS));
- ADDCMD((ID_VIEW_STATUS, '5', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATUS));
- ADDCMD((ID_VIEW_SUBRESYNC, '6', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SUBRESYNC));
- ADDCMD((ID_VIEW_PLAYLIST, '7', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_PLAYLIST));
- ADDCMD((ID_VIEW_CAPTURE, '8', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTURE));
- ADDCMD((ID_VIEW_SHADEREDITOR, '9', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SHADER));
- ADDCMD((ID_VIEW_PRESETS_MINIMAL, '1', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_MINIMAL));
- ADDCMD((ID_VIEW_PRESETS_COMPACT, '2', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_COMPACT));
- ADDCMD((ID_VIEW_PRESETS_NORMAL, '3', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_NORMAL));
- ADDCMD((ID_VIEW_FULLSCREEN, VK_RETURN, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_FULLSCREEN, 0, wmcmd::LDBLCLK));
- ADDCMD((ID_VIEW_FULLSCREEN_SECONDARY, VK_RETURN, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_39));
- ADDCMD((ID_VIEW_ZOOM_50, '1', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_50));
- ADDCMD((ID_VIEW_ZOOM_100, '2', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_100));
- ADDCMD((ID_VIEW_ZOOM_200, '3', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_200));
- ADDCMD((ID_VIEW_ZOOM_AUTOFIT, '4', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_AUTO_FIT));
- ADDCMD((ID_ASPECTRATIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AR_PRESET));
- ADDCMD((ID_VIEW_VF_HALF, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_HALF));
- ADDCMD((ID_VIEW_VF_NORMAL, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_NORMAL));
- ADDCMD((ID_VIEW_VF_DOUBLE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_DOUBLE));
- ADDCMD((ID_VIEW_VF_STRETCH, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_STRETCH));
- ADDCMD((ID_VIEW_VF_FROMINSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_INSIDE));
- ADDCMD((ID_VIEW_VF_FROMOUTSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_OUTSIDE));
- ADDCMD((ID_ONTOP_ALWAYS, 'A', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_ALWAYS_ON_TOP));
- ADDCMD((ID_VIEW_RESET, VK_NUMPAD5, FVIRTKEY | FNOINVERT, IDS_AG_PNS_RESET));
- ADDCMD((ID_VIEW_INCSIZE, VK_NUMPAD9, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_SIZE));
- ADDCMD((ID_VIEW_INCWIDTH, VK_NUMPAD6, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_WIDTH));
- ADDCMD((ID_VIEW_INCHEIGHT, VK_NUMPAD8, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_47));
- ADDCMD((ID_VIEW_DECSIZE, VK_NUMPAD1, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_SIZE));
- ADDCMD((ID_VIEW_DECWIDTH, VK_NUMPAD4, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_WIDTH));
- ADDCMD((ID_VIEW_DECHEIGHT, VK_NUMPAD2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_50));
- ADDCMD((ID_PANSCAN_CENTER, VK_NUMPAD5, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_CENTER));
- ADDCMD((ID_PANSCAN_MOVELEFT, VK_NUMPAD4, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_LEFT));
- ADDCMD((ID_PANSCAN_MOVERIGHT, VK_NUMPAD6, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_RIGHT));
- ADDCMD((ID_PANSCAN_MOVEUP, VK_NUMPAD8, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UP));
- ADDCMD((ID_PANSCAN_MOVEDOWN, VK_NUMPAD2, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWN));
- ADDCMD((ID_PANSCAN_MOVEUPLEFT, VK_NUMPAD7, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPLEFT));
- ADDCMD((ID_PANSCAN_MOVEUPRIGHT, VK_NUMPAD9, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPRIGHT));
- ADDCMD((ID_PANSCAN_MOVEDOWNLEFT, VK_NUMPAD1, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWNLEFT));
- ADDCMD((ID_PANSCAN_MOVEDOWNRIGHT, VK_NUMPAD3, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_59));
- ADDCMD((ID_PANSCAN_ROTATEXP, VK_NUMPAD8, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_P));
- ADDCMD((ID_PANSCAN_ROTATEXM, VK_NUMPAD2, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_M));
- ADDCMD((ID_PANSCAN_ROTATEYP, VK_NUMPAD4, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_P));
- ADDCMD((ID_PANSCAN_ROTATEYM, VK_NUMPAD6, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_M));
- ADDCMD((ID_PANSCAN_ROTATEZP, VK_NUMPAD1, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_P));
- ADDCMD((ID_PANSCAN_ROTATEZM, VK_NUMPAD3, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_M));
- ADDCMD((ID_VOLUME_UP, VK_UP, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_UP, APPCOMMAND_VOLUME_UP, wmcmd::WUP));
- ADDCMD((ID_VOLUME_DOWN, VK_DOWN, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_DOWN, APPCOMMAND_VOLUME_DOWN, wmcmd::WDOWN));
- ADDCMD((ID_VOLUME_MUTE, 'M', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_VOLUME_MUTE, APPCOMMAND_VOLUME_MUTE));
- ADDCMD((ID_VOLUME_BOOST_INC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_INC));
- ADDCMD((ID_VOLUME_BOOST_DEC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_DEC));
- ADDCMD((ID_VOLUME_BOOST_MIN, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MIN));
- ADDCMD((ID_VOLUME_BOOST_MAX, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MAX));
- ADDCMD((ID_NAVIGATE_TITLEMENU, 'T', FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_63));
- ADDCMD((ID_NAVIGATE_ROOTMENU, 'R', FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_ROOT_MENU));
- ADDCMD((ID_NAVIGATE_SUBPICTUREMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_65));
- ADDCMD((ID_NAVIGATE_AUDIOMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_66));
- ADDCMD((ID_NAVIGATE_ANGLEMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_67));
- ADDCMD((ID_NAVIGATE_CHAPTERMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_68));
- ADDCMD((ID_NAVIGATE_MENU_LEFT, VK_LEFT, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_LEFT));
- ADDCMD((ID_NAVIGATE_MENU_RIGHT, VK_RIGHT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_70));
- ADDCMD((ID_NAVIGATE_MENU_UP, VK_UP, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_UP));
- ADDCMD((ID_NAVIGATE_MENU_DOWN, VK_DOWN, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_DOWN));
- ADDCMD((ID_NAVIGATE_MENU_ACTIVATE, VK_SPACE, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_73));
- ADDCMD((ID_NAVIGATE_MENU_BACK, 0, FVIRTKEY | FNOINVERT, IDS_AG_DVD_MENU_BACK));
- ADDCMD((ID_NAVIGATE_MENU_LEAVE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_75));
- ADDCMD((ID_BOSS, 'B', FVIRTKEY | FNOINVERT, IDS_AG_BOSS_KEY));
- ADDCMD((ID_MENU_PLAYER_SHORT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_77, 0, wmcmd::RUP));
- ADDCMD((ID_MENU_PLAYER_LONG, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_78));
- ADDCMD((ID_MENU_FILTERS, 0, FVIRTKEY | FNOINVERT, IDS_AG_FILTERS_MENU));
- ADDCMD((ID_VIEW_OPTIONS, 'O', FVIRTKEY | FNOINVERT, IDS_AG_OPTIONS));
- ADDCMD((ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AUDIO));
- ADDCMD((ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_AUDIO));
- ADDCMD((ID_STREAM_SUB_NEXT, 'S', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_SUBTITLE));
- ADDCMD((ID_STREAM_SUB_PREV, 'S', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_SUBTITLE));
- ADDCMD((ID_STREAM_SUB_ONOFF, 'W', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_85));
- ADDCMD((ID_SUBTITLES_SUBITEM_START + 2, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_86));
- ADDCMD((ID_OGM_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_87));
- ADDCMD((ID_OGM_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_88));
- ADDCMD((ID_OGM_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_89));
- ADDCMD((ID_OGM_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_90));
- ADDCMD((ID_DVD_ANGLE_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_91));
- ADDCMD((ID_DVD_ANGLE_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_92));
- ADDCMD((ID_DVD_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_93));
- ADDCMD((ID_DVD_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_94));
- ADDCMD((ID_DVD_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_95));
- ADDCMD((ID_DVD_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_96));
- ADDCMD((ID_DVD_SUB_ONOFF, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_97));
- ADDCMD((ID_VIEW_TEARING_TEST, 'T', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TEARING_TEST));
- ADDCMD((ID_VIEW_REMAINING_TIME, 'I', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_98));
- ADDCMD((ID_SHADER_TOGGLE, 'P', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AT_TOGGLE_SHADER));
- ADDCMD((ID_SHADER_TOGGLESCREENSPACE, 'P', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AT_TOGGLE_SHADERSCREENSPACE));
- ADDCMD((ID_D3DFULLSCREEN_TOGGLE, 'F', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_99));
- ADDCMD((ID_GOTO_PREV_SUB, 'Y', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_100, APPCOMMAND_BROWSER_BACKWARD));
- ADDCMD((ID_GOTO_NEXT_SUB, 'U', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_101, APPCOMMAND_BROWSER_FORWARD));
- ADDCMD((ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_102));
- ADDCMD((ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_103));
- ADDCMD((ID_VIEW_DISPLAYSTATS, 'J', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_DISPLAY_STATS));
- ADDCMD((ID_VIEW_RESETSTATS, 'R', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_RESET_STATS));
- ADDCMD((ID_VIEW_VSYNC, 'V', FVIRTKEY | FNOINVERT, IDS_AG_VSYNC));
- ADDCMD((ID_VIEW_ENABLEFRAMETIMECORRECTION, 'C', FVIRTKEY | FNOINVERT, IDS_AG_ENABLEFRAMETIMECORRECTION));
- ADDCMD((ID_VIEW_VSYNCACCURATE, 'V', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCACCURATE));
- ADDCMD((ID_VIEW_VSYNCOFFSET_DECREASE, VK_UP, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_DECREASE));
- ADDCMD((ID_VIEW_VSYNCOFFSET_INCREASE, VK_DOWN, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_INCREASE));
- ADDCMD((ID_SUB_DELAY_DOWN, VK_F1, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_104));
- ADDCMD((ID_SUB_DELAY_UP, VK_F2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_105));
- ADDCMD((ID_FILE_SAVE_THUMBNAILS, 0, FVIRTKEY | FNOINVERT, IDS_FILE_SAVE_THUMBNAILS));
-
- ADDCMD((ID_VIEW_EDITLISTEDITOR, 0, FVIRTKEY | FNOINVERT, IDS_AG_TOGGLE_EDITLISTEDITOR));
- ADDCMD((ID_EDL_IN, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_IN));
- ADDCMD((ID_EDL_OUT, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_OUT));
- ADDCMD((ID_EDL_NEWCLIP, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDO_NEW_CLIP));
-
- ResetPositions();
+ ADDCMD((ID_FILE_OPENQUICK, 'Q', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_0));
+ ADDCMD((ID_FILE_OPENMEDIA, 'O', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_OPEN_FILE));
+ ADDCMD((ID_FILE_OPENDVD, 'D', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_OPEN_DVD));
+ ADDCMD((ID_FILE_OPENDEVICE, 'V', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_OPEN_DEVICE));
+ ADDCMD((ID_FILE_SAVE_COPY, 0, FVIRTKEY|FNOINVERT, IDS_AG_SAVE_AS));
+ ADDCMD((ID_FILE_SAVE_IMAGE, 'I', FVIRTKEY|FALT|FNOINVERT, IDS_AG_SAVE_IMAGE));
+ ADDCMD((ID_FILE_SAVE_IMAGE_AUTO, VK_F5, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_6));
+ ADDCMD((ID_FILE_LOAD_SUBTITLE, 'L', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_LOAD_SUBTITLE));
+ ADDCMD((ID_FILE_SAVE_SUBTITLE, 'S', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_SAVE_SUBTITLE));
+ ADDCMD((ID_FILE_CLOSEPLAYLIST, 'C', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_CLOSE));
+ ADDCMD((ID_FILE_PROPERTIES, VK_F10, FVIRTKEY|FSHIFT|FNOINVERT, IDS_AG_PROPERTIES));
+ ADDCMD((ID_FILE_EXIT, 'X', FVIRTKEY|FALT|FNOINVERT, IDS_AG_EXIT));
+ ADDCMD((ID_PLAY_PLAYPAUSE, VK_SPACE, FVIRTKEY|FNOINVERT, IDS_AG_PLAYPAUSE, APPCOMMAND_MEDIA_PLAY_PAUSE, wmcmd::LDOWN));
+ ADDCMD((ID_PLAY_PLAY, 0, FVIRTKEY|FNOINVERT, IDS_AG_PLAY, APPCOMMAND_MEDIA_PLAY));
+ ADDCMD((ID_PLAY_PAUSE, 0, FVIRTKEY|FNOINVERT, IDS_AG_PAUSE, APPCOMMAND_MEDIA_PAUSE));
+ ADDCMD((ID_PLAY_STOP, VK_OEM_PERIOD, FVIRTKEY|FNOINVERT, IDS_AG_STOP, APPCOMMAND_MEDIA_STOP));
+ ADDCMD((ID_PLAY_FRAMESTEP, VK_RIGHT, FVIRTKEY|FNOINVERT, IDS_AG_FRAMESTEP));
+ ADDCMD((ID_PLAY_FRAMESTEPCANCEL, VK_LEFT, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_16));
+ ADDCMD((ID_PLAY_GOTO, 'G', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_GO_TO));
+ ADDCMD((ID_PLAY_INCRATE, VK_UP, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_INCREASE_RATE));
+ ADDCMD((ID_PLAY_DECRATE, VK_DOWN, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_DECREASE_RATE));
+ ADDCMD((ID_PLAY_RESETRATE, 'R', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_RESET_RATE));
+ ADDCMD((ID_PLAY_INCAUDDELAY, VK_ADD, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_21));
+ ADDCMD((ID_PLAY_DECAUDDELAY, VK_SUBTRACT, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_22));
+ ADDCMD((ID_PLAY_SEEKFORWARDSMALL, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_23));
+ ADDCMD((ID_PLAY_SEEKBACKWARDSMALL, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_24));
+ ADDCMD((ID_PLAY_SEEKFORWARDMED, VK_RIGHT, FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_25));
+ ADDCMD((ID_PLAY_SEEKBACKWARDMED, VK_LEFT, FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_26));
+ ADDCMD((ID_PLAY_SEEKFORWARDLARGE, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_27));
+ ADDCMD((ID_PLAY_SEEKBACKWARDLARGE, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_28));
+ ADDCMD((ID_PLAY_SEEKKEYFORWARD, VK_RIGHT, FVIRTKEY|FSHIFT|FNOINVERT, IDS_MPLAYERC_29));
+ ADDCMD((ID_PLAY_SEEKKEYBACKWARD, VK_LEFT, FVIRTKEY|FSHIFT|FNOINVERT, IDS_MPLAYERC_30));
+ ADDCMD((ID_NAVIGATE_SKIPFORWARD, VK_NEXT, FVIRTKEY|FNOINVERT, IDS_AG_NEXT, APPCOMMAND_MEDIA_NEXTTRACK, wmcmd::X2DOWN));
+ ADDCMD((ID_NAVIGATE_SKIPBACK, VK_PRIOR, FVIRTKEY|FNOINVERT, IDS_AG_PREVIOUS, APPCOMMAND_MEDIA_PREVIOUSTRACK, wmcmd::X1DOWN));
+ ADDCMD((ID_NAVIGATE_SKIPFORWARDPLITEM, VK_NEXT, FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_33));
+ ADDCMD((ID_NAVIGATE_SKIPBACKPLITEM, VK_PRIOR, FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_34));
+ ADDCMD((ID_NAVIGATE_TUNERSCAN, 'T', FVIRTKEY|FSHIFT|FNOINVERT, IDS_NAVIGATE_TUNERSCAN));
+ ADDCMD((ID_FAVORITES_QUICKADDFAVORITE, 'Q', FVIRTKEY|FSHIFT|FNOINVERT, IDS_FAVORITES_QUICKADDFAVORITE));
+ ADDCMD((ID_VIEW_CAPTIONMENU, '0', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_CAPTION));
+ ADDCMD((ID_VIEW_SEEKER, '1', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_SEEKER));
+ ADDCMD((ID_VIEW_CONTROLS, '2', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_CONTROLS));
+ ADDCMD((ID_VIEW_INFORMATION, '3', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_INFO));
+ ADDCMD((ID_VIEW_STATISTICS, '4', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_STATS));
+ ADDCMD((ID_VIEW_STATUS, '5', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_STATUS));
+ ADDCMD((ID_VIEW_SUBRESYNC, '6', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_SUBRESYNC));
+ ADDCMD((ID_VIEW_PLAYLIST, '7', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_PLAYLIST));
+ ADDCMD((ID_VIEW_CAPTURE, '8', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_CAPTURE));
+ ADDCMD((ID_VIEW_SHADEREDITOR, '9', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_SHADER));
+ ADDCMD((ID_VIEW_PRESETS_MINIMAL, '1', FVIRTKEY|FNOINVERT, IDS_AG_VIEW_MINIMAL));
+ ADDCMD((ID_VIEW_PRESETS_COMPACT, '2', FVIRTKEY|FNOINVERT, IDS_AG_VIEW_COMPACT));
+ ADDCMD((ID_VIEW_PRESETS_NORMAL, '3', FVIRTKEY|FNOINVERT, IDS_AG_VIEW_NORMAL));
+ ADDCMD((ID_VIEW_FULLSCREEN, VK_RETURN, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_FULLSCREEN, 0, wmcmd::LDBLCLK));
+ ADDCMD((ID_VIEW_FULLSCREEN_SECONDARY, VK_RETURN, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_39));
+ ADDCMD((ID_VIEW_ZOOM_50, '1', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_50));
+ ADDCMD((ID_VIEW_ZOOM_100, '2', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_100));
+ ADDCMD((ID_VIEW_ZOOM_200, '3', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_200));
+ ADDCMD((ID_VIEW_ZOOM_AUTOFIT, '4', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_AUTO_FIT));
+ ADDCMD((ID_ASPECTRATIO_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_AG_NEXT_AR_PRESET));
+ ADDCMD((ID_VIEW_VF_HALF, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_HALF));
+ ADDCMD((ID_VIEW_VF_NORMAL, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_NORMAL));
+ ADDCMD((ID_VIEW_VF_DOUBLE, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_DOUBLE));
+ ADDCMD((ID_VIEW_VF_STRETCH, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_STRETCH));
+ ADDCMD((ID_VIEW_VF_FROMINSIDE, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_INSIDE));
+ ADDCMD((ID_VIEW_VF_FROMOUTSIDE, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_OUTSIDE));
+ ADDCMD((ID_ONTOP_ALWAYS, 'A', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_ALWAYS_ON_TOP));
+ ADDCMD((ID_VIEW_RESET, VK_NUMPAD5, FVIRTKEY|FNOINVERT, IDS_AG_PNS_RESET));
+ ADDCMD((ID_VIEW_INCSIZE, VK_NUMPAD9, FVIRTKEY|FNOINVERT, IDS_AG_PNS_INC_SIZE));
+ ADDCMD((ID_VIEW_INCWIDTH, VK_NUMPAD6, FVIRTKEY|FNOINVERT, IDS_AG_PNS_INC_WIDTH));
+ ADDCMD((ID_VIEW_INCHEIGHT, VK_NUMPAD8, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_47));
+ ADDCMD((ID_VIEW_DECSIZE, VK_NUMPAD1, FVIRTKEY|FNOINVERT, IDS_AG_PNS_DEC_SIZE));
+ ADDCMD((ID_VIEW_DECWIDTH, VK_NUMPAD4, FVIRTKEY|FNOINVERT, IDS_AG_PNS_DEC_WIDTH));
+ ADDCMD((ID_VIEW_DECHEIGHT, VK_NUMPAD2, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_50));
+ ADDCMD((ID_PANSCAN_CENTER, VK_NUMPAD5, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_CENTER));
+ ADDCMD((ID_PANSCAN_MOVELEFT, VK_NUMPAD4, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_LEFT));
+ ADDCMD((ID_PANSCAN_MOVERIGHT, VK_NUMPAD6, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_RIGHT));
+ ADDCMD((ID_PANSCAN_MOVEUP, VK_NUMPAD8, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_UP));
+ ADDCMD((ID_PANSCAN_MOVEDOWN, VK_NUMPAD2, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_DOWN));
+ ADDCMD((ID_PANSCAN_MOVEUPLEFT, VK_NUMPAD7, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_UPLEFT));
+ ADDCMD((ID_PANSCAN_MOVEUPRIGHT, VK_NUMPAD9, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_UPRIGHT));
+ ADDCMD((ID_PANSCAN_MOVEDOWNLEFT, VK_NUMPAD1, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_DOWNLEFT));
+ ADDCMD((ID_PANSCAN_MOVEDOWNRIGHT, VK_NUMPAD3, FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_59));
+ ADDCMD((ID_PANSCAN_ROTATEXP, VK_NUMPAD8, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEX_P));
+ ADDCMD((ID_PANSCAN_ROTATEXM, VK_NUMPAD2, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEX_M));
+ ADDCMD((ID_PANSCAN_ROTATEYP, VK_NUMPAD4, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEY_P));
+ ADDCMD((ID_PANSCAN_ROTATEYM, VK_NUMPAD6, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEY_M));
+ ADDCMD((ID_PANSCAN_ROTATEZP, VK_NUMPAD1, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEZ_P));
+ ADDCMD((ID_PANSCAN_ROTATEZM, VK_NUMPAD3, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEZ_M));
+ ADDCMD((ID_VOLUME_UP, VK_UP, FVIRTKEY|FNOINVERT, IDS_AG_VOLUME_UP, APPCOMMAND_VOLUME_UP, wmcmd::WUP));
+ ADDCMD((ID_VOLUME_DOWN, VK_DOWN, FVIRTKEY|FNOINVERT, IDS_AG_VOLUME_DOWN, APPCOMMAND_VOLUME_DOWN, wmcmd::WDOWN));
+ ADDCMD((ID_VOLUME_MUTE, 'M', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_VOLUME_MUTE, APPCOMMAND_VOLUME_MUTE));
+ ADDCMD((ID_VOLUME_BOOST_INC, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_INC));
+ ADDCMD((ID_VOLUME_BOOST_DEC, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_DEC));
+ ADDCMD((ID_VOLUME_BOOST_MIN, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_MIN));
+ ADDCMD((ID_VOLUME_BOOST_MAX, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_MAX));
+ ADDCMD((ID_NAVIGATE_TITLEMENU, 'T', FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_63));
+ ADDCMD((ID_NAVIGATE_ROOTMENU, 'R', FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_ROOT_MENU));
+ ADDCMD((ID_NAVIGATE_SUBPICTUREMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_65));
+ ADDCMD((ID_NAVIGATE_AUDIOMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_66));
+ ADDCMD((ID_NAVIGATE_ANGLEMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_67));
+ ADDCMD((ID_NAVIGATE_CHAPTERMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_68));
+ ADDCMD((ID_NAVIGATE_MENU_LEFT, VK_LEFT, FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_MENU_LEFT));
+ ADDCMD((ID_NAVIGATE_MENU_RIGHT, VK_RIGHT, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_70));
+ ADDCMD((ID_NAVIGATE_MENU_UP, VK_UP, FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_MENU_UP));
+ ADDCMD((ID_NAVIGATE_MENU_DOWN, VK_DOWN, FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_MENU_DOWN));
+ ADDCMD((ID_NAVIGATE_MENU_ACTIVATE, VK_SPACE, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_73));
+ ADDCMD((ID_NAVIGATE_MENU_BACK, 0, FVIRTKEY|FNOINVERT, IDS_AG_DVD_MENU_BACK));
+ ADDCMD((ID_NAVIGATE_MENU_LEAVE, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_75));
+ ADDCMD((ID_BOSS, 'B', FVIRTKEY|FNOINVERT, IDS_AG_BOSS_KEY));
+ ADDCMD((ID_MENU_PLAYER_SHORT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_77, 0, wmcmd::RUP));
+ ADDCMD((ID_MENU_PLAYER_LONG, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_78));
+ ADDCMD((ID_MENU_FILTERS, 0, FVIRTKEY|FNOINVERT, IDS_AG_FILTERS_MENU));
+ ADDCMD((ID_VIEW_OPTIONS, 'O', FVIRTKEY|FNOINVERT, IDS_AG_OPTIONS));
+ ADDCMD((ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY|FNOINVERT, IDS_AG_NEXT_AUDIO));
+ ADDCMD((ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY|FSHIFT|FNOINVERT, IDS_AG_PREV_AUDIO));
+ ADDCMD((ID_STREAM_SUB_NEXT, 'S', FVIRTKEY|FNOINVERT, IDS_AG_NEXT_SUBTITLE));
+ ADDCMD((ID_STREAM_SUB_PREV, 'S', FVIRTKEY|FSHIFT|FNOINVERT, IDS_AG_PREV_SUBTITLE));
+ ADDCMD((ID_STREAM_SUB_ONOFF, 'W', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_85));
+ ADDCMD((ID_SUBTITLES_SUBITEM_START+2, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_86));
+ ADDCMD((ID_OGM_AUDIO_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_87));
+ ADDCMD((ID_OGM_AUDIO_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_88));
+ ADDCMD((ID_OGM_SUB_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_89));
+ ADDCMD((ID_OGM_SUB_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_90));
+ ADDCMD((ID_DVD_ANGLE_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_91));
+ ADDCMD((ID_DVD_ANGLE_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_92));
+ ADDCMD((ID_DVD_AUDIO_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_93));
+ ADDCMD((ID_DVD_AUDIO_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_94));
+ ADDCMD((ID_DVD_SUB_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_95));
+ ADDCMD((ID_DVD_SUB_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_96));
+ ADDCMD((ID_DVD_SUB_ONOFF, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_97));
+ ADDCMD((ID_VIEW_TEARING_TEST, 'T', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TEARING_TEST));
+ ADDCMD((ID_VIEW_REMAINING_TIME, 'I', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_98));
+ ADDCMD((ID_SHADER_TOGGLE, 'P', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AT_TOGGLE_SHADER));
+ ADDCMD((ID_SHADER_TOGGLESCREENSPACE, 'P', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AT_TOGGLE_SHADERSCREENSPACE));
+ ADDCMD((ID_D3DFULLSCREEN_TOGGLE, 'F', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_99));
+ ADDCMD((ID_GOTO_PREV_SUB, 'Y', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_100, APPCOMMAND_BROWSER_BACKWARD));
+ ADDCMD((ID_GOTO_NEXT_SUB, 'U', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_101, APPCOMMAND_BROWSER_FORWARD));
+ ADDCMD((ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_102));
+ ADDCMD((ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_103));
+ ADDCMD((ID_VIEW_DISPLAYSTATS, 'J', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_DISPLAY_STATS));
+ ADDCMD((ID_VIEW_RESETSTATS, 'R', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_RESET_STATS));
+ ADDCMD((ID_VIEW_VSYNC, 'V', FVIRTKEY|FNOINVERT, IDS_AG_VSYNC));
+ ADDCMD((ID_VIEW_ENABLEFRAMETIMECORRECTION, 'C', FVIRTKEY|FNOINVERT, IDS_AG_ENABLEFRAMETIMECORRECTION));
+ ADDCMD((ID_VIEW_VSYNCACCURATE, 'V', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCACCURATE));
+ ADDCMD((ID_VIEW_VSYNCOFFSET_DECREASE, VK_UP, FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCOFFSET_DECREASE));
+ ADDCMD((ID_VIEW_VSYNCOFFSET_INCREASE, VK_DOWN, FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCOFFSET_INCREASE));
+ ADDCMD((ID_SUB_DELAY_DOWN, VK_F1, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_104));
+ ADDCMD((ID_SUB_DELAY_UP, VK_F2, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_105));
+ ADDCMD((ID_FILE_SAVE_THUMBNAILS, 0, FVIRTKEY|FNOINVERT, IDS_FILE_SAVE_THUMBNAILS));
+
+ ADDCMD((ID_VIEW_EDITLISTEDITOR, 0, FVIRTKEY|FNOINVERT, IDS_AG_TOGGLE_EDITLISTEDITOR));
+ ADDCMD((ID_EDL_IN, 0, FVIRTKEY|FNOINVERT, IDS_AG_EDL_IN));
+ ADDCMD((ID_EDL_OUT, 0, FVIRTKEY|FNOINVERT, IDS_AG_EDL_OUT));
+ ADDCMD((ID_EDL_NEWCLIP, 0, FVIRTKEY|FNOINVERT, IDS_AG_EDO_NEW_CLIP));
+
+ ResetPositions();
#undef ADDCMD
}
CMPlayerCApp::Settings::~Settings()
{
- if(hAccel)
- DestroyAcceleratorTable(hAccel);
+ if(hAccel)
+ DestroyAcceleratorTable(hAccel);
}
bool CMPlayerCApp::Settings::IsD3DFullscreen()
{
- if(nCLSwitches & CLSW_D3DFULLSCREEN)
- return true;
- else
- return fD3DFullscreen;
+ if(nCLSwitches&CLSW_D3DFULLSCREEN)
+ return true;
+ else
+ return fD3DFullscreen;
}
CString CMPlayerCApp::Settings::SelectedAudioRender()
{
- CString strResult;
- if(nCLSwitches & CLSW_AUDIORENDER)
- strResult = AfxGetMyApp()->m_AudioRendererDisplayName_CL;
- else
- strResult = AfxGetAppSettings().AudioRendererDisplayName;
- return strResult;
+ CString strResult;
+ if (nCLSwitches&CLSW_AUDIORENDER)
+ strResult = AfxGetMyApp()->m_AudioRendererDisplayName_CL;
+ else
+ strResult = AfxGetAppSettings().AudioRendererDisplayName;
+ return strResult;
}
void CMPlayerCApp::Settings::ResetPositions()
{
- nCurrentDvdPosition = -1;
- nCurrentFilePosition = -1;
+ nCurrentDvdPosition = -1;
+ nCurrentFilePosition = -1;
}
DVD_POSITION* CMPlayerCApp::Settings::CurrentDVDPosition()
{
- if(nCurrentDvdPosition != -1)
- return &DvdPosition[nCurrentDvdPosition];
- else
- return NULL;
+ if (nCurrentDvdPosition != -1)
+ return &DvdPosition[nCurrentDvdPosition];
+ else
+ return NULL;
}
bool CMPlayerCApp::Settings::NewDvd(ULONGLONG llDVDGuid)
{
- int i;
+ int i;
- // Recherche si la position du DVD est connue
- for(i = 0; i < MAX_DVD_POSITION; i++)
- {
- if(DvdPosition[i].llDVDGuid == llDVDGuid)
- {
- nCurrentDvdPosition = i;
- return false;
- }
- }
+ // Recherche si la position du DVD est connue
+ for (i=0; i<MAX_DVD_POSITION; i++)
+ {
+ if (DvdPosition[i].llDVDGuid == llDVDGuid)
+ {
+ nCurrentDvdPosition = i;
+ return false;
+ }
+ }
- // Si DVD inconnu, le mettre en premier
- for(int i = MAX_DVD_POSITION - 1; i > 0; i--)
- memcpy(&DvdPosition[i], &DvdPosition[i-1], sizeof(DVD_POSITION));
- DvdPosition[0].llDVDGuid = llDVDGuid;
- nCurrentDvdPosition = 0;
- return true;
+ // Si DVD inconnu, le mettre en premier
+ for (int i=MAX_DVD_POSITION-1; i>0; i--)
+ memcpy (&DvdPosition[i], &DvdPosition[i-1], sizeof(DVD_POSITION));
+ DvdPosition[0].llDVDGuid = llDVDGuid;
+ nCurrentDvdPosition = 0;
+ return true;
}
FILE_POSITION* CMPlayerCApp::Settings::CurrentFilePosition()
{
- if(nCurrentFilePosition != -1)
- return &FilePosition[nCurrentFilePosition];
- else
- return NULL;
+ if (nCurrentFilePosition != -1)
+ return &FilePosition[nCurrentFilePosition];
+ else
+ return NULL;
}
bool CMPlayerCApp::Settings::NewFile(LPCTSTR strFileName)
{
- int i;
+ int i;
- // Recherche si la position du fichier est connue
- for(i = 0; i < MAX_FILE_POSITION; i++)
- {
- if(FilePosition[i].strFile == strFileName)
- {
- nCurrentFilePosition = i;
- return false;
- }
- }
+ // Recherche si la position du fichier est connue
+ for (i=0; i<MAX_FILE_POSITION; i++)
+ {
+ if (FilePosition[i].strFile == strFileName)
+ {
+ nCurrentFilePosition = i;
+ return false;
+ }
+ }
- // Si fichier inconnu, le mettre en premier
- for(int i = MAX_FILE_POSITION - 1; i > 0; i--)
- {
- FilePosition[i].strFile = FilePosition[i-1].strFile;
- FilePosition[i].llPosition = FilePosition[i-1].llPosition;
- }
- FilePosition[0].strFile = strFileName;
- FilePosition[0].llPosition = 0;
- nCurrentFilePosition = 0;
- return true;
+ // Si fichier inconnu, le mettre en premier
+ for (int i=MAX_FILE_POSITION-1; i>0; i--)
+ {
+ FilePosition[i].strFile = FilePosition[i-1].strFile;
+ FilePosition[i].llPosition = FilePosition[i-1].llPosition;
+ }
+ FilePosition[0].strFile = strFileName;
+ FilePosition[0].llPosition = 0;
+ nCurrentFilePosition = 0;
+ return true;
}
-void CMPlayerCApp::Settings::DeserializeHex(LPCTSTR strVal, BYTE* pBuffer, int nBufSize)
+void CMPlayerCApp::Settings::DeserializeHex (LPCTSTR strVal, BYTE* pBuffer, int nBufSize)
{
- long lRes;
+ long lRes;
- for(int i = 0; i < nBufSize; i++)
- {
- _stscanf_s(strVal + (i * 2), _T("%02x"), &lRes);
- pBuffer[i] = (BYTE)lRes;
- }
+ for (int i=0; i<nBufSize; i++)
+ {
+ _stscanf_s (strVal+(i*2), _T("%02x"), &lRes);
+ pBuffer[i] = (BYTE)lRes;
+ }
}
-CString CMPlayerCApp::Settings::SerializeHex(BYTE* pBuffer, int nBufSize)
+CString CMPlayerCApp::Settings::SerializeHex (BYTE* pBuffer, int nBufSize)
{
- CString strTemp;
- CString strResult;
+ CString strTemp;
+ CString strResult;
- for(int i = 0; i < nBufSize; i++)
- {
- strTemp.Format(_T("%02x"), pBuffer[i]);
- strResult += strTemp;
- }
+ for (int i=0; i<nBufSize; i++)
+ {
+ strTemp.Format (_T("%02x"), pBuffer[i]);
+ strResult += strTemp;
+ }
- return strResult;
+ return strResult;
}
void CMPlayerCApp::Settings::UpdateData(bool fSave)
{
- CWinApp* pApp = AfxGetApp();
- ASSERT(pApp);
-
- UINT len;
- BYTE* ptr = NULL;
-
- if(fSave)
- {
- if(!fInitialized) return;
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, fHideCaptionMenu);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, fHideNavigation);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, nCS);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, iDefaultVideoSize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, fKeepAspectRatio);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, fCompMonDeskARDiff);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, nVolume);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, nBalance);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, fMute);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, nLoops);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, fLoopForever);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, fRewind);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, iZoomLevel);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, fAllowMultipleInst);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, iTitleBarTextStyle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, fTitleBarTextTitle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, iOnTop);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, fTrayIcon);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, fRememberZoomLevel);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, fShowBarsWhenFullScreen);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, nShowBarsWhenFullScreenTimeOut);
- pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, (BYTE*)&AutoChangeFullscrRes, sizeof(AutoChangeFullscrRes));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, fExitFullScreenAtTheEnd);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("RestoreResAfterExit"), fRestoreResAfterExit);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, fRememberWindowPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, fRememberWindowSize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, fSnapToDesktopEdges);
- pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, (BYTE*)&rcLastWindowPos, sizeof(rcLastWindowPos));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, lastWindowType);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, AspectRatio.cx);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, AspectRatio.cy);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, fKeepHistory);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, iDSVideoRendererType);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, iRMVideoRendererType);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, iQTVideoRendererType);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, iAPSurfaceUsage);
+ CWinApp* pApp = AfxGetApp();
+ ASSERT(pApp);
+
+ UINT len;
+ BYTE* ptr = NULL;
+
+ if(fSave)
+ {
+ if(!fInitialized) return;
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, fHideCaptionMenu);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, fHideNavigation);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, nCS);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, iDefaultVideoSize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, fKeepAspectRatio);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, fCompMonDeskARDiff);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, nVolume);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, nBalance);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, fMute);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, nLoops);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, fLoopForever);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, fRewind);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, iZoomLevel);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, fAllowMultipleInst);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, iTitleBarTextStyle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, fTitleBarTextTitle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, iOnTop);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, fTrayIcon);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, fRememberZoomLevel);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, fShowBarsWhenFullScreen);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, nShowBarsWhenFullScreenTimeOut);
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, (BYTE*)&AutoChangeFullscrRes, sizeof(AutoChangeFullscrRes));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, fExitFullScreenAtTheEnd);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("RestoreResAfterExit"), fRestoreResAfterExit);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, fRememberWindowPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, fRememberWindowSize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, fSnapToDesktopEdges);
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, (BYTE*)&rcLastWindowPos, sizeof(rcLastWindowPos));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, lastWindowType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, AspectRatio.cx);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, AspectRatio.cy);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, fKeepHistory);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, iDSVideoRendererType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, iRMVideoRendererType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, iQTVideoRendererType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, iAPSurfaceUsage);
// pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMRSYNCFIX, fVMRSyncFix);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, iDX9Resizer);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, fVMR9MixerMode);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, fVMR9MixerYUV);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), m_RenderSettings.fVMR9AlterativeVSync);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), m_RenderSettings.iVMR9VSyncOffset);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), m_RenderSettings.iVMR9VSyncAccurate);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), m_RenderSettings.iVMR9FullscreenGUISupport);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), m_RenderSettings.iVMR9VSync);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), m_RenderSettings.iVMRDisableDesktopComposition);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), m_RenderSettings.iEVROutputRange);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), m_RenderSettings.iEVRHighColorResolution);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), m_RenderSettings.iEVREnableFrameTimeCorrection);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), m_RenderSettings.iVMRFlushGPUBeforeVSync);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), m_RenderSettings.iVMRFlushGPUAfterPresent);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), m_RenderSettings.iVMRFlushGPUWait);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), m_RenderSettings.bSynchronizeVideo);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), m_RenderSettings.bSynchronizeDisplay);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), m_RenderSettings.bSynchronizeNearest);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("LineDelta"), m_RenderSettings.iLineDelta);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), m_RenderSettings.iColumnDelta);
-
- pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE)&(m_RenderSettings.fCycleDelta), sizeof(m_RenderSettings.fCycleDelta));
- pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE)&(m_RenderSettings.fTargetSyncOffset), sizeof(m_RenderSettings.fTargetSyncOffset));
- pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE)&(m_RenderSettings.fControlLimit), sizeof(m_RenderSettings.fControlLimit));
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), fResetDevice);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, CString(AudioRendererDisplayName));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, fAutoloadAudio);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, fAutoloadSubtitles);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, CString(m_subtitlesLanguageOrder));
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, CString(m_audiosLanguageOrder));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, fBlockVSFilter);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, fEnableWorkerThreadForOpening);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, fReportFailedPins);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, sDVDPath);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, fUseDVDPath);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, idMenuLang);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, idAudioLang);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, idSubtitlesLang);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, fAutoSpeakerConf);
- CString style;
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, style <<= subdefstyle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, fOverridePlacement);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, nHorPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, nVerPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, nSPCSize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, nSPCMaxRes);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, nSubDelayInterval);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, fSPCPow2Tex);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), fSPCAllowAnimationWhenBuffering);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, fEnableSubtitles);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, fUseDefaultSubtitlesStyle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, fEnableAudioSwitcher);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, fAudioTimeShift);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, tAudioTimeShift);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, fDownSampleTo441);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, fCustomChannelMapping);
- pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, (BYTE*)pSpeakerToChannelMap, sizeof(pSpeakerToChannelMap));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, fAudioNormalize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, fAudioNormalizeRecover);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, (int)AudioBoost);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, fnChannels);
-
- // Multi-monitor code
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, CString(f_hmonitor));
- // Prevent Minimize when in Fullscreen mode on non default monitor
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, m_fPreventMinimize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, m_fUseWin7TaskBar);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, m_fExitAfterPlayback);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, m_fNextInDirAfterPlayback);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, m_fDontUseSearchInFolder);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, nOSD_Size);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, m_OSD_Font);
-
- // Associated types with icon or not...
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, fAssociatedWithIcons);
- // Last Open Dir
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, f_lastOpenDir);
-
-
- // CASIMIR666 : nouveau settings
- CString strTemp;
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, fD3DFullscreen);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, fMonitorAutoRefreshRate);
-
- strTemp.Format(_T("%f"), dBrightness);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, strTemp);
- strTemp.Format(_T("%f"), dContrast);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, strTemp);
- strTemp.Format(_T("%f"), dHue);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, strTemp);
- strTemp.Format(_T("%f"), dSaturation);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, strTemp);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, strShaderList);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, strShaderListScreenSpace);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, (int)m_bToggleShader);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, (int)m_bToggleShaderScreenSpace);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, iEvrBuffers);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, (int)fShowOSD);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, (int)fEnableEDLEditor);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, (int)iLanguage);
-
- // Save analog capture settings
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, iDefaultCaptureDevice);
- pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, strAnalogVideo);
- pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, strAnalogAudio);
- pApp->WriteProfileInt(IDS_RS_CAPTURE, IDS_RS_COUNTRY, iAnalogCountry);
-
- // Save digital capture settings (BDA)
- pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, BDANetworkProvider);
- pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, BDATuner);
- pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, BDAReceiver);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, DVBLastChannel);
-
- int iChannel = 0;
- POSITION pos = DVBChannels.GetHeadPosition();
- while(pos)
- {
- CString strTemp;
- CString strChannel;
- CDVBChannel& Channel = DVBChannels.GetNext(pos);
- strTemp.Format(_T("%d"), iChannel);
- pApp->WriteProfileString(IDS_RS_DVB, strTemp, Channel.ToString());
- iChannel++;
- }
-
-
- // Position de lecture des derniers DVD's
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, (int)fRememberDVDPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, (int)fRememberFilePos);
- if(fKeepHistory)
- {
- for(int i = 0; i < MAX_DVD_POSITION; i++)
- {
- CString strDVDPos;
- CString strValue;
-
- strDVDPos.Format(_T("DVD Position %d"), i);
- strValue = SerializeHex((BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
- pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, strValue);
- }
-
- // Position de lecture des derniers fichiers
- for(int i = 0; i < MAX_FILE_POSITION; i++)
- {
- CString strFilePos;
- CString strValue;
-
- strFilePos.Format(_T("File Name %d"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, FilePosition[i].strFile);
- strFilePos.Format(_T("File Position %d"), i);
- strValue.Format(_T("%I64d"), FilePosition[i].llPosition);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, strValue);
- }
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, (int)fLastFullScreen);
- // CASIMIR666 : fin nouveaux settings
-
- {
- for(int i = 0; ; i++)
- {
- CString key;
- key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
- int j = pApp->GetProfileInt(key, _T("Enabled"), -1);
- pApp->WriteProfileString(key, NULL, NULL);
- if(j < 0) break;
- }
- pApp->WriteProfileString(IDS_R_FILTERS, NULL, NULL);
-
- POSITION pos = filters.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
- FilterOverride* f = filters.GetNext(pos);
-
- if(f->fTemporary)
- continue;
-
- CString key;
- key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
-
- pApp->WriteProfileInt(key, _T("SourceType"), (int)f->type);
- pApp->WriteProfileInt(key, _T("Enabled"), (int)!f->fDisabled);
- if(f->type == FilterOverride::REGISTERED)
- {
- pApp->WriteProfileString(key, _T("DisplayName"), CString(f->dispname));
- pApp->WriteProfileString(key, _T("Name"), f->name);
- }
- else if(f->type == FilterOverride::EXTERNAL)
- {
- pApp->WriteProfileString(key, _T("Path"), f->path);
- pApp->WriteProfileString(key, _T("Name"), f->name);
- pApp->WriteProfileString(key, _T("CLSID"), CStringFromGUID(f->clsid));
- }
- POSITION pos2 = f->backup.GetHeadPosition();
- for(int i = 0; pos2; i++)
- {
- CString val;
- val.Format(_T("org%04d"), i);
- pApp->WriteProfileString(key, val, CStringFromGUID(f->backup.GetNext(pos2)));
- }
- pos2 = f->guids.GetHeadPosition();
- for(int i = 0; pos2; i++)
- {
- CString val;
- val.Format(_T("mod%04d"), i);
- pApp->WriteProfileString(key, val, CStringFromGUID(f->guids.GetNext(pos2)));
- }
- pApp->WriteProfileInt(key, _T("LoadType"), f->iLoadType);
- pApp->WriteProfileInt(key, _T("Merit"), f->dwMerit);
- }
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, fIntRealMedia);
- // pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, fRealMediaRenderless);
- // pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, iQuickTimeRenderer);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&RealMediaQuickTimeFPS));
-
- pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, NULL, NULL);
- for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++)
- {
- CString str;
- str.Format(_T("Preset%d"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, m_pnspresets[i]);
- }
-
- pApp->WriteProfileString(IDS_R_COMMANDS, NULL, NULL);
- pos = wmcmds.GetHeadPosition();
- for(int i = 0; pos;)
- {
- wmcmd& wc = wmcmds.GetNext(pos);
- if(wc.IsModified())
- {
- CString str;
- str.Format(_T("CommandMod%d"), i);
- CString str2;
- str2.Format(_T("%d %x %x %s %d %d %d"),
- wc.cmd, wc.fVirt, wc.key,
- _T("\"") + CString(wc.rmcmd) + _T("\""), wc.rmrepcnt,
- wc.mouse, wc.appcmd);
- pApp->WriteProfileString(IDS_R_COMMANDS, str, str2);
- i++;
- }
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, fWinLirc);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, WinLircAddr);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, fUIce);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, UIceAddr);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, fGlobalMedia);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEXPTOOLBARS, fDisableXPToolbars);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEWMASFREADER, fUseWMASFReader);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, nJumpDistS);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, nJumpDistM);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, nJumpDistL);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, fLimitWindowProportions);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, fNotifyMSN);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYGTSDLL, fNotifyGTSdll);
-
- Formats.UpdateData(true);
-
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_SRCFILTERS, SrcFilters | ~(SRC_LAST - 1));
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_TRAFILTERS, TraFilters | ~(TRA_LAST - 1));
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_DXVAFILTERS, DXVAFilters | ~(DXVA_LAST - 1));
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_FFMPEGFILTERS, FFmpegFilters | ~(FFM_LAST - 1));
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, logofn);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, logoid);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, logoext);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, fHideCDROMsSubMenu);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, priority);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, launchfullscreen);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, fEnableWebServer);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, nWebServerPort);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, fWebServerPrintDebugInfo);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, fWebServerUseCompression);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, fWebServerLocalhostOnly);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, WebRoot);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, WebDefIndex);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, WebServerCGI);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, SnapShotPath);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, SnapShotExt);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, ThumbRows);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, ThumbCols);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, ThumbWidth);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, ISDb);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, D3D9RenderDevice);
-
- pApp->WriteProfileString(_T("Shaders"), NULL, NULL);
- pApp->WriteProfileInt(_T("Shaders"), _T("Initialized"), 1);
- pApp->WriteProfileString(_T("Shaders"), _T("Combine"), m_shadercombine);
- pApp->WriteProfileString(_T("Shaders"), _T("CombineScreenSpace"), m_shadercombineScreenSpace);
-
-
- pos = m_shaders.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
- const Shader& s = m_shaders.GetNext(pos);
-
- if(!s.label.IsEmpty())
- {
- CString index;
- index.Format(_T("%d"), i);
- CString srcdata = s.srcdata;
- srcdata.Replace(_T("\r"), _T(""));
- srcdata.Replace(_T("\n"), _T("\\n"));
- srcdata.Replace(_T("\t"), _T("\\t"));
- AfxGetApp()->WriteProfileString(_T("Shaders"), index, s.label + _T("|") + s.target + _T("|") + srcdata);
- }
- }
-
- if(pApp->m_pszRegistryKey)
- {
- // WINBUG: on win2k this would crash WritePrivateProfileString
- pApp->WriteProfileInt(_T(""), _T(""), pApp->GetProfileInt(_T(""), _T(""), 0) ? 0 : 1);
- }
- }
- else
- {
- if(fInitialized) return;
-
- OSVERSIONINFO vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- GetVersionEx(&vi);
- fXpOrBetter = (vi.dwMajorVersion >= 5 && vi.dwMinorVersion >= 1 || vi.dwMajorVersion >= 6);
-
- iDXVer = 0;
- CRegKey dxver;
- if(ERROR_SUCCESS == dxver.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), KEY_READ))
- {
- CString str;
- ULONG len = 64;
- if(ERROR_SUCCESS == dxver.QueryStringValue(_T("Version"), str.GetBuffer(len), &len))
- {
- str.ReleaseBuffer(len);
- int ver[4];
- _stscanf_s(str, _T("%d.%d.%d.%d"), ver + 0, ver + 1, ver + 2, ver + 3);
- iDXVer = ver[1];
- }
- }
-
- // Set interface language first!
- iLanguage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, 0);
- if(iLanguage != 0) SetLanguage(iLanguage);
- CreateCommands();
-
- fHideCaptionMenu = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, 0);
- fHideNavigation = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, 0);
- nCS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, CS_SEEKBAR | CS_TOOLBAR | CS_STATUSBAR);
- iDefaultVideoSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, DVS_FROMINSIDE);
- fKeepAspectRatio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, TRUE);
- fCompMonDeskARDiff = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, FALSE);
- nVolume = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, 100);
- nBalance = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, 0);
- fMute = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, 0);
- nLoops = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, 1);
- fLoopForever = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, 0);
- fRewind = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, FALSE);
- iZoomLevel = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, 1);
- iDSVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, (IsVistaOrAbove() ? (HasEVR() ? VIDRNDT_DS_EVR_CUSTOM : VIDRNDT_DS_DEFAULT) : VIDRNDT_DS_OVERLAYMIXER));
- iRMVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, VIDRNDT_RM_DEFAULT);
- iQTVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, VIDRNDT_QT_DEFAULT);
- iAPSurfaceUsage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, (IsVistaOrAbove() ? VIDRNDT_AP_TEXTURE3D : VIDRNDT_AP_TEXTURE2D));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, iDX9Resizer);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, fVMR9MixerMode);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, fVMR9MixerYUV);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), m_RenderSettings.fVMR9AlterativeVSync);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), m_RenderSettings.iVMR9VSyncOffset);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), m_RenderSettings.iVMR9VSyncAccurate);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), m_RenderSettings.iVMR9FullscreenGUISupport);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), m_RenderSettings.iVMR9VSync);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), m_RenderSettings.iVMRDisableDesktopComposition);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), m_RenderSettings.iEVROutputRange);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), m_RenderSettings.iEVRHighColorResolution);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), m_RenderSettings.iEVREnableFrameTimeCorrection);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), m_RenderSettings.iVMRFlushGPUBeforeVSync);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), m_RenderSettings.iVMRFlushGPUAfterPresent);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), m_RenderSettings.iVMRFlushGPUWait);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), m_RenderSettings.bSynchronizeVideo);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), m_RenderSettings.bSynchronizeDisplay);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), m_RenderSettings.bSynchronizeNearest);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("LineDelta"), m_RenderSettings.iLineDelta);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), m_RenderSettings.iColumnDelta);
+
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE)&(m_RenderSettings.fCycleDelta), sizeof(m_RenderSettings.fCycleDelta));
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE)&(m_RenderSettings.fTargetSyncOffset), sizeof(m_RenderSettings.fTargetSyncOffset));
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE)&(m_RenderSettings.fControlLimit), sizeof(m_RenderSettings.fControlLimit));
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), fResetDevice);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, CString(AudioRendererDisplayName));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, fAutoloadAudio);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, fAutoloadSubtitles);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, CString(m_subtitlesLanguageOrder));
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, CString(m_audiosLanguageOrder));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, fBlockVSFilter);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, fEnableWorkerThreadForOpening);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, fReportFailedPins);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, sDVDPath);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, fUseDVDPath);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, idMenuLang);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, idAudioLang);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, idSubtitlesLang);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, fAutoSpeakerConf);
+ CString style;
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, style <<= subdefstyle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, fOverridePlacement);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, nHorPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, nVerPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, nSPCSize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, nSPCMaxRes);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, nSubDelayInterval);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, fSPCPow2Tex);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), fSPCAllowAnimationWhenBuffering);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, fEnableSubtitles);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, fUseDefaultSubtitlesStyle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, fEnableAudioSwitcher);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, fAudioTimeShift);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, tAudioTimeShift);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, fDownSampleTo441);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, fCustomChannelMapping);
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, (BYTE*)pSpeakerToChannelMap, sizeof(pSpeakerToChannelMap));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, fAudioNormalize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, fAudioNormalizeRecover);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, (int)AudioBoost);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, fnChannels);
+
+ // Multi-monitor code
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, CString(f_hmonitor));
+ // Prevent Minimize when in Fullscreen mode on non default monitor
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, m_fPreventMinimize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, m_fUseWin7TaskBar);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, m_fExitAfterPlayback);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, m_fNextInDirAfterPlayback);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, m_fDontUseSearchInFolder);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, nOSD_Size);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, m_OSD_Font);
+
+ // Associated types with icon or not...
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, fAssociatedWithIcons);
+ // Last Open Dir
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, f_lastOpenDir);
+
+
+ // CASIMIR666 : nouveau settings
+ CString strTemp;
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, fD3DFullscreen);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, fMonitorAutoRefreshRate);
+
+ strTemp.Format (_T("%f"), dBrightness);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, strTemp);
+ strTemp.Format (_T("%f"), dContrast);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, strTemp);
+ strTemp.Format (_T("%f"), dHue);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, strTemp);
+ strTemp.Format (_T("%f"), dSaturation);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, strTemp);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, strShaderList);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, strShaderListScreenSpace);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, (int)m_bToggleShader);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, (int)m_bToggleShaderScreenSpace);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, iEvrBuffers);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, (int)fShowOSD);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, (int)fEnableEDLEditor);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, (int)iLanguage);
+
+ // Save analog capture settings
+ pApp->WriteProfileInt (IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, iDefaultCaptureDevice);
+ pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, strAnalogVideo);
+ pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, strAnalogAudio);
+ pApp->WriteProfileInt (IDS_RS_CAPTURE, IDS_RS_COUNTRY, iAnalogCountry);
+
+ // Save digital capture settings (BDA)
+ pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, BDANetworkProvider);
+ pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, BDATuner);
+ pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, BDAReceiver);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, DVBLastChannel);
+
+ int iChannel = 0;
+ POSITION pos = DVBChannels.GetHeadPosition();
+ while (pos)
+ {
+ CString strTemp;
+ CString strChannel;
+ CDVBChannel& Channel = DVBChannels.GetNext(pos);
+ strTemp.Format(_T("%d"), iChannel);
+ pApp->WriteProfileString(IDS_RS_DVB, strTemp, Channel.ToString());
+ iChannel++;
+ }
+
+
+ // Position de lecture des derniers DVD's
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, (int)fRememberDVDPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, (int)fRememberFilePos);
+ if (fKeepHistory)
+ {
+ for (int i=0; i<MAX_DVD_POSITION; i++)
+ {
+ CString strDVDPos;
+ CString strValue;
+
+ strDVDPos.Format (_T("DVD Position %d"), i);
+ strValue = SerializeHex((BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
+ pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, strValue);
+ }
+
+ // Position de lecture des derniers fichiers
+ for (int i=0; i<MAX_FILE_POSITION; i++)
+ {
+ CString strFilePos;
+ CString strValue;
+
+ strFilePos.Format (_T("File Name %d"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, FilePosition[i].strFile);
+ strFilePos.Format (_T("File Position %d"), i);
+ strValue.Format (_T("%I64d"), FilePosition[i].llPosition);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, strValue);
+ }
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, (int)fLastFullScreen);
+ // CASIMIR666 : fin nouveaux settings
+
+ {
+ for(int i = 0; ; i++)
+ {
+ CString key;
+ key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
+ int j = pApp->GetProfileInt(key, _T("Enabled"), -1);
+ pApp->WriteProfileString(key, NULL, NULL);
+ if(j < 0) break;
+ }
+ pApp->WriteProfileString(IDS_R_FILTERS, NULL, NULL);
+
+ POSITION pos = filters.GetHeadPosition();
+ for(int i = 0; pos; i++)
+ {
+ FilterOverride* f = filters.GetNext(pos);
+
+ if(f->fTemporary)
+ continue;
+
+ CString key;
+ key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
+
+ pApp->WriteProfileInt(key, _T("SourceType"), (int)f->type);
+ pApp->WriteProfileInt(key, _T("Enabled"), (int)!f->fDisabled);
+ if(f->type == FilterOverride::REGISTERED)
+ {
+ pApp->WriteProfileString(key, _T("DisplayName"), CString(f->dispname));
+ pApp->WriteProfileString(key, _T("Name"), f->name);
+ }
+ else if(f->type == FilterOverride::EXTERNAL)
+ {
+ pApp->WriteProfileString(key, _T("Path"), f->path);
+ pApp->WriteProfileString(key, _T("Name"), f->name);
+ pApp->WriteProfileString(key, _T("CLSID"), CStringFromGUID(f->clsid));
+ }
+ POSITION pos2 = f->backup.GetHeadPosition();
+ for(int i = 0; pos2; i++)
+ {
+ CString val;
+ val.Format(_T("org%04d"), i);
+ pApp->WriteProfileString(key, val, CStringFromGUID(f->backup.GetNext(pos2)));
+ }
+ pos2 = f->guids.GetHeadPosition();
+ for(int i = 0; pos2; i++)
+ {
+ CString val;
+ val.Format(_T("mod%04d"), i);
+ pApp->WriteProfileString(key, val, CStringFromGUID(f->guids.GetNext(pos2)));
+ }
+ pApp->WriteProfileInt(key, _T("LoadType"), f->iLoadType);
+ pApp->WriteProfileInt(key, _T("Merit"), f->dwMerit);
+ }
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, fIntRealMedia);
+ // pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, fRealMediaRenderless);
+ // pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, iQuickTimeRenderer);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&RealMediaQuickTimeFPS));
+
+ pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, NULL, NULL);
+ for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++)
+ {
+ CString str;
+ str.Format(_T("Preset%d"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, m_pnspresets[i]);
+ }
+
+ pApp->WriteProfileString(IDS_R_COMMANDS, NULL, NULL);
+ pos = wmcmds.GetHeadPosition();
+ for(int i = 0; pos; )
+ {
+ wmcmd& wc = wmcmds.GetNext(pos);
+ if(wc.IsModified())
+ {
+ CString str;
+ str.Format(_T("CommandMod%d"), i);
+ CString str2;
+ str2.Format(_T("%d %x %x %s %d %d %d"),
+ wc.cmd, wc.fVirt, wc.key,
+ _T("\"") + CString(wc.rmcmd) + _T("\""), wc.rmrepcnt,
+ wc.mouse, wc.appcmd);
+ pApp->WriteProfileString(IDS_R_COMMANDS, str, str2);
+ i++;
+ }
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, fWinLirc);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, WinLircAddr);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, fUIce);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, UIceAddr);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, fGlobalMedia);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEXPTOOLBARS, fDisableXPToolbars);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEWMASFREADER, fUseWMASFReader);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, nJumpDistS);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, nJumpDistM);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, nJumpDistL);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, fLimitWindowProportions);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, fNotifyMSN);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYGTSDLL, fNotifyGTSdll);
+
+ Formats.UpdateData(true);
+
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_SRCFILTERS, SrcFilters|~(SRC_LAST-1));
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_TRAFILTERS, TraFilters|~(TRA_LAST-1));
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_DXVAFILTERS, DXVAFilters|~(DXVA_LAST-1));
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_FFMPEGFILTERS, FFmpegFilters|~(FFM_LAST-1));
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, logofn);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, logoid);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, logoext);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, fHideCDROMsSubMenu);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, priority);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, launchfullscreen);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, fEnableWebServer);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, nWebServerPort);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, fWebServerPrintDebugInfo);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, fWebServerUseCompression);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, fWebServerLocalhostOnly);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, WebRoot);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, WebDefIndex);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, WebServerCGI);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, SnapShotPath);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, SnapShotExt);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, ThumbRows);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, ThumbCols);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, ThumbWidth);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, ISDb);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, D3D9RenderDevice);
+
+ pApp->WriteProfileString(_T("Shaders"), NULL, NULL);
+ pApp->WriteProfileInt(_T("Shaders"), _T("Initialized"), 1);
+ pApp->WriteProfileString(_T("Shaders"), _T("Combine"), m_shadercombine);
+ pApp->WriteProfileString(_T("Shaders"), _T("CombineScreenSpace"), m_shadercombineScreenSpace);
+
+
+ pos = m_shaders.GetHeadPosition();
+ for(int i = 0; pos; i++)
+ {
+ const Shader& s = m_shaders.GetNext(pos);
+
+ if(!s.label.IsEmpty())
+ {
+ CString index;
+ index.Format(_T("%d"), i);
+ CString srcdata = s.srcdata;
+ srcdata.Replace(_T("\r"), _T(""));
+ srcdata.Replace(_T("\n"), _T("\\n"));
+ srcdata.Replace(_T("\t"), _T("\\t"));
+ AfxGetApp()->WriteProfileString(_T("Shaders"), index, s.label + _T("|") + s.target + _T("|") + srcdata);
+ }
+ }
+
+ if(pApp->m_pszRegistryKey)
+ {
+ // WINBUG: on win2k this would crash WritePrivateProfileString
+ pApp->WriteProfileInt(_T(""), _T(""), pApp->GetProfileInt(_T(""), _T(""), 0)?0:1);
+ }
+ }
+ else
+ {
+ if(fInitialized) return;
+
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ GetVersionEx(&vi);
+ fXpOrBetter = (vi.dwMajorVersion >= 5 && vi.dwMinorVersion >= 1 || vi.dwMajorVersion >= 6);
+
+ iDXVer = 0;
+ CRegKey dxver;
+ if(ERROR_SUCCESS == dxver.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), KEY_READ))
+ {
+ CString str;
+ ULONG len = 64;
+ if(ERROR_SUCCESS == dxver.QueryStringValue(_T("Version"), str.GetBuffer(len), &len))
+ {
+ str.ReleaseBuffer(len);
+ int ver[4];
+ _stscanf_s(str, _T("%d.%d.%d.%d"), ver+0, ver+1, ver+2, ver+3);
+ iDXVer = ver[1];
+ }
+ }
+
+ // Set interface language first!
+ iLanguage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, 0);
+ if (iLanguage != 0) SetLanguage(iLanguage);
+ CreateCommands();
+
+ fHideCaptionMenu = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, 0);
+ fHideNavigation = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, 0);
+ nCS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, CS_SEEKBAR|CS_TOOLBAR|CS_STATUSBAR);
+ iDefaultVideoSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, DVS_FROMINSIDE);
+ fKeepAspectRatio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, TRUE);
+ fCompMonDeskARDiff = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, FALSE);
+ nVolume = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, 100);
+ nBalance = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, 0);
+ fMute = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, 0);
+ nLoops = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, 1);
+ fLoopForever = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, 0);
+ fRewind = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, FALSE);
+ iZoomLevel = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, 1);
+ iDSVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, (IsVistaOrAbove() ? (HasEVR() ? VIDRNDT_DS_EVR_CUSTOM : VIDRNDT_DS_DEFAULT) : VIDRNDT_DS_OVERLAYMIXER) );
+ iRMVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, VIDRNDT_RM_DEFAULT);
+ iQTVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, VIDRNDT_QT_DEFAULT);
+ iAPSurfaceUsage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, (IsVistaOrAbove() ? VIDRNDT_AP_TEXTURE3D : VIDRNDT_AP_TEXTURE2D));
// fVMRSyncFix = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMRSYNCFIX, FALSE);
- iDX9Resizer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, 1);
- fVMR9MixerMode = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, TRUE);
- fVMR9MixerYUV = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, FALSE);
- CRendererSettingsEVR DefaultSettings;
- m_RenderSettings.fVMR9AlterativeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), DefaultSettings.fVMR9AlterativeVSync);
- m_RenderSettings.iVMR9VSyncOffset = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), DefaultSettings.iVMR9VSyncOffset);
- m_RenderSettings.iVMR9VSyncAccurate = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), DefaultSettings.iVMR9VSyncAccurate);
- m_RenderSettings.iVMR9FullscreenGUISupport = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), DefaultSettings.iVMR9FullscreenGUISupport);
- m_RenderSettings.iEVRHighColorResolution = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), DefaultSettings.iEVRHighColorResolution);
- m_RenderSettings.iEVREnableFrameTimeCorrection = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), DefaultSettings.iEVREnableFrameTimeCorrection);
- m_RenderSettings.iVMR9VSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), DefaultSettings.iVMR9VSync);
- m_RenderSettings.iVMRDisableDesktopComposition = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), DefaultSettings.iVMRDisableDesktopComposition);
-
- m_RenderSettings.iEVROutputRange = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), DefaultSettings.iEVROutputRange);
-
- m_RenderSettings.iVMRFlushGPUBeforeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), DefaultSettings.iVMRFlushGPUBeforeVSync);
- m_RenderSettings.iVMRFlushGPUAfterPresent = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), DefaultSettings.iVMRFlushGPUAfterPresent);
- m_RenderSettings.iVMRFlushGPUWait = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), DefaultSettings.iVMRFlushGPUWait);
-
- m_RenderSettings.bSynchronizeVideo = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), DefaultSettings.bSynchronizeVideo);
- m_RenderSettings.bSynchronizeDisplay = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), DefaultSettings.bSynchronizeDisplay);
- m_RenderSettings.bSynchronizeNearest = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), DefaultSettings.bSynchronizeNearest);
- m_RenderSettings.iLineDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("LineDelta"), DefaultSettings.iLineDelta);
- m_RenderSettings.iColumnDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), DefaultSettings.iColumnDelta);
-
- double *dPtr;
- UINT dSize;
- if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE*)&dPtr, &dSize))
- {
- m_RenderSettings.fCycleDelta = *dPtr;
- delete [] dPtr;
- }
-
- if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE*)&dPtr, &dSize))
- {
- m_RenderSettings.fTargetSyncOffset = *dPtr;
- delete [] dPtr;
- }
- if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE*)&dPtr, &dSize))
- {
- m_RenderSettings.fControlLimit = *dPtr;
- delete [] dPtr;
- }
-
- fResetDevice = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), TRUE);
-
- AudioRendererDisplayName = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, _T(""));
- fAutoloadAudio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, TRUE);
- fAutoloadSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, !IsVSFilterInstalled() || (IsVistaOrAbove() && HasEVR()));
- m_subtitlesLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
- m_audiosLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
- fBlockVSFilter = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, TRUE);
- fEnableWorkerThreadForOpening = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, TRUE);
- fReportFailedPins = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, TRUE);
- fAllowMultipleInst = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, 0);
- iTitleBarTextStyle = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, 1);
- fTitleBarTextTitle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, FALSE);
- iOnTop = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, 0);
- fTrayIcon = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, 0);
- fRememberZoomLevel = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, 1);
- fShowBarsWhenFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, 1);
- nShowBarsWhenFullScreenTimeOut = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, 0);
-
- //Multi-monitor code
- f_hmonitor = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, _T(""));
- // Prevent Minimize when in Fullscreen mode on non default monitor
- m_fPreventMinimize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, 0);
- m_fUseWin7TaskBar = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, 1);
- m_fExitAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, 0);
- m_fNextInDirAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, 0);
- m_fDontUseSearchInFolder = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, 0);
- nOSD_Size = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, 20);
- m_OSD_Font = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, _T("Arial"));
-
- // Associated types with icon or not...
- fAssociatedWithIcons = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, 1);
- // Last Open Dir
- f_lastOpenDir = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, _T("C:\\"));
-
- if(pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, &ptr, &len))
- {
- if(len == sizeof(AChFR))
- memcpy(&AutoChangeFullscrRes, ptr, sizeof(AChFR));
- else
- AutoChangeFullscrRes.bEnabled = false;
- delete [] ptr;
- }
- else
- {
- AutoChangeFullscrRes.bEnabled = false;
- }
-
- fExitFullScreenAtTheEnd = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, 1);
- fRestoreResAfterExit = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("RestoreResAfterExit"), 1);
- fRememberWindowPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, 0);
- fRememberWindowSize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, 0);
- fSnapToDesktopEdges = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, 0);
- AspectRatio.cx = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, 0);
- AspectRatio.cy = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, 0);
- fKeepHistory = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, 1);
- if(pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, &ptr, &len))
- {
- if(len == sizeof(CRect))
- memcpy(&rcLastWindowPos, ptr, sizeof(CRect));
- else
- fRememberWindowPos = false;
- delete [] ptr;
- }
- else
- {
- fRememberWindowPos = false;
- }
- lastWindowType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, SIZE_RESTORED);
- sDVDPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, _T(""));
- fUseDVDPath = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, 0);
- idMenuLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, ::GetUserDefaultLCID());
- idAudioLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, ::GetUserDefaultLCID());
- idSubtitlesLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, ::GetUserDefaultLCID());
- fAutoSpeakerConf = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, 1);
- // TODO: rename subdefstyle -> defStyle, IDS_RS_SPLOGFONT -> IDS_RS_SPSTYLE
- subdefstyle <<= pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, _T(""));
- fOverridePlacement = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, 0);
- nHorPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, 50);
- nVerPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, 90);
- nSPCSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, 3);
- nSPCMaxRes = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, 2);
- nSubDelayInterval = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, 500);
- fSPCPow2Tex = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, TRUE);
-
- bool bAllowAnimationWhenBuffering = true;
- SYSTEM_INFO SysInfo;
- GetSystemInfo(&SysInfo);
- if(SysInfo.dwNumberOfProcessors < 3)
- bAllowAnimationWhenBuffering = false;
-
-
- fSPCAllowAnimationWhenBuffering = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), bAllowAnimationWhenBuffering);
- fEnableSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, TRUE);
- fUseDefaultSubtitlesStyle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, FALSE);
- fEnableAudioSwitcher = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, TRUE);
- fAudioTimeShift = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, 0);
- tAudioTimeShift = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, 0);
- fDownSampleTo441 = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, 0);
- fCustomChannelMapping = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, 0);
-
- BOOL bResult = pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, &ptr, &len);
- if(bResult && len == sizeof(pSpeakerToChannelMap))
- {
- memcpy(pSpeakerToChannelMap, ptr, sizeof(pSpeakerToChannelMap));
- }
- else
- {
- memset(pSpeakerToChannelMap, 0, sizeof(pSpeakerToChannelMap));
- for(int j = 0; j < 18; j++)
- for(int i = 0; i <= j; i++)
- pSpeakerToChannelMap[j][i] = 1 << i;
-
- pSpeakerToChannelMap[0][0] = 1 << 0;
- pSpeakerToChannelMap[0][1] = 1 << 0;
-
- pSpeakerToChannelMap[3][0] = 1 << 0;
- pSpeakerToChannelMap[3][1] = 1 << 1;
- pSpeakerToChannelMap[3][2] = 0;
- pSpeakerToChannelMap[3][3] = 0;
- pSpeakerToChannelMap[3][4] = 1 << 2;
- pSpeakerToChannelMap[3][5] = 1 << 3;
-
- pSpeakerToChannelMap[4][0] = 1 << 0;
- pSpeakerToChannelMap[4][1] = 1 << 1;
- pSpeakerToChannelMap[4][2] = 1 << 2;
- pSpeakerToChannelMap[4][3] = 0;
- pSpeakerToChannelMap[4][4] = 1 << 3;
- pSpeakerToChannelMap[4][5] = 1 << 4;
- }
- if(bResult)
- delete [] ptr;
-
- fAudioNormalize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, FALSE);
- fAudioNormalizeRecover = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, TRUE);
- AudioBoost = (float)pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, 1);
- fnChannels = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, 2);
-
- {
- for(int i = 0; ; i++)
- {
- CString key;
- key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
-
- CAutoPtr<FilterOverride> f(DNew FilterOverride);
-
- f->fDisabled = !pApp->GetProfileInt(key, _T("Enabled"), 0);
-
- UINT j = pApp->GetProfileInt(key, _T("SourceType"), -1);
- if(j == 0)
- {
- f->type = FilterOverride::REGISTERED;
- f->dispname = CStringW(pApp->GetProfileString(key, _T("DisplayName"), _T("")));
- f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
- }
- else if(j == 1)
- {
- f->type = FilterOverride::EXTERNAL;
- f->path = pApp->GetProfileString(key, _T("Path"), _T(""));
- f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
- f->clsid = GUIDFromCString(pApp->GetProfileString(key, _T("CLSID"), _T("")));
- }
- else
- {
- pApp->WriteProfileString(key, NULL, 0);
- break;
- }
-
- f->backup.RemoveAll();
- for(int i = 0; ; i++)
- {
- CString val;
- val.Format(_T("org%04d"), i);
- CString guid = pApp->GetProfileString(key, val, _T(""));
- if(guid.IsEmpty()) break;
- f->backup.AddTail(GUIDFromCString(guid));
- }
-
- f->guids.RemoveAll();
- for(int i = 0; ; i++)
- {
- CString val;
- val.Format(_T("mod%04d"), i);
- CString guid = pApp->GetProfileString(key, val, _T(""));
- if(guid.IsEmpty()) break;
- f->guids.AddTail(GUIDFromCString(guid));
- }
-
- f->iLoadType = (int)pApp->GetProfileInt(key, _T("LoadType"), -1);
- if(f->iLoadType < 0) break;
-
- f->dwMerit = pApp->GetProfileInt(key, _T("Merit"), MERIT_DO_NOT_USE + 1);
-
- filters.AddTail(f);
- }
- }
-
- fIntRealMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, 0);
- //fRealMediaRenderless = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, 0);
- //iQuickTimeRenderer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, 2);
- RealMediaQuickTimeFPS = 25.0;
- *((DWORD*)&RealMediaQuickTimeFPS) = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&RealMediaQuickTimeFPS));
-
- m_pnspresets.RemoveAll();
- for(int i = 0; i < (ID_PANNSCAN_PRESETS_END - ID_PANNSCAN_PRESETS_START); i++)
- {
- CString str;
- str.Format(_T("Preset%d"), i);
- str = pApp->GetProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, _T(""));
- if(str.IsEmpty()) break;
- m_pnspresets.Add(str);
- }
- if(m_pnspresets.IsEmpty())
- {
- double _4p3 = 4.0 / 3.0;
- double _16p9 = 16.0 / 9.0;
- double _185p1 = 1.85 / 1.0;
- double _235p1 = 2.35 / 1.0;
-
- CString str;
- str.Format(ResStr(IDS_SCALE_16_9), 0.5, 0.5, _4p3 / _4p3, _16p9 / _4p3);
- m_pnspresets.Add(str);
- str.Format(ResStr(IDS_SCALE_WIDESCREEN), 0.5, 0.5, _16p9 / _4p3, _16p9 / _4p3);
- m_pnspresets.Add(str);
- str.Format(ResStr(IDS_SCALE_ULTRAWIDE), 0.5, 0.5, _235p1 / _4p3, _235p1 / _4p3);
- m_pnspresets.Add(str);
- }
-
- for(int i = 0; i < wmcmds.GetCount(); i++)
- {
- CString str;
- str.Format(_T("CommandMod%d"), i);
- str = pApp->GetProfileString(IDS_R_COMMANDS, str, _T(""));
- if(str.IsEmpty()) break;
- int cmd, fVirt, key, repcnt, mouse, appcmd;
- TCHAR buff[128];
- int n;
- if(5 > (n = _stscanf_s(str, _T("%d %x %x %s %d %d %d"), &cmd, &fVirt, &key, buff, countof(buff), &repcnt, &mouse, &appcmd)))
- break;
- if(POSITION pos = wmcmds.Find(cmd))
- {
- wmcmd& wc = wmcmds.GetAt(pos);
- wc.cmd = cmd;
- wc.fVirt = fVirt;
- wc.key = key;
- if(n >= 6) wc.mouse = (UINT)mouse;
- if(n >= 7) wc.appcmd = (UINT)appcmd;
- wc.rmcmd = CStringA(buff).Trim('\"');
- wc.rmrepcnt = repcnt;
- }
- }
-
- CAtlArray<ACCEL> pAccel;
- pAccel.SetCount(wmcmds.GetCount());
- POSITION pos = wmcmds.GetHeadPosition();
- for(int i = 0; pos; i++) pAccel[i] = wmcmds.GetNext(pos);
- hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
-
- WinLircAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, _T("127.0.0.1:8765"));
- fWinLirc = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, 0);
- UIceAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, _T("127.0.0.1:1234"));
- fUIce = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, 0);
- fGlobalMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, 0);
-
- fDisableXPToolbars = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEXPTOOLBARS, 0);
- fUseWMASFReader = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEWMASFREADER, FALSE);
- nJumpDistS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, 1000);
- nJumpDistM = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, 5000);
- nJumpDistL = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, 20000);
- fLimitWindowProportions = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, FALSE);
- fNotifyMSN = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, FALSE);
- fNotifyGTSdll = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYGTSDLL, FALSE);
-
- Formats.UpdateData(false);
-
- SrcFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_SRCFILTERS, ~0);
- TraFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_TRAFILTERS, ~0);
- DXVAFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_DXVAFILTERS, ~0);
- FFmpegFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_FFMPEGFILTERS, ~0);
-
- logofn = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, _T(""));
- logoid = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, IDF_LOGO4);
- logoext = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, 0);
-
- fHideCDROMsSubMenu = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, 0);
-
- priority = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, NORMAL_PRIORITY_CLASS);
- ::SetPriorityClass(::GetCurrentProcess(), priority);
- launchfullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, FALSE);
-
- fEnableWebServer = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, FALSE);
- nWebServerPort = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, 13579);
- fWebServerPrintDebugInfo = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, FALSE);
- fWebServerUseCompression = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, TRUE);
- fWebServerLocalhostOnly = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, FALSE);
- WebRoot = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, _T("*./webroot"));
- WebDefIndex = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, _T("index.html;index.php"));
- WebServerCGI = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, _T(""));
-
- CString MyPictures;
-
- CRegKey key;
- // grrrrr
- // if(!SHGetSpecialFolderPath(NULL, MyPictures.GetBufferSetLength(MAX_PATH), CSIDL_MYPICTURES, TRUE)) MyPictures.Empty();
- // else MyPictures.ReleaseBuffer();
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ))
- {
- ULONG len = MAX_PATH;
- if(ERROR_SUCCESS == key.QueryStringValue(_T("My Pictures"), MyPictures.GetBuffer(MAX_PATH), &len)) MyPictures.ReleaseBufferSetLength(len);
- else MyPictures.Empty();
- }
- SnapShotPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, MyPictures);
- SnapShotExt = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, _T(".jpg"));
-
- ThumbRows = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, 4);
- ThumbCols = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, 4);
- ThumbWidth = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, 1024);
-
- ISDb = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, _T("www.opensubtitles.org/isdb"));
-
- D3D9RenderDevice = pApp->GetProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, _T(""));
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("LastUsedPage"), 0);
-
- //
-
- m_shaders.RemoveAll();
-
- CAtlStringMap<UINT> shaders;
-
- shaders[_T("16-235 -> 0-255 [SD][HD]")] = IDF_SHADER_LEVELS;
- shaders[_T("16-235 -> 0-255 [SD]")] = IDF_SHADER_LEVELS2;
- shaders[_T("0-255 -> 16-235")] = IDF_SHADER_LEVELS3;
- shaders[_T("BT.601 -> BT.709")] = IDF_SHADER_BT601_BT709;
- shaders[_T("contour")] = IDF_SHADER_CONTOUR;
- shaders[_T("deinterlace (blend)")] = IDF_SHADER_DEINTERLACE;
- shaders[_T("edge sharpen")] = IDF_SHADER_EDGE_SHARPEN;
- shaders[_T("emboss")] = IDF_SHADER_EMBOSS;
- shaders[_T("grayscale")] = IDF_SHADER_GRAYSCALE;
- shaders[_T("invert")] = IDF_SHADER_INVERT;
- shaders[_T("letterbox")] = IDF_SHADER_LETTERBOX;
- shaders[_T("nightvision")] = IDF_SHADER_NIGHTVISION;
- shaders[_T("procamp")] = IDF_SHADER_PROCAMP;
- shaders[_T("sharpen")] = IDF_SHADER_SHARPEN;
- shaders[_T("sharpen complex")] = IDF_SHADER_SHARPEN_COMPLEX;
- shaders[_T("sharpen complex 2")] = IDF_SHADER_SHARPEN_COMPLEX2;
- shaders[_T("sphere")] = IDF_SHADER_SPHERE;
- shaders[_T("spotlight")] = IDF_SHADER_SPOTLIGHT;
- shaders[_T("wave")] = IDF_SHADER_WAVE;
- shaders[_T("denoise")] = IDF_SHADER_DENOISE;
- shaders[_T("YV12 Chroma Upsampling")] = IDF_SHADER_YV12CHROMAUP;
-
- int iShader = 0;
-
- for(; ; iShader++)
- {
- CString str;
- str.Format(_T("%d"), iShader);
- str = pApp->GetProfileString(_T("Shaders"), str);
-
- CAtlList<CString> sl;
- CString label = Explode(str, sl, '|');
- if(label.IsEmpty()) break;
- if(sl.GetCount() < 3) continue;
-
- Shader s;
- s.label = sl.RemoveHead();
- s.target = sl.RemoveHead();
- s.srcdata = sl.RemoveHead();
- s.srcdata.Replace(_T("\\n"), _T("\n"));
- s.srcdata.Replace(_T("\\t"), _T("\t"));
- m_shaders.AddTail(s);
-
- shaders.RemoveKey(s.label);
- }
-
- pos = shaders.GetStartPosition();
- for(; pos; iShader++)
- {
- CAtlStringMap<UINT>::CPair* pPair = shaders.GetNext(pos);
-
- CStringA srcdata;
- if(LoadResource(pPair->m_value, srcdata, _T("FILE")))
- {
- Shader s;
- s.label = pPair->m_key;
-
- // Select minimum version for each shader!
- switch(pPair->m_value)
- {
- case IDF_SHADER_DENOISE :
- s.target = _T("ps_3_0");
- break;
- case IDF_SHADER_SHARPEN_COMPLEX2 :
- s.target = _T("ps_2_a");
- break;
- default :
- s.target = _T("ps_2_0");
- break;
- }
- s.srcdata = CString(srcdata);
- m_shaders.AddTail(s);
- }
- }
-
- // CASIMIR666 : nouveaux settings
- fD3DFullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, FALSE);
- fMonitorAutoRefreshRate = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, FALSE);
-
- dBrightness = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, _T("1")));
- dContrast = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, _T("1")));
- dHue = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, _T("0")));
- dSaturation = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, _T("1")));
- strShaderList = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, _T(""));
- strShaderListScreenSpace = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, _T(""));
- m_bToggleShader = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, 0);
- m_bToggleShaderScreenSpace = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, 0);
-
- iEvrBuffers = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, 5);
- fShowOSD = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, 1);
- fEnableEDLEditor = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, FALSE);
-
- // Save analog capture settings
- iDefaultCaptureDevice = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, 0);
- strAnalogVideo = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, _T(""));
- strAnalogAudio = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, _T(""));
- iAnalogCountry = pApp->GetProfileInt(IDS_RS_CAPTURE, IDS_RS_COUNTRY, 1);
-
- BDANetworkProvider = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, _T(""));
- BDATuner = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, _T(""));
- BDAReceiver = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, _T(""));
- DVBLastChannel = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, 1);
-
- for(int iChannel = 0; ; iChannel++)
- {
- CString strTemp;
- CString strChannel;
- CDVBChannel Channel;
- strTemp.Format(_T("%d"), iChannel);
- strChannel = pApp->GetProfileString(IDS_RS_DVB, strTemp, _T(""));
- if(strChannel.IsEmpty()) break;
- Channel.FromString(strChannel);
- DVBChannels.AddTail(Channel);
- }
-
- // Position de lecture des derniers DVD's
- fRememberDVDPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, 0);
- nCurrentDvdPosition = -1;
- memset(DvdPosition, 0, sizeof(DvdPosition));
- for(int i = 0; i < MAX_DVD_POSITION; i++)
- {
- CString strDVDPos;
- CString strValue;
-
- strDVDPos.Format(_T("DVD Position %d"), i);
- strValue = pApp->GetProfileString(IDS_R_SETTINGS, strDVDPos, _T(""));
- if(strValue.GetLength() / 2 == sizeof(DVD_POSITION))
- {
- DeserializeHex(strValue, (BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
- }
- }
-
- // Position de lecture des derniers fichiers
- fRememberFilePos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, 0);
- nCurrentFilePosition = -1;
- for(int i = 0; i < MAX_FILE_POSITION; i++)
- {
- CString strFilePos;
- CString strValue;
-
- strFilePos.Format(_T("File Name %d"), i);
- FilePosition[i].strFile = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
-
- strFilePos.Format(_T("File Position %d"), i);
- strValue = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
- FilePosition[i].llPosition = _tstoi64(strValue);
- }
-
- fLastFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, 0);
-
- // CASIMIR666 : fin nouveaux settings
-
-
- // TODO: sort shaders by label
-
- m_shadercombine = pApp->GetProfileString(_T("Shaders"), _T("Combine"), _T(""));
- m_shadercombineScreenSpace = pApp->GetProfileString(_T("Shaders"), _T("CombineScreenSpace"), _T(""));
-
- if(launchfullscreen) nCLSwitches |= CLSW_FULLSCREEN;
-
- fInitialized = true;
- }
+ iDX9Resizer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, 1);
+ fVMR9MixerMode = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, TRUE);
+ fVMR9MixerYUV = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, FALSE);
+ CRendererSettingsEVR DefaultSettings;
+ m_RenderSettings.fVMR9AlterativeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), DefaultSettings.fVMR9AlterativeVSync);
+ m_RenderSettings.iVMR9VSyncOffset = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), DefaultSettings.iVMR9VSyncOffset);
+ m_RenderSettings.iVMR9VSyncAccurate = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), DefaultSettings.iVMR9VSyncAccurate);
+ m_RenderSettings.iVMR9FullscreenGUISupport = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), DefaultSettings.iVMR9FullscreenGUISupport);
+ m_RenderSettings.iEVRHighColorResolution = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), DefaultSettings.iEVRHighColorResolution);
+ m_RenderSettings.iEVREnableFrameTimeCorrection = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), DefaultSettings.iEVREnableFrameTimeCorrection);
+ m_RenderSettings.iVMR9VSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), DefaultSettings.iVMR9VSync);
+ m_RenderSettings.iVMRDisableDesktopComposition = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), DefaultSettings.iVMRDisableDesktopComposition);
+
+ m_RenderSettings.iEVROutputRange = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), DefaultSettings.iEVROutputRange);
+
+ m_RenderSettings.iVMRFlushGPUBeforeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), DefaultSettings.iVMRFlushGPUBeforeVSync);
+ m_RenderSettings.iVMRFlushGPUAfterPresent = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), DefaultSettings.iVMRFlushGPUAfterPresent);
+ m_RenderSettings.iVMRFlushGPUWait = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), DefaultSettings.iVMRFlushGPUWait);
+
+ m_RenderSettings.bSynchronizeVideo = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), DefaultSettings.bSynchronizeVideo);
+ m_RenderSettings.bSynchronizeDisplay = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), DefaultSettings.bSynchronizeDisplay);
+ m_RenderSettings.bSynchronizeNearest = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), DefaultSettings.bSynchronizeNearest);
+ m_RenderSettings.iLineDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("LineDelta"), DefaultSettings.iLineDelta);
+ m_RenderSettings.iColumnDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), DefaultSettings.iColumnDelta);
+
+ double *dPtr;
+ UINT dSize;
+ if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE*)&dPtr, &dSize))
+ {
+ m_RenderSettings.fCycleDelta = *dPtr;
+ delete [] dPtr;
+ }
+
+ if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE*)&dPtr, &dSize))
+ {
+ m_RenderSettings.fTargetSyncOffset = *dPtr;
+ delete [] dPtr;
+ }
+ if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE*)&dPtr, &dSize))
+ {
+ m_RenderSettings.fControlLimit = *dPtr;
+ delete [] dPtr;
+ }
+
+ fResetDevice = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), TRUE);
+
+ AudioRendererDisplayName = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, _T(""));
+ fAutoloadAudio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, TRUE);
+ fAutoloadSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, !IsVSFilterInstalled() || (IsVistaOrAbove() && HasEVR()) );
+ m_subtitlesLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
+ m_audiosLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
+ fBlockVSFilter = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, TRUE);
+ fEnableWorkerThreadForOpening = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, TRUE);
+ fReportFailedPins = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, TRUE);
+ fAllowMultipleInst = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, 0);
+ iTitleBarTextStyle = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, 1);
+ fTitleBarTextTitle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, FALSE);
+ iOnTop = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, 0);
+ fTrayIcon = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, 0);
+ fRememberZoomLevel = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, 1);
+ fShowBarsWhenFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, 1);
+ nShowBarsWhenFullScreenTimeOut = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, 0);
+
+ //Multi-monitor code
+ f_hmonitor = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, _T(""));
+ // Prevent Minimize when in Fullscreen mode on non default monitor
+ m_fPreventMinimize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, 0);
+ m_fUseWin7TaskBar = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, 1);
+ m_fExitAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, 0);
+ m_fNextInDirAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, 0);
+ m_fDontUseSearchInFolder = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, 0);
+ nOSD_Size = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, 20);
+ m_OSD_Font= pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, _T("Arial"));
+
+ // Associated types with icon or not...
+ fAssociatedWithIcons = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, 1);
+ // Last Open Dir
+ f_lastOpenDir = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, _T("C:\\"));
+
+ if ( pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, &ptr, &len) )
+ {
+ if ( len == sizeof(AChFR) )
+ memcpy( &AutoChangeFullscrRes, ptr, sizeof(AChFR) );
+ else
+ AutoChangeFullscrRes.bEnabled = false;
+ delete [] ptr;
+ }
+ else
+ {
+ AutoChangeFullscrRes.bEnabled = false;
+ }
+
+ fExitFullScreenAtTheEnd = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, 1);
+ fRestoreResAfterExit = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("RestoreResAfterExit"), 1);
+ fRememberWindowPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, 0);
+ fRememberWindowSize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, 0);
+ fSnapToDesktopEdges = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, 0);
+ AspectRatio.cx = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, 0);
+ AspectRatio.cy = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, 0);
+ fKeepHistory = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, 1);
+ if ( pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, &ptr, &len) )
+ {
+ if ( len == sizeof(CRect) )
+ memcpy( &rcLastWindowPos, ptr, sizeof(CRect) );
+ else
+ fRememberWindowPos = false;
+ delete [] ptr;
+ }
+ else
+ {
+ fRememberWindowPos = false;
+ }
+ lastWindowType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, SIZE_RESTORED);
+ sDVDPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, _T(""));
+ fUseDVDPath = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, 0);
+ idMenuLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, ::GetUserDefaultLCID());
+ idAudioLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, ::GetUserDefaultLCID());
+ idSubtitlesLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, ::GetUserDefaultLCID());
+ fAutoSpeakerConf = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, 1);
+ // TODO: rename subdefstyle -> defStyle, IDS_RS_SPLOGFONT -> IDS_RS_SPSTYLE
+ subdefstyle <<= pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, _T(""));
+ fOverridePlacement = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, 0);
+ nHorPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, 50);
+ nVerPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, 90);
+ nSPCSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, 3);
+ nSPCMaxRes = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, 2);
+ nSubDelayInterval = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, 500);
+ fSPCPow2Tex = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, TRUE);
+
+ bool bAllowAnimationWhenBuffering = true;
+ SYSTEM_INFO SysInfo;
+ GetSystemInfo(&SysInfo);
+ if (SysInfo.dwNumberOfProcessors < 3)
+ bAllowAnimationWhenBuffering = false;
+
+
+ fSPCAllowAnimationWhenBuffering = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), bAllowAnimationWhenBuffering);
+ fEnableSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, TRUE);
+ fUseDefaultSubtitlesStyle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, FALSE);
+ fEnableAudioSwitcher = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, TRUE);
+ fAudioTimeShift = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, 0);
+ tAudioTimeShift = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, 0);
+ fDownSampleTo441 = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, 0);
+ fCustomChannelMapping = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, 0);
+
+ BOOL bResult = pApp->GetProfileBinary( IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, &ptr, &len );
+ if ( bResult && len == sizeof(pSpeakerToChannelMap) )
+ {
+ memcpy( pSpeakerToChannelMap, ptr, sizeof(pSpeakerToChannelMap) );
+ }
+ else
+ {
+ memset(pSpeakerToChannelMap, 0, sizeof(pSpeakerToChannelMap));
+ for(int j = 0; j < 18; j++)
+ for(int i = 0; i <= j; i++)
+ pSpeakerToChannelMap[j][i] = 1<<i;
+
+ pSpeakerToChannelMap[0][0] = 1<<0;
+ pSpeakerToChannelMap[0][1] = 1<<0;
+
+ pSpeakerToChannelMap[3][0] = 1<<0;
+ pSpeakerToChannelMap[3][1] = 1<<1;
+ pSpeakerToChannelMap[3][2] = 0;
+ pSpeakerToChannelMap[3][3] = 0;
+ pSpeakerToChannelMap[3][4] = 1<<2;
+ pSpeakerToChannelMap[3][5] = 1<<3;
+
+ pSpeakerToChannelMap[4][0] = 1<<0;
+ pSpeakerToChannelMap[4][1] = 1<<1;
+ pSpeakerToChannelMap[4][2] = 1<<2;
+ pSpeakerToChannelMap[4][3] = 0;
+ pSpeakerToChannelMap[4][4] = 1<<3;
+ pSpeakerToChannelMap[4][5] = 1<<4;
+ }
+ if ( bResult )
+ delete [] ptr;
+
+ fAudioNormalize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, FALSE);
+ fAudioNormalizeRecover = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, TRUE);
+ AudioBoost = (float)pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, 1);
+ fnChannels = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, 2);
+
+ {
+ for(int i = 0; ; i++)
+ {
+ CString key;
+ key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
+
+ CAutoPtr<FilterOverride> f(DNew FilterOverride);
+
+ f->fDisabled = !pApp->GetProfileInt(key, _T("Enabled"), 0);
+
+ UINT j = pApp->GetProfileInt(key, _T("SourceType"), -1);
+ if(j == 0)
+ {
+ f->type = FilterOverride::REGISTERED;
+ f->dispname = CStringW(pApp->GetProfileString(key, _T("DisplayName"), _T("")));
+ f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
+ }
+ else if(j == 1)
+ {
+ f->type = FilterOverride::EXTERNAL;
+ f->path = pApp->GetProfileString(key, _T("Path"), _T(""));
+ f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
+ f->clsid = GUIDFromCString(pApp->GetProfileString(key, _T("CLSID"), _T("")));
+ }
+ else
+ {
+ pApp->WriteProfileString(key, NULL, 0);
+ break;
+ }
+
+ f->backup.RemoveAll();
+ for(int i = 0; ; i++)
+ {
+ CString val;
+ val.Format(_T("org%04d"), i);
+ CString guid = pApp->GetProfileString(key, val, _T(""));
+ if(guid.IsEmpty()) break;
+ f->backup.AddTail(GUIDFromCString(guid));
+ }
+
+ f->guids.RemoveAll();
+ for(int i = 0; ; i++)
+ {
+ CString val;
+ val.Format(_T("mod%04d"), i);
+ CString guid = pApp->GetProfileString(key, val, _T(""));
+ if(guid.IsEmpty()) break;
+ f->guids.AddTail(GUIDFromCString(guid));
+ }
+
+ f->iLoadType = (int)pApp->GetProfileInt(key, _T("LoadType"), -1);
+ if(f->iLoadType < 0) break;
+
+ f->dwMerit = pApp->GetProfileInt(key, _T("Merit"), MERIT_DO_NOT_USE+1);
+
+ filters.AddTail(f);
+ }
+ }
+
+ fIntRealMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, 0);
+ //fRealMediaRenderless = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, 0);
+ //iQuickTimeRenderer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, 2);
+ RealMediaQuickTimeFPS = 25.0;
+ *((DWORD*)&RealMediaQuickTimeFPS) = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&RealMediaQuickTimeFPS));
+
+ m_pnspresets.RemoveAll();
+ for(int i = 0; i < (ID_PANNSCAN_PRESETS_END - ID_PANNSCAN_PRESETS_START); i++)
+ {
+ CString str;
+ str.Format(_T("Preset%d"), i);
+ str = pApp->GetProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, _T(""));
+ if(str.IsEmpty()) break;
+ m_pnspresets.Add(str);
+ }
+ if(m_pnspresets.IsEmpty())
+ {
+ double _4p3 = 4.0/3.0;
+ double _16p9 = 16.0/9.0;
+ double _185p1 = 1.85/1.0;
+ double _235p1 = 2.35/1.0;
+
+ CString str;
+ str.Format(ResStr(IDS_SCALE_16_9), 0.5, 0.5, _4p3/_4p3, _16p9/_4p3);
+ m_pnspresets.Add(str);
+ str.Format(ResStr(IDS_SCALE_WIDESCREEN), 0.5, 0.5, _16p9/_4p3, _16p9/_4p3);
+ m_pnspresets.Add(str);
+ str.Format(ResStr(IDS_SCALE_ULTRAWIDE), 0.5, 0.5, _235p1/_4p3, _235p1/_4p3);
+ m_pnspresets.Add(str);
+ }
+
+ for(int i = 0; i < wmcmds.GetCount(); i++)
+ {
+ CString str;
+ str.Format(_T("CommandMod%d"), i);
+ str = pApp->GetProfileString(IDS_R_COMMANDS, str, _T(""));
+ if(str.IsEmpty()) break;
+ int cmd, fVirt, key, repcnt, mouse, appcmd;
+ TCHAR buff[128];
+ int n;
+ if(5 > (n = _stscanf_s(str, _T("%d %x %x %s %d %d %d"), &cmd, &fVirt, &key, buff, countof(buff), &repcnt, &mouse, &appcmd)))
+ break;
+ if(POSITION pos = wmcmds.Find(cmd))
+ {
+ wmcmd& wc = wmcmds.GetAt(pos);
+ wc.cmd = cmd;
+ wc.fVirt = fVirt;
+ wc.key = key;
+ if(n >= 6) wc.mouse = (UINT)mouse;
+ if(n >= 7) wc.appcmd = (UINT)appcmd;
+ wc.rmcmd = CStringA(buff).Trim('\"');
+ wc.rmrepcnt = repcnt;
+ }
+ }
+
+ CAtlArray<ACCEL> pAccel;
+ pAccel.SetCount(wmcmds.GetCount());
+ POSITION pos = wmcmds.GetHeadPosition();
+ for(int i = 0; pos; i++) pAccel[i] = wmcmds.GetNext(pos);
+ hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
+
+ WinLircAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, _T("127.0.0.1:8765"));
+ fWinLirc = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, 0);
+ UIceAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, _T("127.0.0.1:1234"));
+ fUIce = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, 0);
+ fGlobalMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, 0);
+
+ fDisableXPToolbars = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEXPTOOLBARS, 0);
+ fUseWMASFReader = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEWMASFREADER, FALSE);
+ nJumpDistS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, 1000);
+ nJumpDistM = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, 5000);
+ nJumpDistL = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, 20000);
+ fLimitWindowProportions = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, FALSE);
+ fNotifyMSN = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, FALSE);
+ fNotifyGTSdll = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYGTSDLL, FALSE);
+
+ Formats.UpdateData(false);
+
+ SrcFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_SRCFILTERS, ~0);
+ TraFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_TRAFILTERS, ~0);
+ DXVAFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_DXVAFILTERS, ~0);
+ FFmpegFilters = pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, IDS_RS_FFMPEGFILTERS, ~0);
+
+ logofn = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, _T(""));
+ logoid = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, IDF_LOGO4);
+ logoext = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, 0);
+
+ fHideCDROMsSubMenu = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, 0);
+
+ priority = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, NORMAL_PRIORITY_CLASS);
+ ::SetPriorityClass(::GetCurrentProcess(), priority);
+ launchfullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, FALSE);
+
+ fEnableWebServer = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, FALSE);
+ nWebServerPort = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, 13579);
+ fWebServerPrintDebugInfo = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, FALSE);
+ fWebServerUseCompression = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, TRUE);
+ fWebServerLocalhostOnly = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, FALSE);
+ WebRoot = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, _T("*./webroot"));
+ WebDefIndex = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, _T("index.html;index.php"));
+ WebServerCGI = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, _T(""));
+
+ CString MyPictures;
+
+ CRegKey key;
+ // grrrrr
+ // if(!SHGetSpecialFolderPath(NULL, MyPictures.GetBufferSetLength(MAX_PATH), CSIDL_MYPICTURES, TRUE)) MyPictures.Empty();
+ // else MyPictures.ReleaseBuffer();
+ if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ))
+ {
+ ULONG len = MAX_PATH;
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("My Pictures"), MyPictures.GetBuffer(MAX_PATH), &len)) MyPictures.ReleaseBufferSetLength(len);
+ else MyPictures.Empty();
+ }
+ SnapShotPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, MyPictures);
+ SnapShotExt = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, _T(".jpg"));
+
+ ThumbRows = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, 4);
+ ThumbCols = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, 4);
+ ThumbWidth = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, 1024);
+
+ ISDb = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, _T("www.opensubtitles.org/isdb"));
+
+ D3D9RenderDevice = pApp->GetProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, _T(""));
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("LastUsedPage"), 0);
+
+ //
+
+ m_shaders.RemoveAll();
+
+ CAtlStringMap<UINT> shaders;
+
+ shaders[_T("16-235 -> 0-255 [SD][HD]")] = IDF_SHADER_LEVELS;
+ shaders[_T("16-235 -> 0-255 [SD]")] = IDF_SHADER_LEVELS2;
+ shaders[_T("0-255 -> 16-235")] = IDF_SHADER_LEVELS3;
+ shaders[_T("BT.601 -> BT.709")] = IDF_SHADER_BT601_BT709;
+ shaders[_T("contour")] = IDF_SHADER_CONTOUR;
+ shaders[_T("deinterlace (blend)")] = IDF_SHADER_DEINTERLACE;
+ shaders[_T("edge sharpen")] = IDF_SHADER_EDGE_SHARPEN;
+ shaders[_T("emboss")] = IDF_SHADER_EMBOSS;
+ shaders[_T("grayscale")] = IDF_SHADER_GRAYSCALE;
+ shaders[_T("invert")] = IDF_SHADER_INVERT;
+ shaders[_T("letterbox")] = IDF_SHADER_LETTERBOX;
+ shaders[_T("nightvision")] = IDF_SHADER_NIGHTVISION;
+ shaders[_T("procamp")] = IDF_SHADER_PROCAMP;
+ shaders[_T("sharpen")] = IDF_SHADER_SHARPEN;
+ shaders[_T("sharpen complex")] = IDF_SHADER_SHARPEN_COMPLEX;
+ shaders[_T("sharpen complex 2")] = IDF_SHADER_SHARPEN_COMPLEX2;
+ shaders[_T("sphere")] = IDF_SHADER_SPHERE;
+ shaders[_T("spotlight")] = IDF_SHADER_SPOTLIGHT;
+ shaders[_T("wave")] = IDF_SHADER_WAVE;
+ shaders[_T("denoise")] = IDF_SHADER_DENOISE;
+ shaders[_T("YV12 Chroma Upsampling")] = IDF_SHADER_YV12CHROMAUP;
+
+ int iShader = 0;
+
+ for(; ; iShader++)
+ {
+ CString str;
+ str.Format(_T("%d"), iShader);
+ str = pApp->GetProfileString(_T("Shaders"), str);
+
+ CAtlList<CString> sl;
+ CString label = Explode(str, sl, '|');
+ if(label.IsEmpty()) break;
+ if(sl.GetCount() < 3) continue;
+
+ Shader s;
+ s.label = sl.RemoveHead();
+ s.target = sl.RemoveHead();
+ s.srcdata = sl.RemoveHead();
+ s.srcdata.Replace(_T("\\n"), _T("\n"));
+ s.srcdata.Replace(_T("\\t"), _T("\t"));
+ m_shaders.AddTail(s);
+
+ shaders.RemoveKey(s.label);
+ }
+
+ pos = shaders.GetStartPosition();
+ for(; pos; iShader++)
+ {
+ CAtlStringMap<UINT>::CPair* pPair = shaders.GetNext(pos);
+
+ CStringA srcdata;
+ if(LoadResource(pPair->m_value, srcdata, _T("FILE")))
+ {
+ Shader s;
+ s.label = pPair->m_key;
+
+ // Select minimum version for each shader!
+ switch (pPair->m_value)
+ {
+ case IDF_SHADER_DENOISE :
+ s.target = _T("ps_3_0");
+ break;
+ case IDF_SHADER_SHARPEN_COMPLEX2 :
+ s.target = _T("ps_2_a");
+ break;
+ default :
+ s.target = _T("ps_2_0");
+ break;
+ }
+ s.srcdata = CString(srcdata);
+ m_shaders.AddTail(s);
+ }
+ }
+
+ // CASIMIR666 : nouveaux settings
+ fD3DFullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, FALSE);
+ fMonitorAutoRefreshRate = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, FALSE);
+
+ dBrightness = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, _T("1")));
+ dContrast = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, _T("1")));
+ dHue = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, _T("0")));
+ dSaturation = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, _T("1")));
+ strShaderList = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, _T(""));
+ strShaderListScreenSpace = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, _T(""));
+ m_bToggleShader = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, 0);
+ m_bToggleShaderScreenSpace = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, 0);
+
+ iEvrBuffers = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, 5);
+ fShowOSD = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, 1);
+ fEnableEDLEditor= !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, FALSE);
+
+ // Save analog capture settings
+ iDefaultCaptureDevice = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, 0);
+ strAnalogVideo = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, _T(""));
+ strAnalogAudio = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, _T(""));
+ iAnalogCountry = pApp->GetProfileInt(IDS_RS_CAPTURE, IDS_RS_COUNTRY, 1);
+
+ BDANetworkProvider = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, _T(""));
+ BDATuner = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, _T(""));
+ BDAReceiver = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, _T(""));
+ DVBLastChannel = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, 1);
+
+ for(int iChannel = 0; ; iChannel++)
+ {
+ CString strTemp;
+ CString strChannel;
+ CDVBChannel Channel;
+ strTemp.Format(_T("%d"), iChannel);
+ strChannel = pApp->GetProfileString(IDS_RS_DVB, strTemp, _T(""));
+ if (strChannel.IsEmpty()) break;
+ Channel.FromString(strChannel);
+ DVBChannels.AddTail (Channel);
+ }
+
+ // Position de lecture des derniers DVD's
+ fRememberDVDPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, 0);
+ nCurrentDvdPosition = -1;
+ memset (DvdPosition, 0, sizeof(DvdPosition));
+ for (int i=0; i<MAX_DVD_POSITION; i++)
+ {
+ CString strDVDPos;
+ CString strValue;
+
+ strDVDPos.Format (_T("DVD Position %d"), i);
+ strValue = pApp->GetProfileString(IDS_R_SETTINGS, strDVDPos, _T(""));
+ if (strValue.GetLength()/2 == sizeof(DVD_POSITION))
+ {
+ DeserializeHex(strValue, (BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
+ }
+ }
+
+ // Position de lecture des derniers fichiers
+ fRememberFilePos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, 0);
+ nCurrentFilePosition = -1;
+ for (int i=0; i<MAX_FILE_POSITION; i++)
+ {
+ CString strFilePos;
+ CString strValue;
+
+ strFilePos.Format (_T("File Name %d"), i);
+ FilePosition[i].strFile = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
+
+ strFilePos.Format (_T("File Position %d"), i);
+ strValue = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
+ FilePosition[i].llPosition = _tstoi64 (strValue);
+ }
+
+ fLastFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, 0);
+
+ // CASIMIR666 : fin nouveaux settings
+
+
+ // TODO: sort shaders by label
+
+ m_shadercombine = pApp->GetProfileString(_T("Shaders"), _T("Combine"), _T(""));
+ m_shadercombineScreenSpace = pApp->GetProfileString(_T("Shaders"), _T("CombineScreenSpace"), _T(""));
+
+ if(launchfullscreen) nCLSwitches |= CLSW_FULLSCREEN;
+
+ fInitialized = true;
+ }
}
__int64 CMPlayerCApp::Settings::ConvertTimeToMSec(CString& time)
{
- __int64 Sec = 0;
- __int64 mSec = 0;
- __int64 mult = 1;
-
- int pos = time.GetLength() - 1;
- if(pos < 3) return 0;
-
- while(pos >= 0)
- {
- TCHAR ch = time[pos];
- if(ch == '.')
- {
- mSec = Sec * 1000 / mult;
- Sec = 0;
- mult = 1;
- }
- else if(ch == ':')
- {
- mult = mult * 6 / 10;
- }
- else if(ch >= '0' && ch <= '9')
- {
- Sec += (ch - '0') * mult;
- mult *= 10;
- }
- else
- {
- mSec = Sec = 0;
- break;
- }
- pos--;
- }
- return Sec * 1000 + mSec;
+ __int64 Sec = 0;
+ __int64 mSec = 0;
+ __int64 mult = 1;
+
+ int pos = time.GetLength() - 1;
+ if (pos < 3) return 0;
+
+ while (pos >= 0) {
+ TCHAR ch = time[pos];
+ if (ch == '.') {
+ mSec = Sec * 1000 / mult;
+ Sec = 0;
+ mult = 1;
+ } else if (ch == ':') {
+ mult = mult * 6 / 10;
+ } else if (ch >= '0' && ch <= '9') {
+ Sec += (ch - '0') * mult;
+ mult *= 10;
+ } else {
+ mSec = Sec = 0;
+ break;
+ }
+ pos--;
+ }
+ return Sec*1000 + mSec;
}
void CMPlayerCApp::Settings::ExtractDVDStartPos(CString& strParam)
{
- int i = 0, j = 0;
- for(CString token = strParam.Tokenize(_T("#"), i);
- j < 3 && !token.IsEmpty();
- token = strParam.Tokenize(_T("#"), i), j++)
- {
- switch(j)
- {
- case 0 :
- lDVDTitle = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
- break;
- case 1 :
- if(token.Find(':') > 0)
- _stscanf_s(token, _T("%02d:%02d:%02d.%03d"), &DVDPosition.bHours, &DVDPosition.bMinutes, &DVDPosition.bSeconds, &DVDPosition.bFrames);
- else
- lDVDChapter = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
- break;
- }
- }
+ int i = 0, j = 0;
+ for(CString token = strParam.Tokenize(_T("#"), i);
+ j < 3 && !token.IsEmpty();
+ token = strParam.Tokenize(_T("#"), i), j++)
+ {
+ switch (j)
+ {
+ case 0 :
+ lDVDTitle = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
+ break;
+ case 1 :
+ if (token.Find(':') >0)
+ _stscanf_s(token, _T("%02d:%02d:%02d.%03d"), &DVDPosition.bHours, &DVDPosition.bMinutes, &DVDPosition.bSeconds, &DVDPosition.bFrames);
+ else
+ lDVDChapter = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
+ break;
+ }
+ }
}
void CMPlayerCApp::Settings::ParseCommandLine(CAtlList<CString>& cmdln)
{
- nCLSwitches = 0;
- slFiles.RemoveAll();
- slDubs.RemoveAll();
- slSubs.RemoveAll();
- slFilters.RemoveAll();
- rtStart = 0;
- rtShift = 0;
- lDVDTitle = 0;
- lDVDChapter = 0;
- memset(&DVDPosition, 0, sizeof(DVDPosition));
- iAdminOption = 0;
- fixedWindowSize.SetSize(0, 0);
- iMonitor = 0;
- hMasterWnd = 0;
- sPnSPreset.Empty();
-
- POSITION pos = cmdln.GetHeadPosition();
- while(pos)
- {
- CString param = cmdln.GetNext(pos);
- if(param.IsEmpty()) continue;
-
- if((param[0] == '-' || param[0] == '/') && param.GetLength() > 1)
- {
- CString sw = param.Mid(1).MakeLower();
- if(sw == _T("open")) nCLSwitches |= CLSW_OPEN;
- else if(sw == _T("play")) nCLSwitches |= CLSW_PLAY;
- else if(sw == _T("fullscreen")) nCLSwitches |= CLSW_FULLSCREEN;
- else if(sw == _T("minimized")) nCLSwitches |= CLSW_MINIMIZED;
- else if(sw == _T("new")) nCLSwitches |= CLSW_NEW;
- else if(sw == _T("help") || sw == _T("h") || sw == _T("?")) nCLSwitches |= CLSW_HELP;
- else if(sw == _T("dub") && pos) slDubs.AddTail(cmdln.GetNext(pos));
- else if(sw == _T("dubdelay") && pos)
- {
- CString strFile = cmdln.GetNext(pos);
- int nPos = strFile.Find(_T("DELAY"));
- if(nPos != -1)
- rtShift = 10000 * _tstol(strFile.Mid(nPos + 6));
- slDubs.AddTail(strFile);
- }
- else if(sw == _T("sub") && pos) slSubs.AddTail(cmdln.GetNext(pos));
- else if(sw == _T("filter") && pos) slFilters.AddTail(cmdln.GetNext(pos));
- else if(sw == _T("dvd")) nCLSwitches |= CLSW_DVD;
- else if(sw == _T("dvdpos")) ExtractDVDStartPos(cmdln.GetNext(pos));
- else if(sw == _T("cd")) nCLSwitches |= CLSW_CD;
- else if(sw == _T("add")) nCLSwitches |= CLSW_ADD;
- else if(sw == _T("regvid")) nCLSwitches |= CLSW_REGEXTVID;
- else if(sw == _T("regaud")) nCLSwitches |= CLSW_REGEXTAUD;
- else if(sw == _T("unregall")) nCLSwitches |= CLSW_UNREGEXT;
- else if(sw == _T("unregvid")) nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
- else if(sw == _T("unregaud")) nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
- else if(sw == _T("start") && pos)
- {
- rtStart = 10000i64 * _tcstol(cmdln.GetNext(pos), NULL, 10);
- nCLSwitches |= CLSW_STARTVALID;
- }
- else if(sw == _T("startpos") && pos)
- {
- rtStart = 10000i64 * ConvertTimeToMSec(cmdln.GetNext(pos));
- nCLSwitches |= CLSW_STARTVALID;
- }
- else if(sw == _T("nofocus")) nCLSwitches |= CLSW_NOFOCUS;
- else if(sw == _T("close")) nCLSwitches |= CLSW_CLOSE;
- else if(sw == _T("standby")) nCLSwitches |= CLSW_STANDBY;
- else if(sw == _T("hibernate")) nCLSwitches |= CLSW_HIBERNATE;
- else if(sw == _T("shutdown")) nCLSwitches |= CLSW_SHUTDOWN;
- else if(sw == _T("logoff")) nCLSwitches |= CLSW_LOGOFF;
- else if(sw == _T("d3dfs")) nCLSwitches |= CLSW_D3DFULLSCREEN;
- else if(sw == _T("adminoption"))
- {
- nCLSwitches |= CLSW_ADMINOPTION;
- iAdminOption = _ttoi(cmdln.GetNext(pos));
- }
- else if(sw == _T("slave"))
- {
- nCLSwitches |= CLSW_SLAVE;
- hMasterWnd = (HWND)_ttol(cmdln.GetNext(pos));
- }
- else if(sw == _T("fixedsize") && pos)
- {
- CAtlList<CString> sl;
- Explode(cmdln.GetNext(pos), sl, ',', 2);
- if(sl.GetCount() == 2)
- {
- fixedWindowSize.SetSize(_ttol(sl.GetHead()), _ttol(sl.GetTail()));
- if(fixedWindowSize.cx > 0 && fixedWindowSize.cy > 0)
- nCLSwitches |= CLSW_FIXEDSIZE;
- }
- }
- else if(sw == _T("monitor") && pos)
- {
- iMonitor = _tcstol(cmdln.GetNext(pos), NULL, 10);
- nCLSwitches |= CLSW_MONITOR;
- }
- else if(sw == _T("minidump"))
- {
- CMiniDump::Enable();
- }
- else if(sw == _T("pns")) sPnSPreset = cmdln.GetNext(pos);
- else if(sw == _T("audiorender") && pos)
- {
- SetAudioRender(_ttoi(cmdln.GetNext(pos)));
- }
- else nCLSwitches |= CLSW_HELP | CLSW_UNRECOGNIZEDSWITCH;
- }
- else
- {
- slFiles.AddTail(param);
- }
- }
+ nCLSwitches = 0;
+ slFiles.RemoveAll();
+ slDubs.RemoveAll();
+ slSubs.RemoveAll();
+ slFilters.RemoveAll();
+ rtStart = 0;
+ rtShift = 0;
+ lDVDTitle = 0;
+ lDVDChapter = 0;
+ memset (&DVDPosition, 0, sizeof(DVDPosition));
+ iAdminOption=0;
+ fixedWindowSize.SetSize(0, 0);
+ iMonitor = 0;
+ hMasterWnd = 0;
+ sPnSPreset.Empty();
+
+ POSITION pos = cmdln.GetHeadPosition();
+ while(pos)
+ {
+ CString param = cmdln.GetNext(pos);
+ if(param.IsEmpty()) continue;
+
+ if((param[0] == '-' || param[0] == '/') && param.GetLength() > 1)
+ {
+ CString sw = param.Mid(1).MakeLower();
+ if(sw == _T("open")) nCLSwitches |= CLSW_OPEN;
+ else if(sw == _T("play")) nCLSwitches |= CLSW_PLAY;
+ else if(sw == _T("fullscreen")) nCLSwitches |= CLSW_FULLSCREEN;
+ else if(sw == _T("minimized")) nCLSwitches |= CLSW_MINIMIZED;
+ else if(sw == _T("new")) nCLSwitches |= CLSW_NEW;
+ else if(sw == _T("help") || sw == _T("h") || sw == _T("?")) nCLSwitches |= CLSW_HELP;
+ else if(sw == _T("dub") && pos) slDubs.AddTail(cmdln.GetNext(pos));
+ else if(sw == _T("dubdelay") && pos)
+ {
+ CString strFile = cmdln.GetNext(pos);
+ int nPos = strFile.Find (_T("DELAY"));
+ if (nPos != -1)
+ rtShift = 10000 * _tstol(strFile.Mid(nPos + 6));
+ slDubs.AddTail(strFile);
+ }
+ else if(sw == _T("sub") && pos) slSubs.AddTail(cmdln.GetNext(pos));
+ else if(sw == _T("filter") && pos) slFilters.AddTail(cmdln.GetNext(pos));
+ else if(sw == _T("dvd")) nCLSwitches |= CLSW_DVD;
+ else if(sw == _T("dvdpos")) ExtractDVDStartPos(cmdln.GetNext(pos));
+ else if(sw == _T("cd")) nCLSwitches |= CLSW_CD;
+ else if(sw == _T("add")) nCLSwitches |= CLSW_ADD;
+ else if(sw == _T("regvid")) nCLSwitches |= CLSW_REGEXTVID;
+ else if(sw == _T("regaud")) nCLSwitches |= CLSW_REGEXTAUD;
+ else if(sw == _T("unregall")) nCLSwitches |= CLSW_UNREGEXT;
+ else if(sw == _T("unregvid")) nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
+ else if(sw == _T("unregaud")) nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
+ else if(sw == _T("start") && pos) {rtStart = 10000i64*_tcstol(cmdln.GetNext(pos), NULL, 10); nCLSwitches |= CLSW_STARTVALID;}
+ else if(sw == _T("startpos") && pos) {rtStart = 10000i64 * ConvertTimeToMSec(cmdln.GetNext(pos)); nCLSwitches |= CLSW_STARTVALID;}
+ else if(sw == _T("nofocus")) nCLSwitches |= CLSW_NOFOCUS;
+ else if(sw == _T("close")) nCLSwitches |= CLSW_CLOSE;
+ else if(sw == _T("standby")) nCLSwitches |= CLSW_STANDBY;
+ else if(sw == _T("hibernate")) nCLSwitches |= CLSW_HIBERNATE;
+ else if(sw == _T("shutdown")) nCLSwitches |= CLSW_SHUTDOWN;
+ else if(sw == _T("logoff")) nCLSwitches |= CLSW_LOGOFF;
+ else if(sw == _T("d3dfs")) nCLSwitches |= CLSW_D3DFULLSCREEN;
+ else if(sw == _T("adminoption")) { nCLSwitches |= CLSW_ADMINOPTION; iAdminOption = _ttoi (cmdln.GetNext(pos)); }
+ else if(sw == _T("slave"))
+ {
+ nCLSwitches |= CLSW_SLAVE;
+ hMasterWnd = (HWND)_ttol (cmdln.GetNext(pos));
+ }
+ else if(sw == _T("fixedsize") && pos)
+ {
+ CAtlList<CString> sl;
+ Explode(cmdln.GetNext(pos), sl, ',', 2);
+ if(sl.GetCount() == 2)
+ {
+ fixedWindowSize.SetSize(_ttol(sl.GetHead()), _ttol(sl.GetTail()));
+ if(fixedWindowSize.cx > 0 && fixedWindowSize.cy > 0)
+ nCLSwitches |= CLSW_FIXEDSIZE;
+ }
+ }
+ else if(sw == _T("monitor") && pos) {iMonitor = _tcstol(cmdln.GetNext(pos), NULL, 10); nCLSwitches |= CLSW_MONITOR;}
+ else if(sw == _T("minidump")) { CMiniDump::Enable(); }
+ else if(sw == _T("pns")) sPnSPreset = cmdln.GetNext(pos);
+ else if(sw == _T("audiorender") && pos)
+ {
+ SetAudioRender(_ttoi(cmdln.GetNext(pos)));
+ }
+ else nCLSwitches |= CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH;
+ }
+ else
+ {
+ slFiles.AddTail(param);
+ }
+ }
}
void CMPlayerCApp::Settings::GetFav(favtype ft, CAtlList<CString>& sl)
{
- sl.RemoveAll();
+ sl.RemoveAll();
- CString root;
+ CString root;
- switch(ft)
- {
- case FAV_FILE:
- root = IDS_R_FAVFILES;
- break;
- case FAV_DVD:
- root = IDS_R_FAVDVDS;
- break;
- case FAV_DEVICE:
- root = IDS_R_FAVDEVICES;
- break;
- default:
- return;
- }
+ switch(ft)
+ {
+ case FAV_FILE: root = IDS_R_FAVFILES; break;
+ case FAV_DVD: root = IDS_R_FAVDVDS; break;
+ case FAV_DEVICE: root = IDS_R_FAVDEVICES; break;
+ default: return;
+ }
- for(int i = 0; ; i++)
- {
- CString s;
- s.Format(_T("Name%d"), i);
- s = AfxGetApp()->GetProfileString(root, s, NULL);
- if(s.IsEmpty()) break;
- sl.AddTail(s);
- }
+ for(int i = 0; ; i++)
+ {
+ CString s;
+ s.Format(_T("Name%d"), i);
+ s = AfxGetApp()->GetProfileString(root, s, NULL);
+ if(s.IsEmpty()) break;
+ sl.AddTail(s);
+ }
}
void CMPlayerCApp::Settings::SetFav(favtype ft, CAtlList<CString>& sl)
{
- CString root;
+ CString root;
- switch(ft)
- {
- case FAV_FILE:
- root = IDS_R_FAVFILES;
- break;
- case FAV_DVD:
- root = IDS_R_FAVDVDS;
- break;
- case FAV_DEVICE:
- root = IDS_R_FAVDEVICES;
- break;
- default:
- return;
- }
+ switch(ft)
+ {
+ case FAV_FILE: root = IDS_R_FAVFILES; break;
+ case FAV_DVD: root = IDS_R_FAVDVDS; break;
+ case FAV_DEVICE: root = IDS_R_FAVDEVICES; break;
+ default: return;
+ }
- AfxGetApp()->WriteProfileString(root, NULL, NULL);
+ AfxGetApp()->WriteProfileString(root, NULL, NULL);
- int i = 0;
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- CString s;
- s.Format(_T("Name%d"), i++);
- AfxGetApp()->WriteProfileString(root, s, sl.GetNext(pos));
- }
+ int i = 0;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ CString s;
+ s.Format(_T("Name%d"), i++);
+ AfxGetApp()->WriteProfileString(root, s, sl.GetNext(pos));
+ }
}
void CMPlayerCApp::Settings::AddFav(favtype ft, CString s)
{
- CAtlList<CString> sl;
- GetFav(ft, sl);
- if(sl.Find(s)) return;
- sl.AddTail(s);
- SetFav(ft, sl);
+ CAtlList<CString> sl;
+ GetFav(ft, sl);
+ if(sl.Find(s)) return;
+ sl.AddTail(s);
+ SetFav(ft, sl);
}
CDVBChannel* CMPlayerCApp::Settings::FindChannelByPref(int nPrefNumber)
{
- POSITION pos = DVBChannels.GetHeadPosition();
- while(pos)
- {
- CDVBChannel& Channel = DVBChannels.GetNext(pos);
- if(Channel.GetPrefNumber() == nPrefNumber)
- {
- return &Channel;
- }
- }
+ POSITION pos = DVBChannels.GetHeadPosition();
+ while (pos)
+ {
+ CDVBChannel& Channel = DVBChannels.GetNext (pos);
+ if (Channel.GetPrefNumber() == nPrefNumber)
+ {
+ return &Channel;
+ }
+ }
- return NULL;
+ return NULL;
}
// CMPlayerCApp::Settings::CRecentFileAndURLList
CMPlayerCApp::Settings::CRecentFileAndURLList::CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
- LPCTSTR lpszEntryFormat, int nSize,
- int nMaxDispLen)
- : CRecentFileList(nStart, lpszSection, lpszEntryFormat, nSize, nMaxDispLen)
+ LPCTSTR lpszEntryFormat, int nSize,
+ int nMaxDispLen)
+ : CRecentFileList(nStart, lpszSection, lpszEntryFormat, nSize, nMaxDispLen)
{
}
@@ -2901,151 +2820,151 @@ extern BOOL AFXAPI AfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2);
void CMPlayerCApp::Settings::CRecentFileAndURLList::Add(LPCTSTR lpszPathName)
{
- ASSERT(m_arrNames != NULL);
- ASSERT(lpszPathName != NULL);
- ASSERT(AfxIsValidString(lpszPathName));
+ ASSERT(m_arrNames != NULL);
+ ASSERT(lpszPathName != NULL);
+ ASSERT(AfxIsValidString(lpszPathName));
- if(CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0)
- return;
+ if(CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0)
+ return;
- bool fURL = (CString(lpszPathName).Find(_T("://")) >= 0);
+ bool fURL = (CString(lpszPathName).Find(_T("://")) >= 0);
- // fully qualify the path name
- TCHAR szTemp[1024];
- if(fURL) _tcscpy_s(szTemp, lpszPathName);
- else AfxFullPath(szTemp, lpszPathName);
+ // fully qualify the path name
+ TCHAR szTemp[1024];
+ if(fURL) _tcscpy_s(szTemp, lpszPathName);
+ else AfxFullPath(szTemp, lpszPathName);
- // update the MRU list, if an existing MRU string matches file name
- int iMRU;
- for(iMRU = 0; iMRU < m_nSize - 1; iMRU++)
- {
- if((fURL && !_tcscmp(m_arrNames[iMRU], szTemp))
- || AfxComparePath(m_arrNames[iMRU], szTemp))
- break; // iMRU will point to matching entry
- }
- // move MRU strings before this one down
- for(; iMRU > 0; iMRU--)
- {
- ASSERT(iMRU > 0);
- ASSERT(iMRU < m_nSize);
- m_arrNames[iMRU] = m_arrNames[iMRU-1];
- }
- // place this one at the beginning
- m_arrNames[0] = szTemp;
+ // update the MRU list, if an existing MRU string matches file name
+ int iMRU;
+ for (iMRU = 0; iMRU < m_nSize-1; iMRU++)
+ {
+ if((fURL && !_tcscmp(m_arrNames[iMRU], szTemp))
+ || AfxComparePath(m_arrNames[iMRU], szTemp))
+ break; // iMRU will point to matching entry
+ }
+ // move MRU strings before this one down
+ for (; iMRU > 0; iMRU--)
+ {
+ ASSERT(iMRU > 0);
+ ASSERT(iMRU < m_nSize);
+ m_arrNames[iMRU] = m_arrNames[iMRU-1];
+ }
+ // place this one at the beginning
+ m_arrNames[0] = szTemp;
}
void CMPlayerCApp::OnHelpShowcommandlineswitches()
{
- ShowCmdlnSwitches();
+ ShowCmdlnSwitches();
}
//
void GetCurDispMode(dispmode& dm, CString& DisplayName)
-{
- HDC hDC;
- CString DisplayName1 = DisplayName;
- if((DisplayName == _T("Current")) || (DisplayName == _T("")))
- {
- CMonitor monitor;
- CMonitors monitors;
- monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
- monitor.GetName(DisplayName1);
- }
- if(hDC = CreateDC(DisplayName1, NULL, NULL, NULL))
- {
- dm.fValid = true;
- dm.size = CSize(GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES));
- dm.bpp = GetDeviceCaps(hDC, BITSPIXEL);
- dm.freq = GetDeviceCaps(hDC, VREFRESH);
- DeleteDC(hDC);
- }
-}
+{
+ HDC hDC;
+ CString DisplayName1 = DisplayName;
+ if ((DisplayName == _T("Current")) || (DisplayName == _T("")))
+ {
+ CMonitor monitor;
+ CMonitors monitors;
+ monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
+ monitor.GetName(DisplayName1);
+ }
+ if(hDC = CreateDC(DisplayName1, NULL, NULL, NULL))
+ {
+ dm.fValid = true;
+ dm.size = CSize(GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES));
+ dm.bpp = GetDeviceCaps(hDC, BITSPIXEL);
+ dm.freq = GetDeviceCaps(hDC, VREFRESH);
+ DeleteDC(hDC);
+ }
+}
bool GetDispMode(int i, dispmode& dm, CString& DisplayName)
{
- DEVMODE devmode;
- CString DisplayName1 = DisplayName;
- devmode.dmSize = sizeof(DEVMODE);
- if((DisplayName == _T("Current")) || (DisplayName == _T("")))
- {
- CMonitor monitor;
- CMonitors monitors;
- monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
- monitor.GetName(DisplayName1);
- }
- if(!EnumDisplaySettings(DisplayName1, i, &devmode))
- return(false);
- dm.fValid = true;
- dm.size = CSize(devmode.dmPelsWidth, devmode.dmPelsHeight);
- dm.bpp = devmode.dmBitsPerPel;
- dm.freq = devmode.dmDisplayFrequency;
- dm.dmDisplayFlags = devmode.dmDisplayFlags;
- return(true);
+ DEVMODE devmode;
+ CString DisplayName1 = DisplayName;
+ devmode.dmSize = sizeof(DEVMODE);
+ if ((DisplayName == _T("Current")) || (DisplayName == _T("")))
+ {
+ CMonitor monitor;
+ CMonitors monitors;
+ monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
+ monitor.GetName(DisplayName1);
+ }
+ if(!EnumDisplaySettings(DisplayName1, i, &devmode))
+ return(false);
+ dm.fValid = true;
+ dm.size = CSize(devmode.dmPelsWidth, devmode.dmPelsHeight);
+ dm.bpp = devmode.dmBitsPerPel;
+ dm.freq = devmode.dmDisplayFrequency;
+ dm.dmDisplayFlags = devmode.dmDisplayFlags;
+ return(true);
}
void SetDispMode(dispmode& dm, CString& DisplayName)
{
- dispmode dm1;
- GetCurDispMode(dm1, DisplayName);
- if((dm.size == dm1.size) && (dm.bpp == dm1.bpp) && (dm.freq == dm1.freq)) return;
-
- if(!dm.fValid) return;
- DEVMODE dmScreenSettings;
- memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
- dmScreenSettings.dmSize = sizeof(dmScreenSettings);
- dmScreenSettings.dmPelsWidth = dm.size.cx;
- dmScreenSettings.dmPelsHeight = dm.size.cy;
- dmScreenSettings.dmBitsPerPel = dm.bpp;
- dmScreenSettings.dmDisplayFrequency = dm.freq;
- dmScreenSettings.dmDisplayFlags = dm.dmDisplayFlags;
- dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS;
- CString DisplayName1 = DisplayName;
- if((DisplayName == _T("Current")) || (DisplayName == _T("")))
- {
- CMonitor monitor;
- CMonitors monitors;
- monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
- monitor.GetName(DisplayName1);
- }
- if(AfxGetAppSettings().fRestoreResAfterExit)
- ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, CDS_FULLSCREEN, NULL);
- else
- ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, NULL, NULL);
+ dispmode dm1;
+ GetCurDispMode(dm1, DisplayName);
+ if ((dm.size == dm1.size) && (dm.bpp == dm1.bpp) && (dm.freq == dm1.freq)) return;
+
+ if(!dm.fValid) return;
+ DEVMODE dmScreenSettings;
+ memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
+ dmScreenSettings.dmSize = sizeof(dmScreenSettings);
+ dmScreenSettings.dmPelsWidth = dm.size.cx;
+ dmScreenSettings.dmPelsHeight = dm.size.cy;
+ dmScreenSettings.dmBitsPerPel = dm.bpp;
+ dmScreenSettings.dmDisplayFrequency = dm.freq;
+ dmScreenSettings.dmDisplayFlags = dm.dmDisplayFlags;
+ dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS;
+ CString DisplayName1 = DisplayName;
+ if ((DisplayName == _T("Current")) || (DisplayName == _T("")))
+ {
+ CMonitor monitor;
+ CMonitors monitors;
+ monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
+ monitor.GetName(DisplayName1);
+ }
+ if(AfxGetAppSettings().fRestoreResAfterExit)
+ ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, CDS_FULLSCREEN, NULL);
+ else
+ ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, NULL, NULL);
}
void SetAudioRender(int AudioDevNo)
{
- CStringArray m_AudioRendererDisplayNames;
- m_AudioRendererDisplayNames.Add(_T(""));
- int i = 2;
-
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
- {
- LPOLESTR olestr = NULL;
- if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr)))
- continue;
- CStringW str(olestr);
- CoTaskMemFree(olestr);
- m_AudioRendererDisplayNames.Add(CString(str));
- i++;
- }
- EndEnumSysDev
-
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
- i += 3;
- if(AudioDevNo >= 1 && AudioDevNo <= i)
- {
- AfxGetMyApp()->m_AudioRendererDisplayName_CL = m_AudioRendererDisplayNames[AudioDevNo-1];
- AfxGetAppSettings().nCLSwitches |= CLSW_AUDIORENDER;
- }
+ CStringArray m_AudioRendererDisplayNames;
+ m_AudioRendererDisplayNames.Add(_T(""));
+ int i=2;
+
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
+ {
+ LPOLESTR olestr = NULL;
+ if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr)))
+ continue;
+ CStringW str(olestr);
+ CoTaskMemFree(olestr);
+ m_AudioRendererDisplayNames.Add(CString(str));
+ i++;
+ }
+ EndEnumSysDev
+
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
+ i+=3;
+ if (AudioDevNo>=1 && AudioDevNo<=i)
+ {
+ AfxGetMyApp()->m_AudioRendererDisplayName_CL = m_AudioRendererDisplayNames[AudioDevNo-1];
+ AfxGetAppSettings().nCLSwitches |= CLSW_AUDIORENDER;
+ }
}
void SetHandCursor(HWND m_hWnd, UINT nID)
{
- SetClassLongPtr(GetDlgItem(m_hWnd, nID), GCLP_HCURSOR, (long) AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ SetClassLongPtr(GetDlgItem(m_hWnd, nID), GCLP_HCURSOR, (long) AfxGetApp()->LoadStandardCursor(IDC_HAND));
}
#include <afxsock.h>
@@ -3058,579 +2977,565 @@ typedef CAtlREMatchContext<CAtlRECharTraits> CAtlREMatchContextT;
bool FindRedir(CUrl& src, CString ct, CString& body, CAtlList<CString>& urls, CAutoPtrList<CAtlRegExpT>& res)
{
- POSITION pos = res.GetHeadPosition();
- while(pos)
- {
- CAtlRegExpT* re = res.GetNext(pos);
-
- CAtlREMatchContextT mc;
- const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
- const CAtlREMatchContextT::RECHAR* e = NULL;
- for(; s && re->Match(s, &mc, &e); s = e)
- {
- const CAtlREMatchContextT::RECHAR* szStart = 0;
- const CAtlREMatchContextT::RECHAR* szEnd = 0;
- mc.GetMatch(0, &szStart, &szEnd);
-
- CString url;
- url.Format(_T("%.*s"), szEnd - szStart, szStart);
- url.Trim();
-
- if(url.CompareNoCase(_T("asf path")) == 0) continue;
-
- CUrl dst;
- dst.CrackUrl(CString(url));
- if(_tcsicmp(src.GetSchemeName(), dst.GetSchemeName())
- || _tcsicmp(src.GetHostName(), dst.GetHostName())
- || _tcsicmp(src.GetUrlPath(), dst.GetUrlPath()))
- {
- urls.AddTail(url);
- }
- else
- {
- // recursive
- urls.RemoveAll();
- break;
- }
- }
- }
-
- return urls.GetCount() > 0;
+ POSITION pos = res.GetHeadPosition();
+ while(pos)
+ {
+ CAtlRegExpT* re = res.GetNext(pos);
+
+ CAtlREMatchContextT mc;
+ const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
+ const CAtlREMatchContextT::RECHAR* e = NULL;
+ for(; s && re->Match(s, &mc, &e); s = e)
+ {
+ const CAtlREMatchContextT::RECHAR* szStart = 0;
+ const CAtlREMatchContextT::RECHAR* szEnd = 0;
+ mc.GetMatch(0, &szStart, &szEnd);
+
+ CString url;
+ url.Format(_T("%.*s"), szEnd - szStart, szStart);
+ url.Trim();
+
+ if(url.CompareNoCase(_T("asf path")) == 0) continue;
+
+ CUrl dst;
+ dst.CrackUrl(CString(url));
+ if(_tcsicmp(src.GetSchemeName(), dst.GetSchemeName())
+ || _tcsicmp(src.GetHostName(), dst.GetHostName())
+ || _tcsicmp(src.GetUrlPath(), dst.GetUrlPath()))
+ {
+ urls.AddTail(url);
+ }
+ else
+ {
+ // recursive
+ urls.RemoveAll();
+ break;
+ }
+ }
+ }
+
+ return urls.GetCount() > 0;
}
bool FindRedir(CString& fn, CString ct, CAtlList<CString>& fns, CAutoPtrList<CAtlRegExpT>& res)
{
- CString body;
+ CString body;
- CTextFile f(CTextFile::ANSI);
- if(f.Open(fn)) for(CString tmp; f.ReadString(tmp); body += tmp + '\n');
+ CTextFile f(CTextFile::ANSI);
+ if(f.Open(fn)) for(CString tmp; f.ReadString(tmp); body += tmp + '\n');
- CString dir = fn.Left(max(fn.ReverseFind('/'), fn.ReverseFind('\\')) + 1); // "ReverseFindOneOf"
+ CString dir = fn.Left(max(fn.ReverseFind('/'), fn.ReverseFind('\\'))+1); // "ReverseFindOneOf"
- POSITION pos = res.GetHeadPosition();
- while(pos)
- {
- CAtlRegExpT* re = res.GetNext(pos);
-
- CAtlREMatchContextT mc;
- const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
- const CAtlREMatchContextT::RECHAR* e = NULL;
- for(; s && re->Match(s, &mc, &e); s = e)
- {
- const CAtlREMatchContextT::RECHAR* szStart = 0;
- const CAtlREMatchContextT::RECHAR* szEnd = 0;
- mc.GetMatch(0, &szStart, &szEnd);
-
- CString fn2;
- fn2.Format(_T("%.*s"), szEnd - szStart, szStart);
- fn2.Trim();
-
- if(!fn2.CompareNoCase(_T("asf path"))) continue;
- if(fn2.Find(_T("EXTM3U")) == 0 || fn2.Find(_T("#EXTINF")) == 0) continue;
-
- if(fn2.Find(_T(":")) < 0 && fn2.Find(_T("\\\\")) != 0 && fn2.Find(_T("//")) != 0)
- {
- CPath p;
- p.Combine(dir, fn2);
- fn2 = (LPCTSTR)p;
- }
-
- if(!fn2.CompareNoCase(fn))
- continue;
-
- fns.AddTail(fn2);
- }
- }
+ POSITION pos = res.GetHeadPosition();
+ while(pos)
+ {
+ CAtlRegExpT* re = res.GetNext(pos);
- return fns.GetCount() > 0;
-}
+ CAtlREMatchContextT mc;
+ const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
+ const CAtlREMatchContextT::RECHAR* e = NULL;
+ for(; s && re->Match(s, &mc, &e); s = e)
+ {
+ const CAtlREMatchContextT::RECHAR* szStart = 0;
+ const CAtlREMatchContextT::RECHAR* szEnd = 0;
+ mc.GetMatch(0, &szStart, &szEnd);
-CStringA GetContentType(CString fn, CAtlList<CString>* redir)
-{
- CUrl url;
- CString ct, body;
+ CString fn2;
+ fn2.Format(_T("%.*s"), szEnd - szStart, szStart);
+ fn2.Trim();
- if(fn.Find(_T("://")) >= 0)
- {
- url.CrackUrl(fn);
-
- if(_tcsicmp(url.GetSchemeName(), _T("pnm")) == 0)
- return "audio/x-pn-realaudio";
-
- if(_tcsicmp(url.GetSchemeName(), _T("mms")) == 0)
- return "video/x-ms-asf";
-
- if(_tcsicmp(url.GetSchemeName(), _T("http")) != 0)
- return "";
-
- DWORD ProxyEnable = 0;
- CString ProxyServer;
- DWORD ProxyPort = 0;
-
- ULONG len = 256 + 1;
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), KEY_READ)
- && ERROR_SUCCESS == key.QueryDWORDValue(_T("ProxyEnable"), ProxyEnable) && ProxyEnable
- && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len))
- {
- ProxyServer.ReleaseBufferSetLength(len);
-
- CAtlList<CString> sl;
- ProxyServer = Explode(ProxyServer, sl, ';');
- if(sl.GetCount() > 1)
- {
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- CAtlList<CString> sl2;
- if(!Explode(sl.GetNext(pos), sl2, '=', 2).CompareNoCase(_T("http"))
- && sl2.GetCount() == 2)
- {
- ProxyServer = sl2.GetTail();
- break;
- }
- }
- }
-
- ProxyServer = Explode(ProxyServer, sl, ':');
- if(sl.GetCount() > 1) ProxyPort = _tcstol(sl.GetTail(), NULL, 10);
- }
-
- CSocket s;
- s.Create();
- if(s.Connect(
- ProxyEnable ? ProxyServer : url.GetHostName(),
- ProxyEnable ? ProxyPort : url.GetPortNumber()))
- {
- CStringA host = CStringA(url.GetHostName());
- CStringA path = CStringA(url.GetUrlPath()) + CStringA(url.GetExtraInfo());
-
- if(ProxyEnable) path = "http://" + host + path;
-
- CStringA hdr;
- hdr.Format(
- "GET %s HTTP/1.0\r\n"
- "User-Agent: Media Player Classic\r\n"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "\r\n", path, host);
+ if(!fn2.CompareNoCase(_T("asf path"))) continue;
+ if(fn2.Find(_T("EXTM3U")) == 0 || fn2.Find(_T("#EXTINF")) == 0) continue;
-// MessageBox(NULL, CString(hdr), _T("Sending..."), MB_OK);
+ if(fn2.Find(_T(":")) < 0 && fn2.Find(_T("\\\\")) != 0 && fn2.Find(_T("//")) != 0)
+ {
+ CPath p;
+ p.Combine(dir, fn2);
+ fn2 = (LPCTSTR)p;
+ }
- if(s.Send((LPCSTR)hdr, hdr.GetLength()) < hdr.GetLength()) return "";
-
- hdr.Empty();
- while(1)
- {
- CStringA str;
- str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
- if(str.IsEmpty()) break;
- hdr += str;
- int hdrend = hdr.Find("\r\n\r\n");
- if(hdrend >= 0)
- {
- body = hdr.Mid(hdrend + 4);
- hdr = hdr.Left(hdrend);
- break;
- }
- }
+ if(!fn2.CompareNoCase(fn))
+ continue;
-// MessageBox(NULL, CString(hdr), _T("Received..."), MB_OK);
+ fns.AddTail(fn2);
+ }
+ }
- CAtlList<CStringA> sl;
- Explode(hdr, sl, '\n');
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- CStringA& hdrline = sl.GetNext(pos);
- CAtlList<CStringA> sl2;
- Explode(hdrline, sl2, ':', 2);
- CStringA field = sl2.RemoveHead().MakeLower();
- if(field == "location" && !sl2.IsEmpty())
- return GetContentType(CString(sl2.GetHead()), redir);
- if(field == "content-type" && !sl2.IsEmpty())
- ct = sl2.GetHead();
- }
-
- while(body.GetLength() < 256)
- {
- CStringA str;
- str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
- if(str.IsEmpty()) break;
- body += str;
- }
-
- if(body.GetLength() >= 8)
- {
- CStringA str = TToA(body);
- if(!strncmp((LPCSTR)str, ".ra", 3))
- return "audio/x-pn-realaudio";
- if(!strncmp((LPCSTR)str, ".RMF", 4))
- return "audio/x-pn-realaudio";
- if(*(DWORD*)(LPCSTR)str == 0x75b22630)
- return "video/x-ms-wmv";
- if(!strncmp((LPCSTR)str + 4, "moov", 4))
- return "video/quicktime";
- }
-
- if(redir && (ct == _T("audio/x-scpls") || ct == _T("audio/x-mpegurl")))
- {
- while(body.GetLength() < 4 * 1024) // should be enough for a playlist...
- {
- CStringA str;
- str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
- if(str.IsEmpty()) break;
- body += str;
- }
- }
- }
- }
- else if(!fn.IsEmpty())
- {
- CPath p(fn);
- CString ext = p.GetExtension().MakeLower();
- if(ext == _T(".asx")) ct = _T("video/x-ms-asf");
- else if(ext == _T(".pls")) ct = _T("audio/x-scpls");
- else if(ext == _T(".m3u")) ct = _T("audio/x-mpegurl");
- else if(ext == _T(".qtl")) ct = _T("application/x-quicktimeplayer");
- else if(ext == _T(".mpcpl")) ct = _T("application/x-mpc-playlist");
- else if(ext == _T(".bdmv")) ct = _T("application/x-bdmv-playlist");
-
- if(FILE* f = _tfopen(fn, _T("rb")))
- {
- CStringA str;
- str.ReleaseBufferSetLength(fread(str.GetBuffer(10240), 1, 10240, f));
- body = AToT(str);
- fclose(f);
- }
- }
+ return fns.GetCount() > 0;
+}
- if(body.GetLength() >= 4) // here only those which cannot be opened through dshow
- {
- CStringA str = TToA(body);
- if(!strncmp((LPCSTR)str, ".ra", 3))
- return "audio/x-pn-realaudio";
- if(!strncmp((LPCSTR)str, "FWS", 3))
- return "application/x-shockwave-flash";
+CStringA GetContentType(CString fn, CAtlList<CString>* redir)
+{
+ CUrl url;
+ CString ct, body;
+
+ if(fn.Find(_T("://")) >= 0)
+ {
+ url.CrackUrl(fn);
+
+ if(_tcsicmp(url.GetSchemeName(), _T("pnm")) == 0)
+ return "audio/x-pn-realaudio";
+
+ if(_tcsicmp(url.GetSchemeName(), _T("mms")) == 0)
+ return "video/x-ms-asf";
+
+ if(_tcsicmp(url.GetSchemeName(), _T("http")) != 0)
+ return "";
+
+ DWORD ProxyEnable = 0;
+ CString ProxyServer;
+ DWORD ProxyPort = 0;
+
+ ULONG len = 256+1;
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryDWORDValue(_T("ProxyEnable"), ProxyEnable) && ProxyEnable
+ && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len))
+ {
+ ProxyServer.ReleaseBufferSetLength(len);
+
+ CAtlList<CString> sl;
+ ProxyServer = Explode(ProxyServer, sl, ';');
+ if(sl.GetCount() > 1)
+ {
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ CAtlList<CString> sl2;
+ if(!Explode(sl.GetNext(pos), sl2, '=', 2).CompareNoCase(_T("http"))
+ && sl2.GetCount() == 2)
+ {
+ ProxyServer = sl2.GetTail();
+ break;
+ }
+ }
+ }
+
+ ProxyServer = Explode(ProxyServer, sl, ':');
+ if(sl.GetCount() > 1) ProxyPort = _tcstol(sl.GetTail(), NULL, 10);
+ }
+
+ CSocket s;
+ s.Create();
+ if(s.Connect(
+ ProxyEnable ? ProxyServer : url.GetHostName(),
+ ProxyEnable ? ProxyPort : url.GetPortNumber()))
+ {
+ CStringA host = CStringA(url.GetHostName());
+ CStringA path = CStringA(url.GetUrlPath()) + CStringA(url.GetExtraInfo());
+
+ if(ProxyEnable) path = "http://" + host + path;
+
+ CStringA hdr;
+ hdr.Format(
+ "GET %s HTTP/1.0\r\n"
+ "User-Agent: Media Player Classic\r\n"
+ "Host: %s\r\n"
+ "Accept: */*\r\n"
+ "\r\n", path, host);
- }
+// MessageBox(NULL, CString(hdr), _T("Sending..."), MB_OK);
- if(redir && !ct.IsEmpty())
- {
- CAutoPtrList<CAtlRegExpT> res;
- CAutoPtr<CAtlRegExpT> re;
-
- if(ct == _T("video/x-ms-asf"))
- {
- // ...://..."/>
- re.Attach(DNew CAtlRegExpT());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("{[a-zA-Z]+://[^\n\">]*}"), FALSE))
- res.AddTail(re);
- // Ref#n= ...://...\n
- re.Attach(DNew CAtlRegExpT());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("Ref\\z\\b*=\\b*[\"]*{([a-zA-Z]+://[^\n\"]+}"), FALSE))
- res.AddTail(re);
- }
- else if(ct == _T("audio/x-scpls"))
- {
- // File1=...\n
- re.Attach(DNew CAtlRegExp<>());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("file\\z\\b*=\\b*[\"]*{[^\n\"]+}"), FALSE))
- res.AddTail(re);
- }
- else if(ct == _T("audio/x-mpegurl"))
- {
- // #comment
- // ...
- re.Attach(DNew CAtlRegExp<>());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE))
- res.AddTail(re);
- }
- else if(ct == _T("audio/x-pn-realaudio"))
- {
- // rtsp://...
- re.Attach(DNew CAtlRegExp<>());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("{rtsp://[^\n]+}"), FALSE))
- res.AddTail(re);
- }
-
- if(!body.IsEmpty())
- {
- if(fn.Find(_T("://")) >= 0) FindRedir(url, ct, body, *redir, res);
- else FindRedir(fn, ct, *redir, res);
- }
- }
+ if(s.Send((LPCSTR)hdr, hdr.GetLength()) < hdr.GetLength()) return "";
+
+ hdr.Empty();
+ while(1)
+ {
+ CStringA str;
+ str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
+ if(str.IsEmpty()) break;
+ hdr += str;
+ int hdrend = hdr.Find("\r\n\r\n");
+ if(hdrend >= 0) {body = hdr.Mid(hdrend+4); hdr = hdr.Left(hdrend); break;}
+ }
- return TToA(ct);
+// MessageBox(NULL, CString(hdr), _T("Received..."), MB_OK);
+
+ CAtlList<CStringA> sl;
+ Explode(hdr, sl, '\n');
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ CStringA& hdrline = sl.GetNext(pos);
+ CAtlList<CStringA> sl2;
+ Explode(hdrline, sl2, ':', 2);
+ CStringA field = sl2.RemoveHead().MakeLower();
+ if(field == "location" && !sl2.IsEmpty())
+ return GetContentType(CString(sl2.GetHead()), redir);
+ if(field == "content-type" && !sl2.IsEmpty())
+ ct = sl2.GetHead();
+ }
+
+ while(body.GetLength() < 256)
+ {
+ CStringA str;
+ str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
+ if(str.IsEmpty()) break;
+ body += str;
+ }
+
+ if(body.GetLength() >= 8)
+ {
+ CStringA str = TToA(body);
+ if(!strncmp((LPCSTR)str, ".ra", 3))
+ return "audio/x-pn-realaudio";
+ if(!strncmp((LPCSTR)str, ".RMF", 4))
+ return "audio/x-pn-realaudio";
+ if(*(DWORD*)(LPCSTR)str == 0x75b22630)
+ return "video/x-ms-wmv";
+ if(!strncmp((LPCSTR)str+4, "moov", 4))
+ return "video/quicktime";
+ }
+
+ if(redir && (ct == _T("audio/x-scpls") || ct == _T("audio/x-mpegurl")))
+ {
+ while(body.GetLength() < 4*1024) // should be enough for a playlist...
+ {
+ CStringA str;
+ str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
+ if(str.IsEmpty()) break;
+ body += str;
+ }
+ }
+ }
+ }
+ else if(!fn.IsEmpty())
+ {
+ CPath p(fn);
+ CString ext = p.GetExtension().MakeLower();
+ if(ext == _T(".asx")) ct = _T("video/x-ms-asf");
+ else if(ext == _T(".pls")) ct = _T("audio/x-scpls");
+ else if(ext == _T(".m3u")) ct = _T("audio/x-mpegurl");
+ else if(ext == _T(".qtl")) ct = _T("application/x-quicktimeplayer");
+ else if(ext == _T(".mpcpl")) ct = _T("application/x-mpc-playlist");
+ else if(ext == _T(".bdmv")) ct = _T("application/x-bdmv-playlist");
+
+ if(FILE* f = _tfopen(fn, _T("rb")))
+ {
+ CStringA str;
+ str.ReleaseBufferSetLength(fread(str.GetBuffer(10240), 1, 10240, f));
+ body = AToT(str);
+ fclose(f);
+ }
+ }
+
+ if(body.GetLength() >= 4) // here only those which cannot be opened through dshow
+ {
+ CStringA str = TToA(body);
+ if(!strncmp((LPCSTR)str, ".ra", 3))
+ return "audio/x-pn-realaudio";
+ if(!strncmp((LPCSTR)str, "FWS", 3))
+ return "application/x-shockwave-flash";
+
+ }
+
+ if(redir && !ct.IsEmpty())
+ {
+ CAutoPtrList<CAtlRegExpT> res;
+ CAutoPtr<CAtlRegExpT> re;
+
+ if(ct == _T("video/x-ms-asf"))
+ {
+ // ...://..."/>
+ re.Attach(DNew CAtlRegExpT());
+ if(re && REPARSE_ERROR_OK == re->Parse(_T("{[a-zA-Z]+://[^\n\">]*}"), FALSE))
+ res.AddTail(re);
+ // Ref#n= ...://...\n
+ re.Attach(DNew CAtlRegExpT());
+ if(re && REPARSE_ERROR_OK == re->Parse(_T("Ref\\z\\b*=\\b*[\"]*{([a-zA-Z]+://[^\n\"]+}"), FALSE))
+ res.AddTail(re);
+ }
+ else if(ct == _T("audio/x-scpls"))
+ {
+ // File1=...\n
+ re.Attach(DNew CAtlRegExp<>());
+ if(re && REPARSE_ERROR_OK == re->Parse(_T("file\\z\\b*=\\b*[\"]*{[^\n\"]+}"), FALSE))
+ res.AddTail(re);
+ }
+ else if(ct == _T("audio/x-mpegurl"))
+ {
+ // #comment
+ // ...
+ re.Attach(DNew CAtlRegExp<>());
+ if(re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE))
+ res.AddTail(re);
+ }
+ else if(ct == _T("audio/x-pn-realaudio"))
+ {
+ // rtsp://...
+ re.Attach(DNew CAtlRegExp<>());
+ if(re && REPARSE_ERROR_OK == re->Parse(_T("{rtsp://[^\n]+}"), FALSE))
+ res.AddTail(re);
+ }
+
+ if(!body.IsEmpty())
+ {
+ if(fn.Find(_T("://")) >= 0) FindRedir(url, ct, body, *redir, res);
+ else FindRedir(fn, ct, *redir, res);
+ }
+ }
+
+ return TToA(ct);
}
LONGLONG CMPlayerCApp::GetPerfCounter()
{
- LARGE_INTEGER i64Ticks100ns;
- LARGE_INTEGER llPerfFrequency;
+ LARGE_INTEGER i64Ticks100ns;
+ LARGE_INTEGER llPerfFrequency;
- QueryPerformanceFrequency(&llPerfFrequency);
- if(llPerfFrequency.QuadPart != 0)
- {
- QueryPerformanceCounter(&i64Ticks100ns);
- return llMulDiv(i64Ticks100ns.QuadPart, 10000000, llPerfFrequency.QuadPart, 0);
- }
- else
- {
- // ms to 100ns units
- return timeGetTime() * 10000;
- }
+ QueryPerformanceFrequency (&llPerfFrequency);
+ if (llPerfFrequency.QuadPart != 0)
+ {
+ QueryPerformanceCounter (&i64Ticks100ns);
+ return llMulDiv (i64Ticks100ns.QuadPart, 10000000, llPerfFrequency.QuadPart, 0);
+ }
+ else
+ {
+ // ms to 100ns units
+ return timeGetTime() * 10000;
+ }
}
COLORPROPERTY_RANGE* CMPlayerCApp::GetColorControl(ControlType nFlag)
{
- switch(nFlag)
- {
- case Brightness :
- return &m_ColorControl[0];
- case Contrast :
- return &m_ColorControl[1];
- case Hue :
- return &m_ColorControl[2];
- case Saturation :
- return &m_ColorControl[3];
- }
- return NULL;
+ switch (nFlag)
+ {
+ case Brightness :
+ return &m_ColorControl[0];
+ case Contrast :
+ return &m_ColorControl[1];
+ case Hue :
+ return &m_ColorControl[2];
+ case Saturation :
+ return &m_ColorControl[3];
+ }
+ return NULL;
}
HINSTANCE CMPlayerCApp::GetD3X9Dll()
{
- if(m_hD3DX9Dll == NULL)
- {
- int min_ver = D3DX_SDK_VERSION;
- int max_ver = D3DX_SDK_VERSION;
-
- m_nDXSdkRelease = 0;
-
- if(D3DX_SDK_VERSION >= 42)
- {
- // August 2009 SDK (v42) is not compatible with older versions
- min_ver = 42;
- }
- else
- {
- if(D3DX_SDK_VERSION > 33)
- {
- // versions between 34 and 41 have no known compatibility issues
- min_ver = 34;
- }
- else
- {
- // The minimum version that supports the functionality required by MPC is 24
- min_ver = 24;
-
- if(D3DX_SDK_VERSION == 33)
- {
- // The April 2007 SDK (v33) should not be used (crash sometimes during shader compilation)
- max_ver = 32;
- }
- }
- }
-
- // load latest compatible version of the DLL that is available
- for(int i = max_ver; i >= min_ver; i--)
- {
- m_strD3DX9Version.Format(_T("d3dx9_%d.dll"), i);
- m_hD3DX9Dll = LoadLibrary(m_strD3DX9Version);
- if(m_hD3DX9Dll)
- {
- m_nDXSdkRelease = i;
- break;
- }
- }
- }
-
- return m_hD3DX9Dll;
+ if (m_hD3DX9Dll == NULL)
+ {
+ int min_ver = D3DX_SDK_VERSION;
+ int max_ver = D3DX_SDK_VERSION;
+
+ m_nDXSdkRelease = 0;
+
+ if(D3DX_SDK_VERSION >= 42) {
+ // August 2009 SDK (v42) is not compatible with older versions
+ min_ver = 42;
+ } else {
+ if(D3DX_SDK_VERSION > 33) {
+ // versions between 34 and 41 have no known compatibility issues
+ min_ver = 34;
+ } else {
+ // The minimum version that supports the functionality required by MPC is 24
+ min_ver = 24;
+
+ if(D3DX_SDK_VERSION == 33) {
+ // The April 2007 SDK (v33) should not be used (crash sometimes during shader compilation)
+ max_ver = 32;
+ }
+ }
+ }
+
+ // load latest compatible version of the DLL that is available
+ for (int i=max_ver; i>=min_ver; i--)
+ {
+ m_strD3DX9Version.Format(_T("d3dx9_%d.dll"), i);
+ m_hD3DX9Dll = LoadLibrary (m_strD3DX9Version);
+ if (m_hD3DX9Dll)
+ {
+ m_nDXSdkRelease = i;
+ break;
+ }
+ }
+ }
+
+ return m_hD3DX9Dll;
}
LPCTSTR CMPlayerCApp::GetSatelliteDll(int nLanguage)
{
- switch(nLanguage)
- {
- case 1: // French
- return _T("mpcresources.fr.dll");
- case 2: // German
- return _T("mpcresources.de.dll");
- case 3: // Russian
- return _T("mpcresources.ru.dll");
- case 4: // Turkish
- return _T("mpcresources.tr.dll");
- case 5: // Czech
- return _T("mpcresources.cz.dll");
- case 6: // Spanish
- return _T("mpcresources.es.dll");
- case 7: // Hungarian
- return _T("mpcresources.hu.dll");
- case 8: // Korean
- return _T("mpcresources.kr.dll");
- case 9: // Polish
- return _T("mpcresources.pl.dll");
- case 10: // Ukrainian
- return _T("mpcresources.ua.dll");
- case 11: // Italian
- return _T("mpcresources.it.dll");
- case 12 : // Slovak
- return _T("mpcresources.sk.dll");
- case 13 : // Chinese (simplified)
- return _T("mpcresources.sc.dll");
- case 14 : // Chinese (traditional)
- return _T("mpcresources.tc.dll");
- case 15 : // Belarusian
- return _T("mpcresources.by.dll");
- case 16 : // Sweedish
- return _T("mpcresources.sv.dll");
- case 17 : // Portuguese (brasil)
- return _T("mpcresources.br.dll");
- case 18 : // Dutch
- return _T("mpcresources.nl.dll");
- }
- return NULL;
-}
-
-
-void CMPlayerCApp::SetLanguage(int nLanguage)
-{
- AppSettings& s = AfxGetAppSettings();
- HMODULE hMod = NULL;
- LPCTSTR strSatellite;
-
- strSatellite = GetSatelliteDll(nLanguage);
- if(strSatellite)
- {
- CFileVersionInfo Version;
- CString strSatVersion;
-
- if(Version.Create(strSatellite))
- {
- strSatVersion = Version.GetFileVersionEx();
-
- if(strSatVersion == _T("1.3.0.0"))
- {
- hMod = LoadLibrary(strSatellite);
- s.iLanguage = nLanguage;
- }
- else
- {
- // This message should stay in english!
- MessageBox(NULL, _T("Your language pack will not work with this version. Please download a compatible one from the MPC-HC homepage."),
- _T("Media Player Classic - Home Cinema"), MB_OK);
- }
- }
- }
-
- if(hMod == NULL)
- {
- hMod = AfxGetApp()->m_hInstance;
- s.iLanguage = 0;
- }
-
- AfxSetResourceHandle(hMod);
+ switch (nLanguage)
+ {
+ case 1: // French
+ return _T("mpcresources.fr.dll");
+ case 2: // German
+ return _T("mpcresources.de.dll");
+ case 3: // Russian
+ return _T("mpcresources.ru.dll");
+ case 4: // Turkish
+ return _T("mpcresources.tr.dll");
+ case 5: // Czech
+ return _T("mpcresources.cz.dll");
+ case 6: // Spanish
+ return _T("mpcresources.es.dll");
+ case 7: // Hungarian
+ return _T("mpcresources.hu.dll");
+ case 8: // Korean
+ return _T("mpcresources.kr.dll");
+ case 9: // Polish
+ return _T("mpcresources.pl.dll");
+ case 10: // Ukrainian
+ return _T("mpcresources.ua.dll");
+ case 11: // Italian
+ return _T("mpcresources.it.dll");
+ case 12 : // Slovak
+ return _T("mpcresources.sk.dll");
+ case 13 : // Chinese (simplified)
+ return _T("mpcresources.sc.dll");
+ case 14 : // Chinese (traditional)
+ return _T("mpcresources.tc.dll");
+ case 15 : // Belarusian
+ return _T("mpcresources.by.dll");
+ case 16 : // Sweedish
+ return _T("mpcresources.sv.dll");
+ case 17 : // Portuguese (brasil)
+ return _T("mpcresources.br.dll");
+ case 18 : // Dutch
+ return _T("mpcresources.nl.dll");
+ }
+ return NULL;
+}
+
+
+void CMPlayerCApp::SetLanguage (int nLanguage)
+{
+ AppSettings& s = AfxGetAppSettings();
+ HMODULE hMod = NULL;
+ LPCTSTR strSatellite;
+
+ strSatellite = GetSatelliteDll( nLanguage );
+ if ( strSatellite )
+ {
+ CFileVersionInfo Version;
+ CString strSatVersion;
+
+ if ( Version.Create(strSatellite) )
+ {
+ strSatVersion = Version.GetFileVersionEx();
+
+ if ( strSatVersion == _T("1.3.0.0") )
+ {
+ hMod = LoadLibrary( strSatellite );
+ s.iLanguage = nLanguage;
+ }
+ else
+ {
+ // This message should stay in english!
+ MessageBox(NULL, _T("Your language pack will not work with this version. Please download a compatible one from the MPC-HC homepage."),
+ _T("Media Player Classic - Home Cinema"), MB_OK);
+ }
+ }
+ }
+
+ if ( hMod == NULL )
+ {
+ hMod = AfxGetApp()->m_hInstance;
+ s.iLanguage = 0;
+ }
+
+ AfxSetResourceHandle( hMod );
}
bool CMPlayerCApp::IsVistaOrAbove()
{
- OSVERSIONINFO osver;
-
- osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ OSVERSIONINFO osver;
- if(::GetVersionEx(&osver) &&
- osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
- (osver.dwMajorVersion >= 6))
- return TRUE;
+ osver.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
+
+ if ( ::GetVersionEx( &osver ) &&
+ osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
+ (osver.dwMajorVersion >= 6 ) )
+ return TRUE;
- return FALSE;
+ return FALSE;
}
bool CMPlayerCApp::IsVSFilterInstalled()
{
- bool result = false;
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{9852A670-F845-491B-9BE6-EBD841B8A613}"), KEY_READ))
- {
- result = true;
- }
-
- return result;
+ bool result = false;
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{9852A670-F845-491B-9BE6-EBD841B8A613}"), KEY_READ)) {
+ result = true;
+ }
+
+ return result;
}
bool CMPlayerCApp::HasEVR()
{
- bool result = false;
- CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{FA10746C-9B63-4B6C-BC49-FC300EA5F256}"), KEY_READ))
- {
- result = true;
- }
-
- return result;
+ bool result = false;
+ CRegKey key;
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{FA10746C-9B63-4B6C-BC49-FC300EA5F256}"), KEY_READ)) {
+ result = true;
+ }
+
+ return result;
}
-HRESULT CMPlayerCApp::GetElevationType(TOKEN_ELEVATION_TYPE* ptet)
+HRESULT CMPlayerCApp::GetElevationType(TOKEN_ELEVATION_TYPE* ptet )
{
- ASSERT(IsVistaOrAbove());
- ASSERT(ptet);
+ ASSERT( IsVistaOrAbove() );
+ ASSERT( ptet );
- HRESULT hResult = E_FAIL; // assume an error occured
- HANDLE hToken = NULL;
+ HRESULT hResult = E_FAIL; // assume an error occured
+ HANDLE hToken = NULL;
- if(!::OpenProcessToken(
- ::GetCurrentProcess(),
- TOKEN_QUERY,
- &hToken))
- {
- ASSERT(FALSE);
- return hResult;
- }
+ if ( !::OpenProcessToken(
+ ::GetCurrentProcess(),
+ TOKEN_QUERY,
+ &hToken ) )
+ {
+ ASSERT( FALSE );
+ return hResult;
+ }
- DWORD dwReturnLength = 0;
+ DWORD dwReturnLength = 0;
- if(!::GetTokenInformation(
- hToken,
- TokenElevationType,
- ptet,
- sizeof(*ptet),
- &dwReturnLength))
- {
- ASSERT(FALSE);
- }
- else
- {
- ASSERT(dwReturnLength == sizeof(*ptet));
- hResult = S_OK;
- }
+ if ( !::GetTokenInformation(
+ hToken,
+ TokenElevationType,
+ ptet,
+ sizeof( *ptet ),
+ &dwReturnLength ) )
+ {
+ ASSERT( FALSE );
+ }
+ else
+ {
+ ASSERT( dwReturnLength == sizeof( *ptet ) );
+ hResult = S_OK;
+ }
- ::CloseHandle(hToken);
+ ::CloseHandle( hToken );
- return hResult;
+ return hResult;
}
void CMPlayerCApp::RunAsAdministrator(LPCTSTR strCommand, LPCTSTR strArgs, bool bWaitProcess)
{
- SHELLEXECUTEINFO execinfo;
- memset(&execinfo, 0, sizeof(execinfo));
- execinfo.lpFile = strCommand;
- execinfo.cbSize = sizeof(execinfo);
- execinfo.lpVerb = _T("runas");
- execinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
- execinfo.nShow = SW_SHOWDEFAULT;
- execinfo.lpParameters = strArgs;
-
- ShellExecuteEx(&execinfo);
+ SHELLEXECUTEINFO execinfo;
+ memset(&execinfo, 0, sizeof(execinfo));
+ execinfo.lpFile = strCommand;
+ execinfo.cbSize = sizeof(execinfo);
+ execinfo.lpVerb = _T("runas");
+ execinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
+ execinfo.nShow = SW_SHOWDEFAULT;
+ execinfo.lpParameters = strArgs;
+
+ ShellExecuteEx(&execinfo);
- if(bWaitProcess)
- WaitForSingleObject(execinfo.hProcess, INFINITE);
+ if (bWaitProcess)
+ WaitForSingleObject(execinfo.hProcess, INFINITE);
}
void CAboutDlg::OnHomepage(NMHDR *pNMHDR, LRESULT *pResult)
{
- ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/about-homepage.html"), NULL, NULL, SW_SHOWDEFAULT);
- *pResult = 0;
+ ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/about-homepage.html"), NULL, NULL, SW_SHOWDEFAULT);
+ *pResult = 0;
}
diff --git a/src/apps/mplayerc/mplayerc.h b/src/apps/mplayerc/mplayerc.h
index fe7143945..67cd7843d 100644
--- a/src/apps/mplayerc/mplayerc.h
+++ b/src/apps/mplayerc/mplayerc.h
@@ -24,7 +24,7 @@
#pragma once
#ifndef __AFXWIN_H__
-#error include 'stdafx.h' before including this file for PCH
+ #error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
@@ -41,15 +41,15 @@
#define MPC_WND_CLASS_NAME "MediaPlayerClassicA"
#endif
-enum
+enum
{
- WM_GRAPHNOTIFY = WM_APP + 1,
- WM_REARRANGERENDERLESS,
- WM_RESUMEFROMSTATE,
- WM_TUNER_SCAN_PROGRESS,
- WM_TUNER_SCAN_END,
- WM_TUNER_STATS,
- WM_TUNER_NEW_CHANNEL
+ WM_GRAPHNOTIFY = WM_APP+1,
+ WM_REARRANGERENDERLESS,
+ WM_RESUMEFROMSTATE,
+ WM_TUNER_SCAN_PROGRESS,
+ WM_TUNER_SCAN_END,
+ WM_TUNER_STATS,
+ WM_TUNER_NEW_CHANNEL
};
#define WM_MYMOUSELAST WM_XBUTTONDBLCLK
@@ -66,36 +66,36 @@ extern CStringA GetContentType(CString fn, CAtlList<CString>* redir = NULL);
// Casimir666
//
typedef enum
-{
- Brightness = 0x1,
- Contrast = 0x2,
- Hue = 0x4,
- Saturation = 0x8,
+{
+ Brightness = 0x1,
+ Contrast = 0x2,
+ Hue = 0x4,
+ Saturation = 0x8,
} ControlType;
typedef struct // _VMR9ProcAmpControlRange
{
- DWORD dwSize;
- DWORD dwProperty;
- float MinValue;
- float MaxValue;
- float DefaultValue;
- float StepSize;
+ DWORD dwSize;
+ DWORD dwProperty;
+ float MinValue;
+ float MaxValue;
+ float DefaultValue;
+ float StepSize;
} COLORPROPERTY_RANGE;
#define MAX_DVD_POSITION 20
typedef struct
{
- ULONGLONG llDVDGuid;
- ULONG lTitle;
- DVD_HMSF_TIMECODE Timecode;
+ ULONGLONG llDVDGuid;
+ ULONG lTitle;
+ DVD_HMSF_TIMECODE Timecode;
} DVD_POSITION;
#define MAX_FILE_POSITION 20
typedef struct
{
- CString strFile;
- LONGLONG llPosition;
+ CString strFile;
+ LONGLONG llPosition;
} FILE_POSITION;
@@ -105,107 +105,107 @@ typedef struct
//
// flags for AppSettings::nCS
-enum
+enum
{
- CS_NONE = 0,
- CS_SEEKBAR = 1,
- CS_TOOLBAR = CS_SEEKBAR << 1,
- CS_INFOBAR = CS_TOOLBAR << 1,
- CS_STATSBAR = CS_INFOBAR << 1,
- CS_STATUSBAR = CS_STATSBAR << 1,
- CS_LAST = CS_STATUSBAR
+ CS_NONE=0,
+ CS_SEEKBAR=1,
+ CS_TOOLBAR=CS_SEEKBAR<<1,
+ CS_INFOBAR=CS_TOOLBAR<<1,
+ CS_STATSBAR=CS_INFOBAR<<1,
+ CS_STATUSBAR=CS_STATSBAR<<1,
+ CS_LAST=CS_STATUSBAR
};
enum
{
- CLSW_NONE = 0,
- CLSW_OPEN = 1,
- CLSW_PLAY = CLSW_OPEN << 1,
- CLSW_CLOSE = CLSW_PLAY << 1,
- CLSW_STANDBY = CLSW_CLOSE << 1,
- CLSW_HIBERNATE = CLSW_STANDBY << 1,
- CLSW_SHUTDOWN = CLSW_HIBERNATE << 1,
- CLSW_LOGOFF = CLSW_SHUTDOWN << 1,
- CLSW_AFTERPLAYBACK_MASK = CLSW_CLOSE | CLSW_STANDBY | CLSW_SHUTDOWN | CLSW_HIBERNATE | CLSW_LOGOFF,
- CLSW_FULLSCREEN = CLSW_LOGOFF << 1,
- CLSW_NEW = CLSW_FULLSCREEN << 1,
- CLSW_HELP = CLSW_NEW << 1,
- CLSW_DVD = CLSW_HELP << 1,
- CLSW_CD = CLSW_DVD << 1,
- CLSW_ADD = CLSW_CD << 1,
- CLSW_MINIMIZED = CLSW_ADD << 1,
- CLSW_REGEXTVID = CLSW_MINIMIZED << 1, // 16
- CLSW_REGEXTAUD = CLSW_REGEXTVID << 1,
- CLSW_UNREGEXT = CLSW_REGEXTAUD << 1,
- CLSW_STARTVALID = CLSW_UNREGEXT << 2,
- CLSW_NOFOCUS = CLSW_STARTVALID << 1,
- CLSW_FIXEDSIZE = CLSW_NOFOCUS << 1,
- CLSW_MONITOR = CLSW_FIXEDSIZE << 1,
- CLSW_D3DFULLSCREEN = CLSW_MONITOR << 1,
- CLSW_ADMINOPTION = CLSW_D3DFULLSCREEN << 1,
- CLSW_SLAVE = CLSW_ADMINOPTION << 1,
- CLSW_AUDIORENDER = CLSW_SLAVE << 1,
- CLSW_UNRECOGNIZEDSWITCH = CLSW_AUDIORENDER << 1
+ CLSW_NONE=0,
+ CLSW_OPEN=1,
+ CLSW_PLAY=CLSW_OPEN<<1,
+ CLSW_CLOSE=CLSW_PLAY<<1,
+ CLSW_STANDBY=CLSW_CLOSE<<1,
+ CLSW_HIBERNATE=CLSW_STANDBY<<1,
+ CLSW_SHUTDOWN=CLSW_HIBERNATE<<1,
+ CLSW_LOGOFF=CLSW_SHUTDOWN<<1,
+ CLSW_AFTERPLAYBACK_MASK=CLSW_CLOSE|CLSW_STANDBY|CLSW_SHUTDOWN|CLSW_HIBERNATE|CLSW_LOGOFF,
+ CLSW_FULLSCREEN=CLSW_LOGOFF<<1,
+ CLSW_NEW=CLSW_FULLSCREEN<<1,
+ CLSW_HELP=CLSW_NEW<<1,
+ CLSW_DVD=CLSW_HELP<<1,
+ CLSW_CD=CLSW_DVD<<1,
+ CLSW_ADD=CLSW_CD<<1,
+ CLSW_MINIMIZED=CLSW_ADD<<1,
+ CLSW_REGEXTVID=CLSW_MINIMIZED<<1, // 16
+ CLSW_REGEXTAUD=CLSW_REGEXTVID<<1,
+ CLSW_UNREGEXT=CLSW_REGEXTAUD<<1,
+ CLSW_STARTVALID=CLSW_UNREGEXT<<2,
+ CLSW_NOFOCUS=CLSW_STARTVALID<<1,
+ CLSW_FIXEDSIZE=CLSW_NOFOCUS<<1,
+ CLSW_MONITOR=CLSW_FIXEDSIZE<<1,
+ CLSW_D3DFULLSCREEN=CLSW_MONITOR<<1,
+ CLSW_ADMINOPTION=CLSW_D3DFULLSCREEN<<1,
+ CLSW_SLAVE=CLSW_ADMINOPTION<<1,
+ CLSW_AUDIORENDER=CLSW_SLAVE<<1,
+ CLSW_UNRECOGNIZEDSWITCH=CLSW_AUDIORENDER<<1
};
enum
{
- VIDRNDT_DS_DEFAULT,
- VIDRNDT_DS_OLDRENDERER,
- VIDRNDT_DS_OVERLAYMIXER,
- VIDRNDT_DS_VMR7WINDOWED,
- VIDRNDT_DS_VMR9WINDOWED,
- VIDRNDT_DS_VMR7RENDERLESS,
- VIDRNDT_DS_VMR9RENDERLESS,
- VIDRNDT_DS_DXR,
- VIDRNDT_DS_NULL_COMP,
- VIDRNDT_DS_NULL_UNCOMP,
- VIDRNDT_DS_EVR,
- VIDRNDT_DS_EVR_CUSTOM,
- VIDRNDT_DS_MADVR,
- VIDRNDT_DS_SYNC
+ VIDRNDT_DS_DEFAULT,
+ VIDRNDT_DS_OLDRENDERER,
+ VIDRNDT_DS_OVERLAYMIXER,
+ VIDRNDT_DS_VMR7WINDOWED,
+ VIDRNDT_DS_VMR9WINDOWED,
+ VIDRNDT_DS_VMR7RENDERLESS,
+ VIDRNDT_DS_VMR9RENDERLESS,
+ VIDRNDT_DS_DXR,
+ VIDRNDT_DS_NULL_COMP,
+ VIDRNDT_DS_NULL_UNCOMP,
+ VIDRNDT_DS_EVR,
+ VIDRNDT_DS_EVR_CUSTOM,
+ VIDRNDT_DS_MADVR,
+ VIDRNDT_DS_SYNC
};
enum
{
- VIDRNDT_RM_DEFAULT,
- VIDRNDT_RM_DX7,
- VIDRNDT_RM_DX9,
+ VIDRNDT_RM_DEFAULT,
+ VIDRNDT_RM_DX7,
+ VIDRNDT_RM_DX9,
};
enum
{
- VIDRNDT_QT_DEFAULT,
- VIDRNDT_QT_DX7,
- VIDRNDT_QT_DX9,
+ VIDRNDT_QT_DEFAULT,
+ VIDRNDT_QT_DX7,
+ VIDRNDT_QT_DX9,
};
enum
{
- VIDRNDT_AP_SURFACE,
- VIDRNDT_AP_TEXTURE2D,
- VIDRNDT_AP_TEXTURE3D,
+ VIDRNDT_AP_SURFACE,
+ VIDRNDT_AP_TEXTURE2D,
+ VIDRNDT_AP_TEXTURE3D,
};
// Enumeration for MCE remotecontrol (careful : add 0x010000 for all keys!)
enum MCE_RAW_INPUT
{
- MCE_DETAILS = 0x010209,
- MCE_GUIDE = 0x01008D,
- MCE_TVJUMP = 0x010025,
- MCE_STANDBY = 0x010082,
- MCE_OEM1 = 0x010080,
- MCE_OEM2 = 0x010081,
- MCE_MYTV = 0x010046,
- MCE_MYVIDEOS = 0x01004A,
- MCE_MYPICTURES = 0x010049,
- MCE_MYMUSIC = 0x010047,
- MCE_RECORDEDTV = 0x010048,
- MCE_DVDANGLE = 0x01004B,
- MCE_DVDAUDIO = 0x01004C,
- MCE_DVDMENU = 0x010024,
- MCE_DVDSUBTITLE = 0x01004D,
+ MCE_DETAILS = 0x010209,
+ MCE_GUIDE = 0x01008D,
+ MCE_TVJUMP = 0x010025,
+ MCE_STANDBY = 0x010082,
+ MCE_OEM1 = 0x010080,
+ MCE_OEM2 = 0x010081,
+ MCE_MYTV = 0x010046,
+ MCE_MYVIDEOS = 0x01004A,
+ MCE_MYPICTURES = 0x010049,
+ MCE_MYMUSIC = 0x010047,
+ MCE_RECORDEDTV = 0x010048,
+ MCE_DVDANGLE = 0x01004B,
+ MCE_DVDAUDIO = 0x01004C,
+ MCE_DVDMENU = 0x010024,
+ MCE_DVDSUBTITLE = 0x01004D,
MCE_RED = 0x01005B,
MCE_GREEN = 0x01005C,
MCE_YELLOW = 0x01005D,
@@ -221,162 +221,149 @@ enum MCE_RAW_INPUT
enum
{
- SRC_CDDA = 1,
- SRC_CDXA = SRC_CDDA << 1,
- SRC_VTS = SRC_CDXA << 1,
- SRC_FLIC = SRC_VTS << 1,
- SRC_D2V = SRC_FLIC << 1,
- SRC_DTSAC3 = SRC_D2V << 1,
- SRC_MATROSKA = SRC_DTSAC3 << 1,
- SRC_SHOUTCAST = SRC_MATROSKA << 1,
- SRC_REALMEDIA = SRC_SHOUTCAST << 1,
- SRC_AVI = SRC_REALMEDIA << 1,
- SRC_RADGT = SRC_AVI << 1,
- SRC_ROQ = SRC_RADGT << 1,
- SRC_OGG = SRC_ROQ << 1,
- SRC_NUT = SRC_OGG << 1,
- SRC_MPEG = SRC_NUT << 1,
- SRC_DIRAC = SRC_MPEG << 1,
- SRC_MPA = SRC_DIRAC << 1,
- SRC_DSM = SRC_MPA << 1,
- SRC_SUBS = SRC_DSM << 1,
- SRC_MP4 = SRC_SUBS << 1,
- SRC_FLV = SRC_MP4 << 1,
- SRC_FLAC = SRC_FLV << 1,
- SRC_LAST = SRC_FLAC << 1
+ SRC_CDDA = 1,
+ SRC_CDXA = SRC_CDDA<<1,
+ SRC_VTS = SRC_CDXA<<1,
+ SRC_FLIC = SRC_VTS<<1,
+ SRC_D2V = SRC_FLIC<<1,
+ SRC_DTSAC3 = SRC_D2V<<1,
+ SRC_MATROSKA = SRC_DTSAC3<<1,
+ SRC_SHOUTCAST = SRC_MATROSKA<<1,
+ SRC_REALMEDIA = SRC_SHOUTCAST<<1,
+ SRC_AVI = SRC_REALMEDIA<<1,
+ SRC_RADGT = SRC_AVI<<1,
+ SRC_ROQ = SRC_RADGT<<1,
+ SRC_OGG = SRC_ROQ<<1,
+ SRC_NUT = SRC_OGG<<1,
+ SRC_MPEG = SRC_NUT<<1,
+ SRC_DIRAC = SRC_MPEG<<1,
+ SRC_MPA = SRC_DIRAC<<1,
+ SRC_DSM = SRC_MPA<<1,
+ SRC_SUBS = SRC_DSM<<1,
+ SRC_MP4 = SRC_SUBS<<1,
+ SRC_FLV = SRC_MP4<<1,
+ SRC_FLAC = SRC_FLV<<1,
+ SRC_LAST = SRC_FLAC<<1
};
enum
{
- TRA_MPEG1 = 1,
- TRA_MPEG2 = TRA_MPEG1 << 1,
- TRA_RV = TRA_MPEG2 << 1,
- TRA_RA = TRA_RV << 1,
- TRA_MPA = TRA_RA << 1,
- TRA_LPCM = TRA_MPA << 1,
- TRA_AC3 = TRA_LPCM << 1,
- TRA_DTS = TRA_AC3 << 1,
- TRA_AAC = TRA_DTS << 1,
- TRA_PS2AUD = TRA_AAC << 1,
- TRA_DIRAC = TRA_PS2AUD << 1,
- TRA_VORBIS = TRA_DIRAC << 1,
- TRA_FLAC = TRA_VORBIS << 1,
- TRA_NELLY = TRA_FLAC << 1,
- TRA_AMR = TRA_NELLY << 1,
- TRA_LAST = TRA_AMR << 1
+ TRA_MPEG1 = 1,
+ TRA_MPEG2 = TRA_MPEG1<<1,
+ TRA_RV = TRA_MPEG2<<1,
+ TRA_RA = TRA_RV<<1,
+ TRA_MPA = TRA_RA<<1,
+ TRA_LPCM = TRA_MPA<<1,
+ TRA_AC3 = TRA_LPCM<<1,
+ TRA_DTS = TRA_AC3<<1,
+ TRA_AAC = TRA_DTS<<1,
+ TRA_PS2AUD = TRA_AAC<<1,
+ TRA_DIRAC = TRA_PS2AUD<<1,
+ TRA_VORBIS = TRA_DIRAC<<1,
+ TRA_FLAC = TRA_VORBIS<<1,
+ TRA_NELLY = TRA_FLAC<<1,
+ TRA_AMR = TRA_NELLY<<1,
+ TRA_LAST = TRA_AMR<<1
};
enum
{
- DXVA_H264 = 1,
- DXVA_VC1 = DXVA_H264 << 1,
- DXVA_MPEG2 = DXVA_VC1 << 1,
- DXVA_LAST = DXVA_MPEG2 << 1
+ DXVA_H264 = 1,
+ DXVA_VC1 = DXVA_H264<<1,
+ DXVA_MPEG2 = DXVA_VC1<<1,
+ DXVA_LAST = DXVA_MPEG2<<1
};
enum
{
- FFM_H264 = 1,
- FFM_VC1 = FFM_H264 << 1,
- FFM_FLV4 = FFM_VC1 << 1,
- FFM_VP62 = FFM_FLV4 << 1,
- FFM_XVID = FFM_VP62 << 1,
- FFM_DIVX = FFM_XVID << 1,
- FFM_MSMPEG4 = FFM_DIVX << 1,
- FFM_WMV = FFM_MSMPEG4 << 1,
- FFM_SVQ3 = FFM_WMV << 1,
- FFM_H263 = FFM_SVQ3 << 1,
- FFM_THEORA = FFM_H263 << 1,
- FFM_AMVV = FFM_THEORA << 1,
- FFM_LAST = FFM_AMVV << 1
+ FFM_H264 = 1,
+ FFM_VC1 = FFM_H264<<1,
+ FFM_FLV4 = FFM_VC1<<1,
+ FFM_VP62 = FFM_FLV4<<1,
+ FFM_XVID = FFM_VP62<<1,
+ FFM_DIVX = FFM_XVID<<1,
+ FFM_MSMPEG4 = FFM_DIVX<<1,
+ FFM_WMV = FFM_MSMPEG4<<1,
+ FFM_SVQ3 = FFM_WMV<<1,
+ FFM_H263 = FFM_SVQ3<<1,
+ FFM_THEORA = FFM_H263<<1,
+ FFM_AMVV = FFM_THEORA<<1,
+ FFM_LAST = FFM_AMVV<<1
};
enum
{
- DVS_HALF,
- DVS_NORMAL,
- DVS_DOUBLE,
- DVS_STRETCH,
- DVS_FROMINSIDE,
- DVS_FROMOUTSIDE
+ DVS_HALF,
+ DVS_NORMAL,
+ DVS_DOUBLE,
+ DVS_STRETCH,
+ DVS_FROMINSIDE,
+ DVS_FROMOUTSIDE
};
-typedef enum
+typedef enum
{
- FAV_FILE,
- FAV_DVD,
- FAV_DEVICE
+ FAV_FILE,
+ FAV_DVD,
+ FAV_DEVICE
} favtype;
#pragma pack(push, 1)
typedef struct
{
- bool fValid;
- CSize size;
- int bpp, freq;
- DWORD dmDisplayFlags;
+ bool fValid;
+ CSize size;
+ int bpp, freq;
+ DWORD dmDisplayFlags;
} dispmode;
typedef struct
{
- bool bEnabled;
- dispmode dmFullscreenRes24Hz;
- dispmode dmFullscreenRes25Hz;
- dispmode dmFullscreenRes30Hz;
- dispmode dmFullscreenResOther;
- bool bApplyDefault;
- dispmode dmFullscreenRes23d976Hz;
- dispmode dmFullscreenRes29d97Hz;
+ bool bEnabled;
+ dispmode dmFullscreenRes24Hz;
+ dispmode dmFullscreenRes25Hz;
+ dispmode dmFullscreenRes30Hz;
+ dispmode dmFullscreenResOther;
+ bool bApplyDefault;
+ dispmode dmFullscreenRes23d976Hz;
+ dispmode dmFullscreenRes29d97Hz;
} AChFR; //AutoChangeFullscrRes
class wmcmd : public ACCEL
{
- ACCEL backup;
- UINT appcmdorg;
- UINT mouseorg;
+ ACCEL backup;
+ UINT appcmdorg;
+ UINT mouseorg;
public:
- DWORD dwname;
- UINT appcmd;
- enum {NONE, LDOWN, LUP, LDBLCLK, MDOWN, MUP, MDBLCLK, RDOWN, RUP, RDBLCLK, X1DOWN, X1UP, X1DBLCLK, X2DOWN, X2UP, X2DBLCLK, WUP, WDOWN, LAST};
- UINT mouse;
- CStringA rmcmd;
- int rmrepcnt;
- wmcmd(WORD cmd = 0)
- {
- this->cmd = cmd;
- }
- wmcmd(WORD cmd, WORD key, BYTE fVirt, DWORD dwname, UINT appcmd = 0, UINT mouse = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5)
- {
- this->cmd = cmd;
- this->key = key;
- this->fVirt = fVirt;
- this->appcmd = appcmdorg = appcmd;
- this->dwname = dwname;
- this->mouse = mouseorg = mouse;
- this->rmcmd = rmcmd;
- this->rmrepcnt = rmrepcnt;
- backup = *this;
- }
- bool operator == (const wmcmd& wc) const
- {
- return(cmd > 0 && cmd == wc.cmd);
- }
-
- CString GetName()
- {
- return ResStr(dwname);
- }
- void Restore()
- {
- *(ACCEL*)this = backup;
- appcmd = appcmdorg;
- mouse = mouseorg;
- rmcmd.Empty();
- rmrepcnt = 5;
- }
- bool IsModified()
- {
- return(memcmp((const ACCEL*)this, &backup, sizeof(ACCEL)) || appcmd != appcmdorg || mouse != mouseorg || !rmcmd.IsEmpty() || rmrepcnt != 5);
- }
+ DWORD dwname;
+ UINT appcmd;
+ enum {NONE,LDOWN,LUP,LDBLCLK,MDOWN,MUP,MDBLCLK,RDOWN,RUP,RDBLCLK,X1DOWN,X1UP,X1DBLCLK,X2DOWN,X2UP,X2DBLCLK,WUP,WDOWN,LAST};
+ UINT mouse;
+ CStringA rmcmd;
+ int rmrepcnt;
+ wmcmd(WORD cmd = 0) {this->cmd = cmd;}
+ wmcmd(WORD cmd, WORD key, BYTE fVirt, DWORD dwname, UINT appcmd = 0, UINT mouse = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5)
+ {
+ this->cmd = cmd;
+ this->key = key;
+ this->fVirt = fVirt;
+ this->appcmd = appcmdorg = appcmd;
+ this->dwname = dwname;
+ this->mouse = mouseorg = mouse;
+ this->rmcmd = rmcmd;
+ this->rmrepcnt = rmrepcnt;
+ backup = *this;
+ }
+ bool operator == (const wmcmd& wc) const
+ {
+ return(cmd > 0 && cmd == wc.cmd);
+ }
+
+ CString GetName()
+ {
+ return ResStr (dwname);
+ }
+ void Restore() {*(ACCEL*)this = backup; appcmd = appcmdorg; mouse = mouseorg; rmcmd.Empty(); rmrepcnt = 5;}
+ bool IsModified() {return(memcmp((const ACCEL*)this, &backup, sizeof(ACCEL)) || appcmd != appcmdorg || mouse != mouseorg || !rmcmd.IsEmpty() || rmrepcnt != 5);}
};
#pragma pack(pop)
@@ -385,45 +372,42 @@ public:
class CRemoteCtrlClient : public CAsyncSocket
{
protected:
- CCritSec m_csLock;
- CWnd* m_pWnd;
- enum {DISCONNECTED, CONNECTED, CONNECTING} m_nStatus;
- CString m_addr;
+ CCritSec m_csLock;
+ CWnd* m_pWnd;
+ enum {DISCONNECTED, CONNECTED, CONNECTING} m_nStatus;
+ CString m_addr;
- virtual void OnConnect(int nErrorCode);
- virtual void OnClose(int nErrorCode);
- virtual void OnReceive(int nErrorCode);
+ virtual void OnConnect(int nErrorCode);
+ virtual void OnClose(int nErrorCode);
+ virtual void OnReceive(int nErrorCode);
- virtual void OnCommand(CStringA str) = 0;
+ virtual void OnCommand(CStringA str) = 0;
- void ExecuteCommand(CStringA cmd, int repcnt);
+ void ExecuteCommand(CStringA cmd, int repcnt);
public:
- CRemoteCtrlClient();
- void SetHWND(HWND hWnd);
- void Connect(CString addr);
- int GetStatus()
- {
- return(m_nStatus);
- }
+ CRemoteCtrlClient();
+ void SetHWND(HWND hWnd);
+ void Connect(CString addr);
+ int GetStatus() {return(m_nStatus);}
};
class CWinLircClient : public CRemoteCtrlClient
{
protected:
- virtual void OnCommand(CStringA str);
+ virtual void OnCommand(CStringA str);
public:
- CWinLircClient();
+ CWinLircClient();
};
class CUIceClient : public CRemoteCtrlClient
{
protected:
- virtual void OnCommand(CStringA str);
+ virtual void OnCommand(CStringA str);
public:
- CUIceClient();
+ CUIceClient();
};
extern void GetCurDispMode(dispmode& dm, CString& DisplayName);
@@ -435,443 +419,437 @@ extern void SetHandCursor(HWND m_hWnd, UINT nID);
class CMPlayerCApp : public CWinApp
{
- ATL::CMutex m_mutexOneInstance;
+ ATL::CMutex m_mutexOneInstance;
- CAtlList<CString> m_cmdln;
- void PreProcessCommandLine();
- void SendCommandLine(HWND hWnd);
- UINT GetVKFromAppCommand(UINT nAppCommand);
+ CAtlList<CString> m_cmdln;
+ void PreProcessCommandLine();
+ void SendCommandLine(HWND hWnd);
+ UINT GetVKFromAppCommand(UINT nAppCommand);
- // === CASIMIR666 : Ajout CMPlayerCApp
- COLORPROPERTY_RANGE m_ColorControl[4];
- HINSTANCE m_hD3DX9Dll;
- int m_nDXSdkRelease;
+ // === CASIMIR666 : Ajout CMPlayerCApp
+ COLORPROPERTY_RANGE m_ColorControl[4];
+ HINSTANCE m_hD3DX9Dll;
+ int m_nDXSdkRelease;
- static UINT GetRemoteControlCodeMicrosoft(UINT nInputcode, HRAWINPUT hRawInput);
- static UINT GetRemoteControlCodeSRM7500(UINT nInputcode, HRAWINPUT hRawInput);
+ static UINT GetRemoteControlCodeMicrosoft(UINT nInputcode, HRAWINPUT hRawInput);
+ static UINT GetRemoteControlCodeSRM7500(UINT nInputcode, HRAWINPUT hRawInput);
public:
- CMPlayerCApp();
-
- void ShowCmdlnSwitches();
-
- bool StoreSettingsToIni();
- bool StoreSettingsToRegistry();
- CString GetIniPath();
- bool IsIniValid();
-
- bool GetAppSavePath(CString& path);
-
- // === CASIMIR666 : Ajout CMPlayerCApp
- bool m_fTearingTest;
- int m_fDisplayStats;
- bool m_bResetStats; // Set to reset the presentation statistics
- CString m_strVersion;
- CString m_strD3DX9Version;
- CString m_AudioRendererDisplayName_CL;
-
- typedef UINT(*PTR_GetRemoteControlCode)(UINT nInputcode, HRAWINPUT hRawInput);
-
- PTR_GetRemoteControlCode GetRemoteControlCode;
- LONGLONG GetPerfCounter();
- COLORPROPERTY_RANGE* GetColorControl(ControlType nFlag);
- HINSTANCE GetD3X9Dll();
- int GetDXSdkRelease()
- {
- return m_nDXSdkRelease;
- };
- static void SetLanguage(int nLanguage);
- static LPCTSTR GetSatelliteDll(int nLang);
- static bool IsVistaOrAbove();
- static bool IsVSFilterInstalled();
- static bool HasEVR();
- static HRESULT GetElevationType(TOKEN_ELEVATION_TYPE* ptet);
- static void RunAsAdministrator(LPCTSTR strCommand, LPCTSTR strArgs, bool bWaitProcess);
-
- void RegisterHotkeys();
- void UnregisterHotkeys();
+ CMPlayerCApp();
+
+ void ShowCmdlnSwitches();
+
+ bool StoreSettingsToIni();
+ bool StoreSettingsToRegistry();
+ CString GetIniPath();
+ bool IsIniValid();
+
+ bool GetAppSavePath(CString& path);
+
+ // === CASIMIR666 : Ajout CMPlayerCApp
+ bool m_fTearingTest;
+ int m_fDisplayStats;
+ bool m_bResetStats; // Set to reset the presentation statistics
+ CString m_strVersion;
+ CString m_strD3DX9Version;
+ CString m_AudioRendererDisplayName_CL;
+
+ typedef UINT (*PTR_GetRemoteControlCode)(UINT nInputcode, HRAWINPUT hRawInput);
+
+ PTR_GetRemoteControlCode GetRemoteControlCode;
+ LONGLONG GetPerfCounter();
+ COLORPROPERTY_RANGE* GetColorControl(ControlType nFlag);
+ HINSTANCE GetD3X9Dll();
+ int GetDXSdkRelease() { return m_nDXSdkRelease; };
+ static void SetLanguage (int nLanguage);
+ static LPCTSTR GetSatelliteDll(int nLang);
+ static bool IsVistaOrAbove();
+ static bool IsVSFilterInstalled();
+ static bool HasEVR();
+ static HRESULT GetElevationType(TOKEN_ELEVATION_TYPE* ptet);
+ static void RunAsAdministrator(LPCTSTR strCommand, LPCTSTR strArgs, bool bWaitProcess);
+
+ void RegisterHotkeys();
+ void UnregisterHotkeys();
// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CMPlayerCApp)
-public:
- virtual BOOL InitInstance();
- virtual int ExitInstance();
- //}}AFX_VIRTUAL
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CMPlayerCApp)
+ public:
+ virtual BOOL InitInstance();
+ virtual int ExitInstance();
+ //}}AFX_VIRTUAL
// Implementation
- class Settings
- {
- friend class CMPlayerCApp;
-
- bool fInitialized;
-
- class CRecentFileAndURLList : public CRecentFileList
- {
- public:
- CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
- LPCTSTR lpszEntryFormat, int nSize,
- int nMaxDispLen = AFX_ABBREV_FILENAME_LEN);
-
- virtual void Add(LPCTSTR lpszPathName); // we have to override CRecentFileList::Add because the original version can't handle URLs
- };
-
- public:
- // cmdline params
- int nCLSwitches;
- CAtlList<CString> slFiles, slDubs, slSubs, slFilters;
-
- // Initial position (used by command line flags)
- __int64 rtShift;
- __int64 rtStart;
- ULONG lDVDTitle;
- ULONG lDVDChapter;
- DVD_HMSF_TIMECODE DVDPosition;
-
- CSize fixedWindowSize;
- bool HasFixedWindowSize() const
- {
- return fixedWindowSize.cx > 0 || fixedWindowSize.cy > 0;
- }
- // int iFixedWidth, iFixedHeight;
- int iMonitor;
-
- CString sPnSPreset;
-
- void ParseCommandLine(CAtlList<CString>& cmdln);
-
- bool fXpOrBetter;
- int iDXVer;
- int iAdminOption;
-
- int nCS;
- bool fHideCaptionMenu;
- bool fHideNavigation;
- int iDefaultVideoSize;
- bool fKeepAspectRatio;
- bool fCompMonDeskARDiff;
-
- CRecentFileAndURLList MRU;
- CRecentFileAndURLList MRUDub;
-
- CAutoPtrList<FilterOverride> filters;
-
- bool fResetDevice;
-
- class CRendererSettingsShared
- {
- public:
- CRendererSettingsShared()
- {
- SetDefault();
- }
- bool fVMR9AlterativeVSync;
- int iVMR9VSyncOffset;
- bool iVMR9VSyncAccurate;
- bool iVMR9FullscreenGUISupport;
- bool iVMR9VSync;
- bool iVMRDisableDesktopComposition;
- int iVMRFlushGPUBeforeVSync;
- int iVMRFlushGPUAfterPresent;
- int iVMRFlushGPUWait;
-
- // SyncRenderer settings
- int bSynchronizeVideo;
- int bSynchronizeDisplay;
- int bSynchronizeNearest;
- int iLineDelta;
- int iColumnDelta;
- double fCycleDelta;
- double fTargetSyncOffset;
- double fControlLimit;
-
- void SetDefault()
- {
- fVMR9AlterativeVSync = 0;
- iVMR9VSyncOffset = 0;
- iVMR9VSyncAccurate = 1;
- iVMR9FullscreenGUISupport = 0;
- iVMR9VSync = 1;
- iVMRDisableDesktopComposition = 0;
- iVMRFlushGPUBeforeVSync = 1;
- iVMRFlushGPUAfterPresent = 1;
- iVMRFlushGPUWait = 0;
- bSynchronizeVideo = 0;
- bSynchronizeDisplay = 0;
- bSynchronizeNearest = 1;
- iLineDelta = 0;
- iColumnDelta = 0;
- fCycleDelta = 0.0012;
- fTargetSyncOffset = 12.0;
- fControlLimit = 2.0;
- }
- void SetOptimal()
- {
- fVMR9AlterativeVSync = 1;
- iVMR9VSyncAccurate = 1;
- iVMR9VSync = 1;
- iVMRDisableDesktopComposition = 1;
- iVMRFlushGPUBeforeVSync = 1;
- iVMRFlushGPUAfterPresent = 1;
- iVMRFlushGPUWait = 0;
- bSynchronizeVideo = 0;
- bSynchronizeDisplay = 0;
- bSynchronizeNearest = 1;
- iLineDelta = 0;
- iColumnDelta = 0;
- fCycleDelta = 0.0012;
- fTargetSyncOffset = 12.0;
- fControlLimit = 2.0;
- }
- };
- class CRendererSettingsEVR : public CRendererSettingsShared
- {
- public:
- bool iEVRHighColorResolution;
- bool iEVREnableFrameTimeCorrection;
- int iEVROutputRange;
-
- CRendererSettingsEVR()
- {
- SetDefault();
- }
- void SetDefault()
- {
- CRendererSettingsShared::SetDefault();
- iEVRHighColorResolution = 0;
- iEVREnableFrameTimeCorrection = 0;
- iEVROutputRange = 0;
- }
- void SetOptimal()
- {
- CRendererSettingsShared::SetOptimal();
- iEVRHighColorResolution = 0;
- }
- };
-
- CRendererSettingsEVR m_RenderSettings;
-
- int iDSVideoRendererType;
- int iRMVideoRendererType;
- int iQTVideoRendererType;
- int iAPSurfaceUsage;
+ class Settings
+ {
+ friend class CMPlayerCApp;
+
+ bool fInitialized;
+
+ class CRecentFileAndURLList : public CRecentFileList
+ {
+ public:
+ CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
+ LPCTSTR lpszEntryFormat, int nSize,
+ int nMaxDispLen = AFX_ABBREV_FILENAME_LEN);
+
+ virtual void Add(LPCTSTR lpszPathName); // we have to override CRecentFileList::Add because the original version can't handle URLs
+ };
+
+ public:
+ // cmdline params
+ int nCLSwitches;
+ CAtlList<CString> slFiles, slDubs, slSubs, slFilters;
+
+ // Initial position (used by command line flags)
+ __int64 rtShift;
+ __int64 rtStart;
+ ULONG lDVDTitle;
+ ULONG lDVDChapter;
+ DVD_HMSF_TIMECODE DVDPosition;
+
+ CSize fixedWindowSize;
+ bool HasFixedWindowSize() const {return fixedWindowSize.cx > 0 || fixedWindowSize.cy > 0;}
+ // int iFixedWidth, iFixedHeight;
+ int iMonitor;
+
+ CString sPnSPreset;
+
+ void ParseCommandLine(CAtlList<CString>& cmdln);
+
+ bool fXpOrBetter;
+ int iDXVer;
+ int iAdminOption;
+
+ int nCS;
+ bool fHideCaptionMenu;
+ bool fHideNavigation;
+ int iDefaultVideoSize;
+ bool fKeepAspectRatio;
+ bool fCompMonDeskARDiff;
+
+ CRecentFileAndURLList MRU;
+ CRecentFileAndURLList MRUDub;
+
+ CAutoPtrList<FilterOverride> filters;
+
+ bool fResetDevice;
+
+ class CRendererSettingsShared
+ {
+ public:
+ CRendererSettingsShared()
+ {
+ SetDefault();
+ }
+ bool fVMR9AlterativeVSync;
+ int iVMR9VSyncOffset;
+ bool iVMR9VSyncAccurate;
+ bool iVMR9FullscreenGUISupport;
+ bool iVMR9VSync;
+ bool iVMRDisableDesktopComposition;
+ int iVMRFlushGPUBeforeVSync;
+ int iVMRFlushGPUAfterPresent;
+ int iVMRFlushGPUWait;
+
+ // SyncRenderer settings
+ int bSynchronizeVideo;
+ int bSynchronizeDisplay;
+ int bSynchronizeNearest;
+ int iLineDelta;
+ int iColumnDelta;
+ double fCycleDelta;
+ double fTargetSyncOffset;
+ double fControlLimit;
+
+ void SetDefault()
+ {
+ fVMR9AlterativeVSync = 0;
+ iVMR9VSyncOffset = 0;
+ iVMR9VSyncAccurate = 1;
+ iVMR9FullscreenGUISupport = 0;
+ iVMR9VSync = 1;
+ iVMRDisableDesktopComposition = 0;
+ iVMRFlushGPUBeforeVSync = 1;
+ iVMRFlushGPUAfterPresent = 1;
+ iVMRFlushGPUWait = 0;
+ bSynchronizeVideo = 0;
+ bSynchronizeDisplay = 0;
+ bSynchronizeNearest = 1;
+ iLineDelta = 0;
+ iColumnDelta = 0;
+ fCycleDelta = 0.0012;
+ fTargetSyncOffset = 12.0;
+ fControlLimit = 2.0;
+ }
+ void SetOptimal()
+ {
+ fVMR9AlterativeVSync = 1;
+ iVMR9VSyncAccurate = 1;
+ iVMR9VSync = 1;
+ iVMRDisableDesktopComposition = 1;
+ iVMRFlushGPUBeforeVSync = 1;
+ iVMRFlushGPUAfterPresent = 1;
+ iVMRFlushGPUWait = 0;
+ bSynchronizeVideo = 0;
+ bSynchronizeDisplay = 0;
+ bSynchronizeNearest = 1;
+ iLineDelta = 0;
+ iColumnDelta = 0;
+ fCycleDelta = 0.0012;
+ fTargetSyncOffset = 12.0;
+ fControlLimit = 2.0;
+ }
+ };
+ class CRendererSettingsEVR : public CRendererSettingsShared
+ {
+ public:
+ bool iEVRHighColorResolution;
+ bool iEVREnableFrameTimeCorrection;
+ int iEVROutputRange;
+
+ CRendererSettingsEVR()
+ {
+ SetDefault();
+ }
+ void SetDefault()
+ {
+ CRendererSettingsShared::SetDefault();
+ iEVRHighColorResolution = 0;
+ iEVREnableFrameTimeCorrection = 0;
+ iEVROutputRange = 0;
+ }
+ void SetOptimal()
+ {
+ CRendererSettingsShared::SetOptimal();
+ iEVRHighColorResolution = 0;
+ }
+ };
+
+ CRendererSettingsEVR m_RenderSettings;
+
+ int iDSVideoRendererType;
+ int iRMVideoRendererType;
+ int iQTVideoRendererType;
+ int iAPSurfaceUsage;
// bool fVMRSyncFix;
- int iDX9Resizer;
- bool fVMR9MixerMode;
- bool fVMR9MixerYUV;
-
- int nVolume;
- int nBalance;
- bool fMute;
- int nLoops;
- bool fLoopForever;
- bool fRewind;
- int iZoomLevel;
- // int iVideoRendererType;
- CStringW AudioRendererDisplayName;
- bool fAutoloadAudio;
- bool fAutoloadSubtitles;
- bool fBlockVSFilter;
- bool fEnableWorkerThreadForOpening;
- bool fReportFailedPins;
-
- CStringW f_hmonitor;
- bool fAssociatedWithIcons;
- CStringW f_lastOpenDir;
-
- bool fAllowMultipleInst;
- int iTitleBarTextStyle;
- bool fTitleBarTextTitle;
- int iOnTop;
- bool fTrayIcon;
- bool fRememberZoomLevel;
- bool fShowBarsWhenFullScreen;
- int nShowBarsWhenFullScreenTimeOut;
- AChFR AutoChangeFullscrRes;
- bool fExitFullScreenAtTheEnd;
- bool fRestoreResAfterExit;
- bool fRememberWindowPos;
- bool fRememberWindowSize;
- bool fSnapToDesktopEdges;
- CRect rcLastWindowPos;
- UINT lastWindowType;
- CSize AspectRatio;
- bool fKeepHistory;
-
- CString sDVDPath;
- bool fUseDVDPath;
- LCID idMenuLang, idAudioLang, idSubtitlesLang;
- bool fAutoSpeakerConf;
-
- STSStyle subdefstyle;
- bool fOverridePlacement;
- int nHorPos, nVerPos;
- int nSPCSize;
- int nSPCMaxRes;
- int nSubDelayInterval;
- bool fSPCPow2Tex;
- bool fSPCAllowAnimationWhenBuffering;
- bool fEnableSubtitles;
- bool fUseDefaultSubtitlesStyle;
-
- bool fDisableXPToolbars;
- bool fUseWMASFReader;
- int nJumpDistS;
- int nJumpDistM;
- int nJumpDistL;
- bool fLimitWindowProportions;
- bool fNotifyMSN;
- bool fNotifyGTSdll;
-
- bool fEnableAudioSwitcher;
- bool fDownSampleTo441;
- bool fAudioTimeShift;
- int tAudioTimeShift;
- bool fCustomChannelMapping;
- DWORD pSpeakerToChannelMap[18][18];
- bool fAudioNormalize;
- bool fAudioNormalizeRecover;
- float AudioBoost;
-
- bool fIntRealMedia;
- // bool fRealMediaRenderless;
- int iQuickTimeRenderer;
- float RealMediaQuickTimeFPS;
-
- CStringArray m_pnspresets;
-
- CList<wmcmd> wmcmds;
- HACCEL hAccel;
-
- bool fWinLirc;
- CString WinLircAddr;
- CWinLircClient WinLircClient;
- bool fUIce;
- CString UIceAddr;
- CUIceClient UIceClient;
- bool fGlobalMedia;
-
- CMediaFormats Formats;
-
- UINT SrcFilters, TraFilters, DXVAFilters, FFmpegFilters;
-
- CString logofn;
- UINT logoid;
- bool logoext;
-
- bool fHideCDROMsSubMenu;
-
- DWORD priority;
- bool launchfullscreen;
-
- BOOL fEnableWebServer;
- int nWebServerPort;
- bool fWebServerPrintDebugInfo;
- bool fWebServerUseCompression;
- bool fWebServerLocalhostOnly;
- CString WebRoot, WebDefIndex;
- CString WebServerCGI;
-
- CString SnapShotPath, SnapShotExt;
- int ThumbRows, ThumbCols, ThumbWidth;
-
- CString ISDb;
-
- struct Shader
- {
- CString label;
- CString target;
- CString srcdata;
- };
- CAtlList<Shader> m_shaders;
- CString m_shadercombine;
- CString m_shadercombineScreenSpace;
-
- // === CASIMIR666 : nouveau settings
- bool fD3DFullscreen;
- bool fMonitorAutoRefreshRate;
- bool fLastFullScreen;
- bool fEnableEDLEditor;
- float dBrightness;
- float dContrast;
- float dHue;
- float dSaturation;
- CString strShaderList;
- CString strShaderListScreenSpace;
- bool m_bToggleShader;
- bool m_bToggleShaderScreenSpace;
-
- bool fRememberDVDPos;
- bool fRememberFilePos;
- bool fShowOSD;
- int iEvrBuffers;
- int iLanguage;
-
- // BDA configuration
- int iDefaultCaptureDevice; // Default capture device (analog=0, 1=digital)
- CString strAnalogVideo;
- CString strAnalogAudio;
- int iAnalogCountry;
- CString BDANetworkProvider;
- CString BDATuner;
- CString BDAReceiver;
- int DVBLastChannel;
- CAtlList<CDVBChannel> DVBChannels;
-
-
- HWND hMasterWnd;
-
- bool IsD3DFullscreen();
- CString SelectedAudioRender();
- void ResetPositions();
- DVD_POSITION* CurrentDVDPosition();
- bool NewDvd(ULONGLONG llDVDGuid);
- FILE_POSITION* CurrentFilePosition();
- bool NewFile(LPCTSTR strFileName);
-
- void DeserializeHex(LPCTSTR strVal, BYTE* pBuffer, int nBufSize);
- CString SerializeHex(BYTE* pBuffer, int nBufSize);
-
- private :
- DVD_POSITION DvdPosition[MAX_DVD_POSITION];
- int nCurrentDvdPosition;
- FILE_POSITION FilePosition[MAX_FILE_POSITION];
- int nCurrentFilePosition;
-
- __int64 ConvertTimeToMSec(CString& time);
- void ExtractDVDStartPos(CString& strParam);
-
- void CreateCommands();
- public:
- Settings();
- virtual ~Settings();
- void UpdateData(bool fSave);
-
- void GetFav(favtype ft, CAtlList<CString>& sl);
- void SetFav(favtype ft, CAtlList<CString>& sl);
- void AddFav(favtype ft, CString s);
- CDVBChannel* FindChannelByPref(int nPrefNumber);
-
- bool m_fPreventMinimize;
- bool m_fUseWin7TaskBar;
- bool m_fExitAfterPlayback;
- bool m_fNextInDirAfterPlayback;
- bool m_fDontUseSearchInFolder;
- int nOSD_Size;
- CString m_OSD_Font;
- CStringW m_subtitlesLanguageOrder;
- CStringW m_audiosLanguageOrder;
-
- int fnChannels;
-
- CString D3D9RenderDevice;
- } m_s;
+ int iDX9Resizer;
+ bool fVMR9MixerMode;
+ bool fVMR9MixerYUV;
+
+ int nVolume;
+ int nBalance;
+ bool fMute;
+ int nLoops;
+ bool fLoopForever;
+ bool fRewind;
+ int iZoomLevel;
+ // int iVideoRendererType;
+ CStringW AudioRendererDisplayName;
+ bool fAutoloadAudio;
+ bool fAutoloadSubtitles;
+ bool fBlockVSFilter;
+ bool fEnableWorkerThreadForOpening;
+ bool fReportFailedPins;
+
+ CStringW f_hmonitor;
+ bool fAssociatedWithIcons;
+ CStringW f_lastOpenDir;
+
+ bool fAllowMultipleInst;
+ int iTitleBarTextStyle;
+ bool fTitleBarTextTitle;
+ int iOnTop;
+ bool fTrayIcon;
+ bool fRememberZoomLevel;
+ bool fShowBarsWhenFullScreen;
+ int nShowBarsWhenFullScreenTimeOut;
+ AChFR AutoChangeFullscrRes;
+ bool fExitFullScreenAtTheEnd;
+ bool fRestoreResAfterExit;
+ bool fRememberWindowPos;
+ bool fRememberWindowSize;
+ bool fSnapToDesktopEdges;
+ CRect rcLastWindowPos;
+ UINT lastWindowType;
+ CSize AspectRatio;
+ bool fKeepHistory;
+
+ CString sDVDPath;
+ bool fUseDVDPath;
+ LCID idMenuLang, idAudioLang, idSubtitlesLang;
+ bool fAutoSpeakerConf;
+
+ STSStyle subdefstyle;
+ bool fOverridePlacement;
+ int nHorPos, nVerPos;
+ int nSPCSize;
+ int nSPCMaxRes;
+ int nSubDelayInterval;
+ bool fSPCPow2Tex;
+ bool fSPCAllowAnimationWhenBuffering;
+ bool fEnableSubtitles;
+ bool fUseDefaultSubtitlesStyle;
+
+ bool fDisableXPToolbars;
+ bool fUseWMASFReader;
+ int nJumpDistS;
+ int nJumpDistM;
+ int nJumpDistL;
+ bool fLimitWindowProportions;
+ bool fNotifyMSN;
+ bool fNotifyGTSdll;
+
+ bool fEnableAudioSwitcher;
+ bool fDownSampleTo441;
+ bool fAudioTimeShift;
+ int tAudioTimeShift;
+ bool fCustomChannelMapping;
+ DWORD pSpeakerToChannelMap[18][18];
+ bool fAudioNormalize;
+ bool fAudioNormalizeRecover;
+ float AudioBoost;
+
+ bool fIntRealMedia;
+ // bool fRealMediaRenderless;
+ int iQuickTimeRenderer;
+ float RealMediaQuickTimeFPS;
+
+ CStringArray m_pnspresets;
+
+ CList<wmcmd> wmcmds;
+ HACCEL hAccel;
+
+ bool fWinLirc;
+ CString WinLircAddr;
+ CWinLircClient WinLircClient;
+ bool fUIce;
+ CString UIceAddr;
+ CUIceClient UIceClient;
+ bool fGlobalMedia;
+
+ CMediaFormats Formats;
+
+ UINT SrcFilters, TraFilters, DXVAFilters, FFmpegFilters;
+
+ CString logofn;
+ UINT logoid;
+ bool logoext;
+
+ bool fHideCDROMsSubMenu;
+
+ DWORD priority;
+ bool launchfullscreen;
+
+ BOOL fEnableWebServer;
+ int nWebServerPort;
+ bool fWebServerPrintDebugInfo;
+ bool fWebServerUseCompression;
+ bool fWebServerLocalhostOnly;
+ CString WebRoot, WebDefIndex;
+ CString WebServerCGI;
+
+ CString SnapShotPath, SnapShotExt;
+ int ThumbRows, ThumbCols, ThumbWidth;
+
+ CString ISDb;
+
+ struct Shader
+ {
+ CString label;
+ CString target;
+ CString srcdata;
+ };
+ CAtlList<Shader> m_shaders;
+ CString m_shadercombine;
+ CString m_shadercombineScreenSpace;
+
+ // === CASIMIR666 : nouveau settings
+ bool fD3DFullscreen;
+ bool fMonitorAutoRefreshRate;
+ bool fLastFullScreen;
+ bool fEnableEDLEditor;
+ float dBrightness;
+ float dContrast;
+ float dHue;
+ float dSaturation;
+ CString strShaderList;
+ CString strShaderListScreenSpace;
+ bool m_bToggleShader;
+ bool m_bToggleShaderScreenSpace;
+
+ bool fRememberDVDPos;
+ bool fRememberFilePos;
+ bool fShowOSD;
+ int iEvrBuffers;
+ int iLanguage;
+
+ // BDA configuration
+ int iDefaultCaptureDevice; // Default capture device (analog=0, 1=digital)
+ CString strAnalogVideo;
+ CString strAnalogAudio;
+ int iAnalogCountry;
+ CString BDANetworkProvider;
+ CString BDATuner;
+ CString BDAReceiver;
+ int DVBLastChannel;
+ CAtlList<CDVBChannel> DVBChannels;
+
+
+ HWND hMasterWnd;
+
+ bool IsD3DFullscreen();
+ CString SelectedAudioRender();
+ void ResetPositions();
+ DVD_POSITION* CurrentDVDPosition();
+ bool NewDvd(ULONGLONG llDVDGuid);
+ FILE_POSITION* CurrentFilePosition();
+ bool NewFile(LPCTSTR strFileName);
+
+ void DeserializeHex (LPCTSTR strVal, BYTE* pBuffer, int nBufSize);
+ CString SerializeHex (BYTE* pBuffer, int nBufSize);
+
+ private :
+ DVD_POSITION DvdPosition[MAX_DVD_POSITION];
+ int nCurrentDvdPosition;
+ FILE_POSITION FilePosition[MAX_FILE_POSITION];
+ int nCurrentFilePosition;
+
+ __int64 ConvertTimeToMSec(CString& time);
+ void ExtractDVDStartPos(CString& strParam);
+
+ void CreateCommands();
+ public:
+ Settings();
+ virtual ~Settings();
+ void UpdateData(bool fSave);
+
+ void GetFav(favtype ft, CAtlList<CString>& sl);
+ void SetFav(favtype ft, CAtlList<CString>& sl);
+ void AddFav(favtype ft, CString s);
+ CDVBChannel* FindChannelByPref(int nPrefNumber);
+
+ bool m_fPreventMinimize;
+ bool m_fUseWin7TaskBar;
+ bool m_fExitAfterPlayback;
+ bool m_fNextInDirAfterPlayback;
+ bool m_fDontUseSearchInFolder;
+ int nOSD_Size;
+ CString m_OSD_Font;
+ CStringW m_subtitlesLanguageOrder;
+ CStringW m_audiosLanguageOrder;
+
+ int fnChannels;
+
+ CString D3D9RenderDevice;
+ } m_s;
public:
- DECLARE_MESSAGE_MAP()
- afx_msg void OnAppAbout();
- afx_msg void OnFileExit();
- afx_msg void OnHelpShowcommandlineswitches();
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnAppAbout();
+ afx_msg void OnFileExit();
+ afx_msg void OnHelpShowcommandlineswitches();
};
#define AfxGetMyApp() static_cast<CMPlayerCApp*>(AfxGetApp())
diff --git a/src/apps/mplayerc/pngdib.c b/src/apps/mplayerc/pngdib.c
index 2dd6b5d9b..f3bb8ca04 100644
--- a/src/apps/mplayerc/pngdib.c
+++ b/src/apps/mplayerc/pngdib.c
@@ -37,1615 +37,1397 @@
// This is basically a Windows-only utility with a simple-as-possible
-// interface, so I'm not too concerned about allowing a
+// interface, so I'm not too concerned about allowing a
// user-configurable screen gamma.
//static const double screen_gamma = 2.2;
#define MAX_ERRMSGLEN 100
-struct errstruct
-{
- jmp_buf *jbufp;
- TCHAR *errmsg;
+struct errstruct {
+ jmp_buf *jbufp;
+ TCHAR *errmsg;
};
-static void pngd_get_error_message(int rv, TCHAR *e)
+static void pngd_get_error_message(int rv,TCHAR *e)
{
- switch(rv)
- {
- case PNGD_E_ERROR:
- lstrcpy(e, _T("Unknown error"));
- break;
- case PNGD_E_VERSION:
- lstrcpy(e, _T("Incompatible library version"));
- break;
- case PNGD_E_NOMEM:
- lstrcpy(e, _T("Unable to allocate memory"));
- break;
- case PNGD_E_UNSUPP:
- lstrcpy(e, _T("Invalid or unsupported image"));
- break;
- case PNGD_E_LIBPNG:
- lstrcpy(e, _T("libpng reported an error"));
- break;
- case PNGD_E_BADBMP:
- lstrcpy(e, _T("Invalid BMP image"));
- break;
- case PNGD_E_BADPNG:
- lstrcpy(e, _T("Invalid PNG image"));
- break;
- case PNGD_E_READ:
- lstrcpy(e, _T("Unable to read file"));
- break;
- case PNGD_E_WRITE:
- lstrcpy(e, _T("Unable to write file"));
- break;
- }
+ switch(rv) {
+ case PNGD_E_ERROR: lstrcpy(e,_T("Unknown error")); break;
+ case PNGD_E_VERSION: lstrcpy(e,_T("Incompatible library version")); break;
+ case PNGD_E_NOMEM: lstrcpy(e,_T("Unable to allocate memory")); break;
+ case PNGD_E_UNSUPP: lstrcpy(e,_T("Invalid or unsupported image")); break;
+ case PNGD_E_LIBPNG: lstrcpy(e,_T("libpng reported an error")); break;
+ case PNGD_E_BADBMP: lstrcpy(e,_T("Invalid BMP image")); break;
+ case PNGD_E_BADPNG: lstrcpy(e,_T("Invalid PNG image")); break;
+ case PNGD_E_READ: lstrcpy(e,_T("Unable to read file")); break;
+ case PNGD_E_WRITE: lstrcpy(e,_T("Unable to write file")); break;
+ }
}
static unsigned char* uncompress_dib(LPBITMAPINFO lpbmi1, int infosize, void *lpbits1)
{
- LPBITMAPINFOHEADER lpdib2;
- unsigned char *lpbits2;
- void *whatever;
- int linesize, bitssize;
- HBITMAP hb;
- HDC hdc;
- HGDIOBJ rvgdi;
- int rvi;
- int width, height;
- LPBITMAPINFOHEADER lpdib1;
-
- lpdib1 = (LPBITMAPINFOHEADER)lpbmi1;
- width = lpdib1->biWidth;
- height = lpdib1->biHeight;
-
- linesize = (((width * lpdib1->biBitCount) + 31) / 32) * 4;
- bitssize = linesize * height;
-
- lpdib2 = (LPBITMAPINFOHEADER)malloc(infosize);
- if(!lpdib2) return NULL;
-
- // create a header for the new uncompressed DIB
- CopyMemory((void*)lpdib2, (void*)lpdib1, infosize);
- lpdib2->biCompression = BI_RGB;
- lpdib2->biSizeImage = 0;
-
- lpbits2 = (unsigned char*)malloc(bitssize);
- if(!lpbits2)
- {
- free((void*)lpdib2);
- return NULL;
- }
-
-
- // Windows bitmap handling functions are not exactly convenient,
- // especially when trying to deal with DIBs. Every function wants
- // to convert them into DDBs. We have to play stupid games and
- // convert back and forth. This probably uses too much memory,
- // and I'm not 100% sure it is exactly correct, but it seems to
- // work for me.
-
- hb = CreateDIBSection(NULL, (LPBITMAPINFO)lpdib2, DIB_RGB_COLORS, &whatever, NULL, 0);
-
- hdc = CreateCompatibleDC(NULL);
- rvgdi = SelectObject(hdc, hb);
- //SetStretchBltMode(hdc,COLORONCOLOR);
- rvi = StretchDIBits(hdc,
- 0, 0, width, height,
- 0, 0, width, height,
- lpbits1, (LPBITMAPINFO)lpdib1,
- DIB_RGB_COLORS, SRCCOPY);
- rvi = GetDIBits(hdc, hb, 0, height, (LPVOID)lpbits2,
- (LPBITMAPINFO)lpdib2, DIB_RGB_COLORS);
-
- DeleteDC(hdc);
- DeleteObject(hb);
- free((void*)lpdib2);
-
- return lpbits2;
+ LPBITMAPINFOHEADER lpdib2;
+ unsigned char *lpbits2;
+ void *whatever;
+ int linesize, bitssize;
+ HBITMAP hb;
+ HDC hdc;
+ HGDIOBJ rvgdi;
+ int rvi;
+ int width,height;
+ LPBITMAPINFOHEADER lpdib1;
+
+ lpdib1=(LPBITMAPINFOHEADER)lpbmi1;
+ width=lpdib1->biWidth;
+ height=lpdib1->biHeight;
+
+ linesize= (((width * lpdib1->biBitCount)+31)/32)*4;
+ bitssize= linesize*height;
+
+ lpdib2= (LPBITMAPINFOHEADER)malloc(infosize);
+ if(!lpdib2) return NULL;
+
+ // create a header for the new uncompressed DIB
+ CopyMemory((void*)lpdib2,(void*)lpdib1,infosize);
+ lpdib2->biCompression=BI_RGB;
+ lpdib2->biSizeImage=0;
+
+ lpbits2= (unsigned char*)malloc(bitssize);
+ if(!lpbits2) { free((void*)lpdib2); return NULL; }
+
+
+ // Windows bitmap handling functions are not exactly convenient,
+ // especially when trying to deal with DIBs. Every function wants
+ // to convert them into DDBs. We have to play stupid games and
+ // convert back and forth. This probably uses too much memory,
+ // and I'm not 100% sure it is exactly correct, but it seems to
+ // work for me.
+
+ hb=CreateDIBSection(NULL,(LPBITMAPINFO)lpdib2,DIB_RGB_COLORS,&whatever,NULL,0);
+
+ hdc=CreateCompatibleDC(NULL);
+ rvgdi=SelectObject(hdc,hb);
+ //SetStretchBltMode(hdc,COLORONCOLOR);
+ rvi=StretchDIBits(hdc,
+ 0,0,width,height,
+ 0,0,width,height,
+ lpbits1, (LPBITMAPINFO)lpdib1,
+ DIB_RGB_COLORS,SRCCOPY);
+ rvi=GetDIBits(hdc,hb,0,height, (LPVOID)lpbits2,
+ (LPBITMAPINFO)lpdib2,DIB_RGB_COLORS);
+
+ DeleteDC(hdc);
+ DeleteObject(hb);
+ free((void*)lpdib2);
+
+ return lpbits2;
}
static void my_png_error_fn(png_structp png_ptr, const char *err_msg)
{
- struct errstruct *errinfop;
- jmp_buf *j;
+ struct errstruct *errinfop;
+ jmp_buf *j;
- errinfop = (struct errstruct *)png_get_error_ptr(png_ptr);
- j = errinfop->jbufp;
+ errinfop = (struct errstruct *)png_get_error_ptr(png_ptr);
+ j = errinfop->jbufp;
#ifdef _UNICODE
- _snwprintf(errinfop->errmsg, MAX_ERRMSGLEN, _T("[libpng] %S"), err_msg);
+ _snwprintf(errinfop->errmsg,MAX_ERRMSGLEN,_T("[libpng] %S"),err_msg);
#else
- _snprintf(errinfop->errmsg, MAX_ERRMSGLEN, "[libpng] %s", err_msg);
+ _snprintf(errinfop->errmsg,MAX_ERRMSGLEN,"[libpng] %s",err_msg);
#endif
- errinfop->errmsg[MAX_ERRMSGLEN-1] = '\0';
- longjmp(*j, -1);
+ errinfop->errmsg[MAX_ERRMSGLEN-1]='\0';
+ longjmp(*j, -1);
}
static void my_png_warning_fn(png_structp png_ptr, const char *warn_msg)
{
- return;
+ return;
}
// A callback function used when reading memory-mapped PNG files.
static void my_png_read_fn(png_structp png_ptr,
- png_bytep data, png_size_t length)
+ png_bytep data, png_size_t length)
{
- struct p2d_struct *p2d;
+ struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)png_get_io_ptr(png_ptr);
+ p2d = (struct p2d_struct*)png_get_io_ptr(png_ptr);
- if(p2d->input_memblk_size > 0)
- {
- if((int)length > (p2d->input_memblk_size - p2d->input_memblk_curpos))
- {
- png_error(png_ptr, "read error: unexpected end of file");
- return;
- }
- }
+ if(p2d->input_memblk_size>0) {
+ if((int)length > (p2d->input_memblk_size - p2d->input_memblk_curpos)) {
+ png_error(png_ptr, "read error: unexpected end of file");
+ return;
+ }
+ }
- CopyMemory((void*)data, (void*)&p2d->input_memblk[p2d->input_memblk_curpos], length);
- p2d->input_memblk_curpos += length;
+ CopyMemory((void*)data,(void*)&p2d->input_memblk[p2d->input_memblk_curpos],length);
+ p2d->input_memblk_curpos+=length;
}
// This function should perform identically to libpng's gamma correction.
// I'd prefer to have libpng do all gamma correction itself,
// but I can't figure out how to do that efficiently.
-static void gamma_correct(double screen_gamma, double file_gamma,
- unsigned char *red, unsigned char *green, unsigned char *blue)
+static void gamma_correct(double screen_gamma,double file_gamma,
+ unsigned char *red, unsigned char *green, unsigned char *blue)
{
- double g;
+ double g;
#ifndef PNG_GAMMA_THRESHOLD
# define PNG_GAMMA_THRESHOLD 0.05
#endif
- if(fabs(screen_gamma * file_gamma - 1.0) <= PNG_GAMMA_THRESHOLD) return;
+ if(fabs(screen_gamma*file_gamma-1.0)<=PNG_GAMMA_THRESHOLD) return;
- if(screen_gamma > 0.000001)
- g = 1.0 / (file_gamma * screen_gamma);
- else
- g = 1.0;
+ if (screen_gamma>0.000001)
+ g=1.0/(file_gamma*screen_gamma);
+ else
+ g=1.0;
- (*red) = (unsigned char)(pow((double)(*red) / 255.0, g) * 255.0 + 0.5);
- (*green) = (unsigned char)(pow((double)(*green) / 255.0, g) * 255.0 + 0.5);
- (*blue) = (unsigned char)(pow((double)(*blue) / 255.0, g) * 255.0 + 0.5);
+ (*red) = (unsigned char)(pow((double)(*red )/255.0,g)*255.0+0.5);
+ (*green) = (unsigned char)(pow((double)(*green)/255.0,g)*255.0+0.5);
+ (*blue) = (unsigned char)(pow((double)(*blue )/255.0,g)*255.0+0.5);
}
int PNGDIB_DECL pngdib_p2d_run(PNGDIB *qq)
{
- struct p2d_struct *p2d;
-
- png_structp png_ptr;
- png_infop info_ptr;
- jmp_buf jbuf;
- struct errstruct errinfo;
- png_uint_32 width, height;
- int png_bit_depth, color_type, interlace_type;
- png_colorp png_palette;
- png_uint_32 res_x, res_y;
- int has_phys, has_gama;
- int res_unit_type;
- FILE *fp;
- int palette_entries;
- unsigned char **row_pointers;
- unsigned char *lpdib;
- unsigned char *dib_palette;
- unsigned char *dib_bits;
- unsigned char *tmprow;
- int dib_bpp, dib_bytesperrow;
- int i, j;
- int rv;
- png_color_16 bkgd; // used with png_set_background
- int has_trns, trns_color;
- int has_bkgd; // ==1 if there a bkgd chunk, and USE_BKGD flag
- png_color_16p temp_colorp;
- png_color_16p bg_colorp; // background color (if has_bkgd)
- png_bytep trns_trans;
- int manual_trns;
- int manual_gamma;
- struct PNGD_COLOR_struct bkgd_color;
- int is_grayscale, has_alpha_channel;
- double file_gamma;
- int dib_alpha32;
- int write_bitfields;
-
- p2d = (struct p2d_struct*)qq;
-
- dib_alpha32 = 0;
- write_bitfields = 0;
-
-
- manual_trns = 0;
- has_trns = has_bkgd = 0;
- rv = PNGD_E_ERROR;
- png_ptr = NULL;
- info_ptr = NULL;
- fp = NULL;
- row_pointers = NULL;
- lpdib = NULL;
-
- lstrcpy(p2d->common.errmsg, _T(""));
-
- if(p2d->use_custom_bg_flag)
- {
- bkgd_color.red = p2d->bgcolor.red;
- bkgd_color.green = p2d->bgcolor.green;
- bkgd_color.blue = p2d->bgcolor.blue;
- }
- else
- {
- bkgd_color.red = 255; // Should never get used. If the
- bkgd_color.green = 128; // background turns orange, it's a bug.
- bkgd_color.blue = 0;
- }
-
- // Set the user-defined pointer to point to our jmp_buf. This will
- // hopefully protect against potentially different sized jmp_buf's in
- // libpng, while still allowing this library to be threadsafe.
- errinfo.jbufp = &jbuf;
- errinfo.errmsg = p2d->common.errmsg;
-
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (void*)(&errinfo),
- my_png_error_fn, my_png_warning_fn);
- if(!png_ptr)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
-
- info_ptr = png_create_info_struct(png_ptr);
- if(!info_ptr)
- {
- //png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
- if(setjmp(jbuf))
- {
- // we'll get here if an error occurred in any of the following
- // png_ functions
-
- rv = PNGD_E_LIBPNG;
- goto abort;
- }
-
- if(p2d->input_method == 0)
- {
- // reading from a filename
- if(!p2d->input_filename)
- {
- wsprintf(p2d->common.errmsg, _T("Input filename not set"));
- rv = PNGD_E_ERROR;
- goto abort;
- }
-
- if((fp = _tfopen(p2d->input_filename, _T("rb"))) == NULL)
- {
- rv = PNGD_E_READ;
- goto abort;
- }
- png_init_io(png_ptr, fp);
- }
- else if(p2d->input_method == 1)
- {
- // reading from a memory block
- p2d->input_memblk_curpos = 0;
- png_set_read_fn(png_ptr, (void*)p2d, my_png_read_fn);
- }
- else
- {
- goto abort;
- }
-
- png_read_info(png_ptr, info_ptr);
-
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &png_bit_depth, &color_type,
- &interlace_type, NULL, NULL);
-
- p2d->color_type = color_type;
- p2d->bits_per_sample = png_bit_depth;
- p2d->interlace = interlace_type;
- switch(color_type)
- {
- case PNG_COLOR_TYPE_RGB:
- p2d->bits_per_pixel = png_bit_depth * 3;
- break;
- case PNG_COLOR_TYPE_RGB_ALPHA:
- p2d->bits_per_pixel = png_bit_depth * 4;
- break;
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- p2d->bits_per_pixel = png_bit_depth * 2;
- break;
- default:
- p2d->bits_per_pixel = png_bit_depth;
- }
-
- is_grayscale = !(color_type & PNG_COLOR_MASK_COLOR);
- has_alpha_channel = (color_type & PNG_COLOR_MASK_ALPHA) ? 1 : 0;
-
- has_trns = png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS);
-
- if(p2d->common.dib_alpha32 && (has_trns || has_alpha_channel))
- {
- // Fixme - if trns(for palette) has no transparent entries,
- // we could skip this.
- dib_alpha32 = 1;
- write_bitfields = 1;
-
- if(!(color_type & PNG_COLOR_MASK_COLOR))
- {
- png_set_gray_to_rgb(png_ptr);
- }
- else if(color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_set_palette_to_rgb(png_ptr);
- }
-
- if(has_trns) png_set_tRNS_to_alpha(png_ptr);
-
- goto notrans;
- }
-
- // look for bKGD chunk, and process if applicable
- if(p2d->use_file_bg_flag)
- {
- if(png_get_bKGD(png_ptr, info_ptr, &bg_colorp))
- {
- // process the background, store 8-bit RGB in bkgd_color
- has_bkgd = 1;
-
- if(is_grayscale && png_bit_depth < 8)
- {
- bkgd_color.red =
- bkgd_color.green =
- bkgd_color.blue =
- (unsigned char)((bg_colorp->gray * 255) / ((1 << png_bit_depth) - 1));
- }
- else if(png_bit_depth <= 8)
- {
- bkgd_color.red = (unsigned char)(bg_colorp->red);
- bkgd_color.green = (unsigned char)(bg_colorp->green);
- bkgd_color.blue = (unsigned char)(bg_colorp->blue);
- }
- else
- {
- bkgd_color.red = (unsigned char)(bg_colorp->red >> 8);
- bkgd_color.green = (unsigned char)(bg_colorp->green >> 8);
- bkgd_color.blue = (unsigned char)(bg_colorp->blue >> 8);
- }
- }
- }
-
- if(!(color_type & PNG_COLOR_MASK_ALPHA) && !has_trns)
- {
- // If no transparency, we can skip this whole background-color mess.
- goto notrans;
- }
-
- if(has_bkgd && (png_bit_depth > 8 || !is_grayscale || has_alpha_channel))
- {
- png_set_background(png_ptr, bg_colorp,
- PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
- }
- else if(is_grayscale && has_trns && png_bit_depth <= 8
- && (has_bkgd || (p2d->use_custom_bg_flag)))
- {
- // grayscale binarytrans,<=8bpp: transparency is handle manually
- // by modifying a palette entry (later)
- png_get_tRNS(png_ptr, info_ptr, &trns_trans, &i, &temp_colorp);
- if(i >= 1)
- {
- trns_color = temp_colorp->gray; // corresponds to a palette entry
- manual_trns = 1;
- }
- }
- else if(!has_bkgd && (has_trns || has_alpha_channel) &&
- (p2d->use_custom_bg_flag))
- {
- // process most CUSTOM background colors
- bkgd.index = 0; // unused
- bkgd.red = p2d->bgcolor.red;
- bkgd.green = p2d->bgcolor.green;
- bkgd.blue = p2d->bgcolor.blue;
-
- // libpng may use bkgd.gray if bkgd.red==bkgd.green==bkgd.blue.
- // Not sure if that's a libpng bug or not.
- bkgd.gray = p2d->bgcolor.red;
-
- if(png_bit_depth > 8)
- {
- bkgd.red = (bkgd.red << 8) | bkgd.red;
- bkgd.green = (bkgd.green << 8) | bkgd.green;
- bkgd.blue = (bkgd.blue << 8) | bkgd.blue;
- bkgd.gray = (bkgd.gray << 8) | bkgd.gray;
- }
-
- if(is_grayscale)
- {
- /* assert(png_bit_depth>8); */
-
- /* Need to expand to full RGB if unless background is pure gray */
- if(bkgd.red != bkgd.green || bkgd.red != bkgd.blue)
- {
- png_set_gray_to_rgb(png_ptr);
-
- // png_set_tRNS_to_alpha() is called here because otherwise
- // binary transparency for 16-bps grayscale images doesn't
- // work. Libpng will think black pixels are transparent.
- // I don't know exactly why it works. It does *not* add an
- // alpha channel, as you might think (adding an alpha
- // channnel makes no sense if you are using
- // png_set_background).
- //
- // Here's an alternate hack that also seems to work, but
- // uses direct structure access:
- //
- // png_ptr->trans_values.red =
- // png_ptr->trans_values.green =
- // png_ptr->trans_values.blue = png_ptr->trans_values.gray;
- if(has_trns)
- png_set_tRNS_to_alpha(png_ptr);
-
- png_set_background(png_ptr, &bkgd,
- PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
-
- }
- else // gray custom background
- {
- png_set_background(png_ptr, &bkgd,
- PNG_BACKGROUND_GAMMA_SCREEN, 1, 1.0);
- }
-
- }
- else
- {
- png_set_background(png_ptr, &bkgd,
- PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
- }
- }
+ struct p2d_struct *p2d;
+
+ png_structp png_ptr;
+ png_infop info_ptr;
+ jmp_buf jbuf;
+ struct errstruct errinfo;
+ png_uint_32 width, height;
+ int png_bit_depth, color_type, interlace_type;
+ png_colorp png_palette;
+ png_uint_32 res_x, res_y;
+ int has_phys, has_gama;
+ int res_unit_type;
+ FILE *fp;
+ int palette_entries;
+ unsigned char **row_pointers;
+ unsigned char *lpdib;
+ unsigned char *dib_palette;
+ unsigned char *dib_bits;
+ unsigned char *tmprow;
+ int dib_bpp, dib_bytesperrow;
+ int i,j;
+ int rv;
+ png_color_16 bkgd; // used with png_set_background
+ int has_trns, trns_color;
+ int has_bkgd; // ==1 if there a bkgd chunk, and USE_BKGD flag
+ png_color_16p temp_colorp;
+ png_color_16p bg_colorp; // background color (if has_bkgd)
+ png_bytep trns_trans;
+ int manual_trns;
+ int manual_gamma;
+ struct PNGD_COLOR_struct bkgd_color;
+ int is_grayscale,has_alpha_channel;
+ double file_gamma;
+ int dib_alpha32;
+ int write_bitfields;
+
+ p2d=(struct p2d_struct*)qq;
+
+ dib_alpha32=0;
+ write_bitfields=0;
+
+
+ manual_trns=0;
+ has_trns=has_bkgd=0;
+ rv=PNGD_E_ERROR;
+ png_ptr=NULL;
+ info_ptr=NULL;
+ fp=NULL;
+ row_pointers=NULL;
+ lpdib=NULL;
+
+ lstrcpy(p2d->common.errmsg,_T(""));
+
+ if(p2d->use_custom_bg_flag) {
+ bkgd_color.red= p2d->bgcolor.red;
+ bkgd_color.green= p2d->bgcolor.green;
+ bkgd_color.blue= p2d->bgcolor.blue;
+ }
+ else {
+ bkgd_color.red= 255; // Should never get used. If the
+ bkgd_color.green= 128; // background turns orange, it's a bug.
+ bkgd_color.blue= 0;
+ }
+
+ // Set the user-defined pointer to point to our jmp_buf. This will
+ // hopefully protect against potentially different sized jmp_buf's in
+ // libpng, while still allowing this library to be threadsafe.
+ errinfo.jbufp = &jbuf;
+ errinfo.errmsg = p2d->common.errmsg;
+
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,(void*)(&errinfo),
+ my_png_error_fn, my_png_warning_fn);
+ if(!png_ptr) { rv=PNGD_E_NOMEM; goto abort; }
+
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if(!info_ptr) {
+ //png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+ rv=PNGD_E_NOMEM; goto abort;
+ }
+
+ if(setjmp(jbuf)) {
+ // we'll get here if an error occurred in any of the following
+ // png_ functions
+
+ rv=PNGD_E_LIBPNG;
+ goto abort;
+ }
+
+ if(p2d->input_method==0) {
+ // reading from a filename
+ if(!p2d->input_filename) {
+ wsprintf(p2d->common.errmsg,_T("Input filename not set"));
+ rv=PNGD_E_ERROR; goto abort;
+ }
+
+ if((fp = _tfopen(p2d->input_filename,_T("rb"))) == NULL) {
+ rv=PNGD_E_READ;
+ goto abort;
+ }
+ png_init_io(png_ptr, fp);
+ }
+ else if(p2d->input_method==1) {
+ // reading from a memory block
+ p2d->input_memblk_curpos=0;
+ png_set_read_fn(png_ptr, (void*)p2d, my_png_read_fn);
+ }
+ else { goto abort; }
+
+ png_read_info(png_ptr, info_ptr);
+
+ png_get_IHDR(png_ptr, info_ptr, &width, &height, &png_bit_depth, &color_type,
+ &interlace_type, NULL, NULL);
+
+ p2d->color_type=color_type;
+ p2d->bits_per_sample=png_bit_depth;
+ p2d->interlace=interlace_type;
+ switch(color_type) {
+ case PNG_COLOR_TYPE_RGB: p2d->bits_per_pixel=png_bit_depth*3; break;
+ case PNG_COLOR_TYPE_RGB_ALPHA: p2d->bits_per_pixel=png_bit_depth*4; break;
+ case PNG_COLOR_TYPE_GRAY_ALPHA: p2d->bits_per_pixel=png_bit_depth*2; break;
+ default: p2d->bits_per_pixel=png_bit_depth;
+ }
+
+ is_grayscale = !(color_type&PNG_COLOR_MASK_COLOR);
+ has_alpha_channel = (color_type&PNG_COLOR_MASK_ALPHA)?1:0;
+
+ has_trns = png_get_valid(png_ptr,info_ptr,PNG_INFO_tRNS);
+
+ if(p2d->common.dib_alpha32 && (has_trns || has_alpha_channel)) {
+ // Fixme - if trns(for palette) has no transparent entries,
+ // we could skip this.
+ dib_alpha32=1;
+ write_bitfields=1;
+
+ if (!(color_type&PNG_COLOR_MASK_COLOR)) {
+ png_set_gray_to_rgb(png_ptr);
+ }
+ else if(color_type==PNG_COLOR_TYPE_PALETTE) {
+ png_set_palette_to_rgb(png_ptr);
+ }
+
+ if (has_trns) png_set_tRNS_to_alpha(png_ptr);
+
+ goto notrans;
+ }
+
+ // look for bKGD chunk, and process if applicable
+ if(p2d->use_file_bg_flag) {
+ if(png_get_bKGD(png_ptr, info_ptr, &bg_colorp)) {
+ // process the background, store 8-bit RGB in bkgd_color
+ has_bkgd=1;
+
+ if(is_grayscale && png_bit_depth<8) {
+ bkgd_color.red =
+ bkgd_color.green=
+ bkgd_color.blue =
+ (unsigned char) ( (bg_colorp->gray*255)/( (1<<png_bit_depth)-1 ) );
+ }
+ else if(png_bit_depth<=8) {
+ bkgd_color.red=(unsigned char)(bg_colorp->red);
+ bkgd_color.green=(unsigned char)(bg_colorp->green);
+ bkgd_color.blue =(unsigned char)(bg_colorp->blue);
+ }
+ else {
+ bkgd_color.red=(unsigned char)(bg_colorp->red>>8);
+ bkgd_color.green=(unsigned char)(bg_colorp->green>>8);
+ bkgd_color.blue =(unsigned char)(bg_colorp->blue>>8);
+ }
+ }
+ }
+
+ if( !(color_type & PNG_COLOR_MASK_ALPHA) && !has_trns) {
+ // If no transparency, we can skip this whole background-color mess.
+ goto notrans;
+ }
+
+ if(has_bkgd && (png_bit_depth>8 || !is_grayscale || has_alpha_channel)) {
+ png_set_background(png_ptr, bg_colorp,
+ PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+ }
+ else if(is_grayscale && has_trns && png_bit_depth<=8
+ && (has_bkgd || (p2d->use_custom_bg_flag)) )
+ {
+ // grayscale binarytrans,<=8bpp: transparency is handle manually
+ // by modifying a palette entry (later)
+ png_get_tRNS(png_ptr,info_ptr,&trns_trans, &i, &temp_colorp);
+ if(i>=1) {
+ trns_color= temp_colorp->gray; // corresponds to a palette entry
+ manual_trns=1;
+ }
+ }
+ else if(!has_bkgd && (has_trns || has_alpha_channel) &&
+ (p2d->use_custom_bg_flag) )
+ { // process most CUSTOM background colors
+ bkgd.index = 0; // unused
+ bkgd.red = p2d->bgcolor.red;
+ bkgd.green = p2d->bgcolor.green;
+ bkgd.blue = p2d->bgcolor.blue;
+
+ // libpng may use bkgd.gray if bkgd.red==bkgd.green==bkgd.blue.
+ // Not sure if that's a libpng bug or not.
+ bkgd.gray = p2d->bgcolor.red;
+
+ if(png_bit_depth>8) {
+ bkgd.red = (bkgd.red <<8)|bkgd.red;
+ bkgd.green= (bkgd.green<<8)|bkgd.green;
+ bkgd.blue = (bkgd.blue <<8)|bkgd.blue;
+ bkgd.gray = (bkgd.gray <<8)|bkgd.gray;
+ }
+
+ if(is_grayscale) {
+ /* assert(png_bit_depth>8); */
+
+ /* Need to expand to full RGB if unless background is pure gray */
+ if(bkgd.red!=bkgd.green || bkgd.red!=bkgd.blue) {
+ png_set_gray_to_rgb(png_ptr);
+
+ // png_set_tRNS_to_alpha() is called here because otherwise
+ // binary transparency for 16-bps grayscale images doesn't
+ // work. Libpng will think black pixels are transparent.
+ // I don't know exactly why it works. It does *not* add an
+ // alpha channel, as you might think (adding an alpha
+ // channnel makes no sense if you are using
+ // png_set_background).
+ //
+ // Here's an alternate hack that also seems to work, but
+ // uses direct structure access:
+ //
+ // png_ptr->trans_values.red =
+ // png_ptr->trans_values.green =
+ // png_ptr->trans_values.blue = png_ptr->trans_values.gray;
+ if(has_trns)
+ png_set_tRNS_to_alpha(png_ptr);
+
+ png_set_background(png_ptr, &bkgd,
+ PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+
+ }
+ else { // gray custom background
+ png_set_background(png_ptr, &bkgd,
+ PNG_BACKGROUND_GAMMA_SCREEN, 1, 1.0);
+ }
+
+ }
+ else {
+ png_set_background(png_ptr, &bkgd,
+ PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+ }
+ }
notrans:
- // If we don't have any background color at all that we can use,
- // strip the alpha channel.
- if(!dib_alpha32 && has_alpha_channel && !has_bkgd &&
- !(p2d->use_custom_bg_flag))
- {
- png_set_strip_alpha(png_ptr);
- }
-
- if(png_bit_depth > 8)
- png_set_strip_16(png_ptr);
-
- if(png_get_sRGB(png_ptr, info_ptr, &i))
- {
- has_gama = 1;
- file_gamma = 0.45455;
- }
- else if(png_get_gAMA(png_ptr, info_ptr, &file_gamma))
- {
- has_gama = 1;
- }
- else
- {
- has_gama = 0;
- file_gamma = 0.45455;
- }
-
- if(/*imginfo && */ has_gama)
- {
- p2d->file_gamma = file_gamma;
- p2d->gamma_returned = 1;
- }
-
- manual_gamma = 0;
- if(p2d->gamma_correction)
- {
-
- if(!is_grayscale || png_bit_depth > 8 || has_alpha_channel)
- {
- png_set_gamma(png_ptr, p2d->screen_gamma, file_gamma);
- //png_ptr->transformations |= 0x2000; // hack for old libpng versions
- }
- else manual_gamma = 1;
-
- if(has_bkgd)
- {
- // Gamma correct the background color (if we got it from the file)
- // before returning it to the app.
- gamma_correct(p2d->screen_gamma, file_gamma, &bkgd_color.red, &bkgd_color.green, &bkgd_color.blue);
- }
- }
-
- png_read_update_info(png_ptr, info_ptr);
-
- // color type may have changed, due to our transformations
- color_type = png_get_color_type(png_ptr, info_ptr);
-
-
- switch(color_type)
- {
- case PNG_COLOR_TYPE_RGB_ALPHA:
- assert(dib_alpha32);
- dib_bpp = 32;
- palette_entries = 0;
- png_set_bgr(png_ptr);
- break;
- case PNG_COLOR_TYPE_RGB:
- dib_bpp = 24;
- palette_entries = 0;
- png_set_bgr(png_ptr);
- break;
- case PNG_COLOR_TYPE_PALETTE:
- dib_bpp = png_bit_depth;
- png_get_PLTE(png_ptr, info_ptr, &png_palette, &palette_entries);
- break;
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- dib_bpp = png_bit_depth;
- if(png_bit_depth > 8) dib_bpp = 8;
- palette_entries = 1 << dib_bpp;
- // we'll construct a grayscale palette later
- break;
- default:
- rv = PNGD_E_BADPNG;
- goto abort;
- }
-
- if(dib_bpp == 2) dib_bpp = 4;
-
- has_phys = png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs);
- if(has_phys)
- {
- png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &res_unit_type);
- if(res_x > 0 && res_y > 0)
- {
- p2d->res_x = res_x;
- p2d->res_y = res_y;
- p2d->res_units = res_unit_type;
- p2d->res_valid = 1;
- }
- }
-
- // DIB scanlines are padded to 4-byte boundaries.
- dib_bytesperrow = (((width * dib_bpp) + 31) / 32) * 4;
-
- p2d->bitssize = height * dib_bytesperrow;
-
- p2d->dibsize = sizeof(BITMAPINFOHEADER) + 4 * palette_entries +
- (write_bitfields ? 12 : 0) + p2d->bitssize;
-
- if(p2d->common.malloc_function)
- {
- lpdib = (unsigned char*)(*(p2d->common.malloc_function))(p2d->common.userdata, p2d->dibsize);
- }
- else
- {
- lpdib = (unsigned char*)calloc(p2d->dibsize, 1);
- }
-
-
- if(!lpdib)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
- p2d->pdib = (LPBITMAPINFOHEADER)lpdib;
-
- row_pointers = (unsigned char**)malloc(height * sizeof(unsigned char*));
- if(!row_pointers)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
- // there is some redundancy here...
- p2d->palette_offs = sizeof(BITMAPINFOHEADER);
- p2d->bits_offs = sizeof(BITMAPINFOHEADER) + 4 * palette_entries + (write_bitfields ? 12 : 0);
- dib_palette = &lpdib[p2d->palette_offs];
- p2d->palette = (RGBQUAD*)dib_palette;
- dib_bits = &lpdib[p2d->bits_offs];
- p2d->pbits = (VOID*)dib_bits;
- p2d->palette_colors = palette_entries;
-
- // set up the DIB palette, if needed
- switch(color_type)
- {
- case PNG_COLOR_TYPE_PALETTE:
- for(i = 0; i < palette_entries; i++)
- {
- p2d->palette[i].rgbRed = png_palette[i].red;
- p2d->palette[i].rgbGreen = png_palette[i].green;
- p2d->palette[i].rgbBlue = png_palette[i].blue;
- }
- break;
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- for(i = 0; i < palette_entries; i++)
- {
- p2d->palette[i].rgbRed =
- p2d->palette[i].rgbGreen =
- p2d->palette[i].rgbBlue = (i * 255) / (palette_entries - 1);
- if(manual_gamma)
- {
- gamma_correct(p2d->screen_gamma, file_gamma,
- &(p2d->palette[i].rgbRed),
- &(p2d->palette[i].rgbGreen),
- &(p2d->palette[i].rgbBlue));
- }
- }
- if(manual_trns)
- {
- p2d->palette[trns_color].rgbRed = bkgd_color.red;
- p2d->palette[trns_color].rgbGreen = bkgd_color.green;
- p2d->palette[trns_color].rgbBlue = bkgd_color.blue;
- }
- break;
- }
-
- // set up BITFIELDS, if needed
- if(dib_alpha32)
- {
- static const unsigned char bf_data[12] =
- {
- 0x00, 0x00, 0xff, 0x00,
- 0x00, 0xff, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0x00
- };
-
- for(i = 0; i < 12; i++)
- {
- lpdib[p2d->palette_offs+i] = bf_data[i];
- }
-
- }
-
- for(j = 0; j < (int)height; j++)
- {
- row_pointers[height-1-j] = &dib_bits[j*dib_bytesperrow];
- }
-
- png_read_image(png_ptr, row_pointers);
-
- // special handling for this bit depth, since it doesn't exist in DIBs
- // expand 2bpp to 4bpp
- if(png_bit_depth == 2)
- {
- tmprow = (unsigned char*)malloc((width + 3) / 4);
- if(!tmprow)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
- for(j = 0; j < (int)height; j++)
- {
- CopyMemory(tmprow, row_pointers[j], (width + 3) / 4);
- ZeroMemory(row_pointers[j], (width + 1) / 2);
-
- for(i = 0; i < (int)width; i++)
- {
- row_pointers[j][i/2] |=
- (((tmprow[i/4] >> (2 * (3 - i % 4))) & 0x03) << (4 * (1 - i % 2)));
- }
- }
- free((void*)tmprow);
- }
-
- free((void*)row_pointers);
- row_pointers = NULL;
-
- png_read_end(png_ptr, info_ptr);
-
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
- png_ptr = NULL;
-
- if(p2d->input_method == 0)
- {
- fclose(fp);
- fp = NULL;
- }
-
- // fill in the DIB header fields
- p2d->pdib->biSize = sizeof(BITMAPINFOHEADER);
- p2d->pdib->biWidth = width;
- p2d->pdib->biHeight = height;
- p2d->pdib->biPlanes = 1;
- p2d->pdib->biBitCount = dib_bpp;
- p2d->pdib->biCompression = write_bitfields ? BI_BITFIELDS : BI_RGB;
- // biSizeImage can also be 0 in uncompressed bitmaps
- p2d->pdib->biSizeImage = height * dib_bytesperrow;
-
- if(has_phys)
- {
- if(res_unit_type == 1)
- {
- p2d->pdib->biXPelsPerMeter = res_x;
- p2d->pdib->biYPelsPerMeter = res_y;
- }
- }
- p2d->pdib->biClrUsed = palette_entries;
- p2d->pdib->biClrImportant = 0;
-
- if(has_bkgd || (p2d->use_custom_bg_flag))
- {
- // return the background color if one was used
- p2d->bgcolor.red = bkgd_color.red;
- p2d->bgcolor.green = bkgd_color.green;
- p2d->bgcolor.blue = bkgd_color.blue;
- p2d->bgcolor_returned = 1;
- }
-
- return PNGD_E_SUCCESS;
+ // If we don't have any background color at all that we can use,
+ // strip the alpha channel.
+ if(!dib_alpha32 && has_alpha_channel && !has_bkgd &&
+ !(p2d->use_custom_bg_flag) )
+ {
+ png_set_strip_alpha(png_ptr);
+ }
+
+ if(png_bit_depth>8)
+ png_set_strip_16(png_ptr);
+
+ if (png_get_sRGB(png_ptr, info_ptr, &i)) {
+ has_gama=1;
+ file_gamma = 0.45455;
+ }
+ else if(png_get_gAMA(png_ptr, info_ptr, &file_gamma)) {
+ has_gama=1;
+ }
+ else {
+ has_gama=0;
+ file_gamma = 0.45455;
+ }
+
+ if(/*imginfo && */ has_gama) {
+ p2d->file_gamma=file_gamma;
+ p2d->gamma_returned=1;
+ }
+
+ manual_gamma=0;
+ if(p2d->gamma_correction) {
+
+ if(!is_grayscale || png_bit_depth>8 || has_alpha_channel) {
+ png_set_gamma(png_ptr, p2d->screen_gamma, file_gamma);
+ //png_ptr->transformations |= 0x2000; // hack for old libpng versions
+ }
+ else manual_gamma=1;
+
+ if(has_bkgd) {
+ // Gamma correct the background color (if we got it from the file)
+ // before returning it to the app.
+ gamma_correct(p2d->screen_gamma,file_gamma,&bkgd_color.red,&bkgd_color.green,&bkgd_color.blue);
+ }
+ }
+
+ png_read_update_info(png_ptr, info_ptr);
+
+ // color type may have changed, due to our transformations
+ color_type = png_get_color_type(png_ptr,info_ptr);
+
+
+ switch(color_type) {
+ case PNG_COLOR_TYPE_RGB_ALPHA:
+ assert(dib_alpha32);
+ dib_bpp= 32;
+ palette_entries=0;
+ png_set_bgr(png_ptr);
+ break;
+ case PNG_COLOR_TYPE_RGB:
+ dib_bpp= 24;
+ palette_entries=0;
+ png_set_bgr(png_ptr);
+ break;
+ case PNG_COLOR_TYPE_PALETTE:
+ dib_bpp=png_bit_depth;
+ png_get_PLTE(png_ptr,info_ptr,&png_palette,&palette_entries);
+ break;
+ case PNG_COLOR_TYPE_GRAY:
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ dib_bpp=png_bit_depth;
+ if(png_bit_depth>8) dib_bpp=8;
+ palette_entries= 1<<dib_bpp;
+ // we'll construct a grayscale palette later
+ break;
+ default:
+ rv=PNGD_E_BADPNG;
+ goto abort;
+ }
+
+ if(dib_bpp==2) dib_bpp=4;
+
+ has_phys=png_get_valid(png_ptr,info_ptr,PNG_INFO_pHYs);
+ if(has_phys) {
+ png_get_pHYs(png_ptr,info_ptr,&res_x,&res_y,&res_unit_type);
+ if(res_x>0 && res_y>0) {
+ p2d->res_x=res_x;
+ p2d->res_y=res_y;
+ p2d->res_units=res_unit_type;
+ p2d->res_valid=1;
+ }
+ }
+
+ // DIB scanlines are padded to 4-byte boundaries.
+ dib_bytesperrow= (((width * dib_bpp)+31)/32)*4;
+
+ p2d->bitssize = height*dib_bytesperrow;
+
+ p2d->dibsize=sizeof(BITMAPINFOHEADER) + 4*palette_entries +
+ (write_bitfields?12:0) + p2d->bitssize;
+
+ if(p2d->common.malloc_function) {
+ lpdib = (unsigned char*)(*(p2d->common.malloc_function))(p2d->common.userdata,p2d->dibsize);
+ }
+ else {
+ lpdib = (unsigned char*)calloc(p2d->dibsize,1);
+ }
+
+
+ if(!lpdib) { rv=PNGD_E_NOMEM; goto abort; }
+ p2d->pdib = (LPBITMAPINFOHEADER)lpdib;
+
+ row_pointers=(unsigned char**)malloc(height*sizeof(unsigned char*));
+ if(!row_pointers) { rv=PNGD_E_NOMEM; goto abort; }
+
+ // there is some redundancy here...
+ p2d->palette_offs=sizeof(BITMAPINFOHEADER);
+ p2d->bits_offs =sizeof(BITMAPINFOHEADER) + 4*palette_entries + (write_bitfields?12:0);
+ dib_palette= &lpdib[p2d->palette_offs];
+ p2d->palette= (RGBQUAD*)dib_palette;
+ dib_bits = &lpdib[p2d->bits_offs];
+ p2d->pbits = (VOID*)dib_bits;
+ p2d->palette_colors = palette_entries;
+
+ // set up the DIB palette, if needed
+ switch(color_type) {
+ case PNG_COLOR_TYPE_PALETTE:
+ for(i=0;i<palette_entries;i++) {
+ p2d->palette[i].rgbRed = png_palette[i].red;
+ p2d->palette[i].rgbGreen = png_palette[i].green;
+ p2d->palette[i].rgbBlue = png_palette[i].blue;
+ }
+ break;
+ case PNG_COLOR_TYPE_GRAY:
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ for(i=0;i<palette_entries;i++) {
+ p2d->palette[i].rgbRed =
+ p2d->palette[i].rgbGreen =
+ p2d->palette[i].rgbBlue = (i*255)/(palette_entries-1);
+ if(manual_gamma) {
+ gamma_correct(p2d->screen_gamma,file_gamma,
+ &(p2d->palette[i].rgbRed),
+ &(p2d->palette[i].rgbGreen),
+ &(p2d->palette[i].rgbBlue));
+ }
+ }
+ if(manual_trns) {
+ p2d->palette[trns_color].rgbRed = bkgd_color.red;
+ p2d->palette[trns_color].rgbGreen = bkgd_color.green;
+ p2d->palette[trns_color].rgbBlue = bkgd_color.blue;
+ }
+ break;
+ }
+
+ // set up BITFIELDS, if needed
+ if(dib_alpha32) {
+ static const unsigned char bf_data[12] = {
+ 0x00,0x00,0xff,0x00,
+ 0x00,0xff,0x00,0x00,
+ 0xff,0x00,0x00,0x00
+ };
+
+ for(i=0;i<12;i++) {
+ lpdib[p2d->palette_offs+i]=bf_data[i];
+ }
+
+ }
+
+ for(j=0;j<(int)height;j++) {
+ row_pointers[height-1-j]= &dib_bits[j*dib_bytesperrow];
+ }
+
+ png_read_image(png_ptr, row_pointers);
+
+ // special handling for this bit depth, since it doesn't exist in DIBs
+ // expand 2bpp to 4bpp
+ if(png_bit_depth==2) {
+ tmprow = (unsigned char*)malloc((width+3)/4 );
+ if(!tmprow) { rv=PNGD_E_NOMEM; goto abort; }
+
+ for(j=0;j<(int)height;j++) {
+ CopyMemory(tmprow, row_pointers[j], (width+3)/4 );
+ ZeroMemory(row_pointers[j], (width+1)/2 );
+
+ for(i=0;i<(int)width;i++) {
+ row_pointers[j][i/2] |=
+ ( ((tmprow[i/4] >> (2*(3-i%4)) ) & 0x03)<< (4*(1-i%2)) );
+ }
+ }
+ free((void*)tmprow);
+ }
+
+ free((void*)row_pointers);
+ row_pointers=NULL;
+
+ png_read_end(png_ptr, info_ptr);
+
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ png_ptr=NULL;
+
+ if(p2d->input_method==0) {
+ fclose(fp);
+ fp=NULL;
+ }
+
+ // fill in the DIB header fields
+ p2d->pdib->biSize= sizeof(BITMAPINFOHEADER);
+ p2d->pdib->biWidth= width;
+ p2d->pdib->biHeight= height;
+ p2d->pdib->biPlanes= 1;
+ p2d->pdib->biBitCount= dib_bpp;
+ p2d->pdib->biCompression= write_bitfields?BI_BITFIELDS:BI_RGB;
+ // biSizeImage can also be 0 in uncompressed bitmaps
+ p2d->pdib->biSizeImage= height*dib_bytesperrow;
+
+ if(has_phys) {
+ if(res_unit_type==1) {
+ p2d->pdib->biXPelsPerMeter= res_x;
+ p2d->pdib->biYPelsPerMeter= res_y;
+ }
+ }
+ p2d->pdib->biClrUsed= palette_entries;
+ p2d->pdib->biClrImportant= 0;
+
+ if(has_bkgd || (p2d->use_custom_bg_flag)) {
+ // return the background color if one was used
+ p2d->bgcolor.red = bkgd_color.red;
+ p2d->bgcolor.green = bkgd_color.green;
+ p2d->bgcolor.blue = bkgd_color.blue;
+ p2d->bgcolor_returned=1;
+ }
+
+ return PNGD_E_SUCCESS;
abort:
- if(png_ptr) png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
- if(p2d->input_method == 0 && fp) fclose(fp);
- if(row_pointers) free((void*)row_pointers);
- if(lpdib)
- {
- pngdib_p2d_free_dib((PNGDIB*)p2d, NULL);
- }
-
- // If we don't have an error message yet, use a
- // default one based on the code
- if(!lstrlen(p2d->common.errmsg))
- {
- pngd_get_error_message(rv, p2d->common.errmsg);
- }
-
- return rv;
+ if(png_ptr) png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ if(p2d->input_method==0 && fp) fclose(fp);
+ if(row_pointers) free((void*)row_pointers);
+ if(lpdib) {
+ pngdib_p2d_free_dib((PNGDIB*)p2d,NULL);
+ }
+
+ // If we don't have an error message yet, use a
+ // default one based on the code
+ if(!lstrlen(p2d->common.errmsg)) {
+ pngd_get_error_message(rv,p2d->common.errmsg);
+ }
+
+ return rv;
}
void PNGDIB_DECL pngdib_p2d_free_dib(PNGDIB *qq, BITMAPINFOHEADER* pdib)
{
- struct p2d_struct *p2d;
-
- if(!qq)
- {
- if(pdib) free((void*)pdib);
- return;
- }
-
- p2d = (struct p2d_struct*)qq;
- if(!pdib)
- {
- // DIB not explicitly given; use the one from the PNGDIB object.
- // (this is the normal case)
- pdib = p2d->pdib;
- p2d->pdib = NULL;
- }
- if(pdib)
- {
- if(p2d->common.free_function)
- {
- (*(p2d->common.free_function))(p2d->common.userdata, (void*)pdib);
- }
- else
- {
- free((void*)pdib);
- }
- }
+ struct p2d_struct *p2d;
+
+ if(!qq) {
+ if(pdib) free((void*)pdib);
+ return;
+ }
+
+ p2d=(struct p2d_struct*)qq;
+ if(!pdib) {
+ // DIB not explicitly given; use the one from the PNGDIB object.
+ // (this is the normal case)
+ pdib = p2d->pdib;
+ p2d->pdib = NULL;
+ }
+ if(pdib) {
+ if(p2d->common.free_function) {
+ (*(p2d->common.free_function))(p2d->common.userdata,(void*)pdib);
+ }
+ else {
+ free((void*)pdib);
+ }
+ }
}
int PNGDIB_DECL pngdib_d2p_run(PNGDIB *qq)
{
- struct d2p_struct *d2p;
- png_structp png_ptr;
- png_infop info_ptr;
- jmp_buf jbuf;
- struct errstruct errinfo;
- png_text text_ptr[1];
- unsigned char *bits;
- unsigned char *newimage;
- RGBQUAD* dib_palette;
- int headersize, dib_bpp;
- int png_color_type;
- png_uint_32 res_x, res_y;
- png_color_8 pngc8;
- int height, width;
- int palette_entries;
- int topdown;
- int dib_bytesperrow;
- int compression;
- FILE *fp;
- png_color png_palette[256];
- unsigned char **row_pointers;
- int i, x, y, size;
- DWORD *bitfields;
- unsigned int v;
- int bf_format; // bitfields format identifier
- int iscompressed;
- int bfsize; // bytes in "bitfields" section
- int palsize; // bytes in palette
-
- int palentsize; // bytes in a palette entry: 3 or 4;
- BITMAPCOREHEADER *lpolddib;
- int rv; // return code
- int dib_alpha32;
-
- d2p = (struct d2p_struct*)qq;
-
- rv = PNGD_E_ERROR; // this should always get changed before returning
- png_ptr = NULL;
- info_ptr = NULL;
- fp = NULL;
- row_pointers = NULL;
- newimage = NULL;
- dib_alpha32 = 0;
-
- lstrcpy(d2p->common.errmsg, _T(""));
-
- if(!d2p->output_filename)
- {
- wsprintf(d2p->common.errmsg, _T("Output filename not set"));
- rv = PNGD_E_ERROR;
- goto abort;
- }
-
- if(!d2p->pdib)
- {
- wsprintf(d2p->common.errmsg, _T("Input DIB not set"));
- rv = PNGD_E_ERROR;
- goto abort;
- }
-
-
- headersize = d2p->pdib->biSize;
-
- if(headersize < 40 && headersize != 12)
- {
- wsprintf(d2p->common.errmsg, _T("Unexpected BMP header size (%d)"), headersize);
- rv = PNGD_E_BADBMP;
- goto abort;
- }
-
- if(headersize == 12)
- {
- // This is to support an old kind of DIBs (OS/2) that aren't really
- // used anymore.
- palentsize = 3;
- lpolddib = (BITMAPCOREHEADER*) d2p->pdib;
- width = lpolddib->bcWidth;
- height = lpolddib->bcHeight;
- dib_bpp = lpolddib->bcBitCount;
- compression = BI_RGB;
- res_x = res_y = 0;
-
- // This will get adjusted later if there is a palette.
- // Not sure it's right, though. Do old DIBs always have a
- // full-sized palette?
- palette_entries = 0;
- }
- else
- {
- palentsize = 4;
- width = d2p->pdib->biWidth;
- height = d2p->pdib->biHeight;
- dib_bpp = d2p->pdib->biBitCount;
- compression = d2p->pdib->biCompression;
- res_x = d2p->pdib->biXPelsPerMeter;
- res_y = d2p->pdib->biYPelsPerMeter;
- palette_entries = d2p->pdib->biClrUsed;
- }
-
- // supposedly, if the height is negative, the top scanline is stored first
- topdown = 0;
- if(height < 0)
- {
- height = -height;
- topdown = 1;
- }
-
- // sanity check
- if(height < 1 || height > 1000000 || width < 1 || width > 1000000)
- {
- wsprintf(d2p->common.errmsg, _T("Unreasonable image dimensions (%dx%d)"), width, height);
- rv = PNGD_E_BADBMP;
- goto abort;
- }
-
- if(dib_bpp == 32 && (d2p->common.dib_alpha32))
- {
- dib_alpha32 = 1;
- }
-
- // only certain combinations of compression and bpp are allowed
- switch(compression)
- {
- case BI_RGB:
- if(dib_bpp != 1 && dib_bpp != 4 && dib_bpp != 8 && dib_bpp != 16
- && dib_bpp != 24 && dib_bpp != 32)
- {
- wsprintf(d2p->common.errmsg, _T("Unsupported bit depth (%d)"), dib_bpp);
- rv = PNGD_E_UNSUPP;
- goto abort;
- }
- break;
- case BI_RLE4:
- if(dib_bpp != 4)
- {
- rv = PNGD_E_UNSUPP;
- goto abort;
- }
- break;
- case BI_RLE8:
- if(dib_bpp != 8)
- {
- rv = PNGD_E_UNSUPP;
- goto abort;
- }
- break;
- case BI_BITFIELDS:
- if(dib_bpp != 16 && dib_bpp != 32)
- {
- rv = PNGD_E_UNSUPP;
- goto abort;
- }
- break;
- default:
- wsprintf(d2p->common.errmsg, _T("Unsupported compression scheme"));
- return PNGD_E_UNSUPP;
- }
-
- iscompressed = (compression == BI_RLE4 || compression == BI_RLE8);
-
- // uncompressed dibs are padded to 4-byte bondaries
- dib_bytesperrow = (((width * dib_bpp) + 31) / 32) * 4;
-
- if(dib_bpp < 16)
- {
- if(palette_entries == 0) palette_entries = 1 << dib_bpp;
- }
-
- bfsize = (compression == BI_BITFIELDS) ? 12 : 0;
-
- palsize = palentsize * palette_entries;
-
- // bounds check
- size = headersize + bfsize + palsize;
- if(d2p->dibsize)
- {
- if(size > d2p->dibsize)
- {
- rv = PNGD_E_BADBMP;
- goto abort;
- }
- }
-
- if(d2p->pbits)
- {
- if(d2p->bitssize && !iscompressed) // bounds check
- {
- size = dib_bytesperrow * height;
- if(size > d2p->bitssize)
- {
- rv = PNGD_E_BADBMP;
- goto abort;
- }
- }
-
- bits = (unsigned char*)d2p->pbits;
- }
- else
- {
- // If not provided by user, assume the bits immediately
- // follow the palette.
-
- if(d2p->dibsize && !iscompressed) // bounds check
- {
- size = headersize + bfsize + palsize + dib_bytesperrow * height;
- if(size > d2p->dibsize)
- {
- rv = PNGD_E_BADBMP;
- goto abort;
- }
- }
-
- bits = &((unsigned char*)(d2p->pdib))[headersize+bfsize+palsize];
- }
-
- bitfields = (DWORD*)(&((unsigned char*)(d2p->pdib))[headersize]);
- dib_palette = (RGBQUAD*)(&((unsigned char*)(d2p->pdib))[headersize+bfsize]);
-
- bf_format = 0;
- if(compression == BI_BITFIELDS)
- {
- if(dib_bpp == 16)
- {
- if(bitfields[0] == 0x00007c00 && bitfields[1] == 0x000003e0 &&
- bitfields[2] == 0x0000001f) bf_format = 11; // 555
- else if(bitfields[0] == 0x0000f800 && bitfields[1] == 0x000007e0 &&
- bitfields[2] == 0x0000001f) bf_format = 12; // 565
- else
- {
- rv = PNGD_E_UNSUPP;
- goto abort;
- }
- }
- if(dib_bpp == 32)
- {
- if(bitfields[0] == 0x00ff0000 && bitfields[1] == 0x0000ff00 &&
- bitfields[2] == 0x000000ff) bf_format = 21;
- else
- {
- rv = PNGD_E_UNSUPP;
- goto abort;
- }
- }
- }
-
- if(bf_format == 0 && dib_bpp == 16) bf_format = 10;
- if(bf_format == 0 && dib_bpp == 32) bf_format = 20;
-
-
- // Done analyzing the DIB, now time to convert it to PNG
-
- // FIXME: this probably isn't quite right
- // jbuf: see comments in read_png_to_dib()
- errinfo.jbufp = &jbuf;
- errinfo.errmsg = d2p->common.errmsg;
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (void*)(&errinfo),
- my_png_error_fn, my_png_warning_fn);
- if(!png_ptr)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
-
- info_ptr = png_create_info_struct(png_ptr);
- if(!info_ptr)
- {
- //png_destroy_write_struct(&png_ptr,(png_infopp)NULL);
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
- if(setjmp(jbuf))
- {
- // we'll get here if an error occurred in any of the following
- // png_ functions
- rv = PNGD_E_LIBPNG;
- goto abort;
- }
-
- fp = _tfopen(d2p->output_filename, _T("wb"));
- if(!fp)
- {
- rv = PNGD_E_WRITE;
- goto abort;
- }
-
- png_init_io(png_ptr, fp);
-
- if(dib_alpha32)
- {
- png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
- }
- else
- {
- png_color_type = (dib_bpp > 8) ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_PALETTE;
- }
-
- png_set_IHDR(png_ptr, info_ptr, width, height, (dib_bpp > 8) ? 8 : dib_bpp,
- png_color_type,
- (d2p->interlaced) ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- // write sRGB and gAMA chunks
- if(d2p->file_gamma_valid)
- {
- if(d2p->file_gamma > 0.454539 && d2p->file_gamma < 0.454551)
- {
- png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_RELATIVE);
- }
- png_set_gAMA(png_ptr, info_ptr, d2p->file_gamma);
- }
-
- // For 16-bit DIBs, we get to write an sBIT chunk.
- if(bf_format == 10 || bf_format == 11)
- {
- pngc8.red = 5;
- pngc8.green = 5;
- pngc8.blue = 5;
- png_set_sBIT(png_ptr, info_ptr, &pngc8);
- }
- if(bf_format == 12)
- {
- pngc8.red = 5;
- pngc8.green = 6;
- pngc8.blue = 5;
- png_set_sBIT(png_ptr, info_ptr, &pngc8);
- }
-
- // pHYs
- if(res_x > 0 && res_y > 0)
- png_set_pHYs(png_ptr, info_ptr, res_x, res_y, 1);
-
-
- if(palette_entries > 0)
- {
- for(i = 0; i < palette_entries; i++)
- {
- if(palentsize == 3)
- {
- png_palette[i].red = ((RGBTRIPLE*)dib_palette)[i].rgbtRed;
- png_palette[i].green = ((RGBTRIPLE*)dib_palette)[i].rgbtGreen;
- png_palette[i].blue = ((RGBTRIPLE*)dib_palette)[i].rgbtBlue;
- }
- else
- {
- png_palette[i].red = dib_palette[i].rgbRed;
- png_palette[i].green = dib_palette[i].rgbGreen;
- png_palette[i].blue = dib_palette[i].rgbBlue;
- }
- }
- png_set_PLTE(png_ptr, info_ptr, png_palette, palette_entries);
- }
-
- if(dib_bpp > 8)
- png_set_bgr(png_ptr);
-
- png_write_info(png_ptr, info_ptr);
-
- row_pointers = (unsigned char**)malloc(height * sizeof(unsigned char*));
- if(!row_pointers)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
-
- if(dib_bpp == 16 || (dib_bpp == 32 && !dib_alpha32))
- {
-
- // Special handling for these bit depths.
- // This uses a lot of memory, and could be improved by processing
- // one line at a time (but that makes it tricky to write interlaced
- // images).
-
- newimage = (unsigned char*)malloc(height * width * 3);
- if(!newimage)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
-
- for(y = 0; y < height; y++)
- {
- for(x = 0; x < width; x++)
- {
- switch(bf_format)
- {
- case 10:
- case 11: // 16-bit, format 555 (xRRRRRGG GGGBBBBB)
- v = bits[y*dib_bytesperrow+x*2+0] | (bits[y*dib_bytesperrow+x*2+1] << 8);
- newimage[(y*width+x)*3+0] = (v & 0x0000001f) << 3 | (v & 0x0000001f) >> 2; // blue
- newimage[(y*width+x)*3+1] = (v & 0x000003e0) >> 2 | (v & 0x000003e0) >> 7; // green
- newimage[(y*width+x)*3+2] = (v & 0x00007c00) >> 7 | (v & 0x00007c00) >> 12; // red
- break;
- case 12: // 16-bit, format 565 (RRRRRGGG GGGBBBBB)
- v = bits[y*dib_bytesperrow+x*2+0] | (bits[y*dib_bytesperrow+x*2+1] << 8);
- newimage[(y*width+x)*3+0] = (v & 0x0000001f) << 3 | (v & 0x0000001f) >> 2; // blue
- newimage[(y*width+x)*3+1] = (v & 0x000007e0) >> 3 | (v & 0x000007e0) >> 9; // green
- newimage[(y*width+x)*3+2] = (v & 0x0000f800) >> 8 | (v & 0x0000f800) >> 13; // red
- break;
- case 20:
- case 21: // 32-bit, every 4th byte wasted (b g r x)
- newimage[(y*width+x)*3+0] = bits[y*dib_bytesperrow+x*4+0]; // blue
- newimage[(y*width+x)*3+1] = bits[y*dib_bytesperrow+x*4+1]; // green
- newimage[(y*width+x)*3+2] = bits[y*dib_bytesperrow+x*4+2]; // red
- break;
- }
- }
- }
-
- for(i = 0; i < height; i++)
- {
- if(topdown)
- row_pointers[i] = &newimage[i*width*3];
- else
- row_pointers[height-1-i] = &newimage[i*width*3];
- }
- png_write_image(png_ptr, row_pointers);
-
- free(newimage);
- newimage = NULL;
- }
- else if(iscompressed)
- {
- newimage = uncompress_dib((LPBITMAPINFO)d2p->pdib, headersize + bfsize + palsize, bits);
- if(!newimage)
- {
- rv = PNGD_E_NOMEM;
- goto abort;
- }
- for(i = 0; i < height; i++)
- {
- if(topdown)
- row_pointers[i] = &newimage[i*dib_bytesperrow];
- else
- row_pointers[height-1-i] = &newimage[i*dib_bytesperrow];
- }
- png_write_image(png_ptr, row_pointers);
-
- free(newimage);
- newimage = NULL;
- }
- else
- {
- for(i = 0; i < height; i++)
- {
- if(topdown)
- row_pointers[i] = &bits[i*dib_bytesperrow];
- else
- row_pointers[height-1-i] = &bits[i*dib_bytesperrow];
- }
- png_write_image(png_ptr, row_pointers);
- }
-
- free((VOID*)row_pointers);
- row_pointers = NULL;
-
- if(d2p->software_id_string)
- {
- text_ptr[0].key = "Software";
- text_ptr[0].text = d2p->software_id_string;
- text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
- png_set_text(png_ptr, info_ptr, text_ptr, 1);
- }
-
- png_write_end(png_ptr, info_ptr);
-
- rv = PNGD_E_SUCCESS;
+ struct d2p_struct *d2p;
+ png_structp png_ptr;
+ png_infop info_ptr;
+ jmp_buf jbuf;
+ struct errstruct errinfo;
+ png_text text_ptr[1];
+ unsigned char *bits;
+ unsigned char *newimage;
+ RGBQUAD* dib_palette;
+ int headersize, dib_bpp;
+ int png_color_type;
+ png_uint_32 res_x, res_y;
+ png_color_8 pngc8;
+ int height,width;
+ int palette_entries;
+ int topdown;
+ int dib_bytesperrow;
+ int compression;
+ FILE *fp;
+ png_color png_palette[256];
+ unsigned char **row_pointers;
+ int i,x,y,size;
+ DWORD *bitfields;
+ unsigned int v;
+ int bf_format; // bitfields format identifier
+ int iscompressed;
+ int bfsize; // bytes in "bitfields" section
+ int palsize; // bytes in palette
+
+ int palentsize; // bytes in a palette entry: 3 or 4;
+ BITMAPCOREHEADER *lpolddib;
+ int rv; // return code
+ int dib_alpha32;
+
+ d2p=(struct d2p_struct*)qq;
+
+ rv=PNGD_E_ERROR; // this should always get changed before returning
+ png_ptr=NULL;
+ info_ptr=NULL;
+ fp=NULL;
+ row_pointers=NULL;
+ newimage=NULL;
+ dib_alpha32=0;
+
+ lstrcpy(d2p->common.errmsg,_T(""));
+
+ if(!d2p->output_filename) {
+ wsprintf(d2p->common.errmsg,_T("Output filename not set"));
+ rv=PNGD_E_ERROR; goto abort;
+ }
+
+ if(!d2p->pdib) {
+ wsprintf(d2p->common.errmsg,_T("Input DIB not set"));
+ rv=PNGD_E_ERROR; goto abort;
+ }
+
+
+ headersize= d2p->pdib->biSize;
+
+ if(headersize<40 && headersize!=12) {
+ wsprintf(d2p->common.errmsg,_T("Unexpected BMP header size (%d)"),headersize);
+ rv=PNGD_E_BADBMP; goto abort;
+ }
+
+ if(headersize==12) {
+ // This is to support an old kind of DIBs (OS/2) that aren't really
+ // used anymore.
+ palentsize= 3;
+ lpolddib= (BITMAPCOREHEADER*) d2p->pdib;
+ width= lpolddib->bcWidth;
+ height= lpolddib->bcHeight;
+ dib_bpp= lpolddib->bcBitCount;
+ compression = BI_RGB;
+ res_x = res_y = 0;
+
+ // This will get adjusted later if there is a palette.
+ // Not sure it's right, though. Do old DIBs always have a
+ // full-sized palette?
+ palette_entries=0;
+ }
+ else {
+ palentsize=4;
+ width = d2p->pdib->biWidth;
+ height = d2p->pdib->biHeight;
+ dib_bpp = d2p->pdib->biBitCount;
+ compression = d2p->pdib->biCompression;
+ res_x = d2p->pdib->biXPelsPerMeter;
+ res_y = d2p->pdib->biYPelsPerMeter;
+ palette_entries = d2p->pdib->biClrUsed;
+ }
+
+ // supposedly, if the height is negative, the top scanline is stored first
+ topdown=0;
+ if(height<0) {
+ height= -height;
+ topdown=1;
+ }
+
+ // sanity check
+ if(height<1 || height>1000000 || width<1 || width>1000000) {
+ wsprintf(d2p->common.errmsg,_T("Unreasonable image dimensions (%dx%d)"),width,height);
+ rv=PNGD_E_BADBMP; goto abort;
+ }
+
+ if(dib_bpp==32 && (d2p->common.dib_alpha32)) {
+ dib_alpha32=1;
+ }
+
+ // only certain combinations of compression and bpp are allowed
+ switch(compression) {
+ case BI_RGB:
+ if(dib_bpp!=1 && dib_bpp!=4 && dib_bpp!=8 && dib_bpp!=16
+ && dib_bpp!=24 && dib_bpp!=32)
+ {
+ wsprintf(d2p->common.errmsg,_T("Unsupported bit depth (%d)"),dib_bpp);
+ rv=PNGD_E_UNSUPP; goto abort;
+ }
+ break;
+ case BI_RLE4:
+ if(dib_bpp!=4) {
+ rv=PNGD_E_UNSUPP; goto abort;
+ }
+ break;
+ case BI_RLE8:
+ if(dib_bpp!=8) {
+ rv=PNGD_E_UNSUPP; goto abort;
+ }
+ break;
+ case BI_BITFIELDS:
+ if(dib_bpp!=16 && dib_bpp!=32) {
+ rv=PNGD_E_UNSUPP; goto abort;
+ }
+ break;
+ default:
+ wsprintf(d2p->common.errmsg,_T("Unsupported compression scheme"));
+ return PNGD_E_UNSUPP;
+ }
+
+ iscompressed= (compression==BI_RLE4 || compression==BI_RLE8);
+
+ // uncompressed dibs are padded to 4-byte bondaries
+ dib_bytesperrow= (((width * dib_bpp)+31)/32)*4;
+
+ if(dib_bpp<16) {
+ if(palette_entries==0) palette_entries = 1<<dib_bpp;
+ }
+
+ bfsize = (compression==BI_BITFIELDS)?12:0;
+
+ palsize=palentsize*palette_entries;
+
+ // bounds check
+ size= headersize + bfsize + palsize;
+ if(d2p->dibsize) {
+ if(size>d2p->dibsize) {
+ rv=PNGD_E_BADBMP; goto abort;
+ }
+ }
+
+ if(d2p->pbits) {
+ if(d2p->bitssize && !iscompressed) { // bounds check
+ size=dib_bytesperrow*height;
+ if(size>d2p->bitssize) { rv=PNGD_E_BADBMP; goto abort; }
+ }
+
+ bits=(unsigned char*)d2p->pbits;
+ }
+ else {
+ // If not provided by user, assume the bits immediately
+ // follow the palette.
+
+ if(d2p->dibsize && !iscompressed) { // bounds check
+ size= headersize+bfsize+palsize+dib_bytesperrow*height;
+ if(size>d2p->dibsize) { rv=PNGD_E_BADBMP; goto abort; }
+ }
+
+ bits= &((unsigned char*)(d2p->pdib))[headersize+bfsize+palsize];
+ }
+
+ bitfields = (DWORD*) ( &((unsigned char*)(d2p->pdib))[headersize] );
+ dib_palette = (RGBQUAD*) ( &((unsigned char*)(d2p->pdib))[headersize+bfsize] );
+
+ bf_format=0;
+ if(compression==BI_BITFIELDS) {
+ if(dib_bpp==16) {
+ if (bitfields[0]==0x00007c00 && bitfields[1]==0x000003e0 &&
+ bitfields[2]==0x0000001f) bf_format=11; // 555
+ else if(bitfields[0]==0x0000f800 && bitfields[1]==0x000007e0 &&
+ bitfields[2]==0x0000001f) bf_format=12; // 565
+ else { rv=PNGD_E_UNSUPP; goto abort; }
+ }
+ if(dib_bpp==32) {
+ if (bitfields[0]==0x00ff0000 && bitfields[1]==0x0000ff00 &&
+ bitfields[2]==0x000000ff) bf_format=21;
+ else { rv=PNGD_E_UNSUPP; goto abort; }
+ }
+ }
+
+ if(bf_format==0 && dib_bpp==16) bf_format=10;
+ if(bf_format==0 && dib_bpp==32) bf_format=20;
+
+
+ // Done analyzing the DIB, now time to convert it to PNG
+
+ // FIXME: this probably isn't quite right
+ // jbuf: see comments in read_png_to_dib()
+ errinfo.jbufp = &jbuf;
+ errinfo.errmsg = d2p->common.errmsg;
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (void*)(&errinfo),
+ my_png_error_fn, my_png_warning_fn);
+ if (!png_ptr) { rv=PNGD_E_NOMEM; goto abort; }
+
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ //png_destroy_write_struct(&png_ptr,(png_infopp)NULL);
+ rv=PNGD_E_NOMEM; goto abort;
+ }
+
+ if(setjmp(jbuf)) {
+ // we'll get here if an error occurred in any of the following
+ // png_ functions
+ rv=PNGD_E_LIBPNG;
+ goto abort;
+ }
+
+ fp= _tfopen(d2p->output_filename,_T("wb"));
+ if(!fp) {
+ rv=PNGD_E_WRITE;
+ goto abort;
+ }
+
+ png_init_io(png_ptr, fp);
+
+ if(dib_alpha32) {
+ png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ }
+ else {
+ png_color_type = (dib_bpp>8)?PNG_COLOR_TYPE_RGB:PNG_COLOR_TYPE_PALETTE;
+ }
+
+ png_set_IHDR(png_ptr, info_ptr, width, height, (dib_bpp>8)?8:dib_bpp,
+ png_color_type,
+ (d2p->interlaced)?PNG_INTERLACE_ADAM7:PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+
+ // write sRGB and gAMA chunks
+ if(d2p->file_gamma_valid) {
+ if(d2p->file_gamma>0.454539 && d2p->file_gamma<0.454551) {
+ png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_RELATIVE);
+ }
+ png_set_gAMA(png_ptr, info_ptr, d2p->file_gamma);
+ }
+
+ // For 16-bit DIBs, we get to write an sBIT chunk.
+ if(bf_format==10 || bf_format==11) {
+ pngc8.red= 5; pngc8.green= 5; pngc8.blue= 5;
+ png_set_sBIT(png_ptr, info_ptr, &pngc8);
+ }
+ if(bf_format==12) {
+ pngc8.red= 5; pngc8.green= 6; pngc8.blue= 5;
+ png_set_sBIT(png_ptr, info_ptr, &pngc8);
+ }
+
+ // pHYs
+ if(res_x>0 && res_y>0)
+ png_set_pHYs(png_ptr, info_ptr, res_x, res_y, 1);
+
+
+ if(palette_entries>0) {
+ for(i=0;i<palette_entries;i++) {
+ if(palentsize==3) {
+ png_palette[i].red = ((RGBTRIPLE*)dib_palette)[i].rgbtRed;
+ png_palette[i].green = ((RGBTRIPLE*)dib_palette)[i].rgbtGreen;
+ png_palette[i].blue = ((RGBTRIPLE*)dib_palette)[i].rgbtBlue;
+ }
+ else {
+ png_palette[i].red = dib_palette[i].rgbRed;
+ png_palette[i].green = dib_palette[i].rgbGreen;
+ png_palette[i].blue = dib_palette[i].rgbBlue;
+ }
+ }
+ png_set_PLTE(png_ptr, info_ptr, png_palette, palette_entries);
+ }
+
+ if(dib_bpp>8)
+ png_set_bgr(png_ptr);
+
+ png_write_info(png_ptr, info_ptr);
+
+ row_pointers=(unsigned char**)malloc(height*sizeof(unsigned char*));
+ if(!row_pointers) { rv=PNGD_E_NOMEM; goto abort; }
+
+
+ if(dib_bpp==16 || (dib_bpp==32 && !dib_alpha32)) {
+
+ // Special handling for these bit depths.
+ // This uses a lot of memory, and could be improved by processing
+ // one line at a time (but that makes it tricky to write interlaced
+ // images).
+
+ newimage=(unsigned char*)malloc(height*width*3);
+ if(!newimage) { rv=PNGD_E_NOMEM; goto abort; }
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ switch(bf_format) {
+ case 10: case 11: // 16-bit, format 555 (xRRRRRGG GGGBBBBB)
+ v= bits[y*dib_bytesperrow+x*2+0] | (bits[y*dib_bytesperrow+x*2+1]<<8);
+ newimage[(y*width+x)*3+0]= (v & 0x0000001f)<<3 | (v & 0x0000001f)>>2; // blue
+ newimage[(y*width+x)*3+1]= (v & 0x000003e0)>>2 | (v & 0x000003e0)>>7; // green
+ newimage[(y*width+x)*3+2]= (v & 0x00007c00)>>7 | (v & 0x00007c00)>>12; // red
+ break;
+ case 12: // 16-bit, format 565 (RRRRRGGG GGGBBBBB)
+ v= bits[y*dib_bytesperrow+x*2+0] | (bits[y*dib_bytesperrow+x*2+1]<<8);
+ newimage[(y*width+x)*3+0]= (v & 0x0000001f)<<3 | (v & 0x0000001f)>>2; // blue
+ newimage[(y*width+x)*3+1]= (v & 0x000007e0)>>3 | (v & 0x000007e0)>>9; // green
+ newimage[(y*width+x)*3+2]= (v & 0x0000f800)>>8 | (v & 0x0000f800)>>13; // red
+ break;
+ case 20: case 21: // 32-bit, every 4th byte wasted (b g r x)
+ newimage[(y*width+x)*3+0]= bits[y*dib_bytesperrow+x*4+0]; // blue
+ newimage[(y*width+x)*3+1]= bits[y*dib_bytesperrow+x*4+1]; // green
+ newimage[(y*width+x)*3+2]= bits[y*dib_bytesperrow+x*4+2]; // red
+ break;
+ }
+ }
+ }
+
+ for(i=0;i<height;i++) {
+ if(topdown)
+ row_pointers[i]= &newimage[i*width*3];
+ else
+ row_pointers[height-1-i]= &newimage[i*width*3];
+ }
+ png_write_image(png_ptr, row_pointers);
+
+ free(newimage);
+ newimage=NULL;
+ }
+ else if(iscompressed) {
+ newimage= uncompress_dib((LPBITMAPINFO)d2p->pdib, headersize+bfsize+palsize, bits);
+ if(!newimage) { rv=PNGD_E_NOMEM; goto abort; }
+ for(i=0;i<height;i++) {
+ if(topdown)
+ row_pointers[i]= &newimage[i*dib_bytesperrow];
+ else
+ row_pointers[height-1-i]= &newimage[i*dib_bytesperrow];
+ }
+ png_write_image(png_ptr, row_pointers);
+
+ free(newimage);
+ newimage=NULL;
+ }
+ else {
+ for(i=0;i<height;i++) {
+ if(topdown)
+ row_pointers[i]= &bits[i*dib_bytesperrow];
+ else
+ row_pointers[height-1-i]= &bits[i*dib_bytesperrow];
+ }
+ png_write_image(png_ptr, row_pointers);
+ }
+
+ free((VOID*)row_pointers);
+ row_pointers=NULL;
+
+ if(d2p->software_id_string) {
+ text_ptr[0].key = "Software";
+ text_ptr[0].text = d2p->software_id_string;
+ text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
+ png_set_text(png_ptr, info_ptr, text_ptr, 1);
+ }
+
+ png_write_end(png_ptr, info_ptr);
+
+ rv=PNGD_E_SUCCESS;
abort:
- if(png_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
- if(fp) fclose(fp);
- if(row_pointers) free(row_pointers);
- if(newimage) free(newimage);
-
- // If we don't have an error message yet, use a
- // default one based on the code
- if(!lstrlen(d2p->common.errmsg))
- {
- pngd_get_error_message(rv, d2p->common.errmsg);
- }
- return rv;
+ if(png_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
+ if(fp) fclose(fp);
+ if(row_pointers) free(row_pointers);
+ if(newimage) free(newimage);
+
+ // If we don't have an error message yet, use a
+ // default one based on the code
+ if(!lstrlen(d2p->common.errmsg)) {
+ pngd_get_error_message(rv,d2p->common.errmsg);
+ }
+ return rv;
}
TCHAR* PNGDIB_DECL pngdib_get_version_string(void)
{
- return PNGDIB_SRC_VERSION_STRING;
+ return PNGDIB_SRC_VERSION_STRING;
}
int PNGDIB_DECL pngdib_get_version(void)
{
- return PNGDIB_SRC_VERSION;
+ return PNGDIB_SRC_VERSION;
}
PNGDIB* PNGDIB_DECL _pngdib_init(int structtype, int caller_header_vers)
{
- PNGDIB *qq = NULL;
-
- if(structtype == PNGD_ST_D2P)
- {
- struct d2p_struct *d2p;
-
- d2p = (struct d2p_struct *)calloc(sizeof(struct d2p_struct), 1);
- if(d2p)
- {
- d2p->common.structtype = PNGD_ST_D2P;
- d2p->file_gamma_valid = 1;
- d2p->file_gamma = PNGDIB_DEFAULT_FILE_GAMMA;
- }
- qq = (PNGDIB*)d2p;
-
- }
- else if(structtype == PNGD_ST_P2D)
- {
- struct p2d_struct *p2d;
-
- p2d = (struct p2d_struct *)calloc(sizeof(struct p2d_struct), 1);
- if(p2d)
- {
- p2d->common.structtype = PNGD_ST_P2D;
- }
- qq = (PNGDIB*)p2d;
- }
-
- // initialize common fields:
- if(qq)
- {
- qq->errmsg = calloc(PNGDIB_ERRMSG_MAX, sizeof(TCHAR));
- }
-
- return qq;
+ PNGDIB *qq = NULL;
+
+ if(structtype==PNGD_ST_D2P) {
+ struct d2p_struct *d2p;
+
+ d2p = (struct d2p_struct *)calloc(sizeof(struct d2p_struct),1);
+ if(d2p) {
+ d2p->common.structtype = PNGD_ST_D2P;
+ d2p->file_gamma_valid = 1;
+ d2p->file_gamma = PNGDIB_DEFAULT_FILE_GAMMA;
+ }
+ qq=(PNGDIB*)d2p;
+
+ }
+ else if(structtype==PNGD_ST_P2D) {
+ struct p2d_struct *p2d;
+
+ p2d = (struct p2d_struct *)calloc(sizeof(struct p2d_struct),1);
+ if(p2d) {
+ p2d->common.structtype = PNGD_ST_P2D;
+ }
+ qq=(PNGDIB*)p2d;
+ }
+
+ // initialize common fields:
+ if(qq) {
+ qq->errmsg = calloc(PNGDIB_ERRMSG_MAX,sizeof(TCHAR));
+ }
+
+ return qq;
}
int PNGDIB_DECL pngdib_d2p_set_dib(PNGDIB *qq,
- const BITMAPINFOHEADER* lpdib, int dibsize,
- const void* lpbits, int bitssize)
+ const BITMAPINFOHEADER* lpdib, int dibsize,
+ const void* lpbits, int bitssize)
{
- struct d2p_struct *d2p;
- if(qq->structtype != PNGD_ST_D2P) return 0;
- d2p = (struct d2p_struct*)qq;
-
- d2p->pdib = lpdib;
- d2p->dibsize = dibsize;
- d2p->pbits = lpbits;
- d2p->bitssize = bitssize;
- return 1;
+ struct d2p_struct *d2p;
+ if(qq->structtype!=PNGD_ST_D2P) return 0;
+ d2p=(struct d2p_struct*)qq;
+
+ d2p->pdib = lpdib;
+ d2p->dibsize = dibsize;
+ d2p->pbits = lpbits;
+ d2p->bitssize = bitssize;
+ return 1;
}
void PNGDIB_DECL pngdib_d2p_set_interlace(PNGDIB *qq, int interlaced)
{
- struct d2p_struct *d2p;
- d2p = (struct d2p_struct*)qq;
- d2p->interlaced = interlaced;
+ struct d2p_struct *d2p;
+ d2p=(struct d2p_struct*)qq;
+ d2p->interlaced = interlaced;
}
int PNGDIB_DECL pngdib_d2p_set_png_filename(PNGDIB *qq, const TCHAR *fn)
{
- struct d2p_struct *d2p;
- d2p = (struct d2p_struct*)qq;
- d2p->output_filename = _tcsdup(fn);
- return (d2p->output_filename) ? 1 : 0;
+ struct d2p_struct *d2p;
+ d2p=(struct d2p_struct*)qq;
+ d2p->output_filename = _tcsdup(fn);
+ return (d2p->output_filename)?1:0;
}
int PNGDIB_DECL pngdib_d2p_set_software_id(PNGDIB *qq, const TCHAR *s)
{
- struct d2p_struct *d2p;
- int len;
+ struct d2p_struct *d2p;
+ int len;
- d2p = (struct d2p_struct*)qq;
- len = lstrlen(s);
+ d2p=(struct d2p_struct*)qq;
+ len= lstrlen(s);
- // The software id is never stored as UNICODE.
+ // The software id is never stored as UNICODE.
#ifdef _UNICODE
- d2p->software_id_string = calloc(len + 10, 1);
- _snprintf(d2p->software_id_string, len + 10, "%S", s);
+ d2p->software_id_string = calloc(len+10,1);
+ _snprintf(d2p->software_id_string,len+10,"%S",s);
#else
- d2p->software_id_string = _strdup(s);
+ d2p->software_id_string = _strdup(s);
#endif
- return (d2p->output_filename) ? 1 : 0;
+ return (d2p->output_filename)?1:0;
}
void PNGDIB_DECL pngdib_d2p_set_gamma_label(PNGDIB *qq, int flag, double file_gamma)
{
- struct d2p_struct *d2p;
- d2p = (struct d2p_struct*)qq;
- d2p->file_gamma_valid = flag;
- d2p->file_gamma = file_gamma;
+ struct d2p_struct *d2p;
+ d2p=(struct d2p_struct*)qq;
+ d2p->file_gamma_valid = flag;
+ d2p->file_gamma = file_gamma;
}
int PNGDIB_DECL pngdib_done(PNGDIB *qq)
{
- struct d2p_struct *d2p;
- struct p2d_struct *p2d;
-
- if(!qq) return 0;
-
- if(qq->errmsg) free(qq->errmsg);
-
- switch(qq->structtype)
- {
- case PNGD_ST_D2P:
- d2p = (struct d2p_struct*)qq;
- if(d2p->output_filename) free(d2p->output_filename);
- if(d2p->software_id_string) free(d2p->software_id_string);
- free(d2p);
- return 1;
- case PNGD_ST_P2D:
- p2d = (struct p2d_struct*)qq;
- if(p2d->input_filename) free(p2d->input_filename);
- free(p2d);
- return 1;
- }
- return 0;
+ struct d2p_struct *d2p;
+ struct p2d_struct *p2d;
+
+ if(!qq) return 0;
+
+ if(qq->errmsg) free(qq->errmsg);
+
+ switch(qq->structtype) {
+ case PNGD_ST_D2P:
+ d2p=(struct d2p_struct*)qq;
+ if(d2p->output_filename) free(d2p->output_filename);
+ if(d2p->software_id_string) free(d2p->software_id_string);
+ free(d2p);
+ return 1;
+ case PNGD_ST_P2D:
+ p2d=(struct p2d_struct*)qq;
+ if(p2d->input_filename) free(p2d->input_filename);
+ free(p2d);
+ return 1;
+ }
+ return 0;
}
void PNGDIB_DECL pngdib_setcallback_malloc(PNGDIB *qq,
- pngdib_malloc_cb_type mallocfunc,
- pngdib_free_cb_type freefunc,
- pngdib_realloc_cb_type reallocfunc)
+ pngdib_malloc_cb_type mallocfunc,
+ pngdib_free_cb_type freefunc,
+ pngdib_realloc_cb_type reallocfunc)
{
- qq->malloc_function = mallocfunc;
- qq->free_function = freefunc;
- qq->realloc_function = reallocfunc;
+ qq->malloc_function = mallocfunc;
+ qq->free_function = freefunc;
+ qq->realloc_function = reallocfunc;
}
TCHAR* PNGDIB_DECL pngdib_get_error_msg(PNGDIB *qq)
{
- return qq->errmsg;
+ return qq->errmsg;
}
void PNGDIB_DECL pngdib_set_userdata(PNGDIB* qq, void* userdata)
{
- qq->userdata = userdata;
+ qq->userdata = userdata;
}
void* PNGDIB_DECL pngdib_get_userdata(PNGDIB* qq)
{
- return qq->userdata;
+ return qq->userdata;
}
int PNGDIB_DECL pngdib_p2d_set_png_filename(PNGDIB *qq, const TCHAR *fn)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- p2d->input_filename = _tcsdup(fn);
- p2d->input_method = 0;
- return (p2d->input_filename) ? 1 : 0;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ p2d->input_filename = _tcsdup(fn);
+ p2d->input_method = 0;
+ return (p2d->input_filename)?1:0;
}
void PNGDIB_DECL pngdib_p2d_set_png_memblk(PNGDIB *qq, const void *mem, int memsize)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- p2d->input_memblk = (unsigned char*)mem;
- p2d->input_method = 1;
- if(memsize >= 0)
- p2d->input_memblk_size = memsize;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ p2d->input_memblk = (unsigned char*)mem;
+ p2d->input_method = 1;
+ if(memsize>=0)
+ p2d->input_memblk_size = memsize;
}
void PNGDIB_DECL pngdib_p2d_set_use_file_bg(PNGDIB *qq, int flag)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- p2d->use_file_bg_flag = flag;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ p2d->use_file_bg_flag = flag;
}
void PNGDIB_DECL pngdib_p2d_set_custom_bg(PNGDIB *qq, unsigned char r,
- unsigned char g, unsigned char b)
+ unsigned char g, unsigned char b)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- p2d->bgcolor.red = r;
- p2d->bgcolor.green = g;
- p2d->bgcolor.blue = b;
- p2d->use_custom_bg_flag = 1;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ p2d->bgcolor.red = r;
+ p2d->bgcolor.green = g;
+ p2d->bgcolor.blue = b;
+ p2d->use_custom_bg_flag = 1;
}
void PNGDIB_DECL pngdib_p2d_set_gamma_correction(PNGDIB *qq, int flag, double screen_gamma)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- p2d->screen_gamma = screen_gamma;
- p2d->gamma_correction = flag;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ p2d->screen_gamma = screen_gamma;
+ p2d->gamma_correction = flag;
}
int PNGDIB_DECL pngdib_p2d_get_dib(PNGDIB *qq,
- BITMAPINFOHEADER **ppdib, int *pdibsize)
+ BITMAPINFOHEADER **ppdib, int *pdibsize)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- *ppdib = p2d->pdib;
- if(pdibsize) *pdibsize = p2d->dibsize;
- return 1;
-}
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ *ppdib = p2d->pdib;
+ if(pdibsize) *pdibsize = p2d->dibsize;
+ return 1;
+}
int PNGDIB_DECL pngdib_p2d_get_dibbits(PNGDIB *qq, void **ppbits, int *pbitsoffset, int *pbitssize)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- *ppbits = p2d->pbits;
- if(pbitsoffset) *pbitsoffset = p2d->bits_offs;
- if(pbitssize) *pbitssize = p2d->bitssize;
- return 1;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ *ppbits = p2d->pbits;
+ if(pbitsoffset) *pbitsoffset = p2d->bits_offs;
+ if(pbitssize) *pbitssize = p2d->bitssize;
+ return 1;
}
int PNGDIB_DECL pngdib_p2d_get_palette(PNGDIB *qq, RGBQUAD **ppal, int *ppaloffset, int *ppalnumcolors)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- if(ppal) *ppal = p2d->palette;
- if(ppaloffset) *ppaloffset = p2d->palette_offs;
- if(ppalnumcolors) *ppalnumcolors = p2d->palette_colors;
- return 1;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ if(ppal) *ppal = p2d->palette;
+ if(ppaloffset) *ppaloffset = p2d->palette_offs;
+ if(ppalnumcolors) *ppalnumcolors = p2d->palette_colors;
+ return 1;
}
int PNGDIB_DECL pngdib_p2d_get_colortype(PNGDIB *qq)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- return p2d->color_type;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ return p2d->color_type;
}
int PNGDIB_DECL pngdib_p2d_get_bitspersample(PNGDIB *qq)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- return p2d->bits_per_sample;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ return p2d->bits_per_sample;
}
int PNGDIB_DECL pngdib_p2d_get_bitsperpixel(PNGDIB *qq)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- return p2d->bits_per_pixel;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ return p2d->bits_per_pixel;
}
int PNGDIB_DECL pngdib_p2d_get_samplesperpixel(PNGDIB *qq)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- return p2d->bits_per_pixel / p2d->bits_per_sample;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ return p2d->bits_per_pixel/p2d->bits_per_sample;
}
int PNGDIB_DECL pngdib_p2d_get_interlace(PNGDIB *qq)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- return p2d->interlace;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ return p2d->interlace;
}
int PNGDIB_DECL pngdib_p2d_get_density(PNGDIB *qq, int *pres_x, int *pres_y, int *pres_units)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- if(p2d->res_valid)
- {
- *pres_x = p2d->res_x;
- *pres_y = p2d->res_y;
- *pres_units = p2d->res_units;
- return 1;
- }
- *pres_x = 1;
- *pres_y = 1;
- *pres_units = 0;
- return 0;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ if(p2d->res_valid) {
+ *pres_x = p2d->res_x;
+ *pres_y = p2d->res_y;
+ *pres_units = p2d->res_units;
+ return 1;
+ }
+ *pres_x = 1;
+ *pres_y = 1;
+ *pres_units = 0;
+ return 0;
}
int PNGDIB_DECL pngdib_p2d_get_file_gamma(PNGDIB *qq, double *pgamma)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
- if(p2d->gamma_returned)
- {
- *pgamma = p2d->file_gamma;
- return 1;
- }
- return 0;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+ if(p2d->gamma_returned) {
+ *pgamma = p2d->file_gamma;
+ return 1;
+ }
+ return 0;
}
int PNGDIB_DECL pngdib_p2d_get_bgcolor(PNGDIB *qq, unsigned char *pr, unsigned char *pg, unsigned char *pb)
{
- struct p2d_struct *p2d;
- p2d = (struct p2d_struct*)qq;
-
- if(p2d->bgcolor_returned)
- {
- *pr = p2d->bgcolor.red;
- *pg = p2d->bgcolor.green;
- *pb = p2d->bgcolor.blue;
- return 1;
- }
- return 0;
+ struct p2d_struct *p2d;
+ p2d=(struct p2d_struct*)qq;
+
+ if(p2d->bgcolor_returned) {
+ *pr = p2d->bgcolor.red;
+ *pg = p2d->bgcolor.green;
+ *pb = p2d->bgcolor.blue;
+ return 1;
+ }
+ return 0;
}
void PNGDIB_DECL pngdib_set_dibalpha32(PNGDIB *qq, int flag)
{
- qq->dib_alpha32 = flag;
+ qq->dib_alpha32 = flag;
}
@@ -1656,169 +1438,157 @@ void PNGDIB_DECL pngdib_set_dibalpha32(PNGDIB *qq, int flag)
static void* PNGDIB_DECL globalalloc_callback(void *userdata, int memblksize)
{
- return (void*)GlobalAlloc(GPTR, memblksize);
+ return (void*)GlobalAlloc(GPTR,memblksize);
}
static void PNGDIB_DECL globalfree_callback(void *userdata, void *memblk)
{
- GlobalFree((HGLOBAL)memblk);
+ GlobalFree((HGLOBAL)memblk);
}
static void* PNGDIB_DECL heapalloc_callback(void *userdata, int memblksize)
{
- return HeapAlloc((HANDLE)userdata, HEAP_ZERO_MEMORY, memblksize);
+ return HeapAlloc((HANDLE)userdata,HEAP_ZERO_MEMORY,memblksize);
}
static void PNGDIB_DECL heapfree_callback(void *userdata, void *memblk)
{
- HeapFree((HANDLE)userdata, 0, memblk);
+ HeapFree((HANDLE)userdata,0,memblk);
}
int read_png_to_dib(PNGD_P2DINFO *p2dp)
{
- PNGDIB *qq;
- int errcode;
- char *msg;
- HANDLE heap;
- int use_heapalloc;
- int imginfo;
-
- imginfo = 0;
- use_heapalloc = 0;
-
-
- qq = pngdib_p2d_init();
- if(!qq) return PNGD_E_NOMEM;
-
-
- // fields through errmsg must exist
- if(p2dp->structsize < 48) return PNGD_E_VERSION;
-
- // try to be somewhat backward-compatible
- if(p2dp->structsize >= 88)
- {
- imginfo = 1;
- }
-
- if(p2dp->structsize >= 96)
- {
- if(p2dp->flags & PNGD_USE_HEAPALLOC)
- {
- use_heapalloc = 1;
- heap = p2dp->heap;
- if(!heap) heap = GetProcessHeap();
- }
- }
-
- if(use_heapalloc)
- {
- pngdib_set_userdata(qq, (void*)heap);
- pngdib_setcallback_malloc(qq, heapalloc_callback, heapfree_callback, NULL);
- }
- else
- {
- pngdib_setcallback_malloc(qq, globalalloc_callback, globalfree_callback, NULL);
- }
-
- pngdib_p2d_set_png_filename(qq, p2dp->pngfn);
-
- pngdib_p2d_set_gamma_correction(qq, (p2dp->flags & PNGD_GAMMA_CORRECTION) ? 1 : 0, PNGDIB_DEFAULT_SCREEN_GAMMA);
-
- if(p2dp->flags & PNGD_USE_BKGD)
- pngdib_p2d_set_use_file_bg(qq, 1);
-
-
- if(p2dp->flags & PNGD_USE_CUSTOM_BG)
- {
- pngdib_p2d_set_custom_bg(qq, p2dp->bgcolor.red,
- p2dp->bgcolor.green, p2dp->bgcolor.blue);
- }
-
- if(p2dp->flags & PNGD_DIB_ALPHA32)
- pngdib_set_dibalpha32(qq, 1);
-
- errcode = pngdib_p2d_run(qq);
-
- if(!errcode)
- {
-
- pngdib_p2d_get_dib(qq, &p2dp->lpdib, &p2dp->dibsize);
- pngdib_p2d_get_dibbits(qq, &p2dp->lpbits, &p2dp->bits_offs, NULL);
- pngdib_p2d_get_palette(qq, &p2dp->palette, &p2dp->palette_offs, &p2dp->palette_colors);
-
- if(imginfo)
- {
- p2dp->color_type = pngdib_p2d_get_colortype(qq);
- p2dp->bits_per_sample = pngdib_p2d_get_bitspersample(qq);
- p2dp->interlace = pngdib_p2d_get_interlace(qq);
- p2dp->bits_per_pixel = pngdib_p2d_get_bitsperpixel(qq);
- if(pngdib_p2d_get_file_gamma(qq, &p2dp->file_gamma))
- {
- p2dp->flags |= PNGD_GAMMA_RETURNED;
- }
- if(pngdib_p2d_get_density(qq, &p2dp->res_x, &p2dp->res_y, &p2dp->res_units))
- {
- p2dp->flags |= PNGD_RES_RETURNED;
- }
- if(pngdib_p2d_get_bgcolor(qq, &p2dp->bgcolor.red, &p2dp->bgcolor.green,
- &p2dp->bgcolor.blue))
- {
- p2dp->flags |= PNGD_BG_RETURNED;
- }
- }
- }
-
- if(p2dp->errmsg)
- {
- msg = pngdib_get_error_msg(qq);
- lstrcpyn(p2dp->errmsg, msg, 100);
- }
-
- pngdib_done(qq);
-
- return errcode;
+ PNGDIB *qq;
+ int errcode;
+ char *msg;
+ HANDLE heap;
+ int use_heapalloc;
+ int imginfo;
+
+ imginfo=0;
+ use_heapalloc=0;
+
+
+ qq=pngdib_p2d_init();
+ if(!qq) return PNGD_E_NOMEM;
+
+
+ // fields through errmsg must exist
+ if(p2dp->structsize<48) return PNGD_E_VERSION;
+
+ // try to be somewhat backward-compatible
+ if(p2dp->structsize>=88) {
+ imginfo=1;
+ }
+
+ if(p2dp->structsize>=96) {
+ if(p2dp->flags & PNGD_USE_HEAPALLOC) {
+ use_heapalloc=1;
+ heap = p2dp->heap;
+ if(!heap) heap = GetProcessHeap();
+ }
+ }
+
+ if(use_heapalloc) {
+ pngdib_set_userdata(qq,(void*)heap);
+ pngdib_setcallback_malloc(qq,heapalloc_callback,heapfree_callback,NULL);
+ }
+ else {
+ pngdib_setcallback_malloc(qq,globalalloc_callback,globalfree_callback,NULL);
+ }
+
+ pngdib_p2d_set_png_filename(qq,p2dp->pngfn);
+
+ pngdib_p2d_set_gamma_correction(qq,(p2dp->flags&PNGD_GAMMA_CORRECTION)?1:0,PNGDIB_DEFAULT_SCREEN_GAMMA);
+
+ if(p2dp->flags&PNGD_USE_BKGD)
+ pngdib_p2d_set_use_file_bg(qq,1);
+
+
+ if(p2dp->flags&PNGD_USE_CUSTOM_BG) {
+ pngdib_p2d_set_custom_bg(qq,p2dp->bgcolor.red,
+ p2dp->bgcolor.green,p2dp->bgcolor.blue);
+ }
+
+ if(p2dp->flags&PNGD_DIB_ALPHA32)
+ pngdib_set_dibalpha32(qq,1);
+
+ errcode=pngdib_p2d_run(qq);
+
+ if(!errcode) {
+
+ pngdib_p2d_get_dib(qq,&p2dp->lpdib, &p2dp->dibsize);
+ pngdib_p2d_get_dibbits(qq,&p2dp->lpbits, &p2dp->bits_offs, NULL);
+ pngdib_p2d_get_palette(qq,&p2dp->palette, &p2dp->palette_offs, &p2dp->palette_colors);
+
+ if(imginfo) {
+ p2dp->color_type = pngdib_p2d_get_colortype(qq);
+ p2dp->bits_per_sample = pngdib_p2d_get_bitspersample(qq);
+ p2dp->interlace = pngdib_p2d_get_interlace(qq);
+ p2dp->bits_per_pixel = pngdib_p2d_get_bitsperpixel(qq);
+ if(pngdib_p2d_get_file_gamma(qq, &p2dp->file_gamma)) {
+ p2dp->flags |= PNGD_GAMMA_RETURNED;
+ }
+ if(pngdib_p2d_get_density(qq, &p2dp->res_x, &p2dp->res_y, &p2dp->res_units)) {
+ p2dp->flags |= PNGD_RES_RETURNED;
+ }
+ if(pngdib_p2d_get_bgcolor(qq, &p2dp->bgcolor.red, &p2dp->bgcolor.green,
+ &p2dp->bgcolor.blue))
+ {
+ p2dp->flags |= PNGD_BG_RETURNED;
+ }
+ }
+ }
+
+ if(p2dp->errmsg) {
+ msg=pngdib_get_error_msg(qq);
+ lstrcpyn(p2dp->errmsg,msg,100);
+ }
+
+ pngdib_done(qq);
+
+ return errcode;
}
int write_dib_to_png(PNGD_D2PINFO *d2pp)
{
- PNGDIB *qq;
- int errcode;
- char *msg;
+ PNGDIB *qq;
+ int errcode;
+ char *msg;
- if(d2pp->structsize != sizeof(PNGD_D2PINFO)) return PNGD_E_VERSION;
+ if(d2pp->structsize != sizeof(PNGD_D2PINFO)) return PNGD_E_VERSION;
- qq = pngdib_d2p_init();
- if(!qq) return PNGD_E_NOMEM;
- pngdib_d2p_set_dib(qq, d2pp->lpdib, d2pp->dibsize,
- d2pp->lpbits, d2pp->bitssize);
- if(d2pp->flags & PNGD_INTERLACED)
- pngdib_d2p_set_interlace(qq, 1);
+ qq=pngdib_d2p_init();
+ if(!qq) return PNGD_E_NOMEM;
+ pngdib_d2p_set_dib(qq,d2pp->lpdib,d2pp->dibsize,
+ d2pp->lpbits,d2pp->bitssize);
+ if(d2pp->flags&PNGD_INTERLACED)
+ pngdib_d2p_set_interlace(qq,1);
- if(d2pp->flags & PNGD_NO_GAMMA_LABEL)
- pngdib_d2p_set_gamma_label(qq, 0, 0.0);
- else
- pngdib_d2p_set_gamma_label(qq, 1, PNGDIB_DEFAULT_FILE_GAMMA);
+ if(d2pp->flags&PNGD_NO_GAMMA_LABEL)
+ pngdib_d2p_set_gamma_label(qq,0,0.0);
+ else
+ pngdib_d2p_set_gamma_label(qq,1,PNGDIB_DEFAULT_FILE_GAMMA);
- pngdib_d2p_set_png_filename(qq, d2pp->pngfn);
+ pngdib_d2p_set_png_filename(qq,d2pp->pngfn);
- if(d2pp->software)
- pngdib_d2p_set_software_id(qq, d2pp->software);
+ if(d2pp->software)
+ pngdib_d2p_set_software_id(qq, d2pp->software);
- if(d2pp->flags & PNGD_DIB_ALPHA32)
- pngdib_set_dibalpha32(qq, 1);
+ if(d2pp->flags&PNGD_DIB_ALPHA32)
+ pngdib_set_dibalpha32(qq,1);
- errcode = pngdib_d2p_run(qq);
+ errcode=pngdib_d2p_run(qq);
- if(d2pp->errmsg)
- {
- msg = pngdib_get_error_msg(qq);
- lstrcpyn(d2pp->errmsg, msg, 100);
- }
+ if(d2pp->errmsg) {
+ msg=pngdib_get_error_msg(qq);
+ lstrcpyn(d2pp->errmsg,msg,100);
+ }
- pngdib_done(qq);
- return errcode;
+ pngdib_done(qq);
+ return errcode;
}
#endif // PNGDIB_V2COMPATIBLE
diff --git a/src/apps/mplayerc/pngdib.h b/src/apps/mplayerc/pngdib.h
index 6cea7f051..124864ee9 100644
--- a/src/apps/mplayerc/pngdib.h
+++ b/src/apps/mplayerc/pngdib.h
@@ -47,50 +47,46 @@ extern "C" {
#if (PNGDIB_V2COMPATIBLE) || defined(PNGDIB_INTERNALS)
- struct PNGD_COLOR_struct
- {
- unsigned char red, green, blue, reserved;
- };
+struct PNGD_COLOR_struct {
+ unsigned char red, green, blue, reserved;
+};
#endif
#if PNGDIB_V2COMPATIBLE
- typedef struct PNGD_D2PINFO_struct
- {
- DWORD structsize; // sizeof(PNGD_D2PINFO)
- DWORD flags;
+typedef struct PNGD_D2PINFO_struct {
+ DWORD structsize; // sizeof(PNGD_D2PINFO)
+ DWORD flags;
#define PNGD_INTERLACED 0x00000001
#define PNGD_NO_GAMMA_LABEL 0x00000002
#define PNGD_DIB_ALPHA32 0x00000010
- char* pngfn; // PNG filename to write
+ char* pngfn; // PNG filename to write
- LPBITMAPINFOHEADER lpdib;
- int dibsize; // can be 0
+ LPBITMAPINFOHEADER lpdib;
+ int dibsize; // can be 0
- VOID* lpbits; // can be NULL
- int bitssize; // can be 0
+ VOID* lpbits; // can be NULL
+ int bitssize; // can be 0
- char* software; // (NULL==don't include)
+ char* software; // (NULL==don't include)
// added in v2.0
- char* errmsg; // user can set to null or 100-char buffer
- } PNGD_D2PINFO;
+ char* errmsg; // user can set to null or 100-char buffer
+} PNGD_D2PINFO;
- typedef struct PNGD_IMAGEINFO_struct
- {
- DWORD structsize; // sizeof(PNGD_IMAGEINFO)
- DWORD flags;
+typedef struct PNGD_IMAGEINFO_struct {
+ DWORD structsize; // sizeof(PNGD_IMAGEINFO)
+ DWORD flags;
- } PNGD_IMAGEINFO;
+} PNGD_IMAGEINFO;
- typedef struct PNGD_P2DINFO_struct
- {
- DWORD structsize; // sizeof(PNGD_P2DINFO)
+typedef struct PNGD_P2DINFO_struct {
+ DWORD structsize; // sizeof(PNGD_P2DINFO)
- DWORD flags; // combination of below:
+ DWORD flags; // combination of below:
#define PNGD_USE_BKGD 0x00000001
#define PNGD_USE_CUSTOM_BG 0x00000002
#define PNGD_GAMMA_CORRECTION 0x00000004
@@ -101,47 +97,47 @@ extern "C" {
#define PNGD_RES_RETURNED 0x00020000 // set if xres,yres,res_units are valid
#define PNGD_GAMMA_RETURNED 0x00040000 // set if file_gamma is valid
- char* pngfn; // PNG filename to read
+ char* pngfn; // PNG filename to read
- LPBITMAPINFOHEADER lpdib; // return value only
- int dibsize; // return value only
- int palette_offs; // return value only
- int bits_offs; // return value only
- RGBQUAD* palette; // return value only
- int palette_colors; // return value only
- VOID* lpbits; // return value only
+ LPBITMAPINFOHEADER lpdib; // return value only
+ int dibsize; // return value only
+ int palette_offs; // return value only
+ int bits_offs; // return value only
+ RGBQUAD* palette; // return value only
+ int palette_colors; // return value only
+ VOID* lpbits; // return value only
// added in v2.0 (size=48)
- struct PNGD_COLOR_struct bgcolor; // IN OUT
- char* errmsg; // user can set to null or 100-char buffer
+ struct PNGD_COLOR_struct bgcolor; // IN OUT
+ char* errmsg; // user can set to null or 100-char buffer
// added in v2.1 (size=88)
- int color_type;
- int bits_per_sample;
- int bits_per_pixel;
- int interlace;
- int res_x, res_y;
- int res_units;
- int reserved1;
- double file_gamma;
+ int color_type;
+ int bits_per_sample;
+ int bits_per_pixel;
+ int interlace;
+ int res_x,res_y;
+ int res_units;
+ int reserved1;
+ double file_gamma;
// added in v2.2 (size=96)
- HANDLE heap;
- int reserved2;
+ HANDLE heap;
+ int reserved2;
- } PNGD_P2DINFO;
+} PNGD_P2DINFO;
- int read_png_to_dib(PNGD_P2DINFO *p2dinfo);
- int write_dib_to_png(PNGD_D2PINFO *d2pinfo);
+int read_png_to_dib(PNGD_P2DINFO *p2dinfo);
+int write_dib_to_png(PNGD_D2PINFO *d2pinfo);
#endif // PNGDIB_V2COMPATIBLE
// public definitions
- typedef void*(PNGDIB_DECL *pngdib_malloc_cb_type)(void *userdata, int memblksize);
- typedef void (PNGDIB_DECL *pngdib_free_cb_type)(void *userdata, void *memblk);
- typedef void*(PNGDIB_DECL *pngdib_realloc_cb_type)(void *userdata, void *memblk, int memblksize);
+typedef void* (PNGDIB_DECL *pngdib_malloc_cb_type)(void *userdata, int memblksize);
+typedef void (PNGDIB_DECL *pngdib_free_cb_type)(void *userdata, void *memblk);
+typedef void* (PNGDIB_DECL *pngdib_realloc_cb_type)(void *userdata, void *memblk, int memblksize);
- struct pngdib_common_struct;
- typedef struct pngdib_common_struct PNGDIB;
+struct pngdib_common_struct;
+typedef struct pngdib_common_struct PNGDIB;
#define PNGD_ST_D2P 1
@@ -155,67 +151,64 @@ extern "C" {
#define PNGDIB_ERRMSG_MAX 200
- struct pngdib_common_struct
- {
- int structtype;
- void *userdata;
- TCHAR *errmsg;
- pngdib_malloc_cb_type malloc_function;
- pngdib_free_cb_type free_function;
- pngdib_realloc_cb_type realloc_function;
- int dib_alpha32;
- };
-
- struct d2p_struct
- {
- struct pngdib_common_struct common;
-
- const BITMAPINFOHEADER* pdib;
- int dibsize;
- const void* pbits;
- int bitssize;
- int interlaced;
- TCHAR* output_filename;
- char* software_id_string;
- int file_gamma_valid;
- double file_gamma;
- };
-
- struct p2d_struct
- {
- struct pngdib_common_struct common;
-
- int input_method; // 0=filename, 1=memory
- TCHAR* input_filename;
- unsigned char* input_memblk;
- int input_memblk_size;
- int input_memblk_curpos;
-
- int use_file_bg_flag;
- int use_custom_bg_flag;
- struct PNGD_COLOR_struct bgcolor;
- int gamma_correction; // should we gamma correct (using screen_gamma)?
- double screen_gamma;
-
- BITMAPINFOHEADER* pdib;
- int dibsize;
- int palette_offs;
- int bits_offs;
- int bitssize;
- RGBQUAD* palette;
- int palette_colors;
- void* pbits;
- int color_type;
- int bits_per_sample;
- int bits_per_pixel;
- int interlace;
- int res_x, res_y;
- int res_units;
- int res_valid; // are res_x, res_y, res_units valid?
- double file_gamma;
- int gamma_returned; // set if we know the file gamma
- int bgcolor_returned;
- };
+struct pngdib_common_struct {
+ int structtype;
+ void *userdata;
+ TCHAR *errmsg;
+ pngdib_malloc_cb_type malloc_function;
+ pngdib_free_cb_type free_function;
+ pngdib_realloc_cb_type realloc_function;
+ int dib_alpha32;
+};
+
+struct d2p_struct {
+ struct pngdib_common_struct common;
+
+ const BITMAPINFOHEADER* pdib;
+ int dibsize;
+ const void* pbits;
+ int bitssize;
+ int interlaced;
+ TCHAR* output_filename;
+ char* software_id_string;
+ int file_gamma_valid;
+ double file_gamma;
+};
+
+struct p2d_struct {
+ struct pngdib_common_struct common;
+
+ int input_method; // 0=filename, 1=memory
+ TCHAR* input_filename;
+ unsigned char* input_memblk;
+ int input_memblk_size;
+ int input_memblk_curpos;
+
+ int use_file_bg_flag;
+ int use_custom_bg_flag;
+ struct PNGD_COLOR_struct bgcolor;
+ int gamma_correction; // should we gamma correct (using screen_gamma)?
+ double screen_gamma;
+
+ BITMAPINFOHEADER* pdib;
+ int dibsize;
+ int palette_offs;
+ int bits_offs;
+ int bitssize;
+ RGBQUAD* palette;
+ int palette_colors;
+ void* pbits;
+ int color_type;
+ int bits_per_sample;
+ int bits_per_pixel;
+ int interlace;
+ int res_x,res_y;
+ int res_units;
+ int res_valid; // are res_x, res_y, res_units valid?
+ double file_gamma;
+ int gamma_returned; // set if we know the file gamma
+ int bgcolor_returned;
+};
#undef _PNGD_DEFINE_COMMON_FIELDS
@@ -226,16 +219,16 @@ extern "C" {
#define pngdib_d2p_init() _pngdib_init(PNGD_ST_D2P,PNGDIB_HEADER_VERSION)
- PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_set_dib(PNGDIB *d2p,
- const BITMAPINFOHEADER* pdib, int dibsize,
- const void* pbits, int bitssize);
+PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_set_dib(PNGDIB *d2p,
+ const BITMAPINFOHEADER* pdib, int dibsize,
+ const void* pbits, int bitssize);
- PNGDIB_EXT void PNGDIB_DECL pngdib_d2p_set_interlace(PNGDIB *d2p, int interlaced);
- PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_set_png_filename(PNGDIB *d2p, const TCHAR *fn);
- PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_set_software_id(PNGDIB *d2p, const TCHAR *s);
- PNGDIB_EXT void PNGDIB_DECL pngdib_d2p_set_gamma_label(PNGDIB *d2p, int flag, double file_gamma);
+PNGDIB_EXT void PNGDIB_DECL pngdib_d2p_set_interlace(PNGDIB *d2p, int interlaced);
+PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_set_png_filename(PNGDIB *d2p, const TCHAR *fn);
+PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_set_software_id(PNGDIB *d2p, const TCHAR *s);
+PNGDIB_EXT void PNGDIB_DECL pngdib_d2p_set_gamma_label(PNGDIB *d2p, int flag, double file_gamma);
- PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_run(PNGDIB *d2p);
+PNGDIB_EXT int PNGDIB_DECL pngdib_d2p_run(PNGDIB *d2p);
////////////
@@ -243,50 +236,50 @@ extern "C" {
#define pngdib_p2d_init() _pngdib_init(PNGD_ST_P2D,PNGDIB_HEADER_VERSION)
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_set_png_filename(PNGDIB *p2d, const TCHAR *fn);
- PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_png_memblk(PNGDIB *p2d, const void *mem, int memsize);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_set_png_filename(PNGDIB *p2d, const TCHAR *fn);
+PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_png_memblk(PNGDIB *p2d, const void *mem, int memsize);
- PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_use_file_bg(PNGDIB *p2d, int flag);
- PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_custom_bg(PNGDIB *p2d, unsigned char r,
- unsigned char g, unsigned char b);
- PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_gamma_correction(PNGDIB *p2d, int flag, double screen_gamma);
+PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_use_file_bg(PNGDIB *p2d, int flag);
+PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_custom_bg(PNGDIB *p2d, unsigned char r,
+ unsigned char g, unsigned char b);
+PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_set_gamma_correction(PNGDIB *p2d, int flag, double screen_gamma);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_run(PNGDIB *p2d);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_run(PNGDIB *p2d);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_dib(PNGDIB *p2d, BITMAPINFOHEADER **ppdib, int *pdibsize);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_dibbits(PNGDIB *p2d, void **ppbits, int *pbitsoffset, int *pbitssize);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_palette(PNGDIB *p2d, RGBQUAD **ppal, int *ppaloffset, int *ppalnumcolors);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_dib(PNGDIB *p2d, BITMAPINFOHEADER **ppdib, int *pdibsize);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_dibbits(PNGDIB *p2d, void **ppbits, int *pbitsoffset, int *pbitssize);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_palette(PNGDIB *p2d, RGBQUAD **ppal, int *ppaloffset, int *ppalnumcolors);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_colortype(PNGDIB *p2d);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_bitspersample(PNGDIB *p2d);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_bitsperpixel(PNGDIB *p2d);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_samplesperpixel(PNGDIB *p2d);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_interlace(PNGDIB *p2d);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_density(PNGDIB *p2d, int *pres_x, int *pres_y, int *pres_units);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_file_gamma(PNGDIB *p2d, double *pgamma);
- PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_bgcolor(PNGDIB *p2d, unsigned char *pr, unsigned char *pg, unsigned char *pb);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_colortype(PNGDIB *p2d);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_bitspersample(PNGDIB *p2d);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_bitsperpixel(PNGDIB *p2d);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_samplesperpixel(PNGDIB *p2d);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_interlace(PNGDIB *p2d);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_density(PNGDIB *p2d, int *pres_x, int *pres_y, int *pres_units);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_file_gamma(PNGDIB *p2d, double *pgamma);
+PNGDIB_EXT int PNGDIB_DECL pngdib_p2d_get_bgcolor(PNGDIB *p2d, unsigned char *pr, unsigned char *pg, unsigned char *pb);
- PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_free_dib(PNGDIB *p2d, BITMAPINFOHEADER *pdib);
+PNGDIB_EXT void PNGDIB_DECL pngdib_p2d_free_dib(PNGDIB *p2d, BITMAPINFOHEADER *pdib);
//////////// common functions
- PNGDIB_EXT PNGDIB* PNGDIB_DECL _pngdib_init(int structtype, int caller_header_vers);
+PNGDIB_EXT PNGDIB* PNGDIB_DECL _pngdib_init(int structtype, int caller_header_vers);
- PNGDIB_EXT int PNGDIB_DECL pngdib_done(PNGDIB *xx);
+PNGDIB_EXT int PNGDIB_DECL pngdib_done(PNGDIB *xx);
- PNGDIB_EXT void PNGDIB_DECL pngdib_setcallback_malloc(PNGDIB *xx,
- pngdib_malloc_cb_type mallocfunc,
- pngdib_free_cb_type freefunc,
- pngdib_realloc_cb_type reallocfunc);
+PNGDIB_EXT void PNGDIB_DECL pngdib_setcallback_malloc(PNGDIB *xx,
+ pngdib_malloc_cb_type mallocfunc,
+ pngdib_free_cb_type freefunc,
+ pngdib_realloc_cb_type reallocfunc);
- PNGDIB_EXT void PNGDIB_DECL pngdib_set_userdata(PNGDIB *xx, void *userdata);
- PNGDIB_EXT void* PNGDIB_DECL pngdib_get_userdata(PNGDIB *xx);
- PNGDIB_EXT TCHAR* PNGDIB_DECL pngdib_get_error_msg(PNGDIB *xx);
+PNGDIB_EXT void PNGDIB_DECL pngdib_set_userdata(PNGDIB *xx, void *userdata);
+PNGDIB_EXT void* PNGDIB_DECL pngdib_get_userdata(PNGDIB *xx);
+PNGDIB_EXT TCHAR* PNGDIB_DECL pngdib_get_error_msg(PNGDIB *xx);
- PNGDIB_EXT TCHAR* PNGDIB_DECL pngdib_get_version_string(void);
- PNGDIB_EXT int PNGDIB_DECL pngdib_get_version(void);
+PNGDIB_EXT TCHAR* PNGDIB_DECL pngdib_get_version_string(void);
+PNGDIB_EXT int PNGDIB_DECL pngdib_get_version(void);
- PNGDIB_EXT void PNGDIB_DECL pngdib_set_dibalpha32(PNGDIB *xx, int flag);
+PNGDIB_EXT void PNGDIB_DECL pngdib_set_dibalpha32(PNGDIB *xx, int flag);
////////////
diff --git a/src/apps/mplayerc/stdafx.h b/src/apps/mplayerc/stdafx.h
index 1ec13e664..05798764a 100644
--- a/src/apps/mplayerc/stdafx.h
+++ b/src/apps/mplayerc/stdafx.h
@@ -77,7 +77,7 @@
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
-template < class T = CString, class S = CString >
+template <class T = CString, class S = CString>
class CAtlStringMap : public CAtlMap<S, T, CStringElementTraits<S> > {};
#define CheckAndLog(x, msg) hr = ##x; if (FAILED (hr)) { TRACE(msg" : 0x%08x\n", hr); return hr; }