core/vidl/vidl_dshow_istream_params.h
Go to the documentation of this file.
00001 // This is core/vidl/vidl_dshow_istream_params.h
00002 #ifndef vidl_dshow_istream_params_h_
00003 #define vidl_dshow_istream_params_h_
00004 //=========================================================================
00005 //:
00006 // \file
00007 // \brief  DirectShow input stream parameter block.
00008 // \author Miguel A. Figueroa-Villanueva (miguelf at ieee dot org)
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   01/30/2006 - File created. (miguelfv)
00013 // \endverbatim
00014 //=========================================================================
00015 
00016 #include <vcl_string.h>
00017 #include <vcl_map.h>
00018 
00019 #include <atlbase.h>
00020 #include <dshow.h>
00021 
00022 //-------------------------------------------------------------------------
00023 // ***** implementation detail...
00024 //       maybe remove from here and forward declare
00025 // *****
00026 //-------------------------------------------------------------------------
00027 struct null_type {};
00028 
00029 template <typename T, typename U = null_type>
00030 struct property_wrap;
00031 
00032 template <typename T, typename U>
00033 struct property_wrap
00034 {
00035   T     key;
00036   U     value;
00037   bool  is_changed;
00038 
00039   property_wrap(const T& key_tag = T())
00040     : key(key_tag)
00041     , is_changed(false)
00042   {}
00043 };
00044 
00045 template <typename U>
00046 struct property_wrap<U,null_type>
00047 {
00048   U     value;
00049   bool  is_changed;
00050 
00051   property_wrap()
00052     : is_changed(false)
00053   {}
00054 };
00055 
00056 typedef property_wrap<VideoProcAmpProperty,long> vpa_property_wrap;
00057 
00058 //-------------------------------------------------------------------------
00059 //: Parameter structure for DirectShow input streams.
00060 //
00061 // Enables the configuration of DirectShow source filters through the
00062 // IAMVideoProcAmp and IAMStreamConfig interfaces.
00063 //
00064 // Example Usage:
00065 // \code
00066 //   vidl_dshow_istream = vidl_dshow_istream(vidl_dshow_istream_params()
00067 //                                             .set_xxx(xxx));
00068 // \endcode
00069 //-------------------------------------------------------------------------
00070 class vidl_dshow_istream_params //: public vidl_iostream_params
00071 {
00072  public:
00073   //: Constructor - default
00074   vidl_dshow_istream_params();
00075 
00076   //: Configure the source filter based on the parameters.
00077   void configure_filter(const CComPtr<IBaseFilter>& source);
00078 
00079   //: Print a list of parameters and proper value ranges.
00080   static void print_parameter_help(const vcl_string& name);
00081 
00082   //: Print a list of parameters and proper value ranges.
00083   static void print_parameter_help(const CComPtr<IBaseFilter>& filter);
00084 
00085   //: Set properties from a map(string,value).
00086   vidl_dshow_istream_params& set_properties(
00087     const vcl_map<vcl_string,vcl_string>& props);
00088 
00089   // Read accessor functions
00090   // - general params (all dshow_params should have)
00091   bool register_in_rot()       const { return register_in_rot_;      }
00092   bool run_when_ready()        const { return run_when_ready_;       }
00093   vcl_string save_graph_to()   const { return save_graph_to_;        }
00094   vcl_string device_name()     const { return device_name_;          }
00095   vcl_string output_filename() const { return output_filename_;      }
00096   GUID target_output_format()  const { return target_output_format_; }
00097 
00098   // Write accessor functions.
00099   // - general params (all dshow_params should have)
00100   vidl_dshow_istream_params& set_register_in_rot(bool);
00101   vidl_dshow_istream_params& set_run_when_ready(bool);
00102   vidl_dshow_istream_params& set_save_graph_to(const vcl_string&);
00103   vidl_dshow_istream_params& set_device_name(const vcl_string&);
00104   vidl_dshow_istream_params& set_output_filename(const vcl_string&);
00105   vidl_dshow_istream_params& set_target_output_format(GUID);
00106   vidl_dshow_istream_params& set_load_filter_defaults(bool);
00107   // - IAMVideoProcAmp specific (see DirectShow documentation)
00108   // - IAMStreamConfig specific (see DirectShow documentation)
00109   vidl_dshow_istream_params& set_output_format(int);
00110 
00111  private:
00112   //: Enable remote graph viewing with GraphEdit.
00113   bool register_in_rot_;
00114 
00115   //: Immediately run graph after creating it, else wait for run command.
00116   bool run_when_ready_;
00117 
00118   //: Write the filter graph to filename 'save_graph_to_'.
00119   vcl_string save_graph_to_;
00120 
00121   //: Device name.
00122   vcl_string device_name_;
00123 
00124   //: If non-empty create file writing section in the filter_graph.
00125   vcl_string output_filename_;
00126 
00127   //: Target output format, as returned by current_frame.
00128   GUID target_output_format_;
00129 
00130   //: Load source filter defaults for values not manually set.
00131   bool load_filter_defaults_;
00132 
00133   // IAMVideoProcAmp interface.
00134   vcl_map<vcl_string,vpa_property_wrap> vpa_properties_;
00135   //long brightness_;
00136   //long contrast_;
00137   //long hue_;
00138   //long saturation_;
00139   //long sharpness_;
00140   //long gamma_;
00141   //long color_enable_;
00142   //long white_balance_;
00143   //long backlight_compensation_;
00144   //long gain_;
00145 
00146   // IAMStreamConfig interface.
00147   property_wrap<int> output_format_;
00148   //long output_format_;
00149 };
00150 
00151 #endif // vidl_dshow_istream_params_h_