Benjamin Otte
2007-Mar-20 15:47 UTC
[Swfdec] 5 commits - configure.ac doc/Makefile.am doc/swfdec-sections.txt libswfdec/swfdec_js_net_stream.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h libswfdec/swfdec_net_stream.c
configure.ac | 2 doc/Makefile.am | 1 doc/swfdec-sections.txt | 3 + libswfdec/swfdec_js_net_stream.c | 32 ++++++++++++++- libswfdec/swfdec_loader.c | 81 ++++++++++++++++++++++++++++++++++++++- libswfdec/swfdec_loader.h | 5 ++ libswfdec/swfdec_net_stream.c | 5 ++ 7 files changed, 125 insertions(+), 4 deletions(-) New commits: diff-tree badb4883c0eff1236bf7698b759b04355fa9999c (from 6eeb97209e5b60af1dd930ad7063810c73c21654) Author: Benjamin Otte <otte@gnome.org> Date: Tue Mar 20 23:46:58 2007 +0100 implement swfdec_loader_get_loaded to query the already loaded amount of bytes diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt index 26a98ab..f8a4514 100644 --- a/doc/swfdec-sections.txt +++ b/doc/swfdec-sections.txt @@ -22,8 +22,9 @@ swfdec_loader_new_from_file swfdec_loader_push swfdec_loader_eof swfdec_loader_error -swfdec_loader_get_size swfdec_loader_set_size +swfdec_loader_get_size +swfdec_loader_get_loaded swfdec_loader_get_filename swfdec_loader_get_data_type <SUBSECTION Standard> diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c index 1fd0e65..69c460f 100644 --- a/libswfdec/swfdec_loader.c +++ b/libswfdec/swfdec_loader.c @@ -76,7 +76,8 @@ enum { PROP_ERROR, PROP_EOF, PROP_DATA_TYPE, - PROP_SIZE + PROP_SIZE, + PROP_LOADED }; G_DEFINE_ABSTRACT_TYPE (SwfdecLoader, swfdec_loader, G_TYPE_OBJECT) @@ -100,6 +101,9 @@ swfdec_loader_get_property (GObject *obj case PROP_SIZE: g_value_set_ulong (value, loader->size); break; + case PROP_LOADED: + g_value_set_ulong (value, swfdec_loader_get_loaded (loader)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -163,6 +167,9 @@ swfdec_loader_class_init (SwfdecLoaderCl g_object_class_install_property (object_class, PROP_SIZE, g_param_spec_ulong ("size", "size", "amount of bytes in loader", 0, G_MAXULONG, 0, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_SIZE, + g_param_spec_ulong ("loaded", "loaded", "bytes already loaded", + 0, G_MAXULONG, 0, G_PARAM_READWRITE)); } static void @@ -420,6 +427,7 @@ swfdec_loader_push (SwfdecLoader *loader g_return_if_fail (buffer != NULL); swfdec_buffer_queue_push (loader->queue, buffer); + g_object_notify (G_OBJECT (loader), "loaded"); swfdec_loader_parse (loader); } @@ -437,8 +445,7 @@ swfdec_loader_eof (SwfdecLoader *loader) loader->eof = TRUE; if (loader->size == 0) { - gulong bytes = swfdec_buffer_queue_get_offset (loader->queue) + - swfdec_buffer_queue_get_depth (loader->queue); + gulong bytes = swfdec_loader_get_loaded (loader); if (bytes) swfdec_loader_set_size (loader, bytes); } @@ -568,6 +575,24 @@ swfdec_loader_get_size (SwfdecLoader *lo } /** + * swfdec_loader_get_loaded: + * @loader: a #SwfdecLoader + * + * Gets the amount of bytes that have already been pushed into @loader and are + * available to Swfdec. + * + * Returns: Amount of bytes in @loader + **/ +gulong +swfdec_loader_get_loaded (SwfdecLoader *loader) +{ + g_return_val_if_fail (SWFDEC_IS_LOADER (loader), 0); + + return swfdec_buffer_queue_get_depth (loader->queue) + + swfdec_buffer_queue_get_offset (loader->queue); +} + +/** * swfdec_loader_data_type_get_extension: * @type: a #SwfdecLoaderDataType * diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h index 9afec81..482c810 100644 --- a/libswfdec/swfdec_loader.h +++ b/libswfdec/swfdec_loader.h @@ -79,6 +79,7 @@ void swfdec_loader_error (SwfdecLoader void swfdec_loader_set_size (SwfdecLoader * loader, gulong size); gulong swfdec_loader_get_size (SwfdecLoader * loader); +gulong swfdec_loader_get_loaded (SwfdecLoader * loader); char * swfdec_loader_get_filename (SwfdecLoader * loader); SwfdecLoaderDataType swfdec_loader_get_data_type (SwfdecLoader * loader); diff-tree 6eeb97209e5b60af1dd930ad7063810c73c21654 (from 0f3acdb9630e4443894956dac6cfb0b8609a649a) Author: Benjamin Otte <otte@gnome.org> Date: Tue Mar 20 22:46:28 2007 +0100 API was broken by adding new members to SwfdecLoader struct, so update libversion diff --git a/configure.ac b/configure.ac index e640a78..2159631 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ else fi AC_DEFINE_UNQUOTED(SWFDEC_LEVEL_DEFAULT, $DEFAULT_DEBUG_LEVEL, [Default debug level used]) -SWFDEC_LIBVERSION="1:2:0" +SWFDEC_LIBVERSION="2:0:0" AC_SUBST(SWFDEC_LIBVERSION) AM_PROG_LIBTOOL diff-tree 0f3acdb9630e4443894956dac6cfb0b8609a649a (from 1fa988074827d10c989f3e301abcda86f513daf2) Author: Benjamin Otte <otte@gnome.org> Date: Tue Mar 20 22:39:22 2007 +0100 add swfdec_loader_[gs]et_size diff --git a/doc/Makefile.am b/doc/Makefile.am index afe0261..ba9c4cb 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -54,6 +54,7 @@ CFILE_GLOB=$(top_srcdir)/libswfdec/*.c IGNORE_HFILES= \ js \ jpeg \ + swfdec_amf.h \ swfdec_audio_internal.h \ swfdec_audio_event.h \ swfdec_audio_flv.h \ diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt index e0bb55f..26a98ab 100644 --- a/doc/swfdec-sections.txt +++ b/doc/swfdec-sections.txt @@ -22,6 +22,8 @@ swfdec_loader_new_from_file swfdec_loader_push swfdec_loader_eof swfdec_loader_error +swfdec_loader_get_size +swfdec_loader_set_size swfdec_loader_get_filename swfdec_loader_get_data_type <SUBSECTION Standard> diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c index 9087748..1fd0e65 100644 --- a/libswfdec/swfdec_loader.c +++ b/libswfdec/swfdec_loader.c @@ -75,7 +75,8 @@ enum { PROP_0, PROP_ERROR, PROP_EOF, - PROP_DATA_TYPE + PROP_DATA_TYPE, + PROP_SIZE }; G_DEFINE_ABSTRACT_TYPE (SwfdecLoader, swfdec_loader, G_TYPE_OBJECT) @@ -96,6 +97,9 @@ swfdec_loader_get_property (GObject *obj case PROP_DATA_TYPE: g_value_set_enum (value, loader->data_type); break; + case PROP_SIZE: + g_value_set_ulong (value, loader->size); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -116,6 +120,10 @@ swfdec_loader_set_property (GObject *obj if (g_value_get_boolean (value) && !loader->eof) swfdec_loader_eof (loader); break; + case PROP_SIZE: + if (loader->size == 0 && g_value_get_ulong (value) > 0) + swfdec_loader_set_size (loader, g_value_get_ulong (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -152,6 +160,9 @@ swfdec_loader_class_init (SwfdecLoaderCl g_object_class_install_property (object_class, PROP_DATA_TYPE, g_param_spec_enum ("data-type", "data type", "the data's type as identified by Swfdec", SWFDEC_TYPE_LOADER_DATA_TYPE, SWFDEC_LOADER_DATA_UNKNOWN, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_SIZE, + g_param_spec_ulong ("size", "size", "amount of bytes in loader", + 0, G_MAXULONG, 0, G_PARAM_READWRITE)); } static void @@ -221,6 +232,7 @@ swfdec_file_loader_load (SwfdecLoader *l swfdec_loader_error (ret, error->message); g_error_free (error); } else { + swfdec_loader_set_size (ret, buffer->length); swfdec_loader_push (ret, buffer); swfdec_loader_eof (ret); } @@ -324,6 +336,7 @@ swfdec_loader_new_from_file (const char g_free (cur); } SWFDEC_FILE_LOADER (loader)->dir = g_path_get_dirname (loader->url); + swfdec_loader_set_size (loader, buf->length); swfdec_loader_push (loader, buf); swfdec_loader_eof (loader); return loader; @@ -423,6 +436,12 @@ swfdec_loader_eof (SwfdecLoader *loader) g_return_if_fail (loader->eof == FALSE); loader->eof = TRUE; + if (loader->size == 0) { + gulong bytes = swfdec_buffer_queue_get_offset (loader->queue) + + swfdec_buffer_queue_get_depth (loader->queue); + if (bytes) + swfdec_loader_set_size (loader, bytes); + } g_object_notify (G_OBJECT (loader), "eof"); swfdec_loader_parse (loader); } @@ -514,6 +533,41 @@ swfdec_loader_set_data_type (SwfdecLoade } /** + * swfdec_loader_set_size: + * @loader: a #SwfdecLoader + * @size: the amount of bytes in this loader + * + * Sets the size of bytes in this loader. This function may only be called once. + **/ +void +swfdec_loader_set_size (SwfdecLoader *loader, gulong size) +{ + g_return_if_fail (SWFDEC_IS_LOADER (loader)); + g_return_if_fail (loader->size == 0); + g_return_if_fail (size > 0); + + loader->size = size; + g_object_notify (G_OBJECT (loader), "size"); +} + +/** + * swfdec_loader_get_size: + * @loader: a #SwfdecLoader + * + * Queries the amount of bytes inside @loader. If the size is unknown, 0 is + * returned. + * + * Returns: the total number of bytes for this loader or 0 if unknown + **/ +gulong +swfdec_loader_get_size (SwfdecLoader *loader) +{ + g_return_val_if_fail (SWFDEC_IS_LOADER (loader), 0); + + return loader->size; +} + +/** * swfdec_loader_data_type_get_extension: * @type: a #SwfdecLoaderDataType * diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h index fc4983c..9afec81 100644 --- a/libswfdec/swfdec_loader.h +++ b/libswfdec/swfdec_loader.h @@ -49,6 +49,7 @@ struct _SwfdecLoader char * url; /* the URL for this loader in UTF-8 - must be set on creation */ /*< private >*/ + gulong size; /* number of bytes in stream or 0 if unknown */ gboolean eof; /* if we're in EOF already */ char * error; /* if there's an error (from parsing the loader) */ gpointer target; /* SwfdecLoaderTarget that gets notified about loading progress */ @@ -75,6 +76,9 @@ void swfdec_loader_push (SwfdecLoader void swfdec_loader_eof (SwfdecLoader * loader); void swfdec_loader_error (SwfdecLoader * loader, const char * error); +void swfdec_loader_set_size (SwfdecLoader * loader, + gulong size); +gulong swfdec_loader_get_size (SwfdecLoader * loader); char * swfdec_loader_get_filename (SwfdecLoader * loader); SwfdecLoaderDataType swfdec_loader_get_data_type (SwfdecLoader * loader); diff-tree 1fa988074827d10c989f3e301abcda86f513daf2 (from b5cf5799383500fc93aca5aaf2b6e58602c677c7) Author: Benjamin Otte <otte@gnome.org> Date: Tue Mar 20 22:39:16 2007 +0100 emit a Buffer.Full when we're full and in eof diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c index 09239e2..2bc6b23 100644 --- a/libswfdec/swfdec_net_stream.c +++ b/libswfdec/swfdec_net_stream.c @@ -254,11 +254,16 @@ swfdec_net_stream_loader_target_parse (S } out: if (loader->eof) { + guint first, last; swfdec_flv_decoder_eof (stream->flvdecoder); recheck = TRUE; swfdec_net_stream_onstatus (stream, "NetStream.Buffer.Flush", "status"); swfdec_net_stream_video_goto (stream, stream->current_time); stream->buffering = FALSE; + if (swfdec_flv_decoder_get_video_info (stream->flvdecoder, &first, &last) && + stream->current_time + stream->buffer_time <= last) { + swfdec_net_stream_onstatus (stream, "NetStream.Buffer.Full", "status"); + } } if (recheck) { if (stream->buffering) { diff-tree b5cf5799383500fc93aca5aaf2b6e58602c677c7 (from 6363187dd9b03c0c32bbce14ba5de298deb3533d) Author: Benjamin Otte <otte@gnome.org> Date: Tue Mar 20 22:37:37 2007 +0100 add time property diff --git a/libswfdec/swfdec_js_net_stream.c b/libswfdec/swfdec_js_net_stream.c index 908f4b2..2b91bfb 100644 --- a/libswfdec/swfdec_js_net_stream.c +++ b/libswfdec/swfdec_js_net_stream.c @@ -84,7 +84,35 @@ static JSFunctionSpec net_stream_methods { "pause", swfdec_js_net_stream_pause, 0, 0, 0 }, { "play", swfdec_js_net_stream_play, 1, 0, 0 }, { "setBufferTime", swfdec_js_net_stream_set_buffer_time, 1, 0, 0 }, - {0,0,0,0,0} + { NULL } +}; + +static JSBool +swfdec_js_net_stream_time (JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + SwfdecNetStream *stream; + guint msecs; + + stream = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_NET_STREAM); + if (stream == NULL) + return JS_TRUE; + + if (stream->flvdecoder == NULL || + !swfdec_flv_decoder_get_video_info (stream->flvdecoder, &msecs, NULL)) { + *vp = INT_TO_JSVAL (0); + return JS_TRUE; + } + if (msecs >= stream->current_time) + msecs = 0; + else + msecs = stream->current_time - msecs; + + return JS_NewNumberValue (cx, msecs / 1000., vp); +} + +static JSPropertySpec net_stream_props[] = { + { "time", -1, JSPROP_PERMANENT|JSPROP_READONLY, swfdec_js_net_stream_time, NULL }, + { NULL } }; static void @@ -131,7 +159,7 @@ void swfdec_js_add_net_stream (SwfdecPlayer *player) { JS_InitClass (player->jscx, player->jsobj, NULL, - &net_stream_class, swfdec_js_net_stream_new, 0, NULL, net_stream_methods, + &net_stream_class, swfdec_js_net_stream_new, 0, net_stream_props, net_stream_methods, NULL, NULL); }
Possibly Parallel Threads
- 4 commits - libswfdec-gtk/swfdec_gtk_loader.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h libswfdec/swfdec_load_object.c
- 9 commits - doc/swfdec-sections.txt libswfdec/swfdec_as_frame.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h libswfdec/swfdec_loader_internal.h libswfdec/swfdec_loadertarget.c libswfdec/swfdec_loadertarget.h libswfdec/swfdec_movie.c
- 4 commits - libswfdec-gtk/swfdec_gtk_loader.c libswfdec/swfdec_file_loader.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h player/swfdec_slow_loader.c
- libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h libswfdec/swfdec_loader_internal.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_root_movie.c libswfdec/swfdec_xml.c
- 10 commits - doc/swfdec-docs.sgml doc/swfdec-sections.txt libswfdec-gtk/swfdec_gtk_loader.c libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_buffer.c libswfdec/swfdec_debugger.c libswfdec/swfdec.h