Gnash
0.8.10
|
00001 // VideoInput.h: Video input processing using Gstreamer 00002 // 00003 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 00004 // Free Software Foundation, Inc. 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 00020 #ifndef GNASH_VIDEOINPUTGST_H 00021 #define GNASH_VIDEOINPUTGST_H 00022 00023 #include <vector> 00024 #include <boost/cstdint.hpp> // for C99 int types 00025 #include "VideoInput.h" 00026 #include "gst/gst.h" 00027 00028 namespace gnash { 00029 namespace media { 00034 namespace gst { 00035 00036 class GnashWebcam; 00037 class GnashWebcamPrivate; 00038 00044 class FramerateFraction 00045 { 00046 public: 00049 gint numerator; 00052 gint denominator; 00053 00059 FramerateFraction(gint num, gint denom); 00060 00062 FramerateFraction(); 00063 }; 00064 00069 class WebcamVidFormat 00070 { 00071 public: 00076 gchar *mimetype; 00077 00081 gint width; 00082 00086 gint height; 00087 00091 gint numFramerates; 00092 00098 FramerateFraction *framerates; 00099 00103 FramerateFraction highestFramerate; 00104 00106 WebcamVidFormat(); 00107 }; 00108 00109 00116 class VideoInputGst : public VideoInput 00117 { 00118 public: 00119 00121 VideoInputGst(); 00122 00124 ~VideoInputGst(); 00125 00126 static void getNames(std::vector<std::string>& names); 00127 00129 // 00132 double activityLevel () const { return _activityLevel; } 00133 00135 // 00137 size_t bandwidth() const { return _bandwidth; } 00138 00139 void setBandwidth(size_t bandwidth) { 00140 _bandwidth = bandwidth; 00141 } 00142 00144 // 00146 double currentFPS() const { return _currentFPS; } 00147 00149 // 00151 double fps() const { return _fps; } 00152 00154 size_t height() const { return _height; } 00155 00157 size_t width() const { return _width; } 00158 00160 size_t index() const { return _index; } 00161 00163 // 00168 void requestMode(size_t width, size_t height, double fps, bool favorArea); 00169 00171 void setMotionLevel(int m) { _motionLevel = m; } 00172 00174 int motionLevel() const { return _motionLevel; } 00175 00177 void setMotionTimeout(int m) { _motionTimeout = m; } 00178 00180 int motionTimeout() const { return _motionTimeout; } 00181 00182 void mute(bool m) { _muted = m; } 00183 bool muted() const { return _muted; } 00184 00186 // 00188 const std::string& name() const { return _name; } 00189 00191 void setQuality(int q) { _quality = q; } 00192 00194 int quality() const { return _quality; } 00195 00200 bool play(); 00201 00205 bool stop(); 00206 00207 00209 // 00219 bool setWebcam(size_t index); 00220 00222 // 00224 // 00227 bool init(); 00228 00237 int makeWebcamDeviceSelection(); 00238 00242 00250 gboolean webcamMakeVideoSaveLink(); 00251 00257 gboolean webcamBreakVideoSaveLink(); 00258 00269 gboolean webcamCreateSaveBin(); 00270 00279 gboolean webcamMakeVideoDisplayLink(); 00280 00288 gboolean webcamBreakVideoDisplayLink(); 00289 00290 private: 00291 00292 00306 void getSelectedCaps(gint dev_select); 00307 00318 void getSupportedFormats(GnashWebcam *cam, GstCaps *caps); 00319 00329 void addSupportedFormat(GnashWebcam *cam, WebcamVidFormat *video_format, 00330 GstStructure *format_structure); 00331 00344 void getSupportedFramerates(WebcamVidFormat *video_format, 00345 GstStructure *structure); 00346 00353 gboolean checkForSupportedFramerate (GnashWebcamPrivate *webcam, int fps); 00354 00363 void findHighestFramerate(WebcamVidFormat *format); 00364 00375 gboolean webcamCreateSourceBin(); 00376 00382 gboolean webcamChangeSourceBin(); 00383 00394 gboolean webcamCreateMainBin(); 00395 00406 gboolean webcamCreateDisplayBin(); 00407 00408 00409 00413 GnashWebcamPrivate* getGlobalWebcam() {return _globalWebcam;} 00414 00419 // 00422 static void findVidDevs(std::vector<GnashWebcam*>& cams); 00423 00426 std::vector<GnashWebcam*> _vidVect; 00427 00431 int _devSelection; 00432 00436 gint _numdevs; 00437 00441 GnashWebcamPrivate *_globalWebcam; 00442 00446 00449 double _activityLevel; 00450 00453 size_t _bandwidth; 00454 00457 double _currentFPS; 00458 00460 double _fps; 00461 00464 size_t _height; 00465 00468 size_t _width; 00469 00471 size_t _index; 00472 00474 int _motionLevel; 00475 00477 int _motionTimeout; 00478 00481 bool _muted; 00482 00484 std::string _name; 00485 00487 int _quality; 00488 00489 }; 00490 00491 00492 00493 00494 } //gst namespace 00495 } // gnash.media namespace 00496 } // gnash namespace 00497 00498 #endif