1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2008-2013 |
---|
3 | // Created by Roman Ryltsov roman@alax.info |
---|
4 | |
---|
5 | #pragma once |
---|
6 | |
---|
7 | #include <wmsdk.h> |
---|
8 | #include "rodshow.h" |
---|
9 | #include "rocontrols.h" |
---|
10 | #include "rocrypt.h" |
---|
11 | #include "rowinhttp.h" |
---|
12 | #include "AboutDialog.h" |
---|
13 | |
---|
14 | #pragma comment(lib, "wmvcore.lib") |
---|
15 | |
---|
16 | //////////////////////////////////////////////////////////// |
---|
17 | // CMainDialog |
---|
18 | |
---|
19 | class CMainDialog : |
---|
20 | public CDialogImpl<CMainDialog>, |
---|
21 | public CDialogResize<CMainDialog>, |
---|
22 | public CWindowWithPrivateMessagesT<CMainDialog> |
---|
23 | { |
---|
24 | public: |
---|
25 | enum { IDD = IDD_MAIN }; |
---|
26 | |
---|
27 | BEGIN_MSG_MAP_EX(CMainDialog) |
---|
28 | //CHAIN_MSG_MAP(CDialogImpl<CMainDialog>) |
---|
29 | CHAIN_MSG_MAP(CDialogResize<CMainDialog>) |
---|
30 | CHAIN_MSG_MAP(CWindowWithPrivateMessagesT<CMainDialog>) |
---|
31 | MSG_WM_INITDIALOG(OnInitDialog) |
---|
32 | MSG_WM_SYSCOMMAND(OnSysCommand) |
---|
33 | COMMAND_ID_HANDLER_EX(IDCANCEL, OnCancel) |
---|
34 | MSG_TVN_GETINFOTIP(IDC_TREE, OnTreeGetInfoTip) |
---|
35 | MSG_TVN_SELCHANGED(IDC_TREE, OnTreeViewSelChanged) |
---|
36 | //COMMAND_ID_HANDLER_EX(ID_APP_ABOUT, OnAppAbout) |
---|
37 | // SUGG: List view column sort |
---|
38 | MSG_LVN_GETINFOTIP(IDC_LIST, OnListGetInfoTip) |
---|
39 | COMMAND_ID_HANDLER_EX(IDC_COPY, OnCopyButtonClicked) |
---|
40 | COMMAND_ID_HANDLER_EX(IDC_SUBMIT, OnSubmitButtonClicked) |
---|
41 | REFLECT_NOTIFICATIONS() |
---|
42 | END_MSG_MAP() |
---|
43 | |
---|
44 | BEGIN_DLGRESIZE_MAP(CMainDialog) |
---|
45 | DLGRESIZE_CONTROL(IDC_TREE, DLSZ_SIZE_Y) |
---|
46 | DLGRESIZE_CONTROL(IDC_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y) |
---|
47 | DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X) |
---|
48 | DLGRESIZE_CONTROL(IDC_COPY, DLSZ_MOVE_X) |
---|
49 | DLGRESIZE_CONTROL(IDC_SUBMIT, DLSZ_MOVE_X) |
---|
50 | DLGRESIZE_CONTROL(IDC_OSVERSION, DLSZ_MOVE_X | DLSZ_MOVE_Y) |
---|
51 | END_DLGRESIZE_MAP() |
---|
52 | |
---|
53 | public: |
---|
54 | |
---|
55 | //////////////////////////////////////////////////// |
---|
56 | // CWmCodecInfo3 |
---|
57 | |
---|
58 | class CWmCodecInfo3 : |
---|
59 | public CComQIPtr<IWMCodecInfo3> |
---|
60 | { |
---|
61 | public: |
---|
62 | // CWmCodecInfo3 |
---|
63 | CWmCodecInfo3(IWMCodecInfo3* pWmCodecInfo3 = NULL) throw() : |
---|
64 | CComQIPtr<IWMCodecInfo3>(pWmCodecInfo3) |
---|
65 | { |
---|
66 | } |
---|
67 | CWmCodecInfo3(IUnknown* pUnknown) throw() : |
---|
68 | CComQIPtr<IWMCodecInfo3>(pUnknown) |
---|
69 | { |
---|
70 | } |
---|
71 | HRESULT GetDwordCodecProperty(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, DWORD& nValue) const throw() |
---|
72 | { |
---|
73 | _A(pszName); |
---|
74 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
---|
75 | DWORD nValueSize = sizeof nValue; |
---|
76 | _C(p->GetCodecProp(MajorType, nCodecIndex, pszName, &nType, (BYTE*) &nValue, &nValueSize)); |
---|
77 | _D(nType == WMT_TYPE_DWORD && nValueSize == sizeof nValue, E_UNNAMED); |
---|
78 | return S_OK; |
---|
79 | } |
---|
80 | DWORD GetDwordCodecProperty(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName) const |
---|
81 | { |
---|
82 | DWORD nValue; |
---|
83 | __C(GetDwordCodecProperty(MajorType, nCodecIndex, pszName, nValue)); |
---|
84 | return nValue; |
---|
85 | } |
---|
86 | HRESULT GetBoolCodecProperty(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, BOOL& bValue) const throw() |
---|
87 | { |
---|
88 | _A(pszName); |
---|
89 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
---|
90 | DWORD nValueSize = sizeof bValue; |
---|
91 | _C(p->GetCodecProp(MajorType, nCodecIndex, pszName, &nType, (BYTE*) &bValue, &nValueSize)); |
---|
92 | _D(nType == WMT_TYPE_BOOL && nValueSize == sizeof bValue, E_UNNAMED); |
---|
93 | return S_OK; |
---|
94 | } |
---|
95 | BOOL GetBoolCodecProperty(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName) const |
---|
96 | { |
---|
97 | BOOL bValue; |
---|
98 | __C(GetBoolCodecProperty(MajorType, nCodecIndex, pszName, bValue)); |
---|
99 | return bValue; |
---|
100 | } |
---|
101 | HRESULT GetDwordCodecEnumerationSetting(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, DWORD& nValue) const throw() |
---|
102 | { |
---|
103 | _A(pszName); |
---|
104 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
---|
105 | DWORD nValueSize = sizeof nValue; |
---|
106 | _C(p->GetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, &nType, (BYTE*) &nValue, &nValueSize)); |
---|
107 | _D(nType == WMT_TYPE_DWORD && nValueSize == sizeof nValue, E_UNNAMED); |
---|
108 | return S_OK; |
---|
109 | } |
---|
110 | DWORD GetDwordCodecEnumerationSetting(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName) const |
---|
111 | { |
---|
112 | DWORD nValue; |
---|
113 | __C(GetDwordCodecEnumerationSetting(MajorType, nCodecIndex, pszName, nValue)); |
---|
114 | return nValue; |
---|
115 | } |
---|
116 | HRESULT GetBoolCodecEnumerationSetting(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, BOOL& bValue) const throw() |
---|
117 | { |
---|
118 | _A(pszName); |
---|
119 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
---|
120 | DWORD nValueSize = sizeof bValue; |
---|
121 | _C(p->GetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, &nType, (BYTE*) &bValue, &nValueSize)); |
---|
122 | _D(nType == WMT_TYPE_BOOL && nValueSize == sizeof bValue, E_UNNAMED); |
---|
123 | return bValue; |
---|
124 | } |
---|
125 | BOOL GetBoolCodecEnumerationSetting(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName) const |
---|
126 | { |
---|
127 | BOOL bValue; |
---|
128 | __C(GetBoolCodecEnumerationSetting(MajorType, nCodecIndex, pszName, bValue)); |
---|
129 | return bValue; |
---|
130 | } |
---|
131 | HRESULT SetDwordCodecEnumerationSetting(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, DWORD nValue) const throw() |
---|
132 | { |
---|
133 | return p->SetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, WMT_TYPE_DWORD, (const BYTE*) &nValue, sizeof nValue); |
---|
134 | } |
---|
135 | HRESULT SetBoolCodecEnumerationSetting(const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, BOOL nValue) const throw() |
---|
136 | { |
---|
137 | return p->SetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, WMT_TYPE_BOOL, (const BYTE*) &nValue, sizeof nValue); |
---|
138 | } |
---|
139 | }; |
---|
140 | |
---|
141 | //////////////////////////////////////////////////// |
---|
142 | // CEnumerationSetting |
---|
143 | |
---|
144 | class CEnumerationSetting |
---|
145 | { |
---|
146 | public: |
---|
147 | CStringW m_sName; |
---|
148 | WMT_ATTR_DATATYPE m_nType; |
---|
149 | CHeapPtr<BYTE> m_pnData; |
---|
150 | SIZE_T m_nDataSize; |
---|
151 | |
---|
152 | public: |
---|
153 | // CEnumerationSetting |
---|
154 | CEnumerationSetting() throw() |
---|
155 | { |
---|
156 | } |
---|
157 | explicit CEnumerationSetting(const CStringW& sName, DWORD nValue) : |
---|
158 | m_sName(sName) |
---|
159 | { |
---|
160 | m_nType = WMT_TYPE_DWORD; |
---|
161 | m_nDataSize = sizeof (DWORD); |
---|
162 | __D(m_pnData.Allocate(m_nDataSize), E_OUTOFMEMORY); |
---|
163 | *((DWORD*) (BYTE*) m_pnData) = nValue; |
---|
164 | } |
---|
165 | explicit CEnumerationSetting(const CStringW& sName, BOOL bValue) : |
---|
166 | m_sName(sName) |
---|
167 | { |
---|
168 | m_nType = WMT_TYPE_BOOL; |
---|
169 | m_nDataSize = sizeof (BOOL); |
---|
170 | __D(m_pnData.Allocate(m_nDataSize), E_OUTOFMEMORY); |
---|
171 | *((BOOL*) (BYTE*) m_pnData) = bValue; |
---|
172 | } |
---|
173 | CEnumerationSetting(const CEnumerationSetting& EnumerationSetting) |
---|
174 | { |
---|
175 | m_sName = EnumerationSetting.m_sName; |
---|
176 | m_nType = EnumerationSetting.m_nType; |
---|
177 | if(EnumerationSetting.m_nDataSize) |
---|
178 | { |
---|
179 | __D(m_pnData.Allocate(EnumerationSetting.m_nDataSize), E_OUTOFMEMORY); |
---|
180 | CopyMemory(m_pnData, EnumerationSetting.m_pnData, EnumerationSetting.m_nDataSize); |
---|
181 | } |
---|
182 | m_nDataSize = EnumerationSetting.m_nDataSize; |
---|
183 | } |
---|
184 | CString GetValueString() const |
---|
185 | { |
---|
186 | switch(m_nType) |
---|
187 | { |
---|
188 | case WMT_TYPE_DWORD: |
---|
189 | return AtlFormatString(_T("%d"), *((const DWORD*) (const BYTE*) m_pnData)); |
---|
190 | case WMT_TYPE_BOOL: |
---|
191 | return AtlFormatString(_T("%d"), *((const BOOL*) (const BYTE*) m_pnData)); |
---|
192 | default: |
---|
193 | _A(FALSE); |
---|
194 | } |
---|
195 | return (LPCTSTR) NULL; |
---|
196 | } |
---|
197 | }; |
---|
198 | |
---|
199 | //////////////////////////////////////////////////// |
---|
200 | // CEnumerationSettingList |
---|
201 | |
---|
202 | class CEnumerationSettingList : |
---|
203 | public CAtlList<CEnumerationSetting> |
---|
204 | { |
---|
205 | public: |
---|
206 | CString m_sName; |
---|
207 | |
---|
208 | public: |
---|
209 | // CEnumerationSettingList |
---|
210 | CEnumerationSettingList& operator = (const CEnumerationSettingList& EnumerationSettingList) |
---|
211 | { |
---|
212 | RemoveAll(); |
---|
213 | for(POSITION Position = EnumerationSettingList.GetHeadPosition(); Position; EnumerationSettingList.GetNext(Position)) |
---|
214 | AddTail(EnumerationSettingList.GetAt(Position)); |
---|
215 | m_sName = EnumerationSettingList.m_sName; |
---|
216 | return *this; |
---|
217 | } |
---|
218 | }; |
---|
219 | |
---|
220 | //////////////////////////////////////////////////// |
---|
221 | // CCodecFormatData |
---|
222 | |
---|
223 | class CCodecFormatData |
---|
224 | { |
---|
225 | public: |
---|
226 | DWORD m_nIndex; |
---|
227 | CStringW m_sDescription; |
---|
228 | CComPtr<IWMStreamConfig> m_pWmStreamConfig; |
---|
229 | CMediaType m_pMediaType; |
---|
230 | |
---|
231 | public: |
---|
232 | // CCodecFormatData |
---|
233 | CCodecFormatData() throw() : |
---|
234 | m_nIndex(0) |
---|
235 | { |
---|
236 | } |
---|
237 | VOID Initialize(DWORD nIndex, const CStringW& sDescription, IWMStreamConfig* pWmStreamConfig, const CMediaType& pMediaType) |
---|
238 | { |
---|
239 | m_nIndex = nIndex; |
---|
240 | m_sDescription = sDescription; |
---|
241 | m_pWmStreamConfig = pWmStreamConfig; |
---|
242 | m_pMediaType = pMediaType; |
---|
243 | } |
---|
244 | CString GetDescription() const |
---|
245 | { |
---|
246 | if(m_sDescription.IsEmpty()) |
---|
247 | return _T("(no description)"); |
---|
248 | return CString(m_sDescription); |
---|
249 | } |
---|
250 | }; |
---|
251 | |
---|
252 | typedef CAtlList<CCodecFormatData> CCodecFormatDataList; |
---|
253 | |
---|
254 | //////////////////////////////////////////////////// |
---|
255 | // CCodecData |
---|
256 | |
---|
257 | class CCodecData |
---|
258 | { |
---|
259 | public: |
---|
260 | CComPtr<IWMCodecInfo2> m_pWmCodecInfo2; |
---|
261 | GUID m_MajorType; |
---|
262 | DWORD m_nIndex; |
---|
263 | CStringW m_sName; |
---|
264 | CCodecFormatDataList m_CodecFormatDataList; |
---|
265 | |
---|
266 | public: |
---|
267 | // CCodecData |
---|
268 | CCodecData() throw() : |
---|
269 | m_MajorType(GUID_NULL) |
---|
270 | { |
---|
271 | } |
---|
272 | VOID Initialize(IWMCodecInfo2* pWmCodecInfo2, const GUID& MajorType, DWORD nIndex, const CStringW& sName) |
---|
273 | { |
---|
274 | _A(pWmCodecInfo2); |
---|
275 | m_pWmCodecInfo2 = pWmCodecInfo2; |
---|
276 | m_MajorType = MajorType; |
---|
277 | m_nIndex = nIndex; |
---|
278 | m_sName = sName; |
---|
279 | m_CodecFormatDataList.RemoveAll(); |
---|
280 | DWORD nFormatCount = 0; |
---|
281 | __C(pWmCodecInfo2->GetCodecFormatCount(MajorType, nIndex, &nFormatCount)); |
---|
282 | _Z4(atlTraceGeneral, 4, _T("nFormatCount %d\n"), nFormatCount); |
---|
283 | for(DWORD nFormatIndex = 0; nFormatIndex < nFormatCount; nFormatIndex++) |
---|
284 | { |
---|
285 | DWORD nCodecFormatDescriptionLength = 0; |
---|
286 | __C(pWmCodecInfo2->GetCodecFormatDesc(MajorType, nIndex, nFormatIndex, NULL, NULL, &nCodecFormatDescriptionLength)); |
---|
287 | _A(nCodecFormatDescriptionLength > 0); |
---|
288 | CComPtr<IWMStreamConfig> pWmStreamConfig; |
---|
289 | CStringW sFormatDescription; |
---|
290 | __C(pWmCodecInfo2->GetCodecFormatDesc(MajorType, nIndex, nFormatIndex, &pWmStreamConfig, sFormatDescription.GetBufferSetLength(nCodecFormatDescriptionLength - 1), &nCodecFormatDescriptionLength)); |
---|
291 | _Z4(atlTraceGeneral, 4, _T("nFormatIndex %d, sFormatDescription \"%ls\"\n"), nFormatIndex, sFormatDescription); |
---|
292 | CComQIPtr<IWMMediaProps> pWmMediaProps = pWmStreamConfig; |
---|
293 | __D(pWmMediaProps, E_NOINTERFACE); |
---|
294 | DWORD nMediaTypeSize = 0; |
---|
295 | pWmMediaProps->GetMediaType(NULL, &nMediaTypeSize); |
---|
296 | CTempBuffer<WM_MEDIA_TYPE> pMediaType; |
---|
297 | pMediaType.AllocateBytes(nMediaTypeSize); |
---|
298 | __C(pWmMediaProps->GetMediaType(pMediaType, &nMediaTypeSize)); |
---|
299 | _Z4(atlTraceGeneral, 4, _T("pMediaType->subtype %ls\n"), _PersistHelper::StringFromIdentifier(pMediaType->subtype)); |
---|
300 | POSITION Position = m_CodecFormatDataList.AddTail(); |
---|
301 | _ATLTRY |
---|
302 | { |
---|
303 | CCodecFormatData& CodecFormatData = m_CodecFormatDataList.GetAt(Position); |
---|
304 | CodecFormatData.Initialize(nFormatIndex, sFormatDescription, pWmStreamConfig, (const AM_MEDIA_TYPE*) (const WM_MEDIA_TYPE*) pMediaType); |
---|
305 | } |
---|
306 | _ATLCATCHALL() |
---|
307 | { |
---|
308 | m_CodecFormatDataList.RemoveAt(Position); |
---|
309 | _ATLRETHROW; |
---|
310 | } |
---|
311 | } |
---|
312 | } |
---|
313 | CString GetTitle() const |
---|
314 | { |
---|
315 | return CString(m_sName); |
---|
316 | } |
---|
317 | }; |
---|
318 | |
---|
319 | //////////////////////////////////////////////////// |
---|
320 | // CCodecDataList |
---|
321 | |
---|
322 | class CCodecDataList : |
---|
323 | public CAtlList<CCodecData> |
---|
324 | { |
---|
325 | public: |
---|
326 | GUID m_MajorType; |
---|
327 | CEnumerationSettingList m_EnumerationSettingList; |
---|
328 | |
---|
329 | public: |
---|
330 | // CCodecDataList |
---|
331 | CCodecDataList() throw() : |
---|
332 | m_MajorType(GUID_NULL) |
---|
333 | { |
---|
334 | } |
---|
335 | CCodecDataList(IWMCodecInfo2* pWmCodecInfo2, const GUID& MajorType) |
---|
336 | { |
---|
337 | Initialize(pWmCodecInfo2, MajorType); |
---|
338 | } |
---|
339 | VOID Initialize(IWMCodecInfo2* pWmCodecInfo2, const GUID& MajorType) |
---|
340 | { |
---|
341 | _A(pWmCodecInfo2); |
---|
342 | RemoveAll(); |
---|
343 | m_MajorType = MajorType; |
---|
344 | _A(m_EnumerationSettingList.IsEmpty() && m_EnumerationSettingList.m_sName.IsEmpty()); |
---|
345 | DWORD nCodecCount = 0; |
---|
346 | __C(pWmCodecInfo2->GetCodecInfoCount(MajorType, &nCodecCount)); |
---|
347 | for(DWORD nCodecIndex = 0; nCodecIndex < nCodecCount; nCodecIndex++) |
---|
348 | _ATLTRY |
---|
349 | { |
---|
350 | DWORD nCodecNameLength = 0; |
---|
351 | __C(pWmCodecInfo2->GetCodecName(MajorType, nCodecIndex, NULL, &nCodecNameLength)); |
---|
352 | _A(nCodecNameLength > 0); |
---|
353 | CStringW sCodecName; |
---|
354 | if(nCodecNameLength) |
---|
355 | __C(pWmCodecInfo2->GetCodecName(MajorType, nCodecIndex, sCodecName.GetBufferSetLength(nCodecNameLength - 1), &nCodecNameLength)); |
---|
356 | _Z4(atlTraceGeneral, 4, _T("nCodecIndex %d, sCodecName \"%ls\"\n"), nCodecIndex, sCodecName); |
---|
357 | POSITION Position = AddTail(); |
---|
358 | _ATLTRY |
---|
359 | { |
---|
360 | CCodecData& CodecData = GetAt(Position); |
---|
361 | CodecData.Initialize(pWmCodecInfo2, MajorType, nCodecIndex, sCodecName); |
---|
362 | } |
---|
363 | _ATLCATCHALL() |
---|
364 | { |
---|
365 | RemoveAt(Position); |
---|
366 | _ATLRETHROW; |
---|
367 | } |
---|
368 | } |
---|
369 | _ATLCATCHALL() |
---|
370 | { |
---|
371 | _Z_EXCEPTION(); |
---|
372 | } |
---|
373 | } |
---|
374 | VOID Initialize(CWmCodecInfo3 pWmCodecInfo3, const GUID& MajorType, const CEnumerationSettingList& EnumerationSettingList) |
---|
375 | { |
---|
376 | _A(pWmCodecInfo3); |
---|
377 | RemoveAll(); |
---|
378 | m_MajorType = MajorType; |
---|
379 | m_EnumerationSettingList = EnumerationSettingList; |
---|
380 | DWORD nCodecCount = 0; |
---|
381 | __C(pWmCodecInfo3->GetCodecInfoCount(MajorType, &nCodecCount)); |
---|
382 | for(DWORD nCodecIndex = 0; nCodecIndex < nCodecCount; nCodecIndex++) |
---|
383 | _ATLTRY |
---|
384 | { |
---|
385 | DWORD nCodecNameLength = 0; |
---|
386 | __C(pWmCodecInfo3->GetCodecName(MajorType, nCodecIndex, NULL, &nCodecNameLength)); |
---|
387 | _A(nCodecNameLength > 0); |
---|
388 | CStringW sCodecName; |
---|
389 | if(nCodecNameLength) |
---|
390 | __C(pWmCodecInfo3->GetCodecName(MajorType, nCodecIndex, sCodecName.GetBufferSetLength(nCodecNameLength - 1), &nCodecNameLength)); |
---|
391 | _Z4(atlTraceGeneral, 4, _T("nCodecIndex %d, sCodecName \"%ls\"\n"), nCodecIndex, sCodecName); |
---|
392 | POSITION Position = AddTail(); |
---|
393 | _ATLTRY |
---|
394 | { |
---|
395 | CCodecData& CodecData = GetAt(Position); |
---|
396 | for(POSITION EnumerationSettingPosition = EnumerationSettingList.GetHeadPosition(); EnumerationSettingPosition; EnumerationSettingList.GetNext(EnumerationSettingPosition)) |
---|
397 | { |
---|
398 | const CEnumerationSetting& EnumerationSetting = EnumerationSettingList.GetAt(EnumerationSettingPosition); |
---|
399 | if(FAILED(pWmCodecInfo3->SetCodecEnumerationSetting(MajorType, nCodecIndex, EnumerationSetting.m_sName, EnumerationSetting.m_nType, EnumerationSetting.m_pnData, (DWORD) EnumerationSetting.m_nDataSize))) |
---|
400 | { |
---|
401 | RemoveAt(Position); |
---|
402 | Position = NULL; |
---|
403 | break; |
---|
404 | } |
---|
405 | } |
---|
406 | if(!Position) |
---|
407 | continue; |
---|
408 | CodecData.Initialize(pWmCodecInfo3, MajorType, nCodecIndex, sCodecName); |
---|
409 | } |
---|
410 | _ATLCATCHALL() |
---|
411 | { |
---|
412 | RemoveAt(Position); |
---|
413 | _ATLRETHROW; |
---|
414 | } |
---|
415 | } |
---|
416 | _ATLCATCHALL() |
---|
417 | { |
---|
418 | _Z_EXCEPTION(); |
---|
419 | } |
---|
420 | } |
---|
421 | CString GetTitle() const |
---|
422 | { |
---|
423 | if(!m_EnumerationSettingList.m_sName.IsEmpty()) |
---|
424 | return m_EnumerationSettingList.m_sName; |
---|
425 | return _T("Default"); |
---|
426 | } |
---|
427 | }; |
---|
428 | |
---|
429 | //////////////////////////////////////////////////////// |
---|
430 | // CTreeViewItem |
---|
431 | |
---|
432 | class CTreeViewItem |
---|
433 | { |
---|
434 | public: |
---|
435 | GUID m_MajorType; |
---|
436 | const CCodecDataList* m_pCodecDataList; |
---|
437 | const CCodecData* m_pCodecData; |
---|
438 | |
---|
439 | public: |
---|
440 | // CTreeViewItem |
---|
441 | CTreeViewItem() throw() |
---|
442 | { |
---|
443 | } |
---|
444 | CTreeViewItem(const GUID& MajorType, const CCodecDataList* pCodecDataList = NULL, const CCodecData* pCodecData = NULL) throw() : |
---|
445 | m_MajorType(MajorType), |
---|
446 | m_pCodecDataList(pCodecDataList), |
---|
447 | m_pCodecData(pCodecData) |
---|
448 | { |
---|
449 | } |
---|
450 | }; |
---|
451 | |
---|
452 | //////////////////////////////////////////////////////// |
---|
453 | // CListViewItem |
---|
454 | |
---|
455 | class CListViewItem |
---|
456 | { |
---|
457 | public: |
---|
458 | const CCodecFormatData* m_pCodecFormatData; |
---|
459 | |
---|
460 | public: |
---|
461 | // CListViewItem |
---|
462 | CListViewItem() throw() : |
---|
463 | m_pCodecFormatData(NULL) |
---|
464 | { |
---|
465 | } |
---|
466 | CListViewItem(const CCodecFormatData* pCodecFormatData) throw() : |
---|
467 | m_pCodecFormatData(pCodecFormatData) |
---|
468 | { |
---|
469 | } |
---|
470 | CString GetInfoTipText() const |
---|
471 | { |
---|
472 | CString sText; |
---|
473 | if(m_pCodecFormatData) |
---|
474 | { |
---|
475 | if(!m_pCodecFormatData->m_sDescription.IsEmpty()) |
---|
476 | { |
---|
477 | sText.AppendFormat(_T("Description: %ls\r\n"), m_pCodecFormatData->m_sDescription); |
---|
478 | sText.Append(_T("\r\n")); |
---|
479 | } |
---|
480 | #pragma region Interfaces |
---|
481 | if(m_pCodecFormatData->m_pWmStreamConfig) |
---|
482 | { |
---|
483 | sText += AtlFormatString(_T("Interfaces:") _T("\r\n")); |
---|
484 | static const struct |
---|
485 | { |
---|
486 | const IID* pIdentifier; |
---|
487 | LPCSTR pszName; |
---|
488 | } g_pMap[] = |
---|
489 | { |
---|
490 | #define A(x) { &__uuidof(x), #x }, |
---|
491 | A(IWMMediaProps) |
---|
492 | A(IWMStreamConfig) |
---|
493 | A(IWMStreamConfig2) |
---|
494 | A(IWMStreamConfig3) |
---|
495 | A(IWMVideoMediaProps) |
---|
496 | #undef A |
---|
497 | }; |
---|
498 | for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++) |
---|
499 | { |
---|
500 | CComPtr<IUnknown> pUnknown; |
---|
501 | m_pCodecFormatData->m_pWmStreamConfig->QueryInterface(*g_pMap[nIndex].pIdentifier, (VOID**) &pUnknown); |
---|
502 | if(pUnknown) |
---|
503 | sText += AtlFormatString(_T(" ") _T("%hs") _T("\r\n"), g_pMap[nIndex].pszName); |
---|
504 | } |
---|
505 | sText.Append(_T("\r\n")); |
---|
506 | } |
---|
507 | #pragma endregion |
---|
508 | #pragma region Media Type |
---|
509 | if(m_pCodecFormatData->m_pMediaType) |
---|
510 | { |
---|
511 | sText.Append(_T("AM_MEDIA_TYPE:\r\n")); |
---|
512 | const CMediaType& pMediaType = reinterpret_cast<const CMediaType&>(m_pCodecFormatData->m_pMediaType); |
---|
513 | //sText.AppendFormat(_T(" ...\r\n"), pMediaType->majortype); |
---|
514 | if(memcmp(&pMediaType->subtype.Data2, &MEDIASUBTYPE_MJPG.Data2, sizeof (GUID) - offsetof(GUID, Data2)) == 0) |
---|
515 | sText.AppendFormat(_T(" subtype: %ls (%s)\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->subtype), _FilterGraphHelper::GetFourccCodeString(pMediaType->subtype.Data1)); |
---|
516 | else |
---|
517 | sText.AppendFormat(_T(" subtype: %ls\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->subtype)); |
---|
518 | sText.AppendFormat(_T(" bFixedSizeSamples: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->bFixedSizeSamples)); |
---|
519 | sText.AppendFormat(_T(" bTemporalCompression: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->bTemporalCompression)); |
---|
520 | sText.AppendFormat(_T(" lSampleSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->lSampleSize)); |
---|
521 | #pragma region Format |
---|
522 | static const struct |
---|
523 | { |
---|
524 | GUID formattype; |
---|
525 | LPCTSTR pszTitle; |
---|
526 | } g_pMap[] = |
---|
527 | { |
---|
528 | { FORMAT_VideoInfo, _T("FORMAT_VideoInfo") }, |
---|
529 | { FORMAT_VideoInfo2, _T("FORMAT_VideoInfo2") }, |
---|
530 | { FORMAT_MPEG2_VIDEO, _T("FORMAT_MPEG2_VIDEO") }, |
---|
531 | { FORMAT_WaveFormatEx, _T("FORMAT_WaveFormatEx") }, |
---|
532 | }; |
---|
533 | BOOL bFound = FALSE; |
---|
534 | for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++) |
---|
535 | if(pMediaType->formattype == g_pMap[nIndex].formattype) |
---|
536 | { |
---|
537 | sText.AppendFormat(_T(" formattype: %ls (%s)\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->formattype), g_pMap[nIndex].pszTitle); |
---|
538 | bFound = TRUE; |
---|
539 | break; |
---|
540 | } |
---|
541 | if(!bFound) |
---|
542 | sText.AppendFormat(_T(" formattype: %ls\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->formattype)); |
---|
543 | #pragma endregion |
---|
544 | sText.AppendFormat(_T(" cbFormat: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->cbFormat)); |
---|
545 | #pragma region FORMAT_VideoInfo |
---|
546 | if(pMediaType->formattype == FORMAT_VideoInfo) |
---|
547 | { |
---|
548 | sText.Append(_T("\r\n")); |
---|
549 | sText.Append(_T("VIDEOINFOHEADER:\r\n")); |
---|
550 | const CVideoInfoHeader* pVideoInfoHeader = pMediaType.GetVideoInfoHeader(); |
---|
551 | sText.AppendFormat(_T(" rcSource: %d, %d - %d, %d\r\n"), pVideoInfoHeader->rcSource); |
---|
552 | sText.AppendFormat(_T(" rcTarget: %d, %d - %d, %d\r\n"), pVideoInfoHeader->rcTarget); |
---|
553 | sText.AppendFormat(_T(" dwBitRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader->dwBitRate)); |
---|
554 | sText.AppendFormat(_T(" dwBitErrorRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader->dwBitErrorRate)); |
---|
555 | sText.AppendFormat(_T(" AvgTimePerFrame: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader->AvgTimePerFrame)); |
---|
556 | sText.Append(_T("\r\n")); |
---|
557 | sText.Append(_T("BITMAPINFOHEADER:\r\n")); |
---|
558 | const CBitmapInfoHeader* pBitmapInfoHeader = &pVideoInfoHeader->GetBitmapInfoHeader(); |
---|
559 | sText.AppendFormat(_T(" biSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSize)); |
---|
560 | sText.AppendFormat(_T(" biWidth: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biWidth)); |
---|
561 | sText.AppendFormat(_T(" biHeight: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biHeight)); |
---|
562 | sText.AppendFormat(_T(" biPlanes: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biPlanes)); |
---|
563 | sText.AppendFormat(_T(" biBitCount: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biBitCount)); |
---|
564 | sText.AppendFormat(_T(" biCompression: %s\r\n"), StringFromFourCharacterCode(pBitmapInfoHeader->biCompression)); |
---|
565 | sText.AppendFormat(_T(" biSizeImage: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSizeImage)); |
---|
566 | //biXPelsPerMeter; |
---|
567 | //biYPelsPerMeter; |
---|
568 | //biClrUsed; |
---|
569 | //biClrImportant; |
---|
570 | sText.Append(_T("\r\n")); |
---|
571 | |
---|
572 | } else |
---|
573 | #pragma endregion |
---|
574 | #pragma region FORMAT_VideoInfo2 |
---|
575 | if(pMediaType->formattype == FORMAT_VideoInfo2) |
---|
576 | { |
---|
577 | sText.Append(_T("\r\n")); |
---|
578 | sText.Append(_T("VIDEOINFOHEADER2:\r\n")); |
---|
579 | const CVideoInfoHeader2* pVideoInfoHeader2 = pMediaType.GetVideoInfoHeader2(); |
---|
580 | sText.AppendFormat(_T(" rcSource: %d, %d - %d, %d\r\n"), pVideoInfoHeader2->rcSource); |
---|
581 | sText.AppendFormat(_T(" rcTarget: %d, %d - %d, %d\r\n"), pVideoInfoHeader2->rcTarget); |
---|
582 | sText.AppendFormat(_T(" dwBitRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwBitRate)); |
---|
583 | sText.AppendFormat(_T(" dwBitErrorRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwBitErrorRate)); |
---|
584 | sText.AppendFormat(_T(" AvgTimePerFrame: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->AvgTimePerFrame)); |
---|
585 | sText.AppendFormat(_T(" dwInterlaceFlags: 0x%x\r\n"), pVideoInfoHeader2->dwInterlaceFlags); |
---|
586 | sText.AppendFormat(_T(" dwCopyProtectFlags: 0x%x\r\n"), pVideoInfoHeader2->dwCopyProtectFlags); |
---|
587 | if(pVideoInfoHeader2->dwPictAspectRatioX || pVideoInfoHeader2->dwPictAspectRatioY) |
---|
588 | { |
---|
589 | sText.AppendFormat(_T(" dwPictAspectRatioX: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwPictAspectRatioX)); |
---|
590 | sText.AppendFormat(_T(" dwPictAspectRatioY: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwPictAspectRatioY)); |
---|
591 | } |
---|
592 | sText.AppendFormat(_T(" dwControlFlags: 0x%x\r\n"), pVideoInfoHeader2->dwControlFlags); |
---|
593 | sText.Append(_T("\r\n")); |
---|
594 | sText.Append(_T("BITMAPINFOHEADER:\r\n")); |
---|
595 | const CBitmapInfoHeader* pBitmapInfoHeader = &pVideoInfoHeader2->GetBitmapInfoHeader(); |
---|
596 | sText.AppendFormat(_T(" biSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSize)); |
---|
597 | sText.AppendFormat(_T(" biWidth: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biWidth)); |
---|
598 | sText.AppendFormat(_T(" biHeight: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biHeight)); |
---|
599 | sText.AppendFormat(_T(" biPlanes: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biPlanes)); |
---|
600 | sText.AppendFormat(_T(" biBitCount: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biBitCount)); |
---|
601 | sText.AppendFormat(_T(" biCompression: %s\r\n"), StringFromFourCharacterCode(pBitmapInfoHeader->biCompression)); |
---|
602 | sText.AppendFormat(_T(" biSizeImage: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSizeImage)); |
---|
603 | //biXPelsPerMeter; |
---|
604 | //biYPelsPerMeter; |
---|
605 | //biClrUsed; |
---|
606 | //biClrImportant; |
---|
607 | } else |
---|
608 | #pragma endregion |
---|
609 | #pragma region FORMAT_WaveFormatEx |
---|
610 | if(pMediaType->formattype == FORMAT_WaveFormatEx) |
---|
611 | { |
---|
612 | sText.Append(_T("\r\n")); |
---|
613 | sText.Append(_T("WAVEFORMATEX:\r\n")); |
---|
614 | const CWaveFormatEx* pWaveFormatEx = pMediaType.GetWaveFormatEx(); |
---|
615 | sText.AppendFormat(_T(" wFormatTag: 0x%04x\r\n"), pWaveFormatEx->wFormatTag); |
---|
616 | sText.AppendFormat(_T(" nChannels: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nChannels)); |
---|
617 | sText.AppendFormat(_T(" nSamplesPerSec: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nSamplesPerSec)); |
---|
618 | sText.AppendFormat(_T(" nAvgBytesPerSec: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nAvgBytesPerSec)); |
---|
619 | sText.AppendFormat(_T(" nBlockAlign: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nBlockAlign)); |
---|
620 | sText.AppendFormat(_T(" wBitsPerSample: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->wBitsPerSample)); |
---|
621 | sText.AppendFormat(_T(" cbSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->cbSize)); |
---|
622 | if(pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE && sizeof *pWaveFormatEx + pWaveFormatEx->cbSize >= sizeof (WAVEFORMATEXTENSIBLE)) |
---|
623 | { |
---|
624 | sText.Append(_T("\r\n")); |
---|
625 | sText.Append(_T("WAVEFORMATEXTENSIBLE:\r\n")); |
---|
626 | const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) (const WAVEFORMATEX*) pWaveFormatEx; |
---|
627 | sText.AppendFormat(_T(" wValidBitsPerSample/wSamplesPerBlock: %d\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatExtensible->Samples.wValidBitsPerSample)); |
---|
628 | sText.AppendFormat(_T(" dwChannelMask: 0x%x\r\n"), pWaveFormatExtensible->dwChannelMask); |
---|
629 | sText.AppendFormat(_T(" SubFormat: %ls\r\n"), _PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat)); |
---|
630 | } else |
---|
631 | if(pWaveFormatEx->cbSize) |
---|
632 | sText.AppendFormat(_T(" %s\r\n"), StringFromData((const BYTE*) (pWaveFormatEx + 1), pWaveFormatEx->cbSize)); |
---|
633 | } |
---|
634 | #pragma endregion |
---|
635 | } |
---|
636 | #pragma endregion |
---|
637 | #pragma region IWMMediaProps |
---|
638 | const CComQIPtr<IWMMediaProps> pWmMediaProps = m_pCodecFormatData->m_pWmStreamConfig; |
---|
639 | if(pWmMediaProps) |
---|
640 | _ATLTRY |
---|
641 | { |
---|
642 | GUID Type = GUID_NULL; |
---|
643 | __C(pWmMediaProps->GetType(&Type)); |
---|
644 | sText.Append(_T("IWMMediaProps:\r\n")); |
---|
645 | sText.AppendFormat(_T(" ") _T("Type: %ls") _T("\r\n"), _FilterGraphHelper::FormatMajorType(Type)); |
---|
646 | sText.Append(_T("\r\n")); |
---|
647 | } |
---|
648 | _ATLCATCHALL() |
---|
649 | { |
---|
650 | _Z_EXCEPTION(); |
---|
651 | } |
---|
652 | #pragma endregion |
---|
653 | #pragma region IWMStreamConfig |
---|
654 | const CComQIPtr<IWMStreamConfig> pWmStreamConfig = m_pCodecFormatData->m_pWmStreamConfig; |
---|
655 | if(pWmStreamConfig) |
---|
656 | _ATLTRY |
---|
657 | { |
---|
658 | GUID StreamType = GUID_NULL; |
---|
659 | __C(pWmStreamConfig->GetStreamType(&StreamType)); |
---|
660 | WORD nStreamNumber = 0; |
---|
661 | __C(pWmStreamConfig->GetStreamNumber(&nStreamNumber)); |
---|
662 | WORD nStreamNameLength = 0; |
---|
663 | pWmStreamConfig->GetStreamName(NULL, &nStreamNameLength); |
---|
664 | CTempBufferT<WCHAR> pszStreamName(nStreamNameLength + 1); |
---|
665 | __C(pWmStreamConfig->GetStreamName(pszStreamName, &nStreamNameLength)); |
---|
666 | WORD nConnectionNameLength = 0; |
---|
667 | pWmStreamConfig->GetConnectionName(NULL, &nConnectionNameLength); |
---|
668 | CTempBufferT<WCHAR> pszConnectionName(nConnectionNameLength + 1); |
---|
669 | __C(pWmStreamConfig->GetConnectionName(pszConnectionName, &nConnectionNameLength)); |
---|
670 | DWORD nBitrate = 0; |
---|
671 | __C(pWmStreamConfig->GetBitrate(&nBitrate)); |
---|
672 | DWORD nBufferWindow = 0; |
---|
673 | __C(pWmStreamConfig->GetBufferWindow(&nBufferWindow)); |
---|
674 | sText.Append(_T("IWMStreamConfig:\r\n")); |
---|
675 | sText.AppendFormat(_T(" ") _T("StreamType: %ls") _T("\r\n"), _FilterGraphHelper::FormatMajorType(StreamType)); |
---|
676 | sText.AppendFormat(_T(" ") _T("StreamNumber: %d") _T("\r\n"), nStreamNumber); |
---|
677 | if(wcslen(pszStreamName)) |
---|
678 | sText.AppendFormat(_T(" ") _T("StreamName: %ls") _T("\r\n"), (LPCWSTR) pszStreamName); |
---|
679 | if(wcslen(pszConnectionName)) |
---|
680 | sText.AppendFormat(_T(" ") _T("ConnectionName: %ls") _T("\r\n"), (LPCWSTR) pszConnectionName); |
---|
681 | sText.AppendFormat(_T(" ") _T("Bitrate: %d") _T("\r\n"), nBitrate); |
---|
682 | sText.AppendFormat(_T(" ") _T("BufferWindow: %d") _T("\r\n"), nBufferWindow); |
---|
683 | sText.Append(_T("\r\n")); |
---|
684 | } |
---|
685 | _ATLCATCHALL() |
---|
686 | { |
---|
687 | _Z_EXCEPTION(); |
---|
688 | } |
---|
689 | #pragma endregion |
---|
690 | #pragma region IWMStreamConfig2 |
---|
691 | const CComQIPtr<IWMStreamConfig2> pWmStreamConfig2 = m_pCodecFormatData->m_pWmStreamConfig; |
---|
692 | if(pWmStreamConfig2) |
---|
693 | _ATLTRY |
---|
694 | { |
---|
695 | WMT_TRANSPORT_TYPE TransportType; |
---|
696 | __C(pWmStreamConfig2->GetTransportType(&TransportType)); |
---|
697 | WORD nDataUnitExtensionCount = 0; |
---|
698 | pWmStreamConfig2->GetDataUnitExtensionCount(&nDataUnitExtensionCount); |
---|
699 | for(WORD nDataUnitExtensionIndex = 0; nDataUnitExtensionIndex < nDataUnitExtensionCount; nDataUnitExtensionIndex++) |
---|
700 | { |
---|
701 | GUID Identifier = GUID_NULL; |
---|
702 | WORD nSize = 0; |
---|
703 | DWORD nInformationSize = 0; |
---|
704 | __C(pWmStreamConfig2->GetDataUnitExtension(nDataUnitExtensionIndex, &Identifier, &nSize, NULL, &nInformationSize)); |
---|
705 | } |
---|
706 | sText.Append(_T("IWMStreamConfig2:\r\n")); |
---|
707 | sText.AppendFormat(_T(" ") _T("TransportType: %d") _T("\r\n"), TransportType); |
---|
708 | if(nDataUnitExtensionCount) |
---|
709 | sText.AppendFormat(_T(" ") _T("DataUnitExtensionCount: %d") _T("\r\n"), nDataUnitExtensionCount); |
---|
710 | sText.Append(_T("\r\n")); |
---|
711 | } |
---|
712 | _ATLCATCHALL() |
---|
713 | { |
---|
714 | _Z_EXCEPTION(); |
---|
715 | } |
---|
716 | #pragma endregion |
---|
717 | #pragma region IWMStreamConfig3 |
---|
718 | const CComQIPtr<IWMStreamConfig3> pWmStreamConfig3 = m_pCodecFormatData->m_pWmStreamConfig; |
---|
719 | if(pWmStreamConfig3) |
---|
720 | _ATLTRY |
---|
721 | { |
---|
722 | WORD nLanguageStringLength = 0; |
---|
723 | pWmStreamConfig3->GetLanguage(NULL, &nLanguageStringLength); |
---|
724 | CTempBufferT<WCHAR> pszLanguageString(nLanguageStringLength + 1); |
---|
725 | __C(pWmStreamConfig3->GetLanguage(pszLanguageString, &nLanguageStringLength)); |
---|
726 | if(wcslen(pszLanguageString)) |
---|
727 | { |
---|
728 | sText.Append(_T("IWMStreamConfig3:\r\n")); |
---|
729 | if(wcslen(pszLanguageString)) |
---|
730 | sText.AppendFormat(_T(" ") _T("Language: %ls") _T("\r\n"), (LPCWSTR) pszLanguageString); |
---|
731 | sText.Append(_T("\r\n")); |
---|
732 | } |
---|
733 | } |
---|
734 | _ATLCATCHALL() |
---|
735 | { |
---|
736 | _Z_EXCEPTION(); |
---|
737 | } |
---|
738 | #pragma endregion |
---|
739 | #pragma region IWMVideoMediaProps |
---|
740 | const CComQIPtr<IWMVideoMediaProps> pWmVideoMediaProps = m_pCodecFormatData->m_pWmStreamConfig; |
---|
741 | if(pWmVideoMediaProps) |
---|
742 | _ATLTRY |
---|
743 | { |
---|
744 | LONGLONG nMaximalKeyFrameIntervalTime = 0; |
---|
745 | __C(pWmVideoMediaProps->GetMaxKeyFrameSpacing(&nMaximalKeyFrameIntervalTime)); |
---|
746 | DWORD nQuality = 0; |
---|
747 | __C(pWmVideoMediaProps->GetQuality(&nQuality)); |
---|
748 | sText.Append(_T("IWMVideoMediaProps:\r\n")); |
---|
749 | sText.AppendFormat(_T(" ") _T("MaxKeyFrameSpacing: %s") _T("\r\n"), _FilterGraphHelper::FormatReferenceTime(nMaximalKeyFrameIntervalTime)); |
---|
750 | sText.AppendFormat(_T(" ") _T("Quality: %d") _T("\r\n"), nQuality); |
---|
751 | sText.Append(_T("\r\n")); |
---|
752 | } |
---|
753 | _ATLCATCHALL() |
---|
754 | { |
---|
755 | _Z_EXCEPTION(); |
---|
756 | } |
---|
757 | #pragma endregion |
---|
758 | } |
---|
759 | sText.Trim(_T("\t\n\r .")); |
---|
760 | return sText; |
---|
761 | } |
---|
762 | }; |
---|
763 | |
---|
764 | private: |
---|
765 | CComPtr<IWMProfileManager> m_pWmProfileManager; |
---|
766 | CAtlList<CCodecDataList> m_VideoCodecDataListList; |
---|
767 | CAtlList<CCodecDataList> m_AudioCodecDataListList; |
---|
768 | CRoTreeViewT<CTreeViewItem, CRoListControlDataTraitsT> m_TreeView; |
---|
769 | CRoListViewT<CListViewItem, CRoListControlDataTraitsT> m_ListView; |
---|
770 | CRoHyperStatic m_OsVersionStatic; |
---|
771 | |
---|
772 | static CString StringFromData(const BYTE* pnData, SIZE_T nDataSize) |
---|
773 | { |
---|
774 | CString sString; |
---|
775 | for(SIZE_T nIndex = 0; nIndex < nDataSize; nIndex++) |
---|
776 | sString.AppendFormat(_T("%02X "), pnData[nIndex]); |
---|
777 | sString.TrimRight(); |
---|
778 | return sString; |
---|
779 | } |
---|
780 | static CString StringFromFourCharacterCode(DWORD nCode) |
---|
781 | { |
---|
782 | BOOL bValid = TRUE; |
---|
783 | CHAR pszString[5]; |
---|
784 | for(UINT nIndex = 0; bValid && nIndex < 4; nIndex++) |
---|
785 | { |
---|
786 | pszString[nIndex] = (nCode >> (8 * nIndex)) & 0xFF; |
---|
787 | bValid &= pszString[nIndex] >= 0x20; |
---|
788 | } |
---|
789 | pszString[4] = 0; |
---|
790 | if(bValid) |
---|
791 | return AtlFormatString(_T("%hs (0x%08x)"), pszString, nCode); |
---|
792 | return AtlFormatString(_T("0x%08x"), nCode); |
---|
793 | } |
---|
794 | VOID InsertVideoListViewItem(const CCodecFormatData& CodecFormatData) |
---|
795 | { |
---|
796 | const INT nItem = m_ListView.InsertItem(m_ListView.GetItemCount(), CListViewItem(&CodecFormatData), CodecFormatData.GetDescription()); |
---|
797 | if(CodecFormatData.m_pMediaType->formattype == FORMAT_VideoInfo) |
---|
798 | { |
---|
799 | _A(CodecFormatData.m_pMediaType->cbFormat >= sizeof (VIDEOINFOHEADER)); |
---|
800 | const CVideoInfoHeader* pVideoInfoHeader = CodecFormatData.m_pMediaType.GetVideoInfoHeader(); |
---|
801 | _W(m_ListView.SetItemText(nItem, 1, StringFromFourCharacterCode(pVideoInfoHeader->GetBitmapInfoHeader().biCompression))); |
---|
802 | } else |
---|
803 | if(CodecFormatData.m_pMediaType->formattype == FORMAT_VideoInfo2) |
---|
804 | { |
---|
805 | _A(CodecFormatData.m_pMediaType->cbFormat >= sizeof (VIDEOINFOHEADER2)); |
---|
806 | const CVideoInfoHeader2* pVideoInfoHeader = CodecFormatData.m_pMediaType.GetVideoInfoHeader2(); |
---|
807 | _W(m_ListView.SetItemText(nItem, 1, StringFromFourCharacterCode(pVideoInfoHeader->GetBitmapInfoHeader().biCompression))); |
---|
808 | } |
---|
809 | } |
---|
810 | VOID InsertAudioListViewItem(const CCodecFormatData& CodecFormatData) |
---|
811 | { |
---|
812 | const INT nItem = m_ListView.InsertItem(m_ListView.GetItemCount(), CListViewItem(&CodecFormatData), CodecFormatData.GetDescription()); |
---|
813 | if(CodecFormatData.m_pMediaType->formattype == FORMAT_WaveFormatEx) |
---|
814 | { |
---|
815 | _A(CodecFormatData.m_pMediaType->cbFormat >= sizeof (WAVEFORMATEX)); |
---|
816 | const CWaveFormatEx* pWaveFormatEx = CodecFormatData.m_pMediaType.GetWaveFormatEx(); |
---|
817 | _W(m_ListView.SetItemText(nItem, 1, _StringHelper::FormatNumber((LONG) CodecFormatData.m_pMediaType->bFixedSizeSamples))); |
---|
818 | _W(m_ListView.SetItemText(nItem, 2, _StringHelper::FormatNumber((LONG) CodecFormatData.m_pMediaType->bTemporalCompression))); |
---|
819 | _W(m_ListView.SetItemText(nItem, 3, _StringHelper::FormatNumber((LONG) CodecFormatData.m_pMediaType->lSampleSize))); |
---|
820 | _W(m_ListView.SetItemText(nItem, 4, AtlFormatString(_T("0x%02x"), pWaveFormatEx->wFormatTag))); |
---|
821 | _W(m_ListView.SetItemText(nItem, 5, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nChannels))); |
---|
822 | _W(m_ListView.SetItemText(nItem, 6, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nSamplesPerSec))); |
---|
823 | _W(m_ListView.SetItemText(nItem, 7, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nAvgBytesPerSec))); |
---|
824 | _W(m_ListView.SetItemText(nItem, 8, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nBlockAlign))); |
---|
825 | _W(m_ListView.SetItemText(nItem, 9, _StringHelper::FormatNumber((LONG) pWaveFormatEx->wBitsPerSample))); |
---|
826 | _W(m_ListView.SetItemText(nItem, 10, _StringHelper::FormatNumber((LONG) pWaveFormatEx->cbSize))); |
---|
827 | _W(m_ListView.SetItemText(nItem, 11, StringFromData((const BYTE*) (pWaveFormatEx + 1), pWaveFormatEx->cbSize))); |
---|
828 | } |
---|
829 | } |
---|
830 | VOID UpdateListView() |
---|
831 | { |
---|
832 | CWindowRedraw ListViewRedraw(m_ListView); |
---|
833 | m_ListView.DeleteAllItems(); |
---|
834 | while(m_ListView.DeleteColumn(0)) |
---|
835 | ; |
---|
836 | HTREEITEM hTreeItem = m_TreeView.GetSelectedItem(); |
---|
837 | if(!hTreeItem) |
---|
838 | return; |
---|
839 | CTreeViewItem& TreeViewItem = m_TreeView.GetItemData(hTreeItem); |
---|
840 | // SUGG: List all codecs/formats in absense of .m_pCodecData |
---|
841 | if(TreeViewItem.m_pCodecData) |
---|
842 | { |
---|
843 | if(TreeViewItem.m_MajorType == WMMEDIATYPE_Video) |
---|
844 | { |
---|
845 | _W(m_ListView.InsertColumn(0, _T("Description"), LVCFMT_LEFT, 180) >= 0); |
---|
846 | _W(m_ListView.InsertColumn(1, _T("biCompression"), LVCFMT_LEFT, 120) >= 0); |
---|
847 | const CCodecFormatDataList& CodecFormatDataList = TreeViewItem.m_pCodecData->m_CodecFormatDataList; |
---|
848 | for(POSITION Position = CodecFormatDataList.GetHeadPosition(); Position; CodecFormatDataList.GetNext(Position)) |
---|
849 | InsertVideoListViewItem(CodecFormatDataList.GetAt(Position)); |
---|
850 | } |
---|
851 | if(TreeViewItem.m_MajorType == WMMEDIATYPE_Audio) |
---|
852 | { |
---|
853 | _W(m_ListView.InsertColumn(0, _T("Description"), LVCFMT_LEFT, 210) >= 0); |
---|
854 | _W(m_ListView.InsertColumn(1, _T("bFixedSizeSamples"), LVCFMT_RIGHT, 60) >= 0); |
---|
855 | _W(m_ListView.InsertColumn(2, _T("bTemporalCompression"), LVCFMT_RIGHT, 60) >= 0); |
---|
856 | _W(m_ListView.InsertColumn(3, _T("lSampleSize"), LVCFMT_RIGHT, 60) >= 0); |
---|
857 | _W(m_ListView.InsertColumn(4, _T("wFormatTag"), LVCFMT_RIGHT, 90) >= 0); |
---|
858 | _W(m_ListView.InsertColumn(5, _T("nChannels"), LVCFMT_RIGHT, 60) >= 0); |
---|
859 | _W(m_ListView.InsertColumn(6, _T("nSamplesPerSec"), LVCFMT_RIGHT, 90) >= 0); |
---|
860 | _W(m_ListView.InsertColumn(7, _T("nAvgBytesPerSec"), LVCFMT_RIGHT, 90) >= 0); |
---|
861 | _W(m_ListView.InsertColumn(8, _T("nBlockAlign"), LVCFMT_RIGHT, 60) >= 0); |
---|
862 | _W(m_ListView.InsertColumn(9, _T("wBitsPerSample"), LVCFMT_RIGHT, 60) >= 0); |
---|
863 | _W(m_ListView.InsertColumn(10, _T("cbSize"), LVCFMT_RIGHT, 60) >= 0); |
---|
864 | _W(m_ListView.InsertColumn(11, _T("Extra Data"), LVCFMT_LEFT, 120) >= 0); |
---|
865 | const CCodecFormatDataList& CodecFormatDataList = TreeViewItem.m_pCodecData->m_CodecFormatDataList; |
---|
866 | for(POSITION Position = CodecFormatDataList.GetHeadPosition(); Position; CodecFormatDataList.GetNext(Position)) |
---|
867 | InsertAudioListViewItem(CodecFormatDataList.GetAt(Position)); |
---|
868 | // SUGG: List g_wszSpeechCaps proeprty if/where available |
---|
869 | } |
---|
870 | } |
---|
871 | } |
---|
872 | CString GetSubmissionText() const |
---|
873 | { |
---|
874 | CString sText; |
---|
875 | #pragma region OS Version |
---|
876 | { |
---|
877 | OSVERSIONINFOEX VersionInformation = { sizeof VersionInformation }; |
---|
878 | _W(GetVersionEx((OSVERSIONINFO*) &VersionInformation)); |
---|
879 | CAtlArray<CString> Array; |
---|
880 | _W(Array.Add(_T("OS Version")) >= 0); |
---|
881 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwMajorVersion)) >= 0); |
---|
882 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwMinorVersion)) >= 0); |
---|
883 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwBuildNumber)) >= 0); |
---|
884 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwPlatformId)) >= 0); |
---|
885 | _W(Array.Add(VersionInformation.szCSDVersion) >= 0); |
---|
886 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wServicePackMajor)) >= 0); |
---|
887 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wServicePackMinor)) >= 0); |
---|
888 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wSuiteMask)) >= 0); |
---|
889 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wProductType)) >= 0); |
---|
890 | #if defined(_WIN64) |
---|
891 | _W(Array.Add(_T("x64")) >= 0); |
---|
892 | #else |
---|
893 | _W(Array.Add(_T("Win32")) >= 0); |
---|
894 | #endif // defined(_WIN64) |
---|
895 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
896 | sText.Append(_T("\r\n")); |
---|
897 | } |
---|
898 | #pragma endregion |
---|
899 | #pragma region Windows Media Version |
---|
900 | { |
---|
901 | CAtlArray<CString> Array; |
---|
902 | _W(Array.Add(_T("WMV Core Version")) >= 0); |
---|
903 | _W(Array.Add(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_T("wmvcore.dll")))) >= 0); |
---|
904 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
905 | sText.Append(_T("\r\n")); |
---|
906 | } |
---|
907 | #pragma endregion |
---|
908 | #pragma region Codecs |
---|
909 | const CAtlList<CCodecDataList>* ppCodecDataListLists[] = { &m_VideoCodecDataListList, &m_AudioCodecDataListList }; |
---|
910 | for(SIZE_T nCodecDataListListIndex = 0; nCodecDataListListIndex < DIM(ppCodecDataListLists); nCodecDataListListIndex++) |
---|
911 | { |
---|
912 | const CAtlList<CCodecDataList>& CodecDataListList = *ppCodecDataListLists[nCodecDataListListIndex]; |
---|
913 | for(POSITION CodecDataListListPosition = CodecDataListList.GetHeadPosition(); CodecDataListListPosition; CodecDataListList.GetNext(CodecDataListListPosition)) |
---|
914 | { |
---|
915 | const CCodecDataList& CodecDataList = CodecDataListList.GetAt(CodecDataListListPosition); |
---|
916 | { |
---|
917 | CAtlArray<CString> Array; |
---|
918 | _W(Array.Add(_T("Codec Enumeration")) >= 0); |
---|
919 | _W(Array.Add(AtlFormatString(_T("%ls"), _PersistHelper::StringFromIdentifier(CodecDataList.m_MajorType))) >= 0); |
---|
920 | _W(Array.Add(AtlFormatString(_T("%s"), CodecDataList.m_EnumerationSettingList.m_sName)) >= 0); |
---|
921 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
922 | sText.Append(_T("\r\n")); |
---|
923 | for(POSITION EnumerationSettingPosition = CodecDataList.m_EnumerationSettingList.GetHeadPosition(); EnumerationSettingPosition; CodecDataList.m_EnumerationSettingList.GetNext(EnumerationSettingPosition)) |
---|
924 | { |
---|
925 | const CEnumerationSetting& EnumerationSetting = CodecDataList.m_EnumerationSettingList.GetAt(EnumerationSettingPosition); |
---|
926 | CAtlArray<CString> Array; |
---|
927 | _W(Array.Add(_T("Codec Enumeration Setting")) >= 0); |
---|
928 | _W(Array.Add(AtlFormatString(_T("%ls"), EnumerationSetting.m_sName)) >= 0); |
---|
929 | _W(Array.Add(AtlFormatString(_T("%s"), EnumerationSetting.GetValueString())) >= 0); |
---|
930 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
931 | sText.Append(_T("\r\n")); |
---|
932 | } |
---|
933 | } |
---|
934 | for(POSITION CodecDataListPosition = CodecDataList.GetHeadPosition(); CodecDataListPosition; CodecDataList.GetNext(CodecDataListPosition)) |
---|
935 | { |
---|
936 | const CCodecData& CodecData = CodecDataList.GetAt(CodecDataListPosition); |
---|
937 | CAtlArray<CString> Array; |
---|
938 | _W(Array.Add(_T("Codec")) >= 0); |
---|
939 | _W(Array.Add(AtlFormatString(_T("%ls"), _PersistHelper::StringFromIdentifier(CodecData.m_MajorType))) >= 0); |
---|
940 | _W(Array.Add(AtlFormatString(_T("%d"), CodecData.m_nIndex)) >= 0); |
---|
941 | _W(Array.Add(AtlFormatString(_T("%ls"), CodecData.m_sName)) >= 0); |
---|
942 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
943 | sText.Append(_T("\r\n")); |
---|
944 | const CCodecFormatDataList& CodecFormatDataList = CodecData.m_CodecFormatDataList; |
---|
945 | for(POSITION CodecFormatDataListPosition = CodecFormatDataList.GetHeadPosition(); CodecFormatDataListPosition; CodecFormatDataList.GetNext(CodecFormatDataListPosition)) |
---|
946 | { |
---|
947 | const CCodecFormatData& CodecFormatData = CodecFormatDataList.GetAt(CodecFormatDataListPosition); |
---|
948 | CAtlArray<CString> Array; |
---|
949 | _W(Array.Add(_T("Codec Format")) >= 0); |
---|
950 | _W(Array.Add(AtlFormatString(_T("%d"), CodecFormatData.m_nIndex)) >= 0); |
---|
951 | _W(Array.Add(AtlFormatString(_T("%ls"), CodecFormatData.m_sDescription)) >= 0); |
---|
952 | // TODO: Human friendly media type |
---|
953 | _A(CodecFormatData.m_pMediaType); |
---|
954 | _W(Array.Add(StringFromData((const BYTE*) (const AM_MEDIA_TYPE*) CodecFormatData.m_pMediaType, sizeof (AM_MEDIA_TYPE))) >= 0); |
---|
955 | _W(Array.Add(StringFromData(CodecFormatData.m_pMediaType->pbFormat, CodecFormatData.m_pMediaType->cbFormat)) >= 0); |
---|
956 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
957 | sText.Append(_T("\r\n")); |
---|
958 | } |
---|
959 | } |
---|
960 | } |
---|
961 | } |
---|
962 | #pragma endregion |
---|
963 | return sText; |
---|
964 | } |
---|
965 | |
---|
966 | public: |
---|
967 | // CMainDialog |
---|
968 | CMainDialog() throw() |
---|
969 | { |
---|
970 | } |
---|
971 | |
---|
972 | // Window message handlers |
---|
973 | LRESULT OnInitDialog(HWND, LPARAM) |
---|
974 | { |
---|
975 | DlgResize_Init(); |
---|
976 | SetIcon(AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), FALSE); |
---|
977 | SetIcon(AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE); |
---|
978 | #if defined(_WIN64) |
---|
979 | CString sCaption; |
---|
980 | GetWindowText(sCaption); |
---|
981 | sCaption += _T(" (x64)"); |
---|
982 | SetWindowText(sCaption); |
---|
983 | #endif // defined(_WIN64) |
---|
984 | { |
---|
985 | CWaitCursor WaitCursor; |
---|
986 | CComPtr<IWMProfileManager> pWmProfileManager; |
---|
987 | __C(WMCreateProfileManager(&pWmProfileManager)); |
---|
988 | CComQIPtr<IWMProfileManager2> pWmProfileManager2 = pWmProfileManager; |
---|
989 | if(pWmProfileManager2) |
---|
990 | _V(pWmProfileManager2->SetSystemProfileVersion(WMT_VER_9_0)); |
---|
991 | m_pWmProfileManager = pWmProfileManager; |
---|
992 | CComQIPtr<IWMCodecInfo2> pWmCodecInfo2 = pWmProfileManager; |
---|
993 | __D(pWmCodecInfo2, E_NOINTERFACE); |
---|
994 | CWmCodecInfo3 pWmCodecInfo3 = pWmCodecInfo2; |
---|
995 | // Video |
---|
996 | CCodecDataList& VideoCodecDataList = m_VideoCodecDataListList.GetAt(m_VideoCodecDataListList.AddTail()); |
---|
997 | VideoCodecDataList.Initialize(pWmCodecInfo2, WMMEDIATYPE_Video); |
---|
998 | //if(pWmCodecInfo3) |
---|
999 | // _ATLTRY |
---|
1000 | // { |
---|
1001 | // for(UINT nVbrMode = 0; nVbrMode <= 1; nVbrMode++) |
---|
1002 | // for(UINT nPassCount = 1; nPassCount <= 2; nPassCount++) |
---|
1003 | // { |
---|
1004 | // CEnumerationSettingList EnumerationSettingList; |
---|
1005 | // _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszVBREnabled, (BOOL) (nVbrMode != 0)))); |
---|
1006 | // _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszNumPasses, (DWORD) nPassCount))); |
---|
1007 | // EnumerationSettingList.m_sName = AtlFormatString(_T("%s, %d passes"), nVbrMode ? _T("VBR") : _T("CBR"), nPassCount); |
---|
1008 | // CCodecDataList& VideoCodecDataList = m_VideoCodecDataListList.GetAt(m_VideoCodecDataListList.AddTail()); |
---|
1009 | // VideoCodecDataList.Initialize(pWmCodecInfo3, WMMEDIATYPE_Video, EnumerationSettingList); |
---|
1010 | // } |
---|
1011 | // } |
---|
1012 | // _ATLCATCHALL() |
---|
1013 | // { |
---|
1014 | // _Z_EXCEPTION(); |
---|
1015 | // } |
---|
1016 | // Audio |
---|
1017 | CCodecDataList& AudioCodecDataList = m_AudioCodecDataListList.GetAt(m_AudioCodecDataListList.AddTail()); |
---|
1018 | AudioCodecDataList.Initialize(pWmCodecInfo2, WMMEDIATYPE_Audio); |
---|
1019 | if(pWmCodecInfo3) |
---|
1020 | _ATLTRY |
---|
1021 | { |
---|
1022 | for(UINT nVbrMode = 0; nVbrMode <= 1; nVbrMode++) |
---|
1023 | for(UINT nPassCount = 1; nPassCount <= 2; nPassCount++) |
---|
1024 | { |
---|
1025 | CEnumerationSettingList EnumerationSettingList; |
---|
1026 | _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszVBREnabled, (BOOL) (nVbrMode != 0)))); |
---|
1027 | _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszNumPasses, (DWORD) nPassCount))); |
---|
1028 | EnumerationSettingList.m_sName = AtlFormatString(_T("%s, %d passes"), nVbrMode ? _T("VBR") : _T("CBR"), nPassCount); |
---|
1029 | CCodecDataList& AudioCodecDataList = m_AudioCodecDataListList.GetAt(m_AudioCodecDataListList.AddTail()); |
---|
1030 | AudioCodecDataList.Initialize(pWmCodecInfo3, WMMEDIATYPE_Audio, EnumerationSettingList); |
---|
1031 | } |
---|
1032 | } |
---|
1033 | _ATLCATCHALL() |
---|
1034 | { |
---|
1035 | _Z_EXCEPTION(); |
---|
1036 | } |
---|
1037 | } |
---|
1038 | m_TreeView = GetDlgItem(IDC_TREE); |
---|
1039 | HTREEITEM hVideoItem = m_TreeView.InsertItem(NULL, NULL, CTreeViewItem(WMMEDIATYPE_Video), _T("Video")); |
---|
1040 | HTREEITEM hPreviousVideoCodecListItem = NULL; |
---|
1041 | for(POSITION ListPosition = m_VideoCodecDataListList.GetHeadPosition(); ListPosition; m_VideoCodecDataListList.GetNext(ListPosition)) |
---|
1042 | { |
---|
1043 | const CCodecDataList* pCodecDataList = &m_VideoCodecDataListList.GetAt(ListPosition); |
---|
1044 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty() && pCodecDataList->IsEmpty()) |
---|
1045 | continue; |
---|
1046 | HTREEITEM hVideoCodecListItem = m_TreeView.InsertItem(hVideoItem, hPreviousVideoCodecListItem, CTreeViewItem(WMMEDIATYPE_Video, pCodecDataList), pCodecDataList->GetTitle()); |
---|
1047 | hPreviousVideoCodecListItem = hVideoCodecListItem; |
---|
1048 | HTREEITEM hPreviousVideoCodecItem = NULL; |
---|
1049 | for(POSITION Position = pCodecDataList->GetHeadPosition(); Position; pCodecDataList->GetNext(Position)) |
---|
1050 | { |
---|
1051 | const CCodecData* pCodecData = &pCodecDataList->GetAt(Position); |
---|
1052 | HTREEITEM hVideoCodecItem = m_TreeView.InsertItem(hVideoCodecListItem, hPreviousVideoCodecItem, CTreeViewItem(WMMEDIATYPE_Video, pCodecDataList, pCodecData), pCodecData->GetTitle()); |
---|
1053 | hPreviousVideoCodecItem = hVideoCodecItem; |
---|
1054 | } |
---|
1055 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty()) |
---|
1056 | m_TreeView.Expand(hVideoCodecListItem); |
---|
1057 | } |
---|
1058 | m_TreeView.Expand(hVideoItem); |
---|
1059 | HTREEITEM hAudioItem = m_TreeView.InsertItem(NULL, NULL, CTreeViewItem(WMMEDIATYPE_Audio), _T("Audio")); |
---|
1060 | HTREEITEM hPreviousAudioCodecListItem = NULL; |
---|
1061 | for(POSITION ListPosition = m_AudioCodecDataListList.GetHeadPosition(); ListPosition; m_AudioCodecDataListList.GetNext(ListPosition)) |
---|
1062 | { |
---|
1063 | const CCodecDataList* pCodecDataList = &m_AudioCodecDataListList.GetAt(ListPosition); |
---|
1064 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty() && pCodecDataList->IsEmpty()) |
---|
1065 | continue; |
---|
1066 | HTREEITEM hAudioCodecListItem = m_TreeView.InsertItem(hAudioItem, hPreviousAudioCodecListItem, CTreeViewItem(WMMEDIATYPE_Audio, pCodecDataList), pCodecDataList->GetTitle()); |
---|
1067 | hPreviousAudioCodecListItem = hAudioCodecListItem; |
---|
1068 | HTREEITEM hPreviousAudioCodecItem = NULL; |
---|
1069 | for(POSITION Position = pCodecDataList->GetHeadPosition(); Position; pCodecDataList->GetNext(Position)) |
---|
1070 | { |
---|
1071 | const CCodecData* pCodecData = &pCodecDataList->GetAt(Position); |
---|
1072 | HTREEITEM hAudioCodecItem = m_TreeView.InsertItem(hAudioCodecListItem, hPreviousAudioCodecItem, CTreeViewItem(WMMEDIATYPE_Audio, pCodecDataList, pCodecData), pCodecData->GetTitle()); |
---|
1073 | hPreviousAudioCodecItem = hAudioCodecItem; |
---|
1074 | } |
---|
1075 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty()) |
---|
1076 | m_TreeView.Expand(hAudioCodecListItem); |
---|
1077 | } |
---|
1078 | m_TreeView.Expand(hAudioItem); |
---|
1079 | m_ListView = GetDlgItem(IDC_LIST); |
---|
1080 | m_ListView.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP); |
---|
1081 | CToolTipCtrl ListViewToolTip = m_ListView.GetToolTips(); |
---|
1082 | ListViewToolTip.SetDelayTime(TTDT_AUTOMATIC, 2 * 60 * 1000); // 2 minutes |
---|
1083 | m_TreeView.SelectItem(m_TreeView.GetNextItem(hAudioItem, TVGN_CHILD)); |
---|
1084 | UpdateListView(); |
---|
1085 | _W(m_OsVersionStatic.SubclassWindow(GetDlgItem(IDC_OSVERSION))); |
---|
1086 | OSVERSIONINFOEX VersionInformation = { sizeof VersionInformation }; |
---|
1087 | _W(GetVersionEx((OSVERSIONINFO*) &VersionInformation)); |
---|
1088 | m_OsVersionStatic.SetWindowText(AtlFormatString(_T("<A TITLE=\"Version %d.%d, Build %d, %s (%d.%d)\">Win %d.%d.%d</A>"), |
---|
1089 | VersionInformation.dwMajorVersion, VersionInformation.dwMinorVersion, VersionInformation.dwBuildNumber, |
---|
1090 | VersionInformation.szCSDVersion, VersionInformation.wServicePackMajor, VersionInformation.wServicePackMinor, |
---|
1091 | VersionInformation.dwMajorVersion, VersionInformation.dwMinorVersion, VersionInformation.dwBuildNumber)); |
---|
1092 | { |
---|
1093 | CMenuHandle Menu = GetSystemMenu(FALSE); |
---|
1094 | _W(Menu.AppendMenu(MF_SEPARATOR)); |
---|
1095 | _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About..."))); |
---|
1096 | } |
---|
1097 | _W(CenterWindow()); |
---|
1098 | return TRUE; |
---|
1099 | } |
---|
1100 | LRESULT OnSysCommand(UINT nCommand, CPoint) |
---|
1101 | { |
---|
1102 | switch(nCommand) |
---|
1103 | { |
---|
1104 | case ID_APP_ABOUT: |
---|
1105 | { |
---|
1106 | CAboutDialog Dialog; |
---|
1107 | Dialog.DoModal(m_hWnd); |
---|
1108 | } |
---|
1109 | break; |
---|
1110 | default: |
---|
1111 | SetMsgHandled(FALSE); |
---|
1112 | } |
---|
1113 | return 0; |
---|
1114 | } |
---|
1115 | LRESULT OnCancel(UINT, INT nIdentifier, HWND) |
---|
1116 | { |
---|
1117 | _W(EndDialog(nIdentifier)); |
---|
1118 | return 0; |
---|
1119 | } |
---|
1120 | LRESULT OnTreeGetInfoTip(NMTVGETINFOTIP* pHeader) |
---|
1121 | { |
---|
1122 | if(pHeader->hItem) |
---|
1123 | { |
---|
1124 | const CTreeViewItem& TreeViewItem = m_TreeView.DataFromParameter(pHeader->lParam); |
---|
1125 | if(TreeViewItem.m_pCodecData) |
---|
1126 | { |
---|
1127 | CString sText; |
---|
1128 | sText.AppendFormat(_T("Title: %s\r\n"), TreeViewItem.m_pCodecData->GetTitle()); |
---|
1129 | CWmCodecInfo3 pWmCodecInfo3 = TreeViewItem.m_pCodecData->m_pWmCodecInfo2; |
---|
1130 | if(pWmCodecInfo3) |
---|
1131 | _ATLTRY |
---|
1132 | { |
---|
1133 | sText.Append(_T("\r\n")); |
---|
1134 | if(TreeViewItem.m_pCodecData->m_MajorType == WMMEDIATYPE_Video) |
---|
1135 | { |
---|
1136 | DWORD nMaximalComplexity, nOfflineComplexity, nLiveComplexity; |
---|
1137 | if(SUCCEEDED(pWmCodecInfo3.GetDwordCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszComplexityMax, nMaximalComplexity))) |
---|
1138 | sText.AppendFormat(_T("g_wszComplexityMax: %d\r\n"), nMaximalComplexity); |
---|
1139 | if(SUCCEEDED(pWmCodecInfo3.GetDwordCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszComplexityOffline, nOfflineComplexity))) |
---|
1140 | sText.AppendFormat(_T("g_wszComplexityOffline: %d\r\n"), nOfflineComplexity); |
---|
1141 | if(SUCCEEDED(pWmCodecInfo3.GetDwordCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszComplexityLive, nLiveComplexity))) |
---|
1142 | sText.AppendFormat(_T("g_wszComplexityLive: %d\r\n"), nLiveComplexity); |
---|
1143 | } |
---|
1144 | BOOL bIsVbrSupported; |
---|
1145 | if(SUCCEEDED(pWmCodecInfo3.GetBoolCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszIsVBRSupported, bIsVbrSupported))) |
---|
1146 | sText.AppendFormat(_T("g_wszIsVBRSupported: %d\r\n"), bIsVbrSupported); |
---|
1147 | } |
---|
1148 | _ATLCATCH(Exception) |
---|
1149 | { |
---|
1150 | _Z_ATLEXCEPTION(Exception); |
---|
1151 | sText.AppendFormat(_T("Error 0x%08x: %s\r\n"), (HRESULT) Exception, AtlFormatSystemMessage(Exception).TrimRight(_T("\t\n\r ."))); |
---|
1152 | } |
---|
1153 | _ATLCATCHALL() |
---|
1154 | { |
---|
1155 | _Z_EXCEPTION(); |
---|
1156 | } |
---|
1157 | sText.TrimRight(_T("\t\n\r")); |
---|
1158 | _tcscpy_s(pHeader->pszText, pHeader->cchTextMax, sText); |
---|
1159 | if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0) |
---|
1160 | { |
---|
1161 | SetClipboardText(m_hWnd, sText); |
---|
1162 | MessageBeep(MB_OK); |
---|
1163 | } |
---|
1164 | } |
---|
1165 | } |
---|
1166 | return 0; |
---|
1167 | } |
---|
1168 | LRESULT OnTreeViewSelChanged(NMTREEVIEW*) |
---|
1169 | { |
---|
1170 | UpdateListView(); |
---|
1171 | return 0; |
---|
1172 | } |
---|
1173 | LRESULT OnListGetInfoTip(NMLVGETINFOTIP* pHeader) |
---|
1174 | { |
---|
1175 | CListViewItem& ListViewItem = m_ListView.GetItemData(pHeader->iItem); |
---|
1176 | const CString sInfoTipText = ListViewItem.GetInfoTipText(); |
---|
1177 | _tcscpy_s(pHeader->pszText, pHeader->cchTextMax, sInfoTipText); |
---|
1178 | if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0) |
---|
1179 | { |
---|
1180 | SetClipboardText(m_hWnd, sInfoTipText); |
---|
1181 | MessageBeep(MB_OK); |
---|
1182 | } |
---|
1183 | return 0; |
---|
1184 | } |
---|
1185 | LRESULT OnCopyButtonClicked(UINT, INT, HWND) |
---|
1186 | { |
---|
1187 | SetClipboardText(m_hWnd, GetSubmissionText()); |
---|
1188 | MessageBeep(MB_OK); |
---|
1189 | return 0; |
---|
1190 | } |
---|
1191 | LRESULT OnSubmitButtonClicked(UINT, INT, HWND) |
---|
1192 | { |
---|
1193 | CWaitCursor WaitCursor; |
---|
1194 | const CString sFileDescription = _VersionInfoHelper::GetString(_VersionInfoHelper::GetModulePath(), _T("FileDescription")); |
---|
1195 | CWinHttpPostData PostData; |
---|
1196 | PostData.AddValue(_T("subj"), sFileDescription); |
---|
1197 | CStringA sTextA = Utf8StringFromString(GetSubmissionText()); |
---|
1198 | PostData.AddValue(_T("body"), _Base64Helper::Encode<CString>((const BYTE*) (LPCSTR) sTextA, sTextA.GetLength(), _Base64Helper::FLAG_NOPAD | _Base64Helper::FLAG_NOCRLF)); |
---|
1199 | CWinHttpSessionHandle Session = OpenWinHttpSessionHandle(AtlLoadString(IDS_PROJNAME)); |
---|
1200 | __E(Session); |
---|
1201 | CWinHttpConnectionHandle Connection = Session.Connect(CStringW(_T("alax.info"))); |
---|
1202 | __E(Connection); |
---|
1203 | CWinHttpRequestHandle Request = Connection.OpenRequest(CStringW(_T("POST")), CStringW(_T("/post.php"))); |
---|
1204 | __E(Request); |
---|
1205 | CStringW sPostHeaders = PostData.GetHeaders(); |
---|
1206 | CStringA sPostData(PostData.GetValue()); |
---|
1207 | __E(Request.Send(sPostHeaders, -1, const_cast<LPSTR>((LPCSTR) sPostData), sPostData.GetLength(), sPostData.GetLength())); |
---|
1208 | __E(Request.ReceiveResponse()); |
---|
1209 | DWORD nStatusCode = 0; |
---|
1210 | __E(Request.QueryNumberHeader(WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, nStatusCode)); |
---|
1211 | __D(nStatusCode / 100 == HTTP_STATUS_OK / 100, MAKE_HRESULT(SEVERITY_ERROR, FACILITY_HTTP, nStatusCode)); |
---|
1212 | AtlMessageBoxEx(m_hWnd, _T("Submission complete, thank you!"), IDS_INFORMATION, MB_ICONINFORMATION | MB_OK); |
---|
1213 | return 0; |
---|
1214 | } |
---|
1215 | }; |
---|