• R/O
  • HTTP
  • SSH
  • HTTPS

main: Commit

メインリポジトリ


Commit MetaInfo

Revision6dec797b1de4edc3180710ef2621ac000ee81e03 (tree)
Time2009-07-03 12:11:43
AuthorNoumi Akira <noumiakira@user...>
CommiterNoumi Akira

Log Message

add QPlayerEx.

Change Summary

Incremental Difference

--- a/QTheoraEx.sln
+++ b/QTheoraEx.sln
@@ -11,6 +11,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TBenchEx", "Tests\TBenchEx\
1111 EndProject
1212 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QTheoraEx", "Lib\QTheoraEx\QTheoraEx.vcproj", "{2FE5C617-C9E8-48DD-BB21-CEC1DCD32865}"
1313 EndProject
14+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QDecoder", "Lib\QDecoder\QDecoder.vcproj", "{04962854-17F2-4F48-BBB5-8F60EF5DCB39}"
15+EndProject
16+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QPlayerEx", "Tests\QPlayerEx\QPlayerEx.vcproj", "{652330EF-E833-4CB6-9212-547A2E1999F9}"
17+ ProjectSection(ProjectDependencies) = postProject
18+ {2FE5C617-C9E8-48DD-BB21-CEC1DCD32865} = {2FE5C617-C9E8-48DD-BB21-CEC1DCD32865}
19+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39} = {04962854-17F2-4F48-BBB5-8F60EF5DCB39}
20+ {B108EB7F-BE91-4F76-AAAF-3E4EA95BBFFF} = {B108EB7F-BE91-4F76-AAAF-3E4EA95BBFFF}
21+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647} = {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}
22+ EndProjectSection
23+EndProject
24+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QVorbis", "Lib\QVorbis\QVorbis.vcproj", "{3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}"
25+EndProject
1426 Global
1527 GlobalSection(SolutionConfigurationPlatforms) = preSolution
1628 Debug|Any CPU = Debug|Any CPU
@@ -51,6 +63,36 @@ Global
5163 {2FE5C617-C9E8-48DD-BB21-CEC1DCD32865}.Release|Mixed Platforms.Build.0 = Release|Win32
5264 {2FE5C617-C9E8-48DD-BB21-CEC1DCD32865}.Release|Win32.ActiveCfg = Release|Win32
5365 {2FE5C617-C9E8-48DD-BB21-CEC1DCD32865}.Release|Win32.Build.0 = Release|Win32
66+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Debug|Any CPU.ActiveCfg = Debug|Win32
67+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
68+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Debug|Mixed Platforms.Build.0 = Debug|Win32
69+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Debug|Win32.ActiveCfg = Debug|Win32
70+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Debug|Win32.Build.0 = Debug|Win32
71+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Release|Any CPU.ActiveCfg = Release|Win32
72+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Release|Mixed Platforms.ActiveCfg = Release|Win32
73+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Release|Mixed Platforms.Build.0 = Release|Win32
74+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Release|Win32.ActiveCfg = Release|Win32
75+ {04962854-17F2-4F48-BBB5-8F60EF5DCB39}.Release|Win32.Build.0 = Release|Win32
76+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Debug|Any CPU.ActiveCfg = Debug|Win32
77+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
78+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Debug|Mixed Platforms.Build.0 = Debug|Win32
79+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Debug|Win32.ActiveCfg = Debug|Win32
80+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Debug|Win32.Build.0 = Debug|Win32
81+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Release|Any CPU.ActiveCfg = Release|Win32
82+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Release|Mixed Platforms.ActiveCfg = Release|Win32
83+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Release|Mixed Platforms.Build.0 = Release|Win32
84+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Release|Win32.ActiveCfg = Release|Win32
85+ {652330EF-E833-4CB6-9212-547A2E1999F9}.Release|Win32.Build.0 = Release|Win32
86+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Debug|Any CPU.ActiveCfg = Debug|Win32
87+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
88+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Debug|Mixed Platforms.Build.0 = Debug|Win32
89+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Debug|Win32.ActiveCfg = Debug|Win32
90+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Debug|Win32.Build.0 = Debug|Win32
91+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Release|Any CPU.ActiveCfg = Release|Win32
92+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Release|Mixed Platforms.ActiveCfg = Release|Win32
93+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Release|Mixed Platforms.Build.0 = Release|Win32
94+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Release|Win32.ActiveCfg = Release|Win32
95+ {3BF50EBE-F204-4DF0-A9E8-A47F4A3D1647}.Release|Win32.Build.0 = Release|Win32
5496 EndGlobalSection
5597 GlobalSection(SolutionProperties) = preSolution
5698 HideSolutionNode = FALSE
--- /dev/null
+++ b/Tests/QPlayerEx/Main.cpp
@@ -0,0 +1,119 @@
1+// Main.cpp
2+// 2009/05/29
3+
4+#include "StdAfx.h"
5+
6+#include <crtdbg.h>
7+
8+#include "TheoraDecoder.h"
9+#include "VorbisDecoder.h"
10+
11+/* */
12+
13+#include "MainDialog.h"
14+
15+/* */
16+
17+WTL::CAppModule _Module;
18+
19+/* */
20+
21+int DoProcess();
22+
23+/* */
24+
25+int WINAPI wWinMain(
26+ HINSTANCE hInstance,
27+ HINSTANCE /*hPrevInstance*/,
28+ LPWSTR /*lpCmdLine*/,
29+ int /*nCmdShow*/)
30+{
31+ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
32+ // _CrtSetBreakAlloc(1);
33+
34+ HRESULT hRslt = OleInitialize(0);
35+ if (FAILED(hRslt)) {
36+ return -1;
37+ }
38+
39+ _Module.Init(0, hInstance);
40+
41+ int result = DoProcess();
42+
43+ _Module.Term();
44+
45+ OleUninitialize();
46+
47+ return result;
48+}
49+
50+/* */
51+
52+static bool DoInitialize();
53+static void DoUninitialize();
54+static int DoMain();
55+
56+int DoProcess()
57+{
58+ int result = -1;
59+
60+ if (DoInitialize()) {
61+ result = DoMain();
62+ }
63+
64+ DoUninitialize();
65+
66+ return result;
67+}
68+
69+/* */
70+
71+static bool DoInitialize()
72+{
73+ if (!QT_Initialize()) {
74+ return false;
75+ }
76+
77+ if (!QV_Initialize()) {
78+ return false;
79+ }
80+
81+ return true;
82+}
83+
84+static void DoUninitialize()
85+{
86+}
87+
88+/* */
89+
90+static int DoMain()
91+{
92+ int result = -1;
93+
94+ WTL::CMessageLoop theLoop;
95+ _Module.AddMessageLoop(&theLoop);
96+
97+ {
98+ MainDialog dlg;
99+
100+ theLoop.AddMessageFilter(&dlg);
101+
102+ HWND hwnd = dlg.Create(0);
103+ if (hwnd != 0) {
104+ dlg.ShowWindow(SW_NORMAL);
105+ dlg.UpdateWindow();
106+
107+ result = theLoop.Run();
108+ }
109+
110+ theLoop.RemoveMessageFilter(&dlg);
111+ }
112+
113+ _Module.RemoveMessageLoop();
114+
115+ return result;
116+}
117+
118+/* */
119+
--- /dev/null
+++ b/Tests/QPlayerEx/MainDialog.h
@@ -0,0 +1,737 @@
1+// MainDialog.h
2+// 2009/05/29
3+
4+#pragma once
5+
6+#include "resource.h"
7+
8+#include "QDecoder.h"
9+
10+// MainDialog
11+class MainDialog :
12+ public ATL::CDialogImpl<MainDialog>,
13+ public WTL::CMessageFilter {
14+
15+ enum {
16+ TID_TICK = 1,
17+ TICK_TIMEOUT = 20
18+ };
19+
20+ enum {
21+ WM_EVENT_NOTIFY = WM_APP + 1
22+ };
23+
24+ enum {
25+ ID_MENU_DEFAULT = 100,
26+ ID_MENU_YUY2,
27+ ID_MENU_YV12
28+ };
29+
30+ ATL::CComPtr<IGraphBuilder> m_FilterGraph;
31+
32+ ATL::CComPtr<IBaseFilter> m_Decoder;
33+
34+ DWORD m_dwCookie;
35+
36+ INT32 m_VideoMode;
37+
38+public:
39+
40+ /* */
41+
42+ enum { IDD = IDD_MAIN };
43+
44+ /* */
45+
46+ MainDialog() : m_dwCookie(0), m_VideoMode(ID_MENU_DEFAULT)
47+ {
48+ }
49+
50+ ~MainDialog()
51+ {
52+ }
53+
54+ /* */
55+
56+ BEGIN_MSG_MAP_EX(MainDialog)
57+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
58+ MESSAGE_HANDLER(WM_COMMAND, OnCommand )
59+
60+ MSG_WM_DESTROY(OnDestroy)
61+
62+ MSG_WM_TIMER(OnTimer)
63+
64+ MSG_WM_CONTEXTMENU(OnContextMenu)
65+
66+ MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles )
67+ MESSAGE_HANDLER(WM_EVENT_NOTIFY, OnEventNotify)
68+ END_MSG_MAP()
69+
70+ /* */
71+
72+ LRESULT OnInitDialog(
73+ UINT uMsg,
74+ WPARAM wParam,
75+ LPARAM lParam,
76+ BOOL& bHandled)
77+ {
78+ SetWindowPos(
79+ 0,
80+ 0, 0,
81+ 0, 0,
82+ SWP_NOZORDER | SWP_NOSIZE);
83+
84+ SetDlgItemTextW(IDC_PATH, L"");
85+ SetDlgItemTextW(IDC_VIDEO, L"");
86+ SetDlgItemTextW(IDC_AUDIO, L"");
87+ SetDlgItemTextW(IDC_DURATION, L"");
88+ SetDlgItemTextW(IDC_CURRENT, L"");
89+
90+ WTL::CButton b1(GetDlgItem(IDC_E_VIDEO));
91+ b1.SetCheck(1);
92+
93+ WTL::CButton b2(GetDlgItem(IDC_E_AUDIO));
94+ b2.SetCheck(1);
95+
96+ SetTimer(TID_TICK, TICK_TIMEOUT);
97+
98+ DragAcceptFiles(TRUE);
99+
100+ return TRUE;
101+ }
102+
103+ LRESULT OnCommand(
104+ UINT uMsg,
105+ WPARAM wParam,
106+ LPARAM lParam,
107+ BOOL& bHandled)
108+ {
109+ int id = LOWORD(wParam);
110+ int code = HIWORD(wParam);
111+
112+ switch (id) {
113+ case IDC_OPEN:
114+ Open();
115+ break;
116+
117+ case IDC_RUN:
118+ Run();
119+ break;
120+
121+ case IDC_PAUSE:
122+ Pause();
123+ break;
124+
125+ case IDC_RELEASE:
126+ ReleaseFilterGraph();
127+ SetDlgItemTextW(IDC_PATH, L"");
128+ SetDlgItemTextW(IDC_VIDEO, L"");
129+ SetDlgItemTextW(IDC_AUDIO, L"");
130+ SetDlgItemTextW(IDC_DURATION, L"");
131+ SetDlgItemTextW(IDC_CURRENT, L"");
132+ break;
133+
134+ case IDOK:
135+ case IDCANCEL:
136+ case IDCLOSE:
137+ ReleaseFilterGraph();
138+ DestroyWindow();
139+ break;
140+ }
141+
142+ return 0;
143+ }
144+
145+ /* */
146+
147+ void OnDestroy()
148+ {
149+ PostQuitMessage(0);
150+ }
151+
152+ /* */
153+
154+ void OnTimer(UINT_PTR nIDEvent)
155+ {
156+ if (nIDEvent == TID_TICK) {
157+ OnTick();
158+ }
159+ }
160+
161+ /* */
162+
163+ void OnContextMenu(HWND hwnd, WTL::CPoint pt)
164+ {
165+ WTL::CMenu menu;
166+
167+ menu.CreatePopupMenu();
168+
169+ menu.InsertMenu(0, MF_BYPOSITION | ((m_VideoMode == ID_MENU_DEFAULT) ? MF_CHECKED : 0), ID_MENU_DEFAULT, L"Video Default");
170+ menu.InsertMenu(1, MF_BYPOSITION | ((m_VideoMode == ID_MENU_YUY2) ? MF_CHECKED : 0), ID_MENU_YUY2, L"Video YUY2" );
171+ menu.InsertMenu(2, MF_BYPOSITION | ((m_VideoMode == ID_MENU_YV12) ? MF_CHECKED : 0), ID_MENU_YV12, L"Video YV12" );
172+
173+ INT32 cmd = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, hwnd);
174+
175+ switch (cmd) {
176+ case ID_MENU_DEFAULT:
177+ case ID_MENU_YUY2:
178+ case ID_MENU_YV12:
179+ m_VideoMode = cmd;
180+ break;
181+ }
182+ }
183+
184+ /* */
185+
186+ virtual BOOL PreTranslateMessage(MSG* pMsg)
187+ {
188+ HWND hwnd = *this;
189+
190+ if (hwnd != 0) {
191+ if (pMsg->message == WM_KEYDOWN &&
192+ ::GetParent(pMsg->hwnd) == hwnd) {
193+ ATLTRACE("DOWN\n");
194+ INT32 code = (INT32)pMsg->wParam;
195+ if (code >= '0' && code <= '9') {
196+ INT32 p = code - '0';
197+ Seek(p);
198+ return TRUE;
199+ }
200+ }
201+
202+ if (::IsDialogMessageW(hwnd, pMsg)) {
203+ return TRUE;
204+ }
205+ }
206+
207+ return FALSE;
208+ }
209+
210+ /* */
211+
212+ void OnTick()
213+ {
214+ if (m_FilterGraph != 0) {
215+ ATL::CComQIPtr<IMediaSeeking> seek(m_FilterGraph);
216+
217+ INT64 pos = 0;
218+ seek->GetCurrentPosition(&pos);
219+
220+ INT32 ds = (INT32)(pos / (1000*1000));
221+ INT32 ss = ds / 10;
222+
223+ ATL::CStringW buf;
224+ buf.Format(L"%d:%02d:%d", ss / 60, ss % 60, ds % 10);
225+
226+ SetDlgItemText(IDC_CURRENT, buf);
227+ }
228+ }
229+
230+ /* */
231+
232+private:
233+
234+ /* */
235+
236+ void ReleaseFilterGraph()
237+ {
238+ if (m_dwCookie != 0) {
239+ RemoveFromRot(m_dwCookie);
240+ m_dwCookie = 0;
241+ }
242+
243+ if (m_FilterGraph != 0) {
244+ ATL::CComQIPtr<IMediaControl> ctrl(m_FilterGraph);
245+ ctrl->Stop();
246+
247+ ATL::CComQIPtr<IMediaEventEx> me(m_FilterGraph);
248+ me->SetNotifyWindow(0, 0, 0);
249+ }
250+
251+ m_Decoder.Release();
252+
253+ m_FilterGraph.Release();
254+ }
255+
256+ /* */
257+
258+ void Open()
259+ {
260+ WTL::CFileDialog dlg(
261+ TRUE,
262+ L"mkv",
263+ 0,
264+ OFN_HIDEREADONLY,
265+ L"Matroska Files (*.mkv;*.mka)\0*.mkv;*.mka\0All Files (*.*)\0*.*\0\0");
266+
267+ if (dlg.DoModal() == IDOK) {
268+ ReleaseFilterGraph();
269+ Prepare(dlg.m_szFileName);
270+ }
271+ }
272+
273+ /* */
274+
275+ void Prepare(LPCWSTR path)
276+ {
277+ if (m_FilterGraph != 0) {
278+ return;
279+ }
280+
281+ SetDlgItemTextW(IDC_PATH, path);
282+ SetDlgItemTextW(IDC_VIDEO, L"");
283+ SetDlgItemTextW(IDC_AUDIO, L"");
284+ SetDlgItemTextW(IDC_DURATION, L"");
285+ SetDlgItemTextW(IDC_CURRENT, L"");
286+
287+ GetDlgItem(IDC_RUN) .EnableWindow(FALSE);
288+ GetDlgItem(IDC_PAUSE).EnableWindow(FALSE);
289+ GetDlgItem(IDC_RUN) .ShowWindow(SW_HIDE);
290+ GetDlgItem(IDC_PAUSE).ShowWindow(SW_HIDE);
291+
292+ WTL::CButton b1(GetDlgItem(IDC_E_VIDEO));
293+ WTL::CButton b2(GetDlgItem(IDC_E_AUDIO));
294+
295+ UpdateWindow();
296+
297+ WTL::CWaitCursor wait;
298+
299+ HRESULT hRslt = m_FilterGraph.CoCreateInstance(
300+ CLSID_FilterGraph,
301+ 0,
302+ CLSCTX_INPROC_SERVER);
303+ if (FAILED(hRslt)) {
304+ return;
305+ }
306+
307+ {
308+ ATL::CComQIPtr<IMediaEventEx> me(m_FilterGraph);
309+
310+ HWND hwnd = *this;
311+ hRslt = me->SetNotifyWindow(
312+ (OAHWND)hwnd,
313+ WM_EVENT_NOTIFY,
314+ 0);
315+ if (FAILED(hRslt)) {
316+ return;
317+ }
318+ }
319+
320+ ATL::CComPtr<IBaseFilter> filter;
321+ hRslt = QD_CreateDecoder(
322+ path,
323+ &filter);
324+ if (FAILED(hRslt)) {
325+ return;
326+ }
327+
328+ hRslt = m_FilterGraph->AddFilter(
329+ filter,
330+ L"QDecoder");
331+ if (FAILED(hRslt)) {
332+ return;
333+ }
334+
335+ m_Decoder = filter;
336+
337+ /* Video */
338+
339+ if (b1.GetCheck() != 0) {
340+ ATL::CComPtr<IPin> pin;
341+ hRslt = filter->FindPin(L"Video", &pin);
342+ if (FAILED(hRslt)) {
343+ return;
344+ }
345+
346+ ATL::CComPtr<IEnumMediaTypes> em;
347+ hRslt = pin->EnumMediaTypes(&em);
348+ if (FAILED(hRslt)) {
349+ return;
350+ }
351+
352+ bool b = false;
353+
354+ while (!b) {
355+ AM_MEDIA_TYPE* mt = 0;
356+ ULONG c = 0;
357+ hRslt = em->Next(1, &mt, &c);
358+ if (FAILED(hRslt)) {
359+ return;
360+ }
361+ if (mt == 0) {
362+ break;
363+ }
364+
365+ if (mt->formattype == FORMAT_VideoInfo2 &&
366+ mt->pbFormat != 0 &&
367+ mt->cbFormat >= sizeof(VIDEOINFOHEADER2)) {
368+
369+ VIDEOINFOHEADER2* v = (VIDEOINFOHEADER2*)(mt->pbFormat);
370+ BITMAPINFOHEADER* bmi = &(v->bmiHeader);
371+
372+ INT32 cx = bmi->biWidth;
373+ INT32 cy = bmi->biHeight;
374+ if (cy < 0) cy = -cy;
375+
376+ ATL::CStringW buf;
377+ buf.Format(L"V: %d x %d", cx, cy);
378+ SetDlgItemTextW(IDC_VIDEO, buf);
379+
380+ b = true;
381+ }
382+
383+ QD_FreeMediaType(mt);
384+ }
385+
386+ if (b) {
387+ ATL::CComPtr<IBaseFilter> rend;
388+ hRslt = rend.CoCreateInstance(
389+ CLSID_VideoMixingRenderer9,
390+ 0,
391+ CLSCTX_INPROC_SERVER);
392+ if (FAILED(hRslt)) {
393+ return;
394+ }
395+
396+ hRslt = m_FilterGraph->AddFilter(
397+ rend,
398+ L"V-Renderer");
399+ if (FAILED(hRslt)) {
400+ return;
401+ }
402+
403+ ATL::CComPtr<IEnumPins> e;
404+ hRslt = rend->EnumPins(&e);
405+ if (FAILED(hRslt)) {
406+ return;
407+ }
408+
409+ ATL::CComPtr<IPin> ip;
410+ ULONG c = 0;
411+ hRslt = e->Next(1, &ip, &c);
412+ if (FAILED(hRslt)) {
413+ return;
414+ }
415+
416+ AM_MEDIA_TYPE mt = { 0 };
417+
418+ AM_MEDIA_TYPE* pmt = 0;
419+ switch (m_VideoMode) {
420+ case ID_MENU_YUY2:
421+ mt.majortype = MEDIATYPE_Video;
422+ mt.subtype = MEDIASUBTYPE_YUY2;
423+ pmt = &mt;
424+ break;
425+
426+ case ID_MENU_YV12:
427+ mt.majortype = MEDIATYPE_Video;
428+ mt.subtype = MEDIASUBTYPE_YV12;
429+ pmt = &mt;
430+ break;
431+ }
432+
433+ hRslt = m_FilterGraph->ConnectDirect(
434+ pin,
435+ ip,
436+ pmt);
437+ if (FAILED(hRslt)) {
438+ ATLTRACE("ERROR ConnectDirect (V).\n");
439+ return;
440+ }
441+
442+ } else {
443+ SetDlgItemTextW(IDC_VIDEO, L"NO Video");
444+ }
445+ }
446+
447+ /* Audio */
448+
449+ if (b2.GetCheck() != 0) {
450+ ATL::CComPtr<IPin> pin;
451+ hRslt = filter->FindPin(L"Audio", &pin);
452+ if (FAILED(hRslt)) {
453+ return;
454+ }
455+
456+ ATL::CComPtr<IEnumMediaTypes> em;
457+ hRslt = pin->EnumMediaTypes(&em);
458+ if (FAILED(hRslt)) {
459+ return;
460+ }
461+
462+ bool b = false;
463+
464+ while (!b) {
465+ AM_MEDIA_TYPE* mt = 0;
466+ ULONG c = 0;
467+ hRslt = em->Next(1, &mt, &c);
468+ if (FAILED(hRslt)) {
469+ return;
470+ }
471+ if (mt == 0) {
472+ break;
473+ }
474+
475+ if (mt->formattype == FORMAT_WaveFormatEx &&
476+ mt->pbFormat != 0 &&
477+ mt->cbFormat >= sizeof(WAVEFORMATEX)) {
478+
479+ WAVEFORMATEX* w = (WAVEFORMATEX*)(mt->pbFormat);
480+
481+ ATL::CStringW buf;
482+ buf.Format(L"A: %d ch %d Hz", w->nChannels, w->nSamplesPerSec);
483+ SetDlgItemTextW(IDC_AUDIO, buf);
484+
485+ b = true;
486+ }
487+
488+ QD_FreeMediaType(mt);
489+ }
490+
491+ if (b) {
492+ ATL::CComPtr<IBaseFilter> rend;
493+ hRslt = rend.CoCreateInstance(
494+ CLSID_DSoundRender,
495+ 0,
496+ CLSCTX_INPROC_SERVER);
497+ if (FAILED(hRslt)) {
498+ return;
499+ }
500+
501+ hRslt = m_FilterGraph->AddFilter(
502+ rend,
503+ L"A-Renderer");
504+ if (FAILED(hRslt)) {
505+ return;
506+ }
507+
508+ ATL::CComPtr<IEnumPins> e;
509+ hRslt = rend->EnumPins(&e);
510+ if (FAILED(hRslt)) {
511+ return;
512+ }
513+
514+ ATL::CComPtr<IPin> ip;
515+ ULONG c = 0;
516+ hRslt = e->Next(1, &ip, &c);
517+ if (FAILED(hRslt)) {
518+ return;
519+ }
520+
521+ hRslt = m_FilterGraph->ConnectDirect(
522+ pin,
523+ ip,
524+ 0);
525+ if (FAILED(hRslt)) {
526+ ATLTRACE("ERROR ConnectDirect (A).\n");
527+ return;
528+ }
529+
530+ } else {
531+ SetDlgItemTextW(IDC_AUDIO, L"NO Audio");
532+ }
533+ }
534+
535+ /* */
536+
537+ {
538+ ATL::CComQIPtr<IMediaSeeking> seek(m_FilterGraph);
539+ if (seek != 0) {
540+ INT64 duration = 0;
541+ seek->GetDuration(&duration);
542+
543+ INT32 ds = (INT32)(duration / (1000*1000));
544+ INT32 ss = ds / 10;
545+
546+ ATL::CStringW buf;
547+ buf.Format(L"%d:%02d:%d", ss / 60, ss % 60, ds % 10);
548+
549+ SetDlgItemText(IDC_DURATION, buf);
550+ }
551+ }
552+
553+ {
554+ ATL::CComQIPtr<IVideoWindow> v(m_FilterGraph);
555+ if (v != 0) {
556+ INT32 x = 0;
557+
558+ RECT rc = { 0 };
559+ GetWindowRect(&rc);
560+
561+ x = rc.right + 8;
562+
563+ v->put_Top(0);
564+ v->put_Left(x);
565+ }
566+ }
567+
568+ /* */
569+
570+#ifdef _DEBUG
571+ AddToRot(m_FilterGraph, &m_dwCookie);
572+#endif
573+
574+ /* */
575+
576+ GetDlgItem(IDC_RUN) .ShowWindow(SW_NORMAL);
577+ GetDlgItem(IDC_PAUSE).ShowWindow(SW_NORMAL);
578+ GetDlgItem(IDC_RUN) .EnableWindow(TRUE);
579+ GetDlgItem(IDC_PAUSE).EnableWindow(TRUE);
580+ }
581+
582+ /* */
583+
584+ void Run()
585+ {
586+ if (m_FilterGraph == 0) {
587+ return;
588+ }
589+
590+ ATL::CComQIPtr<IMediaControl> ctrl(m_FilterGraph);
591+ ctrl->Run();
592+ }
593+
594+ void Pause()
595+ {
596+ if (m_FilterGraph == 0) {
597+ return;
598+ }
599+
600+ ATL::CComQIPtr<IMediaControl> ctrl(m_FilterGraph);
601+ ctrl->Pause();
602+ }
603+
604+ /* */
605+
606+ void Seek(INT32 p)
607+ {
608+ if (m_FilterGraph != 0) {
609+ ATL::CComQIPtr<IMediaSeeking> seek(m_FilterGraph);
610+ if (seek != 0) {
611+ INT64 duration = 0;
612+ seek->GetDuration(&duration);
613+
614+ INT64 pos = p * (duration / 10);
615+ seek->SetPositions(
616+ &pos,
617+ AM_SEEKING_AbsolutePositioning,
618+ 0,
619+ AM_SEEKING_NoPositioning);
620+ }
621+ }
622+ }
623+
624+ /* */
625+
626+ LRESULT OnDropFiles(
627+ UINT uMsg,
628+ WPARAM wParam,
629+ LPARAM lParam,
630+ BOOL& bHandled)
631+ {
632+ HDROP hDrop = (HDROP)wParam;
633+
634+ UINT c = DragQueryFileW(hDrop, (UINT)-1, 0, 0);
635+ if (c > 0) {
636+ WCHAR path[MAX_PATH];
637+ DragQueryFileW(hDrop, 0, path, MAX_PATH);
638+
639+ ReleaseFilterGraph();
640+ Prepare(path);
641+ }
642+
643+ DragFinish(hDrop);
644+
645+ return 0;
646+ }
647+
648+ /* */
649+
650+ LRESULT OnEventNotify(
651+ UINT uMsg,
652+ WPARAM wParam,
653+ LPARAM lParam,
654+ BOOL& bHandled)
655+ {
656+ if (m_FilterGraph == 0) {
657+ return 0;
658+ }
659+
660+ ATL::CComQIPtr<IMediaEvent> me(m_FilterGraph);
661+ if (me != 0) {
662+ LONG lEventCode = 0;
663+
664+ LONG_PTR lParam1 = 0;
665+ LONG_PTR lParam2 = 0;
666+
667+ HRESULT hRslt = me->GetEvent(
668+ &lEventCode,
669+ &lParam1,
670+ &lParam2,
671+ 0);
672+ if (SUCCEEDED(hRslt)) {
673+ if (lEventCode == EC_COMPLETE) {
674+ ATLTRACE("EC_COMPLETE\n");
675+
676+ ATL::CComQIPtr<IMediaControl> ctrl(m_FilterGraph);
677+ ctrl->Stop();
678+ }
679+
680+ me->FreeEventParams(
681+ lEventCode,
682+ lParam1,
683+ lParam2);
684+ }
685+ }
686+
687+ return 0;
688+ }
689+
690+ /* */
691+
692+ static HRESULT AddToRot(IUnknown* pUnkGraph, DWORD* pdwRegister)
693+ {
694+ ATL::CComPtr<IRunningObjectTable> rot;
695+ HRESULT hRslt = GetRunningObjectTable(0, &rot);
696+ if (FAILED(hRslt)) {
697+ return hRslt;
698+ }
699+
700+ WCHAR name[256];
701+ swprintf_s(name, 256, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId());
702+
703+ ATL::CComPtr<IMoniker> moniker;
704+ hRslt = CreateItemMoniker(L"!", name, &moniker);
705+ if (FAILED(hRslt)) {
706+ return hRslt;
707+ }
708+
709+ hRslt = rot->Register(
710+ ROTFLAGS_REGISTRATIONKEEPSALIVE,
711+ pUnkGraph,
712+ moniker,
713+ pdwRegister);
714+ if (FAILED(hRslt)) {
715+ return hRslt;
716+ }
717+
718+ return S_OK;
719+ }
720+
721+ static void RemoveFromRot(DWORD dwRegister)
722+ {
723+ ATL::CComPtr<IRunningObjectTable> rot;
724+ HRESULT hRslt = GetRunningObjectTable(0, &rot);
725+ if (FAILED(hRslt)) {
726+ return;
727+ }
728+
729+ rot->Revoke(dwRegister);
730+ }
731+
732+ /* */
733+
734+}; // MainDialog
735+
736+/* */
737+
--- /dev/null
+++ b/Tests/QPlayerEx/QPlayer.rc
@@ -0,0 +1,106 @@
1+// Microsoft Visual C++ generated resource script.
2+//
3+#include "resource.h"
4+
5+#define APSTUDIO_READONLY_SYMBOLS
6+/////////////////////////////////////////////////////////////////////////////
7+//
8+// Generated from the TEXTINCLUDE 2 resource.
9+//
10+#include "afxres.h"
11+
12+/////////////////////////////////////////////////////////////////////////////
13+#undef APSTUDIO_READONLY_SYMBOLS
14+
15+/////////////////////////////////////////////////////////////////////////////
16+// 日本語 resources
17+
18+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
19+#ifdef _WIN32
20+LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
21+#pragma code_page(932)
22+#endif //_WIN32
23+
24+#ifdef APSTUDIO_INVOKED
25+/////////////////////////////////////////////////////////////////////////////
26+//
27+// TEXTINCLUDE
28+//
29+
30+1 TEXTINCLUDE
31+BEGIN
32+ "resource.h\0"
33+END
34+
35+2 TEXTINCLUDE
36+BEGIN
37+ "#include ""afxres.h""\r\n"
38+ "\0"
39+END
40+
41+3 TEXTINCLUDE
42+BEGIN
43+ "\r\n"
44+ "\0"
45+END
46+
47+#endif // APSTUDIO_INVOKED
48+
49+
50+/////////////////////////////////////////////////////////////////////////////
51+//
52+// Dialog
53+//
54+
55+IDD_MAIN DIALOGEX 0, 0, 200, 74
56+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
57+CAPTION "QPlayer"
58+FONT 8, "MS Shell Dlg", 400, 0, 0x1
59+BEGIN
60+ LTEXT "PATH",IDC_PATH,7,7,128,8,SS_NOPREFIX | SS_PATHELLIPSIS
61+ PUSHBUTTON "Open...",IDC_OPEN,143,7,50,14
62+ CTEXT "Video",IDC_VIDEO,7,24,60,8
63+ CTEXT "Audio",IDC_AUDIO,100,24,60,8
64+ CTEXT "00:00:00",IDC_DURATION,7,36,60,8
65+ CTEXT "00:00:00",IDC_CURRENT,100,36,60,8
66+ CONTROL "V",IDC_E_VIDEO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,24,22,10
67+ CONTROL "A",IDC_E_AUDIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,36,22,10
68+ PUSHBUTTON "Run",IDC_RUN,7,53,50,14
69+ PUSHBUTTON "Pause",IDC_PAUSE,74,53,50,14
70+ PUSHBUTTON "Release",IDC_RELEASE,143,53,50,14
71+END
72+
73+
74+/////////////////////////////////////////////////////////////////////////////
75+//
76+// DESIGNINFO
77+//
78+
79+#ifdef APSTUDIO_INVOKED
80+GUIDELINES DESIGNINFO
81+BEGIN
82+ IDD_MAIN, DIALOG
83+ BEGIN
84+ LEFTMARGIN, 7
85+ RIGHTMARGIN, 193
86+ TOPMARGIN, 7
87+ BOTTOMMARGIN, 67
88+ END
89+END
90+#endif // APSTUDIO_INVOKED
91+
92+#endif // 日本語 resources
93+/////////////////////////////////////////////////////////////////////////////
94+
95+
96+
97+#ifndef APSTUDIO_INVOKED
98+/////////////////////////////////////////////////////////////////////////////
99+//
100+// Generated from the TEXTINCLUDE 3 resource.
101+//
102+
103+
104+/////////////////////////////////////////////////////////////////////////////
105+#endif // not APSTUDIO_INVOKED
106+
--- /dev/null
+++ b/Tests/QPlayerEx/QPlayerEx.vcproj
@@ -0,0 +1,231 @@
1+<?xml version="1.0" encoding="shift_jis"?>
2+<VisualStudioProject
3+ ProjectType="Visual C++"
4+ Version="9.00"
5+ Name="QPlayerEx"
6+ ProjectGUID="{652330EF-E833-4CB6-9212-547A2E1999F9}"
7+ RootNamespace="QPlayerEx"
8+ Keyword="Win32Proj"
9+ TargetFrameworkVersion="196613"
10+ >
11+ <Platforms>
12+ <Platform
13+ Name="Win32"
14+ />
15+ </Platforms>
16+ <ToolFiles>
17+ </ToolFiles>
18+ <Configurations>
19+ <Configuration
20+ Name="Debug|Win32"
21+ OutputDirectory="$(ConfigurationName)"
22+ IntermediateDirectory="$(ConfigurationName)"
23+ ConfigurationType="1"
24+ CharacterSet="1"
25+ >
26+ <Tool
27+ Name="VCPreBuildEventTool"
28+ />
29+ <Tool
30+ Name="VCCustomBuildTool"
31+ />
32+ <Tool
33+ Name="VCXMLDataGeneratorTool"
34+ />
35+ <Tool
36+ Name="VCWebServiceProxyGeneratorTool"
37+ />
38+ <Tool
39+ Name="VCMIDLTool"
40+ />
41+ <Tool
42+ Name="VCCLCompilerTool"
43+ Optimization="0"
44+ AdditionalIncludeDirectories="../WTL/include;../../Lib/QDecoder;../../Lib/QTheoraEx;../../Lib/QVorbis"
45+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
46+ MinimalRebuild="true"
47+ BasicRuntimeChecks="3"
48+ RuntimeLibrary="3"
49+ UsePrecompiledHeader="2"
50+ WarningLevel="3"
51+ DebugInformationFormat="4"
52+ />
53+ <Tool
54+ Name="VCManagedResourceCompilerTool"
55+ />
56+ <Tool
57+ Name="VCResourceCompilerTool"
58+ />
59+ <Tool
60+ Name="VCPreLinkEventTool"
61+ />
62+ <Tool
63+ Name="VCLinkerTool"
64+ LinkIncremental="2"
65+ GenerateDebugInformation="true"
66+ SubSystem="2"
67+ TargetMachine="1"
68+ />
69+ <Tool
70+ Name="VCALinkTool"
71+ />
72+ <Tool
73+ Name="VCManifestTool"
74+ />
75+ <Tool
76+ Name="VCXDCMakeTool"
77+ />
78+ <Tool
79+ Name="VCBscMakeTool"
80+ />
81+ <Tool
82+ Name="VCFxCopTool"
83+ />
84+ <Tool
85+ Name="VCAppVerifierTool"
86+ />
87+ <Tool
88+ Name="VCPostBuildEventTool"
89+ />
90+ </Configuration>
91+ <Configuration
92+ Name="Release|Win32"
93+ OutputDirectory="$(ConfigurationName)"
94+ IntermediateDirectory="$(ConfigurationName)"
95+ ConfigurationType="1"
96+ CharacterSet="1"
97+ WholeProgramOptimization="1"
98+ >
99+ <Tool
100+ Name="VCPreBuildEventTool"
101+ />
102+ <Tool
103+ Name="VCCustomBuildTool"
104+ />
105+ <Tool
106+ Name="VCXMLDataGeneratorTool"
107+ />
108+ <Tool
109+ Name="VCWebServiceProxyGeneratorTool"
110+ />
111+ <Tool
112+ Name="VCMIDLTool"
113+ />
114+ <Tool
115+ Name="VCCLCompilerTool"
116+ Optimization="2"
117+ EnableIntrinsicFunctions="true"
118+ AdditionalIncludeDirectories="../WTL/include;../../Lib/QDecoder;../../Lib/QTheoraEx;../../Lib/QVorbis"
119+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
120+ RuntimeLibrary="2"
121+ EnableFunctionLevelLinking="true"
122+ UsePrecompiledHeader="2"
123+ WarningLevel="3"
124+ DebugInformationFormat="3"
125+ />
126+ <Tool
127+ Name="VCManagedResourceCompilerTool"
128+ />
129+ <Tool
130+ Name="VCResourceCompilerTool"
131+ />
132+ <Tool
133+ Name="VCPreLinkEventTool"
134+ />
135+ <Tool
136+ Name="VCLinkerTool"
137+ LinkIncremental="1"
138+ GenerateDebugInformation="true"
139+ SubSystem="2"
140+ OptimizeReferences="2"
141+ EnableCOMDATFolding="2"
142+ TargetMachine="1"
143+ />
144+ <Tool
145+ Name="VCALinkTool"
146+ />
147+ <Tool
148+ Name="VCManifestTool"
149+ />
150+ <Tool
151+ Name="VCXDCMakeTool"
152+ />
153+ <Tool
154+ Name="VCBscMakeTool"
155+ />
156+ <Tool
157+ Name="VCFxCopTool"
158+ />
159+ <Tool
160+ Name="VCAppVerifierTool"
161+ />
162+ <Tool
163+ Name="VCPostBuildEventTool"
164+ />
165+ </Configuration>
166+ </Configurations>
167+ <References>
168+ </References>
169+ <Files>
170+ <Filter
171+ Name="ソース ファイル"
172+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
173+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
174+ >
175+ <File
176+ RelativePath=".\Main.cpp"
177+ >
178+ </File>
179+ <File
180+ RelativePath=".\StdAfx.cpp"
181+ >
182+ <FileConfiguration
183+ Name="Debug|Win32"
184+ >
185+ <Tool
186+ Name="VCCLCompilerTool"
187+ UsePrecompiledHeader="1"
188+ />
189+ </FileConfiguration>
190+ <FileConfiguration
191+ Name="Release|Win32"
192+ >
193+ <Tool
194+ Name="VCCLCompilerTool"
195+ UsePrecompiledHeader="1"
196+ />
197+ </FileConfiguration>
198+ </File>
199+ </Filter>
200+ <Filter
201+ Name="ヘッダー ファイル"
202+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
203+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
204+ >
205+ <File
206+ RelativePath=".\MainDialog.h"
207+ >
208+ </File>
209+ <File
210+ RelativePath=".\resource.h"
211+ >
212+ </File>
213+ <File
214+ RelativePath=".\StdAfx.h"
215+ >
216+ </File>
217+ </Filter>
218+ <Filter
219+ Name="リソース ファイル"
220+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
221+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
222+ >
223+ <File
224+ RelativePath=".\QPlayer.rc"
225+ >
226+ </File>
227+ </Filter>
228+ </Files>
229+ <Globals>
230+ </Globals>
231+</VisualStudioProject>
--- /dev/null
+++ b/Tests/QPlayerEx/StdAfx.cpp
@@ -0,0 +1,5 @@
1+// StdAfx.cpp
2+// 2009/05/29
3+
4+#include "StdAfx.h"
5+
--- /dev/null
+++ b/Tests/QPlayerEx/StdAfx.h
@@ -0,0 +1,70 @@
1+// StdAfx.h
2+// 2009/05/29
3+
4+#pragma once
5+
6+#ifndef STRICT
7+#define STRICT
8+#endif
9+
10+#ifndef WINVER
11+#define WINVER 0x0501
12+#endif
13+
14+#ifndef _WIN32_WINNT
15+#define _WIN32_WINNT 0x0501
16+#endif
17+
18+#ifndef _WIN32_WINDOWS
19+#define _WIN32_WINDOWS 0x0410
20+#endif
21+
22+#ifndef _WIN32_IE
23+#define _WIN32_IE 0x0600
24+#endif
25+
26+#define _SECURE_ATL 1
27+
28+#define _ATL_APARTMENT_THREADED
29+#define _ATL_NO_AUTOMATIC_NAMESPACE
30+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
31+#define _ATL_ALL_WARNINGS
32+
33+#include <atlbase.h>
34+#include <atlcom.h>
35+#include <atlfile.h>
36+#include <atlcoll.h>
37+#include <atlstr.h>
38+
39+#include <atlwin.h>
40+
41+#define _WTL_NO_AUTOMATIC_NAMESPACE
42+
43+#include <atlapp.h>
44+#include <atlctrls.h>
45+#include <atlcrack.h>
46+#include <atlmisc.h>
47+#include <atlframe.h>
48+#include <atlgdi.h>
49+#include <atlddx.h>
50+#include <atldlgs.h>
51+#include <atlctrlx.h>
52+
53+/* */
54+
55+#include <mmsystem.h>
56+#pragma comment(lib, "winmm.lib")
57+
58+#include <dshow.h>
59+#pragma comment(lib, "strmiids.lib")
60+
61+#include <shlwapi.h>
62+
63+#include <dvdmedia.h>
64+
65+/* */
66+
67+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
68+
69+/* */
70+
--- /dev/null
+++ b/Tests/QPlayerEx/resource.h
@@ -0,0 +1,27 @@
1+//{{NO_DEPENDENCIES}}
2+// Microsoft Visual C++ generated include file.
3+// Used by QPlayer.rc
4+//
5+#define IDD_MAIN 101
6+#define IDC_RUN 1001
7+#define IDC_RELEASE 1002
8+#define IDC_CURRENT 1003
9+#define IDC_PATH 1004
10+#define IDC_OPEN 1005
11+#define IDC_VIDEO 1006
12+#define IDC_AUDIO 1007
13+#define IDC_DURATION 1008
14+#define IDC_PAUSE 1009
15+#define IDC_E_VIDEO 1010
16+#define IDC_E_AUDIO 1011
17+
18+// Next default values for new objects
19+//
20+#ifdef APSTUDIO_INVOKED
21+#ifndef APSTUDIO_READONLY_SYMBOLS
22+#define _APS_NEXT_RESOURCE_VALUE 102
23+#define _APS_NEXT_COMMAND_VALUE 40001
24+#define _APS_NEXT_CONTROL_VALUE 1012
25+#define _APS_NEXT_SYMED_VALUE 101
26+#endif
27+#endif
Show on old repository browser