[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ./ChangeLog backend/gnash.cpp server/Movi...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ./ChangeLog backend/gnash.cpp server/Movi... |
Date: |
Tue, 16 May 2006 08:05:14 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: Sandro Santilli <address@hidden> 06/05/16 08:05:14
Modified files:
. : ChangeLog
backend : gnash.cpp
server : MovieClipLoader.cpp action.cpp gnash.h impl.cpp
server/swf : tag_loaders.cpp
utilities : processor.cpp
Log message:
* server/gnash.h, server/impl.cpp: changed definition
of file_opener_callback, create_movie and
create_library_movie to take an URL parameter.
* server/swf/tag_loaders.cpp, server/MovieClipLoader.cpp,
server/action.cpp: updated to use new signatures of
movie loaders.
* backend/gnash.cpp, utilities/processor.cpp:
updated file_opener signature, use curl_adapter
when available.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.328&tr2=1.329&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/gnash.cpp.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/MovieClipLoader.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.73&tr2=1.74&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/gnash.h.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.cpp.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/swf/tag_loaders.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/utilities/processor.cpp.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.328 gnash/ChangeLog:1.329
--- gnash/ChangeLog:1.328 Tue May 16 08:02:18 2006
+++ gnash/ChangeLog Tue May 16 08:05:13 2006
@@ -1,5 +1,14 @@
2006-05-16 Sandro Santilli <address@hidden>
+ * server/gnash.h, server/impl.cpp: changed definition
+ of file_opener_callback, create_movie and
+ create_library_movie to take an URL parameter.
+ * server/swf/tag_loaders.cpp, server/MovieClipLoader.cpp,
+ server/action.cpp: updated to use new signatures of
+ movie loaders.
+ * backend/gnash.cpp, utilities/processor.cpp:
+ updated file_opener signature, use curl_adapter
+ when available.
* server/movie_def_impl.{h,cpp}: changed
read() method to return bool (false on error)
Index: gnash/backend/gnash.cpp
diff -u gnash/backend/gnash.cpp:1.32 gnash/backend/gnash.cpp:1.33
--- gnash/backend/gnash.cpp:1.32 Thu May 11 09:34:43 2006
+++ gnash/backend/gnash.cpp Tue May 16 08:05:13 2006
@@ -40,6 +40,10 @@
#include "config.h"
#endif
+#ifdef HAVE_CURL_CURL_H
+#define USE_CURL 1
+#endif
+
#ifdef HAVE_SDL_H
#include "SDL.h"
#include "SDL_thread.h"
@@ -49,6 +53,7 @@
#include <cstdlib>
#include <cstdio>
#include <vector>
+#include <string>
#include <GL/gl.h>
#include <GL/glu.h>
@@ -72,6 +77,12 @@
#include "xmlsocket.h"
//#include "Movie.h"
#include "movie_definition.h"
+#include "URL.h"
+#ifdef USE_CURL
+# include <curl/curl.h>
+# include "curl_adapter.h"
+#endif
+#include "GnashException.h"
using namespace std;
using namespace gnash;
@@ -121,17 +132,32 @@
//#define TEST_GRAPHIC
static tu_file*
-file_opener(const char* url)
+file_opener(const URL& url)
// Callback function. This opens files for the library.
{
// GNASH_REPORT_FUNCTION;
- if (strcmp(url, "-") == 0) {
- FILE *newin = fdopen(dup(0),"rb");
- return new tu_file(newin, false);
- } else {
- return new tu_file(url, "rb");
- }
+ if (url.protocol() == "file")
+ {
+ std::string path = url.path();
+ if ( path == "-" )
+ {
+ FILE *newin = fdopen(dup(0), "rb");
+ return new tu_file(newin, false);
+ }
+ else
+ {
+ return new tu_file(path.c_str(), "rb");
+ }
+ }
+ else
+ {
+#ifdef USE_CURL
+ return curl_adapter::make_stream(url.str().c_str());
+#else
+ log_error("Unsupported network connections");
+#endif
+ }
}
static void
@@ -398,8 +424,13 @@
int movie_width = 0;
int movie_height = 0;
float movie_fps = 30.0f;
- gnash::get_movie_info(infiles[0], &movie_version, &movie_width,
+ try {
+ gnash::get_movie_info(URL(infiles[0]), &movie_version, &movie_width,
&movie_height, &movie_fps, NULL, NULL);
+ } catch (const GnashException& er) {
+ fprintf(stderr, "%s\n", er.what());
+ movie_version = 0;
+ }
if (movie_version == 0) {
fprintf(stderr, "error: can't get info about %s\n", infiles[0]);
exit(1);
@@ -604,7 +635,13 @@
}
// Load the actual movie.
- gnash::movie_definition* md = gnash::create_library_movie(infiles[0]);
+ gnash::movie_definition* md;
+ try {
+ md = gnash::create_library_movie(URL(infiles[0]));
+ } catch (const GnashException& er) {
+ fprintf(stderr, "%s\n", er.what());
+ md = NULL;
+ }
if (md == NULL) {
fprintf(stderr, "error: can't create a movie from '%s'\n", infiles[0]);
exit(1);
Index: gnash/server/MovieClipLoader.cpp
diff -u gnash/server/MovieClipLoader.cpp:1.18
gnash/server/MovieClipLoader.cpp:1.19
--- gnash/server/MovieClipLoader.cpp:1.18 Mon May 8 21:12:24 2006
+++ gnash/server/MovieClipLoader.cpp Tue May 16 08:05:13 2006
@@ -68,6 +68,10 @@
#include "image.h"
#include "render.h"
#include "impl.h"
+#include "URL.h"
+#include "GnashException.h"
+
+#include <string>
namespace gnash {
@@ -208,7 +212,6 @@
void moviecliploader_loadclip(const fn_call& fn)
{
-#ifdef HAVE_LIBXML
as_value val, method;
struct stat stats;
int fd;
@@ -220,11 +223,11 @@
assert(ptr);
- tu_string url = fn.arg(0).to_string();
+ tu_string tu_url = fn.arg(0).to_string();
as_object *target = (as_object *)fn.arg(1).to_object();
- log_msg("load clip: %s, target is: %p (%s)\n", url.c_str(),
- target, typeid(*target).name());
+ log_msg("load clip: %s, target is: %p (%s)\n", tu_url.c_str(),
+ (void*)target, typeid(*target).name());
//
// Extract root movie URL
@@ -238,9 +241,6 @@
log_msg(" target._url: %s\n", target_url.to_string());
- xmlNanoHTTPInit(); // This doesn't do much for now, but in the
- // future it might, so here it is...
-
if (target == NULL)
{
//log_error("target doesn't exist:\n");
@@ -251,51 +251,16 @@
//
// Resolve relative urls
// @@ todo
-
-
- // local file path
- // this is either fetched from http or local in origin
- tu_string filespec;
- bool filespec_copied = false;
-
- if (url.utf8_substring(0, 7) == "http://")
- {
- // Grab the filename off the end of the URL, and use the same
name
- // as the disk file when something is fetched. Store files in
/tmp/.
- // If the file exists, libxml properly replaces it.
- char *filename = strrchr(url.c_str(), '/');
- filespec = "/tmp";
- filespec += filename;
-
- // fetch resource from URL
- xmlNanoHTTPFetch(url.c_str(), filespec.c_str(), NULL);
- xmlNanoHTTPCleanup();
-
- // FIXME: check for success or failure
- filespec_copied = true;
-
- }
- else if (url.utf8_substring(0, 7) == "file://")
- {
- filespec = url.utf8_substring(7, url.length());
- }
- else
- {
- // @@ should never happen if we resolve relative urls
- log_msg("FIXME: unresolved relative url\n");
- filespec = url;
- }
- // If the file doesn't exist, don't try to do anything.
- if (stat(filespec.c_str(), &stats) < 0)
- {
- log_error("MovieClipLoader.loadClip(%s): doesn't exist\n",
- filespec.c_str());
- fn.result->set_bool(false);
- return;
- }
-
- log_msg(" local filename: %s\n", filespec.c_str());
+ // We have a problem with exceptions here...
+ // unless we heap-allocate the URL or define
+ // a default ctor + assignment op we can't
+ // wrap in a try/catch block w/out hiding
+ // the variable inside the block.
+ //
+ URL url(tu_url.c_str(), URL(target_url.to_string()));
+
+ log_msg(" resolved url: %s\n", url.str().c_str());
// Call the callback since we've started loading the file
if (fn.this_ptr->get_member("onLoadStart", &method))
@@ -358,25 +323,32 @@
#endif
- tu_string suffix = filespec.utf8_substring(filespec.length() - 4,
- filespec.length());
+ std::string path = url.path();
+ std::string suffix = path.substr(path.size() - 4);
log_msg("File suffix to load is: %s\n", suffix.c_str());
if (suffix == ".swf")
{
- movie_definition* md = create_library_movie(filespec.c_str());
+ movie_definition* md = create_library_movie(url);
if (md == NULL) {
log_error("can't create movie_definition for %s\n",
- filespec.c_str());
+ url.str().c_str());
+ fn.result->set_bool(false);
return;
}
+
+ log_msg("movie definition created\n");
+
gnash::movie_interface* extern_movie;
extern_movie = md->create_instance();
if (extern_movie == NULL) {
log_error("can't create extern movie_interface "
- "for %s\n", filespec.c_str());
+ "for %s\n", url.str().c_str());
+ fn.result->set_bool(false);
return;
}
+
+ log_msg("movie instance created\n");
save_extern_movie(extern_movie);
@@ -417,6 +389,9 @@
fn.result->set_bool(false);
return;
+ // WRONG: we must open it and check if it's a jpeg.
+ std::string filespec = url.path();
+
// Just case the filespec suffix claims it's a jpeg,
// we have to check, since when grabbing an image from a
@@ -425,7 +400,6 @@
if ((fd=open(filespec.c_str(), O_RDONLY)) < 0)
{
log_error("can't open image!\n");
- if ( filespec_copied ) unlink(filespec.c_str());
fn.result->set_bool(false);
return;
}
@@ -435,7 +409,6 @@
if (!read(fd, buf, 4))
{
log_error("Can't read image header!\n");
- if ( filespec_copied ) unlink(filespec.c_str());
fn.result->set_bool(false);
return;
}
@@ -446,7 +419,6 @@
if ((buf[0] == 0xff) && (buf[1] == 0xd8) && (buf[2] != 0xff))
{
log_error("File is not a JPEG!\n");
- if ( filespec_copied ) unlink(filespec.c_str());
fn.result->set_bool(false);
return;
}
@@ -481,11 +453,10 @@
// add image to movie, under character id.
//m->add_bitmap_character(666, ch);
- tu_string swfm = filespec.utf8_substring(0,
- filespec.length() - 3);
+ std::string swfm = filespec.substr(0, filespec.length() - 3);
swfm += "swf";
- movie_definition *ms = create_movie(swfm.c_str());
+ movie_definition *ms = create_movie(URL(swfm.c_str()));
// The file may not exist.
if (ms) {
//movie_interface* extern_movie =
@@ -531,7 +502,7 @@
tar->get_matrix(),
tar->get_ratio(),
tar->get_clip_depth());
-#endif // def HAVE_LIBXML
+#endif // 0
parent->replace_display_object(newch,
name,
@@ -563,7 +534,6 @@
//xmlNanoHTTPCleanup();
-#endif // HAVE_LIBXML
}
void
@@ -696,7 +666,7 @@
tu_string url = fn.arg(0).to_string();
as_object *target = (as_object*) fn.arg(1).to_object();
- log_msg("load clip: %s, target is: %p\n", url.c_str(), target);
+ log_msg("load clip: %s, target is: %p\n", url.c_str(), (void *)target);
//log_msg("%s: FIXME: Default event handler, you shouldn't be here!\n",
__FUNCTION__);
if (fn.this_ptr->get_member("onLoadError", &method)) {
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.73 gnash/server/action.cpp:1.74
--- gnash/server/action.cpp:1.73 Mon May 15 12:50:59 2006
+++ gnash/server/action.cpp Tue May 16 08:05:13 2006
@@ -87,6 +87,8 @@
#include "Global.h"
#include "swf.h"
#include "ASHandlers.h"
+#include "URL.h"
+#include "GnashException.h"
#ifndef HAVE_GTK2
int windowid = 0;
@@ -179,60 +181,59 @@
#define EXTERN_MOVIE
#ifdef EXTERN_MOVIE
-void attach_extern_movie(const char* url, const movie* target, const movie*
root_movie)
+void attach_extern_movie(const char* c_url, const movie* target, const movie*
root_movie)
{
- tu_string infile = get_workdir();
- infile += url;
+ URL url(c_url);
- movie_definition* md = create_library_movie(infile.c_str());
- if (md == NULL)
+ movie_definition* md = create_library_movie(url);
+ if (md == NULL)
{
- log_error("can't create movie_definition for %s\n", infile.c_str());
+ log_error("can't create movie_definition for %s\n",
url.str().c_str());
return;
}
- gnash::movie_interface* extern_movie;
+ gnash::movie_interface* extern_movie;
- if (target == root_movie)
+ if (target == root_movie)
{
- extern_movie = create_library_movie_inst(md);
- if (extern_movie == NULL)
+ extern_movie = create_library_movie_inst(md);
+ if (extern_movie == NULL)
{
- log_error("can't create extern root movie_interface for
%s\n", infile.c_str());
- return;
+ log_error("can't create extern root movie_interface for
%s\n", url.str().c_str());
+ return;
}
set_current_root(extern_movie);
movie* m = extern_movie->get_root_movie();
m->on_event(event_id::LOAD);
}
- else
+ else
{
- extern_movie = md->create_instance();
- if (extern_movie == NULL)
+ extern_movie = md->create_instance();
+ if (extern_movie == NULL)
{
- log_error("can't create extern movie_interface for %s\n",
infile.c_str());
- return;
+ log_error("can't create extern movie_interface for
%s\n", url.str().c_str());
+ return;
}
- save_extern_movie(extern_movie);
+ save_extern_movie(extern_movie);
- const character* tar = (const character*)target;
- const char* name = tar->get_name().c_str();
- uint16_t depth = tar->get_depth();
- bool use_cxform = false;
- cxform color_transform = tar->get_cxform();
- bool use_matrix = false;
- matrix mat = tar->get_matrix();
- float ratio = tar->get_ratio();
- uint16_t clip_depth = tar->get_clip_depth();
+ const character* tar = (const character*)target;
+ const char* name = tar->get_name().c_str();
+ uint16_t depth = tar->get_depth();
+ bool use_cxform = false;
+ cxform color_transform = tar->get_cxform();
+ bool use_matrix = false;
+ matrix mat = tar->get_matrix();
+ float ratio = tar->get_ratio();
+ uint16_t clip_depth = tar->get_clip_depth();
- movie* parent = tar->get_parent();
- movie* new_movie = extern_movie->get_root_movie();
+ movie* parent = tar->get_parent();
+ movie* new_movie = extern_movie->get_root_movie();
- assert(parent != NULL);
+ assert(parent != NULL);
- ((character*)new_movie)->set_parent(parent);
+ ((character*)new_movie)->set_parent(parent);
parent->replace_display_object(
(character*) new_movie,
Index: gnash/server/gnash.h
diff -u gnash/server/gnash.h:1.22 gnash/server/gnash.h:1.23
--- gnash/server/gnash.h:1.22 Tue May 9 15:34:16 2006
+++ gnash/server/gnash.h Tue May 16 08:05:13 2006
@@ -89,6 +89,7 @@
struct rgba;
struct sound_handler;
struct stream;
+class URL;
///
/// Log & error reporting control.
@@ -120,7 +121,7 @@
sound_handler* get_sound_handler();
/// Signature of file opener callback function
-typedef tu_file* (*file_opener_callback)(const char* url_or_path);
+typedef tu_file* (*file_opener_callback)(const URL& url);
/// Register a callback to the host, for providing a file,
/// given a "URL" (i.e. a path name). This is the only means
@@ -191,9 +192,10 @@
/// Sets *version to 0 if info can't be extracted.
///
/// You can pass NULL for any entries you're not interested in.
+/// FIXME: use a stream here, so we can use an already opened one.
///
void get_movie_info(
- const char* filename,
+ const URL& url,
int* version,
int* width,
int* height,
@@ -205,7 +207,7 @@
/// Enable/disable attempts to read cache files (.gsc) when loading movies.
void set_use_cache_files(bool use_cache);
-/// Create a gnash::movie_definition from the given file name.
+/// Create a gnash::movie_definition from the given URL.
//
/// Normally, will also try to load any cached data file
/// (".gsc") that corresponds to the given movie file. This
@@ -226,7 +228,7 @@
/// global-ish flags, libraries, callback pointers, font
/// library, etc.
///
-movie_definition* create_movie(const char* filename);
+movie_definition* create_movie(const URL& url);
/// Creates the movie from the given input stream.
//
@@ -262,7 +264,7 @@
// create_font_shapes_flag cfs);
/// \brief
-/// Create a gnash::movie_definition from the given file name.
+/// Create a gnash::movie_definition from the given URL
///
/// This is just like create_movie(), except that it checks the
/// "library" to see if a movie of this name has already been
@@ -281,7 +283,7 @@
/// Or use smart_ptr<T> from base/smart_ptr.h if you want.
///
///
-movie_definition* create_library_movie(const char* filename);
+movie_definition* create_library_movie(const URL& url);
/// Helper to pregenerate cached data (basically, shape tesselations).
Index: gnash/server/impl.cpp
diff -u gnash/server/impl.cpp:1.37 gnash/server/impl.cpp:1.38
--- gnash/server/impl.cpp:1.37 Sat May 13 05:45:27 2006
+++ gnash/server/impl.cpp Tue May 16 08:05:13 2006
@@ -75,6 +75,10 @@
#include "swf/TagLoadersTable.h"
#include "swf/tag_loaders.h"
#include "generic_character.h"
+#include "URL.h"
+
+#include <string>
+#include <map>
namespace gnash
{
@@ -130,7 +134,7 @@
//
// file_opener callback stuff
//
-static file_opener_callback s_opener_function = NULL;
+static file_opener_callback s_opener_function = NULL;
void
register_file_opener_callback(file_opener_callback opener)
@@ -283,7 +287,7 @@
void get_movie_info(
- const char* filename,
+ const URL& url,
int* version,
int* width,
int* height,
@@ -295,7 +299,7 @@
// Put extracted info in the given vars.
// Sets *version to 0 if info can't be extracted.
{
- //printf("%s: filename is %s\n", __PRETTY_FUNCTION__, filename);
+ //printf("%s: url is %s\n", __PRETTY_FUNCTION__, url.str().c_str());
if (s_opener_function == NULL) {
log_error("error: get_movie_info(): no file opener function
registered\n");
@@ -303,9 +307,9 @@
return;
}
- tu_file* in = s_opener_function(filename);
+ tu_file* in = s_opener_function(url);
if (in == NULL || in->get_error() != TU_FILE_NO_ERROR) {
- log_error("error: get_movie_info(): can't open '%s'\n", filename);
+ log_error("error: get_movie_info(): can't open '%s'\n",
url.str().c_str());
if (version) *version = 0;
delete in;
return;
@@ -320,7 +324,7 @@
if ((header & 0x0FFFFFF) != 0x00535746
&& (header & 0x0FFFFFF) != 0x00535743) {
// ERROR
- log_error("error: get_movie_info(): file '%s' does not start with a SWF
header!\n", filename);
+ log_error("error: get_movie_info(): file '%s' does not start with a SWF
header!\n", url.str().c_str());
if (version) *version = 0;
delete in;
return;
@@ -375,9 +379,12 @@
delete original_in;
}
-movie_definition* create_movie(const char* filename)
+movie_definition* create_movie(const URL& url)
{
- //printf("%s: filename is %s\n", __PRETTY_FUNCTION__, filename);
+ const char* c_url = url.str().c_str();
+
+ printf("%s: url is %s\n", __PRETTY_FUNCTION__, c_url);
+
if (s_opener_function == NULL)
{
// Don't even have a way to open the file.
@@ -386,15 +393,15 @@
return NULL;
}
- tu_file* in = s_opener_function(filename);
+ tu_file* in = s_opener_function(url);
if (in == NULL)
{
- log_error("failed to open '%s'; can't create movie.\n", filename);
+ log_error("failed to open '%s'; can't create movie.\n", c_url);
return NULL;
}
else if (in->get_error())
{
- log_error("error: file opener can't open '%s'\n", filename);
+ log_error("error: file opener can't open '%s'\n", c_url);
return NULL;
}
@@ -402,16 +409,18 @@
movie_def_impl* m = new movie_def_impl(DO_LOAD_BITMAPS,
DO_LOAD_FONT_SHAPES);
- m->read(in, filename);
+ if ( ! m->read(in, c_url) ) return NULL;
delete in;
if (m && s_use_cache_files)
{
- // Try to load a .gsc file.
- tu_string cache_filename(filename);
+ // Try to load a .gsc file.
+ // WILL NOT WORK FOR NETWORK URLS, would need an hash
+ tu_string cache_filename(c_url);
cache_filename += ".gsc";
- tu_file* cache_in = s_opener_function(cache_filename.c_str());
+ //tu_file* cache_in = s_opener_function(cache_filename.c_str());
+ tu_file* cache_in = new tu_file(cache_filename.c_str(), "rb");
if (cache_in == NULL
|| cache_in->get_error() != TU_FILE_NO_ERROR)
{
@@ -422,6 +431,7 @@
}
else
{
+ log_msg("Loading cache file %s",
cache_filename.c_str());
// Load the cached data.
m->input_cached_data(cache_in);
}
@@ -453,7 +463,7 @@
s_no_recurse_while_loading = true;
movie_def_impl* m = new movie_def_impl(cbf, cfs);
- m->read(in);
+ if ( ! m->read(in) ) return NULL;
s_no_recurse_while_loading = false;
@@ -483,7 +493,51 @@
//
-static stringi_hash< smart_ptr<movie_definition> > s_movie_library;
+//static stringi_hash< smart_ptr<movie_definition> > s_movie_library;
+
+/// Library of SWF movies indexed by URL strings
+//
+/// Elements are actually movie_def_impl, the ones
+/// associated with URLS. Dunno why, but we were using
+/// movie_definition here before so this didn't change
+/// when the new class was introduced.
+///
+class MovieLibrary
+{
+private:
+
+ typedef std::map< std::string, smart_ptr<movie_definition> > container;
+
+ container _map;
+
+public:
+
+ MovieLibrary() {}
+
+ bool get(const std::string& key, smart_ptr<movie_definition>* ret)
+ {
+ container::iterator it = _map.find(key);
+ if ( it != _map.end() )
+ {
+ *ret = it->second;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ void add(const std::string& key, movie_definition* mov)
+ {
+ _map[key] = mov;
+ }
+
+ void clear() { _map.clear(); }
+};
+
+static MovieLibrary s_movie_library;
+
static hash< movie_definition*, smart_ptr<movie_interface> >
s_movie_library_inst;
static std::vector<movie_interface*> s_extern_sprites;
static movie_interface* s_current_root;
@@ -548,17 +602,14 @@
// Try to load a movie from the given url, if we haven't
// loaded it already. Add it to our library on success, and
// return a pointer to it.
-movie_definition* create_library_movie(const char* filename)
+movie_definition* create_library_movie(const URL& url)
{
- tu_string fn(filename);
-
- //log_msg("%s: filename is %s\n", __PRETTY_FUNCTION__, filename);
+ log_msg("%s: url is %s\n", __PRETTY_FUNCTION__, url.str().c_str());
// Is the movie already in the library?
{
smart_ptr<movie_definition> m;
- s_movie_library.get(fn, &m);
- if (m != NULL)
+ if ( s_movie_library.get(url.str(), &m) )
{
log_msg(" movie already in library\n");
// Return cached movie.
@@ -568,16 +619,16 @@
}
// Try to open a file under the filename.
- movie_definition* mov = create_movie(filename);
+ movie_definition* mov = create_movie(url);
if (mov == NULL)
{
- log_error("error: couldn't load library movie '%s'\n", filename);
+ log_error("error: couldn't load library movie '%s'\n",
url.str().c_str());
return NULL;
}
else
{
- s_movie_library.add(fn, mov);
+ s_movie_library.add(url.str(), mov);
}
mov->add_ref();
Index: gnash/server/swf/tag_loaders.cpp
diff -u gnash/server/swf/tag_loaders.cpp:1.4
gnash/server/swf/tag_loaders.cpp:1.5
--- gnash/server/swf/tag_loaders.cpp:1.4 Tue May 9 22:30:41 2006
+++ gnash/server/swf/tag_loaders.cpp Tue May 16 08:05:13 2006
@@ -69,6 +69,8 @@
#include "generic_character.h"
#include "text.h"
#include "execute_tag.h" // for do_action inheritance (DOACTION tag loader)
+#include "URL.h"
+#include "GnashException.h"
namespace gnash {
// @@ TODO get rid of this; make it the normal mode.
@@ -1211,8 +1213,13 @@
if (s_no_recurse_while_loading == false)
{
- source_movie = create_library_movie(source_url);
- if (source_movie == NULL)
+ try {
+ source_movie = create_library_movie(URL(source_url));
+ } catch (gnash::GnashException& e) {
+ log_error("%s\n", e.what());
+ source_movie = NULL;
+ }
+ if (source_movie == NULL)
{
// Give up on imports.
log_error("can't import movie from url %s\n", source_url);
Index: gnash/utilities/processor.cpp
diff -u gnash/utilities/processor.cpp:1.8 gnash/utilities/processor.cpp:1.9
--- gnash/utilities/processor.cpp:1.8 Sun May 7 12:02:39 2006
+++ gnash/utilities/processor.cpp Tue May 16 08:05:13 2006
@@ -41,6 +41,10 @@
#include "config.h"
#endif
+#ifdef HAVE_CURL_CURL_H
+#define USE_CURL 1
+#endif
+
#include "tu_file.h"
#include "container.h"
#include "gnash.h"
@@ -48,6 +52,12 @@
#include "movie_definition.h"
#include "movie_interface.h"
#include "log.h"
+#include "URL.h"
+#ifdef USE_CURL
+# include <curl/curl.h>
+# include "curl_adapter.h"
+#endif
+#include "GnashException.h"
#include <iostream>
@@ -77,10 +87,33 @@
static void usage (const char *);
+static tu_file*
+file_opener(const URL& url)
// Callback function. This opens files for the library.
-static tu_file* file_opener(const char* url)
{
- return new tu_file(url, "rb");
+// GNASH_REPORT_FUNCTION;
+
+ if (url.protocol() == "file")
+ {
+ std::string path = url.path();
+ if ( path == "-" )
+ {
+ FILE *newin = fdopen(dup(0), "rb");
+ return new tu_file(newin, false);
+ }
+ else
+ {
+ return new tu_file(path.c_str(), "rb");
+ }
+ }
+ else
+ {
+#ifdef USE_CURL
+ return curl_adapter::make_stream(url.str().c_str());
+#else
+ log_error("Unsupported network connections");
+#endif
+ }
}
@@ -202,7 +235,16 @@
gnash::movie_definition*
play_movie(const char* filename)
{
- gnash::movie_definition* md = gnash::create_library_movie(filename);
+ gnash::movie_definition* md;
+ try
+ {
+ md = gnash::create_library_movie(URL(filename));
+ }
+ catch (GnashException& ge)
+ {
+ md = NULL;
+ fprintf(stderr, "%s\n", ge.what());
+ }
if (md == NULL) {
fprintf(stderr, "error: can't play movie '%s'\n", filename);
exit(1);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ./ChangeLog backend/gnash.cpp server/Movi...,
Sandro Santilli <=