core/vidl/vidl_dshow_istream_params_esf.h
Go to the documentation of this file.
00001 // This is core/vidl/vidl_dshow_istream_params_esf.h
00002 #ifndef vidl_dshow_istream_params_esf_h_
00003 #define vidl_dshow_istream_params_esf_h_
00004 //=========================================================================
00005 //:
00006 // \file
00007 // \brief  Euresys Source Filter (ESF) DirectShow istream parameter block.
00008 // \author Miguel A. Figueroa-Villanueva (miguelf at ieee dot org)
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   02/18/2006 - File created. (miguelf)
00013 // \endverbatim
00014 //=========================================================================
00015 
00016 #include <vcl_string.h>
00017 #include <vcl_bitset.h>
00018 #include <vcl_map.h>
00019 
00020 #include <atlbase.h>
00021 #include <dshow.h>
00022 
00023 #include <initguid.h>
00024 #include <ESFilter.h>
00025 
00026 //-------------------------------------------------------------------------
00027 //: Param struct for DirectShow input streams using Euresys Source Filter.
00028 //
00029 // Enables the configuration of DirectShow Euresys source filters
00030 // (IESFilter) through the IESFProperties and IESFCompression interfaces.
00031 //
00032 // Example Usage:
00033 // \code
00034 //   vidl_dshow_istream = vidl_dshow_istream(vidl_dshow_istream_params()
00035 //                                             .set_xxx(xxx));
00036 // \endcode
00037 //-------------------------------------------------------------------------
00038 class vidl_dshow_istream_params_esf //: public vidl_iostream_params
00039 {
00040  public:
00041   //: Constructor - default
00042   vidl_dshow_istream_params_esf();
00043 
00044   //: Configure the source filter based on the parameters.
00045   void configure_filter(const CComPtr<IBaseFilter>& source);
00046 
00047   //: Print a list of parameters and proper value ranges.
00048   static void print_parameter_help(const vcl_string& name);
00049 
00050   //: Print a list of parameters and proper value ranges.
00051   static void print_parameter_help(const CComPtr<IBaseFilter>& filter);
00052 
00053   //: Set properties from a map(string,value).
00054   vidl_dshow_istream_params_esf& set_properties(
00055     const vcl_map<vcl_string,vcl_string>& props);
00056 
00057   // Read accessor functions
00058   // - general params (all dshow_params should have)
00059   bool register_in_rot()       const { return register_in_rot_;      }
00060   bool run_when_ready()        const { return run_when_ready_;       }
00061   vcl_string save_graph_to()   const { return save_graph_to_;        }
00062   vcl_string device_name()     const { return device_name_;          }
00063   vcl_string output_filename() const { return output_filename_;      }
00064   GUID target_output_format()  const { return target_output_format_; }
00065 
00066   // Write accessor functions.
00067   // - general params (all dshow_params should have)
00068   vidl_dshow_istream_params_esf& set_register_in_rot(bool);
00069   vidl_dshow_istream_params_esf& set_run_when_ready(bool);
00070   vidl_dshow_istream_params_esf& set_save_graph_to(const vcl_string&);
00071   vidl_dshow_istream_params_esf& set_device_name(const vcl_string&);
00072   vidl_dshow_istream_params_esf& set_output_filename(const vcl_string&);
00073   vidl_dshow_istream_params_esf& set_target_output_format(GUID);
00074   // - IESFProperties specific (see Euresys Source Filter documentation)
00075   vidl_dshow_istream_params_esf& set_video_standard(ESF_VIDEO_STANDARD,bool);
00076   vidl_dshow_istream_params_esf& set_resolution(ESF_RESOLUTION,long,long);
00077   vidl_dshow_istream_params_esf& set_capture_region_size(long,long);
00078   vidl_dshow_istream_params_esf& set_capture_region_pos(long,long);
00079   vidl_dshow_istream_params_esf& set_output_format(GUID);
00080   vidl_dshow_istream_params_esf& set_capture_rate(double);
00081   vidl_dshow_istream_params_esf& set_brightness(long);
00082   vidl_dshow_istream_params_esf& set_contrast(long);
00083   vidl_dshow_istream_params_esf& set_saturation(long);
00084   // - IESFCompression specific (see Euresys Source Filter documentation)
00085   vidl_dshow_istream_params_esf& set_bitrate_control(ESF_BITRATECONTROL);
00086   vidl_dshow_istream_params_esf& set_average_bitrate(long);
00087   vidl_dshow_istream_params_esf& set_video_quality(long);
00088   vidl_dshow_istream_params_esf& set_gop_structure(ESF_GOPSTRUCTURE);
00089   vidl_dshow_istream_params_esf& set_gop_size(long);
00090 
00091  private:
00092   enum esf_property
00093   {
00094     esf_property_video_standard = 0,
00095     esf_property_resolution,
00096     esf_property_capture_region_size,
00097     esf_property_capture_region_pos,
00098     esf_property_output_format,
00099     esf_property_capture_rate,
00100     esf_property_brightness,
00101     esf_property_contrast,
00102     esf_property_saturation,
00103     esf_property_bitrate_control,
00104     esf_property_average_bitrate,
00105     esf_property_video_quality,
00106     esf_property_gop_structure,
00107     esf_property_gop_size,
00108     esf_property_enum_size // needs to be at the end
00109   };
00110 
00111   //: Flag param to be used in configure_filter.
00112   vcl_bitset<esf_property_enum_size> is_property_changed_;
00113 
00114   //: Enable remote graph viewing with GraphEdit.
00115   bool register_in_rot_;
00116 
00117   //: Immediately run graph after creating it, else wait for run command.
00118   bool run_when_ready_;
00119 
00120   //: Write the filter graph to filename 'save_graph_to_'.
00121   vcl_string save_graph_to_;
00122 
00123   //: Device name.
00124   vcl_string device_name_;
00125 
00126   //: If non-empty create file writing section in the filter_graph.
00127   vcl_string output_filename_;
00128 
00129   //: Target output format, as returned by current_frame.
00130   GUID target_output_format_;
00131 
00132   // IESFProperties interface.
00133   ESF_VIDEO_STANDARD video_standard_;
00134   bool is_monochrome_;
00135   ESF_RESOLUTION resolution_;
00136   long width_;
00137   long height_;
00138   long capture_region_size_x_;
00139   long capture_region_size_y_;
00140   long capture_region_pos_x_;
00141   long capture_region_pos_y_;
00142   GUID output_format_;
00143   double capture_rate_;
00144   long brightness_;
00145   long contrast_;
00146   long saturation_;
00147 
00148   // IESFCompression interface.
00149   ESF_BITRATECONTROL bitrate_control_;
00150   long average_bitrate_;
00151   long video_quality_;
00152   ESF_GOPSTRUCTURE gop_structure_;
00153   long gop_size_;
00154 };
00155 
00156 #endif // vidl_dshow_istream_params_esf_h_