[66] | 1 | //////////////////////////////////////////////////////////// |
---|
[186] | 2 | // Copyright (C) Roman Ryltsov, 2008-2013 |
---|
[66] | 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()) |
---|
[186] | 476 | { |
---|
[66] | 477 | sText.AppendFormat(_T("Description: %ls\r\n"), m_pCodecFormatData->m_sDescription); |
---|
[186] | 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) |
---|
[187] | 496 | A(IWMPropertyVault) |
---|
[186] | 497 | #undef A |
---|
| 498 | }; |
---|
| 499 | for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++) |
---|
| 500 | { |
---|
| 501 | CComPtr<IUnknown> pUnknown; |
---|
| 502 | m_pCodecFormatData->m_pWmStreamConfig->QueryInterface(*g_pMap[nIndex].pIdentifier, (VOID**) &pUnknown); |
---|
| 503 | if(pUnknown) |
---|
| 504 | sText += AtlFormatString(_T(" ") _T("%hs") _T("\r\n"), g_pMap[nIndex].pszName); |
---|
| 505 | } |
---|
| 506 | sText.Append(_T("\r\n")); |
---|
| 507 | } |
---|
| 508 | #pragma endregion |
---|
| 509 | #pragma region Media Type |
---|
[66] | 510 | if(m_pCodecFormatData->m_pMediaType) |
---|
| 511 | { |
---|
| 512 | sText.Append(_T("AM_MEDIA_TYPE:\r\n")); |
---|
| 513 | const CMediaType& pMediaType = reinterpret_cast<const CMediaType&>(m_pCodecFormatData->m_pMediaType); |
---|
| 514 | //sText.AppendFormat(_T(" ...\r\n"), pMediaType->majortype); |
---|
[67] | 515 | if(memcmp(&pMediaType->subtype.Data2, &MEDIASUBTYPE_MJPG.Data2, sizeof (GUID) - offsetof(GUID, Data2)) == 0) |
---|
| 516 | sText.AppendFormat(_T(" subtype: %ls (%s)\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->subtype), _FilterGraphHelper::GetFourccCodeString(pMediaType->subtype.Data1)); |
---|
| 517 | else |
---|
| 518 | sText.AppendFormat(_T(" subtype: %ls\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->subtype)); |
---|
[66] | 519 | sText.AppendFormat(_T(" bFixedSizeSamples: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->bFixedSizeSamples)); |
---|
| 520 | sText.AppendFormat(_T(" bTemporalCompression: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->bTemporalCompression)); |
---|
| 521 | sText.AppendFormat(_T(" lSampleSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->lSampleSize)); |
---|
[67] | 522 | #pragma region Format |
---|
| 523 | static const struct |
---|
| 524 | { |
---|
| 525 | GUID formattype; |
---|
| 526 | LPCTSTR pszTitle; |
---|
| 527 | } g_pMap[] = |
---|
| 528 | { |
---|
| 529 | { FORMAT_VideoInfo, _T("FORMAT_VideoInfo") }, |
---|
| 530 | { FORMAT_VideoInfo2, _T("FORMAT_VideoInfo2") }, |
---|
| 531 | { FORMAT_MPEG2_VIDEO, _T("FORMAT_MPEG2_VIDEO") }, |
---|
| 532 | { FORMAT_WaveFormatEx, _T("FORMAT_WaveFormatEx") }, |
---|
| 533 | }; |
---|
| 534 | BOOL bFound = FALSE; |
---|
| 535 | for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++) |
---|
| 536 | if(pMediaType->formattype == g_pMap[nIndex].formattype) |
---|
| 537 | { |
---|
| 538 | sText.AppendFormat(_T(" formattype: %ls (%s)\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->formattype), g_pMap[nIndex].pszTitle); |
---|
| 539 | bFound = TRUE; |
---|
| 540 | break; |
---|
| 541 | } |
---|
| 542 | if(!bFound) |
---|
| 543 | sText.AppendFormat(_T(" formattype: %ls\r\n"), _PersistHelper::StringFromIdentifier(pMediaType->formattype)); |
---|
| 544 | #pragma endregion |
---|
[66] | 545 | sText.AppendFormat(_T(" cbFormat: %s\r\n"), _StringHelper::FormatNumber((LONG) pMediaType->cbFormat)); |
---|
[186] | 546 | #pragma region FORMAT_VideoInfo |
---|
[66] | 547 | if(pMediaType->formattype == FORMAT_VideoInfo) |
---|
| 548 | { |
---|
| 549 | sText.Append(_T("\r\n")); |
---|
| 550 | sText.Append(_T("VIDEOINFOHEADER:\r\n")); |
---|
| 551 | const CVideoInfoHeader* pVideoInfoHeader = pMediaType.GetVideoInfoHeader(); |
---|
| 552 | sText.AppendFormat(_T(" rcSource: %d, %d - %d, %d\r\n"), pVideoInfoHeader->rcSource); |
---|
| 553 | sText.AppendFormat(_T(" rcTarget: %d, %d - %d, %d\r\n"), pVideoInfoHeader->rcTarget); |
---|
| 554 | sText.AppendFormat(_T(" dwBitRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader->dwBitRate)); |
---|
| 555 | sText.AppendFormat(_T(" dwBitErrorRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader->dwBitErrorRate)); |
---|
| 556 | sText.AppendFormat(_T(" AvgTimePerFrame: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader->AvgTimePerFrame)); |
---|
| 557 | sText.Append(_T("\r\n")); |
---|
| 558 | sText.Append(_T("BITMAPINFOHEADER:\r\n")); |
---|
| 559 | const CBitmapInfoHeader* pBitmapInfoHeader = &pVideoInfoHeader->GetBitmapInfoHeader(); |
---|
| 560 | sText.AppendFormat(_T(" biSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSize)); |
---|
| 561 | sText.AppendFormat(_T(" biWidth: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biWidth)); |
---|
| 562 | sText.AppendFormat(_T(" biHeight: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biHeight)); |
---|
| 563 | sText.AppendFormat(_T(" biPlanes: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biPlanes)); |
---|
| 564 | sText.AppendFormat(_T(" biBitCount: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biBitCount)); |
---|
| 565 | sText.AppendFormat(_T(" biCompression: %s\r\n"), StringFromFourCharacterCode(pBitmapInfoHeader->biCompression)); |
---|
| 566 | sText.AppendFormat(_T(" biSizeImage: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSizeImage)); |
---|
| 567 | //biXPelsPerMeter; |
---|
| 568 | //biYPelsPerMeter; |
---|
| 569 | //biClrUsed; |
---|
| 570 | //biClrImportant; |
---|
[186] | 571 | sText.Append(_T("\r\n")); |
---|
| 572 | |
---|
[66] | 573 | } else |
---|
[186] | 574 | #pragma endregion |
---|
| 575 | #pragma region FORMAT_VideoInfo2 |
---|
[66] | 576 | if(pMediaType->formattype == FORMAT_VideoInfo2) |
---|
| 577 | { |
---|
| 578 | sText.Append(_T("\r\n")); |
---|
| 579 | sText.Append(_T("VIDEOINFOHEADER2:\r\n")); |
---|
| 580 | const CVideoInfoHeader2* pVideoInfoHeader2 = pMediaType.GetVideoInfoHeader2(); |
---|
| 581 | sText.AppendFormat(_T(" rcSource: %d, %d - %d, %d\r\n"), pVideoInfoHeader2->rcSource); |
---|
| 582 | sText.AppendFormat(_T(" rcTarget: %d, %d - %d, %d\r\n"), pVideoInfoHeader2->rcTarget); |
---|
| 583 | sText.AppendFormat(_T(" dwBitRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwBitRate)); |
---|
| 584 | sText.AppendFormat(_T(" dwBitErrorRate: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwBitErrorRate)); |
---|
| 585 | sText.AppendFormat(_T(" AvgTimePerFrame: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->AvgTimePerFrame)); |
---|
| 586 | sText.AppendFormat(_T(" dwInterlaceFlags: 0x%x\r\n"), pVideoInfoHeader2->dwInterlaceFlags); |
---|
| 587 | sText.AppendFormat(_T(" dwCopyProtectFlags: 0x%x\r\n"), pVideoInfoHeader2->dwCopyProtectFlags); |
---|
| 588 | if(pVideoInfoHeader2->dwPictAspectRatioX || pVideoInfoHeader2->dwPictAspectRatioY) |
---|
| 589 | { |
---|
| 590 | sText.AppendFormat(_T(" dwPictAspectRatioX: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwPictAspectRatioX)); |
---|
| 591 | sText.AppendFormat(_T(" dwPictAspectRatioY: %s\r\n"), _StringHelper::FormatNumber((LONG) pVideoInfoHeader2->dwPictAspectRatioY)); |
---|
| 592 | } |
---|
| 593 | sText.AppendFormat(_T(" dwControlFlags: 0x%x\r\n"), pVideoInfoHeader2->dwControlFlags); |
---|
| 594 | sText.Append(_T("\r\n")); |
---|
| 595 | sText.Append(_T("BITMAPINFOHEADER:\r\n")); |
---|
| 596 | const CBitmapInfoHeader* pBitmapInfoHeader = &pVideoInfoHeader2->GetBitmapInfoHeader(); |
---|
| 597 | sText.AppendFormat(_T(" biSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSize)); |
---|
| 598 | sText.AppendFormat(_T(" biWidth: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biWidth)); |
---|
| 599 | sText.AppendFormat(_T(" biHeight: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biHeight)); |
---|
| 600 | sText.AppendFormat(_T(" biPlanes: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biPlanes)); |
---|
| 601 | sText.AppendFormat(_T(" biBitCount: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biBitCount)); |
---|
| 602 | sText.AppendFormat(_T(" biCompression: %s\r\n"), StringFromFourCharacterCode(pBitmapInfoHeader->biCompression)); |
---|
| 603 | sText.AppendFormat(_T(" biSizeImage: %s\r\n"), _StringHelper::FormatNumber((LONG) pBitmapInfoHeader->biSizeImage)); |
---|
| 604 | //biXPelsPerMeter; |
---|
| 605 | //biYPelsPerMeter; |
---|
| 606 | //biClrUsed; |
---|
| 607 | //biClrImportant; |
---|
| 608 | } else |
---|
[186] | 609 | #pragma endregion |
---|
| 610 | #pragma region FORMAT_WaveFormatEx |
---|
[66] | 611 | if(pMediaType->formattype == FORMAT_WaveFormatEx) |
---|
| 612 | { |
---|
| 613 | sText.Append(_T("\r\n")); |
---|
| 614 | sText.Append(_T("WAVEFORMATEX:\r\n")); |
---|
| 615 | const CWaveFormatEx* pWaveFormatEx = pMediaType.GetWaveFormatEx(); |
---|
| 616 | sText.AppendFormat(_T(" wFormatTag: 0x%04x\r\n"), pWaveFormatEx->wFormatTag); |
---|
| 617 | sText.AppendFormat(_T(" nChannels: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nChannels)); |
---|
| 618 | sText.AppendFormat(_T(" nSamplesPerSec: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nSamplesPerSec)); |
---|
| 619 | sText.AppendFormat(_T(" nAvgBytesPerSec: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nAvgBytesPerSec)); |
---|
| 620 | sText.AppendFormat(_T(" nBlockAlign: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->nBlockAlign)); |
---|
| 621 | sText.AppendFormat(_T(" wBitsPerSample: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->wBitsPerSample)); |
---|
| 622 | sText.AppendFormat(_T(" cbSize: %s\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatEx->cbSize)); |
---|
| 623 | if(pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE && sizeof *pWaveFormatEx + pWaveFormatEx->cbSize >= sizeof (WAVEFORMATEXTENSIBLE)) |
---|
| 624 | { |
---|
| 625 | sText.Append(_T("\r\n")); |
---|
| 626 | sText.Append(_T("WAVEFORMATEXTENSIBLE:\r\n")); |
---|
| 627 | const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) (const WAVEFORMATEX*) pWaveFormatEx; |
---|
| 628 | sText.AppendFormat(_T(" wValidBitsPerSample/wSamplesPerBlock: %d\r\n"), _StringHelper::FormatNumber((LONG) pWaveFormatExtensible->Samples.wValidBitsPerSample)); |
---|
| 629 | sText.AppendFormat(_T(" dwChannelMask: 0x%x\r\n"), pWaveFormatExtensible->dwChannelMask); |
---|
| 630 | sText.AppendFormat(_T(" SubFormat: %ls\r\n"), _PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat)); |
---|
| 631 | } else |
---|
| 632 | if(pWaveFormatEx->cbSize) |
---|
| 633 | sText.AppendFormat(_T(" %s\r\n"), StringFromData((const BYTE*) (pWaveFormatEx + 1), pWaveFormatEx->cbSize)); |
---|
| 634 | } |
---|
[186] | 635 | #pragma endregion |
---|
[66] | 636 | } |
---|
[186] | 637 | #pragma endregion |
---|
| 638 | #pragma region IWMMediaProps |
---|
| 639 | const CComQIPtr<IWMMediaProps> pWmMediaProps = m_pCodecFormatData->m_pWmStreamConfig; |
---|
| 640 | if(pWmMediaProps) |
---|
| 641 | _ATLTRY |
---|
| 642 | { |
---|
| 643 | GUID Type = GUID_NULL; |
---|
| 644 | __C(pWmMediaProps->GetType(&Type)); |
---|
| 645 | sText.Append(_T("IWMMediaProps:\r\n")); |
---|
| 646 | sText.AppendFormat(_T(" ") _T("Type: %ls") _T("\r\n"), _FilterGraphHelper::FormatMajorType(Type)); |
---|
| 647 | sText.Append(_T("\r\n")); |
---|
| 648 | } |
---|
| 649 | _ATLCATCHALL() |
---|
| 650 | { |
---|
| 651 | _Z_EXCEPTION(); |
---|
| 652 | } |
---|
| 653 | #pragma endregion |
---|
| 654 | #pragma region IWMStreamConfig |
---|
| 655 | const CComQIPtr<IWMStreamConfig> pWmStreamConfig = m_pCodecFormatData->m_pWmStreamConfig; |
---|
| 656 | if(pWmStreamConfig) |
---|
| 657 | _ATLTRY |
---|
| 658 | { |
---|
| 659 | GUID StreamType = GUID_NULL; |
---|
| 660 | __C(pWmStreamConfig->GetStreamType(&StreamType)); |
---|
| 661 | WORD nStreamNumber = 0; |
---|
| 662 | __C(pWmStreamConfig->GetStreamNumber(&nStreamNumber)); |
---|
| 663 | WORD nStreamNameLength = 0; |
---|
| 664 | pWmStreamConfig->GetStreamName(NULL, &nStreamNameLength); |
---|
| 665 | CTempBufferT<WCHAR> pszStreamName(nStreamNameLength + 1); |
---|
| 666 | __C(pWmStreamConfig->GetStreamName(pszStreamName, &nStreamNameLength)); |
---|
| 667 | WORD nConnectionNameLength = 0; |
---|
| 668 | pWmStreamConfig->GetConnectionName(NULL, &nConnectionNameLength); |
---|
| 669 | CTempBufferT<WCHAR> pszConnectionName(nConnectionNameLength + 1); |
---|
| 670 | __C(pWmStreamConfig->GetConnectionName(pszConnectionName, &nConnectionNameLength)); |
---|
| 671 | DWORD nBitrate = 0; |
---|
| 672 | __C(pWmStreamConfig->GetBitrate(&nBitrate)); |
---|
| 673 | DWORD nBufferWindow = 0; |
---|
| 674 | __C(pWmStreamConfig->GetBufferWindow(&nBufferWindow)); |
---|
| 675 | sText.Append(_T("IWMStreamConfig:\r\n")); |
---|
| 676 | sText.AppendFormat(_T(" ") _T("StreamType: %ls") _T("\r\n"), _FilterGraphHelper::FormatMajorType(StreamType)); |
---|
| 677 | sText.AppendFormat(_T(" ") _T("StreamNumber: %d") _T("\r\n"), nStreamNumber); |
---|
| 678 | if(wcslen(pszStreamName)) |
---|
| 679 | sText.AppendFormat(_T(" ") _T("StreamName: %ls") _T("\r\n"), (LPCWSTR) pszStreamName); |
---|
| 680 | if(wcslen(pszConnectionName)) |
---|
| 681 | sText.AppendFormat(_T(" ") _T("ConnectionName: %ls") _T("\r\n"), (LPCWSTR) pszConnectionName); |
---|
| 682 | sText.AppendFormat(_T(" ") _T("Bitrate: %d") _T("\r\n"), nBitrate); |
---|
| 683 | sText.AppendFormat(_T(" ") _T("BufferWindow: %d") _T("\r\n"), nBufferWindow); |
---|
| 684 | sText.Append(_T("\r\n")); |
---|
| 685 | } |
---|
| 686 | _ATLCATCHALL() |
---|
| 687 | { |
---|
| 688 | _Z_EXCEPTION(); |
---|
| 689 | } |
---|
| 690 | #pragma endregion |
---|
| 691 | #pragma region IWMStreamConfig2 |
---|
| 692 | const CComQIPtr<IWMStreamConfig2> pWmStreamConfig2 = m_pCodecFormatData->m_pWmStreamConfig; |
---|
| 693 | if(pWmStreamConfig2) |
---|
| 694 | _ATLTRY |
---|
| 695 | { |
---|
| 696 | WMT_TRANSPORT_TYPE TransportType; |
---|
| 697 | __C(pWmStreamConfig2->GetTransportType(&TransportType)); |
---|
| 698 | WORD nDataUnitExtensionCount = 0; |
---|
| 699 | pWmStreamConfig2->GetDataUnitExtensionCount(&nDataUnitExtensionCount); |
---|
| 700 | for(WORD nDataUnitExtensionIndex = 0; nDataUnitExtensionIndex < nDataUnitExtensionCount; nDataUnitExtensionIndex++) |
---|
| 701 | { |
---|
| 702 | GUID Identifier = GUID_NULL; |
---|
| 703 | WORD nSize = 0; |
---|
| 704 | DWORD nInformationSize = 0; |
---|
| 705 | __C(pWmStreamConfig2->GetDataUnitExtension(nDataUnitExtensionIndex, &Identifier, &nSize, NULL, &nInformationSize)); |
---|
| 706 | } |
---|
| 707 | sText.Append(_T("IWMStreamConfig2:\r\n")); |
---|
| 708 | sText.AppendFormat(_T(" ") _T("TransportType: %d") _T("\r\n"), TransportType); |
---|
| 709 | if(nDataUnitExtensionCount) |
---|
| 710 | sText.AppendFormat(_T(" ") _T("DataUnitExtensionCount: %d") _T("\r\n"), nDataUnitExtensionCount); |
---|
| 711 | sText.Append(_T("\r\n")); |
---|
| 712 | } |
---|
| 713 | _ATLCATCHALL() |
---|
| 714 | { |
---|
| 715 | _Z_EXCEPTION(); |
---|
| 716 | } |
---|
| 717 | #pragma endregion |
---|
| 718 | #pragma region IWMStreamConfig3 |
---|
| 719 | const CComQIPtr<IWMStreamConfig3> pWmStreamConfig3 = m_pCodecFormatData->m_pWmStreamConfig; |
---|
| 720 | if(pWmStreamConfig3) |
---|
| 721 | _ATLTRY |
---|
| 722 | { |
---|
| 723 | WORD nLanguageStringLength = 0; |
---|
| 724 | pWmStreamConfig3->GetLanguage(NULL, &nLanguageStringLength); |
---|
| 725 | CTempBufferT<WCHAR> pszLanguageString(nLanguageStringLength + 1); |
---|
| 726 | __C(pWmStreamConfig3->GetLanguage(pszLanguageString, &nLanguageStringLength)); |
---|
| 727 | if(wcslen(pszLanguageString)) |
---|
| 728 | { |
---|
| 729 | sText.Append(_T("IWMStreamConfig3:\r\n")); |
---|
| 730 | if(wcslen(pszLanguageString)) |
---|
| 731 | sText.AppendFormat(_T(" ") _T("Language: %ls") _T("\r\n"), (LPCWSTR) pszLanguageString); |
---|
| 732 | sText.Append(_T("\r\n")); |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | _ATLCATCHALL() |
---|
| 736 | { |
---|
| 737 | _Z_EXCEPTION(); |
---|
| 738 | } |
---|
| 739 | #pragma endregion |
---|
| 740 | #pragma region IWMVideoMediaProps |
---|
| 741 | const CComQIPtr<IWMVideoMediaProps> pWmVideoMediaProps = m_pCodecFormatData->m_pWmStreamConfig; |
---|
| 742 | if(pWmVideoMediaProps) |
---|
| 743 | _ATLTRY |
---|
| 744 | { |
---|
| 745 | LONGLONG nMaximalKeyFrameIntervalTime = 0; |
---|
| 746 | __C(pWmVideoMediaProps->GetMaxKeyFrameSpacing(&nMaximalKeyFrameIntervalTime)); |
---|
| 747 | DWORD nQuality = 0; |
---|
| 748 | __C(pWmVideoMediaProps->GetQuality(&nQuality)); |
---|
| 749 | sText.Append(_T("IWMVideoMediaProps:\r\n")); |
---|
| 750 | sText.AppendFormat(_T(" ") _T("MaxKeyFrameSpacing: %s") _T("\r\n"), _FilterGraphHelper::FormatReferenceTime(nMaximalKeyFrameIntervalTime)); |
---|
| 751 | sText.AppendFormat(_T(" ") _T("Quality: %d") _T("\r\n"), nQuality); |
---|
| 752 | sText.Append(_T("\r\n")); |
---|
| 753 | } |
---|
| 754 | _ATLCATCHALL() |
---|
| 755 | { |
---|
| 756 | _Z_EXCEPTION(); |
---|
| 757 | } |
---|
| 758 | #pragma endregion |
---|
[187] | 759 | #pragma region IWMPropertyVault |
---|
| 760 | const CComQIPtr<IWMPropertyVault> pWmPropertyVault = m_pCodecFormatData->m_pWmStreamConfig; |
---|
| 761 | if(pWmPropertyVault) |
---|
| 762 | _ATLTRY |
---|
| 763 | { |
---|
| 764 | DWORD nPropertyCount = 0; |
---|
| 765 | __C(pWmPropertyVault->GetPropertyCount(&nPropertyCount)); |
---|
| 766 | CRoArrayT<CString> PropertyArray; |
---|
| 767 | for(DWORD nPropertyIndex = 0; nPropertyIndex < nPropertyCount; nPropertyIndex++) |
---|
| 768 | { |
---|
| 769 | DWORD nNameLength = 0; |
---|
| 770 | WMT_ATTR_DATATYPE nType; |
---|
| 771 | DWORD nValueDataSize = 0; |
---|
| 772 | pWmPropertyVault->GetPropertyByIndex(nPropertyIndex, NULL, &nNameLength, &nType, NULL, &nValueDataSize); |
---|
| 773 | CTempBufferT<WCHAR> pszName(nNameLength + 1); |
---|
| 774 | CTempBufferT<BYTE> pnValueData(nValueDataSize + 2); |
---|
| 775 | __C(pWmPropertyVault->GetPropertyByIndex(nPropertyIndex, pszName, &nNameLength, &nType, pnValueData, &nValueDataSize)); |
---|
| 776 | CString sProperty; |
---|
| 777 | BOOL bHandled = FALSE; |
---|
| 778 | switch(nType) |
---|
| 779 | { |
---|
| 780 | case WMT_TYPE_DWORD: |
---|
| 781 | if(nValueDataSize && !(nValueDataSize % sizeof (DWORD))) |
---|
| 782 | { |
---|
| 783 | const DWORD* pnValues = (const DWORD*) (const BYTE*) pnValueData; |
---|
| 784 | const SIZE_T nValueCount = nValueDataSize / sizeof (DWORD); |
---|
| 785 | if(nValueCount == 1) |
---|
| 786 | sProperty = AtlFormatString(_T("%d 0x%02X"), pnValues[0], pnValues[0]); |
---|
| 787 | else |
---|
| 788 | sProperty = AtlFormatString(_T("0x%02X, ..."), pnValues[0]); |
---|
| 789 | bHandled = TRUE; |
---|
| 790 | } |
---|
| 791 | break; |
---|
| 792 | case WMT_TYPE_STRING: |
---|
| 793 | // TODO: ... |
---|
| 794 | break; |
---|
| 795 | case WMT_TYPE_BINARY: |
---|
| 796 | // TODO: ... |
---|
| 797 | break; |
---|
| 798 | case WMT_TYPE_BOOL: |
---|
| 799 | if(nValueDataSize && !(nValueDataSize % sizeof (BOOL))) |
---|
| 800 | { |
---|
| 801 | const BOOL* pnValues = (const BOOL*) (const BYTE*) pnValueData; |
---|
| 802 | const SIZE_T nValueCount = nValueDataSize / sizeof (BOOL); |
---|
| 803 | if(nValueCount == 1) |
---|
| 804 | sProperty = AtlFormatString(_T("%d"), pnValues[0]); |
---|
| 805 | else |
---|
| 806 | sProperty = AtlFormatString(_T("%d, ..."), pnValues[0]); |
---|
| 807 | bHandled = TRUE; |
---|
| 808 | } |
---|
| 809 | break; |
---|
| 810 | case WMT_TYPE_QWORD: |
---|
| 811 | // TODO: ... |
---|
| 812 | break; |
---|
| 813 | case WMT_TYPE_WORD: |
---|
| 814 | // TODO: ... |
---|
| 815 | break; |
---|
| 816 | case WMT_TYPE_GUID: |
---|
| 817 | // TODO: ... |
---|
| 818 | break; |
---|
| 819 | } |
---|
| 820 | if(!bHandled) |
---|
| 821 | sProperty = _T("???"); |
---|
| 822 | sProperty += AtlFormatString(_T(" (Type %d, Size %d)"), nType, nValueDataSize); |
---|
| 823 | _W(PropertyArray.Add(AtlFormatString(_T("%ls: %s"), (LPCWSTR) pszName, sProperty)) >= 0); |
---|
| 824 | } |
---|
| 825 | if(nPropertyCount) |
---|
| 826 | { |
---|
| 827 | sText.Append(_T("IWMPropertyVault:\r\n")); |
---|
| 828 | sText.AppendFormat(_T(" ") _T("PropertyCount: %d") _T("\r\n"), nPropertyCount); |
---|
| 829 | for(SIZE_T nIndex = 0; nIndex < PropertyArray.GetCount(); nIndex++) |
---|
| 830 | sText.AppendFormat(_T(" ") _T("%s") _T("\r\n"), PropertyArray[nIndex]); |
---|
| 831 | sText.Append(_T("\r\n")); |
---|
| 832 | } |
---|
| 833 | } |
---|
| 834 | _ATLCATCHALL() |
---|
| 835 | { |
---|
| 836 | _Z_EXCEPTION(); |
---|
| 837 | } |
---|
| 838 | #pragma endregion |
---|
[66] | 839 | } |
---|
| 840 | sText.Trim(_T("\t\n\r .")); |
---|
| 841 | return sText; |
---|
| 842 | } |
---|
| 843 | }; |
---|
| 844 | |
---|
| 845 | private: |
---|
| 846 | CComPtr<IWMProfileManager> m_pWmProfileManager; |
---|
| 847 | CAtlList<CCodecDataList> m_VideoCodecDataListList; |
---|
| 848 | CAtlList<CCodecDataList> m_AudioCodecDataListList; |
---|
| 849 | CRoTreeViewT<CTreeViewItem, CRoListControlDataTraitsT> m_TreeView; |
---|
| 850 | CRoListViewT<CListViewItem, CRoListControlDataTraitsT> m_ListView; |
---|
| 851 | CRoHyperStatic m_OsVersionStatic; |
---|
| 852 | |
---|
| 853 | static CString StringFromData(const BYTE* pnData, SIZE_T nDataSize) |
---|
| 854 | { |
---|
| 855 | CString sString; |
---|
| 856 | for(SIZE_T nIndex = 0; nIndex < nDataSize; nIndex++) |
---|
| 857 | sString.AppendFormat(_T("%02X "), pnData[nIndex]); |
---|
| 858 | sString.TrimRight(); |
---|
| 859 | return sString; |
---|
| 860 | } |
---|
| 861 | static CString StringFromFourCharacterCode(DWORD nCode) |
---|
| 862 | { |
---|
| 863 | BOOL bValid = TRUE; |
---|
| 864 | CHAR pszString[5]; |
---|
| 865 | for(UINT nIndex = 0; bValid && nIndex < 4; nIndex++) |
---|
| 866 | { |
---|
| 867 | pszString[nIndex] = (nCode >> (8 * nIndex)) & 0xFF; |
---|
| 868 | bValid &= pszString[nIndex] >= 0x20; |
---|
| 869 | } |
---|
| 870 | pszString[4] = 0; |
---|
| 871 | if(bValid) |
---|
| 872 | return AtlFormatString(_T("%hs (0x%08x)"), pszString, nCode); |
---|
| 873 | return AtlFormatString(_T("0x%08x"), nCode); |
---|
| 874 | } |
---|
| 875 | VOID InsertVideoListViewItem(const CCodecFormatData& CodecFormatData) |
---|
| 876 | { |
---|
| 877 | const INT nItem = m_ListView.InsertItem(m_ListView.GetItemCount(), CListViewItem(&CodecFormatData), CodecFormatData.GetDescription()); |
---|
| 878 | if(CodecFormatData.m_pMediaType->formattype == FORMAT_VideoInfo) |
---|
| 879 | { |
---|
| 880 | _A(CodecFormatData.m_pMediaType->cbFormat >= sizeof (VIDEOINFOHEADER)); |
---|
| 881 | const CVideoInfoHeader* pVideoInfoHeader = CodecFormatData.m_pMediaType.GetVideoInfoHeader(); |
---|
| 882 | _W(m_ListView.SetItemText(nItem, 1, StringFromFourCharacterCode(pVideoInfoHeader->GetBitmapInfoHeader().biCompression))); |
---|
| 883 | } else |
---|
| 884 | if(CodecFormatData.m_pMediaType->formattype == FORMAT_VideoInfo2) |
---|
| 885 | { |
---|
| 886 | _A(CodecFormatData.m_pMediaType->cbFormat >= sizeof (VIDEOINFOHEADER2)); |
---|
| 887 | const CVideoInfoHeader2* pVideoInfoHeader = CodecFormatData.m_pMediaType.GetVideoInfoHeader2(); |
---|
| 888 | _W(m_ListView.SetItemText(nItem, 1, StringFromFourCharacterCode(pVideoInfoHeader->GetBitmapInfoHeader().biCompression))); |
---|
| 889 | } |
---|
| 890 | } |
---|
| 891 | VOID InsertAudioListViewItem(const CCodecFormatData& CodecFormatData) |
---|
| 892 | { |
---|
| 893 | const INT nItem = m_ListView.InsertItem(m_ListView.GetItemCount(), CListViewItem(&CodecFormatData), CodecFormatData.GetDescription()); |
---|
| 894 | if(CodecFormatData.m_pMediaType->formattype == FORMAT_WaveFormatEx) |
---|
| 895 | { |
---|
| 896 | _A(CodecFormatData.m_pMediaType->cbFormat >= sizeof (WAVEFORMATEX)); |
---|
| 897 | const CWaveFormatEx* pWaveFormatEx = CodecFormatData.m_pMediaType.GetWaveFormatEx(); |
---|
| 898 | _W(m_ListView.SetItemText(nItem, 1, _StringHelper::FormatNumber((LONG) CodecFormatData.m_pMediaType->bFixedSizeSamples))); |
---|
| 899 | _W(m_ListView.SetItemText(nItem, 2, _StringHelper::FormatNumber((LONG) CodecFormatData.m_pMediaType->bTemporalCompression))); |
---|
| 900 | _W(m_ListView.SetItemText(nItem, 3, _StringHelper::FormatNumber((LONG) CodecFormatData.m_pMediaType->lSampleSize))); |
---|
| 901 | _W(m_ListView.SetItemText(nItem, 4, AtlFormatString(_T("0x%02x"), pWaveFormatEx->wFormatTag))); |
---|
| 902 | _W(m_ListView.SetItemText(nItem, 5, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nChannels))); |
---|
| 903 | _W(m_ListView.SetItemText(nItem, 6, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nSamplesPerSec))); |
---|
| 904 | _W(m_ListView.SetItemText(nItem, 7, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nAvgBytesPerSec))); |
---|
| 905 | _W(m_ListView.SetItemText(nItem, 8, _StringHelper::FormatNumber((LONG) pWaveFormatEx->nBlockAlign))); |
---|
| 906 | _W(m_ListView.SetItemText(nItem, 9, _StringHelper::FormatNumber((LONG) pWaveFormatEx->wBitsPerSample))); |
---|
| 907 | _W(m_ListView.SetItemText(nItem, 10, _StringHelper::FormatNumber((LONG) pWaveFormatEx->cbSize))); |
---|
| 908 | _W(m_ListView.SetItemText(nItem, 11, StringFromData((const BYTE*) (pWaveFormatEx + 1), pWaveFormatEx->cbSize))); |
---|
| 909 | } |
---|
| 910 | } |
---|
| 911 | VOID UpdateListView() |
---|
| 912 | { |
---|
| 913 | CWindowRedraw ListViewRedraw(m_ListView); |
---|
| 914 | m_ListView.DeleteAllItems(); |
---|
| 915 | while(m_ListView.DeleteColumn(0)) |
---|
| 916 | ; |
---|
| 917 | HTREEITEM hTreeItem = m_TreeView.GetSelectedItem(); |
---|
| 918 | if(!hTreeItem) |
---|
| 919 | return; |
---|
| 920 | CTreeViewItem& TreeViewItem = m_TreeView.GetItemData(hTreeItem); |
---|
| 921 | // SUGG: List all codecs/formats in absense of .m_pCodecData |
---|
| 922 | if(TreeViewItem.m_pCodecData) |
---|
| 923 | { |
---|
| 924 | if(TreeViewItem.m_MajorType == WMMEDIATYPE_Video) |
---|
| 925 | { |
---|
| 926 | _W(m_ListView.InsertColumn(0, _T("Description"), LVCFMT_LEFT, 180) >= 0); |
---|
| 927 | _W(m_ListView.InsertColumn(1, _T("biCompression"), LVCFMT_LEFT, 120) >= 0); |
---|
| 928 | const CCodecFormatDataList& CodecFormatDataList = TreeViewItem.m_pCodecData->m_CodecFormatDataList; |
---|
| 929 | for(POSITION Position = CodecFormatDataList.GetHeadPosition(); Position; CodecFormatDataList.GetNext(Position)) |
---|
| 930 | InsertVideoListViewItem(CodecFormatDataList.GetAt(Position)); |
---|
| 931 | } |
---|
| 932 | if(TreeViewItem.m_MajorType == WMMEDIATYPE_Audio) |
---|
| 933 | { |
---|
| 934 | _W(m_ListView.InsertColumn(0, _T("Description"), LVCFMT_LEFT, 210) >= 0); |
---|
| 935 | _W(m_ListView.InsertColumn(1, _T("bFixedSizeSamples"), LVCFMT_RIGHT, 60) >= 0); |
---|
| 936 | _W(m_ListView.InsertColumn(2, _T("bTemporalCompression"), LVCFMT_RIGHT, 60) >= 0); |
---|
| 937 | _W(m_ListView.InsertColumn(3, _T("lSampleSize"), LVCFMT_RIGHT, 60) >= 0); |
---|
| 938 | _W(m_ListView.InsertColumn(4, _T("wFormatTag"), LVCFMT_RIGHT, 90) >= 0); |
---|
| 939 | _W(m_ListView.InsertColumn(5, _T("nChannels"), LVCFMT_RIGHT, 60) >= 0); |
---|
| 940 | _W(m_ListView.InsertColumn(6, _T("nSamplesPerSec"), LVCFMT_RIGHT, 90) >= 0); |
---|
| 941 | _W(m_ListView.InsertColumn(7, _T("nAvgBytesPerSec"), LVCFMT_RIGHT, 90) >= 0); |
---|
| 942 | _W(m_ListView.InsertColumn(8, _T("nBlockAlign"), LVCFMT_RIGHT, 60) >= 0); |
---|
| 943 | _W(m_ListView.InsertColumn(9, _T("wBitsPerSample"), LVCFMT_RIGHT, 60) >= 0); |
---|
| 944 | _W(m_ListView.InsertColumn(10, _T("cbSize"), LVCFMT_RIGHT, 60) >= 0); |
---|
| 945 | _W(m_ListView.InsertColumn(11, _T("Extra Data"), LVCFMT_LEFT, 120) >= 0); |
---|
| 946 | const CCodecFormatDataList& CodecFormatDataList = TreeViewItem.m_pCodecData->m_CodecFormatDataList; |
---|
| 947 | for(POSITION Position = CodecFormatDataList.GetHeadPosition(); Position; CodecFormatDataList.GetNext(Position)) |
---|
| 948 | InsertAudioListViewItem(CodecFormatDataList.GetAt(Position)); |
---|
| 949 | // SUGG: List g_wszSpeechCaps proeprty if/where available |
---|
| 950 | } |
---|
| 951 | } |
---|
| 952 | } |
---|
| 953 | CString GetSubmissionText() const |
---|
| 954 | { |
---|
| 955 | CString sText; |
---|
| 956 | #pragma region OS Version |
---|
| 957 | { |
---|
| 958 | OSVERSIONINFOEX VersionInformation = { sizeof VersionInformation }; |
---|
| 959 | _W(GetVersionEx((OSVERSIONINFO*) &VersionInformation)); |
---|
| 960 | CAtlArray<CString> Array; |
---|
| 961 | _W(Array.Add(_T("OS Version")) >= 0); |
---|
| 962 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwMajorVersion)) >= 0); |
---|
| 963 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwMinorVersion)) >= 0); |
---|
| 964 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwBuildNumber)) >= 0); |
---|
| 965 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.dwPlatformId)) >= 0); |
---|
| 966 | _W(Array.Add(VersionInformation.szCSDVersion) >= 0); |
---|
| 967 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wServicePackMajor)) >= 0); |
---|
| 968 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wServicePackMinor)) >= 0); |
---|
| 969 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wSuiteMask)) >= 0); |
---|
| 970 | _W(Array.Add(AtlFormatString(_T("%d"), VersionInformation.wProductType)) >= 0); |
---|
| 971 | #if defined(_WIN64) |
---|
| 972 | _W(Array.Add(_T("x64")) >= 0); |
---|
| 973 | #else |
---|
| 974 | _W(Array.Add(_T("Win32")) >= 0); |
---|
| 975 | #endif // defined(_WIN64) |
---|
| 976 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
| 977 | sText.Append(_T("\r\n")); |
---|
| 978 | } |
---|
| 979 | #pragma endregion |
---|
| 980 | #pragma region Windows Media Version |
---|
| 981 | { |
---|
| 982 | CAtlArray<CString> Array; |
---|
| 983 | _W(Array.Add(_T("WMV Core Version")) >= 0); |
---|
| 984 | _W(Array.Add(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_T("wmvcore.dll")))) >= 0); |
---|
| 985 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
| 986 | sText.Append(_T("\r\n")); |
---|
| 987 | } |
---|
| 988 | #pragma endregion |
---|
| 989 | #pragma region Codecs |
---|
| 990 | const CAtlList<CCodecDataList>* ppCodecDataListLists[] = { &m_VideoCodecDataListList, &m_AudioCodecDataListList }; |
---|
| 991 | for(SIZE_T nCodecDataListListIndex = 0; nCodecDataListListIndex < DIM(ppCodecDataListLists); nCodecDataListListIndex++) |
---|
| 992 | { |
---|
| 993 | const CAtlList<CCodecDataList>& CodecDataListList = *ppCodecDataListLists[nCodecDataListListIndex]; |
---|
| 994 | for(POSITION CodecDataListListPosition = CodecDataListList.GetHeadPosition(); CodecDataListListPosition; CodecDataListList.GetNext(CodecDataListListPosition)) |
---|
| 995 | { |
---|
| 996 | const CCodecDataList& CodecDataList = CodecDataListList.GetAt(CodecDataListListPosition); |
---|
| 997 | { |
---|
| 998 | CAtlArray<CString> Array; |
---|
| 999 | _W(Array.Add(_T("Codec Enumeration")) >= 0); |
---|
| 1000 | _W(Array.Add(AtlFormatString(_T("%ls"), _PersistHelper::StringFromIdentifier(CodecDataList.m_MajorType))) >= 0); |
---|
| 1001 | _W(Array.Add(AtlFormatString(_T("%s"), CodecDataList.m_EnumerationSettingList.m_sName)) >= 0); |
---|
| 1002 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
| 1003 | sText.Append(_T("\r\n")); |
---|
| 1004 | for(POSITION EnumerationSettingPosition = CodecDataList.m_EnumerationSettingList.GetHeadPosition(); EnumerationSettingPosition; CodecDataList.m_EnumerationSettingList.GetNext(EnumerationSettingPosition)) |
---|
| 1005 | { |
---|
| 1006 | const CEnumerationSetting& EnumerationSetting = CodecDataList.m_EnumerationSettingList.GetAt(EnumerationSettingPosition); |
---|
| 1007 | CAtlArray<CString> Array; |
---|
| 1008 | _W(Array.Add(_T("Codec Enumeration Setting")) >= 0); |
---|
| 1009 | _W(Array.Add(AtlFormatString(_T("%ls"), EnumerationSetting.m_sName)) >= 0); |
---|
| 1010 | _W(Array.Add(AtlFormatString(_T("%s"), EnumerationSetting.GetValueString())) >= 0); |
---|
| 1011 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
| 1012 | sText.Append(_T("\r\n")); |
---|
| 1013 | } |
---|
| 1014 | } |
---|
| 1015 | for(POSITION CodecDataListPosition = CodecDataList.GetHeadPosition(); CodecDataListPosition; CodecDataList.GetNext(CodecDataListPosition)) |
---|
| 1016 | { |
---|
| 1017 | const CCodecData& CodecData = CodecDataList.GetAt(CodecDataListPosition); |
---|
| 1018 | CAtlArray<CString> Array; |
---|
| 1019 | _W(Array.Add(_T("Codec")) >= 0); |
---|
| 1020 | _W(Array.Add(AtlFormatString(_T("%ls"), _PersistHelper::StringFromIdentifier(CodecData.m_MajorType))) >= 0); |
---|
| 1021 | _W(Array.Add(AtlFormatString(_T("%d"), CodecData.m_nIndex)) >= 0); |
---|
| 1022 | _W(Array.Add(AtlFormatString(_T("%ls"), CodecData.m_sName)) >= 0); |
---|
| 1023 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
| 1024 | sText.Append(_T("\r\n")); |
---|
| 1025 | const CCodecFormatDataList& CodecFormatDataList = CodecData.m_CodecFormatDataList; |
---|
| 1026 | for(POSITION CodecFormatDataListPosition = CodecFormatDataList.GetHeadPosition(); CodecFormatDataListPosition; CodecFormatDataList.GetNext(CodecFormatDataListPosition)) |
---|
| 1027 | { |
---|
| 1028 | const CCodecFormatData& CodecFormatData = CodecFormatDataList.GetAt(CodecFormatDataListPosition); |
---|
| 1029 | CAtlArray<CString> Array; |
---|
| 1030 | _W(Array.Add(_T("Codec Format")) >= 0); |
---|
| 1031 | _W(Array.Add(AtlFormatString(_T("%d"), CodecFormatData.m_nIndex)) >= 0); |
---|
| 1032 | _W(Array.Add(AtlFormatString(_T("%ls"), CodecFormatData.m_sDescription)) >= 0); |
---|
| 1033 | // TODO: Human friendly media type |
---|
| 1034 | _A(CodecFormatData.m_pMediaType); |
---|
| 1035 | _W(Array.Add(StringFromData((const BYTE*) (const AM_MEDIA_TYPE*) CodecFormatData.m_pMediaType, sizeof (AM_MEDIA_TYPE))) >= 0); |
---|
| 1036 | _W(Array.Add(StringFromData(CodecFormatData.m_pMediaType->pbFormat, CodecFormatData.m_pMediaType->cbFormat)) >= 0); |
---|
| 1037 | sText.Append(_StringHelper::GetCommaSeparatedValue(Array)); |
---|
| 1038 | sText.Append(_T("\r\n")); |
---|
| 1039 | } |
---|
| 1040 | } |
---|
| 1041 | } |
---|
| 1042 | } |
---|
| 1043 | #pragma endregion |
---|
| 1044 | return sText; |
---|
| 1045 | } |
---|
| 1046 | |
---|
| 1047 | public: |
---|
| 1048 | // CMainDialog |
---|
| 1049 | CMainDialog() throw() |
---|
| 1050 | { |
---|
| 1051 | } |
---|
| 1052 | |
---|
| 1053 | // Window message handlers |
---|
| 1054 | LRESULT OnInitDialog(HWND, LPARAM) |
---|
| 1055 | { |
---|
| 1056 | DlgResize_Init(); |
---|
| 1057 | SetIcon(AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), FALSE); |
---|
| 1058 | SetIcon(AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE); |
---|
| 1059 | #if defined(_WIN64) |
---|
| 1060 | CString sCaption; |
---|
| 1061 | GetWindowText(sCaption); |
---|
| 1062 | sCaption += _T(" (x64)"); |
---|
| 1063 | SetWindowText(sCaption); |
---|
| 1064 | #endif // defined(_WIN64) |
---|
| 1065 | { |
---|
| 1066 | CWaitCursor WaitCursor; |
---|
| 1067 | CComPtr<IWMProfileManager> pWmProfileManager; |
---|
| 1068 | __C(WMCreateProfileManager(&pWmProfileManager)); |
---|
| 1069 | CComQIPtr<IWMProfileManager2> pWmProfileManager2 = pWmProfileManager; |
---|
| 1070 | if(pWmProfileManager2) |
---|
| 1071 | _V(pWmProfileManager2->SetSystemProfileVersion(WMT_VER_9_0)); |
---|
| 1072 | m_pWmProfileManager = pWmProfileManager; |
---|
| 1073 | CComQIPtr<IWMCodecInfo2> pWmCodecInfo2 = pWmProfileManager; |
---|
| 1074 | __D(pWmCodecInfo2, E_NOINTERFACE); |
---|
| 1075 | CWmCodecInfo3 pWmCodecInfo3 = pWmCodecInfo2; |
---|
| 1076 | // Video |
---|
| 1077 | CCodecDataList& VideoCodecDataList = m_VideoCodecDataListList.GetAt(m_VideoCodecDataListList.AddTail()); |
---|
| 1078 | VideoCodecDataList.Initialize(pWmCodecInfo2, WMMEDIATYPE_Video); |
---|
| 1079 | //if(pWmCodecInfo3) |
---|
| 1080 | // _ATLTRY |
---|
| 1081 | // { |
---|
| 1082 | // for(UINT nVbrMode = 0; nVbrMode <= 1; nVbrMode++) |
---|
| 1083 | // for(UINT nPassCount = 1; nPassCount <= 2; nPassCount++) |
---|
| 1084 | // { |
---|
| 1085 | // CEnumerationSettingList EnumerationSettingList; |
---|
| 1086 | // _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszVBREnabled, (BOOL) (nVbrMode != 0)))); |
---|
| 1087 | // _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszNumPasses, (DWORD) nPassCount))); |
---|
| 1088 | // EnumerationSettingList.m_sName = AtlFormatString(_T("%s, %d passes"), nVbrMode ? _T("VBR") : _T("CBR"), nPassCount); |
---|
| 1089 | // CCodecDataList& VideoCodecDataList = m_VideoCodecDataListList.GetAt(m_VideoCodecDataListList.AddTail()); |
---|
| 1090 | // VideoCodecDataList.Initialize(pWmCodecInfo3, WMMEDIATYPE_Video, EnumerationSettingList); |
---|
| 1091 | // } |
---|
| 1092 | // } |
---|
| 1093 | // _ATLCATCHALL() |
---|
| 1094 | // { |
---|
| 1095 | // _Z_EXCEPTION(); |
---|
| 1096 | // } |
---|
| 1097 | // Audio |
---|
| 1098 | CCodecDataList& AudioCodecDataList = m_AudioCodecDataListList.GetAt(m_AudioCodecDataListList.AddTail()); |
---|
| 1099 | AudioCodecDataList.Initialize(pWmCodecInfo2, WMMEDIATYPE_Audio); |
---|
| 1100 | if(pWmCodecInfo3) |
---|
| 1101 | _ATLTRY |
---|
| 1102 | { |
---|
| 1103 | for(UINT nVbrMode = 0; nVbrMode <= 1; nVbrMode++) |
---|
| 1104 | for(UINT nPassCount = 1; nPassCount <= 2; nPassCount++) |
---|
| 1105 | { |
---|
| 1106 | CEnumerationSettingList EnumerationSettingList; |
---|
| 1107 | _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszVBREnabled, (BOOL) (nVbrMode != 0)))); |
---|
| 1108 | _W(EnumerationSettingList.AddTail(CEnumerationSetting(g_wszNumPasses, (DWORD) nPassCount))); |
---|
| 1109 | EnumerationSettingList.m_sName = AtlFormatString(_T("%s, %d passes"), nVbrMode ? _T("VBR") : _T("CBR"), nPassCount); |
---|
| 1110 | CCodecDataList& AudioCodecDataList = m_AudioCodecDataListList.GetAt(m_AudioCodecDataListList.AddTail()); |
---|
| 1111 | AudioCodecDataList.Initialize(pWmCodecInfo3, WMMEDIATYPE_Audio, EnumerationSettingList); |
---|
| 1112 | } |
---|
| 1113 | } |
---|
| 1114 | _ATLCATCHALL() |
---|
| 1115 | { |
---|
| 1116 | _Z_EXCEPTION(); |
---|
| 1117 | } |
---|
| 1118 | } |
---|
| 1119 | m_TreeView = GetDlgItem(IDC_TREE); |
---|
| 1120 | HTREEITEM hVideoItem = m_TreeView.InsertItem(NULL, NULL, CTreeViewItem(WMMEDIATYPE_Video), _T("Video")); |
---|
| 1121 | HTREEITEM hPreviousVideoCodecListItem = NULL; |
---|
| 1122 | for(POSITION ListPosition = m_VideoCodecDataListList.GetHeadPosition(); ListPosition; m_VideoCodecDataListList.GetNext(ListPosition)) |
---|
| 1123 | { |
---|
| 1124 | const CCodecDataList* pCodecDataList = &m_VideoCodecDataListList.GetAt(ListPosition); |
---|
| 1125 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty() && pCodecDataList->IsEmpty()) |
---|
| 1126 | continue; |
---|
| 1127 | HTREEITEM hVideoCodecListItem = m_TreeView.InsertItem(hVideoItem, hPreviousVideoCodecListItem, CTreeViewItem(WMMEDIATYPE_Video, pCodecDataList), pCodecDataList->GetTitle()); |
---|
| 1128 | hPreviousVideoCodecListItem = hVideoCodecListItem; |
---|
| 1129 | HTREEITEM hPreviousVideoCodecItem = NULL; |
---|
| 1130 | for(POSITION Position = pCodecDataList->GetHeadPosition(); Position; pCodecDataList->GetNext(Position)) |
---|
| 1131 | { |
---|
| 1132 | const CCodecData* pCodecData = &pCodecDataList->GetAt(Position); |
---|
| 1133 | HTREEITEM hVideoCodecItem = m_TreeView.InsertItem(hVideoCodecListItem, hPreviousVideoCodecItem, CTreeViewItem(WMMEDIATYPE_Video, pCodecDataList, pCodecData), pCodecData->GetTitle()); |
---|
| 1134 | hPreviousVideoCodecItem = hVideoCodecItem; |
---|
| 1135 | } |
---|
| 1136 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty()) |
---|
| 1137 | m_TreeView.Expand(hVideoCodecListItem); |
---|
| 1138 | } |
---|
| 1139 | m_TreeView.Expand(hVideoItem); |
---|
| 1140 | HTREEITEM hAudioItem = m_TreeView.InsertItem(NULL, NULL, CTreeViewItem(WMMEDIATYPE_Audio), _T("Audio")); |
---|
| 1141 | HTREEITEM hPreviousAudioCodecListItem = NULL; |
---|
| 1142 | for(POSITION ListPosition = m_AudioCodecDataListList.GetHeadPosition(); ListPosition; m_AudioCodecDataListList.GetNext(ListPosition)) |
---|
| 1143 | { |
---|
| 1144 | const CCodecDataList* pCodecDataList = &m_AudioCodecDataListList.GetAt(ListPosition); |
---|
| 1145 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty() && pCodecDataList->IsEmpty()) |
---|
| 1146 | continue; |
---|
| 1147 | HTREEITEM hAudioCodecListItem = m_TreeView.InsertItem(hAudioItem, hPreviousAudioCodecListItem, CTreeViewItem(WMMEDIATYPE_Audio, pCodecDataList), pCodecDataList->GetTitle()); |
---|
| 1148 | hPreviousAudioCodecListItem = hAudioCodecListItem; |
---|
| 1149 | HTREEITEM hPreviousAudioCodecItem = NULL; |
---|
| 1150 | for(POSITION Position = pCodecDataList->GetHeadPosition(); Position; pCodecDataList->GetNext(Position)) |
---|
| 1151 | { |
---|
| 1152 | const CCodecData* pCodecData = &pCodecDataList->GetAt(Position); |
---|
| 1153 | HTREEITEM hAudioCodecItem = m_TreeView.InsertItem(hAudioCodecListItem, hPreviousAudioCodecItem, CTreeViewItem(WMMEDIATYPE_Audio, pCodecDataList, pCodecData), pCodecData->GetTitle()); |
---|
| 1154 | hPreviousAudioCodecItem = hAudioCodecItem; |
---|
| 1155 | } |
---|
| 1156 | if(pCodecDataList->m_EnumerationSettingList.IsEmpty()) |
---|
| 1157 | m_TreeView.Expand(hAudioCodecListItem); |
---|
| 1158 | } |
---|
| 1159 | m_TreeView.Expand(hAudioItem); |
---|
| 1160 | m_ListView = GetDlgItem(IDC_LIST); |
---|
| 1161 | m_ListView.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP); |
---|
| 1162 | CToolTipCtrl ListViewToolTip = m_ListView.GetToolTips(); |
---|
| 1163 | ListViewToolTip.SetDelayTime(TTDT_AUTOMATIC, 2 * 60 * 1000); // 2 minutes |
---|
| 1164 | m_TreeView.SelectItem(m_TreeView.GetNextItem(hAudioItem, TVGN_CHILD)); |
---|
| 1165 | UpdateListView(); |
---|
| 1166 | _W(m_OsVersionStatic.SubclassWindow(GetDlgItem(IDC_OSVERSION))); |
---|
| 1167 | OSVERSIONINFOEX VersionInformation = { sizeof VersionInformation }; |
---|
| 1168 | _W(GetVersionEx((OSVERSIONINFO*) &VersionInformation)); |
---|
| 1169 | m_OsVersionStatic.SetWindowText(AtlFormatString(_T("<A TITLE=\"Version %d.%d, Build %d, %s (%d.%d)\">Win %d.%d.%d</A>"), |
---|
| 1170 | VersionInformation.dwMajorVersion, VersionInformation.dwMinorVersion, VersionInformation.dwBuildNumber, |
---|
| 1171 | VersionInformation.szCSDVersion, VersionInformation.wServicePackMajor, VersionInformation.wServicePackMinor, |
---|
| 1172 | VersionInformation.dwMajorVersion, VersionInformation.dwMinorVersion, VersionInformation.dwBuildNumber)); |
---|
| 1173 | { |
---|
| 1174 | CMenuHandle Menu = GetSystemMenu(FALSE); |
---|
| 1175 | _W(Menu.AppendMenu(MF_SEPARATOR)); |
---|
| 1176 | _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About..."))); |
---|
| 1177 | } |
---|
| 1178 | _W(CenterWindow()); |
---|
| 1179 | return TRUE; |
---|
| 1180 | } |
---|
| 1181 | LRESULT OnSysCommand(UINT nCommand, CPoint) |
---|
| 1182 | { |
---|
| 1183 | switch(nCommand) |
---|
| 1184 | { |
---|
| 1185 | case ID_APP_ABOUT: |
---|
| 1186 | { |
---|
| 1187 | CAboutDialog Dialog; |
---|
| 1188 | Dialog.DoModal(m_hWnd); |
---|
| 1189 | } |
---|
| 1190 | break; |
---|
| 1191 | default: |
---|
| 1192 | SetMsgHandled(FALSE); |
---|
| 1193 | } |
---|
| 1194 | return 0; |
---|
| 1195 | } |
---|
| 1196 | LRESULT OnCancel(UINT, INT nIdentifier, HWND) |
---|
| 1197 | { |
---|
| 1198 | _W(EndDialog(nIdentifier)); |
---|
| 1199 | return 0; |
---|
| 1200 | } |
---|
| 1201 | LRESULT OnTreeGetInfoTip(NMTVGETINFOTIP* pHeader) |
---|
| 1202 | { |
---|
| 1203 | if(pHeader->hItem) |
---|
| 1204 | { |
---|
| 1205 | const CTreeViewItem& TreeViewItem = m_TreeView.DataFromParameter(pHeader->lParam); |
---|
| 1206 | if(TreeViewItem.m_pCodecData) |
---|
| 1207 | { |
---|
| 1208 | CString sText; |
---|
| 1209 | sText.AppendFormat(_T("Title: %s\r\n"), TreeViewItem.m_pCodecData->GetTitle()); |
---|
| 1210 | CWmCodecInfo3 pWmCodecInfo3 = TreeViewItem.m_pCodecData->m_pWmCodecInfo2; |
---|
| 1211 | if(pWmCodecInfo3) |
---|
| 1212 | _ATLTRY |
---|
| 1213 | { |
---|
| 1214 | sText.Append(_T("\r\n")); |
---|
| 1215 | if(TreeViewItem.m_pCodecData->m_MajorType == WMMEDIATYPE_Video) |
---|
| 1216 | { |
---|
| 1217 | DWORD nMaximalComplexity, nOfflineComplexity, nLiveComplexity; |
---|
| 1218 | if(SUCCEEDED(pWmCodecInfo3.GetDwordCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszComplexityMax, nMaximalComplexity))) |
---|
| 1219 | sText.AppendFormat(_T("g_wszComplexityMax: %d\r\n"), nMaximalComplexity); |
---|
| 1220 | if(SUCCEEDED(pWmCodecInfo3.GetDwordCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszComplexityOffline, nOfflineComplexity))) |
---|
| 1221 | sText.AppendFormat(_T("g_wszComplexityOffline: %d\r\n"), nOfflineComplexity); |
---|
| 1222 | if(SUCCEEDED(pWmCodecInfo3.GetDwordCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszComplexityLive, nLiveComplexity))) |
---|
| 1223 | sText.AppendFormat(_T("g_wszComplexityLive: %d\r\n"), nLiveComplexity); |
---|
| 1224 | } |
---|
| 1225 | BOOL bIsVbrSupported; |
---|
| 1226 | if(SUCCEEDED(pWmCodecInfo3.GetBoolCodecProperty(TreeViewItem.m_pCodecData->m_MajorType, TreeViewItem.m_pCodecData->m_nIndex, g_wszIsVBRSupported, bIsVbrSupported))) |
---|
| 1227 | sText.AppendFormat(_T("g_wszIsVBRSupported: %d\r\n"), bIsVbrSupported); |
---|
| 1228 | } |
---|
| 1229 | _ATLCATCH(Exception) |
---|
| 1230 | { |
---|
| 1231 | _Z_ATLEXCEPTION(Exception); |
---|
| 1232 | sText.AppendFormat(_T("Error 0x%08x: %s\r\n"), (HRESULT) Exception, AtlFormatSystemMessage(Exception).TrimRight(_T("\t\n\r ."))); |
---|
| 1233 | } |
---|
| 1234 | _ATLCATCHALL() |
---|
| 1235 | { |
---|
| 1236 | _Z_EXCEPTION(); |
---|
| 1237 | } |
---|
| 1238 | sText.TrimRight(_T("\t\n\r")); |
---|
| 1239 | _tcscpy_s(pHeader->pszText, pHeader->cchTextMax, sText); |
---|
| 1240 | if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0) |
---|
| 1241 | { |
---|
| 1242 | SetClipboardText(m_hWnd, sText); |
---|
| 1243 | MessageBeep(MB_OK); |
---|
| 1244 | } |
---|
| 1245 | } |
---|
| 1246 | } |
---|
| 1247 | return 0; |
---|
| 1248 | } |
---|
| 1249 | LRESULT OnTreeViewSelChanged(NMTREEVIEW*) |
---|
| 1250 | { |
---|
| 1251 | UpdateListView(); |
---|
| 1252 | return 0; |
---|
| 1253 | } |
---|
| 1254 | LRESULT OnListGetInfoTip(NMLVGETINFOTIP* pHeader) |
---|
| 1255 | { |
---|
| 1256 | CListViewItem& ListViewItem = m_ListView.GetItemData(pHeader->iItem); |
---|
| 1257 | const CString sInfoTipText = ListViewItem.GetInfoTipText(); |
---|
| 1258 | _tcscpy_s(pHeader->pszText, pHeader->cchTextMax, sInfoTipText); |
---|
| 1259 | if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0) |
---|
| 1260 | { |
---|
| 1261 | SetClipboardText(m_hWnd, sInfoTipText); |
---|
| 1262 | MessageBeep(MB_OK); |
---|
| 1263 | } |
---|
| 1264 | return 0; |
---|
| 1265 | } |
---|
| 1266 | LRESULT OnCopyButtonClicked(UINT, INT, HWND) |
---|
| 1267 | { |
---|
[186] | 1268 | SetClipboardText(m_hWnd, GetSubmissionText()); |
---|
| 1269 | MessageBeep(MB_OK); |
---|
[66] | 1270 | return 0; |
---|
| 1271 | } |
---|
| 1272 | LRESULT OnSubmitButtonClicked(UINT, INT, HWND) |
---|
| 1273 | { |
---|
| 1274 | CWaitCursor WaitCursor; |
---|
[186] | 1275 | const CString sFileDescription = _VersionInfoHelper::GetString(_VersionInfoHelper::GetModulePath(), _T("FileDescription")); |
---|
[66] | 1276 | CWinHttpPostData PostData; |
---|
[186] | 1277 | PostData.AddValue(_T("subj"), sFileDescription); |
---|
[66] | 1278 | CStringA sTextA = Utf8StringFromString(GetSubmissionText()); |
---|
| 1279 | PostData.AddValue(_T("body"), _Base64Helper::Encode<CString>((const BYTE*) (LPCSTR) sTextA, sTextA.GetLength(), _Base64Helper::FLAG_NOPAD | _Base64Helper::FLAG_NOCRLF)); |
---|
| 1280 | CWinHttpSessionHandle Session = OpenWinHttpSessionHandle(AtlLoadString(IDS_PROJNAME)); |
---|
| 1281 | __E(Session); |
---|
| 1282 | CWinHttpConnectionHandle Connection = Session.Connect(CStringW(_T("alax.info"))); |
---|
| 1283 | __E(Connection); |
---|
| 1284 | CWinHttpRequestHandle Request = Connection.OpenRequest(CStringW(_T("POST")), CStringW(_T("/post.php"))); |
---|
| 1285 | __E(Request); |
---|
| 1286 | CStringW sPostHeaders = PostData.GetHeaders(); |
---|
| 1287 | CStringA sPostData(PostData.GetValue()); |
---|
| 1288 | __E(Request.Send(sPostHeaders, -1, const_cast<LPSTR>((LPCSTR) sPostData), sPostData.GetLength(), sPostData.GetLength())); |
---|
| 1289 | __E(Request.ReceiveResponse()); |
---|
| 1290 | DWORD nStatusCode = 0; |
---|
| 1291 | __E(Request.QueryNumberHeader(WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, nStatusCode)); |
---|
[186] | 1292 | __D(nStatusCode / 100 == HTTP_STATUS_OK / 100, MAKE_HRESULT(SEVERITY_ERROR, FACILITY_HTTP, nStatusCode)); |
---|
[66] | 1293 | AtlMessageBoxEx(m_hWnd, _T("Submission complete, thank you!"), IDS_INFORMATION, MB_ICONINFORMATION | MB_OK); |
---|
| 1294 | return 0; |
---|
| 1295 | } |
---|
| 1296 | }; |
---|