• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

Player.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 // 
00019 
00020 #ifndef GNASH_PLAYER_H
00021 #define GNASH_PLAYER_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "gnashconfig.h"
00025 #endif
00026 
00027 #include "gnash.h" 
00028 #include "sound_handler.h"
00029 #include "MediaHandler.h" 
00030 #include "gui.h"
00031 #include "movie_definition.h" 
00032 #include "movie_root.h"
00033 #include "RunResources.h"
00034 
00035 #include <boost/intrusive_ptr.hpp>
00036 #include <string>
00037 #include <boost/shared_ptr.hpp>
00038 #include <map>
00039 
00040 // Forward declarations
00041 namespace gnash
00042 {
00043     class MovieClip;
00044 }
00045 
00046 
00047 namespace gnash
00048 {
00049 
00055 class Player
00056 {
00057 public:
00058     
00059     Player();
00060     
00061     ~Player();
00062     
00064     //
00077     void run(int argc, char* argv[],
00078             const std::string& infile, const std::string& url = "");
00079     
00080     float setScale(float s);
00081     
00082     // milliseconds per frame
00083     void setDelay(unsigned int d) { _delay=d; }
00084     
00085 #ifdef GNASH_FPS_DEBUG
00086 
00087     //
00093     void setFpsPrintTime(float time)
00094     {
00095         assert(time >= 0.0);
00096         _fpsDebugTime = time;
00097     }
00098 #endif // def GNASH_FPS_DEBUG
00099     
00100     void setWidth(size_t w) { _width = w; }
00101     size_t getWidth() { return _width; }
00102     
00103     void setHeight(size_t h) { _height = h; }
00104     size_t getHeight() { return _height; }
00105     
00106     void setXPosition(int xPos) { _xPosition = xPos; }
00107     size_t getXPosition() { return _xPosition; }
00108     
00109     void setYPosition(int yPos) { _yPosition = yPos; }
00110     size_t getYPosition() { return _yPosition; }
00111     
00112     void setWindowId(unsigned long x) { _windowID = x; }
00113     
00114     void setDoLoop(bool b) { _doLoop = b; }
00115     
00116     void setDoRender(bool b) { _doRender = b; }
00117     
00118     void setDoSound(bool b) { _doSound = b; }
00119     
00120     void setMaxAdvances(unsigned long ul) { if (ul > 0) _maxAdvances = ul; }
00121     
00123     //
00127     void setBaseUrl(const std::string& baseurl) {
00128         _baseurl = baseurl;
00129     }
00130     
00131     float setExitTimeout(float n) {
00132         float oldtimeout = _exitTimeout;
00133         _exitTimeout = n;
00134         return oldtimeout;
00135     }
00136     
00137     void setParam(std::string& name, std::string& value) {
00138         _params[name] = value;
00139     }
00140     
00141     void setHostFD(int fd) {
00142         _hostfd = fd;
00143     }
00144     
00145     int getHostFD() const {
00146         return _hostfd;
00147     }
00148 
00149     void setMedia(const std::string& media) {
00150         _media = media;
00151     }
00152 
00153     void setControlFD(int fd) {
00154         _controlfd = fd;
00155     }
00156     
00157     int getControlFD() const {
00158         return _controlfd;
00159     }
00160 
00161     void setStartFullscreen(bool x) {
00162         _startFullscreen = x;
00163     }
00164     
00165     void hideMenu(bool x) {
00166         _hideMenu = x;
00167     }
00168     
00169     void setAudioDumpfile(const std::string& filespec) {
00170         _audioDump = filespec;
00171     }
00172     
00176     void setRenderer(const std::string& x) { _renderer = x; }
00177     
00181     void setHWAccel(const std::string& x) { _hwaccel = x; }
00182 
00184     //
00186     //
00189     void setScreenShots(const std::string& screenshots) {
00190         _screenshots = screenshots;
00191     }
00192 
00194     //
00196     void setScreenShotFile(const std::string& file) {
00197         _screenshotFile = file;
00198     }
00199 
00200 private:
00201 
00205     std::string _hwaccel;
00206     
00210     std::string _renderer;
00211 
00212     class CallbacksHandler : public movie_root::AbstractIfaceCallback,
00213                              public movie_root::AbstractFsCallback
00214     {
00215     public:
00216         CallbacksHandler(Gui& gui, const Player& player)
00217             :
00218             _gui(gui),
00219             _player(player)
00220         {
00221         }
00222         
00223         std::string call(const std::string& event,
00224                          const std::string& arg);
00225         
00226         bool yesNo(const std::string& query);
00227         
00228         void error(const std::string& msg);
00229 
00230         void exit();
00231         
00232         // For handling notification callbacks from ActionScript.
00233         // The callback is always sent to a hosting application
00234         // (i.e. if a file descriptor is supplied). It is never
00235         // acted on by Gnash when running as a plugin.
00236         void notify(const std::string& event, const std::string& arg);
00237         
00238     private:
00239         
00240         Gui& _gui;
00241         
00242         const Player& _player;
00243     };
00244     
00245     std::auto_ptr<CallbacksHandler> _callbacksHandler;
00246     
00247     void init();
00248     
00263     static unsigned int silentStream(void* udata, boost::int16_t* stream,
00264                      unsigned int len, bool& atEOF);
00265     
00266     void init_sound();
00267     
00268     void init_logfile();
00269     
00270     void init_gui();
00271     
00273     //
00276     std::auto_ptr<Gui> getGui();
00277     
00278     void setFlashVars(const std::string& varstr);
00279 
00280     void setScriptableVar(const std::string &name, const std::string& value);
00281     
00282     typedef std::map<std::string, std::string, StringNoCaseLessThan> Params;
00283     
00284     // Movie parameters (for -P)
00285     Params      _params;
00286     unsigned int _bitDepth;
00287     
00288     // the scale at which to play 
00289     float       _scale;
00290     unsigned int _delay;
00291     size_t      _width;
00292     size_t      _height;
00293     int         _xPosition;
00294     int         _yPosition;
00295     unsigned long _windowID;
00296     bool        _doLoop;
00297     bool        _doRender;
00298     bool        _doSound;
00299     float       _exitTimeout;
00300     std::string _baseurl;
00301     
00303     //
00309     //
00313     //
00317     boost::shared_ptr<sound::sound_handler> _soundHandler;
00318     
00319     boost::shared_ptr<media::MediaHandler> _mediaHandler;
00320     
00322     //
00325     std::auto_ptr<RunResources> _runResources;
00326     
00328     std::auto_ptr<Gui> _gui;
00329     
00330     std::string         _url;
00331     
00332     std::string         _infile;
00333     
00334     boost::intrusive_ptr<movie_definition> _movieDef;
00335     
00336     unsigned long       _maxAdvances;
00337     
00339     // 
00344     boost::intrusive_ptr<movie_definition> load_movie();
00345     
00346 #ifdef GNASH_FPS_DEBUG
00347     float       _fpsDebugTime;
00348 #endif
00349     
00350     // Filedescriptor to use for host application requests, -1 if none
00351     int         _hostfd;
00352     
00353     int         _controlfd;
00354 
00355     // Whether to start Gnash in fullscreen mode.
00356     // (Or what did you think it meant?)
00357     bool        _startFullscreen;
00358     bool        _hideMenu;
00359     
00361     std::string _audioDump;
00362     
00364     //
00366     std::string _screenshots;
00367     
00369     //
00371     std::string _screenshotFile;
00372 
00374     //
00376     std::string _media;
00377 
00378 };
00379  
00380 } // end of gnash namespace
00381 
00382 // end of _PLAYER_H_
00383 #endif
00384 
00385 // local Variables:
00386 // mode: C++
00387 // indent-tabs-mode: nil
00388 // End:

Generated on Fri Mar 16 2012 15:46:11 for Gnash by  doxygen 1.7.1