Panda3D
|
00001 // Filename: webcamVideo.cxx 00002 // Created by: jyelon (01Nov2007) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "webcamVideo.h" 00016 #include "pandabase.h" 00017 #include "movieVideoCursor.h" 00018 00019 pvector<PT(WebcamVideo)> WebcamVideo::_all_webcams; 00020 TypeHandle WebcamVideo::_type_handle; 00021 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: WebcamVideo::Destructor 00025 // Access: Published, Virtual 00026 // Description: 00027 //////////////////////////////////////////////////////////////////// 00028 WebcamVideo:: 00029 ~WebcamVideo() { 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: WebcamVideo::find_all_webcams 00034 // Access: Public 00035 // Description: Scans the hardware for webcams, and pushes them 00036 // onto the global list of all webcams. 00037 // 00038 // There are several implementations of WebcamVideo, 00039 // including one based on DirectShow, one based on 00040 // Video4Linux, and so forth. These implementations 00041 // are contained in one C++ file each, and they export 00042 // nothing at all except a single "find_all" function. 00043 // Otherwise, they can only be accessed through the 00044 // virtual methods of the WebcamVideo objects they 00045 // create. 00046 //////////////////////////////////////////////////////////////////// 00047 void WebcamVideo:: 00048 find_all_webcams() { 00049 static bool initialized = false; 00050 if (initialized) return; 00051 initialized = true; 00052 00053 #ifdef HAVE_DIRECTCAM 00054 extern void find_all_webcams_ds(); 00055 find_all_webcams_ds(); 00056 #endif 00057 00058 #ifdef HAVE_VIDEO4LINUX 00059 extern void find_all_webcams_v4l(); 00060 find_all_webcams_v4l(); 00061 #endif 00062 00063 #if defined(HAVE_OPENCV) && !defined(HAVE_DIRECTCAM) && !defined(HAVE_VIDEO4LINUX) 00064 extern void find_all_webcams_opencv(); 00065 find_all_webcams_opencv(); 00066 #endif 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: WebcamVideo::get_num_options 00071 // Access: Public, Static 00072 // Description: Returns the number of webcam options. An "option" 00073 // consists of a device plus a set of configuration 00074 // parameters. For example, "Creative Webcam Live at 00075 // 640x480, 30 fps" is an option. 00076 //////////////////////////////////////////////////////////////////// 00077 int WebcamVideo:: 00078 get_num_options() { 00079 find_all_webcams(); 00080 return _all_webcams.size(); 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: WebcamVideo::get_option 00085 // Access: Public, Static 00086 // Description: Returns the nth webcam option. 00087 //////////////////////////////////////////////////////////////////// 00088 PT(WebcamVideo) WebcamVideo:: 00089 get_option(int n) { 00090 find_all_webcams(); 00091 nassertr((n >= 0) && (n < (int)_all_webcams.size()), NULL); 00092 return _all_webcams[n]; 00093 }