Gnash  0.8.11dev
dump.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_DUMP_H
20 #define GNASH_DUMP_H
21 
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
25 
26 #include "dsodefs.h" // for DSOEXPORT
27 #include "gui.h" // for inheritance
28 #include "sound_handler.h" // for dtor visibility
29 #include "ManualClock.h"
30 
31 #include <string>
32 #include <fstream>
33 #include <boost/scoped_array.hpp>
34 #include <boost/shared_ptr.hpp>
35 
36 namespace gnash {
37 
38 class Renderer_agg_base;
39 
40 class DSOEXPORT DumpGui : public Gui
41 {
42  public:
43  DumpGui(unsigned long xid, float scale, bool loop, RunResources& r);
44  ~DumpGui();
45  void beforeRendering();
46  bool createMenu() { return true; }
47  bool createMenuBar() { return true; }
48  bool createWindow(int width, int height);
49  bool createWindow(const char* /*title*/, int width, int height,
50  int /*x*/, int /*y*/)
51  { return createWindow(width, height); }
52  bool init(int argc, char **argv[]);
53  virtual void quitUI();
54  void renderBuffer() {return; }
55  void render() { return; }
56  void render(int /*minx*/, int /*miny*/, int /*maxx*/, int /*maxy*/)
57  { render(); }
58  bool run();
59  void setInterval(unsigned int interval);
60  void setTimeout(unsigned int timeout);
61  bool setupEvents() { return true; }
62  void setFullscreen() { return; }
63  void setInvalidatedRegion(const SWFRect& /*bounds*/) { return; }
64  void setInvalidatedRegions(const InvalidatedRanges& /*ranges*/) { return; }
65  void setCursor(gnash_cursor_type /*newcursor*/) { return; }
66  void setRenderHandlerSize(int width, int height);
67  void unsetFullscreen() { return; }
68  bool want_multiple_regions() { return true; }
69  bool want_redraw() { return false; }
70  void writeFrame();
71  void writeSamples();
72 
73  virtual VirtualClock& getClock() { return _clock; }
74 
75 private:
76 
77  Renderer_agg_base* _agg_renderer;
78 
79  // A buffer to hold the actual image data. A boost::scoped_array
80  // is destroyed on reset and when it goes out of scope (including on
81  // stack unwinding after an exception), so there is no need to delete
82  // it.
83  boost::scoped_array<unsigned char> _offscreenbuf;
84 
85  int _offscreenbuf_size; /* size of window (bytes) */
86 
87  unsigned int _timeout; /* maximum length of movie */
88  unsigned int _framecount; /* number of frames rendered */
89  unsigned int _samplesFetched; /* number of samples fetched */
90 
91  unsigned int _bpp; /* bits per pixel */
92  std::string _pixelformat; /* colorspace name (eg, "RGB24") */
93 
94  std::string _fileOutput; /* path to video output file */
95  unsigned int _fileOutputFPS; /* requested FPS of video output file */
96  unsigned int _fileOutputAdvance; /* ms of time between video dump frms */
97  unsigned long _lastVideoFrameDump; /* time of last video frame dump */
98  std::ofstream _fileStream; /* stream for output file */
99  void init_dumpfile(); /* convenience method to create dump file */
100 
101  boost::shared_ptr<sound::sound_handler> _soundHandler;
102 
103  ManualClock _clock;
104 
105  unsigned long _sleepUS; // micro-seconds sleep between iterations
106 
107  unsigned int _videoDumpFPS;
108 
109  std::string _startTrigger;
110 
111  bool _started;
112 
113  size_t _startTime;
114 
115 };
116 
117 // end of namespace gnash
118 }
119 
120 #endif