Go to the documentation of this file.00001
00002 #ifndef vidl_dshow_h_
00003 #define vidl_dshow_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <vidl/vidl_exception.h>
00019 #include <vidl/vidl_pixel_format.h>
00020
00021 #include <vcl_string.h>
00022 #include <vcl_vector.h>
00023 #include <vcl_iostream.h>
00024
00025 #include <atlbase.h>
00026 #include <dshow.h>
00027 #include <qedit.h>
00028
00029 struct vidl_dshow
00030 {
00031
00032 static void initialize_com();
00033
00034
00035 static vcl_string get_error_text(const char* file, int line, HRESULT hr);
00036
00037
00038 static void register_in_rot(IUnknown* unknown, DWORD& reg);
00039
00040
00041 static void remove_from_rot(DWORD reg);
00042
00043
00044 static void save_graph_to_file(const CComPtr<IFilterGraph2>& filter_graph,
00045 const vcl_string& filename);
00046
00047
00048 static void load_graph_from_file(const CComPtr<IFilterGraph2>& filter_graph,
00049 const vcl_wstring& filename);
00050
00051
00052 static vcl_string get_guid_name(const GUID& guid);
00053
00054
00055 static GUID get_guid_from_fourcc(const vcl_string& fourcc);
00056
00057
00058 static void get_media_info(const AM_MEDIA_TYPE& amt,
00059 unsigned int& width,
00060 unsigned int& height,
00061 vidl_pixel_format& pixel_format);
00062
00063
00064 static void delete_media_type(AM_MEDIA_TYPE& amt);
00065
00066
00067 static void print_capture_device_names();
00068
00069
00070 static vcl_vector<vcl_string> get_capture_device_names();
00071
00072
00073 static CComPtr<IMoniker> get_capture_device_moniker(const vcl_string& name);
00074
00075 #if 0
00076 static void build_filter_graph(
00077 CComPtr<IFilterGraph2>& filter_graph,
00078 CComPtr<IMoniker>& moniker,
00079 CComPtr<ISampleGrabber>& sample_grabber);
00080 #endif
00081
00082 static void connect_filters(CComPtr<IFilterGraph2>& filter_graph,
00083 CComPtr<IBaseFilter>& source,
00084 CComPtr<IBaseFilter>& target);
00085 };
00086
00087
00088 #define DSHOW_GET_ERROR_TEXT(hr) \
00089 vidl_dshow::get_error_text(__FILE__,__LINE__,(hr))
00090
00091 #define DSHOW_WARN_IF_FAILED(stm) { \
00092 HRESULT hr = (stm); \
00093 if FAILED(hr) { \
00094 vcl_cerr << vidl_dshow_exception( \
00095 vidl_dshow::get_error_text(__FILE__,__LINE__,hr)).what()\
00096 << '\n'; \
00097 }}
00098
00099 #define DSHOW_ERROR_IF_FAILED(stm) { \
00100 HRESULT hr = (stm); \
00101 if FAILED(hr) { \
00102 vidl_exception_error(vidl_dshow_exception( \
00103 vidl_dshow::get_error_text(__FILE__,__LINE__,hr)));\
00104 }}
00105
00106 #endif // vidl_dshow_h_