Gnash  0.8.11dev
VideoInputGst.h
Go to the documentation of this file.
1 // VideoInput.h: Video input processing using Gstreamer
2 //
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef GNASH_VIDEOINPUTGST_H
21 #define GNASH_VIDEOINPUTGST_H
22 
23 #include <vector>
24 #include <boost/cstdint.hpp> // for C99 int types
25 #include "VideoInput.h"
26 #include "gst/gst.h"
27 
28 namespace gnash {
29 namespace media {
34 namespace gst {
35 
36 class GnashWebcam;
37 class GnashWebcamPrivate;
38 
45 {
46 public:
49  gint numerator;
53 
59  FramerateFraction(gint num, gint denom);
60 
63 };
64 
70 {
71 public:
76  gchar *mimetype;
77 
81  gint width;
82 
86  gint height;
87 
92 
99 
104 
106  WebcamVidFormat();
107 };
108 
109 
116 class VideoInputGst : public VideoInput
117 {
118 public:
119 
121  VideoInputGst();
122 
124  ~VideoInputGst();
125 
126  static void getNames(std::vector<std::string>& names);
127 
129  //
132  double activityLevel () const { return _activityLevel; }
133 
135  //
137  size_t bandwidth() const { return _bandwidth; }
138 
139  void setBandwidth(size_t bandwidth) {
140  _bandwidth = bandwidth;
141  }
142 
144  //
146  double currentFPS() const { return _currentFPS; }
147 
149  //
151  double fps() const { return _fps; }
152 
154  size_t height() const { return _height; }
155 
157  size_t width() const { return _width; }
158 
160  size_t index() const { return _index; }
161 
163  //
168  void requestMode(size_t width, size_t height, double fps, bool favorArea);
169 
171  void setMotionLevel(int m) { _motionLevel = m; }
172 
174  int motionLevel() const { return _motionLevel; }
175 
177  void setMotionTimeout(int m) { _motionTimeout = m; }
178 
180  int motionTimeout() const { return _motionTimeout; }
181 
182  void mute(bool m) { _muted = m; }
183  bool muted() const { return _muted; }
184 
186  //
188  const std::string& name() const { return _name; }
189 
191  void setQuality(int q) { _quality = q; }
192 
194  int quality() const { return _quality; }
195 
200  bool play();
201 
205  bool stop();
206 
207 
209  //
219  bool setWebcam(size_t index);
220 
222  //
224  //
227  bool init();
228 
238 
242 
250  gboolean webcamMakeVideoSaveLink();
251 
257  gboolean webcamBreakVideoSaveLink();
258 
269  gboolean webcamCreateSaveBin();
270 
279  gboolean webcamMakeVideoDisplayLink();
280 
288  gboolean webcamBreakVideoDisplayLink();
289 
290 private:
291 
292 
306  void getSelectedCaps(gint dev_select);
307 
318  void getSupportedFormats(GnashWebcam *cam, GstCaps *caps);
319 
329  void addSupportedFormat(GnashWebcam *cam, WebcamVidFormat *video_format,
330  GstStructure *format_structure);
331 
344  void getSupportedFramerates(WebcamVidFormat *video_format,
345  GstStructure *structure);
346 
353  gboolean checkForSupportedFramerate (GnashWebcamPrivate *webcam, int fps);
354 
363  void findHighestFramerate(WebcamVidFormat *format);
364 
375  gboolean webcamCreateSourceBin();
376 
382  gboolean webcamChangeSourceBin();
383 
394  gboolean webcamCreateMainBin();
395 
406  gboolean webcamCreateDisplayBin();
407 
408 
409 
413  GnashWebcamPrivate* getGlobalWebcam() {return _globalWebcam;}
414 
419  //
422  static void findVidDevs(std::vector<GnashWebcam*>& cams);
423 
426  std::vector<GnashWebcam*> _vidVect;
427 
431  int _devSelection;
432 
436  gint _numdevs;
437 
441  GnashWebcamPrivate *_globalWebcam;
442 
446 
449  double _activityLevel;
450 
453  size_t _bandwidth;
454 
457  double _currentFPS;
458 
460  double _fps;
461 
464  size_t _height;
465 
468  size_t _width;
469 
471  size_t _index;
472 
474  int _motionLevel;
475 
477  int _motionTimeout;
478 
481  bool _muted;
482 
484  std::string _name;
485 
487  int _quality;
488 
489 };
490 
491 
492 
493 
494 } //gst namespace
495 } // gnash.media namespace
496 } // gnash namespace
497 
498 #endif