[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/Player.cpp gui/Player.h
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog gui/Player.cpp gui/Player.h |
Date: |
Mon, 02 Oct 2006 10:27:38 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/10/02 10:27:38
Modified files:
. : ChangeLog
gui : Player.cpp Player.h
Log message:
Player class cleanups
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.981&r2=1.982
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.h?cvsroot=gnash&r1=1.3&r2=1.4
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.981
retrieving revision 1.982
diff -u -b -r1.981 -r1.982
--- ChangeLog 2 Oct 2006 09:31:49 -0000 1.981
+++ ChangeLog 2 Oct 2006 10:27:37 -0000 1.982
@@ -1,5 +1,9 @@
2006-10-02 Sandro Santilli <address@hidden>
+ * gui/Player.{cpp,h}: some functions split and cleanups.
+
+2006-10-02 Sandro Santilli <address@hidden>
+
* gui/Player.cpp (Player::run): read from stdin when infile == "-"
* server/impl.cpp, server/gnash.h: exposed a create_movie(tu_file*,
std::string&) function to let callers use arbitrary data sources
Index: gui/Player.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- gui/Player.cpp 2 Oct 2006 09:31:49 -0000 1.10
+++ gui/Player.cpp 2 Oct 2006 10:27:38 -0000 1.11
@@ -119,8 +119,10 @@
do_loop(true),
do_render(true),
do_sound(false),
- exit_timeout(0)
+ exit_timeout(0),
+ _movie_def(0)
{
+ init();
}
float
@@ -131,21 +133,21 @@
return oldscale;
}
-int
-Player::run(int argc, char* argv[], const char* infile, const char* url)
+void
+Player::init()
{
+ //set_use_cache_files(false);
- bool background = true;
- unsigned int delay = 0;
-#ifdef USE_KDE
- QApplication *app = new QApplication(argc, argv);
-#else
- void *app=NULL;
-#endif
-
- assert(tu_types_validate());
+ gnash::register_fscommand_callback(fs_callback);
+ init_logfile();
+ init_sound();
+ init_gui();
+}
+void
+Player::init_logfile()
+{
dbglogfile.setWriteDisk(false);
rcfile.loadFiles();
// rcfile.dump();
@@ -179,26 +181,11 @@
dbglogfile.removeLog();
}
- // No file name was supplied
- assert (infile);
-
-// we don't need to register a file opener anymore, the
-// default gnash::globals::streamProvider is good enough
-#if 0
- // strk removed this function..
- gnash::register_file_opener_callback(file_opener);
-#endif
- gnash::register_fscommand_callback(fs_callback);
-
- // Set base url
- if ( _baseurl.empty() )
- {
- if ( url ) _baseurl = url;
- else if ( ! strcmp(infile, "-") ) _baseurl = URL("./").str();
- else _baseurl = infile;
- }
- gnash::set_base_url(URL(_baseurl));
+}
+void
+Player::init_sound()
+{
std::auto_ptr<gnash::sound_handler> sound;
if (do_sound) {
@@ -213,36 +200,38 @@
gnash::set_sound_handler(sound.get());
#endif
}
+}
- std::auto_ptr<Gui> gui_ptr;
- if ( do_render ) {
- gui_ptr.reset(new GUI_CLASS(windowid, scale, do_loop, bit_depth));
+void
+Player::init_gui()
+{
+ if ( do_render )
+ {
+ _gui.reset(new GUI_CLASS(windowid, scale, do_loop, bit_depth));
- } else {
- gui_ptr.reset(new NullGui);
}
- Gui& gui = *gui_ptr;
-
- gui.init(argc, &argv);
+ else
+ {
+ _gui.reset(new NullGui);
+ }
+}
- // Load the actual movie.
- gnash::movie_definition *md;
+movie_definition*
+Player::load_movie()
+{
+ gnash::movie_definition* md=NULL;
try {
- if ( ! strcmp(infile, "-") )
- {
- // Make up an url for the main movie
- if ( ! url )
+ if ( _infile == "-" )
{
- url = _baseurl.c_str();
- }
tu_file* in = noseek_fd_adapter::make_stream(fileno(stdin));
- md = gnash::create_movie(in, std::string(url));
+ md = gnash::create_movie(in, _url);
}
else
{
- md = gnash::create_library_movie(URL(infile), url);
+ // _url should be always set at this point...
+ md = gnash::create_library_movie(URL(_infile), _url.c_str());
}
} catch (const GnashException& er) {
fprintf(stderr, "%s\n", er.what());
@@ -251,14 +240,68 @@
if ( ! md )
{
- fprintf(stderr, "Could not load movie '%s'\n", infile);
+ fprintf(stderr, "Could not load movie '%s'\n", _infile.c_str());
+ return NULL;
+ }
+
+ return md;
+}
+
+int
+Player::run(int argc, char* argv[], const char* infile, const char* url)
+{
+
+ bool background = true;
+ unsigned int delay = 0;
+#ifdef USE_KDE
+ QApplication *app = new QApplication(argc, argv);
+#else
+ void *app=NULL;
+#endif
+
+ assert(tu_types_validate());
+
+ // No file name was supplied
+ assert (infile);
+ _infile = infile;
+
+ // Set base url
+ if ( _baseurl.empty() )
+ {
+ if ( url ) _baseurl = url;
+ else if ( ! strcmp(infile, "-") ) _baseurl = URL("./").str();
+ else _baseurl = infile;
+ }
+
+ // Set _root._url (either explicit of from infile)
+ if ( url ) {
+ _url=std::string(url);
+ } else {
+ _url=std::string(infile);
+ }
+
+
+ // Initialize gui (we need argc/argv for this)
+ // note that this will also initialize the renderer
+ // which is *required* during movie loading
+ _gui->init(argc, &argv);
+
+
+ // Load the actual movie.
+ _movie_def = load_movie();
+ if ( ! _movie_def )
+ {
return EXIT_FAILURE;
}
+ // Set base url for this run/play
+ gnash::set_base_url(URL(_baseurl));
+
+
// Get info about the width & height of the movie.
- int movie_width = static_cast<int>(md->get_width_pixels());
- int movie_height = static_cast<int>(md->get_height_pixels());
- float movie_fps = md->get_frame_rate();
+ int movie_width = static_cast<int>(_movie_def->get_width_pixels());
+ int movie_height = static_cast<int>(_movie_def->get_height_pixels());
+ float movie_fps = _movie_def->get_frame_rate();
if (!width) {
width = int(movie_width * scale);
@@ -269,10 +312,9 @@
// Now that we know about movie size, create gui window.
- gui.createWindow(infile, width, height);
-
+ _gui->createWindow(infile, width, height);
- gnash::movie_interface *m = create_library_movie_inst(md);
+ gnash::movie_interface *m = create_library_movie_inst(_movie_def);
assert(m);
// Parse parameters
@@ -300,15 +342,15 @@
if (!delay) {
delay = (unsigned int) (1000 / movie_fps) ; // milliseconds per frame
}
- gui.setCallback(delay);
+ _gui->setCallback(delay);
if (exit_timeout) {
- gui.setTimeout((unsigned int)(exit_timeout * 1000));
+ _gui->setTimeout((unsigned int)(exit_timeout * 1000));
}
// @@ is it ok for 'app' to be NULL ?
// (this would be the case when USE_KDE is not defined)
- gui.run(app);
+ _gui->run(app);
// Clean up as much as possible, so valgrind will help find actual leaks.
gnash::clear();
Index: gui/Player.h
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gui/Player.h 29 Sep 2006 04:19:33 -0000 1.3
+++ gui/Player.h 2 Oct 2006 10:27:38 -0000 1.4
@@ -45,6 +45,7 @@
#include "tu_config.h"
#include "gnash.h"
+#include "gui.h"
#include <string>
#include <map>
@@ -134,6 +135,15 @@
}
private:
+
+ void init();
+
+ void init_sound();
+
+ void init_logfile();
+
+ void init_gui();
+
static void setFlashVars(movie_interface& m, const std::string& varstr);
static void fs_callback(movie_interface* movie,
@@ -164,6 +174,22 @@
float exit_timeout;
std::string _baseurl;
+
+ std::auto_ptr<Gui> _gui;
+
+ std::string _url;
+
+ std::string _infile;
+
+ movie_definition* _movie_def;
+
+ /// Load the "_infile" movie setting it's url to "_url"
+ //
+ /// This function takes care of interpreting _infile as
+ /// stdin when it equals "-". May throw a GnashException
+ /// on failure.
+ ///
+ movie_definition* load_movie();
};
- [Gnash-commit] gnash ChangeLog gui/Player.cpp gui/Player.h,
Sandro Santilli <=