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