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 "OpenCapDeviceDlg.h"
00028 #include "..\..\DSUtil\DSUtil.h"
00029
00030 static struct cc_t {long code; AnalogVideoStandard standard; const TCHAR* str;} s_countrycodes[] =
00031 {
00032 {1, AnalogVideo_NTSC_M, _T("USA")},
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 {2, AnalogVideo_NTSC_M, _T("Canada")},
00056 {7, AnalogVideo_SECAM_D, _T("Russia")},
00057
00058
00059
00060
00061
00062 {20, AnalogVideo_SECAM_B, _T("Egypt")},
00063 {27, AnalogVideo_PAL_I, _T("South Africa")},
00064 {30, AnalogVideo_SECAM_B, _T("Greece")},
00065 {31, AnalogVideo_PAL_B, _T("Netherlands")},
00066 {32, AnalogVideo_PAL_B, _T("Belgium")},
00067 {33, AnalogVideo_SECAM_L, _T("France")},
00068 {34, AnalogVideo_PAL_B, _T("Spain")},
00069 {36, AnalogVideo_SECAM_D, _T("Hungary")},
00070 {39, AnalogVideo_PAL_B, _T("Italy")},
00071 {39, AnalogVideo_PAL_B, _T("Vatican City")},
00072 {40, AnalogVideo_PAL_D, _T("Romania")},
00073 {41, AnalogVideo_PAL_B, _T("Switzerland")},
00074 {41, AnalogVideo_PAL_B, _T("Liechtenstein")},
00075 {43, AnalogVideo_PAL_B, _T("Austria")},
00076 {44, AnalogVideo_PAL_I, _T("United Kingdom")},
00077 {45, AnalogVideo_PAL_B, _T("Denmark")},
00078 {46, AnalogVideo_PAL_B, _T("Sweden")},
00079 {47, AnalogVideo_PAL_B, _T("Norway")},
00080 {48, AnalogVideo_PAL_B, _T("Poland")},
00081 {49, AnalogVideo_PAL_B, _T("Germany")},
00082 {51, AnalogVideo_NTSC_M, _T("Peru")},
00083 {52, AnalogVideo_NTSC_M, _T("Mexico")},
00084 {53, AnalogVideo_NTSC_M, _T("Cuba")},
00085 {53, AnalogVideo_NTSC_M, _T("Guantanamo Bay")},
00086 {54, AnalogVideo_PAL_N, _T("Argentina")},
00087 {55, AnalogVideo_PAL_M, _T("Brazil")},
00088 {56, AnalogVideo_NTSC_M, _T("Chile")},
00089 {57, AnalogVideo_NTSC_M, _T("Colombia")},
00090 {58, AnalogVideo_NTSC_M, _T("Bolivarian Republic of Venezuela")},
00091 {60, AnalogVideo_PAL_B, _T("Malaysia")},
00092 {61, AnalogVideo_PAL_B, _T("Australia")},
00093 {61, AnalogVideo_NTSC_M, _T("Cocos-Keeling Islands")},
00094 {62, AnalogVideo_PAL_B, _T("Indonesia")},
00095 {63, AnalogVideo_NTSC_M, _T("Philippines")},
00096 {64, AnalogVideo_PAL_B, _T("New Zealand")},
00097 {65, AnalogVideo_PAL_B, _T("Singapore")},
00098 {66, AnalogVideo_PAL_B, _T("Thailand")},
00099 {81, AnalogVideo_NTSC_M_J, _T("Japan")},
00100 {82, AnalogVideo_NTSC_M, _T("Korea (South)")},
00101 {84, AnalogVideo_NTSC_M, _T("Vietnam")},
00102 {86, AnalogVideo_PAL_D, _T("China")},
00103 {90, AnalogVideo_PAL_B, _T("Turkey")},
00104 {91, AnalogVideo_PAL_B, _T("India")},
00105 {92, AnalogVideo_PAL_B, _T("Pakistan")},
00106 {93, AnalogVideo_PAL_B, _T("Afghanistan")},
00107 {94, AnalogVideo_PAL_B, _T("Sri Lanka")},
00108 {95, AnalogVideo_NTSC_M, _T("Myanmar")},
00109 {98, AnalogVideo_SECAM_B, _T("Iran")},
00110 {212, AnalogVideo_SECAM_B, _T("Morocco")},
00111 {213, AnalogVideo_PAL_B, _T("Algeria")},
00112 {216, AnalogVideo_SECAM_B, _T("Tunisia")},
00113 {218, AnalogVideo_SECAM_B, _T("Libya")},
00114 {220, AnalogVideo_SECAM_K, _T("Gambia")},
00115 {221, AnalogVideo_SECAM_K, _T("Senegal Republic")},
00116 {222, AnalogVideo_SECAM_B, _T("Mauritania")},
00117 {223, AnalogVideo_SECAM_K, _T("Mali")},
00118 {224, AnalogVideo_SECAM_K, _T("Guinea")},
00119 {225, AnalogVideo_SECAM_K, _T("Cote D'Ivoire")},
00120 {226, AnalogVideo_SECAM_K, _T("Burkina Faso")},
00121 {227, AnalogVideo_SECAM_K, _T("Niger")},
00122 {228, AnalogVideo_SECAM_K, _T("Togo")},
00123 {229, AnalogVideo_SECAM_K, _T("Benin")},
00124 {230, AnalogVideo_SECAM_B, _T("Mauritius")},
00125 {231, AnalogVideo_PAL_B, _T("Liberia")},
00126 {232, AnalogVideo_PAL_B, _T("Sierra Leone")},
00127 {233, AnalogVideo_PAL_B, _T("Ghana")},
00128 {234, AnalogVideo_PAL_B, _T("Nigeria")},
00129 {235, AnalogVideo_PAL_B, _T("Chad")},
00130 {236, AnalogVideo_PAL_B, _T("Central African Republic")},
00131 {237, AnalogVideo_PAL_B, _T("Cameroon")},
00132 {238, AnalogVideo_NTSC_M, _T("Cape Verde Islands")},
00133 {239, AnalogVideo_PAL_B, _T("Sao Tome and Principe")},
00134 {240, AnalogVideo_SECAM_B, _T("Equatorial Guinea")},
00135 {241, AnalogVideo_SECAM_K, _T("Gabon")},
00136 {242, AnalogVideo_SECAM_D, _T("Congo")},
00137 {243, AnalogVideo_SECAM_K, _T("Congo(DRC)")},
00138 {244, AnalogVideo_PAL_I, _T("Angola")},
00139 {245, AnalogVideo_NTSC_M, _T("Guinea-Bissau")},
00140 {246, AnalogVideo_NTSC_M, _T("Diego Garcia")},
00141 {247, AnalogVideo_NTSC_M, _T("Ascension Island")},
00142 {248, AnalogVideo_PAL_B, _T("Seychelle Islands")},
00143 {249, AnalogVideo_PAL_B, _T("Sudan")},
00144 {250, AnalogVideo_PAL_B, _T("Rwanda")},
00145 {251, AnalogVideo_PAL_B, _T("Ethiopia")},
00146 {252, AnalogVideo_PAL_B, _T("Somalia")},
00147 {253, AnalogVideo_SECAM_K, _T("Djibouti")},
00148 {254, AnalogVideo_PAL_B, _T("Kenya")},
00149 {255, AnalogVideo_PAL_B, _T("Tanzania")},
00150 {256, AnalogVideo_PAL_B, _T("Uganda")},
00151 {257, AnalogVideo_SECAM_K, _T("Burundi")},
00152 {258, AnalogVideo_PAL_B, _T("Mozambique")},
00153 {260, AnalogVideo_PAL_B, _T("Zambia")},
00154 {261, AnalogVideo_SECAM_K, _T("Madagascar")},
00155 {262, AnalogVideo_SECAM_K, _T("Reunion Island")},
00156 {263, AnalogVideo_PAL_B, _T("Zimbabwe")},
00157 {264, AnalogVideo_PAL_I, _T("Namibia")},
00158 {265, AnalogVideo_NTSC_M, _T("Malawi")},
00159 {266, AnalogVideo_PAL_I, _T("Lesotho")},
00160 {267, AnalogVideo_SECAM_K, _T("Botswana")},
00161 {268, AnalogVideo_PAL_B, _T("Swaziland")},
00162 {269, AnalogVideo_SECAM_K, _T("Mayotte Island")},
00163
00164 {290, AnalogVideo_NTSC_M, _T("St. Helena")},
00165 {291, AnalogVideo_NTSC_M, _T("Eritrea")},
00166 {297, AnalogVideo_NTSC_M, _T("Aruba")},
00167 {298, AnalogVideo_PAL_B, _T("Faroe Islands")},
00168 {299, AnalogVideo_NTSC_M, _T("Greenland")},
00169 {350, AnalogVideo_PAL_B, _T("Gibraltar")},
00170 {351, AnalogVideo_PAL_B, _T("Portugal")},
00171 {352, AnalogVideo_PAL_B, _T("Luxembourg")},
00172 {353, AnalogVideo_PAL_I, _T("Ireland")},
00173 {354, AnalogVideo_PAL_B, _T("Iceland")},
00174 {355, AnalogVideo_PAL_B, _T("Albania")},
00175 {356, AnalogVideo_PAL_B, _T("Malta")},
00176 {357, AnalogVideo_PAL_B, _T("Cyprus")},
00177 {358, AnalogVideo_PAL_B, _T("Finland")},
00178 {359, AnalogVideo_SECAM_D, _T("Bulgaria")},
00179 {370, AnalogVideo_PAL_B, _T("Lithuania")},
00180 {371, AnalogVideo_SECAM_D, _T("Latvia")},
00181 {372, AnalogVideo_PAL_B, _T("Estonia")},
00182 {373, AnalogVideo_SECAM_D, _T("Moldova")},
00183 {374, AnalogVideo_SECAM_D, _T("Armenia")},
00184 {375, AnalogVideo_SECAM_D, _T("Belarus")},
00185 {376, AnalogVideo_NTSC_M, _T("Andorra")},
00186 {377, AnalogVideo_SECAM_G, _T("Monaco")},
00187 {378, AnalogVideo_PAL_B, _T("San Marino")},
00188 {380, AnalogVideo_SECAM_D, _T("Ukraine")},
00189 {381, AnalogVideo_PAL_B, _T("Serbia and Montenegro")},
00190 {385, AnalogVideo_PAL_B, _T("Croatia")},
00191 {386, AnalogVideo_PAL_B, _T("Slovenia")},
00192 {387, AnalogVideo_PAL_B, _T("Bosnia and Herzegovina")},
00193 {389, AnalogVideo_PAL_B, _T("F.Y.R.O.M. (Former Yugoslav Republic of Macedonia)")},
00194 {420, AnalogVideo_PAL_D, _T("Czech Republic")},
00195 {421, AnalogVideo_PAL_B, _T("Slovak Republic")},
00196 {500, AnalogVideo_PAL_I, _T("Falkland Islands (Islas Malvinas)")},
00197 {501, AnalogVideo_NTSC_M, _T("Belize")},
00198 {502, AnalogVideo_NTSC_M, _T("Guatemala")},
00199 {503, AnalogVideo_NTSC_M, _T("El Salvador")},
00200 {504, AnalogVideo_NTSC_M, _T("Honduras")},
00201 {505, AnalogVideo_NTSC_M, _T("Nicaragua")},
00202 {506, AnalogVideo_NTSC_M, _T("Costa Rica")},
00203 {507, AnalogVideo_NTSC_M, _T("Panama")},
00204 {508, AnalogVideo_SECAM_K, _T("St. Pierre and Miquelon")},
00205 {509, AnalogVideo_NTSC_M, _T("Haiti")},
00206 {590, AnalogVideo_SECAM_K, _T("Guadeloupe")},
00207
00208 {591, AnalogVideo_PAL_N, _T("Bolivia")},
00209 {592, AnalogVideo_SECAM_K, _T("Guyana")},
00210 {593, AnalogVideo_NTSC_M, _T("Ecuador")},
00211 {594, AnalogVideo_SECAM_K, _T("French Guiana")},
00212 {595, AnalogVideo_PAL_N, _T("Paraguay")},
00213 {596, AnalogVideo_SECAM_K, _T("Martinique")},
00214 {597, AnalogVideo_NTSC_M, _T("Suriname")},
00215 {598, AnalogVideo_PAL_N, _T("Uruguay")},
00216 {599, AnalogVideo_NTSC_M, _T("Netherlands Antilles")},
00217 {670, AnalogVideo_NTSC_M, _T("Saipan Island")},
00218
00219
00220 {671, AnalogVideo_NTSC_M, _T("Guam")},
00221 {672, AnalogVideo_NTSC_M, _T("Christmas Island")},
00222 {672, AnalogVideo_NTSC_M, _T("Australian Antarctic Territory")},
00223 {672, AnalogVideo_PAL_B, _T("Norfolk Island")},
00224 {673, AnalogVideo_PAL_B, _T("Brunei")},
00225 {674, AnalogVideo_NTSC_M, _T("Nauru")},
00226 {675, AnalogVideo_PAL_B, _T("Papua New Guinea")},
00227 {676, AnalogVideo_NTSC_M, _T("Tonga")},
00228 {677, AnalogVideo_NTSC_M, _T("Solomon Islands")},
00229 {678, AnalogVideo_NTSC_M, _T("Vanuatu")},
00230 {679, AnalogVideo_NTSC_M, _T("Fiji Islands")},
00231 {680, AnalogVideo_NTSC_M, _T("Palau")},
00232 {681, AnalogVideo_SECAM_K, _T("Wallis and Futuna Islands")},
00233 {682, AnalogVideo_PAL_B, _T("Cook Islands")},
00234 {683, AnalogVideo_NTSC_M, _T("Niue")},
00235 {684, AnalogVideo_NTSC_M, _T("Territory of American Samoa")},
00236 {685, AnalogVideo_PAL_B, _T("Samoa")},
00237 {686, AnalogVideo_PAL_B, _T("Kiribati Republic")},
00238 {687, AnalogVideo_SECAM_K, _T("New Caledonia")},
00239 {688, AnalogVideo_NTSC_M, _T("Tuvalu")},
00240 {689, AnalogVideo_SECAM_K, _T("French Polynesia")},
00241 {690, AnalogVideo_NTSC_M, _T("Tokelau")},
00242 {691, AnalogVideo_NTSC_M, _T("Micronesia")},
00243 {692, AnalogVideo_NTSC_M, _T("Marshall Islands")},
00244 {850, AnalogVideo_SECAM_D, _T("Korea (North)")},
00245 {852, AnalogVideo_PAL_I, _T("Hong Kong SAR")},
00246 {853, AnalogVideo_PAL_I, _T("Macao SAR")},
00247 {855, AnalogVideo_PAL_B, _T("Cambodia")},
00248 {856, AnalogVideo_PAL_B, _T("Laos")},
00249 {871, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-East)")},
00250 {872, AnalogVideo_NTSC_M, _T("INMARSAT (Pacific)")},
00251 {873, AnalogVideo_NTSC_M, _T("INMARSAT (Indian)")},
00252 {874, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-West)")},
00253 {880, AnalogVideo_PAL_B, _T("Bangladesh")},
00254 {886, AnalogVideo_NTSC_M, _T("Taiwan")},
00255 {960, AnalogVideo_PAL_B, _T("Maldives")},
00256 {961, AnalogVideo_SECAM_B, _T("Lebanon")},
00257 {962, AnalogVideo_PAL_B, _T("Jordan")},
00258 {963, AnalogVideo_SECAM_B, _T("Syria")},
00259 {964, AnalogVideo_SECAM_B, _T("Iraq")},
00260 {965, AnalogVideo_PAL_B, _T("Kuwait")},
00261 {966, AnalogVideo_SECAM_B, _T("Saudi Arabia")},
00262 {967, AnalogVideo_PAL_B, _T("Yemen")},
00263 {968, AnalogVideo_PAL_B, _T("Oman")},
00264 {971, AnalogVideo_PAL_B, _T("United Arab Emirates")},
00265 {972, AnalogVideo_PAL_B, _T("Israel")},
00266 {973, AnalogVideo_PAL_B, _T("Bahrain")},
00267 {974, AnalogVideo_PAL_B, _T("Qatar")},
00268 {975, AnalogVideo_NTSC_M, _T("Bhutan")},
00269 {976, AnalogVideo_SECAM_D, _T("Mongolia")},
00270 {977, AnalogVideo_PAL_B, _T("Nepal")},
00271 {994, AnalogVideo_SECAM_D, _T("Azerbaijan")},
00272 {995, AnalogVideo_SECAM_D,_T("Georgia")},
00273 };
00274
00275
00276
00277
00278 COpenCapDeviceDlg::COpenCapDeviceDlg(CWnd* pParent )
00279 : CResizableDialog(COpenCapDeviceDlg::IDD, pParent)
00280 , m_vidstr(_T(""))
00281 , m_audstr(_T(""))
00282 , m_country(1)
00283 {
00284 }
00285
00286 COpenCapDeviceDlg::~COpenCapDeviceDlg()
00287 {
00288 }
00289
00290 void COpenCapDeviceDlg::DoDataExchange(CDataExchange* pDX)
00291 {
00292 __super::DoDataExchange(pDX);
00293 DDX_Control(pDX, IDC_COMBO1, m_vidctrl);
00294 DDX_Control(pDX, IDC_COMBO2, m_audctrl);
00295 DDX_Control(pDX, IDC_COMBO9, m_countryctrl);
00296 }
00297
00298 BEGIN_MESSAGE_MAP(COpenCapDeviceDlg, CResizableDialog)
00299 ON_BN_CLICKED(IDOK, OnBnClickedOk)
00300 END_MESSAGE_MAP()
00301
00302
00303
00304
00305 BOOL COpenCapDeviceDlg::OnInitDialog()
00306 {
00307 __super::OnInitDialog();
00308
00309 AddAnchor(m_vidctrl, TOP_LEFT, TOP_RIGHT);
00310 AddAnchor(m_audctrl, TOP_LEFT, TOP_RIGHT);
00311 AddAnchor(m_countryctrl, TOP_LEFT, TOP_RIGHT);
00312 AddAnchor(IDOK, TOP_CENTER);
00313 AddAnchor(IDCANCEL, TOP_CENTER);
00314
00315 CRect r;
00316 GetWindowRect(r);
00317 CSize s = r.Size();
00318 SetMinTrackSize(s);
00319 s.cx = 1000;
00320 SetMaxTrackSize(s);
00321
00322 CString dummy = _T("dummy");
00323 CString vidstr = AfxGetApp()->GetProfileString(_T("Capture"), _T("VidDispName"), dummy);
00324 CString audstr = AfxGetApp()->GetProfileString(_T("Capture"), _T("AudDispName"), dummy);
00325 long country = AfxGetApp()->GetProfileInt(_T("Capture"), _T("Country"), 1);
00326
00327 int iSel = vidstr == dummy ? 0 : -1;
00328
00329 BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker)
00330 {
00331 CComPtr<IPropertyBag> pPB;
00332 pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
00333
00334 CComVariant var;
00335 pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
00336 int i = m_vidctrl.AddString(CString(var.bstrVal));
00337
00338 LPOLESTR strName = NULL;
00339 if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
00340 {
00341 m_vidnames.Add(CString(strName));
00342 if(vidstr == CString(strName)) iSel = i;
00343 CoTaskMemFree(strName);
00344 }
00345 }
00346 EndEnumSysDev
00347
00348 if(m_vidctrl.GetCount())
00349 m_vidctrl.SetCurSel(iSel);
00350
00351 iSel = audstr == dummy ? 0 : -1;
00352
00353 BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker)
00354 {
00355 CComPtr<IPropertyBag> pPB;
00356 pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
00357
00358 CComVariant var;
00359 pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
00360 int i = m_audctrl.AddString(CString(var.bstrVal));
00361
00362 LPOLESTR strName = NULL;
00363 if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
00364 {
00365 m_audnames.Add(CString(strName));
00366 if(audstr == CString(strName)) iSel = i;
00367 CoTaskMemFree(strName);
00368 }
00369 }
00370 EndEnumSysDev
00371
00372 if(m_audctrl.GetCount())
00373 m_audctrl.SetCurSel(iSel);
00374
00375 iSel = 0;
00376
00377 for(int j = 0; j < countof(s_countrycodes); j++)
00378 {
00379 CString standard;
00380 switch(s_countrycodes[j].standard)
00381 {
00382 case AnalogVideo_NTSC_M: standard = _T("NTSC M"); break;
00383 case AnalogVideo_NTSC_M_J: standard = _T("NTSC M J"); break;
00384 case AnalogVideo_NTSC_433: standard = _T("NTSC 433"); break;
00385 case AnalogVideo_PAL_B: standard = _T("PAL B"); break;
00386 case AnalogVideo_PAL_D: standard = _T("PAL D"); break;
00387 case AnalogVideo_PAL_G: standard = _T("PAL G"); break;
00388 case AnalogVideo_PAL_H: standard = _T("PAL H"); break;
00389 case AnalogVideo_PAL_I: standard = _T("PAL I"); break;
00390 case AnalogVideo_PAL_M: standard = _T("PAL M"); break;
00391 case AnalogVideo_PAL_N: standard = _T("PAL N"); break;
00392 case AnalogVideo_PAL_60: standard = _T("PAL 60"); break;
00393 case AnalogVideo_SECAM_B: standard = _T("SECAM B"); break;
00394 case AnalogVideo_SECAM_D: standard = _T("SECAM D"); break;
00395 case AnalogVideo_SECAM_G: standard = _T("SECAM G"); break;
00396 case AnalogVideo_SECAM_H: standard = _T("SECAM H"); break;
00397 case AnalogVideo_SECAM_K: standard = _T("SECAM K"); break;
00398 case AnalogVideo_SECAM_K1: standard = _T("SECAM K1"); break;
00399 case AnalogVideo_SECAM_L: standard = _T("SECAM L"); break;
00400 case AnalogVideo_SECAM_L1: standard = _T("SECAM L1"); break;
00401 case AnalogVideo_PAL_N_COMBO: standard = _T("PAL N COMBO"); break;
00402 }
00403
00404 CString str;
00405 str.Format(_T("%d - %s - %s"), s_countrycodes[j].code, s_countrycodes[j].str, standard);
00406
00407 int i = m_countryctrl.AddString(str);
00408 m_countryctrl.SetItemDataPtr(i, &s_countrycodes[j]);
00409 if(country == s_countrycodes[j].code) iSel = i;
00410 }
00411
00412 if(m_countryctrl.GetCount())
00413 m_countryctrl.SetCurSel(iSel);
00414
00415 return TRUE;
00416
00417 }
00418
00419 void COpenCapDeviceDlg::OnBnClickedOk()
00420 {
00421 UpdateData();
00422
00423 if(m_vidctrl.GetCurSel() >= 0)
00424 {
00425 m_vidstr = m_vidnames[m_vidctrl.GetCurSel()];
00426 AfxGetApp()->WriteProfileString(_T("Capture"), _T("VidDispName"), m_vidstr);
00427 }
00428
00429 if(m_audctrl.GetCurSel() >= 0)
00430 {
00431 m_audstr = m_audnames[m_audctrl.GetCurSel()];
00432 AfxGetApp()->WriteProfileString(_T("Capture"), _T("AudDispName"), m_audstr);
00433 }
00434
00435 if(m_countryctrl.GetCurSel() >= 0)
00436 {
00437 m_country = ((cc_t*)m_countryctrl.GetItemDataPtr(m_countryctrl.GetCurSel()))->code;
00438 AfxGetApp()->WriteProfileInt(_T("Capture"), _T("Country"), m_country);
00439 }
00440
00441 OnOK();
00442 }