00001
00002
00003 #include "vidl_dshow_istream_params_esf.h"
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <vidl/vidl_dshow.h>
00013
00014 #include <vcl_iostream.h>
00015 #include <vcl_iomanip.h>
00016 #include <vcl_sstream.h>
00017 #include <vcl_utility.h>
00018
00019 #include <vbl/vbl_triple.h>
00020
00021
00022
00023
00024 namespace
00025 {
00026 const char* esf_video_standards[] = {"ESF_STANDARD_PAL",
00027 "ESF_STANDARD_NTSC"};
00028
00029 const char* esf_resolutions[] = {"ESF_RESOLUTION_FRAME",
00030 "ESF_RESOLUTION_FIELD",
00031 "ESF_RESOLUTION_CIF",
00032 "ESF_RESOLUTION_QCIF",
00033 "ESF_RESOLUTION_CUSTOM"};
00034
00035 const char* esf_bitratecontrols[] = {"ESF_BITRATECONTROL_CBR",
00036 "ESF_BITRATECONTROL_VBR"};
00037
00038 const char* esf_gopstructures[] = {"ESF_GOPSTRUCTURE_IONLY",
00039 "ESF_GOPSTRUCTURE_IPONLY",
00040 "ESF_GOPSTRUCTURE_IPB"};
00041
00042
00043 const int w1 = 25;
00044 const int w2 = 8;
00045
00046 inline void print_4_column_row(const vcl_string& str,
00047 long val, long min, long max)
00048 {
00049 vcl_cout << vcl_setw(w1) << str
00050 << vcl_setw(w2) << val
00051 << vcl_setw(w2) << min
00052 << vcl_setw(w2) << max << '\n';
00053 }
00054
00055 inline void print_5_column_row(const vcl_string& str,
00056 long val, long min, long max, long def)
00057 {
00058 vcl_cout << vcl_setw(w1) << str
00059 << vcl_setw(w2) << val
00060 << vcl_setw(w2) << min
00061 << vcl_setw(w2) << max
00062 << vcl_setw(w2) << def << '\n';
00063 }
00064
00065 void print_video_standard_help(const CComPtr<IESFProperties>& props)
00066 {
00067 ESF_VIDEO_STANDARD val;
00068 bool mono;
00069
00070 props->GetVideoStandard(&val, &mono);
00071 vcl_cout << vcl_setw(w1) << "video_standard"
00072 << ' ' << esf_video_standards[val] << '\n';
00073
00074 vcl_cout << vcl_string(w1, ' ') << " Supported video standards\n"
00075 << vcl_string(w1, ' ') << " -------------------------\n";
00076 for (int i = 0; i < sizeof(esf_video_standards) / sizeof(char*); i++)
00077 {
00078 vcl_cout << vcl_setw(w1) << i
00079 << ' ' << esf_video_standards[i] << '\n';
00080 }
00081
00082 vcl_cout << vcl_setw(w1) << "is_monochrome"
00083 << vcl_setw(w2) << (mono ? "true" : "false") << '\n';
00084 }
00085
00086 void print_resolution_help(const CComPtr<IESFProperties>& props)
00087 {
00088 ESF_RESOLUTION val;
00089 long width, height;
00090
00091 props->GetResolution(&val, &width, &height);
00092 vcl_cout << vcl_setw(w1) << "resolution"
00093 << ' ' << esf_resolutions[val]
00094 << " (" << width << 'x' << height << ")\n";
00095
00096
00097 vcl_cout << vcl_string(w1, ' ') << " Supported resolutions\n"
00098 << vcl_string(w1, ' ') << " ---------------------\n";
00099 for (int i = 0; i < sizeof(esf_resolutions) / sizeof(char*); i++)
00100 {
00101 vcl_cout << vcl_setw(w1) << i
00102 << ' ' << esf_resolutions[i] << '\n';
00103 }
00104
00105 long min_x, max_x, min_y, max_y;
00106 props->GetCustomResolutionRange(&min_x, &max_x, &min_y, &max_y);
00107 vcl_cout << vcl_string(w1, ' ')
00108 << " custom range ("
00109 << min_x << 'x' << min_y << ") -> ("
00110 << max_x << 'x' << max_y << ")\n";
00111 }
00112
00113 void print_output_format_help(const CComPtr<IESFProperties>& props)
00114 {
00115 GUID val;
00116
00117 props->GetOutputFormat(&val);
00118 vcl_cout << vcl_setw(w1) << "output_format"
00119 << ' ' << vidl_dshow::get_guid_name(val) << '\n';
00120
00121 GUID *table = 0;
00122 unsigned long count = 0;
00123 if (SUCCEEDED(props->GetOutputFormatsList(&count, &table)))
00124 {
00125
00126 vcl_cout << vcl_string(w1, ' ') << " Supported output formats\n"
00127 << vcl_string(w1, ' ') << " ------------------------\n"
00128 << vcl_setw(w1) << '0' << " GUID_NULL (AUTO)\n";
00129
00130 for (unsigned int i = 0; i < count; i++)
00131 {
00132 vcl_cout << vcl_setw(w1) << i+1
00133 << ' ' << vidl_dshow::get_guid_name(table[i]) << '\n';
00134 }
00135
00136 CoTaskMemFree(table);
00137 }
00138 }
00139
00140 void print_capture_region_size_help(const CComPtr<IESFProperties>& props)
00141 {
00142 long val_x, min_x, max_x;
00143 long val_y, min_y, max_y;
00144 props->GetCaptureRegionSize(&val_x, &val_y);
00145 props->GetCaptureRegionSizeRange(&min_x, &max_x, &min_y, &max_y);
00146 print_4_column_row("capture_region_size_x", val_x, min_x, max_x);
00147 print_4_column_row("capture_region_size_y", val_y, min_y, max_y);
00148 }
00149
00150 void print_capture_region_pos_help(const CComPtr<IESFProperties>& props)
00151 {
00152 long val_x, min_x, max_x;
00153 long val_y, min_y, max_y;
00154 props->GetCaptureRegionPos(&val_x, &val_y);
00155 props->GetCaptureRegionPosRange(&min_x, &max_x, &min_y, &max_y);
00156 print_4_column_row("capture_region_pos_x", val_x, min_x, max_x);
00157 print_4_column_row("capture_region_pos_y", val_y, min_y, max_y);
00158 }
00159
00160 void print_capture_rate_help(const CComPtr<IESFProperties>& props)
00161 {
00162 double val, min, max, def;
00163 props->GetCaptureRate(&val);
00164 props->GetCaptureRateRange(&min, &max, &def);
00165 vcl_cout << vcl_setw(w1) << "capture_rate"
00166 << vcl_setw(w2) << val
00167 << vcl_setw(w2) << min
00168 << vcl_setw(w2) << max
00169 << vcl_setw(w2) << def << '\n';
00170 }
00171
00172 void print_brightness_help(const CComPtr<IESFProperties>& props)
00173 {
00174 long val, min, max, def;
00175 props->GetBrightness(&val);
00176 props->GetBrightnessRange(&min, &max, &def);
00177 print_5_column_row("brightness", val, min, max, def);
00178 }
00179
00180 void print_contrast_help(const CComPtr<IESFProperties>& props)
00181 {
00182 long val, min, max, def;
00183 props->GetContrast(&val);
00184 props->GetContrastRange(&min, &max, &def);
00185 print_5_column_row("contrast", val, min, max, def);
00186 }
00187
00188 void print_saturation_help(const CComPtr<IESFProperties>& props)
00189 {
00190 long val, min, max, def;
00191 props->GetSaturation(&val);
00192 props->GetSaturationRange(&min, &max, &def);
00193 print_5_column_row("saturation", val, min, max, def);
00194 }
00195
00196 void print_board_help(const CComPtr<IESFProperties>& props)
00197 {
00198 long val, min, max;
00199
00200 props->GetBoard(&val);
00201 props->GetBoardRange(&min, &max);
00202 print_4_column_row("(N/A) board", val, min, max);
00203 }
00204
00205 void print_connector_help(const CComPtr<IESFProperties>& props)
00206 {
00207 long val, min, max;
00208 props->GetConnector(&val);
00209 props->GetConnectorRange(&min, &max);
00210 print_4_column_row("(N/A) connector", val, min, max);
00211 }
00212
00213 void print_individual_control_help(const CComPtr<IESFProperties>& props)
00214 {
00215 bool val;
00216
00217 props->GetIndividualControl(&val);
00218 vcl_cout << vcl_setw(w1) << "(N/S) individual_control"
00219 << vcl_setw(w2) << (val ? "true" : "false") << '\n';
00220 }
00221
00222 void print_bitrate_control_help(const CComPtr<IESFCompression>& props)
00223 {
00224 ESF_BITRATECONTROL val;
00225
00226 vcl_cout << vcl_setw(w1) << "bitrate_control";
00227 if (SUCCEEDED(props->GetBitrateControl(&val)))
00228 {
00229 vcl_cout << ' ' << esf_bitratecontrols[val];
00230 }
00231 vcl_cout << '\n';
00232
00233 vcl_cout << vcl_string(w1, ' ') << " Supported bitrate controls\n"
00234 << vcl_string(w1, ' ') << " --------------------------\n";
00235 for (int i = 0; i < sizeof(esf_bitratecontrols) / sizeof(char*); i++)
00236 {
00237 vcl_cout << vcl_setw(w1) << i
00238 << ' ' << esf_bitratecontrols[i] << '\n';
00239 }
00240 }
00241
00242 void print_average_bitrate_help(const CComPtr<IESFCompression>& props)
00243 {
00244 long val, min, max, def;
00245 if (SUCCEEDED(props->GetAverageBitrate(&val)) &&
00246 SUCCEEDED(props->GetAverageBitrateRange(&min, &max, &def)))
00247 {
00248 print_5_column_row("average_bitrate", val, min, max, def);
00249 }
00250 else { vcl_cout << vcl_setw(w1) << "average_bitrate\n"; }
00251 }
00252
00253 void print_video_quality_help(const CComPtr<IESFCompression>& props)
00254 {
00255 long val, min, max, def;
00256 if (SUCCEEDED(props->GetVideoQuality(&val)) &&
00257 SUCCEEDED(props->GetVideoQualityRange(&min, &max, &def)))
00258 {
00259 print_5_column_row("video_quality", val, min, max, def);
00260 }
00261 else { vcl_cout << vcl_setw(w1) << "video_quality\n"; }
00262 }
00263
00264 void print_gop_size_help(const CComPtr<IESFCompression>& props)
00265 {
00266 long val, min, max, def;
00267 if (SUCCEEDED(props->GetGopSize(&val)) &&
00268 SUCCEEDED(props->GetGopSizeRange(&min, &max, &def)))
00269 {
00270 print_5_column_row("gop_size", val, min, max, def);
00271 }
00272 else { vcl_cout << vcl_setw(w1) << "gop_size\n"; }
00273 }
00274
00275 void print_gop_structure_help(const CComPtr<IESFCompression>& props)
00276 {
00277 ESF_GOPSTRUCTURE val;
00278
00279 vcl_cout << vcl_setw(w1) << "gop_structure ";
00280 if (SUCCEEDED(props->GetGopStructure(&val)))
00281 {
00282 vcl_cout << esf_gopstructures[val];
00283 }
00284 vcl_cout << '\n';
00285
00286 vcl_cout << vcl_string(w1, ' ') << " Supported GOP structures\n"
00287 << vcl_string(w1, ' ') << " ------------------------\n";
00288 for (int i = 0; i < sizeof(esf_gopstructures) / sizeof(char*); i++)
00289 {
00290 vcl_cout << vcl_setw(w1) << i
00291 << ' ' << esf_gopstructures[i] << '\n';
00292 }
00293 }
00294
00295 template <typename T> struct from_string_to
00296 {
00297 T operator()(const vcl_string& str) const
00298 {
00299 T val;
00300
00301 vcl_istringstream iss(str);
00302 iss >> val;
00303
00304 return val;
00305 }
00306 };
00307
00308 template <> struct from_string_to<bool>
00309 {
00310 bool operator()(const vcl_string& str) const
00311 {
00312 if (str == "t" || str == "true" || str == "1")
00313 {
00314 return true;
00315 }
00316 else if (str == "f" || str == "false" || str == "0")
00317 {
00318 return false;
00319 }
00320 else
00321 {
00322 vidl_exception_error(vidl_dshow_exception(
00323 "can't convert boolean param string to bool."
00324 + DSHOW_GET_ERROR_TEXT(E_FAIL)));
00325
00326 return false;
00327 }
00328 }
00329 };
00330
00331 template <> struct from_string_to<ESF_RESOLUTION>
00332 {
00333 ESF_RESOLUTION operator()(const vcl_string& str) const
00334 {
00335 if (str == "ESF_RESOLUTION_FRAME")
00336 {
00337 return ESF_RESOLUTION_FRAME;
00338 }
00339 else if (str == "ESF_RESOLUTION_FIELD")
00340 {
00341 return ESF_RESOLUTION_FIELD;
00342 }
00343 else if (str == "ESF_RESOLUTION_CIF")
00344 {
00345 return ESF_RESOLUTION_CIF;
00346 }
00347 else if (str == "ESF_RESOLUTION_QCIF")
00348 {
00349 return ESF_RESOLUTION_QCIF;
00350 }
00351 else if (str == "ESF_RESOLUTION_CUSTOM")
00352 {
00353 return ESF_RESOLUTION_CUSTOM;
00354 }
00355 else
00356 {
00357 vidl_exception_error(vidl_dshow_exception(
00358 "can't convert resolution param string to ESF_RESOLUTION."
00359 + DSHOW_GET_ERROR_TEXT(E_FAIL)));
00360
00361 return ESF_RESOLUTION_FRAME;
00362 }
00363 }
00364 };
00365
00366 template <> struct from_string_to<ESF_VIDEO_STANDARD>
00367 {
00368 ESF_VIDEO_STANDARD operator()(const vcl_string& str) const
00369 {
00370 if (str == "ESF_STANDARD_PAL" || str == "PAL")
00371 {
00372 return ESF_STANDARD_PAL;
00373 }
00374 else if (str == "ESF_STANDARD_NTSC" || str == "NTSC")
00375 {
00376 return ESF_STANDARD_NTSC;
00377 }
00378 else
00379 {
00380 vidl_exception_error(vidl_dshow_exception(
00381 "can't convert video standard param string to ESF_VIDEO_STANDARD."
00382 + DSHOW_GET_ERROR_TEXT(E_FAIL)));
00383
00384 return ESF_STANDARD_PAL;
00385 }
00386 }
00387 };
00388
00389 template <> struct from_string_to<ESF_BITRATECONTROL>
00390 {
00391 ESF_BITRATECONTROL operator()(const vcl_string& str) const
00392 {
00393 if (str == "ESF_BITRATECONTROL_CBR" || str == "CBR")
00394 {
00395 return ESF_BITRATECONTROL_CBR;
00396 }
00397 else if (str == "ESF_BITRATECONTROL_VBR" || str == "VBR")
00398 {
00399 return ESF_BITRATECONTROL_VBR;
00400 }
00401 else
00402 {
00403 vidl_exception_error(vidl_dshow_exception(
00404 "can't convert bitrate control param string to ESF_BITRATECONTROL."
00405 + DSHOW_GET_ERROR_TEXT(E_FAIL)));
00406
00407 return ESF_BITRATECONTROL_CBR;
00408 }
00409 }
00410 };
00411
00412 template <> struct from_string_to<ESF_GOPSTRUCTURE>
00413 {
00414 ESF_GOPSTRUCTURE operator()(const vcl_string& str) const
00415 {
00416 if (str == "ESF_GOPSTRUCTURE_IONLY" || str == "IONLY")
00417 {
00418 return ESF_GOPSTRUCTURE_IONLY;
00419 }
00420 else if (str == "ESF_GOPSTRUCTURE_IPONLY" || str == "IPONLY")
00421 {
00422 return ESF_GOPSTRUCTURE_IPONLY;
00423 }
00424 else if (str == "ESF_GOPSTRUCTURE_IPB" || str == "IPB")
00425 {
00426 return ESF_GOPSTRUCTURE_IPB;
00427 }
00428 else
00429 {
00430 vidl_exception_error(vidl_dshow_exception(
00431 "can't convert gop structure param string to ESF_GOPSTRUCTURE."
00432 + DSHOW_GET_ERROR_TEXT(E_FAIL)));
00433
00434 return ESF_GOPSTRUCTURE_IONLY;
00435 }
00436 }
00437 };
00438
00439 template <> struct from_string_to<GUID>
00440 {
00441 GUID operator()(const vcl_string& str) const
00442 {
00443 if (str == "MEDIASUBTYPE_DX50" || str == "DX50")
00444 {
00445 return vidl_dshow::get_guid_from_fourcc("DX50");
00446 }
00447 else if (str == "WMMEDIASUBTYPE_MP4S" || str == "MP4S")
00448 {
00449 return vidl_dshow::get_guid_from_fourcc("MP4S");
00450 }
00451 else if (str == "MEDIASUBTYPE_MJPG" || str == "MJPG")
00452 {
00453 return MEDIASUBTYPE_MJPG;
00454 }
00455 else if (str == "MEDIASUBTYPE_YUY2" || str == "YUY2")
00456 {
00457 return MEDIASUBTYPE_YUY2;
00458 }
00459 else if (str == "MEDIASUBTYPE_YV12" || str == "YV12")
00460 {
00461 return MEDIASUBTYPE_YV12;
00462 }
00463 else if (str == "MEDIASUBTYPE_IYUV" || str == "IYUV")
00464 {
00465 return MEDIASUBTYPE_IYUV;
00466 }
00467 else if (str == "MEDIASUBTYPE_Y41P" || str == "Y41P")
00468 {
00469 return MEDIASUBTYPE_Y41P;
00470 }
00471 else if (str == "MEDIASUBTYPE_YVU9" || str == "YVU9")
00472 {
00473 return MEDIASUBTYPE_YVU9;
00474 }
00475 else if (str == "MEDIASUBTYPE_RGB24" || str == "RGB24")
00476 {
00477 return MEDIASUBTYPE_RGB24;
00478 }
00479 else if (str == "MEDIASUBTYPE_RGB555" || str == "RGB555")
00480 {
00481 return MEDIASUBTYPE_RGB555;
00482 }
00483 else if (str == "MEDIASUBTYPE_RGB565" || str == "RGB565")
00484 {
00485 return MEDIASUBTYPE_RGB565;
00486 }
00487 else if (str == "MEDIASUBTYPE_RGB8" || str == "RGB8")
00488 {
00489 return MEDIASUBTYPE_RGB8;
00490 }
00491 else if (str == "MEDIASUBTYPE_ARGB32" || str == "ARGB32")
00492 {
00493 return MEDIASUBTYPE_ARGB32;
00494 }
00495 else if (str == "GUID_NULL" || str == "AUTO")
00496 {
00497 return GUID_NULL;
00498 }
00499 else
00500 {
00501 vidl_exception_error(vidl_dshow_exception(
00502 "can't convert output format param string to GUID."
00503 + DSHOW_GET_ERROR_TEXT(E_FAIL)));
00504
00505 return GUID_NULL;
00506 }
00507 }
00508 };
00509
00510 template <typename T1, typename T2>
00511 struct from_string_to_pair
00512 {
00513 vcl_pair<T1,T2> operator()(const vcl_string& str) const
00514 {
00515 vcl_string buf;
00516 vcl_istringstream iss(str);
00517
00518 vcl_pair<T1,T2> pair;
00519
00520 iss >> buf;
00521 pair.first = from_string_to<T1>()(buf);
00522
00523 iss >> buf;
00524 pair.second = from_string_to<T2>()(buf);
00525
00526 return pair;
00527 }
00528 };
00529
00530 template <typename T1, typename T2, typename T3>
00531 struct from_string_to_triple
00532 {
00533 vbl_triple<T1,T2,T3> operator()(const vcl_string& str) const
00534 {
00535 vcl_string buf;
00536 vcl_istringstream iss(str);
00537
00538 vbl_triple<T1,T2,T3> triple;
00539
00540 iss >> buf;
00541 triple.first = from_string_to<T1>()(buf);
00542
00543 iss >> buf;
00544 triple.second = from_string_to<T2>()(buf);
00545
00546 iss >> buf;
00547 triple.third = from_string_to<T3>()(buf);
00548
00549 return triple;
00550 }
00551 };
00552 }
00553
00554
00555
00556
00557
00558 vidl_dshow_istream_params_esf::vidl_dshow_istream_params_esf(void)
00559 : register_in_rot_(false)
00560 , run_when_ready_(true)
00561 , target_output_format_(GUID_NULL)
00562 {}
00563
00564
00565 void vidl_dshow_istream_params_esf
00566 ::configure_filter(const CComPtr<IBaseFilter>& source)
00567 {
00568 CComPtr<IESFProperties> esf_properties;
00569 source->QueryInterface(
00570 IID_IESFProperties, reinterpret_cast<void**>(&esf_properties));
00571
00572 if (is_property_changed_.test(esf_property_output_format))
00573 {
00574 DSHOW_ERROR_IF_FAILED(esf_properties->SetOutputFormat(output_format_));
00575 }
00576
00577
00578 if (is_property_changed_.test(esf_property_video_standard))
00579 {
00580 DSHOW_ERROR_IF_FAILED(
00581 esf_properties->SetVideoStandard(video_standard_, is_monochrome_));
00582 }
00583
00584
00585 if (is_property_changed_.test(esf_property_resolution))
00586 {
00587 vcl_cout << resolution_ << width_ << height_ << vcl_endl;
00588 DSHOW_ERROR_IF_FAILED(
00589 esf_properties->SetResolution(resolution_, width_, height_));
00590 }
00591
00592 if (is_property_changed_.test(esf_property_capture_region_size))
00593 {
00594 DSHOW_ERROR_IF_FAILED(
00595 esf_properties->SetCaptureRegionSize(capture_region_size_x_,
00596 capture_region_size_y_));
00597 }
00598
00599 if (is_property_changed_.test(esf_property_capture_region_pos))
00600 {
00601 DSHOW_ERROR_IF_FAILED(
00602 esf_properties->SetCaptureRegionPos(capture_region_pos_x_,
00603 capture_region_pos_y_));
00604 }
00605
00606 if (is_property_changed_.test(esf_property_capture_rate))
00607 {
00608 DSHOW_ERROR_IF_FAILED(esf_properties->SetCaptureRate(capture_rate_));
00609 }
00610
00611 if (is_property_changed_.test(esf_property_brightness))
00612 {
00613 DSHOW_ERROR_IF_FAILED(esf_properties->SetBrightness(brightness_));
00614 }
00615
00616 if (is_property_changed_.test(esf_property_contrast))
00617 {
00618 DSHOW_ERROR_IF_FAILED(esf_properties->SetContrast(contrast_));
00619 }
00620
00621 if (is_property_changed_.test(esf_property_saturation))
00622 {
00623 DSHOW_ERROR_IF_FAILED(esf_properties->SetSaturation(saturation_));
00624 }
00625
00626
00627 CComPtr<IESFCompression> esf_compression;
00628 source->QueryInterface(
00629 IID_IESFCompression, reinterpret_cast<void**>(&esf_compression));
00630
00631 if (is_property_changed_.test(esf_property_bitrate_control))
00632 {
00633 DSHOW_ERROR_IF_FAILED(
00634 esf_compression->SetBitrateControl(bitrate_control_));
00635 }
00636
00637 if (is_property_changed_.test(esf_property_average_bitrate))
00638 {
00639 DSHOW_ERROR_IF_FAILED(esf_compression->SetAverageBitrate(average_bitrate_));
00640 }
00641
00642 if (is_property_changed_.test(esf_property_video_quality))
00643 {
00644 DSHOW_ERROR_IF_FAILED(esf_compression->SetVideoQuality(video_quality_));
00645 }
00646
00647 if (is_property_changed_.test(esf_property_gop_structure))
00648 {
00649 DSHOW_ERROR_IF_FAILED(esf_compression->SetGopStructure(gop_structure_));
00650 }
00651
00652 if (is_property_changed_.test(esf_property_gop_size))
00653 {
00654 DSHOW_ERROR_IF_FAILED(esf_compression->SetGopSize(gop_size_));
00655 }
00656 }
00657
00658 void vidl_dshow_istream_params_esf
00659 ::print_parameter_help(const vcl_string& name)
00660 {
00661 vidl_dshow::initialize_com();
00662
00663 CComPtr<IMoniker> moniker = vidl_dshow::get_capture_device_moniker(name);
00664
00665 CComPtr<IBaseFilter> filter;
00666 DSHOW_ERROR_IF_FAILED(moniker->BindToObject(
00667 0, 0, IID_IBaseFilter, reinterpret_cast<void**>(&filter)));
00668
00669 print_parameter_help(filter);
00670 }
00671
00672 void vidl_dshow_istream_params_esf
00673 ::print_parameter_help(const CComPtr<IBaseFilter>& filter)
00674 {
00675 vcl_cout << "\n\nEuresys MultiCam DirectShow (IESFilter) Parameters\n"
00676 << "--------------------------------------------------\n"
00677 << "1. IESFProperties interface:\n\n";
00678
00679
00680 CComPtr<IESFProperties> esf_properties;
00681 filter->QueryInterface(
00682 IID_IESFProperties, reinterpret_cast<void**>(&esf_properties));
00683
00684 print_video_standard_help (esf_properties);
00685 vcl_cout << '\n';
00686
00687 print_resolution_help (esf_properties);
00688 vcl_cout << '\n';
00689
00690 print_output_format_help (esf_properties);
00691 vcl_cout << '\n';
00692
00693
00694 vcl_cout << vcl_string(w1, ' ')
00695 << vcl_setw(w2) << "curr"
00696 << vcl_setw(w2) << "min"
00697 << vcl_setw(w2) << "max"
00698 << vcl_setw(w2) << "default"
00699 << '\n'
00700 << vcl_string(w1, ' ')
00701 << vcl_string(4*w2, '-') << '\n';
00702
00703 print_capture_region_size_help(esf_properties);
00704 print_capture_region_pos_help (esf_properties);
00705 print_capture_rate_help (esf_properties);
00706 print_brightness_help (esf_properties);
00707 print_contrast_help (esf_properties);
00708 print_saturation_help (esf_properties);
00709 print_board_help (esf_properties);
00710 print_connector_help (esf_properties);
00711 print_individual_control_help (esf_properties);
00712 vcl_cout << '\n';
00713
00714
00715 CComPtr<IESFCompression> esf_compression;
00716 filter->QueryInterface(
00717 IID_IESFCompression, reinterpret_cast<void**>(&esf_compression));
00718
00719 vcl_cout << "2. IESFCompression interface:\n\n";
00720
00721 print_bitrate_control_help(esf_compression);
00722 vcl_cout << '\n';
00723
00724
00725 vcl_cout << vcl_string(w1, ' ')
00726 << vcl_setw(w2) << "curr"
00727 << vcl_setw(w2) << "min"
00728 << vcl_setw(w2) << "max"
00729 << vcl_setw(w2) << "default"
00730 << '\n'
00731 << vcl_string(w1, ' ')
00732 << vcl_string(4*w2, '-') << '\n';
00733
00734 print_average_bitrate_help(esf_compression);
00735 print_video_quality_help (esf_compression);
00736 print_gop_size_help (esf_compression);
00737 vcl_cout << '\n';
00738
00739 print_gop_structure_help (esf_compression);
00740 vcl_cout << '\n' << vcl_endl;
00741 }
00742
00743
00744
00745 vidl_dshow_istream_params_esf&
00746 vidl_dshow_istream_params_esf
00747 ::set_properties(const vcl_map<vcl_string,vcl_string>& props)
00748 {
00749 vcl_map<vcl_string,vcl_string>::const_iterator iter;
00750 for (iter = props.begin(); iter != props.end(); iter++)
00751 {
00752 if (iter->first == "register_in_rot")
00753 {
00754 set_register_in_rot(from_string_to<bool>()(iter->second));
00755 }
00756 else if (iter->first == "run_when_ready")
00757 {
00758 set_run_when_ready(from_string_to<bool>()(iter->second));
00759 }
00760 else if (iter->first == "save_graph_to")
00761 {
00762 set_save_graph_to(iter->second);
00763 }
00764 else if (iter->first == "device_name")
00765 {
00766 set_device_name(iter->second);
00767 }
00768 else if (iter->first == "output_filename")
00769 {
00770 set_output_filename(iter->second);
00771 }
00772 else if (iter->first == "target_output_format")
00773 {
00774 set_target_output_format(from_string_to<GUID>()(iter->second));
00775 }
00776 else if (iter->first == "video_standard")
00777 {
00778 vcl_pair<ESF_VIDEO_STANDARD,bool> vs
00779 = from_string_to_pair<ESF_VIDEO_STANDARD,bool>()(iter->second);
00780 set_video_standard(vs.first, vs.second);
00781 }
00782 else if (iter->first == "resolution")
00783 {
00784 vbl_triple<ESF_RESOLUTION,long,long> res
00785 = from_string_to_triple<ESF_RESOLUTION,long,long>()(iter->second);
00786 set_resolution(res.first, res.second, res.third);
00787 }
00788 else if (iter->first == "capture_region_size")
00789 {
00790 vcl_pair<long,long> size
00791 = from_string_to_pair<long,long>()(iter->second);
00792 set_capture_region_size(size.first, size.second);
00793 }
00794 else if (iter->first == "capture_region_pos")
00795 {
00796 vcl_pair<long,long> pos
00797 = from_string_to_pair<long,long>()(iter->second);
00798 set_capture_region_pos(pos.first, pos.second);
00799 }
00800 else if (iter->first == "output_format")
00801 {
00802 set_output_format(from_string_to<GUID>()(iter->second));
00803 }
00804 else if (iter->first == "capture_rate")
00805 {
00806 set_capture_rate(from_string_to<double>()(iter->second));
00807 }
00808 else if (iter->first == "brightness")
00809 {
00810 set_brightness(from_string_to<long>()(iter->second));
00811 }
00812 else if (iter->first == "contrast")
00813 {
00814 set_contrast(from_string_to<long>()(iter->second));
00815 }
00816 else if (iter->first == "saturation")
00817 {
00818 set_saturation(from_string_to<long>()(iter->second));
00819 }
00820 else if (iter->first == "bitrate_control")
00821 {
00822 set_bitrate_control(from_string_to<ESF_BITRATECONTROL>()(iter->second));
00823 }
00824 else if (iter->first == "average_bitrate")
00825 {
00826 set_average_bitrate(from_string_to<long>()(iter->second));
00827 }
00828 else if (iter->first == "video_quality")
00829 {
00830 set_video_quality(from_string_to<long>()(iter->second));
00831 }
00832 else if (iter->first == "gop_structure")
00833 {
00834 set_gop_structure(from_string_to<ESF_GOPSTRUCTURE>()(iter->second));
00835 }
00836 else if (iter->first == "gop_size")
00837 {
00838 set_gop_size(from_string_to<long>()(iter->second));
00839 }
00840 else
00841 {
00842 vcl_cerr << "DSHOW: vidl_dshow_istream_params_esf param not valid: "
00843 << iter->first << vcl_endl;
00844 }
00845 }
00846
00847 return *this;
00848 }
00849
00850
00851
00852
00853
00854
00855
00856
00857 vidl_dshow_istream_params_esf&
00858 vidl_dshow_istream_params_esf::set_register_in_rot(bool val)
00859 {
00860 register_in_rot_ = val;
00861 return *this;
00862 }
00863
00864 vidl_dshow_istream_params_esf&
00865 vidl_dshow_istream_params_esf::set_run_when_ready(bool val)
00866 {
00867 run_when_ready_ = val;
00868 return *this;
00869 }
00870
00871 vidl_dshow_istream_params_esf&
00872 vidl_dshow_istream_params_esf::set_save_graph_to(const vcl_string& name)
00873 {
00874 save_graph_to_ = name;
00875 return *this;
00876 }
00877
00878 vidl_dshow_istream_params_esf&
00879 vidl_dshow_istream_params_esf::set_device_name(const vcl_string& name)
00880 {
00881 device_name_ = name;
00882 return *this;
00883 }
00884
00885 vidl_dshow_istream_params_esf&
00886 vidl_dshow_istream_params_esf::set_output_filename(const vcl_string& name)
00887 {
00888 output_filename_ = name;
00889 return *this;
00890 }
00891
00892 vidl_dshow_istream_params_esf&
00893 vidl_dshow_istream_params_esf::set_target_output_format(GUID val)
00894 {
00895 target_output_format_ = val;
00896 return *this;
00897 }
00898
00899 vidl_dshow_istream_params_esf&
00900 vidl_dshow_istream_params_esf::set_video_standard(
00901 ESF_VIDEO_STANDARD val, bool mono)
00902 {
00903 video_standard_ = val;
00904 is_monochrome_ = mono;
00905 is_property_changed_.set(esf_property_video_standard);
00906 return *this;
00907 }
00908
00909 vidl_dshow_istream_params_esf&
00910 vidl_dshow_istream_params_esf::set_resolution(
00911 ESF_RESOLUTION val, long width = 0, long height = 0)
00912 {
00913 resolution_ = val;
00914 width_ = width;
00915 height_ = height;
00916 is_property_changed_.set(esf_property_resolution);
00917 return *this;
00918 }
00919
00920 vidl_dshow_istream_params_esf&
00921 vidl_dshow_istream_params_esf::set_capture_region_size(long val_x, long val_y)
00922 {
00923 capture_region_size_x_ = val_x;
00924 capture_region_size_y_ = val_y;
00925 is_property_changed_.set(esf_property_capture_region_size);
00926 return *this;
00927 }
00928
00929 vidl_dshow_istream_params_esf&
00930 vidl_dshow_istream_params_esf::set_capture_region_pos(long val_x, long val_y)
00931 {
00932 capture_region_pos_x_ = val_x;
00933 capture_region_pos_y_ = val_y;
00934 is_property_changed_.set(esf_property_capture_region_pos);
00935 return *this;
00936 }
00937
00938 vidl_dshow_istream_params_esf&
00939 vidl_dshow_istream_params_esf::set_output_format(GUID val)
00940 {
00941 output_format_ = val;
00942 is_property_changed_.set(esf_property_output_format);
00943 return *this;
00944 }
00945
00946 vidl_dshow_istream_params_esf&
00947 vidl_dshow_istream_params_esf::set_capture_rate(double val)
00948 {
00949 capture_rate_ = val;
00950 is_property_changed_.set(esf_property_capture_rate);
00951 return *this;
00952 }
00953
00954 vidl_dshow_istream_params_esf&
00955 vidl_dshow_istream_params_esf::set_brightness(long val)
00956 {
00957 brightness_ = val;
00958 is_property_changed_.set(esf_property_brightness);
00959 return *this;
00960 }
00961 vidl_dshow_istream_params_esf&
00962 vidl_dshow_istream_params_esf::set_contrast(long val)
00963 {
00964 contrast_ = val;
00965 is_property_changed_.set(esf_property_contrast);
00966 return *this;
00967 }
00968
00969 vidl_dshow_istream_params_esf&
00970 vidl_dshow_istream_params_esf::set_saturation(long val)
00971 {
00972 saturation_ = val;
00973 is_property_changed_.set(esf_property_saturation);
00974 return *this;
00975 }
00976
00977 vidl_dshow_istream_params_esf&
00978 vidl_dshow_istream_params_esf::set_bitrate_control(ESF_BITRATECONTROL val)
00979 {
00980 bitrate_control_ = val;
00981 is_property_changed_.set(esf_property_bitrate_control);
00982 return *this;
00983 }
00984
00985 vidl_dshow_istream_params_esf&
00986 vidl_dshow_istream_params_esf::set_average_bitrate(long val)
00987 {
00988 average_bitrate_ = val;
00989 is_property_changed_.set(esf_property_average_bitrate);
00990 return *this;
00991 }
00992
00993 vidl_dshow_istream_params_esf&
00994 vidl_dshow_istream_params_esf::set_video_quality(long val)
00995 {
00996 video_quality_ = val;
00997 is_property_changed_.set(esf_property_video_quality);
00998 return *this;
00999 }
01000
01001 vidl_dshow_istream_params_esf&
01002 vidl_dshow_istream_params_esf::set_gop_structure(ESF_GOPSTRUCTURE val)
01003 {
01004 gop_structure_ = val;
01005 is_property_changed_.set(esf_property_gop_structure);
01006 return *this;
01007 }
01008
01009 vidl_dshow_istream_params_esf&
01010 vidl_dshow_istream_params_esf::set_gop_size(long val)
01011 {
01012 gop_size_ = val;
01013 is_property_changed_.set(esf_property_gop_size);
01014 return *this;
01015 }