Benjamin Otte
2007-Nov-07 21:20 UTC
[Swfdec] 7 commits - doc/swfdec-sections.txt libswfdec-gtk/swfdec_gtk_widget.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_decoder.c libswfdec/swfdec_flv_decoder.c libswfdec/swfdec_movie_asprops.c libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_resource.c libswfdec/swfdec_resource.h libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_sprite_movie.h test/image
doc/swfdec-sections.txt | 2 libswfdec-gtk/swfdec_gtk_widget.c | 7 +- libswfdec/swfdec_as_strings.c | 3 + libswfdec/swfdec_decoder.c | 2 libswfdec/swfdec_flv_decoder.c | 57 ---------------------- libswfdec/swfdec_movie_asprops.c | 31 ++++++------ libswfdec/swfdec_net_stream.c | 7 -- libswfdec/swfdec_player.c | 30 ++++++++++- libswfdec/swfdec_player.h | 6 +- libswfdec/swfdec_resource.c | 97 ++++++++++++++++++++++++++------------ libswfdec/swfdec_resource.h | 9 +++ libswfdec/swfdec_sprite_movie.c | 34 ++++++++++--- libswfdec/swfdec_sprite_movie.h | 1 test/image/image.c | 4 - 14 files changed, 165 insertions(+), 125 deletions(-) New commits: commit bcf54fadaac5c67aa56852e97762890ad3ef74c9 Author: Benjamin Otte <otte at gnome.org> Date: Wed Nov 7 19:53:50 2007 +0100 /swfdec_player_get_image_size/swfdec_player_get_default_size/ That name has annoyed me long enough now diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt index 1b61f67..0916f16 100644 --- a/doc/swfdec-sections.txt +++ b/doc/swfdec-sections.txt @@ -80,7 +80,7 @@ swfdec_player_set_loader swfdec_player_set_loader_with_variables swfdec_player_is_initialized swfdec_player_get_rate -swfdec_player_get_image_size +swfdec_player_get_default_size swfdec_player_get_size swfdec_player_set_size swfdec_player_get_next_event diff --git a/libswfdec-gtk/swfdec_gtk_widget.c b/libswfdec-gtk/swfdec_gtk_widget.c index 895d5a3..8d617fd 100644 --- a/libswfdec-gtk/swfdec_gtk_widget.c +++ b/libswfdec-gtk/swfdec_gtk_widget.c @@ -330,8 +330,11 @@ swfdec_gtk_widget_size_request (GtkWidget *gtkwidget, GtkRequisition *req) if (priv->player == NULL) { req->width = req->height = 0; } else { - swfdec_player_get_image_size (priv->player, - &req->width, &req->height); + guint w, h; + swfdec_player_get_default_size (priv->player, &w, &h); + /* FIXME: set some sane upper limit here? */ + req->width = MIN (w, G_MAXINT); + req->height = MIN (h, G_MAXINT); } } diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index dd15962..3d36451 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -2320,7 +2320,7 @@ swfdec_player_get_rate (SwfdecPlayer *player) } /** - * swfdec_player_get_image_size: + * swfdec_player_get_default_size: * @player: a #SwfdecPlayer * @width: integer to store the width in or %NULL * @height: integer to store the height in or %NULL @@ -2329,7 +2329,7 @@ swfdec_player_get_rate (SwfdecPlayer *player) * with the size. Otherwise @width and @height are set to 0. **/ void -swfdec_player_get_image_size (SwfdecPlayer *player, int *width, int *height) +swfdec_player_get_default_size (SwfdecPlayer *player, guint *width, guint *height) { g_return_if_fail (SWFDEC_IS_PLAYER (player)); diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h index 6a0bb2b..d28fce5 100644 --- a/libswfdec/swfdec_player.h +++ b/libswfdec/swfdec_player.h @@ -79,9 +79,9 @@ void swfdec_player_set_loader_with_variables gboolean swfdec_player_is_initialized (SwfdecPlayer * player); glong swfdec_player_get_next_event (SwfdecPlayer * player); double swfdec_player_get_rate (SwfdecPlayer * player); -void swfdec_player_get_image_size (SwfdecPlayer * player, - int * width, - int * height); +void swfdec_player_get_default_size (SwfdecPlayer * player, + guint * width, + guint * height); void swfdec_player_get_size (SwfdecPlayer * player, int * width, int * height); diff --git a/test/image/image.c b/test/image/image.c index e50c9c6..405cfa7 100644 --- a/test/image/image.c +++ b/test/image/image.c @@ -155,7 +155,7 @@ run_test (const char *filename) SwfdecLoader *loader; SwfdecPlayer *player = NULL; guint i, msecs; - int w, h; + guint w, h; cairo_surface_t *surface; cairo_t *cr; @@ -174,7 +174,7 @@ run_test (const char *filename) msecs = swfdec_player_get_next_event (player); swfdec_player_advance (player, msecs); } - swfdec_player_get_image_size (player, &w, &h); + swfdec_player_get_default_size (player, &w, &h); if (w == 0 || h == 0) { g_print (" ERROR: width and height not set\n"); goto error; commit 9bb3e01a2b2ac248146bcefc497df43e3c38728f Author: Benjamin Otte <otte at gnome.org> Date: Wed Nov 7 19:46:55 2007 +0100 add "default-width", "default-height" and "rate" properties This is so we can g_object_notify() about them when they change diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index 37b6f56..dd15962 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -600,6 +600,9 @@ enum { PROP_0, PROP_CACHE_SIZE, PROP_INITIALIZED, + PROP_DEFAULT_WIDTH, + PROP_DEFAULT_HEIGHT, + PROP_RATE, PROP_MOUSE_CURSOR, PROP_NEXT_EVENT, PROP_BACKGROUND_COLOR, @@ -683,6 +686,15 @@ swfdec_player_get_property (GObject *object, guint param_id, GValue *value, case PROP_INITIALIZED: g_value_set_boolean (value, swfdec_player_is_initialized (player)); break; + case PROP_DEFAULT_WIDTH: + g_value_set_uint (value, player->width); + break; + case PROP_DEFAULT_HEIGHT: + g_value_set_uint (value, player->height); + break; + case PROP_RATE: + g_value_set_double (value, player->rate / 256.0); + break; case PROP_MOUSE_CURSOR: g_value_set_enum (value, player->mouse_cursor); break; @@ -1408,6 +1420,15 @@ swfdec_player_class_init (SwfdecPlayerClass *klass) g_object_class_install_property (object_class, PROP_INITIALIZED, g_param_spec_boolean ("initialized", "initialized", "TRUE when the player has initialized its basic values", FALSE, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_DEFAULT_WIDTH, + g_param_spec_uint ("default-width", "default width", "default width of the movie", + 0, G_MAXUINT, 0, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_DEFAULT_HEIGHT, + g_param_spec_uint ("default-height", "default height", "default height of the movie", + 0, G_MAXUINT, 0, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_RATE, + g_param_spec_double ("rate", "rate", "rate in frames per second", + 0.0, 256.0, 0.0, G_PARAM_READABLE)); g_object_class_install_property (object_class, PROP_MOUSE_CURSOR, g_param_spec_enum ("mouse-cursor", "mouse cursor", "how the mouse pointer should be presented", SWFDEC_TYPE_MOUSE_CURSOR, SWFDEC_MOUSE_CURSOR_NONE, G_PARAM_READABLE)); @@ -1875,7 +1896,7 @@ swfdec_player_initialize (SwfdecPlayer *player, guint version, swfdec_as_object_set_constructor (player->roots->data, player->MovieClip); } } - SWFDEC_INFO ("initializing player to size %ux%u", width, height); + SWFDEC_INFO ("initializing player to size %ux%u and rate %u/256", width, height, rate); player->rate = rate; player->width = width; player->height = height; @@ -1889,6 +1910,9 @@ swfdec_player_initialize (SwfdecPlayer *player, guint version, &player->iterate_timeout, player->iterate_timeout.timestamp, player->time); } g_object_notify (G_OBJECT (player), "initialized"); + g_object_notify (G_OBJECT (player), "default-width"); + g_object_notify (G_OBJECT (player), "default-height"); + g_object_notify (G_OBJECT (player), "rate"); swfdec_player_update_scale (player); } commit 4c115fe9eb41911d99a9e922ba4f10803c10a64b Author: Benjamin Otte <otte at gnome.org> Date: Wed Nov 7 19:38:51 2007 +0100 initial implementation of onLoadError. diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c index 4326235..2879324 100644 --- a/libswfdec/swfdec_as_strings.c +++ b/libswfdec/swfdec_as_strings.c @@ -429,5 +429,8 @@ const char swfdec_as_strings[] SWFDEC_AS_CONSTANT_STRING ("onLoadError") SWFDEC_AS_CONSTANT_STRING ("onLoadInit") SWFDEC_AS_CONSTANT_STRING ("onLoadProgress") + SWFDEC_AS_CONSTANT_STRING ("URLNotFound") + SWFDEC_AS_CONSTANT_STRING ("IllegalRequest") + SWFDEC_AS_CONSTANT_STRING ("LoadNeverCompleted") /* add more here */ ; diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c index 3f2af12..d6b5703 100644 --- a/libswfdec/swfdec_resource.c +++ b/libswfdec/swfdec_resource.c @@ -104,11 +104,13 @@ swfdec_resource_loader_target_image (SwfdecResource *instance) /* NB: name must be GC'ed */ static void -swfdec_resource_emit_signal (SwfdecResource *resource, const char *name, SwfdecAsValue *args, guint n_args) +swfdec_resource_emit_signal (SwfdecResource *resource, const char *name, gboolean progress, + SwfdecAsValue *args, guint n_args) { SwfdecAsContext *cx; SwfdecAsObject *movie; - SwfdecAsValue vals[n_args + 2]; + guint skip = progress ? 4 : 2; + SwfdecAsValue vals[n_args + skip]; if (resource->clip_loader == NULL) return; @@ -123,10 +125,37 @@ swfdec_resource_emit_signal (SwfdecResource *resource, const char *name, SwfdecA SWFDEC_AS_VALUE_SET_STRING (&vals[0], name); SWFDEC_AS_VALUE_SET_OBJECT (&vals[1], movie); + if (progress) { + SwfdecResource *res; + + if (SWFDEC_IS_MOVIE (movie)) + res = swfdec_movie_get_own_resource (SWFDEC_MOVIE (movie)); + else + res = NULL; + if (res && res->decoder) { + SwfdecDecoder *dec = res->decoder; + SWFDEC_AS_VALUE_SET_INT (&vals[2], dec->bytes_loaded); + SWFDEC_AS_VALUE_SET_INT (&vals[3], dec->bytes_total); + } else { + SWFDEC_AS_VALUE_SET_INT (&vals[2], 0); + SWFDEC_AS_VALUE_SET_INT (&vals[3], 0); + } + } if (n_args) - memcpy (&vals[2], args, sizeof (SwfdecAsValue) * n_args); + memcpy (&vals[skip], args, sizeof (SwfdecAsValue) * n_args); swfdec_as_object_call (SWFDEC_AS_OBJECT (resource->clip_loader), SWFDEC_AS_STR_broadcastMessage, - n_args + 2, vals, NULL); + n_args + skip, vals, NULL); +} + +static void +swfdec_resource_emit_error (SwfdecResource *resource, const char *message) +{ + SwfdecAsValue vals[2]; + + SWFDEC_AS_VALUE_SET_STRING (&vals[0], message); + SWFDEC_AS_VALUE_SET_INT (&vals[1], 0); + + swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadError, FALSE, vals, 2); } static void @@ -144,7 +173,8 @@ swfdec_resource_loader_target_open (SwfdecLoaderTarget *target, SwfdecLoader *lo SWFDEC_INFO ("set manual movie variables: %s", instance->variables); swfdec_movie_set_variables (SWFDEC_MOVIE (instance->movie), instance->variables); } - swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadStart, NULL, 0); + swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadStart, FALSE, NULL, 0); + instance->state = SWFDEC_RESOURCE_OPENED; } static void @@ -153,7 +183,6 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l SwfdecResource *instance = SWFDEC_RESOURCE (target); SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (instance->movie)->context); SwfdecBuffer *buffer; - SwfdecAsValue vals[2]; SwfdecDecoder *dec = instance->decoder; SwfdecDecoderClass *klass; SwfdecStatus status; @@ -212,9 +241,7 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l } if (status & SWFDEC_STATUS_IMAGE) swfdec_resource_loader_target_image (instance); - SWFDEC_AS_VALUE_SET_INT (&vals[0], dec->bytes_loaded); - SWFDEC_AS_VALUE_SET_INT (&vals[1], dec->bytes_total); - swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadProgress, vals, 2); + swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0); if (status & SWFDEC_STATUS_EOF) return; } @@ -223,21 +250,36 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l static void swfdec_resource_loader_target_eof (SwfdecLoaderTarget *target, SwfdecLoader *loader) { - SwfdecResource *instance = SWFDEC_RESOURCE (target); - SwfdecAsValue vals[2]; - SwfdecDecoder *dec = instance->decoder; + SwfdecAsValue val; + SwfdecResource *resource = SWFDEC_RESOURCE (target); - if (dec == NULL) { - SWFDEC_FIXME ("What do we signal if we have no decoder?"); - SWFDEC_AS_VALUE_SET_INT (&vals[0], 0); - SWFDEC_AS_VALUE_SET_INT (&vals[1], 0); - } else { - SWFDEC_AS_VALUE_SET_INT (&vals[0], dec->bytes_loaded); - SWFDEC_AS_VALUE_SET_INT (&vals[1], dec->bytes_total); + swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0); + SWFDEC_AS_VALUE_SET_INT (&val, 0); /* FIXME */ + swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadComplete, FALSE, &val, 1); + resource->state = SWFDEC_RESOURCE_COMPLETE; +} + +static void +swfdec_resource_loader_target_error (SwfdecLoaderTarget *target, SwfdecLoader *loader) +{ + SwfdecResource *resource = SWFDEC_RESOURCE (target); + const char *message; + + switch (resource->state) { + case SWFDEC_RESOURCE_REQUESTED: + message = SWFDEC_AS_STR_URLNotFound; + break; + case SWFDEC_RESOURCE_OPENED: + message = SWFDEC_AS_STR_LoadNeverCompleted; + break; + case SWFDEC_RESOURCE_NEW: + case SWFDEC_RESOURCE_COMPLETE: + case SWFDEC_RESOURCE_DONE: + g_assert_not_reached (); + message = SWFDEC_AS_STR_EMPTY; + break; } - swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadProgress, vals, 2); - SWFDEC_AS_VALUE_SET_INT (&vals[0], 0); /* FIXME */ - swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadComplete, vals, 1); + swfdec_resource_emit_error (resource, message); } static void @@ -246,6 +288,7 @@ swfdec_resource_loader_target_init (SwfdecLoaderTargetInterface *iface) iface->get_player = swfdec_resource_loader_target_get_player; iface->open = swfdec_resource_loader_target_open; iface->parse = swfdec_resource_loader_target_parse; + iface->error = swfdec_resource_loader_target_error; iface->eof = swfdec_resource_loader_target_eof; } @@ -302,6 +345,7 @@ swfdec_resource_set_loader (SwfdecResource *resource, SwfdecLoader *loader) resource->loader = g_object_ref (loader); swfdec_flash_security_set_url (SWFDEC_FLASH_SECURITY (resource), swfdec_loader_get_url (loader)); + resource->state = SWFDEC_RESOURCE_REQUESTED; } SwfdecResource * @@ -378,6 +422,7 @@ swfdec_resource_do_load (SwfdecPlayer *player, SwfdecLoader *loader, gpointer re if (loader == NULL) { /* *** Security Sandbox Violation *** */ + swfdec_resource_emit_error (resource, SWFDEC_AS_STR_IllegalRequest); return; } diff --git a/libswfdec/swfdec_resource.h b/libswfdec/swfdec_resource.h index ea3192e..b75d77d 100644 --- a/libswfdec/swfdec_resource.h +++ b/libswfdec/swfdec_resource.h @@ -35,6 +35,14 @@ typedef struct _SwfdecResourceClass SwfdecResourceClass; #define SWFDEC_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_RESOURCE, SwfdecResource)) #define SWFDEC_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_RESOURCE, SwfdecResourceClass)) +typedef enum { + SWFDEC_RESOURCE_NEW = 0, /* no loader set yet, only the call to _load() was done */ + SWFDEC_RESOURCE_REQUESTED, /* the URL has been requested, the request was ok, ->loader is set */ + SWFDEC_RESOURCE_OPENED, /* onLoadStart has been called */ + SWFDEC_RESOURCE_COMPLETE, /* onLoadComplete has been called */ + SWFDEC_RESOURCE_DONE /* onLoadInit has been called, clip_loader is unset */ +} SwfdecResourceState; + struct _SwfdecResource { SwfdecFlashSecurity flash_security; @@ -50,6 +58,7 @@ struct _SwfdecResource GHashTable * export_names; /* SwfdecCharacter->string mapping of exported characters */ /* only used while loading */ + SwfdecResourceState state; /* state we're in (for determining callbacks */ char * target; /* target path we use for signalling */ SwfdecMovieClipLoader *clip_loader; /* loader that gets notified about load events */ }; commit 11cb40668238084379c80f8d25d269d649a5d790 Author: Benjamin Otte <otte at gnome.org> Date: Wed Nov 7 13:33:34 2007 +0100 add swfdec_sprite_movie_get_frames_total() and use it diff --git a/libswfdec/swfdec_movie_asprops.c b/libswfdec/swfdec_movie_asprops.c index 35fa280..6456aa9 100644 --- a/libswfdec/swfdec_movie_asprops.c +++ b/libswfdec/swfdec_movie_asprops.c @@ -166,25 +166,12 @@ mc_framesloaded (SwfdecMovie *mov, SwfdecAsValue *rval) } static void -mc_totalframes (SwfdecMovie *movie, SwfdecAsValue *rval) +mc_totalframes (SwfdecMovie *mov, SwfdecAsValue *rval) { - SwfdecResource *resource; - SwfdecDecoder *dec; - int frames; - - g_assert (SWFDEC_IS_SPRITE_MOVIE (movie)); + SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov); - resource = swfdec_movie_get_own_resource (SWFDEC_MOVIE (movie)); - if (resource == NULL) { - frames = 1; - } else { - dec = resource->decoder; - if (dec == NULL) - frames = 0; - else - frames = dec->frames_total; - } - SWFDEC_AS_VALUE_SET_INT (rval, frames); + SWFDEC_AS_VALUE_SET_INT (rval, + swfdec_sprite_movie_get_frames_total (movie)); } static void diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c index 264484b..89d30b4 100644 --- a/libswfdec/swfdec_sprite_movie.c +++ b/libswfdec/swfdec_sprite_movie.c @@ -855,3 +855,20 @@ swfdec_sprite_movie_get_frames_loaded (SwfdecSpriteMovie *movie) return dec->frames_loaded - 1; return dec->frames_total; } + +int +swfdec_sprite_movie_get_frames_total (SwfdecSpriteMovie *movie) +{ + SwfdecResource *resource; + SwfdecDecoder *dec; + + g_return_val_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie), 0); + + resource = swfdec_movie_get_own_resource (SWFDEC_MOVIE (movie)); + if (resource == NULL) + return 1; + dec = resource->decoder; + if (dec == NULL) + return 0; + return dec->frames_total; +} diff --git a/libswfdec/swfdec_sprite_movie.h b/libswfdec/swfdec_sprite_movie.h index 0b7158c..093154d 100644 --- a/libswfdec/swfdec_sprite_movie.h +++ b/libswfdec/swfdec_sprite_movie.h @@ -65,6 +65,7 @@ struct _SwfdecSpriteMovieClass GType swfdec_sprite_movie_get_type (void); int swfdec_sprite_movie_get_frames_loaded (SwfdecSpriteMovie * movie); +int swfdec_sprite_movie_get_frames_total (SwfdecSpriteMovie * movie); void swfdec_sprite_movie_goto (SwfdecSpriteMovie * movie, guint goto_frame); commit 96dabf98373731d3579fcdefea9a3b80a1d38c5b Author: Benjamin Otte <otte at gnome.org> Date: Wed Nov 7 13:27:32 2007 +0100 remove commented out and non-working code for native FLV playback The code had too many hacks and special cases, and that's one thing I don't like. Especially ot for an add-on feature. If we ever introduce native FLV playback again, we should do this via a special SWF file that works as the player and only add special code to set the decoder stream on that SWF. diff --git a/libswfdec/swfdec_decoder.c b/libswfdec/swfdec_decoder.c index 6a98981..b17cb98 100644 --- a/libswfdec/swfdec_decoder.c +++ b/libswfdec/swfdec_decoder.c @@ -58,10 +58,12 @@ swfdec_decoder_new (SwfdecPlayer *player, const SwfdecBuffer *buffer) data[1] == 'W' && data[2] == 'S') { retval = g_object_new (SWFDEC_TYPE_SWF_DECODER, NULL); +#if 0 } else if (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') { retval = g_object_new (SWFDEC_TYPE_FLV_DECODER, NULL); +#endif } else { retval = NULL; } diff --git a/libswfdec/swfdec_flv_decoder.c b/libswfdec/swfdec_flv_decoder.c index 4ba427e..81e7e36 100644 --- a/libswfdec/swfdec_flv_decoder.c +++ b/libswfdec/swfdec_flv_decoder.c @@ -594,27 +594,6 @@ swfdec_flv_decoder_get_data (SwfdecFlvDecoder *flv, guint timestamp, guint *real return tag->buffer; } -/*** HACK ***/ - -/* This is a hack to allow native FLV playback IN SwfdecPlayer */ - -#include "swfdec_loadertarget.h" -#include "swfdec_net_stream.h" -#include "swfdec_sprite.h" -#include "swfdec_video_movie.h" - -#if 0 -static void -notify_initialized (SwfdecPlayer *player, GParamSpec *pspec, SwfdecVideoMovie *movie) -{ - movie->video->width = player->width; - movie->video->height = player->height; - - swfdec_movie_queue_update (SWFDEC_MOVIE (movie), SWFDEC_MOVIE_INVALID_MATRIX); - swfdec_movie_invalidate (SWFDEC_MOVIE (movie)); -} -#endif - gboolean swfdec_flv_decoder_is_eof (SwfdecFlvDecoder *flv) { @@ -631,39 +610,3 @@ swfdec_flv_decoder_eof (SwfdecFlvDecoder *flv) flv->state = SWFDEC_STATE_EOF; } -SwfdecMovie * -swfdec_flv_decoder_add_movie (SwfdecFlvDecoder *flv, SwfdecMovie *parent) -{ - //g_assert_not_reached (); - return NULL; -#if 0 - SwfdecContent *content = swfdec_content_new (0); - SwfdecMovie *movie; - SwfdecVideo *video; - SwfdecConnection *conn; - SwfdecNetStream *stream; - - /* set up the video movie */ - video = g_object_new (SWFDEC_TYPE_VIDEO, NULL); - video->width = G_MAXUINT; - video->height = G_MAXUINT; - content->graphic = SWFDEC_GRAPHIC (video); - content->free = TRUE; - movie = swfdec_movie_new (parent, content); - g_object_weak_ref (G_OBJECT (movie), (GWeakNotify) g_object_unref, video); - g_signal_connect (SWFDEC_ROOT_MOVIE (parent)->player, "notify::initialized", - G_CALLBACK (notify_initialized), movie); - /* set up the playback stream */ - conn = swfdec_connection_new (SWFDEC_ROOT_MOVIE (parent)->player->jscx); - stream = swfdec_net_stream_new (SWFDEC_ROOT_MOVIE (parent)->player, conn); - swfdec_net_stream_set_loader (stream, SWFDEC_ROOT_MOVIE (parent)->loader); - stream->flvdecoder = flv; - swfdec_video_movie_set_input (SWFDEC_VIDEO_MOVIE (movie), &stream->input); - swfdec_net_stream_set_playing (stream, TRUE); - g_object_unref (conn); - g_object_unref (stream); - - return movie; -#endif -} - diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c index 9cfefea..0d719f0 100644 --- a/libswfdec/swfdec_net_stream.c +++ b/libswfdec/swfdec_net_stream.c @@ -284,13 +284,6 @@ swfdec_net_stream_loader_target_parse (SwfdecLoaderTarget *target, status |= klass->parse (SWFDEC_DECODER (stream->flvdecoder), buffer); } while ((status & (SWFDEC_STATUS_ERROR | SWFDEC_STATUS_NEEDBITS | SWFDEC_STATUS_EOF)) == 0); - if (status & SWFDEC_STATUS_INIT) { - /* HACK for native flv playback */ - swfdec_player_initialize (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context), 7, - SWFDEC_DECODER (stream->flvdecoder)->rate, - SWFDEC_DECODER (stream->flvdecoder)->width, - SWFDEC_DECODER (stream->flvdecoder)->height); - } if (status & SWFDEC_STATUS_IMAGE) swfdec_net_stream_loader_target_recheck (stream); } diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c index 260c57d..3f2af12 100644 --- a/libswfdec/swfdec_resource.c +++ b/libswfdec/swfdec_resource.c @@ -33,7 +33,6 @@ #include "swfdec_debug.h" #include "swfdec_decoder.h" #include "swfdec_flash_security.h" -#include "swfdec_flv_decoder.h" #include "swfdec_loader_internal.h" #include "swfdec_loadertarget.h" #include "swfdec_movie_clip_loader.h" @@ -98,8 +97,6 @@ swfdec_resource_loader_target_image (SwfdecResource *instance) movie->n_frames = movie->sprite->n_frames; swfdec_movie_invalidate (SWFDEC_MOVIE (movie)); swfdec_resource_check_rights (instance); - } else if (SWFDEC_IS_FLV_DECODER (instance->decoder)) { - /* nothing to do, please move along */ } else { g_assert_not_reached (); } @@ -174,10 +171,7 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l return; } - if (SWFDEC_IS_FLV_DECODER (dec)) { - swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_FLV); - swfdec_flv_decoder_add_movie (SWFDEC_FLV_DECODER (dec), SWFDEC_MOVIE (instance->movie)); - } else if (SWFDEC_IS_SWF_DECODER (dec)) { + if (SWFDEC_IS_SWF_DECODER (dec)) { swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_SWF); instance->decoder = dec; } else { commit 546be3822d7756028146bc2dbe0c6c077c795dfc Author: Benjamin Otte <otte at gnome.org> Date: Wed Nov 7 13:23:58 2007 +0100 fix computation of _framesloaded property diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c index 1249aaf..264484b 100644 --- a/libswfdec/swfdec_sprite_movie.c +++ b/libswfdec/swfdec_sprite_movie.c @@ -840,15 +840,18 @@ swfdec_sprite_movie_unload (SwfdecSpriteMovie *movie) int swfdec_sprite_movie_get_frames_loaded (SwfdecSpriteMovie *movie) { - SwfdecSprite *sprite; + SwfdecResource *resource; + SwfdecDecoder *dec; g_return_val_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie), 0); - sprite = movie->sprite; - if (sprite == 0) - return 0; - if (sprite->parse_frame == sprite->n_frames) - return sprite->n_frames; - - return sprite->parse_frame - 1; + resource = swfdec_movie_get_own_resource (SWFDEC_MOVIE (movie)); + if (resource == NULL) + return 1; + dec = resource->decoder; + if (dec == NULL) + return -1; + if (dec->frames_loaded < dec->frames_total) + return dec->frames_loaded - 1; + return dec->frames_total; } commit 26330325fa76c32fbbff3609103863a4c6e73832 Author: Benjamin Otte <otte at gnome.org> Date: Wed Nov 7 13:23:44 2007 +0100 fix values for _totalframes property diff --git a/libswfdec/swfdec_movie_asprops.c b/libswfdec/swfdec_movie_asprops.c index f704f79..35fa280 100644 --- a/libswfdec/swfdec_movie_asprops.c +++ b/libswfdec/swfdec_movie_asprops.c @@ -29,6 +29,7 @@ #include "swfdec_as_strings.h" #include "swfdec_bits.h" #include "swfdec_debug.h" +#include "swfdec_decoder.h" #include "swfdec_player_internal.h" #include "swfdec_sprite.h" #include "swfdec_sprite_movie.h" @@ -137,38 +138,53 @@ mc_yscale_set (SwfdecMovie *movie, const SwfdecAsValue *val) } static void -mc_currentframe (SwfdecMovie *movie, SwfdecAsValue *rval) +mc_name_get (SwfdecMovie *movie, SwfdecAsValue *rval) { - g_assert (SWFDEC_IS_SPRITE_MOVIE (movie)); - SWFDEC_AS_VALUE_SET_NUMBER (rval, SWFDEC_SPRITE_MOVIE (movie)->frame); + SWFDEC_AS_VALUE_SET_STRING (rval, movie->name); } static void -mc_framesloaded (SwfdecMovie *mov, SwfdecAsValue *rval) +mc_name_set (SwfdecMovie *movie, const SwfdecAsValue *val) { - SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov); - - SWFDEC_AS_VALUE_SET_INT (rval, - swfdec_sprite_movie_get_frames_loaded (movie)); + movie->name = swfdec_as_value_to_string (SWFDEC_AS_OBJECT (movie)->context, val); } static void -mc_name_get (SwfdecMovie *movie, SwfdecAsValue *rval) +mc_currentframe (SwfdecMovie *movie, SwfdecAsValue *rval) { - SWFDEC_AS_VALUE_SET_STRING (rval, movie->name); + g_assert (SWFDEC_IS_SPRITE_MOVIE (movie)); + SWFDEC_AS_VALUE_SET_NUMBER (rval, SWFDEC_SPRITE_MOVIE (movie)->frame); } static void -mc_name_set (SwfdecMovie *movie, const SwfdecAsValue *val) +mc_framesloaded (SwfdecMovie *mov, SwfdecAsValue *rval) { - movie->name = swfdec_as_value_to_string (SWFDEC_AS_OBJECT (movie)->context, val); + SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov); + + SWFDEC_AS_VALUE_SET_INT (rval, + swfdec_sprite_movie_get_frames_loaded (movie)); } static void mc_totalframes (SwfdecMovie *movie, SwfdecAsValue *rval) { + SwfdecResource *resource; + SwfdecDecoder *dec; + int frames; + g_assert (SWFDEC_IS_SPRITE_MOVIE (movie)); - SWFDEC_AS_VALUE_SET_INT (rval, SWFDEC_SPRITE_MOVIE (movie)->n_frames); + + resource = swfdec_movie_get_own_resource (SWFDEC_MOVIE (movie)); + if (resource == NULL) { + frames = 1; + } else { + dec = resource->decoder; + if (dec == NULL) + frames = 0; + else + frames = dec->frames_total; + } + SWFDEC_AS_VALUE_SET_INT (rval, frames); } static void
Reasonably Related Threads
- 13 commits - libswfdec/Makefile.am libswfdec/swfdec_decoder.c libswfdec/swfdec_decoder.h libswfdec/swfdec_flv_decoder.c libswfdec/swfdec_flv_decoder.h libswfdec/swfdec_image.c libswfdec/swfdec_image_decoder.c libswfdec/swfdec_image_decoder.h
- 36 commits - doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_amf.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_strings.c libswfdec/swfdec_buffer.c libswfdec/swfdec_buffer.h
- 5 commits - libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_resource.c libswfdec/swfdec_resource.h player/swfdec_slow_loader.c test/trace
- 18 commits - doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_button_movie.c libswfdec/swfdec_event.c libswfdec/swfdec_event.h libswfdec/swfdec_flash_security.c
- 7 commits - libswfdec/swfdec_movie.c libswfdec/swfdec_resource.c libswfdec/swfdec_resource.h libswfdec/swfdec_sprite_movie_as.c test/trace