37 | MSG_TVN_SELCHANGED(IDC_TREE, OnTreeViewSelChanged) | 37 | MSG_TVN_SELCHANGED(IDC_TREE, OnTreeViewSelChanged) |
38 | //COMMAND_ID_HANDLER_EX(ID_APP_ABOUT, OnAppAbout) | 38 | //COMMAND_ID_HANDLER_EX(ID_APP_ABOUT, OnAppAbout) |
39 | // SUGG: List view column sort | 39 | // SUGG: List view column sort |
40 | // SUGG: List view info tips | 40 | // SUGG: List view info tips |
46 | DLGRESIZE_CONTROL(IDC_TREE, DLSZ_SIZE_Y) | 47 | DLGRESIZE_CONTROL(IDC_TREE, DLSZ_SIZE_Y) |
47 | DLGRESIZE_CONTROL(IDC_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y) | 48 | DLGRESIZE_CONTROL(IDC_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y) |
48 | DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X) | 49 | DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X) |
115 | _Z4(atlTraceGeneral, 4, _T("nFormatCount %d\n"), nFormatCount); | 119 | _Z4(atlTraceGeneral, 4, _T("nFormatCount %d\n"), nFormatCount); |
116 | for(DWORD nFormatIndex = 0; nFormatIndex < nFormatCount; nFormatIndex++) | 120 | for(DWORD nFormatIndex = 0; nFormatIndex < nFormatCount; nFormatIndex++) |
117 | { | 121 | { |
118 | DWORD nCodecFormatDescriptionLength = 0; | 122 | DWORD nCodecFormatDescriptionLength = 0; |
124 | _Z4(atlTraceGeneral, 4, _T("nFormatIndex %d, sFormatDescription \"%ls\"\n"), nFormatIndex, sFormatDescription); | 128 | _Z4(atlTraceGeneral, 4, _T("nFormatIndex %d, sFormatDescription \"%ls\"\n"), nFormatIndex, sFormatDescription); |
125 | CComQIPtr<IWMMediaProps> pWmMediaProps = pWmStreamConfig; | 129 | CComQIPtr<IWMMediaProps> pWmMediaProps = pWmStreamConfig; |
126 | __D(pWmMediaProps, E_NOINTERFACE); | 130 | __D(pWmMediaProps, E_NOINTERFACE); |
| | 154 | DWORD GetDwordProperty(IWMCodecInfo3* pWmCodecInfo3, LPCWSTR pszName) const |
| | 155 | { |
| | 156 | _A(pWmCodecInfo3 && pszName); |
| | 157 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
| | 158 | DWORD nValue; |
| | 159 | DWORD nValueSize = sizeof nValue; |
| | 160 | __C(pWmCodecInfo3->GetCodecProp(m_MajorType, m_nIndex, pszName, &nType, (BYTE*) &nValue, &nValueSize)); |
| | 161 | __D(nType == WMT_TYPE_DWORD && nValueSize == sizeof nValue, E_UNNAMED); |
| | 162 | return nValue; |
| | 163 | } |
| | 164 | BOOL GetBoolProperty(IWMCodecInfo3* pWmCodecInfo3, LPCWSTR pszName) const |
| | 165 | { |
| | 166 | _A(pWmCodecInfo3 && pszName); |
| | 167 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
| | 168 | BOOL nValue; |
| | 169 | DWORD nValueSize = sizeof nValue; |
| | 170 | __C(pWmCodecInfo3->GetCodecProp(m_MajorType, m_nIndex, pszName, &nType, (BYTE*) &nValue, &nValueSize)); |
| | 171 | __D(nType == WMT_TYPE_BOOL && nValueSize == sizeof nValue, E_UNNAMED); |
| | 172 | return nValue; |
| | 173 | } |
| | 195 | DWORD GetDwordCodecEnumerationSetting(IWMCodecInfo3* pWmCodecInfo3, const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName) const |
| | 196 | { |
| | 197 | _A(pWmCodecInfo3 && pszName); |
| | 198 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
| | 199 | DWORD nValue; |
| | 200 | DWORD nValueSize = sizeof nValue; |
| | 201 | __C(pWmCodecInfo3->GetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, &nType, (BYTE*) &nValue, &nValueSize)); |
| | 202 | __D(nType == WMT_TYPE_DWORD && nValueSize == sizeof nValue, E_UNNAMED); |
| | 203 | return nValue; |
| | 204 | } |
| | 205 | BOOL GetBoolCodecEnumerationSetting(IWMCodecInfo3* pWmCodecInfo3, const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName) const |
| | 206 | { |
| | 207 | _A(pWmCodecInfo3 && pszName); |
| | 208 | WMT_ATTR_DATATYPE nType = (WMT_ATTR_DATATYPE) -1; |
| | 209 | BOOL bValue; |
| | 210 | DWORD nValueSize = sizeof bValue; |
| | 211 | __C(pWmCodecInfo3->GetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, &nType, (BYTE*) &bValue, &nValueSize)); |
| | 212 | __D(nType == WMT_TYPE_BOOL && nValueSize == sizeof bValue, E_UNNAMED); |
| | 213 | return bValue; |
| | 214 | } |
| | 215 | VOID SetDwordCodecEnumerationSetting(IWMCodecInfo3* pWmCodecInfo3, const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, DWORD nValue) const |
| | 216 | { |
| | 217 | _A(pWmCodecInfo3 && pszName); |
| | 218 | __C(pWmCodecInfo3->SetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, WMT_TYPE_DWORD, (const BYTE*) &nValue, sizeof nValue)); |
| | 219 | } |
| | 220 | VOID SetBoolCodecEnumerationSetting(IWMCodecInfo3* pWmCodecInfo3, const GUID& MajorType, DWORD nCodecIndex, LPCWSTR pszName, BOOL nValue) const |
| | 221 | { |
| | 222 | _A(pWmCodecInfo3 && pszName); |
| | 223 | __C(pWmCodecInfo3->SetCodecEnumerationSetting(MajorType, nCodecIndex, pszName, WMT_TYPE_BOOL, (const BYTE*) &nValue, sizeof nValue)); |
| | 224 | } |
| | 246 | if(pWmCodecInfo3) |
| | 247 | _ATLTRY |
| | 248 | { |
| | 249 | const BOOL bDefaultVbrEnabled = GetBoolCodecEnumerationSetting(pWmCodecInfo3, MajorType, nCodecIndex, g_wszVBREnabled); |
| | 250 | const DWORD nDefaultNumPasses = GetDwordCodecEnumerationSetting(pWmCodecInfo3, MajorType, nCodecIndex, g_wszNumPasses); |
| | 251 | _Z4(atlTraceGeneral, 4, _T("bDefaultVbrEnabled %d, nDefaultNumPasses %d\n"), bDefaultVbrEnabled, nDefaultNumPasses); |
| | 252 | // TODO: Enumerate VBR formats |
| | 253 | // SetBoolCodecEnumerationSetting(pWmCodecInfo3, MajorType, nCodecIndex, g_wszVBREnabled, TRUE); |
| | 254 | // SetDwordCodecEnumerationSetting(pWmCodecInfo3, MajorType, nCodecIndex, g_wszNumPasses, 1); |
| | 255 | } |
| | 256 | _ATLCATCHALL() |
| | 257 | { |
| | 258 | _Z_EXCEPTION(); |
| | 259 | } |
| | 468 | LRESULT OnTreeGetInfoTip(NMTVGETINFOTIP* pHeader) |
| | 469 | { |
| | 470 | if(pHeader->hItem) |
| | 471 | { |
| | 472 | const CTreeViewItem& TreeViewItem = m_TreeView.DataFromParameter(pHeader->lParam); |
| | 473 | if(TreeViewItem.m_pCodecData) |
| | 474 | { |
| | 475 | CString sText; |
| | 476 | sText.AppendFormat(_T("Title: %s\r\n"), TreeViewItem.m_pCodecData->GetTitle()); |
| | 477 | CComQIPtr<IWMCodecInfo3> pWmCodecInfo3 = TreeViewItem.m_pCodecData->m_pWmCodecInfo2; |
| | 478 | if(pWmCodecInfo3) |
| | 479 | _ATLTRY |
| | 480 | { |
| | 481 | sText.Append(_T("\r\n")); |
| | 482 | if(TreeViewItem.m_pCodecData->m_MajorType == WMMEDIATYPE_Video) |
| | 483 | { |
| | 484 | sText.AppendFormat(_T("g_wszComplexityMax: %d\r\n"), TreeViewItem.m_pCodecData->GetDwordProperty(pWmCodecInfo3,
g_wszComplexityMax)); |
| | 485 | sText.AppendFormat(_T("g_wszComplexityOffline: %d\r\n"), TreeViewItem.m_pCodecData->GetDwordProperty(pWmCodecInfo3,
g_wszComplexityOffline)); |
| | 486 | sText.AppendFormat(_T("g_wszComplexityLive: %d\r\n"), TreeViewItem.m_pCodecData->GetDwordProperty(pWmCodecInfo3,
g_wszComplexityLive)); |
| | 487 | } |
| | 488 | sText.AppendFormat(_T("g_wszIsVBRSupported: %d\r\n"), TreeViewItem.m_pCodecData->GetBoolProperty(pWmCodecInfo3,
g_wszIsVBRSupported)); |
| | 489 | } |
| | 490 | _ATLCATCH(Exception) |
| | 491 | { |
| | 492 | _Z_ATLEXCEPTION(Exception); |
| | 493 | sText.AppendFormat(_T("Error 0x%08x: %s\r\n"), (HRESULT) Exception,
AtlFormatSystemMessage(Exception).TrimRight(_T("\t\n\r ."))); |
| | 494 | } |
| | 495 | _ATLCATCHALL() |
| | 496 | { |
| | 497 | _Z_EXCEPTION(); |
| | 498 | } |
| | 499 | sText.TrimRight(_T("\t\n\r")); |
| | 500 | _tcscpy_s(pHeader->pszText, pHeader->cchTextMax, sText); |
| | 501 | } |
| | 502 | } |
| | 503 | return 0; |
| | 504 | } |
| | 510 | LRESULT OnCopyButtonClicked(UINT, INT, HWND) |
| | 511 | { |
| | 512 | CStringW sText(GetSubmissionText()); |
| | 513 | __E(OpenClipboard()); |
| | 514 | _ATLTRY |
| | 515 | { |
| | 516 | __E(EmptyClipboard()); |
| | 517 | CGlobalMemoryHandle TextHandle; |
| | 518 | TextHandle.Alloc((sText.GetLength() + 1) * sizeof (WCHAR), GMEM_MOVEABLE | GMEM_SHARE); |
| | 519 | wcscpy_s(CGlobalMemoryHandle::CLockT<WCHAR>(TextHandle), sText.GetLength() + 1, sText); |
| | 520 | __E(SetClipboardData(CF_UNICODETEXT, TextHandle)); |
| | 521 | TextHandle.Detach(); |
| | 522 | MessageBeep(MB_OK); |
| | 523 | } |
| | 524 | _ATLCATCHALL() |
| | 525 | { |
| | 526 | _W(CloseClipboard()); |
| | 527 | _ATLRETHROW; |
| | 528 | } |
| | 529 | _W(CloseClipboard()); |
| | 530 | return 0; |
| | 531 | } |