当前位置:   article > 正文

Media Player Classic - HC 源代码分析 4:核心类 (CMainFrame)(3)_cmainframe::onwjdy()

cmainframe::onwjdy()

=====================================================

Media Player Classic - HC 源代码分析系列文章列表:

Media Player Classic - HC 源代码分析 1:整体结构

Media Player Classic - HC 源代码分析 2:核心类 (CMainFrame)(1)

Media Player Classic - HC 源代码分析 3:核心类 (CMainFrame)(2)

Media Player Classic - HC 源代码分析 4:核心类 (CMainFrame)(3)

Media Player Classic - HC 源代码分析 5:关于对话框 (CAboutDlg)

Media Player Classic - HC 源代码分析 6:MediaInfo选项卡 (CPPageFileMediaInfo)

Media Player Classic - HC 源代码分析 7:详细信息选项卡(CPPageFileInfoDetails)

=====================================================



此前已经写了2篇文章介绍Media Player Classic - HC (mpc-hc)源代码中的核心类 CMainFrame:

Media Player Classic - HC 源代码分析 2:核心类 (CMainFrame)(1)

Media Player Classic - HC 源代码分析 3:核心类 (CMainFrame)(2)

此前的文章一直都是围绕着OpenMedia()以及其调用的函数进行分析的。研究的都是和文件打开有关系的功能。在这里再介绍一些其它函数。

在mpc-hc开始运行的时候,会调用OnCreate():

  1. <span style="font-family:Arial;font-size:12px;">//刚打开的时候加载
  2. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  3. {
  4. if (__super::OnCreate(lpCreateStruct) == -1) {
  5. return -1;
  6. }
  7. //加载菜单
  8. m_popup.LoadMenu(IDR_POPUP);
  9. m_popupmain.LoadMenu(IDR_POPUPMAIN);
  10. // create a view to occupy the client area of the frame
  11. // 创建视频画面部分?
  12. if (!m_wndView.Create(nullptr, nullptr, AFX_WS_DEFAULT_VIEW,
  13. CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, nullptr)) {
  14. TRACE(_T("Failed to create view window\n"));
  15. return -1;
  16. }
  17. // Should never be RTLed
  18. m_wndView.ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);
  19. // static bars
  20. //各种状态栏
  21. BOOL bResult = m_wndStatusBar.Create(this);
  22. if (bResult) {
  23. bResult = m_wndStatsBar.Create(this);
  24. }
  25. if (bResult) {
  26. bResult = m_wndInfoBar.Create(this);
  27. }
  28. if (bResult) {
  29. bResult = m_wndToolBar.Create(this);
  30. }
  31. if (bResult) {
  32. bResult = m_wndSeekBar.Create(this);
  33. }
  34. if (!bResult) {
  35. TRACE(_T("Failed to create all control bars\n"));
  36. return -1; // fail to create
  37. }
  38. // 各种Bar
  39. m_pFullscreenWnd = DEBUG_NEW CFullscreenWnd(this);
  40. m_bars.AddTail(&m_wndSeekBar);
  41. m_bars.AddTail(&m_wndToolBar);
  42. m_bars.AddTail(&m_wndInfoBar);
  43. m_bars.AddTail(&m_wndStatsBar);
  44. m_bars.AddTail(&m_wndStatusBar);
  45. m_wndSeekBar.Enable(false);
  46. // dockable bars
  47. // 可停靠的
  48. EnableDocking(CBRS_ALIGN_ANY);
  49. m_dockingbars.RemoveAll();
  50. m_wndSubresyncBar.Create(this, AFX_IDW_DOCKBAR_TOP, &m_csSubLock);
  51. m_wndSubresyncBar.SetBarStyle(m_wndSubresyncBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  52. m_wndSubresyncBar.EnableDocking(CBRS_ALIGN_ANY);
  53. m_wndSubresyncBar.SetHeight(200);
  54. m_dockingbars.AddTail(&m_wndSubresyncBar);
  55. m_wndPlaylistBar.Create(this, AFX_IDW_DOCKBAR_BOTTOM);
  56. m_wndPlaylistBar.SetBarStyle(m_wndPlaylistBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  57. m_wndPlaylistBar.EnableDocking(CBRS_ALIGN_ANY);
  58. m_wndPlaylistBar.SetHeight(100);
  59. m_dockingbars.AddTail(&m_wndPlaylistBar);
  60. m_wndPlaylistBar.LoadPlaylist(GetRecentFile());
  61. m_wndEditListEditor.Create(this, AFX_IDW_DOCKBAR_RIGHT);
  62. m_wndEditListEditor.SetBarStyle(m_wndEditListEditor.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  63. m_wndEditListEditor.EnableDocking(CBRS_ALIGN_ANY);
  64. m_dockingbars.AddTail(&m_wndEditListEditor);
  65. m_wndEditListEditor.SetHeight(100);
  66. m_wndCaptureBar.Create(this, AFX_IDW_DOCKBAR_LEFT);
  67. m_wndCaptureBar.SetBarStyle(m_wndCaptureBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  68. m_wndCaptureBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
  69. m_dockingbars.AddTail(&m_wndCaptureBar);
  70. m_wndNavigationBar.Create(this, AFX_IDW_DOCKBAR_LEFT);
  71. m_wndNavigationBar.SetBarStyle(m_wndNavigationBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  72. m_wndNavigationBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
  73. m_dockingbars.AddTail(&m_wndNavigationBar);
  74. m_wndShaderEditorBar.Create(this, AFX_IDW_DOCKBAR_TOP);
  75. m_wndShaderEditorBar.SetBarStyle(m_wndShaderEditorBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  76. m_wndShaderEditorBar.EnableDocking(CBRS_ALIGN_ANY);
  77. m_dockingbars.AddTail(&m_wndShaderEditorBar);
  78. // Hide all dockable bars by default
  79. POSITION pos = m_dockingbars.GetHeadPosition();
  80. while (pos) {
  81. m_dockingbars.GetNext(pos)->ShowWindow(SW_HIDE);
  82. }
  83. m_fileDropTarget.Register(this);
  84. const CAppSettings& s = AfxGetAppSettings();
  85. // Load the controls
  86. m_nCS = s.nCS;
  87. ShowControls(m_nCS);
  88. //是否在最前?
  89. SetAlwaysOnTop(s.iOnTop);
  90. //显示系统托盘图标
  91. ShowTrayIcon(s.fTrayIcon);
  92. //焦点
  93. SetFocus();
  94. //创建CGraphThread类的线程
  95. m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
  96. //设置。。
  97. if (m_pGraphThread) {
  98. m_pGraphThread->SetMainFrame(this);
  99. }
  100. if (s.nCmdlnWebServerPort != 0) {
  101. if (s.nCmdlnWebServerPort > 0) {
  102. StartWebServer(s.nCmdlnWebServerPort);
  103. } else if (s.fEnableWebServer) {
  104. StartWebServer(s.nWebServerPort);
  105. }
  106. }
  107. // Casimir666 : reload Shaders
  108. {
  109. CString strList = s.strShaderList;
  110. CString strRes;
  111. int curPos = 0;
  112. strRes = strList.Tokenize(_T("|"), curPos);
  113. while (!strRes.IsEmpty()) {
  114. m_shaderlabels.AddTail(strRes);
  115. strRes = strList.Tokenize(_T("|"), curPos);
  116. }
  117. }
  118. {
  119. CString strList = s.strShaderListScreenSpace;
  120. CString strRes;
  121. int curPos = 0;
  122. strRes = strList.Tokenize(_T("|"), curPos);
  123. while (!strRes.IsEmpty()) {
  124. m_shaderlabelsScreenSpace.AddTail(strRes);
  125. strRes = strList.Tokenize(_T("|"), curPos);
  126. }
  127. }
  128. m_bToggleShader = s.fToggleShader;
  129. m_bToggleShaderScreenSpace = s.fToggleShaderScreenSpace;
  130. //标题
  131. m_strTitle.LoadString(IDR_MAINFRAME);
  132. #ifdef MPCHC_LITE
  133. m_strTitle += _T(" Lite");
  134. #endif
  135. //设置窗口标题
  136. SetWindowText(m_strTitle);
  137. m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
  138. WTSRegisterSessionNotification();
  139. if (s.bNotifySkype) {
  140. m_pSkypeMoodMsgHandler.Attach(DEBUG_NEW SkypeMoodMsgHandler());
  141. m_pSkypeMoodMsgHandler->Connect(m_hWnd);
  142. }
  143. return 0;
  144. }</span>

在mpc-hc关闭的时候,会调用OnDestroy():

  1. <span style="font-family:Arial;font-size:12px;">//关闭的时候加载
  2. void CMainFrame::OnDestroy()
  3. {
  4. WTSUnRegisterSessionNotification();
  5. //关闭系统托盘图标
  6. ShowTrayIcon(false);
  7. m_fileDropTarget.Revoke();
  8. //线程还在运行的话
  9. if (m_pGraphThread) {
  10. CAMMsgEvent e;
  11. //退出
  12. m_pGraphThread->PostThreadMessage(CGraphThread::TM_EXIT, 0, (LPARAM)&e);
  13. if (!e.Wait(5000)) {
  14. TRACE(_T("ERROR: Must call TerminateThread() on CMainFrame::m_pGraphThread->m_hThread\n"));
  15. TerminateThread(m_pGraphThread->m_hThread, (DWORD) - 1);
  16. }
  17. }
  18. if (m_pFullscreenWnd) {
  19. if (m_pFullscreenWnd->IsWindow()) {
  20. m_pFullscreenWnd->DestroyWindow();
  21. }
  22. delete m_pFullscreenWnd;
  23. }
  24. __super::OnDestroy();
  25. }</span>

在关闭一个媒体的时候,会调用OnClose():

  1. //关闭的时候加载
  2. void CMainFrame::OnClose()
  3. {
  4. //获取设置
  5. CAppSettings& s = AfxGetAppSettings();
  6. // Casimir666 : save shaders list
  7. {
  8. POSITION pos;
  9. CString strList = "";
  10. pos = m_shaderlabels.GetHeadPosition();
  11. while (pos) {
  12. strList += m_shaderlabels.GetAt(pos) + "|";
  13. m_dockingbars.GetNext(pos);
  14. }
  15. s.strShaderList = strList;
  16. }
  17. {
  18. POSITION pos;
  19. CString strList = "";
  20. pos = m_shaderlabelsScreenSpace.GetHeadPosition();
  21. while (pos) {
  22. strList += m_shaderlabelsScreenSpace.GetAt(pos) + "|";
  23. m_dockingbars.GetNext(pos);
  24. }
  25. s.strShaderListScreenSpace = strList;
  26. }
  27. s.fToggleShader = m_bToggleShader;
  28. s.fToggleShaderScreenSpace = m_bToggleShaderScreenSpace;
  29. s.dZoomX = m_ZoomX;
  30. s.dZoomY = m_ZoomY;
  31. //存储播放列表
  32. m_wndPlaylistBar.SavePlaylist();
  33. //存储控制条
  34. SaveControlBars();
  35. ShowWindow(SW_HIDE);
  36. //关闭媒体(非private)
  37. CloseMedia();
  38. s.WinLircClient.DisConnect();
  39. s.UIceClient.DisConnect();
  40. SendAPICommand(CMD_DISCONNECT, L"\0"); // according to CMD_NOTIFYENDOFSTREAM (ctrl+f it here), you're not supposed to send NULL here
  41. //调用父类onclose
  42. __super::OnClose();
  43. }

同时还有一个定时器函数OnTimer()。根据不同的nIDEvent做不同的处理操作。

  1. //定时刷新的操作
  2. void CMainFrame::OnTimer(UINT_PTR nIDEvent)
  3. {
  4. switch (nIDEvent) {
  5. //当前播放到的位置
  6. case TIMER_STREAMPOSPOLLER:
  7. if (m_iMediaLoadState == MLS_LOADED) {
  8. REFERENCE_TIME rtNow = 0, rtDur = 0;
  9. //播放方式是文件的时候(还可以是DVD或者摄像头)
  10. if (GetPlaybackMode() == PM_FILE) {
  11. //当前位置
  12. m_pMS->GetCurrentPosition(&rtNow);
  13. //时常
  14. m_pMS->GetDuration(&rtDur);
  15. // Casimir666 : autosave subtitle sync after play
  16. if ((m_nCurSubtitle >= 0) && (m_rtCurSubPos != rtNow)) {
  17. if (m_lSubtitleShift != 0) {
  18. if (m_wndSubresyncBar.SaveToDisk()) {
  19. m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_AG_SUBTITLES_SAVED), 500);
  20. } else {
  21. m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_MAINFRM_4));
  22. }
  23. }
  24. m_nCurSubtitle = -1;
  25. m_lSubtitleShift = 0;
  26. }
  27. if (!m_fEndOfStream) {
  28. CAppSettings& s = AfxGetAppSettings();
  29. if (m_bRememberFilePos) {
  30. FILE_POSITION* filePosition = s.filePositions.GetLatestEntry();
  31. if (filePosition) {
  32. filePosition->llPosition = rtNow;
  33. LARGE_INTEGER time;
  34. QueryPerformanceCounter(&time);
  35. LARGE_INTEGER freq;
  36. QueryPerformanceFrequency(&freq);
  37. if ((time.QuadPart - m_liLastSaveTime.QuadPart) >= 30 * freq.QuadPart) { // save every half of minute
  38. m_liLastSaveTime = time;
  39. s.filePositions.SaveLatestEntry();
  40. }
  41. }
  42. }
  43. }
  44. if (m_rtDurationOverride >= 0) {
  45. rtDur = m_rtDurationOverride;
  46. }
  47. //设置滑动条控件的参数(位置等。。。)
  48. g_bNoDuration = rtDur <= 0;
  49. m_wndSeekBar.Enable(rtDur > 0);
  50. m_wndSeekBar.SetRange(0, rtDur);
  51. m_wndSeekBar.SetPos(rtNow);
  52. m_OSD.SetRange(0, rtDur);
  53. m_OSD.SetPos(rtNow);
  54. m_Lcd.SetMediaRange(0, rtDur);
  55. m_Lcd.SetMediaPos(rtNow);
  56. } else if (GetPlaybackMode() == PM_CAPTURE) {
  57. //如果是摄像头的话,就没有时长信息了
  58. m_pMS->GetCurrentPosition(&rtNow);
  59. if (m_fCapturing && m_wndCaptureBar.m_capdlg.m_pMux) {
  60. CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
  61. if (!pMuxMS || FAILED(pMuxMS->GetCurrentPosition(&rtNow))) {
  62. rtNow = 0;
  63. }
  64. }
  65. if (m_rtDurationOverride >= 0) {
  66. rtDur = m_rtDurationOverride;
  67. }
  68. g_bNoDuration = rtDur <= 0;
  69. m_wndSeekBar.Enable(false);
  70. m_wndSeekBar.SetRange(0, rtDur);
  71. m_wndSeekBar.SetPos(rtNow);
  72. m_OSD.SetRange(0, rtDur);
  73. m_OSD.SetPos(rtNow);
  74. m_Lcd.SetMediaRange(0, rtDur);
  75. m_Lcd.SetMediaPos(rtNow);
  76. }
  77. if (m_pCAP && GetPlaybackMode() != PM_FILE) {
  78. g_bExternalSubtitleTime = true;
  79. if (m_pDVDI) {
  80. DVD_PLAYBACK_LOCATION2 Location;
  81. if (m_pDVDI->GetCurrentLocation(&Location) == S_OK) {
  82. double fps = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
  83. : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
  84. : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
  85. : 25.0;
  86. REFERENCE_TIME rtTimeCode = HMSF2RT(Location.TimeCode, fps);
  87. m_pCAP->SetTime(rtTimeCode);
  88. } else {
  89. m_pCAP->SetTime(/*rtNow*/m_wndSeekBar.GetPos());
  90. }
  91. } else {
  92. // Set rtNow to support DVB subtitle
  93. m_pCAP->SetTime(rtNow);
  94. }
  95. } else {
  96. g_bExternalSubtitleTime = false;
  97. }
  98. }
  99. break;
  100. case TIMER_STREAMPOSPOLLER2:
  101. if (m_iMediaLoadState == MLS_LOADED) {
  102. __int64 start, stop, pos;
  103. m_wndSeekBar.GetRange(start, stop);
  104. pos = m_wndSeekBar.GetPosReal();
  105. GUID tf;
  106. m_pMS->GetTimeFormat(&tf);
  107. if (GetPlaybackMode() == PM_CAPTURE && !m_fCapturing) {
  108. CString str = ResStr(IDS_CAPTURE_LIVE);
  109. long lChannel = 0, lVivSub = 0, lAudSub = 0;
  110. if (m_pAMTuner
  111. && m_wndCaptureBar.m_capdlg.IsTunerActive()
  112. && SUCCEEDED(m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub))) {
  113. CString ch;
  114. ch.Format(_T(" (ch%d)"), lChannel);
  115. str += ch;
  116. }
  117. m_wndStatusBar.SetStatusTimer(str);
  118. } else {
  119. m_wndStatusBar.SetStatusTimer(pos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
  120. if (m_bRemainingTime) {
  121. m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer());
  122. }
  123. }
  124. m_wndSubresyncBar.SetTime(pos);
  125. if (m_pCAP && GetMediaState() == State_Paused) {
  126. m_pCAP->Paint(false);
  127. }
  128. }
  129. break;
  130. case TIMER_FULLSCREENCONTROLBARHIDER: {
  131. CPoint p;
  132. GetCursorPos(&p);
  133. CRect r;
  134. GetWindowRect(r);
  135. bool fCursorOutside = !r.PtInRect(p);
  136. CWnd* pWnd = WindowFromPoint(p);
  137. if (pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
  138. if (AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut >= 0) {
  139. ShowControls(CS_NONE);
  140. }
  141. }
  142. }
  143. break;
  144. case TIMER_FULLSCREENMOUSEHIDER: {
  145. CPoint p;
  146. GetCursorPos(&p);
  147. CRect r;
  148. GetWindowRect(r);
  149. bool fCursorOutside = !r.PtInRect(p);
  150. CWnd* pWnd = WindowFromPoint(p);
  151. if (IsD3DFullScreenMode()) {
  152. if (pWnd && !m_bInOptions && *pWnd == *m_pFullscreenWnd) {
  153. m_pFullscreenWnd->ShowCursor(false);
  154. }
  155. KillTimer(TIMER_FULLSCREENMOUSEHIDER);
  156. } else {
  157. if (pWnd && !m_bInOptions && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
  158. m_fHideCursor = true;
  159. SetCursor(nullptr);
  160. }
  161. }
  162. }
  163. break;
  164. //统计量
  165. case TIMER_STATS: {
  166. //接收端质量信息:抖动,抖动,视音频同步情况等。。。
  167. if (m_pQP) {
  168. CString rate;
  169. rate.Format(_T("%.2f"), m_dSpeedRate);
  170. rate = _T("(") + rate + _T("x)");
  171. //信息
  172. CString info;
  173. int val = 0;
  174. //平均帧率
  175. m_pQP->get_AvgFrameRate(&val); // We hang here due to a lock that never gets released.
  176. info.Format(_T("%d.%02d %s"), val / 100, val % 100, rate);
  177. m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
  178. int avg, dev;
  179. //抖动
  180. m_pQP->get_AvgSyncOffset(&avg);
  181. m_pQP->get_DevSyncOffset(&dev);
  182. info.Format(ResStr(IDS_STATSBAR_SYNC_OFFSET_FORMAT), avg, dev);
  183. m_wndStatsBar.SetLine(ResStr(IDS_STATSBAR_SYNC_OFFSET), info);
  184. //掉帧
  185. int drawn, dropped;
  186. m_pQP->get_FramesDrawn(&drawn);
  187. m_pQP->get_FramesDroppedInRenderer(&dropped);
  188. info.Format(IDS_MAINFRM_6, drawn, dropped);
  189. m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
  190. //抖动
  191. m_pQP->get_Jitter(&val);
  192. info.Format(_T("%d ms"), val);
  193. m_wndStatsBar.SetLine(ResStr(IDS_STATSBAR_JITTER), info);
  194. }
  195. //缓存信息
  196. if (m_pBI) {
  197. CAtlList<CString> sl;
  198. //获取数量
  199. for (int i = 0, j = m_pBI->GetCount(); i < j; i++) {
  200. int samples, size;
  201. //获取缓存状态
  202. if (S_OK == m_pBI->GetStatus(i, samples, size)) {
  203. CString str;
  204. str.Format(_T("[%d]: %03d/%d KB"), i, samples, size / 1024);
  205. sl.AddTail(str);
  206. }
  207. }
  208. if (!sl.IsEmpty()) {
  209. CString str;
  210. str.Format(_T("%s (p%u)"), Implode(sl, ' '), m_pBI->GetPriority());
  211. m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), str);
  212. }
  213. }
  214. //比特率信息
  215. CInterfaceList<IBitRateInfo> pBRIs;
  216. BeginEnumFilters(m_pGB, pEF, pBF) {
  217. BeginEnumPins(pBF, pEP, pPin) {
  218. if (CComQIPtr<IBitRateInfo> pBRI = pPin) {
  219. pBRIs.AddTail(pBRI);
  220. }
  221. }
  222. EndEnumPins;
  223. if (!pBRIs.IsEmpty()) {
  224. CAtlList<CString> sl;
  225. POSITION pos = pBRIs.GetHeadPosition();
  226. for (int i = 0; pos; i++) {
  227. //比特率接口
  228. IBitRateInfo* pBRI = pBRIs.GetNext(pos);
  229. //当前比特率
  230. DWORD cur = pBRI->GetCurrentBitRate() / 1000;
  231. //平均比特率
  232. DWORD avg = pBRI->GetAverageBitRate() / 1000;
  233. if (avg == 0) {
  234. continue;
  235. }
  236. //添加到字符串
  237. CString str;
  238. if (cur != avg) {
  239. str.Format(_T("[%d]: %u/%u Kb/s"), i, avg, cur);
  240. } else {
  241. str.Format(_T("[%d]: %u Kb/s"), i, avg);
  242. }
  243. //加入
  244. sl.AddTail(str);
  245. }
  246. if (!sl.IsEmpty()) {
  247. m_wndStatsBar.SetLine(ResStr(IDS_STATSBAR_BITRATE), Implode(sl, ' ') + ResStr(IDS_STATSBAR_BITRATE_AVG_CUR));
  248. }
  249. break;
  250. }
  251. }
  252. EndEnumFilters;
  253. if (GetPlaybackMode() == PM_DVD) { // we also use this timer to update the info panel for DVD playback
  254. ULONG ulAvailable, ulCurrent;
  255. // Location
  256. CString Location('-');
  257. DVD_PLAYBACK_LOCATION2 loc;
  258. ULONG ulNumOfVolumes, ulVolume;
  259. DVD_DISC_SIDE Side;
  260. ULONG ulNumOfTitles;
  261. ULONG ulNumOfChapters;
  262. if (SUCCEEDED(m_pDVDI->GetCurrentLocation(&loc))
  263. && SUCCEEDED(m_pDVDI->GetNumberOfChapters(loc.TitleNum, &ulNumOfChapters))
  264. && SUCCEEDED(m_pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles))) {
  265. Location.Format(IDS_MAINFRM_9,
  266. ulVolume, ulNumOfVolumes,
  267. loc.TitleNum, ulNumOfTitles,
  268. loc.ChapterNum, ulNumOfChapters);
  269. ULONG tsec = (loc.TimeCode.bHours * 3600)
  270. + (loc.TimeCode.bMinutes * 60)
  271. + (loc.TimeCode.bSeconds);
  272. /* This might not always work, such as on resume */
  273. if (loc.ChapterNum != m_lCurrentChapter) {
  274. m_lCurrentChapter = loc.ChapterNum;
  275. m_lChapterStartTime = tsec;
  276. } else {
  277. /* If a resume point was used, and the user chapter jumps,
  278. then it might do some funky time jumping. Try to 'fix' the
  279. chapter start time if this happens */
  280. if (m_lChapterStartTime > tsec) {
  281. m_lChapterStartTime = tsec;
  282. }
  283. }
  284. }
  285. m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), Location);
  286. // Video
  287. CString Video('-');
  288. DVD_VideoAttributes VATR;
  289. if (SUCCEEDED(m_pDVDI->GetCurrentAngle(&ulAvailable, &ulCurrent))
  290. && SUCCEEDED(m_pDVDI->GetCurrentVideoAttributes(&VATR))) {
  291. Video.Format(IDS_MAINFRM_10,
  292. ulCurrent, ulAvailable,
  293. VATR.ulSourceResolutionX, VATR.ulSourceResolutionY, VATR.ulFrameRate,
  294. VATR.ulAspectX, VATR.ulAspectY);
  295. }
  296. m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), Video);
  297. // Audio
  298. CString Audio('-');
  299. DVD_AudioAttributes AATR;
  300. if (SUCCEEDED(m_pDVDI->GetCurrentAudio(&ulAvailable, &ulCurrent))
  301. && SUCCEEDED(m_pDVDI->GetAudioAttributes(ulCurrent, &AATR))) {
  302. CString lang;
  303. if (AATR.Language) {
  304. int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
  305. lang.ReleaseBufferSetLength(max(len - 1, 0));
  306. } else {
  307. lang.Format(IDS_AG_UNKNOWN, ulCurrent + 1);
  308. }
  309. switch (AATR.LanguageExtension) {
  310. case DVD_AUD_EXT_NotSpecified:
  311. default:
  312. break;
  313. case DVD_AUD_EXT_Captions:
  314. lang += _T(" (Captions)");
  315. break;
  316. case DVD_AUD_EXT_VisuallyImpaired:
  317. lang += _T(" (Visually Impaired)");
  318. break;
  319. case DVD_AUD_EXT_DirectorComments1:
  320. lang += _T(" (Director Comments 1)");
  321. break;
  322. case DVD_AUD_EXT_DirectorComments2:
  323. lang += _T(" (Director Comments 2)");
  324. break;
  325. }
  326. CString format = GetDVDAudioFormatName(AATR);
  327. Audio.Format(IDS_MAINFRM_11,
  328. lang,
  329. format,
  330. AATR.dwFrequency,
  331. AATR.bQuantization,
  332. AATR.bNumberOfChannels,
  333. (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
  334. m_wndStatusBar.SetStatusBitmap(
  335. AATR.bNumberOfChannels == 1 ? IDB_AUDIOTYPE_MONO
  336. : AATR.bNumberOfChannels >= 2 ? IDB_AUDIOTYPE_STEREO
  337. : IDB_AUDIOTYPE_NOAUDIO);
  338. }
  339. m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), Audio);
  340. // Subtitles
  341. CString Subtitles('-');
  342. BOOL bIsDisabled;
  343. DVD_SubpictureAttributes SATR;
  344. if (SUCCEEDED(m_pDVDI->GetCurrentSubpicture(&ulAvailable, &ulCurrent, &bIsDisabled))
  345. && SUCCEEDED(m_pDVDI->GetSubpictureAttributes(ulCurrent, &SATR))) {
  346. CString lang;
  347. int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
  348. lang.ReleaseBufferSetLength(max(len - 1, 0));
  349. switch (SATR.LanguageExtension) {
  350. case DVD_SP_EXT_NotSpecified:
  351. default:
  352. break;
  353. case DVD_SP_EXT_Caption_Normal:
  354. lang += _T("");
  355. break;
  356. case DVD_SP_EXT_Caption_Big:
  357. lang += _T(" (Big)");
  358. break;
  359. case DVD_SP_EXT_Caption_Children:
  360. lang += _T(" (Children)");
  361. break;
  362. case DVD_SP_EXT_CC_Normal:
  363. lang += _T(" (CC)");
  364. break;
  365. case DVD_SP_EXT_CC_Big:
  366. lang += _T(" (CC Big)");
  367. break;
  368. case DVD_SP_EXT_CC_Children:
  369. lang += _T(" (CC Children)");
  370. break;
  371. case DVD_SP_EXT_Forced:
  372. lang += _T(" (Forced)");
  373. break;
  374. case DVD_SP_EXT_DirectorComments_Normal:
  375. lang += _T(" (Director Comments)");
  376. break;
  377. case DVD_SP_EXT_DirectorComments_Big:
  378. lang += _T(" (Director Comments, Big)");
  379. break;
  380. case DVD_SP_EXT_DirectorComments_Children:
  381. lang += _T(" (Director Comments, Children)");
  382. break;
  383. }
  384. if (bIsDisabled) {
  385. lang = _T("-");
  386. }
  387. Subtitles.Format(_T("%s"),
  388. lang);
  389. }
  390. m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), Subtitles);
  391. } else if (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1) {
  392. CComQIPtr<IBDATuner> pTun = m_pGB;
  393. BOOLEAN bPresent;
  394. BOOLEAN bLocked;
  395. LONG lDbStrength;
  396. LONG lPercentQuality;
  397. CString Signal;
  398. if (SUCCEEDED(pTun->GetStats(bPresent, bLocked, lDbStrength, lPercentQuality)) && bPresent) {
  399. Signal.Format(ResStr(IDS_STATSBAR_SIGNAL_FORMAT), (int)lDbStrength, lPercentQuality);
  400. m_wndStatsBar.SetLine(ResStr(IDS_STATSBAR_SIGNAL), Signal);
  401. }
  402. } else if (GetPlaybackMode() == PM_FILE) {
  403. UpdateChapterInInfoBar();
  404. }
  405. if (GetMediaState() == State_Running && !m_fAudioOnly) {
  406. BOOL fActive = FALSE;
  407. if (SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &fActive, 0)) {
  408. SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, nullptr, SPIF_SENDWININICHANGE); // this might not be needed at all...
  409. SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fActive, nullptr, SPIF_SENDWININICHANGE);
  410. }
  411. fActive = FALSE;
  412. if (SystemParametersInfo(SPI_GETPOWEROFFACTIVE, 0, &fActive, 0)) {
  413. SystemParametersInfo(SPI_SETPOWEROFFACTIVE, FALSE, nullptr, SPIF_SENDWININICHANGE); // this might not be needed at all...
  414. SystemParametersInfo(SPI_SETPOWEROFFACTIVE, fActive, nullptr, SPIF_SENDWININICHANGE);
  415. }
  416. // prevent screensaver activate, monitor sleep/turn off after playback
  417. SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
  418. }
  419. }
  420. break;
  421. case TIMER_STATUSERASER: {
  422. KillTimer(TIMER_STATUSERASER);
  423. m_playingmsg.Empty();
  424. }
  425. break;
  426. case TIMER_DVBINFO_UPDATER:
  427. KillTimer(TIMER_DVBINFO_UPDATER);
  428. ShowCurrentChannelInfo(false, false);
  429. break;
  430. }
  431. __super::OnTimer(nIDEvent);
  432. }


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/326822
推荐阅读
  

闽ICP备14008679号