159160
33
    MSG_WM_INITDIALOG(OnInitDialog)
33
    MSG_WM_INITDIALOG(OnInitDialog)
34
    MSG_WM_SYSCOMMAND(OnSysCommand)
34
    MSG_WM_SYSCOMMAND(OnSysCommand)
35
    COMMAND_ID_HANDLER_EX(IDCANCEL, OnCancel)
35
    COMMAND_ID_HANDLER_EX(IDCANCEL, OnCancel)
36
    // SUGG: Tree view info tips
36
    MSG_TVN_GETINFOTIP(IDC_TREE, OnTreeGetInfoTip)
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
 
 
41
    COMMAND_ID_HANDLER_EX(IDC_COPY, OnCopyButtonClicked)
41
    COMMAND_ID_HANDLER_EX(IDC_SUBMIT, OnSubmitButtonClicked)
42
    COMMAND_ID_HANDLER_EX(IDC_SUBMIT, OnSubmitButtonClicked)
42
    REFLECT_NOTIFICATIONS()
43
    REFLECT_NOTIFICATIONS()
43
END_MSG_MAP()
44
END_MSG_MAP()
...
 
...
 
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)
 
 
50
    DLGRESIZE_CONTROL(IDC_COPY, DLSZ_MOVE_X)
49
    DLGRESIZE_CONTROL(IDC_SUBMIT, DLSZ_MOVE_X)
51
    DLGRESIZE_CONTROL(IDC_SUBMIT, DLSZ_MOVE_X)
50
    DLGRESIZE_CONTROL(IDC_OSVERSION, DLSZ_MOVE_X | DLSZ_MOVE_Y)
52
    DLGRESIZE_CONTROL(IDC_OSVERSION, DLSZ_MOVE_X | DLSZ_MOVE_Y)
51
END_DLGRESIZE_MAP()
53
END_DLGRESIZE_MAP()
...
 
...
 
92
    class CCodecData
94
    class CCodecData
93
    {
95
    {
94
    public:
96
    public:
 
 
97
        CComPtr<IWMCodecInfo2> m_pWmCodecInfo2;
95
        GUID m_MajorType;
98
        GUID m_MajorType;
96
        DWORD m_nCodecIndex;
99
        DWORD m_nIndex;
97
        CStringW m_sCodecName;
100
        CStringW m_sName;
98
        CCodecFormatDataList m_CodecFormatDataList;
101
        CCodecFormatDataList m_CodecFormatDataList;
99
 
102
 
100
    public:
103
    public:
...
 
...
 
103
            m_MajorType(GUID_NULL)
106
            m_MajorType(GUID_NULL)
104
        {
107
        {
105
        }
108
        }
106
        VOID Initialize(IWMCodecInfo2* pWmCodecInfo2, const GUID& MajorType, DWORD nCodecIndex, const CStringW& sCodecName)
109
        VOID Initialize(IWMCodecInfo2* pWmCodecInfo2, const GUID& MajorType, DWORD nIndex, const CStringW& sName)
107
        {
110
        {
108
            _A(pWmCodecInfo2);
111
            _A(pWmCodecInfo2);
 
 
112
            m_pWmCodecInfo2 = pWmCodecInfo2;
109
            m_MajorType = MajorType;
113
            m_MajorType = MajorType;
110
            m_nCodecIndex = nCodecIndex;
114
            m_nIndex = nIndex;
111
            m_sCodecName = sCodecName;
115
            m_sName = sName;
112
            m_CodecFormatDataList.RemoveAll();
116
            m_CodecFormatDataList.RemoveAll();
113
            DWORD nFormatCount = 0;
117
            DWORD nFormatCount = 0;
114
            __C(pWmCodecInfo2->GetCodecFormatCount(MajorType, nCodecIndex, &nFormatCount));
118
            __C(pWmCodecInfo2->GetCodecFormatCount(MajorType, nIndex, &nFormatCount));
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;
119
                __C(pWmCodecInfo2->GetCodecFormatDesc(MajorType, nCodecIndex, nFormatIndex, NULL, NULL, &nCodecFormatDescriptionLength));
123
                __C(pWmCodecInfo2->GetCodecFormatDesc(MajorType, nIndex, nFormatIndex, NULL, NULL, &nCodecFormatDescriptionLength));
120
                _A(nCodecFormatDescriptionLength > 0);
124
                _A(nCodecFormatDescriptionLength > 0);
121
                CComPtr<IWMStreamConfig> pWmStreamConfig;
125
                CComPtr<IWMStreamConfig> pWmStreamConfig;
122
                CStringW sFormatDescription;
126
                CStringW sFormatDescription;
123
                __C(pWmCodecInfo2->GetCodecFormatDesc(MajorType, nCodecIndex, nFormatIndex, &pWmStreamConfig, sFormatDescription.GetBufferSetLength(nCodecFormatDescriptionLength - 1), &nCodecFormatDescriptionLength));
127
                __C(pWmCodecInfo2->GetCodecFormatDesc(MajorType, nIndex, nFormatIndex, &pWmStreamConfig,
sFormatDescription.GetBufferSetLength(nCodecFormatDescriptionLength - 1), &nCodecFormatDescriptionLength));
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);
...
 
...
 
145
        }
149
        }
146
        CString GetTitle() const
150
        CString GetTitle() const
147
        {
151
        {
148
            return CString(m_sCodecName);
152
            return CString(m_sName);
149
        }
153
        }
 
 
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
        }
150
    };
174
    };
151
 
175
 
152
    ////////////////////////////////////////////////////
176
    ////////////////////////////////////////////////////
...
 
...
 
168
        {
192
        {
169
            Initialize(pWmCodecInfo2, MajorType);
193
            Initialize(pWmCodecInfo2, MajorType);
170
        }
194
        }
 
 
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
        }
171
        VOID Initialize(IWMCodecInfo2* pWmCodecInfo2, const GUID& MajorType)
225
        VOID Initialize(IWMCodecInfo2* pWmCodecInfo2, const GUID& MajorType)
172
        {
226
        {
173
            _A(pWmCodecInfo2);
227
            _A(pWmCodecInfo2);
...
 
...
 
174
            RemoveAll();
228
            RemoveAll();
175
            DWORD nCodecCount = 0;
229
            DWORD nCodecCount = 0;
176
            __C(pWmCodecInfo2->GetCodecInfoCount(MajorType, &nCodecCount));
230
            __C(pWmCodecInfo2->GetCodecInfoCount(MajorType, &nCodecCount));
 
 
231
            CComQIPtr<IWMCodecInfo3> pWmCodecInfo3 = pWmCodecInfo2;
177
            for(DWORD nCodecIndex = 0; nCodecIndex < nCodecCount; nCodecIndex++)
232
            for(DWORD nCodecIndex = 0; nCodecIndex < nCodecCount; nCodecIndex++)
178
                _ATLTRY
233
                _ATLTRY
179
                {
234
                {
...
 
...
 
188
                    _ATLTRY
243
                    _ATLTRY
189
                    {
244
                    {
190
                        CCodecData& CodecData = GetAt(Position);
245
                        CCodecData& CodecData = GetAt(Position);
 
 
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
                            }
191
                        CodecData.Initialize(pWmCodecInfo2, MajorType, nCodecIndex, sCodecName);
260
                        CodecData.Initialize(pWmCodecInfo2, MajorType, nCodecIndex, sCodecName);
192
                    }
261
                    }
193
                    _ATLCATCHALL()
262
                    _ATLCATCHALL()
...
 
...
 
306
                const CCodecFormatDataList& CodecFormatDataList = TreeViewItem.m_pCodecData->m_CodecFormatDataList;
375
                const CCodecFormatDataList& CodecFormatDataList = TreeViewItem.m_pCodecData->m_CodecFormatDataList;
307
                for(POSITION Position = CodecFormatDataList.GetHeadPosition(); Position; CodecFormatDataList.GetNext(Position))
376
                for(POSITION Position = CodecFormatDataList.GetHeadPosition(); Position; CodecFormatDataList.GetNext(Position))
308
                    InsertAudioListViewItem(CodecFormatDataList.GetAt(Position));
377
                    InsertAudioListViewItem(CodecFormatDataList.GetAt(Position));
 
 
378
                // SUGG: List g_wszSpeechCaps proeprty if/where available
309
            }
379
            }
310
        }
380
        }
311
    }
381
    }
...
 
...
 
395
        _W(EndDialog(nIdentifier));
465
        _W(EndDialog(nIdentifier));
396
        return 0;
466
        return 0;
397
    }
467
    }
 
 
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
    }
398
    LRESULT OnTreeViewSelChanged(NMTREEVIEW*)
505
    LRESULT OnTreeViewSelChanged(NMTREEVIEW*)
399
    {
506
    {
400
        UpdateListView();
507
        UpdateListView();
401
        return 0;
508
        return 0;
402
    }
509
    }
 
 
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
    }
403
    LRESULT OnSubmitButtonClicked(UINT, INT, HWND)
532
    LRESULT OnSubmitButtonClicked(UINT, INT, HWND)
404
    {
533
    {
405
        CWaitCursor WaitCursor;
534
        CWaitCursor WaitCursor;