00001 00002 //#include "stdafx.h" 00003 #include "videosource.h" 00004 00005 #include "iniparser.h" 00006 00007 #ifdef WITH_DSHOWFILE 00008 # include "dshowfile.h" 00009 #endif 00010 #ifdef WITH_DSHOWCB 00011 # include "dshowcb.h" 00012 #endif 00013 00014 #ifdef WITH_FLYCAPTURE 00015 # include "flycapturevs.h" 00016 #endif 00017 #ifdef WITH_FWCAM 00018 # include "fwcam.h" 00019 #endif 00020 00021 #ifdef WITH_LINUXDV 00022 #include "linuxdv.h" 00023 #endif 00024 00025 #ifdef WITH_AVIDV 00026 #include "avidv.h" 00027 #endif 00028 00029 #include "bmpvideosource.h" 00030 00031 #include "opencv_vs.h" 00032 00033 #ifdef WITH_MPLAYER 00034 #include "mplayer.h" 00035 #endif 00036 00037 #ifdef WITH_PNGTRANSP 00038 #include "pngtranspvs.h" 00039 #endif 00040 00041 #ifdef WITH_DC1394 00042 #include "dc1394vs.h" 00043 #endif 00044 00045 VideoSourceFactory* VideoSourceFactory::factory=0; 00046 00047 00048 void VideoSourceFactory::registerParameters(IniParser *parser) 00049 { 00050 ParamSection *sec = new ParamSection(); 00051 sec->name = "VIDEO"; 00052 parser->addSection(sec); 00053 00054 registerParameters(sec); 00055 } 00056 00057 void VideoSourceFactory::registerParameters(ParamSection *sec) 00058 { 00059 for (FactoryVector::iterator it(factories.begin()); it != factories.end(); ++it) { 00060 (*it)->registerParameters(sec); 00061 } 00062 } 00063 00064 VideoSource *VideoSourceFactory::construct() { 00065 for (FactoryVector::iterator it(factories.begin()); it != factories.end(); ++it) { 00066 VideoSource *s= (*it)->construct(); 00067 if (s) return s; 00068 } 00069 return 0; 00070 } 00071 00072 // Singleton implementation 00073 VideoSourceFactory *VideoSourceFactory::instance() { 00074 if (!factory) factory = new VideoSourceFactory(); 00075 return factory; 00076 } 00077 00078 VideoSourceFactory::VideoSourceFactory() { 00079 00080 registerFactory( new BmpFactory() ); 00081 00082 #ifdef WITH_DSHOWFILE 00083 registerFactory( new DShowFileFactory() ); 00084 #endif 00085 00086 #ifdef WITH_DSHOWCB 00087 registerFactory( new DShowCBFactory() ); 00088 #endif 00089 00090 #ifdef WITH_FLYCAPTURE 00091 registerFactory( new FlyCaptureFactory() ); 00092 #endif 00093 00094 #ifdef WITH_AVIDV 00095 registerFactory( new AviDVFactory() ); 00096 #endif 00097 00098 #ifdef WITH_FWCAM 00099 registerFactory( new FWCamFactory() ); 00100 #endif 00101 00102 #ifdef WITH_DC1394 00103 registerFactory( new DC1394Factory() ); 00104 #endif 00105 00106 #ifdef WITH_LINUXDV 00107 registerFactory( new LinuxDVFactory() ); 00108 #endif 00109 00110 #ifdef WITH_MPLAYER 00111 registerFactory( new MPlayerFactory() ); 00112 #endif 00113 00114 registerFactory( new OpenCVFactory() ); 00115 00116 #ifdef WITH_PNGTRANSP 00117 registerFactory( new PngTranspFactory() ); 00118 #endif 00119 00120 } 00121 00122 VideoSourceFactory::~VideoSourceFactory() { 00123 00124 for (FactoryVector::iterator it(factories.begin()); it != factories.end(); ++it) { 00125 delete *it; 00126 } 00127 } 00128