00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "MediaTypesDlg.h"
00028 #include "..\..\DSUtil\DSUtil.h"
00029 #include "..\..\..\include\moreuuids.h"
00030
00031 #pragma pack(push, 1)
00032 typedef struct
00033 {
00034 WAVEFORMATEX Format;
00035 BYTE bBigEndian;
00036 BYTE bsid;
00037 BYTE lfeon;
00038 BYTE copyrightb;
00039 BYTE nAuxBitsCode;
00040 } DOLBYAC3WAVEFORMAT;
00041 #pragma pack(pop)
00042
00043
00044
00045
00046 CMediaTypesDlg::CMediaTypesDlg(CGraphBuilder& gb, CWnd* pParent )
00047 : CResizableDialog(CMediaTypesDlg::IDD, pParent)
00048 {
00049 CGraphBuilder::DeadEnd* pde;
00050 for(int i = 0; pde = gb.GetDeadEnd(i); i++) m_DeadEnds.Add(pde);
00051 m_subtype = GUID_NULL;
00052 m_type = UNKNOWN;
00053 }
00054
00055 CMediaTypesDlg::~CMediaTypesDlg()
00056 {
00057 }
00058
00059 void CMediaTypesDlg::DoDataExchange(CDataExchange* pDX)
00060 {
00061 CResizableDialog::DoDataExchange(pDX);
00062 DDX_Control(pDX, IDC_COMBO1, m_pins);
00063 DDX_Control(pDX, IDC_EDIT1, m_report);
00064 }
00065
00066 void CMediaTypesDlg::AddLine(CString str)
00067 {
00068 str.Replace(_T("\n"), _T("\r\n"));
00069 int len = m_report.GetWindowTextLength();
00070 m_report.SetSel(len, len, TRUE);
00071 m_report.ReplaceSel(str);
00072 }
00073
00074 void CMediaTypesDlg::AddMediaType(AM_MEDIA_TYPE* pmt)
00075 {
00076 CString major = CStringFromGUID(pmt->majortype);
00077 CString sub = CStringFromGUID(pmt->subtype);
00078 CString format = CStringFromGUID(pmt->formattype);
00079
00080 m_subtype = pmt->subtype;
00081 if(pmt->majortype == MEDIATYPE_Video) m_type = VIDEO;
00082 else if(pmt->majortype == MEDIATYPE_Audio) m_type = AUDIO;
00083 else m_type = UNKNOWN;
00084
00085 CString str;
00086
00087 AddLine(_T("AM_MEDIA_TYPE:\n"));
00088 str.Format(_T("majortype: %s %s\n"), CString(GuidNames[pmt->majortype]), major);
00089 AddLine(str);
00090 str.Format(_T("subtype: %s %s\n"), CString(GuidNames[pmt->subtype]), sub);
00091 AddLine(str);
00092 str.Format(_T("formattype: %s %s\n"), CString(GuidNames[pmt->formattype]), format);
00093 AddLine(str);
00094 str.Format(_T("bFixedSizeSamples: %d\n"), pmt->bFixedSizeSamples);
00095 AddLine(str);
00096 str.Format(_T("bTemporalCompression: %d\n"), pmt->bTemporalCompression);
00097 AddLine(str);
00098 str.Format(_T("lSampleSize: %d\n"), pmt->lSampleSize);
00099 AddLine(str);
00100 str.Format(_T("cbFormat: %d\n"), pmt->cbFormat);
00101 AddLine(str);
00102
00103 AddLine();
00104
00105 if(pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_VideoInfo2)
00106 {
00107 VIDEOINFOHEADER& vih = *((VIDEOINFOHEADER*)pmt->pbFormat);
00108 BITMAPINFOHEADER* bih = &vih.bmiHeader;
00109
00110 AddLine(_T("VIDEOINFOHEADER:\n"));
00111 str.Format(_T("rcSource: (%d,%d)-(%d,%d)\n"), vih.rcSource);
00112 AddLine(str);
00113 str.Format(_T("rcTarget: (%d,%d)-(%d,%d)\n"), vih.rcTarget);
00114 AddLine(str);
00115 str.Format(_T("dwBitRate: %d\n"), vih.dwBitRate);
00116 AddLine(str);
00117 str.Format(_T("dwBitErrorRate: %d\n"), vih.dwBitErrorRate);
00118 AddLine(str);
00119 str.Format(_T("AvgTimePerFrame: %I64d\n"), vih.AvgTimePerFrame);
00120 AddLine(str);
00121
00122 if(pmt->formattype == FORMAT_VideoInfo2)
00123 {
00124 VIDEOINFOHEADER2& vih = *((VIDEOINFOHEADER2*)pmt->pbFormat);
00125 bih = &vih.bmiHeader;
00126
00127 AddLine(_T("VIDEOINFOHEADER2:\n"));
00128 str.Format(_T("dwInterlaceFlags: 0x%08x\n"), vih.dwInterlaceFlags);
00129 AddLine(str);
00130 str.Format(_T("dwCopyProtectFlags: 0x%08x\n"), vih.dwCopyProtectFlags);
00131 AddLine(str);
00132 str.Format(_T("dwPictAspectRatioX: %d\n"), vih.dwPictAspectRatioX);
00133 AddLine(str);
00134 str.Format(_T("dwPictAspectRatioY: %d\n"), vih.dwPictAspectRatioY);
00135 AddLine(str);
00136 str.Format(_T("dwControlFlags: 0x%08x\n"), vih.dwControlFlags);
00137 AddLine(str);
00138 str.Format(_T("dwReserved2: 0x%08x\n"), vih.dwReserved2);
00139 AddLine(str);
00140 }
00141
00142 AddLine();
00143
00144 AddLine(_T("BITMAPINFOHEADER:\n"));
00145 str.Format(_T("biSize: %d\n"), bih->biSize);
00146 AddLine(str);
00147 str.Format(_T("biWidth: %d\n"), bih->biWidth);
00148 AddLine(str);
00149 str.Format(_T("biHeight: %d\n"), bih->biHeight);
00150 AddLine(str);
00151 str.Format(_T("biPlanes: %d\n"), bih->biPlanes);
00152 AddLine(str);
00153 str.Format(_T("biBitCount: %d\n"), bih->biBitCount);
00154 AddLine(str);
00155 if(bih->biCompression < 256) str.Format(_T("biCompression: %d\n"), bih->biCompression);
00156 else str.Format(_T("biCompression: %4.4hs\n"), &bih->biCompression);
00157 AddLine(str);
00158 str.Format(_T("biSizeImage: %d\n"), bih->biSizeImage);
00159 AddLine(str);
00160 str.Format(_T("biXPelsPerMeter: %d\n"), bih->biXPelsPerMeter);
00161 AddLine(str);
00162 str.Format(_T("biYPelsPerMeter: %d\n"), bih->biYPelsPerMeter);
00163 AddLine(str);
00164 str.Format(_T("biYPelsPerMeter: %d\n"), bih->biYPelsPerMeter);
00165 AddLine(str);
00166 str.Format(_T("biClrUsed: %d\n"), bih->biClrUsed);
00167 AddLine(str);
00168 str.Format(_T("biClrImportant: %d\n"), bih->biClrImportant);
00169 AddLine(str);
00170 }
00171 else if(pmt->formattype == FORMAT_WaveFormatEx)
00172 {
00173 WAVEFORMATEX& wfe = *((WAVEFORMATEX*)pmt->pbFormat);
00174
00175 AddLine(_T("WAVEFORMATEX:\n"));
00176 str.Format(_T("wFormatTag: 0x%04x\n"), wfe.wFormatTag);
00177 AddLine(str);
00178 str.Format(_T("nChannels: %d\n"), wfe.nChannels);
00179 AddLine(str);
00180 str.Format(_T("nSamplesPerSec: %d\n"), wfe.nSamplesPerSec);
00181 AddLine(str);
00182 str.Format(_T("nAvgBytesPerSec: %d\n"), wfe.nAvgBytesPerSec);
00183 AddLine(str);
00184 str.Format(_T("nBlockAlign: %d\n"), wfe.nBlockAlign);
00185 AddLine(str);
00186 str.Format(_T("wBitsPerSample: %d\n"), wfe.wBitsPerSample);
00187 AddLine(str);
00188
00189 if(wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0)
00190 {
00191 str.Format(_T("cbSize: %d (extra bytes)\n"), wfe.cbSize);
00192 AddLine(str);
00193
00194 if(wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX))
00195 {
00196 WAVEFORMATEXTENSIBLE& wfe = *((WAVEFORMATEXTENSIBLE*)pmt->pbFormat);
00197
00198 AddLine(_T("WAVEFORMATEXTENSIBLE:\n"));
00199 if(wfe.Format.wBitsPerSample != 0) str.Format(_T("wValidBitsPerSample: %d\n"), wfe.Samples.wValidBitsPerSample);
00200 else str.Format(_T("wSamplesPerBlock: %d\n"), wfe.Samples.wSamplesPerBlock);
00201 AddLine(str);
00202 str.Format(_T("dwChannelMask: 0x%08x\n"), wfe.dwChannelMask);
00203 AddLine(str);
00204 str.Format(_T("SubFormat: %s\n"), CStringFromGUID(wfe.SubFormat));
00205 AddLine(str);
00206 }
00207 else if(wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX))
00208 {
00209 DOLBYAC3WAVEFORMAT& wfe = *((DOLBYAC3WAVEFORMAT*)pmt->pbFormat);
00210
00211 AddLine(_T("DOLBYAC3WAVEFORMAT:\n"));
00212 str.Format(_T("bBigEndian: %d\n"), wfe.bBigEndian);
00213 AddLine(str);
00214 str.Format(_T("bsid: %d\n"), wfe.bsid);
00215 AddLine(str);
00216 str.Format(_T("lfeon: %d\n"), wfe.lfeon);
00217 AddLine(str);
00218 str.Format(_T("copyrightb: %d\n"), wfe.copyrightb);
00219 AddLine(str);
00220 str.Format(_T("nAuxBitsCode: %d\n"), wfe.nAuxBitsCode);
00221 AddLine(str);
00222 }
00223 }
00224
00225 AddLine();
00226 }
00227 }
00228
00229 BEGIN_MESSAGE_MAP(CMediaTypesDlg, CResizableDialog)
00230 ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
00231 ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
00232 ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
00233 END_MESSAGE_MAP()
00234
00235
00236
00237
00238 BOOL CMediaTypesDlg::OnInitDialog()
00239 {
00240 CResizableDialog::OnInitDialog();
00241
00242 for(int i = 0; i < m_DeadEnds.GetCount(); i++)
00243 {
00244 m_pins.SetItemData(
00245 m_pins.AddString(m_DeadEnds[i]->filter + _T("::") + m_DeadEnds[i]->pin),
00246 (DWORD_PTR)m_DeadEnds[i]);
00247 }
00248
00249 m_pins.SetCurSel(0);
00250 OnCbnSelchangeCombo1();
00251
00252 AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
00253 AddAnchor(IDC_STATIC2, TOP_LEFT, TOP_RIGHT);
00254 AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
00255 AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
00256 AddAnchor(IDC_BUTTON1, BOTTOM_LEFT);
00257 AddAnchor(IDOK, BOTTOM_RIGHT);
00258
00259 SetMinTrackSize(CSize(300, 200));
00260
00261 return TRUE;
00262
00263 }
00264
00265 void CMediaTypesDlg::OnCbnSelchangeCombo1()
00266 {
00267 m_report.SetWindowText(_T(""));
00268
00269 int i = m_pins.GetCurSel();
00270 if(i < 0) return;
00271
00272 POSITION pos;
00273
00274 CList<CString>& path = m_DeadEnds[i]->path;
00275 pos = path.GetHeadPosition();
00276 while(pos)
00277 {
00278 AddLine(path.GetNext(pos) + _T("\n"));
00279 if(!pos) AddLine(_T("\n"));
00280 }
00281
00282 pos = m_DeadEnds[i]->mts.GetHeadPosition();
00283 for(int j = 0; pos; j++)
00284 {
00285 CString str;
00286 str.Format(_T("Media Type %d:\n"), j);
00287 AddLine(str);
00288 AddLine(_T("--------------------------\n"));
00289 AddMediaType(&m_DeadEnds[i]->mts.GetNext(pos));
00290 AddLine();
00291 }
00292
00293 m_report.SetSel(0, 0);
00294 }
00295
00296 void CMediaTypesDlg::OnBnClickedButton1()
00297 {
00298 if(m_subtype.Data2 == 0x0000 && m_subtype.Data3 == 0x0010
00299 && *(unsigned __int64*)m_subtype.Data4 == 0x719b3800aa000080i64)
00300 {
00301 BYTE* p = (BYTE*)&m_subtype.Data1;
00302 for(int i = 0; i < 4; i++, p++)
00303 if(*p >= 'a' && *p <= 'z') *p -= 0x20;
00304 }
00305
00306 CString str;
00307 str.Format(_T("http://gabest.org/codec.php?type=%d&guid=%s"), m_type, CStringFromGUID(m_subtype));
00308 ShellExecute(NULL, _T("open"), str, NULL, NULL, SW_SHOW);
00309 }
00310
00311 void CMediaTypesDlg::OnUpdateButton1(CCmdUI* pCmdUI)
00312 {
00313 pCmdUI->Enable(m_subtype != GUID_NULL);
00314 }